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 |
---|---|---|---|---|---|---|
Updates all target script phases for the current target, including creating or updating, deleting and reordering. | def add_user_script_phases
native_targets.each do |native_target|
TargetIntegrator.create_or_update_user_script_phases(target.target_definition.script_phases, native_target)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script_phase(options)\n raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?\n raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?\n current_target_definition.store_script_phase(options)\n end",
"def create_or_update_user_script_phases(script_phases, native_target)\n script_phase_names = script_phases.map { |k| k[:name] }\n # Delete script phases no longer present in the target.\n native_target_script_phases = native_target.shell_script_build_phases.select do |bp|\n !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX)\n end\n native_target_script_phases.each do |script_phase|\n script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '')\n unless script_phase_names.include?(script_phase_name_without_prefix)\n native_target.build_phases.delete(script_phase)\n end\n end\n # Create or update the ones that are expected to be.\n script_phases.each do |script_phase|\n name_with_prefix = USER_BUILD_PHASE_PREFIX + script_phase[:name]\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, name_with_prefix, nil)\n phase.shell_script = script_phase[:script]\n phase.shell_path = script_phase[:shell_path] || '/bin/sh'\n phase.input_paths = script_phase[:input_files]\n phase.output_paths = script_phase[:output_files]\n phase.input_file_list_paths = script_phase[:input_file_lists]\n phase.output_file_list_paths = script_phase[:output_file_lists]\n phase.dependency_file = script_phase[:dependency_file]\n # At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only\n # gets set to '0' if the user has explicitly disabled this.\n if (show_env_vars_in_log = script_phase.fetch(:show_env_vars_in_log, '1')) == '0'\n phase.show_env_vars_in_log = show_env_vars_in_log\n end\n\n execution_position = script_phase[:execution_position]\n reorder_script_phase(native_target, phase, execution_position)\n end\n end",
"def configure_phase\n self.project.targets.each do |target|\n begin\n phase = target.sources_build_phase\n next unless phase\n rescue NoMethodError\n next\n end\n\n \n bundle = target.copy_bundle_recources\n\n # remove zombie build files\n phase.files_references.each do |file|\n begin\n file.real_path\n rescue\n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n end\n \n # remove zombie bundle files\n bundle.files_references.each do |file|\n begin\n file.real_path\n rescue\n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file\n end\n end\n end\n\n removings = [] # name of seeds going to be removed from the target\n addings = [] # name of seeds going to be added to the target\n\n self.targets.keys.sort.each do |seed_name|\n target_names = self.targets[seed_name]\n if not target_names.include?(target.name)\n removings << seed_name if not removings.include?(seed_name)\n else\n addings << seed_name if not addings.include?(seed_name)\n end\n end\n\n\n self.file_references.each do |file|\n\n removings.each do |seed_names|\n next if not seed_names.include?(file.parent.name)\n \n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file \n end\n \n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n\n addings.each do |seed_names|\n next if file.name.end_with? \".h\"\n next if not seed_names.include?(file.parent.name)\n uuid = Xcodeproj::uuid_with_name \"#{target.name}:#{file.name}\"\n \n if self.seeds[seed_names].resources.any? { |s| file.name.end_with? s }\n bundle.add_file_reference_with_uuid(file, uuid, true)\n else \n phase.add_file_reference_with_uuid(file, uuid, true)\n end\n\n end\n end\n end\n end",
"def create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + EMBED_FRAMEWORK_PHASE_NAME)\n phase.shell_script = %(\"#{script_path}\"\\n)\n TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n end",
"def update_targets(targets)\n default_transit_key = options.fetch(:sanctum).fetch(:transit_key, nil)\n default_secrets_version = options.fetch(:sanctum).fetch(:secrets_version)\n\n # TODO: make this better\n # remove_trailing_slash needs to run first, as some of the other logic in other methods\n # rely on it\n targets = remove_trailing_slash(targets)\n targets = set_secrets_version(targets, default_secrets_version)\n targets = set_transit_key(targets, default_transit_key)\n targets = update_prefix(targets)\n targets\n end",
"def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)\n phase.shell_script = %(\"#{script_path}\"\\n)\n TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n reorder_script_phase(native_target, phase, :before_compile)\n end",
"def warn_for_installed_script_phases\n pods_to_install = sandbox_state.added | sandbox_state.changed\n pod_targets.group_by(&:pod_name).each do |name, pod_targets|\n if pods_to_install.include?(name) && !sandbox.local?(name)\n script_phase_count = pod_targets.inject(0) { |sum, target| sum + target.script_phases.count }\n unless script_phase_count.zero?\n UI.warn \"#{name} has added #{script_phase_count} #{'script phase'.pluralize(script_phase_count)}. \" \\\n 'Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.'\n end\n end\n end\n end",
"def update_competetion_phases\n competetion.update(no_of_phases: competetion.phases.count)\n end",
"def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0')\n build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)\n build_phases.find { |phase| phase.name && phase.name.end_with?(script_phase_name) }.tap { |p| p.name = script_phase_name if p } ||\n native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase|\n UI.message(\"Adding Build Phase '#{script_phase_name}' to project.\") do\n phase.name = script_phase_name\n unless show_env_vars_in_log.nil?\n phase.show_env_vars_in_log = show_env_vars_in_log\n end\n native_target.build_phases << phase\n end\n end\n end",
"def update_phase4\n case @phase4_step\n when 1\n update_phase4_step1\n when 2\n update_phase4_step2\n when 3\n update_phase4_step3\n when 4\n update_phase4_step4\n when 5\n update_phase4_step5\n when 6\n update_phase4_step6\n end\n end",
"def remove_embed_frameworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME)\n end",
"def setup_target_reset\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n target.reset_pos(@acts[1], @acts[2])\n end\n end",
"def update!(**args)\n @target_ids = args[:target_ids] if args.key?(:target_ids)\n end",
"def update_phase4\r\n case @phase4_step\r\n when 1\r\n update_phase4_step1\r\n when 2\r\n update_phase4_step2\r\n when 3\r\n update_phase4_step3\r\n when 4\r\n update_phase4_step4\r\n when 5\r\n update_phase4_step5\r\n when 6\r\n update_phase4_step6\r\n end\r\n end",
"def upgrade\n if targets.any?\n resolve_dependencies!\n fetch_results!\n end\n\n Upgrades.add_to(self)\n\n run!\n end",
"def add_copy_dsyms_script_phase(native_target)\n script_path = \"${PODS_ROOT}/#{target.copy_dsyms_script_path.relative_path_from(target.sandbox.root)}\"\n dsym_paths = PodTargetInstaller.dsym_paths(target)\n bcsymbolmap_paths = PodTargetInstaller.bcsymbolmap_paths(target)\n\n if dsym_paths.empty? && bcsymbolmap_paths.empty?\n script_phase = native_target.shell_script_build_phases.find do |bp|\n bp.name && bp.name.end_with?(UserProjectIntegrator::TargetIntegrator::COPY_DSYM_FILES_PHASE_NAME)\n end\n native_target.build_phases.delete(script_phase) if script_phase.present?\n return\n end\n\n phase_name = UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX + UserProjectIntegrator::TargetIntegrator::COPY_DSYM_FILES_PHASE_NAME\n phase = UserProjectIntegrator::TargetIntegrator.create_or_update_shell_script_build_phase(native_target, phase_name)\n phase.shell_script = %(\"#{script_path}\"\\n)\n\n input_paths_by_config = {}\n output_paths_by_config = {}\n if use_input_output_paths?\n input_file_list_path = target.copy_dsyms_script_input_files_path\n input_file_list_relative_path = \"${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}\"\n input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)\n input_paths = input_paths_by_config[input_paths_key] = []\n input_paths.concat([dsym_paths, *bcsymbolmap_paths].flatten.compact)\n\n output_file_list_path = target.copy_dsyms_script_output_files_path\n output_file_list_relative_path = \"${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}\"\n output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)\n output_paths = output_paths_by_config[output_paths_key] = []\n\n dsym_output_paths = dsym_paths.map { |dsym_path| \"${DWARF_DSYM_FOLDER_PATH}/#{File.basename(dsym_path)}\" }\n bcsymbolmap_output_paths = bcsymbolmap_paths.map { |bcsymbolmap_path| \"${DWARF_DSYM_FOLDER_PATH}/#{File.basename(bcsymbolmap_path)}\" }\n output_paths.concat([dsym_output_paths, *bcsymbolmap_output_paths].flatten.compact)\n end\n\n UserProjectIntegrator::TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n end",
"def update_phase_states\n validate_phase_state()\n ownerables = users\n irat.phase.transaction do; update_ownerable_phase_states(ownerables); end\n publish_phase_states(ownerables, phase_state => irat.phase)\n publish_messages(users: ownerables)\n end",
"def setup_target_z\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n target.lock_z = @acts[1]\n end\n end",
"def remove_script_phase_from_target(native_target, phase_name)\n build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(phase_name) }\n return unless build_phase.present?\n native_target.build_phases.delete(build_phase)\n end",
"def add_embed_frameworks_script_phase\n unless target.includes_frameworks? || (target.xcframeworks_by_config.values.flatten.any? { |xcf| xcf.build_type.dynamic_framework? })\n native_targets_to_embed_in.each do |native_target|\n TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target)\n end\n return\n end\n\n script_path = target.embed_frameworks_script_relative_path\n input_paths_by_config = {}\n output_paths_by_config = {}\n if use_input_output_paths?\n configs = Set.new(target.framework_paths_by_config.keys + target.xcframeworks_by_config.keys).sort\n configs.each do |config|\n framework_paths = target.framework_paths_by_config[config] || []\n xcframeworks = target.xcframeworks_by_config[config] || []\n\n input_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_input_files_path(config), target.embed_frameworks_script_input_files_relative_path)\n input_paths_by_config[input_paths_key] = [script_path] + TargetIntegrator.embed_frameworks_input_paths(framework_paths, xcframeworks)\n\n output_paths_key = XCFileListConfigKey.new(target.embed_frameworks_script_output_files_path(config), target.embed_frameworks_script_output_files_relative_path)\n output_paths_by_config[output_paths_key] = TargetIntegrator.embed_frameworks_output_paths(framework_paths, xcframeworks)\n end\n end\n\n native_targets_to_embed_in.each do |native_target|\n TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths_by_config, output_paths_by_config)\n end\n end",
"def remove_copy_xcframeworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME)\n end",
"def integrate!\n UI.section(integration_message) do\n XCConfigIntegrator.integrate(target, native_targets)\n\n remove_obsolete_script_phases\n add_pods_library\n add_embed_frameworks_script_phase\n remove_embed_frameworks_script_phase_from_embedded_targets\n add_copy_resources_script_phase\n add_check_manifest_lock_script_phase\n add_user_script_phases\n add_on_demand_resources\n end\n end",
"def update!(**args)\n @phase_configs = args[:phase_configs] if args.key?(:phase_configs)\n end",
"def integrate!\n UI.section(integration_message) do\n target_installation_result.non_library_specs_by_native_target.each do |native_target, spec|\n add_embed_frameworks_script_phase(native_target, spec)\n add_copy_resources_script_phase(native_target, spec)\n add_on_demand_resources(native_target, spec) if spec.app_specification?\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(spec), native_target)\n end\n add_copy_dsyms_script_phase(target_installation_result.native_target)\n add_copy_xcframeworks_script_phase(target_installation_result.native_target)\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(target.library_specs), target_installation_result.native_target)\n end\n end",
"def update\n phase = Phase.find(params[:id])\n authorize phase\n begin\n phase = get_modifiable(phase)\n if phase.update(phase_params)\n flash.now[:notice] = success_message(phase, _('updated'))\n else\n flash.now[:alert] = failure_message(phase, _('update'))\n end\n rescue StandardError => e\n msg = _('Unable to create a new version of this template.')\n flash.now[:alert] = \"#{msg}<br>#{e.message}\"\n end\n redirect_to edit_org_admin_template_phase_path(template_id: phase.template.id,\n id: phase.id)\n end",
"def create_or_update_copy_resources_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase_name = COPY_PODS_RESOURCES_PHASE_NAME\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + phase_name)\n phase.shell_script = %(\"#{script_path}\"\\n)\n TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n end",
"def remove_embed_frameworks_script_phase_from_embedded_targets\n return unless target.requires_host_target?\n native_targets.each do |native_target|\n if AggregateTarget::EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include? native_target.symbol_type\n TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target)\n end\n end\n end",
"def setup_change_target\n return unless PONY::ERRNO::check_sequence(current_act)\n setup_target(@acts[1])\n end",
"def update\n @@easings.each do |ease|\n # Skip to wait for delay option if present\n if ease.delay > 0\n ease.delay -= 1\n next\n elsif ease.overwrite\n # Delete other easings for same target if applicable\n overwrite_other_easings(ease)\n end\n\n # Perform ease calculations\n perform_ease_for(ease)\n end\n end",
"def update!(**args)\n @target = args[:target] if args.key?(:target)\n end",
"def create_carthage_script_phase_for_test_targets(project, name)\n frameworks.each do |platform, fs|\n t = target(project, name, platform, true)\n add_carthage_script(t, platform, fs)\n end\nend",
"def update!(**args)\n @phase_id = args[:phase_id] if args.key?(:phase_id)\n end",
"def update!(**args)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_type = args[:target_type] if args.key?(:target_type)\n end",
"def update_battlephase\r\n # Branch according to phase\r\n case @phase\r\n when 1 # pre-battle phase\r\n update_phase1\r\n when 2 # party command phase\r\n update_phase2\r\n when 3 # actor command phase\r\n update_phase3\r\n when 4 # main phase\r\n update_phase4\r\n when 5 # after battle phase\r\n update_phase5\r\n end\r\n end",
"def sort_project_build_phase\n puts \"Reordering build phase...\"\n\n project = Xcodeproj::Project.open(\"Traveloka.xcodeproj\")\n\n project.native_targets.each { |target|\n\n if target.name == \"Traveloka\" || target.name == \"Traveloka Staging\"\n # Take the native embed frameworks phase and pods build phases.\n native_embed_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"Embed Frameworks\"\n }.first\n pods_embed_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"[CP] Embed Pods Frameworks\"\n }.first\n pods_copy_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"[CP] Copy Pods Resources\"\n }.first\n\n index_native_embed_phase = target.build_phases.index(native_embed_phase)\n\n # Shift the phase to below embed frameworks phase in native build phase.\n if index_native_embed_phase < target.build_phases.length && (pods_embed_phase != nil && pods_copy_phase != nil)\n target.build_phases.delete(pods_embed_phase)\n target.build_phases.delete(pods_copy_phase)\n target.build_phases.insert(index_native_embed_phase + 1, pods_copy_phase)\n target.build_phases.insert(index_native_embed_phase + 1, pods_embed_phase)\n end\n end\n }\n\n project.save\n\n puts \"\\e[32m√ Build phase reorder complete!\\e[0m\"\nend",
"def run_plugins_post_install_hooks\n # This short-circuits because unlocking pod sources is expensive\n if any_plugin_post_install_hooks?\n unlock_pod_sources\n\n context = PostInstallHooksContext.generate(sandbox, pods_project, pod_target_subprojects, aggregate_targets)\n HooksManager.run(:post_install, context, plugins)\n end\n\n lock_pod_sources\n end",
"def update!(**args)\n @target_name = args[:target_name] if args.key?(:target_name)\n @workflow_guid = args[:workflow_guid] if args.key?(:workflow_guid)\n @zone_id = args[:zone_id] if args.key?(:zone_id)\n end",
"def admin_update\n @phase = Phase.find(params[:id])\n authorize @phase\n @phase.description = params[\"phase-desc\"]\n if @phase.update_attributes(params[:phase])\n @phase.template.dirty = true\n @phase.template.save!\n\n redirect_to admin_show_phase_path(@phase), notice: _('Information was successfully updated.')\n else\n @sections = @phase.sections\n @template = @phase.template\n # These params may not be available in this context so they may need\n # to be set to true without the check\n @edit = true\n @open = !params[:section_id].nil?\n @section_id = (params[:section_id].nil? ? nil : params[:section_id].to_i)\n @question_id = (params[:question_id].nil? ? nil : params[:question_id].to_i)\n flash[:notice] = failed_update_error(@phase, _('phase'))\n if @phase.template.customization_of.present?\n @original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org\n else\n @original_org = @phase.template.org\n end\n render 'admin_show'\n end\n end",
"def add_copy_resources_script_phase\n unless target.includes_resources?\n native_targets.each do |native_target|\n TargetIntegrator.remove_copy_resources_script_phase_from_target(native_target)\n end\n return\n end\n\n script_path = target.copy_resources_script_relative_path\n input_paths_by_config = {}\n output_paths_by_config = {}\n if use_input_output_paths\n target.resource_paths_by_config.each do |config, resource_paths|\n input_paths_key = XCFileListConfigKey.new(target.copy_resources_script_input_files_path(config),\n target.copy_resources_script_input_files_relative_path)\n input_paths_by_config[input_paths_key] = [script_path] + resource_paths\n\n output_paths_key = XCFileListConfigKey.new(target.copy_resources_script_output_files_path(config),\n target.copy_resources_script_output_files_relative_path)\n output_paths_by_config[output_paths_key] = TargetIntegrator.resource_output_paths(resource_paths)\n end\n end\n\n native_targets.each do |native_target|\n # Static library targets cannot include resources. Skip this phase from being added instead.\n next if native_target.symbol_type == :static_library\n TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path,\n input_paths_by_config,\n output_paths_by_config)\n end\n end",
"def setup_target_move\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.goto(*args)\n end\n end",
"def setup_targets_flip\n return unless PONY::ERRNO::check_sequence(current_act)\n current_actions_targets.each do |target|\n target.flip = @acts[1]\n end\n end",
"def execute\n supported_swift_versions = ['3.0', '4.0', '4.2']\n if !supported_swift_versions.include? swift_version\n signal_usage_error \"'#{swift_version}' swift version is not supported. Supported values: \" + supported_swift_versions.map { |v| \"'#{v}'\" }.join(\", \")\n end\n \n ProjectMod.apply_build_setting(name: 'SWIFT_VERSION', value: \"#{swift_version}.0\", target_names: target_list)\n \n targets_string = target_list.empty? ? 'All targets' : (target_list.join(\", \") + \" targets\")\n puts \"#{targets_string} were updated to use Swift #{swift_version}!\" \n end",
"def update_metadata!\n compilation_context.source_file_database.update_metadata(source_path)\n compilation_context.target_file_database.update_metadata(source_path)\n end",
"def update!(**args)\n @rollout = args[:rollout] if args.key?(:rollout)\n @rollout_phase_id = args[:rollout_phase_id] if args.key?(:rollout_phase_id)\n end",
"def update!(**args)\n @rollout = args[:rollout] if args.key?(:rollout)\n @rollout_phase_id = args[:rollout_phase_id] if args.key?(:rollout_phase_id)\n end",
"def update_files\n PhrasingPhrase.transaction do\n # 1) Get file contents as keys and values\n keys_and_values = yml_to_keys_and_values\n old_version_keys_and_values = keys_and_values.clone\n\n # 2) Update all translated values in keys_and_values\n puts \"Updating..\"\n phrasing_phrases.each do |phrase|\n print \".\"\n next if phrase.key == phrase.value\n\n @word_counter.update(keys_and_values[\"#{phrase.locale}.#{phrase.key}\"], phrase.yml_value)\n\n keys_and_values[\"#{phrase.locale}.#{phrase.key}\"] = phrase.yml_value\n end\n\n # 3) Update keys_and_values to same yml file\n if @word_counter.has_change?\n # Create last version file entry in releases\n create_to_recent_version_entry_for(old_version_keys_and_values)\n # Update root file to new version\n update_as_next_root_version(keys_and_values)\n end\n\n # 4) Delete All Database Records for lang\n # phrasing_phrases.delete_all\n\n display_word_count\n\n # Return true for successfull execution\n return @word_counter.has_change?\n end\n end",
"def update!(**args)\n @first_level_target = args[:first_level_target] if args.key?(:first_level_target)\n @second_level_target = args[:second_level_target] if args.key?(:second_level_target)\n end",
"def update_script\n\t\tif self.event_type == \"Script\"\n\t\t\tupdate_script = Script.find_by(id: self.script_tag)\n\t\t\tif update_script.title != self.title || update_script.start_time != self.start_time || update_script.end_time != self.end_time \n\t\t\t\tupdate_script.update :title => self.title, :start_time => self.start_time, :end_time => self.end_time\n\t\t\tend\t\n\t\tend\n\tend",
"def targets=( *args )\n update_state_collection( '@targets', *args )\n end",
"def update\n update_phase\n end",
"def setup_target_slide\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.slide(*args)\n end\n end",
"def command_ids=(new_commands_or_ids)\n @script_was ||= script\n\n self.stage_commands = new_commands_or_ids.reject(&:blank?).map.with_index do |command_or_id, position|\n find_or_create_stage_command(command_or_id, position)\n end\n end",
"def process_hooks(user, actual_targets)\n exec_hooks(Move, :process_hooks, binding)\n return true\n end",
"def update!(**args)\n @missing_targets = args[:missing_targets] if args.key?(:missing_targets)\n @status = args[:status] if args.key?(:status)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def update_phase4_step3\n if @active_battler.current_action.kind == 0 and\n @active_battler.current_action.basic == 0\n # in this one... we have our weapon animations... for player and monster\n if @active_battler.is_a?(Game_Actor)\n @spriteset.actor_sprites[@active_battler.index].pose(@weapon_sprite)\n elsif @active_battler.is_a?(Game_Enemy)\n @spriteset.enemy_sprites[@active_battler.index].enemy_pose(@weapon_sprite_enemy)\n end\n end\n if @animation1_id == 0\n @active_battler.white_flash = true\n else\n @active_battler.animation_id = @animation1_id\n @active_battler.animation_hit = true\n end\n @phase4_step = 4\n end",
"def target_exec(script_on_target)\n print_status(\"Executing script #{script_on_target}\")\n proc = session.sys.process.execute(script_on_target, nil, 'Hidden' => true)\n print_good(\"Agent executed with PID #{proc.pid}\")\n @clean_up_rc << \"kill #{proc.pid}\\n\"\n proc.pid\n end",
"def update_phase4_step4\n # Animation for target\n for target in @target_battlers\n target.animation_id = @animation2_id\n target.animation_hit = (target.damage != \"Miss\")\n end\n # Animation has at least 8 frames, regardless of its length\n @wait_count = 8\n # Shift to step 5\n @phase4_step = 5\n end",
"def update_target\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Erase target window\r\n @skill_window.active = true\r\n @target_window.visible = false\r\n @target_window.active = false\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If unable to use because SP ran out\r\n unless @actor.skill_can_use?(@skill.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If target is all\r\n if @target_window.index == -1\r\n # Apply skill use effects to entire party\r\n used = false\r\n for i in $game_party.actors\r\n used |= i.skill_effect(@actor, @skill)\r\n end\r\n end\r\n # If target is user\r\n if @target_window.index <= -2\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index + 10]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If single target\r\n if @target_window.index >= 0\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If skill was used\r\n if used\r\n # Play skill use SE\r\n $game_system.se_play(@skill.menu_se)\r\n # Use up SP\r\n @actor.sp -= @skill.sp_cost\r\n # Remake each window content\r\n @status_window.refresh\r\n @skill_window.refresh\r\n @target_window.refresh\r\n # If entire party is dead\r\n if $game_party.all_dead?\r\n # Switch to game over screen\r\n $scene = Scene_Gameover.new\r\n return\r\n end\r\n # If command event ID is valid\r\n if @skill.common_event_id > 0\r\n # Command event call reservation\r\n $game_temp.common_event_id = @skill.common_event_id\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n # If skill wasn't used\r\n unless used\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n end\r\n return\r\n end\r\n end",
"def update_included_targets(id, opts = {})\n data, _status_code, _headers = update_included_targets_with_http_info(id, opts)\n data\n end",
"def update!(**args)\n @params = args[:params] if args.key?(:params)\n @raw_target = args[:raw_target] if args.key?(:raw_target)\n @target = args[:target] if args.key?(:target)\n end",
"def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end",
"def update\n update_item_count\n update_totals\n if order.completed?\n update_payment_state\n update_shipments\n update_shipment_state\n update_shipment_total\n end\n run_hooks\n persist_totals\n end",
"def update_index\n index_files = []\n index_files << upload(\"specs.4.8.gz\", specs_index)\n log \"Uploaded all specs index\"\n index_files << upload(\"latest_specs.4.8.gz\", latest_index)\n log \"Uploaded latest specs index\"\n index_files << upload(\"prerelease_specs.4.8.gz\", prerelease_index)\n log \"Uploaded prerelease specs index\"\n\n index_files.each do |file|\n tuf_repo.replace_file(file, 'targets/unclaimed', 'targets')\n end\n\n # For now assume all files are unclaimed\n pending_files = tuf_pending_store.pending\n pending_files.each do |file|\n puts \"Adding file: #{file.path}\"\n tuf_repo.add_file(file, 'targets/unclaimed', 'targets')\n end\n tuf_repo.publish!\n tuf_pending_store.clear(pending_files)\n end",
"def update_target\n obj = JSON.load(@clnt.get(@config_url).body) || []\n obj = @parsing_block.call(obj) if @parsing_block\n\n obj.each do |target|\n @target_array = []\n name = target[\"name\"]\n type = target[\"type\"]\n target_array << path_for(name, type)\n end\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 setup_change_target\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n case @acts[1]\n # --------------------\n when 0 # Original Target\n self.area_flag = item_in_use.area?\n @target = @ori_target\n @target_array = @ori_targets.clone\n # -------------------\n when 1 # All Battler\n self.area_flag = true\n t = $game_party.alive_members + $game_troop.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 2 # All Battler except user\n self.area_flag = true\n t = $game_party.alive_members + $game_troop.alive_members\n t -= [self]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 3 # All Enemies\n self.area_flag = true\n t = opponents_unit.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 4 # All Enemies except current target\n self.area_flag = true\n t = opponents_unit.alive_members\n t -= [target]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 5 # All Allies\n self.area_flag = true\n t = friends_unit.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 6 # All Allies except user\n self.area_flag = true\n t = friends_unit.alive_members\n t -= [self]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 7 # Next random enemy\n self.area_flag = false\n @target = opponents_unit.random_target\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n # -------------------\n when 8 # Next random ally\n self.area_flag = false\n @target = friends_unit.random_target\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n # -------------------\n when 9 # Absolute Targets (Enemies)\n self.area_flag = true\n @target_array = opponents_unit.abs_target(@acts[2])\n @target_array -= [target] if @acts[3]\n $game_temp.battler_targets += @target_array\n # -------------------\n when 10 # Absolute Target (Allies)\n self.area_flag = true\n @target_array = friends_unit.abs_target(@acts[2])\n @target_array -= [target] if @acts[3]\n $game_temp.battler_targets += @target_array\n # -------------------\n when 11 # self\n self.area_flag = false\n @target = self\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n end\n end",
"def add_copy_xcframeworks_script_phase(native_target)\n script_path = \"${PODS_ROOT}/#{target.copy_xcframeworks_script_path.relative_path_from(target.sandbox.root)}\"\n\n input_paths_by_config = {}\n output_paths_by_config = {}\n\n xcframeworks = target.xcframeworks.values.flatten\n\n if use_input_output_paths? && !xcframeworks.empty?\n input_file_list_path = target.copy_xcframeworks_script_input_files_path\n input_file_list_relative_path = \"${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}\"\n input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)\n input_paths = input_paths_by_config[input_paths_key] = [script_path]\n\n framework_paths = xcframeworks.map { |xcf| \"${PODS_ROOT}/#{xcf.path.relative_path_from(target.sandbox.root)}\" }\n input_paths.concat framework_paths\n\n output_file_list_path = target.copy_xcframeworks_script_output_files_path\n output_file_list_relative_path = \"${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}\"\n output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)\n output_paths_by_config[output_paths_key] = xcframeworks.map do |xcf|\n \"#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/#{xcf.target_name}/#{xcf.name}.framework\"\n end\n end\n\n if xcframeworks.empty?\n UserProjectIntegrator::TargetIntegrator.remove_copy_xcframeworks_script_phase_from_target(native_target)\n else\n UserProjectIntegrator::TargetIntegrator.create_or_update_copy_xcframeworks_script_phase_to_target(\n native_target, script_path, input_paths_by_config, output_paths_by_config)\n end\n end",
"def update_phase3\n # If enemy arrow is enabled\n if @enemy_arrow != nil\n update_phase3_enemy_select\n # If actor arrow is enabled\n elsif @actor_arrow != nil\n update_phase3_actor_select\n # If skill window is enabled\n elsif @skill_window != nil\n update_phase3_skill_select\n # If item window is enabled\n elsif @item_window != nil\n update_phase3_item_select\n # If actor command window is enabled\n elsif @actor_command_window.active\n update_phase3_basic_command\n end\n end",
"def update_phase4_step4\r\n # Animation for target\r\n for target in @target_battlers\r\n target.animation_id = @animation2_id\r\n target.animation_hit = (target.damage != \"Miss\")\r\n end\r\n # Animation has at least 8 frames, regardless of its length\r\n @wait_count = 8\r\n # Shift to step 5\r\n @phase4_step = 5\r\n end",
"def up\n final_covers = Task.find_by_name(\"Final Covers\")\n return if final_covers.nil?\n\n # create Update PSD task\n new_task = Task.new\n new_task.name = 'Update PSD'\n new_task.tab_text = 'Update PSD'\n new_task.partial = 'update_psd'\n new_task.icon = 'icon-cloud-upload'\n new_task.next_id = nil\n new_task.team_only = true\n new_task.workflow = final_covers.workflow\n new_task.save\n\n # add Update PSD after Final Covers\n final_covers_tab = Tab.find_by_task_id(final_covers.id)\n new_tab = Tab.new\n new_tab.task = new_task\n new_tab.phase = final_covers_tab.phase\n new_tab.order = final_covers_tab.order + 1\n new_tab.save\n\n # adjust all remaining tabs\n remaining_tabs = new_tab.phase.tabs.joins(:task)\n .where(\"tabs.order >= ? and tasks.name != ? \", new_tab.order, new_task.name)\n remaining_tabs.each do | tab |\n tab.order = tab.order + 1\n tab.save\n end\n\n # unlock update_psd for everything beyond \"Final Covers\"\n task = final_covers\n while task.next_id\n task = Task.find(task.next_id)\n task.unlocked_tasks.create!(unlocked_task: new_task)\n end\n\n # retext some stuff so that the tabs will all fit in 1280px!\n @@renames.each do |rename|\n retext_tab(rename[:old_text], rename[:new_text])\n end\n end",
"def update_phase4_step4\n if @target_battlers[0] != nil\n $game_temp.battle_actor_index = @target_battlers[0].index\n @status_window.refresh\n end\n # Animation for target\n for target in @target_battlers\n target.animation_id = @animation2_id\n target.animation_hit = (target.damage != \"Miss\")\n end\n # Animation has at least 8 frames, regardless of its length\n @wait_count = 8\n # Shift to step 5\n @phase4_step = 5\n end",
"def update\n @target = current_user.targets.find(params[:target][:id])\n\n respond_to do |format|\n if @target.update(target_params)\n format.html { redirect_to index_home_path, notice: 'Target was successfully updated.' }\n format.json { render :show, status: :ok, location: @target }\n else\n format.html { render :edit, alert: 'An error ocurred while updating the target.' }\n format.json { render json: @target.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @dependency_targets = args[:dependency_targets] if args.key?(:dependency_targets)\n @disabled = args[:disabled] if args.key?(:disabled)\n @parent_action = args[:parent_action] if args.key?(:parent_action)\n @relation_descriptor = args[:relation_descriptor] if args.key?(:relation_descriptor)\n @select_query = args[:select_query] if args.key?(:select_query)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update!(**args)\n @url_target = args[:url_target] if args.key?(:url_target)\n @citationtarget = args[:citationtarget] if args.key?(:citationtarget)\n @involumetarget = args[:involumetarget] if args.key?(:involumetarget)\n end",
"def update(target, *source_paths)\n patterns = Parser.new(*source_paths).patterns[:simple]\n LocaleFile.new(target).update(patterns)\n end",
"def update!(**args)\n @triggers = args[:triggers] if args.key?(:triggers)\n end",
"def update!(**args)\n @triggers = args[:triggers] if args.key?(:triggers)\n end",
"def update\n verify_no_uncommitted_merge\n verify_valid_update\n \n check_unknown if force\n check_collision if false # case-insensitive file-system? seriously? (uh... mac os x ring a bell?)\n \n @actions = []\n \n forget_removed\n manifest_merge\n \n stats = apply_updates\n record_updates\n stats\n end",
"def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end",
"def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end",
"def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end",
"def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end",
"def update_phase3\r\n # If enemy arrow is enabled\r\n if @enemy_arrow != nil\r\n update_phase3_enemy_select\r\n # If actor arrow is enabled\r\n elsif @actor_arrow != nil\r\n update_phase3_actor_select\r\n # If skill window is enabled\r\n elsif @skill_window != nil\r\n update_phase3_skill_select\r\n # If item window is enabled\r\n elsif @item_window != nil\r\n update_phase3_item_select\r\n # If actor command window is enabled\r\n elsif @actor_command_window.active\r\n update_phase3_basic_command\r\n end\r\n end",
"def all_done!\n unless complete?\n self.work_started_at = Time.now unless work_started_at?\n self.work_finished_at = Time.now\n done!\n #update_properties - Now done at request level\n if component_id && own_version?\n update_installed_component_version\n end\n end\n\n containing_object = parent || request\n containing_object.state_changer = state_changer\n containing_object.prepare_steps_for_execution(self)\n\n # unless version.blank?\n # installed_component.update_attribute(:version, version) if installed_component\n # end\n the_steps = containing_object.is_a?(Request) ? containing_object.steps.top_level.reload : containing_object.steps.reload\n\n if the_steps.all? { |step| step.complete_or_not_executable? }\n\n if containing_object.respond_to?(:finish!)\n containing_object.finish! if containing_object.started?\n else\n containing_object.all_done!\n end\n\n end\n\n\n end",
"def finalize!\n if !@_before_triggers.empty?\n @_before_triggers.map { |t| t.finalize! }\n end\n\n if !@_after_triggers.empty?\n @_after_triggers.map { |t| t.finalize! }\n end\n end",
"def update!(**args)\n @devtools_frame_id = args[:devtools_frame_id] if args.key?(:devtools_frame_id)\n @target_type = args[:target_type] if args.key?(:target_type)\n end",
"def auto_process_target(app_target_names, embedded_target_name, installer)\n words = find_words_at_embedded_target('Pods-' + embedded_target_name,\n installer)\n handle_app_targets(app_target_names.map{ |str| 'Pods-' + str },\n words,\n installer)\nend",
"def post_perform!\n return unless perform_hooks?\n unless hooks.post_hooks.any?\n GitPusshuTen::Log.message \"No post deploy hooks to perform.\"\n return\n end\n \n ##\n # Connect to the remote environment and perform the post deploy hooks\n hooks.render_commands(hooks.post_hooks).each do |name, commands|\n adjusted_name = name.sub(/^\\d+\\)\\s/, '')\n \n GitPusshuTen::Log.message(\"Performing post deploy hook: #{y(adjusted_name)}\")\n standard environment.execute_as_user(\"cd '#{e.app_dir}'; #{commands}\")\n end\n end",
"def update!(**args)\n @assertion = args[:assertion] if args.key?(:assertion)\n @canonical_target = args[:canonical_target] if args.key?(:canonical_target)\n @declaration = args[:declaration] if args.key?(:declaration)\n @file_path = args[:file_path] if args.key?(:file_path)\n @operations = args[:operations] if args.key?(:operations)\n @relation = args[:relation] if args.key?(:relation)\n @target = args[:target] if args.key?(:target)\n end",
"def update_included_targets(id, opts = {})\n data, _status_code, _headers = update_included_targets_with_http_info(id, opts)\n return data\n end",
"def run_plugins_post_integrate_hooks\n if any_plugin_post_integrate_hooks?\n context = PostIntegrateHooksContext.generate(sandbox, pods_project, pod_target_subprojects, aggregate_targets)\n HooksManager.run(:post_integrate, context, plugins)\n end\n end",
"def perform_post_install_actions\n run_plugins_post_install_hooks\n warn_for_deprecations\n warn_for_installed_script_phases\n warn_for_removing_git_master_specs_repo\n print_post_install_message\n end",
"def update!(**args)\n @phase = args[:phase] if args.key?(:phase)\n @type = args[:type] if args.key?(:type)\n end",
"def set_translation_target(opts)\n opts = check_params(opts,[:targets])\n super(opts)\n end",
"def remove_copy_resources_script_phase_from_target(native_target)\n build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) }\n return unless build_phase.present?\n native_target.build_phases.delete(build_phase)\n end",
"def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_name)\n path = target.copy_resources_script_relative_path\n phase.shell_script = %{\"#{path}\"\\n}\n phase.show_env_vars_in_log = '0'\n end\n end",
"def update!(**args)\n @optimization_goal_types = args[:optimization_goal_types] if args.key?(:optimization_goal_types)\n end",
"def update!(**args)\n @advance_rollout_jobs = args[:advance_rollout_jobs] if args.key?(:advance_rollout_jobs)\n @create_rollout_jobs = args[:create_rollout_jobs] if args.key?(:create_rollout_jobs)\n end",
"def update!(**args)\n @deploy_parameters = args[:deploy_parameters] if args.key?(:deploy_parameters)\n @profiles = args[:profiles] if args.key?(:profiles)\n @strategy = args[:strategy] if args.key?(:strategy)\n @target_id = args[:target_id] if args.key?(:target_id)\n end",
"def remove()\n CCProcess.start(\"sdk-manage --target --remove '#{@name}'\", (_ :removing_target) + \" #{@name}\", 60*15)\n @@targets.delete(@name)\n end"
] | [
"0.63579714",
"0.61931425",
"0.58182645",
"0.569193",
"0.5387635",
"0.5368888",
"0.5324073",
"0.5166562",
"0.5161826",
"0.5152414",
"0.5149767",
"0.51259726",
"0.509653",
"0.5056445",
"0.5055019",
"0.5053777",
"0.5039345",
"0.500798",
"0.5005767",
"0.4997562",
"0.49560797",
"0.4899431",
"0.4895217",
"0.48786783",
"0.487042",
"0.48678854",
"0.48634073",
"0.48627278",
"0.48470977",
"0.48239776",
"0.48189944",
"0.4813885",
"0.47763893",
"0.4768551",
"0.47533092",
"0.47307125",
"0.47255126",
"0.47141072",
"0.46805963",
"0.46788883",
"0.4678282",
"0.46769473",
"0.46745217",
"0.4658897",
"0.46579707",
"0.4632714",
"0.4632306",
"0.46278653",
"0.46179876",
"0.4616153",
"0.4604727",
"0.45994353",
"0.45986405",
"0.45938787",
"0.45847592",
"0.45768058",
"0.4574803",
"0.45739147",
"0.45628747",
"0.45552337",
"0.45418084",
"0.45409936",
"0.45377633",
"0.4530278",
"0.45210606",
"0.45202735",
"0.4518052",
"0.45092207",
"0.45051053",
"0.4504955",
"0.4504083",
"0.44956464",
"0.4492225",
"0.4490083",
"0.44840574",
"0.44800246",
"0.44800246",
"0.44687334",
"0.44596946",
"0.44596946",
"0.44596946",
"0.44596946",
"0.4454166",
"0.44513634",
"0.44445893",
"0.44249094",
"0.4421178",
"0.44162154",
"0.44123247",
"0.44122976",
"0.4405491",
"0.43982473",
"0.43980658",
"0.4397303",
"0.4393514",
"0.43907788",
"0.43863627",
"0.43838155",
"0.43782997",
"0.4377256"
] | 0.62622136 | 1 |
Adds a shell script build phase responsible for checking if the Pods locked in the Pods/Manifest.lock file are in sync with the Pods defined in the Podfile.lock. | def add_check_manifest_lock_script_phase
phase_name = CHECK_MANIFEST_PHASE_NAME
native_targets.each do |native_target|
phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + phase_name)
native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase
phase.shell_script = <<-SH.strip_heredoc
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [ $? != 0 ] ; then
# print error to STDERR
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
exit 1
fi
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
SH
phase.input_paths = %w(${PODS_PODFILE_DIR_PATH}/Podfile.lock ${PODS_ROOT}/Manifest.lock)
phase.output_paths = [target.check_manifest_lock_script_output_file_path]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_check_manifest_lock_script_phase\n phase_name = 'Check Pods Manifest.lock'\n native_targets.each do |native_target|\n next if native_target.shell_script_build_phases.any? { |phase| phase.name == phase_name }\n phase = native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)\n native_target.build_phases.unshift(phase)\n phase.name = phase_name\n phase.shell_script = <<-EOS.strip_heredoc\n diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\n if [[ $? != 0 ]] ; then\n cat << EOM\n error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\n EOM\n exit 1\n fi\n EOS\n phase.show_env_vars_in_log = '0'\n end\n end",
"def warn_for_installed_script_phases\n pods_to_install = sandbox_state.added | sandbox_state.changed\n pod_targets.group_by(&:pod_name).each do |name, pod_targets|\n if pods_to_install.include?(name) && !sandbox.local?(name)\n script_phase_count = pod_targets.inject(0) { |sum, target| sum + target.script_phases.count }\n unless script_phase_count.zero?\n UI.warn \"#{name} has added #{script_phase_count} #{'script phase'.pluralize(script_phase_count)}. \" \\\n 'Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.'\n end\n end\n end\n end",
"def lint_pod_lib()\n\n\t\t \t\toutput = shell_command(\"bundle exec pod lib lint #{podspec} --allow-warnings\")\n\t\t \t\tlint_pod_validate(output)\n\t\t \tend",
"def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_name)\n path = target.copy_resources_script_relative_path\n phase.shell_script = %{\"#{path}\"\\n}\n phase.show_env_vars_in_log = '0'\n end\n end",
"def run_podfile_post_install_hooks\n UI.message '- Running post install hooks' do\n executed = run_podfile_post_install_hook\n UI.message '- Podfile' if executed\n end\n end",
"def verify_pods_are_installed!\n lockfile_roots = config.lockfile.pod_names.map { |p| Specification.root_name(p) }\n missing_pods = @pods.map { |p| Specification.root_name(p) }.select do |pod|\n !lockfile_roots.include?(pod)\n end\n\n unless missing_pods.empty?\n message = if missing_pods.length > 1\n \"Pods `#{missing_pods.join('`, `')}` are not \" \\\n 'installed and cannot be updated'\n else\n \"The `#{missing_pods.first}` Pod is not installed \" \\\n 'and cannot be updated'\n end\n raise Informative, message\n end\n end",
"def run_podfile_pre_integrate_hooks\n UI.message '- Running pre integrate hooks' do\n executed = run_podfile_pre_integrate_hook\n UI.message '- Podfile' if executed\n end\n end",
"def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0')\n build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)\n build_phases.find { |phase| phase.name && phase.name.end_with?(script_phase_name) }.tap { |p| p.name = script_phase_name if p } ||\n native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase|\n UI.message(\"Adding Build Phase '#{script_phase_name}' to project.\") do\n phase.name = script_phase_name\n unless show_env_vars_in_log.nil?\n phase.show_env_vars_in_log = show_env_vars_in_log\n end\n native_target.build_phases << phase\n end\n end\n end",
"def pod_dry_run\n print \"Pod dry run...\"\n result = system \"pod lib lint #{@configuration.podspec_file} --only-errors\"\n raise \"** Pod dry run failed **\" if !result\n puts \"Done\"\n end",
"def lint!\n all_valid = true\n @files.each do |file|\n file = file.realpath\n file_spec = Specification.from_file(file)\n\n specs = file_spec.recursive_subspecs.any? ? file_spec.recursive_subspecs : [file_spec]\n specs.each do |spec|\n # Show immediatly which pod is being processed.\n # This line will be overwritten once the result is known\n print \" -> #{spec}\\r\" unless config.silent? || @is_repo\n $stdout.flush\n\n # If the spec doesn't validate it raises and informative\n spec.validate!\n\n warnings = warnings_for_spec(spec, file)\n deprecations = deprecation_notices_for_spec(spec, file)\n build_messages, file_patterns_errors = [], []\n unless @is_repo || @quick\n platform_names(spec).each do |platform_name|\n set_up_lint_environment\n build_messages += build_errors_for_spec(spec, file, platform_name)\n file_patterns_errors += file_patterns_errors_for_spec(spec, file, platform_name)\n tear_down_lint_environment\n end\n end\n build_errors = build_messages.select {|msg| msg.include?('error')}\n build_warnings = build_messages - build_errors\n\n # Errors compromise the functionality of a spec, warnings can be ignored\n all = warnings + deprecations + build_messages + file_patterns_errors\n errors = file_patterns_errors + build_errors\n warnings = all - errors\n\n if @only_errors\n all_valid = false unless errors.empty?\n else\n # avoid to fail validation for xcode warnings\n all_valid = false unless (all - build_warnings).empty?\n end\n\n clean_duplicate_platfrom_messages(errors)\n clean_duplicate_platfrom_messages(warnings)\n\n # This overwrites the previously printed text\n unless config.silent?\n if errors.empty? && warnings.empty?\n puts \" -> \".green + \"#{spec} passed validation\" unless @is_repo\n elsif errors.empty?\n puts \" -> \".yellow + spec.to_s\n else\n puts \" -> \".red + spec.to_s\n end\n end\n\n warnings.each {|msg| puts \" - WARN | #{msg}\"} unless config.silent?\n errors.each {|msg| puts \" - ERROR | #{msg}\"} unless config.silent?\n puts unless config.silent? || ( @is_repo && all.flatten.empty? )\n end\n end\n all_valid\n end",
"def check!\n Capistrano::Deploy::Dependencies.new(configuration) do |d|\n d.remote.file(Capistrano::Puppet::Service::Webrick::SERVICE_INIT).or(\"`#{Capistrano::Puppet::Service::Webrick::SERVICE_INIT}' does not exist. Please run `cap deploy:setup'.\")\n end\n end",
"def apply_patch(patch_file)\n working_dir = Dir.pwd\n repo_root = `git rev-parse --show-toplevel`.strip\n ios_project_path = Pathname.new(working_dir).relative_path_from(Pathname.new(repo_root))\n\n directory_arg = (ios_project_path.to_s.eql? \".\") ? \"Pods\" : File.join(ios_project_path, 'Pods')\n\n Dir.chdir(repo_root) {\n check_cmd = \"git apply --check '#{patch_file}' --directory='#{directory_arg}' -p2 2> /dev/null\"\n\n can_apply = system(check_cmd)\n if can_apply\n apply_cmd = check_cmd.gsub('--check ', '')\n did_apply = system(apply_cmd)\n if did_apply\n Pod::UI.puts \"Successfully applied #{patch_file} 🎉\"\n else\n Pod::UI.warn \"Error: failed to apply #{patch_file}\"\n end\n end\n }\nend",
"def validate_dependencies_are_present!\n if @podfile_dependency_cache.target_definition_list.all?(&:empty?)\n add_warning 'The Podfile does not contain any dependencies.'\n end\n end",
"def prebuild_frameworks! \n\n # build options\n sandbox_path = sandbox.root\n existed_framework_folder = sandbox.generate_framework_path\n bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled\n targets = []\n \n if local_manifest != nil\n\n changes = prebuild_pods_changes\n added = changes.added\n changed = changes.changed \n unchanged = changes.unchanged\n deleted = changes.deleted \n \n existed_framework_folder.mkdir unless existed_framework_folder.exist?\n exsited_framework_pod_names = sandbox.exsited_framework_pod_names\n \n # additions\n missing = unchanged.select do |pod_name|\n not exsited_framework_pod_names.include?(pod_name)\n end\n\n\n root_names_to_update = (added + changed + missing)\n\n # transform names to targets\n cache = []\n targets = root_names_to_update.map do |pod_name|\n tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)\n if tars.nil? || tars.empty?\n raise \"There's no target named (#{pod_name}) in Pod.xcodeproj.\\n #{self.pod_targets.map(&:name)}\" if t.nil?\n end\n tars\n end.flatten\n\n # add the dendencies\n dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []\n targets = (targets + dependency_targets).uniq\n else\n targets = self.pod_targets\n end\n \n # frameworks which mark binary true, should be filtered before prebuild\n prebuild_framework_pod_names = []\n podfile.target_definition_list.each do |target_definition|\n next if target_definition.prebuild_framework_pod_names.empty?\n prebuild_framework_pod_names += target_definition.prebuild_framework_pod_names\n end\n \n \n\n \n # filter local pods\n targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) } if not Podfile::DSL.allow_local_pod\n\n # filter dependency\n # targets = targets.select {|pod_target| prebuild_framework_pod_names.include?(pod_target.pod_name) }\n \n # build!\n Pod::UI.puts \"🚀 Prebuild files (total #{targets.count})\"\n Pod::Prebuild.remove_build_dir(sandbox_path)\n \n targets = targets.reject { |pod_target| Pod::Podfile::DSL.binary_white_list.include?(pod_target.pod_name) }\n \n # 是否值缓存 .a 文件\n only_store_lib_file = Podfile::DSL.only_store_lib_file\n \n # 是否开启md5 命名\n md5_file_name = Podfile::DSL.md5_file_name\n md5_file_name_list = []\n \n \n subspec_name_enable = true\n \n # building check ...\n targets.each do |target|\n \n target_name = target.name\n # root_name = \"#{target_name}/\"\n spec = target.root_spec\n\n# Pod::UI.puts \"🚀 000 #{target.specs.to_json} \"\n\n specs_name = get_subspec_name(target)\n# Pod::UI.puts \"🚀 666 #{specs_name} \"\n\n \n # 如果过长 采用md5 + 文件记录\n if md5_file_name\n item = get_subspec_name_md5(target_name, specs_name, spec.version)\n specs_name = item[\"specs_name\"]\n# Pod::UI.puts \"🚀 333 #{specs_name} \"\n md5_file_name_list.push(item)\n end\n \n# specs_name = spec.name\n# Pod::UI.puts \"🚀 666 #{target.to_json} \"\n \n UI.section \"🍭 Prebuild Ready to build #{target_name} [#{target.label}]\".blue do\n if !target.should_build?\n Pod::UI.puts \"🏇 Skipping #{target.label}\"\n next\n end\n\n output_path = sandbox.framework_folder_path_for_target_name(target_name)\n output_path.mkpath unless output_path.exist?\n \n need_pull = Podfile::DSL.binary_cache\n need_push = false\n need_build = false\n\n generate_path = sandbox.generate_framework_path.to_s\n rsync_server_url = Podfile::DSL.rsync_server_url\n \n loop do\n if not need_pull\n need_build = true\n break\n end\n \n if sandbox.local?target_name and not Podfile::DSL.local_binary_cache\n need_build = true\n break\n end\n \n exist_remote_framework = Pod::PrebuildFetch.fetch_remote_framework_for_target(spec.name, specs_name, spec.version, generate_path, rsync_server_url)\n if not exist_remote_framework\n Pod::UI.puts \"💦 Non exist remote cache, #{target_name}\".blue\n \n need_build = true\n need_push = true\n break\n end\n \n Pod::UI.puts \"🎁 Exist remote cache, #{target_name}\".green\n\n break\n end\n\n if need_build\n Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)\n end\n \n if need_push\n Podfile::DSL.builded_list.push(target_name)\n\n \n if only_store_lib_file\n Pod::PrebuildFetch.sync_prebuild_framework_to_server(spec.name, specs_name, spec.version, generate_path, rsync_server_url)\n else\n store_pack = {}\n store_pack[\"spec_name\"] = spec.name\n store_pack[\"specs_name\"] = specs_name\n store_pack[\"spec_version\"] = \"#{spec.version}\"\n store_pack[\"generate_path\"] = generate_path\n store_pack[\"server_url\"] = rsync_server_url\n\n Podfile::DSL.builded_store_list.push(store_pack)\n end\n end\n \n \n \n # public private headers\n if Podfile::DSL.allow_public_headers and target.build_as_framework?\n headers = []\n target.file_accessors.each do |fa|\n headers += fa.headers || []\n end\n\n config_umbrella_header(output_path, target_name, headers)\n end\n\n \n # ...\n #target.static_framework\n #target.build_as_dynamic_library\n #target.build_as_static_framework\n \n # save the resource paths for later installing\n if !target.resource_paths.empty? #and target.build_as_dynamic?\n framework_path = output_path\n framework_path = framework_path + target.framework_name if target.build_as_framework?\n \n standard_sandbox_path = sandbox.standard_sanbox_path\n\n resources = begin\n if Pod::VERSION.start_with? \"1.5\"\n target.resource_paths\n else\n # resource_paths is Hash{String=>Array<String>} on 1.6 and above\n # (use AFNetworking to generate a demo data)\n # https://github.com/leavez/cocoapods-binary/issues/50\n target.resource_paths.values.flatten\n end\n end\n raise \"Wrong type: #{resources}\" unless resources.kind_of? Array\n\n path_objects = resources.map do |path|\n object = Prebuild::Passer::ResourcePath.new\n #object.real_file_path = framework_path + File.basename(path)\n object.real_file_path = path.gsub('${PODS_ROOT}', sandbox.generate_framework_path.to_s) if path.start_with? '${PODS_ROOT}'\n \n object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'\n object.target_file_path = path.gsub(\"${PODS_CONFIGURATION_BUILD_DIR}\", standard_sandbox_path.to_s) if path.start_with? \"${PODS_CONFIGURATION_BUILD_DIR}\"\n \n object\n end\n # mark Generated files to Pods/xx\n Prebuild::Passer.resources_to_copy_for_static_framework[target_name] = path_objects\n \n # Logger(1000, \"path_objects\", path_objects)\n # Logger(1001, \"target.name\", target.name)\n\n end\n \n end\n\n end\n \n if md5_file_name\n pods_path = self.sandbox.root\n md5_file_name_path = pods_path + \"md5_file_name.txt\"\n File.write(md5_file_name_path.to_s, md5_file_name_list.to_json)\n end\n \n \n # remove build path\n Pod::Prebuild.remove_build_dir(sandbox_path) if Podfile::DSL.clean_build_dir\n \n def copy_vendered_files(lib_paths, root_path, target_folder)\n lib_paths.each do |lib_path|\n relative = lib_path.relative_path_from(root_path)\n destination = target_folder + relative\n destination.dirname.mkpath unless destination.dirname.exist?\n FileUtils.cp_r(lib_path, destination, :remove_destination => true, :verbose => Pod::Podfile::DSL.verbose_log)\n end\n end\n \n def copy_vendered_headers(lib_paths, root_path)\n lib_paths.each do |lib_path|\n FileUtils.cp_r(lib_path, root_path, :remove_destination => true, :verbose => Pod::Podfile::DSL.verbose_log)\n end\n end\n \n \n # copy vendored libraries and frameworks\n targets.each do |target|\n root_path = self.sandbox.pod_dir(target.name)\n target_folder = sandbox.framework_folder_path_for_target_name(target.name)\n \n # If target shouldn't build, we copy all the original files\n # This is for target with only .a and .h files\n if not target.should_build? \n Prebuild::Passer.target_names_to_skip_integration_framework << target.name\n\n FileUtils.cp_r(root_path, target_folder, :remove_destination => true, :verbose => Pod::Podfile::DSL.verbose_log)\n next\n end\n \n# Logger(10032, \"dependencies\", target.dependencies)\n \n # continue ....\n next unless File.exist?(root_path)\n \n # copy to Generated\n target.spec_consumers.each do |consumer|\n file_accessor = Sandbox::FileAccessor.new(root_path, consumer)\n \n lib_paths = []\n\n #add frameworks\n lib_paths += file_accessor.vendored_frameworks || []\n \n if Pod::VERSION.start_with? \"1.9\"\n lib_paths += file_accessor.vendored_xcframeworks || [] # cocoapods version 1.9.0+\n end\n \n #add libraries\n lib_paths += file_accessor.vendored_libraries || []\n \n #add headers\n lib_paths += file_accessor.headers || []\n \n lib_paths += file_accessor.docs || []\n\n #add resources\n lib_paths += file_accessor.resources || []\n \n lib_paths += file_accessor.resource_bundles.values if not file_accessor.resource_bundles.nil?\n lib_paths += file_accessor.resource_bundle_files || []\n\n #add license\n lib_paths += [file_accessor.license] if not file_accessor.license.nil?\n lib_paths += [file_accessor.spec_license] if not file_accessor.spec_license.nil?\n\n #add readme\n lib_paths += [file_accessor.readme] if not file_accessor.readme.nil?\n \n\n #developer_files ⇒ Array<Pathname> Paths to include for local pods to assist in development.\n\n copy_vendered_files(lib_paths, root_path, target_folder)\n\n # framework not same\n if Podfile::DSL.allow_public_headers and target.build_as_framework?\n headers = file_accessor.headers || []\n copy_vendered_headers(headers, \"#{target_folder}/#{target.framework_name}/Headers\")\n end\n end\n end\n\n # save the pod_name for prebuild framwork in sandbox \n targets.each do |target|\n sandbox.save_pod_name_for_target target\n end\n \n \n # Remove useless files\n # remove useless pods\n all_needed_names = self.pod_targets.map(&:name).uniq\n useless_target_names = sandbox.exsited_framework_target_names.reject do |name| \n all_needed_names.include? name\n end\n \n \n useless_target_names.each do |name|\n path = sandbox.framework_folder_path_for_target_name(name)\n #path.rmtree if path.exist?\n FileUtils.rm_r(path.realpath, :verbose => Pod::Podfile::DSL.verbose_log) if path.exist?\n end\n \n if not Podfile::DSL.dont_remove_source_code\n # only keep manifest.lock and framework folder in _Prebuild\n to_remain_files = [\"Manifest.lock\", File.basename(existed_framework_folder)]\n to_delete_files = sandbox_path.children.select do |file|\n filename = File.basename(file)\n not to_remain_files.include?(filename)\n end\n to_delete_files.each do |path|\n #path.rmtree if path.exist?\n FileUtils.rm_r(path.realpath, :verbose => Pod::Podfile::DSL.verbose_log) if path.exist?\n end\n else \n # just remove the tmp files\n path = sandbox.root + 'Manifest.lock.tmp'\n #path.rmtree if path.exist?\n FileUtils.rm_r(path.realpath, :verbose => Pod::Podfile::DSL.verbose_log) if path.exist?\n end\n \n \n Pod::UI.puts \"🚀 Push Store Info: #{Podfile::DSL.builded_store_list}\"\n\n Podfile::DSL.builded_store_list.each do |store_pack|\n spec_name = store_pack[\"spec_name\"]\n specs_name = store_pack[\"specs_name\"]\n spec_version = store_pack[\"spec_version\"]\n generate_path = store_pack[\"generate_path\"]\n server_url = store_pack[\"server_url\"]\n \n Pod::PrebuildFetch.sync_prebuild_framework_to_server(spec_name, specs_name, spec_version, generate_path, server_url)\n end\n \n Podfile::DSL.builded_store_list = []\n end",
"def check!\n Capistrano::Deploy::Dependencies.new(configuration) do |d|\n # d.remote.directory(configuration[:releases_path]).or(\"`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.\")\n # d.remote.writable(configuration[:deploy_to]).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n # d.remote.writable(configuration[:releases_path]).or(\"You do not have permissions to write to `#{configuration[:releases_path]}'.\")\n end\n end",
"def meets_pods_project_source_dependency(source_filename, dependent_source_filename)\n has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true\nend",
"def meets_pods_project_source_dependency(source_filename, dependent_source_filename)\n has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true\nend",
"def check_requirements!\n return unless Command.up?\n\n matomo_js = File.join(@config.get('source'), 'piwik.js')\n\n error_source_missing(@config.get('source')) unless File.exist?(matomo_js)\n end",
"def bootstrap_sh_has_been_modified\n \n modified = git.modified_files.include?(\"bootstrap.sh\")\n return modified\n \nend",
"def run_podfile_post_integrate_hooks\n UI.message '- Running post integrate hooks' do\n executed = run_podfile_post_integrate_hook\n UI.message '- Podfile' if executed\n end\n end",
"def bundle_check\n system(\"bundle check --path=#{VENDOR_BUNDLE}\")\n end",
"def add_copy_dsyms_script_phase(native_target)\n script_path = \"${PODS_ROOT}/#{target.copy_dsyms_script_path.relative_path_from(target.sandbox.root)}\"\n dsym_paths = PodTargetInstaller.dsym_paths(target)\n bcsymbolmap_paths = PodTargetInstaller.bcsymbolmap_paths(target)\n\n if dsym_paths.empty? && bcsymbolmap_paths.empty?\n script_phase = native_target.shell_script_build_phases.find do |bp|\n bp.name && bp.name.end_with?(UserProjectIntegrator::TargetIntegrator::COPY_DSYM_FILES_PHASE_NAME)\n end\n native_target.build_phases.delete(script_phase) if script_phase.present?\n return\n end\n\n phase_name = UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX + UserProjectIntegrator::TargetIntegrator::COPY_DSYM_FILES_PHASE_NAME\n phase = UserProjectIntegrator::TargetIntegrator.create_or_update_shell_script_build_phase(native_target, phase_name)\n phase.shell_script = %(\"#{script_path}\"\\n)\n\n input_paths_by_config = {}\n output_paths_by_config = {}\n if use_input_output_paths?\n input_file_list_path = target.copy_dsyms_script_input_files_path\n input_file_list_relative_path = \"${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}\"\n input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)\n input_paths = input_paths_by_config[input_paths_key] = []\n input_paths.concat([dsym_paths, *bcsymbolmap_paths].flatten.compact)\n\n output_file_list_path = target.copy_dsyms_script_output_files_path\n output_file_list_relative_path = \"${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}\"\n output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)\n output_paths = output_paths_by_config[output_paths_key] = []\n\n dsym_output_paths = dsym_paths.map { |dsym_path| \"${DWARF_DSYM_FOLDER_PATH}/#{File.basename(dsym_path)}\" }\n bcsymbolmap_output_paths = bcsymbolmap_paths.map { |bcsymbolmap_path| \"${DWARF_DSYM_FOLDER_PATH}/#{File.basename(bcsymbolmap_path)}\" }\n output_paths.concat([dsym_output_paths, *bcsymbolmap_output_paths].flatten.compact)\n end\n\n UserProjectIntegrator::TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n end",
"def run_prepare_command\n return unless spec.prepare_command\n UI.section(' > Running prepare command', '', 1) do\n Dir.chdir(path) do\n begin\n ENV.delete('CDPATH')\n ENV['COCOAPODS_VERSION'] = Pod::VERSION\n prepare_command = spec.prepare_command.strip_heredoc.chomp\n full_command = \"\\nset -e\\n\" + prepare_command\n bash!('-c', full_command)\n ensure\n ENV.delete('COCOAPODS_VERSION')\n end\n end\n end\n end",
"def build_rubocop_todo\n system! \"bundle exec rake rubocop:auto_gen_config\"\n end",
"def ensure_dependences_script\n fname = dependences_scriptname\n return if fname.exist?\n fname.dirname.mkpath\n fname.open('w')\n end",
"def validate_pre_run!\n check_if_yml_present!\n check_if_yml_has_correct_content!\n check_if_rubocop_command_exists!\n end",
"def build_pod\n if !xcodebuild_available?\n UI.warn \"Skipping compilation with `xcodebuild` because it can't be found.\\n\".yellow\n else\n UI.message \"\\nBuilding with `xcodebuild`.\\n\".yellow do\n scheme = if skip_import_validation?\n validation_pod_target.label if validation_pod_target.should_build?\n else\n 'App'\n end\n if scheme.nil?\n UI.warn \"Skipping compilation with `xcodebuild` because target contains no sources.\\n\".yellow\n else\n requested_configuration = configuration ? configuration : 'Release'\n if analyze\n output = xcodebuild('analyze', scheme, requested_configuration, :deployment_target => deployment_target)\n find_output = Executable.execute_command('find', [validation_dir, '-name', '*.html'], false)\n if find_output != ''\n message = 'Static Analysis failed.'\n message += ' You can use `--verbose` for more information.' unless config.verbose?\n message += ' You can use `--no-clean` to save a reproducible buid environment.' unless no_clean\n error('build_pod', message)\n end\n else\n output = xcodebuild('build', scheme, requested_configuration, :deployment_target => deployment_target)\n end\n parsed_output = parse_xcodebuild_output(output)\n translate_output_to_linter_messages(parsed_output)\n end\n end\n end\n end",
"def ensure_shell_commands\n xcodebuild_version\n swift_version\n end",
"def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)\n phase.shell_script = %(\"#{script_path}\"\\n)\n TargetIntegrator.set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n reorder_script_phase(native_target, phase, :before_compile)\n end",
"def publish_pod_lib()\n\t\t \t\tverbose_message(\"publishing pod repo=#{@podrepo} spec=#{@podspec}\")\n\t\t \t\tshell_command(\"bundle exec pod repo push #{@podrepo} #{@podspec} --allow-warnings\")\n\t\t \tend",
"def flutter_macos_podfile_setup; end",
"def create_health_script file\n contents = <<EOF\n#!/bin/bash\nf1=static.cfg\nf2=runtime.cfg\nf3=prefs.cfg\nif [[ ! (-e $f1 && -e $f2 && -e $f3) ]]; then\n echo \"files missing, no, it's not good :-(\"\n exit 1\nfi\nSTATIC=$(grep \".*\" $f1)\nRUNTIME=$(grep \".*\" $f2)\nPREFS=$(grep \".*\" $f3)\nif [[ (\"$STATIC\" == \"ncores=4\") && (\"$RUNTIME\" == \"memory=1024\") && (\"$PREFS\" == \"folder=home\") ]]; then\n echo \"yes, it's good :-)\"\nelse\n echo \"no, it's not good :-(\"\n exit 2\nfi\nEOF\n File.open file, \"w\" do |f|\n f.puts contents\n end\n File.chmod(0744, file)\nend",
"def file_unchanged?(js_name)\n # Start-Open3\n Open3.popen3(\"git status --short #{js_name}\") do |stdin, stdout, stderr|\n # Start-If: Check if job script in working dir is modified since last check-in\n if stdout.read.empty? \n return true\n else \n puts \"#{js_name} modified since last commit. Please commit changes to the repo and #{$0} again!\"\n return false\n end\n # End-If: Check if job script in working dir is modified since last check-in\n end\n # End-Open3\nend",
"def lock_pod_sources\n return unless installation_options.lock_pod_sources?\n pod_installers.each do |installer|\n pod_target = pod_targets.find { |target| target.pod_name == installer.name }\n installer.lock_files!(pod_target.file_accessors)\n end\n end",
"def pre_run_check\n # Validate :triggers\n triggers = parameter(:triggers)\n triggers.value.each do |res|\n retrieve_resource_reference(res)\n rescue ArgumentError => e\n raise Puppet::Error, \"Parameter triggers failed: #{e} at #{@file}:#{@line}\"\n end\n\n package = self[:name]\n package_res = \"Package[#{package}]\"\n begin\n res = retrieve_resource_reference(package_res)\n package_in_catalog = true\n rescue ArgumentError\n package_in_catalog = false\n end\n\n if package_in_catalog\n if ['present', 'installed', 'latest'].include?(res['ensure'].to_s)\n Puppet.send('notice', \"#{package_res} (managed) will be updated by Patching_as_code\")\n catalog.resource(package_res)['ensure'] = 'latest'\n catalog.resource(package_res)['schedule'] = self[:patch_window]\n catalog.resource(package_res)['before'] = Array(catalog.resource(package_res)['before']) + ['Anchor[patching_as_code::patchday::end]']\n catalog.resource(package_res)['require'] = Array(catalog.resource(package_res)['require']) + ['Anchor[patching_as_code::patchday::start]']\n catalog.resource(package_res)['notify'] = Array(catalog.resource(package_res)['notify']) + triggers.value\n else\n Puppet.send('notice', \"#{package_res} (managed) will not be updated by Patching_as_code, due to the package enforcing a specific version\")\n end\n else\n Puppet.send('notice', \"#{package_res} (unmanaged) will be updated by Patching_as_code\")\n catalog.create_resource('package',\n title: package,\n ensure: 'latest',\n schedule: self[:patch_window],\n before: 'Anchor[patching_as_code::patchday::end]',\n require: 'Anchor[patching_as_code::patchday::start]',\n notify: triggers.value)\n end\n end",
"def run!\n config.update_mangling! if config.needs_update?\n config.update_pod_xcconfigs_for_mangling!\n end",
"def pr_contains_code_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.swift/).empty?\n end",
"def add_copy_xcframeworks_script_phase(native_target)\n script_path = \"${PODS_ROOT}/#{target.copy_xcframeworks_script_path.relative_path_from(target.sandbox.root)}\"\n\n input_paths_by_config = {}\n output_paths_by_config = {}\n\n xcframeworks = target.xcframeworks.values.flatten\n\n if use_input_output_paths? && !xcframeworks.empty?\n input_file_list_path = target.copy_xcframeworks_script_input_files_path\n input_file_list_relative_path = \"${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}\"\n input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)\n input_paths = input_paths_by_config[input_paths_key] = [script_path]\n\n framework_paths = xcframeworks.map { |xcf| \"${PODS_ROOT}/#{xcf.path.relative_path_from(target.sandbox.root)}\" }\n input_paths.concat framework_paths\n\n output_file_list_path = target.copy_xcframeworks_script_output_files_path\n output_file_list_relative_path = \"${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}\"\n output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)\n output_paths_by_config[output_paths_key] = xcframeworks.map do |xcf|\n \"#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/#{xcf.target_name}/#{xcf.name}.framework\"\n end\n end\n\n if xcframeworks.empty?\n UserProjectIntegrator::TargetIntegrator.remove_copy_xcframeworks_script_phase_from_target(native_target)\n else\n UserProjectIntegrator::TargetIntegrator.create_or_update_copy_xcframeworks_script_phase_to_target(\n native_target, script_path, input_paths_by_config, output_paths_by_config)\n end\n end",
"def check_for_required_files(opts={})\n missing_files = 0\n $generated_files.each do |f|\n if !File.exists?(f)\n puts \"Required file missing: #{f}\"\n missing_files +=1\n end\n end\n if missing_files > 0\n error = \"#{missing_files} required files not found. Run `rake build` before deploying.\"\n if opts[:warning] then puts error else fail error end\n end\nend",
"def copy_project_dependencies_for_awestruct_image\n\n puts \"- Copying project dependencies into '_docker/awestruct' for build...\"\n\n parent_gemfile = File.open '../Gemfile'\n parent_gemlock = File.open '../Gemfile.lock'\n\n target_gemfile = FileHelpers.open_or_new('awestruct/Gemfile')\n target_gemlock = FileHelpers.open_or_new('awestruct/Gemfile.lock')\n #Only copy if the file has changed. Otherwise docker won't cache optimally\n FileHelpers.copy_if_changed(parent_gemfile, target_gemfile)\n FileHelpers.copy_if_changed(parent_gemlock, target_gemlock)\n\n puts \"- Successfully copied project dependencies into '_docker/awestruct' for build.\"\n\nend",
"def have_exact_prebuild_cache?\n\n # check if need build frameworks\n return false if local_manifest == nil\n \n changes = prebuild_pods_changes\n added = changes.added\n changed = changes.changed \n unchanged = changes.unchanged\n deleted = changes.deleted \n \n exsited_framework_pod_names = sandbox.exsited_framework_pod_names\n missing = unchanged.select do |pod_name|\n not exsited_framework_pod_names.include?(pod_name)\n end\n\n needed = (added + changed + deleted + missing)\n \n return needed.empty?\n end",
"def check_lock(run_name)\n Helpers::log(\"Checking lock file for #{run_name}\")\n File.exists?(\"#{ENV['HOME']}/.hgsc_solid/#{@machine}/#{run_name}.lock\")\n end",
"def local_pods\n color(32) { puts \"Installing Local Pods...\" }\n pod 'BasicCommons', :path => '../../BasicCommons/'\nend",
"def rebuild\n # default to no paths\n triggered_paths = STDIN.tty? ? [] : eval($stdin.read)\n puts \"\\n\\nProject command: rebuild\"\n puts \"\\n project root: #{root_dir}\"\n puts \"\\n triggered by:\"\n triggered_paths.each{|path| puts \" #{path}\"}\n # triggered_paths: files that invoked the trigger\n # modifed_paths: files modified since previous 'watchman since' query\n # touched_paths: files modified by running the docker touch command\n query = \"watchman since . n:mod 'app/*' 'test/*'\"\n modified_paths = JSON.parse(`#{query}`)['files'].collect{|file| file['name']}.select{|file| File.file?(file)}\n modified_paths = triggered_paths & modified_paths # handle first-run\n puts \"\\n actually modified:\"\n if modified_paths.size > 0\n modified_paths.each{|path| puts \" #{path}\"}\n puts \"\\n rebuild: triggered\"\n # TODO: display notification center message when 'docker exec' fails to remind them to run 'project stop'\n `#{setup_docker_env_vars_str} docker exec #{container_name(project_config['docker-compose']['service'])} touch -c #{modified_paths.collect{|path| \"'#{path}'\"}.join(' ')}`\n # `#{dm_env} docker run --entrypoint /usr/bin/touch -v $(pwd):/myapp danlynn/ember-cli:0.2.3 #{modified_paths.join(' ')}`\n touched_paths = JSON.parse(`#{query}`)['files'].collect{|file| file['name']}.select{|file| File.file?(file)}\n puts \" touched #{touched_paths.size} of #{modified_paths.size} files\"\n else\n puts ' none'\n puts \"\\n rebuild: skipped\"\n end\n puts \"\\n complete\\n\\n\\n\"\nend",
"def wrap_xcodebuild\n require 'fileutils'\n @wrapped_xcodebuild_path ||= File.join(Gym::ROOT, \"lib/assets/wrap_xcodebuild/xcbuild-safe.sh\")\n end",
"def script_settings_files_def\n {\n 'pod_restart.pods' => {\n :uid => sftp_user_uid,\n :gid => group_gid,\n :reject_mmask => 0007,\n }\n }\nend",
"def remove_copy_resources_script_phase_from_target(native_target)\n build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) }\n return unless build_phase.present?\n native_target.build_phases.delete(build_phase)\n end",
"def check!\n # does not inherit any dependencies (super.check will inherit)\n Dependencies.new(configuration) do |d|\n d.remote.directory(configuration[:deploy_to]).or(\"`#{configuration[:deploy_to]}' does not exist.\")\n d.remote.writable(configuration[:deploy_to], :via => :sudo).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n d.remote.command(\"svn\")\n d.remote.match(\"cd #{repository_dir}; svn info|grep URL\", configuration[:repository])\n end\n end",
"def develop_pods\n color(32) { puts \"Installing Develop Pods...\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => 'develop'\nend",
"def write_versionlock_file\n transform_str = \"<transform pkg depend -> default facet.version-lock.*> false>\"\n File.write(\"#{staging_dir}/version-lock\", transform_str)\n end",
"def update_app\n in_root do\n run(\"echo 'a' | rake rails:update:scripts\")\n run(\"echo 'a' | rake rails:update:javascripts\")\n run(\"echo 'a' | rake rails:update:configs\")\n run(\"echo 'a' | rake rails:update:application_controller\")\n\n if @javascript_library != \"prototype\"\n run \"rm public/javascripts/controls.js\"\n run \"rm public/javascripts/dragdrop.js\"\n run \"rm public/javascripts/effects.js\"\n run \"rm public/javascripts/prototype.js\"\n end\n end\nend",
"def pre_run_check\n # Check for pending reboots\n pending_reboot = false\n kernel = parameter(:os).value.downcase\n case kernel\n when 'windows'\n sysroot = ENV['SystemRoot']\n powershell = \"#{sysroot}\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe\"\n # get the script path relative to the Puppet Type\n checker_script = File.join(\n __dir__,\n '..',\n '..',\n 'patching_as_code',\n 'pending_reboot.ps1',\n )\n pending_reboot = Puppet::Util::Execution.execute(\"#{powershell} -ExecutionPolicy Unrestricted -File #{checker_script}\", { failonfail: false }).exitstatus.to_i.zero?\n when 'linux'\n # get the script path relative to the Puppet Type\n checker_script = File.join(\n __dir__,\n '..',\n '..',\n 'patching_as_code',\n 'pending_reboot.sh',\n )\n pending_reboot = Puppet::Util::Execution.execute(\"/bin/sh #{checker_script}\", { failonfail: false }).exitstatus.to_i.zero?\n else\n raise Puppet::Error, \"Patching as Code - Unsupported Operating System type: #{kernel}\"\n end\n return unless pending_reboot\n\n Puppet.send('notice', 'Patching as Code - Pending OS reboot detected, node will reboot at start of patch window today')\n ## Reorganize dependencies for pre-patch, post-patch and pre-reboot exec resources:\n pre_patch_resources = []\n post_patch_resources = []\n pre_reboot_resources = []\n catalog.resources.each do |res|\n next unless res.type.to_s == 'exec'\n next unless res['tag'].is_a? Array\n next unless (res['tag'] & ['patching_as_code_pre_patching', 'patching_as_code_post_patching', 'patching_as_code_pre_reboot']).any?\n\n if res['tag'].include?('patching_as_code_pre_patching')\n pre_patch_resources << res\n elsif res['tag'].include?('patching_as_code_post_patching')\n post_patch_resources << res\n elsif res['tag'].include?('patching_as_code_pre_reboot')\n pre_reboot_resources << res\n end\n end\n ## pre-patch resources should gain Reboot[Patching as Code - Pending OS reboot] for require\n pre_patch_resources.each do |res|\n catalog.resource(res.to_s)['require'] = Array(catalog.resource(res.to_s)['require']) << 'Reboot[Patching as Code - Pending OS reboot]'\n end\n ## post-patch resources should lose existing before dependencies\n post_patch_resources.each do |res|\n catalog.resource(res.to_s)['before'] = []\n end\n ## pre-reboot resources should lose existing dependencies\n pre_reboot_resources.each do |res|\n catalog.resource(res.to_s)['require'] = []\n catalog.resource(res.to_s)['before'] = []\n end\n\n catalog.add_resource(Puppet::Type.type('reboot').new(\n title: 'Patching as Code - Pending OS reboot',\n apply: 'immediately',\n schedule: parameter(:patch_window).value,\n before: 'Anchor[patching_as_code::start]',\n require: pre_reboot_resources,\n ))\n\n catalog.add_resource(Puppet::Type.type('notify').new(\n title: 'Patching as Code - Performing Pending OS reboot before patching...',\n schedule: parameter(:patch_window).value,\n notify: 'Reboot[Patching as Code - Pending OS reboot]',\n before: 'Anchor[patching_as_code::start]',\n require: pre_reboot_resources,\n ))\n end",
"def patch_kingfisher_for_ios10\n system(\"rm -rf ./Pods/Kingfisher/Sources/SwiftUI\")\n code_file = \"./Pods/Kingfisher/Sources/General/KFOptionsSetter.swift\"\n code_text = File.read(code_file)\n code_text.gsub!(/#if canImport\\(SwiftUI\\) \\&\\& canImport\\(Combine\\)(.|\\n)+#endif/,'')\n system(\"rm -rf \" + code_file)\n aFile = File.new(code_file, 'w+')\n aFile.syswrite(code_text)\n aFile.close()\nend",
"def develop_pods\n color(32) { puts \"Installing Develop Pods...\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => 'develop'\n pod 'BasicUIElements', :git => 'git@github.com:kevinOlivet/BasicUIElements.git', :branch => 'develop'\n pod 'CuotasModule', :git => 'git@github.com:kevinOlivet/CuotasModule.git', :branch => 'develop'\nend",
"def master_pods\n color(32) { puts \"Installing Develop Pods...\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => 'master'\nend",
"def deintegrate_if_different_major_version\n return unless lockfile\n return if lockfile.cocoapods_version.major == Version.create(VERSION).major\n UI.section('Re-creating CocoaPods due to major version update.') do\n projects = Pathname.glob(config.installation_root + '*.xcodeproj').map { |path| Xcodeproj::Project.open(path) }\n deintegrator = Deintegrator.new\n projects.each do |project|\n config.with_changes(:silent => true) { deintegrator.deintegrate_project(project) }\n project.save if project.dirty?\n end\n end\n end",
"def common_xcode_summary_check\n\n xcode_summary.inline_mode = true\n xcode_summary.report 'xcodebuild.json'\n\nend",
"def flutter_ios_podfile_setup; end",
"def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n # remove leftovers from previous rake.\n rm_rf \"#{TGT_DIR}/lib\"\n rm_rf \"#{TGT_DIR}/etc\"\n rm_rf \"#{TGT_DIR}/share\"\n rm_rf \"#{TGT_DIR}/conf.d\"\n mkdir_p \"#{TGT_DIR}/lib\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy include files\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n # do some windows things\n mkdir_p \"#{TGT_DIR}/share/glib-2.0/schemas\"\n if APP['GTK'] == \"gtk+-2.0\" \n cp_r\"#{TGT_SYS_DIR}/share/glib-2.0/schemas/gschema.dtd\",\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n elsif APP['GTK'] == \"gtk+-3.0\"\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n else\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n end\n sh \"#{WINDRES} -I. shoes/appwin32.rc shoes/appwin32.o\"\n cp_r \"#{ShoesDeps}/etc\", TGT_DIR\n mkdir_p \"#{ShoesDeps}/lib\"\n if APP['GTK'] == \"gtk+-3.0\"\n cp_r \"#{ShoesDeps}/lib/gtk-3.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n else\n cp_r \"#{ShoesDeps}/lib/gtk-2.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n end\n bindir = \"#{ShoesDeps}/bin\"\n #cp_r \"#{bindir}/fc-cache.exe\", TGT_DIR\n cp_r \"#{bindir}/gtk-update-icon-cache.exe\", TGT_DIR\n # below for debugging purposes\n if ENV['GDB'] \n cp \"#{bindir}/fc-cat.exe\", TGT_DIR\n cp \"#{bindir}/fc-list.exe\", TGT_DIR\n cp \"#{bindir}/fc-match.exe\", TGT_DIR\n cp \"#{bindir}/fc-pattern.exe\", TGT_DIR\n cp \"#{bindir}/fc-query.exe\", TGT_DIR\n cp \"#{bindir}/fc-scan.exe\", TGT_DIR\n cp \"#{bindir}/fc-validate.exe\", TGT_DIR\n end\n # disable MS Theme\n if !ENABLE_MS_THEME \n Dir.chdir(\"#{TGT_DIR}/share/themes/MS-Windows/gtk-2.0/\") do\n mv 'gtkrc', 'disabled-gtkrc'\n end\n else\n # add our overrides to the MS-Windows theme\n cp \"platform/msw/gtkrc\", \"#{TGT_DIR}/etc/gtk-2.0/\"\n end\n end",
"def commit_as_pod_requirement\n if @required_local_path\n nil\n else\n @required_commit\n end\n end",
"def run()\n\n\t\t\t\t# start the exception handling block\n\t\t\t\tbegin\n\n\t\t\t\t\tcheck_podspec_exists()\n\n\t\t\t\t\t# lib pod library - if it fails bail immediately\n\t\t\t\t\tif (@skipLibLint)\n\t\t\t\t\t\tUI.message(\"skipping pod lib lint\") if (@verbose)\n\t\t\t\t\telse\n\t\t\t\t\t\tUI.message(\"linting pod locally\") if (@verbose)\n\t\t\t\t\t\tlint_pod_lib()\n\t\t\t\t\tend\n\n\t\t\t\t\tif (@libLintOnly)\n\t\t\t\t\t\tUI.message(\"lib linted ok\")\n\t\t\t\t\t\treturn\n\t\t\t\t\tend\n\n\t\t\t\t\t# parse podspec, returning bumped version and text for\n\t\t\t\t\t# both the original, and new bumped version podspec\n\t\t\t\t\tinfo = parse_podspec()\n\n\t\t\t\t\tif (@verbose) \n\t\t\t\t\t\tUI.message(\"creating pod:\")\n\t\t\t\t\t\tUI.message(\"\\tpodspec = #{@podspec}\")\n\t\t\t\t\t\tUI.message(\"\\tpodrepo = #{@podrepo}\")\n\t\t\t\t\t\tUI.message(\"\\tversion = #{info.versionString()}\")\n\t\t\t\t\t\tUI.message(\"\\tskipLibLint = #{@skipLibLint}\")\n\t\t\t\t\t\tUI.message(\"\\tnoClean = #{@noClean}\")\n\t\t\t\t\t\tUI.message(\"\\tlibLintOnly = #{@libLintOnly}\")\n\t\t\t\t\tend\n\n\t\t\t\t\t# check new version is greater than any existing tag\n\t\t\t\t\tverbose_message(\"checking version bump ok\")\n\t\t\t\t\tsemantic_validate(info.podversion)\n\n\t\t\t\t\t# save the original podspec to a temporary filename\n\t\t\t\t\toldfname = old_filename()\n\t\t\t\t\t\n\t\t\t\t\tverbose_message(\"saving original podspec to #{oldfname}\")\n\t\t\t\t\tsave_podspec(oldfname, info.original_spec)\n\n\t\t\t\t\t# save the bumped version text to the podspec\n\t\t\t\t\tverbose_message(\"saving new podspec to #{@podspec}\")\n\n\t\t\t\t\tsave_podspec(@podspec, info.update_spec)\n\n\t\t\t\t\t# commit changes\n\t\t\t\t\tverbose_message(\"commit podspec revision: #{info.versionString()}\")\n\n\t\t\t\t\tgit_commit_push(\"commit podspec revision: #{info.versionString()}\")\n\n\t\t\t\t\t# tag changes based on bumped version\n\t\t\t\t\tverbose_message(\"creating new tag: #{info.versionString()}\")\n\n\t\t\t\t\tgit_tag(info.versionString())\n\n\t\t\t\t\t# try to public the podspec, it'll throw if something goes wrong\n\t\t\t\t\tpublish_pod_lib()\n\n\t\t\t\t\tif (@noClean) \n\t\t\t\t\t\tverbose_message(\"noClean set. Skipping clean up step\")\n\t\t\t\t\telse\n\t\t\t\t\t\tverbose_message(\"tidying up old files\")\n\t\t\t\t\t\tdelete_oldpodspec_file(@podspec)\n\t\t\t\t\tend\n\n\t\t\t\t\tUI.message(\"pod version #{info.versionString()} published OK\")\n\n\t\t\t\trescue Exception => error\n\n\t\t\t\t\tUI.message(\"pod create failed with #{error}\")\n\n\t\t\t\t\tif (@noClean) \n\t\t\t\t\t\tverbose_message(\"noClean set. Skipping clean up\")\n\t\t\t\t\telse\n\t\t\t\t\t\tverbose_message(\"rolling back changes\")\n\t\t\t\t\t\trollback_changes(@podspec, info)\n\t\t\t\t\tend\n\n\t\t\t\t\t# rethrow the error, so fastlane fails\n\t\t\t\t\traise error\n\n\t\t\t\tend\n\n\t\t\tend",
"def new_shell_script_build_phase(name = nil)\n phase = project.new(PBXShellScriptBuildPhase)\n phase.name = name\n build_phases << phase\n phase\n end",
"def run_podfile_pre_integrate_hook\n podfile.pre_integrate!(self)\n rescue => e\n raise Informative, 'An error occurred while processing the pre-integrate ' \\\n 'hook of the Podfile.' \\\n \"\\n\\n#{e.message}\\n\\n#{e.backtrace * \"\\n\"}\"\n end",
"def add_watchman_trigger\n unless watchman_trigger_installed?\n matches = project_config['watchman']['directories'].collect{|dir| \"[\\\"match\\\",\\\"#{dir}\\\",\\\"wholename\\\"]\"}.join(',')\n json = <<-EOJ\n [\"trigger\", \"#{root_dir}\", {\n \"name\": \"trigger_rebuild\",\n \"expression\": [\"allof\",\n [\"anyof\",\n #{matches}\n ],\n [\"type\", \"f\"]\n ],\n \"stdin\": [\"name\"],\n \"command\": [\"#{root_dir}/project.rb\",\"rebuild\"]\n }]\n EOJ\n stdout_data, stderr_data = Open3.capture3(\"watchman -j\", :stdin_data => json)\n return JSON.parse(stdout_data)['disposition'] == 'created'\n end\n false # no trigger installed\nend",
"def run_lint()\n swiftlint.binary_path = './Pods/SwiftLint/swiftlint'\n swiftlint.verbose = true\n swiftlint.lint_all_files = false\n swiftlint.lint_files\nend",
"def install_plugin_pods\n current_dir = Pathname.new __dir__\n project_dir= Pathname.new Dir.pwd\n relative = current_dir.relative_path_from project_dir\n pluginDir = File.join(relative.to_s, 'Plugins')\n if File.directory?(pluginDir) then\n plugins = Dir.children(pluginDir).each{}\n plugins.map do |r|\n if r != '.DS_Store' then\n podDir = File.join(pluginDir, r)\n pod r, :path => podDir, :nhibit_warnings => true\n puts(r)\n end\n end\n end\nend",
"def create_or_update_user_script_phases(script_phases, native_target)\n script_phase_names = script_phases.map { |k| k[:name] }\n # Delete script phases no longer present in the target.\n native_target_script_phases = native_target.shell_script_build_phases.select do |bp|\n !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX)\n end\n native_target_script_phases.each do |script_phase|\n script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '')\n unless script_phase_names.include?(script_phase_name_without_prefix)\n native_target.build_phases.delete(script_phase)\n end\n end\n # Create or update the ones that are expected to be.\n script_phases.each do |script_phase|\n name_with_prefix = USER_BUILD_PHASE_PREFIX + script_phase[:name]\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, name_with_prefix, nil)\n phase.shell_script = script_phase[:script]\n phase.shell_path = script_phase[:shell_path] || '/bin/sh'\n phase.input_paths = script_phase[:input_files]\n phase.output_paths = script_phase[:output_files]\n phase.input_file_list_paths = script_phase[:input_file_lists]\n phase.output_file_list_paths = script_phase[:output_file_lists]\n phase.dependency_file = script_phase[:dependency_file]\n # At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only\n # gets set to '0' if the user has explicitly disabled this.\n if (show_env_vars_in_log = script_phase.fetch(:show_env_vars_in_log, '1')) == '0'\n phase.show_env_vars_in_log = show_env_vars_in_log\n end\n\n execution_position = script_phase[:execution_position]\n reorder_script_phase(native_target, phase, execution_position)\n end\n end",
"def publish_to_cocoapods()\n command = \"cd downstream_repos/card.io-iOS-SDK;\"\n command += \"pod trunk push CardIO.podspec\"\n \n CommandProcessor.command(command, live_output=true)\nend",
"def run_podfile_pre_install_hook\n podfile.pre_install!(self)\n rescue => e\n raise Informative, 'An error occurred while processing the pre-install ' \\\n 'hook of the Podfile.' \\\n \"\\n\\n#{e.message}\\n\\n#{e.backtrace * \"\\n\"}\"\n end",
"def check_for_executable; end",
"def podready!(pod, ssh:nil)\n details = getpods(pod:pod, ssh:ssh)\n status = details ? details[3] : \"Missing\"\n\n # Skip wait if pod already running\n if status.include?('Running')\n puts(\"Waiting for '#{pod}' to be ready - Running\".colorize(:cyan))\n\n # Wait for pod to be ready\n else\n ready = 0\n until ready > 1\n !puts(\"Waiting for '#{pod}' to be ready - #{status}\".colorize(:cyan)) and sleep(10)\n details = getpods(pod:pod, ssh:ssh)\n status = details ? details[3] : \"Missing\"\n ready += 1 if status.include?('Running')\n end\n end\n end",
"def run\n print \"Checking markdown files...\"\n\n load_files\n load_releases\n check\n check_releases\n report\n\n exit(1) if errors.any? && exit_on_errors\n end",
"def master_pods\n color(32) { puts \"Installing Develop Pods...\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => 'master'\n pod 'BasicUIElements', :git => 'git@github.com:kevinOlivet/BasicUIElements.git', :branch => 'master'\n pod 'CuotasModule', :git => 'git@github.com:kevinOlivet/CuotasModule.git', :branch => 'master'\nend",
"def verify_kubernetes_templates!\n release = Kubernetes::Release.new(project: @job.project, git_sha: @job.commit)\n deploy_group_configs.each do |config|\n config.fetch(:roles).each do |role|\n Kubernetes::ReleaseDoc.new(\n kubernetes_release: release,\n deploy_group: config.fetch(:deploy_group),\n kubernetes_role: role.fetch(:role)\n ).verify_template\n end\n end\n end",
"def checks\n @chekkufile = options[:chekkufile]\n verify_chekku_file_existence\n check_dependencies\n end",
"def common_swiftlint_check\n\n swiftlint.config_file = '.swiftlint.yml'\n swiftlint.lint_files inline_mode: true\n\nend",
"def check_if_bundle_needed\n if `bundle exec #{rspec_command} -v` == `#{rspec_command} -v`\n @bundle = \"\"\n else\n @bundle = \"bundle exec \"\n end\n end",
"def define_sanitycheck_tasks\n\n\t\ttask 'hg:precheckin' => [:spec] if File.directory?( 'spec' )\n\t\ttask 'hg:prep_release' => [ :check_manifest, :check_history ]\n\n\t\t# Rebuild the ChangeLog immediately before release\n\t\ttask :check_manifest => 'ChangeLog'\n\t\ttask :prerelease => 'ChangeLog'\n\n\tend",
"def add_pods_to_unity \n ios_project_path = File.join(BuildPath, \"ios\", \"Unity-iPhone.xcodeproj\")\n proj = ::Xcodeproj::Project.open(ios_project_path)\n\n pods_project_path = File.join(BuildPath, \"ios\", \"Pods\", \"Pods.xcodeproj\")\n proj.new_file(pods_project_path)\n\n proj.save\n end",
"def autorun_cmd(repo_name)\n [\"cp -Rf #{STARTDIR}/components/autogen/#{repo_name}/* .\",\n \"touch Makefile\"]\nend",
"def update(_show_output)\n @check_existing_files_for_update = true\n begin\n preheat_existing_files\n ensure\n @check_existing_files_for_update = false\n end\n []\n end",
"def patch_pod_file(path, old_code, new_code)\n file = File.join($root, path)\n unless File.exist?(file)\n Pod::UI.warn \"#{file} does not exist so was not patched..\"\n return\n end\n code = File.read(file)\n if code.include?(old_code)\n Pod::UI.message \"Patching #{file}\", '- '\n FileUtils.chmod('+w', file)\n File.write(file, code.sub(old_code, new_code))\n end\nend",
"def patch_pod_file(path, old_code, new_code)\n file = File.join($root, path)\n unless File.exist?(file)\n Pod::UI.warn \"#{file} does not exist so was not patched..\"\n return\n end\n code = File.read(file)\n if code.include?(old_code)\n Pod::UI.message \"Patching #{file}\", '- '\n FileUtils.chmod('+w', file)\n File.write(file, code.sub(old_code, new_code))\n end\nend",
"def patch_pod_file(path, old_code, new_code)\n file = File.join($root, path)\n unless File.exist?(file)\n Pod::UI.warn \"#{file} does not exist so was not patched..\"\n return\n end\n code = File.read(file)\n if code.include?(old_code)\n Pod::UI.message \"Patching #{file}\", '- '\n FileUtils.chmod('+w', file)\n File.write(file, code.sub(old_code, new_code))\n end\nend",
"def j2objc_shared\n pod 'j2objc-shared-debug', :configuration => ['Debug'], :path => '../shared/build'\n pod 'j2objc-shared-release', :configuration => ['Release'], :path => '../shared/build'\nend",
"def test_postInstall_updatesThePodCorrectly\n # Arrange\n installer = prepare_mocked_installer\n\n # Act\n flipper_post_install(installer)\n\n # Assert\n\n reactCore_target = installer.target_with_name(\"React-RCTAppDelegate\")\n reactCore_target.build_configurations.each do |config|\n if config.name == 'Debug' || config.name == 'CustomConfig' then\n assert_equal(config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'], ['$(inherited)', 'FB_SONARKIT_ENABLED=1'])\n else\n assert_true(config.build_settings.empty?)\n end\n end\n end",
"def run_puppet_lint(manifests)\r\n manifests.each do |manifest|\r\n sh \"puppet-lint --fail-on-warnings --no-80chars-check \\\"#{manifest}\\\"\"\r\n end\r\nend",
"def verify_puppet_exists\n MakeMakefile::Logging.instance_variable_set(:@logfile, File::NULL)\n find_executable0('puppet')\n end",
"def bundler_audit\n output = `bundle audit check --update`\n return if output&.empty?\n\n heading('Bundler Audit', output)\n end",
"def strip bash_script\n @notfound = [] # collecting poms not found\n script = File.open(bash_script, \"w+\")\n raise \"Can't open #{bash_script}\" unless script\n # for each .jar in @m2dir do\n # check if .pom exists\n # read .pom\n # find corresponding entry in maven universe\n # write entry to bash scrip\n # done\n puts \"Looking in #{@m2dir}\" if @verbose\n script.puts \"mkdir -p kit\"\n script.puts \"cd kit\"\n kitdir = File.dirname @m2dir\n # find ant\n # find maven\n # find gradle\n Dir.foreach(kitdir) do |name|\n case name\n when /apache-ant-(\\d+\\.\\d+.\\d+)/\n version = $1\n STDERR.puts \"ant version #{version}\"\n script.puts \"wget https://archive.apache.org/dist/ant/binaries/apache-ant-#{version}-bin.tar.bz2\"\n script.puts \"tar xf apache-ant-#{version}-bin.tar.bz2\"\n script.puts \"rm -f apache-ant-#{version}-bin.tar.bz2\"\n when /apache-maven-(\\d+\\.\\d+.\\d+)/\n version = $1\n STDERR.puts \"maven version #{version}\"\n script.puts \"wget https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/#{version}/apache-maven-#{version}-bin.tar.gz\"\n script.puts \"tar xf apache-maven-#{version}-bin.tar.gz\"\n script.puts \"rm -f apache-maven-#{version}-bin.tar.gz\"\n when \"jars\", \"m2\", \".\", \"..\", \".keep\"\n # skip\n else\n STDERR.puts \"\\e[33mUnknown #{kitdir}/#{name}\\e[0m\"\n end\n end\n script.puts \"mkdir -p m2\"\n script.puts \"cd m2\"\n been_there = []\n Dir.chdir(@m2dir) do |d|\n Dir.glob(\"**/*.{jar,pom,signature}\") do |f|\n dir = File.dirname(f)\n# puts \"found #{f} in #{dir}\"\n next if been_there.include? dir\n handle_dir dir, f, script\n been_there << dir\n end\n end\n script.puts \"cd ..\"\n script.puts \"cd ..\"\n @notfound.each do |pom|\n STDERR.puts \"*** Pom not found: #{pom}\"\n end\n end",
"def configure_phase\n self.project.targets.each do |target|\n begin\n phase = target.sources_build_phase\n next unless phase\n rescue NoMethodError\n next\n end\n\n \n bundle = target.copy_bundle_recources\n\n # remove zombie build files\n phase.files_references.each do |file|\n begin\n file.real_path\n rescue\n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n end\n \n # remove zombie bundle files\n bundle.files_references.each do |file|\n begin\n file.real_path\n rescue\n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file\n end\n end\n end\n\n removings = [] # name of seeds going to be removed from the target\n addings = [] # name of seeds going to be added to the target\n\n self.targets.keys.sort.each do |seed_name|\n target_names = self.targets[seed_name]\n if not target_names.include?(target.name)\n removings << seed_name if not removings.include?(seed_name)\n else\n addings << seed_name if not addings.include?(seed_name)\n end\n end\n\n\n self.file_references.each do |file|\n\n removings.each do |seed_names|\n next if not seed_names.include?(file.parent.name)\n \n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file \n end\n \n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n\n addings.each do |seed_names|\n next if file.name.end_with? \".h\"\n next if not seed_names.include?(file.parent.name)\n uuid = Xcodeproj::uuid_with_name \"#{target.name}:#{file.name}\"\n \n if self.seeds[seed_names].resources.any? { |s| file.name.end_with? s }\n bundle.add_file_reference_with_uuid(file, uuid, true)\n else \n phase.add_file_reference_with_uuid(file, uuid, true)\n end\n\n end\n end\n end\n end",
"def run\n if !repo_manifest_exists?\n Rails.logger.info \"Creating manifest for #{manifest['name']}\"\n\n create_repo_manifest!\n elsif repo_manifest_changed?\n Rails.logger.info \"Updating manifest for #{manifest['name']}\"\n\n update_repo_manifest!\n else\n Rails.logger.info \"No changes to manifest for #{manifest['name']}, \" \\\n \"skipping...\"\n end\n end",
"def should_build?\n return true if tagged_build?\n return should_build_nightly? if ENV['IS_NIGHTLY']\n\n # Find the oldest common revision between HEAD's parent and our\n # default branch.\n #\n # HEAD's parent may _be_ our default branch, or the commit before\n # `master` if we've forked to a branch off it. More than likely,\n # though, `HEAD^1` is some commit in our stream of history, and will\n # be sufficient to find the starting point of divergence, if such a\n # point exists.\n #\n # If HEAD is a merge commit on `master`, then HEAD^1 points to the\n # previous commit on `master`, which should clearly be completely\n # separate from the branch that was merged, and hence the fork point\n # will be the point of divergence.\n oldest_shared_revision = sh(\"git merge-base '#{DEFAULT_BRANCH}' 'HEAD^1'\")\n\n # Get all files that changed between the fork point and HEAD\n changed_files = git_log_between(oldest_shared_revision, 'HEAD').unique_lines\n\n # 1. Check if any packages we care about changed\n if changed_files.include?('package.json') &&\n npm_native_package_changed?(oldest_shared_revision, 'HEAD')\n puts \"some dependency matching #{NPM_DEP_NAME_REGEXP.inspect} changed\"\n return true\n end\n\n # 2. Check if any files we care about changed\n if native_file_changed?(changed_files)\n puts 'some native file changed'\n return true\n end\n\n # 3. If we haven't decided to build yet, we aren't going to.\n puts 'build skippable'\n false\nend",
"def feature_pods\n ### ONLY FOR DEVELOP PURPOSES ###\n feature_branch = \"master\" # <- HERE: Change this line to setup ALL the pods repository from another branch WHEN pods_environment = \"develop\"\n ### ONLY FOR DEVELOP PURPOSES ###\n\n color(32) { puts \"Installing Develop Pods from branch: #{feature_branch}\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => \"#{feature_branch}\"\n pod 'BasicUIElements', :git => 'git@github.com:kevinOlivet/BasicUIElements.git', :branch => \"#{feature_branch}\"\n pod 'CuotasModule', :git => 'git@github.com:kevinOlivet/CuotasModule.git', :branch => \"#{feature_branch}\"\nend",
"def validate_podspec_files\n UI.puts \"\\nValidating #{'spec'.pluralize(count)}\".yellow\n podspec_files.each do |podspec|\n validator = Validator.new(podspec, @source_urls)\n validator.allow_warnings = @allow_warnings\n validator.use_frameworks = @use_frameworks\n validator.use_modular_headers = @use_modular_headers\n validator.ignore_public_only_results = @private\n validator.swift_version = @swift_version\n validator.skip_import_validation = @skip_import_validation\n validator.skip_tests = @skip_tests\n validator.validation_dir = @validation_dir\n begin\n validator.validate\n rescue => e\n raise Informative, \"The `#{podspec}` specification does not validate.\" \\\n \"\\n\\n#{e.message}\"\n end\n raise Informative, \"The `#{podspec}` specification does not validate.\" unless validator.validated?\n end\n end",
"def ios_app_pods\n # SpotHero Pods or Forks\n pod 'SHEmailValidator'\n pod 'ParkonectSDK', '~> 0.2.0'\n\n # Third Party Pods\n pod 'AppsFlyerFramework', '~> 4.8.11'\n pod 'Branch', '~> 0.25.10'\n pod 'CardIO', '~> 5.4.1'\n pod 'FBSDKCoreKit', FACEBOOK_VERSION\n pod 'FBSDKLoginKit', FACEBOOK_VERSION\n pod 'Firebase', '~> 5.20.2', subspecs: ['Analytics', 'Core']\n pod 'FlashAccess', path: 'SpotHero/vendors/FlashAccess/FlashAccess.podspec'\n pod 'GoogleSignIn', '~> 4.4.0'\n pod 'OptimizelySDKiOS', '~> 3.0.2'\n pod 'SwiftyGif', '~> 4.2.0'\n pod 'SwiftLint', '~> 0.32.0'\n\n # Using our own fork so that we only use the Appboy Core dependency, otherwise Segment-Appboy defaults to using all their UI dependencies\n # If reverting back to using Appboy (including their UI framework) ensure you update our import of SDWebImage to include the /GIF subspec\n # and that it matches the version Appboy needs: https://github.com/Appboy/appboy-ios-sdk/blob/master/Appboy-iOS-SDK.podspec\n pod 'Segment-Appboy', git: 'https://github.com/spothero/appboy-segment-ios.git', branch: 'master'\n\n # Official podspec doesnt exist and local podspec is outdated, using the latest commit\n pod 'GenericPasswordExtension',\n git: 'https://github.com/joelastpass/generic-password-app-extension',\n commit: '4f9a65df3b5131178f380245cdcc5ec980c659a7'\nend",
"def install_pod\n %i(validate_targets generate_pods_project integrate_user_project\n perform_post_install_actions).each { |m| @installer.send(m) }\n\n deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)\n configure_pod_targets(@installer.target_installation_results)\n validate_dynamic_framework_support(@installer.aggregate_targets, deployment_target)\n @installer.pods_project.save\n end",
"def edit_check(exec_action)\n t = Chef::Resource::Template.new(tpl_name, run_context)\n t.cookbook new_resource.cookbook\n t.path tpl_path\n t.source 'monit.check.erb'\n t.variables monit_check_config\n if Chef::VERSION.to_f >= 12\n t.verify do |path|\n \"monit -tc #{path}\"\n end\n end\n t.run_action exec_action\n t.updated_by_last_action?\n end",
"def first_run?\n ::File.exist?(node['tomcat']['validation_script'])\n end",
"def feature_pods\n ### ONLY FOR DEVELOP PURPOSES ###\n feature_branch = \"develop\" # <- HERE: Change this line to setup ALL the pods repository from another branch WHEN pods_environment = \"develop\"\n ### ONLY FOR DEVELOP PURPOSES ###\n\n color(32) { puts \"Installing Develop Pods from branch: #{feature_branch}\" }\n pod 'BasicCommons', :git => 'git@github.com:kevinOlivet/BasicCommons.git', :branch => \"#{feature_branch}\"\nend"
] | [
"0.8060131",
"0.61538553",
"0.5682199",
"0.5630723",
"0.5587884",
"0.5550743",
"0.5519414",
"0.55132455",
"0.54747367",
"0.53839135",
"0.5336132",
"0.5320417",
"0.5279995",
"0.52783394",
"0.52426434",
"0.5242064",
"0.5242064",
"0.52115595",
"0.51987386",
"0.51917833",
"0.5174142",
"0.5172776",
"0.51346046",
"0.5128527",
"0.51268643",
"0.511703",
"0.5097797",
"0.50688344",
"0.5048579",
"0.5020304",
"0.5017516",
"0.49906522",
"0.498593",
"0.4971482",
"0.49709916",
"0.4968842",
"0.49286082",
"0.49103034",
"0.49059308",
"0.48987",
"0.4895051",
"0.4889485",
"0.4870875",
"0.48635384",
"0.48609403",
"0.4851771",
"0.48406595",
"0.4839009",
"0.48312926",
"0.48197237",
"0.48099533",
"0.47889903",
"0.47770146",
"0.4769926",
"0.47629103",
"0.47576156",
"0.4757022",
"0.47356805",
"0.47298083",
"0.4724934",
"0.47217408",
"0.4719453",
"0.47170332",
"0.4716821",
"0.47163337",
"0.47149807",
"0.47123834",
"0.47062808",
"0.4704489",
"0.47032264",
"0.47008827",
"0.46999884",
"0.46920195",
"0.46902046",
"0.46850803",
"0.46825606",
"0.4676206",
"0.46737587",
"0.46700242",
"0.46692345",
"0.46680477",
"0.46673444",
"0.46673444",
"0.46673444",
"0.46633235",
"0.46601295",
"0.46552107",
"0.46487987",
"0.46479923",
"0.4644688",
"0.4641237",
"0.46403483",
"0.46340778",
"0.46297804",
"0.46267948",
"0.46244133",
"0.46203294",
"0.46164986",
"0.4614034",
"0.46117008"
] | 0.78093374 | 1 |
Read the project from the disk to ensure that it is up to date as other TargetIntegrators might have modified it. | def user_project
target.user_project
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_load\n (project_dir = reachable_projects.first) || raise(InputError, \"Could not find a project file containing #{path}\")\n @project = ProjectCache.open(project_dir)\n end",
"def project_load\n project_dir = reachable_projects.first || abort(\"Could not find a project file containing #{path}\")\n @project = ProjectCache.open(project_dir)\n end",
"def rebuild_files\n @project.rebuild_files()\n end",
"def sync_project(project)\n return false unless _fetch_and_patch(project)\n\n # Does this project contains a makefile? If so, enqueue a derivative build.\n has_makefile = prepare_derivative_build(project)\n\n # Ignore libraries that may be installed inside this project\n pp = @platform.local_path + @platform.dest_path(project)\n @libraries_paths.each do |lp|\n if lp.fnmatch?(pp.to_s + '/*')\n project.ignore_path(lp.relative_path_from(pp))\n @log.notice(\"Ignoring #{project.ignore_paths.last} inside #{project.extended_name}\")\n end\n end\n\n # Does the project exist in the platform? If so, compare the two.\n if @platform.has_project?(project.name)\n platform_project = @platform.get_project(project.name)\n # Fix project location\n new_path = @platform.dest_path(project)\n if @platform.local_path + new_path != platform_project.local_path\n log.action(MoveAction.new(@platform, platform_project, new_path))\n if (@platform.local_path + new_path).exist?\n if @force_changes\n owarn \"Overwriting existing path: #{new_path}\"\n else\n log.error(\"#{new_path} already exists. Use --force to overwrite.\")\n end\n end\n end\n # Compare versions and log suitable actions\n _compare_versions project, platform_project\n else\n # If analyzing the platform does not allow us to detect the project (e.g., Fusion),\n # we try to see if the directory exists where it is supposed to be.\n proj_path = @platform.local_path + @platform.dest_path(project)\n if proj_path.exist?\n begin\n platform_project = PlatformProject.new(@platform, proj_path)\n _compare_versions project, platform_project\n rescue => ex\n log.action(UpdateProjectAction.new(@platform, project))\n if @force_changes\n owarn \"Overwriting existing path: #{proj_path}\"\n else\n log.error(\"#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}\")\n end\n end\n else # new project\n log.action(InstallProjectAction.new(@platform, project))\n end\n end\n return (not has_makefile)\n end",
"def read_json\n if project.source_exists?\n JSON.parse(File.read(project.project_path))\n else\n []\n end\n end",
"def project\n project_obj_files = Dir[\"*.yaml\"]\n unless project_obj_files.empty?\n AimsProject::Project.load(project_obj_files.first)\n else\n raise AimsProject::AimsProjectException.new(\"Sorry, I can't tell what project this is. Please move to the project root directory.\")\n end\nend",
"def reload\n response = ODPS.conn.get \"projects/#{self.name}\"\n self.creation_time = response['x-odps-creation-time']\n self.last_modified_time = response['Last-Modified']\n self.owner = response['x-odps-owner']\n self.deserialize response.body\n end",
"def load_local_configfile\n Dir.glob('**/project.yml') do |filename|\n project = Project.new(config: @config, filename: filename)\n @projects[project.name] = project if project.valid?\n end\n end",
"def load\n Project.purge\n \n if !File.exists?(Options.database_location)\n error!\n return\n end\n\n database = SQLite3::Database.new(Options.database_location)\n database.results_as_hash = true\n database.execute(\"SELECT * FROM projects\").each do |row|\n ## Custom actions\n # Defer date\n defer_date = row[\"deferredDate\"]\n defer_date = (defer_date > 0 && Time.at(defer_date))\n days_deferred = defer_date && (defer_date.to_date - Date.today).to_i\n\n # Status\n status = row[\"status\"]\n if status == \"Deferred\"\n if row[\"deferralType\"] == \"task\"\n status = \"Task deferred\"\n else\n status = \"Project deferred\"\n end\n end\n \n p = Project.new(\n name: row[\"name\"],\n status: status,\n days_deferred: days_deferred,\n id: row[\"ofid\"],\n num_tasks: row[\"numberOfTasks\"]\n )\n p.ancestors_string = row[\"ancestors\"]\n end\n end",
"def init solution\n FileUtils.touch(file_path(solution))\n end",
"def load(path) \n #puts \"Loading project file #{path}\" \n projectPath = ProjectPath.new(path)\n \n if(!projectPath.exist?() || !projectPath.file?())\n currentlyLoadedProjectFileString = (CurrentlyLoadedProjectFile() == nil) ? \"nil\" : CurrentlyLoadedProjectFile().Path.to_s\n raise \"Could not find project file '#{path}' to load. Currently loaded project files is #{currentlyLoadedProjectFileString}\"\n end\n \n LoadProjectFile(projectPath)\n end",
"def source_file_up_to_date?\n return false unless compilation_context.incremental_build?\n\n source_db = compilation_context.source_file_database\n source_db.up_to_date?(source_path)\n end",
"def compare_to(project_name)\n compare_contents @project_path, project_fixture(project_name)\n end",
"def remove_from_project\n build_files.each(&:remove_from_project)\n super\n end",
"def clear\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n projectFile.clear()\n end\n end",
"def user_project\n @user_project ||= Xcodeproj::Project.open(target.user_project_path)\n end",
"def load\n Project.purge\n database = SQLite3::Database.new(DATABASE_LOCATION)\n database.results_as_hash = true\n database.type_translation = true\n database.execute(\"SELECT * FROM projects\").each do |row|\n if not HIDE_PROJECTS.include? row[\"name\"] then\n p = Project.new(\n name: row[\"name\"],\n status: row[\"status\"],\n days_deferred: row[\"daysdeferred\"],\n id: row[\"ofid\"],\n num_tasks: row[\"num_tasks\"]\n )\n p.ancestors_string = row[\"ancestors\"]\n end\n end\n end",
"def update(rubyOF_project=nil)\n\t\t# If you invoke with no arguments, provide useful help,\n\t\t# rather than the standard error message.\n\t\tif rubyOF_project.nil?\n\t\t\traise ArgumentError, \"<1 argument>: Need to specify project name, or relative path (relative to [GEM_ROOT]/bin/projects), or absolute path to project. Project must already exist in order to update it.\"\n\t\tend\n\t\t\n\t\t\n\t\tname, path = RubyOF::Build.load_project rubyOF_project\n\t\t\n\t\t# TODO: remove this once everything is updated to use Pathname\n\t\tproject_root = Pathname.new(path).expand_path\n\t\tgem_root = Pathname.new(GEM_ROOT)\n\t\t\n\t\tputs \"gem_root = #{gem_root}\"\n\t\tputs \"project_root = #{project_root}\"\n\t\t\n\t\t# === Update files where GEM_ROOT is declared.\n\t\ttarget_file = 'build_variables.rb'\n\t\t\n\t\t[\n\t\t\t(project_root/'config'/'build_variables.rb'),\n\t\t\t(project_root/'Gemfile')\n\t\t].each do |path|\n\t\t\t# Declare the new GEM_ROOT path\n\t\t\t# (use relative paths for projects inside the gem)\n\t\t\tpath_to_root = \n\t\t\t\tif path.to_s.start_with? gem_root.to_s\n\t\t\t\t\t# Relative path\n\t\t\t\t\t# (project is inside the default directory)\n\t\t\t\t\tgem_root.relative_path_from(path.dirname)\n\t\t\t\telse\n\t\t\t\t\t# Absolute path\n\t\t\t\t\t# (project is outside of the default directory)\n\t\t\t\t\tgem_root\n\t\t\t\tend\n\t\t\t\n\t\t\tputs path_to_root\n\t\t\t\n\t\t\t# Load the file\n\t\t\tunless path.exist?\n\t\t\t\traise \"ERROR: Could not find '#{path.basename}' @ path #{path}\"\n\t\t\tend\n\t\t\tfile_lines = File.readlines(path)\n\t\t\t# p file_lines\n\t\t\t\n\t\t\t# Find the line that sets GEM_ROOT\n\t\t\t# and replace it with the new declaration\n\t\t\tfile_lines.collect! do |line|\n\t\t\t\tif line.start_with? 'GEM_ROOT = '\n\t\t\t\t\t\"GEM_ROOT = Pathname.new('#{path_to_root}').expand_path\\n\"\n\t\t\t\telse\n\t\t\t\t\tline\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t# Write the modified contents back into the file\n\t\t\tFile.open(path, \"w\") do |f|\n\t\t\t\tf.write file_lines.join\n\t\t\tend\n\t\tend\n\t\t\n\tend",
"def import_projects\n Project.unrestrict_primary_key\n iterate_lines(@directory + 'projects.json') do |idx, line|\n print \"\\rImporting Projects #{idx}...\"\n Project.create(JSON.parse(line))\n end\n print \"Done\\n\"\n Project.restrict_primary_key\n end",
"def project\n return nil if workspace?\n @project ||= Xcodeproj::Project.open(path)\n end",
"def read_project_configuration\n if File.exists?(projectize('config.rb'))\n Compass.configuration.parse(projectize('config.rb'))\n elsif File.exists?(projectize('src/config.rb'))\n Compass.configuration.parse(projectize('src/config.rb'))\n end\n end",
"def load_attributes\n puts \"Loading project information from #{project_file}\"\n @attributes = MultiJson.decode(File.new(project_file, 'r').read)\n end",
"def test_respects_force_reload\n project = Project.create()\n Actor.create(:project_id => project.id)\n\n actor = Actor.find_version(1, 2)\n project = actor.project\n\n assert_same project, actor.project\n assert_same project, actor.project(false)\n \n reloaded_project = actor.project(true)\n assert_not_same project, reloaded_project\n assert_equal project, reloaded_project\n end",
"def update_project\n self.project.update_project\n #not updating when adding activities or tasks\n end",
"def project\n @recipe_file.project\n end",
"def projects\n return @projects if @projects\n @projects = []\n IO.readlines(@file).each do |line|\n @projects << Project.new(line, @dir) if /^Project.*\\.csproj/ =~ line\n end\n end",
"def read!(filename)\n \n puts \"Project: parsing #{filename}\" if $op_verbose\n\n xml = BugParse::XMLBase.new(filename)\n\n # Each block\n xml.elements.each(\"project/block\") { |block|\n blk = ProjectBlock.new(block)\n @block[blk.name] = blk\n }\n puts \"Project: done\" if $op_verbose\n end",
"def init_project\n da_user = user\n new_project = da_user.projects.build(\n # user_id: self.id, # handled through build method\n school_id: school_id, # merged from user.school.Institution_ID\n name: name, # take on name of work\n\n file_content_md: file_content_md, # these are of most recent, will be replaced as versions are added\n file_content_html: file_content_html,\n file_content_text: file_content_text,\n\n works_count: 1, # is first work\n recent_work_id: id, # as original work\n\n anonymouse: anonymouse?, # and work gets this from user\n author_name: author_name, # ditto\n school_name: school_name,\n )\n\n if new_project.save\n self.update_columns(project_id: new_project.id, is_latest_version: true, project_name: name)\n else\n errors[:base] << (\"There was an error versioning this work.\")\n end\n end",
"def LoadedProjectFiles\n @LoadedProjectFilesList\n end",
"def updated_source_file?; end",
"def load()\n\n # Get the project root directory\n @root_dir = locate_root\n\n if File.file? File.join(@root_dir, SETTINGS_FILE)\n settings = YAML.load_file File.join(@root_dir, SETTINGS_FILE)\n @targets = settings[:targets]\n @src = settings[:src]\n @notify = settings[:notify]\n else\n puts \"No settings file found, creating one now\"\n # Settings file doesn't exist\n # Create it\n @targets = {}\n @active_target = nil\n @src = './src'\n @notify = true\n\n dump_settings\n end\n\n # Set the default target\n @targets.values.each do |target|\n # Check if this one is active\n if target.active == true\n # Set it if there is no default target set yet\n if @active_target == nil\n @active_target = target\n else\n puts \"Two active targets set. Using #{@active_target.print}\"\n end\n end\n end\n end",
"def update_project(from_version, to_version, tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end",
"def load()\n\n # Get the project root directory\n @root_dir = locate_root\n\n if File.file? File.join(@root_dir, SETTINGS_FILE)\n settings = YAML.load_file File.join(@root_dir, SETTINGS_FILE)\n @targets = settings[:targets]\n @src = settings[:src]\n @notify = settings[:notify]\n else\n puts \"No settings file found, creating one now\"\n # Settings file doesn't exist\n # Create it\n @targets = {}\n @active_target = nil\n @src = './src'\n @notify = true\n\n dump_settings\n end\n\n # Set the default target\n @targets.values.each do |target|\n # Check if this one is active\n if target.active == true\n # Set it if there is no default target set yet\n if @active_target == nil\n @active_target = target\n else\n puts \"Two active targets set. Using #{@active_target.print}\"\n end\n end\n end\n end",
"def data\n data = @repo.working_read(@path) rescue nil\n data\n end",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }\n end",
"def loaded_projects\n @loaded_projects ||= {}\n end",
"def loaded_projects\n @loaded_projects ||= {}\n end",
"def request_project\n @has_data = Settings.has_user_data\n @data = Settings.getSavedData\n end",
"def update_info_from_file()\n @ole.UpdateInfoFromFile()\n end",
"def project; end",
"def project\n @project ||= export_repository_project\n end",
"def updated_source_file; end",
"def CurrentlyLoadedProjectFile\n @CurrentlyLoadedProjectFileStack[-1]\n end",
"def replace_project_versions proj_files\r\n\r\n begin\r\n # iterate each package file, replace version numbers and save\r\n proj_files.each{ |file|\r\n puts \"Updating references in: #{file}...\"\r\n doc = Nokogiri::XML File.read file\r\n nodes = doc.search 'Reference'\r\n nodes.each { |node|\r\n ref_val = node['Include']\r\n # grab the identifier\r\n id = ref_val.split(',')[0]\r\n # clean out file version\r\n node['Include'] = id\r\n\r\n # replace version in hint path\r\n hint_path = node.search 'HintPath'\r\n if hint_path && hint_path[0] != nil\r\n hint_path_value = hint_path[0].children.to_s\r\n # this identifier is not the same as the node['Include'] one.\r\n # For ex., Runtime, Core and Storage assemblies will be referred to from within other packages like Management, Test etc\r\n hint_path_id = id_from_hint_path hint_path_value\r\n if @versions.has_key? hint_path_id\r\n hint_path_parts = hint_path_value.split '\\\\'\r\n hint_path_parts[2] = hint_path_id + GlobalConstants::DOT + @versions[hint_path_id]\r\n hint_path[0].children = hint_path_parts.join '\\\\'\r\n end\r\n end\r\n }\r\n File.write file, doc.to_xml\r\n }\r\n rescue\r\n puts $!\r\n return false\r\n end\r\n\r\n return true\r\n\r\n end",
"def load_config\n projects = Array.new\n Dir.glob(\"#{@config_path}/*.json\") do |cf|\n if !cf.end_with?(\"template.json\")\n projects << Project.new(cf)\n end\n end\n projects\nend",
"def merge_local_with_api(filename)\n project = YAML.safe_load_file(filename)\n api_data = JSON.parse(open(\"_data/projects/all.json\").read)\n unless project.nil?\n new_data = update_from_api(project, api_data[project['name']])\n end\nend",
"def check_project\n return if project.dataset_names.empty?\n return unless project.done_preprocessing?(false)\n to_run = project.next_distances(true)\n to_run = project.next_inclade(true) if to_run.nil?\n queue_job(to_run) unless to_run.nil?\n end",
"def update_metadata!\n compilation_context.source_file_database.update_metadata(source_path)\n compilation_context.target_file_database.update_metadata(source_path)\n end",
"def project_files\n self.class.load_csv(path, @executable, @configurations)\n url = self.class.url_for(self)\n\n return [] if url.nil?\n\n license_data = self.class.retrieve_license(url)\n\n Array(Licensee::ProjectFiles::LicenseFile.new(license_data, { uri: url }))\n end",
"def copy_project_dependencies_for_awestruct_image\n\n puts \"- Copying project dependencies into '_docker/awestruct' for build...\"\n\n parent_gemfile = File.open '../Gemfile'\n parent_gemlock = File.open '../Gemfile.lock'\n\n target_gemfile = FileHelpers.open_or_new('awestruct/Gemfile')\n target_gemlock = FileHelpers.open_or_new('awestruct/Gemfile.lock')\n #Only copy if the file has changed. Otherwise docker won't cache optimally\n FileHelpers.copy_if_changed(parent_gemfile, target_gemfile)\n FileHelpers.copy_if_changed(parent_gemlock, target_gemlock)\n\n puts \"- Successfully copied project dependencies into '_docker/awestruct' for build.\"\n\nend",
"def load_monkfile\n file = find_in_project(\"Monkfile\")\n\n if file\n load file\n @project = File.dirname(file)\n Dir.chdir @project\n end\n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def pods_project\n @pods_project ||= Xcodeproj::Project.open(target.sandbox.project_path)\n end",
"def ignore_test_active_record_respects_force_reload\n actor = Actor.find 1\n project = actor.project\n\n assert_same project, actor.project\n assert_same project, actor.project(false)\n \n reloaded_project = actor.project(true)\n assert_not_same project, reloaded_project\n assert_equal project, reloaded_project\n end",
"def discover_projects!\n self.discover_projects.each(&:save!)\n end",
"def project\n @project ||= Project.new(root)\n end",
"def post_process(file)\n if File.basename(file.to_s).match(/library/)\n oldfile = file\n file = file.to_s.sub(\"library\", @options[:lib_name_u])\n FileUtils.mv(oldfile, file)\n end\n if File.dirname(file.to_s).split(\"/\").last == \"library\"\n origdir = File.dirname(file.to_s)\n dirarr = origdir.split(\"/\")\n dirarr[dirarr.size-1] = @options[:lib_name_u]\n new_dir = File.join(dirarr)\n mkdir(new_dir)\n oldfile = file\n file = File.join(new_dir, File.basename(file))\n FileUtils.mv(oldfile, file)\n FileUtils.rmdir(origdir)\n end\n if file.to_s.match(/\\.seed$/)\n out_file = Pathname.new(file.to_s.sub(/\\.seed$/, ''))\n # Don't overwrite a file of the same name, unless they --force\n if copy_check(out_file)\n template = ::ERB.new(File.read(file))\n # This binding has access to any instance variables of\n # the ProjectCreator instance\n result = template.result(binding)\n File.open(file.to_s.sub(/\\.seed$/,''), 'w+') do |io|\n io.puts result\n end\n end\n # Remove the seed file whether we copied or not\n FileUtils.rm_f(file)\n end\n end",
"def xcodeproj(path)\n proejct_filename = File.join(self.root_path, path)\n self.project = Xcodeproj::Project.open(proejct_filename)\n self.validate_project\n end",
"def load_project\n local_params = params\n @project = Project.find local_params[:project_id]\n end",
"def main_build_loop\n @import = Import.find_or_create_by(name: IMPORT_NAME) \n @import.metadata ||= {} \n handle_projects_and_users(@data, @import)\n raise '$project_id or $user_id not set.' if $project_id.nil? || $user_id.nil?\n handle_namespaces(@data, @import)\n handle_preparation_types(@data, @import)\n handle_controlled_vocabulary(@data, @import)\n\n handle_people(@data, @import) ## !created as new\n\n handle_taxa(@data, @import)\n\n checkpoint_save(@import) if ENV['no_transaction']\n\n # !! The following can not be loaded from the database they are always created anew.\n handle_collecting_events(@data, @import)\n handle_specimens(@data, @import)\n\n # handle_users(@data, @import)\n\n @import.save!\n puts \"\\n\\n !! Success \\n\\n\"\n end",
"def project\n strong_memoize(:project) do\n projects.first\n end\n end",
"def load_project\n load_warning = load_warnings\n warn load_warning unless load_warning == ''\n\n @project_modules&.each(&method(:require_all))\n build_page_stores\n end",
"def project\n @project ||= DataStore.find_project_by_id(project_id)\n end",
"def load_projects\n @projects = Project.all\n end",
"def fetch_project_data\n response = fetch_data(@@SETTINGS.project_tab)\n unless response.nil?\n adjust_projects response\n return true\n end\n false\n end",
"def assign_to_project\n da_user = self.user # get user\n if self.project == nil\n new_project = da_user.projects.build(\n\n # user_id: self.id, # handled through build method\n school_id: self.school_id,\n name: self.name,\n\n file_content_md: self.file_content_md,\n file_content_html: self.file_content_html,\n file_content_text: self.file_content_text,\n\n works_count: 1,\n recent_work_id: self.id,\n\n anonymouse: self.anonymouse?,\n author_name: self.author_name,\n school_name: self.school_name,\n\n impressions_count: self.impressions_count,\n bookmarks_count: self.bookmarks_count\n\n )\n\n if new_project.save\n self.update_attributes(project_id: new_project.id, is_latest_version: true, project_name: self.name)\n puts \"Successfully saved \" + new_project.name.to_s\n else\n puts \"Error saving \" + self.name + \", id: \" + self.id.to_s\n end\n\n # this should only be necessary in development scenario\n else\n puts \"Project id: \" + self.project.id.to_s + \" already exists for this work id: \" + self.id.to_s\n end\n\n end",
"def sync_projects(options = {})\n exclude(@core_projects) # Skip core projects\n processed = Array.new(excluded) # List of names of processed projects\n dep_queue = Array.new # Queue of Drupid::Project objects whose dependencies must be checked. This is always a subset of processed.\n\n @makefile.each_project do |makefile_project|\n dep_queue << makefile_project if sync_project(makefile_project)\n processed += makefile_project.extensions\n end\n\n unless options[:nofollow]\n # Recursively get dependent projects.\n # An invariant is that each project in the dependency queue has been processed\n # and cached locally. Hence, it has a version and its path points to the\n # cached copy.\n while not dep_queue.empty? do\n project = dep_queue.shift\n project.dependencies.each do |dependent_project_name|\n unless processed.include?(dependent_project_name)\n debug \"Queue dependency: #{dependent_project_name} <- #{project.extended_name}\"\n new_project = Project.new(dependent_project_name, project.core)\n dep_queue << new_project if sync_project(new_project)\n @makefile.add_project(new_project)\n processed += new_project.extensions\n end\n end\n end\n end\n\n # Determine projects that should be deleted\n pending_delete = @platform.project_names - processed\n pending_delete.each do |p|\n proj = platform.get_project(p)\n log.action(DeleteAction.new(platform, proj))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing deletion.\"\n else\n log.error \"#{proj.extended_name}: use --force to force deletion or install Drush >=6.0.\"\n end\n elsif proj.installed?(site)\n if @force_changes\n owarn \"Deleting an installed/enabled project.\"\n else\n log.error \"#{proj.extended_name} cannot be deleted because it is installed\"\n end\n end\n end\n end",
"def project=(project)\n association(:project).writer(project)\n\n # Set fixed_version to the project default version if it's valid\n if new_record? && fixed_version.nil? && project && project.default_version_id?\n if project.shared_versions.open.exists?(project.default_version_id)\n self.fixed_version_id = project.default_version_id\n end\n end\n\n self.project\n end",
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end",
"def configure_phase\n self.project.targets.each do |target|\n begin\n phase = target.sources_build_phase\n next unless phase\n rescue NoMethodError\n next\n end\n\n \n bundle = target.copy_bundle_recources\n\n # remove zombie build files\n phase.files_references.each do |file|\n begin\n file.real_path\n rescue\n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n end\n \n # remove zombie bundle files\n bundle.files_references.each do |file|\n begin\n file.real_path\n rescue\n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file\n end\n end\n end\n\n removings = [] # name of seeds going to be removed from the target\n addings = [] # name of seeds going to be added to the target\n\n self.targets.keys.sort.each do |seed_name|\n target_names = self.targets[seed_name]\n if not target_names.include?(target.name)\n removings << seed_name if not removings.include?(seed_name)\n else\n addings << seed_name if not addings.include?(seed_name)\n end\n end\n\n\n self.file_references.each do |file|\n\n removings.each do |seed_names|\n next if not seed_names.include?(file.parent.name)\n \n bundle.files.each do |bundle_file|\n bundle.files.delete(bundle_file) if bundle_file.file_ref == file \n end\n \n phase.files.each do |build_file|\n phase.files.delete(build_file) if build_file.file_ref == file\n end\n end\n\n addings.each do |seed_names|\n next if file.name.end_with? \".h\"\n next if not seed_names.include?(file.parent.name)\n uuid = Xcodeproj::uuid_with_name \"#{target.name}:#{file.name}\"\n \n if self.seeds[seed_names].resources.any? { |s| file.name.end_with? s }\n bundle.add_file_reference_with_uuid(file, uuid, true)\n else \n phase.add_file_reference_with_uuid(file, uuid, true)\n end\n\n end\n end\n end\n end",
"def fetch\n log.info(log_key) { \"Copying from `#{source_path}'\" }\n\n create_required_directories\n FileSyncer.sync(source_path, project_dir, source_options)\n # Reset target shasum on every fetch\n @target_shasum = nil\n target_shasum\n end",
"def load_project\n @project = Project.find(params[:id])\n end",
"def read\n if @draft_content\n @draft_content\n else\n file = @options['path']\n abort \"File #{file} not found.\" if !File.exist? file\n @draft_content = File.open(file).read\n end\n end",
"def reset!\n @loaded_projects = nil\n end",
"def reset!\n self.draft = find_original_file!.read\n save!\n end",
"def refresh!\n updated_contents = File.read(@path)\n updated_yml = YAML.load(updated_contents)\n\n updated_items = fetch_items(updated_yml)\n original_items = items.flatten\n\n updated_items.flatten.each do |updated_item|\n original_item = original_items.find do |oi|\n oi.full_src == updated_item.full_src\n end\n\n # If this is a new item, we're good\n next if !original_item\n\n # Otherwise, we'll need to see if this file changed\n if !original_item.identical?(updated_item)\n original_item.delete!\n end\n end\n\n @items = updated_items\n\n prepare!\n end",
"def atomic_read(path, name)\n main_file = File.join(path, name) + '.yml'\n dup_file = File.join(path, name) + '.yml2'\n \n # choose the single good file or, if both are good, use the latest timestamp\n # this works as long as the time on a box doesn't go back (it's ok to have it skewed)\n results = [main_file, dup_file].map { |file| atomic_read_internal file }\n results.sort { |a, b| b[1] <=> a[1] } \n return results.first[0]\n end",
"def load_project\n html = URI.parse(\"http://#{domain}/projects/#{unixname}/index.html\").read\n\n group_id = html[/(frs|tracker)\\/\\?group_id=\\d+/][/\\d+/].to_i\n\n self.group_id = group_id\n\n if $DEBUG\n puts \"GROUP_ID = #{group_id}\"\n end\n\n html = URI.parse(\"http://rubyforge.org/frs/?group_id=#{group_id}\").read\n\n package = nil\n html.scan(/<h3>[^<]+|release_id=\\d+\">[^>]+|filemodule_id=\\d+/).each do |s|\n case s\n when /<h3>([^<]+)/ then\n package = $1.strip\n when /filemodule_id=(\\d+)/ then\n @package_ids[package] = $1.to_i\n when /release_id=(\\d+)\">([^<]+)/ then\n package_id = @package_ids[package]\n @release_ids[[package_id,$2]] = $1.to_i\n end\n end\n\n if $DEBUG\n p @package_ids, @release_ids\n end\n end",
"def read_yml\n yml = YAML.load(File.open(@project))\n file_name = @document_class\n\n @document_class = yml['document-class'] if ['document-class']\n if yml['document-classes']\n @document_class = yml['document-classes'][0]\n yml['document-classes'].each { |v| @document_class = v if v == file_name }\n end\n @flex_sdk_bin = yml['flex-sdk-bin'] if ['flex-sdk-bin']\n yml['compile-options'].each { |k,v| @compile_options[k] = v } if yml['compile-options']\n\n @output_swf = yml['compile-options']['output'] || @document_class + \".swf\"\nend",
"def load()\n\n checkFileExists()\n loadConfigs()\n checkConfigs() \n end",
"def load_project_ruby\r\n # Load up patches and the like for the project\r\n if File.exist?(File.join(SAF::PROJECTS, project, \"lib\")) then\r\n Dir.glob(File.join(SAF::PROJECTS, project,\r\n \"lib\", \"**\", \"*.rb\")) do |f|\r\n require_relative(f)\r\n end\r\n end\r\n\r\n # Load up page objects and steps for this project\r\n load_directory(File.join(SAF::PROJECTS, project, \"page_objects\"))\r\n load_directory(File.join(SAF::PROJECTS, project, \"features\",\r\n \"step_definitions\"))\r\n end",
"def internal\n @internal ||= load_from_file\n end",
"def find_active_project\n if @textmate.documents.first\n active_path = @textmate.documents.first.path\n @projects.find {|p| active_path =~ /^#{p.path}/}\n end\n end",
"def inside_project?\n project_found = false\n cwd = Pathname(Dir.pwd)\n home_directory = File.expand_path('~')\n cwd.ascend do |current_path|\n project_found = File.file?(\"#{current_path.to_s}/.bebox\")\n self.project_root = current_path.to_s if project_found\n break if project_found || (current_path.to_s == home_directory)\n end\n project_found\n end",
"def update_project!(new_project)\n @project = new_project\n end",
"def spec_file\n return @spec_file if defined?(@spec_file)\n return @spec_file = nil unless loaded_from && File.file?(loaded_from)\n @spec_file = begin\n file = { name: File.basename(loaded_from), dir: File.dirname(loaded_from) }\n Licensee::ProjectFiles::PackageManagerFile.new(File.read(loaded_from), file)\n end\n end",
"def from_eclipse(path = Dir.pwd, root = true)\n # We need two passes to be able to determine the dependencies correctly\n Dir.chdir(path) do\n name = File.basename(path)\n dot_projects = []\n mf = nil # avoid reloading manifest\n if root\n @@allProjects = Hash.new\n @@topDir = File.expand_path(Dir.pwd)\n script = HEADER.split(\"\\n\")\n script << \"require 'buildr/ide/eclipse'\"\n header = getEclipseBuildfileHeader(path, name)\n script += header.split(\"\\n\")\n script << \" # you may see hints about which jars are missing and should resolve them correctly\"\n script << \" # dependencies << 'junit should be commented out and replace by correct ARTIFACT definition. Eg\"\n script << \" # dependencies << 'junit:junit:jar:4.11'\"\n script << setLayout('src', 'bin') # default values for eclipse\n dot_projects = Dir.glob('**/.project', File::FNM_DOTMATCH).find_all { |dot_project| get_project_natures(dot_project) }\n dot_projects.sort.each { |dot_project| from_eclipse(File.dirname(dot_project), false) } if dot_projects\n else\n # Skip fragments. Buildr cannot handle it without the help of buildr4osgi\n return [\"\"] if File.exists?('fragment.xml')\n projectName = name\n version = \"\"\n mfName = File.join('META-INF', 'MANIFEST.MF')\n if File.exists?(mfName)\n mf = Packaging::Java::Manifest.parse(IO.readlines(mfName).join(''))\n if mf.main['Bundle-SymbolicName']\n projectName = mf.main['Bundle-SymbolicName'].split(';')[0]\n bundleVersion = mf.main['Bundle-Version']\n version = \", :version => \\\"#{bundleVersion}\\\"\" unless \"1.0.0\".eql?(bundleVersion)\n end\n end\n # in the first run we just want to know that we exist\n unless @@allProjects[projectName]\n @@allProjects[projectName] = Dir.pwd\n return\n end\n base_dir = \"\"\n unless File.join(@@topDir, projectName).eql?(File.expand_path(Dir.pwd))\n base_dir = \", :base_dir => \\\"#{File.expand_path(Dir.pwd).sub(@@topDir+File::SEPARATOR, '')}\\\"\"\n end\n script = [%{define \"#{projectName}\"#{version}#{base_dir} do}]\n end\n natures = get_project_natures('.project')\n if natures && natures.index('org.eclipse.pde.PluginNature')\n script << \" package(:jar)\"\n end\n script << \" dependencies ||= []\"\n if mf && mf.main['Require-Bundle']\n mf.main['Require-Bundle'].split(',').each do\n |bundle|\n requiredName = bundle.split(';')[0]\n if @@allProjects.has_key?(requiredName)\n script << \" dependencies << projects(\\\"#{requiredName}\\\")\"\n else\n script << \" # dependencies << '#{requiredName}'\"\n end\n end\n end\n script << \" compile.with dependencies # Add more classpath dependencies\" if Dir.glob(File.join('src', '**', '*.java')).size > 0\n script << \" resources\" if File.exist?(\"rsc\")\n sourceProp = get_build_property('.', 'source..')\n outputProp = get_build_property('.', 'output..')\n if (sourceProp && !/src\\/+/.match(sourceProp)) or (outputProp && !/bin\\/+/.match(outputProp))\n setLayout(sourceProp, outputProp) # default values are overridden in this project\n end\n unless dot_projects.empty?\n script << \"\"\n dot_projects.sort.each do |dot_project|\n next if File.dirname(File.expand_path(dot_project)).eql?(File.expand_path(Dir.pwd))\n next unless get_project_natures(dot_project)\n script << from_eclipse(File.dirname(dot_project), false).flatten.map { |line| \" \" + line } << \"\"\n end\n end\n script << \"end\\n\\n\"\n script.flatten\n end\n end",
"def purge\n @projects = []\n end",
"def purge\n @projects = []\n end",
"def read_project_configuration\n if file = detect_configuration_file\n Compass.configuration.parse(file)\n end\n end",
"def read\n up_to_date? || prepare_et_save\n system \"less -R \\\"#{path}\\\"\"\n end",
"def unlocked_reload\n return if !@index_file.file?\n\n data = nil\n begin\n data = JSON.load(@index_file.read)\n rescue JSON::ParserError\n raise Errors::CorruptMachineIndex, path: @index_file.to_s\n end\n\n if data\n if !data[\"version\"] || data[\"version\"].to_i != 1\n raise Errors::CorruptMachineIndex, path: @index_file.to_s\n end\n\n @machines = data[\"machines\"] || {}\n end\n end",
"def get_invoked_project_file(invokingProjectFilePath, invokedProjectFilePath)\n #if(invokedProjectFilePath.BasePath == invokedProjectFilePath.BasePath)\n # topRelativePath = invokedProjectFilePath\n #else\n topRelativePath = (invokingProjectFilePath.DirectoryPath() + invokedProjectFilePath).MakeRelativeTo(@TopmostProjectFile.DirectoryPath())\n #end\n #puts \"top relative path is #{topRelativePath}\"\n return @ProjectFileLoader.LoadedProjectFile(topRelativePath.RelativePath())\n end",
"def fetchUntestedProjects \r\n @logger.debug \"search untested projects: #{@workspaceFolder}\"\r\n\t\tprojectFolders = FileList.new(@workspaceFolder+\"/*/\")\r\n\t\tprojectFolders.exclude(@workspaceFolder+\"/.*/\") # no meta-data\t\t\r\n\t\tprojectFolders.each do |projectFolder|\r\n\t\t\tsourceFiles = FileList.new(projectFolder+\"/**/*.{h,hpp,c,cpp}\")\r\n\t\t\tif sourceFiles.size() > 0 then\r\n\t\t\t\r\n\t\t\t\tprojectPath = Pathname.new(projectFolder).cleanpath.to_s\r\n\t\t\t\tif @testedProjects.find{ |item| item.projectFolder.eql?(projectPath) } == nil then\r\n @logger.debug \"=> untested project: #{File.basename(projectPath)}\" \r\n\t\t\t\t\t@untestedProjects << projectPath\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def load_active_from_disk\n workdir = Pathname.new(@workdir)\n if workdir.exist?\n workdir.find do |path|\n # symlinks indicate an active version of a resource\n next unless File.symlink?(path)\n\n target = File.readlink(path)\n # the version will be the parent directory\n version = target.split('/')[-2]\n @active[path.relative_path_from(workdir).to_s] = version\n end\n end\n end",
"def restore()\n @inihash = Ini.read_from_file(@path)\n @comment = Ini.read_comment_from_file(@path)\n end",
"def update\n is_valid_project\n $VERBOSE = !options[:verbose].nil?\n name = File.basename(CURR_DIR)\n project_dir = CURR_DIR\n overwrite_config = !options[:overwrite_config].nil?\n version = options[:version]\n unless version == nil or OK_OBD_VERSIONS.include?(version)\n throw \"Specified version \\\"#{version}\\\" isn't supported.\\nTry one of the following:\\n #{OK_OBD_VERSIONS.join(\"\\n \")}\"\n end\n rebuild = !options[:rebuild].nil?\n download_openbd(version, rebuild) unless version.nil?\n update_project(name, version, false, overwrite_config, true) \n display \"#{name} updated to OpenBD #{version}\" unless version.nil?\n end",
"def read\n @resource_paths = Dir.chdir(path) do\n Dir['**/Contents.json'].map { |p| Pathname(p) + '..' }\n end\n @resources = @resource_paths.map do |path|\n Resource.new(self, path)\n end\n self\n end",
"def force_reload_reader\n reload(true)\n target\n end",
"def destination_file_up_to_date?\n return false unless compilation_context.incremental_build?\n\n source_db = compilation_context.source_file_database\n target_db = compilation_context.target_file_database\n\n destination_file_exist? && # destination file must exist\n target_db.up_to_date?(source_path) && # source file must be up-to-date from last build of this target\n source_db.file_stat_for(source_path) == target_db.file_stat_for(source_path)\n end",
"def project?; @is_project || false; end"
] | [
"0.67098427",
"0.66306657",
"0.6172231",
"0.6025915",
"0.5955649",
"0.5888299",
"0.57617193",
"0.57176095",
"0.561057",
"0.56013095",
"0.5600888",
"0.5574852",
"0.5483389",
"0.5468534",
"0.54674596",
"0.54382515",
"0.54281783",
"0.5415009",
"0.54060835",
"0.53618103",
"0.5357357",
"0.53572154",
"0.5336155",
"0.5319953",
"0.53149515",
"0.5301848",
"0.5296045",
"0.5262142",
"0.52474165",
"0.5244439",
"0.5195425",
"0.51947296",
"0.51941675",
"0.5180819",
"0.51639074",
"0.5139175",
"0.5139175",
"0.5129179",
"0.51262593",
"0.5121943",
"0.51160157",
"0.51090807",
"0.51071244",
"0.5103392",
"0.5099528",
"0.5094076",
"0.5086241",
"0.5073721",
"0.5071913",
"0.50616145",
"0.50590205",
"0.50571495",
"0.50119394",
"0.5011448",
"0.4998785",
"0.49792406",
"0.49760768",
"0.49756435",
"0.4966148",
"0.49640715",
"0.4960587",
"0.49464488",
"0.49319667",
"0.48977515",
"0.4892081",
"0.4891268",
"0.4890113",
"0.48873562",
"0.48786485",
"0.48765492",
"0.48727077",
"0.48704615",
"0.48674953",
"0.48601583",
"0.4856955",
"0.48561352",
"0.48473862",
"0.48401302",
"0.4834737",
"0.48285684",
"0.48211414",
"0.48208535",
"0.48099616",
"0.48065758",
"0.48061484",
"0.48014674",
"0.4800256",
"0.47992745",
"0.47992745",
"0.47988975",
"0.47968185",
"0.47950837",
"0.47934037",
"0.47930944",
"0.47811583",
"0.47779953",
"0.47756708",
"0.47688112",
"0.47677082",
"0.47627157",
"0.4759335"
] | 0.0 | -1 |
show all payments of user | def index
@payments = @user.payments.order("date desc").page( params[:page] ).per(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @payments = Payment.all_for_user(current_user)\n end",
"def index\n @payments = @user.payments\n end",
"def index\n if current_user.admin?\n @payments = Payment.order(updated_at: :desc).paginate(page: params[:page], per_page: 12)\n else\n @payments = Payment.order(updated_at: :desc).where(user: current_user).paginate(page: params[:page], per_page: 12)\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @payment = @user.payments.find(params[:id])\n end",
"def user_payments\n @payments = Payment.get_user_payments(current_user.id)\n end",
"def show\n @payment = @user.payments.find(params[:id])\n end",
"def index\n @payment_entries = ReceiptEntry.all.where(\"user_id =?\", current_user.id)\n end",
"def index\n @typepayments = Typepayment.where(user_id: current_user.id)\n end",
"def index\n # #payments are paid orders\n @payments = @user.payments\n render :layout=>\"accounts\"\n end",
"def index\n @payments = Payment.search(attach_owner_user_id)\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payments = Payment.all\n end",
"def index\n @payment_methods = @user.payment_methods.page(params[:page]).per(params[:per])\n render json: @payment_methods\n end",
"def index\n if current_user.has_role?(:admin)\n @payments = Payment.all.order(:created_at).reverse_order\n else\n @payments = current_user.profile.payments.order(:created_at).reverse_order\n end\n end",
"def index\n #@payments = Payment.all\n @payment = Payment.find(params[:id])\n end",
"def index\n @user = User.find(current_user.id)\n @user_payouts = Payout.where(user_id:@user.id)\n end",
"def index\n if logged_in?\n @payments = Payment.all\n else\n redirect_to home_path\n end\n end",
"def show\n @payments = Payment.for_fundraiser(@fundraiser.id).chronological.all\n end",
"def index\n @user = User.find_by_id(params[:user_id])\n unless @user.present?\n flash[:danger] = \"No User Found.\"\n redirect_to root_path\n else\n @payment_txns = @user.payment_txns.where('status in (?)', params[:status]).paginate(:page => params[:page], :per_page => 10)\n @status = params[:status]\n end\n end",
"def index\n @payments = Payment.where client: @client\n end",
"def index\n @paymentts = Paymentt.all\n end",
"def index\n @user_payment_methods = UserPaymentMethod.all\n\n render json: @user_payment_methods\n end",
"def index\n @recieve_payments = RecievePayment.all\n end",
"def index\n @payments = current_student.all_payments.order(created_at: :desc)\n end",
"def payments\n if params['form_payment']\n results = CsApi::Member.update(current_access_token, @current_user.username, params['form_payment'])\n #check for errors!!\n if results['success'].eql?('false')\n flash.now[:error] = results['message']\n else\n flash.now[:notice] = 'Your payment information has been updated.'\n get_account\n end\n end\n # set the member's id for docusign\n @memberId = @account['id']\n @payments = CsApi::Member.payments(current_access_token, @current_user.username)\n @payments.each do |record| \n if record['status'].eql?('Paid')\n @show_paid_section = true\n else \n @show_outstanding_section = true\n end\n end\n @page_title = 'Your Payments and Payment Info'\n respond_to do |format|\n format.html\n format.json { render :json => @payments }\n end\n end",
"def show\n @payments = Payment.where(enterprise_id: current_enterprise.id)\n end",
"def payments\n @session.payments @account_id\n end",
"def index\n @pays = Pay.all\n end",
"def index\n @debt_payments = DebtPayment.all\n end",
"def index\n @user = UserSession.find\n if @user.nil?\n flash[:notice] = \"Please sign in to create a new listing.\"\n redirect_to(:controller => \"user_session\", :action => \"new\")\n end\n \n @payments = Payment.all\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @payments }\n end\n end",
"def index\n @users = User.instructors.all(:include => [:payment_level]).sort_by{|user| user.unpaid_credits_amount * -1}.paginate :page => params[:page],\n :per_page => @per_page\n end",
"def index\n @payments = []\n end",
"def index\n @payment_entries = PaymentEntry.all\n end",
"def index\n @api_payments = Api::Payment.all\n end",
"def payments\n @session.payments @account_id\n end",
"def index\n @transactions = User.find(params[:id])\n end",
"def index\n @title = \"Mes paiements\"\n @description = \"Consulter vos paiements effectués.\"\n\n @payements = current_user.payements.includes(:product)\n end",
"def index\n @provider_payments = ProviderPayment.all\n end",
"def index\n @type_of_payments = TypeOfPayment.all\n end",
"def show\n @payment_records = @pay_roll.payment_records.page(params[:page]).per(10)\n end",
"def index\n @payements = Payement.all\n end",
"def index\n @customer = Customer.find(params[:cust_id])\n @payments = @customer.payments\n end",
"def index\n @payment_records = PaymentRecord.all\n end",
"def index\n @payments = Payment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @payments }\n end\n end",
"def show\n @payment = Payment.find(params[:id])\n index\n end",
"def index\n @type_of_payments = TypeOfPayment.accessible_by(current_ability).order(id: :desc).page params[:page]\n end",
"def index\n @pay_items = PayItem.all\n end",
"def index\n @rent_payments = RentPayment.all\n end",
"def index\n @rent_payments = RentPayment.all\n end",
"def index\n @payment_details = PaymentDetail.all\n end",
"def index\n @payment_requests = PaymentRequest.all\n end",
"def index\n @transactions = current_user.wallet.transactions\n\n end",
"def index\n @debit_payments = DebitPayment.all\n end",
"def index\n @cargapp_payments = CargappPayment.all\n end",
"def index\n @transactions = current_user.transactions\n end",
"def index\n @payments = Payment.order('creation_date DESC').all\n\n if current_login.has_role? :administrator\n @payments = Payment.find_by_sql('select *\nfrom Payments p, (select clinic_id, max(due_date) as d from payments group by clinic_id) s\nwhere p.clinic_id = s.clinic_id and p.due_date = s.d order by payed')\n\n\n \n elsif current_login.has_role? :manager\n logged_user = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @payments = Payment.in_clinic(logged_user.clinic.id).all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @payments }\n end\n end",
"def all_payment_entries\n @ac = ApplicationController.new\n @payments = PaymentFromDestination.find(:all, :order => \"created_at\").reverse!\n end",
"def index\n @pay_methods = PayMethod.all\n end",
"def index\n @propiedads = Propiedad.where(user: current_user)\n end",
"def show\n @payments = Payment.find(params[:id]) \n render json: @payments\n end",
"def show\n @payments = Payment.where(group: current_group).\n where('(from_id = ? AND to_id = ?) OR (from_id = ? AND to_id = ?)', current_diner.id, @diner.id, @diner.id, current_diner.id).\n order(:created_at).\n includes(:from, :to)\n end",
"def index\n @sale_payments = SalePayment.all\n end",
"def index\n @group_payment_items = GroupPaymentItem.all\n end",
"def show\n @transactions = Transaction.where(user_id: params[:id])\n render json: @transactions\n end",
"def index\n @corporate_users = User.get_all_users(current_user).where.not(id: current_user.id)\n @corporate_users = @corporate_users.paginate(:page => params[:page],:per_page => 10).order('id DESC')\n end",
"def index\n @daily_data_payments = DailyDataPayment.all\n end",
"def index\n @payments = Payment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @payments }\n end\n end",
"def index\n @payments = Payment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @payments }\n end\n end",
"def index\n @payment_managers = PaymentManager.all\n end",
"def index\n @pay_periods = PayPeriod.all\n end",
"def index\n @pay_periods = PayPeriod.all\n end",
"def index\n @payment_orders = PaymentOrder.all\n end",
"def index\n @commandes = Commande.where(user_id: current_user.id).all\n end",
"def index\n authorize User\n @users = User.order(admin: :desc).order(active: :desc).order(:plan_id).order(first_name: :asc).order(last_name: :asc).includes(:plan).all.page(params[:page] || 0).per(20)\n\n @stripe_total = 0\n\n User.includes(:plan).each do |user|\n if user.plan\n @stripe_total += user.plan.stripe_plan_amount\n end\n end\n\n end",
"def index\n @payment_plans = PaymentPlan.all\n end",
"def index\n if current_user.is_admin?\n @transactions = Transaction.order('created_at DESC')\n else\n @transactions = current_user.transactions.order('created_at DESC')\n end\n @transactions = @transactions.page(params[:page])\n end",
"def index\n @payment_providers = PaymentProvider.all\n end",
"def index\n @cc_bill_payments = CcBillPayment.all\n end",
"def index\n @main_page = \"Admin\"\n @page_title = \"Pagamentos\"\n @payments = Payment.all\n @payment_status = Payment.statuses\n end",
"def index\n @payments = Array.wrap(payments)\n .map { |payment| Payment.new(payment) }\n .sort_by { |payment| payment.sort_key(:payment_date) }\n\n respond_to do |format|\n format.html { render }\n format.json { render json: payments_json_response }\n end\n end",
"def index\n @users_wallets = Users::Wallet.all\n end",
"def index\n @invoices = Invoice.where(user_id: current_user)\n @orders = Order.where(user_id: current_user)\n @user = current_user\n end",
"def index\n @payments = Payment.all\n \n @unit = current_user.unit\n \n @utility = UtilityCharge.all\n \n @utility_charge = current_user.unit.present? ? current_user.unit.latest_utility_charge : 0\n \n #Find the next month due from the paid_rents Table\n @paid_rent = PaidRent.all\n last_unpaid_rent_for_unit = PaidRent.where(paid: false, unit_id: @unit).first\n @current_due_date = last_unpaid_rent_for_unit.present? ? last_unpaid_rent_for_unit.date_due : nil\n \n #determine if security deposit has been paid and assign it a variable for use in the view \n @security_amount = current_user.unit.present? ? @unit.security_charge : 0\n \n end",
"def index\n if(current_user)\n User.all.each do |x|\n x.update_points\n end\n @users = User.where(paid:true)\n else\n redirect_to root_path\n end\n end",
"def show\n @payment = Payment.find(params[:id])\n end"
] | [
"0.844051",
"0.83171374",
"0.78485864",
"0.78261",
"0.77858174",
"0.7509901",
"0.74950135",
"0.74512434",
"0.72589165",
"0.72369087",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7167777",
"0.7063027",
"0.70618397",
"0.6967966",
"0.6931158",
"0.68981576",
"0.6895816",
"0.68941915",
"0.68935734",
"0.68793863",
"0.6783034",
"0.67814106",
"0.6775293",
"0.6710844",
"0.67014235",
"0.66852117",
"0.6679803",
"0.66795355",
"0.6676987",
"0.6674037",
"0.6662422",
"0.66500926",
"0.66491395",
"0.6639147",
"0.66330004",
"0.6629858",
"0.6624904",
"0.6622055",
"0.6612313",
"0.658865",
"0.65724206",
"0.6568502",
"0.6565259",
"0.6561532",
"0.65419495",
"0.652608",
"0.652608",
"0.6486645",
"0.6477666",
"0.64766157",
"0.6471105",
"0.6464992",
"0.64464206",
"0.6446099",
"0.6443867",
"0.64435476",
"0.6434072",
"0.64298266",
"0.64296436",
"0.6408033",
"0.64055777",
"0.6393172",
"0.6388646",
"0.6387732",
"0.637318",
"0.637318",
"0.63614464",
"0.63476527",
"0.63476527",
"0.6332777",
"0.63218874",
"0.6308106",
"0.6286084",
"0.62857336",
"0.6279847",
"0.6278282",
"0.6271182",
"0.6266157",
"0.62614006",
"0.624672",
"0.62446845",
"0.6237192",
"0.6232535"
] | 0.7927198 | 2 |
Add extension to path if present do not add extra dot before extesion | def filename(id, extension)
path = filepath(id)
return path if extension.nil?
"#{path}.#{extension.gsub(/^\./, '')}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_with_extname(path, options); end",
"def path_with_extname(path, options); end",
"def add_extension(path); end",
"def replace_ext(path, new_ext)\n path.sub(/\\..+$/, '.' + new_ext)\n end",
"def replace_extension path, ext\n base_name = File.basename(path, File.extname(path))\n File.join(File.dirname(path), base_name) + '.' + ext\n end",
"def replace_extname(path, extension)\n path.sub(/#{File.extname(path)[1..-1]}$/, extension)\n end",
"def changeExt(filename, newext) \n\tuseme = filename.dup\n\treturn useme if ['.', '..'].include? filename\n\tif newext != ''\n\t\tnewext = (newext =~ /^\\./) ? newext : (\".\" + newext)\n\tend\n\tuseme.sub!(%r(([^/\\\\])\\.[^./\\\\]*$)) { $1 + newext } || useme + newext\nend",
"def path_with_extension(path)\n return 'index.html'.freeze if path == Spontaneous::SLASH\n return path unless ::File.extname(path).blank?\n \"#{path}.html\"\n end",
"def add_extension_path(path)\n validate_extension(path)\n @options[:extension_paths] ||= []\n @options[:extension_paths] << path\n end",
"def add_ext(str,ext)\n ( str.strip=~/\\.#{ext}$/ ) ? str.strip : \"#{str.strip}.#{ext}\"\n end",
"def add_extension(path, name = T.unsafe(nil)); end",
"def extensionize(fname, ext, opts={})\n extname = File.extname(fname)\n return fname if (extname =~ /\\.?#{ext}$/i) == 0\n fname = fname.gsub(/#{extname}$/, '') if opts[:chomp] == true\n return fname.strip + '.' + ext.to_s.gsub(/^\\./, '')\n end",
"def extname() File.extname(path) end",
"def extname() File.extname(@path) end",
"def change_extension(filepath, new_ext)\n dirname = File.dirname(filepath)\n extname = File.extname(filepath)\n basename = File.basename(filepath, extname)\n File.expand_path(File.join(dirname, basename + '.' + new_ext))\n end",
"def add_extension_path(path)\n raise Error::WebDriverError, \"could not find extension at #{path.inspect}\" unless File.directory?(path)\n\n @extension_paths << path\n end",
"def sub_ext(repl)\n ext = File.extname(@path)\n self.class.new(@path.chomp(ext) + repl)\n end",
"def path_without_ext\n @path_without_ext ||= path.chomp(ext)\n end",
"def chop_extension filename\n filename.sub %r{\\.\\w+$}, \"\"\n end",
"def pure_ext(ext)\n ext = ext.to_s and ext.start_with?('.') ? ext[1..-1] : ext\n end",
"def extension\n @ext ||= ( ( e = File.extname( path ) ).empty? ? nil : e )\n end",
"def changeFileExtensionTo(filename, extension)\n return \"#{File.basename(filename, File.extname(filename))}.#{extension}\"\nend",
"def dotted_ext(ext)\n ext = ext.to_s and (ext.empty? or ext.start_with?('.')) ? ext : \".#{ext}\"\n end",
"def change_extension(file, new_extension)\n file.sub(/\\.[a-zA-Z0-9]+\\z/, new_extension)\n end",
"def normalize_extension(extension)\n extension = extension.to_s\n if extension[/^\\./]\n extension\n else\n \".#{extension}\"\n end\n end",
"def normalize_extension(extension)\n extension = extension.to_s\n if extension[/^\\./]\n extension\n else\n \".#{extension}\"\n end\n end",
"def get_extension(path)\n return path[/^.+(\\.[a-z0-9]+)$/i, 1]\n end",
"def path_and_extension(template_path)\n template_path_without_extension = template_path.sub(/\\.(\\w+)$/, '')\n [template_path_without_extension, $1]\n end",
"def add_extension(path)\n unless File.exist?(path)\n raise Error::WebDriverError, \"could not find extension at #{path.inspect}\"\n end\n\n if File.directory? path\n root = path\n else\n unless %w[.zip .xpi].include? File.extname(path)\n raise Error::WebDriverError, \"expected .zip or .xpi extension, got #{path.inspect}\"\n end\n\n root = ZipHelper.unzip(path)\n end\n\n id = read_id_from_install_rdf(root)\n ext_path = File.join(extensions_dir, id)\n\n FileUtils.rm_rf ext_path\n FileUtils.mkdir_p File.dirname(ext_path), :mode => 0700\n FileUtils.cp_r root, ext_path\n end",
"def ext\n @ext ||= File.extname(path)\n end",
"def extension\n path.split('.').last\n end",
"def extension\n filename = File.extname(self.filename.to_s)\n filename[0] = '' # remove the dot, i.e. (.docx or .pptx)\n filename\n end",
"def strip_ext(path)\n path.rpartition(File.extname(path))[0]\n end",
"def add_suffix filename, suffix\n parts = filename.split(\"\\.\")\n base = parts[0..-2]\n parts2 = base << suffix << parts[-1]\n fn = parts2.join(\".\")\n end",
"def add_suffix filename, suffix\n parts = filename.split(\"\\.\")\n base = parts[0..-2]\n parts2 = base << suffix << parts[-1]\n fn = parts2.join(\".\")\n end",
"def ensure_extension(source, extension)\n if source =~ /^https?:/ || source.end_with?(\".#{extension}\")\n return source\n end\n\n \"#{source}.#{extension}\"\n end",
"def path\n path = @file.sub(File.expand_path(root_path), '')\n\n # if xx.haml (but not xx.html.haml), \n if tilt?\n path = path.sub(/\\.[^\\.]*$/, \"\")\n path += \".#{default_ext}\" unless File.basename(path).include?('.')\n end\n\n path\n end",
"def extname(path)\n File.extname(path)\n end",
"def maybe_convert_extension(ext); end",
"def with_file_extension(name, entry_type)\n return name unless File.extname(name.to_s).empty?\n\n extension = extension_for_type(entry_type)\n extension ? \"#{ name }.#{ extension }\" : name\n end",
"def extname( fn )\n ::File.extname(fn).tr('.', '')\n end",
"def extname? path\n (last_dot_idx = path.rindex '.') && !(path.index '/', last_dot_idx)\n end",
"def ext\n @ext ||= path.split('.').size > 1 ? path.split('.')[-1] : 'html'\n end",
"def ext_path\n path = \"/#{@bucket_name}\"\n path += \"/#{String(@file_name)}\" if @file_name && !@file_name.empty?\n Addressable::URI.escape path\n end",
"def infer_extension\n return if name.nil?\n\n self.extension ||= File.extname(name)\n end",
"def append_filetype string\n return \"#{string}.yay\" unless /\\.yay$/.match(string)\n return string\n end",
"def eponymous_directory_path\n path.sub(ext, '/').sub(/\\/$/, '') + '/'\n end",
"def asset_normalize_extension(kind, source)\n ignore_extension = !APPEND_ASSET_EXTENSIONS.include?(kind.to_s)\n source << \".#{kind}\" unless ignore_extension || source =~ /\\.#{kind}/ || source =~ ABSOLUTE_URL_PATTERN\n source\n end",
"def filename_without_extension\n filename.include?('.') ? filename.split('.')[0..-2].join('.') : filename\n end",
"def basename_without_ext\n if not @basename_without_ext\n @basename_without_ext = File.basename(path, '.*')\n if not @is_default_language\n @basename_without_ext ['.' + @language] = ''\n end\n end\n @basename_without_ext\n end",
"def ext_of(filename)\n filename =~ extension_regex ? $2 : ''\n end",
"def proper_ext?(raw_path)\n path = raw_path.is_a?(Pathname) ? raw_path : Pathname.new(raw_path)\n LokaliseRails.file_ext_regexp.match? path.extname\n end",
"def add_filename_suffix(filename, suffix)\n f = filename.split(File::SEPARATOR)\n # If the filename is '.' or '..' add the suffix to the parent path,\n # otherwise add it to the basename\n i = %w[. ..].include?(f[-1]) ? -2 : -1\n # Split the basename around the file extension and prepend the suffix\n # to the extension\n if f[i]\n file_ext = f[i].rpartition(File.extname(f[i]))\n file_ext[1] = \"#{suffix}#{file_ext[1]}\"\n f[i] = file_ext.join\n end\n # Reconstruct the filename, preserving any trailing path separator\n f.push('') if filename.end_with?(File::SEPARATOR)\n File.join(f)\n end",
"def append_extensions(match, options={})\n unless Find::EXTENSIONS.include?(File.extname(match))\n match = match + '{' + Find::EXTENSIONS.join(',') + '}'\n end\n match\n end",
"def ext\n File.extname(path)\n end",
"def slash_to_dot(path)\n dot = super\n dot.sub!(@useless,'')\n dot=dot[1..-1] if dot[0] == '.'\n dot\n end",
"def tempfile_extension\n # complexity here is due to supporting mangling non-UTF8 strings (e.g. latin-1 filenames with characters that are illegal in UTF-8)\n b = File.basename(@new_resource.path)\n i = b.index(\".\")\n i.nil? ? \"\" : b[i..].scrub\n end",
"def split_extensions(path)\n filename = path.split('/').last\n (filename =~ %r|.+\\.([a-z,A-Z]+)$|) ? $1 : nil\n end",
"def ext_of(filename)\n filename =~ /((\\.[a-z]+)*)$/ ? $1 : ''\n end",
"def extension\n filename = File.extname(self.filename.to_s)\n filename[0] = '' # remove the dot, i.e. (.docx or .pptx)\n filename\n end",
"def ext\n File.extname( fullpath )\n end",
"def add_extension(extension)\n @parts[-1] += extension\n self\n end",
"def ext\n File.extname(@path)\n end",
"def extension\n filename =~ /\\./ ? filename.split('.').last : nil\n end",
"def extension_with_delimiter\n File.extname @filename\n end",
"def basename_without_ext\n @basename_without_ext ||= File.basename(path, \".*\")\n end",
"def extensionless_path(file)\n app.cache.fetch(:extensionless_path, file) do\n path = file.dup\n\n end_of_the_line = false\n while !end_of_the_line\n if !::Tilt[path].nil?\n path = path.sub(File.extname(path), \"\")\n else\n end_of_the_line = true\n end\n end\n\n # If there is no extension, look for one\n if File.extname(path).empty?\n input_ext = File.extname(file)\n \n if !input_ext.empty?\n input_ext = input_ext.split(\".\").last.to_sym\n if app.template_extensions.has_key?(input_ext)\n path << \".#{app.template_extensions[input_ext]}\"\n end\n end\n end\n \n path\n end\n end",
"def dotextension(attachment, style_name)\n ext = extension(attachment, style_name)\n ext.empty? ? ext : \".#{ext}\"\n end",
"def visit_ext?(path)\n @ext_rules.accept?(File.extname(path)[1..-1])\n end",
"def basename_without_ext; end",
"def file_path(append_extension = true)\n\t\tpath = SOLUTION_PATH + folder_name + class_name\n\t\tpath += '.java' if append_extension\n\t\treturn path\n\tend",
"def full_path(*name)\n # @type [Array<String>] Pathname#join only allows Strings\n rel_path = name.map(&:to_s)\n\n # @type [Pathname] Expand the relative path based on the template path provided to the initializer.\n fp = path.join(*rel_path).to_s\n\n # No more processing required if the user provided the file extension in the name.\n return fp unless File.extname(fp).empty?\n\n # No more processing required when a file extension was not provided, and the default file extension is disabled.\n return fp if !default_file_ext || default_file_ext.empty?\n\n # Only add a period if the file doesn't end with a period, or the extension doesn't begin with one.\n sep = default_file_ext[0] == '.' || fp[-1] == '.' ? '' : '.'\n\n # Add the default file extension.\n [fp, default_file_ext].join(sep)\n end",
"def file_ext(filename)\n File.extname( filename ).gsub(\".\", \"\") rescue nil\n end",
"def path\n name + extension\n end",
"def extension\n File.basename(root_path)\n end",
"def file_path(ext = nil)\n return nil unless file_name(ext)\n \"#{self.base_path}/#{file_name(ext)}\"\n end",
"def file_extension(extension = T.unsafe(nil)); end",
"def file_extension; end",
"def file_extension; end",
"def file_extension; end",
"def to_extension\n path = to_path\n return nil unless path\n\n segs = path.split('.')\n segs.length > 1 ? Wgit::Url.new(segs.last) : nil\n end",
"def to_extension\n path = to_path\n return nil unless path\n\n segs = path.split('.')\n segs.length > 1 ? Wgit::Url.new(segs.last) : nil\n end",
"def extension_from_path(path)\n @extensions.find {|e| e.path == path}\n end",
"def asset_output_filename(path, processed_extensions)\n path = Pathname.new(path) if path.is_a?(String)\n\n return path if path.basename.to_s.split('.').length == 2\n\n extension = path.extname\n processed_extensions.map! { |ext| (ext[0] != '.' ? '.' : '') + ext }\n\n if processed_extensions.include?(extension)\n asset_output_filename(path.to_s.sub(/#{extension}\\Z/, ''), processed_extensions)\n else\n path\n end\n end",
"def coverpath(filepath)\n extname = File.extname(filepath)\n filepath.gsub(/#{extname}$/, '.jpg')\n end",
"def process_url_extension(url)\n return url if uses_extension?\n\n url += Silly.html_extensions.include?(ext) ? '.html' : ext\n\n url.gsub(/index|index.html$/, '').gsub(/\\.html$/, '')\n end",
"def make_file_name aExtension, *aWords #:nodoc:\n aWords.join(' ').to_file_name.ext(aExtension)\n end",
"def remove_file_extension(filename)\r\n extensions = [\"TIF\", \"TIFF\", \"JPEG\", \"JPG\", \"PDF\"]\r\n original_file_extension = filename.split('.').last\r\n if extensions.include?(original_file_extension.upcase)\r\n unwanted_string = \".\"+original_file_extension\r\n filename = filename.chomp(unwanted_string)\r\n end\r\n filename\r\n end",
"def real_extension(filename)\n ext = File.extname(filename)\n return ext if ext.empty?\n ext = ext[1, ext.length - 1].sub('.', '_').downcase\n e_s = ext.to_sym\n return ext unless ALT_EXTENSIONS.key?(e_s)\n ALT_EXTENSIONS[e_s].dup\n end",
"def path_without_extentions\n path[/^[^.]+/]\n end",
"def ext_path\n \"/#{@file.bucket}/#{@file.name}\"\n end",
"def add_slash_if_needed(filename)\n CGI::escape(filename[0..0] == '/' ? filename : \"/#{filename}\").gsub('%2F', '/')\n end",
"def process\n self.ext = File.extname(name)\n end",
"def new_ending(sourcefile, type)\n #sourcefile.sub(/\\.[^.]+$/, \".#{type.to_s}\")\n \"#{sourcefile}.#{type.to_s}\"\nend",
"def persp_and_ext_for_basename(path)\n [main_name(path).sub('resource-epo-',''), File.extname(path)]\n end",
"def no_ext(path)\n File.basename(path, \".rb\")\n end",
"def process(name)\n self.ext = File.extname(name)\n end",
"def process(name)\n self.ext = File.extname(name)\n end",
"def process(name)\n self.ext = File.extname(name)\n end",
"def process(name)\n self.ext = File.extname(name)\n end",
"def understands_ext?(path)\n extensions.find{|ext| ext == File.extname(path)}\n end"
] | [
"0.8319581",
"0.8319581",
"0.827129",
"0.8154756",
"0.8091627",
"0.766852",
"0.7534236",
"0.73235595",
"0.73117393",
"0.7291221",
"0.72898513",
"0.71369547",
"0.7105219",
"0.7072652",
"0.70189625",
"0.69333935",
"0.69213",
"0.6872853",
"0.6868919",
"0.6859369",
"0.6759887",
"0.67477894",
"0.67355484",
"0.6729746",
"0.6702812",
"0.6702812",
"0.6695769",
"0.6682541",
"0.66363883",
"0.66324663",
"0.662635",
"0.6610577",
"0.66023535",
"0.65856576",
"0.65856576",
"0.6574299",
"0.655457",
"0.654099",
"0.6536846",
"0.65130407",
"0.6489465",
"0.64881456",
"0.64691126",
"0.64494234",
"0.6429758",
"0.63913035",
"0.6378503",
"0.6377042",
"0.63611853",
"0.635279",
"0.6345929",
"0.63413346",
"0.6324407",
"0.6312026",
"0.63091767",
"0.63083833",
"0.6305668",
"0.6300456",
"0.6284915",
"0.6272786",
"0.6272671",
"0.62668693",
"0.62450105",
"0.6236844",
"0.62364465",
"0.6226887",
"0.62226766",
"0.62214774",
"0.6212671",
"0.6206784",
"0.62052494",
"0.6196941",
"0.6188088",
"0.61855936",
"0.6177112",
"0.6174243",
"0.61718494",
"0.6072978",
"0.6072978",
"0.6072978",
"0.6067324",
"0.6067324",
"0.60508406",
"0.6048598",
"0.60432655",
"0.604106",
"0.6035583",
"0.6031019",
"0.60290176",
"0.6028401",
"0.6023955",
"0.60220486",
"0.5992284",
"0.59863657",
"0.59852177",
"0.5980946",
"0.59738976",
"0.59738976",
"0.59738976",
"0.59738976",
"0.5970094"
] | 0.0 | -1 |
Convert string like `abcdefghi` to `ab/cd/ef/ghi` to represent location on file system | def filepath(id)
tokens = hmac(id).chars.each_slice(2).map(&:join)
result = []
nesting_depth.times { result << tokens.shift }
result << tokens.join
result.join('/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level_down(s)\nreturn s.split(\"/\").insert(-2, \"*\").join(\"/\")\nend",
"def dir_name string\n string.split('/')[0..-2].join('/')\nend",
"def simplify_path(str)\n directory_names = str.split('/')\n stack = Stack.new\n\n directory_names.each do |name|\n next if name == '.' || name.empty?\n next stack.pop if name == '..'\n stack.push(\"/#{name}\")\n end\n\n result = ''\n until stack.empty?\n result.prepend(stack.pop || '')\n end\n result == '' ? '/' : result\nend",
"def unify_path(s)\r\n p = s.frozen? ? s.dup : s\r\n p.gsub!( /\\\\/, '/' )\r\n p = \"#{$1.upcase}/#{$POSTMATCH}\" if p =~ REGEX_DISK\r\n if RUBY_PLATFORM =~ REGEX_CYGWIN\r\n\tif p =~ REGEX_CYGDRIVE\r\n\t p = \"/cygdrive/#{$1.upcase}/#{$POSTMATCH}\" \r\n\telse\r\n\t p.sub!( REGEX_DISK2, '/cygdrive/\\1/' ) if @name == 'PATH'\r\n\tend\r\n end\r\n return p\r\n end",
"def relative_path(from_str, to_str)\n require 'pathname'\n Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s\n end",
"def url_for(str)\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\n end",
"def convert_path(string, direction)\n string = string.dup\n if direction == :decode\n ENCODINGS.each { |k, v| string.gsub!(v.to_s, k.to_s) }\n elsif direction == :encode\n ENCODINGS.each { |k, v| string.gsub!(k.to_s, v.to_s) }\n else\n raise ArgumentError, \"direction is required\"\n end\n string\n end",
"def expand_file_path(a_path_string)\n if a_path_string.start_with? '~'\n a_path_string = \"${HOME}\" + a_path_string[1, a_path_string.size-1]\n end\n\n a_path_string = `echo \"#{a_path_string}\"`.chomp\n\n return a_path_string\nend",
"def uri_path(str)\n str.gsub(%r{[^/]+}n) { uri_segment($&) }\n end",
"def get_Path(initial)\n\tinitial.split(' ',3)[1]\nend",
"def split_path\n to_s.split_path\n end",
"def split_chroot(str)\n if idx = str.index('/')\n host = str[0...idx]\n chroot_path = str[idx..-1]\n\n [host, chroot_path]\n else\n [str, nil]\n end\n end",
"def optimal_path(str)\n return [] if str.empty?\n @str = str\n\n @cache = {}\n return optimal_path_from(0)\nend",
"def uniPath(source)\n source.gsub(/\\\\/, File::SEPARATOR)\nend",
"def canonicalize\n FilePath.new(File.expand_path(to_s))\n end",
"def absolute_url_for(uri, str)\n # TODO: use URI.parse() for better handling?\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \n str)\n end",
"def normalize_path(path)\n path.scan(/%(\\h\\h)/) do |hex, _|\n path = path.gsub(/%#{hex}/, hex.to_i(16).chr)\n end\n path\nend",
"def solution(str)\n if str.size.even?\n res = str.scan(/../)\n else\n str << '_'\n res = str.scan(/../)\n end\n res\nend",
"def path_str\n path.join(\"-\")\n end",
"def get_object(o)\n p = URI.unescape(URI(o.split(\" \")[1]).path)\n return File.join('./',p) # join on the current directory\nend",
"def normalize_path(path); end",
"def normalize_path(path); end",
"def solution(str)\n if str.size.odd? # если не чётное\n str << '_' # то добавить в конец подчёркивание и при разбиении оно будет с подчеркиванием\n str.scan(/../)\n else\n str.scan(/../) # если чётное просто разбить по два\n end\nend",
"def soutai2relative(str)\n {\n '左' => 'L',\n '直' => 'C',\n '右' => 'R'\n }[str] || ''\n end",
"def rto(a, b)\n\tPathname.new(File.join a, '..', b).cleanpath.to_s\nend",
"def klass2file(str)\n\t\t\tstr.split(/::/).map {|c|\n\t\t\t\tc.scan(/[A-Z][a-z0-9]*/).join(\"_\").downcase\n\t\t\t}.join(\"/\")\n\t\tend",
"def get_path(str)\n child_node = @children[str[0]] || raise(NotFound)\n return [child_node.end_of_word?] if str.length == 1\n [child_node.end_of_word?].concat child_node.get_path(str[1..-1])\n end",
"def normalized_path(file); end",
"def format_path(str)\n first_format = str[1..str.length - 2].split('|') # => [ \"['ATL', 'EWR'] \", \" ['SFO', 'ATL']\" ]\n second_format = first_format.map { |e| e[1..e.length - 2] } # => [\"'ATL', 'EWR'\", \"'SFO', 'ATL'\"]\n second_format.map { |e| e.strip.split(',') } # [[\"'ATL'\", \" 'EWR'\"], [\"'SFO'\", \" 'ATL'\"]]\n end",
"def format_path(entry)\n server_path = entry.path\n if base_path && server_path[0,base_path.length] == base_path\n if server_path == base_path\n return \".\"\n elsif server_path[base_path.length,1] == \"/\"\n return server_path[base_path.length + 1, server_path.length - base_path.length - 1]\n elsif base_path == \"/\" && server_path[0,1] == \"/\"\n return server_path[1, server_path.length - 1]\n end\n end\n server_path\n end",
"def solution(str)\n (str + '_').scan /../\nend",
"def format(string)\n return nil if string.nil?\n string.gsub(/%[bBfFpxdD]/) do |s|\n case s\n when '%f' then relative_directory + name\n when '%F' then name\n when '%b' then relative_directory + basename\n when '%B' then basename\n when '%x' then ext\n when '%d' then relative_directory\n when '%D' then directory\n when '%p' then @path\n end\n end\n end",
"def parse_filename(string)\n string.sub(/^\\//, '') #remove leading slash\n end",
"def clean_path(path_str)\n path = Pathname.new(path_str).cleanpath\n if path.absolute?\n return path\n else\n return Pathname.new(\"./#{path}\")\n end\n end",
"def homify f = ''\n if f.length == 0 then @homedir\n else \"#{@homedir}/#{f}\" end\n end",
"def remove_slash(str)\n\t\tarr = str.split('/')\n\t\tret = arr.first\n\t\tarr.delete_at(0)\n\t\tarr.each { |s|\n\t\t\tif s != ''\n\t\t\t\tret += \"/#{s}\"\n\t\t\tend\n\t\t}\n\t\tret\n\tend",
"def package_to_path(str)\n str.to_s.split('.').map{|e| underscore(e) }.join('/')\n end",
"def relative_path(path)\n path.split('/').drop(5).join('/')\nend",
"def smart_slash(input)\n if !(input =~ /\\.\\w+$/)\n input = File.join(input, '/')\n end\n input\n end",
"def split_path; end",
"def path\n return @path.sub(/^\\//,'').sub(/^%2F/,'/')\n end",
"def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end",
"def simplify_path(path)\n return '' if path.empty?\n\n start_with_slash = path[0] == '/'\n stack = []\n stack << '' if start_with_slash\n tokens = path.split('/')\n tokens.each do |token|\n case token\n when '..'\n stack.pop if stack[-1] != ''\n\n when '.', ''\n next\n else\n stack.push token\n end\n end\n\n return '/' if stack.length == 1 && stack[0] == ''\n\n stack.join('/')\nend",
"def expand_path(file_name, dir_string = '/')\n expanded = File.expand_path(file_name, dir_string)\n if RUBY_PLATFORM.match?(/(:?mswin|mingw)/) # only if the platform is Windows\n expanded = expanded[2..-1] # remove the drive letter ('D:')\n end\n expanded\n end",
"def CorrectPath(str)\n missing_count = str.count('?')\n combinations = %w(u d l r).repeated_combination(missing_count).to_a\n\n combinations.each do |comb|\n final = str.dup\n comb.each { |el| final.sub!('?', el) }\n horz_count, vert_count = 0, 0\n\n validity = final.each_char do |dir|\n horz_count += 1 if dir == 'r'\n horz_count -= 1 if dir == 'l'\n vert_count += 1 if dir == 'd'\n vert_count -= 1 if dir == 'u'\n \n break if horz_count < 0 || horz_count > 4\n break if vert_count < 0 || vert_count > 4\n end\n\n next unless validity\n return final if horz_count == 4 && vert_count == 4\n end\nend",
"def normalize_path(path)\n raise if !path.instance_of?(String)\n\n path = path.strip\n if path.size == 0\n path = \"/\"\n end\n if path[0] != \"/\"\n path = \"/\" + path\n end\n return path\n end",
"def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.index(\"//\")\n\n # Makes sure there's a starting slash\n unless new_str[0,1] == '/'\n new_str = '/' + new_str\n end\n\n new_str\n end",
"def path_string\n \"\\#{#{position}}\"\n end",
"def scrub_path(p)\n np = \"\"\n for i in 0..(p.size-1)\n c = p[i]\n if c == '/'\n c = '\\\\'\n end\n np += c\n end\n np\nend",
"def expand_path(file_name, dir_string)\n raise NotImplementedError\n end",
"def relative_path(from, to); end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def pathname(path)\n path = path.tr(\"/\", \"\\\\\") if windows?\n Pathname.new(path)\n end",
"def normalize(input)\n no_dots = remove_dots(input)\n\n final = []\n while i = no_dots.index('..')\n if i == 0\n final << no_dots.shift\n else\n no_dots.delete_at(i-1)\n no_dots.delete_at(i-1)\n end\n end\n\n (final+no_dots).join('/')\nend",
"def convert_glob_to_absolute(glob); end",
"def simplify_path(path)\n stack = []\n result = ''\n\n path.split('/').each do |dir|\n if dir == '' || dir == '.'\n next\n elsif dir == '..'\n stack.pop()\n else\n stack.push(dir)\n end\n end\n\n while stack.length > 0\n result = '/' + stack.pop() + result\n end\n\n return '/' if result == ''\n\n result\nend",
"def simplify_path(path)\n path_tokens = path.split(\"/\").reject{ |x| x.empty? || x == \".\" }\n stack = []\n path_tokens.each{ |x|\n if x == \"..\"\n stack.pop if stack.any?\n else\n stack.push(x)\n end\n }\n\n \"/\" << stack.join(\"/\")\nend",
"def seq2filepath(basedir,seq)\n n = seq.to_s\n basedir+\"/\"+n[0,6]+\"_\"+n[6,6]+\".jpg\"\nend",
"def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end",
"def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end",
"def extract_dirname(input)\n result = extract_path(input).gsub(/\\/[^\\/]+$/, '')\n result != \"\" ? result : \"/\"\n end",
"def shorten2(path)\n p = get(path)\n home = Pa.home2\n\n return p if home.empty?\n\n ret = relative_to2(p, home)\n\n if ret == p\n p\n else\n ret == \".\" ? \"\" : ret\n File.join(\"~\", ret)\n end\n end",
"def convert_path(path)\n return path\n end",
"def file2klass(str)\n\t\t\tstr.split(\"/\").map {|c|\n\t\t\t\tc.split(/_/).collect {|i| i.capitalize }.join(\"\")\n\t\t\t}.join(\"::\")\n\t\tend",
"def sanity(str)\n str.chomp('/')+'/'\n end",
"def sanity(str)\n str.chomp('/')+'/'\n end",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def solution(str)\n (str+\"_\").scan /../\nend",
"def to_absolute_path(file, dir_str)\n Pathname.new(file).absolute? ? file : File.expand_path(file, dir_str)\n end",
"def split_path(str)\n return str.map(&:to_s) if str.is_a?(::Array)\n @delimiter_handler.split_path(str.to_s)\n end",
"def divide_shortpath(shortpath)\n shortpath = shortpath[1..-1] if shortpath[0..0] == '/' # 先頭の'/'はカット\n a = shortpath.split('/')\n\n if (a.size >= 2)\n return a[0], a[1..-1].join('/')\n else\n return a[0], nil\n end\n end",
"def get_parent_id_folder(id)\n if id.to_s.length > 4\n id.to_s[0..id.to_s.length-2]\n else\n id.to_s\n end\nend",
"def decode_slash(string)\n string.gsub('_slash_', '/')\n end",
"def decode_slash(string)\n string.gsub('_slash_', '/')\n end",
"def absolutify url, cd \n url = url.to_s\n # deal w/ bad URLs, already absolute, etc\n begin\n u = URI.parse(url)\n rescue\n # GIGO, no need for alarm\n return url\n end\n\n return url if u.absolute? # http://example.com/about\n c = URI.parse(cd)\n return c.scheme + \"://\" + c.host + url if url.index('/') == 0 # /about\n return cd + url if url.match(/^[a-zA-Z]+/) # about*\n\n # only relative from here on in; ../about, ./about, ../../about\n u_dirs = u.path.split('/')\n c_dirs = c.path.split('/')\n\n # move up the directory until there are no more relative paths\n u.path.split('/').each do |x|\n break unless (x == '' || x == '..' || x == '.')\n u_dirs.shift\n c_dirs.pop unless x == '.'\n end\n return c.scheme + \"://\" + c.host + c_dirs.join('/') + '/' + u_dirs.join('/')\n end",
"def work\n '/' + File.dirname(file)\n end",
"def parse_path(path_chunks)\n path = path_chunks[1]\n subpath_chunks = path.split(\"/\")\n base_dir = subpath_chunks[1]\n remaining_path = subpath_chunks[2..-1].join(\"/\")\n [base_dir, remaining_path]\n end",
"def expandPath(url)\n stack = []\n urlTokens = url.split '/'\n while urlTokens.count > 0\n token = urlTokens.shift\n next if token == '.'\n if token == '..'\n puts 'error: invalid path' and return if stack.count == 0\n stack.pop\n else\n stack.push token\n end\n end\n stack.join('/')\nend",
"def reverse_string_1(string)\n string = string.to_s\n result = ''\n string.scan(/./) { |char| result = char << result }\n result\nend",
"def sanitizeForPath(str)\n # Code from (modified) http://gavinmiller.io/2016/creating-a-secure-sanitization-function/\n # Bad as defined by wikipedia:\n # https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n bad_chars = ['/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ']\n bad_chars.each do |c|\n str.gsub!(c, '_')\n end\n str\nend",
"def pathto id\n str = '%08d' % id\n str = '0' + str if str.length % 2 == 1\n @datapath + '/' + str.scan(/../).join('/')\n end",
"def normalize_path(p) # NOTE BOOTSTRAP: was action::base::escape_windows_path\n p.tr(\"\\\\\", \"/\")\n end",
"def directoryname\n new_parts = @parts[0..-2]\n new_parts[0] = absolute_prefix + new_parts[0]\n FilePath.new(*new_parts).to_s\n end",
"def fully_split_pathname(pathname, accumulator = nil)\n accumulator ||= Array.new\n rest, last = pathname.split\n accumulator << last.to_s\n if rest.to_s == '.'\n return accumulator.reverse\n else\n return fully_split_pathname(rest, accumulator)\n end\n end",
"def reconstruct_path(came_from, current)\n while came_from.include?(current)\n current = came_from[current]\n current.path!\n end\n @start.start!\n @end.end!\n end",
"def extract_basename(input)\n input.to_s.gsub(/^.*\\/([^\\/\\?]+).*$/, '\\1')\n end",
"def file_name(s)\n s.gsub(/[\\s\\\\\\/]/, '_')\n end",
"def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end",
"def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end",
"def chop_path(path, base='.')\n full_base = File.expand_path(base)\n full_path = File.expand_path(path)\n if full_path == full_base\n '.'\n elsif full_path.start_with?(full_base)\n full_path[full_base.size+1..-1]\n else\n full_path\n end\n end",
"def sanitizeForPath(str)\n # Code from (modified) http://gavinmiller.io/2016/creating-a-secure-sanitization-function/\n # Bad as defined by wikipedia:\n # https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n badChars = [ '/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ' ]\n badChars.each do |c|\n str.gsub!(c, '_')\n end\n str\nend",
"def path\n \"%s/%s\" % [dirname, filename]\n end",
"def expand_path path\n dir = File.dirname path\n full_dir = call \"cd #{dir} && pwd\"\n File.join full_dir, File.basename(path)\n end",
"def dirname_up(path)\n path =~ /(.*)\\\\(.*)$/\n\n return $1 || path\n end",
"def get_full_path(sub_path)\n File.join(Dir.pwd, sub_path)\nend",
"def fix_drive_letter(path); end",
"def format_path(path)\n path[1..-1]\n end",
"def store_dir\n prepend1 = model.id.to_s.split('')[8].to_s\n prepend12 = \"#{model.id.to_s.split('')[0].to_s}#{model.id.to_s.split('')[1].to_s}#{model.id.to_s.split('')[2].to_s}\"\n prepend34 = \"#{model.id.to_s.split('')[3].to_s}#{model.id.to_s.split('')[4].to_s}#{model.id.to_s.split('')[5].to_s}\"\n prepend56 = \"#{model.id.to_s.split('')[6].to_s}#{model.id.to_s.split('')[7].to_s}#{model.id.to_s.split('')[8].to_s}\"\n \n case prepend1\n when \"1\", \"5\", \"9\", \"c\"\n \"/mnt/fs/a1/portrait/#{prepend12}/#{prepend34}/#{prepend56}\"\n when \"2\", \"6\", \"0\", \"d\"\n \"/mnt/fs/a2/portrait/#{prepend12}/#{prepend34}/#{prepend56}\"\n when \"3\", \"7\", \"a\", \"e\"\n \"/mnt/fs/a3/portrait/#{prepend12}/#{prepend34}/#{prepend56}\"\n when \"4\", \"8\", \"b\", \"f\"\n \"/mnt/fs/a4/portrait/#{prepend12}/#{prepend34}/#{prepend56}\"\n end\n end",
"def clean_path(directory)\n directory.gsub(/\\/\\//, '/')\n end"
] | [
"0.64209956",
"0.63464165",
"0.6341418",
"0.63336974",
"0.60376376",
"0.58481985",
"0.57632387",
"0.57549554",
"0.57315826",
"0.5699524",
"0.569912",
"0.56402403",
"0.56317985",
"0.5598191",
"0.55802023",
"0.5562177",
"0.5553768",
"0.5551075",
"0.5535505",
"0.55299276",
"0.5524295",
"0.5524295",
"0.5467648",
"0.5457359",
"0.54221696",
"0.54189277",
"0.5408272",
"0.53916115",
"0.5386527",
"0.5375237",
"0.5371847",
"0.53622276",
"0.5340068",
"0.533001",
"0.5317125",
"0.5314421",
"0.5284845",
"0.5281588",
"0.527939",
"0.5275501",
"0.5258808",
"0.52500445",
"0.524676",
"0.5233218",
"0.52263844",
"0.52226794",
"0.521424",
"0.52095604",
"0.52020097",
"0.5185801",
"0.51847386",
"0.518242",
"0.518242",
"0.51801014",
"0.5173162",
"0.5161617",
"0.51594204",
"0.515476",
"0.5147366",
"0.51429695",
"0.51429695",
"0.5142219",
"0.5140313",
"0.5135921",
"0.5134951",
"0.513372",
"0.51314",
"0.5125348",
"0.5125348",
"0.51237744",
"0.51218337",
"0.5116992",
"0.5109222",
"0.5105854",
"0.50849557",
"0.50849557",
"0.5081462",
"0.50786823",
"0.50714904",
"0.5070955",
"0.5070747",
"0.5069168",
"0.506622",
"0.50648004",
"0.5062503",
"0.50604105",
"0.5059594",
"0.50587356",
"0.5057819",
"0.50577956",
"0.50539887",
"0.50527906",
"0.5051457",
"0.50504154",
"0.5050407",
"0.5018638",
"0.5016929",
"0.50146216",
"0.50145245",
"0.50126815",
"0.5010169"
] | 0.0 | -1 |
def like(likeable) return false if likeable.blank? return false if likeable.like_by_user?(self) likeable.push(liked_user_ids: self.id) likeable.inc (likes_count: 1) likeable.touch end def unlike(likeable) return false if likeable.blank? return false if likeable.like_by_user?(self) likeable.pull(liked_user_ids: self.id) likeable.inc (likes_count: 1) likeable.touch end | def populer
# 流行 数据来源来自mysql
# redis 将存储数据
# 数据 包含 post 和 post 喜欢的人
@posts = Post.paginate(:page => params[:page])
render :status => :200,
:json => { :success => 200,
:info => "",
:data => @posts
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def like_by user\n likers << user && change_like_count(1)\n end",
"def unlike(model)\n if self.id != model.id && self.likes?(model)\n\n # this is necessary to handle mongodb caching on collection if unlike is following a like\n model.reload\n self.reload\n\n model.before_unliked_by(self) if model.respond_to?('before_unliked_by')\n model.likers_assoc.where(:like_type => self.class.name, :like_id => self.id).destroy\n model.inc(:liked_count_field, -1)\n model.after_unliked_by(self) if model.respond_to?('after_unliked_by')\n\n self.before_unlike(model) if self.respond_to?('before_unlike')\n self.likes_assoc.where(:like_type => model.class.name, :like_id => model.id).destroy\n self.inc(:likes_count_field, -1)\n self.after_unlike(model) if self.respond_to?('after_unlike')\n\n return true\n else\n return false\n end\n end",
"def is_liked user\n \tLike.find_by(user_id: user_id, post_id: id)\n end",
"def like\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n if current_user.already_dislikes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id ,likeble_type: 'Comment').first\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_likes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end",
"def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end",
"def dislike\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n\n if current_user.already_likes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id,likeble_type: 'Comment').first\n like.like_status = false\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_dislikes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = false\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end",
"def like(model)\n if self.id != model.id && !self.likes?(model)\n\n model.before_liked_by(self) if model.respond_to?('before_liked_by')\n model.likers_assoc.create!(:like_type => self.class.name, :like_id => self.id)\n model.inc(:liked_count_field, 1)\n model.after_liked_by(self) if model.respond_to?('after_liked_by')\n\n self.before_like(model) if self.respond_to?('before_like')\n self.likes_assoc.create!(:like_type => model.class.name, :like_id => model.id)\n self.inc(:likes_count_field, 1)\n self.after_like(model) if self.respond_to?('after_like')\n\n return true\n else\n return false\n end\n end",
"def liked?(user_id)\n !StoryLike.where(story_id: self.id, user_id: user_id).empty?\n end",
"def like_of(likable)\n likes?(likable) ? likes.find_by(:likable_id => likable.id, :likable_type => likable.class.name) : nil\n end",
"def is_liked(comment)\n if Like.where(:likeable => comment ,:user_id => self.id).present?\n Like.where(:likeable => comment ,:user_id => self.id).last.like==true\n end\n end",
"def unlike(obj)\n return unless likes?(obj)\n\n run_hook(:before_unlike, obj)\n Recommendable.redis.srem(Recommendable::Helpers::RedisKeyMapper.liked_set_for(obj.class, id), obj.id)\n Recommendable.redis.srem(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(obj.class, obj.id), id)\n run_hook(:after_unlike, obj)\n\n true\n end",
"def delete_likes\n # Delete user's own likes.\n Like.where(user_id: user.id).delete_all\n # Delete likes on user's posts.\n Like.where('post_id IN (SELECT id FROM posts WHERE user_id = ?)', user.id).delete_all\n end",
"def like(user)\n likes << Like.new(user: user)\n end",
"def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end",
"def like(user)\n likes.create(user: user)\n end",
"def change_like\n user = User.find(params[:id])\n if current_user.likes?(user)\n msg = \"I <span>like</span> this profile\"\n Like.delay.delete_all([\"user_id = ? and likeable_id = ? and likeable_type = ?\", current_user.id, user.id, \"User\"])\n NetworkUpdate.removeLikedUpdate(current_user.id, user.id)\n else\n current_user.like!(user)\n msg = \"Remove <span>like</span>\"\n NetworkUpdate.delay.createLikedUpdate(current_user.id, user.id)\n SneakPeekMailer.delay.like_email(current_user, user)\n end\n render :text => msg\n end",
"def like_toggle\n like = Like.find_by(user: current_user, drink_id: params[:id])\n if like.nil?\n Like.create!(user: current_user, drink_id: params[:id])\n else\n like.destroy\n end\n redirect_to drink_url(params[:id])\n end",
"def already_liked_by?(current_user)\n return false unless current_user\n self.likes.where(:user_id => current_user.id).count > 0\n end",
"def trigger_after_unlike\n likeable.fire_after_unlike(self) if likeable.respond_to?(:fire_after_unlike)\n user.fire_after_unlike(self) if user.respond_to?(:fire_after_unlike)\n end",
"def unlike!\n connection.delete(\"/photos/#{id}/like\")\n true\n end",
"def like\n @comment.liked_by current_user\n end",
"def like_comment(id = nil, user_id = nil)\n comment = Comment.where(:id => id).first\n if not comment.nil?\n #check to make sure user cant like comment more than once\n #users_who_liked is a string which is a comma-separated list of ids of users who like a comment\n\n users = comment.users_who_liked\n if not users.nil?\n users = comment.users_who_liked.split(\",\")\n end\n\n if not user_id.nil? and (users.nil? or not users.include?(user_id.to_s))\n comment.numlikes += 1\n users = users.join(\",\")\n users += \",\" + user_id.to_s\n comment.users_who_liked = users\n comment.save\n return SUCCESS\n end\n end\n return FAILED\n end",
"def already_liked?\n Like.where(user_id: current_user.id, post_id: params[:post_id]).exists?\n end",
"def like\n @pointless = Pointless.find(params[:pointless_id])\n iorn = true\n @pointless.pluids.each do |p|\n puts p.user_id\n if current_user.id == p.user_id\n p.destroy\n iorn = false\n break\n end\n end\n if iorn == true\n @pluid = Pluid.new(user_id: current_user.id, pointless_id: @pointless.id)\n @pluid.save\n @pointless.like = @pointless.like + 1\n else\n @pointless.like = @pointless.like - 1\n end\n @pointless.save\n redirect_to :back\n\n end",
"def user_can_like(user_id)\n\t\t# self makes an object of Post class and tells if a user with user_id: as passed in the function, has a like on this post(like.length == 1)\n\t\tif self.likes.where(user_id: user_id).length == 1\n\t\t\treturn false\n\t\tend\n\n\t\treturn true\n\tend",
"def like_for(likeable)\n if likeable.likes.loaded?\n return likeable.likes.detect{ |like| like.user_id == self.id }\n else\n return Like.where(user_id: self.id, likeable_type: likeable.class.base_class.to_s, likeable_id: likeable.id).first\n end\n end",
"def like_or_dislike\n\t\tresponse.headers['Content-Type'] = 'text/javascript' # Tells Rails/Redis that content is JavaScript\n\t\troom = current_user.room\n\t\tusers = room.users.length\n\t\tcurrent_song = Song.where(currently_playing: true).first\n\t\tlikes = current_song.likes\n\t\tdislikes = current_song.dislikes\n\t\t# --- Increments either like or dislike to all users depending on which is clicked ---\n\t\tif params[:vote] == 'like'\n\t\t\tlikes += 1\n\t\t\tcurrent_song.update_attributes(likes: likes)\n\t\t\t$redis.publish(\"like_or_dislike_#{room.id}\", {vote: 'like', sc_ident: current_song.sc_ident, users: users, likes: likes}.to_json)\n\t\telsif params[:vote] == 'dislike'\n\t\t\tdislikes += 1\n\t\t\tcurrent_song.update_attributes(dislikes: dislikes)\n\t\t\t$redis.publish(\"like_or_dislike_#{room.id}\", {vote: 'dislike', sc_ident: current_song.sc_ident, users: users, dislikes: dislikes}.to_json)\n\t\tend\n\t\t# --- end ---\n\t\trender nothing: true\n\tend",
"def like\n self.likes += 1\n save\n end",
"def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend",
"def unlike!\n new_count = self.like_count - 1\n if new_count < 0\n logger.error \"Song :: #{self.attributes.inspect} unliked by 1 \" <<\n \"would result in negative likes. Defaulting to 0 likes.\"\n new_count = 0\n end\n\n self.like_count = new_count\n self.save\n logger.debug \"Song :: #{self.title} unliked by 1.\"\n end",
"def like\n @dream = Dream.find(params[:id])\n @user = User.find_by_id(session[:remember_token])\n @likee = @dream.user_id\n @dream.rank +=1\n #record the like to 1. update the like btn to unlike btn, & 2. prevent repeated votes\n @like = Like.new(:user_id=>@user.id, :likee_id=>@likee, :dream_id=>params[:id])\n @like.save\n if(@dream.save! && @like.save)\n redirect_to :action=>'show', :id => @dream.id\n else\n flash.now[:error] = \"illegal input!\"\n end\n end",
"def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end",
"def unlike(object)\n if likes.where(:likeable_id => object.id, :likeable_type => object.class.to_s).first.try(:destroy)\n Resque.enqueue RecommendationRefresher, self.id, object.send(:rates_by)\n true\n end\n end",
"def liked?(likeable)\n if likeable.likes.loaded?\n if self.like_for(likeable)\n return true\n else\n return false\n end\n else\n Like.exists?(user_id: self.id, likeable_type: likeable.class.base_class.to_s, likeable_id: likeable.id)\n end\n end",
"def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end",
"def delete_likes\n end",
"def delete_likes\n end",
"def delete_likes\n end",
"def likes\n UserReaction.where(note_id: self.id, like: 1).count\n end",
"def like\n @item = Item.find_by_id(params[:id])\n like_data = Like.find_by_item_id_and_user_id(params[:id],current_user.id)\n if params[:like] == \"true\" or params[:item_card_like] == \"true\"\n if like_data.blank?\n Like.create(:item_id => params[:id],:user_id => current_user.id )\n end\n like = Like.find_by_item_id_and_user_id(params[:id],current_user.id)\n # Send mail if item liked\n ItemMailer.item_liked(@item.id,current_user.id).deliver\n # Activity Feed\n like.create_activity key: @item.id, owner: current_user, recipient: @item.user\n\n elsif params[:remove_item] == \"true\" or like_data\n like_data.destroy\n end\n if params[:remove_item]\n @user = current_user\n @liked_items = @user.liked_items\n if @liked_items.blank?\n search_result = Item.item_search(nil, nil, \"most offered\",nil,nil, 1, session[:user_ll], nil,10)\n @items = search_result.results\n @distance = Item.calculate_distance(@items,session[:user_ll])\n end\n end\n @like_count = Like.where(:item_id => params[:id]).count\n respond_to do |format|\n format.js\n format.html {\n if params[:remove_item]\n redirect_to likes_user_path(@user)\n elsif params[:like]\n redirect_to item_path(@item)\n end\n }\n end\n end",
"def like(user_id)\n UserLike.find_or_create_by(user_id: user_id, feed_id: self.id)\n end",
"def like\n @topic = Topic.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n if @post.not_liked_already?(current_user)\n @post.likes.create(user: current_user)\n redirect_to [@post.topic, @post]\n else\n @post.likes.where(user: current_user).destroy_all\n redirect_to [@post.topic, @post]\n end\n end",
"def like?(post)\n self.likes.where(post_id: post.id.to_s)\n end",
"def liked?(user_id)\n Like.where(user_id: user_id, dog_id: self.id).exists?\n end",
"def user_likes_list?\n Like.exists?(:user_id => current_user, :list_id => @list)\n end",
"def liked_by?(user)\n likes.find_by_user_id(user.id).present?\n end",
"def add_like(uid_of_liker)\n doc = get_document(@docs[:liked_by])\n\n Rails.logger.debug(doc.inspect)\n\n # unless this has already been liked by this person (liking_uid)\n unless doc[:users].include?(uid_of_liker)\n\n # add to front\n doc[:users].unshift(uid_of_liker)\n\n # store the array of uid's\n replace_document(@docs[:liked_by], doc)\n\n # increase the number of unique likes on this radlib\n increase_atomic_count(@docs[:num_likes])\n\n # add to likes_received for the author of this radlib\n author = find_user_by_uid(@uid)\n author.increment_num_likes_received if author\n\n Analytics.analyze_most_popular_radlibs(self)\n Analytics.analyze_user(author)\n true\n end\n\n false\n end",
"def trigger_after_like\n likeable.fire_after_like(self) if likeable.respond_to?(:fire_after_like)\n user.fire_after_like(self) if user.respond_to?(:fire_after_like)\n end",
"def like_dislike\n begin\n @video.update_no_of_likes_dislikes(params[:mt_action])\n UserVideoHistory.update_like_dislike_history(current_user.id, @video.id, params[:like_dislike_status])\n @success = true\n rescue Exception => e\n @success = false\n log_error(e, \"Error occured in like_dislike action of VideosController\")\n end\n end",
"def like(params,userid)\r\n db = connect_non_hash()\r\n likedposts=db.execute(\"SELECT likes.postid FROM likes WHERE userid=(?)\", userid)\r\n likedposts = likedposts.flatten\r\n if likedposts.include? params[\"postid\"].to_i\r\n redirect('/cantliketwice')\r\n else\r\n db.execute(\"INSERT INTO likes(userid, postid) VALUES (?, ?)\", userid, params[\"postid\"])\r\n redirect('/posts')\r\n end\r\n end",
"def save_likes(beers)\n user = current_user\n beers.each do |beer_id|\n user.likes << Like.find_or_create_by_beer_id(beer_id: beer_id)\n end\n user.save\n end",
"def toggle_opinion\n if current_user.nil?\n render(:json=>{:error=>\"First, you need to log in, buddy. Upper right corner.\"}) and return\n else\n @opinion_type = params[:opinion_type] # 'like' or 'dislike'\n @opposite_opinion_type = (@opinion_type=='like' ? 'dislike' : 'like')\n @name = Name.find_by_secret_id(params[:name_id])\n render(:json=>{:error=>\"Yikes! Something went wrong. Try again.\"}) and return unless @name\n @like = @name.likes.find_by_user_id(current_user.id)\n @dislike = @name.dislikes.find_by_user_id(current_user.id)\n @no_prior_opinion = true if (@like.nil? && @dislike.nil?)\n if @like\n @like.destroy\n @name.likes_count-=1\n if @opinion_type=='dislike'\n Dislike.create(:user_id=>current_user.id, :name_id=>@name.id)\n @name.dislikes_count+=1\n end\n end\n if @dislike\n @dislike.destroy\n @name.dislikes_count-=1\n if @opinion_type=='like'\n Like.create(:user_id=>current_user.id, :name_id=>@name.id)\n @name.likes_count+=1\n end\n end\n if @no_prior_opinion\n if @opinion_type=='like'\n Like.create(:user_id=>current_user.id, :name_id=>@name.id)\n @name.likes_count+=1\n elsif @opinion_type=='dislike'\n Dislike.create(:user_id=>current_user.id, :name_id=>@name.id)\n @name.dislikes_count+=1\n end\n end\n @name.save\n render(:json=>(params[:list]=='true' ? \n {:ok=>true} : \n {:ok=>true, :redirect=>true})) and return \n end\n end",
"def like\n @postcomment.liked_by current_user\n redirect_to @urltoredirect\n end",
"def likes\n likers(User).count\n end",
"def liked_by_user?\n\t\tLike.where(user_id: current_user.id, post_id:\n\t \tparams[:post_id]).exists?\n\tend",
"def liked?(post_id)\n Like.where(post_id: post_id, user_id: self.id).exists?\n end",
"def add_like(uid)\n # get the list of users who have liked this fillin\n doc = get_document(@docs[:liked_by])\n \n # unless this has already been liked by this person (liking_uid)\n unless doc[:users].include?(uid)\n # add to list\n doc[:users].unshift(uid)\n \n # store the new list\n replace_document(@docs[:liked_by], doc)\n\n # increase the count of likes for the fillin\n increase_atomic_count(@docs[:num_likes])\n\n return true\n end\n\n false\n end",
"def update\n @like = Like.find(params[:id])\n if current_user.already_likes?(@like.post)\n user_likeship = UserLikeship.find_by_user_id current_user.id, conditions: ['like_id = ?', @like.id]\n user_likeship.destroy\n @like.update_attribute(:count, \"#{@like.count - 1}\")\n else\n user_likeship = UserLikeship.create( like: @like, user: current_user )\n @like.update_attribute(:count, \"#{@like.count + 1}\")\n end\n respond_to do |format|\n format.js\n format.html { redirect_to index_url, notice: 'Like was successfully updated.' }\n end\n end",
"def likes\n\t\t@likes ||= fetch_likes\n\tend",
"def set_post\n @post = Post.find(params[:id])\n @likes = @post.likes\n @liked_by = @likes.find { |like| like.user_id == current_user.id }\n end",
"def like!\n self.like_count = self.like_count + 1\n self.save\n logger.debug \"Song :: #{self.title} liked.\"\n end",
"def create\n @post =Post.find(params[:post_id])\n @liked_post = @post.liked_posts.build(liked_post_params)\n @liked_post.user_id = current_user.id\n if LikedPost.where(user_id:@liked_post.user_id,post_id:@liked_post.post_id,positive:true).count>0\n respond_to do |format|\n LikedPost.where(user_id:@liked_post.user_id,post_id:@liked_post.post_id,positive:true).take.destroy\n if @liked_post.positive==true\n format.html { redirect_to post_path(@post), notice: 'now you dont like it!' }\n else\n if @liked_post.save\n format.html { redirect_to post_path(@post), notice: 'You disliked this post!' }\n format.json { render :show, status: :created, location: post_path(@post) }\n end\n end\n end\n elsif LikedPost.where(user_id:@liked_post.user_id,post_id:@liked_post.post_id,positive:false).count>0\n respond_to do |format|\n LikedPost.where(user_id:@liked_post.user_id,post_id:@liked_post.post_id,positive:false).take.destroy\n if @liked_post.positive==false\n format.html { redirect_to post_path(@post), notice: 'now you dont dislike this post!' }\n else\n if @liked_post.save\n format.html { redirect_to post_path(@post), notice: 'now you like this post!' }\n format.json { render :show, status: :created, location: post_path(@post) }\n end\n end\n end\n else\n respond_to do |format|\n if @liked_post.positive==false\n if @liked_post.save\n format.html { redirect_to post_path(@post), notice: 'you dont like this post!' }\n format.json { render :show, status: :created, location: post_path(@post) }\n end\n else\n if @liked_post.save\n format.html { redirect_to post_path(@post), notice: 'you like this post!' }\n format.json { render :show, status: :created, location: post_path(@post) }\n end\n end\n end\n end\n end",
"def liked_by\n User.where(:id => liked_by_ids)\n end",
"def liked_by\n\t\tcomment = Comment.includes(:liked_by).find_by(id: params[:id])\n\t\t@users = comment.has_been_liked_by\t\t\t\t\t\t\t\t\t\n\tend",
"def add_like(like_name)\n UserLikeLinker.link_user_and_like(self, self.personality.get_new_like(like_name)) \n end",
"def likes?(tweet)\n \ttweet.likes.where(user_id: id).any?\n end",
"def user_likes\n q = \"INNER JOIN liked_info ON users.id = liked_info.user_id WHERE liked_info.thing_id = #{id} AND liked_info.thing_type = 'Serial'\"\n User.joins(q)\n end",
"def decrease_post_like_counter\n Post.find(post_id).decrement(:total_likes_count).save\n end",
"def downvote_and_update(user)\n self.disliked_by user\n self.save\n end",
"def liked_by?(user)\n likers.exists?(user.id)\n end",
"def like\n @micropost = Micropost.find(params[:postid])\n if current_user.nil?\n render text: \"no_login\"\n else\n @micropost.like(current_user.id,@micropost.user.id)\n render text: \"liked\"\n end\n \n end",
"def liked_by? user\n not likes.reject { |like| like.created_by != user }.blank?\n end",
"def like_status(user)\n if !liking?(user)\n return \"like\"\n else\n return \"unlike\"\n end\n end",
"def like\n tweet = Tweet.find(params[:tweet_id]) #id del tweet\n flash[:notice] = \"NO puedes dar dos likes sobre el mismo tweet\" if tweet.likes.pluck(:user_id).include? (current_user.id)\n new_like = Like.create(tweet: tweet, user: current_user)#nos permite crear el like\n redirect_to root_path #redirecciona al index\n end",
"def unlike(obj)\n return unless liked?(obj)\n Recommendations.redis.srem(Recommendations::Helpers::RedisKeyMapper.liked_set_for(obj.class, id), obj.id)\n Recommendations.redis.srem(Recommendations::Helpers::RedisKeyMapper.liked_by_set_for(obj.class, obj.id), id)\n end",
"def set_postlike\n @likes = Like.where(post_id: params[:post_id])\n end",
"def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end",
"def add_like\n post = Post.find(params[:id])\n post.add_like\n render nothing: true\n end",
"def like_params\n params.permit(:id, :likable_id, :likable_type, :user_id)\n end",
"def likes?(user)\n if likes.where(user_id: user.id).any?\n return true\n else\n return false\n end\n end",
"def upvote_and_update(user)\n self.liked_by user\n self.save #trigger set_hotness!\n end",
"def unlike\n @dream = Dream.find(params[:id])\n @user = User.find_by_id(session[:remember_token])\n @dream.rank -=1\n if(@dream.save!)\n @like = @user.likes.find_by_dream_id(params[:id])\n @like.destroy\n redirect_to :action=>'show'\n else\n flash.now[:error] = \"illegal input!\"\n end\n end",
"def like_post!(post)\n likes.create!(epost_id: post.id, like: 1)\n end",
"def like(user)\n comment_vote = CommentVote.new\n comment_vote.comment = self\n comment_vote.user = user\n comment_vote.value = true\n comment_vote.save\n comment_vote\n end",
"def like\n\n @like = @shoe.likes.build(user_id: current_user.id)\n if @like.save\n flash[:notice] = \"You liked this shoe!\"\n redirect_to shoes_path\n else\n flash[:notice] = \"You already liked this shoe!\"\n redirect_to shoes_path\n end\n end",
"def like?(post)\n liked_posts.include?(post)\n end",
"def liked?\n liked_ids = h.current_user.liked_replies.pluck(:id)\n liked_ids.include?(self.id)\n end",
"def dislike\n @comment.disliked_by current_user\n end",
"def dislike\n @book.disliked_by current_user\n redirect_to :back\n end",
"def liked_comments_count\n # Creating comments\n comment_ids = \"SELECT id FROM comments WHERE user_id = :user_id\"\n # Except for self like\n CommentLike.where(\"comment_id IN (#{comment_ids}) AND user_id <> :user_id\", user_id: id).count\n end",
"def dislikes?(object)\n dislikes.exists?(:dislikeable_id => object.id, :dislikeable_type => object.class.to_s)\n end",
"def liked\n likes.map {|like| like.likeable}\n end",
"def comment_like(comment)\n comment_likes.create(comment_id: comment.id)\n end",
"def setLike(value)\n @likes = value\n end",
"def create_likes\n end",
"def create_likes\n end",
"def create_likes\n end",
"def update \n @idea = @agenda.ideas.find(params[:id])\n @like = Like.find_by_sql([\"select * from likes where user_id = ? and agenda_id = ? and idea_id = ?\", current_user.id, @agenda.id, @idea.id])\n if @like.size == 0\n @like_new = Like.new(params[:like])\n @like_new.user_id = current_user.id\n @like_new.agenda_id = @agenda.id\n @like_new.idea_id = @idea.id\n @like_new.save\n if @idea.likes == nil\n @idea.likes = 1\n else\n @idea.likes += 1\n end \n @idea.update_attribute(:likes, @idea.likes)\n redirect_to agenda_path(@agenda)\n else\n flash[:error] = 'You have already liked the idea.'\n redirect_to agenda_path(@agenda)\n end\n end",
"def unlike\n giver_id = current_user.id\n kudo_id = params.require(:kudo_id)\n\n unless (kudo = Kudo.find_by(id: kudo_id))\n return render json: { errors: \"kudo with id #{kudo_id.inspect} could not be found\" }, status: :not_found\n end\n\n unless (like = Like.find_by(kudo_id: kudo_id, giver_id: giver_id))\n return render json: { errors: \"this like doesn't exist\" }, status: :conflict\n end\n\n like.destroy\n \n render json: { deleted: true }, status: :accepted\n end",
"def like\n #@recipe = Recipe.find(params[:id])\n #to like a recipe chef must be logged in as current_user(befor_action) the befor action is to log in\n like = Like.create(like: params[:like], chef: current_user, recipe:@recipe)\n if like.valid?\n flash[:success] = \"Your selection was successful\"\n redirect_to :back\n else\n flash[:danger] = \"You can only like/dislike a recipe once\"\n \n redirect_to :back\n end\n \n end",
"def already_liked?\n Vote.where(author_id: current_user.id, comment_id:\n params[:comment_id]).exists?\n end"
] | [
"0.77496785",
"0.746539",
"0.7444829",
"0.7408665",
"0.7324753",
"0.73113805",
"0.7242246",
"0.7135449",
"0.707977",
"0.70669466",
"0.7051708",
"0.7050466",
"0.7040351",
"0.7026188",
"0.70057744",
"0.69930905",
"0.6938517",
"0.6934798",
"0.69224286",
"0.6916944",
"0.6914971",
"0.6909538",
"0.68762964",
"0.68561655",
"0.68547976",
"0.68403655",
"0.6830361",
"0.6828575",
"0.68165207",
"0.68052804",
"0.6778071",
"0.67742103",
"0.67561144",
"0.67467016",
"0.67394537",
"0.6735448",
"0.6735448",
"0.6735448",
"0.671715",
"0.66992205",
"0.66861564",
"0.66827816",
"0.6663253",
"0.6661503",
"0.6646149",
"0.66460156",
"0.6642563",
"0.66386896",
"0.6621607",
"0.66162",
"0.66017795",
"0.6594797",
"0.65933657",
"0.65916663",
"0.65833193",
"0.6578968",
"0.6573584",
"0.6555848",
"0.6554976",
"0.6554425",
"0.65452117",
"0.65330404",
"0.6522961",
"0.6506704",
"0.65035266",
"0.6499391",
"0.64990413",
"0.6498531",
"0.6494155",
"0.6488533",
"0.6482098",
"0.646278",
"0.6458295",
"0.64513814",
"0.6446338",
"0.6439821",
"0.643879",
"0.6432538",
"0.6426684",
"0.64235514",
"0.641353",
"0.641336",
"0.6412987",
"0.64051086",
"0.6397614",
"0.63868356",
"0.6381224",
"0.63770485",
"0.6363599",
"0.63607675",
"0.6359082",
"0.63501054",
"0.6345772",
"0.6345319",
"0.63450557",
"0.63450557",
"0.63450557",
"0.63352174",
"0.63347423",
"0.6333737",
"0.6331641"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_dog
@dog = Dog.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a list of trusted parameters through. | def dog_params
params.require(:dog).permit(:name, :breed, :age, :neighbor_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
Question 3: Alan wrote the following method, which was intended to show all of the factors of the input number: | def factors(number)
divisor = number
factors = []
begin
factors << number / divisor if number % divisor == 0
divisor -= 1
end until divisor == 0
factors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend",
"def factors_of(num)\n # Write your code here\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend",
"def factors() (1..self).select { |n| (self % n).zero? } end",
"def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend",
"def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend",
"def factors( n )\n p = Primer.ld( n )\n return n if p == n\n factors n.div( p )\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend>0 do \n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n p divisors\nend",
"def factors(number)\n factors = []\n divisor = number\n while divisor > 0 do\n factors << (number / divisor) if number % divisor == 0\n divisor -= 1\n end\n if divisor <= 0\n puts \"Invalid number: no 0's or negatives!\"\n else\n end\n factors\n end",
"def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend",
"def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend",
"def print_factors(number)\n current_number = 1\n while current_number <= number\n puts current_number if is_factor_of(number, current_number)\n current_number += 1\n end\n end",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\n end",
"def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors_for( num )\n facts = []\n (1..(num/2)).each {|divisor| facts << divisor if (num % divisor == 0)}\n facts\nend",
"def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n # TODO: can optimise by only going up to the square of the number\n (1..number).select { |x| number % x == 0 }.count\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |n|\n factors << n if num % n == 0\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n factors\n \nend",
"def factors_of(num)\n (1..num).select{|ele| num % ele == 0}\nend",
"def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def find_factors!\n (1..number).each do |n|\n break if @factors.include?(n)\n if number % n == 0\n @factors << n << (number / n)\n end\n end\n # handle any perfect squares\n\n @factors.uniq!\n end",
"def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end",
"def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n 1.upto(num).select { |x| num % x == 0 }\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if number <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end \n factors\nend",
"def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factors(num)\n (1..num).select{|i| num % i == 0 }\nend",
"def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend",
"def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend",
"def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n if divisors.any?\n divisors\n else\n \"Sorry, can't find factors for negative numbers or zero.\"\n end\nend",
"def factors(num)\n answer = []\n (1...num).each {|i| answer << i if num % i == 0 }\n answer\nend",
"def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend",
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def factors(num)\n (1..num).select { |el| num % el == 0 }\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if divisor <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend",
"def factors(num)\n (1..num).select { |n| num%n == 0}\nend",
"def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend",
"def factors_of(number)\n\t\tprimes, powers = number.prime_division.transpose\n\t\texponents = powers.map{|i| (0..i).to_a}\n\t\tdivisors = exponents.shift.product(*exponents).map do |powers|\n\t\t\tprimes.zip(powers).map{|prime, power| prime ** power}.inject(:*)\n\t\tend\n\t\tdivisors.sort.map{|div| [div, number / div]}\n\tend",
"def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend",
"def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n \n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\ndivisors\nend",
"def at_least_n_factors(numbers, n)\n\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend",
"def factors3(number)\n factors = []\n for n in 1..number do\n factors << number / n if number % n == 0\n end \n factors\nend",
"def proper_factors(n)\n f = []\n 1.step((n/2).to_i, 1).each do |x|\n if n % x == 0\n f.push(x)\n end\n end\n f.sort\nend",
"def factors(number)\n answer = []\n count = 1\n while count < (number + 1)\n result = number % count\n answer << count if result == 0\n count += 1\n end\n puts answer\nend",
"def factors(n)\n\n\t#create an Array\n\tarray = []\n\t\n\t(1..n).each do |num|\n\t\tif (n % num) == 0\n\t\t\tarray.push(num)\n\t\tend\n\tend\n\treturn array\nend",
"def factors(num)\n facs = []\n i = 1\n while i <= num\n if num % i == 0\n facs << i\n end\n i += 1\n end\n facs\nend",
"def factors(num)\n (1..num).select {|x| num % x == 0 }\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor != 0\n # not the cleanest way to do it, will return the same results\n # if we take the abs value of the number, removing the ternary operator\n factors << number / divisor if number % divisor == 0\n divisor > 0 ? divisor -= 1 : divisor += 1\n end\n factors\nend",
"def factors_new(number)\n divisors = []\n dividend = number\n while dividend > 0 \n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\n end\n divisors\nend"
] | [
"0.8378287",
"0.8378287",
"0.8378287",
"0.8201097",
"0.8186601",
"0.8122372",
"0.80807006",
"0.8071275",
"0.8027347",
"0.80248845",
"0.80136937",
"0.80091006",
"0.8004312",
"0.7999205",
"0.79876035",
"0.798218",
"0.79782736",
"0.79654485",
"0.79632527",
"0.7962471",
"0.79591876",
"0.7942096",
"0.7942096",
"0.7942096",
"0.7942096",
"0.7942096",
"0.7942096",
"0.7941604",
"0.79394335",
"0.7939076",
"0.793215",
"0.7928785",
"0.7927399",
"0.7914429",
"0.7907356",
"0.7889991",
"0.7889965",
"0.7888538",
"0.7888538",
"0.7888538",
"0.7888538",
"0.7888538",
"0.7882345",
"0.78812903",
"0.78801364",
"0.7878513",
"0.7878282",
"0.7878149",
"0.7867102",
"0.7861312",
"0.7860255",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78586966",
"0.78476995",
"0.7843556",
"0.7839512",
"0.7834324",
"0.7834248",
"0.78322786",
"0.78281397",
"0.78166485",
"0.7809973",
"0.78078157",
"0.7806282",
"0.7802991",
"0.7798293",
"0.7797334",
"0.7793316",
"0.7793059",
"0.7784313",
"0.77739626",
"0.7760636",
"0.77564526",
"0.7746564",
"0.7746564",
"0.7743338",
"0.7743039",
"0.77414244",
"0.77411306",
"0.7738386",
"0.77314675",
"0.772506",
"0.77209324",
"0.77192855",
"0.77177936",
"0.77166784",
"0.77134854",
"0.77038854"
] | 0.77364075 | 91 |
=begin Alyssa noticed that this will fail if the input is 0, or a negative number, and asked Alan to change the loop. How can you make this work without using begin/end/until? Note that we're not looking to find the factors for 0 or negative numbers, but we just want to handle it gracefully instead of raising an exception or going into an infinite loop. =end | def factors(number)
divisor = number
factors = []
while divisor > 0 do
factors << number / divisor if number % divisor == 0
divisor -= 1
end
factors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n if divisors.any?\n divisors\n else\n \"Sorry, can't find factors for negative numbers or zero.\"\n end\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end",
"def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend",
"def factors(number)\n factors = []\n divisor = number\n while divisor > 0 do\n factors << (number / divisor) if number % divisor == 0\n divisor -= 1\n end\n if divisor <= 0\n puts \"Invalid number: no 0's or negatives!\"\n else\n end\n factors\n end",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if number <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end \n factors\nend",
"def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend",
"def factors(num)\n return nil if num < 0\n return 1 if num == 1\n (1..num).select { |n| num % n == 0}\n\n\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n factors\n \nend",
"def factors(num)\n 1.upto(num).select { |x| num % x == 0 }\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors() (1..self).select { |n| (self % n).zero? } end",
"def factor(number)\r\n i = 1\r\n while i <= number\r\n puts i if number % i == 0\r\n i += 1\r\n end\r\nend",
"def factor(num)\n (1..num).select { |f| (num % f).zero? }\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if divisor <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(num)\n return nil if num <= 0\n return [1] if num == 0\n (1..num).select { |i| (num % i) == 0 }\nend",
"def factors(num)\n (1..num).select{|i| num % i == 0 }\nend",
"def factorial(input)\n if input < 0\n raise ArgumentError.new(\"Factorial of negative number is undefined.\")\n end\n\n result = 1\n\n for i in 1..input\n result *= i\n end\n\n result\nend",
"def factors(num)\n (1..num).select { |el| num % el == 0 }\nend",
"def factors(num)\n (1..num).select {|x| num % x == 0 }\nend",
"def factors(number)\n dividend = number\n divisors = []\n loop do\n break if dividend <= 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n (1..num).select { |n| num%n == 0}\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\ndivisors\nend",
"def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend",
"def divide_by_zero_fail(number) \n while number != nil\n number = number_fail(number) \n if number == '0'\n puts 'You cant divide by 0. Please enter a new number'\n number = gets.chomp\n else \n return number\n end\n end\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors_of(num)\n (1..num).select{|ele| num % ele == 0}\nend",
"def factor(n)\n n /= 2 while n.even?\n i = 3\n while i * i <= n\n n /= i while n % i == 0\n i += 2\n end\n n\nend",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor != 0\n # not the cleanest way to do it, will return the same results\n # if we take the abs value of the number, removing the ternary operator\n factors << number / divisor if number % divisor == 0\n divisor > 0 ? divisor -= 1 : divisor += 1\n end\n factors\nend",
"def factors(number)\n # TODO: can optimise by only going up to the square of the number\n (1..number).select { |x| number % x == 0 }.count\nend",
"def factorial(number)\n if number == nil\n raise ArgumentError, \"Please enter an integer, you've entered nil.\"\n elsif number == 0\n return 1\n elsif number < 0\n raise ArgumentError, \"Please enter a positive number.\"\n end\n\n lesser_number = number - 1\n (number - 2).times do\n number *= lesser_number\n lesser_number -= 1\n end\n\n return number\nend",
"def factors(number)\n dividend = number\n divisors = [] # make an empty array called divisors\n begin\n # if the number / dividend is a whole number add it to the array\n divisors << number / dividend if number % dividend == 0\n # minus 1 from the dividend\n dividend -= 1\n # end when dividend is 0\n end until dividend == 0\n divisors\nend",
"def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend",
"def factorial(number)\n result = 1\n if number < 0\n puts \"number needs to be a positive integer\"\n elsif number != number.to_i\n puts \"number needs to be an integer\"\n elsif number == 0\n return result\n else\n array = []\n while number > 0\n array << number\n number -= 1\n end\n for i in array do\n result = result * i\n end\n end\n return result\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend",
"def factors_of(num) # Define method with one param\n \n i = 1 # To prevent dividing by zero start at one because of future modula expression\n new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement\n \n while i <= num \n \n if num % i == 0 # Parameter entered must be a factor of i since we are cycling through iterations and i is incrementing upwards\n \n new_array << i # Shovel iterations that fulfill logical conditions\n end\n \n i += 1 # Increment up 1 at a time\n end\n return new_array # Prints array after while loop ends; while loop conditions are met\n\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def factorial(number)\n if number < 0\n return \"Error, that is not a positive integer.\"\n else\n counter = number.to_i\n end\n total = 1\n while counter > 0\n total = total*counter\n counter -= 1\n end\n return total\nend",
"def factorial(num)\n if num.class != Fixnum || num < 0 || num > 10079\n raise ArgumentError.new(\"this bad\")\n elsif num == 0\n 1\n else\n answer = 1\n while num > 1\n answer *= num\n num -= 1\n end\n answer\n end\nend",
"def factorial(input)\n if input == 0 \n return 1\n end\n num = input - 1 \n result = input \n \n while num >= 1\n result = result * num\n num -= 1\n end\n return result\nend",
"def factors num\n if num != 1\n #Start with 1 and num as the first factors\n c = 2\n 2.upto(num/2) { |f|\n if num % f == 0\n c += 1\n end\n }\n else\n c = 1\n end\n\n c\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend",
"def factor_primes(num)\n\n return \"Not a valid number\" if num < 2\n\n for divisor in 2..(num - 1)\n while num % divisor == 0 \n (divisor * divisor > num) ? (return num) : (num /= divisor)\n # puts \"The divisor is #{divisor}\"\n # puts \"The new num is #{num}\"\n end\n end\n puts \"only divisible by 1 and itself\"\nend",
"def factorial(number)\n if number < 0\n 'Please check your input number! The given number is a negative number.'\n elsif number == 0\n \"The factorial of #{number} is 1.\"\n else\n result = (1..number).inject(:*)\n \"The factorial of #{number} is #{result}.\"\n end\nrescue StandardError\n 'Error: Please provide integer only!'\nend",
"def factors(n)\n return (1..n).select {|x| n % x == 0}\nend",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend",
"def factorial(number)\n accumulator = 1\n if number.nil?\n raise ArgumentError.new(\"You can't factorialize 'nil.' \")\n elsif\n number == 0 || number == 1\n return 1\n else\n until number == 0 do\n accumulator = number * accumulator\n number -= 1\n end\n end\n return accumulator\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend",
"def factorial(number)\n result = 1\n if number < 0\n puts \"number needs to be a positive integer\"\n elsif number != number.to_i\n puts \"number needs to be an integer\"\n elsif number == 0\n return result\n else\n array = []\n while number > 0\n array << number\n number -= 1\n end\n for i in array do\n result = result * i\n end\n end\n return result\nend",
"def factors(num)\n facs = []\n i = 1\n while i <= num\n if num % i == 0\n facs << i\n end\n i += 1\n end\n facs\nend",
"def check_factor(factor, max_divisor)\n is_factor = true\n \n # Start looping high, since higher numbers are less likely to be factors, so\n # the loop can bail out early if the highest number isn't a factor\n # Only loop down to 2, since everything is divisible by 1\n max_divisor.downto(2).each { |i|\n # Determine factor is evenly divisble by 1\n is_factor = is_factor && (factor % i == 0)\n\n # If factor is not evenly divisible by i, don't bother checking lower nums\n break if !is_factor\n }\n\n # Return whether or not it's a factor\n is_factor\nend",
"def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factorial(number)\n counter = number.to_i - 1\n if number.to_i == 0\n return 1\n else\n while counter > 0\n number = number * counter\n counter = counter - 1\n end\nend\nreturn number\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factorial(number)\n if number < 0\n return \"Error, that is not a positive integer.\"\n else\n counter = number.to_i\n end\n total = 1\n while counter > 0\n total = total*counter\n counter -= 1\n end\n return total\nend",
"def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def prime_factors(n)\r\n num=Math.sqrt(n).round\r\n while num>0\r\n if n%num==0\r\n return num if prime?(num)\r\n end\r\n num-=1\r\n end\r\nend",
"def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n\n factors = []\n # iterate through all nums from 1 to num\n # add to factors if evenly divisible\n # return factors\n\n i = 1\n while i <= num\n factors << i if num % i == 0\n i += 1\n end\n\n factors\n\nend",
"def factorial(number)\n if number\n factorial = 1\n until number == 0\n factorial *= number\n number -= 1\n end\n return factorial \n else\n raise ArgumentError\n end\nend",
"def fact(n)\n if n < 0\n 'Please enter a non-negative integer!' \n elsif n == 0\n 1\n else\n n * fact(n-1)\n end\nend",
"def factorial(number)\n # =begin\n # Pseudo-code here\n # Only accepts a positive number\n # Take number and calculate factorial\n # while number >= 0\n # number*(number-1)*(number-2)*...(1)\n # outputs result\n # =end\n\n if number < 0\n return None\n end\n result = 1\n while number > 1\n result = result * number\n number = number - 1\n end\n return result\nend",
"def factors2(number)\n dividend = number\n divisors = []\n while number > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def factor\n @factor if valid?\n end",
"def factors(number)\n dividend = number\n divisors = []\n while dividend>0 do \n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n p divisors\nend",
"def find_factors(num)\n\t# type here\n\t# change return\n\treturn false\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors1(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend"
] | [
"0.780065",
"0.75567836",
"0.7471524",
"0.73657",
"0.733559",
"0.73110867",
"0.7230983",
"0.71877104",
"0.71671486",
"0.71591777",
"0.71459126",
"0.7145483",
"0.7145483",
"0.7145483",
"0.7145483",
"0.71439445",
"0.71120816",
"0.7086939",
"0.7082828",
"0.70712894",
"0.7069699",
"0.7058665",
"0.7039088",
"0.7026166",
"0.7005387",
"0.698986",
"0.69891524",
"0.6970665",
"0.6948083",
"0.6923532",
"0.69164187",
"0.69164187",
"0.6911126",
"0.6896646",
"0.6894915",
"0.68663645",
"0.68583566",
"0.68491185",
"0.68306077",
"0.6830426",
"0.6812854",
"0.6807544",
"0.6802157",
"0.6781818",
"0.6775828",
"0.67600876",
"0.675672",
"0.67517966",
"0.6748435",
"0.67359596",
"0.67290676",
"0.6726716",
"0.67145705",
"0.6709081",
"0.67017764",
"0.66795063",
"0.6661132",
"0.6648794",
"0.6631491",
"0.66287094",
"0.66243136",
"0.6617391",
"0.66163373",
"0.66151774",
"0.6614761",
"0.6597724",
"0.65947443",
"0.6590971",
"0.6586419",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6578277",
"0.6576858",
"0.65716696",
"0.65665746",
"0.65665746",
"0.65665746",
"0.65665746",
"0.65665746",
"0.6565344",
"0.6563722",
"0.6560159",
"0.6558541",
"0.6551791",
"0.6549356",
"0.6548943",
"0.6542512",
"0.65346175",
"0.65312165"
] | 0.6701012 | 60 |
Bonus 1: What is the purpose of the number % divisor == 0 ? it is the solution to finding the factors of the number that was passed into the method as an argument if number modulo by the divisor is equal to 0, then it is a factor of number is is pushed into the array 'factors' Bonus 2: What is the purpose of the secondtolast line (line 8) in the method (the factors before the method's end)? =begin This is what is the actual return value from the method. Recall that without an explicit return statement in the code, the return value of the method is the last statement executed. If we omitted this line, the code would execute, but the return value of the method would be nil. =end Question 4: =begin Alyssa was asked to write an implementation of a rolling buffer. Elements are added to the rolling buffer and if the buffer becomes full, then new elements that are added will displace the oldest elements in the buffer. She wrote two implementations saying, "Take your pick. Do you like << or + for modifying the buffer?". Is there a difference between the two, other than what operator she chose to use to add an element to the buffer? =end | def rolling_buffer1(buffer, max_buffer_size, new_element)
buffer << new_element
buffer.shift if buffer.size > max_buffer_size
buffer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n dividend = number\n divisors = [] # make an empty array called divisors\n begin\n # if the number / dividend is a whole number add it to the array\n divisors << number / dividend if number % dividend == 0\n # minus 1 from the dividend\n dividend -= 1\n # end when dividend is 0\n end until dividend == 0\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\ndivisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n loop do\n break if dividend <= 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if divisor <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend",
"def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors_new(number)\n divisors = []\n dividend = number\n while dividend > 0 \n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\n end\n divisors\nend",
"def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend",
"def factors_of(num) # Define method with one param\n \n i = 1 # To prevent dividing by zero start at one because of future modula expression\n new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement\n \n while i <= num \n \n if num % i == 0 # Parameter entered must be a factor of i since we are cycling through iterations and i is incrementing upwards\n \n new_array << i # Shovel iterations that fulfill logical conditions\n end\n \n i += 1 # Increment up 1 at a time\n end\n return new_array # Prints array after while loop ends; while loop conditions are met\n\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend>0 do \n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n p divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend == 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\n\n # number % dividend == 0 checks if the number is divisable with no remainder\n # returns the divisors array\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n factors\n \nend",
"def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor != 0\n # not the cleanest way to do it, will return the same results\n # if we take the abs value of the number, removing the ternary operator\n factors << number / divisor if number % divisor == 0\n divisor > 0 ? divisor -= 1 : divisor += 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n break if number <= 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end \n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n puts \"Prime!!\" if divisors.length < 3\n divisors\nend",
"def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend",
"def factors1(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n\n factors = []\n # iterate through all nums from 1 to num\n # add to factors if evenly divisible\n # return factors\n\n i = 1\n while i <= num\n factors << i if num % i == 0\n i += 1\n end\n\n factors\n\nend",
"def factors2(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\nfactors\nend",
"def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0 #Allows you to determine if the result of the division is an integer number (no remainder).\r\n divisor -= 1\r\n end \r\n factors #with no return statement, the last line is returned - in this case we want to return 'factors'\r\nend",
"def factors(num)\n arr = (1..num).to_a\n factored_arr = []\n i = 0\n while i < arr.length\n if num % arr[i] == 0\n factored_arr = factored_arr + arr[i]\n end\n i +=1\n end\n factored_arr\nend",
"def factors2(number)\n dividend = number\n divisors = []\n while number > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def factors_2(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n answer = []\n count = 1\n while count < (number + 1)\n result = number % count\n answer << count if result == 0\n count += 1\n end\n puts answer\nend",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def factors num\n f = Array.new # creates a new array to store factors\n 1.upto(num) do |i|\n f << i if num%i == 0\n end\n f # returns factors\nend",
"def factors() (1..self).select { |n| (self % n).zero? } end",
"def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors_of(num)\n new_arr = []\n\n i = 1\n while i <= num\n if num % i == 0\n new_arr << i\n else \n end \n i += 1\n end\n return new_arr\nend",
"def factors(num)\n arr = []\n (2..num).each do |ele|\n if (num % ele == 0)\n arr << ele\n end\n end\n return arr\nend",
"def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend",
"def factors(num)\n array = []\n (1..num).each do |x|\n if num % x == 0\n array << [x, num/x]\n end\n end\n array\nend",
"def factors(n)\n new_arr = []\n (1...n).each do |i|\n if n % i == 0 \n new_arr << i \n end\n end\n new_arr \nend",
"def factor (num)\n div = 2\n\n while num % div != 0\n div += 1\n end\n\n return [div]\n .concat((num / div > 1) ? factor(num / div) : [])\nend",
"def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend",
"def factors(num)\n facs = []\n i = 1\n while i <= num\n if num % i == 0\n facs << i\n end\n i += 1\n end\n facs\nend",
"def divisible_by(numbers, divisor)\n arr = []\n numbers.each do |x|\n if (x % divisor) == 0\n x >> arr\n end\n end \n return arr\nend",
"def factors(num)\n array = []\n (1..num).each do |number|\n array << number if num % number == 0\n end\n array.sort!\nend",
"def arrayDivisible(n)\n not_factors = []\n numbers_to_check = remove_factors(n)\n\n index1 = 0\n index2 = 1\n\n puts \"index1: #{index1}, index2: #{index2}, array: #{numbers_to_check}\"\n #binding.pry\n\n while index1 <= range_length\n\n while index2 <= range_length\n if numbers_to_check[index2] % numbers_to_check[index1] != 0\n puts \"num1: #{numbers_to_check[index1]}, num2: #{numbers_to_check[index2]}, array: #{numbers_to_check}\"\n not_factors << numbers_to_check[index2]\n puts \"New array: #{not_factors}\"\n puts nil\n end\n index2 += 1\n end\n index1 += 1\n end\n\n not_factors\n\nend",
"def factors(num)\n facs = [1]\n (2..num/2).each{|n| facs.push(n) if num % n == 0 }\n facs.push(num)\nend",
"def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend",
"def factors(num)\n arr = []\n (1..num).each do |el|\n arr << el if num % el == 0\n end\n arr\nend",
"def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend",
"def factors_of(num)\n arr = []\n\n i = 1\n\n while i <= num\n if num % i == 0\n arr << i\n end\n i += 1\n end\n\n return arr\nend",
"def factors_of(num)\n\ti = 1\n \tarry = []\n while i <= num\n if num % i == 0\n arry << i\n end\n\n i += 1\n end\n return arry\nend",
"def factors(num)\n arr = []\n for i in 1..num\n if num%i == 0\n arr << i\n end\n end\n arr\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend",
"def prime_factors(number, array=[])\n 2.upto(number) do |factor|\n if number % factor == 0\n array << factor\n number /= factor\n prime_factors(number, array)\n break\n end\n end\n array\nend",
"def factor(number)\r\n i = 1\r\n while i <= number\r\n puts i if number % i == 0\r\n i += 1\r\n end\r\nend",
"def prime_factors(number, array = [])\n return if number == 1\n 2.upto(number).each do |num|\n if number % num == 0\n number /= num\n array << num\n else\n end\n end\n prime_factors(number, array)\nend",
"def prime_factors(number)\n primes = []\n return primes unless number >= 1\n return primes << number if is_prime?(number)\n # until is_prime?(number) do\n (2..(number / 2)).to_a.each do |num|\n if number % num == 0 # Divisor\n if is_prime?(num)\n primes << num\n number /= num\n return (primes << prime_factors(number)).flatten\n # break\n end\n end\n end\n # end\n # primes << number\nend",
"def factors(num)\n output_arr = []\n\n (1..num).each do |el|\n if num % el == 0\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n \n factors\nend",
"def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend",
"def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def divisor(input_number)\n output_array = []\n while input_number > 2\n output_array << input_number - 1\n input_number -= 1\n end\n output_array\nend"
] | [
"0.74213076",
"0.7376787",
"0.7337819",
"0.73376524",
"0.7262693",
"0.7255039",
"0.7230122",
"0.7221738",
"0.72130316",
"0.7212513",
"0.7212513",
"0.72073495",
"0.72073495",
"0.72073495",
"0.72073495",
"0.72073495",
"0.7193636",
"0.7190664",
"0.71823895",
"0.7172062",
"0.7169709",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.71616286",
"0.7150757",
"0.71368957",
"0.71368176",
"0.7133757",
"0.7086619",
"0.70842034",
"0.7084056",
"0.70814854",
"0.70804346",
"0.70804346",
"0.70804346",
"0.70804346",
"0.70790386",
"0.7078811",
"0.70655364",
"0.70650655",
"0.7062876",
"0.7062876",
"0.7062876",
"0.7062876",
"0.7062876",
"0.7062876",
"0.7045219",
"0.70291644",
"0.7021449",
"0.70030016",
"0.69981056",
"0.6971043",
"0.69668514",
"0.6961396",
"0.6954789",
"0.6871626",
"0.685206",
"0.685094",
"0.6833238",
"0.6827386",
"0.6774058",
"0.67454743",
"0.6734898",
"0.6734898",
"0.6734898",
"0.6715015",
"0.67131716",
"0.6686921",
"0.6655751",
"0.6652071",
"0.66515213",
"0.6649735",
"0.66345453",
"0.66248614",
"0.66189456",
"0.6615502",
"0.661413",
"0.6613323",
"0.6612968",
"0.66035557",
"0.6600465",
"0.65828943",
"0.6567275",
"0.6566632",
"0.6558767",
"0.65491897",
"0.65463364",
"0.65253747",
"0.6521367",
"0.6512096",
"0.64934343",
"0.64865285",
"0.64831513",
"0.64729315",
"0.6472814"
] | 0.0 | -1 |
due to variable scope, a method definitions scope is selfcontained, it cannot access the local variable 'limit' outside of its definition. Therefore moving the variable 'limit' inside of the method 'fib' makes it accessible for use within the scope of the method 'fib' OR..... LS Solution: You can make limit an additional argument to the definition of the fib method and pass it in when you call fib. | def fib(first_num, second_num, limit)
while first_num + second_num < limit
sum = first_num + second_num
first_num = second_num
second_num = sum
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fib(limit)\n\tfib = 0\n\tprev = 1\n\tcurrent = 1\n\twhile current < limit\n\t\tif (prev + current).even? && (current + prev) < limit\n\t\t\tfib += (prev + current)\n\t\tend\n\n\t\told_current = current\n\t\tcurrent = prev + current\n\t\tprev = old_current\n\tend\n\tfib\nend",
"def fib(first_num, second_num, limit) #add to method's scope.\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fibs(limit, n=2)\n\t@a ||= []\n\tf = fib(n)\n\tif f < limit \n\t\t@a.push(f) \n\t\tn += 1\n\t\tfibs(limit, n)\n\telse\n\t\t@a\n\tend\nend",
"def fib(first_num, second_num, limit) #add limit as additional argument\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(limit, first_num, second_num) # made limit an argument to be passed in\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def sumOfFibsBelow(limit)\n\tfibs = fibsBelow(limit)\n\tsum = fibs.inject() {|result, num| result + num}\n\treturn sum\nend",
"def fibsBelow(limit)\n\tfibs = [1, 2]\n\ti = 0\n\tloop do\n\t\tnextFib = fibs[i] + fibs[i+1]\n\t\tbreak if nextFib > limit\n\t\tfibs << nextFib\n\t\ti += 1\n\tend\n\treturn fibs\nend",
"def fib(first_num, second_num, limit=15)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\n end",
"def fib(first_num, second_num, limit = 15)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit = 15)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit = 15)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fibonacci(a, b, count, count_limit)\n if(count >= count_limit)\n return a\n else\n c = a + b\n puts a\n a = b\n b = c\n fibonacci(a, b, count += 1, count_limit)\n end\n\nend",
"def fib(first_num, second_num, limit=15)\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num, limit)\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def find_fibonaccis(limit)\n fib_array = []\n i = 1\n while i <= limit\n first_num = fib_array[i-1] ||= 1 # 1, \n second_num = fib_array[i] ||= 1 # 1, \n result = first_num + second_num\n if result > limit\n break\n end\n fib_array << result\n i += 1\n end\n fib_array\nend",
"def fib(n)\n # your work here\nend",
"def fib(n)\n \nend",
"def fib(first_num, second_num)\n limit = 15\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(n)\n\nend",
"def fib(n)\nend",
"def fib(n)\nend",
"def fib(first_num, second_num)\n limit = 15\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum \nend",
"def fib(first_num, second_num)\n limit = 15\n\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def even_fibonacci(limit, current, prev, sum = 0)\n return sum if current >= limit\n\n sum += current if (current % 2).zero?\n current, prev = current + prev, current\n even_fibonacci(limit, current, prev, sum)\nend",
"def fib(first_num, second_num)\n while second_num < LIMIT\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def limit(limit); end",
"def fib(first_num, second_num)\n limit = 15\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib bound\n\tsum = 0\n\tval1 = 1\n\tval2 = 2\n\ttotal = val2\n\twhile true\n\t\tsum = val1 + val2\n\t\tbreak if sum > bound \n\t\t\n\t\tval1 = val2\n\t\tval2 = sum\n\t\ttotal += sum if sum%2 == 0\n\tend\n\n\ttotal\nend",
"def fib_sequence(limit)\n seq = [1,2]\n while seq[-1] + seq[-2] < limit do\n seq << seq[-1] + seq[-2]\n end\n\n return seq\nend",
"def fib(first_num, second_num)\n limit = 15\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fib(first_num, second_num)\n limit = 15\n while first_num + second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def fibs(n)\nend",
"def even_fib_sum(limit)\n fib0, fib1, sum = 1, 2, 0\n while fib1 <= limit\n sum += fib1 if fib1 % 2 == 0\n fib0, fib1 = fib1, fib0 + fib1\n end\n sum\nend",
"def fibonacci(limit)\n sequence = [0]\n if limit == 0\n puts \"Please enter a number above 0\"\n else\n pattern = 1\n (limit - 1).times do |index|\n sequence << pattern\n pattern = pattern + sequence[index]\n end\n puts \"The first #{limit.to_s} numbers in the Fibonacci Sequence are #{sequence}\"\n end\nend",
"def miter_limit(limit)\n end",
"def generate_fibonacci_numbers(limit)\n i = 1\n fibonacci_numbers = [0, 1]\n sum = 0\n check = true\n\n while check == true do\n if fibonacci_numbers[i - 1] + fibonacci_numbers[i] > limit\n check = false\n else\n fibonacci_numbers << fibonacci_numbers[i - 1] + fibonacci_numbers[i]\n end\n\n i += 1\n end\n\n # return fibonacci_numbers.inspect\n\n fibonacci_numbers.each do |fib|\n if fib % 2 == 0\n sum += fib\n end\n end\n\n return sum\nend",
"def fibonacci_sum(limit)\r\n\tsum = 0\r\n\tprev_term = 1\r\n\tcurr_term = 2\r\n\twhile curr_term <= limit \r\n\t\tsum += curr_term if curr_term % 2 == 0\r\n\t\thold = curr_term\r\n\t\tcurr_term += prev_term\r\n\t\tprev_term = hold\r\n\tend\r\n\treturn sum\r\nend",
"def fibonacci_sequence(limit)\n fib_seq = [1,2]\n i = 1\n until fib_seq[i] + fib_seq[i-1] > limit\n fib_seq.push(fib_seq[i] + fib_seq[i-1])\n i += 1\n end\n\n return fib_seq\nend",
"def even_fibonacci(limit)\r\n start = [1, 2]\r\n\r\n start << start.last(2).inject(:+) while start[-1] < limit\r\n\r\n start.select { |number| number.even? }.inject(:+)\r\nend",
"def problem_2_build_fib_array(upper_limit)\n fib_array = [1,2]\n while fib_array.last < upper_limit\n next_fib = fib_array[-1] + fib_array[-2]\n fib_array << next_fib\n end\n fib_array.pop\n fib_array\nend",
"def fib( max_val )\n x = [ 1, 2 ]\n while\n next_val = ( x[ -2 ] + x[ -1 ] )\n return x if next_val > max_val\n x << next_val \n end\nend",
"def fib2(first_num, second_num)\n limit = 100\n while second_num < limit\n sum = first_num + second_num\n first_num = second_num\n second_num = sum\n end\n sum\nend",
"def sum_of_even_fibonaccis(limit)\n\n holder = [1,2]\n\n while ( holder[-1] + holder[-2] ) < limit\n holder << holder[-1] + holder[-2]\n end\n\n return holder.select { |n| n.even? }.reduce(:+)\n\nend",
"def sum_of_fib_evens(limit_num)\n first = 1\n second = 2\n third = 3\n sum_evens = 2\n \n loop do\n first = second\n second = third\n third = first + second\n break if third > limit_num\n sum_evens += third if third.even?\n end\n \n sum_evens\nend",
"def fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend",
"def fibonnaci_even(limit)\n fibonnacci = [1, 1]\n (1...limit).each { fibonnacci << fibonnacci.last(2).sum }\n fibo_even = fibonnacci.select { |num| num.even? }.sum\nend",
"def even_fibo_summer(upper_limit)\n f0 = 0\n f1 = 1\n sum = 0\n\n loop do\n f2 = f0 + f1\n break if f2 > upper_limit\n # puts \"f2 is #{f2}\"\n sum += f2 if (f2 % 2 == 0)\n # puts \" sum is #{sum}\"\n f0 = f1\n f1 = f2\n # puts \" f0 is now #{f0} and f1 is now #{f1}\"\n end\n\n puts \"The sum of the even-valued Fibonacci numbers under #{upper_limit} is #{sum}.\"\nend",
"def even_fibonacci_sum(limit)\n fibs = [1, 2]\n even_fibs = 2\n next_fib = 3\n\n while next_fib < limit\n fibs << next_fib\n #binding.pry\n even_fibs += next_fib if next_fib % 2 == 0\n next_fib += fibs[-2]\n end\n even_fibs\nend",
"def sum_even_fib(upper_limit)\n sum = fib0 = 0\n fib = 1\n while (fib < upper_limit)\n sum+= fib if(fib%2 == 0)\n temp = fib0\n fib0 = fib\n fib+= temp\n end \n sum\nend",
"def limit=(_arg0); end",
"def limit; end",
"def limit; end",
"def limit; end",
"def fib(n)\r\n if n == 1 then\r\n 10\r\n elsif n == 0 then\r\n 1\r\n else\r\n fib(n - 1) + fib(n - 2)\r\n end\r\nend",
"def even_fibs(limit)\n a = []\n i = 0\n j = 1\n \n while j < limit do\n i, j = j, i+j\n a << j if j.even?\n end\n a.sum\nend",
"def fibonacci(n)\n \nend",
"def fibonacci(n)\n \nend",
"def recursive_fib(number)\n _recursive_fib(number, 0, 1)\nend",
"def fibonacci_adder(num, num2, limit, holder=[])\n holder << num2 if num2.even?\n return holder.inject(:+) if num2 > limit\n fibonacci_adder(num2, num+num2, limit, holder)\nend",
"def fizz_buzz_to(limit)\n 1.upto(limit).each do |num|\n puts fizzbuzz(num)\n end\n end",
"def fib(n)\n if n < 2\n n\n else\n fib(n-1)+fib(n-2)\n end\nend",
"def faster_fib_helper(solution_arr, current, n)\n # n is negative\n if n < 0\n raise ArgumentError, \"Fib(n) error - n must be 0 or larger.\"\n\n # base cases n = 0 , n = 1\n elsif n == 0 || n == 1\n return n\n\n # the other case we check for is if current has reached n\n # this means we can end the recursion\n # and the final return value will be the sum of the previous two\n # elements in solution_arr we have been saving up until this point\n elsif current == n\n # n or current works here since they're the same value at this point\n # can do this because now the array only holds two elements at a time.\n return solution_arr[0] + solution_arr[1]\n\n # otherwise we shovel the next fib # to the back of the array\n # again, found by summing the two elements in front\n # and recusively call the helper with current incremented\n else\n # we only have current number of elements at this point\n # we have to specifically save this in solution_arr, if we do it in the function call\n # it will create a new slot instead of re-using the old one i think\n solution_arr = [solution_arr[1], solution_arr[0] + solution_arr[1]]\n return faster_fib_helper(solution_arr, current + 1, n)\n end\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fibs_sum(n)\n\nend",
"def fib(num)\n return num if num < 2\n return fib(num - 1) + fib(num - 2)\nend",
"def fib(num)\n return num if num <= 1\n fib(num-1) + fib(num-2)\nend",
"def fibonacci_evens_sum(limit)\n arr = []\n a,b = 0,1\n #While 'a' is less than the specified limit, the value of each subsequent number is the sum of the previous two,\n #creating the Fibonacci sequence.\n while a < limit\n arr << a\n a, b = b, a + b\n end\n #When the limit is reached the 'select' method returns an array of 'num's that are divisible by 2 with no remainder.\n #The 'reduce' method then adds every item in the returned array together. The 'reduce' method is just an alias for the \n #'inject' method, so they can be used interchangeably.\n sum = arr.select {|num| num % 2 == 0}.reduce(:+)\n puts sum\nend",
"def firstFibOfLength(limit)\n\tfl, fc = 1,1\n\tcount = 2\n\twhile(fc < limit)\n\t\tfl,fc,count = fc,fl+fc,count + 1\n\tend\n\tcount\nend",
"def fib(first, second)\n temp_sum = first + second\n @sum += temp_sum if (temp_sum % 2).zero?\n first = second\n second = temp_sum\n\n fib(first, second) if temp_sum < 4000000\nend",
"def fizz_buzz_to(limit)\n 1.upto(limit).each do |num|\n puts fizzbuzz(num)\n end\nend",
"def recursive_fib(n, a=0, b=1)\r\n if n == 0\r\n return a\r\n else\r\n recursive_fib(n - 1, b, a + b)\r\n end\r\nend",
"def create_fibonacci(max)\n fibonacci = [1,2]\n until fibonacci[-1] > max\n fibonacci << fibonacci[-1] + fibonacci[-2]\n end\n fibonacci\nend",
"def fib_numbers(max) #max must be integer 1 or greater\n\tfib = [1,1]\n\n\ti = 1\n\n\twhile fib[i] < max\n\t\tfib << fib[i] + fib[i-1]\n\t\ti += 1\n\tend\n\n\tfib.delete_at(fib.length - 1) if fib.last > max\n\n\treturn fib\nend",
"def fizzbuzz_to(limit)\n # a loop that starts at 1 calling the method upto what ever limit is entered, then it will do whats in the block.\n 1.upto(limit) do |i|\n # puts the method fizzbuzz which is the loop code up untill whay ever limit is set. (Im a bit confused about the |i| in this scenario???)\n puts(fizzbuzz(i))\n # ends the loop\n end\n# ends the method\nend",
"def even_fibonacci_sum(limit)\n array = [0, 1]\n array << (array[-1] + array[-2]) while (array[-1] + array[-2]) < limit\n array.select(&:even?).reduce(:+)\nend",
"def find_fibonacci_index_by_length(int)\nlimit = (10**int)/10\nindex = 2\nx = 1\ny = 1\n loop do\n z = x + y\n x = y\n y = z\n index += 1\n break if z > limit \n end\n index\nend",
"def fib(n)\n if (n <= 1) \n return n;\n else\n return fib(n-1)+fib(n-2);\n end\nend",
"def buildFibbs(fibbs, max)\n while fibbs[fibbs.length-1] < max do\n fibbs.push(fibbs[fibbs.length-1] + fibbs[fibbs.length-2])\n end\n fibbs\nend",
"def fib(sum, curr, prev)\n if curr > 4_000_000\n puts sum\n return\n end\n if curr % 2 == 0\n sum += curr\n end\n fib(sum, prev + curr, curr)\nend",
"def fib(n)\n return n if n < 2\n fib(n-1) + fib(n-2)\nend",
"def fib(n)\n if n <= 2\n n\n else\n fib(n-1) + fib(n-2)\n end\nend",
"def fib(num)\n if num == 0\n return 0\n elsif num == 1\n return 1\n else\n result = fib(num - 1) + fib(num - 2)\n return result\n end\nend",
"def quick_fib(n)\n (((1 + Math.sqrt(5)) / 2) ** n / Math.sqrt(5)).round\nend"
] | [
"0.77141535",
"0.75998026",
"0.75298756",
"0.7521875",
"0.74169844",
"0.7308885",
"0.7278338",
"0.7215116",
"0.72035474",
"0.72035474",
"0.72035474",
"0.7145171",
"0.70976573",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.6979531",
"0.68784773",
"0.6834653",
"0.6818013",
"0.68139917",
"0.67560875",
"0.67560875",
"0.6755854",
"0.67533135",
"0.6743219",
"0.6728864",
"0.6706446",
"0.67054605",
"0.67054605",
"0.67054605",
"0.67054605",
"0.6676148",
"0.66747457",
"0.66138744",
"0.66138744",
"0.66138744",
"0.66138744",
"0.65785074",
"0.6554889",
"0.64665306",
"0.64635897",
"0.64594233",
"0.6432838",
"0.6419445",
"0.6408633",
"0.6364541",
"0.63483495",
"0.63248825",
"0.6324748",
"0.6303447",
"0.62954074",
"0.62669444",
"0.6265953",
"0.62559247",
"0.62449706",
"0.6189093",
"0.6171058",
"0.6171058",
"0.6171058",
"0.61555296",
"0.6150574",
"0.61482036",
"0.6142984",
"0.6139208",
"0.6131276",
"0.6093327",
"0.6083129",
"0.6080323",
"0.6077715",
"0.6077715",
"0.6077715",
"0.6077715",
"0.6077715",
"0.60706997",
"0.6066047",
"0.60642743",
"0.6063403",
"0.60624516",
"0.6044717",
"0.60357535",
"0.6032876",
"0.6027881",
"0.6024224",
"0.60169625",
"0.60113955",
"0.60068965",
"0.6005359",
"0.60032266",
"0.5999153",
"0.5997138",
"0.5995964",
"0.5985674"
] | 0.7016519 | 23 |
Did the family's data get ransacked? Why or why not? Yes, it has! Below I have copied LS's explanation I struggled to explain this :/ =begin Spot will find himself in the "dog" house for this one. The family's data is all in shambles now. Why? Remember that in Ruby, what gets passed to a method isn't the value of the object. Under the hood, Ruby passes the object_id of each argument to the method. The method stores these object_id's internally in locally scoped (private to the method) variables (named per the method definition's parameter list). So Spot's demo_hash starts off pointing to the munsters hash. His program could wind up replacing that with some other object id and then the family's data would be safe. In this case, the program does not reassign demo_hash it just uses it asis. So the actual hash object that is being messed with inside of the method IS the munsters hash. =end Question 8: Method calls can take expressions as arguments. Suppose we define a method called rps as follows, which follows the classic rules of rockpaperscissors game, but with a slight twist that it declares whatever hand was used in the tie as the result of that tie. | def rps(fist1, fist2)
if fist1 == "rock"
(fist2 == "paper") ? "paper" : "rock"
elsif fist1 == "paper"
(fist2 == "scissors") ? "scissors" : "paper"
else
(fist2 == "rock") ? "rock" : "scissors"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hashed_rooster\r\nend",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end",
"def game_hash \n\ngame_hash =\t{\n\thome: {\n\t\tteam_name: \"Brooklyn Nets\",\n\t\tcolors: [\"Black\", \"White\"], \t\t\t#array of strings\n\t\tplayers: {\n\t\t\t\"Alan Anderson\": {\n\t\t\t\tnumber: 0, \n\t\t\t\tshoe: 16, \n\t\t\t\tpoints: 22, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 1\n\t\t\t}, \n\n\t\t\t\"Reggie Evans\": {\n\t\t\t\tnumber: 30,\n\t\t\t\tshoe: 14, \n\t\t\t\tpoints: 12, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 12, \n\t\t\t\tblocks: 12, \n\t\t\t\tslam_dunks: 7\n\t\t\t},\n\t\t\t\"Brook Lopez\": {\n\t\t\t\tnumber: 11, \n\t\t\t\tshoe: 17, \n\t\t\t\tpoints: 17, \n\t\t\t\trebounds: 19, \n\t\t\t\tassists: 10, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 15\n\t\t\t},\n\t\t\t\"Mason Plumlee\": {\n\t\t\t\tnumber: 1, \n\t\t\t\tshoe: 19, \n\t\t\t\tpoints: 26, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 6, \n\t\t\t\tsteals: 3, \n\t\t\t\tblocks: 8, \n\t\t\t\tslam_dunks: 5\n\t\t\t},\n\t\t\t\"Jason Terry\": {\n\t\t\t\tnumber: 31, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 19, \n\t\t\t\trebounds: 2, \n\t\t\t\tassists: 2, \n\t\t\t\tsteals: 4, \n\t\t\t\tblocks: 11, \n\t\t\t\tslam_dunks: 1\n\t\t\t}\n\n\t\t}\n\t}, \n\n\taway: {\n\t\tteam_name: \"Charlotte Hornets\",\n\t\tcolors: [\"Turquoise\", \"Purple\"], \t\t#array of strings\n\t\tplayers: {\n\t\t\t\"Jeff Adrien\": {\n\t\t\t\tnumber: 4, \n\t\t\t\tshoe: 18, \n\t\t\t\tpoints: 10, \n\t\t\t\trebounds: 1, \n\t\t\t\tassists: 1, \n\t\t\t\tsteals: 2, \n\t\t\t\tblocks: 7, \n\t\t\t\tslam_dunks: 2\n\t\t\t}, \n\n\t\t\t\"Bismack Biyombo\": {\n\t\t\t\tnumber: 0, \n\t\t\t\tshoe: 16, \n\t\t\t\tpoints: 12, \n\t\t\t\trebounds: 4, \n\t\t\t\tassists: 7, \n\t\t\t\tsteals: 7, \n\t\t\t\tblocks: 15, \n\t\t\t\tslam_dunks: 10\n\t\t\t},\n\t\t\t\"DeSagna Diop\": {\n\t\t\t\tnumber: 2, \n\t\t\t\tshoe: 14, \n\t\t\t\tpoints: 24, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 4, \n\t\t\t\tblocks: 5, \n\t\t\t\tslam_dunks: 5\n\t\t\t},\n\t\t\t\"Ben Gordon\": {\n\t\t\t\tnumber: 8, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 33, \n\t\t\t\trebounds: 3, \n\t\t\t\tassists: 2, \n\t\t\t\tsteals: 1, \n\t\t\t\tblocks: 1, \n\t\t\t\tslam_dunks: 0 \n\t\t\t},\n\t\t\t\"Brendan Haywood\": {\n\t\t\t\tnumber: 33, \n\t\t\t\tshoe: 15, \n\t\t\t\tpoints: 6, \n\t\t\t\trebounds: 12, \n\t\t\t\tassists: 12, \n\t\t\t\tsteals: 22, \n\t\t\t\tblocks: 5, \n\t\t\t\tslam_dunks: 12\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nreturn game_hash\n\nend",
"def game_hash\n game_hash = {home:{team_name:\"Brooklyn Nets\", colors:[\"Black\", \"White\"], players:{\"Alan Anderson\"=>{number: 0, shoe: 16, points: 22, rebounds: 12, assists: 12, steals: 3, blocks: 1, slam_dunks: 1},\n \"Reggie Evans\"=>{number: 30, shoe: 14, points: 12, rebounds: 12, assists: 12, steals: 12, blocks: 12, slam_dunks: 7},\n \"Brook Lopez\"=>{number: 11, shoe: 17, points: 17, rebounds: 19, assists: 10, steals: 3, blocks: 1, slam_dunks: 15},\n \"Mason Plumlee\"=>{number: 1, shoe: 19, points: 26, rebounds: 12, assists: 6, steals: 3, blocks: 8, slam_dunks: 5},\n \"Jason Terry\"=>{number: 31, shoe: 15, points: 19, rebounds: 2, assists: 2, steals: 4, blocks: 11, slam_dunks: 1}}},\n away:{team_name:\"Charlotte Hornets\", colors:[\"Turquoise\", \"Purple\"], players:{\"Jeff Adrien\"=>{number: 4, shoe: 18, points: 10, rebounds: 1, assists: 1, steals: 2, blocks: 7, slam_dunks: 2},\n \"Bismak Biyombo\"=>{number: 0, shoe: 16, points: 12, rebounds: 4, assists: 7, steals: 7, blocks: 15, slam_dunks: 10},\n \"DeSagna Diop\"=>{number: 2, shoe: 14, points: 24, rebounds: 12, assists: 12, steals: 4, blocks: 5, slam_dunks: 5},\n \"Ben Gordon\"=>{number: 8, shoe: 15, points: 33, rebounds: 3, assists: 2, steals: 1, blocks: 1, slam_dunks: 0},\n \"Brendan Haywood\"=>{number: 33, shoe: 15, points: 6, rebounds: 12, assists: 12, steals: 22, blocks: 5, slam_dunks: 12}}}}\n game_hash\nend",
"def game_hash\n\t#game_hash = \n\t{\n\t\thome: {\n\t\t\tteam_name: \"Brooklyn Nets\",\n\t\t\tcolors: [\"Black\", \"White\"],\n\t\t\tplayers: {\n\t\t\t\t\"Alan Anderson\" => {\n\t\t\t\t\tnumber: 0,\n\t\t\t\t\tshoe: 16,\n\t\t\t\t\tpoints: 22,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 1\n\t\t\t\t},\n\t\t\t\t\"Reggie Evans\" => {\n\t\t\t\t\tnumber: 30,\n\t\t\t\t\tshoe: 14,\n\t\t\t\t\tpoints: 12,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 12,\n\t\t\t\t\tblocks: 12,\n\t\t\t\t\tslam_dunks: 7\n\t\t\t\t},\n\t\t\t\t\"Brook Lopez\" => {\n\t\t\t\t\tnumber: 11,\n\t\t\t\t\tshoe: 17,\n\t\t\t\t\tpoints:17,\n\t\t\t\t\trebounds: 19,\n\t\t\t\t\tassists: 10,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 15\n\t\t\t\t},\n\t\t\t\t\"Mason Plumlee\" => {\n\t\t\t\t\tnumber: 1,\n\t\t\t\t\tshoe: 19,\n\t\t\t\t\tpoints: 26,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 6,\n\t\t\t\t\tsteals: 3,\n\t\t\t\t\tblocks: 8,\n\t\t\t\t\tslam_dunks: 5\n\t\t\t\t},\n\t\t\t\t\"Jason Terry\" => {\n\t\t\t\t\tnumber: 31,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 19,\n\t\t\t\t\trebounds: 2,\n\t\t\t\t\tassists: 2,\n\t\t\t\t\tsteals: 4,\n\t\t\t\t\tblocks: 11,\n\t\t\t\t\tslam_dunks: 1\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\taway: {\n\t\t\tteam_name: \"Charlotte Hornets\",\n\t\t\tcolors: [\"Turquoise\", \"Purple\"],\n\t\t\tplayers: {\n\t\t\t\t\"Jeff Adrien\" => {\n\t\t\t\t\tnumber: 4,\n\t\t\t\t\tshoe: 18,\n\t\t\t\t\tpoints: 10,\n\t\t\t\t\trebounds: 1,\n\t\t\t\t\tassists: 1,\n\t\t\t\t\tsteals: 2,\n\t\t\t\t\tblocks: 7,\n\t\t\t\t\tslam_dunks: 2\n\t\t\t\t},\n\t\t\t\t\"Bismak Biyombo\" => {\n\t\t\t\t\tnumber: 0,\n\t\t\t\t\tshoe: 16,\n\t\t\t\t\tpoints: 12,\n\t\t\t\t\trebounds: 4,\n\t\t\t\t\tassists: 7,\n\t\t\t\t\tsteals: 7,\n\t\t\t\t\tblocks: 15,\n\t\t\t\t\tslam_dunks: 10\n\t\t\t\t},\n\t\t\t\t\"DeSagna Diop\" => {\n\t\t\t\t\tnumber: 2,\n\t\t\t\t\tshoe: 14,\n\t\t\t\t\tpoints: 24,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 4,\n\t\t\t\t\tblocks: 5,\n\t\t\t\t\tslam_dunks: 5\n\t\t\t\t},\n\t\t\t\t\"Ben Gordon\" => {\n\t\t\t\t\tnumber: 8,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 33,\n\t\t\t\t\trebounds: 3,\n\t\t\t\t\tassists: 2,\n\t\t\t\t\tsteals: 1,\n\t\t\t\t\tblocks: 1,\n\t\t\t\t\tslam_dunks: 0\n\t\t\t\t},\n\t\t\t\t\"Brendan Haywood\" => {\n\t\t\t\t\tnumber: 33,\n\t\t\t\t\tshoe: 15,\n\t\t\t\t\tpoints: 6,\n\t\t\t\t\trebounds: 12,\n\t\t\t\t\tassists: 12,\n\t\t\t\t\tsteals: 22,\n\t\t\t\t\tblocks: 5,\n\t\t\t\t\tslam_dunks: 12\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nend",
"def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0, \n shoe: 16, \n points: 22, \n rebounds: 12, \n assists: 12, \n steals: 3, \n blocks: 1, \n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30, \n shoe: 14, \n points: 12, \n rebounds: 12, \n assists: 12, \n steals: 12, \n blocks: 12, \n slam_dunks: 7\n }, \n \"Brook Lopez\" => {\n number: 11, \n shoe: 17, \n points: 17, \n rebounds: 19, \n assists: 10, \n steals: 3, \n blocks: 1, \n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1, \n shoe: 19, \n points: 26, \n rebounds: 12, \n assists: 6, \n steals: 3, \n blocks: 8, \n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31, \n shoe: 15, \n points: 19, \n rebounds: 2, \n assists: 2, \n steals: 4, \n blocks: 11, \n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4, \n shoe: 18, \n points: 10, \n rebounds: 1, \n assists: 1, \n steals: 2, \n blocks: 7, \n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0, \n shoe: 16, \n points: 12, \n rebounds: 4, \n assists: 7, \n steals: 7, \n blocks: 15, \n slam_dunks: 10\n }, \n \"DeSagna Diop\" => {\n number: 2, \n shoe: 14, \n points: 24, \n rebounds: 12, \n assists: 12, \n steals: 4, \n blocks: 5, \n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8, \n shoe: 15, \n points: 33, \n rebounds: 3, \n assists: 2, \n steals: 1, \n blocks: 1, \n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33, \n shoe: 15, \n points: 6, \n rebounds: 12, \n assists: 12, \n steals: 22, \n blocks: 5, \n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash \n stats = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: ['Black', 'White'],\n players: [\n {'Alan Anderson' => { number: 0, shoe: 16, points: 22, rebounds: 12, assists: 12, steals: 3, blocks: 1, slam_dunks: 1}},\n {'Reggie Evans' => { number: 30, shoe: 14, points: 12, rebounds: 12, assists: 12, steals: 12, blocks: 12, slam_dunks: 7}},\n {'Brook Lopez' => { number: 11, shoe: 17, points: 17, rebounds: 19, assists: 10, steals: 3, blocks: 1, slam_dunks: 15}},\n {'Mason Plumlee' => { number: 1, shoe: 19, points: 26, rebounds: 11, assists: 6, steals: 3, blocks: 8, slam_dunks: 5}},\n {'Jason Terry' => { number: 31, shoe: 15, points: 19, rebounds: 2, assists: 2, steals: 4, blocks: 11, slam_dunks: 1}}\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: ['Turquoise', 'Purple'],\n players: [\n {'Jeff Adrien' => { number: 4, shoe: 18, points: 10, rebounds: 1, assists: 1, steals: 2, blocks: 7, slam_dunks: 2}},\n {'Bismack Biyombo' => { number: 0, shoe: 16, points: 12, rebounds: 4, assists: 7, steals: 22, blocks: 15, slam_dunks: 10}},\n {'DeSagna Diop' => { number: 2, shoe: 14, points: 24, rebounds: 12, assists: 12, steals: 4, blocks: 5, slam_dunks: 5}},\n {'Ben Gordon' => { number: 8, shoe: 15, points: 33, rebounds: 3, assists: 2, steals: 1, blocks: 1, slam_dunks: 0}},\n {'Kemba Walker' => { number: 33, shoe: 15, points: 6, rebounds: 12, assists: 12, steals: 7, blocks: 5, slam_dunks: 12}}\n ]\n }\n }\nend",
"def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash\n game_hash = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismack Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Kemba Walker\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def test_dynamic_palisades_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. dynamic_palisades_search}\n end",
"def test_matzburgh_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=3\n ruby_rush.real_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.matzburgh_search}\n end",
"def game_hash\n game = {\n home: {\n team_name: \"Brooklyn Nets\",\n colors:[\"Black\", \"White\"],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name:\"Charlotte Hornets\",\n colors:[\"Turquoise\", \"Purple\"] ,\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash\n {\n :home => {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n :away => {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismack Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Kemba Walker\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend",
"def game_hash\n game_hash = { :home => { :team_name => \"Brooklyn Nets\", \n :colors => [\"Black\", \"White\"], \n :players => { :alan_anderson => { :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 },\n :reggie_evans => { :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7 },\n :brook_lopez => { :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 },\n :mason_plumlee => { :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 },\n :jason_terry => { :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 }\n }\n }, \n\n :away => { :team_name => \"Charlotte Hornets\", \n :colors => [\"Turquoise\", \"Purple\"], \n :players => { :jeff_adrien => { :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 },\n :bismak_biyombo => { :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10 },\n :desagna_diop => { :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5 },\n :ben_gordon => { :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0 },\n :brendan_haywood => { :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12 }\n }\n } \n }\n return game_hash\nend",
"def game_hash\n{\n\t:home => {\n\t\t:team_name => \"Brooklyn Nets\",\n\t\t:colors => [\"Black\", \"White\"],\n\t\t:players => {\n\t\t\t\"Alan Anderson\" => {\n\t\t\t\t:number => 0,\n\t\t\t\t:shoe => 16,\n\t\t\t\t:points => 22,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 1\n\t\t\t},\n\t\t\t\"Reggie Evans\" => {\n\t\t\t\t:number => 30,\n\t\t\t\t:shoe => 14,\n\t\t\t\t:points => 12,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 12,\n\t\t\t\t:blocks => 12,\n\t\t\t\t:slam_dunks => 7\n\t\t\t},\n\t\t\t\"Brook Lopez\" => {\n\t\t\t\t:number => 11,\n\t\t\t\t:shoe => 17,\n\t\t\t\t:points => 17,\n\t\t\t\t:rebounds => 19,\n\t\t\t\t:assists => 10,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 15\n\t\t\t},\n\t\t\t\"Mason Plumlee\" => {\n\t\t\t\t:number => 1,\n\t\t\t\t:shoe => 19,\n\t\t\t\t:points => 26,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 6,\n\t\t\t\t:steals => 3,\n\t\t\t\t:blocks => 8,\n\t\t\t\t:slam_dunks => 5\n\t\t\t},\n\t\t\t\"Jason Terry\" => {\n\t\t\t\t:number => 31,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 19,\n\t\t\t\t:rebounds => 2,\n\t\t\t\t:assists => 2,\n\t\t\t\t:steals => 4,\n\t\t\t\t:blocks => 11,\n\t\t\t\t:slam_dunks => 1\n\t\t\t}\n\t\t}\n\t},\n\t:away => {\n\t\t:team_name => \"Charlotte Hornets\",\n\t\t:colors => [\"Turquoise\", \"Purple\"],\n\t\t:players => {\n\t\t\t\"Jeff Adrien\" => {\n\t\t\t\t:number => 4,\n\t\t\t\t:shoe => 18,\n\t\t\t\t:points => 10,\n\t\t\t\t:rebounds => 1,\n\t\t\t\t:assists => 1,\n\t\t\t\t:steals => 2,\n\t\t\t\t:blocks => 7,\n\t\t\t\t:slam_dunks => 2\n\t\t\t},\n\t\t\t\"Bismack Biyombo\" => {\n\t\t\t\t:number => 0,\n\t\t\t\t:shoe => 16,\n\t\t\t\t:points => 12,\n\t\t\t\t:rebounds => 4,\n\t\t\t\t:assists => 7,\n\t\t\t\t:steals => 7,\n\t\t\t\t:blocks => 15,\n\t\t\t\t:slam_dunks => 10\n\t\t\t},\n\t\t\t\"DeSagna Diop\" => {\n\t\t\t\t:number => 2,\n\t\t\t\t:shoe => 14,\n\t\t\t\t:points => 24,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 4,\n\t\t\t\t:blocks => 5,\n\t\t\t\t:slam_dunks => 5\n\t\t\t},\n\t\t\t\"Ben Gordon\" => {\n\t\t\t\t:number => 8,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 33,\n\t\t\t\t:rebounds => 3,\n\t\t\t\t:assists => 2,\n\t\t\t\t:steals => 1,\n\t\t\t\t:blocks => 1,\n\t\t\t\t:slam_dunks => 0\n\t\t\t},\n\t\t\t\"Brendan Haywood\" => {\n\t\t\t\t:number => 33,\n\t\t\t\t:shoe => 15,\n\t\t\t\t:points => 6,\n\t\t\t\t:rebounds => 12,\n\t\t\t\t:assists => 12,\n\t\t\t\t:steals => 22,\n\t\t\t\t:blocks => 5,\n\t\t\t\t:slam_dunks => 12\n\t\t\t}\n\t\t}\n\t}\n}\nend",
"def game_hash\n #binding.pry\n hash = Hash.new\n hash[:home] = {:team_name => \"Brooklyn Nets\", :colors => [\"Black\", \"White\"], :players => {\"Alan Anderson\" =>\n {:number => 0, :shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1}, \"Reggie Evans\" => {:number => 30, :shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7}, \"Brook Lopez\" => {:number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15}, \"Mason Plumlee\" => {:number => 1, :shoe => 19, :points => 26, :rebounds => 12, :assists => 6, :steals => 3, :blocks => 8, :slam_dunks => 5}, \"Jason Terry\" => {:number => 31, :shoe => 15, :points => 19, :rebounds => 2, :assists => 2, :steals => 4, :blocks => 11, :slam_dunks => 1}}}\n hash[:away] = {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe =>18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n \n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},\n \"Ben Gordon\" => {:number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists => 2, :steals => 1, :blocks => 1, :slam_dunks => 0 },\n \"Brendan Haywood\" => {:number => 33, :shoe => 15, :points => 6, :rebounds => 12, :assists => 12, :steals => 22, :blocks => 5, :slam_dunks => 12}}}\n hash\nend",
"def game_hash \n hash = {:home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {:team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismack Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Kemba Walker\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\n \nend",
"def local_spares\n #super.merge(:rear_shock => rear_shock)\n {:rear_shock => rear_shock}\n end",
"def game_hash\n # puts \"#2 World\"\n # binding.pry\n\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n }, {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n }, {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n }, {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n }, {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n }, {\n player_name: \"Bismak Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n }, {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n }, {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n }, {\n player_name: \"Brendan Haywood\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\n end",
"def build_a_bear(name, age, fur, clothes, special_power)\n #declares a variable with a string assignment and includes string interpolation of first parameter of method\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #declares a variable with an array assignment & includes name & age parameters\n demographics = [name, age]\n #declares a variable with a string assignment & includes string interpolation of special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n #declares a hash with 6 key-value pairs\n built_bear = {\n #creates key-value pair\n 'basic_info' => demographics,\n #creates key-value pair\n 'clothes' => clothes,\n #creates key-value pair\n 'exterior' => fur,\n #creates key-value pair\n 'cost' => 49.99,\n #creates key-value pair in which the value is an array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #creates key-value pair\n 'is_cuddly' => true,\n }\n #the value of the built_bear hash is being returned\n return built_bear\n #closes the method\nend",
"def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime. My\n # memoizing the hash value that was reduced to 12%.\n return @hash unless @hash.nil?\n @hash = @value.hash ^ @suit.hash\n end",
"def rushing\n @rushing ||= if response[\"rushing\"]\n response[\"rushing\"] = parse_out_hashes response[\"rushing\"]\n Sportradar::Api::Football::StatPack::Rushing.new(response[\"rushing\"])\n end\n end",
"def game_hash\n\tgame_hash = {\n\t\t:home => {\n\t\t\t:team_name => \"Brooklyn Nets\",\n\t\t\t:colors => [\"Black\", \"White\"],\n\t\t\t:players => {\n\t\t\t\t\"Alan Anderson\" => {:number => 0, \n\t\t\t\t\t\t\t\t\t:shoe => 16, \n\t\t\t\t\t\t\t\t\t:points => 22,\n\t\t\t\t\t\t\t\t\t:rebounds => 12,\n\t\t\t\t\t\t\t\t\t:assists => 12,\n\t\t\t\t\t\t\t\t\t:steals => 3,\n\t\t\t\t\t\t\t\t\t:blocks => 1,\n\t\t\t\t\t\t\t\t\t:slam_dunks => 1\n\t\t\t\t},\n\t\t\t\t\"Reggie Evans\" =>{:number => 30,\n\t\t\t\t\t\t\t\t :shoe => 14,\n\t\t\t\t\t\t\t\t :points => 12,\n\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t\t :steals => 12,\n\t\t\t\t\t\t\t\t :blocks => 12,\n\t\t\t\t\t\t\t\t :slam_dunks => 7\n\n\t\t\t\t},\n\t\t\t\t\"Brook Lopez\" => {:number => 11,\n\t\t\t\t\t\t\t\t :shoe => 17,\n\t\t\t\t\t\t\t :points => 17,\n\t\t\t\t\t\t\t :rebounds => 19,\n\t\t\t\t\t\t\t\t :assists => 10,\n\t\t\t\t\t\t\t :steals => 3,\n\t\t\t\t\t\t\t\t :blocks => 1,\n\t\t\t\t\t\t\t\t :slam_dunks => 15\n\n\t\t\t\t},\n\t\t\t\t\"Mason Plumlee\" => {:number => 1,\n\t\t\t\t\t\t\t\t\t:shoe => 19,\n\t\t\t\t\t\t\t\t\t:points => 26,\n\t\t\t\t\t\t\t\t\t:rebounds => 12,\n\t\t\t\t\t\t\t\t\t:assists => 6,\n\t\t\t\t\t\t\t :steals => 3,\n\t\t\t\t\t\t\t\t :blocks => 8,\n\t\t\t\t\t\t\t\t :slam_dunks => 5\n\t\t\t\t},\n\t\t\t\t\"Jason Terry\" => {:number => 31,\n\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t :points => 19,\n\t\t\t\t\t\t\t\t :rebounds => 2,\n\t\t\t\t\t\t\t\t :assists => 2,\n\t\t\t\t\t\t\t :steals => 4,\n\t\t\t\t\t\t\t\t :blocks => 11,\n\t\t\t\t\t\t\t\t :slam_dunks => 1\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t:away => {\n\t\t\t:team_name => \"Charlotte Hornets\",\n\t\t\t:colors => [\"Turquoise\", \"Purple\"],\n\t\t\t:players => {\n\t\t\t\t\"Jeff Adrien\" => {:number => 4,\n\t\t\t\t\t\t\t\t :shoe => 18,\n\t\t\t\t\t\t\t\t :points => 10,\n\t\t\t\t\t\t\t\t :rebounds => 1,\n\t\t\t\t\t\t\t\t :assists => 1,\n\t\t\t\t\t\t\t :steals => 2,\n\t\t\t\t\t\t\t\t :blocks => 7,\n\t\t\t\t\t\t\t\t :slam_dunks => 2\n\t\t\t\t},\n\t\t\t\t\"Bismak Biyombo\" => {:number => 0,\n\t\t\t\t\t\t\t\t\t :shoe => 16,\n\t\t\t\t\t\t\t\t\t :points => 12,\n\t\t\t\t\t\t\t\t\t :rebounds => 4,\n\t\t\t\t\t\t\t\t\t :assists => 7,\n\t\t\t\t\t\t\t :steals => 7,\n\t\t\t\t\t\t\t\t :blocks => 15,\n\t\t\t\t\t\t\t\t :slam_dunks => 10\n\t\t\t\t},\n\t\t\t\t\"DeSagna Diop\" => {:number => 2,\n\t\t\t\t\t\t\t\t :shoe => 14,\n\t\t\t\t\t\t\t\t :points => 24,\n\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t :steals => 4, \n\t\t\t\t\t\t\t\t :blocks => 5,\n\t\t\t\t\t\t\t\t :slam_dunks => 5\n\t\t\t\t},\n\t\t\t\t\"Ben Gordon\" => {:number => 8,\n\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t :points => 33,\n\t\t\t\t\t\t\t\t :rebounds => 3,\n\t\t\t\t\t\t\t\t :assists => 2,\n\t\t\t\t\t\t\t :steals => 1,\n\t\t\t\t\t\t\t\t :blocks => 1,\n\t\t\t\t\t\t\t\t :slam_dunks => 0\n\t\t\t\t},\n\t\t\t\t\"Brendan Haywood\" => {:number => 33,\n\t\t\t\t\t\t\t\t\t :shoe => 15,\n\t\t\t\t\t\t\t\t\t :points => 6,\n\t\t\t\t\t\t\t\t\t :rebounds => 12,\n\t\t\t\t\t\t\t\t\t :assists => 12,\n\t\t\t\t\t\t\t \t :steals => 22,\n\t\t\t\t\t\t\t\t \t :blocks => 5,\n\t\t\t\t\t\t\t\t \t :slam_dunks => 12\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nend",
"def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => \"0\",\n :shoe => \"16\",\n :points => \"22\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"3\",\n :blocks => \"1\",\n :slam_dunks => \"1\"\n },\n \"Reggie Evans\" => {\n :number => \"30\",\n :shoe => \"14\",\n :points => \"12\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"12\",\n :blocks => \"12\",\n :slam_dunks => \"7\"\n },\n \"Brook Lopez\" => {\n :number => \"11\",\n :shoe => \"17\",\n :points => \"17\",\n :rebounds => \"19\",\n :assists => \"10\",\n :steals => \"3\",\n :blocks => \"1\",\n :slam_dunks => \"15\"\n },\n \"Mason Plumlee\" => {\n :number => \"1\",\n :shoe => \"19\",\n :points => \"26\",\n :rebounds => \"12\",\n :assists => \"6\",\n :steals => \"3\",\n :blocks => \"8\",\n :slam_dunks => \"5\"\n },\n \"Jason Terry\" => {\n :number => \"31\",\n :shoe => \"15\",\n :points => \"19\",\n :rebounds => \"2\",\n :assists => \"2\",\n :steals => \"4\",\n :blocks => \"11\",\n :slam_dunks => \"1\"\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {\n :number => \"4\",\n :shoe => \"18\",\n :points => \"10\",\n :rebounds => \"1\",\n :assists => \"1\",\n :steals => \"2\",\n :blocks => \"7\",\n :slam_dunks => \"2\"\n },\n \"Bismak Biyombo\" => {\n :number => \"0\",\n :shoe => \"16\",\n :points => \"12\",\n :rebounds => \"4\",\n :assists => \"7\",\n :steals => \"7\",\n :blocks => \"15\",\n :slam_dunks => \"10\"\n },\n \"DeSagna Diop\" => {\n :number => \"2\",\n :shoe => \"14\",\n :points => \"24\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"4\",\n :blocks => \"5\",\n :slam_dunks => \"5\"\n },\n \"Ben Gordon\" => {\n :number => \"8\",\n :shoe => \"15\",\n :points => \"33\",\n :rebounds => \"3\",\n :assists => \"2\",\n :steals => \"1\",\n :blocks => \"1\",\n :slam_dunks => \"0\"\n },\n \"Brendan Haywood\" => {\n :number => \"33\",\n :shoe => \"15\",\n :points => \"6\",\n :rebounds => \"12\",\n :assists => \"12\",\n :steals => \"22\",\n :blocks => \"5\",\n :slam_dunks => \"12\"\n }\n }\n }\n }\nend",
"def game_hash\n {\n :home => {\n :team_name=> \"Brooklyn Nets\",\n :colors=> [\"Black\", \"White\"],\n :players=> [\n {\n :name=> \"Alan Anderson\",\n :number=>0,\n :shoe=>16,\n :points=>22,\n :rebounds=>12,\n :assists=>12,\n :steals=>3,\n :blocks=>1,\n :slam_dunks=>1,\n },\n {\n :name=> \"Reggie Evans\",\n :number=>30,\n :shoe=>14,\n :points=>12,\n :rebounds=>12,\n :assists=>12,\n :steals=>12,\n :blocks=>12,\n :slam_dunks=>7,\n },\n {\n :name=> \"Brook Lopez\",\n :number=>11,\n :shoe=>17,\n :points=>17,\n :rebounds=>19,\n :assists=>10,\n :steals=>3,\n :blocks=>1,\n :slam_dunks=>15,\n },\n {\n :name=> \"Mason Plumlee\",\n :number=>1,\n :shoe=>19,\n :points=>26,\n :rebounds=>12,\n :assists=>6,\n :steals=>3,\n :blocks=>8,\n :slam_dunks=>5,\n },\n {\n :name=> \"Jason Terry\",\n :number=>31,\n :shoe=>15,\n :points=>19,\n :rebounds=>2,\n :assists=>2,\n :steals=>4,\n :blocks=>11,\n :slam_dunks=>1,\n },\n ],\n },\n\n :away => {\n :team_name=> \"Charlotte Hornets\",\n :colors=> [\"Turquoise\", \"Purple\"],\n :players=> [\n {\n :name=> \"Jeff Adrien\",\n :number=>4,\n :shoe=>18,\n :points=>10,\n :rebounds=>1,\n :assists=>1,\n :steals=>2,\n :blocks=>7,\n :slam_dunks=>2,\n },\n {\n :name=> \"Bismak Biyombo\",\n :number=>0,\n :shoe=>16,\n :points=>12,\n :rebounds=>4,\n :assists=>7,\n :steals=>7,\n :blocks=>15,\n :slam_dunks=>10,\n },\n {\n :name=> \"DeSagna Diop\",\n :number=>2,\n :shoe=>14,\n :points=>24,\n :rebounds=>12,\n :assists=>12,\n :steals=>4,\n :blocks=>5,\n :slam_dunks=>5,\n },\n {\n :name=> \"Ben Gordon\",\n :number=>8,\n :shoe=>15,\n :points=>33,\n :rebounds=>3,\n :assists=>2,\n :steals=>1,\n :blocks=>1,\n :slam_dunks=>0,\n },\n {\n :name=> \"Brendan Haywood\",\n :number=>33,\n :shoe=>15,\n :points=>6,\n :rebounds=>12,\n :assists=>12,\n :steals=>22,\n :blocks=>5,\n :slam_dunks=>12,\n },\n ],\n }\n}\nend",
"def game_hash\n hash = {\n home: {\n team_name: \"Brooklyn Nets\" ,\n colors: ['Black', 'White'],\n players: {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n\n away: {\n team_name: \"Charlotte Hornets\" ,\n colors: [\"Turquoise\", \"Purple\"],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n}\nend",
"def test_Hash_InstanceMethods_rassoc\n\t\th = {'a'=>100, 'b'=>200, 'c'=>100 }\n\t\tassert_equal(['a',100], h.rassoc(100))\n\t\tassert_equal(['b',200], h.rassoc(200))\n\tend",
"def game_hash\n{\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n}\nend",
"def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\",\"White\"],\n :players => {\n \"Alan Anderson\": {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\": {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\": {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \"Mason Plumlee\": {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\": {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\",\"Purple\"],\n :players => {\n \"Jeff Adrien\": {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\": {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\": {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\": {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Brendan Haywood\": {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend",
"def hash\n @rank.hash ^ @suit.hash\n end",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\n \"Black\",\n \"White\"\n ],\n players: {\n \"Alan Anderson\" => {\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n \"Reggie Evans\" => {\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n \"Brook Lopez\" => {\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n \"Mason Plumlee\" => {\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n \"Jason Terry\" => {\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n }\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\n \"Turquoise\",\n \"Purple\"\n ],\n players: {\n \"Jeff Adrien\" => {\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n \"Bismak Biyombo\" => {\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n },\n \"DeSagna Diop\" => {\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n \"Ben Gordon\" => {\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n \"Brendan Haywood\" => {\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n }\n }\n }\nend",
"def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :name => \"Bismack Biyombo\", \n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :name => \"DeSagna Diop\", \n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n}\nend",
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nHeading from a to a\n Found no rubies or fake rubies in a.\n Found no rubies or fake rubies in a.\nAfter 3 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend",
"def game_hash\n {\n :home => {\n :team_name => 'Brooklyn Nets',\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n }, \n {\n :name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 \n },\n {\n :name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [ \n {\n :name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n }, \n {\n :name => \"Bismak Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n \n },\n {\n :name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :name => \"Brendan Haywood\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n },\n ] \n }\n }\nend",
"def game_hash \n {home: \n {team_name: \"Brooklyn Nets\", colors: [\"Black\", \"White\"], \n players: {:AlanAnderson=> \n {player_name: \"Alan Anderson\", number: \"0\", shoe: \"16\", points: \"22\", \n rebounds: \"12\", assists: \"12\", steals: \"3\", blocks: \"1\", slam_dunks: \"1\"}, \n :ReggieEvans=> {player_name: \"Reggie Evans\", number: \"30\", shoe: \"14\", points: \"12\", \n rebounds: \"12\", assists: \"12\", steals: \"12\", blocks: \"12\", slam_dunks: \"7\"}, \n :BrookLopez=> {player_name: \"Brook Lopez\", number: \"11\", shoe: \"17\", points: \"17\", \n rebounds: \"19\", assists: \"10\", steals: \"3\", blocks: \"1\", slam_dunks: \"15\"},\n :MasonPlumlee=> {player_name: \"Mason Plumlee\", number: \"1\", shoe: \"19\", points: \"26\", \n rebounds: \"12\", assists: \"6\", steals: \"3\", blocks: \"8\", slam_dunks: \"5\"},\n :JasonTerry=> {player_name: \"Jason Terry\", number: \"31\", shoe: \"15\", points: \"19\", \n rebounds: \"2\", assists: \"2\", steals: \"4\", blocks: \"11\", slam_dunks: \"1\"}\n }}, \naway: \n {team_name: \"Charlotte Hornets\", colors: [\"Turquoise\", \"Purple\"], \n players: {:JeffAdrien=> \n {player_name: \"Jeff Adrien\", number: \"4\", shoe: \"18\", points: \"10\", \n rebounds: \"1\", assists: \"1\", steals: \"2\", blocks: \"7\", slam_dunks: \"2\"}, \n :BismakBiyombo=> {player_name: \"Bismak Biyombo\", number: \"0\", shoe: \"16\", points: \"12\", \n rebounds: \"4\", assists: \"7\", steals: \"7\", blocks: \"15\", slam_dunks: \"10\"}, \n :DeSagnaDiop=> {player_name: \"DeSagna Diop\", number: \"2\", shoe: \"14\", points: \"24\", \n rebounds: \"12\", assists: \"12\", steals: \"4\", blocks: \"5\", slam_dunks: \"5\"},\n :BenGordon=> {player_name: \"Ben Gordon\", number: \"8\", shoe: \"15\", points: \"33\", \n rebounds: \"3\", assists: \"2\", steals: \"1\", blocks: \"1\", slam_dunks: \"0\"},\n :BrendanHaywood=> {player_name: \"Brendan Haywood\", number: \"33\", shoe: \"15\", points: \"6\", \n rebounds: \"12\", assists: \"12\", steals: \"22\", blocks: \"5\", slam_dunks: \"12\"}\n }}}\n\nend",
"def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\", #is a separate line for each key, or one long list preferred for hash display?\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 #damn.\n },\n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" => {\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"], #wow I can't spell turquoise. Whats the etymology?\n :players => {\n \"Jeff Adrien\" => {\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\" => {\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" => {\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" => {\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n \"Brendan Haywood\" => {\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22,\n :blocks => 5,\n :slam_dunks => 12\n }\n }\n }\n }\nend",
"def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" => {:number => 0, :shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1},\n \"Reggie Evans\" => {:number => 30, :shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7},\n \"Brook Lopez\" => {:number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15},\n \"Mason Plumlee\" => {:number => 1, :shoe => 19, :points => 26, :rebounds => 12, :assists => 6, :steals => 3, :blocks => 8, :slam_dunks => 5},\n \"Jason Terry\" => {:number => 31, :shoe => 15, :points => 19, :rebounds => 2, :assists => 2, :steals => 4, :blocks => 11, :slam_dunks => 1}\n }\n },\n\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => {\n \"Jeff Adrien\" => {:number => 4, :shoe => 18, :points => 10, :rebounds => 1, :assists => 1, :steals => 2, :blocks => 7, :slam_dunks => 2},\n \"Bismak Biyombo\" => {:number => 0, :shoe => 16, :points => 12, :rebounds => 4, :assists => 7, :steals => 7, :blocks => 15, :slam_dunks => 10},\n \"DeSagna Diop\" => {:number => 2, :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},\n \"Ben Gordon\" => {:number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists => 2, :steals => 1, :blocks => 1, :slam_dunks => 0},\n \"Brendan Haywood\" => {:number => 33, :shoe => 15, :points => 6, :rebounds => 12, :assists => 12, :steals => 22, :blocks => 5, :slam_dunks => 12}\n }\n }\n }\n\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n #defined greeting variable\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # provided demographics via an array\n demographics = [name, age]\n # variable defined for power_saying\n power_saying = \"Did you know that I can #{special_power}?\"\n # hash for key/value pairs for built_bear\n built_bear = {\n # ties basic_info to array demographics\n 'basic_info' => demographics,\n # clothes is tied to argument clothes in method build_a_bear\n 'clothes' => clothes,\n # defines exterior to argument fur in mthod build_a_bear\n 'exterior' => fur,\n # cost is tied to float 49.99\n 'cost' => 49.99,\n #sayings is tied to array with greeting, power_saying and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # is_cuddly is tied to true I dont think booleans are allowed in hashes but this is a set value correct?\n 'is_cuddly' => true,\n # ends hash\n }\n # prints key/value pairs in built_bear hash\n return built_bear\n # ends method\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n#defines a variable named greeting, as a string interpolated with one of the arguments from above\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#defines a variable named demographics, as an array containing two of the arguments from above\n demographics = [name, age]\n#defines a variable named power_saying, as a string interpolated with one of the arguments from above\n power_saying = \"Did you know that I can #{special_power}?\"\n#defines a variable named built_bear, as a hash\n built_bear = {\n#this key points to the variable array above\n 'basic_info' => demographics,\n#this key points to the method argument clothes\n 'clothes' => clothes,\n#this key points to the method argument fur\n 'exterior' => fur,\n#this key points to a float for the cost\n 'cost' => 49.99,\n#this key points to an array of two string variables from above, and another string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n#this key points to a boolean, telling if the object is cuddly or not\n 'is_cuddly' => true,\n }\n#this tells the console to log the results of the hash\n return built_bear\n#end method codeblock\nend",
"def game_hash\n game_hash = {\n :home => {\n :team_name =>\"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 \n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7 \n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15 \n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 \n }\n ]\n }, \n :away => {\n :team_name =>\"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 \n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10 \n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0 \n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12 \n }\n ]\n }\n }\n game_hash\nend",
"def fill_stats(raw_hash)\n logger.debug(\"************** building match_stats with raw_hash: #{raw_hash}\")\n stats_hash = {:win => raw_hash[\"wins\"].to_i,\n :hero_id => raw_hash[\"hero_id\"].to_i,\n :team => raw_hash[\"team\"].to_i,\n :position => raw_hash[\"position\"].to_i,\n :hero_kills => raw_hash[\"herokills\"].to_i,\n :deaths => raw_hash[\"deaths\"].to_i,\n :hero_assists => raw_hash[\"heroassists\"].to_i,\n :level => raw_hash[\"level\"].to_i,\n :item_1 => raw_hash[\"slot_1\"].to_i,\n :item_2 => raw_hash[\"slot_2\"].to_i,\n :item_3 => raw_hash[\"slot_3\"].to_i,\n :item_4 => raw_hash[\"slot_4\"].to_i,\n :item_5 => raw_hash[\"slot_5\"].to_i,\n :item_6 => raw_hash[\"slot_6\"].to_i,\n :rating_change => raw_hash[\"amm_team_rating\"].to_f,\n :gold_lost_death => raw_hash[\"goldlost2death\"].to_i,\n :secs_dead => raw_hash[\"secs_dead\"].to_i,\n :hero_dmg => raw_hash[\"herodmg\"].to_i,\n :hero_kill_exp => raw_hash[\"heroexp\"].to_i,\n :hero_kill_gold => raw_hash[\"herokillsgold\"].to_i,\n :creep_kills => raw_hash[\"teamcreepkills\"].to_i,\n :creep_dmg => raw_hash[\"teamcreepdmg\"].to_i,\n :creep_exp => raw_hash[\"teamcreepexp\"].to_i,\n :creep_gold => raw_hash[\"teamcreepgold\"].to_i,\n :neutral_kills => raw_hash[\"neutralcreepkills\"].to_i,\n :neutral_dmg => raw_hash[\"teamcreepdmg\"].to_i,\n :neutral_exp => raw_hash[\"neutralcreepexp\"].to_i,\n :neutral_gold => raw_hash[\"neutralcreepgold\"].to_i,\n :building_dmg => raw_hash[\"bdmg\"].to_i,\n :building_gold => raw_hash[\"bgold\"].to_i,\n :denies => raw_hash[\"denies\"].to_i,\n :exp_denied => raw_hash[\"exp_denied\"].to_i,\n :gold => raw_hash[\"gold\"].to_i,\n :gold_spent => raw_hash[\"gold_spent\"].to_i,\n :exp => raw_hash[\"exp\"].to_i,\n :actions => raw_hash[\"actions\"].to_i,\n :secs => raw_hash[\"secs\"].to_i,\n :consumables => raw_hash[\"consumables\"].to_i,\n :wards => raw_hash[\"wards\"].to_i,\n :nickname => raw_hash[\"nickname\"],\n :hon_id => raw_hash[\"account_id\"].to_i,\n :match_number => raw_hash[\"match_id\"].to_i}\n return \"duplicate\" if MatchStat.where(\"hon_id = ? AND match_number = ?\", stats_hash[:hon_id], stats_hash[:match_number]).any?\n stats_hash.each_key {|field| self.send(\"#{field}=\", stats_hash[field])}\n user = User.find_by_hon_id(self.hon_id)\n uid = user.id if user\n self.user_id = uid if uid and !self.user_id\n return self.save\n \n end",
"def game_hash\n { :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => {\n \"Alan Anderson\" =>{\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n \"Reggie Evans\" => {\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds =>12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n \n },\n \"Brook Lopez\" => {\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n \n \"Mason Plumlee\" => {\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 12,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n \"Jason Terry\" =>{\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n }\n \n \n },\n \n :away =>{\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players =>{\n \"Jeff Adrien\" =>{\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n \"Bismak Biyombo\"=>{\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 7,\n :blocks => 15,\n :slam_dunks => 10\n },\n \"DeSagna Diop\" =>{\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n \"Ben Gordon\" =>{\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks =>1 ,\n :slam_dunks => 0\n },\n \"Brendan Haywood\" =>{\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 22 ,\n :blocks => 5,\n :slam_dunks => 12\n \n }\n }\n }\n }\n \nend",
"def addBlankPlayer(retrosheet_id, hash)\n perfs = Hash.new\n perfs[\"career_games\"] = 0.0\n \n perfs[\"at_bats_last_1_game\"] = [0]\n perfs[\"at_bats_last_2_games\"] = [0, 0]\n perfs[\"at_bats_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"at_bats_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"at_bats_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_at_bats\"] = 0.0\n \n perfs[\"walks_last_1_game\"] = [0]\n perfs[\"walks_last_2_games\"] = [0, 0]\n perfs[\"walks_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"walks_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"walks_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_walks\"] = 0\n \n perfs[\"hits_last_1_game\"] = [0]\n perfs[\"hits_last_2_games\"] = [0, 0]\n perfs[\"hits_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"hits_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"hits_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_hits\"] = 0\n \n perfs[\"strikeouts_last_1_game\"] = [0]\n perfs[\"strikeouts_last_2_games\"] = [0, 0]\n perfs[\"strikeouts_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_strikeouts\"] = 0\n \n \n perfs[\"total_bases_last_1_game\"] = [0]\n perfs[\"total_bases_last_2_games\"] = [0, 0]\n perfs[\"total_bases_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"total_bases_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"total_bases_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_total_bases\"] = 0\n \n hash[retrosheet_id] = perfs\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n # declare variable \"greeting\" and assign it to a string impterpolated with\n # \"name\" argument from the method parameter\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declare variable \"demographic\" and assign it to an array using \"name\"\n # and \"age\" arguments from the method paramters\n demographics = [name, age]\n # declare variable \"power_saying\" and assign it to a string interpolated with\n # \"special_power\" argument from the method paramters\n power_saying = \"Did you know that I can #{special_power}?\"\n # declare variable \"built_bear\" and assign it to a hash with 6 keys\n built_bear = {\n # declare hash key \"basic info\" assign to the local variable\n # \"demographics\" as the value\n 'basic_info' => demographics,\n # declare hash key \"clothes\" and assign \"clothes\" argument from the method parameter\n 'clothes' => clothes,\n # declare hash key \"fur\" and assign \"fur\" argument from the method parameter\n 'exterior' => fur,\n # delcare hash key \"cost\" and assign to integar \"49.99\"\n 'cost' => 49.99,\n # declare hash key \"sayings\" and assign to array with 3 parameters, \"greeting\"\n # local variable, \"power_saying\" local variable, and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # declare hash key \"is_cuddly\" and assign to boolean \"true\"\n 'is_cuddly' => true,\n # end hash\n }\n # method return value local variable \"built_bear\", a hash\n return built_bear\n # end method \"build_a_bear\"\nend",
"def mess_with_demographics(demo_hash)\n demo_hash.values.each do |family_member|\n family_member[\"age\"] += 42 # This is NOT variable reassignment\n family_member[\"gender\"] = \"other\"\n end\nend",
"def game_hash\n hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {\n :player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {\n :player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n }\n hash\nend",
"def rehash() end",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n },\n {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n },\n {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n },\n {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 11,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n },\n {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n },\n {\n player_name: \"Bismack Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 22,\n blocks: 15,\n slam_dunks: 10\n },\n {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n },\n {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n },\n {\n player_name: \"Kemba Walker\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 7,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n # assigns greeting to string\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # assigns demographics to array with name and age in it.\n demographics = [name, age]\n # assigns power_saying to string with special_power interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n # assigns built_bear to hash\n built_bear = {\n # assigns basic_info to demographics\n 'basic_info' => demographics,\n # assigns clothes to clothes\n 'clothes' => clothes,\n # assigns exterior to fur\n 'exterior' => fur,\n # assigns cost to float 49.99\n 'cost' => 49.99,\n # assigns sayings to array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # assigns is_cuddly to boolean value of true\n 'is_cuddly' => true,\n # closes hash\n }\n # returns built_bear hash\n return built_bear\n # ends function\nend",
"def test_move_turns_hash_crossing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_hash_crossing\n assert_includes ['Matzburg', 'Nil Town', 'Dynamic Palisades'], ruby_rush.city\n end",
"def build_a_bear(name, age, fur, clothes, special_power)\n #define variable greeting\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #define variable demographics with 2 arguments\n demographics = [name, age]\n #define variable power_saying as a string with interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n #define built_bear as a hash and set variables inside\n built_bear = {\n #set basic_info to string\n 'basic_info' => demographics,\n #set clothes to string\n 'clothes' => clothes,\n #set exterior to a string\n 'exterior' => fur,\n #set cost to a float\n 'cost' => 49.99,\n #set sayings as an array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #set is_cuddly to a boolean\n 'is_cuddly' => true,\n #close hash\n }\n #return the built_bear hash\n return built_bear\n #close the build_a_bear method\nend",
"def test_ruby_rush_no_turn\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def game_hash \n {\n :home => {:team_name =>\"Brooklyn Nets\", :colors =>[\"Black\", \"White\"],:players =>[\n \n {:player_name => \"Alan Anderson\", :number => 0,:shoe => 16, :points => 22, :rebounds => 12, :assists => 12, :steals => 3, :blocks => 1, :slam_dunks => 1},\n \n {:player_name => \"Reggie Evans\", :number => 30,:shoe => 14, :points => 12, :rebounds => 12, :assists => 12, :steals => 12, :blocks => 12, :slam_dunks => 7},\n \n {:player_name => \"Brook Lopez\", :number => 11, :shoe => 17, :points => 17, :rebounds => 19, :assists => 10, :steals => 3, :blocks => 1, :slam_dunks => 15}, \n \n {:player_name => \"Mason Plumlee\", :number => 1, :shoe => 19, :points => 26, :rebounds => 11, :assists =>6, :steals =>3, :blocks => 8, :slam_dunks => 5},\n \n {:player_name => \"Jason Terry\", :number =>31 , :shoe =>15, :points =>19, :rebounds => 2, :assists =>2, :steals =>4, :blocks =>11, :slam_dunks =>1}]},\n \n \n \n :away => {:team_name =>\"Charlotte Hornets\", :colors => [\"Turquoise\", \"Purple\"], :players => [\n {:player_name => \"Jeff Adrien\", :number => 4, :shoe => 18, :points => 10, :rebounds => 1, :assists => 1, :steals => 2, :blocks => 7, :slam_dunks => 2 }, {:player_name => \"Bismack Biyombo\", :number => 0,:shoe => 16, :points => 12, :rebounds => 4, :assists => 7, :steals => 22, :blocks => 15, :slam_dunks => 10},{:player_name => \"DeSagna Diop\", :number => 2, :shoe => 14, :points => 24, :rebounds => 12, :assists => 12, :steals => 4, :blocks => 5, :slam_dunks => 5},{:player_name => \"Ben Gordon\", :number => 8, :shoe => 15, :points => 33, :rebounds => 3, :assists =>2, :steals =>1, :blocks => 1, :slam_dunks => 0},{:player_name => \"Kemba Walker\", :number =>33 , :shoe =>15, :points =>6, :rebounds => 12, :assists =>12, :steals =>7, :blocks =>5, :slam_dunks =>12\n }]}}\n \nend",
"def game_hash\n game_hash = {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\",\"White\"],\n :players => [\n {:player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1 \n },\n {\n :player_name => \"Reggie Evans\",\n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {\n :player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {\n :player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5 \n },\n {\n :player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1 \n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\" ],\n :players => [\n {:player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2 \n },\n {\n :player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {\n :player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {\n :player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {\n :player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12 \n }\n ]\n }\n }\n game_hash\nend",
"def yards_hash(total_xml, rushing_xml)\n overall = plays_yards_average(total_xml)\n overall[:rushing] = plays_yards_average(rushing_xml)\n overall\n end",
"def build_a_bear(name, age, fur, clothes, special_power)\n #initializes a variable greeting with an interpolated string\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #initializes a variable demographic with an array\n demographics = [name, age]\n #initializes a variable power_saying with an interpolated string\n power_saying = \"Did you know that I can #{special_power}?\"\n #initializes a variable built bear containing a hash\n built_bear = {\n #creates a string key and assigns is to value demographics\n 'basic_info' => demographics,\n #creates a string key and assigns is to value clothes\n 'clothes' => clothes,\n #creates a string key and assigns is to value fur\n 'exterior' => fur,\n #creates a string key and assigns is to a float value\n 'cost' => 49.99,\n #creates a string key and assigns is to an array value\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #creates a string key and assigns is to a boolean value\n 'is_cuddly' => true,\n }\n #calls the hash built_bear\n return built_bear\n#closes the class\nend",
"def game_hash\n {\n home: {\n team_name: \"Brooklyn Nets\",\n colors: [\"Black\", \"White\"],\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n }, {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n }, {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n }, {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n }, {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n }, {\n player_name: \"Bismak Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n }, {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n }, {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n }, {\n player_name: \"Brendan Haywood\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def big_shoe_rebounds\n # built an empty array called names\n names = []\n # built an empty array called shoe_sizes\n shoe_sizes = []\n # game_hash.each do |team, random| iterates over the hash\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name,stats|\n names.push(name)\n shoe_sizes.push(stats[:shoe])\n end\n end\n # finds the player with largest shoes size\n largest = -1\n shoe_sizes.each do |x|\n if x > largest\n largest = x\n end\n end\n\n # we want to add to player_with_largest the actual largest shoe size and we can do that by adding a key with an array as a value\n player_with_largest = names[shoe_sizes.index(largest)]\n\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_with_largest == name\n return stats[:rebounds]\n # once we've found the player with the largest shoe size\n # we've returned that player's number of rebounds by first accessing their stats and then going into the value of rebounds\n\n end\n end\n end\nend",
"def game_hash\n {\n :home => {\n :team_name => \"Brooklyn Nets\",\n :colors => [\"Black\", \"White\"],\n :players => [\n {:player_name => \"Alan Anderson\",\n :number => 0,\n :shoe => 16,\n :points => 22,\n :rebounds => 12,\n :assists => 12,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 1\n },\n {:player_name => \"Reggie Evans\", \n :number => 30,\n :shoe => 14,\n :points => 12,\n :rebounds => 12,\n :assists => 12,\n :steals => 12,\n :blocks => 12,\n :slam_dunks => 7\n },\n {:player_name => \"Brook Lopez\",\n :number => 11,\n :shoe => 17,\n :points => 17,\n :rebounds => 19,\n :assists => 10,\n :steals => 3,\n :blocks => 1,\n :slam_dunks => 15\n },\n {:player_name => \"Mason Plumlee\",\n :number => 1,\n :shoe => 19,\n :points => 26,\n :rebounds => 11,\n :assists => 6,\n :steals => 3,\n :blocks => 8,\n :slam_dunks => 5\n },\n {:player_name => \"Jason Terry\",\n :number => 31,\n :shoe => 15,\n :points => 19,\n :rebounds => 2,\n :assists => 2,\n :steals => 4,\n :blocks => 11,\n :slam_dunks => 1\n }\n ]\n },\n :away => {\n :team_name => \"Charlotte Hornets\",\n :colors => [\"Turquoise\", \"Purple\"],\n :players => [\n {:player_name => \"Jeff Adrien\",\n :number => 4,\n :shoe => 18,\n :points => 10,\n :rebounds => 1,\n :assists => 1,\n :steals => 2,\n :blocks => 7,\n :slam_dunks => 2\n },\n {:player_name => \"Bismack Biyombo\",\n :number => 0,\n :shoe => 16,\n :points => 12,\n :rebounds => 4,\n :assists => 7,\n :steals => 22,\n :blocks => 15,\n :slam_dunks => 10\n },\n {:player_name => \"DeSagna Diop\",\n :number => 2,\n :shoe => 14,\n :points => 24,\n :rebounds => 12,\n :assists => 12,\n :steals => 4,\n :blocks => 5,\n :slam_dunks => 5\n },\n {:player_name => \"Ben Gordon\",\n :number => 8,\n :shoe => 15,\n :points => 33,\n :rebounds => 3,\n :assists => 2,\n :steals => 1,\n :blocks => 1,\n :slam_dunks => 0\n },\n {:player_name => \"Kemba Walker\",\n :number => 33,\n :shoe => 15,\n :points => 6,\n :rebounds => 12,\n :assists => 12,\n :steals => 7,\n :blocks => 5,\n :slam_dunks => 12\n }\n ]\n }\n }\nend",
"def random_reviews_hash\n\t\t[{title: \"Pretty decent, could have been better\", stars: 4, summary: \"This chair arrived well-packaged and protected with a lot of foam insulation around the wheels and metal components. Assembly was quick and simple, as I didn't even need the instructions. All you have to do is put the air lift on the base and place the seat on the air lift, then it's ready to go. The chair has great lumbar support and reaches all the way up to my head, allowing me to rest entirely against it. It's also fairly comfortable, having a few inches of padding, while not being too compliant so as to lack support, making for a pretty good balance that I particularly like. The air lift lever (for raising/lowering the height of the chair) is designed so that when pushed in the chair cannot recline, but if you pull it out slightly, it releases a mechanical lock and allows the chair to recline back about 20-30 degrees.\"},\n\t\t{title: \"Got exactly what I needed and more!\", stars: 5, summary: \"Customer Service: We often encounter a customer service rep who has had a bad day or just does not care or any of the negative phrases that make us some reps. This is absolutely NOT the case with the folks at BOSS. After opening the box and putting it together (a feat accomplished by anyone who can lift a sack of potatoes) I could not get the gas cylinder to raise the seat level. One of us is 5'6\\\" and the other is 6'3\\\" and the seat is either too high or too low unless the gas cylinder works. It did not. \n\n\t\t\t\tIt was too late to call and it was Thanksgiving eve. Even if anyone had been home I would have waited until Frantic Friday to call. So I emailed my concern and expected no reply until today or maybe tomorrow. On Friday, the 26th, the height adjustment absence was just too much to endure. A call was placed to BOSS and a woman told me exactly what to do and I did. Closed case. Wow! I did suggest that the instructions would benefit from her advice in future iterations. Regardless, my problem was settled in seconds and when I finally got to reviewing my email I saw a response from BOSS saying the same thing. Let's all give a big shout to BOSS for fantastic service.\"\n\t\t},\n\t\t{title: \"Quick, Easy, and Fast!\", stars: 4, summary: \"The chair leans back which is nice. Doesn't seem to have too much lean which i don't really like but it's enough to put my feet up on my sub woofer. The leather is very nice quality and it has a built-in lumbar support which feels nice. My only issue with the chair was the first chair i sat in it and a bolt sheered off. But i told amazon and they had my new chair their the next day (same as what i paid for to ship it originally) and they had a ups man there the next day to pick up the broken chair. After that the chair has been flawless and very comfortable. The leather feels less cheap then the leather on my old chair.\"\n\t\t\t},\n\t\t\t{title: \"Bad Overall Experience\", stars: 2 , summary: \"This chair is nicely built. It looks elegant and cool. It is easy to clean.\n\t\t\t\tThe problem for me is that this is too big.\n\t\t\t\tI am male, 170 cm, 56 kg, that is about 5 foot 7 inches and 123 pounds. I don't feel very comfortable in this chair especially due to the armrest. The armrest is just a few centimeters too high, it pushes my elbow up, and that's annoying.\n\t\t\t\tThe part where you sit on is very large, and I seem to \\\"sink\\\" inside it, which worsens the armrest problem.\n\t\t\t\tBut I think if you are taller, this should be good. It will be even better if you are both taller and fatter. Maybe if I were 180cm(5 foot 11 inches) 85kg(188 pounds), this chair would be perfect.\" },\n\t\t\t\t\t\t\t{title: \"Worse Lender In Dojo!\", stars: 1, summary: \"First the positives:\n\n\t\t\t\t* This is the easiest chair I've ever put together. Simply unfold the chair back and the seat, which come pre-attached along with the arms, until they lock together. Next, place the gas cylinder firmly into the chair base and snap the 5 wheels onto the bottom. Finally, slide the gas cylinder/base into the seat bottom. It's completely tool-less and takes minutes.\n\n\t\t\t\t* The chair itself is pretty comfortable. It fit my back perfectly and was firm enough to give support while being soft enough to sit for extended periods.\n\n\t\t\t\t* Contrary to what other reviewers say, this chair can lean back. Just slide the height adjustment lever in towards the chair to lock the back in place, or slide it out to allow the chair to lean backwards.\"\n\t\t},\n\t\t{title: \"The Best Lender In the Dojo!\", stars: 5, summary: \"Purchased this chair once before on July 26, 2012. Was happy with the chair and the material that was used. This time the material was totally different. Very Cheap, so called Leather Plus..................... Very Cheap. In the description it does say Leather Plus but in the details as this is how it is described, below. I copied and pasted the information. It is not Leather............. Don't be fooled and it feels and looks very cheap. This material is totally different from the purchase in the past. If it were the same as the first chair I bought, I would have been happy. It was discribe to be the exact same and was not............ I don't write many reviews and I shop a lot with Amazon and this time I am a very unhappy shopper. Beware of this cheap chair...........................................\"\n\t\t},\n\t\t{title: \"Very good experience\", stars: 4, summary: \"This chair was packed sufficiently, arrived quickly, and was easy to assemble (5mins, no tools). The chair is comfortable, but I'll have to either turn my A/C colder or wear a shirt (I work at home) because this material either makes me sweat a lot more, or it just shows up more.\"\n\t\t},\n\t\t{title: \"Experienced teach, but always late\", stars: 2, summary: \"Update: after less that 1 year of use, this chair's piston is giving out. It rises on it's own, and I have to lower the chair every time I sit in it. It even rises slowly while I am in it, causing me to have to constantly lower it again. CHEAP CRAP!!!\"\n\t\t}].sample\n\tend",
"def build_a_bear(name, age, fur, clothes, special_power)\n #define method variables (name is interpolated)\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #define array\n demographics = [name, age]\n #interp\n power_saying = \"Did you know that I can #{special_power}?\"\n #hash, redefines a few variables in keys/values such as exterior, cost\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n#execute\n return built_bear\nend",
"def slam_dunk\n # When you dunk, your @slam_dunks go up AND @points go up.\n @slam_dunks += 1\n # @points += 2\n # Alternatively, you can do this!\n self.score_two # WHAAAAT??\n\n self # <= what is this?\n # self can be called anywhere\n # it will tell you who called the method you are in\n # So ask yourself, who called me? => That's self!\n\n # self in an instance method is the instance that called it\n # So self.score_two is calling the score_two instance method.\n # binding.pry\n # self.slam_dunk\n puts \"OOOOOHHHHHH!!!\"\n end",
"def hash\n [rank, suit].hash\n end",
"def build_a_bear(name, age, fur, clothes, special_power) #Defining a function/method called `build_a_bear` which takes 5 parameters (name, age, fur, clothes, special_power)\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\" #Setting a local variable `greeting` to a string which interpolates the `name` variable\n demographics = [name, age] #setting a local variable `demographics` equal to an array containing the `[name, age]` parameters.\n power_saying = \"Did you know that I can #{special_power}?\" #setting local variable `power_saying` to a string which interpolates the `special_power` parameter\n built_bear = { #creates a hash `built_bear` containing the keys `:basic_info, :clothes, :exterior, :cost, :sayings, and :is_cuddly`\n 'basic_info' => demographics, #assigns variable array `demographics` as value for key `basic_info`\n 'clothes' => clothes, #assigns parameter `clothes` as value for `:clothes` key\n 'exterior' => fur, #assigns `fur` parameter as value for `exterior` key\n 'cost' => 49.99, #assigns `49.99` as value for `cost` key\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"], #assigns array containing `greeting, power_saying` variables and a new string as the value for `sayings` key\n 'is_cuddly' => true, #assigns `is_cuddly` key boolean value of true\n }\n return built_bear #returns `built_bear` hash\nend",
"def game_hash\n { #top-level hash = game_hash\n home: { # top-level key\n team_name: \"Brooklyn Nets\", # team-level key/value pairs \n colors: [\"Black\", \"White\"], # look, an array as a value\n players: [\n {\n player_name: \"Alan Anderson\",\n number: 0,\n shoe: 16,\n points: 22,\n rebounds: 12,\n assists: 12,\n steals: 3,\n blocks: 1,\n slam_dunks: 1\n }, {\n player_name: \"Reggie Evans\",\n number: 30,\n shoe: 14,\n points: 12,\n rebounds: 12,\n assists: 12,\n steals: 12,\n blocks: 12,\n slam_dunks: 7\n }, {\n player_name: \"Brook Lopez\",\n number: 11,\n shoe: 17,\n points: 17,\n rebounds: 19,\n assists: 10,\n steals: 3,\n blocks: 1,\n slam_dunks: 15\n }, {\n player_name: \"Mason Plumlee\",\n number: 1,\n shoe: 19,\n points: 26,\n rebounds: 12,\n assists: 6,\n steals: 3,\n blocks: 8,\n slam_dunks: 5\n }, {\n player_name: \"Jason Terry\",\n number: 31,\n shoe: 15,\n points: 19,\n rebounds: 2,\n assists: 2,\n steals: 4,\n blocks: 11,\n slam_dunks: 1\n }\n ]\n },\n away: {\n team_name: \"Charlotte Hornets\",\n colors: [\"Turquoise\", \"Purple\"],\n players: [\n {\n player_name: \"Jeff Adrien\",\n number: 4,\n shoe: 18,\n points: 10,\n rebounds: 1,\n assists: 1,\n steals: 2,\n blocks: 7,\n slam_dunks: 2\n }, {\n player_name: \"Bismak Biyombo\",\n number: 0,\n shoe: 16,\n points: 12,\n rebounds: 4,\n assists: 7,\n steals: 7,\n blocks: 15,\n slam_dunks: 10\n }, {\n player_name: \"DeSagna Diop\",\n number: 2,\n shoe: 14,\n points: 24,\n rebounds: 12,\n assists: 12,\n steals: 4,\n blocks: 5,\n slam_dunks: 5\n }, {\n player_name: \"Ben Gordon\",\n number: 8,\n shoe: 15,\n points: 33,\n rebounds: 3,\n assists: 2,\n steals: 1,\n blocks: 1,\n slam_dunks: 0\n }, {\n player_name: \"Brendan Haywood\",\n number: 33,\n shoe: 15,\n points: 6,\n rebounds: 12,\n assists: 12,\n steals: 22,\n blocks: 5,\n slam_dunks: 12\n }\n ]\n }\n }\nend",
"def slam_dunk\n @slam_dunks += 1\n self.score_two\n\n self # <= what is this?\n # self can be called anywhere\n # it will tell you who called the method you are in\n # So ask yourself, who called me? => That's self!\n # self in an instance method is the instance that called it\n # Because we have access to self, the instance,\n # logically it makes sense that we can use other\n # instance methods in here!\n\n puts \"OOOOOHHHHHH!!!\"\n end",
"def hash=(_arg0); end",
"def test_duck_type_beach_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. duck_type_beach_search}\n end",
"def roll\n #Created a method\n case rand (1..6)\n when 1\n {name:\"Los Negros\", value: 1}\n #Assign names (by using strings in case/when scenario) to the die # roll\n when 2\n {name: \"Los Gallegos\", value: 2}\n #Assign ranking postion with number to the die # roll\n when 3\n {name: \"Jacks\", value: 3}\n when 4\n {name: \"Queen\", value: 4}\n when 5\n {name: \"King\", value: 5}\n when 6\n {name: \"Ace\", value: 6}\n end\n #End the case/when scenario\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n#Declare a variable called greeting, whose value is a string that contains the above name argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#Declare a variable called demographics which is assigned to an array with name and age values\n demographics = [name, age]\n#Declare a variable call power_saying whose value is a string that containsthe above special_power argument\n power_saying = \"Did you know that I can #{special_power}?\"\n#Declare a variable called built_bear whos value is a hash with 6 elements\n built_bear = {\n#The built_bear hash includes the key 'basic_info' whose value is the above demographics variable\n 'basic_info' => demographics,\n#The built_bear hash includes the key clothes, whose value is the clothes argument in line 7\n 'clothes' => clothes,\n#The built_bear hash includes the key exterior, whose value is the fur argument in line 7\n 'exterior' => fur,\n#The built_bear hash includes the key cost, which is assigned the constant value 49.99\n 'cost' => 49.99,\n#The built_bear hash includes the key sayings, whose value is an array of 3 elements (2 aforementioned variables and new unique string)\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n##The built_bear hash includes the key 'is_cuddly', which is assigned the boolean value true.\n 'is_cuddly' => true,\n#Conclude the hash with a curly bracket\n }\n#As the last step of the build_a_bear method, retun the value for built_bear\n return built_bear\n#End the build_a_bear method\nend",
"def oscars_hash\n # your code here\n hash = {\n :actor => \"Leonardo DiCaprio\",\n :picture => \"Spotlight\",\n :effects => \"Ex Machina\"\n}\nend",
"def king_richard_iii; end",
"def build_a_bear(name, age, fur, clothes, special_power)\n # Declares local varriable \"greeting\" and assigns it a string value with the\n # name paramter interpolated into the string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # Declares the local varriable \"demographics\" and assigns the value of an\n # array with the elements being two paramters: name and age.\n demographics = [name, age]\n # Declares the local varriable \"power_saying\" and assigns a string value that\n # has the parameter \"special_power\" interpolated in.\n power_saying = \"Did you know that I can #{special_power}?\"\n # Declares a hash map called \"built_bear\"\n built_bear = {\n # Assigning the value of the local varraible \"demographics\" to the key\n # 'basic info'\n 'basic_info' => demographics,\n # Assigning the value of the parameter \"clothes\" to the key 'clothes'\n 'clothes' => clothes,\n # Assigning the value of the parameter \"fur\" to the key 'exterior'\n 'exterior' => fur,\n # Assigning the float 49.99 to the key 'cost'\n 'cost' => 49.99,\n # Assigning an array containing the elemetnts of local varriable `greeting`,\n # local varriable `power_saying`, and the string \"Goodnight my friend!\" to\n # the key 'sayings'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # Assigning the boolean `true` to the key `\"is_cuddly\"`\n 'is_cuddly' => true,\n # Closes out the hash map\n }\n # Ends the `build_a_bear` method at the `return` statement, returns `built bear`\n return built_bear\n # Signifies the end of the `build_a_bear` method definitions.\nend",
"def hand_score(hand)\n\nend",
"def big_shoe_rebounds\n b_size =0\n rebounds = 0\n player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |p_name, stats|\n if (stats[:shoe] > b_size)\n b_size = stats[:shoe]\n player = p_name.to_s\n rebounds = stats[:rebounds]\n end #if\n end #team_data\n end #game_hash\n rebounds\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n# Assigns the variable \"greeting\" to a string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#Assigns the variable demographics to an array with name and age inside.\n demographics = [name, age]\n# Assigns the variable power_saying to a string.\n power_saying = \"Did you know that I can #{special_power}?\"\n# Assigns the variable built_bear to a hash containing keys and values.\n built_bear = {\n# Assigns the key \"basic_info\" to the value/string \"demographics\".\n 'basic_info' => demographics,\n# Assigns the key \"clothes\" to the value/string \"clothes\".\n 'clothes' => clothes,\n# Assigns the key \"exterior\" to the value/string \"fur\".\n 'exterior' => fur,\n# Assigns the key \"cost\" to the value/float 49.99.\n 'cost' => 49.99,\n# Assigns the key \"sayings\" to a value/array with greeting, power_saying, and \"Goodnight my friend!\".\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n# Assigns the key \"is_cuddly\" to a value/boolean \"true\".\n 'is_cuddly' => true,\n }\n# Stops the method and returns the values in the hash \"built_bear\".\n return built_bear\n# Ends the method.\nend",
"def witcher; end",
"def agent_namer\n agents = {}\n response = ''\n until response == 'quit'\n puts 'Give me your full name, agent (or tell me when to quit)'\n response = gets.chomp\n break if response == 'quit'\n # flip first and last names\n agent_name = response.reverse.split(/\\s+/, 2).collect(&:reverse).join(' ')\n # first scramble vowels\n scrambled_vowel = agent_name.tr('aeiouAEIOU', 'eiouaEIOUA')\n # then scramble consonants\n scrambled_consonents = scrambled_vowel.tr('bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ', 'cdfghjklmnpqrstvwxyzbCDFGHJKLMNPQRSTVWXYZB')\n # Store that data in an agents hash!!!\n agents.store(response, scrambled_consonents)\n\n puts \"your new name is #{scrambled_consonents}\"\n\n end\n puts \"Okay, here's a list of our current agents that have been scrambled through this session:\"\n # Print em all out! How the HECK do I hide the hash summary after the printed one? It's cool to see what the hash looks like but I'd like it to be hidden from the user\n agents.each { |x, y| puts \"#{x} is actually #{y}\" }\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n#assigns variable greeting to a string which uses interpolation with the name argument.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#assigns variable demographics to an array made of the name and age arguments\n demographics = [name, age]\n#assings variable power_saying to a string which uses interpolation of the special_power argument\n power_saying = \"Did you know that I can #{special_power}?\"\n#creates a hash named built_bear\n built_bear = {\n#Key named basic_info assigned to value demographics from arguments\n 'basic_info' => demographics,\n#Key named clothes assigned to value clothes from arguments\n 'clothes' => clothes,\n#Key named exterior assigned to value exterior from arguments\n 'exterior' => fur,\n#Key named cost assigned to float value of 49.99\n 'cost' => 49.99,\n#Key named sayings assigned to array with greeting, power_saying arguments and string 'Goodnight my friend!'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n#Key named is_cuddly assigned to boolean value of true\n 'is_cuddly' => true,\n }\n#returns variable built_bear with the completed information from the hash using interpolation.\n return built_bear\n#ends the method\nend",
"def evaluate(player, computer)\n # `#{scores.key scores[:player1_name]} wins!`\n if player == computer\n return \"It's a draw!\"\n else\n if player == \"Rock\"\n if computer == \"Paper\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n elsif player == \"Paper\"\n if computer == \"Scissors\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n else\n if computer == \"Rock\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n end\n end\nend",
"def result_update_to player, dealer_player, odds\r\n if player[:state] == 'won' \r\n amount = (player[:bet].to_f * odds).to_i\r\n player[:total_chips] = player[:total_chips] + amount\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] - amount\r\n\tplayer[:total_win] = player[:total_win] + 1\r\n\tplayer[:history].push('won')\r\n elsif player[:state] == 'lost'\r\n player[:total_chips] = player[:total_chips] - player[:bet]\r\n\tdealer_player[:total_chips] = dealer_player[:total_chips] + player[:bet]\r\n player[:history].push('lost')\r\n else\r\n player[:history].push('push')\r\n end\r\n player[:total_round] = (player[:state] == 'won' || player[:state] == 'lost')? player[:total_round] + 1 : player[:total_round]\r\n player[:rate] = (player[:total_round] > 0)? player[:total_win].to_f / player[:total_round].to_f : player[:rate]\r\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n #Sets a greeting variable equal to a string interpolating 1 argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #Sets a demographics variable equal to an array taking in 2 arguments\n demographics = [name, age]\n #Sets a power_saying variable equal to a string interpolating 1 argument\n power_saying = \"Did you know that I can #{special_power}?\"\n #Makes a hash with 6 key/value pairs, starts with curly bracket\n built_bear = {\n #Sets a key 'basic_info' paired to value with variable demographics\n 'basic_info' => demographics,\n #Sets a key 'clothes' paired to value with argument clothes\n 'clothes' => clothes,\n #Sets a key 'exterior' paired to value with argument fur\n 'exterior' => fur,\n #Sets a key 'cost' paired to value with float 49.99\n 'cost' => 49.99,\n #Sets a key 'sayings' paired to value with mixed array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #Sets a key 'is cuddly' to value with true boolean\n 'is_cuddly' => true,\n #Ends hash with curly bracket\n }\n #Returns all the info put into the hash made\n return built_bear\n #Ends the function\nend",
"def mess_with_demographics(demo_hash)\n new_hash = demo_hash\n new_hash.values.each do |family_member|\n family_member[\"age\"] += 42\n family_member[\"gender\"] = \"other\"\n end\nend",
"def build_a_bear(name, age, fur, clothes, special_power)\n #defines new method called 'build a bear' with several parameters\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #defines string with name variable\n demographics = [name, age]\n #defines demographics with array\n power_saying = \"Did you know that I can #{special_power}?\"\n #defines string with special_power variable\n\n built_bear = {\n #this creates a hash which stores info about built_bear.\n 'basic_info' => demographics,\n #this assigns 'basic info' to 'demographics'\n 'clothes' => clothes,\n #assigns clothes to value 'clothes'\n 'exterior' => fur,\n #assigns 'exterior' to value 'fur'\n 'cost' => 49.99,\n #assings 'cost' to float'49.99'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #assigns 'saying' to array that calls methods 'greeting' and 'power_saying', as well as string 'Goodnight my friend!'\n 'is_cuddly' => true,\n } #assigns value 'is cuddly' to boolean.\n return built_bear\n #\nend"
] | [
"0.6364895",
"0.5974998",
"0.5673059",
"0.56286997",
"0.5624507",
"0.561475",
"0.56066096",
"0.5541112",
"0.5541112",
"0.55406326",
"0.5498184",
"0.54893255",
"0.5484093",
"0.54498416",
"0.5426625",
"0.5385213",
"0.5375753",
"0.53750026",
"0.5367389",
"0.53664887",
"0.5348015",
"0.5347721",
"0.5344155",
"0.53400075",
"0.5339299",
"0.5338968",
"0.533573",
"0.53254336",
"0.5321292",
"0.53175217",
"0.53087217",
"0.5294223",
"0.529364",
"0.52931243",
"0.5290393",
"0.5289798",
"0.5287087",
"0.5266004",
"0.52639514",
"0.5259609",
"0.5250293",
"0.5237833",
"0.52270603",
"0.5226816",
"0.52265453",
"0.5225344",
"0.52201957",
"0.5215447",
"0.5211754",
"0.5205123",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.5202152",
"0.519487",
"0.5188754",
"0.5187441",
"0.5186689",
"0.5186497",
"0.5183165",
"0.5182996",
"0.51812655",
"0.51810753",
"0.517019",
"0.5163516",
"0.5161476",
"0.51600736",
"0.5154672",
"0.5148584",
"0.5136675",
"0.51353943",
"0.51248306",
"0.5119411",
"0.5116961",
"0.5109878",
"0.51066035",
"0.5099557",
"0.5098682",
"0.50917196",
"0.50848866",
"0.50825316",
"0.50708884",
"0.50689447",
"0.5065223",
"0.5060404",
"0.50564754",
"0.5051335",
"0.50512177",
"0.5049156",
"0.5045715"
] | 0.0 | -1 |
Really lost on this one! My head is spinning trying to trace this! Running it in irb => "paper" =begin The outermost call is evaluated by determining the result of rps(rps("rock", "paper"), rps("rock", "scissors")) versus rock. In turn that means we need to evaluate the two separate results of rps("rock", "paper") and rps("rock", "scissors") and later combine them by calling rps on their individual results. Those innermost expressions will return "paper" and "rock", respectively. Calling rps on that input will return "paper". Which finally when evaluated against "rock" will return "paper". =end Question 9: Given these two methods: | def foo(param = "no")
"yes"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\n end",
"def rps(p1, p2)\n if p1 == \"scissors\" && p2 == \"paper\"\n return \"Player 1 won!\"\n elsif p1 == \"scissors\" && p2 == \"rock\"\n return \"Player 2 won!\"\n elsif p1 == \"scissors\" && p2 == \"scissors\"\n return \"Draw!\"\n end\n\n if p1 == \"paper\" && p2 == \"paper\"\n return \"Draw!\"\n elsif p1 == \"paper\" && p2 == \"rock\"\n return \"Player 1 won!\"\n elsif p1 == \"paper\" && p2 == \"scissors\"\n return \"Player 2 won!\"\n end\n\n if p1 == \"rock\" && p2 == \"paper\"\n return \"Player 2 won!\"\n elsif p1 == \"rock\" && p2 == \"rock\"\n return \"Draw!\"\n elsif p1 == \"rock\" && p2 == \"scissors\"\n return \"Player 1 won!\"\n end\n\nend",
"def rps(fist1, fist2)\n if fist1 == 'rock'\n (fist2 == 'paper') ? 'paper' : 'rock'\n elsif fist1 == 'paper'\n (fist2 == 'scissors') ? 'scissors' : 'paper'\n else\n (fist2 == 'rock') ? 'rock' : 'scissors'\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else \n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(choice)\n choice = choice.capitalize\n rps = [\"Rock\", \"Paper\", \"Scissors\"]\n computer_choice = rps[rand(3)]\n return \"You: #{choice}, Computer: #{computer_choice}, Draw\" if choice == computer_choice\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Rock\" && computer_choice == \"Scissors\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Rock\" && computer_choice == \"Paper\"\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Paper\" && computer_choice == \"Rock\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Paper\" && computer_choice == \"Scissors\"\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Scissors\" && computer_choice == \"Paper\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Scissors\" && computer_choice == \"Rock\"\nend",
"def rps(user_hand)\nuser_hand.downcase!\ncomp_hand = [\"rock\", \"paper\", \"scissors\"].sample\n# \"rock\" < \"paper\"=== tru\n# \"rock\" > \"scissor\"\n# \"paper\" < \"scissor\"\n if (comp_hand == \"rock\" && user_hand == \"paper\") || \n (comp_hand== \"scissors\" && user_hand == \"rock\") || \n (comp_hand== \"paper\" && user_hand == \"scissors\")\n \"user had #{user_hand} and computer had #{comp_hand}. User wins!\"\n elsif comp_hand == user_hand\n \"user had #{user_hand} and computer had #{comp_hand}. Draw!\"\n else \n \"user had #{user_hand} and computer had #{comp_hand}. Computer wins!\"\n end\nend",
"def rps(p1, p2)\n return 'Player 1 won!' if p1 == 'scissors' && p2 == 'paper'\n return 'Player 1 won!' if p1 == 'paper' && p2 == 'rock'\n return 'Player 1 won!' if p1 == 'rock' && p2 == 'scissors'\n return 'Draw!' if p1 == p2\n # Otherwise player 2 wins...\n 'Player 2 won!'\nend",
"def comp_choose_rps\n\trand_num = rand(3) \n\tif rand_num == 1 \n\t \"rock\"\n\telsif rand_num == 2 \n\t \"paper\"\n\telse \n\t \"scissors\"\n\tend\nend",
"def rps\n c = ['r','p','s'].sample\n puts \"choose r, p or s\"\n u = gets\n puts \"comp chose #{c}\"\n if u==c \n puts \"you tie \"\n elsif u==\"r\"&&c==\"p\"||u==\"p\"&&c==\"s\"||u==\"s\"&&c==\"r\"\n puts 'you lose'\n else \n puts \"you win\"\n \n end\n end",
"def rps\nputs \"Rock...\"\nsleep(0.5)\nputs \"Paper...\"\nsleep(0.5)\nputs \"Scissors...\"\nsleep(0.5)\nputs \"Shoot!\"\nsleep(0.1)\nputs \" \"\nend",
"def evaluate(player, computer)\n # `#{scores.key scores[:player1_name]} wins!`\n if player == computer\n return \"It's a draw!\"\n else\n if player == \"Rock\"\n if computer == \"Paper\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n elsif player == \"Paper\"\n if computer == \"Scissors\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n else\n if computer == \"Rock\"\n score = $scores[:player2_name].to_i\n score += 1\n $scores[:player2_name] = score\n return \"Computer wins!\"\n else\n score = $scores[:player1_name].to_i\n score += 1\n $scores[:player1_name] = score\n return \"#{$scores.key $scores.fetch(:player1_name)} wins!\"\n end\n end\n end\nend",
"def game\n if p1 == \"rock\" && p2 == \"scissors\"\n victor = \"rock\"\n elsif p1 == \"scissors\" && p2 == \"rock\"\n victor = \"rock\"\n elsif p1 == \"scissors\" && p2 == \"paper\"\n victor = \"scissors\"\n elsif p1 == \"paper\" && p2 == \"scissors\"\n victor = \"scissors\"\n elsif p1 == \"paper\" && p2 == \"rock\"\n victor = \"paper\"\n else p1 == \"rock\" && p2 == \"paper\"\n victor = \"paper\"\n end\n return victor\n end",
"def rps(arg1, arg2)\n if arg1 == arg2\n puts \"Remis\"\n elsif (arg1 == \"paper\" && arg2 == \"rock\") || (arg1 == \"scissors\" && arg2 == \"paper\") || (arg1 == \"rock\" && arg2 == \"scissors\")\n puts \"Gracz 1 wygrywa\"\n else\n puts \"Gracz 2 wygrywa\"\n end\nend",
"def play(answer)\n until answer.downcase != \"y\"\n puts \"#{$scores[:player1_name]}, I assume that you already know the rules ;)\"\n puts \"Let's go!\"\n r = rand(3)\n computer_rps = $rps[r]\n puts \"Please enter 'R' for Rock, 'P' for Paper or 'S' for Scissors:\"\n player_rps = gets.chomp\n player_rps.upcase!\n case player_rps\n when \"R\"\n player_rps = \"Rock\"\n when \"P\"\n player_rps = \"Paper\"\n when \"S\"\n player_rps = \"Scissors\"\n else\n player_rps = \"Error\"\n end\n if player_rps != \"Error\"\n puts evaluate(player_rps, computer_rps)\n puts get_scores()\n else\n puts \"Error! you have enter something else than R, P or S\"\n end\n puts \"Do you want to play again? y/Y or n/N\"\n answer = gets.chomp\n end\n puts \"Thank you, bye!\"\nend",
"def rock_paper_scissors_game\n \n # Creates What hand (rock, paper, scissors) that the cpu uses\n def cpu_answer\n cpu_answer = rand(3)\n if cpu_answer == 0\n cpu_answer = 'Rock'\n elsif cpu_answer == 1\n cpu_answer = 'Paper'\n elsif cpu_answer == 2\n cpu_answer = 'Scissors'\n end\n end\n\n # Compares your hand and computers hand to see who won or tied\n # if tied will run the program again\n def winner(answer, computers_answer)\n if (answer.downcase == 'rock') && (computers_answer.downcase == 'paper')\n puts 'YOU LOSE'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'rock')\n puts 'WINNER'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'scissors')\n puts 'You Lose'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'paper')\n puts 'WINNER'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'rock')\n puts 'You Lose'\n elsif (answer.downcase == 'rock') && (computers_answer.downcase == 'scissors')\n puts 'Winner'\n else\n puts 'You both tied. Go again.'\n rock_paper_scissors_game\n exit\n end\n end\n \n # Asks if you want to play again after a winner is decided\n def play_again(play_again_response)\n while play_again_response.downcase != 'no'\n puts 'Do you want to play another round of Rock, Paper, Scissors? Yes or No?'\n play_again_response = gets.chomp\n if play_again_response.downcase == 'yes'\n puts \"OK! Lets play again!\"\n rock_paper_scissors_game\n exit\n elsif play_again_response.downcase == 'no'\n else\n puts 'You enetered '+play_again_response.capitalize+' which isnt Yes or No. Please type Yes or No if you want to play again.'\n play_again_response = gets.chomp\n end\n end\n end\n\n puts 'Rock, Paper, Scissors, Shoot!!!'\n puts 'What do you choose, Rock, Paper, or Scissors?'\n answer = gets.chomp\n\n # Gets what the user is picking for his hand (rock, paper, or scissors)\n while answer != nil\n if (answer.downcase == 'rock') || (answer.downcase == 'paper') || (answer.downcase == 'scissors')\n break\n else\n puts 'You entered '+answer.capitalize+' which isn\\'t one of the following words, Scissors, Paper, or Rock. Please try again.'\n answer = gets.chomp\n end\n end\n\n computers_answer = cpu_answer\n puts 'You chose '+answer.capitalize+' and the computer chose '+computers_answer+'!'\n winner(answer, computers_answer)\n play_again('yes')\nend",
"def rps(user_weapon)\n weapons = [\"rock\", \"paper\", \"scissors\"]\n computer_weapon = weapons.shuffle.last\n\n if user_weapon == \"rock\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Draw!\"\n when \"paper\"\n return \"Paper, Lose!\"\n when \"scissors\"\n return \"Scissors, Win!\"\n end\n elsif user_weapon == \"paper\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Win!\"\n when \"paper\"\n return \"Paper, Draw!\"\n when \"scissors\"\n return \"Scissors, Lose!\"\n end\n elsif user_weapon == \"scissors\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Lose!\"\n when \"paper\"\n return \"Paper, Win!\"\n when \"scissors\"\n return \"Scissors, Draw!\"\n end\n end\n\nend",
"def rps_game\n puts \"Player 1 enter rock, paper, or scissors: \"\n player1 = gets.chomp\n puts \"Player 2 enter rock, paper, or scissors: \"\n player2 = gets.chomp\n if player1 != \"rock\" || player1 != \"paper\" || player1 != \"scissors\"\n puts \"Player 1 MUST enter rock, paper, or scissors! \"\n elsif player2 != \"rock\" || player2 != \"paper\" || player2 != \"scissors\"\n puts \"Player 2 MUST enter rock, paper, or scissors! \"\n elsif player1 == \"rock\" && player2 == \"paper\"\n puts \"Player 2 wins\"\n elsif player1 == \"rock\" && player2 == \"scissors\"\n puts \"Player 1 wins\"\n elsif player2 == \"rock\" && player1 == \"paper\"\n puts \"Player 1 wins\"\n elsif player2 == \"rock\" && player1 == \"scissors\"\n puts \"Player 2 wins\"\n elsif player1 == \"paper\" && player2 == \"scissors\"\n puts \"Player 2 wins\"\n elsif player1 == \"paper\" && player2 == \"rock\"\n puts \"Player 2 wins\"\n else\n puts \"Its a tie!\"\n end\nend",
"def won\n divider\n if @input == @comp\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦┌┬┐┌─┐ ┌─┐ ┌┬┐┬┌─┐ \n ║ │ └─┐ ├─┤ │ │├┤ \n ╩ ┴ └─┘ ┴ ┴ ┴ ┴└─┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\" \n play_again\n elsif @input == \"rock\" && @comp == \"scissors\" || @input == \"paper\" && @comp == \"rock\" || @input == \"scissors\" && @comp == \"paper\"\n @u_score += 1\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦┌─┐┬ ┬ ┬ ┬┬┌┐┌┬\n ╚╦╝│ ││ │ ││││││││\n ╩ └─┘└─┘ └┴┘┴┘└┘o\"\n divider2\n puts \"Current Score: [User] #{@u_score} *** [Computer] #{@c_score}\"\n play_again\n elsif \n @c_score += 1\n @input == \"rock\" && @comp == \"paper\" || @input == \"paper\" && @comp == \"scissors\" || @input == \"scissors\" && @comp == \"rock\"\n puts \"You picked #{@input}. Computer picked #{@comp}.\"\n puts \"\n ╦ ╦╔═╗╦ ╦ ╦ ╔═╗╔═╗╔═╗┬┬┬\n ╚╦╝║ ║║ ║ ║ ║ ║╚═╗║╣ │││\n ╩ ╚═╝╚═╝ ╩═╝╚═╝╚═╝╚═╝ooo\"\n divider2\n puts \"Current Score: [User] #{@u_score} /// [Computer] #{@c_score}\"\n play_again\n else\n puts \"You dun fucked up, I'm not even telling you the score because I don't even know how you got here bro\"\n play_again\n end\n end",
"def rps_game()\n print \"Player 1: Rock, paper, scissors? \"\n move1 = gets.chomp.downcase\n print \"Player 2: Rock, paper, scissors? \"\n move2 = gets.chomp.downcase\n\n if move1 == \"rock\"\n if move2 == \"rock\"\n puts \"It's a tie\"\n elsif move2 == \"paper\"\n puts \"Player 2 wins\"\n elsif move2 == \"scissors\"\n puts \"Payer 1 wins\"\n else\n puts \"Wrong input!\"\n end\n elsif move1 == \"paper\"\n if move2 == \"rock\"\n puts \"Player 1 wins\"\n elsif move2 == \"paper\"\n puts \"It's a tie\"\n elsif move2 == \"scissors\"\n puts \"Player 2 wins\"\n else\n puts \"Wrong input!\"\n end\n elsif move1 == \"scissors\"\n if move2 == \"rock\"\n puts \"Player 2 wins\"\n elsif move2 == \"paper\"\n puts \"Player 1 wins\"\n elsif move2 == \"scissors\"\n puts \"It's a tie\"\n else\n puts \"Wrong input!\"\n end\n else\n puts \"Wrong input!\"\n end\nend",
"def user_choose_rps\n\tputs \"Enter rock, paper or scissors:\"\n user = gets.chomp\n user\nend",
"def play_game\n\t#user_choose_rps \n\tcomp_choice = comp_choose_rps #<-- no need to use this because it's used once \n\tuser_choice = user_choose_rps \n\tputs \"The computer chose #{comp_choice}. You chose #{user_choice}.\" \n\tputs get_winner(comp_choice, user_choice) \n\treplay \nend",
"def rockPaperScissors\n sleep(2)\n puts \"Well that was a bit easy\"\n sleep(1)\n puts \"Let's increase her intelligence just a little\"\n sleep(2)\n puts \"ai.intelligence = 30\"\n bar = TTY::ProgressBar.new(\"Initializing [:bar]\", total: 50)\n 50.times do\n sleep(0.02)\n bar.advance # by default increases by 1\n end\n sleep(1)\n puts \"Intelligence now equals 30\".colorize(:magenta)\n sleep(2)\n puts \"Great, now lets test it with a game of Rock, Paper, Scissors\"\n sleep(2)\n puts \"AI initialize a game of Rock, Paper, Scissors\"\n sleep(1)\n rps = TTY::ProgressBar.new(\"Initializing [:bar]\", total: 50)\n 50.times do\n sleep(0.02)\n rps.advance # by default increases by 1\n end\n end",
"def rock_battle\n if computer_rand == \"p\"\n puts \"Paper beats rock.\"\n puts \"The computer won.\"\n elsif computer_rand == \"s\"\n puts \"Rock beats scissors.\"\n puts \"You won!\"\n end\nend",
"def paper_scissors_rock\n clear_screen\n draw_shovel_line\n\tputs \"\\n Play with the Sphinx's stomach to get out!\\n\"\n sleep(1)\n\tresult = rand(3).floor\n\task_user \"\\n What have you got?:\" , \" \\n\\n 1| for paper \\u{1F4C3}\\n 2| for scissors \\u{2702}\\n 3| for rock \\u{270A}\\n\\n\"\n\tsleep(0.5)\n puts \" \\u{1F449}\"\n choice = gets.chomp.to_i\n\n\tif choice == result\n\t\tsay \"\\nIt's a tie!\\n\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice < result\n\t\tsay \"\\nSorry, you lost\\n Try again!\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice > result\n\t\tputs \"\\n You won! Get out!!!!\\n\"\n sleep(1.5)\n draw_shovel_line\n sleep(1.5)\n\n\tend\nend",
"def rps_game_winner(game)\n raise WrongNumberOfPlayersError unless game.length == 2\n @first_player = game[0];\n @second_player = game[1];\n \n raise NoSuchStrategyError unless (@first_player[1] =~ /\\A[RPS]\\z/i) and (@second_player[1] =~ /\\A[RPS]\\z/i)\n # if the first and second player chose the same move, the first player wins\n if @first_player[1] == @second_player[1]\n @winner = @first_player;\n # if the first and second player choose different moves... who wins?\n else\n # if the first player chooses rock\n if @first_player[1].upcase == 'R'\n # second player wins if he chooses paper\n if @second_player[1].upcase == 'P'\n @winner = @second_player\n # second player loses if he chooses scissors\n else\n @winner = @first_player\n end\n # if the first player chooses paper\n elsif @first_player[1].upcase == 'P'\n # second player loses if he chooses rock\n if @second_player[1].upcase == 'R'\n @winner = @first_player\n # second player wins if he chooses scissors\n else\n @winner = @second_player\n end\n # if the first player chooses scissors\n else\n # second player loses if he chooses paper\n if @second_player[1].upcase == 'P'\n @winner = @first_player\n # second player wins if he chooses rock\n else\n @winner = @second_player\n end\n end\n end\n # return the winner\n return @winner;\nend",
"def round_win(p1_answer, p2_answer)\n\tif p1_answer == p2_answer\n\t\treturn 0\n\telsif p1_answer == \"rock\" and p2_answer == \"paper\"\n\t\treturn 2\n\telsif p1_answer == \"scissors\" and p2_answer == \"rock\"\n\t\treturn 2\n\telsif p1_answer == \"paper\" and p2_answer == \"scissors\"\n\t \treturn 2\n\telse\n\t\treturn 1\n\tend\nend",
"def play_game\nget_winner(comp_choose_rps,user_choose_rps)\t\nend",
"def winner(answer, computers_answer)\n if (answer.downcase == 'rock') && (computers_answer.downcase == 'paper')\n puts 'YOU LOSE'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'rock')\n puts 'WINNER'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'scissors')\n puts 'You Lose'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'paper')\n puts 'WINNER'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'rock')\n puts 'You Lose'\n elsif (answer.downcase == 'rock') && (computers_answer.downcase == 'scissors')\n puts 'Winner'\n else\n puts 'You both tied. Go again.'\n rock_paper_scissors_game\n exit\n end\n end",
"def play_round\n puts \"Your throw: #{@user_current_throw}\"\n puts \"Computers throw: #{@comp_current_throw}\"\n case @user_current_throw\n when @rock\n if @comp_current_throw == @rock\n puts \"Tie! play again\"\n elsif @comp_current_throw == @scissors\n @user_score += 1\n puts \"You win this round!\"\n elsif @comp_current_throw == @paper\n @comp_score += 1\n puts \"Computer wins this round\"\n end\n when @paper\n if @comp_current_throw == @paper\n puts \"Tie! play again\"\n elsif @comp_current_throw == @rock\n @user_score += 1\n puts \"You win this round!\"\n elsif @comp_current_throw == @scissors\n @comp_score += 1\n puts \"Computer wins round\"\n end\n when @scissors\n if @comp_current_throw == @scissors\n puts \"Tie! play again\"\n elsif @comp_current_throw == @paper\n @user_score += 1\n puts \"You win this round!\"\n else\n puts \"Computer wins round\"\n @comp_score += 1\n end\n end #end of case/when\n puts \"Current scores: You: #{@user_score} Computer: #{@comp_score}\"\n end",
"def run\n player1 = Player.new(\"You\")\n player2 = Player.new(\"Computer\")\n rps = RockPaperScissors.new\n\t\tbegin\n\t\t\tputs \"---------Play Rock Paper Scissors!----------------\"\n\n\t\t\tplayer1.choose_by_input\n\t\t\tplayer2.choose_by_rand\n\n\t\t\tputs \"#{player1.name} picked #{player1.gesture}, and #{player2.name} picked #{player2.gesture}\"\n\n\t\t\trps.arbitrate(player1, player2)\n\n\t\t\tputs \"Do you want to play again? (Y/N)\"\n\t\t\tplay=gets.chomp.downcase\n\t\t\tplay = ( play =='y') ? TRUE: FALSE\n\n\t\tend while play==TRUE\n\tend",
"def main_game\n p1_wins = 0\n p2_wins = 0\n puts \"Let's play Rock-Paper-Scissors!\"\n games = how_many_games\n best_of(games)\n\n until p1_wins == games || p2_wins == games\n winner = one_round\n display_winner(winner)\n p1_wins += track_p1_wins(winner)\n p2_wins += track_p2_wins(winner)\n end\n\n overall_winner = overall_winner?(p1_wins, p2_wins)\n display_overall_winner(overall_winner)\nend",
"def rules\n \"Choose rock, paper, scissors, lizard, or spock.\"\n end",
"def rules (player_choice, comp_choice, comp_score, player_score)\n\t\tputs \"Player: #{player_choice}\"\n\t\tputs \"Computer: #{comp_choice}\"\n\t\tif player_choice == comp_choice\n\t\t\tputs \"Tie\"\n\t\t\tcomp_score+=1\n\t\t\tplayer_score+=1\n\t\t\tmenu(player_score, comp_score)\n\t\telsif player_choice == 'rock'\n\t\t\tif comp_choice == 'paper'\n\t\t\t\tputs \"Comp wins\"\n\t\t\t\tcomp_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\telse\n\t\t\t\tputs \"Player wins\"\n\t\t\t\tplayer_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\tend\n\t\telsif player_choice == 'paper'\n\t\t\tif comp_choice == 'scissors'\n\t\t\t\tputs \"Comp wins\"\n\t\t\t\tcomp_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\telse \n\t\t\t\tputs \"Player wins\"\n\t\t\t\tplayer_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\tend\n\t\telsif player_choice == 'scissors'\n\t\t\tif comp_choice == 'rock'\n\t\t\t\tputs \"Comp wins\"\n\t\t\t\tcomp_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\telse \n\t\t\t\tputs \"Player wins\"\n\t\t\t\tplayer_score+=1\n\t\t\t\tmenu(player_score, comp_score)\n\t\t\tend\n\t\telse \n\t\t\tputs \"Not a valid choice.\"\n\t\t\tmenu(player_score, comp_score)\n\t\tend\n\tend",
"def get_winner(comp,user)\n if (comp == user) \n puts \"It was a tie!\"\n elsif (comp ==\"rock\" && user == \"scissors\") || (comp ==\"paper\" && user == \"rock\") || (comp ==\"scissors\" && user == \"paper\")\n puts \"The computer wins!\"\n elsif ( comp == \"scissors\" && user ==\"rock\") || (comp == \"rock\" && user ==\"paper\") || (comp == \"paper\" && user ==\"scissors\")\n puts \"You win!\"\n else \n \tputs \"You did not pick either of the choices! Let's try this again.\" \n \tplay_game\n end \nend",
"def main()\n \n obj = RPS.new()\n obj.play_best_of()\n\nend",
"def - rival\n case rival\n when Rock\n puts 'Rock tie (loser Rock)'\n when Paper\n puts 'Paper covers Rock (loser Rock)'\n when Spock\n puts 'Spock vaporizes Rock (loser Rock)'\n else\n return rival - self\n end\n Rock\n end",
"def play\n # print \"\\n Welcome to the game of Scissors-Paper-Rock\"\n print \"\\n Enter your name: \"\n user_name = gets.chomp\n until @user_score == @score_required || @computer_score == @score_required\n options = ['scissors', 'paper', 'rock']\n \n print \"\\nHi #{user_name}, please select 's' for scissors, 'p' for paper or 'r' for rock. \"\n \n # Display user selection:\n selected_options = gets.chomp\n \n puts \"User has selected #{user_choice}.\"\n # p user_choice\n\n # display the computer's randomised selection:\n # options = ['s', 'p', 'r']\n @computer_choice = options.sample\n # p computer_choice\n puts \"Computer has selected #{computer_choice}.\"\n\n result()\n end\n \n return @user_score > @computer_score ? (puts \"Game over! you won!\"): (puts \"Game over! Computer won!\")\n \n end",
"def +(arg)\n if(arg == Rock)\n puts(\"Paper covers Rock (winner Paper)\")\n self\n elsif(arg == Spock)\n puts(\"Paper disproves Spock (winner Paper)\")\n self\n elsif(arg == Paper)\n puts(\"Paper tie (winner Paper)\")\n self\n else\n arg + self\n end\n end",
"def winner(player, comp)\n return 'tie' if player == comp\n if player == 'rock'\n comp == 'scissors' ? 'player' : 'comp'\n elsif player == 'paper'\n comp == 'rock' ? 'player' : 'comp'\n else # player = scissors\n comp == 'rock' ? 'comp' : 'player'\n end\nend",
"def play(p1_choice,p2_choice)\n if p1_choice == \"rock\"\n if p2_choice == \"paper\"\n self.winner_id = p2_choice.id\n elsif p2_choice == \"scissor\"\n self.winner_id = p1_choice.id\n end\n\n return winner_id\n end\n\n if p1_choice == \"paper\"\n if p2_choice == \"rock\"\n return @winner_id = p1_choice.id\n elsif p2_choice == \"scissor\"\n return @winner_id = p2_choice.id\n else\n return @winner_id\n end\n end\n\n if p1_choice == \"scissor\"\n if p2_choice == \"rock\"\n return @winner_id = p2_choice.id\n elsif p2_choice == \"paper\"\n return @winner_id = p1_choice.id\n else\n return @winner_id\n end\n end\n\n\n # plays game\n # return either p1_choice or p2_choice winner\n end",
"def determine_winner(comp_choice, player_choice)\n rock = 0\n paper = 1\n scissors = 2\n\n player_won = 0\n comp_won = 1\n tie = 2\n\n if comp_choice == rock\n if player_choice = rock\n return tie\n elsif player_choice = paper\n return player_won\n else\n return comp_won\n end\n elsif comp_choice == paper\n if player_choice = rock\n return comp_won\n elsif player_choice = paper\n return tie\n else\n return player_won\n end\n else \n if player_choice = rock\n return player_won\n elsif player_choice = paper\n return comp_won\n else\n return tie\n end\n end\nend",
"def print_which_player_wins player_picked, comp_picked\n if player_picked == comp_picked\n puts \"It's a tie!\"\n elsif player_picked == \"Paper\"\n if comp_picked == \"Rock\"\n puts \"Paper wraps Rock, you win!\"\n elsif comp_picked == \"Scissors\"\n puts \"Scissors cuts Paper, you lose!\"\n end\n elsif player_picked == \"Rock\"\n if comp_picked == \"Paper\"\n puts \"Paper wraps Rock, you lose!\"\n elsif comp_picked == \"Scissors\"\n puts \"Rock crushes Scissors, you win!\"\n end\n elsif player_picked == \"Scissors\"\n if comp_picked == \"Paper\"\n puts \"Scissors cut Paper, you win!\"\n elsif comp_picked == \"Rock\"\n puts \"Rock crushes Scissors, you lose!\"\n end\n end\nend",
"def pick_rps\n rpsArr.sample\n end",
"def user_plays_rock\n #we keep as much of our ruby code here as possible\n \n # we first create an array of computer moves\n @computer_move_list = [\"rock\", \"paper\", \"scissors\"]\n \n #randomly choose computer move\n @computer_move = @computer_move_list.sample\n \n # Logic for moves and results\n\n #initialize result as nil\n @rock_game_result = nil\n \n if (@computer_move == \"rock\")\n @rock_game_result = \"We tied!\"\n elsif (@computer_move == \"paper\")\n @rock_game_result = \"We lost!\"\n else\n @rock_game_result = \"We won!\"\n end\n \n render(\"move_templates/played_rock.html.erb\")\n end",
"def result\n 'Rock'\n end",
"def choose_weapons\n puts \"Choose 'r' for rock, 'p' for paper or 's' for scissors\"\n return gets.chomp.downcase\n end",
"def computer_choice \r\n\t\t@computer = [\"rock\", \"paper\", \"scissors\"].shuffle.first\r\n\tend",
"def rps_game_winner(game)\n raise WrongNumberOfPlayersError unless game.length == 2\n @P1 = game[0][1]\n @P2 = game[1][1]\n\n \n if(@P1.match(/[RPS]/)) && (@P2.match(/[RPS]/))\n\n if(@P1 == \"R\") && (@P2 == \"S\")\n return game[0]\n elsif(@P1 == \"R\") && (@P2 == \"P\")\n\treturn game[1]\n end\n\t\n if(@P1 == \"P\") && (@P2 == \"R\")\n return game[0]\n elsif(@P1 == \"P\") && (@P2 == \"S\")\n\treturn game[1]\n end\n \n \n if(@P1 == \"S\") && (@P2 == \"P\")\n\treturn game[0]\n elsif(@P1 == \"S\") && (@P2 == \"R\")\n\treturn game[1]\n end\n end\n\n end",
"def exchange\n :rock\n end",
"def rpc\n puts \"Rock Paper Scissors?\"\n user_choice = gets.strip\n cpu_choice = ['rock', 'paper', 'scissors'].sample\n puts cpu_choice\n if user_choice === cpu_choice\n puts 'Tie'\n else\n case user_choice\n when 'rock'\n result = (cpu_choice === 'scissors') ? 'Win' : 'Lose'\n puts result\n when 'paper'\n result = (cpu_choice === 'rock') ? 'Win' : 'Lose'\n puts result\n when 'scissors'\n result = (cpu_choice === 'paper') ? 'Win' : 'Lose'\n puts result\n else\n user_choice\n end\n end\nend",
"def rps\n\n\n @user_move=params[\"the_move\"]\n @computer_move= [\"rock\", \"paper\", \"scissors\"].sample\n\n\n if @user_move == @computer_move\n @outcome = \"tied\"\n elsif @user_move == \"paper\" && @computer_move == \"rock\"\n @outcome = \"won\"\n elsif @user_move == \"paper\" && @computer_move == \"scissors\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"rock\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"paper\"\n @outcome = \"won\"\n elsif @user_move == \"rock\" && @computer_move == \"paper\"\n @outcome = \"lost\"\n elsif @user_move == \"rock\" && @computer_move == \"scissors\"\n @outcome = \"won\"\n end\n\n\n m = Move.new\n m.user_move = @user_move\n m.computer_move = @computer_move\n if @outcome == \"won\"\n m.user_wins = 1\n m.computer_wins = 0\n m.tie= 0\n elsif @outcome == \"lost\"\n m.user_wins = 0\n m.computer_wins = 1\n m.tie= 0\n else\n m.user_wins = 0\n m.computer_wins=0\n m.tie= 1\n end\n\n m.save\n\n @all_moves= Move.all\n @rockwin=Move.where({:user_move => \"rock\",:user_wins => \"1\"}).count\n @paperwin=Move.where({:user_move => \"paper\",:user_wins => \"1\"}).count\n @scissorswin=Move.where({:user_move => \"scissors\",:user_wins => \"1\"}).count\n\n @rocklose=Move.where({:user_move => \"rock\",:computer_wins => \"1\"}).count\n @paperlose=Move.where({:user_move => \"paper\",:computer_wins => \"1\"}).count\n @scissorslose=Move.where({:user_move => \"scissors\",:computer_wins => \"1\"}).count\n\n\n @rocktie=Move.where({:user_move => \"rock\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @papertie=Move.where({:user_move => \"paper\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @scissorstie=Move.where({:user_move => \"scissors\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n\n @totalwin=Move.where({:user_wins => \"1\", }).count\n @totallose=Move.where({:computer_wins => \"1\"}).count\n @totaltie=Move.where({:tie => \"1\",}).count\n\n @total = @totalwin + @totallose + @totaltie\n\n\n\n\n render \"rps.html.erb\"\n end",
"def scoreRock m\n\t\t[1,0]\n\tend",
"def winner(p,c)\n if p == c\n output \"It's a Draw!\"\n elsif (\"#{p}\" == 'Rock' && \"#{c}\" == 'Paper')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Paper' && \"#{c}\" == 'Scissors')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Scissors' && \"#{c}\" == 'Rock')\n output \"Computer wins!\"\n else \"Player wins!\"\n end\nend",
"def computer_ai_3\n rock = 0\n paper = 0\n scissors = 0\n most_played = \"r\"\n choice = \"p\"\n\n # Find which moves have been played the most.\n \n @human_moves.each do |move|\n if move == 'r'\n rock = rock + 1\n elsif move == 'p'\n paper = paper + 1\n elsif move == 's'\n scissors = scissors + 1\n end\n end\n\n if rock > paper && rock > scissors\n most_played = \"r\"\n elsif paper > rock && paper > scissors\n most_played = \"p\"\n elsif scissors > paper && scissors > rock \n most_played = \"s\"\n else\n #choose random if they tie\n choices =['r', 'p', 's']\n most_played = choices.sample\n end\n\n #play the hand that beats the human move.\n if most_played == 'r'\n choice = 'p'\n elsif most_played == 'p'\n choice = 's'\n elsif most_played == 's'\n choice = 'r'\n end\n\n return choice\n end",
"def scoreRock m\n\t\t[0,1] \n\tend",
"def play_game\n puts \"Would you like to play\"\n puts \"Rock-Paper-Scissor (RPS)\" \n puts \"OR\" \n puts \"Rock-Paper-Scissor-Lizard-Spock? (RPSLS)\"\n h_line\n rule_type = check_input([\"RPS\",\"RPSLS\"])\n rules = rule_type == \"RPS\" ? RPS_Rules.new : RPSLS_Rules.new\n puts \"Ok! Let's play \" + rules.prompt + \"!\"\n h_line\n p1 = create_player(1,rules)\n p2 = create_player(2,rules)\n h_line\n puts \"Great. How many points are you playing to? (1-5)\"\n valid = [\"1\",\"2\",\"3\",\"4\",\"5\"]\n length = check_input(valid).to_i\n this_game = Game.new(p1,p2,length,rules)\n h_line\n puts \"Ok!\"\n puts rules.prompt + \":\"\n puts this_game.p1.control + \":\" +this_game.p1.name + \" > VERSUS < \" + this_game.p2.name + \":\" + this_game.p2.control\n puts \"First to \" + length.to_s + \" points wins!\"\n pause\n this_game.run_game\nend",
"def analyze_results(player, computer)\r\n\r\n #Analyze the results of the game when the player selects ROCK\r\n if player == \"ROCK\" then\r\n if computer == \"SCISSORS\" then\r\n $wins += 1\r\n return \"Rock crushes Scissors. Player wins!\"\r\n end\r\n if computer == \"ROCK\"\r\n $tied += 1\r\n return \"Rock equals Rock. Tie!\"\r\n end\r\n if computer == \"PAPER\"\r\n $lost += 1\r\n return \"Rock is covered by Paper. Computer wins!\"\r\n end\r\n end\r\n\r\n #Analyze the results of the game when the player selects PAPER\r\n if player == \"PAPER\" then\r\n if computer == \"ROCK\" then\r\n $wins += 1\r\n return \"Paper covers Rock. Player wins!\"\r\n end\r\n if computer == \"PAPER\"\r\n $tied += 1\r\n return \"Paper equals Paper. Tie!\"\r\n end\r\n if computer == \"SCISSORS\"\r\n $lost += 1\r\n return \"Paper is cut by Scissors. Computer wins!\"\r\n end\r\n end\r\n\r\n #Analyze the results of the game when the player selects SCISSORS\r\n if player == \"SCISSORS\" then\r\n if computer == \"PAPER\" then\r\n $wins += 1\r\n return \"Scissors cut Paper. Player wins!\"\r\n end\r\n if computer == \"SCISSORS\"\r\n $tied += 1\r\n return \"Scissors equals Scissors. Tie!\"\r\n end\r\n if computer == \"ROCK\"\r\n $lost += 1\r\n return \"Scissors are crushed by Rock. Computer wins!\"\r\n end\r\n end\r\n\r\n end",
"def play\n title\n divider\n puts \"Choose 'Rock', 'Paper', or 'Scissors'\"\n input = gets.strip\n input_downcase(input)\n if valid_selection?\n computer_selection\n won\n else\n play\n end\n end",
"def rps_game_winner(game)\n\traise WrongNumberOfPlayersError if !game.is_a?(Array) || game.size != 2\n\traise NoSuchStrategyError if game.collect{|i| i[1]}.join.match(/^[rps]{2}$/i).nil?\n\n\t# i'll use uppercase (replicating)\n\tgames = game.map{|g| [g[0], g[1].upcase]}\n\n\trule_to_win = { \"R\" => \"S\", \"P\" => \"R\", \"S\" => \"P\" }\n\t\n\tif rule_to_win[games[0][1]] == games[1][1] || games[0][1] == games[1][1]\n\t\tgame[0]\n\telse\n\t\tgame[1]\n\tend\nend",
"def analyze_results(player, computer)\r\n \r\n #Analyze the results of the game when the player selects ROCK\r\n if player =~ /ROCK|R/i then\r\n if computer == \"SCISSORS\"\r\n $wins += 1\r\n return \"Rock destroys scissors! Player wins!\"\r\n elsif computer == \"ROCK\"\r\n $ties += 1\r\n return \"Tie!\"\r\n else\r\n $lost += 1\r\n return \"Paper covers rock! Computer Wins!\"\r\n end \r\n end\r\n\r\n if player =~ /PAPER|P/i then\r\n if computer == \"ROCK\"\r\n $wins += 1\r\n return \"Paper covers rock! Player wins!\" \r\n elsif computer == \"PAPER\"\r\n $ties += 1\r\n return \"Tie!\"\r\n else\r\n $lost += 1 \r\n return \"Scissors cut paper! Computer wins!\"\r\n end\r\n end\r\n\r\n if player =~ /SCISSORS|S/i then\r\n if computer == \"PAPER\"\r\n $wins += 1\r\n return \"Scissors cut paper! Player wins!\" \r\n elsif computer == \"SCISSORS\"\r\n $ties += 1\r\n return \"Tie!\"\r\n else\r\n $lost += 1\r\n return \"Rock destroys scissors! Computer wins!\"\r\n end\r\n end\r\n end",
"def choose\n \n case @last_opponent_choice\n when :paper\n [:rock, :scissors][rand(2)]\n when :rock\n [:paper, :scissors][rand(2)]\n when :scissors\n [:rock, :scissors][rand(2)]\n end\n \n #:paper\n \n \n end",
"def start_game\n\nai = ['R','P','S'].sample\n\nprompt(\"Choose paper(p), rock(r) or scissor(s)\")\nhuman = gets.chomp.upcase\n\n case\n when human == \"P\" && ai == \"P\"\n prompt(\"You chose Paper and I chose Paper: Tie\")\n when human == \"R\" && ai == \"R\"\n prompt(\"You chose Rock and I chose Rock: Tie\")\n when human == \"S\" && ai == \"S\"\n prompt(\"You chose Scissors and I chose Scissors: Tie\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose paper and I chose Rock, you win!\")\n when human == \"R\" && ai == \"S\"\n prompt(\"You chose Rock and I chose Scissors, You win!\")\n when human == \"S\" && ai == \"P\"\n prompt(\"You chose Scissors and I chose Paper, You win!\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose Paper and I chose Rock, You win! \")\n when human == \"S\" && ai == \"R\"\n prompt(\"You chose Scissors and I chose Rock, I win!\")\n when human == \"P\" && ai == \"S\"\n prompt(\"You chose Paper and I chose Scissors, I win\")\n when human == \"R\" && ai == \"P\"\n prompt(\"You chose Rock and I chose Paper, I win!\")\n end\nend",
"def play_a_game\n\t#PLAYER 1 choses a valid selection of r,p,s\n\tprint \"\\nPLAYER 1, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_1_choice = choice\n\n\tputs \"-------------------------------------------------\"\n\tprint \"\\nPLAYER 2, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\t\t#PLAYER 2 choses a valid selection of r,p,s\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_2_choice = choice\n\n\tputs lets_see_who_wins(player_1_choice, player_2_choice)\n\nend",
"def game\n puts \"\\nTake your pick: (R)ock, (P)aper, (S)cissors\"\n sleep(1)\n puts \"\\nShoot!\"\n\n computer = \"rps\"[rand(3)].chr\n player = gets.chomp.downcase\n case [player, computer]\n when ['r','s'],['s','p'],['p','r']\n puts \"\\nWIN\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['r','r'],['p','p'],['s','s']\n puts \"\\nTIE\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['s','r'],['p', 's'],['r', 'p']\n puts \"\\nLOSER\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n else\n puts \"\\nARE YOU A MORON? CHOOSE R,P,S\"\n game\n end\nend",
"def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end",
"def if_player_1_wins?\n\t($p1 == \"scissors\" && $p2 == \"paper\") || ($p1 == \"rock\" && $p2 == \"scissors\") || ($p1 == \"paper\" && $p2 == \"rock\") || ($p1 == \"rock\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 == \"scissors\") || ($p1 == \"scissors\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 == \"rock\") || ($p1 == \"lizard\" && $p2 == \"paper\") || ($p1 == \"paper\" && $p2 == \"spock\")|| ($p1 == \"lizard\" && $p2 == \"spock\") \nend",
"def player_input\n loop do\n puts \"Type 'r', 'p' or 's'.\\n\"\n computer_choice = strategy_implement(strategy)\n input = gets.chomp.downcase\n if input == 'r'\n value = {rock: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Rock\\n\"\n play_game(value.keys.pop, computer_choice)\n @previous_player_choice = value\n add_player_choice_to_log\n elsif input == 'p'\n value = {paper: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Paper\\n\"\n play_game(value.keys.pop, computer_choice)\n add_player_choice_to_log\n @previous_player_choice = value\n elsif input == 's'\n value = {scissors: 1}\n player_choice.clear\n player_choice.merge!(value)\n puts \"Scissors\\n\"\n play_game(value.keys.pop, computer_choice)\n add_player_choice_to_log\n @previous_player_choice = value\n elsif input == 'exit'\n exit_message\n break\n else\n puts \"That is not a valid choice - please try again\"\n end\n end\n end",
"def determineWinner(p1_weapon, p2_weapon)\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telse\n\t\ttext = \"Please enter rock, paper, or scissors!\"\n\tend\n\tputs text\n\treturn text\nend",
"def winner(user, computer)\r\n winner = \"\"\r\n if (user == 'p' && computer == 'r')||\r\n (user == 's' && computer == 'p') ||\r\n (user == 'r' && computer == 's')\r\n winner = \"You\"\r\n elsif (computer == 'p' && user == 'r')||\r\n (computer == 's' && user == 'p') ||\r\n (computer == 'r' && user == 's')\r\n winner = \"Computer\"\r\n else\r\n winner = \"tie\"\r\n end\r\n \r\n if winner == \"tie\"\r\n puts \"It's a tie!\"\r\n else\r\n puts \"#{winner} won!\"\r\n end\r\nend",
"def play_paper\n @computer_move = [\"rock\",\"paper\",\"scissors\"].sample\n if @computer_move == \"paper\"\n @outcome = \"tie\"\n elsif @computer_move == \"scissors\"\n @outcome = \"lose\"\n else\n @outcome = \"win\"\n end\n render(\"games/play_paper.html.erb\")\n end",
"def computer_score(computer)\n\t\t@criticsScore = session[:movie][session[:round_count]].ratings['critics_score'].to_i\n\t\t#Scoring Logic\n\t\tcase computer.difficulty\n\t\twhen 0\n\t\t\tcomputer.guess = rand(1..100)\n\t\t\tcomputer.round_score = (computer.guess - @criticsScore).abs\n\t\t\tcomputer.total_score += (computer.guess - @criticsScore).abs\n\t\twhen 1\n\t\t\t@lower = @criticsScore - 25\n\t\t\t@upper = @criticsScore + 25\n\t\t\t@lower = @lower < 0 ? 0 : @lower\n\t\t\t@upper = @upper > 100 ? 100 : @upper\n\t\t\tcomputer.guess = rand(@lower..@upper)\n\t\t\tcomputer.round_score = (computer.guess - @criticsScore).abs\n\t\t\tcomputer.total_score += (computer.guess - @criticsScore).abs\n\t\twhen 2\n\t\t\t@lower = @criticsScore - 15\n\t\t\t@upper = @criticsScore + 15\n\t\t\t@lower = @lower < 0 ? 0 : @lower\n\t\t\t@upper = @upper > 100 ? 100 : @upper\n\t\t\tcomputer.guess = rand(@lower..@upper)\n\t\t\tcomputer.round_score = (computer.guess - @criticsScore).abs\n\t\t\tcomputer.total_score += (computer.guess - @criticsScore).abs\n\t\tend\n\n\tend",
"def rps_result(m1, m2)\n valid_move = [\"R\", \"P\", \"S\"]\n game_checker = [\"RS\", \"SP\", \"PR\", \"RR\", \"SS\", \"PP\" ]\n move = m1[1].upcase + m2[1].upcase\n if @debug\n printf m1[0] + \"(\" + m1[1] + \") against \" + m2[0] + \"(\" + m2[1] + \")\"\n printf \",move:\" + move\n end\n raise NoSuchStrategyError unless \n valid_move.include?(m1[1].upcase) && \n valid_move.include?(m2[1].upcase)\n if game_checker.include?(move) \n if @debug ; printf \">\" + m1[0] + \" wins\\n\" ; end \n return m1\n else\n if @debug ; printf \">\" + m2[0] + \" wins\\n\" ; end \n return m2\n end\nend",
"def score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{c_score}\"\n puts \" \"\n end",
"def rps(c)\n puts \"enter r, p, or s\"\n o = [\"r\", \"p\", \"s\"]\n d = o.sample\n if (c == d)\n puts 'tie'\n elsif (c == \"r\" && d == \"p\" || c == \"s\" && d == \"r\" || c == \"p\" && d == \"s\")\n puts 'You Lose'\n else\n puts 'You win'\n end\nend",
"def - rival\n case rival\n when Paper\n puts 'Paper tie (loser Paper)'\n when Scissors\n puts 'Scissors cut Paper (loser Paper)'\n when Lizard\n puts 'Lizard eats Paper (loser Paper)'\n else\n return rival - self\n end\n Paper\n end",
"def rps_game_winner(game)\n raise WrongNumberOfPlayersError unless game.length == 2\n game.each do |sign|\nif sign[1] != \"R\" and sign[1] != \"P\" and sign[1] != \"S\"\nraise NoSuchStrategyError\nend\n end\n if game[0][1] == \"R\" and game[1][1] != \"P\"\nreturn game[0]\n elsif game[0][1] == \"P\" and game[1][1] != \"S\"\nreturn game[0]\n elsif game[0][1] == \"S\" and game[1][1] != \"R\"\nreturn game[0]\n else\nreturn game[1]\n end\nend",
"def +(value)\n if(value == Spock)\n puts \"Paper disproves Spock (winner Paper)\"\n self\n elsif(value == Rock)\n puts \"Paper covers Rock (winner Paper)\"\n self\n elsif(value == Paper)\n puts \"Paper tie (winner Paper)\"\n self\n else\n value + self\n end\n end",
"def - rival\n case rival\n when Scissors\n puts 'Scissors tie (loser Scissors)'\n when Rock\n puts 'Rock crushes Scissors (loser Scissors)'\n when Spock\n puts 'Spock smashes Scissors (loser Scissors)'\n else\n return rival - self\n end\n Scissors\n end",
"def scoreRock m\n\t\t[0,0]\n\tend",
"def determineWinner(p1_weapon, p2_weapon)\n\ttext = \"\"\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"scissors\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"rock\" then text = \"Tie!\" \n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"rock\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"paper\" then text = \"Tie!\"\n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"paper\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"scissors\" then text = \"Tie!\"\n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telse \n\t\ttext = \"P1 must choose Rock, Paper or Scissors.\"\n\t\tunless p2_weapon == \"rock\" || p2_weapon == \"paper\" || p2_weapon == \"scissors\"\n\t\t\ttext = text + \"\\nPlayer 2 must choose rock, paper, or scissors. Replay round.\"\n\t\tend\n\tend\n\treturn text\nend",
"def score\n total_score = 0\n current_roll = 0\n\n while current_roll < @rolls.size - 1\n roll = @rolls[current_roll]\n next_roll = @rolls[current_roll + 1]\n\n if roll == 10 #strike\n total_score += 10 + @rolls[current_roll + 1] + @rolls[current_roll + 2]\n current_roll += 1\n elsif roll + next_roll == 10 #spare\n total_score += 10 + @rolls[current_roll + 2]\n current_roll += 2\n else #normal players\n total_score += roll + next_roll\n current_roll += 2\n end\n end\n\n return total_score\n end",
"def playRound(score)\n\tputs \"Player 1 enter your weapon: \"\n\tp1 = gets.chomp.downcase\n\tputs \"Player 2 enter your weapon: \"\n\tp2 = gets.chomp.downcase\n\tresult = determineWinner(p1, p2)\n\tupdateScore(score,result)\nend",
"def get_winner(comp,user)\n\tif comp == user\n\t\t\"It was a tie!\"\n\telsif comp == \"rock\" && user == \"paper\"\n\t\t\"You win!\"\n\telsif comp == \"rock\" && user == \"scissors\"\n\t\t\"The computer wins!\"\n\telsif comp ==\"paper\" && user == \"rock\"\n\t\t\"The computer wins!\"\n\telsif comp == \"paper\" && user == \"scissors\"\n\t\t\"You win!\"\n\telsif comp == \"scissors\" && user == \"rock\"\n\t\t\"You win!\"\n\telsif comp == \"scissors\" && user == \"paper\"\n\t\"The computer wins!\"\n\tend\nend",
"def rps_game\n puts 'Enter a move Player 1: Rock, Paper, or Scissors'\n p1_move = gets.chomp\n puts 'Enter a move Player 2: Rock, Paper, or Scissors'\n p2_move = gets.chomp\n if p1_move == p2_move\n puts \"Draw\"\n elsif (p1_move == \"Rock\" && p2_move == \"Scissors\") || (p1_move == \"Paper\" && p2_move == \"Rock\") ||\n (p1_move == \"Scissors\" && p2_move == \"Paper\")\n puts \"Player 1 Wins!!\"\n elsif (p2_move == \"Rock\" && p1_move == \"Scissors\") || (p2_move == \"Paper\" && p1_move == \"Rock\") ||\n (p2_move == \"Scissors\" && p1_move == \"Paper\")\n puts \"Player 2 Wins!!\"\n end\nend",
"def determineWinner\n if @botChoice == @playerChoice\n puts \"It's a tie! Redo round:\"\n elsif (@playerChoice == \"paper\" and @botChoice == \"rock\") or \\\n (@playerChoice == \"scissors\" and @botChoice == \"paper\") or \\\n (@playerChoice == \"rock\" and @botChoice == \"scissors\")\n @roundsWon += 1\n @roundsLeft -= 1\n puts \"You won this round! Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n else\n @roundsLost += 1\n @roundsLeft -= 1\n puts \"You lost this round... Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n end\n end",
"def calc_result(input1, input2)\n\n rpc = ['rock','paper','scissors']\n if rpc.include?(input1) && rpc.include?(input2)\n \n case input1\n when \"rock\"\n if input2 == \"paper\"\n \"Paper covers rock.\"\n elsif input2 == \"scissors\"\n \"Rock crushes scissors\"\n else \"Tie!\"\n end\n when \"paper\"\n if input2 == \"scissors\"\n \"Scissors cuts paper.\"\n elsif input2 == \"rock\"\n \"Paper covers rock.\"\n else \"Tie!\"\n end\n when \"scissors\"\n if input2 == \"paper\"\n \"Scissors cuts paper.\"\n elsif input2 == \"rock\"\n \"Rock crushes scissors\"\n else \"Tie!\"\n end\n end \n\n else \"No cheaters! Only Rock, Paper or Scissors are allowed.\"\n end\nend",
"def computer_hand\n hands = ['r', 'p', 's']\n ran = hands.sample\n ran.to_s\nend",
"def -(arg)\n if(arg == Paper)\n puts(\"Paper covers Rock (loser Rock)\")\n self\n elsif(arg == Spock)\n puts(\"Spock vaporizes Rock (loser Rock)\")\n self\n elsif(arg == Rock)\n puts(\"Rock tie (loser Rock)\")\n self\n else\n arg - self\n end\n end"
] | [
"0.7168028",
"0.71369135",
"0.6987199",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.69046956",
"0.69025373",
"0.686221",
"0.6724034",
"0.6557759",
"0.65509987",
"0.6527028",
"0.64896303",
"0.6364228",
"0.6349042",
"0.62871575",
"0.6166493",
"0.61169255",
"0.6098547",
"0.6081002",
"0.60781205",
"0.6066536",
"0.60484385",
"0.59797627",
"0.597035",
"0.5937885",
"0.58591163",
"0.582072",
"0.58105195",
"0.57688665",
"0.57554144",
"0.5753289",
"0.57412046",
"0.5737708",
"0.5724638",
"0.57217973",
"0.57004344",
"0.56953996",
"0.56788194",
"0.5657774",
"0.5622404",
"0.56219643",
"0.5586736",
"0.55765414",
"0.55680215",
"0.55674696",
"0.5562243",
"0.5553364",
"0.551679",
"0.55040336",
"0.54998326",
"0.5496577",
"0.5488532",
"0.54790056",
"0.5466805",
"0.5456511",
"0.5450585",
"0.5439604",
"0.54236645",
"0.5415126",
"0.5411187",
"0.5400663",
"0.53989697",
"0.53946245",
"0.53890485",
"0.53763115",
"0.5367204",
"0.5351697",
"0.53433156",
"0.5335387",
"0.53259325",
"0.53241557",
"0.5322736",
"0.5307056",
"0.5292572",
"0.5289799",
"0.52872914",
"0.5278432",
"0.5265644",
"0.5261592",
"0.52592444",
"0.52579415",
"0.52534056",
"0.5240058",
"0.52383715",
"0.5231793",
"0.522783",
"0.5221963",
"0.52192223",
"0.51876783"
] | 0.0 | -1 |
Public: Elevator, Sorts elevators based on the number of stops they have | def elevator
elevators.sort_by { |e| e.stop_count }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_elevators\n @elevator_number.times do |i|\n floor_gap = @building.floors / @elevator_number * i\n elevator_list.append(Elevator.new(i, 1 + floor_gap, 1 + floor_gap))\n end\n end",
"def choose_elevator\n elevator_scores = []\n\n for elevator in @column.elevator_list do\n \n # Initialize score to 0\n score = 0\n floor_difference = elevator.current_floor - @floor\n\n # Prevents use of any offline/under-maintenance elevators\n if elevator.status != \"online\"\n score = -1\n elevator_scores.append(score)\n else\n\n # Bonify score based on difference in floors\n if floor_difference == 0\n score += 5000\n else\n score += 5000/(floor_difference.abs() + 1)\n end\n \n # Bonify score based on direction (highest priority)\n if elevator.movement != \"idle\"\n if floor_difference >= 0 and @direction == \"down\" and elevator.movement == \"down\"\n \n # Paths are crossed going down, therefore favor this elevator\n score += 10000\n \n elsif floor_difference <= 0 and @direction == \"up\" and elevator.movement == \"up\"\n\n # Paths are crossed going down, therefore favor this elevator\n score += 10000\n \n else\n \n # Paths are not crossed, therefore try avoiding the use of this elevator\n score = 0\n \n # Give redemption points, in worst case scenario where all elevators never cross paths\n next_floor_difference = elevator.next_floor - @floor\n if next_floor_difference == 0\n score += 500\n else\n score += 500/(next_floor_difference.abs() + 1)\n end\n end\n end\n\n # Bonify score on request queue size (the smaller number of pre-existing requests, the faster therefore the better)\n if elevator.requests_queue.length() <= 3\n score += 1000\n elsif elevator.requests_queue.length() <= 7\n score += 250\n end\n \n # Send total score of elevator to the scores list\n elevator_scores.append(score)\n end\n end\n\n # Get value of highest score\n highest_score = -1\n for score in elevator_scores do\n if (score > highest_score)\n highest_score = score\n end\n end\n \n # Get elevator with the highest score (or nil if all elevators were offline\n chosen_elevator = nil\n if (highest_score > -1)\n chosen_elevator = @column.elevator_list[elevator_scores.find_index(highest_score)]\n puts \"Chosen elevator: Elevator #{chosen_elevator.id}\"\n end\n return chosen_elevator\n end",
"def debark\n\t\t#Check who on the elevator gets off on this stop.\n\t\tarrivers = []\n\t\tperson_queue.each do |elev_person|\n\t\t\tif elev_person.destination == current_floor\n\t\t\t\tarrivers.push(elev_person)\n\t\t\tend \n\t\tend\n\t\t#Once you have a list of people who are getting off, have those people get off\n\t\tarrivers.each do |elev_person|\n\t\t\tif elev_person.destination == current_floor\n\t\t\t\tremove_person(elev_person)\n\t\t\tend \n\t\tend\n\t\treturn arrivers.count\n\tend",
"def createElevatorsList\n for x in 1..@numberOfElevators do\n @elevatorsList.append(Elevator.new(x, @numberOfFloors, 1, ElevatorStatus::IDLE, SensorStatus::OFF, SensorStatus::OFF))\n # puts \"elevator#{@id} created\"\n end\n end",
"def add_elevators(starting_floor, number_of_elevators)\n\t\tnumber_of_elevators.times do\n\t\t\te = Elevator.new(starting_floor, @elevator_strategy)\n\t\t\t@elevators << e\n\t\t\t@sim.register(e)\n\t\tend\n\tend",
"def elevators_at_floor(floor)\n\t\televators.select{|elevator| elevator.floor.eql? floor}\n\tend",
"def sort_drivers_by_miles\n\t\t@drivers.sort_by { |key,driver| -driver.trip_total_miles }\n\tend",
"def call_elevator elevator_number=0\n\t\t@elevators[elevator_number].add_to_floors_to_visit @floor_number\n\tend",
"def index\n @distance_options = get_distance_options\n\n @offers = Offer.all.sort do |a, b|\n a.distance(@distance_options) <=> b.distance(@distance_options)\n end\n end",
"def find_elevators_by_direction(elevator_direction)\n same_direction = @elevator_list.select { |elevator| elevator.direction == elevator_direction }\n idle = @elevator_list.select { |elevator| elevator.direction.zero? }\n if same_direction.length > 0\n return same_direction\n else\n return idle\n end\n end",
"def sort_offices(coordinates)\n self.sorted_offices = active_office_locations.sorted_by_distance(coordinates)\n sorted_offices.each { |office| office.calculate_distance(coordinates) }\n end",
"def makeElevator\n for elevatorID in 1..@amountOfElevators\n elevator = Elevator.new(elevatorID, 'idle', @amountOfFloors, 1)\n @elevatorsList.push(elevator)\n end\n end",
"def sortFloorList\n if @direction == 'up'\n @floorRequestList.sort!\n elsif @direction == 'down'\n @floorRequestList.sort!.reverse\n end\n end",
"def step\n\t\t@elevators.each do |elevator|\n\t\t\tif elevator.current_floor == @floor_number\n\t\t\t\twhile !@persons_queue.empty?\n\t\t\t\t\tif elevator.number_of_occupants < elevator.max_capacity\n\t\t\t\t\t\televator.add_occupant @persons_queue.shift\n\t\t\t\t\telse\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def service_lane lane, enter, exit\n segment = []\n (enter..exit).each do |x|\n segment << lane[x]\n end\n width = segment.min\n \nend",
"def sort\n\t@events = @events.sort_by { | e | e.time_from_start }\n\trecalc_delta_from_times()\n end",
"def create_elevator_list\n \n for elevatorID in 1..Column.num_elevators do\n elevator = Elevator.new(elevatorID)\n elevator.create_floor_buttons()\n @elevator_list.append(elevator)\n end\n end",
"def serviceLane(n, cases, width)\r\n # Write your code here\r\n allowedWidth = []\r\n finalResult = []\r\n cases.each do |tcase|\r\n (tcase[0]..tcase[1]).each do |indicie|\r\n allowedWidth << width[indicie]\r\n end\r\n finalResult << allowedWidth.sort.first\r\n allowedWidth = []\r\n end\r\n return finalResult\r\nend",
"def sort\n # Find a cycle in the move graph and pick a register to spill to break it.\n spillee = nil\n each_strongly_connected_component do |component|\n if component.size > 1\n fail if spillee # There is one cycle with 3 registers.\n spillee = component.first.src\n end\n end\n\n # Break the cycle.\n spill(spillee) if spillee\n\n tsort\n end",
"def sort_trips_by_driver(trips, number_of_drivers)\n trips_sorted_by_driver_id = Array.new(number_of_drivers) { |i| i = [] }\n trips.each do |trip|\n number_of_drivers.times do |i|\n trips_sorted_by_driver_id[i] << trip if trip.driver_id == i\n end\n end\n trips_sorted_by_driver_id\n end",
"def sort_cyclists_race(race)\n sorted_cyclists = []\n nil_cyclists = []\n stage_max_points = Array.new(race.stages.count, 1)\n\n race.stages.each_with_index do |stage, index|\n race.cyclists.each do |cyclist| \n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n stage_max_points[index] = stage_max_points[index] + 1 if stage_effort\n end\n end\n\n race.cyclists.each_with_index do |cyclist, index| \n total_time = 0\n total_points = 0\n stage_effort = nil\n\n race.stages.each_with_index do |stage, ix_stage|\n today = Time.now.to_date # race.stages.last.close_date\n if stage.close_date >= today\n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n if stage_effort\n total_time = total_time + stage_effort.elapsed_time.to_i\n total_points = total_points + stage_effort.points.to_i\n else\n #break\n total_points = total_points + stage_max_points[ix_stage]\n end\n end\n end\n\n if total_time > 0\n sorted_cyclists << { 'cyclist' => cyclist, 'total_time' => total_time, 'total_points' => total_points} \n else\n nil_cyclists << { 'cyclist' => cyclist, 'total_time' => 'DNF', 'total_points' => total_points} \n end\n end\n\n nil_cyclists.sort_by!{|a| a['total_points']}\n\n #sorted_cyclists.sort_by!{|k| k['total_points'].to_i}.reverse!\n sorted_cyclists.sort! do |a, b|\n [a['total_points'], a['total_time']] <=> [b['total_points'], b['total_time']]\n end\n\n return sorted_cyclists + nil_cyclists\n end",
"def findNearestElevator(currentFloor, selectedList)\n bestElevator = selectedList[0]\n bestDistance = (selectedList[0].floor - currentFloor).abs #abs() returns the absolute value of a number (always positive).\n \n for elevator in selectedList\n if (elevator.floor - currentFloor).abs < bestDistance\n bestElevator = elevator\n end\n end\n \n puts \"\"\n puts \" >> >>> ELEVATOR #{bestElevator.id} WAS CALLED <<< <<\"\n return bestElevator\n end",
"def request_this_elevator()\n self.set_direction\n self.status_update\n case self.direction\n when 0\n self.set_direction\n when 1\n if self.current_floor == self.up_queue[0]\n self.up_queue.shift\n self.status_update\n if self.down_queue.length + self.up_queue.length == 0\n self.direction = 0\n self.status_update\n self.here\n end\n else\n self.current_floor = self.current_floor + 1\n\n if self.up_queue.length > 0\n return self.request_this_elevator\n else\n self.direction = 0\n end\n end\n when -1\n if self.current_floor == self.down_queue[0]\n self.down_queue.shift\n self.status_update\n if self.down_queue.length + self.up_queue.length == 0\n self.direction = 0\n self.status_update\n self.here\n end\n else\n self.current_floor = self.current_floor - 1\n if self.down_queue.length > 0\n return self.request_this_elevator\n else\n self.direction = 0\n end\n end\n end\n end",
"def sort_cyclists_race_stage(race, current_stage)\n sorted_cyclists = []\n nil_cyclists = []\n stage_max_points = Array.new(race.stages.count, 0)\n\n race.stages.each_with_index do |stage, index|\n race.cyclists.each do |cyclist| \n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n stage_max_points[index] = stage_max_points[index] + 1 if stage_effort\n end\n break if stage == current_stage # condition to determine which stage is \n end\n\n race.cyclists.each_with_index do |cyclist, index| \n total_time = 0\n total_points = 0\n stage_effort = nil\n stage_count = 0\n\n race.stages.each_with_index do |stage, ix_stage|\n today = Time.now.to_date # race.stages.last.close_date\n # if race.stages.last.close_date >= today\n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n if stage_effort\n total_time = total_time + stage_effort.elapsed_time.to_i\n total_points = total_points + stage_effort.points.to_i\n stage_count -= 1 \n else\n #break\n total_points = total_points + stage_max_points[ix_stage] + 1\n end\n # end\n break if stage == current_stage # condition to determine which stage is \n end\n\n if total_time > 0\n sorted_cyclists << { 'cyclist' => cyclist, 'total_time' => total_time, 'total_points' => total_points, 'stage_count' => stage_count} \n else\n nil_cyclists << { 'cyclist' => cyclist, 'total_time' => 'DNF', 'total_points' => total_points, 'stage_count' => stage_count} \n end\n end\n\n nil_cyclists.sort_by!{|a| a['total_points']}\n\n #sorted_cyclists.sort_by!{|k| k['total_points'].to_i}.reverse!\n sorted_cyclists.sort! do |a, b|\n [a['total_points'], a['stage_count'], a['total_time']] <=> [b['total_points'], b['stage_count'], b['total_time']]\n end\n\n return sorted_cyclists + nil_cyclists\n end",
"def agents_nearest(coord, count)\n living_agents.sort_by{ |a| coord.vector_to(a.tank).length }[0...count]\n end",
"def run\n start = rand(20)\n puts \" Starting at: #{@locations[start].name}\"\n tripDesc = \"\" # human-readable List of moves for current trip segment\n @locations[start].visited = true\n visited = 1\n totalTime = 0\n while visited < 20\n group = group_nearest(start)\n best_time = 9999999999\n\n for i in 0..3\n result = getBestPath(start, group[i]) if group[i]\n if result[0] < best_time\n best_time = result[0]\n best_path = result[1]\n best_dest = group[i]\n end\n end\n tripDesc << best_path\n totalTime += best_time\n @locations[best_dest].visited = true\n start = best_dest\n visited += 1\n end\n\n puts \"*********** Total Trip Time = #{secondstoHMS(totalTime)} **************\"\n confirm = \"Complete.\\n\"\n for i in 0..19\n confirm = \"Error, not all locations visited!!\\n\" if !@locations[i].visited\n end\n tripDesc << confirm\n return [totalTime, tripDesc]\n\n end",
"def lru_elevator\n\t\televator = elevators.shift\n\t\televators.push(elevator)\n\t\televator\n\tend",
"def sort_abschnitte_and_umschlaege\n abschnitt_umschlag_list = []\n # Hilfsmethode, baut einen nach Orten sortierten Hash auf.\n ort_to_detail = sort_abschnitte_and_umschlaege_by_ort\n File.open(\"log/transport.log\",\"w\"){|f| f.puts \"Ort to detail #{ort_to_detail}\" }\n unless self.start_anlage.nil?\n if self.start_anlage.ort\n ort_aktuell = self.start_anlage.ort\n if ort_aktuell.nil? || ort_to_detail[ort_aktuell.id].nil?\n ort_aktuell = abschnitt_only_start_ort(ort_to_detail.keys) \n end \n counter = 0\n while not (ort_aktuell.nil? || ort_to_detail.empty? || counter > 100)\n counter += 1\n next_ort = nil\n ort_aktuell_id = ort_aktuell.nil? ? 0 : ort_aktuell.id \n unless ort_to_detail[ort_aktuell_id].nil?\n ort_to_detail[ort_aktuell_id].each do |abschnitt_umschlag|\n File.open(\"log/transport.log\",\"a\"){|f| f.puts abschnitt_umschlag.attributes }\n abschnitt_umschlag_list << abschnitt_umschlag\n next_ort = abschnitt_umschlag.end_ort if abschnitt_umschlag.kind_of? Transportabschnitt \n end\n ort_to_detail.delete(ort_aktuell_id) \n ort_aktuell = next_ort\n end\n end \n # Rest nach Datum sortieren\n unless ort_to_detail.empty?\n File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Rest nach Datum\" }\n abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten))\n end\n else \n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Alles nach Datum\" }\n abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten))\n end \n end\n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Transport #{id}: #{abschnitt_umschlag_list.to_s}\" }\n abschnitt_umschlag_list\n end",
"def ascending_distance(ride)\n ascending_point_pairs(ride).inject(0) { |total, pair| total + distance_between(*pair) }\n end",
"def list_all_trains\n Train.all.sort{|a,b| a.destination <=> b.destination}.each.with_index(1) do |element, index|\n puts\"\\n\"\n puts \"#{index}: Destination: #{element.destination}\"\n puts \" Base time: #{element.event_time}\"\n puts \" Line: #{element.line}\"\n puts \" Direction: #{element.dir}\"\n puts \" Incoming Stations:\"\n element.station.each{|hash| puts \"Station: #{hash['station']}\\nWait Time: #{hash['waiting_time']}\\n-----------------------------------\\n\"}\n end\n puts \"\\nType 1 to restart and anything else to end:\\n\"\n get_end = gets.strip\n if get_end == '1'\n restart\n end\nend",
"def rooms_sorted_by_area\n room_sort = @rooms.map do |room|\n room.sort_by {|area| area.size}\n end\n end",
"def updateLane\n @maxVelocity = @currentLane.speedLimit + @driver.speedDiff\n @maxCompare = @maxVelocity - @maxAccel\n @exitTo = @currentLane.exitTo[@exitLane]\n end",
"def descending_distance(ride)\n descending_point_pairs(ride).inject(0) { |total, pair| total + distance_between(*pair) }\n end",
"def sort_drivers\n @drivers.sort! {|x, y| y.miles_driven <=> x.miles_driven}\n end",
"def initialize(number_of_elevators, number_of_floors, elevator_capacity,elevator_resting_floor)\n\t\tputs \"Setting up #{number_of_elevators} elevators of capacity #{elevator_capacity}\"\n\t\t@elevators = Array.new(number_of_elevators).map{\n\t\t\t|elevator| Elevator.new(self, elevator_capacity)\n\t\t}\n\t\tputs \"Setting up #{number_of_floors} floors\"\n\t\t@floors = Array.new(number_of_floors).each_with_index.map{\n\t\t\t|floor, height|Floor.new(self, height)\n\t\t}\n\t\tputs \"Placing elevators on floor #{elevator_resting_floor}\"\n\t\t@elevators.map{\n\t\t\t|elevator| elevator.install(@floors[elevator_resting_floor])\n\t\t}\n\t\tputs \"~~~~~~~~~~~~~~~~~~~~~~~~\"\n\tend",
"def ordenEachMenus (array)\n ordenado = []\n array.each do\n |nodo|\n if ordenado.empty?\n ordenado.push(nodo)\n else\n indice = 0\n while indice < ordenado.length\n aporteActual = (nodo.collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+)\n aporteSiguiente = (ordenado[indice].collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+)\n if aporteActual <= aporteSiguiente\n ordenado.insert(indice, nodo)\n break\n elsif indice == ordenado.length-1\n ordenado.insert(indice+1, nodo)\n break\n end\n indice+=1\n end\n end\n end\n return ordenado\nend",
"def sortWaypoints\n if waypoints.present?\n waypoints = waypoints.sort { |a,b| a.local_index <=> b.local_index } if waypoints.present?\n end\n end",
"def waypoints_must_be_at_most_n_km_apart\n self.waypoints_minus_removed.each do |waypoint|\n next if waypoint.parent_index.nil? || waypoint.parent_index < 0 || waypoint.parent_index == waypoint.local_index\n parent = waypoints_minus_removed[waypoint.parent_index]\n if !parent.nil? && type == 'Road' && waypoint.dist(parent.latitude, parent.longitude) > 50\n\tputs \"cannot be more than 50km apart.\"\n errors.add(:waypoints, \"cannot be more than 50km apart.\")\n elsif !parent.nil? && type != 'Road' && waypoint.dist(parent.latitude, parent.longitude) > 20\n\tputs \"cannot be more than 20km apart.\"\n errors.add(:waypoints, \"cannot be more than 20km apart.\")\n end\n end\n end",
"def set_direction()\n case self.direction\n when 0\n if self.up_queue.length > self.down_queue.length\n self.direction = 1\n elsif self.up_queue.length < self.down_queue.length\n self.direction = -1\n else\n self.direction = 0\n end\n when 1\n if self.up_queue.length > 0\n self.direction = 1\n elsif self.up_queue.length == 0\n if self.down_queue.length > 0\n self.direction = -1\n else\n self.direction = 0\n end\n end\n when -1\n if self.down_queue.length > 0\n self.direction = -1\n elsif self.down_queue.length == 0\n if self.up_queue.length > 0\n self.direction = 1\n else\n self.direction = 0\n end\n end\n end\n\n # handles requests while its queue is not empty\n\n def request_this_elevator()\n self.set_direction\n self.status_update\n case self.direction\n when 0\n self.set_direction\n when 1\n if self.current_floor == self.up_queue[0]\n self.up_queue.shift\n self.status_update\n if self.down_queue.length + self.up_queue.length == 0\n self.direction = 0\n self.status_update\n self.here\n end\n else\n self.current_floor = self.current_floor + 1\n\n if self.up_queue.length > 0\n return self.request_this_elevator\n else\n self.direction = 0\n end\n end\n when -1\n if self.current_floor == self.down_queue[0]\n self.down_queue.shift\n self.status_update\n if self.down_queue.length + self.up_queue.length == 0\n self.direction = 0\n self.status_update\n self.here\n end\n else\n self.current_floor = self.current_floor - 1\n if self.down_queue.length > 0\n return self.request_this_elevator\n else\n self.direction = 0\n end\n end\n end\n end\n\n # responds to floor requests from within the elevator\n\n def request_floor(floor)\n if floor == self.current_floor\n print self.id 'floor button pushed, we are already on this floor, opening doors'\n elsif floor > self.current_floor\n self.a_floor_was_requested(floor)\n self.up_queue.append(floor)\n self.up_queue.sort\n self.set_direction\n self.request_this_elevator\n elsif floor < self.current_floor\n self.a_floor_was_requested(floor)\n self.down_queue.append(floor)\n self.up_queue.sort.reverse\n self.set_direction\n self.request_this_elevator\n end\n end\n end",
"def try_sort\n # Sort the table if the first element next_start_time has changed\n if false && @next_start_time != @sprinkles[0].next_start_time\n @sprinkles.sort_by! {|s| s.next_start_time}\n @next_start_time = @sprinkles[0].next_start_time\n end\n end",
"def next_states\n possible = []\n # possible states going up\n possible += next_states_in_dir(1) if @elevator != 3\n # possible states going down only make sense if there are actually some items available at lower floors\n items_lower = @floors[0...@elevator].map { |floor| floor.length }.sum\n possible += next_states_in_dir(-1) if (@elevator != 0) && (items_lower > 0)\n\n return possible\n end",
"def sort\n @lane_assignments = LaneAssignment.where(id: params[:age_group_entry]).order(:heat, :lane)\n\n # holds the list of all heats/lanes\n previous_heat_lanes = @lane_assignments.map { |la| [la.heat, la.lane] }\n\n # enable a mode which assigns new lane numbers (but not heats)\n if params[:move_lane]\n move_to_new_position = true\n found_moved_lane = false\n end\n\n # XXX this is doing unsafe updates (validations disabled)\n # sets these to the new order given\n new_lanes = []\n moved_heat = 0\n moved_lane = 0\n params[:age_group_entry].each_with_index do |lane_assignment_id, index|\n la = LaneAssignment.find(lane_assignment_id)\n if previous_heat_lanes[index][0] != la.heat || previous_heat_lanes[index][1] != la.lane\n # this lane has been moved\n if move_to_new_position\n unless found_moved_lane\n moved_heat = previous_heat_lanes[index][0]\n moved_lane = previous_heat_lanes[index][1]\n found_moved_lane = true\n end\n if found_moved_lane && la.heat == moved_heat && la.lane == moved_lane\n # this is the lane that we moved\n la.update_attribute(:heat, previous_heat_lanes[index][0])\n la.update_attribute(:lane, previous_heat_lanes[index][1] + 1)\n end\n else\n la.update_attribute(:heat, previous_heat_lanes[index][0])\n la.update_attribute(:lane, previous_heat_lanes[index][1])\n end\n end\n new_lanes << la\n end\n @lane_assignments = new_lanes\n respond_to do |format|\n format.js {}\n end\n end",
"def compute_stops(route)\n route.visited_stops\n end",
"def sortByDistanceFrom(otherLocation)\n ParkingSpots.new(@_parkingSpots.sort { |a, b|\n a.metersFromLocation(otherLocation) <=> b.metersFromLocation(otherLocation)\n })\n end",
"def howManyAgentsToAdd(noOfCurrentAgents, callsTimes)\n return if callsTimes.empty?\n call_ins = []\n call_outs = []\n callsTimes.each do |c|\n call_ins << c[0]\n call_outs << c[1]\n end \n \n call_ins = call_ins.sort\n call_outs = call_outs.sort\n \n i = 0\n j = 0\n c = 0\n max = 0\n while(i < call_ins.length && j < call_outs.length)\n \n if(call_ins[i] < call_outs[j])\n c += 1\n max = [c, max].max\n i += 1\n else\n c -= 1\n j += 1\n end \n end\n return max-1\n \nend",
"def min_meeting_rooms(intervals)\n sorted_intervals = intervals.sort { |a, b| a[0] <=> b[0] }\n heap = MinHeap.new\n\n count = 0\n sorted_intervals.each do |(start, stop)|\n if heap.size.zero?\n heap.add_node(stop)\n count += 1\n else\n if start >= heap.top\n heap.remove_node\n else\n count += 1\n end\n heap.add_node(stop)\n end\n end\n count\nend",
"def airodump_focus routers = Array.new\n \n puts \"You can now choose which AP to attack.\"\n puts \"We suggest to set your terminal to fullscreen.\"\n puts \"Press Enter when ready...\"\n gets.chomp\n \n begin\n\t\tsystem(\"clear\")\n\t\tputs \"Routers with higher data traffic, lower power or those who \"\n\t\tputs \"answered to more probe requests are easier to crack.\" \n\t\tputs \"\\nChoose which router to attack:\"\n\t\tputs \"---------------------------------------\"\n\t \t\n\t\ti = 1\n\t\trouters.each do |el|\n\t\t if el.privacy =~ /WPA/ || el.privacy =~ /WEP/\n\t\t el.id = i\n\t\t n = 30; m = 12; sp = \"\"\n\t\t n -= el.essid.length if el.essid.length > 0\n\t\t m -= el.privacy.length\n\t\t essid_ws = space_gen(n)\n\t\t enc_ws = space_gen(m)\n\t\t sp = \" \" if i < 10\n\t\t (el.probes != \"\") ? (puts \"#{el.id}) #{sp} #{el.essid}#{essid_ws}--> Encryption: #{el.privacy}#{enc_ws}Power: #{el.power*(-1)} Reaver-crackable: #{el.wps} Probes answered: #{el.probes}\") : (puts \"#{el.id}) #{sp} #{el.essid}#{essid_ws}--> Encryption: #{el.privacy}#{enc_ws}Power: #{el.power*(-1)} Reaver-crackable: #{el.wps}\")\n\t\t i += 1\n\t\t end\n\t\tend\n\t \n\t\tputs \"---------------------------------------\"\n\t\tputs \"Example: 5\"\n\t\tprintf \"\\n-> \"\n\t\t\n\t\tinput = gets.chomp\n\t\tinput = input.to_i\n\t\trouter = Router.new\n\t\tvalid_input = false\n \t\n \t\tvalid_input = true if input > 0 && input <= routers.length\n \t\t\n \t\tif valid_input\n\t\t\trouters.each do |el|\n\t\t\t\tif el.id == input\n\t\t\t\t router = el\n\t\t\t\t airodump_runner(1,el)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t puts \"\\nError: No such router id found!\"\n\t\t puts \"Press Enter to continue...\"\n\t\t gets.chomp\n end\n \n end while !valid_input\n \n return router\n \nend",
"def findElevator(currentFloor, direction)\n activeElevatorList = []\n idleElevatorList = []\n sameDirectionElevatorList = []\n for x in @elevatorsList\n if x.status != ElevatorStatus::IDLE #verify if elevator is active and if the request is on the elevator way\n if x.status == ElevatorStatus::UP and x.floor <= currentFloor or x.status == ElevatorStatus::DOWN and x.floor >= currentFloor\n activeElevatorList.append(x)\n end\n else\n idleElevatorList.append(x)\n end\n end\n\n if activeElevatorList.length > 0 #Create new list for elevators with same direction that the request\n sameDirectionElevatorList = activeElevatorList.select {|elevator| elevator.status == direction}\n end\n \n if sameDirectionElevatorList.length > 0\n bestElevator = findNearestElevator(currentFloor, sameDirectionElevatorList)\n else\n bestElevator = findNearestElevator(currentFloor, idleElevatorList)\n end\n \n return bestElevator\n end",
"def ascending_duration(ride)\n point_pairs(ride).inject(0) do |total, pair|\n if active_between?(*pair) && ascending_between?(*pair)\n total + time_between(*pair)\n else\n total\n end\n end\n end",
"def sort_sublists_by_length\n sort_by { |array| array.size }\n end",
"def get_planet_names_sorted_by_size_decreasing()\n planets_sorted_by_size = @planets.sort_by { |planet| planet.diameter }\n planets_sorted_by_size_decreasing = planets_sorted_by_size.reverse\n planets_sorted_by_size_decreasing.map { |planet| planet.name }\n\nend",
"def min_meeting_rooms(intervals)\n s, e = [], []\n intervals.each do |i|\n s << i.start\n e << i.end\n end\n s.sort!\n e.sort!\n i = j = 0\n x = ans = 0\n while i < intervals.size\n if s[i] < e[j]\n x += 1\n ans = [ans, x].max\n i += 1\n else\n x -= 1\n j += 1\n end\n end\n ans\nend",
"def load_elevator\n while(@elevator.has_room? && @floors[0].is_empty?)\n @elevator.enter(@floors[0].dequeue)\n end\n end",
"def sort_abschnitte_and_umschlaege_by_ort\n ort_to_detail = {}\n self.umschlaege.each do |umschlag|\n ort = umschlag.ort\n ort_id = ort.nil? ? 0 : ort.id\n ort_to_detail[ort_id] ||= []\n ort_to_detail[ort_id] << umschlag\n end \n self.transportabschnitte.each do |abschnitt|\n ort = abschnitt.start_ort\n ort_id = ort.nil? ? 0 : ort.id\n ort_to_detail[ort_id] ||= []\n ort_to_detail[ort_id] << abschnitt\n end \n ort_to_detail\n end",
"def sort_by_distance(addressables)\n (addressables && addressables.length > 1 && current_session.addressed_in?) ? addressables.sort_by_distance_from(current_session.address) : addressables\n end",
"def itemsOnFloor(input, floor)\n input.select { |key, value| value == floor}.keys - [:elevator]\nend",
"def find_nearest_elevator(elevator_direction, request_location)\n elevators = find_elevators_by_direction(elevator_direction)\n elevators.each { |elevator| elevator.distance_score = (request_location - elevator.current_floor).abs }\n return elevators.min { |a, b| a.distance_score <=> b.distance_score }\n end",
"def sort_abschnitte_and_umschlaege_by_date start_liste\n abschnitt_umschlag_list = []\n mit_end_datum = start_liste.select{|element| element.end_datum }\n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Mit Ende #{mit_end_datum.to_s}\" }\n abschnitt_umschlag_list.concat(mit_end_datum.sort_by{|element| element.end_datum} )\n ohne_end_datum = start_liste.select{|element| element.end_datum.nil? }\n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Ohne Ende: #{ohne_end_datum.to_s}\" }\n abschnitt_umschlag_list.concat(ohne_end_datum)\n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Liste bei Date #{abschnitt_umschlag_list.to_s}\" }\n abschnitt_umschlag_list\n end",
"def data_sorter\n @file_data.each do |row|\n @trips << Trip.new(row[1], row[2], row[3], row[4]).log_to_driver if row[0] == \"Trip\"\n @drivers << Driver.new(row[1]) if row[0] == \"Driver\"\n end\n end",
"def order\n @controlpoints.size\n end",
"def set_route_stops\n 0\n end",
"def leaders(input)\n leader = []\n temp_lead = 0\n counter = 0\n while counter < input.size\n counter2 = counter + 1\n temp_lead = input[counter]\n while counter2 < input.size && temp_lead > input[counter2]\n counter2 += 1\n end\n leader << temp_lead if counter2 == input.size\n counter += 1\n end\n leader\nend",
"def get_known_orte_with_props\n orte = {}\n strecken = []\n # Transportabschnitte inklusive Beobachtungsorte und Strecke der Route\n transportabschnitte.each do |abschnitt|\n if abschnitt.route && abschnitt.route.name != \"Unbekannt\"\n strecken.concat(abschnitt.route.get_strecken)\n else\n if abschnitt.start_ort && abschnitt.end_ort && abschnitt.start_ort.lat && abschnitt.end_ort.lat\n strecken << [abschnitt.start_ort, abschnitt.end_ort] \n end\n end\n check_ort_p(orte, abschnitt.start_ort, \"Abschnitt\")\n check_ort_p(orte, abschnitt.end_ort, \"Abschnitt\")\n abschnitt.beobachtungen.each do |beob|\n check_ort_p(orte, beob.ort, \"Beobachtung\")\n end\n end\n # Umschlaege\n umschlaege.each do |umschlag|\n check_ort_p(orte, umschlag.ort, \"Umschlag\")\n end\n # Start und Zielanlage zuletzt, damit auf jeden Fall das aktuellste, andere werden ggf. ueberschrieben\n check_ort_p(orte, start_anlage.ort, \"Start-Anlage\")\n check_ort_p(orte, ziel_anlage.ort, \"Ziel-Anlage\")\n if strecken.empty? \n if umschlaege.empty? && start_anlage.ort && ziel_anlage.ort && start_anlage.ort.lat && ziel_anlage.ort.lat\n strecken << [start_anlage.ort, ziel_anlage.ort] \n elsif start_anlage.ort && start_anlage.ort.lat\n ort_aktuell = start_anlage.ort\n umschlaege.each do |umschlag|\n if umschlag.ort\n strecken << [ort_aktuell, umschlag.ort]\n ort_aktuell = umschlag.ort\n end\n end\n if ziel_anlage.ort && ziel_anlage.ort.lat\n strecken << [ort_aktuell, ziel_anlage.ort]\n end\n end\n end\n return orte, strecken\n end",
"def paths_list(file)\n maze = Maze.new\n maze.create_maze(file)\n pathways = Hash.new\n my_paths = maze.path_arr()\n my_course = maze.get_course\n if my_paths.size == 0\n puts \"None\" \n end\n (0...my_paths.size).each {|i|\n sum = 0\n temp = my_paths[i]\n location_x = temp.get_x\n location_y = temp.get_y\n my_directions = temp.get_directions\n (0...my_directions.size).each{ |counter|\n move = my_directions[counter]\n current = my_course[location_x][location_y]\n the_weight = current.get_directions\n sum+= the_weight[move]\n if move =~ /[u]/\n location_y-= 1\n end\n if move =~ /[d]/\n location_y+= 1\n end\n if move =~ /[l]/\n location_x-= 1\n end\n if move =~ /[r]/\n location_x+= 1\n end\n }\n pathways[temp.get_name] = sum\n }\n sorted_list = pathways.sort {|a,b| a[1]<=>b[1]}\n (0...sorted_list.size).each{ |i|\n if i == sorted_list.size-1\n print sorted_list[i][0]\n else\n print sorted_list[i][0]+\", \"\n end\n }\nend",
"def zeno(start, stop)\n distance = stop - start\n travelled = start\n while travelled < stop and distance > 0\n yield travelled\n distance = distance / 2.0\n travelled += distance\n end\nend",
"def sort_options\n\t\t[\n\t\t\t['name', 'name', 'Name'], # Will be passed to #order\n\t\t\t['businesses', lambda { |tag| -1 * tag.active_businesses_in_city(@city).length }, 'Number of Businesses']\n\t\t]\n\tend",
"def best_distance_attempts\n best_attempts_for_each_competitor = competitors.map(&:max_successful_distance_attempt).compact\n\n best_attempts_for_each_competitor.sort{ |a, b| b.distance <=> a.distance }\n end",
"def orderItem()\r\n$globalArr = $globalArr.sort_by { |e| e[2] }\r\nfinalAns = []\r\nfinalAns.push($globalArr.shift)\r\n\twhile $globalArr.size > 0\r\n\t\tcurrentPost = finalAns.last\r\n\t\tcurrentPostRow = currentPost[1][0]\r\n\t\tcurrentPostCol = currentPost[1][1]\r\n\t\tfor r in 0...$globalArr.length\r\n\t\t\tpos = $globalArr[r][1]\r\n\t\t\tdistanceFromPreviousItem = calculateDistance(currentPostRow, currentPostCol, pos[0], pos[1])\r\n\t\t\t$globalArr[r][2] = distanceFromPreviousItem\r\n\t\tend\r\n\t\t$globalArr = $globalArr.sort_by { |e| e[2] }\r\n\t\tfinalAns.push($globalArr.shift)\r\n\tend\r\n\t$BestAns.push(finalAns.collect {|ind| ind[0]})\r\n\t#puts \"Order By Greedy: \" + finalAns.collect {|ind| ind[0]}.to_s\r\nend",
"def schedule(start = 0, stop = 100)\n\n # Sort intervals by end point asc\n # iterate from left to right\n # at each endpoint find the max weight from the start to that endpoint\n # Make a comparison if the start of the interval is after the end of the previous \"checkpoint\"\n # add the weight adn that is the new checkpoint\n # if it overlaps then select the larger of the two endpoints\n # This is almost right but not quite\n # we want to break up at previously weighed sectionif we need to\n # we shodul get keep the list of all endpoints weights\n\n # x---x\n # x----x\n # x-------x\n\n # 1,4,3\n # 5,9,4\n # 7,12,5\n\n # Keep the checkpoints here\n # [4:3, 9:7]\n # then see 7,12,5\n # choose 5 or 7 we'd say 7 and may want to do say 7 is max from 0<=>12\n # but if we split it up\n # [4:3, 9:7, 12:8]\n # we could get max 8 if we exclude the middle one\n\n endpoints = []\n interval_list = sort(@interval_list)\n\n interval_list.each do |interval|\n max_weight = interval.weight\n steps = []\n\n # endpoint list is sorted so ya konw we could just do binary search here\n # woudl bring the whoel thing down to nlgn\n endpoints.reverse.each do |endpoint|\n if interval.start > endpoint.stop\n max_weight += endpoint.best_weight\n steps = endpoint.steps.clone\n break\n end\n end\n\n # If we do better by ignoring this interval than record that\n if endpoints.last && endpoints.last.best_weight > max_weight\n max_weight = endpoints.last.best_weight\n steps = endpoints.last.steps\n else\n steps << interval\n end\n\n endpoints << EndpointWeight.new(interval.stop, max_weight, steps)\n end\n\n # endpoints is non-decrasing with each entry. Last must be max\n puts endpoints.last\n endpoints.last.best_weight\n end",
"def sort(companies)\n companies.sort_by do |company|\n -company.size\n end \nend",
"def determine_allergies\n @allergens.each_with_index do |(allergen_name, allergen_value), index|\n keys = @allergens.keys\n if @number < allergen_value && @number > 0\n @active_allergies << keys[index - 1]\n @number = @number - @allergens[keys[index - 1]]\n break\n elsif @number == allergen_value\n @active_allergies << keys[index]\n @number = @number - allergen_value\n break\n end\n end\n end",
"def game_trains\n trains = build_train_list({\n '2' => 0,\n '3' => 0,\n '4' => 0,\n '5' => 0,\n '6' => 0,\n '7' => 0,\n '3T' => 0,\n 'U3' => 0,\n '2+2' => 0,\n '4T' => 0,\n '4+4E' => 0,\n })\n\n case @units.keys.sort.map(&:to_s).join\n when '1'\n add_train_list(trains, { '2' => 6, '3' => 4, '4' => 3, '5' => 4 })\n when '2'\n add_train_list(trains, { '2' => 5, '3' => 3, '4' => 2, '5' => 3, '6' => 2 })\n when '3'\n # extra 5/3T/U3 for minors\n add_train_list(trains, { '2' => 5, '3' => 3, '4' => 1, '5' => 3, '7' => 2, '3T' => 1, 'U3' => 1 })\n when '12'\n add_train_list(trains, { '2' => 7, '3' => 6, '4' => 4, '5' => 5, '6' => 2, '7' => 0 })\n when '23'\n # extra 5/3T/U3 for minors\n add_train_list(trains, { '2' => 5, '3' => 5, '4' => 4, '5' => 6, '7' => 2, '3T' => 1, 'U3' => 1 })\n else # all units\n # extra 5/3T/U3 for minors\n add_train_list(trains, { '2' => 7, '3' => 6, '4' => 5, '5' => 6, '6' => 2, '7' => 2, '3T' => 1, 'U3' => 1 })\n end\n\n add_train_list(trains, { '3T' => 2, 'U3' => 2 }) if @optional_rules.include?(:u3p)\n add_train_list(trains, { 'U3' => 1, '4T' => 1 }) if @regionals[1]\n add_train_list(trains, { '5' => 1 }) if @regionals[2]\n add_train_list(trains, { '4T' => 1 }) if @regionals[3]\n add_train_list(trains, { '5' => -1, '6' => 3, '7' => 2 }) if @kits[3]\n add_train_list(trains, { '5' => 1, '3T' => 1 }) if @kits[5]\n add_train_list(trains, { '2+2' => 1 }) if @kits[7]\n\n # handle K2\n if @kits[2]\n case @units.keys.sort.map(&:to_s).join\n when '1', '2'\n add_train_list(trains, { '3T' => 3, 'U3' => 1, '2+2' => 3, '4T' => 2, '4+4E' => 2 })\n add_train_list(trains, { '3' => -1, '4' => -1 }) if @kits[3]\n when '12'\n add_train_list(trains, { '3T' => 4, 'U3' => 2, '2+2' => 3, '4T' => 2, '4+4E' => 2 })\n add_train_list(trains, { '3' => -1, '4' => -1, '5' => -1 }) if @kits[3]\n when '23'\n add_train_list(trains, { '3T' => 4, 'U3' => 2, '2+2' => 3, '4T' => 2, '4+4E' => 2 })\n add_train_list(trains, { '3' => -1, '5' => -1 }) if @kits[3]\n when '123'\n add_train_list(trains, { '3T' => 5, 'U3' => 3, '2+2' => 3, '4T' => 2, '4+4E' => 2 })\n add_train_list(trains, { '3' => -1, '4' => -1, '5' => -1 }) if @kits[3]\n end\n end\n\n fix_train_availables(trains)\n\n trains\n end",
"def sort\n @pokers.sort.reverse\n end",
"def topsort(start = nil, &block)\n result = []\n go = true\n back = Proc.new { |e| go = false }\n push = Proc.new { |v| result.unshift(v) if go }\n start ||= vertices[0]\n dfs({ :exit_vertex => push, :back_edge => back, :start => start })\n result.each { |v| block.call(v) } if block\n result\n end",
"def state\n\t\t@flrs.each do |f|\n\t\t\tputs \"Floor #{@flrs.index(f)} has #{f.passengers.length} passengers waiting.\"\n\t\tend\n\t\t@elevators.each do |e|\n\t\t\tputs \"Elevator #{@elevators.index(e)} is in floor #{@flrs.index(e.current_floor)}, #{e.direction} with #{e.passengers.length} passengers\"\n\t\tend\n\tend",
"def sorted_offices\n @sorted_offices ||= active_office_locations.order(:office_id)\n end",
"def find_closest_eligible_elevator(requested_direction, requested_floor)\n closest_eligible_elevator = elevators_sorted_by_call_proximity(requested_floor).detect do |e|\n e.eligible_for_pickup?(requested_direction, requested_floor)\n end\n if closest_eligible_elevator\n closest_eligible_elevator\n else\n find_closest_eligible_elevator(requested_direction, requested_floor)\n end\n end",
"def tick\n\t\t@elevators.each{|elevator| elevator.tick}\n\t\t@floors.each{|floor| floor.tick}\n\tend",
"def number(bus_stops)\n entries = []\n exits = []\n bus_stops.each { |x| entries << x[0] }\n bus_stops.each { |x| exits << x[1] }\n p entries.inject(&:+) - exits.inject(&:+)\nend",
"def next_elevator\n strategies.map { |strategy| strategy.elevator(elevators, request) }.first\n end",
"def get_num_stops(origin, destination, stops)\n (stops.index(destination) - stops.index(origin)).abs\nend",
"def sorted_races\n races.sort\n end",
"def generate_lunch_orders\n until unfilled_meals_count <= 0\n restaurants.each do |restaurant|\n unfilled_meals.each do |meal_type, count|\n until !restaurant.can_cook_meal?(meal_type) || required_meals[meal_type] <= 0\n # restaurant keeps track of meals orders it fills\n restaurant.cook_meal(meal_type)\n\n # team keeps track of meals orders it still needs to have filled\n required_meals[meal_type] -= 1\n\n # Keep track of the restaurants we use.\n # TODO: Could use Set for uniqueness\n @restaurants_used << restaurant unless @restaurants_used.include? restaurant\n end\n end\n end\n end\n end",
"def sort_floor_plans\n if presentable.available_floor_plans.in_group(group).map(&:position).any?{ |e| e.nil? }\n @plans = presentable.available_floor_plans.in_group(group).\n sort{|a,b| NaturalSort.comparator(a.name, b.name)}\n else\n @plans = presentable.available_floor_plans.in_group(group).order(:position)\n end\n end",
"def next_events\n self.around_events.select{|event|\n event.location.present? && event.start_time > self.end_time\n }.sort{|a,b| a.start_time <=> b.start_time}\n end",
"def lineup_students(students)\n students.sort_by { |x| x.length }\nend",
"def min_steps(in_start_pos_array, unlocked_doors = [], cache = {})\n cache_hashkey = [in_start_pos_array.sort.join, unlocked_doors.sort.join]\n if not cache.has_key?(cache_hashkey)\n keys = reachable_keys(in_start_pos_array, unlocked_doors)\n if keys.empty?\n the_min_steps = 0\n else\n steps = []\n keys.each do |walk, key, distance|\n orig = in_start_pos_array[walk]\n in_start_pos_array[walk] = key\n steps << distance + min_steps(in_start_pos_array, unlocked_doors + [key.upcase], cache)\n in_start_pos_array[walk] = orig\n end\n the_min_steps = steps.min\n end\n cache[cache_hashkey] = the_min_steps\n end\n return cache[cache_hashkey]\n end",
"def set_route_stops\n @node_link.set_route_stops + 1\n end",
"def topsort\n graph = RGL::DirectedAdjacencyGraph.new\n # init vertices\n items = @normal_sources\n items.each {|item| graph.add_vertex(item) }\n # init edges\n items.each do |item|\n item.dependencies.each do |dependency|\n # If we can find items that provide the required dependency...\n # (dependency could be a wildcard as well, hence items)\n dependency_cache[dependency] ||= provides_tree.glob(dependency)\n # ... we draw an edge from every required item to the dependant item\n dependency_cache[dependency].each do |required_item|\n graph.add_edge(required_item, item)\n end\n end\n end\n\n begin\n graph.topsorted_vertices\n rescue RGL::TopsortedGraphHasCycles => e\n output_cycles(graph)\n raise e # fail fast\n end\n end",
"def list_of_trains_based_on_direction\n #put puts a list of train stations based on the rail line chosen\n list_stations_from_direction(@get_line)\n\n #receives the input from user to select from an available list of stations based on a rail line\n get_station = gets.strip.to_i\n\n if !get_station.between?(1, @station.length)\n puts \"Lets try this again:\"\n list_of_trains_based_on_direction\n else\n list_trains_from_station_and_dir(get_station)\n end\n end",
"def get_planet_names_sorted_by_increasing_distance_from_sun()\n sorted_planets_by_distance = @planets.sort_by { |planet| planet.distance_from_sun }\n return sorted_planets_by_distance.map { |planet| planet.name}\n end",
"def order\n\t\t\t@controlpoints.size\n\t\tend",
"def apply_sorting(chain)\n chain\n end",
"def best_laps\n best_laps = []\n RACER_RECORDS.each {|racer| best_laps << [ racer.piloto, racer.best_lap ]}\n @view.display_best_laps(best_laps)\n end",
"def route\n index = @possible_distances.index(@possible_distances.min)\n @array_of_city_arrangements[index]\n end",
"def checkBestElevator(scoreToCheck, newElevator, bestElevatorInfo, floor)\n #If elevators situation is more favourable\n if scoreToCheck < bestElevatorInfo[1]\n bestElevatorInfo[1] = scoreToCheck\n bestElevatorInfo[0] = newElevator\n bestElevatorInfo[2] = (newElevator.elevatorCurrentFloor - floor).abs\n #If elevators are in a similar situation, set the closest one to the best elevator\n elsif bestElevatorInfo[1] == scoreToCheck\n gap = (newElevator.elevatorCurrentFloor - floor).abs\n if bestElevatorInfo[2] > gap\n bestElevatorInfo[1] = scoreToCheck\n bestElevatorInfo[0] = newElevator\n bestElevatorInfo[2] = gap\n end\n end\n return bestElevatorInfo \n end",
"def calculateDistanceFromRobot()\r\n\tfor r in 0...$globalArr.length\r\n\t\t#for c in 0...$globalArr[r].length\r\n\t\t\t#calculateDistance(0,0,)\r\n\t\t\t#print \"#{$globalArr[r][c]},\"\r\n\t\t#end\r\n\t\tpos = $globalArr[r][1]\r\n\t\tdistanceFromRobot = calculateDistance(0,0,pos[0],pos[1])\r\n\t\t$globalArr[r].push(distanceFromRobot)\r\n\t\t#$globalArr2[r].push(distanceFromRobot)\r\n\t\t#puts \"\"\r\n\tend\r\n\t#printAns() \r\n\torderItem()\r\n\t#orderItemReverse()\r\nend",
"def get_pokestops(pop_map, cost_map)\n\n # returns number_of_stops poke stops randomly within the map\n # this is a non-deterministic working solution, but produces a lousy (high) \n # quality score for obvious reasons\n \n time = Time.now\n answer = []\n max_y = pop_map.length-1 # y should not go beyond this boundary\n max_x = pop_map[0].length-1 # x should not go beyond this boundary\n \n #uses formula to identify the best midpoint to start from\n number_of_stops = 1\n total_pop = 0\n total_cost = 0\n total_cost_array = []\n \n for y in 0..max_y #initializes total population and total cost\n\tfor x in 0..max_x\n\t\ttotal_pop = total_pop + pop_map[y][x]\n\t\ttotal_cost = total_cost + cost_map[y][x]\n\t\ttotal_cost_array << cost_map[y][x]\n\tend\n end\n\t\n\tno_of_cells = max_x*max_y\n\t\n avg_cost = total_cost/(max_y*max_x)\n total_cost_array.sort!\n count = 0\n test_hash = Hash.new\n \n for y in 0..max_y #equation to figure out margins\n\tfor x in 0..max_x\n\t\tscore = number_of_stops* total_cost_array[count] + total_pop*max_x*max_y*0.25/(2**(number_of_stops*3000/(no_of_cells**1.3)))\n\t\t#puts \"#{number_of_stops} Stops: #{score}\"\n\t\ttest_hash[number_of_stops] = score\n\t\tcount = count + 1\n\t\tnumber_of_stops = number_of_stops + 1\n\tend\n end\n \n test_hash = test_hash.sort_by {|key,value|value}\n equation_no = test_hash[0][0]\n \n \n \n \n margin = 0.025*(max_x*max_y)\n lower = equation_no - margin\n upper = equation_no + margin\n lowest = false\n mid = (lower+upper)/2\n difference = max_x*max_y/500\n difference_interval = max_x*max_y/1000\n if difference_interval == 0\n\tdifference_interval = 1\n end\n difference_limit = difference + 3*difference_interval\n test_hash = Hash.new\n \n #for testing\n # for i in lower.round..upper.round\n\t# number_of_stops = i\n\t# answer = get_pokestops_with_stops(pop_map, number_of_stops,cost_map)\n\t# temp = calculate_score_for_map(pop_map, cost_map, answer, false)\n\t# puts \"Number of Stops: #{number_of_stops}, Score: #{temp}\"\n\t# test_hash[number_of_stops] = temp\n # end\n # test_hash = test_hash.sort_by {|key,value|value}\n # real_no = test_hash[0][0]\n # puts \"Real Number of Stops: #{real_no}\"\n # margin_req = (equation_no - real_no)*100.0/(max_x*max_y)\n # puts \"Margin required: #{margin_req}%\"\n \n\n \n \n if difference == 0 \n\tdifference = 1\n\tend\n\twent_lower = 0\n\twent_upper = 0\n\tstayed = 0\n\tcount = 0\n\tlowestScore = 0\n if ((mid-difference)>0 && (mid+difference)<(pop_map.length*pop_map[0].length)+1) == false\n\t\n\t\tfor i in 1...(0.4*no_of_cells).round\n\t\t\ttest_answer = []\n\t\t\tnumber_of_stops = i\n\t\t\tlowestScore = 0\n\t\t\ttemp_array = get_pokestops_with_stops(pop_map, number_of_stops,cost_map)\n\t\t\tfor i in 0...temp_array.length-2\n\t\t\t\t\ttest_answer << temp_array[i][0]\n\t\t\tend\n\t\t\t\n\t\t\ttemp = calculate_score_for_map(pop_map, cost_map, test_answer, false)\n\t\t\tif i == 1 \n\t\t\t\tlowestScore = temp\n\t\t\t\tanswer = test_answer\n\t\t\telsif lowestScore > temp\n\t\t\t\tanswer = test_answer\n\t\t\t\tlowestScore = temp\n\t\t\tend\n\t\t\t\n\t\tend\n\t\n\telse\n\t\t#puts \"inside here\"\n\t\t#puts \"difference: #{difference}, Limit : #{difference_limit}\"\n\t while difference != difference_limit \n\t\tcount = count +1\n\t\t#mid\n\t\tif count == 10\n\t\t\t\tbreak\n\t\tend\n\t\t\n\t\tmid = (lower+upper)/2\n\t\n\t\t\n\t\tif stayed == 1 \n\t\t\tanswer1 = answer\n\t\t\ttemp1 = lowestScore\n\t\telse\n\t\t\n\t\t\tmap1 = Marshal.load(Marshal.dump(pop_map)) \n\t\t\ttemp_array = get_pokestops_with_stops(map1, mid,cost_map) # answer in format | [y,x] (stop coor), (area_no)| last element are the area coordinates array\n\t\t\tanswer1 = []\n\t\t\ttemp_area_no = Hash.new\n\t\t\t\n\t\t\t\n\t\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\t\tfor i in 0...temp_array.length-2\n\t\t\t\tanswer1 << temp_array[i][0]\n\t\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\t\tend\n\t\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\t\ttemp1 = calculate_score_for_map_search(map1,cost_map,answer1,temp_area_no,area_coordinates, x_areas)\n\t\tend\n\t\t\n\t\tstayed = 0\n\t\tupper1 = mid\n\t\tlower1 = mid\n\t\t\n\t\t# difference before mid\n\t\t\t\n\t\tmap2 = Marshal.load(Marshal.dump(pop_map)) \n\t\ttemp_array = get_pokestops_with_stops(map2, mid-difference,cost_map) # array\n\t\tanswer2 = []\n\t\ttemp_area_no = Hash.new\n\t\t\n\t\t\n\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\tfor i in 0...temp_array.length-2\n\t\t\tanswer2 << temp_array[i][0]\n\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\tend\n\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\ttemp2 = calculate_score_for_map_search(map2,cost_map,answer2,temp_area_no,area_coordinates, x_areas)\n\t\t\n\t\t# difference after mid\n\t\tmap3 = Marshal.load(Marshal.dump(pop_map)) \n\t\ttemp_array = get_pokestops_with_stops(map3, mid+difference,cost_map) # array\n\t\tanswer3 = []\n\t\ttemp_area_no = Hash.new\n\t\t\n\t\t\n\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\tfor i in 0...temp_array.length-2\n\t\t\tanswer3 << temp_array[i][0]\n\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\tend\n\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\ttemp3 = calculate_score_for_map_search(map3,cost_map,answer3,temp_area_no,area_coordinates, x_areas)\n\t\t\n\t\t\n\t\n\t\tif (temp2 < temp1) && (temp3 > temp2) #the one BEFORE mid is smaller\n\t\t\tlowestScore = temp2\n\t\t\tanswer = answer2\n\t\t\tupper = upper1\n\t\t\t\n\t\telsif (temp3 < temp2) && (temp3 < temp1) # the one AFTER mid is smaller\n\t\t\tlowestScore = temp3\n\t\t\tanswer = answer3\n\t\t\tlower = lower1\n\t\t\t\n\t\telse # both are higher; mid is smallest\n\t\t\tlowestScore = temp1\n\t\t\tanswer = answer1\n\t\t\tstayed = 1\n\t\t\tdifference = difference + difference_interval\n\t\t\tif difference > difference_limit\n\t\t\t\tdifference = difference_limit\n\t\t\tend\n\t\tend\n\t end\n end\n\n \n return answer\nend",
"def moveup\n papers = venue.papers.where(\"listorder < ?\",self.listorder).order(:listorder)\n \n if papers.length == 1\n self.listorder = papers[0].listorder - 1.0\n elsif papers.length > 1\n self.listorder = (papers[papers.length-1].listorder + papers[papers.length-2].listorder) / 2\n end\n end",
"def index\n\t @somewhere = [52.477995,13.566360]\n\t @sites = Site.joins(:sizes).includes([:sizes, :reviews])\n\t @sites.sort_by{|s| s.distance_to(@somewhere)}\n\t \n\t #@sites = Site.by_distance(:origin => @somewhere).order('distance ASC')\n\t \n end"
] | [
"0.6298116",
"0.6162324",
"0.5863129",
"0.5796128",
"0.57165194",
"0.56179225",
"0.54705626",
"0.5448131",
"0.5425242",
"0.5390634",
"0.5317472",
"0.5293465",
"0.52821577",
"0.52778375",
"0.52574193",
"0.5252519",
"0.5249105",
"0.51937574",
"0.51047045",
"0.50997806",
"0.5088066",
"0.5070028",
"0.5061834",
"0.50616133",
"0.50614154",
"0.5039168",
"0.50107324",
"0.5009332",
"0.4973753",
"0.49648958",
"0.49636567",
"0.49253008",
"0.49121556",
"0.48824757",
"0.48815998",
"0.48798877",
"0.4874126",
"0.48699892",
"0.4869957",
"0.4863807",
"0.48635858",
"0.48532933",
"0.48519737",
"0.48508582",
"0.48448092",
"0.4829832",
"0.4809273",
"0.48077348",
"0.4807042",
"0.47900274",
"0.47797573",
"0.47726068",
"0.47708958",
"0.47707063",
"0.47685057",
"0.4766358",
"0.4761698",
"0.47518522",
"0.47508818",
"0.47507295",
"0.47495422",
"0.47453487",
"0.473878",
"0.4734056",
"0.4724632",
"0.47192743",
"0.47146216",
"0.4709258",
"0.47091714",
"0.47087035",
"0.46883672",
"0.46876755",
"0.46741277",
"0.4671494",
"0.4671224",
"0.46666694",
"0.4663565",
"0.4663512",
"0.46629846",
"0.46603015",
"0.46555358",
"0.46524596",
"0.46511817",
"0.4647007",
"0.4643551",
"0.46414095",
"0.46409172",
"0.46395627",
"0.4623384",
"0.4622352",
"0.46194577",
"0.46120456",
"0.46087316",
"0.46066815",
"0.46043915",
"0.45981044",
"0.4597368",
"0.45947084",
"0.45925516",
"0.45901194"
] | 0.7403369 | 0 |
Cause the identified items to be updated in the EMMA Unified Index. | def reindex(*entries)
list = Upload.get_relation(*entries).to_a
result = ingest_api.put_records(*list)
result.exec_report.error_messages.each { |e| $stderr.puts e }.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_ion_indices\n ion = self.class.ion\n\n\n # Clear out previous indexes...\n ion.index_types.each { |i_type| i_type.deindex(self) }\n\n Ion.redis.multi\n # And add new ones\n ion.indices.each { |index| index.index(self) }\n Ion.redis.exec\n end",
"def update_in_index\n __elasticsearch__.index_document\n\n index_dependent_models.map(&:update_in_index)\n end",
"def update_index\n all.each do |n|\n n.update_index\n end\n end",
"def update(items)\n # clear!\n self.items.each do |i|\n number = items[i.id].blank? ? 1 : items[i.id].to_i <= 0 ? 1 : items[i.id]\n number.to_i < 99 ? i.quantity = number.to_i : i.quantity=99\n end\n # items.each { |id, quantity| add_items(id, quantity) }\n end",
"def fix_items\n valid_items = EquipmentModel.where(id: items.keys).collect(&:id)\n self.items = items.select { |em, _count| valid_items.include? em }\n end",
"def bulk_update_associated_items\n return unless @image_ids.present?\n @image_ids.each_with_index { |image_id, position| update_position_or_create_item(image_id, position) }\n delete_removed_items\n end",
"def update\n @@all_items[@id] = self\n end",
"def update_all\n delete if blacklight_items.count > 0\n self.exports.collect { |pid| add_to_solr(pid) }\n commit\n end",
"def reindex!\n self.index = {}\n data.each do |inventory_object|\n store_index_for(inventory_object)\n end\n end",
"def update!(**args)\n @indices = args[:indices] if args.key?(:indices)\n end",
"def update_index\n all.nodes.each do |n|\n n.reindex!\n end\n end",
"def update_for_ids\n update_for_items.map(&:package_branch).map(&:id)\n end",
"def update!(**args)\n @deployed_index_id = args[:deployed_index_id] if args.key?(:deployed_index_id)\n @ids = args[:ids] if args.key?(:ids)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n end",
"def update_for=(list)\n build_package_association_assignment(:update_for_items,list)\n end",
"def update_items\n @existing_items = []\n @order.items.each { |i| @existing_items << i.id }\n\n # detail and reproduction_pages will come in as attributes of items, but they actually belong to the item_order\n # so look for those, then add them to the correct record in @item_orders\n\n @item_orders.each do |item_order|\n # add item to order\n if !@existing_items.include?(item_order['item_id'].to_i)\n item_order_record = @order.item_orders.create!(item_id: item_order['item_id'], archivesspace_uri: item_order['archivesspace_uri'], user_id: current_user.id, active: true)\n else\n item_order_record = @order.item_orders.where(item_id: item_order['item_id']).first\n item_order_record.update_attributes(archivesspace_uri: item_order['archivesspace_uri'])\n @order.reload\n # delete id from @existing_items array to track associations to be deleted\n @existing_items.delete(item_order['item_id'])\n end\n\n if item_order['reproduction_spec']\n create_or_update_reproduction_spec(item_order_record.id, item_order['reproduction_spec'])\n end\n\n # handle fees\n if @order_sub_type_name == 'reproduction_fee'\n if item_order['order_fee']\n create_or_update_order_fee(item_order_record.id, 'ItemOrder', item_order['order_fee'])\n end\n else\n # delete any existing fee for this item_order if it exists\n OrderFee.where(record_id: item_order_record.id,\n record_type: 'ItemOrder').each { |f| f.destroy! }\n end\n end\n\n @existing_items.each do |item_id|\n @order.item_orders.where(item_id: item_id).each { |io| io.destroy! }\n end\n end",
"def update_hits(queens)\r\n for q in queens\r\n q.update_conflicts()\r\n end\r\n end",
"def update(key, item)\n raise NotImplementedError, \"#{__method__} has not been implemented for this #{name} index\"\n end",
"def update_index(*args)\n\n # This fixes bug https://github.com/sciencehistory/chf-sufia/issues/428 .\n # It updates the display_label property for each inscription associated with this work\n # before said display_label is indexed into SOLR's 'inscription_tesim' field.\n # That field, in turn, is what is shown on the individual work display page\n # as the inscription[s].\n self.inscription.map(&:compose_label)\n # end fix\n\n super.tap do\n if self.changes.keys.include?(\"representative_id\") ||\n self.previous_changes.keys.include?(\"representative_id\") ||\n (self.changes.blank? && self.previous_changes.blank?)\n GenericWork.where(GenericWork.reflections[:representative_id].solr_key => self.id).each do |parent_work|\n parent_work.update_index\n end\n end\n end\n end",
"def reindex!\n find(:all).each { |r| r.update_index(true) }\n end",
"def updated(item)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update_item(index, attrs)\n new_items = items\n new_items[index] = new_items[index].merge(attrs)\n item = item_from_attributes(new_items[index])\n raise ActiveRecord::RecordInvalid, item unless item && item_is_valid?(item)\n update_attribute :items, new_items\n item\n end",
"def reindex\n collection = Collection.find(params[:id])\n EOL::Solr::CollectionItemsCoreRebuilder.reindex_collection(collection)\n collection.update_attribute(:collection_items_count,\n collection.collection_items.count)\n redirect_to collection, notice: I18n.t(:collection_redindexed)\n end",
"def test_updates_index\n p = Post.create(:title => 'A special title', :body => 'foo bar bla bla bla')\n assert result_ids('title').include?(p.id)\n p.update_attributes(:title => 'No longer special')\n assert !result_ids('title').include?(p.id)\n end",
"def update_supply_items(filename = self.import_filename)\n # Hack: First get rid of all ProductSets that don't have any live components anymore, otherwise\n # updates will fail on calculating the weight\n ProductSet.cleanup\n available_supplier_product_codes = @supplier.supply_items.available.collect(&:supplier_product_code)\n to_delete = available_supplier_product_codes.dup\n\n deleted_supplier_product_codes = @supplier.supply_items.deleted.collect(&:supplier_product_code)\n to_reactivate = []\n\n item_hashes = []\n\n\n file = File.open(filename, \"r\")\n file.each do |line|\n data = parse_line(line)\n next if data == false # The array isn't there, skip this line\n next if data[:supplier_product_code].blank? # The line is incomplete, skip it\n if available_supplier_product_codes.include?(data[:supplier_product_code])\n item_hashes << data\n to_delete -= [data[:supplier_product_code]] # Remove those items that were actually found, so we can delete the rest\n end\n if deleted_supplier_product_codes.include?(data[:supplier_product_code])\n item_hashes << data\n to_reactivate += [data[:supplier_product_code]]\n end\n end\n file.close\n\n SupplyItem.expire_category_tree_cache(@supplier)\n # Update the local supply item's information using the line from the CSV file\n\n ThinkingSphinx::Deltas.suspend :supply_item do\n # Deactivate the supply item if the line's not there anymore\n to_delete.each do |td|\n supply_item = @supplier.supply_items.where(:supplier_product_code => td).first\n unless supply_item.nil?\n supply_item.status_constant = SupplyItem::DELETED\n if supply_item.save\n supplier_logger.info(\"[#{DateTime.now.to_s}] Marked Supply Item as deleted: #{supply_item.to_s}\")\n else\n supplier_logger.info(\"[#{DateTime.now.to_s}] Could not mark Supply Item as deleted: #{supply_item.to_s}: #{supply_item.errors.full_messages}\")\n end\n end\n end\n\n # Deactivate the supply item if the line's not there anymore\n to_reactivate.each do |td|\n supply_item = @supplier.supply_items.where(:supplier_product_code => td).first\n unless supply_item.nil?\n supply_item.status_constant = SupplyItem::AVAILABLE\n if supply_item.save\n supplier_logger.info(\"[#{DateTime.now.to_s}] Reactivated supply item because it reappared in the CSV file: #{supply_item.to_s}\")\n else\n supplier_logger.info(\"[#{DateTime.now.to_s}] Could not reactivate supply item: #{supply_item.to_s}: #{supply_item.errors.full_messages}\")\n end\n end\n end\n\n item_hashes.each do |data|\n supply_item = @supplier.supply_items.where(:supplier_product_code => data[:supplier_product_code]).first\n update_supply_item(supply_item, data)\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n end",
"def convertAllItems(arks)\n # Let the user know what we're doing\n puts \"Converting #{arks==\"ALL\" ? \"all\" : \"selected\"} items.\"\n\n # Build a list of all valid units\n $allUnits = Unit.map { |unit| [unit.id, unit] }.to_h\n $allUnits['lbnl'].type = 'campus'\n\n # Build a cache of unit ancestors\n $unitAncestors = Hash.new { |h,k| h[k] = [] }\n UnitHier.each { |hier| $unitAncestors[hier.unit_id] << hier.ancestor_unit }\n\n # Fire up threads for doing the work in parallel\n Thread.abort_on_exception = true\n prefilterThread = Thread.new { prefilterAllItems }\n indexThread = Thread.new { indexAllItems }\n batchThread = Thread.new { processAllBatches }\n\n # Count how many total there are, for status updates\n $nTotal = QUEUE_DB.fetch(\"SELECT count(*) as total FROM indexStates WHERE indexName='erep'\").first[:total]\n\n # Convert all the items that are indexable\n query = QUEUE_DB[:indexStates].where(indexName: 'erep').select(:itemId, :time).order(:itemId)\n $nTotal = query.count\n if $skipTo\n puts \"Skipping all up to #{$skipTo}...\"\n query = query.where{ itemId >= \"ark:13030/#{$skipTo}\" }\n $nSkipped = $nTotal - query.count\n end\n query.all.each do |row| # all so we don't keep db locked\n shortArk = row[:itemId].sub(%r{^ark:/?13030/}, '')\n next if arks != 'ALL' && !arks.include?(shortArk)\n erepTime = Time.at(row[:time].to_i).to_time\n item = Item[shortArk]\n if !item || item.last_indexed.nil? || item.last_indexed < erepTime || $rescanMode\n $prefilterQueue << [shortArk, erepTime]\n else\n #puts \"#{shortArk} is up to date, skipping.\"\n $nSkipped += 1\n end\n end\n\n $prefilterQueue << nil # end-of-queue\n prefilterThread.join\n indexThread.join\n batchThread.join\nend",
"def reset_indices\n relevant_books = self.user.listed_books.where(is_read: true).order(:order_index)\n relevant_books.each_with_index { |book, i| relevant_books[i].order_index = i }\n relevant_books.each(&:save)\n relevant_books = self.user.listed_books.where(is_read: false).order(:order_index)\n relevant_books.each_with_index { |book, i| relevant_books[i].order_index = i }\n relevant_books.each(&:save)\n\n end",
"def items\n if params[:update] == \"true\"\n ## Invariant: we are about to update all of the items in the library.\n logger.debug(\"Updating Items.\")\n Product.find(:all).each do |product|\n @name_call = product.id.to_s + \".name\"\n product.update_name(params[@name_call])\n @price_call = product.id.to_s + \".price\"\n product.update_price(params[@price_call])\n @inventory_call = product.id.to_s + \".inventory\"\n product.update_inventory(params[@inventory_call])\n @description_call = product.id.to_s + \".description\"\n product.update_description(params[@description_call])\n end\n ## Now we have to add any new items that were written in.\n if params[:added] != 0\n for i in 1..params[:added].to_i\n @n = \"name.new.\" + i.to_s\n @p = \"price.new.\" + i.to_s\n @inv = \"inventory.new.\" + i.to_s\n @des = \"description.new.\" + i.to_s\n if params[@n] && params[@p] && params[@inv] && params[@des]\n Product.create(:name => params[@n].to_s, :price => params[@p].to_f, :inventory => params[@inv].to_i, :description => params[@des].to_s)\n end\n end\n end\n end\n end",
"def update attributes, collection #:nodoc:\n 0\n end",
"def update_index\n index_files = []\n index_files << upload(\"specs.4.8.gz\", specs_index)\n log \"Uploaded all specs index\"\n index_files << upload(\"latest_specs.4.8.gz\", latest_index)\n log \"Uploaded latest specs index\"\n index_files << upload(\"prerelease_specs.4.8.gz\", prerelease_index)\n log \"Uploaded prerelease specs index\"\n\n index_files.each do |file|\n tuf_repo.replace_file(file, 'targets/unclaimed', 'targets')\n end\n\n # For now assume all files are unclaimed\n pending_files = tuf_pending_store.pending\n pending_files.each do |file|\n puts \"Adding file: #{file.path}\"\n tuf_repo.add_file(file, 'targets/unclaimed', 'targets')\n end\n tuf_repo.publish!\n tuf_pending_store.clear(pending_files)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update_quality(items)\n items.each do |item|\n if is_special_item?(item)\n special_item(item)\n else\n item.sell_in > 0 ? decrement_normal_item(item, 1) : decrement_normal_item(item, 2)\n end\n\n item.sell_in -= 1\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!(**args)\n @item_id = args[:item_id] if args.key?(:item_id)\n end",
"def update!(**args)\n @item = args[:item] if args.key?(:item)\n @location = args[:location] if args.key?(:location)\n @update_mask = args[:update_mask] if args.key?(:update_mask)\n end",
"def update_amounts\n @items = @items.each do |item|\n item[:good_tax] = set_tax(item[:good], item[:total], @good_tax_rate)\n item[:import_tax] = set_tax(item[:import], item[:total], @import_tax_rate)\n item[:sales_tax] = add_taxes(item[:sales_tax], item[:good_tax], item[:import_tax])\n item[:total] = add_taxes(item[:total], item[:good_tax], item[:import_tax])\n end\n end",
"def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n end",
"def update_es_index\n \n if self.respond_to? :op_success\n \n if self.op_success.nil?\n \n es_update\n else\n \n es_update if self.op_success == true\n end\n else\n \n es_update\n end\n \n end",
"def update\n update_all\n end",
"def update_report_items\n\t\t\n\t\tself.reports.map{|c|\n\t\t\tc.clear_all_items\n\t\t}\n\n\t\tself.categories.each do |category|\n\t\t\t#puts \"doing category: #{category.name}\"\n\n\t\t\tcategory.set_item_report_applicability(self.reports,self.id.to_s)\n\t\t\t\n\t\t\tcategory.items.each do |item|\n\t\t\t\t#puts \"item applicable to reports are:\"\n\t\t\t\t#puts item.applicable_to_report_ids.to_s\n\t\t\t\t#exit(1)\n\t\t\t\t## can this item be created at all?\n\t\t\t\t## that's the first thing.f\n\t\t\t\tself.reports.each do |report|\n\t\t\t\t\t## if the report id is there in the item applicability then only add it.\n\t\t\t\t\t## and add the errors to the other items.\n\t\t\t\t\t## these will be displayed.\n\t\t\t\t\t## now add errors on the other items.\n\t\t\t\t\tif item.applicable_to_report_ids.include? report.id.to_s\n\t\t\t\t\t\treport.add_item(category,item)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def update\n @item = Item.find(params[:id])\n if params[:item][:index]\n index = params[:item][:index]\n params[:item].delete :index\n @item.update_attribute :ranked_position, index\n end \n\n respond_to do |format|\n if @item.update_attributes(params[:item].slice(*Item.accessible_attributes.to_a))\n format.html { redirect_to @item, notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @index = args[:index] if args.key?(:index)\n end",
"def update!(**args)\n @index = args[:index] if args.key?(:index)\n end",
"def update!(**args)\n @index = args[:index] if args.key?(:index)\n end",
"def update!(**args)\n @index = args[:index] if args.key?(:index)\n end",
"def repair!\n update!\n end",
"def update_index\n if should_be_in_index?\n mapper.process_with([record]) do |context|\n writer.put(context)\n end\n else\n writer.delete(record.send(Kithe.indexable_settings.solr_id_value_attribute))\n end\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @indexed_items_count = args[:indexed_items_count] if args.key?(:indexed_items_count)\n @status_code = args[:status_code] if args.key?(:status_code)\n end",
"def reindex_data(*models) \n Mebla.log(\"Rendexing: #{self.slingshot_index_name}\")\n \n unless drop_index\n raise Mebla::Errors::MeblaIndexException.new(\"Could not drop #{@slingshot_index_name}!!!\")\n end \n \n # Create the index and index the data\n if models && !models.empty?\n index_data(models)\n else\n index_data\n end\n end",
"def approve_items(with_product)\n items = InventoryItem.where(name: name, unit_id: unit_id, category_id: category_id).where(\"type is null and product_id is null\").where(\"id <> ?\", id)\n items << self\n items.each do |item|\n item.name = \"#{with_product.name} \"#(#{with_product.unit_name})\"\n item.unit_id = with_product.unit_id\n item.product_id = with_product.id\n item.save(:validate => false)\n end\n end",
"def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end",
"def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end",
"def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end",
"def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end",
"def update_for\n update_for_items.collect(&:package)\n end",
"def update!(**args)\n @target_ids = args[:target_ids] if args.key?(:target_ids)\n end",
"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 update_item\n self.item.update_complete\n end",
"def update\n respond_to do |format|\n @list = @item.auction.items.all\n temp = Item.new(item_params)\n item = Item.find_by seq: @item.seq, id: @item.id #Item sequence was changed and collides\n # logger.info {\">>>>>item #{item.id} #{item.seq} temp #{temp.seq} <<<<\"}\n @list.each do |l|\n # logger.info {\">>>>> #{item.seq} #{temp.seq} <<<<\"}\n if item.seq > temp.seq # dir = up\n if ((l.seq < item.seq) && (l.seq >= temp.seq)) \n l.seq += 1 \n l.save\n end\n else # dir = down\n if ((l.seq > item.seq) && (l.seq <= temp.seq)) \n l.seq -= 1 \n l.save\n end\n end\n end\n if @item.update(item_params)\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 bulk_results = @invitation.each_with_object({}) do |model, memo|\n memo[model.id] = model.update available: 0\n end\n\n all_good = bulk_results.values.all?\n\n if all_good\n flash[:info] = \"Bulk disable of invitations was successful\"\n render json: { bulk_results: }, status: :ok\n else\n flash[:error] = \"Some invitations could not be disabled\"\n render json: { bulk_results: }, status: :unprocessable_entity\n end\n end",
"def update!(**args)\n @item_count = args[:item_count] if args.key?(:item_count)\n @item_type = args[:item_type] if args.key?(:item_type)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @labels = args[:labels] if args.key?(:labels)\n @section_id = args[:section_id] if args.key?(:section_id)\n end",
"def update_index # :nodoc:\n self.class.indexer.index(self)\n end",
"def update!(**args)\n @x_indices = args[:x_indices] if args.key?(:x_indices)\n end",
"def update!(**args)\n @also_known_as = args[:also_known_as] if args.key?(:also_known_as)\n @name = args[:name] if args.key?(:name)\n @office_indices = args[:office_indices] if args.key?(:office_indices)\n end",
"def update_order_of_items_bulk\n @catalog = Catalog.find(params[:id])\n result = @catalog.do_update_order_of_items_bulk(params[:item_change][:moved_items], params[:item_change][:before_item]);\n \n # return a success message, wouldn't make sense to call this API method as html, but for debugging\n # just return json anyway\n respond_to do |format|\n format.html { render json: result}\n format.json { render json: result}\n end\n end",
"def update!(**args)\n @item_count = args[:item_count] if args.key?(:item_count)\n @item_type = args[:item_type] if args.key?(:item_type)\n end",
"def update!(**args)\n @item_id = args[:item_id] if args.key?(:item_id)\n @list_id = args[:list_id] if args.key?(:list_id)\n end",
"def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end",
"def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def update!(**args)\n @index = args[:index] if args.key?(:index)\n @type = args[:type] if args.key?(:type)\n end",
"def update!(**args)\n @available_inventory_item_ids = args[:available_inventory_item_ids] if args.key?(:available_inventory_item_ids)\n @create_time = args[:create_time] if args.key?(:create_time)\n @details = args[:details] if args.key?(:details)\n @installed_inventory_item_ids = args[:installed_inventory_item_ids] if args.key?(:installed_inventory_item_ids)\n @items = args[:items] if args.key?(:items)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def local_update_members\n if self.respond_to?(:members)\n self.members.each do |member|\n member.reload.update_index\n end\n end\n end",
"def local_update_members\n if self.respond_to?(:members)\n self.members.each do |member|\n member.reload.update_index\n end\n end\n end",
"def update(attributes, collection)\n #collection[0].model.last_query = [attributes, collection]\n fm_params = prepare_fmp_attributes(attributes)\n counter = 0\n collection.each do |resource|\n rslt = layout(resource.model).edit(resource.instance_variable_get(:@_record_id), fm_params)\n merge_fmp_response(resource, rslt[0])\n resource.persistence_state = DataMapper::Resource::PersistenceState::Clean.new resource\n counter +=1\n end\n counter \n end",
"def mte_prepare_updating; send_request_to_mite(\"update\"); end",
"def update_aggregates\n es_client.indices.refresh index: index_name\n self.update_attributes(\n num_users: sample_users.length,\n num_tweets: es_client.count(index: index_name)['count'],\n num_retweets: count_retweets,\n hashtags: MetadataHarvester.new(:hashtags, all_tweets).harvest,\n top_urls: MetadataHarvester.new(:urls, all_tweets).harvest,\n top_words: MetadataHarvester.new(:words, all_tweets).harvest,\n top_mentions: MetadataHarvester.new(:mentions, all_tweets).harvest,\n top_sources: MetadataHarvester.new(:sources, all_tweets).harvest,\n top_retweets: MetadataHarvester.new(:retweets, all_tweets).harvest\n )\n end",
"def update_order_item\n \n end"
] | [
"0.6704029",
"0.6561512",
"0.65048593",
"0.64639896",
"0.617644",
"0.60726136",
"0.5969441",
"0.59573597",
"0.59404886",
"0.59147817",
"0.5902834",
"0.5884477",
"0.5884345",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.58207303",
"0.57513577",
"0.5746867",
"0.5733158",
"0.5708118",
"0.57016176",
"0.5693802",
"0.5680222",
"0.5680222",
"0.56733364",
"0.5668345",
"0.5621707",
"0.56136185",
"0.560934",
"0.55896014",
"0.5589555",
"0.55792016",
"0.55764854",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.55556166",
"0.5550436",
"0.5515184",
"0.55089915",
"0.55008286",
"0.5487149",
"0.54809767",
"0.54780555",
"0.5458757",
"0.5457014",
"0.5447407",
"0.5444257",
"0.5444257",
"0.5444257",
"0.5444257",
"0.54431146",
"0.5426459",
"0.5422003",
"0.54218197",
"0.5409853",
"0.5408683",
"0.5408683",
"0.5408683",
"0.5408683",
"0.54060286",
"0.54004574",
"0.5398485",
"0.5397341",
"0.53943205",
"0.53930223",
"0.5392727",
"0.53861314",
"0.5382931",
"0.53827375",
"0.53797084",
"0.5371565",
"0.53713727",
"0.5366367",
"0.53604144",
"0.53583044",
"0.5356783",
"0.53510725",
"0.53471655",
"0.53471655",
"0.5346938",
"0.5343576",
"0.53342134",
"0.53315663"
] | 0.538517 | 84 |
Method to check the domain registration status. | def check_status(domain=nil)
begin
domain = self.fqdn if domain == nil
rescue NoMethodError
raise ArgumentError, "wrong number of arguments (0 for 1)"
end
@whois = parse_query(domain)
@whois['status']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_registration_status(domain)\n xml = send_recv(:GetRegistrationStatus, split_domain(domain))\n { :hold => xml.RegistrarHold?, :registration => xml.RegistrationStatus, :purchase => xml.PurchaseStatus }\n end",
"def valid?\n !domain.nil?\n end",
"def registered?\n begin\n self.get_registration\n true\n rescue => e\n # any error should be treated as the user not being registered\n false\n end\n end",
"def registration_complete?\n self.address.present?\n end",
"def domain_check(name)\n options = { \"domains\" => [ {\"dname\" => name} ] }\n request_v2(\"domain\", \"check\", options)\n if is_success?\n record = response[\"answer\"][\"domains\"].first\n record && record[\"error_code\"].nil? && record[\"result\"] == \"Available\"\n end\n end",
"def registration_required?\n not hosted?\nend",
"def registration_required?\n not hosted?\nend",
"def registered?\n controller.registered?\n end",
"def register_domain(sld, tld, *extra_info)\n query_push({'Command' => 'Purchase', 'SLD' => sld, 'TLD' => tld,\n 'Debit' => 'True'})\n if extra_info[:admin]\n if extra_info[:admin].is_a? Contact\n query_push {}\n end\n end\n\n if extra_info[:nameservers]\n query_push {}\n else\n query_push {'UseDNS' => 'default'}\n end\n\n get_response\n if @result['RRPCode'].to_i == 200\n return true\n else\n return false\n end\n end",
"def ukda_registration_check(person)\n params={'LoginName' => person.email, 'Login' => 'Login'}\n response= Net::HTTP.post_form(URI.parse(UKDA_EMAIL_ADDRESS),params)\n xml_parser = XML::Parser.string(response.body)\n xml = xml_parser.parse\n node = xml.find('child::registered')\n return node.first.content == \"yes\"\n end",
"def resolvable?(domain)\n Resolv.getaddress domain\n true\n rescue Resolv::ResolvError => _e\n false\n end",
"def resolvable?(domain)\n Resolv.getaddress domain\n true\n rescue Resolv::ResolvError => _e\n false\n end",
"def registration_date?\n return true if @registration\n false\n end",
"def check\n begin\n domains = File.read(@params[:domains_path]).split\n rescue Errno::ENOENT \n STDERR.puts \"File #{@params[:domains_path]} does not exist\"\n exit 1 \n end\n\n checks = domains.map do |domain|\n rdap = Net::HTTP.get(URI(\"#{@params[:rdap_url]}/domain/#{domain}\"))\n db.check domain, rdap \n end\n\n message = checks.map {|check| check.status}.to_json\n STDOUT.puts message\n\n if @params[:gchat] \n # GChat gets every status update\n GChat.new(@params[:gchat]).message(message) \n end\n if @params[:mandrill_key] && @params[:mandrill_email] && checks.any?(&:changed?)\n # We only email changed domains\n Mandrill.new(@params[:mandrill_key], @params[:mandrill_email]).message(message)\n end\n end",
"def valid_whois?\n @status == '200' && parser.valid_whois?\n end",
"def accepts_registrations?\n in_reg_period? and !invite_only?\n end",
"def verify_domain(domain)\n begin\n Socket.gethostbyname(domain)\n rescue SocketError\n return false\n end\n\n true\n end",
"def allow_registration?\n true\n end",
"def is_registered?\n # keep track of where we are: if no password in db\n # it means we still are at the registration step\n\n # Note that we use the \"_was\" suffix here (AR::Dirty) to check\n # the value of the field before the update\n !crypted_password_was.blank?\n end",
"def status domain\n _format_status(post('dcv/v2/validation/status', domain: domain))\n end",
"def registration_passed?\n d = @data_object\n today = Date.today\n d.aff_reg_end.to_date < today\n end",
"def check_gdom_isnt_running(options)\n message = \"Information:\\tChecking Guest Domain \"+options['name']+\" is running\"\n command = \"ldm list-bindings #{options['name']} |grep '^#{options['name']}'\"\n output = execute_command(options,message,command)\n if output.match(/active/)\n handle_output(options,\"Warning:\\tGuest Domain #{options['name']} is already running\")\n quit(options)\n end\n return\nend",
"def registered?\n registrations = self.ring_server.read_all([:name,\n @service,\n nil,\n @identifier])\n registrations.any? { |registration| registration[2] == self }\n rescue DRb::DRbConnError\n @ring_server = nil\n false\n end",
"def valid_domain?\n PublicSuffix.valid? domain\n end",
"def account_created\n URI.escape(@response) == URI.escape(Registration.validate_registration(@screen_id)) ? true : false\n end",
"def check_gdom_is_running(options)\n message = \"Information:\\tChecking Guest Domain \"+options['name']+\" is running\"\n command = \"ldm list-bindings #{options['name']} |grep '^#{options['name']}'\"\n output = execute_command(options,message,command)\n if not output.match(/active/)\n handle_output(options,\"Warning:\\tGuest Domain #{options['name']} is not running\")\n quit(options)\n end\n return\nend",
"def exists?\n\n\t\tbegin\n\t\t\tdom\n\t\t\tdebug \"Domain %s exists? true\" % [resource[:name]]\n\t\t\ttrue\n\t\trescue Libvirt::RetrieveError => e\n\t\t\tdebug \"Domain %s exists? false\" % [resource[:name]]\n\t\t\tfalse # The vm with that name doesnt exist\n\t\tend\n\n\tend",
"def if_can_register(url)\n event_page = @agent.get(url)\n matched_nodes = event_page.search(\"#normal_register > h3\")\n if matched_nodes.empty?\n return false\n elsif matched_nodes[0].text == \"Påmelding\"\n return true\n else\n return false\n end\n end",
"def exist?(domain)\n Domain.all(:name => domain).any?\n end",
"def valid_dns?\n return true unless dns_enabled?\n bool = dns_a_record.size > 0 || set_error(:domain_unknown)\n if localhost? && !@config[:host_local]\n bool = set_error(:domain_no_localhost)\n end\n bool\n end",
"def exists?\n\t\tbegin\n\t\t\tdom\n\t\t\tdebug \"Domain %s exists? true\" % [resource[:name]]\n\t\t\ttrue\n\t\trescue Libvirt::RetrieveError => e\n\t\t\tdebug \"Domain %s exists? false\" % [resource[:name]]\n\t\t\tfalse # The vm with that name doesnt exist\n\t\tend\n\tend",
"def registration_status(dir)\n result = result_status(dir)\n return result unless result.nil?\n log_status(dir)\n end",
"def company_valid?\n return true if AccountType.individual?(account_type) || company.nil?\n\n company.valid?(account_type.registration_type.to_sym)\n end",
"def ukda_registration_check(user)\n begin\n params={'LoginName' => user.email, 'Login' => 'Login'}\n response= Net::HTTP.post_form(URI.parse(UKDA_EMAIL_ADDRESS),params)\n xml_parser = XML::Parser.string(response.body)\n xml = xml_parser.parse\n node = xml.find('child::registered')\n rescue Exception => e\n # ukda reg check service probably down, default to looking at last time checked\n # if less than 6 months ago then say ok as long as they were previously ok\n if user.last_ukda_check != nil && user.last_ukda_check >= Time.now - (60 * 60 * 24 * 180) && user.ukda_registered\n return true\n else\n return false\n end\n end\n \n if node.first.content == \"yes\"\n puts \"updating user ukda\"\n user.update_attributes(:last_ukda_check => Time.now, :ukda_registered => true)\n return true\n else\n user.update_attributes(:last_ukda_check => Time.now, :ukda_registered => false)\n return false\n end\n\n end",
"def check_subdomain?\n subdomain = request.subdomain\n if subdomain == 'www'\n redirect_to root_url(host: Rails.application.config.action_mailer.default_url_options[:host])\n elsif subdomain.blank? || Company.find_by(subdomain: subdomain).nil?\n flash[:alert] = 'Get Registered First'\n redirect_to root_url(host: Rails.application.config.action_mailer.default_url_options[:host])\n end\n end",
"def valid?\n return false if @domain.nil?\n domain_validator = EnumAttributeValidator.new('String', [\"Notification\", \"Organization\", \"OrganizationGateway\", \"Product\", \"User\", \"Subscription\", \"Profile\", \"ProductRatePlan\", \"Client\", \"Invoice\", \"PricingComponentValue\", \"Account\", \"PricingComponentValueChange\", \"PricingComponentTier\", \"PricingComponent\", \"PricingCalculation\", \"Coupon\", \"CouponDiscount\", \"CouponDefinition\", \"CouponInstance\", \"CouponModifier\", \"CouponRule\", \"CouponBookDefinition\", \"CouponBook\", \"InvoiceLine\", \"Webhook\", \"WebhookSubscription\", \"SubscriptionCancellation\", \"NotificationSnapshot\", \"InvoicePayment\", \"Payment\", \"PaymentMethod\", \"PaymentMethodSubscriptionLink\", \"DunningLine\", \"CybersourceToken\", \"Card\", \"Alias\", \"PaypalSimplePaymentReconciliation\", \"FreePaymentReconciliation\", \"LocustworldPaymentReconciliation\", \"CouponInstanceExistingValue\", \"TaxLine\", \"TaxationStrategy\", \"TaxationLink\", \"Address\", \"AmendmentPriceNTime\", \"Authority\", \"UnitOfMeasure\", \"SearchResult\", \"Amendment\", \"AuditLog\", \"Password\", \"Username\", \"FixedTermDefinition\", \"FixedTerm\", \"Refund\", \"CreditNote\", \"Receipt\", \"AmendmentCompoundConstituent\", \"APIConfiguration\", \"StripeToken\", \"BraintreeToken\", \"BalancedToken\", \"AuthorizeNetToken\", \"PaypalToken\", \"SpreedlyToken\", \"SagePayToken\", \"TrustCommerceToken\", \"PayVisionToken\", \"SagePayOutstandingTransaction\", \"SagePayEnabledCardType\", \"SagePayTransaction\", \"GatewayRevenue\", \"Migration\", \"AdhocSubscription\", \"SubscriptionCharge\", \"ComponentChange\", \"Verification\", \"UsageRoundingStrategies\", \"PricingComponentValueMigrationChargeAmendmentMapping\", \"AmendmentDiscardAmendment\", \"EntityTime\", \"AggregatingComponent\", \"PricingComponentMigrationValue\", \"MetadataKeyValue\", \"Metadata\", \"AggregationLink\", \"BFPermission\", \"Role\", \"PermissionLink\", \"PayVisionTransaction\", \"KashToken\", \"DataSynchronizationJob\", \"DataSynchronizationJobError\", \"DataSynchronizationConfiguration\", \"DataSynchronizationAppConfiguration\", \"AggregationChildrenResponse\", \"InvoiceLinePayment\", \"EmailSubscription\", \"EmailProvider\", \"TimeResponse\", \"Email\", \"RevenueAttribution\", \"Unknown\"])\n return false unless domain_validator.valid?(@domain)\n return false if @action.nil?\n action_validator = EnumAttributeValidator.new('String', [\"Accept\", \"Active\", \"AwaitingPayment\", \"AwaitingRefund\", \"Cancelled\", \"Completed\", \"Created\", \"Error\", \"Expiring\", \"Expired\", \"Failed\", \"Migrated\", \"NeedsAmendments\", \"Paid\", \"Pending\", \"Provisioned\", \"Refunded\", \"Reject\", \"Trial\", \"Unknown\", \"Unpaid\", \"Updated\", \"Voided\", \"PaymentFailed\"])\n return false unless action_validator.valid?(@action)\n return false if @organization_id.nil?\n return false if @webhook_id.nil?\n return false if @entity_id.nil?\n return false if @destination_url.nil?\n return false if @format.nil?\n format_validator = EnumAttributeValidator.new('String', [\"JSON\", \"XML\"])\n return false unless format_validator.valid?(@format)\n return false if @ack_enabled.nil?\n return false if @state.nil?\n state_validator = EnumAttributeValidator.new('String', [\"Unsent\", \"Sending\", \"Sent\"])\n return false unless state_validator.valid?(@state)\n return true\n end",
"def check_firecloud_registration\n if user_signed_in?\n if current_user.registered_for_firecloud?\n # make sure user is part of user group\n if !current_user.added_to_unity_group?\n current_user.add_to_unity_user_group\n end\n else\n if user_fire_cloud_client(current_user).registered?\n current_user.add_to_unity_user_group\n current_user.update(registered_for_firecloud: true)\n true\n else\n redirect_to profile_path, notice: 'You must register before using Unity - please fill out the profile form and submit.' and return\n end\n end\n end\n end",
"def registered?\n registrations = ring_server.read_all [:name, @service, nil, @identifier]\n registrations.any? { |registration| registration[2] == @object }\n rescue DRb::DRbConnError\n @ring_server = nil\n return false\n end",
"def program_registration?\n program_registration_id.present?\n end",
"def registered?\n !guest?\n end",
"def check_domain(opts = {})\n data, _status_code, _headers = check_domain_with_http_info(opts)\n data\n end",
"def valid?\n return false if @domain.nil?\n return false if @domain.to_s.length > 64\n return false if @register_server.nil?\n transport_protocol_validator = EnumAttributeValidator.new('String', ['UDP', 'TCP', 'TLS', 'AUTO'])\n return false unless transport_protocol_validator.valid?(@transport_protocol)\n return false if @proxy_server.nil?\n transport_protocol2_validator = EnumAttributeValidator.new('String', ['UDP', 'TCP', 'TLS', 'AUTO'])\n return false unless transport_protocol2_validator.valid?(@transport_protocol2)\n transport_protocol3_validator = EnumAttributeValidator.new('String', ['UDP', 'TCP', 'TLS', 'AUTO'])\n return false unless transport_protocol3_validator.valid?(@transport_protocol3)\n return false if !@registration_expire_time.nil? && @registration_expire_time > 127\n return false if !@registration_expire_time.nil? && @registration_expire_time < 1\n return false if @user_name.nil?\n return false if @user_name.to_s.length > 64\n return false if @password.nil?\n return false if @authorization_name.nil?\n return false if @authorization_name.to_s.length > 64\n return false if @user_email.nil?\n return false if @user_email.to_s.length > 64\n return false if @voice_mail.nil?\n return false if @voice_mail.to_s.length > 255\n true\n end",
"def runasdomain?\n @resource[:runasdomain]\n end",
"def valid_dns?\n @host.exchanger.has_dns_a_record?\n end",
"def registered?\n !new_record? && !anonymous?\n end",
"def registrable?\n # Almost all Names in MO are potentially registrable, so use a blacklist\n # instead of a whitelist\n !unregistrable?\n end",
"def domain_check(*domains)\n super # placeholder so that I can add some doc\n end",
"def sub_domain_known?(domain)\n\t\tputs \"Validate sub-domain: #{domain}\" if @verbose\n\t\tdomain=domain.strip.downcase\n\t\tsubs=dump_sub_domains\n\t\treturn subs.include?(domain)\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def valid?\n @hydra.queue(request('verify'))\n end",
"def registered(user)\n self.rsvped?(user) || self.isHost?(user)\n end",
"def basic_company_details_valid?\n return true unless AccountType.other_organisation?(account_type)\n\n company.valid?(account_type.registration_type.to_sym)\n end",
"def valid?\n PublicSuffix.valid?(domain)\n end",
"def domain_check(*domains)\n domains.flatten!\n response = send_request(domain_check_xml(*domains))\n\n get_result(:xml => response, :callback => :domain_check_process)\n end",
"def signup_allowed?(dd)\n dd.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SIGN_UP\n end",
"def waiting_registry?\n status == 'waiting_registry'\n end",
"def is_registered_true!\n self.is_registered = true\n end",
"def check_pending_registration!\n redirect_to dashboard_finish_registration_path if current_user.is_newbie?\n end",
"def check_registration!\n if current_user\n true\n else\n respond_to do |format|\n format.html do\n store_location\n redirect_to main_app.register_path\n end\n format.json do\n render status: 403, nothing: true\n end\n end\n end\n end",
"def set_registrar_lock_status(action)\n ensure_attribute_has_value :domain\n return false if @errors.any?\n \n params = {'domain' => @domain}\n response = Client.post(\"/domain/registrarlock/#{action.to_s}\", params)\n code = response.code rescue \"\"\n \n case code\n when '200'\n hash = JSON.parse(response.body)\n\n @status = hash['status']\n @transaction_id = hash['transactid']\n \n unless @status == 'SUCCESS'\n set_errors(response)\n return false\n end\n \n return true\n else\n set_errors(response)\n return false\n end\n end",
"def subdomain_available?(subdomain)\n begin\n return put :subdomain_available?, {:subdomain => subdomain}\n rescue RestClient::UnprocessableEntity\n return false\n end\n end",
"def status_domain(domain, type = 'Purchase')\n raise ArgumentError, \"type must be Purchase, Transfer or Extend\" unless %w(purchase transfer extend).include?(type.downcase)\n begin\n xml = send_recv(:StatusDomain, split_domain(domain).merge(:OrderType => type))\n\n xml.DomainStatus do\n return { :known => (xml.Known == 'Known'),\n :in_account => xml.InAccount?, # It'll be either 0 or 1 here, case 2 raises an exception\n :last_order_id => xml.OrderID }\n end\n rescue ResponseError => e\n if e.messages.include?(\"The domain does not belong to this account\")\n # It returns an error if the domain is known to eNom but in another account\n return { :known => true, :in_account => false }\n end\n end\n end",
"def domain_allowed?(domain)\n ALLOWED_SITES.include?(domain)\n end",
"def subdomain_is_unique\n if subdomain.present? && (League.all.count > 0)\n unless League.find_by_subdomain(subdomain).nil?\n errors.add(:subdomain, \"is already taken\")\n end\n if Apartment::Elevators::Subdomain.excluded_subdomains.include?(subdomain)\n errors.add(:subdomain, \"is not available\")\n end\n end\n end",
"def domain_record?\n name.blank? || name == domain.name\n end",
"def status\n\n\t\tif exists? \n\t\t\t# 1 = running, 3 = paused|suspend|freeze, 5 = stopped \n\t\t\tif resource[:ensure].to_s == \"installed\"\n\t\t\t\treturn \"installed\"\n\t\t\telsif dom.info.state != 5\n\t\t\t\tdebug \"Domain %s status: running\" % [resource[:name]]\n\t\t\t\treturn \"running\"\n\t\t\telse\n\t\t\t\tdebug \"Domain %s status: stopped\" % [resource[:name]]\n\t\t\t\treturn \"stopped\"\n\t\t\tend\n\t\telse\n\t\t\tdebug \"Domain %s status: absent\" % [resource[:name]]\n\t\t\treturn \"absent\"\n\t\tend\n\n\tend",
"def status\n\n\t\tif exists? \n\t\t\t# 1 = running, 3 = paused|suspend|freeze, 5 = stopped \n\t\t\tif resource[:ensure].to_s == \"installed\"\n\t\t\t\treturn \"installed\"\n\t\t\telsif dom.info.state != 5\n\t\t\t\tdebug \"Domain %s status: running\" % [resource[:name]]\n\t\t\t\treturn \"running\"\n\t\t\telse\n\t\t\t\tdebug \"Domain %s status: stopped\" % [resource[:name]]\n\t\t\t\treturn \"stopped\"\n\t\t\tend\n\t\telse\n\t\t\tdebug \"Domain %s status: absent\" % [resource[:name]]\n\t\t\treturn \"absent\"\n\t\tend\n\n\tend",
"def valid?\n # Ensure it's a valid domain\n return false unless PublicSuffix.valid?(domain)\n\n # Ensure non-edu\n return false if Swot::is_academic?(domain)\n\n # check using public suffix's standard logic\n rule = Gman.list.find domain\n return true if !rule.nil? && rule.allow?(domain)\n\n # also allow for explicit matches to domain list\n Gman.list.rules.any? { |rule| rule.value == domain }\n end",
"def registered?\n self.class.registered_uids.include? uid\n end",
"def valid?\n ping\n end",
"def valid_type?\n type == \"domain\"\n end",
"def valid_type?\n type == \"domain\"\n end",
"def registration_date_is_valid?\n begin\n USDateParse(self.registration_deadline)\n rescue\n return false\n end\n return true\n end",
"def user_registered? user\n return nil if user.nil?\n return nil if user.person.nil?\n\n if self.registrations.where(:person_id => user.person.id).count == 0\n logger.debug(\"User #{user.email} isn't registered to self.title\")\n return false\n else\n return true\n end\n end",
"def user_registered? user\n return nil if user.nil?\n return nil if user.person.nil?\n\n if self.registrations.where(:person_id => user.person.id).count == 0\n logger.debug(\"User #{user.email} isn't registered to self.title\")\n return false\n else\n return true\n end\n end",
"def check\n request = Grpc::Health::V1::HealthCheckRequest.new\n response = GitalyClient.call(@storage, :health_check, :check, request, timeout: GitalyClient.fast_timeout)\n\n { success: response&.status == :SERVING }\n rescue GRPC::BadStatus => e\n { success: false, message: e.to_s }\n end",
"def google?\n @domain.include?(:Google)\n end",
"def active?\n result = FFI::Libvirt.virDomainIsActive(self)\n return nil if result == -1\n result == 1\n end",
"def active?\n result = FFI::Libvirt.virDomainIsActive(self)\n return nil if result == -1\n result == 1\n end",
"def create\n return true if active?\n FFI::Libvirt.virDomainCreate(self) == 0\n end",
"def create\n return true if active?\n FFI::Libvirt.virDomainCreate(self) == 0\n end",
"def company_registered\n wizard_company_step(accounts_registration_address_url)\n end",
"def valid?\n status == 'Valid'\n end",
"def check!\n raise InvalidDNS unless dns?\n return if proxied?\n raise DeprecatedIP if a_record? && old_ip_address?\n raise InvalidARecord if valid_domain? && a_record? && !should_be_a_record?\n raise InvalidCNAME if valid_domain? && !github_domain? && !apex_domain? && !pointed_to_github_user_domain?\n raise NotServedByPages unless served_by_pages?\n true\n end",
"def validate_subdomain\n if current_account || request.host == \"localhost\"\n elsif current_account.nil?\n redirect_to '/404.html'\n end\n end",
"def status( name, reg )\n @inreg = true\n\n unless reg.has_key?( name )\n @inreg = false\n end\n end",
"def has_related_patient?\n if registrations.count > 0\n return true\n end\n under_supervision_clinics.each do |clinic|\n clinic.registrations.each do |reg|\n return true\n end\n end\n return false\n end",
"def check_registration\n return unless Spree::Auth::Config[:registration_step]\n return if spree_current_user || current_order.email\n store_location\n redirect_to spree.checkout_registration_path\n end",
"def has_subdomain?(subdomain)\n owned_subdomains.include?(subdomain)\n end",
"def check!\n true\n end",
"def verify_register_conclusion\n if !@user.face_confirmed?\n flash[:notice] = \"Insira um e-mail pessoal para receber nossos avisos.\"\n redirect_to email_completar_path\n return false\n end\n if !@user.is_completed?\n flash[:notice] = \"Conclua sua inscrição para acessar todas as funções do sistema\"\n #flash[:notice] = \"Não é possível finalizar seu cadastro. Aguarde até o dia 20 para se inscrever novamente!\"\n redirect_to cadastro_completar_path\n return false\n end\n end",
"def is_a_domain?\n domain? && !subdomain?\n end",
"def check_registration\n registrations = Registration.where(\"user_id = ? and course_id = ?\", self.user_id, self.course_id)\n if (registrations.nil? || registrations.length == 0)\n errors[:name] = \"only users who are registered for the course can review the course.\"\n return false\n end\n end",
"def check\n @response = get_fixity_response_from_fedora\n status.match(\"SUCCESS\") ? true : false\n end",
"def validate\n @domains.each do |d|\n raise 'domain definition error' unless d.class == Domain\n end\n @domains.map(&:validate)\n end",
"def check_registration\n return unless Spree::Auth::Config[:registration_step]\n return if Spree::Config[:allow_guest_checkout] and current_order.email.present?\n return if current_user or not current_order.user.anonymous?\n store_location\n redirect_to checkout_registration_path\n end",
"def registration_status\n if !original_url\n :submitted\n elsif submission_complete\n :confirmed\n elsif order_number\n :printed\n else\n :uploaded\n end\n end",
"def valid_cookie?\n \n cookie = request.cookies[\"kindle\"]\n \n # attempt to look up cookie in registration DB\n reg = Registration.first(:content => cookie)\n \n if $DEBUG\n puts \"Cookie: \" + (cookie.nil? ? \"nil\" : cookie.to_s )\n puts \"Registration: \" + (reg.nil? ? \"nil\" : reg.to_s )\n end\n \n return true if $DEBUG\n return !reg.nil?\n end",
"def validate_admin_subdomain\n #raise ActionController::RoutingError.new('Not Found') unless request.subdomains.first == 'manage'\n end",
"def email_available?\n\t\tself.valid?\n\tend",
"def ready?\n status == \"RUNNING\"\n end"
] | [
"0.6696315",
"0.66007185",
"0.65794474",
"0.651366",
"0.64911664",
"0.6426261",
"0.6426261",
"0.624149",
"0.6241229",
"0.6222592",
"0.618795",
"0.618795",
"0.61872554",
"0.6181001",
"0.6152879",
"0.6134844",
"0.6115462",
"0.6109446",
"0.6078349",
"0.60673165",
"0.60570025",
"0.60476744",
"0.60435915",
"0.60166156",
"0.60024047",
"0.5994537",
"0.59358555",
"0.5934584",
"0.59296197",
"0.5920988",
"0.5909983",
"0.5907253",
"0.58950216",
"0.5890843",
"0.589063",
"0.58903605",
"0.58820534",
"0.58774585",
"0.5871639",
"0.5867506",
"0.5828919",
"0.5826738",
"0.58093446",
"0.58044887",
"0.57980204",
"0.57829547",
"0.5775835",
"0.577554",
"0.5767695",
"0.57571596",
"0.5750205",
"0.5741537",
"0.5741393",
"0.57299894",
"0.5728315",
"0.57277644",
"0.57238334",
"0.57215834",
"0.5708566",
"0.56995374",
"0.5692201",
"0.56636804",
"0.565395",
"0.56536067",
"0.56428844",
"0.56428844",
"0.5633063",
"0.5627901",
"0.56089133",
"0.5600267",
"0.5600267",
"0.558639",
"0.5582207",
"0.5582207",
"0.55791533",
"0.55767244",
"0.5572849",
"0.5572849",
"0.55618364",
"0.55618364",
"0.55596244",
"0.55480057",
"0.5547234",
"0.55391073",
"0.5536733",
"0.55341405",
"0.552999",
"0.55236554",
"0.552105",
"0.55183876",
"0.5515209",
"0.551319",
"0.55056447",
"0.549269",
"0.5489528",
"0.5481969",
"0.5478975",
"0.5478892",
"0.54695594",
"0.54692245"
] | 0.6601201 | 1 |
Method to run the whois program with the domain and parse the output into a hash | def parse_query(domain=nil)
domain_file = "tmp/#{domain}_whois"
#puts("DEBUG >>> whois/parse_query called on domain #{domain}. Cache file will be stored in #{domain_file}")
begin
domain = self.fqdn if domain == nil
rescue NoMethodError
raise ArgumentError, "wrong number of arguments (0 for 1)"
end
if domain_is_cached(domain)
#puts("DEBUG >>> #{domain} is already cached, getting results from file.")
# If we have a valid cached file, we load that up and use it.
@whois = File.open(domain_file) {|f| Marshal.load(f)}
else
# We only actually run a WHOIS query if the domain is not cached - so we
# don't access WHOIS services too much.
#puts("DEBUG >>> #{domain} is not cached, making whois system call.")
whois_output = `whois -H #{domain} 2> /dev/null`
# Check that the whois query worked
if $?.exitstatus > 0
raise "WHOIS query was not successful - possible network error?"
end
# See how we should parse the output based on the TLD
case domain.split('.')[-1]
when 'biz'
#puts("DEBUG >>> .biz TLD. Using biz_parser")
biz_parser(whois_output)
when 'com'
#puts("DEBUG >>> .com TLD. Using com_parser")
com_parser(whois_output)
when 'info'
#puts("DEBUG >>> .info TLD. Using info_parser")
info_parser(whois_output)
when 'net'
#puts("DEBUG >>> .net TLD. Using net_parser")
net_parser(whois_output)
when 'org'
#puts("DEBUG >>> .org TLD. Using org_parser")
org_parser(whois_output)
when 'uk'
#puts("DEBUG >>> .uk TLD. Using uk_parser")
uk_parser(whois_output)
else
raise "This TLD (.#{domain.split('.')[-1]}) has no parser in Whois module."
end
# Marshal dump the @whois hash to a file
#puts("DEBUG >>> Writing the whois query results to cache file.")
File.open(domain_file, 'w') do |f|
Marshal.dump(@whois, f)
end
@whois
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whois(domain)\n raise InvalidDomainError unless domain.to_s =~ /\\.nz\\z/i\n\n fetch_content domain\n self\n end",
"def whoisgem(domain)\n client = Whois::Client.new\n return client.lookup(domain) # returns the Whois::Record relevant to the domain\n end",
"def get_whois_nameservers(domain)\n whois_output = `whois #{domain}`\n soa = nil\n whois_lines = whois_output.split(/\\n+/)\n nameserver_lines = whois_lines.select { |line| line =~ /^Name Server:/ }\n nameservers = nameserver_lines.map { |line| line.split.last.downcase }.uniq\n # whois records don't have trail '.'; NS records do; add trailing '.'\n nameservers.map { |ns| ns << '.' }\n nameservers\nend",
"def whoisQuery(domain)\n\n\t#- Begin routine\n\tbegin\n\t\t#- Attempt \n\t\tr = Whois.whois(domain)\n\t#- Failsafe triggered\n\trescue \n\t\t#- Silence: Nothing to do\n\t#- End routine\n\tend\n\t\n\t#- Connection was successful, port was open\n\tif r\n\t\t#- Let user know port was open\n\t\tputs r\n\t#- End connection state routine\n\tend\n\t\n#- End whoisQuery method\nend",
"def whois(query, field=nil)\n if field\n is_valid_with_error(__method__, [:whois_field], field)\n get('whois/search', {'field' => field, 'query' => query})\n else\n is_valid_with_error(__method__, [:ipv4, :domain], query)\n if domain?(query)\n query = normalize_domain(query)\n end\n get('whois', {'query' => query, 'compact_record' => 'false'})\n end\n end",
"def run\n super\n\n #\n # Set up & make the query\n #\n\n ###\n ### XXX - doesn't currently respect the timeout\n ###\n\n lookup_string = _get_entity_attribute \"name\"\n\n begin\n whois = Whois::Client.new(:timeout => 20)\n answer = whois.lookup(lookup_string)\n rescue Whois::Error => e\n @task_log.log \"Unable to query whois: #{e}\"\n rescue Whois::ResponseIsThrottled => e\n @task_log.log \"Got a response throttled message: #{e}\"\n sleep 10\n return run # retry\n rescue StandardError => e\n @task_log.log \"Unable to query whois: #{e}\"\n rescue Exception => e\n @task_log.log \"UNKNOWN EXCEPTION! Unable to query whois: #{e}\"\n end\n\n #\n # Check first to see if we got an answer back\n #\n if answer\n\n # Log the full text of the answer\n @task_log.log \"== Full Text: ==\"\n @task_log.log answer.parts.first.body\n @task_log.log \"================\"\n\n #\n # if it was a domain, we've got a whole lot of shit we can scoop\n #\n if @entity[\"type\"] == \"DnsRecord\"\n #\n # We're going to have nameservers either way?\n #\n if answer.nameservers\n answer.nameservers.each do |nameserver|\n #\n # If it's an ip address, let's create a host record\n #\n if nameserver.to_s =~ /\\d\\.\\d\\.\\d\\.\\d/\n _create_entity \"IpAddress\", :name => nameserver.to_s\n _create_entity \"DnsServer\", :name => nameserver.to_s\n else\n #\n # Otherwise it's another domain, and we can't do much but add it\n #\n _create_entity \"DnsRecord\", :name => nameserver.to_s\n\n # Resolve the name\n begin\n ip_address = IPSocket::getaddress(nameserver.to_s)\n _create_entity \"IpAddress\", :name => ip_address\n _create_entity \"DnsServer\", :name => ip_address\n rescue SocketError => e\n @task_log.log \"Unable to look up host: #{e}\"\n end\n end\n end\n end\n\n #\n # Set the record properties\n #\n #@entity.disclaimer = answer.disclaimer\n #@entity.domain = answer.domain\n #@entity.referral_whois = answer.referral_whois\n #@entity.status = answer.status\n #@entity.registered = answer.registered?\n #@entity.available = answer.available?\n #if answer.registrar\n # @entity.registrar_name = answer.registrar.name\n # @entity.registrar_org = answer.registrar.organization\n # @entity.registrar_url = answer.registrar.url\n #end\n #@entity.record_created_on = answer.created_on\n #@entity.record_updated_on = answer.updated_on\n #@entity.record_expires_on = answer.expires_on\n #@entity.full_text = answer.parts.first.body\n\n #\n # Create a user from the technical contact\n #\n begin\n if answer.technical_contact\n @task_log.log \"Creating user from technical contact\"\n _create_entity(\"Person\", {:name => answer.technical_contact.name})\n end\n rescue Exception => e\n @task_log.log \"Unable to grab technical contact\"\n end\n\n #\n # Create a user from the admin contact\n #\n begin\n if answer.admin_contact\n @task_log.log \"Creating user from admin contact\"\n _create_entity(\"Person\", {:name => answer.admin_contact.name})\n end\n rescue Exception => e\n @task_log.log \"Unable to grab admin contact\"\n end\n\n #\n # Create a user from the registrant contact\n #\n begin\n if answer.registrant_contact\n @task_log.log \"Creating user from registrant contact\"\n _create_entity(\"Person\", {:name => answer.registrant_contact.name})\n end\n rescue Exception => e\n @task_log.log \"Unable to grab registrant contact\"\n end\n\n # @entity.save!\n\n\n else\n\n #\n # Otherwise our entity must've been a host\n #\n\n #\n # Parse out the netrange - WARNING SUPERJANKYNESS ABOUND\n #\n # Format:\n #\n # <?xml version='1.0'?>\n # <?xml-stylesheet type='text/xsl' href='http://whois.arin.net/xsl/website.xsl' ?>\n # <net xmlns=\"http://www.arin.net/whoisrws/core/v1\" xmlns:ns2=\"http://www.arin.net/whoisrws/rdns/v1\" xmlns:ns3=\"http://www.arin.net/whoisrws/netref/v2\" termsOfUse=\"https://www.arin.net/whois_tou.html\">\n # <registrationDate>2009-09-21T17:15:11-04:00</registrationDate>\n # <ref>http://whois.arin.net/rest/net/NET-8-8-8-0-1</ref>\n # <endAddress>8.8.8.255</endAddress>\n # <handle>NET-8-8-8-0-1</handle>\n # <name>LVLT-GOOGL-1-8-8-8</name>\n # <netBlocks><netBlock>\n # <cidrLength>24</cidrLength>\n # <endAddress>8.8.8.255</endAddress>\n # <description>Reassigned</description>\n # <type>S</type>\n # <startAddress>8.8.8.0</startAddress>\n # </netBlock></netBlocks>\n # <orgRef name=\"Google Incorporated\" handle=\"GOOGL-1\">http://whois.arin.net/rest/org/GOOGL-1</orgRef>\n # <parentNetRef name=\"LVLT-ORG-8-8\" handle=\"NET-8-0-0-0-1\">http://whois.arin.net/rest/net/NET-8-0-0-0-1</parentNetRef>\n # <startAddress>8.8.8.0</startAddress>\n # <updateDate>2009-09-21T17:15:11-04:00</updateDate>\n # <version>4</version>\n # </net>\n\n doc = Nokogiri::XML(http_get_body(\"http://whois.arin.net/rest/ip/#{lookup_string}\"))\n org_ref = doc.xpath(\"//xmlns:orgRef\").text\n parent_ref = doc.xpath(\"//xmlns:parentNetRef\").text\n handle = doc.xpath(\"//xmlns:handle\").text\n\n # For each netblock, create an entity\n doc.xpath(\"//xmlns:net/xmlns:netBlocks\").children.each do |netblock|\n # Grab the relevant info\n\n cidr_length = \"\"\n start_address = \"\"\n end_address = \"\"\n block_type = \"\"\n description = \"\"\n\n netblock.children.each do |child|\n\n cidr_length = child.text if child.name == \"cidrLength\"\n start_address = child.text if child.name == \"startAddress\"\n end_address = child.text if child.name == \"endAddress\"\n block_type = child.text if child.name == \"type\"\n description = child.text if child.name == \"description\"\n\n end # End netblock children\n\n #\n # Create the netblock entity\n #\n entity = _create_entity \"NetBlock\", {\n :name => \"#{start_address}/#{cidr_length}\",\n :start_address => \"#{start_address}\",\n :end_address => \"#{end_address}\",\n :cidr => \"#{cidr_length}\",\n :description => \"#{description}\",\n :block_type => \"#{block_type}\",\n :handle => handle,\n :organization_reference => org_ref,\n :parent_reference => parent_ref\n }\n\n end # End Netblocks\n\n end # end Host Type\n\n else\n @task_log.log \"Domain WHOIS failed, we don't know what nameserver to query.\"\n end\n\n end",
"def search_whois\n s = TCPsocket.open(@server.server, 43)\n s.write(\"#{self.ip.to_s}\\n\")\n ret = ''\n while s.gets do ret += $_ end\n s.close\n @all = ret\n end",
"def query\n @query_text = params[:query]\n\n # call the system utility whois (must install first (see above))\n # pass the query_text enter on last page to whois\n @result = `whois #{@query_text}`.split(\"\\n\")\n # rails will now display the app/views/home/query.html.erb\n # is does this because the controller is named query\n # the @result can be used in the query.html.erb\n end",
"def run\n super\n\n begin\n\n # Make sure the key is set\n api_key = _get_task_config \"whoisology_api_key\"\n entity_name = _get_entity_name\n\n case _get_entity_type_string\n\n when \"EmailAddress\"\n entity_type = \"email\"\n\n when \"DnsRecord\"\n\n ## When we have a host, we need to do a lookup on the current record,\n ## grab the email address, and then do the search based on that email\n\n _log \"Looking up contacts for domain\"\n begin\n # We're going to pull the domain's email address....\n whois = ::Whois::Client.new(:timeout => 20)\n answer = whois.lookup(entity_name)\n # Run through the contacts and pick the first one\n contact_emails = answer.parser.contacts.map{ |contact| contact.email }\n _log \"Got contact_emails: #{contact_emails}\"\n rescue Timeout::Error => e\n _log_error \"Unable to lookup #{entity_name}... try a manual lookup\"\n return nil\n end\n\n entity_name = contact_emails.first\n entity_type = \"email\"\n end\n\n _log \"Got entity: #{entity_type} #{entity_name}\"\n\n unless entity_name\n # Something went wrong with the lookup?\n _log \"Unable to get a current email address\"\n return\n end\n\n unless api_key\n _log_error \"No api_key?\"\n return\n end\n\n # Attach to the whoisology service & search\n whoisology = Whoisology::Api.new(api_key)\n\n # Run a PING to see if we have any results\n result = whoisology.ping entity_type, entity_name\n _log \"Got #{result}\"\n _log \"Got #{result[\"count\"]} results\"\n return if result[\"count\"].to_i == 0\n\n # do the actual search with the FLAT command\n result = whoisology.flat entity_type, entity_name\n\n _log_good \"Creating entities for #{result[\"count\"]} results.\"\n if result[\"domains\"]\n result[\"domains\"].each {|d| _create_entity \"DnsRecord\", {\"name\" => d[\"domain_name\"]} }\n else\n _log_error \"No domains, do we have API credits?\"\n end\n\n rescue RuntimeError => e\n _log_error \"Runtime error: #{e.inspect}\"\n end\n\n end",
"def whois(n, s=nil)\n @socket << \"WHOIS #{[s,n].compact.join(' ')}\"\n end",
"def whois(*args)\n options = args.extract_options!\n target = options[:target] ? \"#{options[:target]} \" : ''\n send_data(\"WHOIS #{target}#{args.join(',')}\")\n end",
"def lookup(object)\t\n\t\tputs \"Perform whois lookup on: #{object}\" if @verbose\n\t\treturn Whois.lookup(object)\n\tend",
"def whois\n connected do\n fiber = Fiber.current\n callbacks = {}\n\n # User is online.\n callbacks[311] = @thaum.on(311) do |event_data|\n nick = event_data[:params].split(' ')[1]\n if nick.downcase == @nick.downcase\n @online = true\n # TODO: Add properties.\n end\n end\n\n # User is not online.\n callbacks[401] = @thaum.on(401) do |event_data|\n nick = event_data[:params].split(' ')[1]\n if nick.downcase == @nick.downcase\n @online = false\n fiber.resume\n end\n end\n\n # End of WHOIS.\n callbacks[318] = @thaum.on(318) do |event_data|\n nick = event_data[:params].split(' ')[1]\n if nick.downcase == @nick.downcase\n fiber.resume\n end\n end\n\n raw \"WHOIS #{@nick}\"\n Fiber.yield\n\n callbacks.each do |type, callback|\n @thaum.callbacks[type].delete(callback)\n end\n end\n\n self\n end",
"def run( nodes )\n\t\t\tself.log.debug \"Got nodes to check with %p: %p\" % [ self, nodes ]\n\n\t\t\trecords = nodes.each_with_object( {} ) do |(identifier, node), hash|\n\t\t\t\tself.log.debug \"Looking up whois info for %p (%p)\" % [ identifier, node ]\n\t\t\t\thash[ identifier ] = self.client.lookup( node['name'] )\n\t\t\tend\n\n\t\t\treturn records.each_with_object( {} ) do |(identifier, record), hash|\n\t\t\t\tparser = record.parser\n\t\t\t\thash[ identifier ] = self.parse_record( parser, identifier )\n\t\t\tend\n\n\t\tend",
"def check_status(domain=nil)\n begin\n domain = self.fqdn if domain == nil\n rescue NoMethodError\n raise ArgumentError, \"wrong number of arguments (0 for 1)\"\n end\n @whois = parse_query(domain)\n @whois['status']\n end",
"def expiration_results\n domains = config[:domain].split(',')\n warning_days = config[:warning].to_i\n critical_days = config[:critical].to_i\n max_retries = 4\n\n results = {\n critical: {},\n warning: {},\n ok: {},\n unknown: {}\n }\n whois = Whois::Client.new(timeout: config[:timeout])\n\n domains.each do |domain|\n begin\n tries ||= 0\n whois_result = whois.lookup(domain).parser\n rescue Timeout::Error, Errno::ECONNRESET, Whois::ConnectionError\n tries += 1\n if tries < max_retries\n retry\n else\n results[:unknown][domain] = 'Connection error' unless config[:'ignore-errors']\n next\n end\n end\n\n begin\n expires_on = DateTime.parse(whois_result.expires_on.to_s)\n domain_result = (expires_on - DateTime.now).to_i\n if domain_result <= critical_days\n results[:critical][domain] = domain_result\n elsif domain_result <= warning_days\n results[:warning][domain] = domain_result\n else\n results[:ok][domain] = domain_result\n end\n rescue StandardError\n results[:unknown][domain] = 'Parsing error' unless config[:'ignore-errors']\n end\n end\n results\n end",
"def parse_dns(raw)\n # Filtering Lines with Comments and Empty Lines\n dns_filter = raw.select { |x| x[0] != \"#\" && x != \"\\n\" }.map {|x| x.split(\", \")}\n\n # Building the Hash\n dns_hash = {}\n dns_filter.each do |x| \n dns_hash[x[1]] = {\n :type => x[0],\n :target => x[2]\n }\n end\n \n dns_hash\nend",
"def run\n super\n\n opt_create_nameservers = _get_option \"create_nameservers\"\n opt_create_contacts = _get_option \"create_contacts\"\n\n # take the first ip if we have a netblock\n if _get_entity_type_string == \"NetBlock\"\n\n # look up the first address\n lookup_string = _get_entity_name.split(\"/\").first\n out = whois_safe lookup_string\n return nil if out.empty?\n\n # and edit this netblock\n _log_good \"Setting entity details (NOTE, only using first range from whois)!\"\n wh = out.first\n get_and_set_entity_details wh\n\n elsif _get_entity_type_string == \"IpAddress\"\n \n # TODO... there might be a way to shortcut so many lookups... \n # store on the ipaddress? or create earlier\n # _get_entity_detail \"whois_full_text\" # return if we have it\n \n out = whois_safe _get_entity_name\n return nil if !out || (out && out.empty?)\n \n out.each do |nb|\n _create_entity \"NetBlock\", { \"name\" => nb[\"name\"] } \n end\n\n elsif _get_entity_type_string == \"Organization\"\n\n # look it up and create all known netblocks\n out = whois_query_arin_org _get_entity_name\n unless out.empty?\n out.each do |nb|\n _create_entity \"NetBlock\", {\"name\" => nb[\"name\"]}\n end\n end\n\n elsif _get_entity_type_string == \"DnsRecord\" || _get_entity_type_string == \"Domain\"\n\n out = whois_safe _get_entity_name\n return nil if out.empty?\n\n out.each do |wh| \n\n if opt_create_nameservers\n wh[\"nameservers\"].each do |n|\n _create_entity(\"DnsRecord\", { \"name\" => \"#{n}\" })\n end\n end\n\n if opt_create_contacts\n wh[\"contacts\"].each do |c|\n _log \"Creating person/email from contact: #{c}\"\n _create_entity(\"Person\", {\"name\" => c[\"name\"]})\n _create_entity(\"EmailAddress\", {\"name\" => c[\"email\"]})\n end\n end\n\n _set_entity_detail(\"whois_full_text\", wh[\"whois_full_text\"]) unless _get_entity_detail(\"whois_full_text\")\n _set_entity_detail(\"nameservers\", wh[\"nameservers\"]) unless _get_entity_detail(\"nameservers\")\n _set_entity_detail(\"contacts\", wh[\"contacts\"]) unless _get_entity_detail(\"contacts\")\n \n end\n\n else\n _log_error \"Unknown entity type, failing\"\n end\n\n end",
"def lookup(domain)\n \tif domain != (nil&&true&&\"\")\n \tc = Whois::Client.new\n\t\t\t@body = c.lookup(domain)\n\t\tend\n\tend",
"def get_parsed_dns( dns_query )\n begin\n parsed_dns = {\n :index => 0,\n :domain_name_dictionary => [],\n :dns_header_field => Hash.new(),\n :question_section => Hash.new(),\n :answer_section => Hash.new(),\n :authority_section => Hash.new(),\n :additional_section => Hash.new()\n }\n\n parsed_dns[:dns_header_field] = get_header_section(dns_query)\n parsed_dns[:index] = QUESTION_FIELD_START_INDEX\n parsed_dns[:question_section] = get_question_section(dns_query, parsed_dns)\n parsed_dns[:answer_section] = get_answer_resource_record(dns_query, parsed_dns)\n parsed_dns[:authority_section] = get_authority_resource_record(dns_query, parsed_dns)\n parsed_dns[:additional_section] = get_additional_resource_record(dns_query, parsed_dns)\n rescue\n end\n parsed_dns\n end",
"def create(domain)\n \n r = whoisgem(domain) # returns the ruby whois response aka the Whois::Record object\n \n # preparing the contact objects\n registrant = Contact.new(r.registrant_contact)\n admin = Contact.new(r.admin_contact)\n tech = Contact.new(r.technical_contact)\n \n # preparing the nameservers\n dns = Nameservers.new(r.nameservers)\n \n # building the record that will be inserted in couch\n #@_id = domain\n @domain_id = r.domain_id\n @domain_name = r.domain\n @status = r.status\n @available = r.available?\n @registered = r.registered?\n @created_on = r.created_on\n @updated_on = r.updated_on\n @expires_on = r.expires_on\n @last_update = r.last_update\n @registrar = Registrar.new(r.registrar.id,\n r.registrar.name,\n r.registrar.organization)\n @registrant = registrant\n @admin = admin\n @technical = tech\n @nameservers = dns\n \n # not implemented yet\n @watchlist = nil\n \n CouchPotato.database.save_document! self\n \n # the boolean is an indicator wether the insertion succeeded or not\n # return boolean\n end",
"def extract(uri)\n parsed = URLExtractor.parse(uri)\n return nil if parsed.nil?\n hostname = parsed[:hostname]\n return nil if hostname.nil?\n \n domaintld = to_domain(hostname)\n domain = domaintld[:domain]\n \n ttl = 0\n begin\n Resolver(hostname).answer.each do |rr|\n if rr.type == 'A' then\n ttl = rr.ttl\n end\n end\n \n c = Whois::Client.new(:timeout => 60)\n a = c.query(domain).properties\n return {\n :created => (a[:created_on]), #DateTime: creation date\n :updated => (a[:updated_on]), #DateTime: update date\n :expires => (a[:expires_on]), #DateTime: expiration date\n :tld => (domaintld[:tld]), #String: top-level domain\n :registrant => (a[:registrant].to_s), #String: registrant's name\n :registrar => (a[:registrar].to_s), #String: registrar's name\n :ttl => ttl #UInt: DNS A record time-to-live\n } \n rescue => e\n return nil\n rescue Timeout::Error => e\n return nil\n end \n \n end",
"def parse_dns(raw)\n # Filtering Lines with Comments and Empty Lines\n dns_filter = raw.select {|x| x[0]!= \"#\" && x != \"\\n\" }\n\n # Creating a List with 3 Columns\n dns_filter_list = []\n dns_filter.each {|x| dns_filter_list.push(x.split(\", \"))}\n\n # Creating the List each DNS for Hash\n record_type_list = []\n source_list = []\n destination_list = []\n\n dns_filter_list.each do |x|\n record_type_list.push(x[0])\n source_list.push(x[1])\n destination_list.push(x[2])\n end\n\n # Building the Hash\n dns_hash = {\n \"RECORDTYPE\".to_sym => record_type_list,\n \"SOURCE\".to_sym => source_list,\n \"DESTINATION\".to_sym => destination_list,\n }\n return dns_hash\nend",
"def getHRN(hostname, domain = \"grid\")\n qs = <<HRN_QS\nSELECT nodes.hrn\n FROM nodes\n LEFT JOIN locations ON nodes.location_id = locations.id\n LEFT JOIN testbeds ON locations.testbed_id = testbeds.id\nWHERE testbeds.name='#{domain}'\n AND nodes.hostname='#{hostname}';\nHRN_QS\n\n addr = nil\n runQuery(qs) { |h|\n hrn = h\n }\n return hrn\n end",
"def description\n\t\t\"Performs a whois & updates the database\"\n\tend",
"def run\n super\n\n ip_address = _get_entity_attribute \"name\"\n\n c = Client::Search::Cymru::IPAddress.new\n c.whois(ip_address)\n\n # result = [“27357”, “US”, “ARIN”, “2003-02-20”, “RACKSPACE - RACKSPACE HOSTING”]\n #:asnum, :cidr, :country, :registry, :allocdate, :asname\n\n _create_entity \"AsNumber\", {\n :number => c.asnum,\n :country => c.country,\n :cidr => c.cidr,\n :registry => c.registry,\n :allocated => c.allocdate,\n :name => c.asname\n }\n end",
"def parse_dns(raw)\n # Filtering Lines with Comments and Empty Lines\n dns_filter = raw.select { |x| x[0] != \"#\" && x != \"\\n\" }\n\n # Creating a List with 3 Columns\n dns_filter_list = []\n dns_filter.each { |x| dns_filter_list.push(x.split(\", \")) }\n\n # Creating the List each DNS for Hash\n record_type_list = []\n source_list = []\n destination_list = []\n\n dns_filter_list.each do |x|\n record_type_list.push(x[0])\n source_list.push(x[1])\n destination_list.push(x[2])\n end\n\n # Building the Hash\n dns_hash = {\n \"RECORDTYPE\".to_sym => record_type_list,\n \"SOURCE\".to_sym => source_list,\n \"DESTINATION\".to_sym => destination_list,\n }\n return dns_hash\nend",
"def send_whois(nick)\n send_raw(WHOIS, nick)\n end",
"def display_info\n @all_domains.each do |key, domain|\n puts \"Domain : \" + domain.domain_name\n puts domain.email_statistics.inspect\n puts \"*\" * 80\n end\n end",
"def contact_info(handle)\n response = query_no_raise :query_whois, contact: handle\n case response[:headers][:status_code]\n when '2303' then nil\n when '0' then\n result = {}\n response[:body].split(\"\\n\").each do |line|\n line.slice! /^contact\\./\n line_parsed = parse_line(line)\n next if line_parsed.is_a? String\n key, value = line_parsed.first\n case key\n when :name then next if value == \"- -\"\n when :address_1, :address_2, :address_3 then\n result[:address] = [] unless result.has_key? :address\n result[:address] << value\n when :state then next if value == \"--\"\n when :organization then next if value == \"-\" or value.empty?\n when :created_date, :modified_date then\n result[key] = DateTime.parse value\n else\n result.merge! line_parsed\n end\n end\n result\n else\n raise_response response\n end\n end",
"def get_domain_data\n get_stored_paths.inject({ 'domain' => base_uri.hostname, 'paths' => {}}) do |hsh, path|\n hsh['paths'][path] = get_path_data(path)\n hsh\n end\n end",
"def get_dominfo_by_domain(domain)\n\t\t\t\tinfo = nil\n\t\t\t\ttraverse_text_file(domain_data_file) do |line|\n\t\t\t\t\tif line.index(domain + ':') == 0\n\t\t\t\t\t\tinfo = parse_domain_data_line(line)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tinfo\n\t\t\tend",
"def parse_dns(dns_raw)\n hash= {}\n dns_raw.each do |record|\n record = record.split(\",\")\n if record.length() > 1 && record[0] != \"# RECORD TYPE\"\n hash[record[1].strip()] = record[2].strip()\n end\n end\n return hash\n end",
"def stdlookup(session,domain,dest)\n\tdest = dest + \"-general-record-lookup.txt\"\n\tprint_status(\"Getting MX and NS Records for Domain #{domain}\")\n\tfilewrt(dest,\"SOA, NS and MX Records for Domain #{domain}\")\n\ttypes = [\"SOA\",\"NS\",\"MX\"]\n\tmxout = []\n\tresults = []\n\tgarbage = []\n\ttypes.each do |t|\n\tbegin\n\t\tr = session.sys.process.execute(\"nslookup -type=#{t} #{domain}\", nil, {'Hidden' => true, 'Channelized' => true})\n\t\twhile(d = r.channel.read)\n\t\t\tmxout << d\n\t\tend\n\t\tr.channel.close\n\t\tr.close\n\t\tresults = mxout.join.split(/\\n/)\n\t\tresults.each do |rec|\n\t\t\t\tif rec.match(/\\s*internet\\saddress\\s\\=\\s/)\n\t\t\t\t\tgarbage << rec.split(/\\s*internet\\saddress\\s\\=/)\n\t\t\t\t\tprint_status(\"#{garbage[0].join.sub(\" \",\" \")} #{t} \")\n\t\t\t\t\tfilewrt(dest,garbage[0].join.sub(\" \",\" \")+\" #{t} \")\n\t\t\t\t\tgarbage.clear\n\t\t\t\tend\n\t\t\t\tgarbage.clear\n\t\tend\n\n\trescue ::Exception => e\n \t\tprint_status(\"The following Error was encountered: #{e.class} #{e}\")\n\tend\n\tend\nend",
"def myaddr_hash_search(hash_to_find=@hash_to_find, verbose=true)\n if @hash_type == 'MD5'\n agent = Mechanize.new\n begin\n agent.user_agent = $config['HTTP']['HTTP_USER_AGENT']\n if $config['HTTP']['PROXY']\n if $config['HTTP']['PROXY_AUTH']\n agent.set_proxy($config['HTTP']['PROXY_IP'], $config['HTTP']['PROXY_PORT'].to_i, user=$config['HTTP']['PROXY_USER'], pass=$config['HTTP']['PROXY_PASS'])\n else\n agent.set_proxy($config['HTTP']['PROXY_IP'], $config['HTTP']['PROXY_PORT'].to_i)\n end\n end\n # Find form, enter hash, run search...\n page = agent.get('http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php')\n search_form = page.form_with(:name => 'f1') # our form\n search_form.md5 = hash_to_find # set hash in form field value\n page = agent.submit(search_form, search_form.buttons.first) # submit form and return new page\n # Check for match found to requesting hash\n checking_hash = /<div class='white_bg_title'><span class='middle_title'>MD5 hash<\\/span>: #{hash_to_find}<\\/div>\\s<br>/\n bad_news = /<div class='error_title'>Hash \"#{hash_to_find}\" not found in database<\\/div>/\n if page.body =~ checking_hash and not page.body =~ bad_news\n if page.body =~ /\\s<div class='white_bg_title'><span class='middle_title'>Hashed string<\\/span>: (.+)<\\/div>/\n plain_jane = $1.to_s.strip.chomp\n if verbose\n print_good(\"Match Found: md5.my-addr.com\")\n puts \" [\".light_green + \"+\".white + \"] \".light_green + \"Hash: #{hash_to_find}\".white\n puts \" [\".light_green + \"+\".white + \"] \".light_green + \"Plain-Text: #{plain_jane}\".white\n end\n return plain_jane\n end\n end\n rescue OpenSSL::SSL::SSLError,Errno::ETIMEDOUT,Net::HTTP::Persistent::Error,NoMethodError,Zlib::DataError,Mechanize::ResponseCodeError => e\n print_error(\"Problem Communicating with: md5.my-addr.com\") if verbose\n return nil\n end\n print_error(\"No Results from: md5.my-addr.com\") if verbose\n return nil\n else\n print_error(\"#{@hash_type} not supported for: md5.my-addr.com\") if verbose\n return nil\n end\n end",
"def domain_info\n @domain = normalized_email.split('@').last\n domain\n end",
"def parse_dns(dns_raw)\n\tdns_records = {}\n\n\n\tdns_raw.\n\tmap{|line| line.strip }.\n\treject {|line| line.empty?}.\n\treject {|line| line[0] == \"#\" }.\n\n\teach{|line|\n\t\tinfo = line.split \",\"\n\t\tdns_records[info[1].strip] = { :type => info[0].strip, :val => info[2].strip }\n\t}\n\treturn dns_records\nend",
"def run(message, channel, private_allowed)\n # Remove the Slack formatting that is surely on the URL, e.g. <http://ucdavis.edu|ucdavis.edu> => ucdavis.edu\n message = Slack::Messages::Formatting.unescape(message)\n\n query = message[5..-1] # Strip away the beginning \"host \"\n\n unless valid_ip_or_hostname(query)\n $logger.warn \"Invalid IP or hostname for 'host' command: '#{query}'\"\n return \"Query '#{query}' does not appear to be an IP address nor hostname.\"\n end\n\n # Call the script, piping the JSON\n ret = IO.popen(\"host #{query}\", 'r+', :err => [:child, :out]) do |pipe|\n pipe.close_write\n pipe.gets(nil)\n end\n\n if $?.exitstatus != 0\n # Error\n $logger.warn \"'host' command did not exit cleanly, status: #{$?.exitstatus}. Output:\"\n $logger.warn ret\n $logger.warn \"End of output.\"\n return \"Error running 'host' command. Exit status: #{$?.exitstatus}\"\n else\n # Success\n if ret and ret.length > 0\n return \"```\" + ret + \"```\"\n else\n $logger.warn \"'host' exited cleanly but produced no output.\"\n return \"'host' exited cleanly but produced no output.\"\n end\n end\n end",
"def whois(masks, server = nil)\n masks = Array(masks).map(&:to_s).join ','\n\n raw \"WHOIS #{server}\".strip << \" #{masks}\\r\\n\"\n end",
"def domain_user_bf(dc_ip,domain,password,huntDu)\n file = huntDu\n output = \"#{domain}-password-attack-#{password}.txt\"\n\n user_hash = Hash.new\n\n r = File.open(file)\n r.each_line {|line| user_hash[line.chomp] = password}\n\n File.open(output, 'w') do |file|\n user_hash.peach(25) do |key, value|\n current = \"Testing: #{key} #{value}\"\n puts current\n smb = `smbclient -U #{domain}\\\\\\\\#{key}%#{value} //#{dc_ip}/NETLOGON -c dir`\n puts smb\n file.write(current + smb)\n end\n end\n data_processing = `sed '/failed/d' #{output} > 1; rm #{output}; cat 1 | awk -F\" \" {'print $2 \" \" $3'} > 2; rm 1; sed -n '/#{password}/p' 2 > 3; rm 2; echo \"The Following Users Exist in Domain: #{domain}\" > #{output}; echo \" \" >> #{output}; cat 3 | sort >> #{output}; rm 3`\n puts \"\"\n puts \"[+] Success! All users which are members of the #{domain} domain have been stored in #{output}\"\nend",
"def info(domain)\n fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain\n @client.get(\"domains/#{domain}\").to_h!\n end",
"def get_uniq_sites\n\t\tputs \"Getter to retrieve unique sites containing unique IP:PORT key identifier.\" if @verbose=\n\t\t#primary_host_tracker=Wmap::HostTracker::PrimaryHost.instance\n\t\tsites=Hash.new\n\t\t#uniqueness=Hash.new\n\t\thost_tracker=Wmap::HostTracker.instance\n\t\thost_tracker.data_dir=@data_dir\n\t\thost_tracker.hosts_file=host_tracker.data_dir + '/' + 'hosts'\n\t\thost_tracker.load_known_hosts_from_file\n\t\t@known_sites.keys.map do |key|\n\t\t\tport=url_2_port(key).to_s\n\t\t\thost=url_2_host(key)\n\t\t\tmd5=@known_sites[key]['md5']\n\t\t\tcode=@known_sites[key]['code']\n\t\t\tip=host_tracker.local_host_2_ip(host)\n\t\t\tip=host_2_ip(host) if ip.nil?\n\t\t\t# filtering out 'un-reachable' sites\n\t\t\tnext if (code == 10000 or code == 20000)\n\t\t\t# filtering out 'empty' sites\n\t\t\tnext if (md5.nil? or md5.empty?)\n\t\t\tnext if ip.nil?\n\t\t\t# url_new=key\n\t\t\t#if primary_host_tracker.ip_known?(ip)\n\t\t\t#\tp_host=primary_host_tracker.known_hosts[ip]\n\t\t\t#\turl_new=key.sub(host,p_host)\n\t\t\t#end\n\t\t\tid=ip+\":\"+port\n\t\t\t# filtering out duplicates by 'IP:PORT' key pair\n\t\t\tunless sites.key?(id)\n\t\t\t\t#if @known_sites.key?(key)\n\t\t\t\t#\tsites[id]=url_new\n\t\t\t\t#else\n\t\t\t\t\t# Further filtering out redundant site by checking MD5 finger-print\n\t\t\t\t\t#unless uniqueness.key?(md5)\n\t\t\t\t\t\tsites[id]=key\n\t\t\t\t\t#\tuniqueness[md5]=true\n\t\t\t\t\t#end\n\t\t\t\t#end\n\t\t\tend\n\t\tend\n\t\t#primary_host_tracker=nil\n\t\thost_tracker=nil\n\t\treturn sites.values\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend",
"def entries\n STDOUT.puts db.entries(@params[:domain]).map{|row| row.to_parsed_h}.to_json\n end",
"def run\n super\n res = []\n entity_name = _get_entity_name\n entity_type = _get_entity_type_string\n\n # skip cdns\n if !get_cdn_domains.select{ |x| entity_name =~ /#{x}/}.empty? || \n !get_internal_domains.select{ |x| entity_name =~ /#{x}/}.empty?\n _log \"This domain resolves to a known cdn or internal host, skipping\"\n return\n end\n\n # check that it resolves\n resolves_to = resolve_names entity_name\n unless resolves_to.first\n _log \"No resolution for this record, unable to check\"\n return \n end\n\n # We use their DNS servers to query\n nameservers= ['185.228.168.168', '185.228.168.169']\n _log \"Querying #{nameservers}\"\n dns_obj = Resolv::DNS.new(nameserver: nameservers)\n \n # Try twice, just in case (avoid FP's)\n res = dns_obj.getaddresses(entity_name)\n res.concat(dns_obj.getresources(entity_name, Resolv::DNS::Resource::IN::CNAME)).flatten\n\n # Detected only if there's no resolution\n if res.any?\n _log \"Resolves to #{res.map{|x| \"#{x.to_s}\" }}. Seems we're good!\"\n else\n source = \"CleanBrowsing\"\n description = \"The Cleanbrowsing DNS security filter focuses on restricting access \" + \n \"to malicious activity. It blocks phishing, spam and known malicious domains.\"\n \n _create_linked_issue(\"blocked_by_dns\", {\n status: \"confirmed\",\n additional_description: description,\n source: source, \n proof: \"Resolved to the following address(es) outside of #{source} (#{nameservers}): #{resolves_to.join(\", \")}\",\n to_reproduce: \"dig #{entity_name} @#{nameservers.first}\",\n references: [{ type: \"remediation\", uri: \"https://cleanbrowsing.org/\" }]\n }) \n \n # Also store it on the entity \n blocked_list = @entity.get_detail(\"suspicious_activity_detected\") || [] \n @entity.set_detail(\"suspicious_activity_detected\", blocked_list.concat([{source: source}]))\n\n end\n\n end",
"def fetch_host_meta(domain)\n cached_value = get_cache(domain)\n return cached_value unless cached_value.nil?\n\n host_meta_url = \"https://www.google.com/accounts/o8/.well-known/host-meta?hd=#{CGI::escape(domain)}\"\n http_resp = OpenID.fetch(host_meta_url)\n if http_resp.code != \"200\" and http_resp.code != \"206\"\n return nil\n end\n matches = /Link: <(.*)>/.match( http_resp.body )\n if matches.nil?\n return nil\n end\n put_cache(domain, matches[1])\n return matches[1]\n end",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end",
"def output\n h1 domain\n status\n\n puts\n\n property(:expires_on) do |p|\n \"Expiration: \" + p.to_s\n end\n\n property(:created_on) do |p|\n \"Creation: \" + p.to_s\n end\n\n property(:registrar) do |p|\n \"Registrar: \" + p.name\n end\n end",
"def enum_dom_users(domain,username,password,dc_ip)\n output = \"#{domain}-users.txt\"\n puts \"[+] Currently enumerating all domain users ...\"\n enum = `rpcclient -U \"#{domain}\\\\#{username}%#{password}\" #{dc_ip} -c enumdomusers | awk -F\"[\" {'print $2'} | awk -F\"]\" {'print $1'} | tee #{output}`\n msg = \"Success! All domain users have been stored in #{output}\"\n ip_check(dc_ip,enum,msg)\nend",
"def get_domain(session)\n domain = \"\"\n ipv4_info = nil\n ipv6_info = nil\n begin\n subkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n v_name = \"DCName\"\n domain_dc = registry_getvaldata(subkey, v_name)\n rescue\n print_error(\"Could not determine if the host is part of a domain.\")\n end\n if (!domain_dc.nil?)\n # leys parse the information\n dom_info = domain_dc.split('.')\n domain = dom_info[1].upcase\n dc = domain_dc.gsub('\\\\\\\\','')\n print_good(\"Domain: #{domain}\")\n print_good(\"Domain Controller: #{dc}\")\n\n # Resolve IPv4 address\n begin\n ipv4_info = session.net.resolve.resolve_host(dc, AF_INET)\n print_good(\"IPv4: #{ipv4_info[:ip]}\")\n\n rescue\n print_status(\"Could not resolve IPv4 for #{dc}\")\n end\n\n # Resolve IPv6 address\n begin\n ipv6_info = session.net.resolve.resolve_host(dc, AF_INET6)\n print_good(\"IPv6: #{ipv6_info[:ip]}\")\n rescue\n print_status(\"Could not resolve IPv6 for #{dc}\")\n end\n\n else\n print_status \"Host is not part of a domain.\"\n end\nend",
"def execute(m, query)\n \n reply = String.new()\n \n # Error-checking to sanitize input. i.e. no illegal symbols.\n if (query =~ /[^\\w@._-]/)\n m.reply(\"Invalid search query '#{query}'\")\n return\n end \n\n query.downcase!\n \n # Determine what field to search and proceed to execute it.\n if (query =~ /@pdx\\.edu/)\n type = 'email alias'\n attribute = 'mailLocalAddress'\n else\n type = 'username'\n attribute = 'uid'\n end\n m.reply(\"Performing LDAP search on #{type} #{query}.\")\n result = $oitldap.search(attribute,query)\n \n # Check for errors.\n if (!result)\n m.reply \"Error: LDAP query failed. Check configuration.\"\n else\n if (result['dn'].empty?)\n reply = \"Error: No results.\\n\"\n elsif (result['dn'].length > 1)\n reply = \"Error: Too many results.\\n\"\n else\n # Piece together the final results and print them out in user-friendly output.\n result['gecos'].each { |name| reply << \"Name: #{name}\\n\" }\n result['uid'].each { |uid| reply << \"Username: #{uid}\\n\" }\n result['ou'].each { |dept| reply << \"Dept: #{dept}\\n\" }\n \n # Determine if this is a sponsored account, and if so, who the sponsor is.\n if (result['psusponsorpidm'].empty?)\n reply << \"Sponsored: no\\n\"\n else\n # Look up sponsor's information.\n reply << \"Sponsored: yes\\n\"\n sponsor_uniqueid = result['psusponsorpidm'][0]\n # Fix some malformed psusponsorpidms.\n if (!(sponsor_uniqueid =~ /^P/i))\n sponsor_uniqueid = \"P\" + sponsor_uniqueid\n end\n \n sponsor_entry = $oitldap.search(\"uniqueIdentifier\",sponsor_uniqueid)\n \n sponsor_name = sponsor_entry['gecos'][0]\n sponsor_uid = sponsor_entry['uid'][0]\n reply << \"Sponsor: #{sponsor_name} (#{sponsor_uid})\\n\"\n end\n \n # Determine the account and password expiration dates. Also, estimate the date the\n # password was originally set by subtracting 6 months from the expiration date.\n result['psuaccountexpiredate'].each do |acctexpiration|\n acct_expire_date = $oitldap.parse_date(acctexpiration)\n reply << \"Account expires: #{acct_expire_date.asctime}\\n\"\n end\n result['psupasswordexpiredate'].each do |pwdexpiration|\n pwd_expire_date = $oitldap.parse_date(pwdexpiration)\n reply << \"Password expires: #{pwd_expire_date.asctime}\\n\"\n # Calculate the date/time that the password was set.\n day = 86400 # seconds\n pwd_set_date = pwd_expire_date - (180 * day)\n reply << \"Password was set: #{pwd_set_date.asctime}\\n\"\n end\n\n # Print out any email aliases.\n result['maillocaladdress'].each { |email_alias| reply << \"Email alias: #{email_alias}\\n\" }\n end\n # Send results via PM so as to not spam the channel.\n User(m.user.nick).send(reply)\n end\n end",
"def get_domain_name(host)\n domain = nil\n search = nil\n resolv_conf = if host['platform'].include?('windows')\n if host.is_cygwin?\n host.exec(Command.new(\"cat /cygdrive/c/Windows/System32/drivers/etc/hosts\")).stdout\n else\n host.exec(Command.new('type C:\\Windows\\System32\\drivers\\etc\\hosts')).stdout\n end\n else\n host.exec(Command.new(\"cat /etc/resolv.conf\")).stdout\n end\n resolv_conf.each_line do |line|\n if (match = /^\\s*domain\\s+(\\S+)/.match(line))\n domain = match[1]\n elsif (match = /^\\s*search\\s+(\\S+)/.match(line))\n search = match[1]\n end\n end\n return_value ||= domain\n return_value ||= search\n\n return unless return_value\n\n return_value.gsub(/\\.$/, '')\n end",
"def domain_info\n result = FFI::Libvirt::DomainInfo.new\n FFI::Libvirt.virDomainGetInfo(self, result.to_ptr)\n result\n end",
"def domain_info\n result = FFI::Libvirt::DomainInfo.new\n FFI::Libvirt.virDomainGetInfo(self, result.to_ptr)\n result\n end",
"def run\n\n\t\tdomain = datastore['DOMAIN']\n\t\thostlst = datastore['NAMELIST']\n\t\ta = []\n\n\t\tprint_status(\"Performing DNS Forward Lookup Bruteforce for Domain #{domain}\")\n\t\tif session.type =~ /shell/\n\t\t\t# Only one thread possible when shell\n\t\t\tthread_num = 1\n\t\t\t# Use the shell platform for selecting the command\n\t\t\tplatform = session.platform\n\t\telse\n\t\t\t# When in Meterpreter the safest thread number is 10\n\t\t\tthread_num = 10\n\t\t\t# For Meterpreter use the sysinfo OS since java Meterpreter returns java as platform\n\t\t\tplatform = session.sys.config.sysinfo['OS']\n\t\tend\n\n\t\tname_list = []\n\t\tif ::File.exists?(hostlst)\n\t\t\t::File.open(hostlst).each do |n|\n\t\t\t\tname_list << n\n\t\t\tend\n\t\tend\n\n\t\tplatform = session.platform\n\n\t\tcase platform\n\t\twhen /win/i\n\t\t\tcmd = \"nslookup\"\n\t\twhen /solaris/i\n\t\t\tcmd = \"/usr/sbin/host \"\n\t\telse\n\t\t\tcmd = \"/usr/bin/host \"\n\t\tend\n\t\twhile(not name_list.nil? and not name_list.empty?)\n\t\t\t 1.upto(thread_num) do\n\t\t\t \ta << framework.threads.spawn(\"Module(#{self.refname})\", false, name_list.shift) do |n|\n\t\t\t \t\tnext if n.nil?\n\t\t\t \t\tvprint_status(\"Trying #{n.strip}.#{domain}\")\n\t\t\t\t\tr = cmd_exec(cmd, \"#{n.strip}.#{domain}\")\n\n\t\t\t\t\tcase session.platform\n\t\t\t\t\twhen /win/\n\t\t\t\t\t\tproccess_win(r, \"#{n.strip}.#{domain}\")\n\t\t\t\t\telse\n\t\t\t\t\t\tprocess_nix(r, \"#{n.strip}.#{domain}\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t \ta.map {|x| x.join }\n\t\t\t end\n\t\tend\n\tend",
"def get_host_info(s)\n\n # Prepare response array of aliases (IP and addresses)\n aliases = []\n\n # Get information from the given IP or name\n begin\n resp = Socket.getaddrinfo(s, nil)\n rescue\n aliases << s\n else\n\n fqdn = resp.first[2]\n ip = resp.first[3]\n aliases << fqdn\n\n if fqdn != ip\n host_dom = fqdn.split('.', 2)\n if $local_domain && host_dom.length == 2 && host_dom.last == $local_domain\n aliases << host_dom.first\n end\n aliases << ip\n end\n\n end\n\n return aliases\n\nend",
"def parse_dns(dns_raw)\n raw_data=dns_raw.reject { |line| line.empty? or line[0] == \"#\" }#removing hash and empty lines,string\n split_data=raw_data.map { |line| line.strip.split(\", \") }#split the entry into columns using ','\n clean_data=split_data.reject { |record| record.length < 3 }# discarding false entries in zone file\n clean_data.each_with_object({}) do |record, records|# preparing hash for dns entries\n records[record[1]] = {\n type: record[0],\n target: record[2],\n }\n end\n end",
"def get_dn\n domain_membership = {\n in_domain: false,\n domain_dn: '',\n domain_fqdn: '',\n domain_controller: ''\n }\n\n begin\n\n machine_subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\DataStore\\Machine\\0'\n subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History'\n v_name = 'DCName'\n key_vals = registry_enumvals(subkey)\n vprint_status('checking if host is in a domain')\n if key_vals.include?(v_name)\n vprint_status('Host appears to be in a domain.')\n domain_membership[:in_domain] = true\n domain_dc = registry_getvaldata(subkey, v_name)\n domain_membership[:domain_controller] = domain_dc\n # lets parse the information\n dom_info = domain_dc.split('.')\n fqdn = \"#{dom_info[1,dom_info.length].join('.')}\"\n dn = \"DC=#{dom_info[1,dom_info.length].join(',DC=')}\"\n machine_dn = registry_getvaldata(machine_subkey, 'DNName')\n machine_site = registry_getvaldata(machine_subkey, 'SiteName')\n\n\n domain_membership[:domain_fqdn] = fqdn\n domain_membership[:domain_dn] = dn\n domain_membership[:machine_dn] = machine_dn\n domain_membership[:machine_site] = machine_site\n\n else\n vprint_status('Host is not part of a domain.')\n end\n rescue\n vprint_error('Could not determine if the host is part of a domain.')\n return domain_membership\n end\n domain_membership\n end",
"def get_dn\n domain_membership = {\n in_domain: false,\n domain_dn: '',\n domain_fqdn: '',\n domain_controller: ''\n }\n\n begin\n\n machine_subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\DataStore\\Machine\\0'\n subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History'\n v_name = 'DCName'\n key_vals = registry_enumvals(subkey)\n vprint_status('checking if host is in a domain')\n if key_vals.include?(v_name)\n vprint_status('Host appears to be in a domain.')\n domain_membership[:in_domain] = true\n domain_dc = registry_getvaldata(subkey, v_name)\n domain_membership[:domain_controller] = domain_dc\n # lets parse the information\n dom_info = domain_dc.split('.')\n fqdn = \"#{dom_info[1,dom_info.length].join('.')}\"\n dn = \"DC=#{dom_info[1,dom_info.length].join(',DC=')}\"\n machine_dn = registry_getvaldata(machine_subkey, 'DNName')\n machine_site = registry_getvaldata(machine_subkey, 'SiteName')\n\n\n domain_membership[:domain_fqdn] = fqdn\n domain_membership[:domain_dn] = dn\n domain_membership[:machine_dn] = machine_dn\n domain_membership[:machine_site] = machine_site\n\n else\n vprint_status('Host is not part of a domain.')\n end\n rescue\n vprint_error('Could not determine if the host is part of a domain.')\n return domain_membership\n end\n domain_membership\n end",
"def find_hypers\n return_output = \"\"\n return_output << \"Running in dry run mode. No changes will be made to EIP config on any hypervisor.\\n\" unless @dryrun == false\n found_hypers = []\n @hypers.each do |hyper| \n return_output << \"#{hyper}: \" unless @verbose == false\n ssh_cmd = \"ssh -o StrictHostKeyChecking=no #{hyper} \\\"ip addr list br0 | grep #{@value}\\\"\"\n ssh_cmd_output = `#{ssh_cmd}`\n unless ssh_cmd_output.empty? \n found_hypers << hyper \n end\n return_output << \"#{ssh_cmd_output}\\n\" unless @verbose == false\n end\n return found_hypers,return_output\n end",
"def execute(m, query)\n\t\t\n\t\treply = String.new\n\t\t\n\t\t# Error-checking to sanitize input. i.e. no illegal symbols.\n\t\tif query =~ /[^\\w@._-]/\n\t\t\tm.reply \"Invalid search query '#{query}'\"\n\t\t\treturn\n\t\tend\t\n\n\t\tquery.downcase!\n\t\t\n\t\t# Determine what field to search and proceed to execute it.\n\t\tif query =~ /@pdx\\.edu/\n\t\t\ttype = 'email alias'\n\t\t\tattribute = 'mailLocalAddress'\n\t\t# This is not useful anymore after the transition to Google Mail.\t\t\t\n\t\telsif query =~ /@/\n\t\t\treply << \"Error: Searching for forwarding addresses is now disabled; they are not\"\n\t\t\treply << \" stored in LDAP after the Google conversion.\"\n\t\t\tm.reply(reply)\n\t\t\treturn\n\t\telse\n\t\t\ttype = 'username'\n\t\t\tattribute = 'uid'\n\t\tend\n\t\tm.reply \"Performing LDAP search on #{type} #{query}.\"\n\t\t\n\t\tldap_entry = ldap_search attribute,query\n\t\t\n\t\tif (!ldap_entry)\n\t\t\tm.reply \"Error: LDAP query failed. Check configuration.\"\n\t\telse\n\t\t\t#\tPiece together the final results and print them out in user-friendly output.\n\t\t\tif ldap_entry['dn'].empty?\n\t\t\t\treply = \"Error: No results.\\n\"\n\t\t\telsif ldap_entry['dn'].length > 1\n\t\t\t\t# Realistically this case should never happen because we filtered '*'\n\t\t\t\t# out of the search string earlier. If this comes up, something in LDAP\n\t\t\t\t# is really janky. The logic to account for this is here nonetheless,\n\t\t\t\t# just in case.\n\t\t\t\treply = \"Error: Too many results.\\n\"\n\t\t\telse\n\t\t\t\t#\tGet name, username and dept of the user.\n\t\t\t\tldap_entry['gecos'].each { |name| reply << \"Name: #{name}\\n\" }\n\t\t\t\tldap_entry['uid'].each { |uid| reply << \"Username: #{uid}\\n\" }\n\t\t\t\tldap_entry['ou'].each { |dept| reply << \"Dept: #{dept}\\n\" }\n\t\t\t\t\n\t\t\t\t# Determine if the user has opted-in to Google Mail.\n\t\t\t\tldap_entry['mailhost'].each do |mhost|\n\t\t\t\t\tif mhost =~ /gmx.pdx.edu/\n\t\t\t\t\t\treply << \"Google: yes\\n\"\n\t\t\t\t\telse\n\t\t\t\t\t\treply << \"Google: no\\n\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Determine if this is a sponsored account, and if so, who the sponsor is.\n\t\t\t\tif ldap_entry['psusponsorpidm'].empty?\n\t\t\t\t\treply << \"Sponsored: no\\n\"\n\t\t\t\telse\n\t\t\t\t\t# Look up sponsor's information.\n\t\t\t\t\treply << \"Sponsored: yes\\n\"\n\t\t\t\t\tsponsor_uniqueid = ldap_entry['psusponsorpidm'][0]\n\t\t\t\t\t# Fix some malformed psusponsorpidms.\n\t\t\t\t\tif (!(sponsor_uniqueid =~ /^P/i))\n\t\t\t\t\t\tsponsor_uniqueid = \"P\" + sponsor_uniqueid\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tldap_sponsor_entry = ldap_search \"uniqueIdentifier\",sponsor_uniqueid\n\t\t\t\t\n\t\t\t\t\tsponsor_name = ldap_sponsor_entry['gecos'][0]\n\t\t\t\t\tsponsor_uid = ldap_sponsor_entry['uid'][0]\n\t\t\t\t\treply << \"Sponsor: #{sponsor_name} (#{sponsor_uid})\\n\"\n\t\t\t\tend\n\t\t\t\n\t\t\t\t# Determine the account and password expiration dates. Also, estimate the date the\n\t\t\t\t# password was originally set by subtracting 6 months from the expiration date.\n\t\t\t\tldap_entry['psuaccountexpiredate'].each do |acctexpiration|\n\t\t\t\t\td = parse_date acctexpiration\n\t\t\t\t\treply << \"Account expires: #{d.asctime}\\n\"\n\t\t\t\tend\n\t\t\t\tldap_entry['psupasswordexpiredate'].each do |pwdexpiration|\n\t\t\t\t\td = parse_date pwdexpiration\n\t\t\t\t\treply << \"Password expires: #{d.asctime}\\n\"\n\t\t\t\t\t# Calculate the date/time that the password was set.\n\t\t\t\t\tday = 86400 # seconds\n\t\t\t\t\te = d - (180 * day)\n\t\t\t\t\treply << \"Password was set: #{e.asctime}\\n\"\n\t\t\t\tend\n\t\t\t\n\t\t\t\t# Determine if email is being forwarded to an external address.\n\t\t\t\tldap_entry['mailroutingaddress'].each do |forward|\n\t\t\t\t\t# If they are on Google, we cannot tell if they are forwarding.\n\t\t\t\t\tif ldap_entry['mailhost'][0] =~ /gmx.pdx.edu/\n\t\t\t\t\t\treply << \"Email forwarded to: Unable to determine with Gmail.\\n\"\n\t\t\t\t\telse\n\t\t\t\t\t\treply << \"Email forwarded to: #{forward}\\n\"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Print out any email aliases.\n\t\t\t\tldap_entry['maillocaladdress'].each { |email_alias| reply << \"Email alias: #{email_alias}\\n\" }\n\t\t\tend\n\t\t\t# Send results via PM so as to not spam the channel.\n\t\t\tUser(m.user.nick).send(reply)\n\t\tend\n\n\tend",
"def run\n print_status(\"Running module against #{sysinfo['Computer']}\")\n if datastore['OU_DN'] =~ /^OU=*/\n # Make sure the extension is loaded.\n if load_extapi\n domain = get_domain\n unless domain.nil?\n\n table = Rex::Ui::Text::Table.new(\n 'Indent' => 4,\n 'SortIndex' => -1,\n 'Width' => 80,\n 'Columns' =>\n [\n 'Name',\n 'SAMAccount',\n 'Distinguished Name',\n 'Type'\n ]\n )\n\n filter = '(|(&(objectCategory=person)(objectClass=user))(objectClass=computer)(objectClass=group)(objectClass=organizationalUnit))'\n query_result = session.extapi.adsi.domain_query(datastore['OU_DN'],\n filter,\n datastore['MAX_SEARCH'],\n datastore['MAX_SEARCH'],\n [\n 'name',\n 'samaccountname',\n 'distinguishedname',\n 'objectcategory']\n )\n if query_result[:results].empty?\n print_status 'No results where found.'\n return\n end\n\n query_result[:results].each do |obj|\n\n # Identify the object type\n objtype = ''\n case obj[3][:value].to_s\n when /^CN=Person*/\n objtype = 'User'\n\n when /^CN=Computer/\n objtype = 'Computer'\n\n when /^CN=Group*/\n objtype = 'Group'\n\n when /^CN=Organizational-Unit*/\n objtype = 'OU'\n end\n\n table << [obj[0][:value], obj[1][:value], obj[2][:value], objtype]\n end\n table.print\n print_line\n\n if datastore['STORE_LOOT']\n stored_path = store_loot('ad.ou_members', 'text/plain', session, table.to_csv)\n print_status(\"Results saved to: #{stored_path}\")\n end\n\n end\n end\n else\n print_error \"Distinguished Name provided is not for an Organizational Unit.\"\n end\n end",
"def array_to_hash(domains)\n domain_hash = {}\n group = ''\n domains.each do |line|\n if line =~ COMMENT_REGEX\n group = COMMENT_REGEX.match(line)[1]\n else\n safe_push(domain_hash, group, line.downcase)\n end\n end\n domain_hash\n end",
"def do_lookup(args)\n if args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"soa\"\n @result = [\n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n ]\n elsif args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [ \n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n record(\"example.com\", \"NS\", \"sns.dns.icann.org\"),\n record_prio(\"example.com\", \"MX\", \"test.example.com\",10)\n ]\n elsif args[\"qname\"] == \"test.example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [\n record(\"test.example.com\", \"A\", \"127.0.0.1\")\n ]\n elsif args[\"qname\"] =~ /(.*)\\.example\\.com$/ and args[\"qtype\"].downcase == \"any\"\n ip = 0\n $1.downcase.each_byte do |b| ip = ip + b end\n ip_2 = ip/256\n ip = ip%256\n @result = [\n record(args[\"qname\"], \"A\", \"127.0.#{ip_2}.#{ip}\")\n ]\n end\n end",
"def domain_report(domain)\n DomainReport.new(api_key: @api_key, domain: domain).response\n end",
"def host_from_fqdn(question)\n domains.each do |domain|\n dd = dotted_domain(domain)\n if question.index(dd)\n host = question[0, question.index(dd)]\n end\n end\n nil\n end",
"def perform\n urls = get_townhall_urls(\"https://annuaire-des-mairies.com/val-d-oise.html\")\n puts array = get_townhall_email_city_name(urls)\n #puts getHash(name_array, mail_array)\n end",
"def dns_responses\n decoded_responses = udp_packets_with_src_port(DNS_PORT).map { |p| Resolv::DNS::Message.decode(p.payload) }\n\n decoded_responses.each_with_object({}) do |response, memo|\n name = response.question.first.first.to_s\n memo[name] ||= []\n response.answer.each do |ans|\n case ans.last\n when Resolv::DNS::Resource::IN::CNAME\n memo[name] << ans.last.name\n when Resolv::DNS::Resource::IN::AAAA, Resolv::DNS::Resource::IN::A\n memo[name] << ans.last.address\n else\n puts ans.last\n end\n end\n end\n end",
"def add(host)\n\t\tputs \"Add entry to the local host repository: #{host}\"\n\t\thost=host.strip.downcase unless host.nil?\n\t\troot=get_domain_root(host)\n\t\tunless @known_hosts.key?(host)\n\t\t\tip=host_2_ip(host)\n\t\t\trecord=Hash.new\n\t\t\tif is_ip?(ip)\n\t\t\t\t# filter host to known domains only\n\t\t\t\tif is_trusted?(host)\n\t\t\t\t\trecord[host]=ip\n\t\t\t\t\trecord[ip]=host\n\t\t\t\t\tputs \"Host data repository entry loaded: #{host} <=> #{ip}\"\n\t\t\t\t\t# Replace instance with the class variable to avoid potential race condition under parallel engine\n\t\t\t\t\t# add additional logic to update the sub-domain table as well, 02/10/2014\n\t\t\t\t\tsub=get_sub_domain(host)\n\t\t\t\t\tif sub!=nil\n\t\t\t\t\t\ttracker=Wmap::DomainTracker::SubDomain.instance\n\t\t\t\t\t\ttracker.data_dir=@data_dir\n\t\t\t\t\t\ttracker.sub_domains_file = tracker.data_dir + \"sub_domains\"\n\t\t\t\t\t\ttracker.known_internet_sub_domains=tracker.load_domains_from_file(tracker.sub_domains_file)\n\t\t\t\t\t\tunless tracker.domain_known?(sub)\n\t\t\t\t\t\t\ttracker.add(sub)\n\t\t\t\t\t\t\ttracker.save!\n\t\t\t\t\t\tend\n\t\t\t\t\t\ttracker=nil\n\t\t\t\t\tend\n\t\t\t\t\t@known_hosts.merge!(record)\n\t\t\t\t\treturn record\n\t\t\t\telse\n\t\t\t\t\tdomain_tracker=nil\n\t\t\t\t\tputs \"Error - host #{host} has an untrusted internet root domain: #{root}\\nPlease update the trusted domain seeds file first if necessary.\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Problem resolve host #{host} - unknown IP: #{ip}\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Host is already exist. Skip: #{host}\"\n\t\tend\n\t#rescue => ee\n\t#\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\tend",
"def parse_domain_name\n mdata = /ip domain-name ([\\w.]+)/.match(config)\n { domain_name: mdata.nil? ? '' : mdata[1] }\n end",
"def run\n super\n \n entity_name = _get_entity_name\n api_key = _get_task_config(\"c99_subdomainfinder_api_key\")\n #limit = _get_option(\"limit\")\n \n begin \n url = \"https://api.c99.nl/subdomainfinder?key=#{api_key}&domain=#{entity_name}&json\"\n response = http_get_body(url)\n result = JSON.parse(response)\n rescue JSON::ParserError => e\n _log_error \"Unable to parse, not JSON!\"\n return \n end\n \n ### parse it up \n if result[\"success\"]\n\n result[\"subdomains\"].each do |s|\n create_dns_entity_from_string(\"#{s[\"subdomain\"]}\")\n end\n\n else\n _log_error \"No success message\"\n end\n \n end",
"def info_host(host)\n validate_list([[\"Host\", host, :presence]])\n options = {\"Host\" => host}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Info\", options)\n end",
"def server_with_hash(ip_hash)\n # Sort by mask of Ip Range\n arr_tmp = ip_hash.sort{|b,c| c[0][/\\/(.+)/, 1].to_i <=> b[0][/\\/(.+)/, 1].to_i}\n arr_tmp.each do |l|\n ip_range = IPAddr.new l[0]\n if ip_range.include? self.ip\n if l[1].nil? or l[1].empty?\n raise WhoisException.new(\"no server of Whois is define for the IP #{self.ip}. Sorry\")\n end\n return Object.instance_eval(\"Server::#{l[1]}.new\")\n end\n end\n end",
"def shodan_query(query, apikey, page)\n # send our query to Shodan\n res = send_request_cgi({\n 'method' => 'GET',\n 'rhost' => 'api.shodan.io',\n 'rport' => 443,\n 'uri' => '/shodan/host/search',\n 'SSL' => true,\n 'vars_get' => {\n 'query' => query,\n 'key' => apikey,\n 'page' => page.to_s\n }\n })\n\n if res && res.code == 401\n fail_with(Failure::BadConfig, '401 Unauthorized. Your SHODAN_APIKEY is invalid')\n end\n\n # Check if we can resolve host, got a response,\n # then parse the JSON, and return it\n if res\n results = ActiveSupport::JSON.decode(res.body)\n return results\n else\n return 'server_response_error'\n end\n end",
"def run\n print_status(\"Running module against #{ sysinfo['Computer'] }\")\n \n domain = get_domain()\n return if domain.nil?\n print_status(\"Host is part of #{domain}\")\n get_gpo_info()\n tradecraft_check(find_audit(domain))\n \n end",
"def domain\n if @sym == SYM_DOMAIN_LITERAL\n\t save_text\n\t @addresses.last.domain = get_text\n\t get\n elsif @sym == SYM_ATOM\n obs_domain\n\t @addresses.last.domain = get_text\n\telse\n\t error \"expected start of domain, got #{@sym.inspect}\"\n\tend\n end",
"def get_domain_info(sld, tld)\n query_push 'Command' => 'GetDomainInfo', 'SLD' => sld, 'TLD'=> tld\n get_response\n end",
"def status_private_who_is(domain)\n validate_list([ [\"Domain\", domain, :domain_format] ])\n options = { \"Domain\" => domain }\n\n connection = Connection.new\n connection.post(\"Domain/PrivateWhois/Status\", options)\n end",
"def answer_string(host)\n answers[host.name].map { |k,v| \"#{k}=#{v}\" }.join(\"\\n\")\n end",
"def normalize(hostname)\n #http://publicsuffix.org/format/\n #Match domain against all rules and take note of the matching ones.\n matching_normal = []\n matching_ex = []\n for r in @rules\n if r.match(hostname) then\n if r.type == :normal then\n matching_normal << r\n else\n matching_ex << r\n end\n end\n end\n #If no rules match, the prevailing rule is \"*\".\n if (matching_normal.length + matching_ex.length) == 0 then\n return {:domain => hostname, :tld => nil}\n end\n #If more than one rule matches, the prevailing rule is the one which is the longest exception rule.\n if (matching_ex.length > 0 ) then\n r = longest_rule(matching_ex) \n return {:domain => r.normalize(hostname), :tld => r.tld}\n end\n \n #If there is no matching exception rule, the prevailing rule is the one with the most labels.\n if (matching_normal.length > 0 ) then\n r = longest_rule(matching_normal) \n return {:domain => r.normalize(hostname), :tld => r.tld}\n end\n end",
"def run\n super\n \n require 'nokogiri'\n require 'open-uri'\n require 'cgi'\n \n # Search URI\n search_uri = \"http://www.hoovers.com/search/company-search-results/100005142-1.html?type=company&term=#{@object.name}\"\n doc = Nokogiri::HTML(open(search_uri))\n company_path = doc.xpath(\"//*[@class='company_name']\").first.children.first['href']\n company_uri = \"http://www.hoovers.com#{company_path}\"\n \n # Open Page & Parse\n doc = Nokogiri::HTML(open(company_uri))\n \n # Get Company Profile\n # TODO\n \n # Get Address & Clean up\n address = (doc/\"/html/body/div[3]/div[2]/table/tbody/tr/td/strong/span\").inner_html\n puts \"Got Address: #{address}\"\n \n # Get Users\n user = (doc/\"/html/body/div[3]/div[2]/div[9]/table/tbody/tr/td\").inner_html\n\n unless user.blank?\n names = user.gsub(\"a href=\\\"/marketing/free-trial/100004836-1.html\\\" title=\\\"Email lists, email contacts, contact phone numbers, email leads, phone leads\\\" relatedarticles=\\\"false\\\" id=\\\"100004836\\\">E-mail</a>\",\"\").split(\"<\") \n puts \"Got Users: #{names.join(\" \")}\"\n \n names.each do |name| \n name.gsub!(\" \",\" \")\n fname,lname = name.split(\" \")\n create_object User, { :fname => fname, :lname => lname }\n end\n end\n \n\tnil\nend",
"def process_domains\n domains.each do |domain|\n params = options\n params[:host] = configuration.host\n params[:server] = servers[domain][\"server\"]\n compiler = YMDP::Compiler::Base.new(domain, git_hash, params)\n \n compiler.process_all\n end\n end",
"def initialize\n @domains = {}\n content = File.read \"#{Driver.config_dir}/root_registry_sea1.json\"\n store_domain(Driver.parse_json(content)['resolveDomainResponse'], 'urn:theplatform:auth:root')\n end",
"def query(q)\n Timeout::timeout(1) {\n @queries += 1\n if @queries >= 999\n disconnect\n \t @sock = TCPSocket.new(@host, @port)\n \t @queries = 0\n end\n #puts \"querying...\"\n @sock.puts(\"query #{q} return all\")\n #puts \"getting response...\"\n resp = @sock.gets\n #puts resp\n while (resp.match(/^Connection\\sclosed\\sby\\sforeign\\host\\./))\n @sock = TCPSocket.new(@host, @port)\n \t @queries = 0\n @sock.puts(\"query #{q} return all\")\n #puts \"getting response...\"\n resp = @sock.gets\n end\n if (resp.match(/^501:.*/))\n # no matches\n return []\n elsif (resp.match(/^102:.*/))\n # go ahead\n # which of the results are we processing?\n result_num = 1\n # array of records to return\n records = Array.new\n record = Hash.new\n while (@sock.gets.match(/^-200:(\\d+):\\s*(\\w+):\\s(.*)$/))\n # $1 => the number person we're processing\n # $2 => the field name\n # $3 => the field contents\n #puts \"$1: #$1 $2: #$2 $3: #$3\"\n # if we're processing a new record now\n if (result_num.to_s != $1)\n # update the num of the record we're processing\n result_num = $1\n # save the previous record in the array\n records.push record\n # start a new record\n record = Hash.new\n end\n \n # save the field\n record[$2] = $3\n \n # handle the two-line address\n if ($2 == \"home_address\")\n @sock.gets.match(/-200:\\d+:\\s*:\\s(.*)$/)\n # $1 => field value\n record[\"home_address_2\"] = $1\n end\n end\n records.push record\n return records\n else\n # error\n @sock = TCPSocket.new(@host, @port)\n \t @queries = 0\n query(q)\n #raise \"Error talking to PH server\"\n end\n }\n end",
"def valid_whois?\n @status == '200' && parser.valid_whois?\n end",
"def process_ehlo domain\n if domain !~ /[\\w.-]+/\n reply 501, \"Syntax: EHLO hostname\"\n elsif receive_ehlo_domain domain\n params = [get_server_domain]\n params << \"STARTTLS\" if respond_to?(:start_tls)\n params << \"AUTH PLAIN LOGIN\" if respond_to?(:authenticate)\n # Multiple values for the keyword AUTH are allowed by RFC 1869, \n # however broke the parsing of several ESMTP client implementations. \n # A work around is, to add artificially a \"=\" (equal sign) between the AUTH keyword and the value.\n #send_data \"250-AUTH=PLAIN\" # ? LOGIN CRAM-MD5\n params << \"SIZE #{max_size}\" if respond_to?(:max_size)\n params << \"PIPELINING\"\n params << \"8BITMIME\"\n params << \"XFORWARD NAME ADDR HELO\"\n #params << \"ENHANCEDSTATUSCODES\"\n reply 250, params\n reset_protocol_state\n @state << :ehlo\n else\n reply 550, \"Requested action not taken\"\n end\n end",
"def statistics\n stats_hash = {}\n stats = info_cmd(\"statistics\")\n\n stats = stats.gsub!(/statistics\\s/, '').gsub!(/\\n/, '').split(\";\")\n\n stats.each do |st|\n type = \"\"\n value = nil\n\n st.split(\"=\").each_with_index do |val, i|\n type = val if i == 0\n value = val if i == 1\n end\n\n stats_hash[type] = value\n end\n\n stats_hash\n end",
"def usage()\n puts \"ruby DNS.rb domain-host lookup-host1..lookup-hostN\"\n puts \"e.g. ruby DNS.rb 192.168.0.1 news.bbc.co.uk\"\n puts \"e.g. ruby DNS.rb 192.168.0.1 www.facebook.com www.twitter.com www.instagram.com\"\n exit(0)\nend",
"def to_stdout\n\t\t\tresult_string = String.new\n\t\t\thashes = Array.new\n\n\t\t\t@results.sort_by {|k| k[:scanner] }.each do |result|\n\t\t\t\tunless hashes.include? result[:hash].downcase\n\t\t\t\t\tresult_string << \"#{result[:hash]}:\\n\"\n\t\t\t\t\thashes << result[:hash].downcase\n\t\t\t\tend\n\t\t\t\tresult_string << \"#{result[:scanner]}: \".rjust(25) + \"#{result[:result]}\\n\"\n\t\t\tend if @results != nil\n\n\t\t\tresult_string\n\t\tend",
"def run\n super\n res = []\n entity_name = _get_entity_name\n\n # Query quad9 nameservers\n nameservers = ['9.9.9.9']\n _log \"Querying #{nameservers}\"\n dns_obj = Resolv::DNS.new(nameserver: nameservers)\n res = dns_obj.getaddresses(entity_name)\n\n # Detected only if there's no resolution\n if res.any?\n _log \"Resolves to #{res.map{|x| \"#{x.to_name}\" }}. Seems we're good!\"\n else\n description = \"Quad9 routes your DNS queries through a secure network of servers around the \" + \n \"globe. The system uses threat intelligence from more than a dozen of the industry’s leading \" +\n \"cyber security companies to give a real-time perspective on what websites are safe and what \" +\n \"sites are known to include malware or other threats. If the system detects that the site you \" + \n \"want to reach is known to be infected, you’ll automatically be blocked from entry – keeping \" +\n \"your data and computer safe.\"\n\n _malicious_entity_detected(\"Quad9\", description) \n end\n\n end",
"def run\n super\n\n lookup_string = _get_entity_name.upcase\n\n begin\n search_doc = Nokogiri::XML(http_get_body(\"http://whois.arin.net/rest/orgs;name=#{URI.escape(lookup_string)}*\"));nil\n orgs = search_doc.xpath(\"//xmlns:orgRef\")\n\n # For each netblock, create an entity\n orgs.children.each do |org|\n _log_good \"Working on #{org.text}\"\n net_list_doc = Nokogiri::XML(http_get_body(\"#{org.text}/nets\"))\n\n begin\n nets = net_list_doc.xpath(\"//xmlns:netRef\")\n nets.children.each do |net_uri|\n _log_good \"[!] Net: #{net_uri}\" if net_uri\n\n #page = \"https://whois.arin.net/rest/net/NET-64-41-230-0-1.xml\"\n page = \"#{net_uri}.xml\"\n\n net_doc = Nokogiri::XML(http_get_body(page));nil\n net_blocks = net_doc.xpath(\"//xmlns:netBlocks\");nil\n\n net_blocks.children.each do |n|\n start_address = n.css(\"startAddress\").text\n end_address = n.css(\"endAddress\").text\n description = n.css(\"description\").text\n cidr_length = n.css(\"cidrLength\").text\n type = n.css(\"type\").text\n\n # Do a lookup - important that we get this so we can verify\n # if the block actually belongs to the expected party (via whois_full_text)\n # see discovery strategy for more info\n begin\n whois = ::Whois::Client.new(:timeout => 20)\n answer = whois.lookup(start_address)\n parser = answer.parser\n whois_full_text = answer.content if answer\n rescue ::Whois::ResponseIsThrottled => e\n _log \"Unable to query whois: #{e}\"\n end\n #===================================\n\n _log_good \"Creating net block: #{start_address}/#{cidr_length}\"\n entity = _create_entity \"NetBlock\", {\n \"name\" => \"#{start_address}/#{cidr_length}\",\n \"start_address\" => \"#{start_address}\",\n \"end_address\" => \"#{end_address}\",\n \"cidr\" => \"#{cidr_length}\",\n \"description\" => \"#{description}\",\n \"block_type\" => \"#{type}\",\n \"whois_full_text\" => \"#{whois_full_text}\"\n }\n\n end # end netblocks.children\n end # end nets.children\n\n rescue Nokogiri::XML::XPath::SyntaxError => e\n _log_error \" [x] No nets for #{org.text}\"\n end\n\n end # end orgs.children\n\n rescue Nokogiri::XML::XPath::SyntaxError => e\n _log_error \" [x] No orgs!\"\n end\n\n end",
"def smb_domains\n\t\tprint_status(\"SMB Domain User Enumeration\")\n\t\tprint_caution(\"Provide Target IP/Range: \")\n\t\tzIP=gets.chomp\n\n\t\tprint_caution(\"Please provide Username: \")\n\t\tsmbUser=gets.chomp\n\n\t\tprint_caution(\"Please provide Password or LM:NTLM Hash:\")\n\t\tsmbPass=gets.chomp\n\n\t\tprint_status(\"Launching Domain User Enumeration Scanner against #{zIP} in a new x-window.....\")\n\t\trcfile=\"#{$temp}msfassist.rc\"\n\t\tf=File.open(rcfile, 'w')\n\t\tf.puts \"db_connect #{MSFDBCREDS}\"\n\t\tf.puts 'use auxiliary/scanner/smb/smb_enumusers_domain'\n\t\tf.puts \"set RHOSTS #{zIP}\"\n\t\tf.puts \"set SMBUser #{smbUser}\"\n\t\tf.puts \"set SMBPass #{smbPass}\"\n\t\tf.puts \"set SMBDOMAIN WORKGROUP\"\n\t\tf.puts \"set THREADS 5\"\n\t\tf.puts 'run'\n\t\tf.close\n\t\tsmb_domain_enum=\"xterm -title 'MSF SMB Domain Enum' -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -e \\\"bash -c '#{MSFPATH}/msfconsole -r #{rcfile}'\\\"\"\n\t\tfireNforget(smb_domain_enum)\n\t\tprint_line(\"\")\n\tend",
"def build_rsp\n fqdn_query = '/pdb/query/v4/facts/fqdn'\n json_hosts_fqdn = JSON.parse(query_pdb(fqdn_query))\n format_facts(json_hosts_fqdn, 'fqdn')\n ip_query = '/pdb/query/v4/facts/ipaddress'\n json_hosts_ip = JSON.parse(query_pdb(ip_query))\n format_facts(json_hosts_ip, 'ipaddress')\n merged_facts = merge_hasharray(json_hosts_fqdn, json_hosts_ip, 'certname')\n hacky_json(merged_facts)\nend",
"def domain\n Domain.new((address.split('@')[1] || '').strip)\n end",
"def get_host_by_displayname(displayname)\n host = nil\n host_json = rpc(\"getHost\", {\"displayName\" => URI::encode(displayname)})\n host_resp = JSON.parse(host_json)\n# p host_resp\n if host_resp[\"status\"] == 200\n host = host_resp[\"data\"]\n# puts(\"Found host matching #{displayname}\")\n end\n host\nend",
"def hash\n [host_list, total_matching, total_returned].hash\n end",
"def parse_dns(dns_raw)\n dns_records = {}\n dns_raw.each do |line|\n arr = line.split(\", \")\n if(arr[0] == \"A\" || arr[0] == \"CNAME\")\n dns_records[arr[1]] = {:type => arr[0], :target => arr[2].strip}\n end\n end\n \n return dns_records\n end",
"def analyze_data\n @input_dataset.each do |name, email|\n domain_name = find_domain(email)\n current_domain = get_current_domain(domain_name) \n current_domain.learn(name, email)\n end\n\n # Generate predictions for available domains\n @all_domains.each{ |key, domain| domain.generate_predictions }\n\n # Utility method to display Email statistics per domain name\n # display_info\n end",
"def hash\n [domain, register_server, transport_protocol, proxy_server, register_server2, transport_protocol2, proxy_server2, register_server3, transport_protocol3, proxy_server3, registration_expire_time, user_name, password, authorization_name, user_email, voice_mail].hash\n end",
"def parse_dns(dns_raw)\n dns = []\n dns_records = {}\n record_type_A = []\n record_type_A_IP = []\n record_type_CNAME = []\n record_type_CNAME_alias = []\n\n #adds each line to dns array and splipt them with \",\"\n dns_raw.each do |lines_in_files|\n dns.push([lines_in_files.split(\",\")])\n end\n\n #Checks for recordA,IP or recordCNAME and adds them to the respected array\n dns.each do |words_in_files|\n if words_in_files[0][0] == \"A\"\n record_type_A.push(words_in_files[0][1].strip)\n record_type_A_IP.push(words_in_files[0][2].strip)\n elsif words_in_files[0][0] == \"CNAME\"\n record_type_CNAME.push(words_in_files[0][1].strip)\n record_type_CNAME_alias.push(words_in_files[0][2].strip)\n end\n end\n\n #record_A hash stores values of recordA\n record_A = {\n :source => record_type_A,\n :ip => record_type_A_IP,\n }\n\n #recordCNAME hash stores values of recordCNAME\n record_CNAME = {\n :source => record_type_CNAME,\n :alias => record_type_CNAME_alias,\n }\n\n #dns_records gets both Hashes\n dns_records = {\n :A => record_A,\n :CNAME => record_CNAME,\n }\n\n #returns record dns_record with two hashes.\n return dns_records\nend",
"def run\n print_status(\"Running module against #{sysinfo['Computer']}\")\n host = Rex::FileUtils.clean_path(sysinfo['Computer'])\n hash_file = store_loot('windows.hashes', 'text/plain', session, '', \"#{host}_hashes.txt\", 'Windows Hashes')\n print_status('Hashes will be saved to the database if one is connected.')\n print_good('Hashes will be saved in loot in JtR password file format to:')\n print_status(hash_file)\n smart_hash_dump(datastore['GETSYSTEM'], hash_file)\n end"
] | [
"0.7176516",
"0.70282465",
"0.6706688",
"0.6699175",
"0.6475335",
"0.63044935",
"0.62118024",
"0.6078173",
"0.59896564",
"0.5939859",
"0.58387315",
"0.5833264",
"0.5777313",
"0.5736887",
"0.57274336",
"0.5693436",
"0.5648879",
"0.5646573",
"0.5550882",
"0.5514687",
"0.55111426",
"0.5465866",
"0.544432",
"0.5439109",
"0.54306513",
"0.5401095",
"0.5385119",
"0.529045",
"0.5267462",
"0.5241598",
"0.5227987",
"0.5209656",
"0.51329863",
"0.50617933",
"0.5035734",
"0.50228554",
"0.50098646",
"0.4985079",
"0.49755362",
"0.49670136",
"0.4966893",
"0.49639338",
"0.4962562",
"0.49529985",
"0.4952375",
"0.48962504",
"0.4895856",
"0.4893775",
"0.48914632",
"0.48874688",
"0.4858187",
"0.4854808",
"0.4854808",
"0.485064",
"0.48451868",
"0.48392242",
"0.48376313",
"0.48376313",
"0.48286185",
"0.48264775",
"0.4825924",
"0.48156595",
"0.48146975",
"0.48117158",
"0.47995436",
"0.478773",
"0.47852024",
"0.478125",
"0.47702634",
"0.47701052",
"0.4765483",
"0.47603026",
"0.4756591",
"0.47548014",
"0.47537866",
"0.4750609",
"0.4747836",
"0.4747779",
"0.47461683",
"0.47443998",
"0.47389656",
"0.47377",
"0.4734251",
"0.47305802",
"0.47257403",
"0.47172332",
"0.4703453",
"0.4703414",
"0.4702649",
"0.4686165",
"0.46842805",
"0.4680818",
"0.46741042",
"0.4673326",
"0.4667032",
"0.46630567",
"0.4662215",
"0.46525452",
"0.46477827",
"0.46393064"
] | 0.76582336 | 0 |
Private method to see if we have a relevant cached query. | def domain_is_cached(domain)
domain_file = "tmp/#{domain}_whois"
if File.file?(domain_file)
if File.mtime(domain_file).to_time < 3.hours.ago
# Cached result file is too old
return false
else
return true
end
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache?\n val = @gapi.configuration.query.use_query_cache\n return false if val.nil?\n val\n end",
"def cache_query?\n false\nend",
"def cache_query?\n false\nend",
"def cacheable_request?\n (request.get? || request.head?) && (request.params[:cache] != 'false')\n end",
"def cache_hit?\n @gapi.statistics.query.cache_hit\n end",
"def cached_lookup_allowed?\n @klass.use_activerecord_cache && arel.where_sql.nil? && arel.join_sources.empty? && @limit_value.nil? && @offset_value.nil?\n end",
"def cached?\n !(!@cached)\n end",
"def from_cache?\n @from_cache\n end",
"def cache?\n caching && true\n end",
"def define_cachedp_method\n # we don't expect this to be called more than once, but we're being\n # defensive.\n return if defined?(cached?)\n\n if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::STRING >= '5.1.0'\n def cached?(payload)\n payload.fetch(:cached, false)\n end\n else\n def cached?(payload)\n payload[:name] == CACHED_QUERY_NAME\n end\n end\n end",
"def use_cache?\n super && !against_head?\n end",
"def use_cache?\n super && !against_head?\n end",
"def cached?(uri)\n @filter.include?(uri)\n end",
"def cached?\n cache_path.exist?\n end",
"def cacheable?\n return false if method != :get && method != :head\n return false if cache_control.no_store?\n true\n end",
"def cached?\n options[:cache] == true\n end",
"def cached?\n cache_path.exist?\n end",
"def cached?(key)\n false\n end",
"def cached?(key)\n not @memcache.get(key).nil?\n end",
"def cached?(name, *args)\n return false if Rails.env == 'development'\n cache = Cacheable.cache[self][name.to_sym]\n return false unless cache.key?(args)\n params = cache[args]\n !(params[:force] && (params[:time] < (Time.new - params[:ttl])))\n end",
"def cached?\n Report::Table::CachedRow.exists_for_table?(table_key)\n end",
"def should_cache?\n false\n end",
"def cache_hit?\n @gapi.cache_hit\n end",
"def cached?(method, url, params = nil, body = nil)\n status = status(method, url, params, body)\n status[:status] != 'miss'\n end",
"def cache_page?\n return false unless @page && Alchemy::Config.get(:cache_pages)\n pagelayout = PageLayout.get(@page.page_layout)\n pagelayout['cache'] != false && pagelayout['searchresults'] != true\n end",
"def caching?\n @params.key?(:cache) ? @params[:cache] : @@caching\n end",
"def cached?\n @rules = cached_rules if cached_rules? && caching_on?\n end",
"def _in_cache?(field)\n return false if self.class._cache.blank?\n cached_obj = self.class._cache[\"#{object.id}.#{object.updated_at.to_i}\"]\n cached_obj.present? && cached_obj[field].present?\n end",
"def cached?; end",
"def cache?\n false\n end",
"def _cached?(field)\n self.class._cacheable_fields.present? && self.class._cacheable_fields.include?(field.to_sym)\n end",
"def cacheable?\n @cacheable\n end",
"def analyse_query?(name:, sql:)\n # FIXME: this seems bad. we should probably have a better way to indicate\n # the query was cached\n name != \"CACHE\" &&\n name != \"SCHEMA\" &&\n name.present? &&\n sql.downcase.include?(\"where\") &&\n IGNORED_SQL.none? { |r| sql =~ r }\n end",
"def cacheable?\n last.nil? || last.cacheable\n end",
"def need_to_fetch?\n @need_to_fetch = true if @need_to_fetch.nil?\n @need_to_fetch\n end",
"def cacheable?(env)\n result = false\n if (url = request_url(env)).blank?\n log(\"NO URI for request #{env.inspect}\")\n elsif cacheable_paths&.none? { |path| url.include?(path) }\n log(\"NON-CACHEABLE URI: #{url}\")\n else\n result = true\n end\n result\n end",
"def cacheable?(env)\n result = false\n if (url = request_url(env)).blank?\n log(\"NO URI for request #{env.inspect}\")\n elsif cacheable_paths&.none? { |path| url.include?(path) }\n log(\"NON-CACHEABLE URI: #{url}\")\n else\n result = true\n end\n result\n end",
"def fetch_needed?\n self.fetched_at.nil? or self.fetched_at < CONFIG[:page][:refetch_interval].seconds.ago\n end",
"def do_http_cache?\n resources.flatten.select do |resource|\n resource.respond_to?(:updated_at)\n end &&\n controller.response.last_modified.nil? && !new_record?\n end",
"def cacheable?\n true\n end",
"def is_query? ; !metadata[:ref] ; end",
"def cache?(key)\n auth_objects_cache.key? key\n end",
"def has_element?(query)\n if @hash_cache && query.kind_of?(Symbol)\n return @hash_cache.has_key? query.to_s\n end\n !find_first(query).nil?\n end",
"def cache?\n persisted?\n end",
"def cache_enabled?(opts)\n # only gets ever get cached\n return false unless opts[:method] == :get\n return false if opts[:cache_key].nil?\n return false unless Tml.cache.enabled?\n true\n end",
"def is_cached_entity?\n # Set in initialize via marshal_load\n @loaded_from_cache\n end",
"def cached?(key)\n if @cache.key?(key)\n _data, _expire = *cache_read(key)\n return true if _expire.nil? || Time.now < _expire\n expire(key)\n end\n false\n end",
"def query?\n !qr?\n end",
"def cacheable?(env)\n if (url = request_url(env)).blank? # NOTE: 0% coverage for this case\n log(\"NO URI for request #{env.inspect}\")\n elsif @cacheable_paths&.none? { |path| url.include?(path) }\n log(\"NON-CACHEABLE URI: #{url}\")\n elsif env&.body && env.body.include?('\"jump_request\"') # NOTE: 0% coverage for this case\n log(\"NON-CACHEABLE URI (jump_request): #{url}\")\n else\n true\n end\n end",
"def cache_on?; end",
"def cache_on?; end",
"def cached? *key\n @cache.has_key? key\n end",
"def cached_file?\n Settings.documents.page_cache && File.exists?(cache_file)\n end",
"def record_cached?(id)\n _record_cache.has_key?(id.to_s)\n end",
"def cache_exists?\n File.exist?(cached_file)\n end",
"def leaked_request?\n !CacheUpdater.executing?\n end",
"def is_in_cache(var)\n Rails.cache.exist?(var)\nend",
"def exists?(cache_key)\n @pg.exec_prepared(@exists_statement_name, [object_to_cache_key(cache_key)]).ntuples.eql?(1)\n end",
"def using_local_cache?\n @use_local_cache == true\n end",
"def has_key?(key)\n @cache.has_key?(key)\n end",
"def should_fetch?\n last_fetched_at.nil? or !fetched_directly? or facebook_api_error.present?\n end",
"def cache_valid?(uri)\n last = last_cached(uri)\n (last > 0 && Time.now.to_i <= (last + @options[:expires_after].to_i))\n end",
"def read_from_cache?\n raise NotImplementedError, \"You must implement #{self.class}##{__method__}\"\n end",
"def custom_query?\n !custom_query.blank?\n end",
"def cache_table_exists?\n @pg.exec(%{SELECT 1 FROM pg_class WHERE pg_class.relname = '#{@table_name}';}).ntuples.eql?(1)\n end",
"def cache_filled?\n !!@cache[:header] && !!@cache[:footer]\n end",
"def use_cache?(opts = {})\n return true if opts[:cache].nil?\n opts[:cache]\n end",
"def needs_db_query?(search)\n search[:author_id].present? || search[:include_closed] == true\n end",
"def data_query_exists?\n # TODO: add_data_query.php says: \"If the data query was already associated, it will be reindexed\"\n # we may need to figure it out somehow to avoid reindexes.\n #\n # use --check patch: returns true if data query does not exist, returns false if data query exists\n # will raise exception, when option not supported\n r = add_data_query(params + ' --check')\n !r\nrescue\n false\nend",
"def cacheable?(response)\n return false unless response.success?\n return false unless method.in? CACHEABLE_METHODS\n return false if header.cache_control && header.cache_control.include?('no-store')\n true\n end",
"def performing_caching?\n @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching\n end",
"def exists_with_identity_cache?(id)\n !!fetch_by_id(id)\n end",
"def cached_size?\n false\n end",
"def check_query\n self.query\n end",
"def existe_cache?(recurso)\n if Rails.cache.exist?(\"#{recurso}_#{id}\")\n cache = Rails.cache.read(\"#{recurso}_#{id}\")\n\n begin\n (cache[:created_at] + cache[:expires_in]) > Time.now.to_f\n rescue\n false\n end\n\n else\n false\n end\n end",
"def consider_caching?(path)\n return false if self.disabled\n return true if self.except.blank? && self.only.blank?\n return false if list_match?(self.except, path)\n return true if self.only.blank?\n return true if list_match?(self.only, path)\n false\n end",
"def may_cache?\n may_cache_field?(headers['cache-control'])\n end",
"def should_cache?\n ctrait = controller.trait\n\n [ Global.cache_all,\n ctrait[:cache_all],\n actions_cached.map{|k,v| k.to_s}.include?(method),\n ].any?\n end",
"def new_cache_needed?\n uses_slug_cache? && slug? && send(friendly_id_config.cache_column) != slug.to_friendly_id\n end",
"def new_cache_needed?\n uses_slug_cache? && slug? && send(friendly_id_config.cache_column) != slug.to_friendly_id\n end",
"def new_cache_needed?\n uses_slug_cache? && slug? && send(friendly_id_config.cache_column) != slug.to_friendly_id\n end",
"def cached?\n Dir.exist?(cached_repo_path)\n end",
"def cache_hit?(client)\n expanded_path = cache_path_for(client.resource)\n return false unless expanded_path\n # this covers permissions and the file actually existing on disk\n return false unless File.readable?(expanded_path)\n # return true if this is a regular file (eg: not a directory)\n return expanded_path if File.file?(expanded_path)\n end",
"def cache_column?\n false\n end",
"def allow_page_to_be_cached?\n return !(agent_logged_in? or current_user.is_admin?)\n end",
"def cache_exist?\n File.exist?(@cache_file)\n end",
"def cacheable?\n return false unless CACHEABLE_RESPONSE_CODES.include?(status)\n return false if cache_control.no_store? || cache_control.private?\n validateable? || fresh?\n end",
"def response_publicly_cached?\n !!(response.cache_control[:public])\n end",
"def data_loaded?\n get_query_params.length > 0\n end",
"def template_cache_configured?\n if defined?(Rails)\n defined?(ActionController::Base) && ActionController::Base.perform_caching\n else\n Rabl.configuration.perform_caching\n end\n end",
"def supports_statement_cache?\n true\n end",
"def supports_statement_cache?\n true\n end",
"def cache_refresh_needed()\n\n refresh_needed = false\n reason = \"\"\n subscription_cache_filename = File.dirname(__FILE__) + \"/\" + SUB_CACHE\n workspace_cache_filename = File.dirname(__FILE__) + \"/\" + WORKSPACE_CACHE\n project_cache_filename = File.dirname(__FILE__) + \"/\" + PROJECT_CACHE\n\n if !FileTest.exist?(subscription_cache_filename) ||\n !FileTest.exist?(workspace_cache_filename) ||\n !FileTest.exist?(project_cache_filename) then\n refresh_needed = true\n reason = \"One or more cache files is not found.\"\n return refresh_needed, reason\n end\n\n cache_age = get_cache_age()\n if cache_age > @max_cache_age then\n refresh_needed = true\n reason = \"Age of workspace/project cache is greater than specified max of #{@max_cache_age}\"\n return refresh_needed, reason\n end\n\n read_subscription_cache()\n cached_subscription_id = @cached_sub_id\n current_subscription_id = get_current_sub_id()\n\n if current_subscription_id != cached_subscription_id then\n refresh_needed = true\n reason = \"Specified SubID: #{current_subscription_id} is different from cached SubID: #{cached_subscription_id}\"\n return refresh_needed, reason\n end\n\n # If we've fallen through to here, no refresh is needed\n reason = \"No workspace/project cache refresh currently required\"\n return refresh_needed, reason\n end",
"def cached_write?\n !@used.any?\n end",
"def page_cached?(page = 1)\n cached_pages.include? page.to_s\n end",
"def matches?(block)\n block.call\n return ActionController::Base.cached?(@url)\n end",
"def cache_warmed?\n Rails.cache.fetch(PHOTOGRAPHY_CACHE_WARMED_KEY)\n end",
"def check_cache(type, id)\n end",
"def check_cache(type, id)\n end",
"def check_cache(type, id)\n end",
"def cache?\n self.inherited_groups.empty?\n end"
] | [
"0.7950755",
"0.7498267",
"0.7498267",
"0.7152269",
"0.71322614",
"0.7100893",
"0.7083884",
"0.7044111",
"0.7023682",
"0.70094377",
"0.699825",
"0.699825",
"0.6856534",
"0.6852669",
"0.6840964",
"0.68393874",
"0.68295044",
"0.6794054",
"0.6732888",
"0.6723752",
"0.6717033",
"0.67105824",
"0.66873163",
"0.66819423",
"0.66741854",
"0.66686755",
"0.6658672",
"0.6637483",
"0.662538",
"0.6599716",
"0.6596849",
"0.65780073",
"0.65677595",
"0.6567623",
"0.654793",
"0.65165293",
"0.65165293",
"0.65049446",
"0.6449674",
"0.6438006",
"0.6428866",
"0.63715535",
"0.6371468",
"0.629174",
"0.62907183",
"0.62892014",
"0.62890273",
"0.6267798",
"0.6261476",
"0.62590986",
"0.62590986",
"0.62215126",
"0.6219718",
"0.6205896",
"0.6177488",
"0.61717814",
"0.61685526",
"0.615584",
"0.61556953",
"0.61405134",
"0.6133264",
"0.61307156",
"0.61233306",
"0.6121797",
"0.6110254",
"0.61092126",
"0.6100097",
"0.60986096",
"0.6087123",
"0.6078379",
"0.6077355",
"0.6069287",
"0.60613716",
"0.60572255",
"0.6041878",
"0.60382944",
"0.60337913",
"0.6022221",
"0.60211945",
"0.60211945",
"0.60211945",
"0.60144687",
"0.60052246",
"0.59996504",
"0.59801847",
"0.59701616",
"0.5969477",
"0.5949458",
"0.5948526",
"0.5936992",
"0.59249765",
"0.59249765",
"0.5913781",
"0.59102744",
"0.59043485",
"0.59029853",
"0.58908856",
"0.5866611",
"0.5866611",
"0.58398116",
"0.58211803"
] | 0.0 | -1 |
Checke if it is possible to authenticate | def authenticated?
return true if @client.folders.count
rescue Viewpoint::EWS::Errors::UnauthorizedResponseError
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_for_authentication?; end",
"def valid_for_authentication?; end",
"def authenticate\n \t\tlogged_in? || access_denied\n \tend",
"def authenticate?\n @authentication_required\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def valid_for_http_auth?; end",
"def authenticate\n self.get && true\n end",
"def authok?\n @connection.authok\n end",
"def authok?\n @connection.authok\n end",
"def authok?\n @connection.authok\n end",
"def auth?\n true\n end",
"def authenticate\n\t\t\tlogged_in? ? true : access_denied\n\t\tend",
"def authok?\n @connection.authok\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def check_authentication\n authenticate_user\n end",
"def auth_ok?(username, password)\n username_present?(username) && password_ok?(username, password)\n end",
"def auth?\n false\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 authentication_successful?\n current_user.present?\n end",
"def api_auth_success?\n token, token_options = get_token\n\n resource = nil\n resource = User.find_by_authentication_token(token) unless token.blank?\n\n comparison = valid_token_login?(resource, token)\n\n # token, resource, and comparison must all be valid\n !token.blank? && !resource.blank? && comparison\n end",
"def authenticate\n \tlogged_in? ? true : access_denied\n end",
"def authenticate\n\tlogged_in? ? true : access_denied \n end",
"def authenticate\n\t logged_in? ? true : access_denied\n\tend",
"def capable_login_auth?; end",
"def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end",
"def valid_http_auth?\n controller.authenticate_with_http_basic do |login, password|\n if !login.blank? && !password.blank?\n send(\"#{login_field}=\", login)\n send(\"#{password_field}=\", password)\n return valid?\n end\n end\n \n false\n end",
"def is_authenticated?\n end",
"def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end",
"def authenticate!\n # Do nothing yet\n end",
"def authenticate\n RestClient.post @apiurl + \"authenticate\", \n :username => @username, \n :password => @password\n rescue RestClient::RequestFailed\n handle_error($!)\n return false\n end",
"def authenticate!\n not_authorized() unless logged_in?()\n end",
"def authenticate(password)\n true\n end",
"def authenticate\n klass.new(request).authenticate == true\n end",
"def authenticated?\n false\n end",
"def authenticates?\n !!@authenticates\n end",
"def authenticate\n authorize || unauthorized\n end",
"def authenticate\n logged_in? ? true : access_denied\nend",
"def authenticated?\n true\n end",
"def should_authenticate?(env)\n @config['should_authenticate_check'] ? @config['should_authenticate_check'].call(env) : true\n end",
"def auth_provided?\n !username.nil? && !password.nil?\n end",
"def authenticate\n begin \n # TODO No data required to authenticate, send a nil string? hacky\n # TODO should retry if a http connection failed\n return @authenticated if @authenticated\n authenticated = call_remote(:authenticate, \"\")\n @authenticated = authenticated =~ /true/\n rescue \n @authenticated = false\n ensure\n return @authenticated\n end\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def check_authentication\n # If path not define then we must be in an isolated engine. In that\n # case security doesn't apply (it does say it wants to be isolated).\n return unless respond_to? :login_url\n\n raise Logmein::NotAuthenticated unless\n is_public_action? || authenticated_record\n end",
"def needs_login?() false end",
"def authenticating?\n username || password\n end",
"def check_auth(request, response)\n # Get the value of the authorization header, and reject the request if it isn't present:\n authorization = request['Authorization']\n if authorization.nil?\n response.status = 401\n response.body = \"The 'Authorization' header is required\"\n return false\n end\n\n # Extract the authorization scheme and token from the authorization header:\n match = /^(?<scheme>Basic|Bearer)\\s+(?<token>.*)$/i.match(authorization)\n unless match\n response.status = 401\n response.body = \"The 'Authorization' doesn't match the expected regular expression\"\n return false\n end\n scheme = match[:scheme]\n token = match[:token]\n\n # Check the token:\n case scheme.downcase\n when 'basic'\n return false unless check_basic_token(response, token)\n when 'bearer'\n return false unless check_bearer_token(response, token)\n else\n response.status = 401\n response.body = \"The authentication scheme '#{scheme} isn't supported\"\n return false\n end\n\n # If we are here then authentication was successful:\n true\n end",
"def authenticate!\n current_user ? true : raise(Pundit::NotAuthorizedError)\n end",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def authenticate(username, password)\n true\n end",
"def authentication_set?\n !@username.nil? && !@password.nil?\n end",
"def authenticate?\n @api_options.has_key?(:authenticate?) ? @api_options[:authenticate?] : !Fleakr.token.blank?\n end",
"def authenticate()\n token = session[:token]\n redirect_to login_prompt_path if token.nil?\n return !token.nil?\n end",
"def authenticate()\n token = session[:token]\n redirect_to login_prompt_path if token.nil?\n return !token.nil?\n end",
"def force_authn?\n force_authn == true\n end",
"def authentication_response_status\n authenticate_user.success? ? :ok : :unauthorized\n end",
"def correct_credentials?\n correct_username = 'admin'\n correct_password = 'admin'\n input_username = @request.params['username']\n input_password = @request.params['password']\n correct_username == input_username && correct_password == input_password\n end",
"def authenticate_if_needed\n # Disable this extra authentication in test mode\n return true if Rails.env.test?\n if (is_hidden || is_staging) && !is_api_or_pdf\n authenticate_or_request_with_http_basic do |username, password|\n username == \"samvera\" && password == \"hyku\"\n end\n end\n end",
"def user_authenticated?\n basic_authenticated? || token_authenticated?\n end",
"def authenticate\n end",
"def authenticated?\n response = institutions\n case response.code\n when 401\n false\n else\n true\n end\n end",
"def authenticated?\n false if @password.nil?\n @client.authenticated?(@username, @password)\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n user = ENV[\"HTTP_USER\"]\n pass = ENV[\"HTTP_PASS\"]\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]\n end",
"def authenticate\n \n authenticate_token || render_unauthorized\n end",
"def verify_credentials\n if auth_supplied?\n response = get \"account/verify_credentials\"\n response.ok? ? response : false\n else\n false\n end\n end",
"def authenticate\n# byebug\n return true if public_action?\n if request.format.json?\n authenticate_token || render_json_unauthorized\n else\n authenticate_user!\n end\n end",
"def authenticate\n token = session[:token]\n redirect_to login_prompt_path if token.nil?\n return !token.nil?\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\n authorized? || access_denied\n end",
"def login_required\n authorized? || access_denied\n end",
"def authenticating_via_oauth_server?\n attempted_record.nil? && errors.empty? && super\n end",
"def authentication_ok?(token_verify_path)\n return false unless token\n return false unless token['access_token']\n return false unless token_verify_path\n\n final_path = token_verify_path.gsub(/\\:access\\_token/, token['access_token'])\n debug { \"Requesting user info from #{final_path}\" }\n request(path: final_path)\n true\n rescue => ex\n error { \"Authentication verification exception\" }\n error { ex }\n false\n end",
"def authorized?\n auth_config = settings.config['authentication']\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [auth_config['username'], auth_config['password']]\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? &&\n @auth.basic? &&\n @auth.credentials &&\n check(@auth.credentials)\n end",
"def test_login\n if @auth!='' then\n result = do_request(json_obj('user.checkauth',\n {'sessionid'=>@auth}))\n if !result['result'] then\n @auth=''\n return false #auth hash bad\n end\n return true #auth hash good\n else\n return false\n end\n end",
"def valid_for_authentication?\n block_given? ? yield : true\n end",
"def authenticate\n response = request('authenticate', nil)\n # A failure to authenticate returns a nil response.\n if response.nil? || response.empty?\n return false\n else\n @session = response\n return true\n end\n end",
"def checkauth\n raise ZbxAPI_ExceptionBadAuth, 'Not logged in' if !loggedin?\n end",
"def credentials?(uri, challenges); end",
"def resource_valid_for_authentication?\n @resource.respond_to?(:valid_for_authentication?) && @resource.valid_for_authentication? { valid_password? }\n end",
"def authenticate_user\n if current_user\n true\n else\n raise Exceptions::AuthorizationError.new('invalid user authorization')\n end\n end",
"def authenticate\n unless session[:loggedin]\n redirect_to :action => 'login'\n return false\n end\n return true\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authentication_successful?\n @user.present?\n end",
"def authenticate\n unauthorized unless current_user\n end",
"def verify_access\n authenticate_or_request_with_http_basic(\"Documents Realm\") do |username, password|\n username == 'rdi' && password == 'btc'\n end\n end",
"def http_authenticatable?; end",
"def authenticate password\n if self.password == password\n true\n else\n false\n end\n end",
"def authenticate_user?\n !current_user.nil?\n end",
"def validate_credentials(options = {})\n !self.class.new(options).user.nil?\n rescue Nearmiss::Unauthorized\n false\n end",
"def authenticate(attempted_password)\n if self.password == attempted_password\n true\n else\n false\n end\n end",
"def authenticate(attempted_password)\n if self.password == attempted_password\n true\n else\n false\n end\n end"
] | [
"0.79316914",
"0.79316914",
"0.7699964",
"0.7663511",
"0.7633985",
"0.7633985",
"0.7633985",
"0.7633985",
"0.76204276",
"0.7590559",
"0.75862694",
"0.7558347",
"0.7537479",
"0.7537479",
"0.7537479",
"0.7490932",
"0.7490799",
"0.74906796",
"0.74735194",
"0.7409206",
"0.7409206",
"0.737796",
"0.7365319",
"0.7363539",
"0.73551154",
"0.73545784",
"0.7346415",
"0.73328334",
"0.7332408",
"0.7319635",
"0.73120886",
"0.7302768",
"0.72835535",
"0.7261582",
"0.7216635",
"0.71960896",
"0.7183068",
"0.7171152",
"0.7168183",
"0.71334034",
"0.7103872",
"0.7101269",
"0.70937264",
"0.70899045",
"0.708688",
"0.70808053",
"0.70761096",
"0.70662576",
"0.70661104",
"0.7054136",
"0.70496815",
"0.70440763",
"0.70436335",
"0.70431495",
"0.7042236",
"0.70320565",
"0.70320565",
"0.7027352",
"0.7025956",
"0.7008831",
"0.7007224",
"0.7007224",
"0.7006756",
"0.6999258",
"0.69930667",
"0.6978439",
"0.69720805",
"0.69639355",
"0.6960676",
"0.69564664",
"0.6934878",
"0.69328326",
"0.6929569",
"0.6929294",
"0.69170517",
"0.69140065",
"0.6912797",
"0.6912797",
"0.6912797",
"0.6909037",
"0.69085294",
"0.6908278",
"0.6906038",
"0.6900786",
"0.6898263",
"0.68970096",
"0.6895981",
"0.68800926",
"0.68797016",
"0.6877115",
"0.68587863",
"0.6853676",
"0.68377006",
"0.68358487",
"0.6835335",
"0.68306655",
"0.68274385",
"0.6826616",
"0.68245167",
"0.68165106",
"0.68165106"
] | 0.0 | -1 |
each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place? | def rotate matrix
min = 0;
max = matrix.length-1
while min < max and max >= matrix.length/2
dif = 0
while min + dif < max
t1 = matrix[min][min+dif]
t2 = matrix[min+dif][max]
t3 = matrix[max][max-dif]
t4 = matrix[max-dif][min]
matrix[min][min+dif] = t4
matrix[min+dif][max] = t1
matrix[max][max-dif] = t2
matrix[max-dif][min] = t3
dif += 1
end
min += 1
max -= 1
end
matrix
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generic_rotate90(image)\n # Rotates a square image 90 degrees clockwise.\n d = image.length\n new_image = d.times.map { \"x\"*d }\n (0...d).each do |r|\n (0...d).each do |c|\n new_image[c][d-1-r] = image[r][c]\n end\n end\n new_image\nend",
"def rotate_image(image)\n\nend",
"def rotated_90_cw\n dst = Image.new(width: height, height: width, bpp: bpp)\n each_pixel do |c,x,y|\n dst[y,width-x-1] = c\n end\n dst\n end",
"def rotateAndFlip(image)\n return image.transpose.flip\nend",
"def rotate_picture(picture)\n (0...$PICTURE_SIZE).map do |i|\n ((0...$PICTURE_SIZE).map do |j|\n picture[j].chars[$PICTURE_SIZE - 1 - i]\n end).join\n end\nend",
"def RotateMatrix (squareImg)\n r = squareImg.size - 1\n c = squareImg[0].size - 1\n\n (0..r/2).each do |row|\n (0..c/2).each do |col|\n\nsquareImg[row][col], squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col] = squareImg[r - row][col], squareImg[r-row][c-col], squareImg[row][c-col], squareImg[row][col]\n\n\n end\n end\nsquareImg\nend",
"def rotate_180!\n pixels.reverse!\n self\n end",
"def rotate\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.rotate(90)\n img.write('public' + @photo.attachment_url)\n end",
"def rotate\n @angle += Math::PI / 16\n @angle = @angle % (Math::PI * 2)\n end",
"def rotated\n RawImage.new(@image.getRotated())\n end",
"def rotate(image)\n # image is a 2 dimentional array like [[1,2,3],[4,5,6], [7,8,9]]\n array = []\n cols = image[0].size\n image.size.times do \n array << Array.new(cols)\n end\n\n image.each_with_index do |rows_array, row|\n rows_array.each_with_index do |element, col|\n array[col][row] = element\n end\n end\n\n array\nend",
"def rotate_matrix(array)\n\n\nend",
"def rotate_image(arr)\n last_index = arr.size - 1\n\n # i will essentially act as our layer\n i = 0\n while i < (arr.size / 2)\n \n # column index, j, which should always start at the same index as the layer\n # to avoid moving outer-layer elements\n j = i\n\n # this makes sure j never iterates over the last element in the layer, because\n # it will have already been rotated from the first rotation in that layer\n # NOTE: this mistake can best be shown in a 5x5 or larger, if we forgot this\n layer_offset = last_index - i\n\n while j < (layer_offset) # last_index = arr[i].size - 1 because the array is square\n # debugger\n\n # store the value in the top row\n stored = arr[i][j]\n\n # rotate left to top\n arr[i][j] = arr[last_index - j][i]\n\n # rotate bottom to left\n arr[last_index - j][i] = arr[layer_offset][last_index - j]\n\n # rotate right to bottom\n arr[layer_offset][last_index - j] = arr[j][layer_offset]\n\n # rotate top to right by replacing right with stored\n arr[j][layer_offset] = stored\n\n j += 1\n end\n \n i += 1\n end\n\n # The submission code shouldn't include this, this is just to visualize the result\n p \"#{arr.size}x#{arr.size} Rotated Matrix\"\n arr.each do |row|\n p row\n end\nend",
"def rotate(arr)\n\nend",
"def rotate_matrix(image_matrix)\n reverse_matrix = image_matrix.reverse\n rotated_matrix = []\n (0...image_matrix.length).each do |i|\n col = reverse_matrix.map { |row| row[i] }\n rotated_matrix[i] = col\n end\n rotated_matrix\nend",
"def rotate_90(array)\n a = copy array\n a.transpose.map { |e| e.reverse }\nend",
"def rotate_matrix(arr)\n\nend",
"def rotate_right!\n @picture.rotate_right!\n end",
"def rotate(angle_or_direction)\n case angle_or_direction\n when :left\n radian = -90.degrees\n when :right\n radian = 90.degrees\n when :flip\n radian = 180.degrees\n when Numeric\n radian = angle_or_direction\n else\n raise \"Unknown angle/direction #{angle_or_direction.inspect}\"\n end\n\n w = (self.size.width * Math.cos(radian)).abs + (self.size.height * Math.sin(radian)).abs\n h = (self.size.height * Math.cos(radian)).abs + (self.size.width * Math.sin(radian)).abs\n new_size = CGSize.new(w, h)\n new_size = self.size\n\n # Create the bitmap context\n UIGraphicsBeginImageContext(new_size)\n bitmap = UIGraphicsGetCurrentContext()\n\n # Move the origin to the middle of the image so we will rotate and scale around the center.\n CGContextTranslateCTM(bitmap, new_size.width / 2, new_size.height / 2)\n\n # Rotate the image context\n CGContextRotateCTM(bitmap, radian)\n\n # otherwise it'll be upside down:\n CGContextScaleCTM(bitmap, 1.0, -1.0)\n # Now, draw the rotated/scaled image into the context\n CGContextDrawImage(bitmap, CGRectMake(-new_size.width / 2, -new_size.height / 2, new_size.width, new_size.height), self.CGImage)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n return new_image\n end",
"def rotate!(angle, axis_x = width / 2.0, axis_y = height / 2.0)\n ptr = self.class.create_image_ptr(width, height, alpha_blending?)\n ::GD2::GD2FFI.send(:gdImageCopyRotated, ptr, image_ptr, axis_x.to_f, axis_y.to_f, 0, 0, width.to_i, height.to_i, angle.to_degrees.round.to_i)\n init_with_image(ptr)\n end",
"def rotate(angle_or_direction)\n case angle_or_direction\n when :left\n radian = -90.degrees\n when :right\n radian = 90.degrees\n when :flip\n radian = 180.degrees\n when Numeric\n radian = angle_or_direction\n else\n raise \"Unknown angle/direction #{angle_or_direction.inspect}\"\n end\n\n w = (self.size.width * Math.cos(radian)).abs + (self.size.height * Math.sin(radian)).abs\n h = (self.size.height * Math.cos(radian)).abs + (self.size.width * Math.sin(radian)).abs\n new_size = CGSize.new(w, h)\n new_size = self.size\n\n # Create the bitmap context\n UIGraphicsBeginImageContextWithOptions(new_size, false, self.scale)\n bitmap = UIGraphicsGetCurrentContext()\n\n # Move the origin to the middle of the image so we will rotate and scale around the center.\n CGContextTranslateCTM(bitmap, new_size.width / 2, new_size.height / 2)\n\n # Rotate the image context\n CGContextRotateCTM(bitmap, radian)\n\n # otherwise it'll be upside down:\n CGContextScaleCTM(bitmap, 1.0, -1.0)\n # Now, draw the rotated/scaled image into the context\n CGContextDrawImage(bitmap, CGRectMake(-new_size.width / 2, -new_size.height / 2, new_size.width, new_size.height), self.CGImage)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n return new_image\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def rotate90(matrix, degrees = 90)\n rotated = matrix\n (degrees / 90).times { rotated = rotated.transpose.map(&:reverse) }\n rotated\nend",
"def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend",
"def rotate(angle, around_x=0, around_y=0, &rendering_code); end",
"def rotate(matrix, degrees)\n rotations = degrees / 90 % 4\n return matrix if rotations == 0\n new_matrix = rotate90(matrix)\n count = 1\n while count < rotations\n new_matrix = rotate90(new_matrix)\n count += 1\n end\n new_matrix\nend",
"def rotate angle\n position = \"#{@placement[:s]}x#{@placement[:s]}+#{@placement[:x]}+#{@placement[:y]}\"\n @image.run_command(\"convert\", @image.path, \"-rotate #{360 - angle}\", @image.path)\n @image.run_command(\"convert\", @image.path, \"-gravity Center -crop #{position}\", @image.path)\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def rotate_left!\n @picture.rotate_left!\n end",
"def rotate\n new_contents = (0...$TILE_SIZE).map do |i|\n ((0...$TILE_SIZE).map do |j|\n @contents[j].chars[$TILE_SIZE - 1 - i]\n end).join\n end\n Tile.new(@tile_id, new_contents)\n end",
"def rotate( deg )\n set_base_image( base_image.rotate( deg ) )\n end",
"def rotate(matrix, degrees)\n rotations = degrees/90\n new_matrix = matrix.dup\n rotations.times do\n new_matrix = rotate90(new_matrix)\n end\n new_matrix\nend",
"def zrotation\n end",
"def rot90\n rot :d90\n end",
"def rotate_right!\n new_pixels = []\n 0.upto(width - 1) { |i| new_pixels += column(i).reverse }\n replace_canvas!(height, width, new_pixels)\n end",
"def my_rotate!(array, amt)\n\nend",
"def rotate_matrix(arr)\n flipped_array = [] # initialize empty array\n transposed_arr = my_transpose(arr) # flip the rows with columns inside using a transpose method\n transposed_arr.each { |row| flipped_array << row.reverse } # once we reverse the new rows, it goes from 45 to 90 degrees rotation\n flipped_array\nend",
"def my_rotate(arr)\n print arr.rotate\n end",
"def rotate90(matrix)\n size = matrix.first.size\n matrix.each_with_object(Array.new(size) {[]}) do |arr, new_arr|\n arr.each_with_index do |el, idx|\n new_arr[idx].unshift el\n end\n end\nend",
"def r90; self.rotation = 'fa-rotate-90'; self; end",
"def rotate(degrees)\n rsp = @flickr.send_request('flickr.photos.transform.rotate', {:photo_id => self.id, :degrees => degrees}, :post)\n true\n end",
"def rotate!\n @grid = @grid.transpose.map{|c| c.reverse}\n end",
"def rotate image, angle, outimage=nil\n m_begin \"rotate\"\n img = get_image(image)\n if false\n rotated = img.rotate(angle)\n else\n#\n# from newsgroup: The alternative way to rotate is to use -filter point +distort SRT {angle} +repage\n#\n rotated = img.resize(img.columns, img.rows, PointFilter)\n rotated = img.distort(ScaleRotateTranslateDistortion, [angle])\n end\n outimage = image if outimage.nil?\n put_image(outimage, rotated)\n m_end \"rotate\"\n end",
"def draw\n @image.draw_rot(@x, @y, 1, @angle)\n end",
"def rotate_matrix(len, mtx)\n (0..(len / 2)).each do |layer|\n first = layer\n last = len - 1 - layer\n (first..last - 1).each do |i|\n top = mtx[first][i]\n mtx[first][i] = mtx[last - i][first] # TOP <-- LEFT\n mtx[last - i][first] = mtx[last][last - i] # LEFT <-- BOTTOM\n mtx[last][last - i] = mtx[i][last] # BOTTOM <-- RIGHT\n mtx[i][last] = top\n end\n end\n mtx\nend",
"def apply_rotation\n if @rotation_block != nil\n (1..@rotation.modulo(@rotation_cycle)).each do |i|\n @blocks.each do |block|\n old_x = block.x\n old_y = block.y\n block.x = @rotation_block.x + (@rotation_block.y - old_y)\n block.y = @rotation_block.y - (@rotation_block.x - old_x)\n end\n end\n end\n end",
"def rotate90(matrix)\n new_matrix = Array.new(matrix[0].size) { Array.new }\n matrix.each_with_index do |sub_array, row|\n matrix[0].size.times do |col|\n new_matrix[col][matrix.size - row - 1] = sub_array[col]\n end\n end\n\n new_matrix\nend",
"def transform(row_index,col_index)\n\n if row_index-1 >= 0\n @image[row_index-1][col_index] = 1\n end\n if col_index - 1 >= 0\n @image[row_index][col_index-1] = 1\n end\n if row_index + 1 <= @image.length - 1\n @image[row_index+1][col_index] = 1\n end\n if col_index + 1 <= @image[row_index].length - 1\n @image[row_index][col_index+1] = 1\n end\n\n end",
"def rotate90(original_matrix)\n num_rows = original_matrix[0].length\n num_columns = original_matrix.length\n new_matrix = []\n\n (0..(num_rows - 1)).each do |row|\n inner_array = []\n (num_columns - 1).downto(0).each do |column|\n inner_array.push(original_matrix[column][row])\n end\n new_matrix.push(inner_array)\n end\n new_matrix\nend",
"def rotate\n\t\t\tswap\n\t\t\tpush [:swap]\n\t\t\tdip\n\t\t\tswap\n\t\tend",
"def rotate_without_changing(arr)\n\nend",
"def rotate(input)\n input[1..-1] << input[0]\nend",
"def rotate90(matrix)\n columns = matrix[0].length\n new_matrix = []\n columns.times { new_matrix << [] }\n matrix.each_with_index do |row, ind|\n row.each_with_index do |elem, r_ind|\n new_matrix[r_ind].unshift(elem)\n end\n end\n new_matrix\nend",
"def fix_exif_rotation\n return unless self.file.content_type.start_with? 'image'\n \n manipulate! do |img|\n img.tap(&:auto_orient)\n img = yield(img) if block_given?\n img\n end\n end",
"def rotate!\n @num_rotations = (@num_rotations+1) % NUM_SIDES\n end",
"def transform\n if rotate\n \"rotate(#{rotate},#{x},#{y})\"\n else\n nil\n end\n end",
"def rotate_origo(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\t@rect.each do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, 0, 0, 0, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend",
"def rotate\n g = Grid.new\n self.each do |point,v|\n g[Point.new(point.y,point.x)] = v\n end\n (0..g.height - 1).each do |y|\n ( 0..g.width/2.ceil - 1 ).each do |x|\n tmp = g[Point.new(x,y)]\n g[Point.new(x,y)] = g[Point.new(g.width - x - 1, y )]\n g[Point.new(g.width - x - 1,y)] = tmp\n end\n end\n g\n end",
"def rotate matrix, direction\n direction == 'clockwise' ? matrix.reverse.transpose : matrix.transpose.reverse\nend",
"def transform(operator)\n case operator\n when :rotate_left then operator = \"-90\"\n when :rotate_right then operator = \"+90\"\n when :mirror then operator = \"-h\"\n else\n raise(\"Invalid transform operator: #{operator.inspect}\")\n end\n system(\"script/rotate_image #{id} #{operator}&\") unless Rails.env.test?\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.tap(&:auto_orient)\n end\n end",
"def rotate\n push shift\n end",
"def flip_horizontally!\n @picture.flip_horizontally!\n end",
"def rotate(unrotated)\n return '' if unrotated.empty?\n unrotated[1..-1] + unrotated[0]\nend",
"def array_rotation(arr, num)\n\tarr.rotate(num)\nend",
"def rotate2!\n replace rotate2\n end",
"def imageDeSteg(password, image)\n # Suck in the image\n original_image = Magick::Image.read(image).first\n\n # Initialize the bits array\n bits = []\n\n # For each pixel in the image\n original_image.each_pixel do |pixel, col, row|\n # Set colors to their current value\n red = pixel.red\n green = pixel.green\n blue = pixel.blue\n\n # If the red value for the pixel is odd\n if (red%2 == 1)\n bits << 1\n else\n bits << 0\n end\n\n # If the green value for the pixel is odd\n if (green%2 == 1)\n bits << 1\n else\n bits << 0\n end\n\n # If the blue value for the pixel is odd\n if (blue%2 == 1)\n bits << 1\n else\n bits << 0\n end\n end\n\n # Initialize the encrypted_length_bits\n encrypted_length_bits = \"\"\n\n # For the first 256 characters in the array\n for counter in (0..255)\n # Append the value to the encrypted_length_bits\n encrypted_length_bits = encrypted_length_bits + bits[counter].to_s()\n end\n\n # Convert the binary encrypted length bits to a string\n encrypted_length = Stegg.convertBinaryToString(encrypted_length_bits)\n\n # Decrypt the encrypted length\n cipher = Gibberish::AES.new(password)\n length = cipher.decrypt(encrypted_length, :binary => true)\n\n # Initialize the encrypted_data_bits\n encrypted_data_bits = \"\"\n\n # Data starts at 256 and goes through the length\n last_bit = 255 + length.to_i()\n \n # For character 256 through the last bit\n for counter in (256..last_bit)\n # Append the value to the encrypted_data_bits\n encrypted_data_bits = encrypted_data_bits + bits[counter].to_s()\n end\n\n # Convert the binary encrypted data bits to a string\n encrypted_data = Stegg.convertBinaryToString(encrypted_data_bits)\n\n # Decrypt the encrypted data\n data = cipher.decrypt(encrypted_data, :binary => true)\n\n # Return the data\n return data\n end",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def auto_orient\n \tmanipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def rotate_deg( angle_deg )\n dup.rotate_deg!( angle_deg )\n end",
"def mirror_angle_horizontally!\n @angle = (-@angle) % 360\n end",
"def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end",
"def rotateRight()\n twoTypeRotate()\n end",
"def print_array(arr)\n print(\"Rotated array is: \" + arr.join(\", \") + \"\\n\")\n return\nend",
"def rotate_x\n x = @x.content\n z = Array.new @z.length, 0\n\n @z.length.times { |i| z[i] = x[(i - 1) % @z.length] }\n\n @z.content = z\n end",
"def rotate(x,y,theta)\n [x*-1*Math.cos(theta) + y*Math.sin(theta), x*-1*Math.sin(theta) + y*-1*Math.cos(theta)]\n end",
"def rotate(matrix, direction)\n if direction == \"clockwise\"\n matrix.transpose.map{|i| i.reverse}\n else\n rotated = []\n matrix.transpose.map{|i| i.reverse}.flatten.reverse.each_slice(matrix.size){\n |a| rotated << a}\n rotated\n end\nend",
"def getOrientation(row, col)\n case (@orientation_index)\n when 0\n return [\n Block.new(row, col),\n Block.new(row, col - 1),\n Block.new(row, col + 1),\n Block.new(row + 1, col + 1)\n ]\n when 1\n return [\n Block.new(row, col),\n Block.new(row + 1, col - 1),\n Block.new(row + 1, col),\n Block.new(row - 1, col)\n ]\n when 2\n return [\n Block.new(row, col),\n Block.new(row, col - 1),\n Block.new(row - 1, col - 1),\n Block.new(row, col + 1)\n ]\n when 3\n return [\n Block.new(row, col),\n Block.new(row + 1, col),\n Block.new(row - 1, col),\n Block.new(row - 1, col + 1)\n ]\n else\n abort('No such rotation orientation')\n end\n end",
"def rotate_matrix(image, direction=:right)\n 0..(image.length / 2 - 1) do |i|\n ((0 + i)..(image.length - 1 - i)).each do |j|\n ij0 = rotate_destination([i, j], direction)\n ij1 = rotate_destination(ij0, direction)\n ij2 = rotate_destination(ij0, direction)\n \n register = image[ij0[0]]][ij0[1]]\n image[ij0[0]][ij0[1]] = image[i][j]\n image[i][j] = image[ij2[0]]][ij2[1]]\n image[ij2[0]][ij3[1]] = image[ij1[0]]][ij1[1]]\n image[ij1[0]][ij1[1]] = register\n end\n end",
"def rot270\n rot :d270\n end",
"def rotate_array(array)\n array[1, array.size] << array[0]\nend",
"def rotate_ninety_degs(array,direction='clockwise')\n if direction == 'clockwise'\n return array.transpose.reverse\n else\n return array.transpose.each{|x| x.reverse!}\n end\nend",
"def rot #@\n a = pop\n b = pop\n c = pop\n push a\n push c\n push b\n end",
"def my_rotate(arr, offset=1)\n offset = offset % 4\n arr_take = arr.take(offset)\n arr_drop = arr.drop(offset)\n arr_drop + arr_take\nend",
"def rotate(angle, x, y, &block)\n cur_page.rotate(angle, x, y, &block)\n end",
"def rotate(angle)\n case angle % 360\n when 0 then dup\n when 90 then rotate_cw\n when 180 then rotate_flip\n when 270 then rotate_ccw\n else\n raise RuntimeError, \"unsupported rotation angle #{angle}\"\n end\n end",
"def flip_vertically!\n @picture.flip_vertically!\n end",
"def orient_patch\n rotmat = CVFFI::CvMat.new CVFFI::cvCreateMat( 2,3, :CV_32F )\n CVFFI::cv2DRotationMatrix( CVFFI::CvPoint2D32f.new( [ @patch.width/2.0, @patch.height/2.0 ]), -@angle*180.0/Math::PI, 1.0, rotmat )\n\n dstimg = @patch.twin\n CVFFI::cvWarpAffine( @patch, dstimg, rotmat )\n\n dstimg \n end",
"def rotate(matrix) \n rows, cols = matrix.size, matrix[0].size\n Array.new(cols) {|i| Array.new(rows) {|j| matrix[j][cols - i - 1]}}\n end",
"def rotate_47(input=\"hello world\")\n decode= ''\n ascii=[]\n #converts to ascii\n input.each_byte do |c|\n ascii << c\n end\n\n for i in 0..ascii.length-1\n if ascii[i]>=33 and ascii[i] <=126\n ascii[i]+=47\n if ascii[i]>126\n ascii[i] += -94\n end\n end\n decode << ascii[i].chr\n end\n decode\nend",
"def rotateLeft()\n twoTypeRotate()\n end",
"def checkrotation(filepath)\n\t# rotate if needed - normally these are 300 wide by 419 high\n\timg = Magick::Image.read(filepath).first\n\n\tif(img.columns > img.rows) # too wide so rotate left\n\t\timg.rotate!(-90)\n\t\timg.write(filepath)\n\tend\t\nend",
"def rotate_array(array)\n array[1..-1] + array[0..0]\nend",
"def draw\n if @image.class == Array\n img = @image[@index]\n else\n img = @image\n end\n img.draw_rot(@x, @y, @z, @angle, 0.5, 0.5, @size, @size, alpha_to_color(@alpha), @blending)\n end",
"def rotate_array(array)\n array[1..-1] << array[0]\nend",
"def rotate_deg!( angle_deg )\n self.angle_deg += angle_deg\n self\n end",
"def rotate_array(ar)\n ar[1..-1] << ar[0]\nend",
"def rotate_array(array)\narray[1..-1] + [array[0]]\nend"
] | [
"0.8023993",
"0.76115024",
"0.7385146",
"0.73238415",
"0.6866579",
"0.6862589",
"0.67585313",
"0.6679004",
"0.66644514",
"0.6662985",
"0.66064477",
"0.6573",
"0.648012",
"0.64334476",
"0.6395792",
"0.6378808",
"0.6374994",
"0.6373767",
"0.63570905",
"0.6327556",
"0.63184184",
"0.6311133",
"0.6289579",
"0.6276648",
"0.62757915",
"0.6267555",
"0.6258797",
"0.6250762",
"0.6249244",
"0.62068564",
"0.6192084",
"0.61788726",
"0.6165905",
"0.6162108",
"0.6152356",
"0.6140888",
"0.60985047",
"0.6082646",
"0.6032005",
"0.60061115",
"0.6001942",
"0.5989096",
"0.5986685",
"0.5984656",
"0.59531504",
"0.59228945",
"0.59219587",
"0.59152853",
"0.5873587",
"0.5871186",
"0.58643574",
"0.58628917",
"0.58560836",
"0.584798",
"0.5825961",
"0.58220035",
"0.5809175",
"0.5794322",
"0.57640487",
"0.5762391",
"0.5723988",
"0.5722661",
"0.57096124",
"0.56964844",
"0.5674815",
"0.56632394",
"0.5652906",
"0.5651319",
"0.56461513",
"0.56461513",
"0.56458026",
"0.5642701",
"0.5641777",
"0.5636035",
"0.5605688",
"0.56034476",
"0.56012857",
"0.5599966",
"0.5598676",
"0.55961406",
"0.55957794",
"0.55952764",
"0.5578469",
"0.5566454",
"0.5565674",
"0.55348086",
"0.55296713",
"0.55246174",
"0.5523915",
"0.5521644",
"0.5515623",
"0.551035",
"0.5505896",
"0.5500195",
"0.5497244",
"0.54822737",
"0.54817003",
"0.54745454",
"0.54622895",
"0.54591936"
] | 0.55122894 | 91 |
def expired? self.expired_at < Time.zone.now end | def remove_in_progress_task
$redis.del("#{studio.studio_id}:#{ip}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired?\n Time.now > self.to_be_expired_at\n end",
"def expired?\n DateTime.now.utc >= self.expires_at\n end",
"def expired?\n self.expires_at && Time.now.utc > self.expires_at\n end",
"def expired?\n self.expires_at && Time.now > self.expires_at\n end",
"def expired?\n Time.zone.today > expires_at\n end",
"def expired?\n Time.now.in_time_zone > expires_at\n end",
"def expired?\n expires_at && expires_at <= Time.now\n end",
"def has_expired?\n self.expires_at ? self.expires_at < Time.now.utc : false\n end",
"def has_expired?\n self.expires_at ? self.expires_at < Time.now.utc : false\n end",
"def expired?\n @expires_at <= Time.now\n end",
"def expired?\n expires_at && Time.now > expires_at\n end",
"def expired?(now)\n @expires_at <= now\n end",
"def expired?\n Date.today > self.expires_on\n end",
"def expired?\n Time.current >= expires_at\n end",
"def expired?\n return self.expires_on < Date.today if self.expires_on\n true\n end",
"def expired?\n !respond_to?(:expires_at) || expires_at < Time.current\n end",
"def expired?\n expiration_date <= Time.now\n end",
"def expired?\n expires_at.to_time <= Time.now.utc\n end",
"def expired?\n expires_at.to_time <= Time.now.utc\n end",
"def expired?\n DateTime.now > @expires\n end",
"def expired?\n @expiry_time < Time.now\n end",
"def expired?\n Time.now > @expires\n end",
"def expired?\n self.expires_on? and self.expires_on < Time.now\n end",
"def expired?\n return false unless expires_at\n expires_at < Time.now\n end",
"def expired?\n Time.now > expiration if expiration\n end",
"def not_expired?\n self.expires_at && Time.now <= self.expires_at\n end",
"def expired?\r\n return Time.now > self.created_on + @@validity_time\r\n end",
"def expired?\n Time.now > self.deadline\n end",
"def expired?\n self.expiration.past? || self[:expired]\n end",
"def expired?\n end",
"def expired?\n if expires?\n Time.now >= expires_at\n else\n false\n end\n end",
"def expired?\n @expired\n end",
"def expired?\n !expires_at.nil? && Time.now >= expires_at\n end",
"def expired?\n Time.now > valid_until\n end",
"def expired?\n exp < Time.now.to_i\n end",
"def expired?\n expires? && (expires_at < Time.now.to_i)\n end",
"def expired?\n\n end",
"def expired?\n self.expired = false unless self.deadline > DateTime.now\n end",
"def expired?\n created_at < 14.days.ago && updated_at < 14.days.ago\n end",
"def expired?\n Time.now > @expiration if @expiration\n end",
"def has_not_expired?\n self.expires_at ? self.expires_at > Time.now.utc : true\n end",
"def has_not_expired?\n self.expires_at ? self.expires_at > Time.now.utc : true\n end",
"def expired?\n @expires_in && @created_at + @expires_in <= Time.now.to_f\n end",
"def expired?\n false\n end",
"def expired?\n expires && expires < Time.now\n end",
"def expired?\n expires? && (Time.now > expires_at)\n end",
"def expired?\n can_expire? && @expiry < Time.now.to_i\n end",
"def expired?(now)\n @value.expired?(now: now)\n end",
"def expired?\n !expiration_date || expiration_date <= Date.today\n end",
"def expired?\n return @expired\n end",
"def is_expired?\n self.end_date < DateTime.now\n end",
"def expired?\n can_expire? && (self.expires_in + self.time_created) < Time.now.to_i\n end",
"def expired?\n not valid?\n end",
"def is_expired(datetime=nil)\n unless datetime\n datetime = Time.zone.now\n end\n \n if self.expiration_date < datetime\n return true\n else\n return false\n end\n end",
"def expired?\n return true if expires - Time.now <= 0\n return false\n end",
"def is_expired?\n\t\tself.event_date < DateTime.now\n\tend",
"def expired?\n age > ttl\n end",
"def expired?\n age > ttl\n end",
"def expired?\n !self.active?\n end",
"def expired?\n Time.now - @created_time > @ttl\n end",
"def expired?(expiration_date)\n Date.today.beginning_of_day >= expiration_date.beginning_of_day\n end",
"def expired(payload)\n Time.zone.at(payload['exp']) < Time.zone.now\n end",
"def expired?; end",
"def expired?\n if (self.last_retrieved == nil)\n return true\n elsif (self.time_to_live < 30.minutes)\n return (self.last_retrieved + 30.minutes) < Time.now.gmtime\n else\n return (self.last_retrieved + self.time_to_live) < Time.now.gmtime\n end\n end",
"def expired?(payload)\n Time.at(payload['exp']) < Time.now\n end",
"def expired?\n (Time.now - created_at) > 1.week\n end",
"def expired?\n return if missing?\n\n validity < (reference_time - time)\n end",
"def access_token_expired?\n Time.zone.now >= self.expires_at\n end",
"def access_token_expired?\n Time.zone.now >= self.expires_at\n end",
"def expired?\n Time.now > vendors_expiration\n end",
"def token_expired?\n return true\n expires_at < Time.now if expires_at?\n end",
"def expired?\n overdue_days > 0\n end",
"def is_valid?\n \tDateTime.now < self.expires_at\n end",
"def token_expired?\n self.expires < Time.zone.now.to_i\n end",
"def is_expired?\n (!end_time.nil? and end_time < Clock.time)\n end",
"def expired?\n self.class.ttl_in_seconds && self.class.rates_expiration <= Time.now\n end",
"def time_expired?\n (Time.now - @duration) > @start_time\n end",
"def access_token_expired?\n\t\taccess_token_expires_at && access_token_expires_at < Time.zone.now\n\tend",
"def is_valid?\n DateTime.now < self.expires_at\n end",
"def expired?\n return true if authentication.nil?\n\n authentication.expires_at < 2.days.from_now\n end",
"def expired?\n timestamp.nil? || (Time.now.to_i - timestamp.to_i).abs > 300\n end",
"def expired?\n lifetime_in_days = time_in_seconds(@lifetime)\n @born + lifetime_in_days < DateTime.now\n end",
"def expired?\n # expired_at set (manually, via cron, etc.)\n return expired_at < Time.now.utc unless expired_at.nil?\n\n # if it is not set, check the last activity against configured expire_after time range\n return last_activity_at < self.class.expire_after.ago unless last_activity_at.nil?\n\n # if last_activity_at is nil as well, the user has to be 'fresh' and is therefore not expired\n false\n end",
"def access_token_expired?\n\t\t\t\treturn false if self.expires_at.nil?\n\n\t\t\t\t# Expiration date less than now == expired\n\t\t\t\tself.expires_at < Time.now\n\t\t\tend",
"def expired_time? time\n time + self.class.ttl_in_seconds.to_i < Time.now\n end",
"def expired?\n pledging_ends_on.past?\n end",
"def expired?\n config['expired'] || false\n end",
"def expired?\n if user.where(:username => current_user).where(:expiration_time) < Time.now\n\n end\n end",
"def expired?\n return false if @expires_in.nil?\n @start_time + Rational(@expires_in - @refresh_timeout, 86400) < DateTime.now\n end",
"def is_expired\n if self.status == \"none\" || self.status == \"pending\"\n return false\n else\n return true\n end\n end",
"def has_expired?(user)\n get_due_time(user) < Time.zone.now\n end",
"def active?\n self.expires_on > Date.today\n end",
"def booking_request_expired?\n created_at < 48.hours.ago\n end",
"def is_token_expired?\n (Time.now - self.updated_at) > 3300\n end",
"def access_expired? (time = Time.current)\n access_expires_at && time > access_expires_at\n end",
"def has_expired?(date)\n # The event will expires 2 hours after is date\n Time.parse(date).to_f < Time.now.to_f - 2.hours.to_i\n rescue TypeError\n true\n end",
"def expired?\n !@conn_expires_at || @conn_expires_at < Time.now\n end",
"def expired?(expire_time)\n return false if expire_time.nil? # Assume that expire check is disabled.\n return true unless expire_time.respond_to?(:to_i) # Verify that expire_time can be converted into an integer.\n\n # Checks to see if the expire time will elapse in the next 10 seconds.\n # True if now is greater than expire time. False if now is less than expire time.\n Time.now.to_i >= (expire_time.to_i - 10)\n end",
"def expired?\n conf_item_hold_time = SystemConfiguration::Variable.get_value('booking.item_hold_time', '0').to_i\n hold_time_diff_in_hours = ((DateTime.now.to_time - self.creation_date.to_time).to_f * 24).to_i\n expired = (hold_time_diff_in_hours > conf_item_hold_time)\n expired && !force_allow_payment\n end",
"def request_expired?\n parsed_timestamp < request_expires_at\n end",
"def expired?\n remaining.zero?\n end"
] | [
"0.94687057",
"0.9339752",
"0.9331974",
"0.92763996",
"0.9261029",
"0.92484343",
"0.91663575",
"0.9162526",
"0.9162526",
"0.91552657",
"0.9136963",
"0.91103196",
"0.91047287",
"0.9102409",
"0.9101769",
"0.90909016",
"0.9074122",
"0.9056781",
"0.9056781",
"0.90451163",
"0.900874",
"0.90047455",
"0.9004705",
"0.8996454",
"0.8972266",
"0.89552456",
"0.8911856",
"0.8906615",
"0.89035124",
"0.8901423",
"0.88972324",
"0.88968164",
"0.88889205",
"0.88761175",
"0.8875788",
"0.8854097",
"0.8845391",
"0.8844541",
"0.8829331",
"0.88266945",
"0.8824589",
"0.8824589",
"0.8813357",
"0.87827516",
"0.8776747",
"0.87526697",
"0.87356615",
"0.87161833",
"0.8715352",
"0.87114555",
"0.8686243",
"0.86714315",
"0.86357856",
"0.86051834",
"0.85523176",
"0.8536756",
"0.8467618",
"0.8467618",
"0.8464157",
"0.8445658",
"0.84392416",
"0.83599305",
"0.8316354",
"0.82337874",
"0.8228116",
"0.82177",
"0.8215102",
"0.82138556",
"0.82138556",
"0.8206206",
"0.8197638",
"0.8196117",
"0.8183596",
"0.81762624",
"0.81574255",
"0.81547",
"0.8154126",
"0.8147917",
"0.8130532",
"0.8125883",
"0.8111823",
"0.81090224",
"0.81070304",
"0.8090395",
"0.80793947",
"0.80490583",
"0.8025081",
"0.8012306",
"0.80027854",
"0.7993176",
"0.79887795",
"0.7938165",
"0.7930479",
"0.7914531",
"0.7910557",
"0.7870412",
"0.78660893",
"0.7852155",
"0.7848692",
"0.78425634",
"0.78391933"
] | 0.0 | -1 |
Building JSON Data for download | def objectify (point_cloud)
{
:id => point_cloud.id,
:name => point_cloud.name,
:data => point_cloud.data,
:created_at => point_cloud.created_at,
:updated_at => point_cloud.updated_at,
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json\n h = Hash.new\n\n h[\"description\"] = overview # add \"...\" if over certain size\n h[\"sources\"] = [full_name]\n h[\"subtitle\"] = \"(#{year}) #{genre}\"\n h[\"thumb\"] = poster\n h[\"art\"] = art\n\n t = name[0..32]\n t = t + \"..\" if t.size > 32\n h[\"title\"] = t\n\n h[\"rating\"] = rating\n h[\"runtime\"] = runtime\n\n h\n end",
"def build_json_data(h)\n # building each item of the json data\n json_items = h.keys().map { |k| \"\\\"#{k}\\\": \\\"#{h[k]}\\\"\" }\n\n # actually returning the json data\n return \"{#{json_items.join(', ')}}\"\n end",
"def json\n fields = dataset.dataset_fields\n e_doc = Hpricot(open(url))\n data = {\"id\"=> id, \"url\"=> url }\n fields.each do |field|\n p field\n data[field.name] = (e_doc/field.css).text.strip\n end\n puts data.inspect \n \n data.to_json \n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:version] = @version\n to_return[:file_path] = @file_path\n to_return[:backup_type] = @backup.type\n to_return[:html] = generate_html\n\n # Add in AppleNotesAccounts\n to_return[:accounts] = Hash.new()\n @accounts.each do |account_id, account|\n to_return[:accounts][account_id] = account.prepare_json\n end\n\n # Add in AppleCloudKitShareParticipants\n to_return[:cloudkit_participants] = Hash.new()\n @cloud_kit_participants.each do |record_id, cloudkit_participant|\n to_return[:cloudkit_participants][record_id] = cloudkit_participant.prepare_json\n end\n\n # Add in AppleNotesFolders\n to_return[:folders] = Hash.new()\n @folders.each do |folder_id, folder|\n to_return[:folders][folder_id] = folder.prepare_json if !folder.is_child?\n end\n\n # Add in AppleNotes\n to_return[:notes] = Hash.new()\n @notes.each do |note_id, note|\n to_return[:notes][note_id] = note.prepare_json\n end\n\n to_return\n end",
"def build_jason\n if @content.is_a?(Array)\n @content[0] = build_header_and_text_hashs @content[0] unless @content[0].empty?\n @content[2] = build_header_and_text_hashs @content[2] unless @content[2].empty?\n content_hash = {}\n content_hash = content_hash.merge(@content[0]) unless @content[0] || @content[0].empty?\n content_hash = content_hash.merge(@content[1])\n content_hash = content_hash.merge(@content[2]) unless @content[2] || @content[2].empty?\n @content = content_hash\n else\n @content = build_header_and_text_hashs @content\n end\n back_hash = build_back_portion @content\n document_hash = build_front_portion.merge( @content ).merge( back_hash ); back_hash = {}\n @content = {\n \"id\" => sha,\n \"nodes\" => document_hash\n }\n end",
"def toJson()\n return ({\"basename\" => @basename,\n \"config\" => @config,\n \"demandStat\" => @demandStat,\n }) ;\n end",
"def content\n fields = self.get_fields\n fields.empty? ? self.data.merge(self.file_data).to_json : fields.to_json\n end",
"def prepare_json\n\t\tjson_header\n\t\tjson_assemble\n\t\t#order_by_line_id(@file)\n\t\t#json_sections\n\t\t#json_order_line_by_section\n\n\tend",
"def generate_json\n if @path\n output = formatted_output\n File.open(@path, 'w') { |f| f.write(output.to_json) }\n end\n end",
"def generate_json\n if @path\n output = formatted_output\n File.open(@path, 'w') { |f| f.write(output.to_json) }\n end\n end",
"def to_json\n io = StringIO.new << \"{\"\n\n io << JSON.create_id.to_json << \":\" << self.class.name.to_json << \",\"\n\n @data.each {|key, value|\n io << key.to_json.to_s << \":\" << value.to_json << \",\"\n }\n\n io.seek(-1, IO::SEEK_CUR)\n io << \"}\"\n\n io.string\n end",
"def generate_json(json_file_name, data)\n File.open(json_file_name, 'w') do |f|\n f.puts(data.to_json)\n end\n end",
"def convert\n agent = Mechanize.new\n data = agent.get(\"http://dataset1:8080/runs/bm_insurance_licenses_raw/latest\").body\n JSON.parse(data).each do |s|\n d = {\n sample_date: s[\"last_updated_at\"],\n company: {\n name: s[\"name\"],\n jurisdiction: \"bm\"\n },\n source_url: s[\"licence_url\"],\n data: [{\n data_type: :licence,\n properties: {\n category: 'Financial',\n jurisdiction_code: \"bm\",\n jurisdiction_classification: \"Insurance: #{s[\"licence_class\"]}\"\n }\n }]\n }\n puts JSON.dump(d).strip\n end\nend",
"def generateJSON\n \n tableau_url = get_townhall_urls\n #/ pour chaque URL d'une ville du Val d'Oise, on associe l'adresse mail de la mairie\n File.open(\"../db/emails.json\",\"w\") do |f|\n for townhall_url in tableau_url do\n f.write(JSON.pretty_generate(get_townhall_email(townhall_url)))\n end\n end\n\n end",
"def data\n construct_url\n JSON.parse(response)\n end",
"def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end",
"def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end",
"def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end",
"def generate_full_data\n return @job_data if @full_data_generated\n @job_data[\"name\"] = @name if @name\n @job_data[\"metadata\"] ||= {}\n @job_data[\"metadata\"].merge!(@file_data)\n @job_data[\"source\"] = @job_data[\"source_name\"].dup\n @job_data.delete(\"source_name\")\n @full_data_generated = true\n @job_data\n end",
"def to_json!\n File.open(\"./meta_data.json\", \"w+\") { |f| f.puts JSON.pretty_generate(raw_data) }\n end",
"def request_data\n @data.to_json\n end",
"def create_json\n File.open('data/pokemon.json', 'w+') do |f|\n f << JSON.pretty_generate(get_basic_data)\n end\nend",
"def buildJsonFile(ndv, p4l, jsonkeys, new_datavalues, path, outputFolder)\r\n (0..ndv).each do |j|\r\n p4l[j] = jsonkeys.zip(new_datavalues[j])\r\n end\r\n File.open(path+\"\\\\#{outputFolder}\\\\users.json\",\"w\") do |json|\r\n json.write(p4l.to_json)\r\n end\r\n new_datavalues = []\r\n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:name] = @name\n to_return[:identifier] = @identifier\n to_return[:cloudkit_identifier] = @user_record_name\n to_return[:cloudkit_last_modified_device] = @cloudkit_last_modified_device\n to_return[:html] = generate_html\n\n to_return\n end",
"def write\n return if PictureTag.site.config['disable_disk_cache']\n\n FileUtils.mkdir_p(File.join(base_directory, sub_directory))\n\n File.open(filename, 'w+') do |f|\n f.write JSON.generate(data)\n end\n end",
"def to_json\n json_hash = {\n :id => @id,\n :timestamp => @timestamp.to_i,\n :data => @data,\n :data_part => @data_part&.to_json,\n :minimum_size => @minimum_size,\n }\n\n JSON.generate(json_hash)\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => '',\n :client => self.client.first_name + ' ' + self.client.last_name,\n :name => self.name,\n# :description => self.description || \"\",\n :start => start_datetime.rfc822,\n :start_window => start_window.rfc822,\n :end => '',\n :allDay => '',\n# :recurring => false,\n :url => Rails.application.routes.url_helpers.job_request_path(id)\n } \n end",
"def output_json_file\n File.write('results.json', { data: data }.to_json)\n end",
"def network_data\n file = \"#{Rails.root}/tmp/vivo/network_data/#{params[:id]}.json\"\n respond_to do |format|\n format.json { send_file file, :type => 'text/json', :disposition => 'inline' }\n format.js { send_file file, :type => 'text/json', :disposition => 'inline' }\n end\n end",
"def to_jq_record\n {\n \"id\" => read_attribute(:id),\n \"description\" => read_attribute(:description),\n \"name\" => read_attribute(:record),\n \"size\" => record.size,\n \"url\" => '/download_record?id=' + read_attribute(:id).to_s,\n \"thumbnail_url\" => is_image? ? '/thumbnail?id=' + read_attribute(:id).to_s : \"/assets/icon_file_lock_24.png\",\n \"delete_url\" => records_path.to_s + \"/\" + self.id.to_s,\n \"delete_type\" => \"DELETE\" \n }\n end",
"def get_json\n @link += \"&maxwidth=\" + @options[:maxwidth] if @options[:maxwidth]\n @link += \"&maxheight=\" + @options[:maxheight] if @options[:maxheight]\n obj = open(@link){ |f| f.read}\n JSON.parse(obj).each{ |key, val| self[key] = val} if JSON.parse(obj)\n end",
"def json_data\n json_format = params[:json_format] or 'default'\n case json_format\n when 'basic'\n collection.map { |v| { 'id' => v.product.id, 'name' => v.product.name }}.uniq { |i| i['id'] }.to_json\n when 'autocomplete'\n collection.map { |v| {\n :data => {\n :id => v.id,\n :product_id => v.product.id,\n :name => v.fullname,\n :sku => v.sku,\n :count_on_hand => v.count_on_hand,\n :image_url => (v.images.count > 0 ? v.images.first.attachment.url(:mini) : nil)\n },\n :value => v.fullname,\n :result => v.fullname\n }\n }.to_json\n else\n collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},\n :images => {:only => [:id], :methods => :mini_url}}},\n :images => {:only => [:id], :methods => :mini_url}, :master => {}})\n end\n end",
"def json(data, *)\n build_string(data, \"\\n\", '{', '}') do |key, value, index:, last:, first:|\n json_row(key, value, index: index, first: first, last: last)\n end\n end",
"def initialize()\n\tjson_data\t= {}\nend",
"def process_json_data jd\n\tjd.each do |gk, hash|\n\t\thash['subproducts'].each do |prod|\n\t\t\tsubroot = get_root prod['machine_name']\n\t\t\tprod['downloads'].each do |dd|\n\t\t\t\troot = subroot.dup\n\t\t\t\t# Fix KindomRush classic being put under Origin because it's included by\n\t\t\t\t# Origin Premium package\n\t\t\t\tif dd['machine_name']\n\t\t\t\t\tnewroot = get_root dd['machine_name']\n\t\t\t\t\troot = newroot.dup if newroot == 'kingdomrush/'\n\t\t\t\tend\n\t\t\t\ttype = dd['platform']\n\t\t\t\tsavepath = File.join(root, type)\n\t\t\t\t$dirs << savepath\n\t\t\t\tdd['download_struct'].each do |ds|\n\t\t\t\t\tsha1 = ds['sha1']\n\t\t\t\t\tmd5 = ds['md5']\n\t\t\t\t\tts = ds['timestamp']\n\t\t\t\t\tif ds['url']\n\t\t\t\t\t\tlink = ds['url']['web']\n\t\t\t\t\t\tbtlink = ds['url']['bittorrent']\n\t\t\t\t\t\tbtlink = nil if btlink and btlink.empty?\n\t\t\t\t\t\tdl = true\n\t\t\t\t\telsif (link = ds['external_link'])\n\t\t\t\t\t\t# TODO only announce once per external link\n\t\t\t\t\t\tSTDERR.puts \"# No automatic downloads for #{savepath} (#{ds['name']}), go to #{link}\"\n\t\t\t\t\t\tdl = false\n\t\t\t\t\tend\n\t\t\t\t\tif dl\n\t\t\t\t\t\tfname = get_filename link\n\t\t\t\t\t\tfkey = fname.intern\n\t\t\t\t\t\t# TODO use sha1\n\t\t\t\t\t\t$files[fkey] << Game.new(fname, md5, savepath, link, btlink, [hash['product']['human_name'], gk])#, ts)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend",
"def request_data\n {\n file: File.new(@upload_path, \"rb\"),\n data: @data.to_json\n }\n end",
"def to_json\n j = \"{\\n\"\n @data.each_pair {|k,v| j += \"#{k}:'#{v}'\\n\"}\n j += '}'\n end",
"def json_response(data = {})\n base = {\n 'api_version' => VERSION,\n 'auth' => 1,\n 'last_refreshed_on_time' => Feed.last_refreshed_at.to_i\n }\n\n content_type :json\n base.merge(data).to_json\n end",
"def save_data(subject_list)\n File.open('data', 'w') do |file|\n subject_list.each do |subj|\n file.write(\"#{subj.code}|#{subj.name}\\n\")\n subj.plans.each do |plan|\n file.write(\"#{plan.name}\\n\")\n plan.classes.each do |cla|\n file.write(\"#{cla.day}\\n#{cla.start}\\n#{cla.finish}\\n\")\n end\n end\n end\n end\n File.open('data.json', 'w') do |file|\n file.write(create_subjects_json(subject_list))\n end\nend",
"def json\n @data.to_json\n end",
"def get_data\n json_file = Egd::Builder.new(File.read(@file)).to_json\n data = JSON.parse(json_file)\n end",
"def fetch_data\n _mem = mem\n _loadavg = loadavg\n {\n :server => \"#{@config[\"server\"]}\",\n :key => \"#{@config[\"key\"]}\",\n :data => {\n :mem => _mem.to_json,\n :loadavg => _loadavg.to_json\n }}.to_json\nend",
"def export\n send_data current_user.records.select(:json).order('updated_at desc').collect(&:json).to_json, filename: 'records.json'\n end",
"def to_json\n i = 0\n datas = Array.new\n td = Array.new\n\n ds = @data\n ds.each_with_index do |row,index|\n data = \"{\"\n td.clear\n row.each_pair do |key,value|\n td.push(\"#{format(key)}: #{format(value)}\")\n end\n\n data +=td.join(\",\")\n data += \"}\"\n datas.push(data)\n end\n data = \"[#{datas.join(\",\")}]\"\n data\n end",
"def tojson\n\t\tend",
"def generate_export_json(output_directory, request, output)\n export = {\n transactionTime: Time.now.strftime(\"%FT%T%:z\"),\n request: request,\n requiresAccessToken: false,\n output: output,\n }\n file_path = File.join(output_directory, \"export.json\")\n File.open(file_path, \"w\") do |file|\n file.write(JSON.pretty_generate(export))\n end\nend",
"def to_json\n att = self.instance_variables.map {|v| v.to_s }\n links = []\n data = {}\n\n att.delete(\"@url\")\n att.delete(\"@client\")\n\n self.links.each do |l|\n links << l.values.first.to_hash\n end\n att.delete(\"@links\")\n\n att.each do |opt|\n data[opt.delete(\"@\")] = instance_variable_get(opt)\n end\n data['links'] = links\n data.to_json\n end",
"def as_json(options = {})\n {\n :id => id,\n :user_id => user_id,\n :latitude => latitude,\n :longitude => longitude,\n :thumbnail => file.url(:thumb),\n :small => file.url(:small),\n\t\t\t:smaller => file.url(:smaller),\n :medium => file.url(:medium),\n :original => file.url\n }\n end",
"def prepare_data(opts)\n MultiJson.dump(opts)\n end",
"def build_metadata\n require 'json'\n require 'tempfile'\n\n metadata = {\n \"description\" => DESCRIPTION,\n \"short_description\" => DESCRIPTION,\n \"name\" => \"manageiq/master\",\n \"versions\" => map_releases\n }\n\n metadata_file = Tempfile.new\n metadata_file.write metadata.to_json\n metadata_file.close\n\n metadata_file\n end",
"def download_data\n # Custom downloader functionality implementation, this is just a simplified example template\n $log.info 'Starting downloading data from the Dummy API.'\n entities = @metadata.list_entities\n results = []\n entities.each do |entity|\n entity_custom = entity.custom\n load_metadata entity, entity_custom['fields']\n start_date, end_date = get_date_interval(entity)\n results << [entity, download_data_range(entity, start_date, end_date)]\n end\n save_to_s3 results\n end",
"def json_data\n { id: self.id, membership_id: self.membership_id, amount: self.amount.round(2), paid_by: self.user.full_name, description: self.description, vendor: self.vendor, group_id: self.group.id }\n end",
"def getJson()\n puts \"getting JSON...\"\n response = HTTParty.get(@url)\n response.parsed_response \n\n txt = open(\"OUT.json\", 'w+')\n txt.write(response)\n txt.close()\n end",
"def to_api_json\n Jbuilder.encode do |json|\n highlighted_album_json(json)\n week_json(json)\n albums_json(json)\n end\n end",
"def final_release_metadata_json\n @final_release_metadata_json ||= Pathname(\"#{final_name}-release-metadata.json\")\n end",
"def to_json\r\n {\r\n files: @files,\r\n dirs: @dirs\r\n }\r\n end",
"def import_data\n @formatted_data = []\n @customers.shift\n @customers.each do |customer|\n customer_data = {\n name: \"#{customer[0]} #{customer[1]}\",\n emails: [\n {\n type: \"\",\n email: customer[2]\n }\n ],\n phones: [\n {\n type: @home_phone_type,\n phone: customer[4]\n },\n {\n type: @work_phone_type,\n phone: customer[5]\n }\n ],\n type: customer[6],\n birthdayAt: customer[3]\n # socials: [\n # {\n # type: \"\",\n # userid: \"\",\n # username: \"\",\n # url: \"\"\n # }\n # ],\n # urls: [\n # {\n # url: \"\"\n # }\n # ],\n # locations: [\n # {\n # type: \"\",\n # address: \"\"\n # }\n # ],\n # locale: \"\",\n # gender: \"\",\n # tags: [\n # ]\n }\n # p @formatted_data << JSON.pretty_generate(customer_data)\n\n @formatted_data << customer_data\n end\n File.open(\"data.json\",\"w\") do |f|\n f.write(@formatted_data.to_json)\n end\n File.open(\"nojsondata.json\",\"w\") do |f|\n f.write(@formatted_data)\n end\n end",
"def json_data_response( status, errors = nil )\n response =\n {\n id: @import_file.id,\n title: @import_file.title,\n goal_id: @import_file.goal_id,\n created_at: @import_file.created_at,\n updated_at: @import_file.updated_at,\n json_data: JSON.parse(@import_file.json_data)\n }\n\n response[:errors] = errors unless errors.nil?\n json_response(response, status)\n end",
"def download\n #require 'debugger'; debugger\n generator = Generator.where(id: params[:id], user_id: current_user.id).first\n send_file TerrainLib::Component.generate JSON.parse(generator.generator_hash)\n end",
"def json_\n hash = {\n \"Id\" => id,\n \"AccountId\" => account_id,\n \"SubscriptionId\" => subscription_id,\n \"Name\" => name,\n \"CampaignTypeId\" => campaign_type_id,\n \"ContentId\" => content_id,\n \"Session\" => session,\n \"SessionLength\" => session_length,\n \"UserData\" => user_data,\n \"SingleUse\" => single_use,\n \"SingleUseContentId\" => single_use_content_id\n }\n\n hash.to_json\n end",
"def to_api_json\n Jbuilder.encode do |json|\n json.set!(:week_start, @week.start.in_time_zone.to_i)\n json.set!(:week_end, @week.end.in_time_zone.to_i)\n json.set!(:week_number, @week.number)\n\n json.albums do\n json.array! @albums do |album|\n json.call(album, :name, :uuid)\n json.set!(:artist, album.artist.name)\n json.set!(:thumbnail_url, album.image || album.thumbnail)\n json.set!(:release_date, album.release_date.in_time_zone.to_i)\n json.set!(:release_date_string, album.release_date.to_s)\n json.set!(:age, album.anniversary.count)\n json.set!(:day_of_week, album.anniversary.current.strftime('%A'))\n json.set!(:anniversary, album.anniversary.current.in_time_zone.to_i)\n json.set!(:anniversary_string, album.anniversary.current.to_s)\n json.set!(:review_link, album.link)\n json.set!(:rating, album.rating)\n json.set!(:link, \"/albums/#{album.slug}\")\n end\n end\n end\n end",
"def download_link\n return_hash = Hash.new\n if params.has_key?('web_ids')\n web_ids_str = params['web_ids']\n web_ids = web_ids_str.split('~')\n if !web_ids.respond_to?(:count) || web_ids.count < 1\n return_hash[\"status\"] = \"error\"\n return_hash[\"error\"] = \"no web_ids after split\"\n render(json: return_hash.to_json, content_type: request.format, :layout => false)\n end\n web_ids.each(&:strip!)\n parametrized_doi = @dataset.identifier.parameterize\n download_hash = DownloaderClient.datafiles_download_hash(@dataset, web_ids, \"DOI-#{parametrized_doi}\")\n if download_hash\n if download_hash['status'] == 'ok'\n web_ids.each do |web_id|\n datafile = Datafile.find_by_web_id(web_id)\n if datafile\n #Rails.logger.warn \"recording datafile download for web_id #{web_id}\"\n datafile.record_download(request.remote_ip)\n else\n #Rails.logger.warn \"did not find datafile for web_id #{web_id}\"\n end\n end\n return_hash[\"status\"] = \"ok\"\n return_hash[\"url\"] = download_hash['download_url']\n return_hash[\"total_size\"] = download_hash['total_size']\n else\n return_hash[\"status\"] = \"error\"\n return_hash[\"error\"] = download_hash[\"error\"]\n end\n else\n return_hash[\"status\"] = \"error\"\n return_hash[\"error\"] = \"nil zip link returned\"\n end\n render(json: return_hash.to_json, content_type: request.format, :layout => false)\n else\n return_hash[\"status\"] = \"error\"\n return_hash[\"error\"] = \"no web_ids in request\"\n render(json: return_hash.to_json, content_type: request.format, :layout => false)\n end\n end",
"def as_json\n { file_line_number: @file_line_number,\n file_name: @file_name,\n folder_path: @folder_path }\n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:note_id] = @note.note_id\n to_return[:uuid] = @uuid\n to_return[:type] = @type\n to_return[:conforms_to] = @conforms_to\n to_return[:alt_text] = @alt_text\n to_return[:token_identifier] = @token_identifier\n to_return[:html] = generate_html\n\n to_return\n end",
"def get_data(event, data={})\n self['event'] = event\n self['properties'] = data \n self['properties']['token'] = @key\n self['properties']['time'] = Time.now.to_i\n \n Base64.encode64(JSON.generate(self))\n end",
"def write_json(a)\n write \"(\" + a.write_json_item + \")\\n\"\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n end",
"def as_json()\n data = {\n 'redirectCount' => self.redirects_count,\n 'startDate' => self.created_at.utc.iso8601,\n }\n\n if self.redirects_count > 0\n data['lastSeenDate'] = self.last_redirect_at.utc.iso8601\n end\n\n data\n end",
"def to_json\n FFI_Yajl::Encoder.encode(@data, pretty: true)\n end",
"def to_api_json\n Jbuilder.encode do |json|\n json.albums do\n json.array! @albums do |album|\n json.call(album, :name, :uuid)\n json.set!(:artist, album.artist_name)\n json.set!(:artist_twitter_screen_name, twitter_screen_name(album))\n json.set!(:thumbnail_url, album.image || album.thumbnail)\n json.set!(:release_date, album.release_date.in_time_zone.to_i)\n json.set!(:release_date_string, album.release_date.to_s)\n json.set!(:age, album.anniversary.count)\n json.set!(:day_of_week, album.anniversary.current.strftime('%A'))\n json.set!(:anniversary, album.anniversary.current.in_time_zone.to_i)\n json.set!(:anniversary_string, album.anniversary.current.to_s)\n json.set!(:review_link, album.link)\n json.set!(:rating, album.rating)\n json.set!(:generated_fun_fact_description, album.generated_fun_fact_description)\n json.set!(:fun_fact_description, album.fun_fact_description)\n json.set!(:fun_fact_source, album.fun_fact_source)\n json.set!(:link, \"/albums/#{album.slug}\")\n json.set!(:update, \"/v1/admin/albums/#{album.id}\")\n end\n end\n end\n end",
"def generate_hash\n \n tmp_file = \"/tmp/zotero.xml\"\n \n File.open(tmp_file, \"w\") { |f| f << @datastreams[\"zotero\"] }\n \n # Check to make sure zotero.xml file has been written\n raise \"Couldn't write #{tmp_file}\" unless File.exist?(tmp_file) and File.file?(tmp_file)\n \n php_output = `/usr/bin/env php #{File.join(Rails.root, 'lib/stanford/zotero_to_json.php' )} /tmp/zotero.xml`\n # puts php_output.inspect\n \n json = JSON(php_output)\n # puts json.inspect\n json.is_a?(Array) ? json = json.first : json = json\n \n if json.nil? or json.is_a?(String)\n json = {}\n end\n\n # this is really stupid, but it's a quick fix to get the coverage data.\n xml = Nokogiri::XML(open(\"/tmp/zotero.xml\"))\n xml.search(\"//dc:coverage\").each do |cov| \n format_coverage(cov.content.strip).each do |key,vals|\n json[\"#{key}\"] ||= [] \n json[\"#{key}\"] << vals.first\n end\n end\n [\"druid\", \"title\", \"originator\", \"date\", \"document_type\", \"document_subtype\",\n \"containing_work\", \"corporate_entity\", \"extent\", \"language\", \"abstract\", \n \"EAF_hard_drive_file_name\", \"tags\", \"notes\", \"box\", \"folder\", \"subseries\"].each {|k| json[k] ||= \"\" }\n return json\n\n end",
"def createDirectJSON\n result = \"{\"\n if(!@params['hp'].nil? && !(@params['hp'].to_i == 0))\n result += \"\\\"hp\\\":\"\n result += @params['hp'] \n end\n if(!@params['exp'].nil? && !(@params['exp'].to_i == 0))\n if(result.length > 2)\n result += \",\"\n end\n result += \"\\\"exp\\\":\"\n result += @params['exp'] \n end\n if(!@params['gold'].nil? && !(@params['gold'].to_i == 0))\n if(result.length > 2)\n result += \",\"\n end\n result += \"\\\"gold\\\":\" \n result += @params['gold']\n end\n result += \"}\"\n result\n end",
"def json_reflect\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n h = {}\n params.each do |x,y|\n h[x]=y\n end\n write_json h\n end",
"def json\n @@id += 1\n \"{\" +\n \"\\\"type\\\": \\\"#{@type}\\\", \\\"id\\\": \\\"A#{@@id}\\\", \\\"value\\\": \\\"#{@value}\\\", \" +\n \"\\\"offset\\\": #{@offset}, \\\"length\\\": #{@length}\" +\n \"}\"\n end",
"def query_filedata(uid)\n json = {}\n id = uid.to_i\n dir = id%100\n dir = \"#{fs_root}/#{dir.to_s}/#{id}_lastread\"\n FileUtils.makedirs(dir)\n fname = \"#{dir}/jsondata\" \n #p \"query_filedata:filename #{fname}\"\n\n begin\n if FileTest::exists?(fname) \n data= nil \n open(fname, \"r\") {|f|\n data = f.read\n # f.seek(0)\n # f.write(\"\") \n # f.truncate(0)\n }\n # p \"data=#{data.inspect}\"\n json = JSON.parse(data) if data\n end\n rescue Exception=>e\n # logger.error e\n p e.inspect\n pe(e)\n \n end\n\n return json\n\n end",
"def to_json(platform)\n rv = []\n needs_sorting = false\n self.each do |item|\n jsonrec = {\n 'htid' => item.htid,\n 'ingest' => item.last_update_date,\n 'rights' => item.rights,\n 'heldby' => [], # not needed, TODO: remove print holdings\n 'collection_code' => item.collection_code,\n }\n\n if item.enum_chron\n jsonrec['enumcron'] = item.enum_chron\n needs_sorting = true\n end\n\n if item.enum_pubdate\n jsonrec['enum_pubdate'] = item.enum_pubdate\n jsonrec['enum_pubdate_range'] = HathiTrust::Traject::Macros::HTMacros.compute_date_range(item.enum_pubdate.to_i)\n end\n\n\n if platform == :ht\n jsonrec['dig_source'] = item.dig_source if item.dig_source\n end\n\n rv << jsonrec\n end\n\n\n if needs_sorting\n rv = sortHathiJSON(rv)\n end\n rv.to_json\n end",
"def generate_data_files\n files = {}\n\n # extracted data\n @classes.each do |category|\n files[category] = {}\n folder = File.join(@res, 'data', category.to_s, 'extracted')\n\n files[category][:extracted] = File.join(folder, \"#{category}.json\")\n end\n\n # divided data\n @classes.each do |category|\n files[category][:divided] = {}\n folder = File.join(@res, 'data', category.to_s, 'divided')\n\n @subsets.each do |subset|\n files[category][:divided][subset] = File.join(folder,\n \"#{category}_#{subset}.json\")\n end\n end\n\n # preprocessed data\n @classes.each do |category|\n files[category][:preprocessed] = {}\n\n @preproc.each do |preprocess|\n folder = File.join(\n @res, 'data', category.to_s, 'preprocessed', preprocess.to_s)\n\n files[category][:preprocessed][preprocess] = {}\n\n @subsets.each do |subset|\n files[category][:preprocessed][preprocess][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n\n # transformed data\n if @trans.size > 0\n @classes.each do |category|\n files[category][:transformed] = {}\n\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'transformed', ctrans.to_s)\n\n files[category][:transformed][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:transformed][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n\n # classified data\n if @classifs.size > 0\n @classes.each do |category|\n files[category][:classified] = {}\n\n @classifs.each do |classifier|\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{classifier}_#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'classified', ctrans.to_s)\n\n files[category][:classified][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:classified][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n end\n files\n end",
"def generate_json_files\n # if no job is served, generate all\n filter do |project, group, job|\n job.generate_json_file\n end\n end",
"def to_json\n data.to_json\n end",
"def as_json(_opts = {})\n {}.tap do |root|\n root[TYPE_KEY] = type\n root[ID_KEY] = object_identifier\n root[ATTRIBUTES_KEY] = generate_attributes\n append_relationships(root)\n append_meta(root)\n append_includes(root)\n end\n end",
"def download\n URI.extract(json, ['http', 'https']).each do |url|\n get_asset(url)\n end\n\n json\n end",
"def export_as_json\n @user = T.must(current_user)\n authorize @user, policy_class: SettingsPolicy\n\n @games = GamePurchase.where(user_id: @user.id).includes(:game, :platforms, :stores)\n\n respond_to do |format|\n format.json do\n export_data = {\n user: {\n id: @user.id,\n username: @user.username\n },\n games: @games.as_json(include: [:game, :platforms, :stores])\n }\n send_data JSON.pretty_generate(export_data), disposition: :json, filename: 'vglist.json'\n end\n end\n end",
"def json_data\n json_format = params[:json_format] || 'default'\n case json_format\n when 'basic'\n collection.map { |u| { 'id' => u.id, 'name' => u.email } }.to_json\n else\n address_fields = [:firstname, :lastname, :address1, :address2, :city, :zipcode, :phone, :state_name, :state_id, :country_id]\n includes = { only: address_fields, include: { state: { only: :name }, country: { only: :name } } }\n\n collection.to_json(only: [:id, :email], include:\n { bill_address: includes, ship_address: includes })\n end\n end",
"def save_as_JSON\n for i in 0..get_townhall_urls.length-1\n json_email = (get_townhall_email(get_townhall_urls[i])).to_json\n File.open(\"db/emails.json\", \"a\") { |file| file.puts json_email}\n end\n end",
"def to_json(*args)\n data.to_json(*args)\n end",
"def to_json\n Yajl::Encoder.encode(@raw_data)\n end",
"def web(_request, response)\n response.headers[\"Content-Type\"] = \"application/json\"\n json = MultiJson.dump(\n adapter: robot.config.robot.adapter,\n lita_version: Lita::VERSION,\n redis_memory_usage: redis_memory_usage,\n redis_version: redis_version,\n robot_mention_name: robot.mention_name,\n robot_name: robot.name\n )\n response.write(json)\n end",
"def json_data\n json_format = params[:json_format] or 'default'\n case json_format\n when 'basic'\n collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json\n else\n collection.to_json()\n end\n end",
"def json()\n tmp = @plan_ir.map {|plan| plan.json()}\n @tiles = @plan_ir.empty? ? {} : @plan_ir[0].tiles.merge(*@plan_ir[1..].map{|ir|ir.tiles})\n tmp\n end",
"def as_json(*args)\n {\n 'image' => parent_image,\n 'url' => url,\n 'path' => path,\n 'pathWithQuery' => path_with_query,\n 'width' => width,\n 'height' => height,\n 'x1' => x1,\n 'x2' => x2,\n 'y1' => y1,\n 'y2' => y2\n }\n end",
"def get_json(url)\n\t# Get the events from scraping \n\tevents = scrape(url)\n\tname = (((url.split \".\")[0]).split \"/\").pop\n\t# Modify the file of the department\n\tFile.open(\"API/#{name}.json\", \"w\") do |f|\n\tf.write(\"{\\n\")\n\tf.write(\"\\t\\\"events\\\": [\\n\")\n\t# Add an object for every event\n\twhile(!events.empty?)\n\t\tcurr = events.pop\n\t\tf.write(\"\\t\\t{\\n\")\n\t\tf.write(\"\\t\\t\\t \\\"title\\\":\\\"#{curr.title}\\\",\\n\")\n\t\tf.write(\"\\t\\t\\t \\\"timedate\\\":\\\"#{curr.timedate}\\\",\\n\")\n\t\tf.write(\"\\t\\t\\t \\\"desc\\\":\\\"#{curr.desc}\\\",\\n\")\n f.write(\"\\t\\t\\t \\\"dept\\\":\\\"#{curr.dept}\\\"\\n\")\n\t\tf.write(\"\\t\\t},\\n\") if !events.empty?\n\t\tf.write(\"\\t\\t}\\n\") if events.empty?\n\tend\n\tf.write(\"\\t]\\n\")\n\tf.write(\"}\")\n\tend\n\treturn name #10/6 Steven\nend",
"def as_json options={}\n t_url = ProductImage.get_thumbnail_image_path(self.product_id,true)\n t_url = \"\" if t_url.nil?\n \n f_url = ProductImage.get_fullsize_image_path(self.product_id,true)\n f_url = \"\" if f_url.nil?\n \n options[:except] = [:updated_at,:origin,:brand_id,:price]\n j = super options\n j[\"thumbnail_url\"] = t_url\n j[\"fullsize_url\"] = f_url\n j[\"created_at\"] = j[\"created_at\"].to_i\n \t \n return j\n\tend",
"def serialized\n start_location = self.request.trip.origin.build_place_details_hash\n end_location = self.request.trip.destination.build_place_details_hash\n json_i = self.as_json \n json_i[\"start_location\"] = start_location\n json_i[\"end_location\"] = end_location\n json_i[\"request\"] = self.request.otp_request\n return json_i\n end",
"def save_output_json(data)\n File.open(\"output.json\", \"wb\") {|f| f.write(JSON.pretty_generate(data))}\nend",
"def to_json\n {:pid=>self.pid,\n :name=>self.name,\n :status=>self.status,\n :release_date=>self.release_date,\n :episodes=>self.get_json_episodes,\n :generas=>self.generas,\n :related_shows=>self.related_shows\n }\n end",
"def generate_ndjson(resource_type, resource_list, output_directory)\n p \"===============================================================\"\n p \"Generating ndjson file of type #{resource_type}...\"\n outfile = File.join(output_directory, \"#{resource_type}.ndjson\")\n ndout = {\n type: resource_type,\n url: \"#{FHIR_SERVER}/resources/#{output_directory.split(\"/\").last}/#{resource_type}.ndjson\",\n }\n NDOUTS << ndout\n\n begin\n o = File.open(outfile, \"w\")\n p \"Writing #{resource_list.size} #{resource_type} resource instances to #{outfile}...\"\n resource_list.each { |instance| o.puts(JSON.generate(instance)) }\n rescue StandardError => e\n puts \"An error occured when generating file #{outfile}: #{e.message}\"\n ensure\n o.close\n end\nend",
"def as_json(options = {})\r\n\t\tsuper\r\n\t\t {type: type,\r\n\t\t \t Title: Title,\r\n\t\t \t Authors: authors,\r\n\t\t \t With: with,\r\n\t\t \t Details: details,\r\n\t\t \t Year: year\r\n\t\t \t }\r\n\tend",
"def json\n\n JSON.fast_generate(@gltf)\n\n end",
"def download\n page = params[:page].to_i\n\n a = download_conjugation(page)\n @verbs_conj.each do |verb|\n v = Verb.new(:infinitive => verb[:infinitive], :translation => verb[:translation], :group => verb[:group])\n if v.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb[tense][form].strip != '')\n @form = Form.new(:content => verb[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => v)\n @form.save\n end\n end\n end\n end\n end\n File.open(\"public/temp_#{page}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(@verbs_conj))\n end\n\n @verbs = Verb.all\n respond_to do |format|\n format.html{ render action: 'index'}\n format.json { head :no_content }\n end\n\n end",
"def json\n {\"creation_date\" => @creation_date}\n end",
"def as_json(opts)\n @data.as_json(opts)\n end",
"def getSongs(groupid) \n res = $conn.exec(\"SELECT songid,song,artist,album,aurl FROM #{groupid} ORDER BY placeid\").values()\n res.each do |song|\n song[0]='{\"key\": \"' + song[0] + '\"'\n song[1]='\"trackname\": \"' + song[1] + '\"'\n song[2]='\"artist\": \"' + song[2] + '\"'\n song[3]='\"album\": \"' + song[3] + '\"'\n song[4]='\"albumcover\": \"' + song[4] + '\"}'\n song = song.join(',')\n end\n json_out_str = '[]'\n if(res.length != 0)\n json_out_str = '['+ res.join(',')+']'\n end\n File.open('songs.json','w') {|f| f.write(json_out_str)}\n send_file('songs.json')\nend"
] | [
"0.6593848",
"0.6560064",
"0.6477827",
"0.64663625",
"0.6459084",
"0.64376944",
"0.6425473",
"0.6415667",
"0.6249833",
"0.6249833",
"0.61774796",
"0.6139515",
"0.61381006",
"0.6128678",
"0.6125907",
"0.6104432",
"0.6104432",
"0.6104432",
"0.6102278",
"0.6061218",
"0.605878",
"0.6020312",
"0.60053897",
"0.59783864",
"0.59539455",
"0.5946866",
"0.58972955",
"0.5893489",
"0.5886859",
"0.58855826",
"0.5876159",
"0.5857253",
"0.585105",
"0.58503646",
"0.5831164",
"0.5824032",
"0.5823508",
"0.58205664",
"0.58138055",
"0.5812808",
"0.5805981",
"0.5785167",
"0.5778977",
"0.5766062",
"0.57631826",
"0.5761108",
"0.5757273",
"0.5757088",
"0.5738845",
"0.5732037",
"0.5726501",
"0.5726108",
"0.57147485",
"0.57065415",
"0.57019866",
"0.5701951",
"0.57004756",
"0.5691867",
"0.56894183",
"0.5688666",
"0.5685211",
"0.5671304",
"0.5669961",
"0.562922",
"0.56291294",
"0.56284845",
"0.5626903",
"0.56267077",
"0.5621851",
"0.56196547",
"0.56182986",
"0.5608151",
"0.5607526",
"0.56073374",
"0.5605857",
"0.5603695",
"0.5600806",
"0.55838716",
"0.55679405",
"0.5565048",
"0.55645645",
"0.5560139",
"0.555822",
"0.554633",
"0.55411327",
"0.5539113",
"0.5527829",
"0.5524667",
"0.5516414",
"0.55155224",
"0.55089104",
"0.5508617",
"0.55004054",
"0.54973036",
"0.5491781",
"0.5489528",
"0.5480668",
"0.547925",
"0.54745746",
"0.5462964",
"0.54627895"
] | 0.0 | -1 |
We are assuming that the style modifier is for the whole word. So this not support styling parts of a word. | def process_style_modifiers
@doc.css('b', 'i', 'em', 'strong', 'ins', 'u', 'del', 'cite').each do |node|
# We are getting the html of the children, we can't use {node.text} here
# because we would be missing all the other html tags.
text = node.children.to_s
replacement_value = MODIFIERS[node.name.to_sym]
node.replace(replacement_value + text.strip + replacement_value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_style\n root = Document.new(Font.new(Font::ROMAN, 'Arial'))\n style = CharacterStyle.new\n style.bold = true\n\n assert(root.apply(style) != nil)\n assert(root.size == 1)\n assert(root[0].class == CommandNode)\n assert(root[0].prefix == '\\b')\n assert(root[0].suffix == nil)\n assert(root[0].split == true)\n\n style.underline = true\n assert(root.apply(style).prefix == '\\b\\ul')\n\n style.bold = false\n style.superscript = true\n assert(root.apply(style).prefix == '\\ul\\super')\n\n style.underline = false\n style.italic = true\n assert(root.apply(style).prefix == '\\i\\super')\n\n style.italic = false\n style.bold = true\n assert(root.apply(style).prefix == '\\b\\super')\n\n style.bold = false\n style.superscript = false\n style.italic = true\n style.font_size = 20\n assert(root.apply(style).prefix == '\\i\\fs20')\n\n node = nil\n root.apply(style) {|n| node = n}\n assert(node == root[-1])\n\n # Test style short cuts.\n node = root.bold\n assert(node.prefix == '\\b')\n assert(node.suffix == nil)\n assert(node == root[-1])\n\n node = root.italic\n assert(node.prefix == '\\i')\n assert(node.suffix == nil)\n assert(node == root[-1])\n\n node = root.underline\n assert(node.prefix == '\\ul')\n assert(node.suffix == nil)\n assert(node == root[-1])\n\n node = root.superscript\n assert(node.prefix == '\\super')\n assert(node.suffix == nil)\n assert(node == root[-1])\n end",
"def style!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n\n type = STYLE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 359:8: 'style'\n match( \"style\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n\n end",
"def style(s, style); color(s, *Styles[style]) end",
"def correct_style_detected; end",
"def correct_style_detected; end",
"def correct_style_detected; end",
"def style_for(char)\n return '' if char.style == @style\n\n @style = char.style\n @style.to_s\n end",
"def style_for(char)\n return ''.freeze if char.style == @style\n\n @style = char.style\n @style.to_s\n end",
"def word_pattern\n @emphasis[:word_pattern]\n end",
"def style(prop); end",
"def style=(_); end",
"def styles=(_arg0); end",
"def allows_style?\n true\n end",
"def add_element_for_CharacterStyleRange(char)\n el = parent_el = nil\n char_style = :regular\n l = { :story => @story_name, :line => char.line }\n\n # Only proceed if char has at least one non-empty Content node\n char_has_non_whitespace_content = char.children.any? { |child|\n 'Content' == child.name && !child.inner_text.strip.empty?\n }\n return el unless char_has_non_whitespace_content\n\n if (\n 'CharacterStyle/Bold Italic' == char['AppliedCharacterStyle'] ||\n 'Bold Italic' == char['FontStyle']\n )\n # Create pair of nested elements to include both bold and italic styles.\n parent_el = ElementRt.new(:strong, nil, nil, :location => l)\n el = ElementRt.new(:em, nil, nil, :location => l)\n parent_el.add_child(el)\n char_style = :bold_italic\n else\n # TODO: assignment of char_style depends on code execution: if both are present, it will always be 'Italic' and never 'Bold'\n # Is this ok or intended?\n if (\n 'CharacterStyle/Bold' == char['AppliedCharacterStyle'] ||\n 'Bold' == char['FontStyle']\n )\n el = parent_el = ElementRt.new(:strong, nil, nil, :location => l)\n char_style = :bold\n end\n\n if (\n 'CharacterStyle/Italic' == char['AppliedCharacterStyle'] ||\n 'Italic' == char['FontStyle']\n )\n if parent_el\n el = ElementRt.new(:em, nil, nil, :location => l)\n parent_el.add_child(el)\n else\n el = parent_el = ElementRt.new(:em, nil, nil, :location => l)\n end\n char_style = :italic\n end\n\n end\n\n if 'CharacterStyle/$ID/[No character style]' == char['AppliedCharacterStyle']\n # Preserve FontStyles\n if 'Italic' == char['FontStyle']\n el = parent_el = ElementRt.new(:em, nil, nil, :location => l)\n char_style = :italic\n elsif 'Bold' == char['FontStyle']\n el = parent_el = ElementRt.new(:strong, nil, nil, :location => l)\n char_style = :bold\n else\n # No FontStyle applied so we don't need to add any parent elements\n # for this CharacterStyleRange\n end\n end\n\n add_class_to_self_or_parent = lambda do |css_class|\n parent_el = el = ElementRt.new(:em, nil, nil, :location => l) if el.nil?\n parent_el.add_class(css_class)\n parent_el.add_class(\n case char_style\n when :regular then ''\n when :italic then ' italic'\n when :bold then ' bold'\n when :bold_italic then ' bold italic'\n end\n )\n end\n\n add_class_to_self_or_parent.call('underline') if 'true' == char['Underline']\n add_class_to_self_or_parent.call('smcaps') if 'SmallCaps' == char['Capitalization']\n\n if \"Color/GAP RED\" == char['FillColor']\n (el.nil? ? @tree : el).add_child(\n ElementRt.new(:gap_mark, nil, nil, :location => l)\n )\n end\n\n if \"Color/TRANSLATORS OMIT\" == char['FillColor']\n containing_para_ke = @stack.last.first\n if (\n containing_para_ke &&\n :p == containing_para_ke.type\n )\n # append omit class\n containing_para_ke.add_class('omit')\n end\n end\n\n if 'CharacterStyle/Paragraph number' == char['AppliedCharacterStyle']\n if @tree.has_class?('normal')\n @tree.remove_class('normal')\n @tree.add_class('normal_pn')\n end\n add_class_to_self_or_parent.call('pn')\n end\n\n if !HANDLED_CHARACTER_STYLES.include?(char['AppliedCharacterStyle'])\n add_class_to_self_or_parent.call(normalize_style_name(char['AppliedCharacterStyle']))\n end\n\n @tree.add_child(parent_el) if !parent_el.nil?\n\n el\n end",
"def match style\n self.active_policy[:style] = style\n end",
"def is_paragraph_style?\n true\n end",
"def is_paragraph_style?\n false\n end",
"def style_on(*v)\n styles = v.map { |i| EscSequence::STYLE[i.to_sym] }.transpose\n \"\\e[\" << styles[0].join(';') << 'm'\n end",
"def myletter\n \n end",
"def detect_style(dtok)\n style = nil\n case dtok.value\n when /\\A\\s*\\[\\*([a-zA-Z0-9_]+)\\*\\]\\s*(.*)\\z/\n style = 'doc'\n when /\\A\\s*\\$([a-zA-Z0-9_]+):: +(.*)\\z/\n style = 'kafo'\n when /\\A\\s*@param (?:\\[.+\\] )?([a-zA-Z0-9_]+)(?: +|$)(.*)\\z/\n style = 'strings'\n end\n [style, * $~]\n end",
"def setup_style\n self.read_only = true\n self.word_wrap_mode = Qt::TextOption::WrapAnywhere\n end",
"def semanticize_font_styles!\n @document.tree.css('span').each do |node|\n if node.bold?\n node.node_name = 'strong'\n elsif node.italic?\n node.node_name = 'em'\n end\n end\n end",
"def style_conversion; end",
"def hl(type=:bold,word=nil)\n if word\n self.gsub(/(\\s|\\A|[[:punct:]])#{word}(\\s|\\Z|[[:punct:]])/,\n \"\\\\1\" + HIGHLIGHT[type] + word.to_s + HIGHLIGHT[:end] + \"\\\\2\")\n else\n HIGHLIGHT[type] + self.to_s + HIGHLIGHT[:end]\n end\n end",
"def s(val); @style = val; end",
"def style\n keyword = loc_hash[:keyword]\n keyword ? keyword.source.to_sym : :ternary\n end",
"def opposite_style_detected; end",
"def opposite_style_detected; end",
"def opposite_style_detected; end",
"def reduce_word(_production, _range, _tokens, _children)\n Regex::Anchor.new('\\b')\n end",
"def is_character_style?\n true\n end",
"def detected_styles; end",
"def create_style_rule(rule); end",
"def set_style\r\n @style = Style.new\r\n\r\n alignment_node = @node.xpath('.//w:jc').first\r\n alignment = alignment_node ? alignment_node.attributes['val'].value : nil\r\n @style.instance_variable_set('@text_align', alignment.to_sym) if alignment\r\n\r\n size_node = @node.xpath('w:pPr//w:sz').first\r\n font_size = size_node ? size_node.attributes['val'].value.to_i / 2 : nil\r\n @style.instance_variable_set('@font_size', font_size)\r\n\r\n bold_node = @node.xpath('w:pPr//w:b').first\r\n @style.instance_variable_set('@font_weight', 'bold') if bold_node\r\n\r\n italic_node = @node.xpath('w:pPr//w:i').first\r\n @style.instance_variable_set('@font_style', 'italic') if italic_node\r\n\r\n underline_node = @node.xpath('w:pPr//w:u').first\r\n @style.instance_variable_set('@text_underline_style', 'solid') if underline_node\r\n end",
"def style(string, type)\n raise \"Type '#{type}' unknown: must be one of \" + TYPES.map{|e| \":#{e}\"}.join(', ') if\n not TYPES.include?(type)\n style = eval(\"@#{type}_style\")\n foreground = eval(\"@#{type}_foreground\")\n background = eval(\"@#{type}_background\")\n # if no style nor colors, return raw string\n return string if not foreground and not background and not style\n # insert style and colors in string\n colorized = \"\\e[\"\n colorized << \"#{STYLE_CODES[style]};\" if style\n colorized << \"#{FOREGROUND_COLOR_CODES[foreground]};\" if foreground\n colorized << \"#{BACKGROUND_COLOR_CODES[background]};\" if background\n colorized = colorized[0..-2]\n colorized << \"m#{string}\\e[#{STYLE_CODES[:reset]}m\"\n return colorized\n end",
"def test_paragraph_with_background_color\n input = '<p style=\"background-color: #123456\"></p>'\n expected_output = para_with_ppr('<w:shd w:val=\"clear\" w:fill=\"123456\" />')\n assert_equal normalize_wordml(expected_output), process(input)\n end",
"def use_style?\n end",
"def change_words_color text, symbol, text_color, symbol_color\n\n splited_text = text.split(/#{Regexp.escape(symbol)}(.*?)#{Regexp.escape(symbol)}/m)\n puts splited_text\n result_text = \"\"\n\n # splited_text.each do |partial_text|\n # partial_text = partial_text.strip\n # puts partial_text.strip\n # if partial_text.include? symbol\n # result_text += partial_text.between(symbol, symbol).send(symbol_color)\n # else\n # result_text += partial_text.send(text_color)\n # end\n # end\n\n # puts result_text\n\n # result_text = \"\"\n # last_text = \"\"\n #\n # for\n #\n #\n # text.each_char do |char, index|\n # while char == symbol\n #\n # end\n # end\n end",
"def getStyleString\n\t\tstyle=\"\"\n\t\t(1..@StyleLtarr.length).each do |i|\n\t\t\tstyle=style+@StylePrefix+(i).to_s+\" lt \"+@StyleLtarr[i-1]+\" lw \"+@oc[\"LineWidth\"]\n\t\t\tstyle=style+\" pt \"+@StylePtarr[i-1]+\" ps 0.5;\\n\"\n\t\tend\n\t\tstyle=style+\"set style line 20 lt 7 lw 1 pt 4 ps 0.5;\\n\"\n\t\treturn style\n\tend",
"def style; end",
"def style; end",
"def style; end",
"def removeStyleName(style)\n styleNameHelper(MODE_REM, style)\n end",
"def styles=(styles)\n @styles = (%w[man] + styles).uniq\n end",
"def truncate_words(options = {})\n stripped = ActionController::Base.helpers.strip_tags(self)\n\n max_length = options[:max_chars] || 100\n omission = options[:omission] || \"...\"\n center = options[:center]\n highlight = [options[:highlight]].flatten.compact\n highlight_class = options[:highlight_class] || \"highlight\"\n\n if max_length < stripped.length\n if center\n r_limit = stripped.index(center) + center.length + ((max_length - center.length) / 2) - 1 - omission.length\n l_limit = stripped.index(center) - ((max_length - center.length) / 2) + omission.length\n\n if l_limit < 0\n r_limit -= l_limit\n r_limit += omission.length\n l_limit = 0\n end\n if r_limit > stripped.length\n l_limit -= r_limit - stripped.length\n l_limit -= omission.length\n r_limit = stripped.length\n end\n result = stripped[l_limit..r_limit]\n if l_limit >0 && stripped[l_limit-1,1] != \" \"\n result = result[result.index(\" \")+1..-1]\n end\n if r_limit < stripped.length && stripped[r_limit + 1,1] != \" \"\n result = result[0..(result.rindex(\" \")-1)]\n end\n\n result = omission + result + omission\n else\n limit = max_length - 1 - omission.length\n result = stripped[0..limit]\n if stripped[limit + 1,1] != \" \"\n if result.rindex(\" \")\n result = result[0..(result.rindex(\" \")-1)]\n else\n result = \"\"\n end\n end\n result += omission\n end\n else\n result = stripped\n end\n\n highlight.each do |h|\n result = result.gsub(h, \"<span class=\\\"#{highlight_class}\\\">#{h}</span>\")\n end\n result\n\n\n end",
"def detected_styles=(_arg0); end",
"def styles; end",
"def styles; end",
"def styles; end",
"def paragraph_style_mappings\n {\n 'header-1' => 'header1',\n 'header-2' => 'header2',\n 'header-3' => 'header3',\n 'hr' => 'horizontalRule',\n 'p.normal' => 'normal',\n 'p.test' => 'paraTest',\n }\n end",
"def list_styles(**opt)\n # Overridden by the subclass if configured for search analysis.\n end",
"def is_character_style?\n false\n end",
"def use_style=(style)\n end",
"def wrapped_by_paragraph; end",
"def test_paragraph_props_passed_to_runs\n input = '<p style=\"color: #123456\"><b>Lorem</b><span>ipsum</span></p>'\n expected_output = <<-DOCX.strip\n <w:p>\n <w:pPr>\n <w:pStyle w:val=\"Paragraph\" />\n </w:pPr>\n <w:r>\n <w:rPr>\n <w:color w:val=\"123456\" />\n <w:b />\n </w:rPr>\n <w:t xml:space=\"preserve\">Lorem</w:t>\n </w:r>\n <w:r>\n <w:rPr>\n <w:color w:val=\"123456\" />\n </w:rPr>\n <w:t xml:space=\"preserve\">ipsum</w:t>\n </w:r>\n </w:p>\n DOCX\n assert_equal normalize_wordml(expected_output), process(input)\n end",
"def draw_word(x, y, xx, width, word, mh, test)\n space = xx == 0 ? '' : ' '\n word_width = text_size(space + word).width\n if !(word_width > width) && (xx + word_width > width)\n xx = 0\n y += line_height\n @paragraph_lines += 1\n raise TooMuchTextEception.new('Limite superato') if mh && y > mh\n space = ''\n end\n draw_text(x + xx, y, word_width, 24, space + word) unless test\n xx += word_width\n {:x => xx, :y => y}\n end",
"def style\n defined?(@style) ? @style : 0\n end",
"def span(stylename, content)\n %Q(<text:span text:style-name=\"#{stylename}\">#{ERB::Util.h(content)}</text:span>)\n end",
"def custom_styles(emote)\n if (1..38).include? emote.id\n 'style=\"font-size: 40px;\"'\n end\n end",
"def mask_article(string, words)\n words.each { |x| string.gsub!(x, strike(x))}\n string\nend",
"def get_basic_style\n (\"#{role} #{$aod_current_cell_style[$aod_tl]} #{$aod_current_list_item_style[$aod_ll]}\").strip\n end",
"def style\n end",
"def paragraph_style_mappings\n self.class.paragraph_style_mappings\n end",
"def is_document_style?\n true\n end",
"def style_it\n\n\t\t#Fetches the style class from the list of ./styles.\n\t\tstyle_instance = fetch_style_class\n\n\t\tFile.open( @file, \"r\" ) do |input|\n\t\t File.open( \"#{File.dirname(@file)}/sc_#{File.basename(@file)}\" , \"w\") do |output|\n\n\t\t\tcomment_lines = []\n\t\t\tshow_something?(lines = input.readlines)\n\t\t\t\n\t\t\tlines.each do |line|\n\t\t\t if line[/\\S/] == @options[:literal] \n\t\t\t\tcomment_lines << line\n\t\t\t elsif not comment_lines.empty?\n\t\t\t\tmodified_comments = style_instance.style_it comment_lines \n\t\t\t\tcomment_lines.clear\n\t\t\t\toutput << modified_comments\n\t\t\t\toutput << line\n\t\t\t else\n\t\t\t\toutput << line\n\t\t\t end\n\t\t\tend\n\n\t\t end\n\t\tend\n\t\tputs \"Done !\"\n\t end",
"def parse_emphasis; end",
"def style\n self\n end",
"def defined_style_conversions; end",
"def start_word_pattern; end",
"def styleNameHelper(mode, style=nil) \n unless elem = getStyleElement()\n raise \"Null widget handle!\"\n end\n\n className = DOM.getProperty(elem, \"className\").strip\n\n # Ensure a primary style name\n if className.empty?\n className = STYLE_EMPTY\n DOM.setProperty(elem, \"className\", className)\n end\n\n if mode != MODE_GET\n # Style names cannot contain leading or trailing whitespace, and cannot\n # legally be empty.\n style = style.strip \n raise \"Style names cannot be empty\" if style.empty?\n end\n\n arr = className.split(\" \")\n\n # The primary style name is always the first token of the full CSS class name.\n primary = arr.first\n\n return primary if mode == MODE_GET\n raise \"Cannot remove primary style name\" if mode == MODE_REM and primary == style \n\n newClassName = [] \n\n `var e, s;\n for (var i=0; i<#<arr>.length; i++)\n {\n e = #<arr>[i];\n if (e == '') continue;\n \n if (#<mode> == #<MODE_SET>)\n {\n // set primary name -> update all dependent style names\n if (e.indexOf(#<primary>) != 0)\n {\n // +e+ doesnt start with the old primary style name \n // -> we dont touch it and keep it!\n s = e;\n }\n else \n {\n // replace +primary+ with +style+ \n s = #<style> + e.substring(#<primary>.length);\n }\n }\n else /* MODE_ADD or MODE_REM */\n {\n // remove the style. in case of MODE_ADD, we add it back later!\n s = (e == #<style>) ? null : e; \n }\n \n if (s) #<newClassName>.push(s);\n }\n\n if (#<mode> == #<MODE_ADD>)\n {\n #<newClassName>.push(#<style>);\n }\n\n #<newClassName> = #<newClassName>.join(\" \");`\n\n DOM.setProperty(elem, \"className\", newClassName)\n end",
"def style\n @style\n end",
"def process(type, text, page)\n if type == \"Underline\"\n if @out[-1].index(text.strip)\n @out << @out.pop.gsub(text.strip,\"::::#{text.strip}::::\")\n else\n type = \"Underline-standalone\"\n end\n end\n return type == \"Underline\" ? nil : format(type, text, page) \nend",
"def style\n return @style\n end",
"def style\n @style ||= Style.new(attributes[:style])\n end",
"def style(options); end",
"def style_identifier=(style_identifier)\n validator = EnumAttributeValidator.new('String', [\"Normal\", \"Heading1\", \"Heading2\", \"Heading3\", \"Heading4\", \"Heading5\", \"Heading6\", \"Heading7\", \"Heading8\", \"Heading9\", \"Index1\", \"Index2\", \"Index3\", \"Index4\", \"Index5\", \"Index6\", \"Index7\", \"Index8\", \"Index9\", \"Toc1\", \"Toc2\", \"Toc3\", \"Toc4\", \"Toc5\", \"Toc6\", \"Toc7\", \"Toc8\", \"Toc9\", \"NormalIndent\", \"FootnoteText\", \"CommentText\", \"Header\", \"Footer\", \"IndexHeading\", \"Caption\", \"TableOfFigures\", \"EnvelopeAddress\", \"EnvelopeReturn\", \"FootnoteReference\", \"CommentReference\", \"LineNumber\", \"PageNumber\", \"EndnoteReference\", \"EndnoteText\", \"TableOfAuthorities\", \"Macro\", \"ToaHeading\", \"List\", \"ListBullet\", \"ListNumber\", \"List2\", \"List3\", \"List4\", \"List5\", \"ListBullet2\", \"ListBullet3\", \"ListBullet4\", \"ListBullet5\", \"ListNumber2\", \"ListNumber3\", \"ListNumber4\", \"ListNumber5\", \"Title\", \"Closing\", \"Signature\", \"DefaultParagraphFont\", \"BodyText\", \"BodyTextInd\", \"ListContinue\", \"ListContinue2\", \"ListContinue3\", \"ListContinue4\", \"ListContinue5\", \"MessageHeader\", \"Subtitle\", \"Salutation\", \"Date\", \"BodyText1I\", \"BodyText1I2\", \"NoteHeading\", \"BodyText2\", \"BodyText3\", \"BodyTextInd2\", \"BodyTextInd3\", \"BlockText\", \"Hyperlink\", \"FollowedHyperlink\", \"Strong\", \"Emphasis\", \"DocumentMap\", \"PlainText\", \"EmailSignature\", \"HtmlTopOfForm\", \"HtmlBottomOfForm\", \"NormalWeb\", \"HtmlAcronym\", \"HtmlAddress\", \"HtmlCite\", \"HtmlCode\", \"HtmlDefinition\", \"HtmlKeyboard\", \"HtmlPreformatted\", \"HtmlSample\", \"HtmlTypewriter\", \"HtmlVariable\", \"TableNormal\", \"CommentSubject\", \"NoList\", \"OutlineList1\", \"OutlineList2\", \"OutlineList3\", \"TableSimple1\", \"TableSimple2\", \"TableSimple3\", \"TableClassic1\", \"TableClassic2\", \"TableClassic3\", \"TableClassic4\", \"TableColorful1\", \"TableColorful2\", \"TableColorful3\", \"TableColumns1\", \"TableColumns2\", \"TableColumns3\", \"TableColumns4\", \"TableColumns5\", \"TableGrid1\", \"TableGrid2\", \"TableGrid3\", \"TableGrid4\", \"TableGrid5\", \"TableGrid6\", \"TableGrid7\", \"TableGrid8\", \"TableList1\", \"TableList2\", \"TableList3\", \"TableList4\", \"TableList5\", \"TableList6\", \"TableList7\", \"TableList8\", \"Table3DEffects1\", \"Table3DEffects2\", \"Table3DEffects3\", \"TableContemporary\", \"TableElegant\", \"TableProfessional\", \"TableSubtle1\", \"TableSubtle2\", \"TableWeb1\", \"TableWeb2\", \"TableWeb3\", \"BalloonText\", \"TableGrid\", \"TableTheme\", \"PlaceholderText\", \"NoSpacing\", \"LightShading\", \"LightList\", \"LightGrid\", \"MediumShading1\", \"MediumShading2\", \"MediumList1\", \"MediumList2\", \"MediumGrid1\", \"MediumGrid2\", \"MediumGrid3\", \"DarkList\", \"ColorfulShading\", \"ColorfulList\", \"ColorfulGrid\", \"LightShadingAccent1\", \"LightListAccent1\", \"LightGridAccent1\", \"MediumShading1Accent1\", \"MediumShading2Accent1\", \"MediumList1Accent1\", \"Revision\", \"ListParagraph\", \"Quote\", \"IntenseQuote\", \"MediumList2Accent1\", \"MediumGrid1Accent1\", \"MediumGrid2Accent1\", \"MediumGrid3Accent1\", \"DarkListAccent1\", \"ColorfulShadingAccent1\", \"ColorfulListAccent1\", \"ColorfulGridAccent1\", \"LightShadingAccent2\", \"LightListAccent2\", \"LightGridAccent2\", \"MediumShading1Accent2\", \"MediumShading2Accent2\", \"MediumList1Accent2\", \"MediumList2Accent2\", \"MediumGrid1Accent2\", \"MediumGrid2Accent2\", \"MediumGrid3Accent2\", \"DarkListAccent2\", \"ColorfulShadingAccent2\", \"ColorfulListAccent2\", \"ColorfulGridAccent2\", \"LightShadingAccent3\", \"LightListAccent3\", \"LightGridAccent3\", \"MediumShading1Accent3\", \"MediumShading2Accent3\", \"MediumList1Accent3\", \"MediumList2Accent3\", \"MediumGrid1Accent3\", \"MediumGrid2Accent3\", \"MediumGrid3Accent3\", \"DarkListAccent3\", \"ColorfulShadingAccent3\", \"ColorfulListAccent3\", \"ColorfulGridAccent3\", \"LightShadingAccent4\", \"LightListAccent4\", \"LightGridAccent4\", \"MediumShading1Accent4\", \"MediumShading2Accent4\", \"MediumList1Accent4\", \"MediumList2Accent4\", \"MediumGrid1Accent4\", \"MediumGrid2Accent4\", \"MediumGrid3Accent4\", \"DarkListAccent4\", \"ColorfulShadingAccent4\", \"ColorfulListAccent4\", \"ColorfulGridAccent4\", \"LightShadingAccent5\", \"LightListAccent5\", \"LightGridAccent5\", \"MediumShading1Accent5\", \"MediumShading2Accent5\", \"MediumList1Accent5\", \"MediumList2Accent5\", \"MediumGrid1Accent5\", \"MediumGrid2Accent5\", \"MediumGrid3Accent5\", \"DarkListAccent5\", \"ColorfulShadingAccent5\", \"ColorfulListAccent5\", \"ColorfulGridAccent5\", \"LightShadingAccent6\", \"LightListAccent6\", \"LightGridAccent6\", \"MediumShading1Accent6\", \"MediumShading2Accent6\", \"MediumList1Accent6\", \"MediumList2Accent6\", \"MediumGrid1Accent6\", \"MediumGrid2Accent6\", \"MediumGrid3Accent6\", \"DarkListAccent6\", \"ColorfulShadingAccent6\", \"ColorfulListAccent6\", \"ColorfulGridAccent6\", \"SubtleEmphasis\", \"IntenseEmphasis\", \"SubtleReference\", \"IntenseReference\", \"BookTitle\", \"Bibliography\", \"TocHeading\", \"PlainTable1\", \"PlainTable2\", \"PlainTable3\", \"PlainTable4\", \"PlainTable5\", \"TableGridLight\", \"GridTable1Light\", \"GridTable2\", \"GridTable3\", \"GridTable4\", \"GridTable5Dark\", \"GridTable6Colorful\", \"GridTable7Colorful\", \"GridTable1LightAccent1\", \"GridTable2Accent1\", \"GridTable3Accent1\", \"GridTable4Accent1\", \"GridTable5DarkAccent1\", \"GridTable6ColorfulAccent1\", \"GridTable7ColorfulAccent1\", \"GridTable1LightAccent2\", \"GridTable2Accent2\", \"GridTable3Accent2\", \"GridTable4Accent2\", \"GridTable5DarkAccent2\", \"GridTable6ColorfulAccent2\", \"GridTable7ColorfulAccent2\", \"GridTable1LightAccent3\", \"GridTable2Accent3\", \"GridTable3Accent3\", \"GridTable4Accent3\", \"GridTable5DarkAccent3\", \"GridTable6ColorfulAccent3\", \"GridTable7ColorfulAccent3\", \"GridTable1LightAccent4\", \"GridTable2Accent4\", \"GridTable3Accent4\", \"GridTable4Accent4\", \"GridTable5DarkAccent4\", \"GridTable6ColorfulAccent4\", \"GridTable7ColorfulAccent4\", \"GridTable1LightAccent5\", \"GridTable2Accent5\", \"GridTable3Accent5\", \"GridTable4Accent5\", \"GridTable5DarkAccent5\", \"GridTable6ColorfulAccent5\", \"GridTable7ColorfulAccent5\", \"GridTable1LightAccent6\", \"GridTable2Accent6\", \"GridTable3Accent6\", \"GridTable4Accent6\", \"GridTable5DarkAccent6\", \"GridTable6ColorfulAccent6\", \"GridTable7ColorfulAccent6\", \"ListTable1Light\", \"ListTable2\", \"ListTable3\", \"ListTable4\", \"ListTable5Dark\", \"ListTable6Colorful\", \"ListTable7Colorful\", \"ListTable1LightAccent1\", \"ListTable2Accent1\", \"ListTable3Accent1\", \"ListTable4Accent1\", \"ListTable5DarkAccent1\", \"ListTable6ColorfulAccent1\", \"ListTable7ColorfulAccent1\", \"ListTable1LightAccent2\", \"ListTable2Accent2\", \"ListTable3Accent2\", \"ListTable4Accent2\", \"ListTable5DarkAccent2\", \"ListTable6ColorfulAccent2\", \"ListTable7ColorfulAccent2\", \"ListTable1LightAccent3\", \"ListTable2Accent3\", \"ListTable3Accent3\", \"ListTable4Accent3\", \"ListTable5DarkAccent3\", \"ListTable6ColorfulAccent3\", \"ListTable7ColorfulAccent3\", \"ListTable1LightAccent4\", \"ListTable2Accent4\", \"ListTable3Accent4\", \"ListTable4Accent4\", \"ListTable5DarkAccent4\", \"ListTable6ColorfulAccent4\", \"ListTable7ColorfulAccent4\", \"ListTable1LightAccent5\", \"ListTable2Accent5\", \"ListTable3Accent5\", \"ListTable4Accent5\", \"ListTable5DarkAccent5\", \"ListTable6ColorfulAccent5\", \"ListTable7ColorfulAccent5\", \"ListTable1LightAccent6\", \"ListTable2Accent6\", \"ListTable3Accent6\", \"ListTable4Accent6\", \"ListTable5DarkAccent6\", \"ListTable6ColorfulAccent6\", \"ListTable7ColorfulAccent6\", \"SmartLink\", \"Mention\", \"SmartHyperlink\", \"Hashtag\", \"UnresolvedMention\", \"User\", \"Nil\"])\n if style_identifier.to_i == 0\n unless validator.valid?(style_identifier)\n raise ArgumentError, \"invalid value for 'style_identifier', must be one of #{validator.allowable_values}.\"\n end\n @style_identifier = style_identifier\n else\n @style_identifier = validator.allowable_values[style_identifier.to_i]\n end\n end",
"def test_speak_as_normal\n style = \"#speak-as-spell-out-local,\n #speak-as-spell-out-inherit,\n #speak-as-spell-out-local-ignore,\n #speak-as-spell-out-inherit-ignore {\n speak-as: spell-out;\n }\n #speak-as-lp-local,\n #speak-as-lp-inherit,\n #speak-as-lp-local-ignore,\n #speak-as-lp-inherit-ignore {\n speak-as: literal-punctuation;\n }\n #speak-as-np-local,\n #speak-as-np-inherit,\n #speak-as-np-local-ignore,\n #speak-as-np-inherit-ignore {\n speak-as: no-punctuation;\n }\n #speak-as-digits-local,\n #speak-as-digits-inherit,\n #speak-as-digits-local-ignore,\n #speak-as-digits-inherit-ignore {\n speak-as: digits;\n }\n span, div {\n speak-as: normal;\n }\"\n html_parser = Hatemile::Util::Html::NokogiriLib::NokogiriHTMLDOMParser.new(\n \"<!DOCTYPE html>\n <html>\n <head>\n <title>HaTeMiLe Tests</title>\n <meta charset=\\\"UTF-8\\\" />\n </head>\n <body>\n <span id=\\\"speak-as-spell-out-local\\\">Speak this text.</span>\n <div id=\\\"speak-as-spell-out-inherit\\\">\n Speak <strong>this text.</strong>\n </div>\n <span id=\\\"speak-as-lp-local\\\">Speak this text.</span>\n <div id=\\\"speak-as-lp-inherit\\\">\n Speak <strong>this text.</strong>\n </div>\n <span id=\\\"speak-as-np-local\\\">Speak this text.</span>\n <div id=\\\"speak-as-np-inherit\\\">\n Speak <strong>this text.</strong>\n </div>\n <span id=\\\"speak-as-digits-local\\\">111</span>\n <div id=\\\"speak-as-digits-inherit\\\">\n 123 <strong>456</strong>\n </div>\n </body>\n </html>\"\n )\n css_parser = Hatemile::Util::Css::Rcp::RCPParser.new(style)\n css = Hatemile::Implementation::AccessibleCSSImplementation.new(\n html_parser,\n css_parser,\n @configure\n )\n css.provide_all_speak_properties\n speak_as_spell_out_local = html_parser.find(\n '#speak-as-spell-out-local'\n ).first_result\n speak_as_spell_out_inherit = html_parser.find(\n '#speak-as-spell-out-inherit'\n ).first_result\n speak_as_lp_local = html_parser.find('#speak-as-lp-local').first_result\n speak_as_lp_inherit = html_parser.find('#speak-as-lp-inherit').first_result\n speak_as_digits_local = html_parser.find(\n '#speak-as-digits-local'\n ).first_result\n speak_as_digits_inherit = html_parser.find(\n '#speak-as-digits-inherit'\n ).first_result\n\n assert_equal('Speak this text.', speak_as_spell_out_local.get_text_content)\n assert_equal(\n 'Speak this text.',\n speak_as_spell_out_inherit.get_text_content.strip\n )\n assert_equal('Speak this text.', speak_as_lp_local.get_text_content.strip)\n assert_equal('Speak this text.', speak_as_lp_inherit.get_text_content.strip)\n assert_nil(\n html_parser.find('#speak-as-np-local [aria-hidden]').first_result\n )\n assert_nil(\n html_parser.find('#speak-as-np-inherit [aria-hidden]').first_result\n )\n assert_equal('111', speak_as_digits_local.get_text_content)\n assert_equal('123 456', speak_as_digits_inherit.get_text_content.strip)\n end",
"def set_styles\n self.has_styles = true\n self.twitter_style = true\n end",
"def end_word_pattern; end",
"def properties_word_ml; end",
"def font_style(style=nil)\n cur_page.font_style(style)\n end",
"def strike text\n if text =~ /\\A[a-z\\d.\\/-]+\\z/i then\n \"~#{text}~\"\n else\n \"<s>#{text}</s>\"\n end\n end",
"def styles\n @document.styles\n end",
"def getStyleName\n styleNameHelper(MODE_GET)\n end",
"def styles(text = nil, &block)\n @styles_render = text || block if (text || block)\n end",
"def is_document_style?\n false\n end",
"def set_style(*v)\n styles = v.map { |i| @@style[i.to_sym] }.transpose\n prepend(\"\\e[\" << styles[0].join(';') << 'm')\n concat(\"\\e[\" << styles[1].join(';') << 'm')\n end",
"def tokenizer_category_header_style\n TokenExtractor.new(\n :style,\n /(?<=0)\\s+(stile\\slibero|farfalla|dorso|rana|misti)/ix,\n /\\s*(master|under)/i\n )\n end",
"def red_style(string)\n pastel = Pastel.new\n red_string = pastel.red(\"#{string}\")\n return red_string\nend",
"def allow_short_words\n not @emphasis[:ignore_short_words]\n end",
"def style\n Style.new(self)\n end",
"def method_missing(stylename, &styles)\n properties = Limelight.new(&styles).styles\n style(stylename, properties)\n end",
"def italic; end",
"def italic; end",
"def style(attachment, style_name)\n style_name || attachment.default_style\n end",
"def nice_typography(text)\n widont(amp(rubypants(text)))\n end",
"def process(type, text, page)\n if type == \"Underline\"\n if @out[-1] && @out[-1].index(text.strip)\n @out << @out.pop.gsub(text.strip,\"::::#{text.strip}::::\")\n else\n type = \"Underline-standalone\"\n end\n end\n return type == \"Underline\" ? nil : format(type, text, page)\nend",
"def remove_style(style_str, screen)\n if screen\n styles_pool[screen]&.delete(style_str)\n elsif styles_pool[:_common]\n styles_pool[:_common].delete(style_str)\n end\n end",
"def styles\n return @metadata[:styles]\n end",
"def word(before: true)\n start_pos = word_start_pos(before: before)\n @text[start_pos..word_end_pos(from: start_pos)]\n end"
] | [
"0.6091082",
"0.60830545",
"0.60539037",
"0.5978823",
"0.5978823",
"0.5978823",
"0.5910565",
"0.5844202",
"0.582488",
"0.57750523",
"0.5755645",
"0.5681169",
"0.56772906",
"0.5606135",
"0.56059647",
"0.5570531",
"0.55613095",
"0.55511254",
"0.5541017",
"0.5534038",
"0.54770255",
"0.54493505",
"0.54439735",
"0.54038084",
"0.5402558",
"0.5401929",
"0.5373477",
"0.5373477",
"0.5373477",
"0.53515756",
"0.53476804",
"0.53434885",
"0.5342299",
"0.5317227",
"0.53096265",
"0.530655",
"0.5303238",
"0.53019327",
"0.52979887",
"0.5297086",
"0.5297086",
"0.5297086",
"0.5296938",
"0.5290467",
"0.5281085",
"0.52577263",
"0.52460396",
"0.52460396",
"0.52460396",
"0.52376527",
"0.52297837",
"0.52265763",
"0.5222748",
"0.5208685",
"0.5203898",
"0.52016306",
"0.52006257",
"0.5196561",
"0.5188491",
"0.51812905",
"0.5175746",
"0.5168576",
"0.5160298",
"0.51500857",
"0.5144662",
"0.5125454",
"0.5113012",
"0.5110078",
"0.5101769",
"0.5099171",
"0.50947267",
"0.50909936",
"0.508959",
"0.50819385",
"0.50765216",
"0.5066843",
"0.5064463",
"0.5062016",
"0.505764",
"0.5052678",
"0.5050539",
"0.5038952",
"0.5035171",
"0.50350237",
"0.5030872",
"0.5029662",
"0.50247055",
"0.50210947",
"0.501853",
"0.5004662",
"0.49905822",
"0.49855503",
"0.4983963",
"0.4983963",
"0.49772787",
"0.49771023",
"0.4975217",
"0.4959995",
"0.4959196",
"0.49576166"
] | 0.5629745 | 13 |
For each root ul/ol we are going to process all children, and then replace the root ul/ol. | def process_lists
@doc.css('ul', 'ol').each do |list|
# If we get a list (ol/ul) which is not a root, we stop processing.
if list.ancestors('ul').count > 0 || list.ancestors('ol').count > 0
return
end
textile_list = []
list.css('li').each do |li|
process_li(li, textile_list)
end
list.replace("\n\n" + textile_list.join("\n") + "\n\n")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_child_nodes(node)\n node.xpath(\"./li/#{@list_tag}\").each do |list|\n # transfer attributes from parent now because the list tag will\n # no longer be a child and won't inheirit them as usual\n transfer_node_attributes(list.children, list.parent.attributes)\n list.parent.add_next_sibling(list)\n end\n end",
"def reorganize\n list = params[:list]\n prev_page = nil\n last_root = nil\n list.each_with_index do |item, i|\n item_params = item[1]\n\n page = Page.find(item_params['id'].to_i)\n \n # if root of tree on rails side\n if item_params['parent_id'] == ''\n page.parent_id = nil\n if last_root\n page.move_to_right_of(last_root.id)\n end\n last_root = page\n page.save\n\n else\n page.parent_id = item_params['parent_id'].to_i\n page.save\n \n # shift to the right of previous element if parent is the same\n if prev_page.parent_id == page.parent_id\n page.move_to_right_of(prev_page.id)\n else\n\n # iterate backwards to find last sibling\n current_index = i - 1 \n found_sibling = false\n keys = list.keys\n\n while found_sibling == false and current_index > 0 do\n if list[keys[current_index]]['parent_id'] == item_params['parent_id']\n page.move_to_right_of(list[keys[current_index]]['id'])\n found_sibling = true\n else\n current_index -= 1\n end\n end\n\n end\n end\n\n # set previous item\n prev_page = page\n\n end\n\n respond_to do |format|\n format.json { head :ok } \n end\n end",
"def rearrange_children\n if rearrange_children?\n self.disable_timestamp_callback()\n self.children.each do |child|\n child.update_path!\n child.save\n # child.reload # might not need to reload?\n end\n self.enable_timestamp_callback()\n end\n @rearrange_children = false\n true\n end",
"def apply_children\n \n end",
"def process_child_nodes(node); end",
"def each(&block)\n squish = lambda do |tree, list|\n new_children = tree.children.reduce(list) { |acc, elem| squish.call(elem, acc) }\n [tree.root].lazy_append(new_children)\n end\n\n squish.call(self, [])\n\n # base = [root]\n # recursive = children.map(&:each)\n # res = base.lazy_append(recursive)\n\n # return res.each(&block) if block_given?\n\n # res\n\n # res = [[root], children.flat_map(&:each)].lazy.flat_map(&:lazy)\n # res = res.map(&block) if block_given?\n # res\n end",
"def replace_nodes\n doc.xpath(\".//text()\").each do |node|\n next if has_ancestor?(node, ignored_ancestor_tags)\n\n content = node.to_html\n html = yield content, node\n\n next if html == content || html.nil?\n if html.length == 0\n node.parent.remove\n else\n node.replace(html)\n end\n end\n end",
"def update_children\n self.children.each do |child|\n child.update_children\n unless child.new_record?\n child.save\n child.move_to_child_of(self) if child.parent_id != self.id\n end\n end if self.changed?\n end",
"def update_tree(element)\n last_blank = nil\n element.children.map! do |child|\n if child.type == :raw_text\n last_blank = nil\n reset_env(src: ::Kramdown::Utils::StringScanner.new(child.value, element.options[:location]),\n text_type: :text)\n parse_spans(child)\n child.children\n elsif child.type == :eob\n update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]\n []\n elsif child.type == :blank\n if last_blank\n last_blank.value << child.value\n []\n else\n last_blank = child\n child\n end\n else\n last_blank = nil\n update_tree(child)\n update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]\n # DEPRECATED: option auto_id_stripping will be removed in 2.0 because then this will be\n # the default behaviour\n if child.type == :dt || (child.type == :header && @options[:auto_id_stripping])\n update_raw_text(child)\n end\n child\n end\n end.flatten!\n end",
"def iterate_children(ts, block, new_model)\n ts.children.each do |cs|\n # assumes there is only one element - could iterate instead but what case would that be?\n element = block.css(cs.selector).first\n\n handle_element(cs, element, new_model)\n end # end top selector children iteration\n end",
"def array\n # assign the sorted tree to a variable\n newlist = params[:ul].sort\n # initialize the previous item\n previous = nil\n #loop through each item in the new list (passed via ajax)\n newlist.each_with_index do |array, index|\n # get the category id of the item being moved\n moved_item_id = array[1][:id].gsub(/category_/,'')\n # find the object that is being moved (in database)\n @current_category = Category.find_by_id(moved_item_id)\n # if this is the first item being moved, move it to the root.\n unless previous.nil?\n @previous_item = Category.find_by_id(previous)\n @current_category.move_to_right_of(@previous_item)\n else\n @current_category.move_to_root\n end\n # then, if this item has children we need to loop through them\n unless array[1][:children].blank?\n # NOTE: unless there are no children in the array, send it to the recursive children function\n childstuff(array[1], @current_category)\n end\n # set previous to the last moved item, for the next round\n previous = moved_item_id\n end\n Category.rebuild!\n render :nothing => true\n end",
"def each_with_level &block\n # @todo A bit of a hack that I would like to fix one day...\n @root.children.each do |element|\n recursive_each_with_level element, 1, block\n end\n end",
"def top_level_li\n lambda do |env|\n name, node = env[:node_name], env[:node]\n if name == LIST_ITEM && !node.ancestors.any? { |n| LISTS.include?(n.name) }\n node.replace(node.children)\n end\n end\n end",
"def each\n @children.each {|child| yield child}\n end",
"def process_tree_with_renew\n @process_tree = nil\n process_tree\n end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def visit_children(parent)\n parent.children.each do |child|\n child.node_parent = parent\n visit(child)\n end\n end",
"def replace_root(obj)\n set_root(obj, children)\n end",
"def update_subtree\n children.find_all {|child| child.kind_of?(NonLeafNode)}.each do |child|\n child.update_subtree\n end\n update_shash(false)\n end",
"def termdef_unnest_cleanup(xmldoc)\n desgn = \"//p/admitted | //p/deprecates | //p/preferred | //p//related\"\n nodes = xmldoc.xpath(desgn)\n while !nodes.empty?\n nodes[0].parent.replace(nodes[0].parent.children)\n nodes = xmldoc.xpath(desgn)\n end\n end",
"def rearrange_children!\n @rearrange_children = true\n end",
"def normalise!(tree)\n tree.each.with_index do |node, i|\n if node.is_a?(Array)\n if node.first == :loop && tree[i+1]\n key = tree[i+1][0]\n if key == :block\n tree[i+1][0] = :lblock\n elsif key == :query # wrap queries like `c.each(&:destroy)` \n tree[i+1] = [:lblock, tree[i+1]]\n end\n end\n tree[i] = normalise!(node)\n end\n end\n tree\n end",
"def update_tree(element); end",
"def replace_children(start_child_index, stop_child_index, t)\n # System.out.println(\"replaceChildren \"+startChildIndex+\", \"+stopChildIndex+\n # \" with \"+((BaseTree)t).toStringTree());\n # System.out.println(\"in=\"+toStringTree());\n if ((@children).nil?)\n raise IllegalArgumentException.new(\"indexes invalid; no children in list\")\n end\n replacing_how_many = stop_child_index - start_child_index + 1\n replacing_with_how_many = 0\n new_tree = t\n new_children = nil\n # normalize to a list of children to add: newChildren\n if (new_tree.is_nil)\n new_children = new_tree.attr_children\n else\n new_children = ArrayList.new(1)\n new_children.add(new_tree)\n end\n replacing_with_how_many = new_children.size\n num_new_children = new_children.size\n delta = replacing_how_many - replacing_with_how_many\n # if same number of nodes, do direct replace\n if ((delta).equal?(0))\n j = 0 # index into new children\n i = start_child_index\n while i <= stop_child_index\n child = new_children.get(j)\n @children.set(i, child)\n child.set_parent(self)\n child.set_child_index(i)\n j += 1\n i += 1\n end\n else\n if (delta > 0)\n # fewer new nodes than there were\n # set children and then delete extra\n j = 0\n while j < num_new_children\n @children.set(start_child_index + j, new_children.get(j))\n j += 1\n end\n index_to_delete = start_child_index + num_new_children\n c = index_to_delete\n while c <= stop_child_index\n # delete same index, shifting everybody down each time\n killed = @children.remove(index_to_delete)\n c += 1\n end\n freshen_parent_and_child_indexes(start_child_index)\n else\n # more new nodes than were there before\n # fill in as many children as we can (replacingHowMany) w/o moving data\n j = 0\n while j < replacing_how_many\n @children.set(start_child_index + j, new_children.get(j))\n j += 1\n end\n num_to_insert = replacing_with_how_many - replacing_how_many\n j_ = replacing_how_many\n while j_ < replacing_with_how_many\n @children.add(start_child_index + j_, new_children.get(j_))\n j_ += 1\n end\n freshen_parent_and_child_indexes(start_child_index)\n end\n end\n # System.out.println(\"out=\"+toStringTree());\n end",
"def process_all_nodes\n debug 'Start processing all nodes'\n hook 'pre_all'\n each_node do |node|\n process_node node\n end\n hook 'post_all'\n end",
"def iterate root_child_itr\t\t\t#to iterate over the nodes\t\t\n\t \n\t ## Collect root_child_itr.children in a variable since it being used twice\n\t ## Can you try using some other conditional construct other than loop and break?\n\t\twhile true\n\t\t ###### Use an intuitive variable name\n\t\t\tchild = root_child_itr.children\n\t\t\t\n\t\t\t##### if temp.children[0]\n\t\t\tif child.children[0] == nil\t\t\t#checking if the node is innermost as innermost node will not be having any childnode\n\t\t\t\t@@arr.push child\n break\n\t\t\telse\n\t\t\t\tscan root_child_itr\t\t# iterate over the childnodes if it is not the parent of the innermost node\n break\n\t\t\tend\t\t\n\t\tend\n\tend",
"def recurse_otml_dirs(&block)\n return unless self.has_otmls\n yield(self)\n self.children.each do |child|\n child.recurse_otml_dirs(&block)\n end\nend",
"def promote_container_children_to_current_level(parent, container)\n container.children.reverse_each {|c| parent.add_child(c) } \n parent.remove_child(container)\n end",
"def nestable_list_recursive(items, block)\n content_tag(:ol, class: 'dd-list') do\n tags = items.map do |item|\n content_tag(:li, class: 'dd-item', data: { id: item.to_param }) do\n content = capture_with_haml { block.call(item) }\n recurse = if item.children.empty?\n ''.html_safe\n else\n nestable_list_recursive(item.children, block)\n end\n\n content.html_safe + recurse\n end\n end\n\n tags.join.html_safe\n end\n end",
"def rearrange_recursively(klass, items, parent = nil)\n last = nil\n items.each do |item|\n record = klass.find(item['id'])\n if last\n record.move_to_right_of(last)\n else\n parent ? record.move_to_child_of(parent) : record.move_to_root\n end\n last = record\n if item['children']\n rearrange_recursively klass, item['children'], record\n end\n end\n end",
"def destroy_tree_from_leaves\n self.subdirectories.each do |subdirectory|\n subdirectory.destroy_tree_from_leaves\n end\n self.subdirectories.reload\n self.cfs_files.each do |cfs_file|\n cfs_file.destroy!\n end\n self.cfs_files.reload\n self.destroy!\n end",
"def process_self_and_descendants\n yield self\n descendants.each { |item| yield(item) }\n end",
"def each\n queue = [@root]\n until queue.empty?\n node = queue.shift\n queue += node.children\n yield node\n end\n end",
"def visit_all(&block)\n visit &block\n children.each {|c| c.visit_all &block}\n end",
"def each\n yield self\n children.each {|c| c.each {|n| yield n}}\n end",
"def each\n queue = [@root]\n until queue.empty?\n kids = queue.shift.children\n kids.each do |x| yield x end\n queue.concat kids\n end\n end",
"def update_unique_names_of_children\n unless root?\n self.descendants.each do |descendant|\n descendant.update_unique_name\n end\n end\n end",
"def post_process_kramdown_tree!(kramdown_tree)\n # override this to post process elements in the kramdown tree\n # NOTE: It's important to call the methods below for correct results.\n # You have two options:\n # 1. call super if you override this method\n # 2. copy the methods below into your own method if you need different sequence\n recursively_process_temp_em_class!(kramdown_tree, 'tmpNoBold')\n recursively_process_temp_em_class!(kramdown_tree, 'tmpNoItalics')\n recursively_merge_adjacent_elements!(kramdown_tree)\n recursively_clean_up_nested_ems!(kramdown_tree) # has to be called after process_temp_em_class\n recursively_push_out_whitespace!(kramdown_tree)\n # needs to run after whitespace has been pushed out so that we won't\n # have a leading \\t inside an :em that is the first child in a para.\n # After whitespace is pushed out, the \\t will be a direct :text child\n # of :p and first char will be easy to detect.\n recursively_sanitize_whitespace_during_import!(kramdown_tree)\n # merge again since we may have new identical siblings after all the\n # other processing.\n recursively_merge_adjacent_elements!(kramdown_tree)\n recursively_clean_up_tree!(kramdown_tree)\n # Run this again since we may have new locations with leading or trailing whitespace\n recursively_sanitize_whitespace_during_import!(kramdown_tree)\n # merge again since we may have new identical siblings after cleaning up the tree\n # e.g. an italic span with whitespace only between two text nodes was removed.\n recursively_merge_adjacent_elements!(kramdown_tree)\n end",
"def each(&proc)\n @subtrees.each(&proc)\n end",
"def each_recursive(&block)\n tree.each_recursive(&block)\n end",
"def apply_to_children(&block)\n self.entities.each do |entity|\n block.call(entity)\n entity.apply_to_children(&block)\n end\n end",
"def tree_map(&blk)\n children.inject([yield(self)]) do |trunk, child| \n trunk << child.tree_map(&blk)\n end\n end",
"def each(&block)\n sorted_children.each do |name, child|\n yield(name, child)\n end\n end",
"def each\n @children.each { |child| yield child }\n end",
"def map_nodes!(&ruby_block)\n @child = ruby_block.call(@child)\n @child.parent = self unless @child.parent\n end",
"def preorder\n preorder_helper(@root, [])\n end",
"def expand_current(nodes, klass)\n nodes.each {|node| node.old_parent = node.parent }\n list = klass.new(nodes)\n list.parent = self\n @nodes[@pos] = list\n end",
"def each_child\n \n end",
"def process_nodes(html_nodes, properties)\n html_nodes.flat_map do |node|\n # get tags from config\n parent_tag = fetch_tag(node.parent.name) if node.parent.name\n tag = fetch_tag(node.name)\n\n # remove all text nodes if the tag doesn't accept them\n node.search('./text()').remove if drop_text?(tag)\n\n # check node hierarchy\n validate_structure(parent_tag, tag)\n\n # merge properties\n local_props = merge_node_properties(node, tag, properties)\n if tag.ast_class\n tag.ast_class.new(@env, node, local_props)\n else\n process_nodes(node.children, local_props)\n end\n end\n end",
"def set_children_for(category, hash)\n if hash['children']\n hash['children'].each do |ch|\n child = Documents::Category.find(ch['id'])\n child.parent = category\n child.save\n\n set_children_for(child, ch)\n end\n else\n # Can't remove children, so nil out the parent of anything that's listed\n # as a child of this node\n category.children.each do |c|\n c.parent = nil\n c.save\n end\n end\n end",
"def traverse_nav_tree_and_convert_to_xml(node)\n \n # traverse subfolders, go deep\n if node_has_children(node)\n node.children.items.each do |child|\n traverse_nav_tree_and_convert_to_xml(child)\n end\n end\n \n return if node.nav_level == 0\n \n mod = node.dup\n\n link = node.link\n full_link = node.full_link\n \n mod.parent_link = parent_link = node.link[0..(link.rindex(\"/\") - 1)] if node.nav_level > 1\n \n if CONTENT_LINK_PREFIX && CONTENT_LINK_PREFIX.length > 0\n full_link = mod.full_link = \"/\" + CONTENT_LINK_PREFIX + node.full_link unless node.full_link.start_with?(\"/#{CONTENT_LINK_PREFIX}\")\n end\n\n \n mod.delete :source_path\n mod.delete :parent_path\n mod.delete :children\n\n\n #puts \"storing [#{mod.nav_level}][#{mod.nav_order}][#{mod.nav_type}] - #{mod.nav_title}\"\n case mod.nav_type \n \n when \"folder\"\n\t\t# do nothing for these\n when \"markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n \n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html) \n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n\n when \"folder+markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n\n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html)\n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\n img_sizes = {\n \"40%\" => \"min\",\n \"50%\" => \"small\",\n \"65%\" => \"medium\",\n \"100%\" => \"full\",\n \"600px\" => \"large\"\n }\n \n img_sizes.each do |size,name|\n img = xml.at_css \"img[width=\\\"#{size}\\\"]\"\n img['size'] = name if img\n puts img.inspect if img\n end\n\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n end\n \nend",
"def replace_children!\n replace(map do |x|\n case x\n when Array\n self.class.new(x, @file_name, @file_source)\n else x\n end\n end)\n end",
"def recursively_fix_breadcrumbs!(cards = collection_cards)\n cards.each do |card|\n next unless card.primary?\n\n if card.item.present?\n # have to reload in order to pick up new parent relationship\n card.item.reload.recalculate_breadcrumb!\n elsif card.collection_id.present?\n # this will run recursively rather than using breadcrumb to find all children\n card.collection.reload.recalculate_breadcrumb!\n card.collection.recursively_fix_breadcrumbs!\n end\n end\n end",
"def update_descendants_with_new_structure\n # Skip this if callbacks are disabled\n unless structure_callbacks_disabled?\n # If node is not a new record and structure was updated and the new structure is sane ...\n if changed.include?(self.base_class.structure_column.to_s) && !new_record? && sane_structure?\n # ... for each descendant ...\n unscoped_descendants.each do |descendant|\n # ... replace old ancestry with new ancestry\n descendant.without_structure_callbacks do\n column = self.class.structure_column\n v = read_attribute(column)\n descendant.update_attribute(\n column,\n descendant.read_attribute(descendant.class.structure_column).gsub(\n /^#{self.child_structure}/,\n if v.blank? then\n id.to_s\n else\n \"#{v}/#{id}\"\n end\n )\n )\n end\n end\n end\n end\n end",
"def process_descendants_and_self\n descendants.reverse.each { |item| yield(item) }\n yield self\n end",
"def map(&block)\n new_root = block.call(root)\n new_children = children.map { |child_tree| child_tree.map(&block) }\n LazyTree.new(new_root, new_children)\n end",
"def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end",
"def process_all_nodes\n debug 'Start processing all nodes'\n each_node do |node|\n process_node node\n end\n end",
"def all_children(accummulator=[])\n return accummulator if children.size == 0\n children.each do |child_id|\n child = Folder.get(child_id)\n accummulator << child\n child.all_children(accummulator)\n end\n accummulator\n end",
"def each(&block)\n tree.each(&block)\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def replace_children(parent, start_child_index, stop_child_index, t)\n raise NotImplementedError\n end",
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end",
"def each(&block)\n root.each(&block)\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def init_root binding, &block\n block.call(self)\n @is_first = @is_last = true\n @level = 0\n @item = nil\n @tabs ||= 0\n root = eval('@items',binding).find{|x| x.identifier == root_identifier}\n children_populate_recursive [root]\n end",
"def each(&block)\n each_node([], @root, block)\n end",
"def expand_children node=:current_index\n $multiplier = 999 if !$multiplier || $multiplier == 0\n node = row_to_node if node == :current_index\n return if node.children.empty? # or node.is_leaf?\n #node.children.each do |e| \n #expand_node e # this will keep expanding parents\n #expand_children e\n #end\n node.breadth_each($multiplier) do |e|\n expand_node e\n end\n $multiplier = 0\n _structure_changed true\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def convertUnits(el, parentMap, childMap, allIds)\n id = el[:id] || el[:ref] || \"root\"\n allIds << id\n #puts \"name=#{el.name} id=#{id.inspect} name=#{el[:label].inspect}\"\n\n # Create or update the main database record\n if el.name != \"ref\"\n puts \"Converting unit #{id}.\"\n unitType = id==\"root\" ? \"root\" : id==\"lbnl\" ? \"campus\" : el[:type]\n Unit.update_or_replace(id,\n type: unitType,\n name: id==\"root\" ? \"eScholarship\" : el[:label],\n status: el[:directSubmit] == \"moribund\" ? \"archived\" :\n el[:hide] == \"eschol\" ? \"hidden\" :\n \"active\"\n )\n\n # We can't totally fill in the brand attributes when initially inserting the record,\n # so do it as an update after inserting.\n attrs = {}\n el[:directSubmit] and attrs[:directSubmit] = el[:directSubmit]\n el[:hide] and attrs[:hide] = el[:hide]\n attrs.merge!(convertUnitBrand(id, unitType))\n Unit[id].update(attrs: JSON.generate(attrs))\n\n addDefaultWidgets(id, unitType)\n end\n\n # Now recursively process the child units\n UnitHier.where(unit_id: id).delete\n el.children.each { |child|\n if child.name != \"allStruct\"\n id or raise(\"id-less node with children\")\n childID = child[:id] || child[:ref]\n childID or raise(\"id-less child node\")\n parentMap[childID] ||= []\n parentMap[childID] << id\n childMap[id] ||= []\n childMap[id] << childID\n end\n convertUnits(child, parentMap, childMap, allIds)\n }\n\n # After traversing the whole thing, it's safe to form all the hierarchy links\n if el.name == \"allStruct\"\n puts \"Linking units.\"\n linkUnit(\"root\", childMap, Set.new)\n\n # Delete extraneous units from prior conversions\n deleteExtraUnits(allIds)\n end\nend",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def add_children(*nodes)\n nodes.flatten.each do |node|\n node.set_parent self\n end\n changed\n notify_observers :new_children, nodes.flatten\n end",
"def update_tree_nodes(node, parent_id, position)\n page = SitePage.find node['id']\n page.parent_id = parent_id\n page.position = position\n page.enabled = node['enabled']\n page.save\n unless node['children'].blank?\n node['children'].each_with_index do |leaf, index|\n update_tree_nodes leaf, node['id'], index\n end\n end\n end",
"def clear_children!\n @children.clear\n end",
"def collect_tree_up_from (foliage,\n parents,\n except_homepage,\n except_page,\n except_with_children)\n ancestry_string = parents.collect {|x| x.id.to_s }.join(\"/\")\n name_prefix = parents.collect {|x| x.title }.join(\" / \")\n name_prefix += \" / \" if name_prefix.present?\n\n our_mans_indexes = []\n foliage.each_index do |indx|\n if foliage[indx].ancestry.to_s == ancestry_string\n our_mans_indexes << indx\n end\n end\n\n leaves = []\n\n our_mans_indexes.reverse!\n our_mans_indexes.each do |indx|\n leaves << foliage.delete_at(indx)\n end\n\n leaves.sort! {|a,b| (a.prior == b.prior) ? a.id <=> b.id : a.prior <=> b.prior }\n result = []\n\n leaves.each do |leaf|\n do_writing = true\n if (except_page && leaf == except_page) || (except_homepage && leaf.home?)\n do_writing = false\n end\n result << [ name_prefix + leaf.title, leaf.id ] if do_writing\n unless do_writing == false && except_with_children\n result += collect_tree_up_from foliage,\n (parents + [ leaf ]),\n except_homepage,\n except_page,\n except_with_children\n end\n end\n\n result\n end",
"def each(&block)\n root.each(&block)\n end",
"def normalize\n return if @children.nil?\n old = nil\n children = @children.to_a.dup\n children.each do |child|\n if !old.nil? && old.nodeType == TEXT_NODE &&\n child.nodeType == TEXT_NODE\n old.appendData(child.nodeValue)\n self.removeChild(child)\n else\n if child.nodeType == ELEMENT_NODE\n child.normalize\n end\n old = child\n end\n end\n end",
"def transform(tree); end",
"def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end",
"def render_tree(elements, symbols, parents = [])\n i = 0\n x = elements.map do |li|\n last = elements.length == i+1\n\n current = indentation(parents, last, symbols) + li[:value]\n\n children = \"\"\n if li[:children].length > 0\n children = \"\\n\" + render_tree(li[:children], symbols, parents + [last])\n end\n\n i += 1\n current + children\n end\n\n x.join(\"\\n\")\n end",
"def walk &blk\n self.children.each do |child|\n yield child\n end\n self.children.each do |child|\n child.walk &blk\n end\n end",
"def map_nodes!(&ruby_block)\n # A block? Apply it on each child.\n @value = ruby_block.call(@value)\n map_whens!(&ruby_block)\n if @default then\n @default = ruby_block.call(@default)\n @default.parent = self unless @default.parent\n end\n end",
"def each_root_relation\n\t for rel in relations\n\t\tyield(rel) unless rel.parent\n\t end\n\tend",
"def each order=:preorder, &block\n # I know, I know. SGF is only preorder. Well, it's implemented, ain't it?\n # Stop complaining.\n case order\n when :preorder\n preorder @root, &block\n end\n end",
"def order\n # This will already have been deserialized by Rails, and is thus likely to\n # be an array (though maybe a Hash if there's only one of them).\n new_order = params[:order]\n new_order = [new_order] if new_order.is_a?(Hash)\n\n # Loop the roots and make them roots, then recursively set their children\n new_order.each do |h|\n id = h['id']\n category = Documents::Category.find(id)\n category.parent = nil\n category.save\n\n set_children_for(category, h)\n end\n\n head :no_content\n end",
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end",
"def each_existing_child &block\n children.each_with_index do |child, idx|\n if child.is_nil_parse? then no(\n \"NilParse found in call do each_existing_child(). \"<<\n \"fix this for #{short}\"\n ) end\n block.call(child, idx)\n end\n nil\n end",
"def replace_references_node(set, inner_html)\n set.each do |references_node|\n ol_node = references_node.document.create_element \"ol\"\n ol_node.inner_html = inner_html\n references_node.parent.replace(ol_node)\n end\n\n nil\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def traverse_sort_and_add_nav_order_to_nodes(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\n\t\t\t node.children.items.each_with_index do |child|\n\t\t\t\t if child.nav_type == \"folder\" || child.nav_type == \"folder+markdown\"\n\t\t\t\t\t items = traverse_sort_and_add_nav_order_to_nodes(child)\n\t\t\t\t\t child.children.items = items if items and items.size > 0\n\t\t\t\t end\n\t\t\t end\n\t\t \n\t\tend\t \n\t\n\t\thas_navig_yml = File.exist?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\n\t\tif has_navig_yml and node.children and node.children.items?\n\t\n\t\telse\n\t\t\treturn nil\t\t\n\t\tend \n\t\n\t\tsorted_nav_items = nil\n\t\n\t\tif node.children? and node.children.items?\n\t\t\tsorted_nav_items = node.children.items\n\t\tend\n\t\n\t\tif File.exists?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\t\t# load aaaa-navigation.yml\n\t\t\tnaml = Map.new(YAML.load_file(\"#{node.source_path}/aaaa-navigation.yml\"))\t\t\n\t\n\t\t\t# iterate and re-order navigation.yml\n\t\t\tsorted_nav_items = node.children.items\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1000\n\t\t\tend\n\n\t\t\tnaml.nav_items.each_with_index do |naml_item, i|\n\t\t\t\tsorted_nav_items.each do |sni| \n\t\t\t\t\tsni.nav_order = i if sni.source == naml_item.source\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tsorted_nav_items.sort! { |x, y| x.nav_order <=> y.nav_order }\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1\n\t\t\tend\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\t\t\t\t\t\t\t\t \n\t\tend\n\t\n\t\tsorted_nav_items\n\tend",
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end",
"def each &block\n @root.each(&block)\n end",
"def wrap_children(children)\n children.map { |c| NodeWrapper.new(c) if c.element? }.compact\n end",
"def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def traverse(&block)\n children.each{|j| j.traverse(&block) }\n block.call(self)\n end",
"def nested_array_to_html(nodes)\n classes = \"depth-#{ nodes.first[:depth] }\"\n classes += \" folder-tree\" if nodes.first[:depth].zero?\n\n html = \"<ul class=\\\"#{ classes }\\\">\"\n nodes.each do |node|\n html += \"<li>\"\n\n if node[:children]\n html += '<i class=\"icon-folder-close\"></i>'\n else\n html += '<i class=\"icon-file-alt\"></i>'\n end\n\n html += \"<span class=\\\"name\\\">#{ node[:name].strip }</span>\"\n unless (node[:children].nil? || node[:children].empty?)\n html += nested_array_to_html(node[:children]) \n end\n html += '</li>'\n end\n\n html += '</ul>'\n\n html\n end",
"def link_tree\n ''.html_safe.tap do |content|\n content << toggle_link\n\n unless leaf?\n content << h.content_tag(:ul) do\n h.content_tag_for(:li, children) do |c|\n c.decorate.link_tree\n end\n end\n end\n end\n end"
] | [
"0.62530977",
"0.6205985",
"0.62044185",
"0.61164755",
"0.60626346",
"0.60519624",
"0.6049954",
"0.60266316",
"0.5990934",
"0.59436643",
"0.5922585",
"0.58766913",
"0.5871193",
"0.5822433",
"0.58136374",
"0.57919",
"0.57919",
"0.5785689",
"0.5749788",
"0.5749248",
"0.5749038",
"0.571539",
"0.56957656",
"0.5674088",
"0.5669553",
"0.5668932",
"0.56536263",
"0.5648148",
"0.56271565",
"0.5612308",
"0.5592842",
"0.55907756",
"0.55875385",
"0.5583417",
"0.556153",
"0.5527784",
"0.5512387",
"0.5503905",
"0.549395",
"0.5493118",
"0.54868364",
"0.54858804",
"0.54844296",
"0.5479694",
"0.5470194",
"0.5445155",
"0.5440871",
"0.5440649",
"0.5438653",
"0.5435188",
"0.54324013",
"0.5424686",
"0.54130614",
"0.5407686",
"0.5407532",
"0.54044235",
"0.5392263",
"0.5391942",
"0.5385468",
"0.5384252",
"0.5377736",
"0.5377736",
"0.5364793",
"0.5357237",
"0.53504646",
"0.5350041",
"0.534842",
"0.5347632",
"0.5343521",
"0.533184",
"0.5311437",
"0.5304772",
"0.5304205",
"0.529553",
"0.52911127",
"0.5287454",
"0.528701",
"0.52856755",
"0.5278213",
"0.5278054",
"0.5277941",
"0.52773196",
"0.52680665",
"0.52667105",
"0.52662045",
"0.5264953",
"0.5259017",
"0.5258864",
"0.5256672",
"0.52561975",
"0.52496046",
"0.52488744",
"0.5244427",
"0.5242611",
"0.52372205",
"0.52357656",
"0.52357656",
"0.5234518",
"0.5227308",
"0.522707"
] | 0.72732353 | 0 |
This should be in another class, we are not transforming to Textile, we are just removing the title tag. | def remove_title_if_present
@doc.css('title').each { |node| node.remove }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end",
"def cut_title\n self.title.sub(RUBY_FORMAT, '')\n# self.title.sub!(RHTML_FORMAT, '')\n# self.title.sub!(RJS_FORMAT, '')\n end",
"def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end",
"def title\n @tagline unless name?\n end",
"def extract_title(doc)\n the_title_tag = title_tag(doc)\n return the_title_tag unless the_title_tag.respond_to? :inner_html\n strip_tags(the_title_tag.inner_html)\n end",
"def meta_title\n\t\tread_attribute('title').gsub(/<\\/?[^>]*>/, \"\")\n\tend",
"def page_title() nil end",
"def title=(text); end",
"def title=(text); end",
"def remove_unittitle_tags(input_string)\n # fcd1: for now, explicit strings. Later, can regex it\n unless input_string.blank?\n input_string.gsub!('<unittitle>','')\n input_string.gsub!('</unittitle>','')\n end\n input_string\n end",
"def cleanup_title(single_line)\n\tif single_line =~ /[^>]*$/ #Starts at the end and finds the first > symbol and matches everything before it (the song title), credit goes to Jonah for reminding me that #{$&} exists\n title = \"#{$&}\"\n end\n\t#Thank you Isaac for telling me to use gsub instead of what I did above\n\ttitle.gsub!(/[\\(|\\[|\\{|\\\\|\\/|_|\\-|\\:|\\\"|\\`|\\+|\\{|\\*].*$/,\"\") #Replaces everything after the first instance of ( [ { \\ / _ - : \" ` + = *\n\ttitle.gsub!(/feat\\..*/) #removes everything after feat.\n\ttitle.gsub!(/[\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|]/,\"\") #removes all punctuation\n\tif title =~ /[^\\w\\s']/ #ignores songs that contain non-Eng\n\t\ttitle = nil\n\tend\n\tif title != nil\n\t\ttitle.downcase!\n\t\t#Stop words implementation\n\t\ttitle.gsub!(/is\\s|a\\s|ab\\s|and\\s|by\\s|for\\s|from\\s|in\\s|of\\s|on\\s|or\\s|out\\s|the\\s|to\\s|with\\s/,\"\")\n\t\treturn title\n\tend\nend",
"def augmented_title\n return self.title\n end",
"def removeDummyTitles(titleCount)\n\t\tif @oc[\"TitleString\"]==\"\"\n\t\t\tc=\"\"\n\t\t\t(1..titleCount).each do |i|\n\t\t\t\tc=c+\"@\" if i>1\n\t\t\t\tc=c+\"empty-notitle\"\n\t\t\tend\n\t\t\t@oc[\"TitleString\"]=c\n\t\tend\n\tend",
"def trimmed_title\n ttl = self.title || \"\"\n if st = self.url && Site.by_link(self.url)\n ttl = SiteServices.new(st).trim_title ttl\n end\n # Convert HTML entities\n @@coder.decode ttl\n end",
"def page_title\n nil\n end",
"def cleanup_title(line)\n\n\t# title variable\n\ttitle = nil\n\n\t# splitting the line by \">\"\n\t# as the result should have 4 different strings\n\t# the tmp_4 war should contain title string\n\ttmp_1, tmp_2, tmp_3, tmp_4 = line.chomp.split(/>/)\n\n\t# ===============================================================\n\t# make the first letter of the string uppercase\n\tstr_up = tmp_4\n\tstr_up[0] = str_up[0].upcase\n\ttitle_tmp = str_up\n\t# ===============================================================\n\n\tif title_tmp.match(/^[\\A]/)\n\n\t\t# splitting up the title_tmp further\n\t\t# after splitting the first part of the title_tmp string should give back title\n\t\t# and the rest what left is the garbage string\n\t\ttitle_tmp_2, garbage = title_tmp.chomp.split(/[\\/\\()\\[\\]\\:\\_\\-\\+\\=\\*\\@\\![0-9]]/)\n\n\t\t# ===============================================================\n\t\t# Replace spaces within an empty char\n\t\tstr_no_sp = title_tmp_2.gsub(/\\s/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\?/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\!/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\./,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\'/,'')\n\t\t\n\t\t# check if title matches the regular expression\n\t\treg_str = str_no_sp[/[a-zA-Z]+$/]\n\t\tis_equal = str_no_sp == reg_str # true or false\n\t\t# ================================================================\n\t\t\n\t\tif is_equal == true\n\t\t\tif title_tmp_2 != \"\"\n\t\t\t\t$counter_1 += 1\n\t\t\t\ttitle = title_tmp_2.downcase!.gsub(/\\s+$/,'')\n\t\t\t\ttitle = title.gsub(/\\.$/,'')\n\t\t\t\t#puts \"*********************\\n\"\n\t\t\t\t#puts \"[ENG][+]: #{title} ==> #{$counter_1}\"\n\t\t\t\t#puts \"*********************\\n\"\n\t\t\tend\t\n\t\telse\n\t\t\t$counter_2 += 1\n\t\t\t#puts \"*********************\\n\"\n\t\t\t#puts \"[NON-ENG][-]: #{title_tmp_2} ==> #{$counter_1}\"\n\t\t\t#puts \"*********************\\n\"\n\t\tend\n\tend\n\n\t# return cleaned up title string\n\treturn title;\n\nend",
"def title\n super.first || ''\n end",
"def title\n super.first || ''\n end",
"def title\n super.first || ''\n end",
"def is_title\n false\n end",
"def title\n @title ||= self.content.split(@@title_separator).first unless self.content.nil?\n end",
"def title\n super.first || \"\"\n end",
"def title\n super.first || \"\"\n end",
"def strip_whitespace\n self.title = self.title.strip\n end",
"def handle_title(name, attrs) \n \n end",
"def strip_blanks\n self.title = self.title.strip\n end",
"def strip_blanks\n self.title = self.title.strip\n end",
"def title\n nil\n end",
"def trim_title\n self.title.downcase.gsub(/[^0-9a-z ]/i, '')\n end",
"def uniquify\n super\n self.short_title = title\n end",
"def title\n \"\"\n end",
"def destroy_old_title\n Content.first.destroy if Content.count >= 1\n end",
"def set_title\n unless self.title\n if self.parent\n if last_untitled_page = self.parent.children.where(:title => /Untitled /i).asc(:title).last\n last_untitled_number = last_untitled_page.title.split(\" \").last.to_i\n self.title = \"Untitled #{last_untitled_number+1}\"\n else\n self.title = \"Untitled 1\"\n end\n else\n self.title = \"Untitled 1\"\n end\n end\n end",
"def accurate_title\n nil\n end",
"def page_title!(title)\n @_page_title = title\n end",
"def title_tag\n content_tag :title, title_text.to_s\n end",
"def title\n # strip some non-breaking space at the end\n @title ||= details.at(\"h1[itemprop='name']\").children.first.text.strip.gsub(' ', '') rescue nil\n end",
"def remove_text_label\n\t\t$tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.p.className(create_ats_regex_string(\"ats-removetxtlbl\")), format_method(__method__))\n\tend",
"def cleanup_title(songTitle)\n\ttitle = songTitle.gsub(/(.)+<SEP>/, \"\") # strips everything but title\n\ttitle = title.gsub(/(([\\(\\[\\{\\\\\\/\\_\\-\\:\\\"\\`\\+\\=\\*]|(feat\\.)).*)/, \"\") # strips non-song title items\n\ttitle = title.gsub(/[\\?\\¿\\!\\¡\\.\\;\\&\\@\\%\\#\\|]/, \"\") # strips punctuation\n\tif title =~ (/[^\\x00-\\x7F]+/) # eliminates (most) non-english titles\n\t\treturn nil\n\tend\n\ttitle = title.downcase # converts title to lowercase\n\treturn title\nend",
"def cleanup_title(line)\n\ttitle = line.gsub(/.*>/, '') #strip everything in front of song title\n\ttitle.gsub!(/\\(.*|\\[.*|\\{.*|\\\\.*|\\/.*|\\_.*|\\-.*|\\:.*|\\\".*|\\`.*|\\+.*|\\=.*|\\*.*|feat\\..*/, \"\") #Remove rest of title following given characters\n\ttitle.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/, '') #remove special characters\n\ttitle = title.downcase\n\ttitle.gsub!(/\\b(and|an|a|by|for|from|in|of|on|or|out|the|to|with)*\\b/, '') #remove stop words\n\ttitle.gsub!(/\\s\\s+/, ' ') #add whitespace between words\n\treturn title\nend",
"def fix_title t\n # remove .html\n t1 = t.sub(/\\.html$/,'')\n # add /wiki/ unless it exists\n if t1.index(\"/wiki/\")\n return t1\n end\n return \"/wiki/\" + t.sub(/\\.html$/,'')\nend",
"def fix_title t\n # remove .html\n t1 = t.sub(/\\.html$/,'')\n # add /wiki/ unless it exists\n if t1.index(\"/wiki/\")\n return t1\n end\n return \"/wiki/\" + t.sub(/\\.html$/,'')\nend",
"def attachment_title\n orig_title = super\n orig_title.blank? ? missing_title : orig_title\n rescue NoMethodError\n missing_title\n end",
"def no_title!\n @no_title = true\n end",
"def title_comp; end",
"def title\n ''\n end",
"def regulate_title\n self.title = self.title.strip\n self.title.downcase!\n end",
"def populate_title\n if self.title.blank?\n self.title = self.file_file_name.blank? ? \"\" : self.file_file_name.gsub(/_/, \" \").capitalize\n end\n\tend",
"def cleanup_page_titles\n pages.each do |p|\n new_title = p.title.sub(/^page\\s*/i, '').strip\n p.title = new_title\n end\n\n pages.each do |p|\n if p.title.empty?\n if p.image_filename # we need to be able to make the assumption this exists\n p.title = file_name(p.image_filename)\n end\n end\n end\n\n seen = {}\n sequence = 1\n problems = []\n pages.each do |p|\n if p.title.empty?\n p.title = sequence.to_s\n end\n if seen[p.title]\n p.title += \" (#{sequence})\"\n problems.push p.title\n end\n seen[p.title] = true\n sequence += 1\n end\n\n if not problems.empty?\n warning \"Some page labels were not unique; the sequence number was appended: '\" + problems.join(\"', '\") + \"'.\"\n end\n end",
"def title\n @title ||= (Nokogiri::HTML.parse(@html).title).to_s.gsub(/\\n|\\t|\\r/,\"\")\n end",
"def display_title_without_link(event, length=nil)\n\t length = Event::TRUNCATE_TITLE_LENGTH_ON_TILE if length.nil?\n\t \n\t if (event.title.nil? or event.title.empty?)\n\t\t\t\"(No Title)\"\n\t\telse\n\t\t h(truncate(event.title, :length => length)).gsub(h(\"→\"), \"→\")\n\t end\n end",
"def get_title(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"Where\")\n title = description.split(\"Where\")[0]\n # Title must fit on single line\n title.gsub!(\"\\n\", \" \").strip!\n title\n else\n super(n)\n end\n else\n super(n)\n end\n end",
"def original_title\n details.at(\"div.originalTitle\").children.first.text.gsub('\"', '').strip rescue nil\n end",
"def title\n return nil\n end",
"def title\n temp = \"X\"+read_attribute(:id).to_s\n if not read_attribute(:title).nil? \n temp += \": \" + read_attribute(:title).to_s\n elsif( !self.tags.nil? && !self.tags.first.nil? )\n temp += \": \" + self.tags.first.tag_name\n end\n return temp\n end",
"def title=(title=\"Untitled Document\")\n # Clean the stripped title\n self[:title] = CGI.unescape_html(self.strip title.strip)\n end",
"def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end",
"def cleanup_title(string)\n\ttitle = \"\"\n\t#looking for the third <SEP> by looking for the <SEP> pattern 3 times, each time setting the new title to everything to the right of the pattern.\n\t#this effectively extracts just the song title from the line\n\tsep_pattern = /<SEP>/\n\tif string =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\tif title =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\tif title =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\n\t#cleanup said title part 2\n\t#pat1 are regular expressions identifying superflous text as stated in the instructions\n\tpart2 = /[(\\[\\{\\/:\"`+\\-_=*\\\\]|feat./\n\t#if the title contains any superfluous text, we just want whatever comes before said text using: (#{$`})\n\tif title =~ part2\n\t\ttitle = \"#{$`}\"\n\tend\n\n\t#eliminate characters part 3\n\t#finding and deleting the following punctuation: ? ¿ ! ¡ . ; & @ % # |\n\tpunctuation = /[?¿!¡.;&@%#|]/\n\tif title =~ punctuation\n\t\ttitle.gsub!(punctuation, \"\") #replace with empty string to remove\n\tend\n\n\t#set to lower case part 5\n\ttitle.downcase!\n\treturn title\nend",
"def title\n \"#{super} #{self.tags.map(&:name).join(\" \")}\"\n end",
"def title?\n !name? && tagline\n end",
"def title\n return @title if @title\n if matches = class_const(:TITLE_RE).match(page)\n @title = matches[1].to_s.strip\n title_processor\n @title = decode_entities(@title)\n end\n end",
"def cleanup_title(line)\n\t#deletes everything but the song title\n\tline.gsub!(/.+>/, '')\n\t#deletes superfluous text\n\tline.gsub!(/(\\(|\\[|\\{|\\\\|\\/|\\_|\\-|\\:|\\\"|\\`|\\+|\\=|\\*|feat\\.).+$/,'')\n\t\t#deletes punctuation\n\t\tline.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/,'')\n\t\t#determines if a word uses english characters or not\n\t\tif line =~ /^[\\w\\s']+$/\n\t\t\tline = line.downcase\n\t\t\t#if not english, sets line to nil\n\t\telse\n\t\t\tline = nil\n\t\tend\n\t\treturn line\n\tend",
"def title(_content)\n raise NotImplementedError\n end",
"def set_title\n @title = File.basename(@absolute_path)\n @title.sub!(/^[0-9][0-9]-/, '')\n @title.gsub!(/_/, ' ')\n @title.gsub!(/-/, ', ')\n end",
"def plain_title\n\t\treturn CGI::unescapeHTML(title_without_numbers.gsub(%r{</?[a-z]+>}i, ''))\n\tend",
"def build_title\n if title.blank?\n lines = body.strip.gsub(/\\r\\n/, \"\\n\").split(/\\n/)\n if lines.first.match(/\\A# (.*)\\Z/)\n self.title = $1\n lines.shift\n self.body = lines.join(\"\\n\").strip\n end\n end\n end",
"def title\n @data.title ||= parsed_document.css('title').inner_html.gsub(/\\t|\\n|\\r/, '') rescue nil\n end",
"def scrub_titles(text)\n \n # We don't want brackets in our JSON array, so we'll change them to parens\n text.gsub!(\"[\",\"(\")\n text.gsub!(\"]\",\")\")\n \n # And let's get rid of unicode characters, too...\n text = text.chars.normalize(:kd).gsub(/[^\\x00-\\x7F]/n,'').to_s\n \n # And just avoid double quotes for displaying titles.\n text.gsub!(\"\\\"\",\"\\'\")\n \n return text\n end",
"def title\n @title ||= doc.search('.moviename-big').xpath('text()').text.strip\n end",
"def title\n raise NotImplementedError, 'Subclasses must implement a title method.'\n end",
"def adjust_transition_text\n if @temporary_objects[:title].width > Window.width - (@margin * 2)\n length_per_char = @temporary_objects[:title].width / @temporary_objects[:title].text.length\n split_title = @temporary_objects[:title].text.split(' ')\n\n remove_from_temporary(:title)\n title_parts = []\n grouped_text = []\n grouped_text_length = 0\n split_title.each_index do |i|\n grouped_text_length += (split_title[i].length + 1) * length_per_char\n if grouped_text_length > Window.width - (@margin * 2)\n if i < split_title.length - 1\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n # make a new text object\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n \n title_parts << @temporary_objects[sym]\n\n grouped_text = []\n grouped_text << split_title[i]\n grouped_text_length = (split_title[i].length + 1) * length_per_char\n else\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n sym2 = \"divided_text_#{i + 1}\".to_sym\n\n # make a new text object with grouped_text\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n # make a new text object with split_title[i]\n @temporary_objects[sym2] = Text.new(split_title[i], {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n\n title_parts << @temporary_objects[sym]\n title_parts << @temporary_objects[sym2]\n end\n else\n if i < split_title.length - 1\n grouped_text << split_title[i]\n else\n grouped_text << split_title[i]\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n # make a new text object with grouped_text\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n title_parts << @temporary_objects[sym]\n end\n end\n end\n\n positions = get_centered_positions(title_parts, 5)\n title_parts.each_index do |i|\n title_parts[i].x = positions[i][:x]\n title_parts[i].y = positions[i][:y]\n end\n end\n end",
"def rem_title_feature(symbol)\n symbol = symbol.to_sym\n $data_actors[self.id].remove_feature(*RVKD::Passives::FEATURES[symbol])\n end",
"def fix_title\r\n # Remove quotes if the user thought they needed them\r\n self.title = self.title.gsub(/^(?:'|\")(.*)(?:'|\")$/, '\\1')\r\n end",
"def capitalize_title\n self.title.capitalize! if title\n end",
"def remove_metadata(content_node)\n extra_meta = content_node.css(\"h1\")[0]\n if extra_meta.present? && page_title.match(extra_meta.text)\n extra_meta.remove\n end\n end",
"def title\n t = _title.text_value.gsub(\"::\", \"\")\n t.blank? ? self.text : t\n end",
"def html_title\n @html_title || title\n end",
"def extract_title(entry)\n if entry.title and not entry.title.empty?\n entry.title\n elsif entry.content && entry.content.first && entry.content.first.value.is_a?(String)\n content = entry.content.first.value\n \n if content.match(/^<?p?>?<(strong|h1|h2|h3|h4|b)>([^<]*)<\\/\\1>/i)\n $2\n else\n content.split(/\\n|<br ?\\/?>/).each do |line|\n potential_title = line.gsub(/<\\/?[^>]*>/, \"\").chomp # strip html\n break potential_title if potential_title and not potential_title.empty?\n end.split(/!|\\?|\\./).first\n end\n else\n \"Untitled\"\n end\n end",
"def fix_title\n # Remove quotes if the user thought they needed them\n self.title = self.title.gsub(/^(?:'|\")(.*)(?:'|\")$/, '\\1')\n end",
"def title(force_refresh = false)\n if @title && !force_refresh\n @title\n else\n @title = document.at(\"h1\").innerHTML.split('<span').first.strip.imdb_unescape_html rescue nil \n end\n end",
"def titleize!\n replace titleize\n end",
"def write_title_rich(title, is_y_axis, font, layout, overlay = nil) # :nodoc:\n @writer.tag_elements('c:title') do\n # Write the c:tx element.\n write_tx_rich(title, is_y_axis, font)\n # Write the c:layout element.\n write_layout(layout, 'text')\n # Write the c:overlay element.\n write_overlay if overlay\n end\n end",
"def page_title\n \n page_title = @renderer.title title()\n \n puts \"[Cutlist.page_title]: #{page_title}\" if $cutlister_debug\n \n page_title\n \n end",
"def title(title_name)\n h.content_tag :h2 do\n title_name.present? ? title_name : \"Perfis\"\n end\n end",
"def title_name; end",
"def prepare\n self.output_title\n end",
"def title\n if @title.nil?\n repair_entities = false\n title_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"atom10:title\",\n \"atom03:title\",\n \"atom:title\",\n \"title\",\n \"dc:title\",\n \"channelTitle\",\n \"TITLE\"\n ])\n @title = FeedTools::HtmlHelper.process_text_construct(title_node,\n self.feed_type, self.feed_version, [self.base_uri])\n if self.feed_type == \"atom\" ||\n self.configurations[:always_strip_wrapper_elements]\n @title = FeedTools::HtmlHelper.strip_wrapper_element(@title)\n end\n @title = nil if @title.blank?\n self.cache_object.title = @title unless self.cache_object.nil?\n end\n return @title\n end",
"def draw_title\n return if hide_title?\n\n metrics = Gruff::Renderer::Text.new(renderer, @title, font: @title_font).metrics\n if metrics.width > @raw_columns\n @title_font.size = @title_font.size * (@raw_columns / metrics.width) * 0.95\n end\n\n text_renderer = Gruff::Renderer::Text.new(renderer, @title, font: @title_font)\n text_renderer.add_to_render_queue(@raw_columns, 1.0, 0, @top_margin)\n end",
"def title=(title)\n\t super(standardize_title(title))\n\t\t\t#self[:title] = title.strip\n\tend",
"def normalized_title\n t = self.title.presence || default_title\n t.gsub('.', '').strip\n end",
"def title_folded_to_filename\n self[:title].gsub(/[^a-z0-9-]/) do |c|\n case c\n when /\\s+|\\./ then '-'\n when /[A-Z]+/ then c.downcase\n else ''\n end\n end.gsub(/\\-+/,'-')\n end",
"def end_page_title()\n return \"</td></tr></table>\";\n end",
"def title_plain\n Redcap::Utilities.html_to_plain_text title\n end",
"def title\n values = super\n values = MetadataHelper.ordered( ordered_values: self.title_ordered, values: values )\n return values\n end",
"def title\n values = super\n values = MetadataHelper.ordered( ordered_values: self.title_ordered, values: values )\n return values\n end",
"def parse_title(tag, page, webpage)\n webpage.css(tag).each do |title| \n @title_obj = Title.new(tag: tag, content: title.text.strip)\n page.titles << @title_obj\n end\n end",
"def first_title\n max_level = 6 # any title with a higher level kicks the current one out\n title = false\n @blocks.each do |block|\n if block.is_a?(Prismic::Fragments::StructuredText::Block::Heading)\n if block.level < max_level\n title = block.text\n max_level = block.level # new maximum\n end\n end\n end\n title\n end",
"def title\n doc.css(\"titleproper\").children.first.text.strip\n end",
"def get_title\n title = @doc.css(\"div.headline h1\").text.gsub(\" From Our Partners\", \"\")\n end",
"def title\n @title ||= details.at(\"h1.header\").text.strip rescue nil\n end"
] | [
"0.6486843",
"0.6468631",
"0.64637405",
"0.64043486",
"0.6299299",
"0.62575483",
"0.6213798",
"0.61520493",
"0.61520493",
"0.6104568",
"0.60666037",
"0.6061295",
"0.6042974",
"0.60358334",
"0.6032165",
"0.6028055",
"0.601616",
"0.601616",
"0.601616",
"0.6011499",
"0.6007132",
"0.599945",
"0.599945",
"0.5992774",
"0.59738153",
"0.59607285",
"0.59607285",
"0.59568995",
"0.5954508",
"0.592344",
"0.59145904",
"0.591374",
"0.5912398",
"0.5898194",
"0.5881355",
"0.58771384",
"0.58688265",
"0.58596027",
"0.58582073",
"0.58497065",
"0.58486027",
"0.58486027",
"0.5838339",
"0.58347166",
"0.58224756",
"0.5821957",
"0.581891",
"0.58181804",
"0.5798017",
"0.57935464",
"0.5784829",
"0.5783379",
"0.57756084",
"0.5773289",
"0.5768972",
"0.5764569",
"0.5762324",
"0.57499415",
"0.5745012",
"0.5743847",
"0.57298154",
"0.5728768",
"0.572866",
"0.57269466",
"0.5720422",
"0.5720373",
"0.57165617",
"0.5709244",
"0.5706762",
"0.5706265",
"0.57011116",
"0.5683443",
"0.5678731",
"0.567452",
"0.5669162",
"0.5658812",
"0.56583077",
"0.5654284",
"0.5651275",
"0.56389266",
"0.56346583",
"0.56128836",
"0.56096935",
"0.55986494",
"0.5594769",
"0.5593731",
"0.5587672",
"0.5584497",
"0.55816793",
"0.558106",
"0.5576137",
"0.5575049",
"0.5573548",
"0.5571862",
"0.5571862",
"0.5565293",
"0.5557732",
"0.55547696",
"0.5553918",
"0.5553525"
] | 0.70244247 | 0 |
Supply Prowl defaults in a hash (:apikey, :providerkey, etc.), along with optional Typhoeus Hydra options. | def initialize(defaults = {}, hydra = {})
@defaults = defaults
@responses = []
@hydra = Typhoeus::Hydra.new(hydra)
@user_agent = USER_AGENT
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key; @opts[:api_key]; end",
"def default_config\n data = {\n 'acr_values' => 'http://idmanagement.gov/ns/assurance/loa/1',\n 'client_id' => 'urn:gov:gsa:openidconnect:sp:sinatra',\n }\n\n if LoginGov::Hostdata.in_datacenter?\n # EC2 deployment defaults\n\n env = LoginGov::Hostdata.env\n domain = LoginGov::Hostdata.domain\n\n if env == 'prod'\n data['idp_url'] = \"https://secure.#{domain}\"\n else\n data['idp_url'] = \"https://idp.#{env}.#{domain}\"\n end\n data['redirect_uri'] = \"https://sp-oidc-sinatra.#{env}.#{domain}/\"\n data['sp_private_key_path'] = \"aws-secretsmanager:#{env}/sp-oidc-sinatra/oidc.key\"\n data['redact_ssn'] = true\n else\n # local dev defaults\n data['idp_url'] = 'http://localhost:3000'\n data['redirect_uri'] = 'http://localhost:9292/'\n data['sp_private_key_path'] = demo_private_key_path\n data['redact_ssn'] = false\n end\n\n data\n end",
"def default_params\n {\n \"pio_appkey\" => @app_key\n }\n end",
"def default_config\n data = {\n 'acr_values' => ENV['acr_values'] || 'http://idmanagement.gov/ns/assurance/ial/1',\n 'client_id' => ENV['client_id'] || 'urn:gov:gsa:openidconnect:sp:sinatra',\n 'mock_irs_client_id' => ENV['mock_irs_client_id'] ||\n 'urn:gov:gsa:openidconnect:sp:mock_irs',\n 'redirect_uri' => ENV['redirect_uri'] || 'http://localhost:9292/',\n 'sp_private_key_path' => ENV['sp_private_key_path'] || './config/demo_sp.key',\n 'redact_ssn' => true,\n 'cache_oidc_config' => true,\n }\n\n # EC2 deployment defaults\n\n env = ENV['idp_environment'] || 'int'\n domain = ENV['idp_domain'] || 'identitysandbox.gov'\n\n data['idp_url'] = ENV.fetch('idp_url', nil)\n unless data['idp_url']\n if env == 'prod'\n data['idp_url'] = \"https://secure.#{domain}\"\n else\n data['idp_url'] = \"https://idp.#{env}.#{domain}\"\n end\n end\n data['sp_private_key'] = ENV.fetch('sp_private_key', nil)\n\n data\n end",
"def initialize options\n @defaults = CrisplyApi.defaults\n @params = override_defaults_with options\n end",
"def default_options\n {\n :name => nil,\n :key_ => nil,\n :hostid => nil,\n :delay => 60,\n :history => 60,\n :status => 0,\n :type => 7,\n :snmp_community => '',\n :snmp_oid => '',\n :value_type => 3,\n :data_type => 0,\n :trapper_hosts => 'localhost',\n :snmp_port => 161,\n :units => '',\n :multiplier => 0,\n :delta => 0,\n :snmpv3_securityname => '',\n :snmpv3_securitylevel => 0,\n :snmpv3_authpassphrase => '',\n :snmpv3_privpassphrase => '',\n :formula => 0,\n :trends => 365,\n :logtimefmt => '',\n :valuemapid => 0,\n :delay_flex => '',\n :authtype => 0,\n :username => '',\n :password => '',\n :publickey => '',\n :privatekey => '',\n :params => '',\n :ipmi_sensor => '',\n }\n end",
"def default_options\n {\n basic_auth: {\n username: Maestrano[self.class.preset].param('api.id'),\n password: Maestrano[self.class.preset].param('api.key')\n },\n timeout: Maestrano[self.class.preset].param('connec.timeout')\n }\n end",
"def initialize(login = nil, apikey = nil)\n @options = {\n :version => API_VERSION\n }\n if login && apikey\n @options.merge({:login => login, :apiKey => apikey})\n elsif (login || apikey)\n raise Shorty::Supr::Error, 'Both the API key and login values must be passed when you want to use authentication'\n end\n end",
"def default_options\n {\n appid: app_id,\n device_id: device_id,\n locale: locale,\n ip: ip,\n offer_types: offer_types,\n timestamp: Time.now.to_i\n }\n end",
"def init_quick_defaults\n @quick_defaults=Hash.new\n @quick_defaults['enabled']=false\n @quick_defaults['launch']='ONETIME'\n @quick_defaults['launch_now']=true\n @quick_defaults['description']='Created with nessus_rest'\n end",
"def set_defaults\n self.help ||= ENV['help_text']\n self.help_url ||= ENV['help_url']\n self.created_at ||= DateTime.current\n end",
"def initialize(opts = {})\n @api_key = opts.fetch(:api_key)\n @username = opts[:username]\n end",
"def default_settings\n {\n :ctrip_username => '',\n :ctrip_password => '',\n :ctrip_hotel_id => '',\n :ctrip_code_context => '',\n\n :ctrip_company_code => 'C',\n\n # 10 is for Channel Manager (see Ctrip Integration API Specification V2.2.pdf)\n # While 1 is for indifidual hotel.\n :ctrip_user_category => 10\n }\n end",
"def initialize(api_key = nil, api_version = nil, url = nil, username = nil, password = nil, options = {})\n load_yaml\n if load_yaml\n @api_key = load_yaml['api_key']\n @api_version = load_yaml['api_version']\n @options = load_yaml['options']\n @password = load_yaml['password']\n @url = load_yaml['url']\n @username = load_yaml['username']\n else\n @api_key = api_key\n @api_version = api_version\n @options = options\n @password = password\n @url = url\n @username = username\n end\n end",
"def initialize(api_key: nil)\r\n Configuration.api_key = api_key\r\n end",
"def setup(args={})\n super\n @conf_key = (args[:config_key] || :http_endpoints).to_sym\n set_points\n end",
"def default_params\n {\n api_key: @api_key,\n api_secret: @api_secret,\n format: @response_format\n }\n end",
"def initialize(init_options={})\n @options = Sunnytrail.options.merge(init_options)\n start_logger if verbose?\n raise ConfigurationError, \"API KEY not set\" if @options[:api_key].nil?\n end",
"def config_options\n {\n 'datacenter' => new_resource.datacenter,\n 'template_path' => new_resource.template_path,\n 'power_on' => true,\n 'datastore' => new_resource.datastore,\n 'wait' => true,\n 'hostname' => new_resource.hostname,\n 'name' => new_resource.name,\n 'customization_spec' => {\n 'domain' => new_resource.domain,\n 'ipsettings' => {\n 'ip' => new_resource.ip || node['vcac_vm']['ip'],\n 'gateway' => new_resource.gateway,\n 'subnetMask' => new_resource.subnet_mask,\n },\n }\n }\nend",
"def init_options( opts )\n options = default_options.merge( opts ) \n @environment = options[:environment]\n @perf_threshold = options[:perf_threshold]\n @moleable = options[:moleable]\n @app_name = options[:app_name]\n @user_key = options[:user_key]\n @store = options[:store]\n @excluded_paths = options[:excluded_paths]\n end",
"def options_for_klient(options = {})\n {\n # TODO Kaui doesn't support multi-tenancy yet\n :api_key => KillBillClient.api_key,\n :api_secret => KillBillClient.api_secret,\n :username => current_user.kb_username || KillBillClient.username,\n :password => current_user.password || KillBillClient.password,\n :session_id => current_user.kb_session_id\n }.merge(options)\n end",
"def initialize(params = {})\n @hostname = params[:hostname]\n @lang = params[:lang]\n @api_key = params[:api_key]\n @timeout = params[:timeout] || 5\n @api_key_in_params = params[:api_key_in_params]\n @enable_logging = params[:enable_logging] || ENV['ENABLE_LOGGING']\n end",
"def setup_config(*args)\n args.first.is_a?(Hash) ? args.first : { default: args }\n end",
"def defaults\n {\n hostname: 'localhost',\n basedn: 'dc=domain,dc=tld',\n rootdn: '',\n passdn: '',\n auth: false,\n port: 389,\n scope: :subtree,\n username_ldap_attribute: 'uid',\n ldaps: false,\n starttls: false,\n tls_options: nil,\n debug: false\n }\n end",
"def defaults\n @defaults ||= {\n # config_root: 'config',\n data_center: DEFAULT_EMPTY_VALUE,\n vsphere_session_limit: 10,\n vsphere_user: DEFAULT_EMPTY_VALUE,\n vsphere_password: DEFAULT_EMPTY_VALUE,\n vsphere_host: DEFAULT_EMPTY_VALUE,\n vsphere_readings_batch_size: 64,\n vsphere_ignore_ssl_errors: false,\n vsphere_debug: false,\n on_prem_api_format: 'json',\n on_prem_api_host: DEFAULT_EMPTY_VALUE,\n # on_prem_login_email: DEFAULT_EMPTY_VALUE,\n # on_prem_login_password: DEFAULT_EMPTY_VALUE,\n on_prem_batch_size: 500,\n on_prem_api_endpoint: DEFAULT_EMPTY_VALUE,\n # on_prem_oauth_endpoint: DEFAULT_EMPTY_VALUE,\n # on_prem_api_scope: DEFAULT_EMPTY_VALUE,\n on_prem_api_threads: 2,\n # on_prem_application_id: DEFAULT_EMPTY_VALUE,\n # on_prem_application_secret: DEFAULT_EMPTY_VALUE,\n on_prem_collector_version: DEFAULT_EMPTY_VALUE,\n on_prem_organization_id: DEFAULT_EMPTY_VALUE,\n # on_prem_organization_name: DEFAULT_EMPTY_VALUE,\n # on_prem_meter_id: DEFAULT_EMPTY_VALUE,\n on_prem_oauth_token: DEFAULT_EMPTY_VALUE,\n on_prem_refresh_token: DEFAULT_EMPTY_VALUE,\n on_prem_proxy_host: DEFAULT_EMPTY_VALUE,\n on_prem_proxy_port: DEFAULT_EMPTY_VALUE,\n on_prem_proxy_user: DEFAULT_EMPTY_VALUE,\n on_prem_proxy_password: DEFAULT_EMPTY_VALUE,\n on_prem_machines_by_inv_timestamp: '500',\n on_prem_inventoried_limit: 10,\n on_prem_log_level: Logger::DEBUG,\n verified_api_connection: false,\n verified_vsphere_connection: true,\n # container_namespace: '6fusion',\n # container_repository: 'vmware-collector'\n }\n end",
"def prov_set_default_options\n {\n :reason_text => nil,\n :applied_states => PROV_STATES.keys,\n :type_choice => 'all',\n :user_choice => approver? ? 'all' : current_user.id,\n :time_period => 7,\n }\n end",
"def get_defaults(api_options)\n defaults = {\n :enable_read => true,\n :enable_write => true,\n :enable_options => true,\n :enable_get_all => true,\n :enable_get => true,\n :enable_post => true,\n :enable_put => true,\n :enable_delete => true,\n }\n api_options.merge!(defaults) { |key, v1, v2| v1 }\n end",
"def kitchen_config\n @kitchen_config ||= {\n defaults: {\n driver: Driver::DEFAULT_PLUGIN,\n provisioner: Provisioner::DEFAULT_PLUGIN,\n verifier: Verifier::DEFAULT_PLUGIN,\n transport: lambda do |_suite, platform|\n platform =~ /^win/i ? \"winrm\" : Transport::DEFAULT_PLUGIN\n end,\n },\n kitchen_root: kitchen_root,\n test_base_path: test_base_path,\n log_level: log_level,\n log_overwrite: log_overwrite,\n debug: debug,\n }\n end",
"def base_opts\n {\n client_id: '277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe',\n client_secret: 'd6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352'\n }\n end",
"def initialize(api_key, options = {})\n @api_key = api_key\n @api_endpoint = DEFAULT_API_ENDPOINT\n end",
"def options(opts)\n options = opts.dup\n options[:platform] = PLATFORM_DETAILS\n options[:app_name] = Mongoid::Config.app_name if Mongoid::Config.app_name\n if (driver_version <=> [2, 13]) >= 0\n wrap_lib = if options[:wrapping_libraries]\n [MONGOID_WRAPPING_LIBRARY] + options[:wrapping_libraries]\n else\n [MONGOID_WRAPPING_LIBRARY]\n end\n options[:wrapping_libraries] = wrap_lib\n end\n options.reject{ |k, _v| k == :hosts }.to_hash.symbolize_keys!\n end",
"def apply_pooka_configure(data)\n @logger_path = data['logger_path']\n @logger_level = data['logger_level']\n @pid_path = data['pid_path'] || @pid_path\n @sleep_time = data['sleep_time'] || @sleep_time\n end",
"def initialize(*args)\n @send_notifications = true\n\n if args.empty?\n CONFIG_ATTRS.each{ |attr| send(\"#{attr}=\".to_sym, Prowler.send(attr)) }\n elsif args.first.is_a?(Hash)\n CONFIG_ATTRS.each do |attr|\n send(\"#{attr}=\".to_sym, args[0][attr] || Prowler.send(attr))\n end\n else\n @service_url = Prowler.service_url\n @api_key, @application, @provider_key = args[0], args[1], args[2]\n end\n end",
"def set_default_options()\n @options = OpenStruct.new(\n :output_base => nil,\n :verbose => false,\n :config_file => nil,\n :samples => nil,\n :delay => 30,\n :scheduler_opts => ''\n )\nend",
"def initialize(opts)\n self.base_url = opts.fetch(:base_url, BASE_URL)\n self.app_name = opts.fetch(:app_name)\n self.api_key = opts.fetch(:api_key)\n end",
"def setup\n FileUtils.cp(VALID_CONFIG_JSON_ORIG, CONFIG_JSON)\n @config = Thermoserver::Configuration.new\n @api_key = @config.api_key\n end",
"def default_request_options\n {'ha_version' => ha_version, 'ha_format' => ha_format, 'ha_fancylayout' => ha_fancylayout} #, 'strict_oauth_spec_response' => true\n end",
"def initialize(key = nil, api_key: nil)\n @api_key = key || api_key\n end",
"def _set_defaults(opts={})\n @miq_provider_name = opts.fetch(:miq_provider, 'noop')\n @export_dir = opts.fetch(:export_dir, 'automate')\n @export_name = opts.fetch(:export_name, @name)\n @miq_import_method = opts.fetch(:miq_import_method, :partial)\n @miq_priority = opts.fetch(:miq_priority, 10)\n @branch_name = opts.fetch(:branch_name, 'No Branch')\n end",
"def init!\n @defaults = {\n :@refresh_token => ShakeTheCounter::Config.refresh_token,\n :@id => ShakeTheCounter::Config.client_id,\n :@secret => ShakeTheCounter::Config.client_secret,\n :@language_code => ShakeTheCounter::Config.language_code,\n }\n end",
"def initialize(options = {})\n requires!(options, :client_id, :site_id, :price_id, :password, :key)\n @options = options\n super\n end",
"def initialize options={}\n if defined?(Rails) && Rails.try(:root) && Rails.try(:env)\n config_path = File.join(Rails.root, 'config', 'tiny_png.yml')\n config = YAML.load_file(config_path)[Rails.env] if File.exists? config_path\n end\n config ||= {}\n \n @options = {\n :suppress_exceptions => config['suppress_exceptions'] || false,\n :api_key => config['api_key'] || '',\n :api_user => config['api_user'] || 'api'\n }.merge(options)\n end",
"def initialize(api_key = nil)\n @api_key = api_key\n @api_key ||= Songkickr.api_key\n \n self.class.default_params :apikey => @api_key\n end",
"def options()\n @options ||= OpenStruct.new({\n :debug => false,\n :gist_api_url => nil,\n :gist_extension => defaults[\"extension\"],\n :private_gist => defaults[\"private\"],\n :browse_enabled => defaults[\"browse\"],\n :embed_enabled => nil,\n :description => nil,\n :setup_credentials => false\n })\n end",
"def init!\n @defaults = {\n :@refresh_token => ENV[\"STC_REFRESH_TOKEN\"],\n :@client_id => ENV[\"STC_CLIENT_ID\"],\n :@client_secret => ENV[\"STC_CLIENT_SECRET\"],\n :@language_code => \"nl-NL\",\n :@environment => 'test',\n :@version => 1,\n :@verbose => false,\n }\n end",
"def initialize(options={})\n\t\t\tPlayapi::Configurable.keys.each do |key|\n\t\t\t\tinstance_variable_set(:\"@#{key}\", options[key] || Playapi.instance_variable_get(:\"@#{key}\"))\n\t\t\tend\n\t\tend",
"def initialize(key: nil,\n env_name: nil,\n description: nil,\n short_option: nil,\n default_value: nil,\n default_value_dynamic: false,\n verify_block: nil,\n is_string: true,\n type: nil,\n skip_type_validation: false,\n optional: nil,\n conflicting_options: nil,\n conflict_block: nil,\n deprecated: nil,\n sensitive: nil,\n code_gen_sensitive: false,\n code_gen_default_value: nil,\n display_in_shell: true)\n UI.user_error!(\"key must be a symbol\") unless key.kind_of?(Symbol)\n UI.user_error!(\"env_name must be a String\") unless (env_name || '').kind_of?(String)\n\n if short_option\n UI.user_error!(\"short_option for key :#{key} must of type String\") unless short_option.kind_of?(String)\n UI.user_error!(\"short_option for key :#{key} must be a string of length 1\") unless short_option.delete('-').length == 1\n end\n\n if description\n UI.user_error!(\"Do not let descriptions end with a '.', since it's used for user inputs as well for key :#{key}\") if description[-1] == '.'\n end\n\n if conflicting_options\n conflicting_options.each do |conflicting_option_key|\n UI.user_error!(\"Conflicting option key must be a symbol\") unless conflicting_option_key.kind_of?(Symbol)\n end\n end\n\n if deprecated\n # deprecated options are automatically optional\n optional = true if optional.nil?\n UI.crash!(\"Deprecated option must be optional\") unless optional\n\n # deprecated options are marked deprecated in their description\n description = deprecated_description(description, deprecated)\n end\n\n optional = false if optional.nil?\n sensitive = false if sensitive.nil?\n\n @key = key\n @env_name = env_name\n @description = description\n @short_option = short_option\n @default_value = default_value\n @default_value_dynamic = default_value_dynamic\n @verify_block = verify_block\n @is_string = is_string\n @data_type = type\n @data_type = String if type == :shell_string\n @optional = optional\n @conflicting_options = conflicting_options\n @conflict_block = conflict_block\n @deprecated = deprecated\n @sensitive = sensitive\n @code_gen_sensitive = code_gen_sensitive || sensitive\n @allow_shell_conversion = (type == :shell_string)\n @display_in_shell = display_in_shell\n @skip_type_validation = skip_type_validation # sometimes we allow multiple types which causes type validation failures, e.g.: export_options in gym\n\n @code_gen_default_value = code_gen_default_value\n\n update_code_gen_default_value_if_able!\n end",
"def initialize(options={})\n @debug = options[:debug]\n @wskey = options[:wskey]\n @secret = options[:secret]\n @principalDNS = options[:principalDNS]\n @principalID = options[:principalID]\n end",
"def config_options\n # config_file_path = File.join(ENV['SHARED_CONFIG_ROOT'] || \"#{Rails.root}/config\", \"college_mapper.yml\")\n # @config_options ||= YAML::load(ERB.new((IO.read(config_file_path))).result)[(Rails.env)].symbolize_keys \n @config_options ||= API_KEYS['collegemapper'][Rails.env].symbolize_keys\n end",
"def initialize(options = {})\n Emma::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", options[key] || Emma.instance_variable_get(:\"@#{key}\"))\n end\n @default_params = {:basic_auth => {:username => @public_key, :password => @private_key}}\n end",
"def defaults\n super.merge({\n chart_code: get_aft_parameter_value(ParameterConstants::DEFAULT_CHART_CODE),\n account_number: get_aft_parameter_value(ParameterConstants::DEFAULT_ACCOUNT_NUMBER),\n sub_account_number: random_alphanums(5),\n name: random_alphanums(10),\n sub_account_type_code: get_aft_parameter_value(ParameterConstants::DEFAULT_EXPENSE_SUB_ACCOUNT_TYPE_CODE)\n }).merge(default_icr_accounts)\n .merge(get_aft_parameter_values_as_hash(ParameterConstants::DEFAULTS_FOR_SUB_ACCOUNT))\n end",
"def create_default_authentication_ad_configuration(opts)\n opts = check_params(opts,[:search_base_dn,:servers])\n super(opts)\n end",
"def initialize(defaults,cmd_opts)\n @fields = defaults\n if !cmd_opts[:config_file].nil?\n path = cmd_opts[:config_file]\n else\n path = defaults[:config_file]\n end\n data = YAML.load_file(path)\n # Now combine data:\n # defaults, config file, command line (low->high priority)\n data.each do |k,v|\n if EXPECTED.include? k.to_sym\n @fields[k.to_sym] = v\n else\n STDERR.puts \"Warning: unknown section '#{k}' in config file\"\n end\n end\n cmd_opts.each do |k,v|\n @fields[k] = v\n end\n end",
"def load_config **kwargs\n project_id = kwargs[:project] || kwargs[:project_id]\n configuration.project_id = project_id unless project_id.nil?\n\n creds = kwargs[:credentials] || kwargs[:keyfile]\n configuration.credentials = creds unless creds.nil?\n\n service_name = kwargs[:service_name]\n configuration.service_name = service_name unless service_name.nil?\n\n service_vers = kwargs[:service_version]\n configuration.service_version = service_vers unless service_vers.nil?\n\n init_default_config\n end",
"def test_initialize_hash\n assert_nothing_raised do\n dfp_api = DfpApi::Api.new(DEFAULT_CONFIG_HASH)\n check_config_data(dfp_api.config)\n end\n end",
"def setup_defaults\n @program_title = 'PROGRAM TITLE'\n @program_site = 'PROGRAM SITE'\n @request_availability = false\n @meeting_times = ''\n @sourcing_options = ''\n @course_options = ''\n @student_id_required = false\n @student_id_format = ''\n @student_id_format_help = ''\n @student_id_excluded_chars = ''\n @contact_email = 'info@bebraven.org'\n @is_preaccelerator_student = false\n end",
"def reset_to_defaults!\n @allowlist_regexp = nil\n @custom_http_auth_scheme = UnsetString.new(\"custom_http_auth_scheme\")\n @env_var_to_hold_api_client_primary_key = NonNullString.new(\"env_var_to_hold_api_client_primary_key\",\"STITCHES_API_CLIENT_ID\")\n @env_var_to_hold_api_client= NonNullString.new(\"env_var_to_hold_api_client\",\"STITCHES_API_CLIENT\")\n @max_cache_ttl = NonNullInteger.new(\"max_cache_ttl\", 0)\n @max_cache_size = NonNullInteger.new(\"max_cache_size\", 0)\n @disabled_key_leniency_in_seconds = ActiveSupport::Duration.days(3)\n @disabled_key_leniency_error_log_threshold_in_seconds = ActiveSupport::Duration.days(2)\n end",
"def initialize base_url, opts={}\n @base_url = base_url\n @hydra = Typhoeus::Hydra.new(opts)\n end",
"def config(api_id, api_key, options={})\n @api_id = api_id\n @api_key = api_key\n @api_endpoint = URI.parse(options.delete(:url))\n @api_options = options\n end",
"def config(api_id, api_key, options={})\n @api_id = api_id\n @api_key = api_key\n @api_endpoint = URI.parse(options.delete(:url))\n @api_options = options\n end",
"def options\n options = super\n\n options.merge(login: preferred_secret_key)\n end",
"def portal_config_params\n params.require(:portal_config).permit(:end_point, :username, :password, :info, :version)\n end",
"def pg_sy_razorpay_config_params\n params.require(:pg_sy_razorpay_config).permit(:publishable_key, :secret_key, :alias_name, :merchant_id, :country_id, :tax_amount, :payment_gateway_id)\n end",
"def presets\n h = Beaker::Options::OptionsHash.new\n h.merge({\n :project => 'Beaker',\n :department => 'unknown',\n :created_by => ENV['USER'] || ENV['USERNAME'] || 'unknown',\n :host_tags => {},\n :openstack_api_key => ENV.fetch('OS_PASSWORD', nil),\n :openstack_username => ENV.fetch('OS_USERNAME', nil),\n :openstack_auth_url => \"#{ENV.fetch('OS_AUTH_URL', nil)}/tokens\",\n :openstack_tenant => ENV.fetch('OS_TENANT_NAME', nil),\n :openstack_keyname => ENV.fetch('OS_KEYNAME', nil),\n :openstack_network => ENV.fetch('OS_NETWORK', nil),\n :openstack_region => ENV.fetch('OS_REGION', nil),\n :openstack_volume_support => ENV['OS_VOLUME_SUPPORT'] || true,\n :jenkins_build_url => nil,\n :validate => true,\n :configure => true,\n :log_level => 'info',\n :trace_limit => 10,\n :\"master-start-curl-retries\" => 120,\n :masterless => false,\n :options_file => nil,\n :type => 'pe',\n :provision => true,\n :preserve_hosts => 'never',\n :root_keys => false,\n :quiet => false,\n :project_root => File.expand_path(File.join(__dir__, \"../\")),\n :xml_dir => 'junit',\n :xml_file => 'beaker_junit.xml',\n :xml_time => 'beaker_times.xml',\n :xml_time_enabled => false,\n :xml_stylesheet => 'junit.xsl',\n :default_log_prefix => 'beaker_logs',\n :log_dir => 'log',\n :log_sut_event => 'sut.log',\n :color => true,\n :dry_run => false,\n :test_tag_and => '',\n :test_tag_or => '',\n :test_tag_exclude => '',\n :timeout => 900, # 15 minutes\n :fail_mode => 'slow',\n :test_results_file => '',\n :accept_all_exit_codes => false,\n :timesync => false,\n :set_env => true,\n :disable_updates => true,\n :repo_proxy => false,\n :package_proxy => false,\n :add_el_extras => false,\n :consoleport => 443,\n :pe_dir => '/opt/enterprise/dists',\n :pe_version_file => 'LATEST',\n :pe_version_file_win => 'LATEST-win',\n :host_env => {},\n :host_name_prefix => nil,\n :ssh_env_file => '~/.ssh/environment',\n :profile_d_env_file => '/etc/profile.d/beaker_env.sh',\n :dot_fog => File.join(ENV.fetch('HOME', nil), '.fog'),\n :ec2_yaml => 'config/image_templates/ec2.yaml',\n :help => false,\n :collect_perf_data => 'none',\n :puppetdb_port_ssl => 8081,\n :puppetdb_port_nonssl => 8080,\n :puppetserver_port => 8140,\n :nodeclassifier_port => 4433,\n :cache_files_locally => false,\n :aws_keyname_modifier => rand(10**10).to_s.rjust(10, '0'), # 10 digit random number string\n :run_in_parallel => [],\n :use_fog_credentials => true,\n :ssh => {\n :config => false,\n :verify_host_key => false,\n :auth_methods => [\"publickey\"],\n :port => 22,\n :forward_agent => true,\n :keys => [\"#{ENV.fetch('HOME', nil)}/.ssh/id_rsa\"],\n :user_known_hosts_file => \"#{ENV.fetch('HOME', nil)}/.ssh/known_hosts\",\n :keepalive => true,\n },\n })\n end",
"def initialize(api_key=nil)\n @api_key = api_key || ENV['KULER_API_KEY'] || raise(ArgumentError, 'no API key found')\n end",
"def init_default_config\n configuration.project_id ||= Debugger.default_project_id\n configuration.credentials ||= Debugger.default_credentials\n configuration.service_name ||= Debugger.default_service_name\n configuration.service_version ||= Debugger.default_service_version\n end",
"def peer_hash_defaults(phash)\n\t\t\tdata = phash.dup\n\t\t\tdata[:port] ||= 3333 # @todo Network;:DEFAULT_PORT\n\t\t\tdata[:name] ||= \"SwarmNode_#{data[:uuid]}\"\n\t\t\tdata[:hive_version] ||= hive_version\n\t\t\tdata[:handler] ||= handler_type\n\t\t\tdata[:protocol] ||= protocol_type\n\t\t\tdata[:ssl] ||= 1\n\t\t\tdata[:peers] ||= []\n\t\t\tif data[:peers].is_a?(Array)\n\t\t\t\tdata[:peers] = data[:peers].join(',')\n\t\t\tend\n#\t\t\tdata[:created_at] ||= DateTime.now.to_s\n#\t\t\tdata[:updated_at] ||= DateTime.now.to_s\n\t\t\tdata\n\t\tend",
"def configure_jira options\n url = options[:url]\n\n # This feels a bit weird, but can't see an obviously better way to share\n # command-global variables.\n options[:client] = Datamine::Jira::REST.factory url\nend",
"def initialize(email, password, apikey)\n @config, @config[:email], @config[:password],@config[:apikey] = {}, email, password,\"?app_key=#{apikey}\"\n end",
"def initialize(options = {})\n options[:store_id] ||= ENV['IGLOBAL_STORE_ID']\n options[:api_key] ||= ENV['IGLOBAL_API_KEY']\n \n requires!(options, :store_id, :api_key)\n @options = options\n super\n end",
"def initialize(opts = {})\n @api_key = opts[:api_key]\n @search_engine_id = opts[:search_engine_id]\n end",
"def asana_api_key\n @default_options.fetch(:asana_api_key, nil)\n end",
"def api_key=(_arg0); end",
"def api_key=(_arg0); end",
"def api_key=(_arg0); end",
"def initialize opts = {}\n opts = Comufy.symbolize_keys(opts)\n\n begin\n yaml_location = opts.delete(:yaml)\n yaml = YAML.load_file(yaml_location)\n yaml = Comufy.symbolize_keys(yaml)\n rescue\n yaml = Hash.new()\n end\n\n @user = yaml.delete(:user) || opts.delete(:user) || ENV.fetch('COMUFY_USER', nil)\n @password = yaml.delete(:password) || opts.delete(:password) || ENV.fetch('COMUFY_PASSWORD', nil)\n @access_token = yaml.delete(:token) || opts.delete(:token) || ENV.fetch('COMUFY_TOKEN', nil)\n @expiry_time = yaml.delete(:time) || opts.delete(:time) || ENV.fetch('COMUFY_EXPIRY_TIME', nil)\n @base_api_url = yaml.delete(:url) || opts.delete(:url) || ENV.fetch('COMUFY_URL', 'http://www.sociableapi.com/xcoreweb/client')\n end",
"def default_options=(opts); end",
"def get_httparty_config(options)\n return if options.nil?\n\n httparty = Gitlab::CLI::Helpers.yaml_load(options)\n raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash\n\n Gitlab::CLI::Helpers.symbolize_keys httparty\n end",
"def autofill_from_config\n self.pid ||= Config.credentials[:PID] if self.respond_to?(:pid=)\n self.pak ||= Config.credentials[:PAK] if self.respond_to?(:pak=)\n \n # Note: URLs are optional fields, but prefilling from config anyway\n self.cancel_url ||= Config.endpoints[:cancel] if self.respond_to?(:cancel_url=)\n self.success_url ||= Config.endpoints[:success] if self.respond_to?(:success_url=)\n self.failure_url ||= Config.endpoints[:failure] if self.respond_to?(:failure_url=)\n end",
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))\n if File.file?(config_path)\n config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})\n defaults = defaults.merge(config_options)\n end\n\n # Enforce implied options\n defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]\n\n Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))\n end",
"def setup(options = {}); end",
"def initialize *params\n if params.first.is_a?(Hash)\n hash_options = params.first\n @user = hash_options[:username]\n @pass = hash_options[:password]\n @dev_key = hash_options[:dev_key]\n @client_id = hash_options[:client_id] || \"youtube_it\"\n @legacy_debug_flag = hash_options[:debug]\n elsif params.first\n puts \"* warning: the method YouTubeIt::Client.new(user, passwd, dev_key) is deprecated, use YouTubeIt::Client.new(:username => 'user', :password => 'passwd', :dev_key => 'dev_key')\"\n @user = params.shift\n @pass = params.shift\n @dev_key = params.shift\n @client_id = params.shift || \"youtube_it\"\n @legacy_debug_flag = params.shift\n end\n end",
"def command_line_params\n params = \"\"\n\n # Disallow password auth. We need to fail if no trusted key is set up.\n params += \"-o PasswordAuthentication=no \"\n\n # Disallow other keyoard-interactive auth methods.\n params += \"-o ChallengeResponseAuthentication=no \"\n\n # Automatically add unknown hosts to the \"known hosts\" file, without prompting.\n params += \"-o StrictHostKeyChecking=no \"\n\n # Also silence warnings since StrictHostKeyChecking=no always issues a warning\n params += \"-o LogLevel=ERROR \"\n\n if !@fail_on_host_changes\n # Ignore when the signature of a host changes. This usually happens when a machine is upgraded,\n # but could also happen due to man-in-the-middle attacks.\n params += \"-o UserKnownHostsFile=/dev/null \"\n end\n\n params\n end",
"def initialize(params={})\n self.api_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi'\n # self.api_url = 'https://pay1.plugnpay.com/payment/inputtestapi.cgi'\n self.publisher_name = params['publisher-name'] if params['publisher-name']\n self.debug = params['debug'] if params['debug']\n end",
"def default_options\n {\n :description => '', # Name\n :type => 0, # 0 - Email, 1 - External script, 2 - SMS, 3 - Jabber, 100 - EzTexting\n :smtp_server => '',\n :smtp_helo => '',\n :smtp_email => '', # Email address of Zabbix server\n :exec_path => '', # Name of external script\n :gsm_modem => '', # Serial device name of GSM modem\n :username => '', # Jabber user name used by Zabbix server\n :passwd => '' # Jabber password used by Zabbix server\n }\n end",
"def set_defaults\n @defaults = RHC::Vendor::ParseConfig.new()\n @opts = RHC::Vendor::ParseConfig.new() # option switches that override config file\n\n @env_config = RHC::Vendor::ParseConfig.new()\n @global_config = nil\n @local_config = nil\n @opts_config = nil # config file passed in the options\n @additional_config = nil\n\n @default_proxy = nil\n\n @defaults.add('insecure', false)\n @defaults.add('libra_server', openshift_online_server)\n\n @env_config.add('libra_server', libra_server_env) if libra_server_env\n @env_config.add('libra_server', rhc_server_env) if rhc_server_env\n\n @opts_config_path = nil\n end",
"def api_base_url; @opts[:api_base_url]; end",
"def default_options; {} end",
"def initialize(api_key, options = {})\n $api_key = api_key\n $redis = options[:redis] || Redis.new\n $debug = options[:debug] || false\n end",
"def create_default_authentication_radius_configuration(opts)\n opts = check_params(opts,[:servers])\n super(opts)\n end",
"def required_properties\n {\n \"cc\" => {\n \"internal_service_hostname\" => \"cc.service.cf.internal\"\n },\n \"loggregator\" => {\n \"etcd\" => {\n \"machines\" => []\n },\n \"uaa\" => {\n \"client_secret\" => \"secret\"\n }\n },\n \"system_domain\" => \"bosh-lite.com\",\n }\n end",
"def setup_options(options = T.unsafe(nil)); end",
"def opts\n load_defaults unless @opts\n @opts\n end",
"def auth_params\n return {} unless TaxCloud.configuration\n {\n 'apiLoginID' => TaxCloud.configuration.api_login_id,\n 'apiKey' => TaxCloud.configuration.api_key\n }\n end",
"def initialize(options)\n @pos_id = options[:pos_id].to_i\n @pos_auth_key = options[:pos_auth_key]\n @key1 = options[:key1]\n @key2 = options[:key2]\n @gateway_url = options[:gateway_url] || 'www.platnosci.pl'\n @variant = options[:variant] || 'default'\n @encoding = options[:encoding] || 'UTF'\n @test_payment = options.fetch(:test_payment, false)\n @add_signature = options.fetch(:add_signature, true)\n\n validate_options!\n end",
"def common_options (d, container)\n # Deprecated section\n if container[\"link\"] != nil\n print \"develop.yaml\\n\"\n print \"link: option is deprecated, use links: \\n\"\n end\n\n container_name = \"\"\n if container[\"image\"] != nil then d.image = container[\"image\"] end\n if container[\"create_args\"] != nil then d.create_args = container[\"create_args\"] end\n if container[\"var_env\"] != nil then d.env = container[\"var_env\"] end\n if container[\"links\"] != nil\n links = container[\"links\"]\n if !links.empty?\n links.each do |link|\n d.link(link)\n end\n end\n end\n if container[\"name\"] != nil\n d.name = container_name = container[\"name\"]\n end\n\n #default volumes for all containers\n default_volumens = [\"/vagrant:/project\"]\n if container_name == \"#{AUTHOR_CTR_NAME}\"\n default_volumens += [\"/aemconfig:/bin/crx-quickstart/install/install\"]\n end\n if container_name == \"#{WORKDIR_CTR_NAME}\" || container_name == \"#{BUILD_CTR_NAME}\" || container_name == \"#{BASE_CTR_NAME}\"\n default_volumens += [\"/.m2:/root/.m2\"]\n end\n if container_name == \"#{BASE_CTR_NAME}\"\n default_volumens += [\"/aemconfig:/root/aemconfig\"]\n end\n if container_name == \"#{GIT_CTR_NAME}\"\n default_volumens += [\"/ssh/id_rsa:/root/.ssh/id_rsa\",\"/gitconfig/.gitconfig:/root/.gitconfig\"]\n end\n if container[\"volumes\"] != nil\n d.volumes = container[\"volumes\"] + default_volumens\n else\n d.volumes = default_volumens\n end\n if container[\"registry\"] != nil\n docker_login d, container[\"registry\"]\n end\nend",
"def set_default_options\n end",
"def kitchen_config\n {\n 'driver' => driver_config,\n 'transport' => transport_config,\n 'provisioner' => provisioner_config,\n 'platforms' => expand_platforms.map {|name| platform_config(name) },\n 'suites' => [suite_config],\n }\n end",
"def core_setting_params\n params.require(:core_setting).permit(:main_phone, :main_email, :address, :site_description, :vk_link, :vk_personal_link, :instagram_link, :youtube_link)\n end",
"def yardopts_options(opts); end"
] | [
"0.6175032",
"0.6031856",
"0.59990984",
"0.59951645",
"0.59257764",
"0.5907216",
"0.5802565",
"0.57861054",
"0.5776028",
"0.57445747",
"0.5729467",
"0.5700546",
"0.56940365",
"0.56734604",
"0.56574047",
"0.5648762",
"0.5642558",
"0.5635029",
"0.55793554",
"0.5576615",
"0.55743414",
"0.5567447",
"0.5542187",
"0.5527732",
"0.55073124",
"0.55044526",
"0.5497295",
"0.5479558",
"0.54759127",
"0.54732794",
"0.5450492",
"0.5428601",
"0.5418314",
"0.54102683",
"0.5409095",
"0.5407526",
"0.54011613",
"0.53972256",
"0.5390217",
"0.5380845",
"0.5378642",
"0.5370372",
"0.53698874",
"0.5367569",
"0.535988",
"0.5352681",
"0.5342596",
"0.53423584",
"0.5341442",
"0.53403777",
"0.53389025",
"0.53363967",
"0.53329086",
"0.5331344",
"0.53129154",
"0.53048825",
"0.53044516",
"0.53003037",
"0.5295937",
"0.5295937",
"0.5293688",
"0.5292267",
"0.5289426",
"0.528793",
"0.5285627",
"0.5284699",
"0.52805436",
"0.5269532",
"0.5268505",
"0.52628225",
"0.525864",
"0.52564347",
"0.5255935",
"0.5255935",
"0.5255935",
"0.5255928",
"0.52492535",
"0.52472514",
"0.5243018",
"0.52366894",
"0.52263576",
"0.52263474",
"0.5221046",
"0.52195704",
"0.5219473",
"0.5211089",
"0.52103585",
"0.5203149",
"0.5199821",
"0.51959383",
"0.5191881",
"0.51895547",
"0.5188097",
"0.51879144",
"0.5186909",
"0.51868606",
"0.5185347",
"0.518359",
"0.5183324",
"0.51828355"
] | 0.54787797 | 28 |
Queue a notification request in the Hydra. | def add(params = {})
@hydra.queue(request('add', params))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue notification\n @notification_queue.unshift notification\n end",
"def queue(request)\n request.hydra = self\n queued_requests << request\n end",
"def will_notify\n #Resque.safe_enqueue Notification, to_user_id, id, APP::NOTIFICATIONS::MESSAGE\n end",
"def queued\n hydra.queued_requests\n end",
"def send_notifications\n DelayedJob.enqueue('NewPostingNotifier',\n Time.now + (CONSTANTS['delay_comment_notifications'].to_i).seconds,\n self.blog.id, self.id\n )\n end",
"def notify_of_request\n # UserNotifier.async_deliver_donations_requested(user)\n end",
"def send_notification\n\n\n end",
"def update_notification!(notification: nil)\n add_to_task_queue do\n notification_data_source.update_notification!(notification: notification)\n end\n end",
"def queue_front(request)\n request.hydra = self\n queued_requests.unshift request\n end",
"def create_notification; end",
"def push(notif)\n\n end",
"def notify_post\n raise \"not yet implemented\"\n end",
"def notifications\n end",
"def send_notification(method, params); end",
"def send_notification method, params\n response = {\n jsonrpc: \"2.0\",\n method: method,\n params: params\n }\n json = response.to_json\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n end",
"def notify(data={})\n RestClient::Request.execute(:method => :post, :url => notify_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT)\n rescue\n nil\n end",
"def act notification, options={}\n # ...or nothing\n end",
"def notify(params)\n client.post('/notify', params)\n end",
"def notify\n end",
"def notification(function_name, *para)\n para = {'method' => function_name, 'params' => para, 'id' => nil}\n .to_json\n send_request para\n nil\n end",
"def notify_resource_added(resource, request)\n email = OrderMailer.create_resource_added(resource, request)\n Thread.new(email) do |e|\n OrderMailer.deliver(email)\n end\n end",
"def notify(event, message, *args)\n api_key = args.first.is_a?(String) || args.first.is_a?(Array) ? args.shift : self.api_key\n\n raise ConfigurationError, \"You must provide an API key to send notifications\" if api_key.nil?\n raise ConfigurationError, \"You must provide an application name to send notifications\" if application.nil?\n\n if args.first.is_a?(Fixnum)\n options = { :priority => args.shift, :delayed => args.shift || Prowler.delayed }\n else\n options = args.last.is_a?(Hash) ? args.pop : {}\n options = { :priority => Prowler::Priority::NORMAL, :delayed => Prowler.delayed }.merge(options)\n end\n\n options.merge!(\n :application => application, :providerkey => provider_key,\n :apikey => api_key, :event => event, :description => message\n )\n\n if options.delete(:delayed)\n enqueue_delayed_job(options)\n else\n perform(:add, options, :post, Success)\n end\n end",
"def send_notifications\n end",
"def async_notify_on_creation\n Delayed::Job.enqueue(\n NewPostingNotifier.new(self.id,\"New Posting by #{self.user.nickname}: #{self.title}\", ADMIN_EMAIL_ADDRESS),\n { :run_at => Time.now()+(CONSTANTS['delay_new_posting_notifications'].to_i).seconds }\n )\n end",
"def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend",
"def add_notification(notification)\n query_api_object Model::Notification, '/rest/notifications', notification.to_hash, 'POST'\n end",
"def notify!\n if self.commentable.comments.count > 1\n MailWorker.perform_async(\"CommentMailer\", :comment_received, self.id)\n else\n MailWorker.perform_async(\"RequestMailer\", :request_in_process, self.commentable.id)\n end\n end",
"def request_notification(request)\n @request = request\n mail to: request.owner.email, subject: \"Incoming request for downloading dataset\"\n end",
"def notify\n return if destroy_if_old\n\n increase_busy_counter\n\n create_push\n end",
"def notify(mid, *args, **kwargs)\n @notification_name = mid\n do_notify(*args, **kwargs)\n end",
"def queue_in\n @channel.queue('dns-in', durable: true)\n end",
"def enqueue(payload)\n end",
"def queue_intention(intention)\n @queued_intentions.push intention\n nil\n end",
"def notify(interests, data = {})\n Request.new(\n @eventflit_client,\n :post,\n url(\"/publishes\"),\n {},\n payload(interests, data)\n ).send_sync\n end",
"def send_request_notification_email\n ReservationMailer.request_notification(self).deliver_now\n end",
"def notify(payload)\n\t\tgeneration_id = [@parameters['generation_id']]\n\t\toptions = {data: { payload: payload } }\n\tend",
"def notify(msg)\n @room_queue.push(msg)\n end",
"def notify\n {\n }\n end",
"def notify\n {\n }\n end",
"def enqueue(payload)\n @queue.publish(JSON.generate(payload), :routing_key => @queue.name)\n end",
"def post_notification( notification_type, from = nil, options={})\n attributes = {\n :info => options,\n :source_id => from.id,\n :target_id => id,\n :typenum => notification_type,\n :accepted => false\n }\n attributes[:source_id] = from.id if from\n notification = Notification.create( attributes )\n self.notifications_received << notification\n notification\n end",
"def create_notification!(id: nil, priority: nil, type: nil, user_id: nil, name: nil, message: nil, details: nil)\n add_to_task_queue do\n notification_data_source.create_notification!(\n id: id,\n priority: priority,\n type: type,\n user_id: user_id,\n name: name,\n message: message,\n details: details\n )\n end\n end",
"def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end",
"def push(event:)\n super\n\n @queue << event\n end",
"def send_notification\n AdminMailer.delay.new_report(self)\n end",
"def notification_on_create\n create_notification(:create)\n end",
"def dispatch(payload)\n queue.push(payload)\n end",
"def requeue\n update_attributes(failed: false, failed_at: nil, failure_reason: nil,\n delivered: false, delivered_at: nil)\n queue\n end",
"def pop_notification\n notification_queue.shift\n end",
"def queue_request(kind, type, payload, target, callback)\n request = {:kind => kind, :type => type, :payload => payload, :target => target, :callback => callback}\n Log.info(\"[offline] Queuing request: #{request.inspect}\")\n vote_to_restart if (@restart_vote_count += 1) >= MAX_QUEUED_REQUESTS\n if @state == :initializing\n # We are in the initialization callback, requests should be put at the head of the queue\n @queue.unshift(request)\n else\n @queue << request\n end\n true\n end",
"def create_notification!\n ::Users::Notifications::NewBuyRequest.create(\n recipient_user_id: buyer.parent_id, sender_user_id: buyer_id, related_model_type:'Trading::BuyRequest', related_model_id: self.id,\n uri: Rails.application.routes.url_helpers.buy_request_path(self)\n )\n ::NotificationMail.create_from_mail(buyer_id, buyer.parent_id, UserMailer.new_buy_request(self.items.first, buyer) )\n end",
"def notify!(event)\n notifications.find_or_create_by!(event: event)\n end",
"def add_request(timestamp)\n # add to total requests\n @total_requests += 1\n @logger.debug(\"Pushing timestamp: #{Time.at(timestamp).to_s}\")\n @queue.push(timestamp)\n end",
"def notify\n {}\n end",
"def notify\n {}\n end",
"def notify\n {}\n end",
"def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end",
"def notify_new_finding\n # TODO: make the method avoid the creation of a Notification record\n end",
"def send_notification(msg)\n EM.next_tick do\n @do_notify.call(msg)\n end\n end",
"def add_notification(notification)\n query_api_object Notification, \"/rest/notifications\", notification.dump(), \"POST\"\n end",
"def log_request\n result = super\n push_outstanding_request\n result\n end",
"def send_new_booking_request_notifications\n\n if pay_now\n notify_manager_pay_now\n notify_request_to_customer_pay_now\n else\n notify_manager\n notify_request_to_customer\n end\n\n end",
"def notify_business\n business.add_message_to_queue(\"Hey #{business.name}, we've just deposited #{amount} into your account! Thanks for being great!\")\n end",
"def deliver\n APN::Notifications.deliver([self])\n end",
"def create_notification(session_id, person_id, user_id, finalised, processing_started_at, sent)\n create(:queued_notification,\n session_id: session_id,\n person_id: person_id,\n current_user_id: user_id,\n processing_started_at: processing_started_at,\n edit_finalised: finalised,\n sent: sent)\n end",
"def queue_dj\n if persisted?\n handler_matcher = \"%SyncRequest%id: #{id}%school_id: #{school_id}%year: #{year}%priority: #{priority}%month: #{month}%\"\n if filter_by_event\n handler_matcher = \"#{handler_matcher}%filter_by_event: #{filter_by_event}%\"\n end\n\n unless Delayed::Job.where(\"handler like ? AND attempts = 0\", handler_matcher).exists?\n # delayed job prioity is lower number -> higher priority\n # queue on DelayedJob starting sync. safe=false for exception to force retrying\n delay(priority: -priority).start(false)\n end\n end\n end",
"def send_notifications\n send_new_post_to(:person) if self.person.notify_on_response_posted\n send_new_post_to(:receiver) if self.receiver && self.receiver.notify_on_response_received\n end",
"def deliver\n @queue << self\n end",
"def send_execution_notification\n payload = execution_notification_payload\n trade_order.portfolio.user.notify_devices payload, self\n end",
"def set_notification\n @notification = Notification.for_user(current_api_v1_user).find(params[:id])\n end",
"def defer(method, object)\n raise NoJobQueueError.new unless @job_queue\n @job_queue.enqueue method, get_request(object).to_hash\n end",
"def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end",
"def call\n context.response ||= notify\n end",
"def queue_msg(msg)\n dispatch_msg(msg)\n end",
"def notification(event)\n scene.notification(event.to_sym,self)\n end",
"def notify(*args, **kwargs)\n new.notify(*args, **kwargs)\n end",
"def post(ev)\n\t\t@queue << ev\n\tend",
"def notify_updating\n @msg = \"Deployment Started\"\n post\n end",
"def notify!(message)\n message = message.merge(reference: @reference) if @reference\n\n notification_url = @notification_url\n if notification_url\n message_json = message.stringify_keys.to_json\n\n # TODO: Retry on failure\n @logger.info { \"Notifying #{notification_url} with message: #{message_json}\" }\n begin\n Excon.post(notification_url,\n :body => message_json,\n :headers => {'Content-Type' => 'application/json; charset=utf-8'})\n rescue => exception\n Application.get.report_exception(exception, \"Notification failed with exception\")\n end\n else\n if (river = Application.get.river)\n begin\n river.publish(message.merge(\n uid: @uid,\n event: \"tootsie_#{message[:event]}\"))\n rescue => exception\n Application.get.report_exception(exception, \"River notification failed with exception\")\n end\n end\n end\n end",
"def sidekiq_enqueue\n ReminderDisplayWorker.perform_at(displayed_at, id)\n end",
"def queue\n @queue.pending\n end",
"def notify\n @transaction_id = params[:transaction_id]\n do_notify\n end",
"def notify(bucket)\n @queue.push({:Event => \"New Message\", :Bucket => bucket})\n end",
"def send_notification *args, &block\n if args.length == 1 && args.first.kind_of?( Rpc::Notification )\n _send_request args.first\n elsif args.length == 1 && args.first.kind_of?( Hash )\n h = args.first\n send_notification( h[\"method\"], h[\"params\"], &block )\n elsif args.length == 2\n _send_request Rpc::Notification.new(self, *args)\n else\n raise Rpc::ServerError(-1, extra_msg: \"in Rpc::Connection.send_notification : Wrong number of argument.\", args: args)\n end\n end",
"def notification(params)\n mail(params)\n end",
"def register!\n return if @registered\n @registered = true\n\n self.behavior = :notify\n @subscriber = ActiveSupport::Notifications.subscribe(%r{^deprecation}) do |*args|\n queue.enqueue args\n end\n end",
"def create\n @notification = Notification.new(notification_params)\n if @notification.save\n Notifier.send_notification(@notification)\n render json: \"Created succesfully\", status: :ok\n else\n render json: @notification.errors, status: :unprocessable_entity\n end\n end",
"def enqueue(payload)\n @queue.publish(payload.encode, :persistent => true)\n end",
"def send_stock_notifications\n SendStockNotificationsJob.perform_later(sku)\n end",
"def create\n @notification = Notification.new(notification_params)\n @notification.app = @app\n\n if params[:send] == 'now'\n @notification.update(scheduled_for: Time.now)\n else\n @notification.update(scheduled_for: Time.parse(notification_params['scheduled_for']).utc)\n end\n\n @notification.user = current_user\n @notification.rpush_app = @notification_app\n @notification.save\n\n respond_modal_with @notification, location: app_notifications_url\n end",
"def queue_job; end",
"def notify(interests, data = {})\n Request.new(\n @pusher_client,\n :post,\n url(\"/notifications\"),\n {},\n payload(interests, data)\n ).send_sync\n end",
"def enqueue(action)\n # add our request id for tracing purposes\n action[:messageId] = uid\n unless queue_full = @queue.length >= @max_queue_size\n ensure_worker_running\n @queue << action\n end\n !queue_full\n end",
"def _publish\n puts(\"pushing message: #{self.to_json} to queue #{@queue}\")\n AMQPCli.instance.push(self.to_json, @queue)\n end",
"def notify\n raise NotImplementedError\n end",
"def notification(data)\n type = data.delete(\"type\") || data.delete(:type) || data.delete(\"type\") || data.delete(:type)\n zone = to_demiurge_name(data.delete(\"zone\") || data.delete(:zone) || @item.zone)\n location = to_demiurge_name(data.delete(\"location\") || data.delete(:location) || @item.location)\n actor = to_demiurge_name(data.delete(\"actor\") || data.delete(:actor) || @item)\n @item.engine.send_notification(data, type: type.to_s, zone: zone, location: location, actor: actor, include_context: true)\n nil\n end",
"def send_notification(msg)\n $BLIX_NOTIFY.push(msg)\n puts \"[DummyServer] notify: message=#{msg}\" if $DEBUG\n end",
"def queue(message); end",
"def notifier\n @loop_notify.promise\n end",
"def enqueue_message(message); end",
"def requeue\n @action = :requeue\n end"
] | [
"0.73767567",
"0.678501",
"0.64936423",
"0.6447023",
"0.63201845",
"0.62905234",
"0.6220999",
"0.61633766",
"0.61333746",
"0.6040526",
"0.60397565",
"0.60196996",
"0.6008436",
"0.59936816",
"0.5992344",
"0.5972296",
"0.59697366",
"0.5967277",
"0.5956669",
"0.5932285",
"0.5926553",
"0.5925114",
"0.5903752",
"0.5887878",
"0.58677113",
"0.5856705",
"0.583795",
"0.58348703",
"0.58304113",
"0.5829587",
"0.58039355",
"0.57991004",
"0.5799001",
"0.5795885",
"0.5792579",
"0.57897633",
"0.5786641",
"0.5780683",
"0.5780683",
"0.5744138",
"0.5738793",
"0.57224774",
"0.5719405",
"0.570485",
"0.5700665",
"0.56748",
"0.5642909",
"0.5634302",
"0.5615583",
"0.5611212",
"0.56050825",
"0.5604371",
"0.56009924",
"0.55858535",
"0.55858535",
"0.55858535",
"0.55641615",
"0.5561542",
"0.5558559",
"0.55517626",
"0.55480427",
"0.55403656",
"0.553448",
"0.552977",
"0.55248684",
"0.5520891",
"0.55196375",
"0.55124915",
"0.5512333",
"0.54920185",
"0.5489865",
"0.5488757",
"0.5484598",
"0.54810286",
"0.5478923",
"0.5465589",
"0.54545283",
"0.54542667",
"0.5450235",
"0.54497695",
"0.54481566",
"0.54444176",
"0.54431695",
"0.54426813",
"0.5440288",
"0.54399705",
"0.5434383",
"0.54268545",
"0.54239583",
"0.54221755",
"0.54080325",
"0.54078615",
"0.54070926",
"0.53985924",
"0.5392029",
"0.53880024",
"0.5370498",
"0.5359474",
"0.5354133",
"0.5348759",
"0.5347744"
] | 0.0 | -1 |
Modify this instance's defaults | def defaults(params)
@defaults = @defaults.merge(params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def defaults\n super\n end",
"def set_defaults\n super\n end",
"def set_defaults\n super\n end",
"def reset_defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def set_default_options\n end",
"def default!(defaults = {})\n replace(defaults.merge(self))\n end",
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"def defaults\n self.class.defaults\n end",
"def defaults\n self.class.defaults #.merge(@defaults || {})\n end",
"def reset!\n @defaults.each do |k, v|\n instance_variable_set(k, v)\n end\n end",
"def set_default_values\n self.class.defaults.each do |key, default|\n self[key] ||= default\n end\n end",
"def defaults!; end",
"def defaults!; end",
"def set_defaults\n self.published ||= false\n self.archived ||= false\n self.is_default ||= false\n self.version ||= 0\n self.visibility = ((self.org.present? && self.org.funder_only?) || self.is_default?) ? Template.visibilities[:publicly_visible] : Template.visibilities[:organisationally_visible] unless self.id.present?\n self.customization_of ||= nil\n self.family_id ||= new_family_id\n self.archived ||= false\n self.links ||= { funder: [], sample_plan: [] }\n end",
"def initialize(options={})\n @values = @@defaults.merge(options)\n end",
"def freeze\n @default_values.freeze\n super\n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end",
"def default_options=(opts); end",
"def set_defaults\n self.width ||= 0.20\n self.height ||= 0.20\n end",
"def options\n original_options = super\n user_defaults = @config\n user_defaults.merge(original_options)\n end",
"def initialize(*)\n super\n apply_defaults\n end",
"def options\n defaults.merge!(@options)\n end",
"def options\n defaults.merge!(@options)\n end",
"def initialize\n set_defaults\n end",
"def initialize\n set_defaults\n end",
"def defaults\n @defaults\n end",
"def set_defaults\n self.version = 0\n end",
"def defaults()\n\t\t@height ||= 200\n\t\t@width ||= 350\n\t\t@title ||= \"Savable Settings Demo\"\n\t\t@text ||= \"Try changing the window size, title and text in this window. You will see that it saves its state \" +\n\t\t\t\"to a file named settings.yaml. So when you run this program again, it will be the same as \" +\n\t\t\t\"when you left. To see this file, click the 'Refresh' button. To reset to \" +\n\t\t\t\"defaults, just delete settings.yaml.\"\n\tend",
"def reload!\n set_instance_variables(self.class.defaults)\n end",
"def reset\n keys.each do |key|\n instance_variable_set(:\"@#{key}\", defaults[key])\n self\n end\n end",
"def defaults!\n @badge_enabled = true\n @badge_position = 'top-left'\n @page_size = 25\n @webpacker_enabled = true\n end",
"def defaults\n {}\n end",
"def update!\n @defaults.each do |key, value|\n instance_variable_set(key, value) unless instance_variable_defined?(key)\n end\n end",
"def default!\n clear.merge!(defaults)\n end",
"def set_defaults\n super\n self.extended_useful_life_months ||= 0\n self.extended_useful_life_miles ||= 0\n end",
"def set_default\n end",
"def initialize\n @options = defaults\n end",
"def initialize\n @options = defaults\n end",
"def default_options; end",
"def default_options; end",
"def default_options; end",
"def reset_defaults_and_overrides\n default.clear\n override.clear\n end",
"def set_defaults\n self.mmr ||= 1500\n self.k_value ||= 40\n self.home_mmr ||= self.mmr\n self.away_mmr ||= self.mmr\n self.active ||= true\n self.total_games ||= 0\n end",
"def new_model_defaults\n end",
"def reset!\n @options = defaults\n end",
"def reset!\n @options = defaults\n end",
"def set_default_values\n # Ethernet configuration\n self.network_1_id ||= 1\n self.ethernet_ip_assignment_method_id ||=1\n # GRPS\n self.gprs_mtu ||= 1450\n # PSTN\n self.pstn_mtu ||= 1500\n # Time configuration\n self.time_zone ||= 'UTC'\n # Interval configuration\n self.configuration_update_interval ||= 3600\n self.status_interval ||= 3600\n self.send_data_interval ||= 86400\n # Software update configuration\n self.auto_update ||= false\n self.software_update_interval ||= 604800\n self.repo_type ||= 'stable'\n # Log configuration\n self.send_log_files ||= false\n # State XML\n self.state_xml ||= \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<modified>true</modified>\\n\"\n end",
"def default_options; {} end",
"def initialize_defaults\n %w(show_first_column show_last_column show_row_stripes show_column_stripes).each do |attr|\n send(\"#{attr}=\", 0)\n end\n end",
"def deferred_defaults\n set_default_path\n set_default_properties\n end",
"def set_defaults\n self.help ||= ENV['help_text']\n self.help_url ||= ENV['help_url']\n self.created_at ||= DateTime.current\n end",
"def reset!\n tap { set_defaults }\n end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def defaults\n self.behaviour_evaluated = false if self.behaviour_evaluated.nil?\n self.special_needs_ok = false if self.special_needs_ok.nil?\n self.long_term_resident = false if self.long_term_resident.nil?\n self.senior = false if self.senior.nil?\n end",
"def defaults\n {}\n end",
"def defaults\n {}\n end",
"def reset!\n @options = Name.defaults.dup\n end",
"def reset!\n configure do |c|\n DEFAULTS.each { |k, v| c.send(\"#{k}=\", v) }\n end\n end",
"def reset\n @options = Marshal.load(@default)\nend",
"def set_defaults\n self.state ||= 'NEW'\n self.account_id ||= Gizmo::Util::Uuid.generate\n self.account_name ||= self.subdomain\n end",
"def set_defaults\n if self.state.blank?\n self.state ||= :unsubmitted\n end\n if self.priority.blank?\n self.priority ||= :medium\n end\n if self.start.blank?\n self.start = Time.now + 1.day\n end\n if self.end.blank?\n self.end = start.to_time + 1.hour\n end\n if self.repeats.blank?\n end\n end",
"def set_defaults\n defaults = { primary_ip: '0.0.0.0',\n priority: 100,\n timers_advertise: 1,\n preempt: true,\n enable: true,\n ip_version: 2,\n mac_addr_adv_interval: 30,\n preempt_delay_min: 0,\n preempt_delay_reload: 0,\n delay_reload: 0 }\n\n # If the value is not set in the @property_hash then set\n # the value in the @property_flush.\n defaults.keys.each do |key|\n @property_flush[key] = defaults[key] unless @property_hash.key?(key)\n end\n end",
"def instance_options(default_options)\n initialize_default_options(default_options)\n set_instance_options(@options)\n end",
"def set_defaults\n self.annual_inflation_rate ||= 1.1\n self.pcnt_residual_value ||= 0\n self.condition_rollup_weight ||= 0\n end",
"def set_defaults\n\n unless self.credits.present?\n Credit.default_credits.each do |item|\n @credit = self.user_credits.new\n @credit.credit_id = item.id\n end\n end\n\n self.video_type ||= ENUMERATIONS[:video_type].first\n self.title = \"Untitled\"\n self.description = \"This video needs a description\"\n self.duration = 60\n end",
"def set_defaults\n set_nil_default( :archived, false )\n end",
"def with_defaults(defaults); end",
"def reset\n @options = VALID_OPTIONS_KEYS.inject({}) do |opts, k|\n default_option = OnTheSnow::Config.const_get(\"DEFAULT_#{k.upcase}\")\n self.send(\"#{k}=\", default_option)\n opts[k.to_s] = default_option #unless default_option.nil?\n opts\n end\n self\n end",
"def initialize options\n @defaults = CrisplyApi.defaults\n @params = override_defaults_with options\n end",
"def set_defaults(options = T.unsafe(nil)); end",
"def initialize_default_values!\n Marshal.load(Marshal.dump(self.class.default_values)).each do |k, v|\n self[k] ||= v\n end\n end",
"def default_settings=(hash)\n @default_settings = hash\n end",
"def set_defaults\n super\n self.seating_capacity ||= 0\n self.standing_capacity ||= 0\n self.wheelchair_capacity ||= 0\n end",
"def set_defaults\n self.state ||= 'ACTIVE'\n self.account_user_id ||= Gizmo::Util::Uuid.generate\n self.is_owner ||= false\n end",
"def defaults\n {\n colour: nil,\n name: nil,\n style: nil,\n value: '',\n position: [1, 1],\n }\n end",
"def set_defaults\n self.rate ||= 0\n end",
"def set_defaults\n unless persisted? \n self.active ||= false\n self.complete ||= false\n self.start_on ||= Date.today\n self.finished_on ||= Date.today + 1\n end\n end",
"def set_default_options()\n @options = OpenStruct.new(\n :output_base => nil,\n :verbose => false,\n :config_file => nil,\n :samples => nil,\n :delay => 30,\n :scheduler_opts => ''\n )\nend",
"def set_defaults\n self.min_service_life_months ||= 0\n self.replacement_cost ||= 0\n self.lease_length_months ||= 0\n self.rehabilitation_service_month ||= 0\n self.rehabilitation_labor_cost ||= 0\n self.rehabilitation_parts_cost ||= 0\n self.extended_service_life_months ||= 0\n self.min_used_purchase_service_life_months ||= 0\n self.cost_fy_year ||= current_planning_year_year\n end",
"def set_defaults\n if self.project.present?\n self.currency = self.project.account.account_setting.default_currency\n end\n \n self.quote_status = 0\n self.vat_rate = 20.0\n self.discount_percentage = 0.0\n self.new_quote = 1\n end"
] | [
"0.7836456",
"0.7836456",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.76169443",
"0.7473179",
"0.7473179",
"0.74016494",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7211073",
"0.7146635",
"0.7120246",
"0.70904917",
"0.7080999",
"0.7077079",
"0.70680934",
"0.70245034",
"0.70245034",
"0.69916743",
"0.6974257",
"0.69481623",
"0.69387925",
"0.69387925",
"0.68842584",
"0.68828213",
"0.68755865",
"0.68695146",
"0.68623763",
"0.68623763",
"0.68610495",
"0.68610495",
"0.6857608",
"0.6840709",
"0.6817107",
"0.68131804",
"0.6809095",
"0.6771298",
"0.67600584",
"0.67380595",
"0.67355955",
"0.67269003",
"0.66758543",
"0.6674563",
"0.6674563",
"0.6665842",
"0.6665842",
"0.6665842",
"0.66525173",
"0.6649476",
"0.6648325",
"0.664053",
"0.664053",
"0.6639268",
"0.6626866",
"0.66179514",
"0.66177946",
"0.66164935",
"0.6615469",
"0.66136736",
"0.66136736",
"0.6598234",
"0.65954006",
"0.6595143",
"0.6583619",
"0.6577842",
"0.65763587",
"0.65666384",
"0.6552102",
"0.6538103",
"0.6528288",
"0.6527394",
"0.6526089",
"0.65182495",
"0.65135807",
"0.650903",
"0.6494929",
"0.6493705",
"0.6493172",
"0.6483826",
"0.6482066",
"0.64818305",
"0.648145",
"0.6480455",
"0.6474697",
"0.64724046",
"0.6464781",
"0.6442393"
] | 0.67624235 | 50 |
Run all queued Hydra requests. | def run
@hydra.run
status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queued\n hydra.queued_requests\n end",
"def execute\n @responses = {succeeded: [], failed: [], pending: [], succeeded_by_id: {}, requests_by_id: {}}\n @start = Time.now\n EventMachine.run do\n requests.each do |request|\n @responses[:pending] << request.process!\n if request.id\n @responses[:requests_by_id][request.id] = request\n end\n end\n\n EM::PeriodicTimer.new(0.001) do\n process_requests\n end\n end\n @responses\n end",
"def run_all\n perform\n end",
"def run_all\n perform\n end",
"def run( nodes )\n\t\t\tresults = {}\n\t\t\thydra = Typhoeus::Hydra.new( self.runner_settings )\n\n\t\t\tnodes.each do |identifier, node|\n\t\t\t\tself.log.debug \"Making request for node %s\" % [ identifier ]\n\t\t\t\trequest = self.request_for_node( node )\n\t\t\t\trequest.on_complete do |response|\n\t\t\t\t\tself.log.debug \"Handling response for %s\" % [ identifier ]\n\t\t\t\t\tresults[ identifier ] =\n\t\t\t\t\t\tself.make_response_results( response, node )\n\t\t\t\tend\n\t\t\t\thydra.queue( request )\n\t\t\tend\n\n\t\t\thydra.run\n\n\t\t\treturn results\n\t\tend",
"def flush\n until @work_queue.empty? && @requests.zero?\n @main_queue.drain!\n sleep 0.1\n end\n end",
"def run_tasks()\n self.task_queue.each do |task|\n\n self.task_list << task\n trigger_event(:start,:task)\n\n result = self.send(task[:name],*(task[:args]))\n if result[:status] == :failed\n break\n end\n\n\n self.task_list.last[:result]=result\n trigger_event(:end,:task)\n end\n end",
"def queue(request)\n request.hydra = self\n queued_requests << request\n end",
"def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend",
"def call\n request_no = @request_queue.length\n Rails.logger.debug(\"Scheduling #{request_no} UN ComTrade requests\")\n\n interval =\n if request_no > MAX_REQUESTS_PER_HOUR\n BATCH_REQUEST_INTERVAL\n else\n REQUEST_INTERVAL\n end\n\n start_time = Time.now\n @request_queue.each.with_index do |uri, idx|\n Rails.logger.debug(\"Scheduling #{uri} ComTrade request\")\n ComTradeRequestWorker.perform_in(interval * idx, uri)\n end\n ComTradeRefreshWorker.perform_in(\n REQUEST_INTERVAL * request_no + 1.hour,\n start_time\n )\n end",
"def run_all()\n end",
"def run_linear_strategy\n\t\tdebug.print(3, \"Running linear strategy\", File.basename(__FILE__), __LINE__)\n\t\t\n\t\twhile hydra.queued_requests.length > 0\n\t\t\tdebug.print(1, \"Inside requests\", File.basename(__FILE__), __LINE__)\n\n\t\t\treq = hydra.queued_requests.pop\n\t\t\t#######binding.pry\n\n\t\t\tdebug.print(1, \"\\n Popped\", req.url, \"length is\", hydra.queued_requests.length, File.basename(__FILE__), __LINE__) \n\t\t\t\t#puts req, hydra.queued_requests.length\n\t\t\t\t\n\t\t\t\tdelay_request\n\n\t\t\t\tdebug.print(1, \"\\nProcessing, \", req.url, File.basename(__FILE__), __LINE__)\n\t\t\t\treq.run\n\t\t\tend\n\t\tend",
"def execute_handlers\n @@handlers.each { |handler| handler.execute }\n end",
"def run_all\n end",
"def run_all\n end",
"def run\n while running? || !queue.empty?\n payload = queue.pop(false)\n call_dispatchers(payload)\n end\n end",
"def masterrun\n self.workersrun \n self.serverrun \n end",
"def run_loop\n # Run all plugins\n @controller_plugins.each do |controller_plugin|\n controller_plugin.run\n log_stats(controller_plugin)\n end\n trigger_success_handlers\n end",
"def typhoeus_batch(urls)\n hydra = Typhoeus::Hydra.new(max_concurrency: 100)\n responses = []\n urls.each do |url|\n request = get_typhoeus_request(url)\n request.on_complete do |response|\n responses << response if response.success?\n end\n hydra.queue(request)\n request\n end\n hydra.run\n responses\n end",
"def run\n @cluster.retriable(api_name) do\n process(retriable_requests)\n\n # Stop retrying when there are no more requests to retry\n retriable_requests.empty?\n end\n\n responses\n end",
"def run_serially\n @all_stopped = false\n\n @resources.each do |name,object|\n object.run\n if object.respond_to? :wait\n object.wait\n else\n object.stop\n end\n end\n\n @all_stopped = true\n end",
"def perform\n\t\tbegin\n\t\t\tnext_run_at = Time.now + 30.minutes\n\t\t\tDataImporterWorker.perform_at(next_run_at)\n\t\t\tqds = QueryDataSource.find_all_by_enabled(true)\n\t\t\tqds.each do |q|\n\t\t\t\tQueryDataSourceWorker.perform_async(q.id)\n\t\t\tend\n\n\t\t\t#spree data source importer\n\t\t \tspree_data_sources = SpreeDataSource.find_all_by_enabled(true)\n\t\t \tspree_data_sources.each do |sds|\n\t\t\t\tSpreeDataSourceWorker.perform_async(sds.id)\n\t\t\tend\n\t\trescue Exception => e\n\t\t \tRails.logger.error e.to_s\n\t\t\tputs e.to_s\n\t\tend\n\tend",
"def process_command_queue\n $logger.debug \"process_cmd_queue: #{@cmd_queue.inspect()}\"\n while (@cmd_queue.length > 0)\n cmd=@cmd_queue.shift()\n if (!cmd.nil?) #Command Recieved\n Analyzer.connection.reconnect!()\n process_cmd(cmd)\n end\n end\n end",
"def run\n @workers = (0...[Etc.nprocessors, @server.length].min).map do\n fork do\n DRb.start_service\n server = DRbObject.new_with_uri(@url)\n\n until server.empty?\n klass, method_name = server.pop\n server.add_reporter(klass.run(method_name, @options)) if klass && method_name\n end\n end\n end\n\n shutdown\n @reporter.print_summary\n @reporter.exit_status\n end",
"def do_requests\n if @requests_queue.length() > 0\n # Make sure queue is sorted before any request is completed\n sort_requests_queue()\n request = @requests_queue[0]\n\n # Go to requested floor\n @next_floor = request.floor\n go_to_next_floor()\n\n # Remove request after it is complete\n @door.open_door()\n @requests_queue.delete(request)\n\n # Automatically close the door\n @door.close_door()\n end\n\n # Automatically go idle if 0 requests or at the end of request\n @movement = \"idle\"\n end",
"def work_with_droplets\n load_droplets\n dispatch_droplets\n logger.debug 'Working with list of DigitalOcean droplets'\n thread_chain\n end",
"def eventLoop\n @executor.executeQueuedTasks\n end",
"def run\n setup_queues\n setup_procs.each(&:call)\n\n Waiter.wait_until_signaled\n\n stop\n end",
"def refill_all_queues!\n # Dla POST musi byc jakies 'body' requestu, bo serwery czesto rzucaja wyjatkami (WEBrick w szczegolnosci).\n post '/queues/refill_all', :body => ' '\n true\n end",
"def fetch_and_store_articles\n hydra = Typhoeus::Hydra.new(max_concurrency: 20)\n FeedEntry.where(fetched: false).each do |feed_entry|\n begin\n request = Typhoeus::Request.new(\"http://access.alchemyapi.com/calls/url/URLGetText?apikey=2dca9a7577657ed330d2a99e2744a167f043b3c6&outputMode=json&url=#{feed_entry.url}\")\n request.on_complete &store_article(feed_entry)\n hydra.queue(request)\n rescue Exception => e\n Rails.logger.error \"Caught an error trying to queue feed_entry #{feed_entry.id} for Typhoeus call: #{e.inspect}\"\n next\n end\n end\n begin\n hydra.run\n rescue Exception => e\n Rails.logger.error \"Hydra threw an error: #{e.inspect}\"\n end\n end",
"def flush\n while !@queue.empty? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end",
"def execute!\n @context.backend.schedule { run }\n end",
"def perform\n track do\n reset!\n\n Restforce::DB::Registry.each do |mapping|\n run(\"CLEANING RECORDS\", Cleaner, mapping)\n run(\"ATTACHING RECORDS\", Attacher, mapping)\n run(\"PROPAGATING RECORDS\", Initializer, mapping)\n run(\"COLLECTING CHANGES\", Collector, mapping)\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n Restforce::DB::Registry.each do |mapping|\n run(\"UPDATING ASSOCIATIONS\", Associator, mapping)\n run(\"APPLYING CHANGES\", Synchronizer, mapping)\n end\n end\n end",
"def run_all\n deploy_code\n run_test\n end",
"def run\n run_build_tasks before_tasks, basic_tasks, after_tasks\n end",
"def run!\n loop do\n begin\n job = Job.new(get_apps)\n job.fetch_targets!\n post_messages!(job.to_hash)\n sleep(@interval)\n rescue Errno::ECONNREFUSED => ce\n puts \"\"\n sleep(@interval)\n end\n\n end\n end",
"def tick\n @requests.each do |id,req|\n req.tick\n end\n end",
"def run_all\n jammit\n end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def run_replications\n # Add fresh schedule\n old_shedule = @schedule\n @schedule = {}\n @active = false\n\n old_shedule.each_value do |conn|\n conn.start\n end\n end",
"def setup\n setup_requeue_queue\n consume_requeue\n setup_retry_queues\n end",
"def run\n install_signal_handlers\n\n loop do\n begin\n cleanup\n emails = find_emails\n deliver(emails) unless emails.empty?\n rescue ActiveRecord::Transactions::TransactionError\n end\n break if @once\n sleep @delay\n end\n end",
"def run\n return if halted?\n\n http = request.em\n http.callback {\n Benchy.logger.info \"#{name}\\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}\"\n run\n }\n http.errback {\n Benchy.logger.error \"#{name}\\t| Connection error!\"\n halt # TODO - Make this fail the ping and try again, not halt\n }\n end",
"def flush\n while !@queue.empty? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end",
"def execute_bulk_requests\n begin\n @responses = Hash.new\n @headers = Hash.new\n @all_urls = Hash.new\n data = ActiveSupport::JSON.decode(params[:data])\n @detailed_results = data[\"detailed_results\"]\n num_threads = data[\"threads\"].to_i\n data[\"lines_to_send\"].threadify(num_threads) { |line|\n path = data[\"path\"].gsub(/XXXCHANGEMEXXX/, line)\n headers = data[\"headers\"].gsub(/XXXCHANGEMEXXX/, line)\n body = data[\"body\"].gsub(/XXXCHANGEMEXXX/, line)\n data.each do |key, value|\n if key.start_with?(\"replace_\") && !key.end_with?(\"_by\")\n path.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n headers.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n body.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n end\n end\n if @cloud\n if @cloud.api == \"Atmos\"\n @responses[line], @headers[line], @all_urls[line] = atmos_request(data[\"http_method\"], path, headers, body)\n elsif @cloud.api == \"Amazon\"\n @responses[line], @headers[line], @all_urls[line] = amazon_request(data[\"http_method\"], path, headers, body)\n elsif @cloud.api == \"Swift\"\n @responses[line], @headers[line], @all_urls[line] = swift_request(data[\"http_method\"], path, headers, body)\n end\n else\n url = path\n uri = URI.parse(url)\n headers_to_send = Hash.new\n headers.split(\"\\n\").each do |row|\n hash = eval(row)\n headers_to_send[hash.keys.first.downcase] = hash.values.first.to_s\n end\n @responses[line] = http_request(url, uri.port, data[\"http_method\"], headers_to_send, body)\n @headers[line] = headers_to_send\n end\n }\n rescue Exception => e\n @exception = e\n end\n respond_to do |format|\n format.js { render 'shared/execute_bulk_requests' }\n end\n end",
"def perform_request\n returned = nil\n @requests ||= 0\n @requests += 1\n @request_time ||= 0\n @request_time += Benchmark.realtime { returned = yield }\n returned\n ensure\n @handlers.each { |handler| handler.call(@requests, @request_time) }\n end",
"def before_queue(urls)\n # stub\n end",
"def _run\n super.tap { reenqueue }\n end",
"def run\n @hydra.run\n end",
"def tick # :nodoc: all\n # Handle the tick\n # Do we have any retries due to be sent yet?\n # @mutex.synchronize{\n @parent.single_res_mutex.synchronize {\n time_now = Time.now\n @timeouts.keys.each do |client_query_id|\n msg, client_queue, select_queue, outstanding = @query_list[client_query_id]\n query_timeout, timeouts = @timeouts[client_query_id]\n if query_timeout < Time.now\n # Time the query out\n send_result_and_stop_querying(client_queue, client_query_id, select_queue, nil,\n ResolvTimeout.new('Query timed out'))\n next\n end\n timeouts_done = []\n timeouts.keys.sort.each do |timeout|\n if timeout < time_now\n # Send the next query\n res, retry_count = timeouts[timeout]\n id = [res, msg, client_query_id, retry_count]\n Dnsruby.log.debug(\"Sending msg to #{res.server}\")\n # We should keep a list of the queries which are outstanding\n outstanding.push(id)\n timeouts_done.push(timeout)\n timeouts.delete(timeout)\n\n # Pick a new QID here @TODO@ !!!\n # msg.header.id = rand(65535);\n # print \"New query : #{new_msg}\\n\"\n res.send_async(msg, select_queue, id)\n else\n break\n end\n end\n timeouts_done.each { |t| timeouts.delete(t) }\n end\n }\n end",
"def dispatch\n @queue.pop.run while @queue.ready?\n end",
"def run\n super\n\n config = _get_task_config \"control/collection_processor\"\n\n @sqs = Aws::SQS::Client.new({\n region: 'us-east-1',\n access_key_id: config[\"aws_access_key\"],\n secret_access_key: config[\"aws_secret_access_key\"]\n })\n\n @control_queue_uri = config[\"control_queue_uri\"]\n @status_queue_uri = config[\"status_queue_uri\"]\n sleep_interval = config[\"sleep\"] || 10\n max_seconds = config[\"max_seconds\"] || 36000\n\n handler = config[\"handler\"]\n\n # connect to the configured amazon queue & Grab one\n _set_status :available, nil\n instruction_data = nil\n iteration = 0\n while true\n\n # loop until we have something\n while !instruction_data\n\n _log \"Attempting to get an instruction from the queue!\"\n instruction_data = _get_queued_instruction # try again\n\n # kick it off if we got one, and break out of this loop\n if instruction_data\n _log \"[+] Executing #{instruction_data[\"id\"]} for #{sleep_interval} seconds! (expire in: ~#{max_seconds - (iteration * sleep_interval) }s)\"\n _set_status :start, \"#{instruction_data[\"id\"]}\"\n _execute_instruction(instruction_data)\n else\n _log \"Nothing to do, waiting!\"\n sleep sleep_interval\n end\n\n end\n\n # hold tight\n sleep sleep_interval\n\n # determine how we're doing\n task_count_left = _tasks_left\n seconds_elapsed = iteration * sleep_interval\n done = (iteration > 10 && task_count_left == 0 ) || (seconds_elapsed > max_seconds)\n\n _log \"Seconds elapsed: #{seconds_elapsed}\" if iteration % 10 == 0\n _log \"Tasks left: #{task_count_left}\" if iteration % 10 == 0\n\n if done\n _log_good \"Done with #{instruction_data[\"id\"]} after #{seconds_elapsed}s\"\n _set_status :end, {\n \"id\" => \"#{instruction_data[\"id\"]}\",\n \"elapsed\" => \"#{seconds_elapsed}\",\n \"entities\" => \"#{Intrigue::Model::Project.first(:name => instruction_data[\"id\"]).entities.count}\"\n }\n\n _log_good \"#{instruction_data[\"id\"]}\"\n _run_handlers instruction_data\n _set_status :sent, \"#{instruction_data[\"id\"]}\"\n\n instruction_data = nil\n iteration = -1\n\n end\n\n iteration +=1\n end\n\n end",
"def process_postponed_queries\n Array(@postponed_queries).each do |arguments, block|\n connection.add_index(*arguments, &block)\n end\n\n clear_queue\n\n self\n end",
"def perform\n ClientPlan.where(status: GlobalConstant::ClientPlan.active_status).all.each do |client_plan|\n client = Client.get_from_memcache(client_plan.client_id)\n client_usage_obj = populate_client_usage(client)\n notify_if_needed(client, client_plan, client_usage_obj)\n return if GlobalConstant::SignalHandling.sigint_received?\n end\n end",
"def process(requests)\n by_broker = requests.group_by {|request| broker_for(request)}\n\n if by_broker.count > 1 && @cluster.config.parallel_batches\n # Run in separate threads for parallelism\n by_broker.map do |broker, requests|\n Thread.new do\n process_broker(broker, requests)\n end\n end.each(&:join)\n else\n # Run in current thread\n by_broker.each do |broker, requests|\n process_broker(broker, requests)\n end\n end\n end",
"def test_proxies_concurrent_requests_properly\n hydra = Typhoeus::Hydra.new\n requests = Array.new(20) do |index|\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/echo_delayed_chunked\", http_options.deep_merge({\n :params => {\n :input => \"#{unique_test_id}-#{index}-#{SecureRandom.hex(40)}\",\n },\n }))\n hydra.queue(request)\n request\n end\n hydra.run\n\n assert_equal(20, requests.length)\n requests.each do |request|\n assert_response_code(200, request.response)\n assert(request.original_options[:params][:input])\n assert_equal(request.original_options[:params][:input], request.response.body)\n end\n end",
"def exec_request\n @urls.map { |url| fetch(url) }\n end",
"def run\n # Connect to Redis\n @redis_client = Redis.new(:host => @redis_host, :port => @redis_port, \n :db => @redis_db)\n # Start listening for items that show up on the queue.\n process_queue\n end",
"def run\n if not @test then\n @dirs.each do |dir|\n if @local\n `cd #{dir}; ./local-run.sh #{File.basename(@executable)} #{@ranges['name']} #{@ranges['args']}`\n puts \"task run: #{dir}\"\n else\n `cd #{dir}; ./pbs-run.sh #{File.basename(@executable)} #{@ranges['name']} #{@ranges['args']}`\n puts \"task queued: #{dir}\"\n end\n end\n end\n end",
"def queue_front(request)\n request.hydra = self\n queued_requests.unshift request\n end",
"def execute!\n @actions.each do |action|\n action.call\n end\n end",
"def perform(resource_id, owner_code, repo_id)\n \n @owner_code = owner_code\n @repo_id = repo_id\n \n resourcetree = URIResolver.resolve_references(Resource.to_jsonmodel(resource_id.to_i), ['tree'])\n \n thread_array = []\n \n archival_object_searched = 0\n digital_objects_created = 0\n \n work_q = Queue.new \n\n prepare_tree_nodes(resourcetree['tree'][\"_resolved\"]) do |child|\n Log.info(child.inspect)\n if child['node_type'] == 'archival_object'\n Log.info('ARCHIVAL OBJECT FOUND: '+child['title'])\n archival_id = child['id']\n #If a digital object does not already exist for the archival object, create one\n if !child['instance_types'].include?('digital_object')\n Log.info(\"Adding \" + archival_id.to_s + \" to queue\")\n work_q << archival_id\n archival_object_searched = archival_object_searched + 1\n end\n \n end\n end\n \n responses = []\n osn_errors = []\n no_osn = []\n mutex = Mutex.new\n @countMutex = Mutex.new\n \n @count = 1\n workers = (0...4).map do\n thread = Thread.new do\n begin\n while archival_id = work_q.pop(true)\n Log.info(\"Poppped \" + archival_id.to_s + \" from queue\")\n RequestContext.open(:repo_id => repo_id) do \n archival_object = ArchivalObject.to_jsonmodel(archival_id.to_i)\n \n Log.info('ARCHIVAL OBJECT RETRIEVED: '+archival_object.to_json)\n #create digital object\n \n if (@count % 15 == 0)\n Log.info(\"SLEEPING 30 SECS TO ALLOW TIME_WAITS TO CLEAR>>>>>\")\n sleep(30)\n end\n t = create_digital_object(archival_object)\n mutex.synchronize do\n if (t.has_key?('error'))\n Log.error(t['error'])\n osn_errors << t['osn']\n elsif (t.has_key?('urn_created'))\n Log.info('URN created for' + t['osn'])\n digital_objects_created = digital_objects_created + 1\n elsif (t.has_key?('no_urn'))\n Log.info('No URN found for' + t['osn'])\n no_osn << t['osn']\n end\n end\n end\n end\n rescue ThreadError\n end\n end\n thread_array << thread\n thread.join\n \n end\n \n response = {:resource_id => resource_id, :osn_errors=>osn_errors, :no_osns=>no_osn, :archival_objects_searched => archival_object_searched, :digital_objects_created => digital_objects_created}\n end",
"def command_queue; end",
"def queued_tasks(options, analysis_type)\n # Initialize variables for queue dependent actions\n submit_time = Time.now #change to submit time for analysis\n rdata_flag = options[:rdata]\n csv_flag = options[:csv]\n zip_flag = options[:zip]\n download_flag = false\n stop_flag = options[:stop]\n kill_flag = options[:kill]\n warnings = []\n start_wait = options[:start_wait]\n analysis_wait = options[:analysis_wait]\n analysis_type = 'batch_run' if OpenStudio::Analysis::ServerApi::BATCH_RUN_METHODS.include? analysis_type\n\n # Verify download directories and set flags to true should they exist\n if rdata_flag || csv_flag || zip_flag\n if !File.exist? options[:download_directory]\n puts \"INFO: MKDIR -- Making new directory for download results at #{options[:download_directory]}\"\n Dir.mkdir options[:download_directory]\n download_flag = true\n else\n download_flag = true\n end\n end\n\n # Hash commands for run_queued_tasks and warning messages\n flags = {download: download_flag, rdata: rdata_flag, csv: csv_flag, zip: zip_flag, stop: stop_flag, kill: kill_flag}\n completed = {rdata: nil, csv: nil, zip: nil, stop: nil, kill: nil}\n\n # Execute queued tasks should they exist with a Timeout\n puts 'INFO: ANALYSIS STATUS -- Waiting for analysis to start.'\n while Time.now - submit_time < start_wait\n server_status = @server_api.get_analysis_status(@analysis_id, analysis_type)\n if server_status == 'started'\n puts 'INFO: ANALYSIS STATUS -- Analysis has started. Waiting for analysis to complete.'\n returned = run_queued_tasks(analysis_type, options[:download_directory], flags, analysis_wait)\n returned ||= {}\n completed.merge! returned\n break\n elsif server_status == 'failed'\n puts 'WARN: ANALYSIS STATUS -- The analysis status has transitioned to failed. Attempting to execute queued tasks.'\n returned = run_queued_tasks(analysis_type, options[:download_directory], flags, analysis_wait)\n completed.merge! returned\n break\n else\n sleep 1\n end\n end\n\n # Warn if flags were set to true but code not executed.\n if flags[:rdata]\n warnings << 'WARN: TIMEOUT -- RData results were not downloaded due to timeout' unless completed[:rdata]\n end\n\n if flags[:csv]\n warnings << 'WARN: TIMEOUT -- CSV results were not downloaded due to timeout' unless completed[:csv]\n end\n\n if flags[:zip]\n warnings << 'WARN: TIMEOUT -- Zipped files were not downloaded due to timeout' unless completed[:zip]\n end\n\n if flags[:stop]\n warnings << 'WARN: TIMEOUT -- Instance was not stopped due to timeout' unless completed[:stop]\n end\n\n if flags[:kill]\n warnings << 'WARN: TIMEOUT -- Instance was not killed due to timeout' unless completed[:kill]\n end\n\n warnings.join(\". \") if warnings != []\n\nend",
"def perform!\n run_callbacks(:before_perform, self)\n self.class.upcoming_mailings\n .in_batches(of: self.class.batch_size)\n .each do |batch|\n run_callbacks(:on_perform, self, batch)\n batch.each(&:process!)\n end\n run_callbacks(:after_perform, self)\n nil\n end",
"def perform\n\n begin\n\n # acquire lock and fetch the locked hooks\n fetch_hooks_to_be_processed\n\n # Process these Hooks\n process_hooks\n\n # Mark Hooks as processed\n update_status_to_processed\n\n rescue StandardError => se\n\n @hooks_to_be_processed.each do |hook|\n hook_id = hook.id\n # Skip if we already know that his hook was processed or failed\n next if @success_responses[hook_id].present? ||\n @failed_hook_to_be_ignored[hook_id].present? ||\n @failed_hook_to_be_retried[hook_id].present?\n @failed_hook_to_be_retried[hook_id] = {\n exception: {message: se.message, trace: se.backtrace}\n }\n end\n\n ensure\n\n # For hooks which failed, mark them as failed\n release_lock_and_update_status_for_non_processed_hooks\n\n # Notify Devs in case on Errors\n notify_devs\n\n success_with_data(processor_response)\n\n end\n\n end",
"def setup\n logger.info 'setup workers'\n\n setup_refresh_timer\n setup_analyze_timer\n end",
"def submit\r\n @sess.DoRequests(@request_set)\r\n end",
"def run\n @run_mutex.synchronize do\n fail 'cannot run without registering services' if rpc_descs.size.zero?\n @server.start\n transition_running_state(:running)\n @run_cond.broadcast\n end\n loop_handle_server_calls\n end",
"def run_bulk; end",
"def do( args )\n\t\tqueue_files_for_processing( args )\n\t\tretrack\n\tend",
"def run_batch\n make_run_batch_call\n end",
"def run_all\n run_on_changes\n end",
"def management_loop\n kill_all_proxies\n loop do\n sync_reader_proxies\n Kernel.sleep 1\n end\n end",
"def x_start\n run_callbacks :execute do\n # binding.pry\n context.resource_runtimes.each do |runtime|\n runtime.execute(:start)\n # binding.pry\n # runtime.start do |queue|\n # binding.pry\n # queue.run\n # queue.map(&:to_a).flatten.each do |msg|\n # Cnfs.logger.warn(msg)\n # end\n # end\n end\n end\n end",
"def run\n Kernel.trap(\"CLD\") do \n pid = Process.wait\n remove_runner(pid)\n end\n \n until @finish\n deliveries = check_queue\n deliveries.each do |del|\n if slot_open?(del) && lock_delivery(del)\n puts \"Delivering #{del[\"class\"]}\\##{del[\"method\"]} at #{Time.now}\" unless quiet\n # Close our connection so that we don't get too many weird copies\n Candygram.connection = nil\n child = fork do\n # We're the runner\n set_status(del, 'running')\n package = Wrapper.unwrap(del[\"package\"])\n args = Wrapper.unwrap(del[\"arguments\"])\n result = package.send(del[\"method\"].to_sym, *args)\n finish_delivery(del, result)\n Candygram.connection = nil\n exit\n end\n # We're the parent\n add_runner del[\"class\"], child\n sleep(0.2) # Give connections time to wrap up\n end\n end\n sleep frequency\n end\n until @index.empty?\n sleep(0.1) # We trust our trap\n end\n end",
"def get_queued_links()\n\t\thydra.queued_requests.map do |req|\n\t\t\treq.url\n\t\tend\n\tend",
"def execute!\n validate_request!\n perform_request!\n\n build_response\n end",
"def trigger_pending!\n BackgroundWorkerRepository.pending.each do |background_worker|\n log_event(background_worker)\n enqueue(background_worker)\n end\n end",
"def run\n schedule_data_reports\n end",
"def run\n loop do\n if @workQ.size < (@pool_size-1)\n Thread.start(@directoryServer.accept) do | proxy |\n @workQ.push 1\n proxy_handler(proxy)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n proxy.close\n end\n end\n end",
"def tick #:nodoc: all\r\n # Handle the tick\r\n # Do we have any retries due to be sent yet?\r\n @mutex.synchronize{\r\n time_now = Time.now\r\n @timeouts.keys.each do |client_query_id|\r\n msg, client_queue, select_queue, outstanding = @query_list[client_query_id]\r\n query_timeout, timeouts = @timeouts[client_query_id]\r\n if (query_timeout < Time.now)\r\n #Time the query out\r\n send_result_and_close(client_queue, client_query_id, select_queue, nil, ResolvTimeout.new(\"Query timed out\"))\r\n next\r\n end\r\n timeouts_done = []\r\n timeouts.keys.sort.each do |timeout|\r\n if (timeout < time_now)\r\n # Send the next query\r\n res, retry_count = timeouts[timeout]\r\n id = [res, msg, client_query_id, retry_count]\r\n TheLog.debug(\"Sending msg to #{res.server}\")\r\n # We should keep a list of the queries which are outstanding\r\n outstanding.push(id)\r\n timeouts_done.push(timeout)\r\n timeouts.delete(timeout)\r\n res.send_async(msg, select_queue, id)\r\n else\r\n break\r\n end\r\n end\r\n timeouts_done.each do |t|\r\n timeouts.delete(t)\r\n end\r\n end\r\n }\r\n end",
"def perform(urls, opts = {})\n @options = HashWithIndifferentAccess.new(DEFAULT_OPTIONS)\n @options.merge!(opts)\n\n return if @options[:depth] == @options[:depth_limit]\n\n before_queue(urls)\n urls.each { |site| self.queue(site) }\n run_queue\n after_queue(urls)\n end",
"def execute\n ActiveRecord::Base.transaction do\n protocol_subscription.responses.not_completed.after_date(future).destroy_all\n schedule_responses\n end\n end",
"def run\n executor.run\n @files\n end",
"def run\n @hydra.run\n end",
"def process\n process_setting_specs\n process_shard_specs\n process_connection_specs\n end",
"def run\n done = []\n\n queues.each_with_object([]) {|(fqdn, queue), workers|\n @thread_limit.times.map.with_index {|i|\n workers << Thread.start {\n Thread.current[:id] = i+1\n done.push *worker_class(fqdn).new(fqdn, queue(fqdn), cache(fqdn), &@block).run(@thread_limit)\n }\n }\n }.each {|t| t.join }\n\n done\n end",
"def start\r\n begin\r\n logger.info{ \"about to start dispatchers with config\\n#{@config.to_yaml}\" }\r\n @config.each{ |conf|\r\n conf[\"threads\"].to_i.times { |index|\r\n Thread.fork(@group, conf, index){|group, conf, index|\r\n dispatching_loop(group, conf, index)\r\n }\r\n }\r\n @dispatch_targets.concat(conf[\"targets\"]).concat(';')\r\n logger.debug{ \"dispatch targets are : #{@dispatch_targets}\" }\r\n }\r\n logger.info \"queue manager has forked dispatchers\"\r\n rescue Exception => err\r\n logger.warn{\"Error in starting dipatchers #{err}\"}\r\n logger.warn{err.backtrace.join(\"\\n\")}\r\n raise err\r\n end\r\n end",
"def flush_deletes\n @queued_for_delete.each do |path|\n client.delete_object(path) if client.object_exists?(path)\n end\n @queue_for_delete = []\n end",
"def run\n schedule_managers\n end",
"def run\n strategy_delay = @dax.collect { |_k, v| v.min_delay }.min\n\n EM.synchrony do\n @dax.each do |name, exchange|\n Arke::Log.debug \"Starting Exchange: #{name}\"\n\n exchange.timer = EM::Synchrony::add_periodic_timer(exchange.min_delay) do\n exchange.queue.pop do |action|\n Arke::Log.debug \"Scheduling Action #{Time.now} - Exchange #{name} Delay #{exchange.min_delay} - Queue size: #{exchange.queue.size}\"\n Arke::Log.debug \"pop: #{action}\"\n schedule(action)\n end\n end\n\n exchange.start\n end\n\n # order stacking is a very big issue here, I multiply by 2 because I yield 2 orders\n # one for buy and one for sell\n @timer = EM::Synchrony::add_periodic_timer(strategy_delay) do\n execute_strategy if queues_empty?\n end\n end\n end",
"def start_jobs\n\n #ActionCable.server.broadcast 'messages',\n #message: 99\n #head :ok\n\n #STDERR.puts \"starting twitter scraper...\"\n Keyword.all.each do |keyword|\n self.queries.create(keyword: keyword.term, status: \"working\")\n end\n\n Resque.enqueue(Harvest::ResultsWorker, self.id)\n\n #byebug\n\n #Harvest::ResultsWorker.perform(self.id)\n\n end",
"def setup\n t = Thread.new { build_directories_records }\n @adapter = initialize_adapter\n t.join\n end",
"def run\n until Thread.current[:should_exit]\n return if @queue.empty?\n\n @lock.synchronize do\n consume_message_from_queue! until @batch.full? || @queue.empty?\n end\n\n res = @transport.send @write_key, @batch\n @on_error.call(res.status, res.error) unless res.status == 200\n\n @lock.synchronize { @batch.clear }\n end\n ensure\n @transport.shutdown\n end",
"def run\n sleep INTERVAL\n loop do\n start = Time.now\n @db.purge\n first_id = @db_id_seen+1\n @db_id_seen, records = @db.nodes_down(first_id)\n sleep INFLIGHT_WAIT\n records = records.all\n @graphite.add @db.id_range(first_id, @db_id_seen).all if @graphite\n @buffer.push records.map { |record| record.peer }\n @buffer.exceed_median? ? @alarm.set(@buffer) : @alarm.clear(@buffer)\n delay = INTERVAL-(Time.now-start)\n # in case delay happens to be too big\n if delay > INTERVAL\n delay = INTERVAL\n Log.warn \"delay became larger than #{INTERVAL}, capping it. (did ntp just sync?)\"\n end\n if delay > 0\n sleep delay\n else\n Log.error \"Analyzer loop took longer than #{INTERVAL}, wanted to sleep for #{delay}s\"\n end\n end\n end",
"def bulk(records)\n records_array = Array(records)\n\n bulk_delay(records_array)\n\n yield\n\n bulk_queue(records_array)\n end",
"def test_backend_remains_in_rotation_after_timeouts\n timeout_hydra = Typhoeus::Hydra.new\n timeout_requests = Array.new(50) do\n delay = $config[\"nginx\"][\"proxy_connect_timeout\"] + 5\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/delay-sec/#{delay}\", http_options)\n timeout_hydra.queue(request)\n request\n end\n timeout_hydra.run\n\n info_hydra = Typhoeus::Hydra.new\n info_requests = Array.new(50) do\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/info/\", http_options)\n info_hydra.queue(request)\n request\n end\n info_hydra.run\n\n assert_equal(50, timeout_requests.length)\n timeout_requests.each do |request|\n assert_response_code(504, request.response)\n end\n\n assert_equal(50, info_requests.length)\n info_requests.each do |request|\n assert_response_code(200, request.response)\n end\n end",
"def start_accepting_requests\n\t\tself.log.info \"Starting the request loop.\"\n\t\tself.reactor.start_polling( ignore_interrupts: true )\n\tend"
] | [
"0.685856",
"0.64856154",
"0.6398706",
"0.6398706",
"0.62887263",
"0.6245718",
"0.61392516",
"0.6111346",
"0.6085774",
"0.60237247",
"0.60234606",
"0.597978",
"0.5971494",
"0.59333783",
"0.59333783",
"0.591823",
"0.59097254",
"0.5868165",
"0.5866978",
"0.58467364",
"0.5844778",
"0.5825051",
"0.58201426",
"0.57876456",
"0.5785907",
"0.57532597",
"0.57330924",
"0.5717656",
"0.5716567",
"0.5704411",
"0.570123",
"0.5700746",
"0.5693463",
"0.5678954",
"0.56756234",
"0.5671215",
"0.56655616",
"0.56647575",
"0.5655864",
"0.5655864",
"0.56490695",
"0.5626811",
"0.5606567",
"0.5603352",
"0.5602387",
"0.5602027",
"0.5595701",
"0.55735666",
"0.5569441",
"0.5548714",
"0.55469316",
"0.5541273",
"0.55402607",
"0.5533595",
"0.55237514",
"0.5523299",
"0.5516635",
"0.5513784",
"0.5510404",
"0.55025744",
"0.5502543",
"0.54951787",
"0.5487671",
"0.54845595",
"0.54804665",
"0.54777724",
"0.5474355",
"0.5467208",
"0.54593307",
"0.5449082",
"0.5440398",
"0.54384065",
"0.54345167",
"0.54332405",
"0.54214823",
"0.54200643",
"0.54174966",
"0.54162806",
"0.54154634",
"0.5414206",
"0.54133385",
"0.5411975",
"0.54079014",
"0.54077864",
"0.53982544",
"0.5396884",
"0.5395768",
"0.538062",
"0.537961",
"0.53767526",
"0.53711426",
"0.53690517",
"0.53549176",
"0.53528184",
"0.5352164",
"0.5346574",
"0.53446144",
"0.5340346",
"0.5335947",
"0.5332032"
] | 0.54150283 | 79 |
Change the useragent sent to the Prowl server. | def user_agent(user_agent)
@user_agent = user_agent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent= user_agent\n @agent.user_agent = user_agent\n end",
"def user_agent=(user_agent); end",
"def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end",
"def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end",
"def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end",
"def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end",
"def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end",
"def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end",
"def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end",
"def user_agent(agent)\n headers.update 'User-Agent' => agent\n end",
"def useragent=(value)\n Curl.set_option(:useragent, value_for(value, :string), handle)\n end",
"def user_agent=(name)\n @user_agent = USER_AGENT[name] || USER_AGENT['bot']\n end",
"def user_agent=(user_agent)\n @attributes[\"user_agent\"] = user_agent\n end",
"def set_user_agent_override(user_agent:, accept_language: nil, platform: nil)\n {\n method: \"Emulation.setUserAgentOverride\",\n params: { userAgent: user_agent, acceptLanguage: accept_language, platform: platform }.compact\n }\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n end",
"def user_agent\n @user_agent || USER_AGENT\n end",
"def user_agent\n @user_agent || USER_AGENT\n end",
"def user_agent; end",
"def user_agent; end",
"def user_agent; end",
"def user_agent\n headers[\"HTTP_USER_AGENT\"] || headers[\"USER-AGENT\"]\n end",
"def user_agent=(user_agent)\n @request_headers['User-Agent'] = user_agent\n @request = Net::HTTP::Get.new(@uri.request_uri, @request_headers)\n end",
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n @request['User-Agent']\n end",
"def user_agent_alias=(name); end",
"def initialize user_agent\n @user_agent = user_agent.strip\n end",
"def initialize user_agent\n @user_agent = user_agent.strip\n end",
"def initialize user_agent\n @user_agent = user_agent.strip\n end",
"def initialize user_agent\n @user_agent = user_agent.strip\n end",
"def initialize user_agent\n @user_agent = user_agent.strip\n end",
"def user_agent(value)\n value || DEFAULT_USER_AGENT\n end",
"def user_agent_on_header\n request.headers['HTTP_USER_AGENT']\n end",
"def user_agent\n @agent.user_agent\n end",
"def get_user_agent\n user_agent\n end",
"def user_agent\n @data[\"user_agent\"]\n end",
"def init_user_agent(options)\n @headers ||= {}\n @headers['User-Agent'] = options[:user_agent] || default_user_agent\n end",
"def user_agent\n \"SocketLabs-ruby/#{VERSION};ruby(#{RUBY_VERSION})\"\n end",
"def user_agent_alias= name\n self.user_agent = AGENT_ALIASES[name] ||\n raise(ArgumentError, \"unknown agent alias #{name.inspect}\")\n end",
"def user_agent (value = nil)\n\t\tif value\n\t\t\traise_if_error C.glyr_opt_useragent(to_native, value)\n\t\telse\n\t\t\tto_native[:useragent]\n\t\tend\n\tend",
"def use_agent=(use_agent); end",
"def default_user_agent\n \"#{NAME}/#{VERSION} (Ruby/#{RUBY_VERSION})\"\n end",
"def http_user_agent\n # User agent is required for cookie validation\n request.env['HTTP_USER_AGENT'].to_s\n end",
"def ua\n @ua ||= begin\n request.env['HTTP_USER_AGENT'].downcase\n rescue\n ''\n end\n end",
"def user_agent\n self.class.user_agent ||= USER_AGENTS.shuffle.first\n end",
"def user_agent\n \"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3\"\n end",
"def setUseMobileUserAgent(value)\n @fields['use_mobile_user_agent'] = value\n self\n end",
"def setUseMobileUserAgent(value)\n @fields['use_mobile_user_agent'] = value\n self\n end",
"def headers=(headers)\n @headers = headers.merge({\"User-Agent\" => user_agent})\n end",
"def user_agent\n @request[FUA]\n end",
"def user_agent(vendor: T.unsafe(nil)); end",
"def default_header\n {\n \"User-Agent\" => user_agent\n }\n end",
"def append_user_agent_to_params\n params[:browser_user_agent] = http_user_agent\n end",
"def user_agent\n @options[:user_agent] || \"Ruby Twitter Gem\"\n end",
"def set_client(user_agent_string)\n user_agent = AgentOrange::UserAgent.new(user_agent_string)\n device = user_agent.device\n if device.is_mobile?\n self.client = device.platform\n self.version = device.platform.version\n else device.is_computer?\n self.client = device.engine.browser.name\n self.version = device.engine.browser.version\n end\n end",
"def user_agent\n kernel = Facter[:kernel] ? Facter[:kernel].value : 'unknown'\n kvers = Facter[:kernelversion] ? Facter[:kernelversion].value : 'unknown'\n values = {\n 'razor' => MK::VERSION,\n 'facter' => Facter.version, # sigh\n 'ruby' => RUBY_VERSION,\n 'kernel' => \"#{kernel}-#{kvers}\"\n }.reject{|k,v| v.nil?}.map{|k,v| k+'/'+v}.join(' ')\n end",
"def getUserAgent()\n\t\t\tUSER_AGENT\n\t\tend",
"def user_agent\n ENV[\"CHEF_API_USER_AGENT\"] || config[\"CHEF_API_USER_AGENT\"] || USER_AGENT\n end",
"def some_user_agent\n \"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090920 Firefox/3.5.3 (Swiftfox)\"\n end",
"def user_agent(string)\n string = string.to_s\n return nil if string.empty?\n UserAgent.new(string)\n end",
"def convert_user_agent(value, _definition)\n value == '-' ? nil : value\n end",
"def engine\n Agent.engine_for_user_agent string\n end",
"def convert_user_agent(value, definition)\n value # TODO\n end",
"def convert_user_agent(value, definition)\n value == '-' ? nil : value\n end",
"def bot_user_agent(vendor: T.unsafe(nil)); end",
"def initialize\n super\n @user_agent_alias = 'Mac Safari'\n @follow_meta_refresh = true\n @redirect_ok = true\n end",
"def user_agent_string\n user_agent_tokens.reverse.join(' ')\n end",
"def agent\n @agent ||= Sawyer::Agent.new('', sawyer_options) do |http|\n http.headers[:user_agent] = user_agent\n end\n end",
"def user_agent\n \"pokitdok-ruby 0.8 #{RUBY_DESCRIPTION}\"\n end",
"def set_defaults\n default_user_agent = Config.user_agent || Typhoeus::USER_AGENT\n\n options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})\n options[:headers]['Expect'] ||= ''\n options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?\n options[:maxredirs] ||= 50\n options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?\n end",
"def user_agent\n \"PriceHubbleGem/#{PriceHubble::VERSION}\"\n end",
"def sanitize_user_agent(string)\n user_agent = user_agent(string)\n return nil unless user_agent\n user_agent.to_s\n end",
"def user_agent\n if defined?(::RUBY_VERSION) && defined?(::RUBY_PLATFORM)\n ruby_description = \"(ruby #{::RUBY_VERSION} #{::RUBY_PLATFORM}) \" # NOTE: the trailing space!\n end\n zlib_version = \"zlib/#{Zlib.zlib_version}\" if defined?(::Zlib) && Zlib.respond_to?(:zlib_version)\n \"NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}\"\n end",
"def user_agent\n ruby_description = ''\n # note the trailing space!\n ruby_description << \"(ruby #{::RUBY_VERSION} #{::RUBY_PLATFORM}) \" if defined?(::RUBY_VERSION) && defined?(::RUBY_PLATFORM)\n zlib_version = ''\n zlib_version << \"zlib/#{Zlib.zlib_version}\" if defined?(::Zlib) && Zlib.respond_to?(:zlib_version)\n \"NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}\"\n end",
"def initialize(user_agent)\n self.class.headers 'User-Agent' =>\n \"#{user_agent} CWSrb/#{Cwsrb::VERSION} (#{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL})\"\n end",
"def set_variant\n # request.variant = :phone if request.user_agent.include?('iPhone')\n # o con la gema browser\n request.variant = :phone if browser.device.mobile?\n end",
"def agent_alias value\n\t\tself.out \"agent_alias #{value}\"\n\t\t@agent.user_agent_alias = value#'Mac Safari' \n\tend",
"def set_variant\n if request.user_agent =~\n /mobile|android|touch|webos|hpwos|iphone|iPhone|iPad|ipod|\n android|blackberry|opera|mini|windows\\sce|palm|smartphone|iemobile|\n ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/\n\n request.variant = :mobile\n else\n request.variant = :desktop\n end\n end",
"def harvest_user_agent\n return \"TimeTrackingConsolidator (patel.aneeesh@gmail.com)\"\n end",
"def set_user(user)\n agent&.set_user(user)\n end",
"def name\n Agent.name_for_user_agent string\n end",
"def headers\n super\n @headers['User-Agent'] = \"Recurly Ruby Client v#{VERSION}\"\n @headers\n end",
"def set_request_variant\n request.variant = :mobile if request.user_agent =~ /android|Android|blackberry|iphone|ipod|iemobile|mobile|webos/\n request.variant = :android_app if request.user_agent =~ /AndroidApp/\n puts \"--------------\"+request.variant.to_s+\"--------------\"\n end",
"def robots= enabled\n @agent.robots = enabled\n end",
"def set_device\n # if HTTP_USER_AGENT is blank/nil defaults to blank, i.e. desktop \n agent = request.env[\"HTTP_USER_AGENT\"].blank? ? \"\" : request.env[\"HTTP_USER_AGENT\"].downcase \n if agent =~ tablet_agents\n \"tablet\"\n elsif (agent =~ mobile_agents_one) || (agent[0..3] =~ mobile_agents_two)\n \"mobile\"\n else\n \"desktop\"\n end \n end",
"def generate_user_agent(extra_ids = [])\n agent_app = @config.read('authentication.user_agent')\n extra_ids << ['AwApi-Ruby/%s' % BingAdsApi::ApiConfig::CLIENT_LIB_VERSION]\n super(extra_ids, agent_app)\n end",
"def generate_user_agent(extra_ids = [])\n agent_app = @config.read('authentication.user_agent')\n extra_ids << ['AwApi-Ruby/%s' % YahooAdApi::ApiConfig::CLIENT_LIB_VERSION]\n super(extra_ids, agent_app)\n end",
"def agent\n @agent ||= Mechanize.new do |agent|\n agent.user_agent_alias = 'Mac Safari'\n end\n end",
"def get_agent\n\t\tagent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n\tend",
"def user_agent\n 'eventful-ruby/%s (Rubygems; Ruby %s %s)' % [Eventful::VERSION, RUBY_VERSION, RUBY_PLATFORM]\n end",
"def update!(**args)\n @user_agent = args[:user_agent] if args.key?(:user_agent)\n @user_id = args[:user_id] if args.key?(:user_id)\n end",
"def headers\n { 'User-Agent' => user_agent }\n end",
"def initialize(user_agent_string)\n @user_agent = user_agent_string\n end"
] | [
"0.7866124",
"0.7823937",
"0.7755849",
"0.7755849",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7634683",
"0.7440789",
"0.7358134",
"0.7259788",
"0.7063613",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.6929085",
"0.6929085",
"0.6915655",
"0.6915655",
"0.6915655",
"0.68533915",
"0.6812335",
"0.67553186",
"0.67553186",
"0.67553186",
"0.67456454",
"0.6701908",
"0.6684665",
"0.6684665",
"0.6684665",
"0.6684665",
"0.6684665",
"0.6599518",
"0.6547911",
"0.653696",
"0.64851075",
"0.64835244",
"0.6470708",
"0.64570224",
"0.6454858",
"0.6427492",
"0.63388264",
"0.633292",
"0.6306818",
"0.6284061",
"0.6279893",
"0.6191755",
"0.61536705",
"0.61536705",
"0.6146804",
"0.6132916",
"0.61239624",
"0.61132693",
"0.6064453",
"0.60581285",
"0.6018182",
"0.60164785",
"0.6008374",
"0.5962297",
"0.594454",
"0.5942432",
"0.59256446",
"0.59248716",
"0.59183645",
"0.5887373",
"0.5863383",
"0.5834219",
"0.5832097",
"0.58261037",
"0.58059627",
"0.58050877",
"0.57484996",
"0.5739738",
"0.57333577",
"0.56892633",
"0.56834906",
"0.5680888",
"0.5680599",
"0.5676949",
"0.56729984",
"0.56713486",
"0.5667591",
"0.562303",
"0.5613464",
"0.56132644",
"0.55929023",
"0.55651873",
"0.55511785",
"0.55360204",
"0.5532356",
"0.5522241",
"0.54670304",
"0.5465045",
"0.54585856"
] | 0.74204785 | 11 |
Queue a verify API call in the Hydra. | def valid?
@hydra.queue(request('verify'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify()\n # TODO\n end",
"def verify\n create_order\n start_challenge\n wait_verify_status\n check_verify_status\n rescue Acme::Client::Error => e\n retry_on_verify_error(e)\n end",
"def verify_response\n\n self.exec\n end",
"def verify_callback; end",
"def verify_callback; end",
"def verify\n end",
"def verify\n\n end",
"def verify\n # nothing to do here, so just return\n end",
"def verify\n end",
"def verify_callback\n @agent.verify_callback\n end",
"def verify\n @bathroom.verify\n end",
"def verify\n transition_to(:verify)\n end",
"def verify\n transition_to(:verify)\n end",
"def verify\n head :ok\n end",
"def flexmock_verify\n @mock.flexmock_verify\n end",
"def flexmock_verify\n @mock.flexmock_verify\n end",
"def verify_signatures?; end",
"def test_verify\n # Start out unavailabl\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def available?(req)\n true\n end\n end\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def authorized?(req)\n true\n end\n end\n assert_nothing_raised do\n @obj.verify(@request)\n end\n end",
"def verify(api_key = nil)\n raise ConfigurationError, \"You must provide an API key to verify\" if api_key.nil? && self.api_key.nil?\n perform(:verify, { :providerkey => provider_key, :apikey => api_key || self.api_key }, :get, Success)\n end",
"def verify\r\n self.verified = true\r\n end",
"def verify_sub; end",
"def verify_sub; end",
"def check\n @response = nil\n verified?\n end",
"def enqueue_verify_reg_status_job\n\n BgJob.enqueue(\n ::RegisterBrandedToken::GetProposeStatusJob,\n {critical_log_id: @critical_chain_interaction_log_id},\n {wait: 30.seconds}\n )\n\n success\n\n end",
"def verified_request?; end",
"def verify\n response = @client.call :payment_verification, message: {\n 'MerchantID' => Zarinpal.configuration.merchant_id,\n 'Authority' => @authority,\n 'Amount' => @amount,\n }\n\n @response.validate(response.body)\n end",
"def verify(*args, **options)\n verified(*args, **options) || raise(InvalidSignature)\n end",
"def verify_callback= verify_callback\n @agent.verify_callback = verify_callback\n end",
"def test_checkin\n req = c.checkin(\"abc123\", 123, &blk)\n\n assert_sent(req.tag, :verb => V::CHECKIN, :path => \"abc123\", :cas => 123)\n assert_recv(reply(req.tag, :cas => 123))\n end",
"def verify_process!\n updated_attribute(:verified, true)\n end",
"def verify_callback=(verify_callback); end",
"def verify_callback=(verify_callback); end",
"def verify\n #@blog.verified = 1\n if @blog.verify\n succ\n else\n err\n end\n end",
"def verify_stubbed_calls; end",
"def flexmock_verify\n flexmock_created_mocks.each do |m|\n m.flexmock_verify\n end\n end",
"def add_api_verifier; end",
"def verify(method_name, &block)\n internal_verify method_name, :instance, &block\n end",
"def verify!(executable, *args, &block); end",
"def verifyPostIdeaResponseContract\n return verifyResponseContract(@postIdea_response_structure)\n end",
"def verify\n verify_commands if commands.any?\n end",
"def acknowledge\n verify? params, KEY\n end",
"def acknowledge\n verify? params, KEY\n end",
"def test_check\n body = {}.to_json\n @srv.should_receive(:make_request).once.and_return(flexmock(:body => body))\n @cls.check\n end",
"def check\n tagged_response(\"CHECK\")\n end",
"def verify(obj)\n Proxy.new(obj, :_verify)\n end",
"def mocha_verify(assertion_counter = nil)\n Mockery.verify(assertion_counter)\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def validate(hydra, &on_complete)\n raise 'link has no queue to use' if not @queue\n\n puts \"querying #{uri}\" if @opts[:verbose]\n\n tries = 0\n\n begin\n #\t\t\trequest = Typhoeus::Request.new(uri.to_s, method: (@opts[:duplicate] ? :get : :method), auth_method: :auto, proxy_auth_method: :auto)\n opts = {\n headers: @@HTTP_header.merge(@opts[:duplicate] ? {} : { 'Accept' => 'text/html,application/xhtml+xml,application/xml,text/css,text/javascript' }),\n }\n\n # set up the proxy and proxy auth on the request if necessary\n proxy = self.proxy\n if proxy\n puts \"using proxy #{proxy[2]}:#{proxy[3]}@#{proxy[0]}:#{proxy[1]}\" if @opts[:verbose]\n opts.proxy = \"http://#{proxy[0]}:#{proxy[1]}\"\n if not proxy[2].empty?\n opts.proxy_username, opts.proxy_password = proxy[2], proxy[3]\n elsif @@userpass_list[:proxy]\n opts.proxy_username, opts.proxy_password = @@userpass_list[:proxy]\n end\n end\n\n # set up the auth on the request if necessary\n if uri.userinfo\n opts.username = uri.user\n opts.password = uri.password\n elsif @@userpass_list[uri.host]\n opts.username, opts.password = @@userpass_list[uri.host]\n end\n\n request = Typhoeus::Request.new(uri.to_s, opts)\n\n request.on_complete {|response|\n puts 'processing response from ' + uri.to_s if @opts[:verbose]\n\n if response.code == 401 or response.code == 407\n # the request requires authentication so ask the user for username and password\n # XXX there's a race here between setting userpass_list, queuing the request, and then an intervening request checking the unconfirmed userpass at the code above\n host = (response.code == 401 ? uri.host : :proxy)\n puts 'asking for ' + uri.to_s\n userpass = LinkToLoad.ask_for_userpass((host == :proxy ? 'proxy for ' : '') + uri.to_s)\n if userpass.empty?\n @@userpass_list[host] = false\n process_response(response)\n else\n @@userpass_list[host] = userpass\n if host == :proxy\n $stderr.puts \"setting proxy auth: #{userpass}\"\n request.proxy_username, request.proxy_password = userpass\n else\n request.username, request.password = userpass\n end\n hydra.queue(request)\n end\n else\n process_response(response)\n end\n\n on_complete\n }\n\n hydra.queue(request)\n rescue OpenURI::HTTPError\n @queue.invalidate(InvalidURI::General_error, msg: \"#{$!.class} - #{$!}\")\n rescue Timeout\n tries += 1\n retry unless tries > 2\n @queue.invalidate(InvalidURI::Timeout)\n end\n end",
"def verify!\n return true if verified?\n http = Net::HTTP.new('rest.akismet.com', 80)\n resp, data = http.post('/1.1/verify-key', \"key=#{@key}&blog=#{@blog}\", @headers)\n @verified = (data == \"valid\")\n end",
"def register_verify_callback(connection)\n connection.verify_callback = self\n end",
"def verify_email\n service_response = UserManagement::DoubleOptIn.new(params).perform\n render_api_response(service_response)\n end",
"def incoming_verification\n # API Check\n raise 'You shall not pass!' unless params[:api_key] == Settings.twilio.webhooks_api_key\n\n # Handle verification\n user = get_user_for_phone_verification\n user.mark_phone_as_verified! if user\n\n render nothing: true\n end",
"def test_purchase_and_void_for_check\n assert purchase = @gateway.purchase(1000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.void(purchase.authorization, @options)\n assert_success void\n assert_approved void\n end",
"def verify_recaptcha\n service_response = Recaptcha::Verify.new({\n 'response' => params['g-recaptcha-response'].to_s,\n 'remoteip' => request.remote_ip.to_s\n }).perform\n\n Rails.logger.info('---- Recaptcha::Verify done')\n\n unless service_response.success?\n render_api_response(service_response)\n end\n\n Rails.logger.info('---- check_recaptcha_before_verification done')\n\n end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def verify\n\t\t#puts \"INSIDE DEF: vERIFY IN ORDER CONCERN.\"\n\t\tself.reports.each do |report|\n\t\t\treport.a_test_was_verified = false\n\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t#puts \"checking report: #{report.name}\"\n\t\t\t#puts \"report verify all is: #{report.verify_all},,, #{Diagnostics::Report::VERIFY_ALL}\"\n\t\t\t\tif report.verify_all == Diagnostics::Report::VERIFY_ALL\n\t\t\t\t\t#puts \"reprot verify all is true\"\n\t\t\t\t\tif report.impression.blank?\n\t\t\t\t\t\t#puts \"impression is balnk\"\n\t\t\t\t\t\treport.tests.each do |test|\n\t\t\t\t\t\t\t#puts \"Calling verify if normal on test: #{test.name}\"\n\t\t\t\t\t\t\tunless test.verify_if_normal(self.current_user).blank?\n\t\t\t\t\t\t\t\treport.a_test_was_verified = true\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\treport.tests.each do |test|\n\t\t\t\t\t\t\tunless test.verify.blank?\n\t\t\t\t\t\t\t\treport.a_test_was_verified = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def test_acknowledgement\n assert @cybersource_secure_acceptance.acknowledge\n end",
"def verifySignature _args\n \"verifySignature _args;\" \n end",
"def verify(domain)\n fail(ParameterError, 'No domain given to verify on Mailgun', caller) unless domain\n @client.put(\"domains/#{domain}/verify\", nil).to_h!\n end",
"def verify_api_key\n http = Net::HTTP.new(@@detectors[@detector], 80, @proxy_host, @proxy_port)\n resp, data = http.post('/1.1/verify-key', \"key=#{@api_key}&blog=#{@blog}\", STANDARD_HEADERS)\n @verified_key = (data == \"valid\") ? true : :false\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def verify\n\t\tself.verified = true\n\t\tself.save\n\tend",
"def verify_aud=(_arg0); end",
"def verify_aud=(_arg0); end",
"def verify\n UserNotifierMailer.verify\n end",
"def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend",
"def tls_verify=(_arg0); end",
"def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def verify!\n self.update_attribute(:status, VERIFIED)\n end",
"def verify(id)\n Verify.new(request(:get, \"verify/#{id}\"))\n end",
"def verify_signature(result); end",
"def verify(subscriber)\n subscriber.is_a?(Class) && subscriber.respond_to?(:perform_async)\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def verify(&blk)\n yield\n rescue Test::Unit::AssertionFailedError => ex\n @verification_errors << ex\n end",
"def send_verify_email_link\n service_response = UserManagement::SendDoubleOptInLink.new(params).perform\n render_api_response(service_response)\n end",
"def verify_sub=(_arg0); end",
"def verify_sub=(_arg0); end",
"def test_acknowledgement\n assert @yandex_kassa.acknowledge('coolpasswd')\n end",
"def send_verify_device_link\n service_response = ManagerManagement::SendDeviceVerificationLink.new(params).perform\n return render_api_response(service_response)\n end",
"def verify &block\n\t\t\tif @verified\n\t\t\t\tyield true\n\t\t\t\treturn true\n\t\t\tend\n\n\t\t\t@request_queue.get '/description.xml', :info, 4 do |result|\n\t\t\t\tputs \"Description result: #{result.inspect}\" # XXX\n\t\t\t\tif result.is_a?(Hash) && result[:status] == 200\n\t\t\t\t\t@desc = REXML::Document.new result[:content]\n\t\t\t\t\t@desc.write($stdout, 4, true) # XXX\n\t\t\t\t\t@desc.elements.each('friendlyName') do |el|\n\t\t\t\t\t\tputs \"Friendly name: #{@name}\" # XXX\n\t\t\t\t\t\tset_name el.text\n\t\t\t\t\tend\n\t\t\t\t\t@desc.elements.each('serialNumber') do |el|\n\t\t\t\t\t\tputs \"Serial number: #{@serial}\" # XXX\n\t\t\t\t\t\t@serial = el.text.downcase\n\t\t\t\t\tend\n\t\t\t\t\t@desc.elements.each('modelName') do |el|\n\t\t\t\t\t\tputs \"modelName: #{el.text}\" # XXX\n\t\t\t\t\t\tif el.text.include? 'Philips hue'\n\t\t\t\t\t\t\t@verified = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# FIXME: Delete this line when converted to em-http-request; this\n\t\t\t\t\t# works around the empty :content returned by EM::HttpClient\n\t\t\t\t\t#\n\t\t\t\t\t# See commits:\n\t\t\t\t\t# 34110773fc45bfdd56c32972650f9d947d8fac78\n\t\t\t\t\t# 6d8d7a0566e3c51c3ab15eb2358dde3e518594d3\n\t\t\t\t\t@verified = true\n\t\t\t\tend\n\n\t\t\t\tbegin\n\t\t\t\t\tyield @verified\n\t\t\t\trescue => e\n\t\t\t\t\tlog_e e, \"Error notifying block after verification\"\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"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 verify!\n raise \"Payment details not active anymore\" if active == false\n end",
"def call_authorization_issue_api(ticket, subject, authTime)\n return call_api(\"/api/auth/authorization/issue\", {\n \"ticket\" => ticket,\n \"subject\" => subject,\n \"authTime\" => authTime\n })\nend",
"def verify(event_data)\n true\n end",
"def acknowledge\n if params[PayFast.signature_parameter_name] == generate_signature(:notify)\n response = ssl_post(PayFast.validate_service_url, notify_signature_string,\n 'Content-Type' => \"application/x-www-form-urlencoded\",\n 'Content-Length' => \"#{notify_signature_string.size}\"\n )\n raise StandardError.new(\"Faulty PayFast result: #{response}\") unless ['VALID', 'INVALID'].include?(response)\n\n response == \"VALID\"\n end\n end",
"def verify_signature\n return_code, response = send_command(\"verify_signature\", token)\n return_code == \"200\"\n end",
"def verify\n if @count > 0\n flunk \"mocked method %p not called %d time(s)\" %\n [@meth, @count]\n end\n self\n end",
"def verify!\n self.update_attribute(:verified,\"true\")\n end",
"def verify(cert)\n @transport.verify_cb(cert) == true ? 1 : 0\n end",
"def _verify\n unless (@_headers['x-allopass-response-signature'] || []).include?(@_signature)\n raise Allorails::ApiFalseResponseSignatureError\n end\n end",
"def tls_verify; end"
] | [
"0.66038525",
"0.6555798",
"0.6433716",
"0.6430709",
"0.6430709",
"0.6425885",
"0.633897",
"0.62767875",
"0.62711334",
"0.61311936",
"0.6080868",
"0.6052273",
"0.6052273",
"0.60451573",
"0.5975101",
"0.5975101",
"0.5961242",
"0.5959812",
"0.5912138",
"0.5899672",
"0.58973867",
"0.58973867",
"0.5811211",
"0.5743898",
"0.57434833",
"0.5691077",
"0.56791085",
"0.567739",
"0.56554556",
"0.5619957",
"0.5609767",
"0.5609767",
"0.55816424",
"0.55753475",
"0.55613863",
"0.55486023",
"0.55185306",
"0.55066097",
"0.5485533",
"0.5477863",
"0.5468137",
"0.5468137",
"0.5460719",
"0.54575366",
"0.5434913",
"0.54262173",
"0.54258",
"0.54258",
"0.541227",
"0.5397485",
"0.53876615",
"0.5385665",
"0.53718096",
"0.53625715",
"0.5308851",
"0.5308316",
"0.5308316",
"0.5308316",
"0.5307411",
"0.53046876",
"0.5299604",
"0.52972555",
"0.528472",
"0.5282289",
"0.5273411",
"0.5271728",
"0.5271728",
"0.52636933",
"0.52633905",
"0.52544045",
"0.52343",
"0.521469",
"0.52089584",
"0.5204784",
"0.5194596",
"0.51933235",
"0.51933235",
"0.51933235",
"0.51933235",
"0.51933235",
"0.51933235",
"0.51933235",
"0.51933235",
"0.5188432",
"0.518065",
"0.518065",
"0.51637816",
"0.51520044",
"0.5136317",
"0.5135814",
"0.51186657",
"0.5118023",
"0.51167655",
"0.5106981",
"0.50981295",
"0.509718",
"0.50928235",
"0.50757575",
"0.50724375",
"0.5062959"
] | 0.6897904 | 0 |
Setup and return a Typhoeus HTTP request | def request(action, params = {})
# Merge the default params with any custom ones
params = @defaults.merge(params) unless !@defaults
# Exception checks
if !params[:apikey] || (params[:apikey].is_a?(Array) && params[:apikey].size < 1)
raise MissingAPIKey
end
if params[:priority] && !PRIORITY_RANGE.include?(params[:priority])
raise PriorityOutOfRange
end
# Raise an exception if we're trying to use more API keys than allowed for this action
if params[:apikey].is_a?(Array) && ((action == 'verify' && params[:apikey].size > 1) || params[:apikey].size > MAX_API_KEYS)
raise TooManyAPIKeys
end
# If there are multiple API Keys in an array, merge them into a comma-delimited string
if params[:apikey].is_a?(Array)
params[:apikey] = params[:apikey].collect{|v| v + ',' }.to_s.chop
end
# Delete any empty key/value sets
params.delete_if {|key, value| value.nil? }
# Make the request
req = Typhoeus::Request.new(API_URL + action,
:user_agent => @user_agent,
:method => (action == 'add') ? :post : :get,
:params => (action == 'add') ? params : {:apikey => params[:apikey]}
)
# Typhoeus request on_complete method adds the HTTP code to an array
req.on_complete do |response|
@responses << response.code
end
# Return the request
req
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_request\n return Typhoeus::Request.new(\n endpoint_url,\n method: @method,\n params: @params,\n body: @body,\n headers: @headers)\n end",
"def make_request(url)\n res = Typhoeus::Request.new(\n url,\n method: :get,\n headers: {\n \"Accept-Charset\": \"application/x-www-form-urlencoded; charset=UTF-8\",\n \"Accept-Language\" => \"en-US,en;q=0.9,pt;q=0.8\",\n \"X-Riot-Token\" => @api_key.to_s,\n \"User-Agent\": \"https://github.com/drish/rioter\"\n }\n ).run\n parse!(res)\n end",
"def init_request(url)\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: {'User-Agent' => user_agent}, \n followlocation: true\n # proxy: ...,\n # proxyuserpwd: ...\n )\n\n request.on_complete do |response|\n if response.success?\n # do nothing here\n elsif response.timed_out?\n raise Hubberlyzer::ResponseError, \"Time out when requesting: #{url}\"\n elsif response.code != 200\n raise Hubberlyzer::ResponseError, \"Response code #{response.code}, #{response.return_message} when requesting: #{url}\"\n else\n # Received a non-successful http response.\n raise Hubberlyzer::ResponseError, \"HTTP request failed. Response code #{response.code} when requesting: #{url}\"\n end\n end\n\n request\n end",
"def typhoeus_request # rubocop:disable Metrics/MethodLength\n request = Typhoeus::Request.new(\n @url,\n method: @method,\n headers: {\n 'aftership-api-key' => @api_key,\n 'Content-Type' => 'application/json'\n }\n )\n\n request.options[:body] = MultiJson.dump(@body) if @body\n make_verbose(request) if AfterShip.debug\n\n request\n end",
"def make_request\n response = @http.request(@request)\n end",
"def request(url)\n\t\tTyphoeus::Request.new( url, \n\t\t\tfollowlocation: true, \n\t\t\theaders: {\"User-Agent\" => BrowserHeader.random}, \n\t\t\tcookiefile: config[:cookie][:file],\n\t\t\tcookiejar: config[:cookie][:file]\n\t\t)\n\tend",
"def build_request()\n @http = Net::HTTP.new(@uri.host, @uri.port)\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n end",
"def perform_http_request\n request_opts = { followlocation: true, ssl_verifypeer: false, timeout: 30 }\n @response = Typhoeus.get(@webpage_request.url, request_opts)\n @response && process_response_data\n @response\n end",
"def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end",
"def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end",
"def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :proxy => @config.proxy\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end",
"def make_request(http, request)\n response = http.request(request)\n Response.new(response)\n end",
"def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end",
"def make_request(req)\n if @http && @http.address == req.uri.host && !@http.started?\n @http.start\n else\n @http = Net::HTTP.new(req.uri.host, req.uri.port)\n @http.use_ssl = req.ssl?\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if req.ssl?\n @http.set_debug_output($stderr) if req.debug\n @http.start\n end\n @http.request(req.http_request)\n end",
"def build_request(http_method, path, opts = {})\n url = build_request_url(path, opts)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n follow_location = opts[:follow_location] || true\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :followlocation => follow_location\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end",
"def request\n @request ||= Request.new(::Minfraud::HTTPService.configuration)\n end",
"def request\n EventMachine::HttpRequest.new(url)\n end",
"def http_request\n @http_request ||= begin\n request = request_for_verb\n add_post_data(request)\n add_bearer_token(request)\n add_headers(request)\n request\n end\n end",
"def setup_request(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n http\n end",
"def build_request\n uri = @config[:endpoint]\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.start\n request = build_request_stream(uri)\n return http, request\n end",
"def make_generic_request(request)\n request_path = path(request)\n\n Puppet::Network::HTTP::Request.new(\n headers(request),\n params(request),\n http_method(request),\n request_path, # path\n request_path, # routing_path\n client_cert(request),\n body(request)\n )\n end",
"def request_setup request_context\n http_method = case request_context[:method]\n when :get\n Net::HTTP::Get\n when :post\n Net::HTTP::Post\n when :put\n Net::HTTP::Put\n when :delete\n Net::HTTP::Delete\n else\n raise \"Only :get, :post and :delete http method types are allowed.\"\n end\n headers = request_context[:headers] || {}\n setup = http_method.new request_context[:uri].request_uri\n setup.initialize_http_header headers\n setup.basic_auth(request_context[:uri].user, request_context[:uri].password) if request_context[:uri].user && request_context[:uri].password\n setup\n end",
"def make_request(type, headers = nil, body = nil)\n request = \"#{type.to_s.upcase} #{@path} HTTP/1.0\\r\\n\"\n request << add_headers(headers) if headers\n request << \"\\r\\n\"\n request << body if body\n request\n end",
"def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end",
"def request_for_node( node_data )\n\t\t\thttp_version = convert_http_version( node_data['http_version'] || DEFAULT_HTTP_VERSION )\n\n\t\t\toptions = {\n\t\t\t\tmethod: node_data['http_method'] || DEFAULT_HTTP_METHOD,\n\t\t\t\thttp_version: http_version,\n\t\t\t\theaders: self.make_headers_hash( node_data ),\n\t\t\t\tbody: node_data['body'],\n\t\t\t\ttimeout: self.timeout,\n\t\t\t\tconnecttimeout: self.timeout / 2.0,\n\t\t\t}\n\n\t\t\tif ssl_opts = self.make_ssl_options( node_data['uri'], node_data )\n\t\t\t\toptions.merge!( ssl_opts )\n\t\t\tend\n\n\t\t\tself.log.debug \"Node options for %p are: %p\" % [ node_data['uri'], options ]\n\t\t\treturn Typhoeus::Request.new( node_data['uri'], options )\n\t\tend",
"def build_request(uri)\n Net::HTTP::Get.new(uri)\n end",
"def get_request(url)\n\n request = Net::HTTP::Get.new(url)\n request['content-type'] = 'application/x-www-form-urlencoded'\n request['accept'] = '*/*'\n return request\nend",
"def create_new_http_request\n # Create a new HTTP request instance\n request_spec = @data[:request][:instance]\n http_class = \"Net::HTTP::#{request_spec.verb._camelize}\"\n http_request = http_class._constantize::new(request_spec.path)\n # Set the request body\n if request_spec.is_io?\n http_request.body_stream = request_spec.body\n else\n http_request.body = request_spec.body\n end\n # Copy headers\n request_spec.headers.each { |header, value| http_request[header] = value }\n # Save the new request\n request_spec.raw = http_request\n # Set user-agent\n if @data[:options].has_key?(:connection_user_agent)\n http_request['user-agent'] ||= @data[:options][:connection_user_agent]\n end\n http_request\n end",
"def request\n @request ||= HTTPI::Request.new\n @request.url = document\n @request\n end",
"def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend",
"def build_request\n\n uri = URI.parse(@endpoint)\n # add uri\n params = [uri.host, uri.port]\n # add proxy\n params += @proxy.values_at(:host, :port, :user, :pass) unless @proxy.empty?\n\n @http = Net::HTTP.new(*params)\n # add ssl\n if @endpoint.start_with?('https')\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n\n net_http = Kernel.const_get('Net::HTTP::' + @request_method[:method].capitalize)\n @request = add_request_headers(net_http.new(uri.request_uri))\n\n end",
"def send_request(req); end",
"def request\n @request ||= ::Lotus::Action::Request.new(@_env)\n end",
"def initialize(url, options = {})\n @method = options[:method] || :get\n @params = options[:params]\n @body = options[:body]\n @timeout = options[:timeout]\n @connect_timeout = options[:connect_timeout]\n @interface = options[:interface]\n @headers = options[:headers] || {}\n @user_agent = options[:user_agent] || Typhoeus::USER_AGENT\n @cache_timeout = options[:cache_timeout]\n @follow_location = options[:follow_location]\n @max_redirects = options[:max_redirects]\n @proxy = options[:proxy]\n @proxy_type = options[:proxy_type]\n @ipresolve = options[:ipresolve]\n @proxy_username = options[:proxy_username]\n @proxy_password = options[:proxy_password]\n @proxy_auth_method = options[:proxy_auth_method]\n @disable_ssl_peer_verification = options[:disable_ssl_peer_verification]\n @disable_ssl_host_verification = options[:disable_ssl_host_verification]\n @ssl_cert = options[:ssl_cert]\n @ssl_cert_type = options[:ssl_cert_type]\n @ssl_key = options[:ssl_key]\n @ssl_key_type = options[:ssl_key_type]\n @ssl_key_password = options[:ssl_key_password]\n @ssl_cacert = options[:ssl_cacert]\n @ssl_capath = options[:ssl_capath]\n @verbose = options[:verbose]\n @username = options[:username]\n @password = options[:password]\n @auth_method = options[:auth_method]\n @attempt_retry = !options.has_key?(:retry) || options[:retry]\n @performed = false\n\n if @method == :post\n @url = url\n else\n @url = @params ? \"#{url}?#{params_string}\" : url\n end\n\n @parsed_uri = URI.parse(@url)\n\n @on_complete = nil\n @on_retry = nil\n @after_complete = nil\n @handled_response = nil\n end",
"def set_request; end",
"def http_request\n req = VanillaRequest.new @http_method, @uri.request_uri, @headers\n\n req.basic_auth @auth[:username], @auth[:password] if\n @auth && @auth[:username]\n\n req\n end",
"def make_request url, method: ::Rack::GET, body: nil, headers: []\n env = Testing.build_standard_env URI(url), headers\n env[::Rack::REQUEST_METHOD] = method\n env[::Rack::RACK_INPUT] = ::StringIO.new body if body\n ::Rack::Request.new env\n end",
"def http_request\n req = VanillaRequest.new @http_method, @uri.request_uri, @headers\n\n if @oauth\n req['Authorization'] =\n SimpleOAuth::Header.new(@http_method, @uri, {}, self.oauth).to_s\n elsif @auth && @auth[:username]\n req.basic_auth @auth[:username], @auth[:password]\n end\n\n # Stream Multipart\n if Kronk::Multipart === @body\n req.body_stream = @body.to_io\n\n # Stream IO\n elsif @body.respond_to?(:read)\n req.body_stream = @body\n\n else\n req.body = @body\n end\n\n b = req.body || req.body_stream\n\n if b.respond_to?(:bytesize)\n req['Content-Length'] = b.bytesize.to_s\n elsif b.respond_to?(:size) && b.size\n req['Content-Length'] = b.size.to_s\n elsif b.nil?\n req['Content-Length'] = \"0\"\n end\n\n req['Transfer-Encoding'] = 'chunked' if !req['Content-Length']\n\n req\n end",
"def build_http\n http = Net::HTTP.new(@timber_host, @timber_port)\n http.set_debug_output(Config.instance.debug_logger) if Config.instance.debug_logger\n if @timber_scheme == 'https'\n http.use_ssl = true\n # Verification on Windows fails despite having a valid certificate.\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n http.read_timeout = 30\n http.ssl_timeout = 10\n http.open_timeout = 10\n http\n end",
"def requestor(req, json = nil)\n res = Net::HTTP.start(@host, @port, {:use_ssl => true}) { |http|\n create_the_request(req, json, http)\n }\n unless res.kind_of?(Net::HTTPSuccess)\n # let rails and sinatra handle this or print out if using ruby i say if, elsif, else\n handle_error(req, res)\n end\n res\n end",
"def get_request\n # Use our @http_object object's request method to call the\n # Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end",
"def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end",
"def make_request\n query = {'income': @income, 'zipcode': @zipcode, 'age': @age}\n begin\n response = HTTParty.get(BASE_URL, query: query)\n # I know I can do better than this\n rescue Exception => e\n raise RequestException\n else\n response\n end\n end",
"def _request(url, type, key)\n url = URI(url)\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n req.add_field('X-Vermillion-Key', key)\n req.add_field('Accept', 'application/json')\n req.add_field('Cache-Control', 'no-cache')\n req.add_field('From', @config.get(:user))\n req.add_field('User-Agent', 'Vermillion Client 1.0')\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end",
"def initialize(address)\n @requests = [HTTY::Request.new(address)]\n end",
"def request(api_method, params = {}, request_method = :get)\n self.params = params.merge(method: api_method, format: 'json')\n self.request_method = request_method\n self.header = new_header\n self.typhoeus_request = new_typhoeus_request\n self.response = typhoeus_request.run\n self.body = Oj.load(response.body, OJ_OPTIONS)\n check_response!\n body\n end",
"def build_request\n client.request request_name\n end",
"def typhoeus_response\n @request.run\n end",
"def make_request(file, url, hydra, &block)\n request = Typhoeus::Request.new(url, timeout: 15000)\n\n request.on_complete do |response|\n if response.success?\n block.call(response.body)\n else\n puts Rainbow(\"Failed to get #{url}\").red\n end\n\n file.close\n end\n\n if req_parallel and hydra\n hydra.queue(request)\n else\n request.run\n end\n end",
"def setup_http_request(obj, cookie=nil, args={})\n if args.has_key?(:url) and args[:url] != nil\n if args[:url].scan(/%[s|d]/).length > 0\n if args[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % args[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(args[:url] % args[:url_arg])\n else\n req = obj[:method].new(args[:url])\n end\n else\n if args.has_key?(:url_arg)\n if obj[:url].scan(/%[s|d]/).length > 0\n if obj[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(obj[:url] % args[:url_arg])\n else\n req = obj[:method].new(obj[:url])\n end\n else\n req = obj[:method].new(obj[:url])\n end\n end\n req[\"Host\"] = \"www.blablacar.fr\"\n req[\"origin\"] = \"https://www.blablacar.fr\"\n req[\"User-Agent\"] = \"Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0\"\n req[\"Accept\"] = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\"\n if obj.has_key?(:referer)\n req['Referer'] = obj[:referer]\n else\n req[\"Referer\"] = \"https://www.blablacar.fr/dashboard\"\n end\n req.add_field(\"Connection\", \"keep-alive\")\n if cookie\n req.add_field(\"Cookie\", cookie)\n end\n if obj.has_key?(:header)\n obj[:header].each_slice(2).map{|h|\n req.add_field(h[0], h[1])\n }\n end\n if obj.has_key?(:data)\n if obj[:data].scan(/%[s|d]/).length > 0\n if obj[:data].scan(/%[s|d]/).length != args[:arg].length\n ALERT.call(caller_locations, __callee__, \"Body request contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:data].scan(/%[s|d]/).length)\n exit 2\n else\n req.body = obj[:data] % args[:arg]\n end\n else\n req.body = obj[:data]\n end\n req['Content-Length'] = req.body.length\n end\n req\nend",
"def http\n @http ||= create_http\n end",
"def http\n @http ||= create_http\n end",
"def generate_request(request)\n\n\t\t\trequest_uri = request[:uri].request_uri\n\n\t\t\tcase request[:method]\n\t\t\twhen :get\n\t\t\t\treq = Net::HTTP::Get.new request_uri\n\t\t\twhen :post\n\t\t\t\treq = Net::HTTP::Post.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :put\n\t\t\t\treq = Net::HTTP::Put.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :patch\n\t\t\t\treq = Net::HTTP::Patch.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :delete\n\t\t\t\treq = Net::HTTP::Delete.new request_uri\n\t\t\tend\n\t\tend",
"def make_request_object( opts={} )\n\t\tdata = make_request( opts )\n\t\treturn Mongrel2::Request.parse( data )\n\tend",
"def request\n WebRequest.create(build_request_url)\n end",
"def setup_fixtured_request( action, *args )\n\t\turi = '/' + File.join( @appletname, action.to_s )\n\t\treq = Apache::Request.new( uri )\n\n\t\tparams = args.last.is_a?( Hash ) ? args.pop : {}\n\t\tdebug_msg \"Parameters hash set to: %p\" % [params]\n\t\treq.paramtable = params\n\n\t\tdebug_msg \"Request is: %p\" % [req]\n\t\t#txn = Arrow::Transaction.new( req, @config, nil )\n\t\ttxn = flexmock( \"transaction\" )\n\t\ttxn.should_receive( :request ).\n\t\t and_return( req ).zero_or_more_times\n\t\ttxn.should_receive( :vargs= ).\n\t\t with( Arrow::FormValidator ).zero_or_more_times\n\t\t\n\t\tvargs = flexmock( \"form validator\" )\n\t\ttxn.should_receive( :vargs ).\n\t\t\tand_return( vargs ).\n\t\t\tzero_or_more_times\n\t\tvargs.should_receive( :[] ).zero_or_more_times\n\t\t\n\t\tdebug_msg \"Transaction is: %p\" % [txn]\n\t\treturn txn, req, vargs, *args\n\tend",
"def make_request\n\t\t\tresponse = nil\n\t\t\tif self.respond_to? :headers\n\t\t\t\turi = URI.parse(request_string)\n\n\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\thttp.set_debug_output $stderr if @test_request\n\t\t\t\thttp.use_ssl = true\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\t\t\t\trequest = Net::HTTP::Get.new(uri.request_uri)\n\t\t\t\theaders.each do |k,v|\n\t\t\t\t\trequest[k] = v\n\t\t\t\tend\n\n\t\t\t\tresponse = http.request(request).body\n\t\t\telse\n\t\t\t\t$stderr.puts(request_string) if @test_request\n\n\t\t\t\tresponse = open(request_string)\n\t\t\tend\n\n\t\t\treturn process_response(response)\n\t\tend",
"def request\n @req\n end",
"def request\n url1 = url\n return false unless valid?\n http_response = HTTParty.post(url, :format => :plain,\n :query => @params.merge({ :cmd => @cmd }),\n :headers => {\n 'ZooZ-Unique-ID' => @unique_id,\n 'ZooZ-App-Key' => @app_key,\n 'ZooZ-Response-Type' => @response_type,\n }) if @response_type.eql?('NVP')\n\n\n\n http_response = HTTParty.post(url, :format => :json,\n :body => @params.merge({ :cmd => @cmd }),\n :headers => {\n 'ZooZDeveloperId' => @developer_id,\n 'ZooZServerAPIKey' => CGI::escape(@app_key)\n }) if @response_type.eql?('JSON')\n\n response = Response.new\n response.request = self\n response.http_response = http_response\n unless response.success?\n @errors = response.errors\n return false\n end\n response\n end",
"def send_request_for(testcase)\n @http_client.send_request(testcase.request['method'], testcase.request['path'], testcase.request['headers'], testcase.request['body'], testcase.request['parameters'])\n end",
"def request(type)\n request = case type\n when :wsdl then Net::HTTP::Get.new @endpoint.request_uri\n when :soap then Net::HTTP::Post.new @soap.endpoint.request_uri, soap_headers.merge(headers)\n end\n\n request.basic_auth(*@basic_auth) if @basic_auth\n yield request if block_given?\n request\n end",
"def make_request!(options = {})\n\t\t\toptions[:client] = client\n\t\t\tself.client.transporter.make_request(options)\n\t\tend",
"def make_request(request)\n parsed_url = request.url\n\n raise ArgumentError, \"Expecting get argument url to be a valid_url?, got #{request.url}\" if !parsed_url.valid_url? && current_url.nil?\n\n parsed_url = current_url.join_url(request.url) if !request.url.valid_url? && !current_url.nil?\n\n client_resource = RestClient::Resource.new(parsed_url, ssl_version: 'SSLv23_client')\n response = client_resource.send(request.type, params: request.params)\n\n self.xml = Nokogiri::HTML.parse(response)\n end",
"def request(url, type)\n url = URI(URI.encode(url))\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end",
"def new_http(uri); end",
"def send_request; end",
"def http\n @http || prepare_http_connection\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 make_http_request\n Net::HTTP.get_response('localhost', '/ping', 3000).body\nend",
"def make_request(request, options)\n gather_headers(request, options)\n response = @http.request(request)\n Validators::ResponseValidator.validate!(response)\n JSON.parse(response.body)\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",
"def make_tn_request( opts={} )\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( headers )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def make_tn_request( opts={} )\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( headers )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def build_request(identity, next_service, username, hostname, client_username); end",
"def make_api_request(request_url)\n url = URI.parse(request_url)\n request = Net::HTTP::Get.new(url.path)\n connection = Net::HTTP.new(url.host, url.port)\n connection.use_ssl = true\n connection.request(request)\n end",
"def make_tn_request( opts={} )\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( headers )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend",
"def request(url)\n # Allow the user to specify the full URL.\n remainder = url[0, base.length] == base ? url.sub(base, '') : url\n\n request = nil\n delim = remainder.include?('?') ? '&' : '?'\n @limiter.times 1 do\n request = NYTResponse.new(\"#{base}#{remainder}#{delim}api-key=#{key}\")\n end\n request\n end",
"def create_http(_url = nil)\n\n\n if !request_endpoint.nil?\n _url = request_endpoint\n end\n\n\n if _url.nil? || _url[0] =~ /^\\//\n our_uri = URI.parse(site)\n else\n our_uri = URI.parse(_url)\n end\n\n\n if proxy.nil?\n http_object = Net::HTTP.new(our_uri.host, our_uri.port)\n else\n proxy_uri = proxy.is_a?(URI) ? proxy : URI.parse(proxy)\n http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)\n end\n\n http_object.use_ssl = (our_uri.scheme == 'https')\n\n if @options[:ca_file] || CA_FILE\n http_object.ca_file = @options[:ca_file] || CA_FILE\n http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http_object.verify_depth = 5\n else\n http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 30\n http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]\n\n http_object\n end",
"def build_connection\n Faraday.new(url) do |f|\n f.request :retry, max: 2, interval: 0.1, backoff_factor: 2\n\n f.headers['Content-Type'] = content_type\n f.headers['User-Agent'] = user_agent\n\n f.options.timeout = timeout\n f.options.open_timeout = open_timeout\n\n f.adapter :typhoeus\n end\n end",
"def build_net_http_request request\n\n # Net::HTTP adds a content-type header automatically unless its set\n # and this messes with request signature signing. Also, it expects\n # all header values to be strings (it call strip on them).\n headers = { 'content-type' => '' }\n request.headers.each_pair do |key,value|\n headers[key] = value.to_s\n end\n\n request_class = case request.http_method\n when 'GET' then Net::HTTP::Get\n when 'PUT' then Net::HTTP::Put\n when 'POST' then Net::HTTP::Post\n when 'HEAD' then Net::HTTP::Head\n when 'DELETE' then Net::HTTP::Delete\n else raise \"unsupported http method: #{request.http_method}\"\n end\n\n net_http_req = request_class.new(request.uri, headers)\n net_http_req.body = request.body\n net_http_req\n\n end",
"def create_request(url, options)\n @url = url\n @options = options\n end",
"def request\n self.http_response = http_client.get(url, request_options)\n self\n end",
"def request(req)\n self.class.paths << req.path\n self.class.params << req.body\n response = self.class.responses.shift\n if response.respond_to? :call then\n response.call req\n else\n res = Net::HTTPResponse.new '1.0', 200, 'OK'\n res.body = response\n res\n end\n end",
"def make_request(uri)\n http_client.start do |http|\n req = Net::HTTP::Get.new(uri.request_uri, @headers)\n req.basic_auth(@username, @password)\n http.request(req)\n end\n end",
"def initialize(options = {}, &block)\n @api_key = options.fetch(:api_key)\n @url = options.fetch(:url)\n @method = options.fetch(:method)\n @body = options[:body]\n @request = typhoeus_request\n @block = block\n end",
"def makeRequest(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n\n r = http.request(request)\n return r\nend",
"def build_request(name, args)\n build_args(args) if args\n # build the request & http object\n build_http_request(name)\n # set the content type & request body\n update_content_type(name)\n make_request(@http, @request)\n end",
"def request(type, id=\"\", params=\"\")\n id = id.to_s\n params = params.to_s\n api_path = case type\n when \"orders\"\n \"/api/v2/orders?\"\n when \"order_metadata\"\n raise \"ID required\" if id.empty?\n \"/api/v2/orders/#{id}?\"\n when \"shop_metadata\"\n raise \"ID required\" if id.empty?\n \"/api/v2/shop/#{id}?\"\n end\n api_path.chop! if params.empty?\n\n response = HTTParty.get(\n @domain + api_path + params, \n basic_auth: @auth\n )\n response_valid?(response)\n response\nend",
"def init_request(opts)\n raise ArgumentError, \":uri is for backwards compatibilty and conflicts with :request\" \\\n if opts[:request] && opts[:uri]\n\n # For backwards compatibilty\n if opts[:uri]\n HTTP::Request.new(:uri => opts[:uri], :verb => :get)\n else\n opts.fetch(:request)\n end\n end",
"def webRequest (url)\n\tif url =~ /(https)/\n\t\treturn httpsRequest(url)\n\telse\n\t\treturn httpRequest(url)\n\tend\nend",
"def make_get_request url, headers = []\n make_request url, headers: headers\n end",
"def make_request(uri)\n request = Net::HTTP::Get.new uri\n\n request[\"Authorization\"] = \"Basic #{credentials}\"\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n\n Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|\n http.request request\n end\n end",
"def make_request\n url = 'https://www.googleapis.com/qpxExpress/v1/trips/search?key=' + @api_key\n request = compose_request\n response = RestClient.post url, request, content_type: :json, accept: :json\n response.body\n end",
"def request(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end",
"def make_request( opts={} )\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def api_request(name) \n\tresponse = HTTParty.post('https://api.talentiq.co/v2/person', \n :body => {:name => name }.to_json,\n :headers => { 'Content-Type' => 'application/json', \n \t\t\t'x-api-key:' => 'e058cdd334c69c31d45d87e44b405d128a9e8937939e7d0ab2496334',\n 'Accept' => 'application/json' })\n puts response.body\nend",
"def create_http_request(http_method,path,*arguments)\n http_method=http_method.to_sym\n if [:post,:put].include?(http_method)\n data=arguments.shift\n end\n headers=(arguments.first.is_a?(Hash) ? arguments.shift : {})\n case http_method\n when :post\n request=Net::HTTP::Post.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :put\n request=Net::HTTP::Put.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :get\n request=Net::HTTP::Get.new(path,headers)\n when :delete\n request=Net::HTTP::Delete.new(path,headers)\n when :head\n request=Net::HTTP::Head.new(path,headers)\n else\n raise ArgumentError, \"Don't know how to handle http_method: :#{http_method.to_s}\"\n end\n if data.is_a?(Hash)\n request.set_form_data(data)\n elsif data\n request.body=data.to_s\n request[\"Content-Length\"]=request.body.length\n end\n request\n end",
"def make_request( opts={} )\n\t\tsetup_mongrel2_config()\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def request\n self.response = prepare_response(http_communication.content)\n end",
"def http; end",
"def make_request( opts={} )\n\t\topts = TEST_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts )\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || '' )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend"
] | [
"0.8453924",
"0.7412816",
"0.7254225",
"0.72096765",
"0.7059429",
"0.6931954",
"0.6717415",
"0.6714135",
"0.6672244",
"0.66057146",
"0.65637875",
"0.655671",
"0.6556658",
"0.65307486",
"0.6511367",
"0.6485143",
"0.6446069",
"0.64418554",
"0.6429781",
"0.6414975",
"0.6404596",
"0.6403915",
"0.6371061",
"0.63678956",
"0.6325249",
"0.6293293",
"0.625033",
"0.62296766",
"0.62293434",
"0.6215951",
"0.6206065",
"0.6205622",
"0.6193713",
"0.6192507",
"0.6190212",
"0.61695564",
"0.61673385",
"0.6148097",
"0.61383957",
"0.61335313",
"0.6100493",
"0.6098743",
"0.6098246",
"0.60951215",
"0.60856295",
"0.60833985",
"0.60819656",
"0.60579324",
"0.60542923",
"0.60504025",
"0.6048116",
"0.6048116",
"0.60478926",
"0.60477483",
"0.6034089",
"0.6033913",
"0.6029237",
"0.59873825",
"0.59789544",
"0.5969958",
"0.5968912",
"0.5963274",
"0.5948531",
"0.5947252",
"0.5934407",
"0.59279287",
"0.5926988",
"0.59156567",
"0.5911194",
"0.59089726",
"0.5892161",
"0.5883065",
"0.5883065",
"0.58779806",
"0.5871828",
"0.5871689",
"0.58655095",
"0.58581585",
"0.5856574",
"0.58384085",
"0.58351856",
"0.5826021",
"0.5824212",
"0.58198786",
"0.5812253",
"0.581214",
"0.58111584",
"0.58026505",
"0.5801537",
"0.5798037",
"0.57913524",
"0.57787764",
"0.577337",
"0.5769463",
"0.5765661",
"0.5760733",
"0.5758972",
"0.57550365",
"0.575261",
"0.5747564",
"0.5737719"
] | 0.0 | -1 |
Check to see if any notifications succeeded. Like the Prowl API with multiple API keys, we'll only return false if zero requests succeeded. | def status
return false if !@responses.include?(200)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_succeeded?\n @errors.blank? && [200,0].member?(@response_code)\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def success?\n checks.all?(&:success?)\n end",
"def successful?\n [\n Remit::PipelineStatusCode::SUCCESS_ABT,\n Remit::PipelineStatusCode::SUCCESS_ACH,\n Remit::PipelineStatusCode::SUCCESS_CC,\n Remit::PipelineStatusCode::SUCCESS_RECIPIENT_TOKEN_INSTALLED\n ].include?(request_query[:status])\n end",
"def successful?\n [\n Remit::PipelineStatusCode::SUCCESS_ABT,\n Remit::PipelineStatusCode::SUCCESS_ACH,\n Remit::PipelineStatusCode::SUCCESS_CC,\n Remit::PipelineStatusCode::SUCCESS_RECIPIENT_TOKEN_INSTALLED\n ].include?(request_query[:status])\n end",
"def success?\n not failure_occurred\n end",
"def success?\n not failure_occurred\n end",
"def success?\n (@failures + @errors) == 0\n end",
"def successful?\n status == :successful or tasks_are_successful?\n end",
"def successful\n count(&:ok?)\n end",
"def success?\n stat = false\n if @data and @data['message'] == 'success'\n stat = true\n end\n return stat\n end",
"def successful?\n (200...300).include?(@status_code)\n end",
"def success?\n response.message == 'OK'\n end",
"def has_notifications?\n !notification_queue.empty?\n end",
"def transact_successful?(doc)\n doc != nil &&\n doc.elements['XTMAILING_RESPONSE'] != nil &&\n doc.elements['XTMAILING_RESPONSE'].elements['ERROR_CODE'] != nil\n end",
"def success?\n @success ||= @tasks_results.all?(&:success?)\n end",
"def success?\n reply_code == 0\n end",
"def successful?\n returned_parameters['status'] == 'success'\n end",
"def is_successful?\n status_code == '0'\n end",
"def success?\n return true\n end",
"def success?\n @succeeded\n end",
"def success?\n return @success && errors.empty?\n end",
"def successful?\n status_code == 0 ? true : false\n end",
"def success?\n completed? && !error?\n end",
"def success?\n killers.any?(&:success?)\n end",
"def has_pending_requests?\n received_requests.pending.any?\n end",
"def success?\n result.success\n end",
"def success?\n self[:error].size + self[:fail].size > 0 ? false : true\n end",
"def push_to_epic_complete?\n %w(complete failed).include? last_epic_push_status\n end",
"def success?\n %w[1 2 3].include?(@status.to_s[0])\n end",
"def success?\n errors.none?\n end",
"def success?\n status.nil?\n end",
"def succeeded?\n request_sent? && response.success?\n end",
"def successful?\n @success && errors.empty?\n end",
"def succeeded?\n errors.empty?\n end",
"def success?\n valid? && ack != 'Failure'\n end",
"def success?\n execution_attempted? && errors.empty?\n end",
"def success?\n !soap_fault? && !http_error?\n end",
"def succeeded?\n success_states.include? status\n end",
"def success?\n data_rows.exists? && !data_rows.failed.exists?\n end",
"def success?\n false\n end",
"def success?\n false\n end",
"def success?\n !!@success\n end",
"def successful?\n !!get_status_method\n end",
"def ok?\n @performed && !any_errors? && !any_warnings?\n end",
"def successful?\n status == :successful\n end",
"def successful?\n status == :successful\n end",
"def successful_requests\n @successful_requests ||= @responses.select{|r| r[:success] }\n end",
"def success?\n (status_code.to_s =~ /2../) ? true : false\n end",
"def success?\n status == \"ok\"\n end",
"def success?(response)\n response[:response_code] == 0\n end",
"def success?\n [200, 201, 204, 280, 281].include?(code)\n end",
"def success?\n status < 400\n end",
"def success?\n status == 200\n end",
"def has_failures?\n completed? && @raw_result['failures'] != '0'\n end",
"def success?\n status == 'success'\n end",
"def success?\n response.success?\n end",
"def success?\n true\n end",
"def successful?(result)\n if defined?(result.cancelPackageReply)\n SUCCESSFUL_RESPONSES.any? {|r| r == result.cancelPackageReply.highestSeverity }\n else\n SUCCESSFUL_RESPONSES.any? {|r| r == result.highestSeverity }\n end\n end",
"def success?()\n result != false\n end",
"def success?\n @status && @status.success?\n end",
"def passed?\n counters\n .map { |c| c.ask!(:expected_messages_received?) }\n .reduce { |a, e| a && e }\n end",
"def success?\n response.status == 200\n end",
"def success?\n\t\t\t@ports.select{|p| not p.success}.size + @urls.select{|u| not u.success}.size < 1\n\t\tend",
"def success?\n !error\n end",
"def success?\n end",
"def success?\n\t\t\t@servers.select{|server| not server.success?}.size == 0\n\t\tend",
"def succeeded?\n authorized? || paid?\n end",
"def successful?\n status == 'successful'\n end",
"def success?\n @success == true\n end",
"def successful?\n @success && errors.empty?\n end",
"def success?\n status == 'success'\n end",
"def successful?\n status == \"successful\"\n end",
"def success?\n got.equal?(true)\n end",
"def success\n is_successful?\n end",
"def successful?\n @successful\n end",
"def success?\n @data[:status_code] == '200' || @data[:status_code] == '201' || @data[:status_code] == '407'\n end",
"def successful?(problem)\n return true if (problem[:arguments].first + ADDITION) == problem[:response]\n\n false\n end",
"def success?\n @status == SUCCESS_FLAG\n end",
"def send_notifications?\n self.notification_emails.present?\n end",
"def success?\n got.equal?(true)\n end",
"def success?\n return false unless @result['status'] == 'OK'\n return false unless @result['results'][0]['address_components'].length > 1\n true\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n @success\n end",
"def success?\n CODES[:success].include?(code.to_i)\n end",
"def success?\n @response.success?\n end",
"def success?\n @status && @status.success?\n end",
"def success?\n return unless @request\n if @request.respond_to?(:success?)\n @request.success?\n else\n _response = http_client.response\n _response && _response.code.start_with?('2')\n end\n end",
"def requests?\n return requests.any?\n end",
"def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end",
"def failed?\n @failures && @failures.any?\n end",
"def tasks_are_successful?\n return true if @tasks_are_successful\n return false if @tasks_have_failed\n successful = all? do |task|\n task.successful?\n end\n if successful\n debug 'All tasks are successful'\n @tasks_are_successful = true\n end\n successful\n end",
"def success?\n @errors.empty?\n end",
"def success?\n !raw_response.nil?\n end"
] | [
"0.6952991",
"0.67574304",
"0.67574304",
"0.66165715",
"0.6468016",
"0.6468016",
"0.64526534",
"0.64526534",
"0.64488715",
"0.6410507",
"0.6383525",
"0.63483703",
"0.6346389",
"0.6345137",
"0.63392454",
"0.6336125",
"0.6331401",
"0.6330159",
"0.6329844",
"0.63232625",
"0.63025624",
"0.62863964",
"0.62853396",
"0.62800425",
"0.6267685",
"0.62652117",
"0.62644124",
"0.6250632",
"0.6248788",
"0.6248558",
"0.6234606",
"0.62168604",
"0.6200773",
"0.61917925",
"0.6190474",
"0.6190321",
"0.6176993",
"0.61745244",
"0.61719173",
"0.6167396",
"0.6154338",
"0.6146806",
"0.6146806",
"0.61456937",
"0.61374515",
"0.613581",
"0.6132169",
"0.6132169",
"0.6107836",
"0.6107006",
"0.6106185",
"0.6104897",
"0.61034024",
"0.6100249",
"0.60981935",
"0.60863805",
"0.60851604",
"0.608424",
"0.60829484",
"0.607956",
"0.60754895",
"0.6071447",
"0.6067417",
"0.6065925",
"0.6065353",
"0.60638785",
"0.6051696",
"0.6042065",
"0.60396665",
"0.603954",
"0.603424",
"0.603249",
"0.6018467",
"0.6016186",
"0.60130113",
"0.60106456",
"0.60093725",
"0.6007826",
"0.6007609",
"0.60042506",
"0.60041213",
"0.600397",
"0.5995682",
"0.5986326",
"0.5986326",
"0.5986326",
"0.5986326",
"0.5986326",
"0.5986326",
"0.5986326",
"0.59845567",
"0.5984553",
"0.59829724",
"0.59812325",
"0.59800047",
"0.5977958",
"0.59712064",
"0.59626657",
"0.59578454",
"0.5942468"
] | 0.6294327 | 21 |
Keyvalue representation of the error. Can be directly serialized into JSON. | def to_h
h = {
code: @code,
msg: @msg,
}
h[:meta] = @meta unless @meta.empty?
h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializable_hash\n { errors: (super[:data] || []).map { |error| error[:attributes] } }\n end",
"def as_json(*)\n {\n error_type: error_type,\n error_message: error_message,\n meta: meta\n }\n end",
"def error\n\t\t{ \n\t\t\terror: { \n\t\t\t\tmessage: self.object[:message],\n\t\t\t\tfield: self.object[:field]\n\t\t\t} \n\t\t}\n\tend",
"def key_errors\n key(\"errors\")\n end",
"def error\n @obj['error']\n end",
"def to_s(value)\n \"#{@errors.inspect}\"\n end",
"def error\n data['error']\n end",
"def error\n return {error: \"\"}\n end",
"def errors\n self.__source.errors.messages.to_hash.stringify_keys\n end",
"def error(data = false)\n { error: data }.to_json\n end",
"def error\n @data['error']\n end",
"def error\n @data['error']\n end",
"def as_json\n { errors: @errors.as_json }\n end",
"def error_key\n self.class.error_key\n end",
"def to_s\n @error_description\n end",
"def error_messages_as_json\n { errors: object.errors.messages }\n end",
"def to_s\n \"\\\"#{@key}\\\": #{@value}\"\n end",
"def serialize_error\n case error\n when Common::Exceptions::BaseError\n base_error\n when Common::Client::Errors::ClientError\n client_error\n when EMISRedis::VeteranStatus::NotAuthorized\n emis_error(:not_authorized)\n when EMISRedis::VeteranStatus::RecordNotFound\n emis_error(:not_found)\n when MPI::Errors::RecordNotFound\n mpi_error(404)\n when MPI::Errors::FailedRequestError\n mpi_error(503)\n when MPI::Errors::DuplicateRecords\n mpi_error(404)\n else\n standard_error\n end\n end",
"def to_s\n return @error_description\n end",
"def message # :nodoc:\n @properties['errorMessage'].dup\n end",
"def to_h\n Utils::Hash.new(@errors).deep_dup\n end",
"def error_message\n @data[\"message\"]\n end",
"def error_message\n self[:error_message]\n end",
"def error_object\n {:success => false, :error => \"Error encountered\"}\n end",
"def message\n @error['message']\n end",
"def unknown_key_to_string(value)\n unknown_to_string(value)\n end",
"def value\n raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value\n end",
"def json_values_to_string(value)\n value.class == Hash ? value.to_s : value\n end",
"def format_error(e)\n data = { error: e.class.to_s, message: e.message, backtrace: e.backtrace }\n JSON.pretty_generate(data)\n end",
"def failure_validation_value\n field = validation_result.errors.keys.first\n {\n error: 'ValidationError',\n field: field,\n reason: \"#{field}: #{validation_result.errors[field].first}\"\n }\n end",
"def error=(value)\n doc['error'] = value.nil? ? nil : value.to_s\n end",
"def error_base\n {\n code: JSONAPI::VALIDATION_ERROR,\n status: :unprocessable_entity\n }\n end",
"def error_hash(exception)\n {\n success: false,\n payload: {\n error: exception.class.name,\n message: exception.message\n }\n }\n end",
"def to_s\n @error_status.to_s\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def validation_error_as_json\n Jbuilder.encode do |json|\n json.error 'Validation Failed'\n end\n end",
"def pretty(error)\n data, data_pointer, type, schema = error.values_at('data', 'data_pointer', 'type', 'schema')\n location = data_pointer.empty? ? 'root' : data_pointer\n\n case type\n when 'required'\n keys = error.fetch('details').fetch('missing_keys').join(', ')\n _(\"%{location} is missing required keys: %{keys}\") % { location: location, keys: keys }\n when 'null', 'string', 'boolean', 'integer', 'number', 'array', 'object'\n _(\"'%{data}' at %{location} is not of type: %{type}\") % { data: data, location: location, type: type }\n when 'pattern'\n _(\"'%{data}' at %{location} does not match pattern: %{pattern}\") % { data: data, location: location, pattern: schema.fetch('pattern') }\n when 'format'\n _(\"'%{data}' at %{location} does not match format: %{format}\") % { data: data, location: location, format: schema.fetch('format') }\n when 'const'\n _(\"'%{data}' at %{location} is not: %{const}\") % { data: data, location: location, const: schema.fetch('const').inspect }\n when 'enum'\n _(\"'%{data}' at %{location} is not one of: %{enum}\") % { data: data, location: location, enum: schema.fetch('enum') }\n else\n _(\"'%{data}' at %{location} is invalid: error_type=%{type}\") % { data: data, location: location, type: type }\n end\n end",
"def hash\n [item_id, error_details].hash\n end",
"def to_s\n key.to_s\n end",
"def type\n @error['type']\n end",
"def to_str\n body={\n id: @id,\n event: @event,\n data: @data,\n }\n if errors.any?\n body[:errors_count]=@errors.count\n body[:errors]=@errors\n end\n body.to_json\n end",
"def to_s\n\t\t\t\"#{index}:#{code}:#{error_code} - #{message} (#{type})\"\n\t\tend",
"def error_string\n # This method should be overridden\n end",
"def json_error(message = 'An error occurred')\n { status: 'error', message: message }\n end",
"def error\n response_json.fetch(\"error\", \"\")\n end",
"def serialize(value)\n return super unless value.is_a?(Hash) || implements_model?(value.class)\n\n ActiveSupport::JSON.encode(value, serialize_unknown_attributes: true)\n end",
"def serializable_hash\n if @object.class.ancestors.include?(ActiveModel::Model)\n return _model_errors\n end\n if @object.kind_of? Matterhorn::ResourceError\n return _exceptions \n end\n end",
"def errors_to_json(model)\n\t\treturn ModelError.new({\n\t\t\t:model => model,\n\t\t\t:error => model.errors.collect{ |attr,msg| attr.humanize+' - '+msg }.join('\\n'),\n\t\t})\n\tend",
"def to_json\n\n hash = self.to_hash\n\n if (hash[:error] == nil)\n h = {\n success: true\n }.merge(hash)\n h\n else\n {\n success: false,\n err: {\n internal_id: hash[:internal_id] || 'SDK',\n code: hash[:error],\n msg: hash[:error_message],\n error_data: hash[:error_data] || []\n }\n }\n end\n\n end",
"def exception_to_hash(id, exception, status)\n json_error(id, exception.class.name, exception.message, status)\n end",
"def to_s\r\n value.inspect\r\n end",
"def inspect\n to_hash.to_s\n end",
"def inspect\n to_hash.to_s\n end",
"def hash\n [error, from_date, group_by, message, query, res_type, series, status, to_date].hash\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def json_resource_errors\n resource.errors.messages.to_json\n end",
"def format_errors(_data)\n _data.errors.as_json\n end",
"def error_message\n if @errors\n @errors.map { |(k,v)|\n \"#{k} #{v.join(',')}\"\n }.join(\"; \")\n end\n end",
"def error(status_code, error_message)\n content_type 'application/json'\n [status_code, JSON.dump({error: {message: error_message}})]\n end",
"def error(new_error_key = 'error')\n self.error_key = new_error_key\n end",
"def json_value\n [Base64.strict_encode64(value)]\n end",
"def json\n value.sub(/^serialized-/, '')\n end",
"def error(job, exception)\n REDIS.set key, JSON.dump({status: 1, errmsg: exception.message})\n end",
"def get_error_response()\n error_message = \"\"\n @errors.each do |k,v|\n error_message << v + \",\"\n end\n error_message\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def to_hash\n {\n key_name => (value.to_hash rescue value)\n }\n end",
"def error_message\n error.message\n end",
"def to_s\n\t\t\t\"#{code}:#{error_code} - #{message}. #{details}\"\n\t\tend",
"def parse_key_value\n to_transaction { to_h }\n end",
"def hash_for_collection\n serialized_hashes = super[:data]&.map { |hash| sanitize_values(hash) }\n { errors: serialized_hashes }\n end",
"def custom_error(key_error)\n @errors << key_error\n end",
"def error(body)\n parsed_body = JSON.parse(body)\n \"#{parsed_body['errorNum']}: #{parsed_body[\"errorMessage\"]}\"\n end",
"def as_json(options=nil)\n return {} if messages.empty?\n attribute, types = messages.first\n type = types.first\n\n {\n :error => {\n :param => attribute,\n :type => type,\n :message => nil\n }\n }\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def as_json(options = {})\n \"{#{'errors'.inspect}:#{as_json_original(options)}}\"\n end",
"def json_resource_errors\n {\n error: true,\n errors: resource.errors,\n }\n end",
"def to_s\r\n to_hash.to_s\r\n end",
"def attribute_errors\n {}\n end",
"def pretty_hash_message(msg_hash)\n message = msg_hash['message']\n if msg_hash['errors']\n msg_hash['errors'].each do |k,v|\n if msg_hash['errors'][k]\n message = \"#{message}:\\n#{k}: #{v}\"\n end\n end\n end\n message\n end",
"def inspect\n \"#<#{ self.class.name } key=#{ @key.inspect }>\"\n end",
"def exceptions\n @values['exceptions']\n end",
"def error=(value)\n @error = value\n end",
"def error_message\n return @error_message\n end",
"def full_error\n @response_attributes['FullError'];\n end",
"def hashify_errors\n self.errors.map(&:first).uniq.inject({}) { |h, v|\n h[v] = (self.errors[v].is_a?(Array) ) ? self.errors[v].join(', ') : self.errors[v]\n h\n }\n end",
"def to_s\n value\n end",
"def to_s\n value\n end",
"def validate_key!(key)\n unless key.is_a?(String) or key.is_a?(Symbol)\n raise SketchUpJSON::JSONEncodeError, \"This hash can not generate valid JSON\"\n end\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end"
] | [
"0.66824377",
"0.6638831",
"0.6605591",
"0.6546328",
"0.65115255",
"0.6292544",
"0.627261",
"0.62694836",
"0.62290907",
"0.6224939",
"0.62233377",
"0.62233377",
"0.61827135",
"0.61817557",
"0.6151883",
"0.60664773",
"0.605906",
"0.60453004",
"0.60240746",
"0.59965014",
"0.5988099",
"0.59851766",
"0.5985078",
"0.59627277",
"0.5953306",
"0.59252775",
"0.59155524",
"0.5878532",
"0.58782464",
"0.5875483",
"0.58717257",
"0.5844385",
"0.5813253",
"0.58090925",
"0.58031327",
"0.58031327",
"0.57952136",
"0.5792593",
"0.57792383",
"0.577876",
"0.576374",
"0.5763116",
"0.575965",
"0.5751167",
"0.57471657",
"0.5747144",
"0.5735351",
"0.5733746",
"0.5731088",
"0.5724872",
"0.56878626",
"0.5684911",
"0.5662888",
"0.5662888",
"0.5653894",
"0.56248647",
"0.56248647",
"0.5603622",
"0.55929714",
"0.55797845",
"0.55745137",
"0.5562449",
"0.55605316",
"0.55460334",
"0.55442315",
"0.5541339",
"0.55270064",
"0.5523333",
"0.55227125",
"0.5519664",
"0.5519392",
"0.55190164",
"0.5502101",
"0.55004156",
"0.5494638",
"0.54928064",
"0.54928064",
"0.54928064",
"0.54928064",
"0.54928064",
"0.54928064",
"0.54928064",
"0.5492565",
"0.5474162",
"0.546571",
"0.5456261",
"0.5455216",
"0.5449147",
"0.54452753",
"0.54438645",
"0.5425066",
"0.5420764",
"0.54180783",
"0.5416112",
"0.5416112",
"0.5410848",
"0.5409815",
"0.54094326",
"0.5408872",
"0.5408872",
"0.5408872"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_open_hour
@open_hour = OpenHour.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 open_hour_params
params.required(:open_hour).permit(:event_id, :day_of_the_week, :open_hour, :close_hour)
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 |
Calculates automatically the total amount. There is a gotcha: If not all the payments are from the same money, this method won't calculate the total amount because this gem doesn't force the user to use a exchange service. | def total_amount
common_currency = calculate_common_currency
if common_currency.nil?
self[:total_amount]
else
self[:total_amount] ||= PaymentAmount[calculate_total, common_currency]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_payments\n total = 0\n payments.each{|payment| total += payment.amount}\n total\n end",
"def paid_total\n paid_total = 0\n unless self.payments.blank?\n for payment in self.payments\n paid_total += payment.amount.blank? ? 0 : payment.amount\n end\n end\n return paid_total\n end",
"def total_sum\n sum = if @payment.respond_to?(:total_sum)\n # use this first, because once the owner has set a specific sum\n # that becomes the final sum to be payed\n @payment.total_sum\n elsif @cart.total_sum\n # if owner has not yet set final sum, see if a cart has been\n # allready saved and use that to calculate\n @cart.total_sum\n else\n # while a transaction and it's cart still has not been stored in\n # db calculate the sum on the fly\n sum = @transaction.unit_price * @transaction.listing_quantity\n sum += @cart.cart_sum if @cart\n sum\n end\n end",
"def total_payment\r\n checks.inject(0.00){|sum, check| sum += check.check_amount.to_f}\r\n end",
"def paid_sum\n paid = Money.new(0, 'USD')\n paid += @paid_splits.inject(Money.new(0, 'USD')){ |memo, split| memo + split.sum } if @paid_splits.present?\n paid\n end",
"def total_payment_amount\n sum = 0.00\n unless self.insurance_payment_eobs.blank?\n self.insurance_payment_eobs.each do |eob|\n (sum = sum + eob.total_amount_paid_for_claim) unless eob.total_amount_paid_for_claim.nil?\n end\n end\n sum\n end",
"def total_amount\n t = amount\n t += sub_transactions.sum(:amount) if recurring_period\n t\n end",
"def total_paid\n payments.collect{|i| i.total_amount or i.calculate_total_amount}.sum + credit_notes.collect{|i| i.total_amount or i.calculate_total_amount}.sum\n end",
"def total_amount\n sum = ::Money.new(1, self.currency)\n @line_items.each {|li| sum += li.total_amount}\n sum -= ::Money.new(1, self.currency)\n sum\n end",
"def calculate_total\n sub_total = 0\n\n if size\n sub_total += Config.booths[size][:price]\n end\n\n self.add_ons.each do |add_on|\n sub_total += add_on.total\n end\n sub_total += industries.length * 35000\n sub_total += fees.pluck(:amount).reduce(0, &:+)\n\n self.total = sub_total\n self.balance = total - payments.paid.map(&:amount_paid).reduce(0, &:+)\n self\n end",
"def calculate_total_payment\n\t\tif self.total_amount.blank?\n\t\t\tbalance = 0\n\t\telse\n\t\t\tbalance = (self.total_amount + self.penalty) - paid_total\n\t\tend\n\n\t\tif balance <= 0\n return 0\n else\n return balance\n end\n\tend",
"def total_pay\n total = 0\n @serie_items.each do |item|\n # next if item.quantity.nil?\n total += item.quantity * item.creation.price\n end\n return total\n end",
"def total_price\n total = total_price_without_installments\n if promotions.any?\n adjustment = adjustments.eligible.map(&:amount).sum\n\n (total += adjustment).to_f\n end\n if line_items.any? { |li| li.request_installments == true }\n total = total / 5\n end\n total\n end",
"def total_raised\n payments.inject(0) { |sum, p| sum + p.amount.to_f }\n end",
"def total_amount\n if order_products.any?\n order_products.collect { |order_product| order_product.price }.sum\n else\n Money.new(0, 'EUR')\n end\n end",
"def calculate_total\n self.total = total_money(total_gross)\n end",
"def total\n self.delivery_price +\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end",
"def money_total(type)\n transaction_details(type).select do |value|\n value.instance_of? Money\n end.inject(:+) || Money.new\n end",
"def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end",
"def amount_paid\n accepted_payments.sum(:amount).to_f\n end",
"def payment\n payment = 0\n transactions = finance_transactions\n unless transactions.nil?\n transactions.each do |t|\n payment += t.amount\n end\n end\n payment\n end",
"def total\n total_amount = 0\n @order.each do |product, quantity|\n prod_price = PRODUCTS[product]\n if @pricing_rules.key?(product)\n rule = @pricing_rules[product]\n n = rule[1]\n type = rule[0]\n case type\n when \"Nx1\"\n total_amount += prod_price*( quantity/n + quantity%n )\n when \"BULK\"\n disccount_price = rule[2]\n total_amount += quantity * (quantity < n ? prod_price : disccount_price) #disccount price\n end\n else\n total_amount += prod_price * quantity\n end\n end\n total_amount\n end",
"def total_amount\n (payable.try(:total_amount) || amount).to_f \n end",
"def total\n total_invoice_items_price(invoice_items)\n end",
"def total\n self.inject(0) { |t, calculator| t + (calculator.active? ? calculator.price(@cart) : 0) }\n end",
"def total\n sum = self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price } +\n self.price_modifiers.inject(BigDecimal('0.0')) { |sum, pm| sum + pm.amount }\n return ApplicationHelper.round_currency(sum)\n end",
"def sum_payments\n contracts.sum{ |c| c.payments.sum(&:amount)}\n end",
"def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end",
"def total\n order_total + delivery_price + (prices_include_tax ? 0 : tax_amount)\n end",
"def total_price\r\n total = 0\r\n\r\n #Adds the prices of the orders up\r\n order_items.each do |order_item|\r\n total += order_item.item.price*order_item.quantity\r\n end\r\n\r\n #Applies any discounts\r\n if(campaign)\r\n discount = campaign.campaign_type.percentage_reduced\r\n if discount != 100\r\n total -= (total * discount / 100)\r\n elsif discount == 100\r\n i = []\r\n order_items.each do |order_item|\r\n i.push(order_item.item.price)\r\n end\r\n total -= i.min\r\n end\r\n end\r\n return total\r\n end",
"def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end",
"def total\n order.delivery_price +\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end",
"def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\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 total_paid\n self.user_expenses.reduce(0) { |sum, user_expense| user_expense.paid + sum }\n end",
"def total\n (amount + fee) if amount\n end",
"def total(bill)\n sum=0.0\n bill.items.each do |i|\n sum += i.price\n end\n return sum\n end",
"def total_funds\n self.collect{ |cs| cs.amount.to_f}.inject(0, :+)\n end",
"def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end",
"def total_debt\n Money.new(all_debts.sum { |_, debt| debt }, 'PLN')\n end",
"def set_amounts\n super\n self.paid_amount = 0\n payments.each do |payment|\n self.paid_amount += payment.amount\n end\n end",
"def amount_shares_outstanding_payment\n @amount_shares_paid_for = 0\n\n subscription_payments.each do |sp|\n if sp.paid?\n @amount_shares_paid_for += sp.share_amount\n end\n end\n\n (total_copies - @amount_shares_paid_for).to_i\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 total_payments\n Payment.total_for_tenant(self)\n end",
"def get_total_amount(params, transferred)\n total = 0\n\n if params[:multiple] == 'single'\n total = params[:amount].to_f\n return total * get_direction(params, transferred)\n end\n\n unless params[:transactions].nil?\n transactions = params[:transactions].split(/\\r?\\n/)\n transactions.each do |t_name_amount|\n if /#{@reg}/.match(t_name_amount)\n amount = t_name_amount.split(' ')[-1]\n total += amount.to_f if amount.respond_to? \"to_f\"\n end\n end\n end\n\n return total * get_direction(params, transferred)\n end",
"def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end",
"def generate_total_billing\n total = 0\n self.ur_invoices.each do |ur_invoice|\n total += ur_invoice.final_total\n end\n\n self.invoice_items.each do |invoice_item|\n total += invoice_item.charges\n end\n\n total\n end",
"def total_in(currency)\n Money.new(total_price_cents, \"USD\").exchange_to(currency)\n end",
"def total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end",
"def total_price\n \tresult = 0;\n \titems = self.order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end",
"def return_sum\n @money = 0\n @transactions.each do |t|\n if t.get_action == 'buy'\n @money = @money + t.get_value\n elsif t.get_action == 'sell'\n @money = @money - t.get_value\n end\n end\n total_value_of_shares - @money\n end",
"def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end",
"def add_money\n @total += fee\n end",
"def total_payments\n\t\tammortization * 12\n\tend",
"def total_pay\n total_pay = self.employees.map do |employee|\n employee.pay\n end\n total_pay.inject(:+)\n end",
"def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end",
"def calculate_total_in_cents\n total = 0\n self.subscriptions.each do |s|\n if s.duration.to_i == 30\n total += PriceConfig.pricing(30) * 100\n elsif s.duration.to_i == 60\n total += PriceConfig.pricing(60) * 100\n else\n total += PriceConfig.pricing(90) * 100\n end\n end\n total\n end",
"def total\n charges.map { |x| x.total_cost.to_f }.inject(:+)\n end",
"def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n \n self.item_total = order_items.map(&:amount).sum\n self.billing_total = order_items.map(&:cost).sum\n self.customer_total = item_total\n self.full_total = order_items.map(&:full).sum\n end",
"def grand_total\n order_lines.inject(Money.new(0)) { |grand_total, line| grand_total + line.total_price }\n end",
"def get_total_payment(team_bono)\n decimal_total_bono_percentage = ((get_individual_bono_percentage + team_bono) / 2) / 100\n discounted_bono = @bono * decimal_total_bono_percentage\n @sueldo_completo = @sueldo + discounted_bono\n end",
"def pledge_total\n @pledges = Pledge.all\n pledge_total = 0\n @pledges.each do |pledge|\n if pledge.user_id == self.id\n pledge_total = pledge_total + pledge.dollar_amount\n end\n end\n return pledge_total\n end",
"def find_total_payments_made_by_user(user_id)\n\t\tsum = 0\n\t\tif !self.payments.find_all_by_user_id(user_id).nil?\n\t\t\tself.payments.find_all_by_user_id(user_id).each do |payment|\n\t\t\t\tsum += payment.amount\n\t\t\tend\n\t\tend\n\t\tsum\n\tend",
"def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end",
"def total\n @total ||= ((shipping_amount * subtotal).to_f/100) + subtotal + promotion_amount.to_i\n end",
"def payment_amount\n convert_email_to_user && save\n return override_cost if override_cost.present?\n\n event&.get_cost(member: user&.present?)\n end",
"def calculate_totals\n totals = {}\n if self.amount_due.nil?\n total = 0.00\n order_products.each do |order_product|\n price = order_product.unit_price\n price = order_product.product.price if price.nil?\n total = total + (price * order_product.quantity)\n end\n totals[:product_total] = total\n totals[:tax] = total * 0.055\n totals[:amount_due] = total + totals[:tax]\n else\n totals[:product_total] = self.product_total\n totals[:tax] = self.tax\n totals[:amount_due] = self.amount_due\n end\n return totals\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 calculate_totals\n subtotal_collector = 0\n active_contracts.each do |active_contract|\n subtotal_collector += active_contract.subtotal\n end\n\n self.subtotal = subtotal_collector\n self.tax = subtotal * 0.09\n self.total = subtotal + tax\n save\n end",
"def outstanding_amount\n if payment_item.is_a? GeneralPaymentItem\n [0.0, payment_item.amount - payment_installments.map(&:amount).sum].max\n else\n nil\n end\n end",
"def total\n sum = 0\n order_items.each do |order_item|\n if order_item.item.price.present? && order_item.quantity.present?\n sum += order_item.item.price * order_item.quantity\n end\n end\n return sum\n end",
"def total_value\r\n return 0 if self.value.nil?\r\n self.value + self.expenses.includes(:expense).map{ |e|\r\n (e.quantity || 0) * (e.expense.signed_price || 0)\r\n }.sum\r\n end",
"def calculate_total\n order_items.sum(:total)\n end",
"def outstanding_payment_amount\n (total - amount_paid).round(2)\n end",
"def amount_payment_outstanding\n capital_required - amount_payment_collected\n end",
"def get_total\n total = 0.0\n if !@order.nil?\n @order.order_items.each do |item|\n total = total + item.product.price * item.quantity\n end\n end\n return total.to_f\n end",
"def compute_total(type)\n list = capture_amounts(type)\n generate_total(list)\n end",
"def total_price\n \tresult = 0;\n \titems = self.temp_order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end",
"def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end",
"def total_price\n total = 0\n if self.nil? || self.order_items.empty?\n else\n items = Order.find(self.id).order_items\n if items.length > 0\n items.each do |item|\n total += Product.find(item.product_id).price * item.quantity\n end\n end\n end\n\n\n return total\n end",
"def total_amount\n @total_amount ||= data_analyzer.total_amount\n end",
"def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end",
"def summ\n result = 0.0\n self.propose_items.each do |item|\n result += item.price\n end\n return result\n end",
"def total\n # Calculo el total sin descuentos\n self.total_prize = @products.map {|p| p.prize }.inject :+\n\n # Aplico todos los descuentos dinamicamente\n @discounts.each do |discount|\n discount.call self\n end\n\n self.total_prize # Retorno el precio final\n end",
"def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end",
"def total\n total_cache(:total) || (sub_total + total_tax)\n end",
"def total_quantity\n cached_qty_bank.to_f + cached_qty_consigned.to_f\n end",
"def balance_dollars\n transactions = Transaction.where('contact_id = ?', id)\n .includes(:settled_by)\n\n totalPaid = Money.new(0)\n totalSettled = Money.new(0)\n\n transactions.each do |loan|\n totalPaid = totalPaid + loan.amount_dollars\n\n loan.settled_by.each do |payback|\n totalSettled = totalSettled + payback.amount_dollars\n end\n end\n\n return totalPaid + totalSettled\n end",
"def total_price\n mrg = margin(pricing_policy)\n calculate(pricing_policy, mrg).round\n end",
"def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end",
"def calculate\n=begin\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n=end\n self.total\n end",
"def total_funds\n total = 0\n num_funding_rounds.each do |round| \n total += round.investment\n end\n total\n end",
"def product_total\n\t\ttotal = 0\n\t\tself.items.each do |item|\n\t\t\ttotal += item.amount\n\t\tend\n\t\ttotal\n\tend",
"def total_amount\n sum = 0\n @transactions.each do |transaction|\n if transaction.category.in? %w[deposit refund purchase]\n sum = sum + transaction.amount\n elsif transaction.category.in? %w[withdraw ante]\n sum = sum - transaction.amount\n end\n end\n\n sum\n end",
"def total_amount\n (total * 100).to_i\n end",
"def total\n total = order_items.inject(0) { |sum, p| sum + p.subtotal }\n end",
"def total_earned\n totals = []\n\n self.orders.each do |order|\n totals << order.total_price\n end \n\n return totals.inject{ |sum, n| sum + n } \n end",
"def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end",
"def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end"
] | [
"0.7728512",
"0.7668864",
"0.7522648",
"0.75194734",
"0.7499672",
"0.7485404",
"0.7406738",
"0.73492044",
"0.7337877",
"0.7318705",
"0.7199955",
"0.71560115",
"0.7152253",
"0.71406984",
"0.7124839",
"0.7035886",
"0.70224744",
"0.70153385",
"0.7010843",
"0.7010449",
"0.6980845",
"0.6936375",
"0.69307745",
"0.6929182",
"0.69234824",
"0.6910019",
"0.6906559",
"0.68913376",
"0.68890023",
"0.6885002",
"0.6880119",
"0.68686235",
"0.6858861",
"0.6825581",
"0.6825439",
"0.68195593",
"0.68043816",
"0.6780886",
"0.6773956",
"0.67620075",
"0.6756596",
"0.6743136",
"0.6739873",
"0.6730424",
"0.6727456",
"0.6727333",
"0.6721546",
"0.6719317",
"0.6712915",
"0.6708926",
"0.67010015",
"0.66911495",
"0.6682259",
"0.668206",
"0.6681563",
"0.6678908",
"0.6675106",
"0.66669714",
"0.6662942",
"0.6660064",
"0.6654079",
"0.6650799",
"0.6649271",
"0.6632688",
"0.6632041",
"0.6626351",
"0.66213334",
"0.6620431",
"0.661383",
"0.66129035",
"0.661204",
"0.66022956",
"0.6600128",
"0.65896916",
"0.65745825",
"0.65731156",
"0.65704197",
"0.6568077",
"0.65614915",
"0.65601724",
"0.65513664",
"0.6548404",
"0.6542935",
"0.6535656",
"0.6535308",
"0.6528508",
"0.6527964",
"0.6517794",
"0.6513706",
"0.65127826",
"0.650855",
"0.6504415",
"0.6501734",
"0.65009135",
"0.6500713",
"0.6500684",
"0.64975655",
"0.6495015",
"0.648806",
"0.6486386"
] | 0.7700049 | 1 |
add the necessary class methods, attributes, etc. here to make the tests in spec/wordguesser_game_spec.rb pass. Get a word from remote "random word" service | def initialize(word)
@word = word
@guesses = ''
@wrong_guesses = ''
@word_with_guesses = ''
@wrong_word_with_guesses = ''
@check_win_or_lose
i = 0
while i < @word.length do
@word_with_guesses << '-'
i=i+1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @word = get_random_word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @url = \"https://www.google.com/search?q=define%3A+#{word}\"\n @noko = correct_site()\n @word_info = get_definition()\n end",
"def getRandomWord\n @word = Wordnik.words.get_random_word(\n includePartOfSpeech: \"noun\",\n minLength: 5,\n maxLength: 10\n )\n if request.xhr?\n render :json => @word\n end\n end",
"def select_word\n uri = URI('https://random-word-api.herokuapp.com/word?number=5')\n words = Net::HTTP.get(uri) \n words = words.delete(\"[\").delete(\"]\").delete(\"\\\"\")\n words = words.split(\",\")\n index = rand(words.count - 1)\n return words[index]\n end",
"def setup_game\n\t\t@word = get_word.upcase\n\t\t@misses = []\n\t\t@hits = []\n\t\t@guesses_left = 10\n\tend",
"def test_start\n word = SecretWord.new(\"bob\")\n assert \"bob\" == word.get_word\nend",
"def get_random_word(*args)\n http_method = :get\n path = '/words/randomWord'\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def test_word\n @tester = Faker::Hipster\n @standard_wordlist = I18n.translate('faker.hipster.words')\n\n 1000.times { assert_includes @standard_wordlist, @tester.word }\n end",
"def test_word\n @standard_wordlist = I18n.translate('faker.lorem.words')\n\n 100.times { assert_includes @standard_wordlist, @tester.word }\n end",
"def get_words(text) #no!, two methods named get_words, see word_search.rb\n \twords = text.split('')\n \twords.each do |word|\n \t\t#how to check if word is correct or not?\n \t\tWord.new(name: word, ngsl: false, list: self.id )\n \t\t# example = Wordnik.word.get_top_example(word)['text']\n \tend\n end",
"def getWord\n return RandomWord.adjs.next\nend",
"def get_random_word\r\n @word_list.sample\r\n end",
"def random_word\n wordpair = nil\n File.foreach(\"wordlist\").each_with_index do |line, number|\n wordpair = line if rand < 1.0/(number+1)\n end\n word = Word.new(wordpair.split(':')[0], wordpair.split(':')[1])\n return word\n end",
"def get_word\n word = @word_list[rand(@word_list.length)]\n @word = word.gsub(/\\s+/, \"\").downcase\n end",
"def initialize(word)\n start_new_game(word)\n end",
"def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n self\n end",
"def a_word\n return @random_word\n end",
"def load_words\n case @strategy\n when :user\n @words = twitter_user.status.text.split(/\\s/) \n when :search\n @words = twitter_search(@term).statuses.map(&:text).join(\" \").split(/\\s/)\n end\n end",
"def get_random_words(*args)\n http_method = :get\n path = '/words/randomWords'\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def initialize(word=WordGuesserGame.get_random_word, guesses = '',wrong_guesses='')\n @word = word\n @guesses = guesses\n @wrong_guesses = wrong_guesses\n end",
"def initialize word \n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def get_random_word(words)\n # rand method with an integer argument (the length of words) get a new integer between 0 & the length of words\n return words[rand(words.count)]\n end",
"def random_word\n @words.fetch(rand(@words.length)).chomp\n end",
"def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end",
"def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n end",
"def get_word(key = '')\n words = self.words[key] || []\n extras = key == '' ? 2 : 3\n\n while true\n n = rand(words.length + extras)\n existing_word = words[n]\n return existing_word if existing_word\n\n new_word = make_word(key)\n bad = false\n self.words.each do |word|\n if word.include? new_word\n bad = true\n break\n end\n end\n next if bad\n words << new_word\n self.words[key] = words\n\n return new_word\n end\n end",
"def load_game(chosen_word,word_guess,dead_man)\n @chosen_word = chosen_word\n @word_guess = word_guess\n @dead_man = dead_man\n\n @word_guess.display(@dead_man)\n round\n end",
"def reply(word: :message)\n # DelayInfomationExtractor\n if word.include?('電車')\n DelayInfomationExtractor.new.search_for_delaying_railway(word)\n\n # elsif\n\n # UserLocalAPI\n else\n word = refine_msg(msg: word)\n call_user_local_api(msg: word)\n end\n end",
"def setup\n to_delete = []\n @word_list.each do |word|\n\n # Run the word through the validator and return if it is valid or not\n status = validate_word(word)\n\n # If the words invalid add it to the list of words to delete.\n to_delete.push(word) if status\n end\n\n # Remove all the invalid words\n to_delete.each do |invalid_word|\n @word_list.delete(invalid_word)\n end\n\n # Generate a random number in range of the world list length, the word at this\n # index is the game word, split that into an array of chars, using strip incase there is random\n # whitespace for whatever reason\n word_index = rand(@word_list.length)\n @whole_word = @word_list[word_index]\n @word_to_guess = @word_list[word_index].strip.split('')\n\n home\n end",
"def wordValidator\n print params[:currentWord]\n\n # the api key didn't work need to register to rapidAPI link,is asking for credit card\n #HTTP.get(\"https://github.com\").to_s\n\n=begin\n uri = URI('https://webspellchecker-webspellcheckernet.p.rapidapi.com/ssrv.cgi')\n req = Net::HTTP::Get.new(uri)\n\n req['x-rapidapi-host'] = \"webspellchecker-webspellcheckernet.p.rapidapi.com\"\n req['x-rapidapi-key'] = \"46bca383efmsh1fdbe7cce97066ap1b3476jsn2dc7e69af91b\"\n req['Accept'] = 'application/json'\n req['Content-Type'] = 'application/json'\n\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n=end\n\n\n\n\n wordfound = 'false'\n score = 0\n if word\n wordfound = 'true'\n b = BoggleUtils.new\n score = b.wordScore(params[:currentWord])\n end\n\n render json: { value: wordfound, word: params[:currentWord], score: score}\n end",
"def word_selector\n\t\t@game_word = @word.sample\n\tend",
"def initialize(word)\n @word = word #instanciates a new instance of `word`\n end",
"def initialize(player, difficulty = nil, passed_word = nil)\n url = \"http://app.linkedin-reach.io/words?\"\n \n #Set the difficulty. Get dictionary filtered on difficulty. Initialize secret word.\n if difficulty\n url += \"difficulty=#{difficulty}\"\n end\n response = HTTParty.get(url)\n @dictionary = response.parsed_response.split(\"\\n\")\n passed_word ||= dictionary.sample.downcase\n @secret_word = passed_word.downcase\n\n\n # Initialize the list of players. This can support two players. \n # Set player index to 0, which will support keeping track of two players. \n @players = [player]\n @curr_player_index = 0\n @curr_player = @players[@curr_player_index]\n\n #Give the user the option for two players. \n #If two players are not specified, default to the single player passed to the intialization.\n print \"Enter 1 for one player, or 2 for two player: \"\n player_mode = gets.chomp\n if player_mode == \"2\"\n player_2 = Player.new(\"Player_2\")\n @players += [player_2]\n end\n\n @game_word = \"\"\n @secret_word.each_char do |char|\n add_char = \"_\"\n if char == \" \"\n add_char = \" \"\n end\n @game_word += add_char + \" \"\n end\n \n end",
"def random_word\n\t\tLEGAL_WORDS.sample # Gets random element from array\n\tend",
"def initialize(word)\n # Make the word lowercase\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = ''\n end",
"def initialize(chosen_word,word_guess,dead_man,time)\n @chosen_word = chosen_word\n @word_guess = word_guess\n @dead_man = dead_man\n @time = time\n end",
"def gensecretword\r\n\t\t \trand_index = rand(@wordtable.length)\r\n\t\t \t@secret_clue = @descr[rand_index]\r\n\t\t \t@num_words = @wordtable[rand_index].split(\" \").length\r\n\t\t return @wordtable[rand_index].upcase\r\n\t\t end",
"def initialize()\n @word = ''\n @guesses = ''\n @wrong_guesses = ''\n end",
"def create\n word = Word.new(params['term'], false)\n\n # check to see if the word exists on the board\n board = Boggle.new\n exists = board.search(word.term, params['tiles'])\n\n # now, see if the word is an actual English word\n if exists\n\n # check the cache first - only go to the oxford dictionary if\n # it doesn't exist in our simple word cache\n word_cache_store = MiniCache::Store.new\n if !word_cache_store.get(word.term).nil?\n word.exists = true\n else\n # allowing exceptions from underlying api to throw 500 status code\n # and generate a log entry - to protect system from downstream\n # latency and failures, use circuit breaker\n word.exists = @dictionary_gateway.exists(word.term)\n word_cache_store.set(word.term, '') if word.exists\n\n end\n end\n\n render json: word\n end",
"def test_word\n 1000.times { assert_includes @wordlist, @tester.word }\n end",
"def random_word\n words = @dictionary.dictionary.keys\n words[rand(words.length)]\n end",
"def initialize(word)\n @word = word\n @guesses = \"\"\n @wrong_guesses = \"\"\n @word_with_guesses = word.gsub(/./, \"-\") \n @check_win_or_lose = :play\n @wrong_count = 0\n end",
"def get_definitions\n Dictionary.find_by_word(word_id)\n end",
"def test_words\n @words = @tester.words(number: 1000)\n\n @words.each { |w| assert_includes @standard_wordlist, w }\n end",
"def extended_api(word)\n case word.value\n when \"blah\"\n true\n else\n raise \"word '#{word.value}' not defined\"\n end\n end",
"def test_words\n @words = @tester.words(number: 1000)\n\n @words.each { |w| assert_includes @wordlist, w }\n end",
"def word\n Word.find_by(text: params[:text])\n end",
"def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n end",
"def random_word(msg)\n return if Variables::Constants::IGNORED_USERS.include?(msg.user.nick)\n word = LiterateRandomizer.word\n @last_words = [] if @last_words.nil?\n word = LiterateRandomizer.word while @last_words.include?(word)\n @last_words.prepend_capped(word, 5)\n msg.reply(word)\n end",
"def get_my_words\n # Words associated with online harassment\n trigger_words = [\"rape\",\"murder\",\"nigger\",\"slut\",\"whore\",\"bitch\",\"cunt\",\"kill\",\"die\",\"testword\"]\n my_words = Word.where(user_id: self.id)\n my_words.each do |word|\n trigger_words << word.word\n end\n return trigger_words\n end",
"def robots; end",
"def robots; end",
"def random_word\n\t\tnumber = rand(@modified_dictionary.length)\n\t\t@modified_dictionary[number]\n\tend",
"def new_game\n\t\t# Get the full list of words\n\t\twords = File.readlines('wordlist.txt')\n\t\tvalid_words = []\n\t\twords.each do |w| \n\t\t\t# Take all new lines and returns out\n\t\t\tw.gsub!(/\\r\\n/, \"\")\n\t\t\t# Word is valid if it's between 5 and 12 characters and isn't a proper noun. (no fair using names and such!) \n\t\t\tvalid_words << w if w.length.between?(5,12) && w[0] != w[0].upcase\n\t\tend\n\t\t# Split secret word into an array of letters\n\t\t@word = valid_words.sample.split(\"\").to_a\n\t\t# This holds user's guess. Originally populated with \"_\" for each letter\n\t\t@guess = \"\"\n\t\t@word.length.times { @guess += \"_\"}\n\t\t# Holds user's wrong letters. Originally populated with 9 x \"_\"\n\t\t@wrong_letters = \"\"\n\t\t9.times { @wrong_letters += \"_\"}\n\t\t@turn = 0\n\t\tputs \"Your task is to guess the secret word, letter by letter.\"\n\t\tputs \"You have only 9 wrong letters before you lose, so guess carefully!\"\n\t\tputs\n\t\tputs \"Here is your word. Each _ is a letter.\"\n\t\tputs\n\t\tget_guess\n\tend",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n @word = word\n end",
"def set_word\n @word = Word.find_by_text(params[:text])\n end",
"def initialize(client, *words)\n @client = client\n @words = fetch_words(words).sort { |x,y| y.hits <=> x.hits }\n end",
"def initialize(word)\n @guesses = ''\n @wrong_guesses = ''\n @word = word.downcase\n end",
"def random_word\n open('/usr/share/dict/words').read.split(/\\n/).sample\n end",
"def initialize(word)\n @word=word\n end",
"def word\n options = []\n case @theme\n when \"default\"\n options = [\"cast\", \"puppy\", \"pineapple\", \"bananas\"]\n @word_to_guess = options.sample\n when \"food\"\n options = [\"mango\", \"papaya\", \"guava\", \"apples\", \"lychee\"]\n @word_to_guess = options.sample\n when \"hacker\"\n options = [\"bandwidth\", \"synthesize\", \"bypass\", \"cyberpunk\", \"firewall\"]\n @word_to_guess = options.sample\n when \"game of thrones\"\n options = [\"stark\", \"lannister\", \"arya\", \"hodor\", \"meereen\"]\n @word_to_guess = options.sample\n when \"lord of the rings\"\n options = [\"lothorien\", \"galadriel\", \"frodo\", \"bombadil\", \"goldberry\"]\n @word_to_guess = options.sample\n end\n end",
"def get(word)\r\n return \"\" if !@words[word]\r\n follow = @words[word]\r\n sum = follow.inject(0) { |sum,kv | sum +=kv[1] }\r\n random = rand(sum)+1\r\n part_sum = 0\r\n nextWord = follow.find do |word, count|\r\n part_sum += count\r\n part_sum >= random\r\n end.first\r\n nextWord\r\n\r\n end",
"def get_word\r\n return_word\r\n end",
"def initialize(word)\n\t\t@word = word\n\t\t@guesses = word.length\n\t\t# Initialize a instance variable with empty hash.\n\t\t@guessed_words = {}\n\t\t# Initialize the game_end to boolean false \n\t\t@game_end = false\n\t\t# Index is used to replace the dashes with the correct guess.\n\t\t@index = 0\n\t\t# Initialize the hidden word with dashes instead of alphabets.\n\t\t@hidden_word = word.tr(word,\"-\")\n\tend",
"def random_word\n word = WORDS[rand(WORDS.length)]\n word == \"\" ? random_word : word\nend",
"def set_word\n @word = Word.friendly.find(params[:id])\n end",
"def randomly( word )\n send( [ :point, :delete, :insert ].random, word )\n end",
"def pick_random_word\n random_word = @words.sample.gsub!(/\\s+/, \"\")\n end",
"def pick_secret_word\n @word = dictionary.sample\n word\n end",
"def test_word\n 42.times { assert @standard_wordlist.include?(@tester.word) }\n end",
"def initialize(rounds)\n @rounds = rounds\n \n # round information (gets reset every round)\n @score = 1000\n @guesses = 0\n @searchword = \"\"\n \n @total_score = 0\n @round = 0\n \n @words = %w(\n \"cat\n dog\n beach\n sky\n sea\n ocean\n desert\n pyramid\n temple\n car\n motorbike\n bike\n lantern\n seaweed\n fish\n hamster\n computer\n game\n telephone\n headphones\n stereo\n purple\n red\n green\n blue\n orange\n yellow\n glass\n tree\n flower\n chair\n sofa\n wall\n house\n castle\"\n )\n end",
"def fake_word\n DataFaker.hawaiian_word\nend",
"def initialize(word)\n @word = word\n end",
"def run\n puts \"Welcome to the Hangman game. You will need 2 players.\"\n\n h = Hangman.new # this creates a new instance of the game\n h.getWord\n h.welcomePlayer2\n\n h.startGuess\n\n #h.displayHangman\n\nend",
"def test_class_world_has_create_random_method\n assert_respond_to World, 'create_random'\n end",
"def play_game\n\n\tword = select_word #call on the method that retrievess a random word\n\n\tConsole_Screen.cls #clear the display area\n\n\tconsonants = get_consonants #call on the method that prompts the player\n\t#to enter a list of consonatns\n\n\tConsole_Screen.cls #clear the display area\n\n\t#call on the method that prompts the player to enter a vowel\n\tvowel = get_vowel\n\n\t#remove blank spaces from the word to create a short version of the word\n\tshortWord = word.gsub(\" \", \"\")\n\n\t#call the method that processes palyer guesses\n\tprompt_for_guess(shortWord, word, consonants, vowel)\n\n\tConsole_Screen.cls #clear the display area\n\nend",
"def initialize(word)\n @word = word \nend",
"def test_play_game_with_parse__full_word__true\n @game.parse_guess(\"hi there\")\n @game.check_won?\n assert_equal(true, @game.won)\n end",
"def initialize(word) # initialize with the arguement word\n @name = word # set the name = to the word that is paaed\n end",
"def test_first_word\n execute_secret_word('colombia', 'c')\n end",
"def greeting\n random_response(:greeting)\n end",
"def set_word\n @word = Word.find_by(id:params[:id], user_id:current_user.id)\n end",
"def initialize\r\n load_word_catalog\r\n end",
"def initialize(word)\n\t\t@word = word\n\t\t@guesses = word.length\n\t\t@game_over = false\n\t\t@letters = []\n\tend",
"def prepare( word, m, chainlen, simto )\n xchain = m.bot.set.logic.maxchainlength\n nchain = m.bot.set.logic.minchainlength\n wid = -1\n oword = word\n \n # Rope our chain length into whatever config has it set as\n if not chainlen.is_a? Integer or chainlen <= 0\n chainlen = Random.new.rand nchain..xchain\n elsif chainlen > xchain\n chainlen = xchain\n elsif chainlen < nchain\n chainlen = nchain\n end\n\n if simto\n word = \"%#{word}%\"\n wid = m.getFirst_i_rand \"id\", \"words WHERE word SIMILAR TO ?\", word\n else\n wid = m.getFirst_i_rand \"id\", \"words WHERE word ILIKE ?\", word\n end\n \n if wid == nil or wid <= 0\n m.reply \"I don't know the word: \\\"#{oword}\\\"\"\n end\n\n return wid, chainlen\n end",
"def adv\n @words1 = Word.all.sample(1)[0].word\n @words2 = Word.all.sample(1)[0].word\n end",
"def initialize words\n @word_list = words\n end",
"def new_game\n dictionary = File.readlines(\"assets/5desk.txt\").map {|word| word.chomp}\n dictionary.select! {|word| word.length >= 5 && word.length <= 12}\n @chosen_word = dictionary[(dictionary.size * rand).floor]\n\n puts \"A word has been chosen that is #{@chosen_word.length} letters long.\"\n puts \"You may guess the letters in that word one letter at a time,\"\n puts \"or you may guess the whole word, but a man's life \\\"hangs\\\" in\"\n puts \"the balance. So be careful not to make too many wrong guesses,\"\n puts \"because once his whole body and both of his eyes have been\"\n puts \"drawn, he's dead and you lose!\"\n puts \"\\n\"\n\n @word_guess = WordGuess.new(@chosen_word)\n @dead_man = DeadMan.new\n\n round\n end"
] | [
"0.63192487",
"0.61587685",
"0.61230594",
"0.61190504",
"0.6044818",
"0.60241485",
"0.6006971",
"0.59786767",
"0.59680194",
"0.5951971",
"0.5836244",
"0.58284307",
"0.5783559",
"0.5782174",
"0.56847674",
"0.5656575",
"0.5648067",
"0.56467956",
"0.5631016",
"0.56278706",
"0.56202114",
"0.5602409",
"0.5601724",
"0.55912983",
"0.55912983",
"0.55912983",
"0.55912983",
"0.55862993",
"0.55862993",
"0.55836993",
"0.5575826",
"0.5561412",
"0.55562466",
"0.55541384",
"0.5546797",
"0.55376697",
"0.55244255",
"0.550903",
"0.5503114",
"0.54918647",
"0.54598904",
"0.54549074",
"0.5439065",
"0.5437287",
"0.5426969",
"0.54242855",
"0.5421849",
"0.5421632",
"0.5417589",
"0.54119515",
"0.54113483",
"0.53991884",
"0.53945255",
"0.53898954",
"0.5383595",
"0.5383595",
"0.537925",
"0.53733075",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.536981",
"0.53692967",
"0.5366677",
"0.53527313",
"0.5348636",
"0.5341171",
"0.53363436",
"0.53357726",
"0.5332712",
"0.53305805",
"0.53177595",
"0.5315305",
"0.53101534",
"0.53085554",
"0.5300568",
"0.5300304",
"0.5293947",
"0.5293207",
"0.52894676",
"0.52810407",
"0.528001",
"0.52783465",
"0.5274177",
"0.5270614",
"0.52699965",
"0.5261114",
"0.5258684",
"0.5242459",
"0.52360183",
"0.52274615",
"0.52232116",
"0.5222325",
"0.52202636",
"0.5218945"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_quizz
@quizz = Quizz.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 user, only allow the white list through. | def quizz_params
params.require(:quizz).permit(:title, :description, :difficulty)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def allow_params_authentication!; 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 strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def allowed_params\n ALLOWED_PARAMS\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 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 expected_permitted_parameter_names; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\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 strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\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 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 safe_params\n params.require(:user).permit(:name)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def default_param_whitelist\n [\"mode\"]\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 strong_params\n params.require(:community).permit(param_whitelist)\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 allowed_params\n params.require(:allowed).permit(:email)\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\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 permitted_params\n []\n end",
"def check_params; true; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def valid_params?; 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 sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def check_params\n true\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def valid_params_request?; end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def less_active_member_params\n clean_params = params.require(:less_active_member).permit(:surname, :given_name, :current_address, :new_address, :new_phone, :reference, :new_note, :resources, tag_list: [])\n clean_params.merge!({current_user_id: current_user.id}) unless current_user.nil?\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def backend_user_params\n params.permit!\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 update_sanitized_params\n\t\t\tdevise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}\n\t\tend",
"def list_params\n params.permit(:name)\n end",
"def user_params\n params.require(:member).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\n end",
"def valid_for_params_auth?; end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.require(:user).permit!\n end",
"def user_params\n params.require(:user).permit!\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 filtered_parameters; end",
"def user_params\n end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\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 user_params\n params.require(:user).permit(:first_name, :name, :email, :password, :password_confirmation, :role, :list_ids => [])\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def whitelisted_args\n args.select &:allowed\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 user_params\r\n end",
"def user_params\n params.require(:user).permit(:admin)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def white_listed_parameters\n params\n .require(:department)\n .permit(:department_name)\n .merge(params.permit(:company_id))\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n params[:user].permit(:name)\n end",
"def devise_parameter_sanitizer; end",
"def user_params\nend",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def 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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def people_params\n params.require(:people).permit(:name, :cpf, :cellPhone, :borned, :office, security:[])\n end",
"def permitted?; end",
"def user_access_params\n params.require(:user_access).permit(:username, responsibility_ids:[])\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def list_params\n params.permit(:list_name)\n end",
"def filter_params\n\t\treturn params[:voter].permit(:name_for_filter, :election_id_for_filter)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def quote_params\n params.permit!\n end",
"def additional_permitted_params\n []\n end",
"def authorize_params\n super.tap do |params|\n options[:authorize_options].each do |k|\n params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])\n end\n end\n end"
] | [
"0.7332092",
"0.70251495",
"0.69912875",
"0.6979885",
"0.68902034",
"0.67937815",
"0.6717389",
"0.6653924",
"0.6650712",
"0.6601131",
"0.65513307",
"0.65462005",
"0.6537341",
"0.65337366",
"0.65147483",
"0.6470548",
"0.64448416",
"0.6432828",
"0.64229804",
"0.6414409",
"0.63647574",
"0.63507634",
"0.6324365",
"0.6313649",
"0.6286108",
"0.6285465",
"0.6282848",
"0.6279177",
"0.6240797",
"0.62362534",
"0.62292564",
"0.61912656",
"0.61912656",
"0.6189768",
"0.6176846",
"0.6169328",
"0.6165904",
"0.61277014",
"0.6109583",
"0.60971856",
"0.60953647",
"0.60929394",
"0.6084904",
"0.6066054",
"0.6060144",
"0.60585475",
"0.604413",
"0.60420424",
"0.6040651",
"0.6040651",
"0.6040651",
"0.60202545",
"0.6018903",
"0.6015718",
"0.6009038",
"0.6009038",
"0.6000409",
"0.59990317",
"0.5994294",
"0.5991753",
"0.59873545",
"0.5979792",
"0.5976877",
"0.5972252",
"0.59717345",
"0.59696627",
"0.595182",
"0.59441555",
"0.59425265",
"0.5941868",
"0.59349895",
"0.59316885",
"0.5926872",
"0.5921173",
"0.59159976",
"0.5913945",
"0.5905555",
"0.5903365",
"0.5901272",
"0.5900508",
"0.5887081",
"0.5881679",
"0.5880818",
"0.5877123",
"0.58757603",
"0.5864829",
"0.58638144",
"0.58626217",
"0.58605206",
"0.5858842",
"0.5851922",
"0.5845657",
"0.5845158",
"0.58428746",
"0.58428746",
"0.58396846",
"0.5829662",
"0.58249843",
"0.5824052",
"0.5822456",
"0.5820555"
] | 0.0 | -1 |
init :: [string] > void | def init(args)
if (args.length != 1)
puts usage
return
end
command = args[0].downcase
if (command == "mount")
prompt_with_and_then("Mount", :list_mountable, :mount_command)
elsif (command == "unmount")
prompt_with_and_then("Unmount", :list_mounted, :unmount_command)
else
puts usage
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\r\n @strings = Array.new\r\n end",
"def initialize(z=\"\") end",
"def initialize(p0=\"\") end",
"def init(*args)\r\n \tunless args.nil? || args.empty?\r\n \t\t@ASCII = '0'\r\n \t\t@ASCII = args[0][:ASCII] if !args[0][:ASCII].nil?\r\n \t\t@things = []\r\n \t\t@owner = args[0][:owner] if !args[0][:owner].nil?\r\n \tend\r\n end",
"def initialize(init_concept=nil)\n if init_concept.nil?\n @list = Array.new\n else\n init_concept = Converter.rsc_2_str(init_concept)\n @list = Array[Array[init_concept]]\n end\n empty_temp\n end",
"def initialize array_of_items\n\tend",
"def init(string)\n return string[0]\nend",
"def initialize()\n\t@list_arr\t= []\nend",
"def initialize(string=\"\", mode=0) end",
"def initialize(*); end",
"def init; @entries = [] end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize; @ary = []; end",
"def initPlayers(names) # (names : string[]) : void\n names.each do |k|\n @players << Player.new(k)\n end\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize(name, substring = T.unsafe(nil)); end",
"def initialize(words=nil)\n if words.nil?\n @words = Array.new\n else\n @words = words\n end\n end",
"def initialize(*args)\n params_init # paramable\n array_init(*args)\n end",
"def initialize\r\n\t\t# another way of making an array\r\n\t\t@words = %w\"learning lollipop education image computer mobile january february friday flower beauty light earth machine book\r\n\t\tnews yahoo google internet bangladesh india america cricket football friday sunday sunny\"\r\n\t\t@chances_left = 5\r\n\r\n\t\t@game_over = false\r\n\r\n\t\t\r\n\tend",
"def initialize (names= \"World\")\n @names = names\n end",
"def initialize(str=nil)\n \t@name = str\n \t@songs = []\n \t@genre = []\n \t@@artists.push(self)\n end",
"def initialize(at_init)\n @at_init = at_init.to_s # quelquefois, on envoie un nombre (annulation)\n parse\n end",
"def initialize(names = \"World\")\n\t\t@names = names\n\tend",
"def initialize(names = 'World')\n @names = names\n end",
"def initialize()\n @contenu = [\n [\"t\", \"i\", \"c\"],\n [\"t\", \"a\", \"c\"],\n [\"t\", \"o\", \"e\"]\n ]\n end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize() end",
"def init\n @words = dictionary.sample(20).map(&:strip)\n end",
"def initialize(images,characters)\r\n\t\t@images,@characters=images,characters\r\n\tend",
"def initialize(*rest) end",
"def init; end",
"def init\n\n end",
"def initialize(file_arr=[])\n\t\t@files = [\"-\"]\n\t\t@files = file_arr unless file_arr.empty?\n\t\treset\n\tend",
"def initialize *parts\n @parts = []\n @parts.concat parts\n end",
"def init\n # import text files\n @target_array = acquire_target_array\n @element_array_list = acquire_element_array_list\n\n # set count\n @init_count = acquire_element_init_count(@element_array_list)\n @temp_count = acquire_element_temp_count(@element_array_list)\n\n self\n end",
"def initialize(string)\t\n\t\tself.string = string\n\tend",
"def initialize(str = 'Hello World!')\n @str = str\n # creating hash\n @letters = Hash.new(0)\n end",
"def initialize words\n @word_list = words\n end",
"def test_initialize\n rm = [@g.ruby_mines['Enumerable Canyon'].name, @g.ruby_mines['Monkey Patch City'].name, @g.ruby_mines['Nil Town'].name, @g.ruby_mines['Matzburg'].name, @g.ruby_mines['Hash Crossing'].name, @g.ruby_mines['Dynamic Palisades'].name]\n assert_equal [1, 1, ['Enumerable Canyon', 'Monkey Patch City', 'Nil Town', 'Matzburg', 'Hash Crossing', 'Dynamic Palisades'], 1, 0], [@g.seed, @g.num_prospectors, rm, @g.num_turns, @g.done]\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize(*args); end",
"def init\n\nend",
"def initialize(list_as_string)\n @list = list_as_string.split(/,/)\n end",
"def initialize(string = \"hello\")\n\t\t@string = string\n\tend",
"def init_create\n init_dict()\n @grid = Array.new(self.size) { Array.new(self.size, nil) }\n init_first_word()\n self.finished = false\n end",
"def initialize(arr = [])\n\t\t@root = nil\n\t\tarr.shuffle!\n\t\t\n\t\tarr.each do |value|\n\t\t\tinsert(value)\n\t\tend\n\tend",
"def local_init(args)\n end",
"def initialize(${1:args})\n ${1:$\n(mapconcat\n '(lambda (x) (concat \"@\" x \" = \" x))\n (split-string text \", \")\n (concat \"\\n\" (make-string (current-column) 32)))\n}$0\nend",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def initial=(_arg0); end",
"def initialize\n\n\nend",
"def initialize(name) end",
"def initialize(components=[])\n shell = components[0].split(\" \")\n @n = shell[0].to_i\n first_character = shell[1].split(//).first.downcase.to_sym\n \n row_components = components.reject.with_index{|c, index| index == 0}\n @rows = row_components.map{|component| BasisSetRow.new(first_character, component)}\n end",
"def init(array)\n if array.include?(1)\n testPowerEfficient\n puts @@SEPARATOR\n end\n \n if array.include?(2)\n testBetaPowerEfficient\n puts @@SEPARATOR\n end\n \n if array.include?(3)\n testSpaceCity\n puts @@SEPARATOR\n end\n \n if array.include?(4)\n testNumericDamage\n puts @@SEPARATOR\n end\n \n if array.include?(5)\n testSpecificDamage\n puts @@SEPARATOR\n end\n end",
"def test_2_initialize_build_word_array_with_placeholder_underscores\r\n $build_word = []\r\n $word = \"testing\"\r\n results = initialize_word()\r\n assert_equal([\"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\"], $build_word)\r\n end",
"def initialize\n\n\n\n end",
"def initialize(list)\n @list = list\n end",
"def initialize(content); end",
"def initialize(content); end",
"def initialize arr = []\n super arr\n end",
"def test_initialize\n assert_equal([\"test\", \"tested\"], @tester.array_to_split)\n end",
"def initialize(string)\n @string = string\n end",
"def initialize\n @array = []\n end",
"def initialize(*parts)\n @parts = parts.to_a.flatten\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each {|ele| add ele}\n\n # Fill in the rest of the initialize method here.\n \n # What should you do with each element of the incoming array?\n end",
"def initialize\n\t\t\n\tend",
"def initialize(array)\n @array = array\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each{|new_ele| add new_ele} # PLEASE EXPLAIN IN SECTION\n # Fill in the rest of the initialize method here.\n # What should you do with each element of the incoming array?\n end",
"def init_data\n end",
"def initialize\nend",
"def initialize name=\"null\",gender=\"null\",regno=0,branch=\"null\"\n@name,@gender,@regno,@branch=name,gender,regno,branch\nend",
"def initialize(string)\n self.string = string\n end",
"def initialize(string)\n self.string = string\n end",
"def initialize(string)\n self.string = string\n end",
"def initialize(list_title)\n @title = list_title\n @items = Array.new\n end",
"def initialize(chars)\n #if the valid pegs contain chars --> then set it to @ PEG but char has to be upcase\n if Code.valid_pegs?(chars) #if the arr contains valid pegs, should equal true\n @pegs = chars.map! {|char| char.upcase}\n #chars is an ARR so you can map over it to modify it\n else\n raise \"pegs are not valid\"\n end\n end",
"def initialize(name) #give them a name and songs array right off the bat. They will have many songs\n @name = name\n @songs = []\n end",
"def initialize_from_string(string)\n raise NotImplementedError\n end",
"def at_init\n\n\t\tend",
"def initialize(*args)\n if args.size == 1 and (str=args[0]).is_a? String\n super()\n self.aton(str)\n else\n super(*args)\n end\n end",
"def initialize(string, repositories: [])\n @string = string\n @repositories = repositories\n end"
] | [
"0.74555504",
"0.6888787",
"0.67866904",
"0.6751705",
"0.6611131",
"0.6597892",
"0.65366143",
"0.6486342",
"0.6468287",
"0.643961",
"0.64288414",
"0.64099824",
"0.64099824",
"0.64099824",
"0.64099824",
"0.64040923",
"0.63169944",
"0.63044506",
"0.63044506",
"0.63044506",
"0.6270511",
"0.62542707",
"0.62507236",
"0.6250444",
"0.62316984",
"0.6229363",
"0.62174535",
"0.62024933",
"0.6199293",
"0.61929274",
"0.61699104",
"0.61699104",
"0.61699104",
"0.61699104",
"0.61699104",
"0.6151562",
"0.61366105",
"0.61294717",
"0.61165285",
"0.61035365",
"0.6100587",
"0.60976034",
"0.60798484",
"0.60746145",
"0.6074129",
"0.60445464",
"0.6037285",
"0.6031855",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6009771",
"0.6006796",
"0.5978779",
"0.59782976",
"0.5968421",
"0.59582955",
"0.5942865",
"0.5930912",
"0.59291416",
"0.59195495",
"0.59195495",
"0.5908379",
"0.5906169",
"0.5902883",
"0.58979976",
"0.5896412",
"0.58792216",
"0.58756334",
"0.58660835",
"0.58573496",
"0.58573496",
"0.58532786",
"0.58458155",
"0.58432794",
"0.5841885",
"0.5837115",
"0.58335865",
"0.58330196",
"0.5827478",
"0.5826661",
"0.58200526",
"0.58193564",
"0.58182913",
"0.5816519",
"0.5816519",
"0.5816519",
"0.58047026",
"0.57951194",
"0.5794074",
"0.57932156",
"0.5792683",
"0.5784639",
"0.5777519"
] | 0.0 | -1 |
prompt_with_and_then :: (string, symbol, symbol) > void | def prompt_with_and_then(prompt, items, action)
choice = `echo "#{self.send(items)}" | theme-dmenu -p "#{prompt}"`
if (choice.length > 0)
out, err, code = Open3.capture3(self.send(action, "#{mountable_path}/#{choice}"))
if (err.length > 0)
`notify-send -u critical Easymount "#{err}"`
else
`notify-send Easymount "#{out}"`
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt(string)\n puts \"==> #{string}\"\nend",
"def confirm(prompt); end",
"def prompt(str)\n puts \"=> #{str}\"\nend",
"def prompt(arg)\n puts(arg)\n gets.chomp\nend",
"def prepare_input(prompt); end",
"def prompt(question)\n puts question\n gets.chomp\nend",
"def ask_for_(thing)\n puts \"What's the #{thing}?\"\n gets.chomp\n end",
"def prompt(word)\n puts \"Enter a #{word}:\"\nend",
"def prompt\n puts\"=>\"\n gets.chomp\nend",
"def prompt(string)\n puts \"=> #{string}\"\n gets.chomp\nend",
"def prompt_user\n puts \"Type \\'h\\' to hit or \\'s\\' to stay\"\nend",
"def prompt(text, prompt_symbol = \">>\")\n print \"#{text} #{prompt_symbol} \"\n STDOUT.flush\n @last_response = gets\nend",
"def prompt(text)\n puts \"==> #{text}\"\nend",
"def prompt; end",
"def prompt; end",
"def prompt; end",
"def prompt; end",
"def prompt(message)\n puts\"=> #{message}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt(string)\n puts \">> #{string}\"\nend",
"def prompt\n puts \"Enter a number or bye\"\nend",
"def ask( prompt )\n print prompt\n gets.chomp\nend",
"def prompt\n function = prompt_function\n a, b = prompt_numbers\n return a, b, function\nend",
"def prompt\n print yield\n gets.chomp\nend",
"def prompt_greeting(namehere)\n print(namehere)\n gets\nend",
"def prompt(var, text=nil)\n set(var) do\n Capistrano::CLI.ui.ask \"#{text||var} : \"\n end\n end",
"def prompt(input)\n Kernel.puts(\"=> #{input}\")\nend",
"def prompt(text)\n puts \">> \" + text\nend",
"def prompt (message)\n puts (\"=> #{message}\")\nend",
"def prompt(question, default: nil)\n answer = ask(question) \n answer.empty? ? default : answer\nend",
"def prompt(text)\n print \">> \" + text\nend",
"def prompt(text)\n Kernel.puts(\"=> #{text}\")\nend",
"def ask_user_for(something)\n puts \"What is the recipe #{something} ?\"\n return gets.chomp\n end",
"def ask_first_name\n puts \"\\n\" + \"====\" + \"\\n\" + \"ASK FIRST NAME\" + \"\\n\" + \"====\"\n puts \"Quel est ton nom?\" \nend",
"def prompt_user(message)\n puts message\n print \">> \"\n gets.chomp\nend",
"def prompt_user\n puts \"Type 'h' to hit or 's' to stay\"\nend",
"def prompt_user\n puts \"Type 'h' to hit or 's' to stay\"\nend",
"def prompt_user\n puts \"Type 'h' to hit or 's' to stay\"\nend",
"def prompt_user(msg)\n puts \" => #{msg}\"\nend",
"def prompt\n gets.strip\nend",
"def prompt (message)\r\n puts \"==> #{message}\"\r\nend",
"def prompt(sentence)\n puts \">> #{sentence}\"\nend",
"def prompt(message)\n print message\n gets.chomp\nend",
"def prompt(label)\n print \"#{label}: \"\n STDIN.gets\nend",
"def prompt(mess) # prompt for all questions\n puts \"==> #{mess}\"\nend",
"def prompt(message)\n puts(\"#{message}\")\nend",
"def prompt(message)\r\n puts(\"=> #{message}\")\r\nend",
"def prompt(message)\n puts (\"=> #{message}\")\nend",
"def prompt(message)\n puts (\"=> #{message}\")\nend",
"def prompt(message)\n puts (\"=> #{message}\")\nend",
"def prompt(message)\r\n puts \"=> #{message}\"\r\nend",
"def prompt(message)\r\n puts \"=> #{message}\"\r\nend",
"def prompt(message)\r\n puts \"=> #{message}\"\r\nend",
"def prompt(message)\r\n puts \"=> #{message}\"\r\nend",
"def prompt(message)\r\n puts \"=> #{message}\"\r\nend",
"def prompt(digits, what, name, args = {}, &action)\n @scoped_state.sayings = [] if @scoped_state.sayings.nil?\n @scoped_state.sayings << what\n press(digits, name, args, &action)\n end",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message)\n puts \"=> #{message}\"\nend",
"def prompt(message, valid_options)\n if valid_options\n answer = get_stdin(\"#{message} #{valid_options.to_s.gsub(/\"/, '').gsub(/, /,'/')} \") while !valid_options.include?(answer)\n else\n answer = get_stdin(message)\n end\n answer\nend",
"def prompt_user_song\n puts \"Please enter a song name or number:\"\nend",
"def prompt(msg)\n puts \" => #{msg}\"\n gets.chomp\nend",
"def prompt_function\n puts \"Add, subtract, multiply, divide?\"\n return gets.chomp.downcase #returns answer to above Q for: def prompt\nend"
] | [
"0.6979912",
"0.695627",
"0.6946157",
"0.69441956",
"0.6927728",
"0.6919798",
"0.68738115",
"0.686397",
"0.68070906",
"0.68022656",
"0.67956305",
"0.6787463",
"0.6772956",
"0.677013",
"0.677013",
"0.677013",
"0.677013",
"0.6706561",
"0.66919327",
"0.66919327",
"0.66919327",
"0.66919327",
"0.66919327",
"0.66919327",
"0.66839015",
"0.66817015",
"0.6666002",
"0.6663534",
"0.6656597",
"0.66399336",
"0.6635355",
"0.6626838",
"0.66104424",
"0.66034305",
"0.6595909",
"0.659563",
"0.6578343",
"0.65714014",
"0.6570528",
"0.65673727",
"0.65673727",
"0.65673727",
"0.65509975",
"0.6545997",
"0.65427595",
"0.65348315",
"0.6530531",
"0.6529871",
"0.6529603",
"0.65280455",
"0.6520392",
"0.65192556",
"0.65192556",
"0.65192556",
"0.65188855",
"0.65188855",
"0.65188855",
"0.65188855",
"0.65188855",
"0.6518473",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.65144306",
"0.6514058",
"0.6513344",
"0.65125495",
"0.651148",
"0.65093976",
"0.65044075"
] | 0.6561035 | 42 |
mount_command :: string > string | def mount_command(path)
"udisksctl mount --block-device #{path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mountstring\n mount = nil\n name = \"yaytest\"\n path = tmpdir\n assert_nothing_raised {\n mount = Puppet::Network::Handler.fileserver::Mount.new(name, path)\n }\n\n assert_equal(\"mount[#{name}]\", mount.to_s)\n end",
"def mount_path=(_arg0); end",
"def cmd(string)\n @commands << string\n end",
"def sh command_string\n with_80_columns do\n `2>&1 #{command_string}`\n end\nend",
"def command(command)\n cmd = \"#{@vzctl} exec2 #{@ctid} \"\n cmd << command\n execute(cmd)\n end",
"def sh cmd\n puts cmd\n put `#{cmd}`\nend",
"def issue_command(str)\n puts str\nend",
"def command(type)\n end",
"def execute(command)\n end",
"def execute_command(command)\n %x{#{command}}\n end",
"def execute(command)\r\n system \"#{command}\"\r\nend",
"def mount(name, root_dev)\n puts \"Mounting KVM device: #{root_dev}\"\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n unless(system(\"mount | grep #{mount_loc}\"))\n FileUtils.mkdir_p(mount_loc)\n if(system(\"mount #{root_dev} #{mount_loc}\"))\n mount_loc\n else\n raise \"Failed to mount #{root_dev} to #{mount_loc}\"\n end\n else\n puts \"Device already mounted (#{mount_loc})\"\n mount_loc\n end\nend",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def call(*command); end",
"def execute_command(command)\n end",
"def execute_command(command)\n end",
"def execute(command)\n system \"#{command}\" # rubocop:disable UnneededInterpolation\nend",
"def spawn(cmd)\n puts \">> #{cmd}\"\n\n cmd += ' 2>&1'\n PTY.spawn cmd do |r, w, pid|\n begin\n r.sync\n r.each_char { |chr| STDOUT.write(chr) }\n rescue Errno::EIO => e\n # simply ignoring this\n ensure\n ::Process.wait pid\n end\n end\n abort \"#{cmd} failed\" unless $? && $?.exitstatus == 0\nend",
"def run_command(command)\n `#{command}`\nend",
"def execute(command)\n system \"#{command}\"\nend",
"def execute(command)\n system \"#{command}\"\nend",
"def command(string)\n @request_id = rand(1000)\n @string1 = string\n @string2 = TRAILER\n @command_type = COMMAND_EXEC\n\n @packet_size = build_packet.length\n\n return self\n end",
"def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend",
"def shell_command(command)\n command.map {|word| shell_single_word(word) }.join(' ')\n end",
"def split_commands(cmd_line); end",
"def run_as_system(command)\n Strainer.ui.debug 'Using %x'\n %x{#{command}}\n end",
"def execute_command(command)\n raw(*command)\n end",
"def shell_commands(cmd, args); end",
"def init(args)\n if (args.length != 1)\n puts usage\n return\n end\n\n command = args[0].downcase\n if (command == \"mount\")\n prompt_with_and_then(\"Mount\", :list_mountable, :mount_command)\n elsif (command == \"unmount\")\n prompt_with_and_then(\"Unmount\", :list_mounted, :unmount_command)\n else\n puts usage\n end\nend",
"def command(type, name, data = nil)\n command = \"#{type} /#{name}\"\n command += \" #{data}\" if data\n \n STDOUT.puts(command)\n end",
"def formulate_command\n @command\n end",
"def shell(cmd)\n `#{cmd}`\n end",
"def shell(cmd)\n `#{cmd}`\n end",
"def mount options = {}\n opts = {\n :force_readonly => false\n }.merge!(options)\n args = []\n args << 'readOnly' if opts[:force_readonly]\n args << opts[:mountpoint] if opts.has_key?(:mountpoint)\n args << self.dev_node\n diskutil 'mount', *args\n end",
"def command\n @command ||= Mixlib::ShellOut.new from_instructions\n end",
"def unmount_command(path)\n \"udisksctl unmount --block-device #{path}\"\nend",
"def command\n if @files.length > 0 && @dirs.length > 0\n raise 'watching files AND directories is not supported'\n elsif @files.length > 0\n \"echo #{@files.join(' ')} | #{@@entr} #{@command}\"\n elsif @dirs.length > 0\n \"echo #{@dirs.join(' ')} | #{@@entr} -d #{@command}\" \n else\n raise 'must specify files or dirs to monitor' \n end\n end",
"def raw\n orig_command = \"fsctl #{@command}\"\n end",
"def out(command)\n assert(system(command))\n end",
"def mount_path; end",
"def mountNi(mountString)\n MountTab.instance.add(mountString)\nend",
"def shell_commands(cmd, *args); end",
"def pipe_command(command)\n case command\n when :exit\n \"\\x00\"\n when :execute\n \"\\x01\"\n end\n end",
"def mount(opts)\n ct = lxc_ct(opts[:id])\n\n r, w = IO.pipe\n\n pid = ct.attach(stdout: w) do\n r.close\n\n begin\n src = File.join(opts[:shared_dir], opts[:src])\n\n if !Dir.exist?(opts[:shared_dir])\n puts \"error:Shared dir not found at: #{opts[:shared_dir]}\"\n\n elsif !Dir.exist?(src)\n puts \"error:Source directory not found at: #{src}\"\n\n else\n FileUtils.mkpath(opts[:dst])\n Mount::Sys.move_mount(src, opts[:dst])\n puts 'ok:done'\n end\n\n rescue => e\n puts \"error:Exception (#{e.class}): #{e.message}\"\n\n ensure\n STDOUT.flush\n end\n end\n\n w.close\n\n line = r.readline\n Process.wait(pid)\n r.close\n log(:warn, ct, \"Mounter exited with #{$?.exitstatus}\") if $?.exitstatus != 0\n\n i = line.index(':')\n return error(\"invalid return value: #{line.inspect}\") unless i\n\n status = line[0..i-1]\n msg = line[i+1..-1]\n\n if status == 'ok'\n ok\n\n else\n error(msg)\n end\n end",
"def shell(*) end",
"def command(command)\n transport.command(command) do |out|\n if out =~ %r{^%}mo || out =~ %r{^Command rejected:}mo\n # strip off the command just sent\n error = out.sub(command, '')\n Puppet.err _(\"Error while executing '%{command}', device returned: %{error}\") % { command: command, error: error }\n end\n end\n end",
"def cmd(command)\n\t\tbegin\n\t\t\t`#{command}`\n\t\trescue Exception => e\n\t\t\te.to_s\n\t\tend\n\tend",
"def get_assign_command_for_device(device)\n if device.match(@assignable_disk_regex)\n \"assign letter=#{device[0,1]}\"\n elsif device.match(@assignable_path_regex)\n \"assign mount=\\\"#{device}\\\"\"\n end\n end",
"def mount_device(device, mount_point, owner, group, fs_type)\n puts `echo #{device} #{mount_point} #{fs_type} noatime 0 0|tee -a /etc/fstab`\n puts \"Making mount directory #{mount_point} for #{device}\"\n puts `mkdir -p #{mount_point}`\n puts \"Mounting #{device} at #{mount_point}\"\n puts `mount #{mount_point}`\n puts \"Setting ownership on #{mount_point} to #{owner}\"\n puts `chown #{owner}:#{owner} #{mount_point}`\n end",
"def cmd(command, *arguments) Command.send(command.to_sym, *arguments) end",
"def sh(cmd)\n `#{cmd}`\nend",
"def cmd(str)\n\t\t@pipe.puts str\n\tend",
"def cmd; end",
"def cmd!(command)\n self << command\n end",
"def command\n consume 1, :command\n end",
"def command(command, *args)\n @shell.command(command, *args)\n end",
"def register_command cmd\n $commandlist << cmd\nend",
"def command(command_text)\n @command_text = command_text\n end",
"def spawn(cmd)\n log \">> #{cmd}\"\n\n cmd += ' 2>&1'\n output = \"\"\n PTY.spawn cmd do |r, _w, pid|\n begin\n r.sync\n r.each_char do |chr|\n STDOUT.write(chr) unless @options[:quiet]\n output << chr\n end\n rescue Errno::EIO\n # simply ignoring this\n ensure\n ::Process.wait pid\n end\n end\n abort \"#{cmd} failed, exit code #{$? && $?.exitstatus}\" unless $? && $?.exitstatus == 0\n\n output.strip\n end",
"def esx_cmd(command)\n cmd = \"#{BIN_LOCATION}/tty_expect -u #{@user} -p #{@pass} #{command}\"\nend",
"def command command_string\n connection.command self.id, nil, command_string\n end",
"def sh(command)\n provider.sh command\n end",
"def create_host_cmd(options,passwd)\n hammer_cmd = \"hammer\"\n if options[:debug] == true\n hammer_cmd = hammer_cmd + \" --debug\"\n end\n if passwd !=nil\n hammer_cmd = hammer_cmd + \" --password #{passwd}\"\n end\n hammer_cmd = hammer_cmd + \" host create --name #{options[:name]}\"\n if options[:build] == true\n hammer_cmd = hammer_cmd + \" --build true\"\n else\n hammer_cmd = hammer_cmd + \" --build false\"\n end\n hammer_cmd = hammer_cmd + \" --hostgroup-id #{options[:host_group]}\"\n hammer_cmd = hammer_cmd + \" --architecture-id #{options[:arch]}\"\n hammer_cmd = hammer_cmd + \" --operatingsystem-id #{options[:os]}\"\n hammer_cmd = hammer_cmd + \" --medium-id #{options[:media]}\"\n hammer_cmd = hammer_cmd + \" --partition-table-id #{options[:ptable]}\"\n hammer_cmd = hammer_cmd + \" --compute-resource-id #{options[:compute_resource]}\"\n hammer_cmd = hammer_cmd + \" --compute-attributes guest_id='#{options[:guest_type]}',cpus=#{options[:cpus]},memory_mb=#{options[:memory]},cluster='#{options[:cluster]}',path='#{options[:path]}',start=#{options[:start]}\"\n if options[:nic_ip] != nil\n hammer_cmd = hammer_cmd + \" --ip #{options[:nic_ip]}\"\n end\n if options[:nic_mac] != nil\n hammer_cmd = hammer_cmd + \" --mac #{options[:nic_mac]}\"\n end\n hammer_cmd = hammer_cmd + \" --interface=compute_type=#{options[:nic_type]},compute_network=#{options[:nic_network]},name=#{options[:name]},primary=true,identifier=#{options[:nic_name]},managed=#{options[:nic_managed]},provision=true\"\n hammer_cmd = hammer_cmd + \" --volume datastore=#{options[:volume_datastore]},size_gb=#{options[:volume_size]},name=#{options[:name]}\"\n\n return hammer_cmd\nend",
"def exec(command)\n @commands << %{write text \"#{command}\"}\n end",
"def execute(command)\n system(command)\n end",
"def command(command)\n IO.pipe do |read_io, write_io|\n pid = Process.spawn(command, :in => \"/dev/tty\", :out => write_io)\n Process.wait(pid)\n raise \"Command failed: #{command.inspect}\" unless $?.success?\n write_io.close\n read_io.read\n end\n end",
"def command\n device = \"\"\n if @device != -1\n device = \"--device #{@device.to_s}\"\n end\n blocks = \"\"\n if @include_blocks\n blocks = \"--show_blocks\"\n end\n \"%s --size %d --duration %d --randsleep %s %s\" % [@executable, @input_size,\n @duration, blocks, device]\n end",
"def mount_usb_drive\n execute_system_cmd('mount /home/pi/compartida/musica/discousb')\n end",
"def shell_command(command, context='bash')\n fail \"shell_command api not supported on #{node.product_id}\" unless\n node.product_id[/N3K|N3K.*-F|N9K.*-F|N9K/]\n unless context == 'bash' || context == 'guestshell'\n fail \"Context must be either 'bash' or 'guestshell'\"\n end\n config(\"run #{context} #{command}\")\n end",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def mount(path, options)\n #noop\n end",
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def run_command_via_connection(command)\n command = command.shelljoin if command.is_a? Array\n command = ['sh', '-c', command]\n res = lxd.execute(command)\n CommandResult.new res.stdout, res.stderr, res.exitstatus\n end",
"def test_ls\n cmd=ShellCommand.new(:cmd=>\"ls\")\n assert(!cmd.run?)\n assert(!cmd.success?)\n assert(cmd.run)\n assert(cmd.run?)\n if cmd.success?\n refute_equal(\"\", cmd.output)\n else\n refute_equal(\"\", cmd.error)\n end\n end",
"def system(cmd, *rest) end",
"def propagate(mnt)\n tmp = Digest::SHA2.hexdigest(mnt.mountpoint)\n\n # Bind-mount the new mount into the shared directory\n host_path = File.join(path, tmp)\n Dir.mkdir(host_path)\n syscmd(\"mount --bind \\\"#{mnt.fs}\\\" \\\"#{host_path}\\\"\")\n\n # Move the mount inside the container to the right place\n begin\n ContainerControl::Commands::Mount.run!(\n ct,\n shared_dir: File.join('/', mountpoint),\n src: tmp,\n dst: File.join('/', mnt.mountpoint)\n )\n rescue ContainerControl::Error => e\n log(:warn, ct, \"Failed to mount #{mnt.mountpoint} at runtime: #{e.message}\")\n end\n\n syscmd(\"umount \\\"#{host_path}\\\"\")\n Dir.rmdir(host_path)\n end",
"def command\n return nil unless commands\n\n # Map commands to template & chain\n commands.map(&method(:template_command_with_output_cleaned)).join(' && ')\n end",
"def `(cmd)\n $shell_result\n end",
"def exec!(command, status: T.unsafe(nil), &block); end",
"def execute(command, opts = T.unsafe(nil), command_hash = T.unsafe(nil)); end",
"def send_command(command) \n command_str = command.to_encoded_str\n if @out_command_hasher\n send_frame command_str + @out_command_hasher.hash(command_str)\n else\n send_frame command_str\n end\n end",
"def _unsafe_system(command)\n\n ### ###\n ### XXX - SECURITY ###\n ### ###\n\n if command =~ /(\\||\\;|\\`)/\n #raise \"Illegal character\"\n _log_error \"FATAL Illegal character in #{command}\"\n return\n end\n\n `#{command}`\n end",
"def commands; end",
"def execute_command(command)\n @stdin.puts command\n end",
"def system(command, *opts)\n if opts.empty?\n\tif command =~ /\\*|\\?|\\{|\\}|\\[|\\]|<|>|\\(|\\)|~|&|\\||\\\\|\\$|;|'|`|\"|\\n/\n\t return SystemCommand.new(@shell, find_system_command(\"sh\"), \"-c\", command)\n\telse\n\t command, *opts = command.split(/\\s+/)\n\tend\n end\n SystemCommand.new(@shell, find_system_command(command), *opts)\n end",
"def format_mount(partition, mount)\n\n # Partitions that we already have mounts set for.\n return nil if partition == '/dev/mapper/rootvg-slash'\n return nil if partition == '/dev/mapper/rootvg-var'\n return nil if partition == '/dev/mapper/rootvg-tmp'\n\n mount\nend",
"def test_assembles_only_command_name_in_to_cmd_method\n Crd::Flex::Command.new 'mxmlc' do |c|\n assert_equal( 'mxmlc', c.to_cmd )\n end\n end",
"def command_start=(_arg0); end",
"def command_start=(_arg0); end",
"def command_start=(_arg0); end",
"def run(command)\n puts command\n `#{command}`.tap &method(:puts)\nend",
"def execute(command) # rubocop:disable Lint/UnusedMethodArgument\n end",
"def smb_cmd(cmd, rdir=nil)\n if rdir.nil?\n dir=''\n else\n dir=' -D ' + rdir\n end\n file = Tempfile.new('ruby_smbclient')\n if @hashpass\n success = system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} --pw-nt-hash #{@pass} -c '#{cmd}'#{dir} > #{file.path} 2>&1\")\n else\n success = system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} #{@pass} -c '#{cmd}'#{dir} > #{file.path} 2>&1\")\n end\n if success\n output = File.open(file.path).readlines\n else\n output=nil\n end\n file.unlink\n return output\n end",
"def mount_at(mountpoint)\n @mountpoint = mountpoint\n end",
"def command\n fail 'Not implemented.'\n end"
] | [
"0.61680084",
"0.6104018",
"0.6093119",
"0.6012799",
"0.5979571",
"0.59167814",
"0.5913823",
"0.58655703",
"0.5821163",
"0.5820151",
"0.5807807",
"0.579581",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57941616",
"0.57668674",
"0.57668674",
"0.5759353",
"0.57564896",
"0.5753192",
"0.5753134",
"0.5753134",
"0.5742696",
"0.5737997",
"0.572146",
"0.5719088",
"0.5713521",
"0.5705745",
"0.56969625",
"0.5675655",
"0.56724787",
"0.56715596",
"0.566073",
"0.566073",
"0.5657543",
"0.5653072",
"0.5629766",
"0.5625727",
"0.56220806",
"0.56088805",
"0.56066436",
"0.56062204",
"0.5600805",
"0.5594196",
"0.5588581",
"0.55825144",
"0.55824476",
"0.55708885",
"0.55585086",
"0.5545108",
"0.5541249",
"0.5540106",
"0.5533266",
"0.5518978",
"0.55168045",
"0.55140704",
"0.55091786",
"0.5507511",
"0.5496959",
"0.5492979",
"0.549017",
"0.54897094",
"0.5480768",
"0.5478178",
"0.5460843",
"0.5458708",
"0.54543334",
"0.5445133",
"0.5444987",
"0.5425664",
"0.5424973",
"0.5423496",
"0.5415333",
"0.5414309",
"0.54132146",
"0.5401736",
"0.5400092",
"0.5399724",
"0.5395463",
"0.5392914",
"0.5391882",
"0.53813815",
"0.53793114",
"0.5377602",
"0.5357367",
"0.5351808",
"0.5350381",
"0.5341796",
"0.533581",
"0.533581",
"0.533581",
"0.5334936",
"0.5333641",
"0.5323812",
"0.53234726",
"0.5322063"
] | 0.7148927 | 0 |
unmount_command :: string > string | def unmount_command(path)
"udisksctl unmount --block-device #{path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unmount(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n if(system(\"umount #{mount_loc}\"))\n true\n else\n raise \"Failed to unmount kvm drive\"\n end\nend",
"def rm(path)\n cmd 'rm', path\nend",
"def unmount(opts)\n ct = lxc_ct(opts[:id])\n\n pid = ct.attach do\n next unless Dir.exist?(opts[:mountpoint])\n\n begin\n Mount::Sys.unmount(opts[:mountpoint])\n\n rescue Errno::EINVAL\n # Not mounted, pass\n end\n end\n\n Process.wait(pid)\n\n if $?.exitstatus == 0\n ok\n\n else\n log(:warn, ct, \"Unmounter exited with #{$?.exitstatus}\")\n error('unmount failed')\n end\n end",
"def bring_down(typename, cmd)\n execute_with_fail(typename, cmd, 'to remove')\n end",
"def unmount_device( dev )\n sudo <<-SH\n if mount | grep -q '^#{dev} '; then\n umount #{dev}\n sed -r -i '\\\\|^#{dev}\\\\s|d' /etc/fstab\n fi\n SH\n end",
"def unset_command\n [grep_cmd, '&&', unset_cmd].join(' ')\n end",
"def unmount\n if !is_mounted?\n warning('dev, sys, and proc are already unmounted')\n else\n announcing 'Unmounting dev, sys, and proc' do\n dirs = %w[ dev sys proc ]\n dirs.each{|dir| cmd(\"umount -l #{$chrootdir}/#{dir}\", exit=false) }\n end\n end\n end",
"def destroy\n ret = qmgmt(['volume', 'delete', resource[:name]])\n out = Array.new\n ret.each_line { |l|\n out.push(' ' + l)\n }\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end",
"def unset(str)\n\t\t@pipe.puts \"unset #{str}\"\n\tend",
"def mount_command(path)\n \"udisksctl mount --block-device #{path}\"\nend",
"def get_docker_node_destroy_command_for(node)\n \"docker kill #{node.id}; docker rm #{node.id}\"\nend",
"def destroy\n @command.destroy\n end",
"def rm(*str)\n r\"rm #{str.join(' ')}\"\nend",
"def volume_rm\n # Allow deletion of a default volume.\n # This allows you to create custom default volumes.\n help = [\n '',\n \"Use: #{me} volume rm VOLUME\",\n '',\n \"Removes a volume created with the [#{me} volume create] command\"\n ]\n\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'rm')\n\n run \"docker volume rm #{vol}\"\n if $exit_status != 0\n puts \"FAILED [volume rm #{vol}] can't remove volume if it's in use\"\n exit failed\n end\n\nend",
"def rm_r(path)\n cmd 'rm', '-r', path\nend",
"def set_unmount_backend_config(mountconf)\n Kdbtools::Backends.umount @resource[:name], mountconf\n end",
"def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end",
"def unmount_kvm_volume(name, dev)\n unmount(name)\n disable_netblockdev(dev)\nend",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def uninstall\n command = resource_or_provider_command\n self.class.validate_command(command)\n\n command_options = [\"uninstall\", \"-y\", \"-q\", @resource[:name]]\n\n execute([command, command_options])\n end",
"def umount_dir( path , exact_path=true)\n cur_path = path.strip\n success=false\n while cur_path != \"/\"\n res = `umount #{cur_path} 2>&1`\n if $? == 0\n STDERR.puts \"#{cur_path} successfully unmounted\"\n success=true\n break\n end\n break if exact_path\n cur_path = (cur_path == \"/\" ? \"/\": cur_path.split('/')[0..-2].join('/') )\n end\n raise EBSRemoteExecException.new(nil,$?,\"Error unmounting volume holding (#{path}):\\n\"+res) unless success\n end",
"def unmount(root)\n resources.delete(root)\n end",
"def aliases\n [\n \"rm\", \"delete\", \"rm_vol\"\n ]\n end",
"def rm_rf(path)\n cmd 'rm', '-rf', path\nend",
"def dropbear path, str\n raise 'No instance' if @instance.nil?\n connect if @ssh.nil?\n\n # To make things easier on droppers, try to detect--and strip--leading\n # indentation\n min_indent = str.gsub(/[\\r\\n]+/, \"\\n\").scan(/^ */).map(&:length).min\n str = str.gsub(/^ {#{min_indent}}/, '')\n\n $log.info \"Dropping a file to #{path}:\"\n $log.info str\n\n @ssh.exec! \"sudo mkdir -p \\\"$(dirname #{shellescape path})\\\"\"\n\n channel = @ssh.exec \"sudo tee #{shellescape path} > /dev/null\"\n channel.send_data str\n channel.eof!\n\n channel.wait\n end",
"def remove_gdom_disk(options)\n vds_disk = options['name']+\"_vdisk0\"\n message = \"Information:\\tRemoving disk \"+vds_disk+\" from Virtual Disk Server\"\n command = \"ldm remove-vdisk #{vds_disk} #{options['name']}\"\n execute_command(options,message,command)\n return\nend",
"def deactivate(mountpoint)\n mnt = find_at(mountpoint)\n raise MountNotFound, mountpoint unless mnt\n\n unmount(mnt)\n end",
"def runcmd(cmd, dest)\n Chef::Log.debug(\"fb_rsync[#{dest}]: Running command: #{cmd}\")\n # Throw normal errors except on 25 which is a max-delete limit error\n s = Mixlib::ShellOut.new(cmd, :returns => [0, 25])\n s.run_command.error!\n Chef::Log.debug(\"STDOUT:\\n#{s.stdout}\")\n Chef::Log.debug(\"STDERR:\\n#{s.stderr}\")\n return s.exitstatus\nend",
"def rm_str(options, src)\n\t\targ = \"rm \" + options + \" \" + src\n\t\tputs arg\n\t\tsystem arg\n\tend",
"def delete_gdom_disk(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n client_disk = gdom_dir+\"/vdisk0\"\n message = \"Information:\\tRemoving disk \"+client_disk\n command = \"rm #{client_disk}\"\n execute_command(options,message,command)\n return\nend",
"def destroy_directory!(directory)\n system(\"trash #{directory}\")\n end",
"def unmountiso(vid)\n perform_request(:action => 'vserver-unmountiso', :vserverid => vid)\n end",
"def detachvolume\n false\n end",
"def remove_command(command, resize=true)\n @commands.delete(command)\n @item_max = @commands.size\n refresh_command(resize)\n end",
"def destroy_thing(kind, command)\n puts \"Are you sure you want to DELETE all stopped #{kind}s (y/N)?\"\n should_we_delete = gets.chomp.downcase\n if should_we_delete == 'y'\n exec command\n else\n puts \"No #{kind}s will be removed.\"\n end\nend",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def sh(cmd)\n `#{cmd}`\nend",
"def uninstall cmd=nil, &block\n @uninstall = cmd || block\n end",
"def delete_command\n name = get_param(\"name=\", \"([a-zA-Z]+)\")\n\n deleted = false\n\n if name\n @app.delete_animal(name)\n else\n puts \"Error!: A name is required to delete an animal\"\n delete_command_help()\n end\n end",
"def sh cmd\n puts cmd\n put `#{cmd}`\nend",
"def sub_remove _value=0\n send_cmd(\"sub_remove #{_value}\")\n end",
"def unmountiso(vid)\n perform_request(action: 'vserver-unmountiso', vserverid: vid)\n end",
"def remove_command\n return if !has_manage_messages_permission?\n command.event.message.delete\n end",
"def remove\n dir = Pathname.new(path)\n syscmd(\"umount -f \\\"#{dir}\\\"\", valid_rcs: [32]) # 32 = not mounted\n File.unlink(readme_path) if File.exist?(readme_path)\n dir.rmdir if dir.exist?\n end",
"def drop\n Aptly::runcmd \"aptly mirror drop #{@name.quote}\"\n end",
"def do_unmap(_device, _one_vm, _disk, _directory)\n OpenNebula.log_error(\"unmap function not implemented for #{self.class}\")\n ''\n end",
"def start_point_rm\n # Allow deletion of a default volume.\n # This allows you to create custom default volumes.\n help = [\n '',\n \"Use: #{me} start-point rm NAME\",\n '',\n \"Removes a start-point created with the [#{me} start-point create] command\"\n ]\n\n vol = ARGV[2]\n if [nil,'help'].include? vol\n show help\n exit succeeded\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'rm')\n\n unless ARGV[3].nil?\n puts \"FAILED: unknown argument [#{ARGV[3]}]\"\n exit failed\n end\n\n run \"docker volume rm #{vol} 2>&1 /dev/null\"\n if $exit_status != 0\n puts \"FAILED cannot remove start-point #{vol}. Is it in use?\"\n exit failed\n end\n\nend",
"def destroy\n output = \"oneimage delete #{resource[:name]} \", self.class.login\n `#{output}`\n end",
"def clean\n # TODO: help?\n # TODO: check for unknown args\n\n # Can give the following\n # Error response from daemon: conflict: unable to delete cfc459985b4b (cannot be forced)\n # image is being used by running container a7108a524a4d\n command = \"docker images -q -f='dangling=true' | xargs docker rmi --force\"\n run command\nend",
"def unmount_nfs_share(volume_name)\n begin\n Puppet.debug(\"%s: Unmounting volume name %s\" % [Time.now, volume_name])\n host.esxcli.storage.nfs.remove({:volumename => volume_name})\n Puppet.debug(\"%s: Unmounted volume name %s\" % [Time.now, volume_name])\n return true\n rescue => e\n log_error(\"Failed to unmount\", volume_name, e)\n end\n false\n end",
"def errout(command)\n assert(!system(command))\n end",
"def clean_command\n build_command(\"clean\")\n end",
"def shell(cmd)\n `#{cmd}`\n end",
"def shell(cmd)\n `#{cmd}`\n end",
"def rm(path)\n run_via \"rm #{path}\"\n end",
"def command(command)\n transport.command(command) do |out|\n if out =~ %r{^%}mo || out =~ %r{^Command rejected:}mo\n # strip off the command just sent\n error = out.sub(command, '')\n Puppet.err _(\"Error while executing '%{command}', device returned: %{error}\") % { command: command, error: error }\n end\n end\n end",
"def backtix cmd\n out, err = backtix2 cmd\n err.strip!\n if 0 != err.length\n raise Hipe::AppFail.new(\"failed to run system command -- #{err}\")\n end\n out\n end",
"def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend",
"def usage\n \"store delete_vol SHARE_NAME\"\n end",
"def destroy\n ret = qmgmt(['volume', 'config', 'delete', resource[:name]])\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume config delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end",
"def unset(*args, **kwargs)\n queue UnsetCommand, args, kwargs\n end",
"def m_delete\n a = source \"a\"\n sink a.delete(\"b\") # $ hasTaintFlow=a\n sink a.delete_prefix(\"b\") # $ hasTaintFlow=a\n sink a.delete_suffix(\"b\") # $ hasTaintFlow=a\nend",
"def rm?(*str)\n r?\"rm #{str.join(' ')}\"\nend",
"def erase\n runcmd 'erase'\n end",
"def down\n updown_command :detach\n end",
"def umount_and_detach_device(options={})\n detached_vol=nil\n device = get_device_mount_point(self.MountPoint)\n if(options[:device])\n STDERR.puts \"WARNING! the previously mounted device (#{device}) is different from the device we're asking to detach (#{options[:device]})\"\n device = options[:device]\n end\n begin\n umount_dir(self.MountPoint)\n rescue Exception => e\n STDERR.puts \"#{e}\\n ...continuing without unmounting\"\n end\n #detache the mounted volume\n STDERR.puts \"Detaching volume in device #{device}:\"\n begin\n detached_vol=detach_volume(device)\n\n raise EBSRemoteExecException.new(nil,$?,\"Timeout while waiting for the device to attach\") unless wait_for_detachment(device)\n rescue Exception => e\n display_exception(e, \"unmount_and_detach_device\")\n STDERR.puts \"...was the previously mounted DB directory not an EBS volume??\\n continuing without the detachment...\"\n end\n detached_vol\n end",
"def detach _args\n \"detach _args;\" \n end",
"def run_command(command)\n `#{command}`\nend",
"def sh(command)\n puts command\n system command unless dry_run\nend",
"def remount options = {}\n self.unmount\n self.mount options\n end",
"def smb_rm(filename, rdir=nil)\n if rdir.nil?\n dir=''\n else\n dir=' -D ' + rdir\n end\n file = Tempfile.new('ruby_smbclient')\n if @hashpass\n success = system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} --pw-nt-hash #{@pass} -c 'rm #{filename}'#{dir} > #{file.path} 2>&1\")\n else\n success = system(\"#{@smbclient} \\\\\\\\\\\\\\\\#{@host}\\\\\\\\#{@share} -p #{@port} -U #{@user} #{@pass} -c 'rm #{filename}'#{dir} > #{file.path} 2>&1\")\n end\n file.unlink\n if success\n return true\n else\n return false\n end\n end",
"def drop\n cmd = 'aptly publish drop'\n cmd += \" #{@dist.quote}\"\n cmd += \" #{@prefix.quote}\" if !@prefix.empty?\n\n Aptly::runcmd cmd\n end",
"def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # And then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering command: #{name}...\"\n cmd = @cmds.delete(name)\n \n mod = cmd[:module]\n @modules[mod][:cmds].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def execute_local_command(cmd)\n Bundler.clean_system(cmd)\n end",
"def unregister\n VirtualBox.run_command ['VBoxManage', 'unregistervm', uid, '--delete']\n self\n end",
"def removeSwitchableUnit _args\n \"removeSwitchableUnit _args;\" \n end",
"def invoke_drop(key); end",
"def kill_server( screen_name )\n %x( screen -S #{screen_name} -X stuff $'\\003' )\nend",
"def uninstall\n pacman \"--noconfirm\", \"--noprogressbar\", \"-R\", @resource[:name]\n end",
"def cleanup_commands\n @cleanup_commands ||= []\n end",
"def destroy_dirty_file!(file)\n system(\"trashtrash #{file}\")\n end",
"def destroy_message(string)\n array = string.partition(\":\")\n\tfinal = array[0] + array[1]\nend",
"def delete_from_disk; end",
"def command!(name)\n found = command(name)\n\n if found.nil?\n raise CommandNotFound.new(name, self)\n end\n\n found\n end",
"def docker_rm\n sh 'docker rm --force brownbag', verbose: false\nrescue RuntimeError => error\n puts error.message\nend",
"def shell_command(command)\n command.map {|word| shell_single_word(word) }.join(' ')\n end",
"def uninit\n command('uninit')\n end",
"def remove_mount_point\n FileFoo.call!(api_base_file_name) { |content| remove_from_base(content) }\n end",
"def edged(cmd)\n $lock.synchronize{ \n $network.remove_edge($hostname,cmd[0])\n\n if $rt.has_key? cmd[0]\n $rt.delete cmd[0] \n end\n\n }\nend",
"def delete(*names)\n names.each { |name| commands.delete name }\n end",
"def `(cmd)\n $shell_result\n end",
"def run_destroy\n run(\n result:\n ::Kitchen::Terraform::Client::Command\n .destroy(\n options:\n ::Kitchen::Terraform::Client::Options\n .new\n .enable_lock\n .lock_timeout(duration: config_lock_timeout)\n .disable_input\n .maybe_no_color(toggle: !config_color)\n .parallelism(concurrent_operations: config_parallelism)\n .enable_refresh\n .state(path: config_state)\n .state_out(path: config_state)\n .vars(keys_and_values: config_variables)\n .var_files(paths: config_variable_files)\n .force,\n working_directory: instance_directory\n )\n )\n end",
"def command(command)\n cmd = \"#{@vzctl} exec2 #{@ctid} \"\n cmd << command\n execute(cmd)\n end",
"def devbox_user_command(cmd)\n command(\"sudo -u vagrant bash -i -c '#{cmd}; exit $?'\")\nend",
"def clean_test_box(host, remove_directories = nil)\n on(host, '/var/ibm/InstallationManager/uninstall/uninstallc',\n acceptable_exit_codes: [0, 127]) do |result|\n assert_no_match(%r{Error}, result.stderr, 'Failed to uninstall IBM Installation Manager')\n end\n on(host, \"rm -rf #{remove_directories}\", acceptable_exit_codes: [0, 127]) if remove_directories\nend",
"def destroy\n sharing(\"-r\", share_name)\n end",
"def delete\n execute(\"unregistervm\", @uuid, \"--delete\")\n end",
"def sh(t, s, c)\n\n end",
"def remove(pattern, dest, options)\n [:remove, pattern, dest, options]\nend",
"def destroy!\n Dropio::Resource.client.delete_drop(self)\n end"
] | [
"0.6148337",
"0.61282843",
"0.6105494",
"0.59178114",
"0.5895012",
"0.5881112",
"0.5808577",
"0.5798837",
"0.57206845",
"0.5710889",
"0.5691322",
"0.5689457",
"0.56493556",
"0.5548245",
"0.5541479",
"0.5524508",
"0.5514308",
"0.55064505",
"0.54871696",
"0.547982",
"0.54666984",
"0.54649097",
"0.5458244",
"0.5437873",
"0.5425548",
"0.53801167",
"0.53654623",
"0.53638744",
"0.5355377",
"0.5309385",
"0.52619636",
"0.5221802",
"0.52197456",
"0.5179753",
"0.5179393",
"0.5130932",
"0.5119712",
"0.51097167",
"0.50633806",
"0.50590384",
"0.5058543",
"0.5045063",
"0.5043842",
"0.5034855",
"0.5025174",
"0.50054425",
"0.4985889",
"0.4984336",
"0.49757814",
"0.4974063",
"0.49726954",
"0.49655005",
"0.4963834",
"0.4963834",
"0.4961069",
"0.49603307",
"0.4950881",
"0.49449202",
"0.49393103",
"0.49386352",
"0.49286863",
"0.4925865",
"0.4918308",
"0.4916602",
"0.49147233",
"0.49072412",
"0.4902041",
"0.4898512",
"0.48978734",
"0.48869538",
"0.48860666",
"0.48795387",
"0.48738518",
"0.48682898",
"0.48590115",
"0.48499718",
"0.48393497",
"0.48359197",
"0.48300222",
"0.4828467",
"0.4824944",
"0.48206475",
"0.48185396",
"0.48173383",
"0.48166627",
"0.48154083",
"0.48149604",
"0.4801684",
"0.4801173",
"0.4800146",
"0.47918904",
"0.47895652",
"0.47862798",
"0.47773445",
"0.47733492",
"0.477153",
"0.47652313",
"0.4759893",
"0.4757761",
"0.47568664"
] | 0.7586523 | 0 |
Create a long lived server for the tests | def clc_test_server
puts "clc_test_server"
server = clc_service.servers.find { |s| s.Name == clc_server_name }
unless server
server = clc_service.servers.create({
:Name => clc_server_name
}.merge(clc_set_test_server_attributes))
server.wait_for { ready? }
end
server
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_server\n\n end",
"def start_server!\n httpd_root = \"#{__dir__}/fixtures/httpd\"\n\n # The command to start the server must reset the BUNDLE_GEMFILE environment\n # setting.\n # command = \"cd ../simple-httpd/ && BUNDLE_GEMFILE= PORT=12345 bin/simple-httpd start #{httpd_root} -q\" \n command = \"PORT=12345 bundle exec simple-httpd start #{httpd_root}\" \n command = \"#{command} -q 2> log/simple-httpd.log\" \n\n ::RSpec::Httpd::Server.start! port: PORT, command: command\n end",
"def create_server\n\t\treturn Hglib::Server.new( self.path.to_s )\n\tend",
"def create_server\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end",
"def setup_server\n @port = 0\n begin\n @port = rand(40_000)\n @server = TCPServer.new(@port)\n rescue\n retry\n end\n end",
"def test_server\n TEST_SERVER\n end",
"def server(api, port, options = {}, &blk)\n op = OptionParser.new\n\n s = Goliath::Server.new\n s.logger = setup_logger(options)\n s.api = api.new\n s.app = Goliath::Rack::Builder.build(api, s.api)\n s.api.options_parser(op, options)\n s.options = options\n s.port = port\n s.plugins = api.plugins\n @test_server_port = s.port if blk\n s.start(&blk)\n s\n end",
"def setup_mongrel2_config\n\t\tserver 'test-server' do\n\t\t\tchroot Dir.tmpdir\n\t\t\tport 8080\n\t\t\tdefault_host 'test-host'\n\n\t\t\thost 'test-host' do\n\t\t\t\troute '/handler', handler( TEST_RECV_SPEC, 'test-handler' )\n\t\t\tend\n\t\tend\n\tend",
"def new_server(*args)\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.key, ctx.cert = @key, @cert\n tcps = TCPServer.new(*args)\n OpenSSL::SSL::SSLServer.new(tcps, ctx)\n end",
"def server(api, port, options = {}, &blk)\n op = OptionParser.new\n\n s = GrapeApe::Goliath::Server.new\n s.logger = setup_logger(options)\n s.api = api\n s.app = ::Goliath::Rack::Builder.build(api.class, s.api)\n s.api.options_parser(op, options)\n s.options = options\n s.port = port\n s.plugins = api.class.plugins\n @test_server_port = s.port if blk\n s.start(&blk)\n s\n end",
"def server\n @_server ||= case options.fetch(:type, :tcp)\n when :tcp\n TCPServer.new options.fetch(:host, \"127.0.0.1\"),\n options.fetch(:port, 2010)\n when :unix\n UNIXServer.new options.fetch(:path)\n when :pipe\n FakeServer.new options.fetch(:pipe)\n end\n end",
"def run_server\n EM.synchrony do\n @app = Rack::Builder.new do\n use Rack::Lint\n use Rack::ShowExceptions\n run Rack::Cascade.new([Souffle::Http])\n end.to_app\n\n Rack::Handler.get(:thin).run(@app, rack_options)\n end\n end",
"def setup_server\n ENV[\"RAILS_ENV\"] = \"test\"\n require \"rails\"\n fork do\n exec \"cd test/rails#{Rails::VERSION::MAJOR}_dummy && COVERBAND_TEST=test bundle exec rackup config.ru -p 9999 --pid /tmp/testrack.pid\"\n end\n end",
"def setup_server(s)\n # noop\n end",
"def openvz_fog_test_server\n server = openvz_service.servers.find { |s| s.ctid == '104' }\n unless server\n server = openvz_service.servers.create :ctid => '104'\n server.start\n server.reload\n # Wait for the server to come up\n begin\n server.wait_for(120) { server.reload rescue nil; server.ready? }\n rescue Fog::Errors::TimeoutError\n # Server bootstrap took more than 120 secs!\n end\n end\n\n openvz_fog_test_cleanup\n\n server\nend",
"def server\n # we're in a new process (one of the workers on the test_server),\n # so stop the old server from RemoteWorkerServer\n DRb.stop_service\n \n # since RemoteWorkerServer now uses drbfire, we use it here to communicate with it\n DRb.start_service(@server_proxy.uri, nil, DRbFire::ROLE => DRbFire::CLIENT)\n \n DeepTest.logger.debug \"LocalWorkers start_all worker starting with with blackboard: #{@server_proxy.uri.inspect} #{@server_proxy.inspect}\"\n \n # finally, return a remote reference to the RemoteWorkerServer\n DRbObject.new_with_uri(@server_proxy.uri)\n end",
"def main\n s = GRPC::RpcServer.new\n s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)\n s.handle(RequesterServer)\n s.run_till_terminated\nend",
"def initialize_server(port)\r\n set :port, port # Specify Port For Sinatra Server\r\n set :bind, \"0.0.0.0\" # Allow Ping From External Devices\r\n set :environment, :production # Allow External Nodes To Query Websocket\r\n set :run, true # Start Sinatra Server\r\nend",
"def test_server_port\n 3000\n end",
"def generate_server(cf, https = false)\n port = (https == true) ? cf.https['port'] : cf.port\n\n # Expand relative paths - particularly important for daemonizing.\n docroot = File.expand_path cf.docroot\n\n config = {\n BindAddress: cf.listen_addr,\n Port: port,\n DocumentRoot: docroot,\n StartCallback: lambda do\n # Write the pid to file when the server starts.\n if File.writable? cf.pid_path\n File.open(get_pidfile(cf, https), 'w') do |file|\n file.puts Process.pid.to_s\n end\n end\n end,\n StopCallback: lambda do\n # Delete the pid file when the server shuts down.\n pidfile = get_pidfile(cf, https)\n File.delete pidfile if File.exist? pidfile\n end\n }\n\n config[:ServerType] = Daemon if cf.daemonize\n\n if https\n require 'webrick/https'\n require 'openssl'\n\n if File.readable? cf.https['certificate']\n cert = OpenSSL::X509::Certificate.new File.read cf.https['certificate']\n end\n\n if File.readable? cf.https['private_key']\n pkey = OpenSSL::PKey::RSA.new File.read cf.https['private_key']\n end\n\n config[:SSLEnable] = true\n\n if cert && pkey\n config[:SSLCertificate] = cert\n config[:SSLPrivateKey] = pkey\n else\n # We don't have a certificate so generate a new self-signed certificate.\n config[:SSLCertName] = [%w(CN localhost)]\n end\n\n end\n\n server = HTTPServer.new(config)\n yield server if block_given?\n\n %w(INT TERM).each do |signal|\n trap(signal) { server.shutdown }\n end\n\n server.start\n end",
"def server\n\t\treturn @server ||= self.create_server\n\tend",
"def serve_https\n @server = Support::HTTP::Server.new\n @server.run\n end",
"def server(options = {})\n options = {:mount => endpoint, :timeout => 45, :extensions => []}.merge(options)\n ::Faye::RackAdapter.new(options)\n end",
"def launch(test = false)\n if(test)\n #open two ports for the server to test multiple connections\n t1 = TCPServer.open(44106)\n t2 = TCPServer.open(44107)\n Thread.new{run_server(t1)}\n Thread.new{run_server(t2)}\n\n return [t1, t2]\n else\n run_server(TCPServer.open(54106))\n end\n end",
"def start_server(klass, config={}, &block)\n server = klass.new({\n ServerType: Thread,\n BindAddress: \"127.0.0.1\",\n Port: 0,\n Logger: WEBrick::Log.new([], WEBrick::BasicLog::WARN),\n AccessLog: [],\n }.merge(config))\n\n server_thread = server.start\n\n addr = server.listeners[0].addr\n\n client_thread = Thread.new {\n begin\n block.yield([server, addr[3], addr[1]])\n ensure\n server.shutdown\n end\n }\n\n assert_join_threads([client_thread, server_thread])\nend",
"def create_server(options = {})\n begin\n add_custom_attributes(options[:server_def])\n server = connection.servers.create(options[:server_def])\n rescue Excon::Error::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n if response[\"badRequest\"][\"code\"] == 400\n message = \"Bad request (400): #{response[\"badRequest\"][\"message\"]}\"\n ui.fatal(message)\n else\n message = \"Unknown server error (#{response[\"badRequest\"][\"code\"]}): #{response[\"badRequest\"][\"message\"]}\"\n ui.fatal(message)\n end\n raise CloudExceptions::ServerCreateError, message\n rescue Fog::Errors::Error => e\n raise CloudExceptions::ServerCreateError, e.message\n end\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) { print \".\"; ready? }\n\n puts(\"\\n\")\n server\n end",
"def server(*args, &block)\n Vito::Dsl::Server.new(args).instance_eval(&block)\n end",
"def spawn_server(options = {}, **args)\n unless port_available?(options[\"port\"])\n raise \"Port #{options[\"port\"]} is already in use. Change it to an available port in \"\\\n \"config/config.yml.\"\n end\n prefix = get_fuseki_command_prefix args\n command = \"#{prefix}fuseki-server --memTDB --update --port #{options[\"port\"]} \"\\\n \"--jetty-config=#{File.join(Rails.root, \"config\", \"jetty-fuseki.xml\")} \"\\\n \"/#{options[\"dataset\"]} > /dev/null\"\n spawn command\n end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def start_server path, options = {}\n options[:port] ||= 4444\n set :port, options[:port]\n set :server, 'Mongrel'\n enable :sessions\n disable :logging\n hook = File.expand_path normalize('server.rb')\n load hook if File.exists? hook\n browsers = browsers_for(options[:browsers]) if options.include? :browsers\n JSpec::Server.new(path, options[:port]).start(browsers)\n end",
"def server(port = 9319)\r\n puts \"- Starting server on port: #{port}\"\r\n\r\n $servers[port] = WEBrick::HTTPServer.new(:Port => port) if $servers[port].nil?\r\n server = $servers[port]\r\n $mounts.keys.each{|url|\r\n server.unmount(url)\r\n server.mount(url, $mounts[url][0], *$mounts[url][1])\r\n }\r\n $mounts.clear\r\n\r\n Thread.new { server.start unless server.status == :Running }\r\nend",
"def serve port\n # Create a server on the port requested\n puts \"Creating server on port: #{port}\"\n server = TCPServer.new port\n\n # Continuously create new sessions while listening on the port\n loop do\n client = server.accept\n create_session client\n end\nend",
"def start_server!; @server = TCPServer.open($port) end",
"def create_server(options = {})\n begin\n server = connection.servers.create(options[:server_def])\n rescue Excon::Errors::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n if response['badRequest']['code'] == 400\n message = \"Bad request (400): #{response['badRequest']['message']}\"\n ui.fatal(message)\n else\n message = \"Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}\"\n ui.fatal(message)\n end\n raise CloudExceptions::ServerCreateError, message\n end\n\n msg_pair(\"Instance Name\", server.name)\n msg_pair(\"Instance ID\", server.id)\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) { print \".\"; ready? }\n\n puts(\"\\n\")\n server\n end",
"def server(&blk); end",
"def server(&blk); end",
"def run_webrick(config = {})\n config.update :Port => 8080\n server = HTTPServer.new config\n yield server if block_given?\n [\"INT\", \"TERM\"].each { |signal| trap(signal) { server.shutdown } }\n server.start\nend",
"def serve\n server_options = {}\n options.each { |k, v| server_options[k.to_sym] = v }\n server_options[:server] = {}\n [:port, :handler, :host].each do |k|\n server_options[:server][k] = server_options.delete(k) if server_options.key?(k)\n end\n\n @project.server.set_options(server_options[:server])\n end",
"def start!\n http_server.start\n self\n end",
"def api_server\n @api_server ||= NewRelic::Control::Server.new(Agent.config[:api_host], Agent.config[:api_port])\n end",
"def start\n Server.supervise_as :tishadow_server, self, :run_on_connect\n Builder.supervise_as :tishadow_builder, :build_command => @build_command, :verbose => @verbose, :update => @update, :spec => @spec, :app_root => @app_root\n @builder = Celluloid::Actor[:tishadow_builder]\n @server = Celluloid::Actor[:tishadow_server]\n @server.async.start\n end",
"def start_server(host = T.unsafe(nil), port = T.unsafe(nil)); end",
"def main\n this_dir = File.expand_path(File.dirname(__FILE__))\n echo_server_path = File.join(this_dir, 'echo_server.rb')\n to_child_r, _to_child_w = IO.pipe\n to_parent_r, to_parent_w = IO.pipe\n Process.spawn(RbConfig.ruby, echo_server_path, \"--secure\", in: to_child_r, out: to_parent_w, err: \"server_log\")\n to_child_r.close\n to_parent_w.close\n child_port = to_parent_r.gets.strip\n STDERR.puts \"server running on port: #{child_port}\"\n channel_creds = create_channel_creds.compose(\n GRPC::Core::CallCredentials.new(proc do |args|\n { 'authorization' => 'test' }.merge(args)\n end))\n stub = Echo::EchoServer::Stub.new(\n \"localhost:#{child_port}\", channel_creds,\n channel_args: { GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr' })\n 2.times do\n run_client(stub)\n end\nend",
"def start_webrick(config = {})\n config.update(:Port => 8080) \n server = HTTPServer.new(config)\n yield server if block_given?\n ['INT', 'TERM'].each {|signal| \n trap(signal) {server.shutdown}\n }\n server.start\n\nend",
"def create_server(input_queue, timeout=0)\n HornetQ::Client::ServerPattern.new(self, input_queue, timeout)\n end",
"def create\n @mock_server = MockServer.new(mock_server_params)\n\n respond_to do |format|\n if @mock_server.save\n format.json { render :show, status: :created, location: @mock_server }\n else\n format.json { render json: @mock_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def with_api(api, options = {}, &blk)\n server(GrapeApe::Server.new(api: api), options.delete(:port) || 9900, options, &blk)\n end",
"def with_dev_server\n old_env = ENV.fetch(\"NODE_ENV\", nil)\n ENV[\"NODE_ENV\"] = \"development\"\n\n # Start the server in a forked process:\n Dir.chdir(\"test/#{DUMMY_LOCATION}\") do\n spawn \"RAILS_ENV=development ./bin/shakapacker-dev-server\"\n end\n\n stop_time = Time.now + 30.seconds\n detected_dev_server = false\n loop do\n detected_dev_server = dev_server_running?\n break if detected_dev_server || Time.now > stop_time\n\n sleep 0.5\n end\n\n # If we didn't hook up with a dev server after waiting, fail loudly.\n raise \"Failed to start dev server\" unless detected_dev_server\n\n puts \"Detected dev server - Continuing\"\n\n # Call the test block:\n yield\n ensure\n check_cmd = \"lsof -i :8080 -S\"\n 10.times do\n # puts check_cmd\n status = `#{check_cmd}`\n # puts status\n remaining_pid_match = status.match(/\\n[a-z]+\\s+(\\d+)/)\n break unless remaining_pid_match\n\n remaining_pid = remaining_pid_match[1]\n # puts \"Remaining #{remaining_pid}\"\n kill_cmd = \"kill -9 #{remaining_pid}\"\n # puts kill_cmd\n `#{kill_cmd}`\n sleep 0.5\n end\n\n # Remove the dev-server packs:\n ShakapackerHelpers.clear_shakapacker_packs\n ENV[\"NODE_ENV\"] = old_env\n puts \"Killed.\"\n end",
"def start_server(port: 8080, path_to_binary: \"browserup-proxy-2.1.1-SNAPSHOT/bin/browserup-proxy\")\n current_thread = ENV[\"TEST_ENV_NUMBER\"].to_i\n port += (current_thread * 5 + current_thread)\n puts \"For current thread #{current_thread} port is #{port}\"\n @server = BrowserMob::Proxy::Server.new(path_to_binary, { port: port })\n @server.start\n self\n end",
"def create_server(params)\n body = connection.post(\"/v2/servers/#{account}\", params).body\n async_response(body)\n end",
"def initialize( opts={} )\n @opts = { 'ServerHost' => '0.0.0.0', 'ServerPort' => 1080 }\n @opts = @opts.merge( opts )\n @server = nil\n @clients = ::Array.new\n @running = false\n @server_thread = nil\n end",
"def setup\n Fluent::Test.setup\n @posted = []\n @prohibited = 0\n @auth = false\n @enable_float_number = false\n @dummy_server_thread = Thread.new do\n srv = if ENV['VERBOSE']\n WEBrick::HTTPServer.new({:BindAddress => '127.0.0.1', :Port => SIXPACK_TEST_LISTEN_PORT})\n else\n logger = WEBrick::Log.new('/dev/null', WEBrick::BasicLog::DEBUG)\n WEBrick::HTTPServer.new({:BindAddress => '127.0.0.1', :Port => SIXPACK_TEST_LISTEN_PORT, :Logger => logger, :AccessLog => []})\n end\n begin\n srv.mount_proc('/participate') { |req,res|\n unless req.request_method == 'GET'\n res.status = 405\n res.body = 'request method mismatch'\n next\n end\n if @auth and req.header['authorization'][0] == 'Basic YWxpY2U6c2VjcmV0IQ==' # pattern of user='alice' passwd='secret!'\n # ok, authorized\n elsif @auth\n res.status = 403\n @prohibited += 1\n next\n else\n # ok, authorization not required\n end\n\n post_param = {\n :alternatives=> req.query[\"alternatives\"],\n :alternative => req.query[\"alternative\"],\n :client_id => req.query[\"client_id\"],\n :experiment => req.query[\"experiment\"]\n }\n\n @posted.push(post_param)\n\n res.status = 200\n }\n srv.mount_proc('/convert') { |req,res|\n post_param = {\n :client_id => req.query[\"client_id\"],\n :experiment => req.query[\"experiment\"]\n }\n post_param.merge!({:kpi => req.query[\"kpi\"]}) if req.query[\"kpi\"]\n @posted.push(post_param)\n res.status = 200\n }\n srv.mount_proc('/') { |req,res|\n res.status = 200\n res.body = 'running'\n }\n srv.start\n ensure\n srv.shutdown\n end\n end\n\n # to wait completion of dummy server.start()\n require 'thread'\n cv = ConditionVariable.new\n watcher = Thread.new {\n connected = false\n while not connected\n begin\n get_content('localhost', SIXPACK_TEST_LISTEN_PORT, '/')\n connected = true\n rescue Errno::ECONNREFUSED\n sleep 0.1\n rescue StandardError => e\n p e\n sleep 0.1\n end\n end\n cv.signal\n }\n mutex = Mutex.new\n mutex.synchronize {\n cv.wait(mutex)\n }\n end",
"def start_server(options = {})\n\n # Backward compatibility\n if options.is_a? String\n url = options\n port = nil\n logfile = nil\n else\n url = options[:url]\n port = options[:port]\n logfile = options[:logfile]\n end\n\n url = ENV['TALKSHOW_REMOTE_URL'] if ENV['TALKSHOW_REMOTE_URL']\n port = ENV['TALKSHOW_PORT'] if ENV['TALKSHOW_PORT']\n logfile = ENV['TALKSHOW_LOG'] if ENV['TALKSHOW_LOG']\n\n Talkshow::Server.set_port port if port\n Talkshow::Server.set_logfile logfile if logfile\n \n if !url\n @type = :thread\n @question_queue = ::Queue.new\n @answer_queue = ::Queue.new\n @thread = Thread.new do\n Talkshow::Server.question_queue(@question_queue)\n Talkshow::Server.answer_queue(@answer_queue)\n Talkshow::Server.run!\n end\n else\n @type = :remote\n @question_queue = Talkshow::Queue.new(url)\n @answer_queue = Talkshow::Queue.new(url)\n end\n \n end",
"def prepare(server); end",
"def server(port = 9319)\r\n puts \"- Starting server on port: #{port}\"\r\n\r\n begin\r\n $servers[port].shutdown if $servers.has_key?(port)\r\n rescue => e\r\n puts \"- Server on #{port} failed to shutdown with message: #{e}\"\r\n end\r\n\r\n #TODO: this is where we sometimes get Address already in use - bind - Address already in use: bind\r\n #possibly we need to wait/confirm the server shutdown or maybe retry?\r\n\r\n $servers[port] = WEBrick::HTTPServer.new(:Port => port)\r\n server = $servers[port]\r\n $mounts.keys.each{|url|\r\n server.mount(url, $mounts[url][0], *$mounts[url][1])\r\n }\r\n $mounts.clear\r\n\r\n Thread.new {\r\n begin\r\n sleep 1\r\n server.start\r\n rescue Exception => e\r\n puts \"- Exception starting server on #{port} - #{e}\"\r\n end\r\n }\r\nend",
"def with_api(api, options = {}, &blk)\n server(api, options.delete(:port) || 9900, options, &blk)\n end",
"def server\n '127.0.0.1'\n end",
"def server\n uri = \"#{options[:use_ssl] ? \"https\" : \"http\"}://#{Blupee.config.api_server}\"\n end",
"def create_server(name, region = :'eu-central')\n response = API::Server.create(token, name, region)\n id = JSON.parse(response)['id'].to_i\n sleep 0.1 until (server = @servers[id])\n debug \"Successfully created server #{server.id} with name #{server.name}\"\n server\n end",
"def start_server(server)\n server.start\n end",
"def test\n cmd = \"rackup #{@test_config}\" \n puts \"=> #{cmd} -p 5000 -E test -o 127.0.0.1\"\n system(cmd)\nend",
"def main\n s = GRPC::RpcServer.new\n s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)\n s.handle(CalculadoraServer)\n s.run_till_terminated\nend",
"def main\n s = GRPC::RpcServer.new\n s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)\n s.handle(GreeterServer)\n # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to \n # gracefully shutdown.\n # User could also choose to run server via call to run_till_terminated\n s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])\nend",
"def get_test_server\n {\n 'name' => 'test_db',\n 'address' => '172.19.108.5',\n 'database' => 'MigrationTest',\n 'username' => 'jenkins',\n 'password' => 'QDfVkyVn8tk6'\n }\nend",
"def start_server(options)\n url = build_url(options)\n config = build_config(options)\n\n # drbssl service fails on connection Exceptions, so restart it..\n begin\n proxy = DatabaseProxy.new\n DRb.start_service(url, proxy, config)\n DRb.thread.join\n done = true\n rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::EPIPE, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError => e\n STDERR.puts \"#{e.class.name}: #{e}\"\n done = false\n rescue Exception => e\n STDERR.puts \"#{e.class.name}: #{e}\"\n done = true\n end until done\n end",
"def server(queue, timeout=0, &block)\n session do |s|\n server = nil\n begin\n server = s.create_server(queue, timeout=0)\n block.call(s, server)\n ensure\n server.close\n end\n end\n end",
"def main\n s = GRPC::RpcServer.new\n s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)\n s.handle(GreeterServer)\n # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to\n # gracefully shutdown.\n # User could also choose to run server via call to run_till_terminated\n s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])\nend",
"def main\n s = GRPC::RpcServer.new\n s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)\n s.handle(GreeterServer)\n # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to\n # gracefully shutdown.\n # User could also choose to run server via call to run_till_terminated\n s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])\nend",
"def prepare\n if not @http_server\n config = {}\n config[:BindAddress] = @configuration.get('beef.http.host')\n config[:Port] = @configuration.get('beef.http.port')\n config[:Logger] = WEBrick::Log.new($stdout, WEBrick::Log::ERROR)\n config[:ServerName] = \"BeEF \" + VERSION\n config[:ServerSoftware] = \"BeEF \" + VERSION\n \n @http_server = WEBrick::HTTPServer.new(config)\n \n # Create http handler for the javascript hook file\n mount(\"#{@configuration.get(\"beef.http.hook_file\")}\", true, BeEF::Core::Handlers::HookedBrowsers)\n \n # Create http handlers for all commands in the framework\n BeEF::Modules.get_loaded.each { |k,v|\n mount(\"/command/#{k}.js\", false, BeEF::Core::Handlers::Commands, k)\n }\n \n #\n # We dynamically get the list of all http handler using the API and register them\n #\n BeEF::API.fire(BeEF::API::Server::Handler, 'mount_handlers', self)\n end\n end",
"def start_server!\n @logger.info \"Listening on #{@host}:#{@port}\"\n @server = TCPServer.new(@host, @port)\n end",
"def run\n trap('INT') { http_server.shutdown }\n http_server.start\n end",
"def create_server(options = {})\n begin\n add_custom_attributes(options[:server_def])\n server = connection.servers.create(options[:server_def])\n\n print \"\\nWaiting For Server\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n\n # attach/or create any volumes.\n options[:server_volumes].each do |voldef|\n Chef::Log.debug(\"Volume definition: #{voldef}\")\n if voldef.key?(:size) || voldef.key?(:size_gb)\n # create a new volume\n result = connection.add_volume(server.id, voldef)\n name = (result / 'disk/name').first.text\n elsif voldef.key? :id\n server.attach_volume(voldef)\n name = voldef[:id]\n else\n raise CloudExceptions::ServerCreateError, \"cannot handle volume definition #{voldef}\"\n end\n\n print \"\\nAttached #{name} volume\"\n end\n\n print \"\\nWaiting For Volumes\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n Chef::Log.debug(\"options: #{options}\")\n server.start_with_cloudinit(user_data: options[:cloud_init])\n rescue Excon::Error::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n message = if response['badRequest']['code'] == 400\n \"Bad request (400): #{response['badRequest']['message']}\"\n else\n \"Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}\"\n end\n ui.fatal(message)\n raise CloudExceptions::ServerCreateError, message\n rescue Fog::Errors::Error => e\n raise CloudExceptions::ServerCreateError, e.message\n end\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n ready?\n end\n\n puts(\"\\n\")\n server\n end",
"def start_server\n begin\n require 'webrick'\n rescue LoadError\n abort \"webrick is not found. You may need to `gem install webrick` to install webrick.\"\n end\n\n server = WEBrick::HTTPServer.new :Port => @server\n\n extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact\n\n server.mount '/', RDoc::Servlet, nil, extra_doc_dirs\n\n trap 'INT' do server.shutdown end\n trap 'TERM' do server.shutdown end\n\n server.start\n end",
"def create_http_server(options=nil)\n if !block_given? && options == nil\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createHttpServer, []).call(),::Vertx::HttpServer)\n elsif options.class == Hash && !block_given?\n return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createHttpServer, [Java::IoVertxCoreHttp::HttpServerOptions.java_class]).call(Java::IoVertxCoreHttp::HttpServerOptions.new(::Vertx::Util::Utils.to_json_object(options))),::Vertx::HttpServer)\n end\n raise ArgumentError, \"Invalid arguments when calling create_http_server(options)\"\n end",
"def server(input_queue, timeout=0, &block)\n begin\n server = self.create_server(input_queue, timeout)\n block.call(server)\n ensure\n server.close if server\n end\n end",
"def startServer(params)\n @@server = HTTPServer.new(\n :Port => params[:webPort] || DEF_WEB_PORT,\n :Logger => Log4r::Logger.new(\"#{MObject.logger.fullname}::web\"),\n :RequestHandler => lambda {|req, resp|\n beforeRequestHook(req, resp)\n }\n )\n trap(\"INT\") { @@server.shutdown }\n\n path = File.dirname(params[:configDir]) + \"/favicon.ico\"\n @@server.mount(\"/favicon.ico\", HTTPServlet::FileHandler, path) {\n raise HTTPStatus::NotFound, \"#{path} not found.\"\n }\n @@server.mount_proc('/') {|req, res|\n res['Content-Type'] = \"text/xml\"\n body = [%{<?xml version='1.0'?><serviceGroups>}]\n @@registeredServices.each {|path, service|\n info = service.info\n name = service.serviceName\n body << \"<serviceGroup path='#{path}' name='#{name}'><info>#{info}</info></serviceGroup>\"\n }\n body << \"</serviceGroups>\"\n res.body = body.to_s\n }\nend",
"def create params\n raise_start_server unless Server::node\n new params\n end",
"def run opts = {}\n boot!\n\n handler = opts.delete(:server)\n (handler && Rack::Handler.const_defined?(handler)) || (handler = HTTP__DEFAULT_SERVER)\n\n port = opts.delete(:port)\n opts[:Port] ||= port || HTTP__DEFAULT_PORT\n\n host = opts.delete(:host) || opts.delete(:bind)\n opts[:Host] = host if host\n\n $stderr.puts \"\\n--- Starting Espresso for %s on %s port backed by %s server ---\\n\\n\" % [\n environment, opts[:Port], handler\n ]\n Rack::Handler.const_get(handler).run app, opts do |server|\n %w[INT TERM].each do |sig|\n Signal.trap(sig) do\n $stderr.puts \"\\n--- Stopping Espresso... ---\\n\\n\"\n server.respond_to?(:stop!) ? server.stop! : server.stop\n end\n end\n server.threaded = opts[:threaded] if server.respond_to? :threaded=\n yield server if block_given?\n end\n end",
"def start\n api = @settings[:api] || {}\n bind = api[:bind] || \"0.0.0.0\"\n port = api[:port] || 4567\n start_http_server(bind, port)\n super\n end",
"def initialize(server_url, command, nodes, timeout)\n @server_url = server_url\n @command = command\n @nodes = nodes.map { |n| n.name }\n @timeout = timeout\n ::Chef_Delivery::ClientHelper.enter_client_mode_as_delivery\n @rest = Chef::REST.new(Chef::Config[:chef_server_url])\n ::Chef_Delivery::ClientHelper.leave_client_mode_as_delivery\n end",
"def start_server\n erl = CliRunner.open 'skirmish_server', 'erl', /\\d>/, /Eshell/\n erl << \"code:add_path(\\\"#{server_dir}/ebin\\\").\" >> /true/\n erl << \"application:start(skirmish_server).\" >> /ok/\n @automation_server = erl\n log.info(\"Automation#start_server\") { \"server started\" }\n end",
"def run_app\n http_config = config.http\n\n @server_thread = Thread.new do\n @server = Puma::Server.new(app)\n begin\n @server.add_tcp_listener(http_config.host, http_config.port.to_i)\n rescue Errno::EADDRINUSE, Errno::EACCES => e\n logger.fatal I18n.t(\n \"lita.http.exception\",\n message: e.message,\n backtrace: e.backtrace.join(\"\\n\")\n )\n abort\n end\n @server.min_threads = http_config.min_threads\n @server.max_threads = http_config.max_threads\n @server.run\n end\n\n @server_thread.abort_on_exception = true\n end",
"def test_application_running\n get '/v1/main'\n assert last_response.ok?\n assert last_response.body.include?('Hello world')\n end",
"def server_url\n \"http://#{server_host}:#{server_port}\"\n end",
"def start_server\n @watchman = Thread.new {\n while !@stopped\n @pool_mutex.synchronize\n socket = @server.accept\n @pool << Thread.new(socket) {|socket|\n serve(socket)\n }\n end \n }\n end",
"def clientserver\n end",
"def start_server(port)\n root = Dir.getwd\n server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => root\n trap 'INT' do server.shutdown end\n server.start\n end",
"def setup\n\n @server = ItemServer.new :auth => :basic\n @server.start\n end",
"def create_server(connection, name, options={})\n raise \"Need to extend create_server method!\"\n end",
"def start_server\n loop do\n socket = @server.accept\n @pool.post do\n request = socket.gets\n unless request.nil?\n response = fetch_data(request)\n socket.print build_response(response)\n socket.print \"\\r\\n\"\n socket.print response[:message]\n end\n socket.close\n end\n end\n end",
"def main\n #basePath = \"d:\\\\web\"\n basePath = ENV['PWD'] + '/test/functional/tmp/repo'\n #server = TCPServer.new('XXX.XXX.XXX.XXX', 9090)\n server = TCPServer.new('127.0.0.1', 9090)\n #logfile = basePath + \"\\\\log.txt\"\n logfile = basePath + \"/log.txt\"\n $log = File.open(logfile, \"w+\")\n\n puts \"basePath = #{basePath}\"\n puts \"logfile = #{logfile}\"\n\n loop do\n session = server.accept\n request = session.gets\n logStr = \"#{session.peeraddr[2]} (#{session.peeraddr[3]})\\n\"\n logStr += Time.now.localtime.strftime(\"%Y/%m/%d %H:%M:%S\")\n logStr += \"\\n#{request}\"\n logger(logStr)\n \n Thread.start(session, request) do |session, request|\n HttpServer.new(session, request, basePath).serve()\n end\n\n end\n log.close\nend",
"def start(host, port); end",
"def test_socket_activation\n skip 'requires root privs' unless Process.euid == 0\n skip 'TODO - port to linux' unless Gem::Platform.local.os == 'freebsd'\n\n name = \"relaunchd.test\"\n \n c = Launch::Container.new(name, { \n\t'Enable' => true, \n\t'PostCreateCommands' => [], \n\t})\n\n # ensure a clean environment\n system \"ezjail-admin delete -f -w #{name}\" if c.exists?\n \n start_launchd\n begin\n launchctl \"load #{@fixturesdir}/com.example.container_with_socket.plist\"\n sleep 3 # give it time to run async..\n assert_match 'hello world', `nc -w 60 localhost 24820`\n rescue\n raise\n ensure\n stop_launchd\n delete_container name\n end\n end"
] | [
"0.67443496",
"0.6631078",
"0.6616785",
"0.6594843",
"0.6535144",
"0.65292877",
"0.64969736",
"0.64552104",
"0.63713354",
"0.636591",
"0.6332696",
"0.6237494",
"0.6232441",
"0.6205914",
"0.61973155",
"0.61875737",
"0.6127939",
"0.6112675",
"0.6100854",
"0.6077142",
"0.6061919",
"0.6056289",
"0.60465986",
"0.6045096",
"0.60362726",
"0.6018787",
"0.5989802",
"0.5972473",
"0.59711605",
"0.59711605",
"0.59711605",
"0.59711605",
"0.59711605",
"0.59711605",
"0.59711605",
"0.59711605",
"0.5931877",
"0.5902485",
"0.5884725",
"0.58819515",
"0.5848563",
"0.584733",
"0.584733",
"0.58442074",
"0.58359426",
"0.5832619",
"0.5826647",
"0.5823733",
"0.58216214",
"0.580606",
"0.5803792",
"0.5797974",
"0.5782925",
"0.5773948",
"0.5769867",
"0.5768091",
"0.57611436",
"0.5747791",
"0.5744394",
"0.57357603",
"0.57327116",
"0.57116956",
"0.5702566",
"0.5687381",
"0.56729263",
"0.56720495",
"0.5666454",
"0.56612784",
"0.5649965",
"0.5634966",
"0.56344265",
"0.5633435",
"0.56304514",
"0.5626688",
"0.5626688",
"0.56108195",
"0.560941",
"0.56003547",
"0.55967945",
"0.5594764",
"0.5594741",
"0.5593404",
"0.5587152",
"0.5561108",
"0.55594444",
"0.5557835",
"0.5557581",
"0.5555712",
"0.55376196",
"0.55372345",
"0.553054",
"0.5526983",
"0.5525909",
"0.5522292",
"0.5518052",
"0.5510967",
"0.550305",
"0.549901",
"0.54826164",
"0.5481585"
] | 0.6295105 | 11 |
Destroy the long lived server | def clc_test_server_destroy
server = clc_service.servers.find { |s| s.Name == clc_server_name }
server.destroy if server
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n data = Storm::Base::SODServer.remote_call '/Server/destroy',\n :uniq_id => @uniq_id\n data[:destroyed]\n end",
"def destroy_server(connection, server)\n server.destroy\n end",
"def stop\n @server.close\n end",
"def destroy\n @sock.cmd(\"String\"=>\"quit\")\n @sock.close\n end",
"def finalize\n @server.close if @server\n end",
"def server_destroy(server)\n if(server.persisted?)\n if(server.state == :running)\n result = request(\n :path => \"containers/#{server.id}/state\",\n :method => :put,\n :expects => 202,\n :json => {\n :action => :stop,\n :force => true\n }\n )\n wait_for_operation(result.get(:body, :operation))\n end\n request(\n :path => \"containers/#{server.id}\",\n :method => :delete,\n :expects => 202\n )\n true\n else\n false\n end\n end",
"def destroy!(options={})\n info \"Destroying...\" if verbose?\n servers.each do |server|\n server.destroy\n end\n end",
"def stop\n @server.stop if @server.running?\n end",
"def kill\n server.kill\n end",
"def stop\n @server.shutdown if @server\n end",
"def stop_server\n @server_handler.stop_server\n end",
"def delete!\n server.delete(name)\n end",
"def destroy\n @server.destroy\n session[:server_id] = nil\n respond_to do |format|\n format.html { redirect_to servers_url, notice: t('notice.server.deleted') }\n end\n end",
"def destroy\n @client.client.disconnect\n end",
"def destroy\n destroy_server @server\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def shutdown\n @server.shutdown\n end",
"def stop_server\n unless @servsocket.closed?\n detach\n @servsocket.close\n end\n end",
"def stop_server\n Thin::Server.kill(CloudCrowd.pid_path('server.pid'), 0)\n end",
"def server_stop\n Process.kill 'INT', 0\n end",
"def close #:nodoc:\n @server.shutdown\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cleanup!(h)\n Sudo::System.kill h[:pid]\n Sudo::System.unlink h[:socket]\n end",
"def destroy(state)\n info(\"Destroying instance #{instance.name}\")\n return if state[:server_id].nil?\n instance.transport.connection(state).close\n domain = load_domain(state[:server_id])\n destroy_domain(domain) unless domain.nil?\n info(\"Libvirt instance #{state[:server_id]} destroyed.\")\n state.delete(:server_id)\n state.delete(:hostname)\n end",
"def stop\n server.synchronize do\n File.unlink(service_link) if File.symlink?(service_link)\n sleep(1) until !server.running?\n end\n end",
"def destroy\n authenticate_user!\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :no_content }\n end\n end",
"def shutdown\n @server_active = false\n end",
"def destroy\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :no_content }\n end\n end",
"def stop_server\n if @server\n @server.shutdown\n @server_thread.join\n @server\n end\n end",
"def destroy\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @server_instance = ServerInstance.find(params[:id])\n @server_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to server_instances_url }\n format.json { head :no_content }\n end\n end",
"def openvz_fog_test_server_destroy\n server = openvz_service.servers.find { |s| s.ctid == '104' }\n server.destroy if server\nend",
"def destroy\n go = -> { redirect_to zabbix_servers_url }\n begin\n @zabbix_server.destroy!\n rescue StandardError => ex\n flash[:alert] = ex.message\n go.call and return\n end\n\n ws_send(t('zabbix_servers.msg.deleted', name: @zabbix_server.fqdn), true)\n go.call and return\n end",
"def delete_server\n super\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to servers_url }\n end\n end",
"def destroy\n return if @name.nil?\n delete_rest \"vservers/#{@name}\"\n end",
"def destroy\n @bot_server.destroy\n respond_to do |format|\n format.html { redirect_to bot_servers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server = Server.find(params[:id])\n @server.destroy\n \n respond_to do |format|\n format.html { redirect_to(servers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @app_server.destroy\n respond_to do |format|\n format.html { redirect_to app_servers_url, notice: 'App server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heartbeat.destroy\n\n head :no_content\n end",
"def stop\n server = Communist.servers.delete(app.object_id) { |s| NullServer.new }\n if Communist.server.respond_to?(:shutdown)\n server.shutdown\n elsif Communist.server.respond_to?(:stop!)\n server.stop!\n else\n server.stop\n end\n @server_thread.join\n end",
"def stop\n @logger.warn(\"stopping\")\n EM::stop_server(@http_server)\n @redis.close if @redis\n @transport.close if @transport\n super\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def finish\n @thread.kill if @thread; @thread = nil\n @cleanup.call if @cleanup; @cleanup = nil\n FileUtils.rm sock_name\n end",
"def terminate\n self.destroy\n end",
"def stop\n @builder.terminate\n @server.terminate\n end",
"def destroy\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to(servers_url) }\n format.xml { head :ok }\n end\n end",
"def cleanup \n # close the sockets \n @servers.each{ |server| server[:listner].stop }\n @monitor.close\n end",
"def shutdown\n @manager.shutdow_service_server(self)\n end",
"def destroy\n @gameserver.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def stop_server\n FileUtils.rm_r \"#{ENV['TM_PROJECT_DIRECTORY']}/config/.event_server\"\n pid = params[:pid]\n `kill #{pid}`\n render \"_index\", :locals => { :running => false, :pid => \"\" } \n end",
"def destroy\n connection.close\n end",
"def delete_virtual_server\n super\n end",
"def server_stop(cf, https = false)\n pid = get_pid(cf, https)\n Process.kill('INT', pid) if pid > 0\n end",
"def delete\n Profitbricks.request :delete_server, server_id: self.id\n return true\n end",
"def destroy_connection\r\n\tbegin\r\n\t\t@sock.close if @sock\r\n\tensure\r\n\t\t@connected=false\r\n\tend\r\n end",
"def destroy\n begin\n exitMaintenanceMode\n rescue\n Puppet.err 'Could not find Host system.Either Host is not exist or disconnected'\n end\n end",
"def teardown\n #commented this out because it is now unnecessary\n # @api = nil\n #GC.start\n @api.close_api\n # @server.close\n end",
"def exit\n @server.check_out(@host) unless @server.nil?\n end",
"def destroyX\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to(servers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Process.kill(9, pid)\n end",
"def closeServer()\n com = Sumo::Traci::Command_Close.new() ;\n execCommands(com) ;\n close() ;\n end",
"def cleanup\n\t\tputs \"Reconectando...\"\n\t\t@reconect = true\n\t\tcheck_ip_integrity\n\t\t@server.close\n\t\t@response.kill\n\t\t@request.kill\n\tend",
"def stop_server(server)\n server.stop\n end",
"def destroy\n kill\n reset\n end",
"def stop\n return if not running?\n @running = false\n @server.shutdown\n end",
"def stop!\n self.class.cleanup!(:pid => @sudo_pid, :socket => @socket)\n @proxy = nil\n end",
"def destroy\n @mock_server.destroy\n respond_to do |format|\n format.html { redirect_to mock_servers_url, notice: 'Mock server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server.destroy\n respond_to do |format|\n format.html { redirect_to [:admin, @site] }\n format.json { head :no_content }\n end\n end",
"def close!\n logger.debug \"Closing...\",\n socket: socket,\n server: server,\n path_exists: path.exist?,\n thread: thread,\n env_var: {\n env_var_name => ENV[env_var_name],\n }\n \n # Remove the path from the ENV so if we do anything after this the\n # old one isn't hanging around\n ENV.delete env_var_name\n \n # Kill the thread first so that it can't try to do anything else\n thread.kill if thread && thread.alive?\n \n socket.close unless socket.nil?\n @socket = nil\n server.close unless server.nil?\n @server = nil\n FileUtils.rm( path ) if path.exist?\n \n logger.debug \"Closed.\",\n socket: socket,\n server: server,\n path_exists: path.exist?,\n thread: thread,\n env_var: {\n env_var_name => ENV[env_var_name],\n }\n \n nil\n end",
"def destroy(async=true)\n basedir = @config.get(\"GEAR_BASE_DIR\")\n\n path = File.join(basedir, \".httpd.d\", \"#{container_uuid}_*\")\n FileUtils.rm_rf(Dir.glob(path))\n\n reload_all(async)\n end",
"def destroy(async=true)\n basedir = @config.get(\"GEAR_BASE_DIR\")\n\n path = File.join(basedir, \".httpd.d\", \"#{container_uuid}_*\")\n FileUtils.rm_rf(Dir.glob(path))\n\n reload_all(async)\n end",
"def destroy\n @run.destroy\n head 200\n end",
"def stop\n @appserver.stop\n \n if @thread\n sleep 0.1 while @thread[:running]\n @thread.kill\n @thread = nil\n end\n end",
"def destroy\n @gameserver.destroy\n respond_to do |format|\n format.html { redirect_to gameservers_path, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_server = Game::Server.find(params[:id])\n @game_server.destroy\n\n respond_to do |format|\n format.html { redirect_to game_servers_url }\n format.json { head :ok }\n end\n end",
"def cleanup\n cleanup_primitive full_name, hostname\n wait_for_status name\n end",
"def close\n @server.close if @server\n @accept_thread.kill if @accept_thread\n @accept_thread = nil\n end",
"def destroy!(options = {}, &block)\n options.merge!(force: true)\n\n destroy_remote(options, &block)\n end",
"def cleanup\n server.log.info(\"Shutting down\")\n begin\n lifeline.close\n rescue Errno::EPIPE\n end\n end",
"def stop\n @mutex.synchronize do\n if( not @closed )\n\n begin\n @lsock.close if @lsock\n rescue\n end\n\n begin\n @rsock.close if @rsock\n rescue\n end\n\n @client_thread.kill if( @client_thread and @client_thread.alive? )\n\n @server.remove_client( self )\n\n @closed = true\n end\n end\n end",
"def destroy\n conn.delete(self_link)\n end",
"def graceful_shutdown\n socket_server.close unless socket_server.closed?\n @active_descriptors.delete(socket_server)\n @shutdown = true\n end",
"def destroy\n @app.destroy\n\n head :no_content\n end",
"def stop\n @socket.close\n ensure\n cleanup\n end",
"def destroy\n @server = current_user.administrated_servers.find_by(discord_id: params[:discord_id])\n @server.destroy\n\n render 'api/servers/show'\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def destroy\n run_callbacks :destroy do\n rpc_execute('unlink', [id], context)\n @destroyed = true\n freeze \n end\n end",
"def remove_server( host, port )\n server = get_server( host, port )\n Penctl.update_server( @pen, server[:slot], :address => '0.0.0.0', :port => 0 )\n !server_in_pool? host, port\n end",
"def destroy(name)\n Puppet::SSL::Host.destroy(name)\n end",
"def destroy\n if self.class.cfg_name == \"server\"\n begin\n ip = canonicalIP\n MU::Master.removeIPFromSSHKnownHosts(ip) if ip\n if @deploy and @deploy.deployment and\n @deploy.deployment['servers'] and @config['name']\n me = @deploy.deployment['servers'][@config['name']][@mu_name]\n if me\n [\"private_ip_address\", \"public_ip_address\"].each { |field|\n if me[field]\n MU::Master.removeIPFromSSHKnownHosts(me[field])\n end\n }\n if me[\"private_ip_list\"]\n me[\"private_ip_list\"].each { |private_ip|\n MU::Master.removeIPFromSSHKnownHosts(private_ip)\n }\n end\n end\n end\n rescue MU::MuError => e\n MU.log e.message, MU::WARN\n end\n end\n if !@cloudobj.nil? and !@cloudobj.groomer.nil?\n @cloudobj.groomer.cleanup\n elsif !@groomer.nil?\n @groomer.cleanup\n end\n if !@deploy.nil?\n if !@cloudobj.nil? and !@config.nil? and !@cloudobj.mu_name.nil?\n @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @cloudobj.mu_name, remove: true, triggering_node: @cloudobj, delayed_save: @delayed_save)\n elsif !@mu_name.nil?\n @deploy.notify(self.class.cfg_plural, @config['name'], nil, mu_name: @mu_name, remove: true, triggering_node: self, delayed_save: @delayed_save)\n end\n @deploy.removeKitten(self)\n end\n # Make sure that if notify gets called again it won't go returning a\n # bunch of now-bogus metadata.\n @destroyed = true\n if !@cloudobj.nil?\n def @cloudobj.notify\n {}\n end\n else\n def notify\n {}\n end\n end\n end",
"def cleanup\n super\n if(service)\n stop_service()\n print_status(\"Server stopped.\")\n end\n end",
"def destroy!\n orchio_purge\n end",
"def destroy_server(connection, server)\n disks = server.disks.select{|d| d[\"type\"] == \"PERSISTENT\"}\n server.destroy\n destroy_disks = get_boolean_field('destroy_disks')\n if destroy_disks\n return if disks.empty?\n\n # We need to wait for instance to be terminated before destroying disks\n start = Time.now\n msg = \"Waiting for server to be terminated: #{server.name}\"\n Maestro.log.debug(msg)\n write_output(\"#{msg}...\")\n\n # we need to wait until the server is removed from GCE\n # state == TERMINATED doesn't let us delete the disk yet\n begin\n server.wait_for { false }\n rescue Fog::Errors::NotFound => e\n end\n Maestro.log.debug(\"Server is terminated: #{server.name} (#{Time.now - start}s)\")\n write_output(\"done (#{Time.now - start}s)\\n\")\n\n # Delete the disks\n start = Time.now\n disks_to_delete = []\n disks.each do |d|\n match = d[\"source\"].match(%r{projects/(.*)/zones/(.*)/disks/(.*)})\n disks_to_delete << {:project => match[1], :zone => match[2], :disk => match[3]}\n end\n\n msg = \"Deleting disks: #{disks_to_delete.map{|d| d[:disk]}}\"\n Maestro.log.debug(msg)\n write_output(\"#{msg}...\")\n\n disks_to_delete.each do |d|\n disk = connection.disks.get(d[:disk],d[:zone])\n disk.destroy\n end\n\n Maestro.log.debug(\"Deleted disks: #{disks_to_delete.map{|d| d[:disk]}} (#{Time.now - start}s)\")\n write_output(\"done (#{Time.now - start}s)\\n\")\n end\n end",
"def destroy\n @server_info = ServerInfo.find(params[:id])\n @server_info.destroy\n\n respond_to do |format|\n format.html { redirect_to server_infos_url }\n format.json { head :no_content }\n end\n end",
"def stop\n EM.cancel_timer @notify_timer\n notify :byebye\n stop_ssdp_server\n\n sleep 2\n stop_http_server\n end",
"def shutdown\n client.close\n end",
"def destroy\n @environment_variable.destroy!\n head :ok\n end"
] | [
"0.7429745",
"0.7354424",
"0.72947174",
"0.72772425",
"0.7116922",
"0.7084675",
"0.6995611",
"0.6987602",
"0.69845",
"0.6982915",
"0.69005394",
"0.686551",
"0.6832021",
"0.6823915",
"0.6815131",
"0.6762998",
"0.6721438",
"0.67164475",
"0.66993403",
"0.6696496",
"0.66946596",
"0.66946596",
"0.66946596",
"0.66946596",
"0.66883546",
"0.66749716",
"0.6671593",
"0.6669171",
"0.6666361",
"0.6596323",
"0.65960556",
"0.65751684",
"0.6571263",
"0.6536287",
"0.65355086",
"0.65346193",
"0.6531454",
"0.6529795",
"0.6526123",
"0.65258515",
"0.6522497",
"0.6512999",
"0.65013343",
"0.6501155",
"0.64795595",
"0.64716053",
"0.6466661",
"0.6458204",
"0.6441733",
"0.6430825",
"0.642812",
"0.64279246",
"0.6427514",
"0.6422786",
"0.64224595",
"0.6419078",
"0.64174825",
"0.6416191",
"0.6412843",
"0.6408836",
"0.63987595",
"0.6397233",
"0.63887304",
"0.6386076",
"0.638452",
"0.6376411",
"0.63739216",
"0.6372928",
"0.6368055",
"0.63620424",
"0.63612586",
"0.6332929",
"0.63283306",
"0.63283306",
"0.63154334",
"0.63151324",
"0.63068104",
"0.63066024",
"0.6303596",
"0.6290836",
"0.6277122",
"0.6273683",
"0.626967",
"0.6253763",
"0.6252124",
"0.62457526",
"0.6239568",
"0.62342864",
"0.6221544",
"0.6203328",
"0.6197223",
"0.61943156",
"0.61809677",
"0.61692953",
"0.61607695",
"0.61509895",
"0.61498183",
"0.61319613",
"0.6127122",
"0.6117994"
] | 0.65516144 | 33 |
GET /resource/cancel Forces the session data which is usually expired after sign in to be expired now. This is useful if the user wants to cancel oauth signing in/up in the middle of the process, removing all OAuth session data. | def cancel
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel(oid, request, session)\n session.clear\n access_denied\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\r\n expire_data_after_sign_in!\r\n redirect_to new_registration_path(resource_name)\r\n end",
"def cancel\n set_session\n\n if @session.cancel\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, notice: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_success\") }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, alert: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_failure\") }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cancel\n id = params[ :id ]\n @user = User.find( id )\n\n # We must have found a user in the database matching the ID.\n # The ID must be provided. There must be a currently logged in\n # user and their ID must match that of the cancellation request.\n # The user must not have a name yet - if they do, it implies a\n # created, active account.\n\n if ( @user.nil? or id.nil? or @current_user.nil? or ( id.to_i() != @current_user.id ) or @user.name )\n flash[ :error ] = \"Cancellation request not understood.\"\n else\n @user.destroy()\n flash[ :error ] = 'Sign in cancelled.'\n end\n\n redirect_to( signout_path() )\n end",
"def cancel(params)\n request(Resources::RESOURCE_CANCEL, HTTP_METHOD_POST, params)\n end",
"def cancel\n @service.context.post(@control_path, :action => 'cancel')\n self\n end",
"def cancel\n appointment_service.put_cancel_appointment(cancel_params)\n head :no_content\n end",
"def cancel(params={})\n self.request(__method__, params)\n end",
"def cancel\n if @event.cancel\n render :json => @event.to_json, :status => :ok\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n end",
"def cancel\n __log_activity\n __debug_route\n __debug_request\n super\n rescue => error\n auth_failure_redirect(message: error)\n end",
"def cancel\n flash[:notice] = \"Canceling accounts is not enabled.\"\n redirect_to root_path\n end",
"def cancel!\n update(request_cancelled: true)\n end",
"def cancel\n session_id = params[:id]\n @package = PackageSession.find(session_id)\n session = @package.session.all\n unless session.empty?\n session['status'] = \"cancel\"\n @package.session.update(session)\n AwsService.push_to_queue_cancel(\"get_package_service\", @package.id)\n end\n\n service_logger.note({cancel_package: session})\n redirect_to :authenticated_root\n end",
"def cancel\n\t\t@notification = Notification::Cancel.new\n\t\t@notification.notifiable = @class_session\n\n\t\tunless params[:notification_cancel].blank?\n\t\t\trespond_to do |format|\n\t\t\t\t@notification.assign_attributes class_session_notification_params\n\t\t\t\tif @notification.save\n\t\t\t\t\t@notification.issue_to @class_session.subscribers\n\n\t\t\t\t\tformat.html { redirect_to @class_session, notice: 'Class session cancellation was successfully posted.' }\n\t\t\t\t\tformat.json { render action: 'show', status: :created, location: @class_session }\n\t\t\t\telse\n\t\t\t\t\tthrow\n\t\t\t\t\tformat.html { render :cancel, error: 'Class session cancellation failed.' }\n\t\t\t\t\tformat.json { render json: notification.errors, status: :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def cancel\n @ride = Ride.find_by_id(params[:ride])\n current_user.cancel!(@ride)\n redirect_to root_path\n end",
"def cancel_event\r\n event = Event.find_by(id: params[:eventid].to_i)\r\n if event.present? && event.user_id == current_user.id\r\n event.update(status: 2)\r\n lt_update_event_status event, 'Canceled'\r\n render json: SuccessResponse.new(\r\n code: 200,\r\n message: 'Event cancelled.'\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new(\r\n code: 404,\r\n message: 'Event not found!'\r\n ), adapter: :json, status: :not_found\r\n end\r\n end",
"def cancel()\n if current_user.state == 'requesting'\n current_user.change_state('online')\n else\n # Notify student that he is not in requesting state\n msg = I18n.t('students.errors.appointment.cancel')\n MessageBroadcastJob.perform_later(msg, 'error',\n student_id: current_user.id)\n end\n end",
"def cancel_and_redirect\r\n redirect_back\r\n end",
"def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end",
"def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end",
"def cancel\n if !current_user.worksessions.include?(@worksession)\n respond_to do |format|\n format.html {\n redirect_to user_worksessions_path(params[:user_id]), notice: 'You cannot cancel a worksession you are not signed up for.'\n }\n format.json { render :show, status: :created, location: @worksession }\n end\n else\n @user.worksessions.delete(@worksession)\n @worksession.users.delete(@user)\n @user.save\n if (@worksession.date.wday.between?(0, 1) and @worksession.users.size < 8) or (@worksession.date.wday.between?(5, 6) and @worksession.users.size < 4)\n @worksession.free = true\n @worksession.save\n end\n redirect_to available_path(current_user)\n @worksession.save\n end\n end",
"def cancel\n @error = :cancelled\n end",
"def cancel\n success = current_subscriber.cancel_subscription\n render json: { success: success }\n end",
"def cancel\n response = CoachClient::Request.delete(url, username: @user1.username,\n password: @user1.password)\n set_user_confirmed(response.to_h)\n self\n end",
"def cancel\n # Context is already cleared in before_action\n end",
"def destroy\n set_cancel_status\n @ticket.save\n Account::Tickets::TicketLogs.cancel(@ticket)\n respond_to do |format|\n format.html { redirect_to @last_page, notice: 'Ticket was successfully canceled.' }\n format.json { head :no_content }\n end\n end",
"def cancel\n redirect_to checkid_request.cancel_url\n end",
"def sign_out\n @logout = true\n authenticate_api_user\n @logout = false\n revoke_access if @current_user\n head :no_content\n end",
"def cancel(id)\n http.post(\"/nfse/#{id}/cancel\") do |response|\n respond_with_entity(response, Entities::NfseStatus)\n end\n end",
"def cancel\n @result = :cancel\n $game_system.se_play($data_system.cancel_se)\n end",
"def revoke\n @session.do_rpc_endpoint('/revoke')\n nil\n end",
"def revoke_token\n request @google + '/accounts/AuthSubRevokeToken'\n\n @session_token = false\n end",
"def sso_session_revoke_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SsoApi.sso_session_revoke ...'\n end\n # resource path\n local_var_path = '/sso/session/revoke'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\n data, status_code, headers = @api_client.call_api(:DELETE, 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: SsoApi#sso_session_revoke\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def cancel_request\n\t\tuser = current_user\n\n\t\tassignment = Assignment.find_by(request_id: params[:request_id])\n\t\tuser.accepteds.delete(assignment)\n\t\tpending_status = RequestStatus.find_by(description: \"pending accept\")\n\t\tpending_status.assignments << assignment\n\n\t\tredirect_back fallback_location: '/home'\n\tend",
"def cancel\n end",
"def cancel\n end",
"def cancel\n self.class.cancel(self)\n end",
"def destroy\n @session_resource.destroy\n\n head :no_content\n end",
"def cancel()\n\t\tagent = spike_login()['agent'] # Mechanize agent at successful login page\n\t\tgsr = spike_login()['gsr'] # Mechanize page = successful login page\n\t\t\n\t\tcancel = gsr.link_with(:text => 'Cancel')\n\t\tif (cancel.nil?)\n\t\t\traise \"Error: You have no GSR reservation to cancel.\"\n\t\telse\n\t\t\tgsr = cancel.click\n\t\tend\n\tend",
"def cancel_request\n if params.key?(:tutor_id) && params.key?(:student_id) && params.key?(:tutor_subject_id)\n pending_request = PendingTutorRequest.where('tutor_id = ? AND student_id = ? AND tutor_subject_id = ?',\n params[:tutor_id],\n params[:student_id],\n params[:tutor_subject_id]).first\n course = Course.find(TutorSubject.find(params[:tutor_subject_id]).course_id)\n else\n pending_request = PendingTutorRequest.find(params[:request_id])\n # Look into see if there is another way to do this.\n course = Course.find(TutorSubject.find(pending_request.tutor_subject_id).course_id)\n end\n\n pending_request.destroy\n course_code = course.course_prefix + course.course_code\n notifcation_params = { 'user_id' => params[:tutor_id],\n 'title' => 'Request Cencelled',\n 'body' => 'A request for ' + course_code + ' has been cancelled.',\n 'icon' => 'request_cancelled',\n 'color' => 'lightgrey',\n 'type' => 'cancel' }\n Notifications.send_notification(notifcation_params)\n\n head :ok\n end",
"def disconnect(token)\n # You could reset the state at this point, but as-is it will still stay unique\n # to this user and we're avoiding resetting the client state.\n # session.delete(:state)\n session.delete(:token)\n\n # Send the revocation request and return the result.\n revokePath = 'https://accounts.google.com/o/oauth2/revoke?token=' + token\n uri = URI.parse(revokePath)\n request = Net::HTTP.new(uri.host, uri.port)\n request.use_ssl = true\n status request.get(uri.request_uri).code\nend",
"def session_destroy(input={}, raw=false)\n response = get('mw/Session.Destroy', input, raw)\n end",
"def revoke\n oauth_access_token.revoke\n head :ok\n end",
"def cancel\n redirect_to root_url, flash[:alert] = \"Something went wrong.\"\n end",
"def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end",
"def cancel\n self.update_status :cancelled\n end",
"def sign_out\n request.session.delete(:authorized)\n end",
"def destroy\n appointment_request = current_user.pending_requests\n .find(params[:request_id])\n if appointment_request.cancel!\n redirect_to root_path\n else\n render status: 500\n end\n end",
"def signed_out_other_scope(resource)\n ActiveRecord::SessionStore::Session.all(:conditions => ['user_id = ?', resource.id]).compact.each do |s|\n begin\n s.destroy\n rescue\n next\n end\n end\n end",
"def sub_cancel\n (@shift = find_params_id(Shift)) || return\n #only user can cancel his own sub request or admin can cancel anybody's sub request\n if request.delete? and (from_admin? or (@shift.user == get_user))\n #somehow @shift.sub.destroy shortcut does not work properly\n s = @shift.sub\n s.destroy\n @shift.save\n redirect_with_flash \"Sub request cancelled.\", :action => :index, :date => @shift.shift_date, :anchor => @shift.shift_date\n else\n redirect_with_flash 'Illegal URL call'\n end\n end",
"def cancel\n @delegation = current_user.managed_delegations.find_by(token: params[:delegation_id])\n if @delegation.nil?\n flash[:alert] = 'You are not authorised to access this page'\n redirect_to delegations_path and return\n else\n @delegation.deactivate('manager')\n flash[:notice] = 'Confirmed! You no longer control the account of ' + @delegation.employee.full_identity\n redirect_to delegations_path and return\n end\n end",
"def cancel\n @confirmation_header = \"confirm cancellation\"\n @confirmation_body = \"Are you Sure to cancel this subscription?\"\n @cancel = \"No, Thank you\"\n @submit = \"Confirm cancellation\"\n end",
"def cancel\r\n # @todo Emit a warning for attempts to cancel an action after it's been\r\n # executed\r\n @cancelled = true\r\n end",
"def uncancel \n @project.update_attribute(:canceled, false)\n redirect_to project_path(@project)\n end",
"def destroy\n if params[:cancel]\n flash[:notice] = t('account.cuenta_no_eliminada', :email => Settings.email_addresses[:contact])\n redirect_to account_path\n else\n @user = User.find(current_user.id)\n if @user.deactivate_account\n self.current_user.forget_me if logged_in?\n cookies.delete :auth_token\n reset_session\n flash[:notice] = t('account.cuenta_eliminada')\n redirect_to root_path\n else\n flash[:error] = t('account.cuenta_no_eliminada_razon')\n redirect_to account_path\n end\n end\n end",
"def force_logout\n sign_out(resource) if user_signed_in?\n end",
"def destroy\n sign_out(resource_name)\n doorkeeper_token.revoke\n\n render_meta message: I18n.t('devise.sessions.signed_out')\n end",
"def cancel\n # Define this later\n end",
"def cancel\n redirect_to( default_path ) if params[:commit] == 'cancel'\n end",
"def cancel_trip\n label = request_label(:cancel, trip_id)\n \n @http_request_bundler.add(\n label, \n @url + \"/cancel_trip\", \n :delete,\n head: headers,\n query: { trip_id: trip_id, customer_id: customer_id, customer_token: customer_token }\n ).response!(label)\n end",
"def revoke_session_with_http_info(revoke_session, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.revoke_session ...'\n end\n # verify the required parameter 'revoke_session' is set\n if @api_client.config.client_side_validation && revoke_session.nil?\n fail ArgumentError, \"Missing the required parameter 'revoke_session' when calling DefaultApi.revoke_session\"\n end\n # resource path\n local_var_path = '/api/kratos/public/sessions'\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[:debug_body] || @api_client.object_to_http_body(revoke_session)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"DefaultApi.revoke_session\",\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(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#revoke_session\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def cancel\n throw(:abort)\n end",
"def logout\n request.env[\"keycard.authentication\"] = notary.reject\n reset_session\n end",
"def destroy\n __log_activity(\"LOGOUT #{current_user}\")\n __debug_route\n __debug_request\n user = current_user&.account&.dup\n opt = BS_AUTH ? { no_revoke: true?(params[:no_revoke]) } : {}\n delete_auth_data(**opt)\n super\n api_clear(user: user)\n set_flash_notice(user: user, clear: true)\n rescue => error\n auth_failure_redirect(message: error)\n end",
"def logout\n response = @session.delete\n @auth_token = nil\n @rest.default_headers = { 'Content-Type' => 'application/json' }\n response\n end",
"def cancel\n # renders static page\n end",
"def user_logout\n res = http_delete(:uri=>\"/session\", :fields=>x_cookie)\n return res.code\n end",
"def disable_my_other_sessions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FrontendApi.disable_my_other_sessions ...'\n end\n # resource path\n local_var_path = '/sessions'\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 header_params[:'X-Session-Token'] = opts[:'x_session_token'] if !opts[:'x_session_token'].nil?\n header_params[:'Cookie'] = opts[:'cookie'] if !opts[:'cookie'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'DeleteMySessionsCount'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"FrontendApi.disable_my_other_sessions\",\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(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FrontendApi#disable_my_other_sessions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def logout\n handler = Proc.new do |request|\n if response.code == 204\n clear_session\n else\n case response.code\n when 401 then\n raise Jiralicious::NotLoggedIn.new(\"Not logged in\")\n else\n # Give Net::HTTP reason\n raise Jiralicious::JiraError.new(response)\n end\n end\n end\n\n request(:delete, '/rest/auth/latest/session', :handler => handler)\n end",
"def paypal_cancel\r\n user_id = params[:user_id]\r\n @user = User.find(user_id)\r\n session[:user_id] = @user[:id]\r\n session[:user_email] = @user[:email]\r\n \r\n cancel_purchase(params[:id])\r\n flash[:notice] = I18n.t 'event.purchase.pur_can'\r\n redirect_to(:controller => 'home', :action=>'index') \r\n end",
"def cancelEnv(cancel)\n $Logger.debug \"Cancelling requests for environment #{cancel.service} #{cancel.zone} #{cancel.envid}\"\n match = @reqList.select{|r| r.zone == cancel.zone && r.service == cancel.service && r.envid == cancel.envid}\n if match == nil or match[0] == nil\n # This can happen if oneenvd cancelling environment which didn't\n # request any resources\n $Logger.debug \"No matching requests for client #{cancel.service} #{cancel.zone} #{cancel.envid}\"\n return\n end\n match.each do |r|\n if r.status == \"ALLOCATED\"\n freeup(r)\n end\n r.status = \"CANCELLED\"\n $eventProcessor.updateRequest(r)\n $eventProcessor.expireRequest(r)\n @reqList.delete(r)\n end\n end",
"def cancel\n order = current_user.customer.orders.find(params[:id])\n order.update(status: 9)\n render json: {is_success: true}, status: :ok\n end",
"def cancel\n cookies.delete :payment_in_process\n redirect_to fines_path, flash: { error: (t 'mylibrary.fine_payment.cancel_html') }\n end",
"def cancel\n set_params\n show_translation\n end",
"def cancel_account\n @account.active = 0\n @account.endtime = Time.now\n @account.save\n \n redirect_to :controller => 'subs' and return false\n end",
"def sign_out(resource_or_scope); end",
"def sign_out(resource_or_scope); end",
"def canceladd\n @session['groupcluster']=nil\n @session['groupshop']=nil\n @session['groupkey']=nil\n render :update do |page|\n page.redirect_to url_for(:controller=>'machines', :action=>'list')\n end\n end",
"def logout\n params = {\n 'method' => :delete,\n 'command' => '/session'\n }\n\n response, headers = send_request(params)\n # reset auth key to nil\n @auth_key = nil\n end",
"def __cancel__(what, &blk)\n req = Request.new\n req.verb = Request::Verb::CANCEL\n req.id = what.tag\n\n # Hold on to the tag as unavaiable for reuse until the cancel succeeds.\n @cbx[what.tag] = nil\n\n send(req) do |res|\n # Do not send any more responses from the server to this request.\n @cbx.delete(what.tag)\n blk.call(res) if blk\n end\n end",
"def cancel(id); end",
"def close\n @repo.request_http(:post, path('session/close'),\n :expected_status_code => 204)\n end",
"def logout\n params = {\n 'method' => :delete,\n 'command' => '/session'\n }\n\n response, headers = send_request(params)\n # reset auth key to nil\n @auth_key = nil\n end",
"def cancel_certificate\n @booking = Booking.where(user_id: current_user.id).first\n if @booking.certificate == true\n @booking.toggle!(:certificate)\n redirect_to account_users_path, flash: {notice: \"Successfully cancelled request!\"}\n end\n end",
"def httpdigest_logout\n session.delete(SESSION_NONCE)\n session.delete(SESSION_OPAQUE)\n end",
"def destroy\n id = shift_argument ||\n raise(Heroku::Command::CommandFailed, \"Usage: sessions:destroy [ID]\")\n session = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :delete,\n :path => \"/oauth/sessions/#{CGI.escape(id)}\"\n ).body\n end\n puts %{Destroyed \"#{session[\"description\"]}\".}\n end",
"def destroy\n current_user.authentication_token = nil\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))\n render json: {status:0, data: nil}\n end",
"def revoke_access_token\n\t\t\tif session[:token]\n\t\t\t\t# Use either the refresh or access token to revoke if present.\n\t\t\t\ttoken = session[:token].to_hash[:refresh_token]\n\t\t\t\ttoken = session[:token].to_hash[:access_token] unless token\n\n\t\t\t\t# You could reset the state at this point, but as-is it will still stay unique\n\t\t\t\t# to this user and we're avoiding resetting the client state.\n\t\t\t\tsession.delete(:state)\n\t\t\t\tsession.delete(:token)\n\n\t\t\t\t# Send the revocation request and return the result.\n\t\t\t\trevokePath = 'https://accounts.google.com/o/oauth2/revoke?token=' + token\n\t\t\t\turi = URI.parse revokePath\n\t\t\t\trequest = Net::HTTP.new uri.host, uri.port\n\t\t\t\trequest.use_ssl = true\n\t\t\t\trequest.get uri.request_uri\n\t\t\tend\n\t\tend"
] | [
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.7368125",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7281023",
"0.71451616",
"0.6626427",
"0.65102315",
"0.65042484",
"0.6466236",
"0.63584906",
"0.6335527",
"0.6331443",
"0.6326783",
"0.63036716",
"0.62206745",
"0.6114911",
"0.6087442",
"0.60335624",
"0.6032042",
"0.6028606",
"0.6024588",
"0.6024588",
"0.60088944",
"0.59825283",
"0.5919095",
"0.5891416",
"0.5885776",
"0.5881988",
"0.58694303",
"0.586385",
"0.5849637",
"0.584065",
"0.5839859",
"0.5830429",
"0.5829066",
"0.5821072",
"0.58082545",
"0.58082545",
"0.5806545",
"0.58049434",
"0.5793194",
"0.5784559",
"0.5776758",
"0.5750495",
"0.57493436",
"0.57404673",
"0.57401365",
"0.57264787",
"0.5726417",
"0.5713067",
"0.5709713",
"0.569967",
"0.5699113",
"0.56945735",
"0.5691282",
"0.5686288",
"0.5662085",
"0.56603277",
"0.56522435",
"0.5645926",
"0.5644968",
"0.56403667",
"0.5634962",
"0.5631677",
"0.562936",
"0.56243336",
"0.56048554",
"0.5600905",
"0.5591914",
"0.5591063",
"0.5581514",
"0.55807954",
"0.556977",
"0.5557016",
"0.5554723",
"0.5548741",
"0.5531006",
"0.5525518",
"0.5525518",
"0.55124784",
"0.55094105",
"0.5501725",
"0.5499575",
"0.5496341",
"0.549422",
"0.54909116",
"0.5487487",
"0.5479953",
"0.54623055",
"0.54613674"
] | 0.0 | -1 |
You can put the params you want to permit in the empty array. | def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :nationality_id ])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permitted_params\n []\n end",
"def additional_permitted_params\n []\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\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 multiple_params\n \tparams.require(:posts).permit!\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def permitted_params\n columns.map { |name,multiple| multiple ? { name => [] } : name }\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def formulary_params\n allow = [:responsable_llenado,:cod01,:cod02,:ape01,:ape04,:ape07,:ape02,:ape05,:ape03,:ape06,:api01,:api04,:api02,:ssb01,:api03,:cao01,:cao04,:cao07,:cao10,:tit01,:cao02,:cao05,:cao08,:cao11,:cao03,:cao06,:cao09,:cao12,:uni01,:uni02,:uni03,:ben01,:ben02,:per01,:per02,:user_id]\n params.require(:formulary).permit(allow)\n end",
"def mandatory_params\n return {}\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 post_params\n permit_params\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def activity_params\n params[:activity].permit!\n end",
"def expected_permitted_parameter_names; end",
"def user_params\n params.require(:user).permit({post_ids: []}, :name)\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 permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def submission_params\n allowed = :student_number, :last_name, :first_name, :week, :hours, :comments, :email, :github, :challenging\n (1..Course.current.exercises_max).each do |i|\n allowed << \"a#{i}\".to_s\n end\n params.require(:submission).permit(allowed)\n end",
"def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end",
"def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end",
"def permit_params\n params.require(:permit).permit(:permit_type, :applicant_name, :start_date, :end_date, :address, :payload, :geometry)\n end",
"def block_params\n params.require(required_params).permit(default_permitted_attributes)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def permitted_params\n if is_singleton?\n singleton_permitted_params\n else\n params.require(:data).permit(allowed_resource_params.to_a)\n end\n end",
"def build_permitted_params\n super + [\n { date_of_work_attributes: permitted_time_span_params },\n { inscription_attributes: permitted_inscription_params },\n { additional_credit_attributes: permitted_additional_credit_params },\n after: [],\n artist: [],\n attributed_to: [],\n author: [],\n addressee: [],\n creator_of_work: [],\n contributor: [],\n editor: [],\n engraver: [],\n interviewee: [],\n interviewer: [],\n manner_of: [],\n school_of: [],\n manufacturer: [],\n photographer: [],\n printer: [],\n printer_of_plates: [],\n publisher: [],\n place_of_interview: [],\n place_of_manufacture: [],\n place_of_publication: [],\n place_of_creation: [],\n ]\n end",
"def add_authorize_empty_params(post)\n post[:iata] = nil\n post[:concentrador] = nil\n post[:taxaembarque] = nil\n post[:entrada] = nil\n post[:numdoc1] = nil\n post[:numdoc2] = nil\n post[:numdoc3] = nil\n post[:numdoc4] = nil\n post[:pax1] = nil\n post[:pax2] = nil\n post[:pax3] = nil\n post[:pax4] = nil\n post[:conftxn] = 'S'\n post[:add_data] = nil\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitted_params(action, kind=nil)\n params.require(model_name).permit!\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def post_block_params\n permit_params\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 data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def permit_params_on_create *keys\n filter_strong_params :permit, [:create], keys\n end",
"def member_params\n # params[:member][:car_nums] = unless params[:member][:car_nums].blank?\n params.require(:member).permit(:name, :flat_no, :tower_no, :mob_num, :email, :alt_no, :blood_group, :occupation, :family_memebers, :adult, :kids, :bio, :password, :password_confirmation, :car_nums, roles: [])\n end",
"def user_params\n allowed_params = [:username, :email, :jabber_id, :jabber_otr_fingerprint, :avatar]\n allowed_params << [:password, :password_confirmation] unless params[:user][:password].blank?\n allowed_params << [:role] if current_user.moderator_or_admin?\n allowed_params << [:tenant_ids => []] if current_user.admin?\n allowed_params << [:user_ids => []] if current_user.moderator_or_admin?\n params.require(:user).permit(allowed_params)\n end",
"def exclude_default_params(params)\n params - %w(id created_at updated_at slug position)\n end",
"def trade_params\n params.permit(trade_offers: {})\n end",
"def presenter_params\n params.require(:participant).permit(:name, :email, :bio).to_h.each_with_object({}) do |(k, v), h|\n h[k] = v.blank? ? nil : v\n end\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def unlimited_params\n params[:unlimited]\n end",
"def project_params\n params.require(:project).permit(:name, {:user_ids => []})\n end",
"def article_params\n params.require(:article).permit(:title , :description, {images: []}, {videos: []}, :user_id, tag_list: [])\n end",
"def clean_params(params)\n params.slice()\n end",
"def volunteer_work_params\n \n params.require(:volunteer_work).permit( :name, :company, :dates => [], :city => [], :province => [], :skills => [], :tags => [] )\n end",
"def preco_rotum_params\n params.permit()\n end",
"def permitted_create_params\n fail NotImplementedError\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 post_params\n params.require(:post).permit(:body, {tag_ids: []}, {tag_list: []})\n end",
"def will_params\n wills = params.select { |k, _v| k.starts_with?(\"vault_entry_\") }\n permitted_params = {}\n wills.keys.each do |will|\n permitted_params[will] = [:id, :title, :executor_id, :notes, :agent_ids, :document_id, primary_beneficiary_ids: [], secondary_beneficiary_ids: [], share_ids: [], share_with_contact_ids: []]\n end\n wills.permit(permitted_params)\n end",
"def blank_to_nil_params\n params[:nyucore].merge!(params[:nyucore]){|k, v| v.blank? ? nil : v.is_a?(Array) ? v.reject{|c| c.empty? } : v}\n end",
"def participant_params\n params.require(:participant).permit(:first_name => [] , :last_name => [], :email => [], :gender => [])\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\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 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 post_params\n params.require(:post).permit!\n end",
"def index_params\n params[:page] ||= '1'\n params[:limit] ||= '50'\n params.permit :page, :limit\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def category_params\n params[:category][:related_category_ids].reject! { |c| c.empty? } if params[:category][:related_category_ids]\n params[:category][:related_by_category_ids].reject! { |c| c.empty? } if params[:category][:related_by_category_ids]\n params[:category][:suggested_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_category_ids]\n params[:category][:suggested_by_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_by_category_ids]\n \n params.require(:category).permit(:name, :is_course_type, :related_category_ids => [], :related_by_category_ids => [], :suggested_category_ids => [], :suggested_by_category_ids => [])\n end",
"def quote_params\n params.permit!\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def user_params\n permitted_parameters = [:name, :email, :password, :password_confirmation]\n\n params.slice(*permitted_parameters).permit(*permitted_parameters)\n end",
"def filter_params\n params.permit(\n type: [],\n id: []\n ).to_h.symbolize_keys.merge!(project_id: sessions_current_project_id)\n end",
"def params\n {}\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 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 activity_params \n \n raw_parameters = { \n :activity_Name => \"#{params[:activity_name]}\",\n :active => \"#{params[:active]}\",\n :activity_description => \"#{params[:activity_description]}\",\n :is_page => \"#{params[:is_page]}\"\n }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit( :activity_Name, :active, :activity_description, :is_page)\n \n end",
"def upload_params\n permit = policy(@upload || Upload).permitted_attributes\n params.require(:upload).permit(*permit)\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.require(:person).permit(:name, :gender, :phone, :email, :date_of_birth, {:role_ids => []})\n end",
"def permitted_params\n @permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def non_create_params\n\t\t\tparams.require(:main_class).permit(:name, :position, :pic_url, :desc)\n\t\tend",
"def post_params\n params.require(:post).permit(:title, :body, :url, :user_id, :tag_list, religion_ids: [] )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end",
"def unpermitted_parameters\n fail 'Define me!'\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def subscription_list_params\n #params[:subscription_list].permit(:name, :description)\n #params.permit(:careers, :years, :subjects).permit(subscription_list: [ :name, :description ])\n #params.permit(:careers).require(:subscription_list).permit(:name, :description)\n params.permit! # So far, no strong params here...\n end",
"def blank_wall_params\n params.require(:blank_wall).permit!\n end",
"def payment_request_params\n params.require(:payment_request).permit!\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def post_params\n #params.require(:post).permit(:content, :user_id, :asset, :tag_list) //was not able to figure out how to pass all the params in post, revisit this\n params.permit(:content, :user_id, :asset, :tag_list)\n end",
"def permitted_params\n @permitted_params ||= declared(params,\n include_missing: false,\n include_parent_namespaces: false)\n end",
"def crew_params\n valid_params = Crew.attribute_names.reject do |item|\n item.match(/^_id/)\n end\n [:first_name, :last_name].each_with_object(params) do |key, obj|\n params.require(key)\n end\n valid_params.concat([:page, movie_ids: [], images: [], videos: []])\n params.permit(valid_params)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def user_params\n params.permit(:ids, :name, :email)\n end",
"def type_of_meeting_params\n params.require(:type_of_meeting).except(:title_obtained_ids).permit(:name, :description, :code,\n pre_attendance_meetings_attributes:\n [:title_obtained_id]\n )\n\n end",
"def contest_params\n params[\"params\"].require(:contest).permit(:contest_type, :battlepet_traits => [], :battlepets => [])\n end",
"def permit(keys, key=nil, options={})\n filter! keys, (key.nil? ? params : params[key]), options if keys.any?\n self\n end",
"def params\n {}\n end",
"def post_params\n params.permit(:stars,\n :title,\n :comment,\n :course_id,\n :user_id,\n post_tag_ids: [])\n end"
] | [
"0.80368435",
"0.7541075",
"0.74603844",
"0.7257798",
"0.7257798",
"0.72326684",
"0.7149882",
"0.7099853",
"0.7041125",
"0.6992933",
"0.6952879",
"0.6906974",
"0.6879301",
"0.6855218",
"0.6844021",
"0.6841371",
"0.6808235",
"0.6803163",
"0.6794589",
"0.67901534",
"0.6788",
"0.6773296",
"0.6769235",
"0.67588705",
"0.6751326",
"0.6743761",
"0.674056",
"0.6736899",
"0.6724555",
"0.6722401",
"0.6715796",
"0.67154276",
"0.66960835",
"0.6680739",
"0.6675339",
"0.66529137",
"0.66276324",
"0.660373",
"0.66012853",
"0.65872496",
"0.6581735",
"0.6580954",
"0.65720606",
"0.6558704",
"0.6554613",
"0.65486264",
"0.65408254",
"0.65345013",
"0.6534454",
"0.65311825",
"0.6529169",
"0.6521579",
"0.6519193",
"0.6518676",
"0.65116984",
"0.6510258",
"0.650051",
"0.6499379",
"0.64883727",
"0.6475287",
"0.6474761",
"0.64676183",
"0.64630896",
"0.6458213",
"0.64562273",
"0.6453912",
"0.6453021",
"0.6450526",
"0.6443112",
"0.64387417",
"0.6437082",
"0.6428528",
"0.64282376",
"0.64239836",
"0.6421474",
"0.6412557",
"0.6411592",
"0.640357",
"0.6402974",
"0.6401915",
"0.63941145",
"0.63897866",
"0.6388448",
"0.638716",
"0.63862216",
"0.6383591",
"0.6378583",
"0.6377337",
"0.63699573",
"0.6369347",
"0.6363451",
"0.63621604",
"0.63538367",
"0.63506997",
"0.63471603",
"0.6346069",
"0.63450384",
"0.6343425",
"0.63385963",
"0.6334606",
"0.63339233"
] | 0.0 | -1 |
You can put the params you want to permit in the empty array. | def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permitted_params\n []\n end",
"def additional_permitted_params\n []\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\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 multiple_params\n \tparams.require(:posts).permit!\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def permitted_params\n columns.map { |name,multiple| multiple ? { name => [] } : name }\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def formulary_params\n allow = [:responsable_llenado,:cod01,:cod02,:ape01,:ape04,:ape07,:ape02,:ape05,:ape03,:ape06,:api01,:api04,:api02,:ssb01,:api03,:cao01,:cao04,:cao07,:cao10,:tit01,:cao02,:cao05,:cao08,:cao11,:cao03,:cao06,:cao09,:cao12,:uni01,:uni02,:uni03,:ben01,:ben02,:per01,:per02,:user_id]\n params.require(:formulary).permit(allow)\n end",
"def mandatory_params\n return {}\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 post_params\n permit_params\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def activity_params\n params[:activity].permit!\n end",
"def expected_permitted_parameter_names; end",
"def user_params\n params.require(:user).permit({post_ids: []}, :name)\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 permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def submission_params\n allowed = :student_number, :last_name, :first_name, :week, :hours, :comments, :email, :github, :challenging\n (1..Course.current.exercises_max).each do |i|\n allowed << \"a#{i}\".to_s\n end\n params.require(:submission).permit(allowed)\n end",
"def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end",
"def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end",
"def permit_params\n params.require(:permit).permit(:permit_type, :applicant_name, :start_date, :end_date, :address, :payload, :geometry)\n end",
"def block_params\n params.require(required_params).permit(default_permitted_attributes)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def permitted_params\n if is_singleton?\n singleton_permitted_params\n else\n params.require(:data).permit(allowed_resource_params.to_a)\n end\n end",
"def build_permitted_params\n super + [\n { date_of_work_attributes: permitted_time_span_params },\n { inscription_attributes: permitted_inscription_params },\n { additional_credit_attributes: permitted_additional_credit_params },\n after: [],\n artist: [],\n attributed_to: [],\n author: [],\n addressee: [],\n creator_of_work: [],\n contributor: [],\n editor: [],\n engraver: [],\n interviewee: [],\n interviewer: [],\n manner_of: [],\n school_of: [],\n manufacturer: [],\n photographer: [],\n printer: [],\n printer_of_plates: [],\n publisher: [],\n place_of_interview: [],\n place_of_manufacture: [],\n place_of_publication: [],\n place_of_creation: [],\n ]\n end",
"def add_authorize_empty_params(post)\n post[:iata] = nil\n post[:concentrador] = nil\n post[:taxaembarque] = nil\n post[:entrada] = nil\n post[:numdoc1] = nil\n post[:numdoc2] = nil\n post[:numdoc3] = nil\n post[:numdoc4] = nil\n post[:pax1] = nil\n post[:pax2] = nil\n post[:pax3] = nil\n post[:pax4] = nil\n post[:conftxn] = 'S'\n post[:add_data] = nil\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitted_params(action, kind=nil)\n params.require(model_name).permit!\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def post_block_params\n permit_params\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 data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def permit_params_on_create *keys\n filter_strong_params :permit, [:create], keys\n end",
"def member_params\n # params[:member][:car_nums] = unless params[:member][:car_nums].blank?\n params.require(:member).permit(:name, :flat_no, :tower_no, :mob_num, :email, :alt_no, :blood_group, :occupation, :family_memebers, :adult, :kids, :bio, :password, :password_confirmation, :car_nums, roles: [])\n end",
"def user_params\n allowed_params = [:username, :email, :jabber_id, :jabber_otr_fingerprint, :avatar]\n allowed_params << [:password, :password_confirmation] unless params[:user][:password].blank?\n allowed_params << [:role] if current_user.moderator_or_admin?\n allowed_params << [:tenant_ids => []] if current_user.admin?\n allowed_params << [:user_ids => []] if current_user.moderator_or_admin?\n params.require(:user).permit(allowed_params)\n end",
"def exclude_default_params(params)\n params - %w(id created_at updated_at slug position)\n end",
"def trade_params\n params.permit(trade_offers: {})\n end",
"def presenter_params\n params.require(:participant).permit(:name, :email, :bio).to_h.each_with_object({}) do |(k, v), h|\n h[k] = v.blank? ? nil : v\n end\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def unlimited_params\n params[:unlimited]\n end",
"def project_params\n params.require(:project).permit(:name, {:user_ids => []})\n end",
"def article_params\n params.require(:article).permit(:title , :description, {images: []}, {videos: []}, :user_id, tag_list: [])\n end",
"def clean_params(params)\n params.slice()\n end",
"def volunteer_work_params\n \n params.require(:volunteer_work).permit( :name, :company, :dates => [], :city => [], :province => [], :skills => [], :tags => [] )\n end",
"def preco_rotum_params\n params.permit()\n end",
"def permitted_create_params\n fail NotImplementedError\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 post_params\n params.require(:post).permit(:body, {tag_ids: []}, {tag_list: []})\n end",
"def will_params\n wills = params.select { |k, _v| k.starts_with?(\"vault_entry_\") }\n permitted_params = {}\n wills.keys.each do |will|\n permitted_params[will] = [:id, :title, :executor_id, :notes, :agent_ids, :document_id, primary_beneficiary_ids: [], secondary_beneficiary_ids: [], share_ids: [], share_with_contact_ids: []]\n end\n wills.permit(permitted_params)\n end",
"def blank_to_nil_params\n params[:nyucore].merge!(params[:nyucore]){|k, v| v.blank? ? nil : v.is_a?(Array) ? v.reject{|c| c.empty? } : v}\n end",
"def participant_params\n params.require(:participant).permit(:first_name => [] , :last_name => [], :email => [], :gender => [])\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\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 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 post_params\n params.require(:post).permit!\n end",
"def index_params\n params[:page] ||= '1'\n params[:limit] ||= '50'\n params.permit :page, :limit\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def category_params\n params[:category][:related_category_ids].reject! { |c| c.empty? } if params[:category][:related_category_ids]\n params[:category][:related_by_category_ids].reject! { |c| c.empty? } if params[:category][:related_by_category_ids]\n params[:category][:suggested_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_category_ids]\n params[:category][:suggested_by_category_ids].reject! { |c| c.empty? } if params[:category][:suggested_by_category_ids]\n \n params.require(:category).permit(:name, :is_course_type, :related_category_ids => [], :related_by_category_ids => [], :suggested_category_ids => [], :suggested_by_category_ids => [])\n end",
"def quote_params\n params.permit!\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def user_params\n permitted_parameters = [:name, :email, :password, :password_confirmation]\n\n params.slice(*permitted_parameters).permit(*permitted_parameters)\n end",
"def filter_params\n params.permit(\n type: [],\n id: []\n ).to_h.symbolize_keys.merge!(project_id: sessions_current_project_id)\n end",
"def params\n {}\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 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 activity_params \n \n raw_parameters = { \n :activity_Name => \"#{params[:activity_name]}\",\n :active => \"#{params[:active]}\",\n :activity_description => \"#{params[:activity_description]}\",\n :is_page => \"#{params[:is_page]}\"\n }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit( :activity_Name, :active, :activity_description, :is_page)\n \n end",
"def upload_params\n permit = policy(@upload || Upload).permitted_attributes\n params.require(:upload).permit(*permit)\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.require(:person).permit(:name, :gender, :phone, :email, :date_of_birth, {:role_ids => []})\n end",
"def permitted_params\n @permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def non_create_params\n\t\t\tparams.require(:main_class).permit(:name, :position, :pic_url, :desc)\n\t\tend",
"def post_params\n params.require(:post).permit(:title, :body, :url, :user_id, :tag_list, religion_ids: [] )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end",
"def unpermitted_parameters\n fail 'Define me!'\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def subscription_list_params\n #params[:subscription_list].permit(:name, :description)\n #params.permit(:careers, :years, :subjects).permit(subscription_list: [ :name, :description ])\n #params.permit(:careers).require(:subscription_list).permit(:name, :description)\n params.permit! # So far, no strong params here...\n end",
"def blank_wall_params\n params.require(:blank_wall).permit!\n end",
"def payment_request_params\n params.require(:payment_request).permit!\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def post_params\n #params.require(:post).permit(:content, :user_id, :asset, :tag_list) //was not able to figure out how to pass all the params in post, revisit this\n params.permit(:content, :user_id, :asset, :tag_list)\n end",
"def permitted_params\n @permitted_params ||= declared(params,\n include_missing: false,\n include_parent_namespaces: false)\n end",
"def crew_params\n valid_params = Crew.attribute_names.reject do |item|\n item.match(/^_id/)\n end\n [:first_name, :last_name].each_with_object(params) do |key, obj|\n params.require(key)\n end\n valid_params.concat([:page, movie_ids: [], images: [], videos: []])\n params.permit(valid_params)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def user_params\n params.permit(:ids, :name, :email)\n end",
"def type_of_meeting_params\n params.require(:type_of_meeting).except(:title_obtained_ids).permit(:name, :description, :code,\n pre_attendance_meetings_attributes:\n [:title_obtained_id]\n )\n\n end",
"def contest_params\n params[\"params\"].require(:contest).permit(:contest_type, :battlepet_traits => [], :battlepets => [])\n end",
"def permit(keys, key=nil, options={})\n filter! keys, (key.nil? ? params : params[key]), options if keys.any?\n self\n end",
"def params\n {}\n end",
"def post_params\n params.permit(:stars,\n :title,\n :comment,\n :course_id,\n :user_id,\n post_tag_ids: [])\n end"
] | [
"0.80368435",
"0.7541075",
"0.74603844",
"0.7257798",
"0.7257798",
"0.72326684",
"0.7149882",
"0.7099853",
"0.7041125",
"0.6992933",
"0.6952879",
"0.6906974",
"0.6879301",
"0.6855218",
"0.6844021",
"0.6841371",
"0.6808235",
"0.6803163",
"0.6794589",
"0.67901534",
"0.6788",
"0.6773296",
"0.6769235",
"0.67588705",
"0.6751326",
"0.6743761",
"0.674056",
"0.6736899",
"0.6724555",
"0.6722401",
"0.6715796",
"0.67154276",
"0.66960835",
"0.6680739",
"0.6675339",
"0.66529137",
"0.66276324",
"0.660373",
"0.66012853",
"0.65872496",
"0.6581735",
"0.6580954",
"0.65720606",
"0.6558704",
"0.6554613",
"0.65486264",
"0.65408254",
"0.65345013",
"0.6534454",
"0.65311825",
"0.6529169",
"0.6521579",
"0.6519193",
"0.6518676",
"0.65116984",
"0.6510258",
"0.650051",
"0.6499379",
"0.64883727",
"0.6475287",
"0.6474761",
"0.64676183",
"0.64630896",
"0.6458213",
"0.64562273",
"0.6453912",
"0.6453021",
"0.6450526",
"0.6443112",
"0.64387417",
"0.6437082",
"0.6428528",
"0.64282376",
"0.64239836",
"0.6421474",
"0.6412557",
"0.6411592",
"0.640357",
"0.6402974",
"0.6401915",
"0.63941145",
"0.63897866",
"0.6388448",
"0.638716",
"0.63862216",
"0.6383591",
"0.6378583",
"0.6377337",
"0.63699573",
"0.6369347",
"0.6363451",
"0.63621604",
"0.63538367",
"0.63506997",
"0.63471603",
"0.6346069",
"0.63450384",
"0.6343425",
"0.63385963",
"0.6334606",
"0.63339233"
] | 0.0 | -1 |
The path used after sign up. | def after_sign_up_path_for(resource)
super(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n root? ? boot_path : user_path\n end",
"def path\n root? ? boot_path : user_path\n end",
"def client_signed_up_path\n path_from_cookie(:after_account_signed_up_path) || path_from_cookie(:after_client_signed_up_path) || edit_user_client_path(current_user)\n end",
"def after_sign_up_path_for(_resource)\n return new_user_session_path\n end",
"def after_sign_up_path_for(user)\n return root_url\n end",
"def after_sign_up_path_for(_resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n user_path(resource)\n end",
"def after_sign_up_path_for(resource)\n user_path(resource)\n end",
"def after_sign_up_path_for(resource)\n\t root_path + \"home\"\n end",
"def after_sign_up_path_for(resource)\n profile_path\n end",
"def after_sign_up_path_for(resource)\r\n root_path\r\n end",
"def after_sign_up_path_for(resource)\n stored_location_for(resource) || edit_user_registration_path\n end",
"def path\n \"users/#{@login}\"\n end",
"def after_sign_up_path_for(resource)\n \"/\"\n end",
"def after_sign_up_path_for(resource)\n users_repo_init_path\n end",
"def after_sign_up_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n user_path(resource)\n end",
"def login_path\n ::File.join *[@login_path.to_s, name_unless_default].compact\n end",
"def signed_in_root_path(_)\n current_tribunal_case ? users_login_save_confirmation_path : users_cases_path\n end",
"def after_sign_up_path_for(resource)\n home_user_path(resource)\n end",
"def after_sign_up_path_for(resource)\n user_path(current_user)\n end",
"def after_sign_up_path_for(resource)\n\n end",
"def after_sign_up_path_for(user)\n after_sign_in_path_for(user)\n end",
"def after_sign_up_path_for(resource)\n new_user_session_path\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n super\n end",
"def after_sign_up_path_for(_resource)\n new_participant_session_path\n end",
"def after_sign_up_path_for(resource)\n after_register_path\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n :pre_created\n end",
"def user_root_path\n users_root_path\n end",
"def after_sign_up_path_for(resource)\n get_started_path\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n '/carrier/sign_up_complete'\n end",
"def after_sign_up_path_for(resource)\n complete_user_registration_path\n end",
"def storage_path\n File.join(\n SystemConfiguration.first.storage_path, 'users', email)\n end",
"def file_path\n PATH_USER_DEFAULTS\n end",
"def after_sign_up_path_for(resource)\n users_path\n end",
"def after_sign_up_path_for(resource)\n users_path\n end",
"def path\n ensure_valid\n @path\n end",
"def after_sign_up_path_for(_resource)\n edit_user_registration_path\n end",
"def after_sign_up_path_for(resource)\n user_steps_path\n end",
"def after_sign_up_path_for(resource)\n # super(resource)\n account_path(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n session[:user_return_to] || root_path\n end",
"def after_sign_up_path_for(resource)\n usermgmt_path\n end",
"def after_sign_in_path_for(_resource)\n user_path(current_user.id) # ログイン後に遷移するpathを設定\n end",
"def after_sign_up_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_up_path_for(resource)\n :new_reparation\nend",
"def template_path()\n 'auth/signup.erb'\n end",
"def web_users_path\n verify_path WEB_USERS_PATH\n File.join @tar_contents_path, WEB_USERS_PATH\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource) if is_navigational_format?\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource) if is_navigational_format?\n end",
"def after_sign_up_path_for(resource)\n session[:orga_id] = resource.organisation_id\n user_steps_path(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n welcome_path\n end",
"def after_inactive_sign_up_path_for(resource)\n root_path\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || account_url\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_sign_up_path_for(resource)\n edit_user_path(resource.id)\n end",
"def after_sign_up_path_for(resource)\n :new_profile # Or :prefix_to_your_route\n end",
"def spree_signup_path\n main_app.login_path\n end",
"def after_sign_up_path_for(resource)\n company_path(current_user.company_id )\n end",
"def after_sign_up_path_for(resource)\n new_political_party_path\n end"
] | [
"0.74486095",
"0.74486095",
"0.7348926",
"0.72428125",
"0.71978325",
"0.7191859",
"0.71229225",
"0.71229225",
"0.7114739",
"0.7110063",
"0.71050537",
"0.70890594",
"0.7078605",
"0.70710707",
"0.7039824",
"0.69836",
"0.69836",
"0.69836",
"0.69836",
"0.69687116",
"0.69687116",
"0.69687116",
"0.695565",
"0.6952114",
"0.69462943",
"0.69291764",
"0.692384",
"0.6923245",
"0.6908656",
"0.6892842",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68918073",
"0.68619215",
"0.6849449",
"0.6848581",
"0.68387353",
"0.68329126",
"0.6826204",
"0.6825744",
"0.6811003",
"0.6811003",
"0.6811003",
"0.6805664",
"0.6790916",
"0.67705876",
"0.6764743",
"0.67595524",
"0.67595524",
"0.67446005",
"0.6742484",
"0.673662",
"0.67358214",
"0.67320126",
"0.6713388",
"0.66983753",
"0.66732067",
"0.6667262",
"0.6660478",
"0.6656764",
"0.66527593",
"0.6648839",
"0.6648839",
"0.6642064",
"0.6639703",
"0.6632311",
"0.66255736",
"0.66065633",
"0.66065633",
"0.660423",
"0.65959823",
"0.6594243",
"0.6587384",
"0.65813607",
"0.65472794",
"0.65358824"
] | 0.67457646 | 73 |
The path used after sign up for inactive accounts. | def after_inactive_sign_up_path_for(resource)
super(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n root_path\n end",
"def after_inactive_sign_up_path_for(resource)\n after_sign_up_path_for(resource)\n end",
"def path\n root? ? boot_path : user_path\n end",
"def path\n root? ? boot_path : user_path\n end",
"def after_inactive_sign_up_path_for(_resource)\n new_user_session_path\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n root_path\n end",
"def after_inactive_sign_up_path_for(resource)\n root_path\n end",
"def after_inactive_sign_up_path_for(resource)\n \tputs \"---------------------------------------------------------------\"\n birth_plans_path\n end",
"def after_inactive_sign_up_path_for(resource)\n home_user_path(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n \"/users/sign_up\"\n end",
"def after_inactive_sign_up_path_for(resource)\n after_signup_path\n end",
"def after_inactive_sign_up_path_for(resource)\n super\n end",
"def after_inactive_sign_up_path_for(resource)\n new_user_session_url\n end",
"def after_inactive_sign_up_path_for(resource)\n new_owner_session_path\n end",
"def after_inactive_sign_up_path_for(_resource)\n new_participant_session_path\n end",
"def after_sign_up_path_for(_resource)\n return new_user_session_path\n end",
"def after_inactive_sign_up_path_for(resource)\n new_user_session_path\n end",
"def after_inactive_sign_up_path_for(resource)\n new_user_session_path\n end",
"def after_inactive_sign_up_path_for(resource)\n company_path(current_user.company_id )\n end",
"def after_inactive_sign_up_path_for(resource)\n #logger.debug(\"after_inactive_sign_up_path_for\")\n new_usuario_session_path\n end",
"def after_inactive_sign_up_path_for(resource)\n new_session_path(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n localized_root_path\n end",
"def client_signed_up_path\n path_from_cookie(:after_account_signed_up_path) || path_from_cookie(:after_client_signed_up_path) || edit_user_client_path(current_user)\n end",
"def after_inactive_sign_up_path_for(resource)\n # super(resource)\n session[THANKS_KEY] = { email: resource[:email] }\n if resource.individual_use == true\n users_thanks_personal_path\n else\n users_thanks_company_path\n end\n end",
"def after_inactive_sign_up_path_for(_resource)\n users_confirmations_pending_path\n end",
"def after_inactive_sign_up_path_for(_resource)\n users_confirmations_pending_path\n end",
"def after_inactive_sign_up_path_for(resource)\n '/public/index'\n end",
"def after_inactive_sign_up_path_for(resource)\n \t new_user_registration_path\n end",
"def after_inactive_sign_up_path_for(_resource)\n consultant_welcome_path\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n end",
"def login_path\n ::File.join *[@login_path.to_s, name_unless_default].compact\n end",
"def after_inactive_sign_up_path_for(resource)\n user_steps_path\n end",
"def signed_in_root_path(_)\n current_tribunal_case ? users_login_save_confirmation_path : users_cases_path\n end",
"def after_inactive_sign_up_path_for(resource)\n \"/allusers\"\n end",
"def path\n \"users/#{@login}\"\n end",
"def after_inactive_sign_up_path_for(resource)\n '/app/users/registration/confirm'\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n # users_popups_email_verification_path\n end",
"def after_sign_up_path_for(resource)\n # super(resource)\n account_path(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n signup_success_path\n end",
"def after_inactive_sign_up_path_for(resource)\n signup_success_path\n end",
"def after_inactive_sign_up_path_for(resource, account=nil)\n if account.nil?\n super(resource)\n else\n signin_url(subdomain: account.subdomain)\n end\n end",
"def after_inactive_sign_up_path_for(resource)\n new_political_party_path\n end",
"def after_sign_up_path_for(user)\n return root_url\n end",
"def after_sign_up_path_for(resource)\n profile_path\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n end",
"def after_sign_up_path_for(resource)\n get_started_path\n end",
"def after_inactive_sign_up_path_for(resource)\n rent_path\n end",
"def after_inactive_sign_up_path_for(resource)\n #scope = Devise::Mapping.find_scope!(resource)\n #router_name = Devise.mappings[scope].router_name\n #context = router_name ? send(router_name) : self\n #context.respond_to?(:root_path) ? context.root_path : \"/\"\n after_sign_in_path_for(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : '/'\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\nend",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\nend",
"def after_sign_up_path_for(resource)\n \"/\"\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || account_url\n end",
"def after_sign_up_path_for(_resource)\n root_path\n end",
"def after_inactive_sign_up_path_for(resource)\n thank_you_path\n end",
"def after_sign_up_path_for(resource)\n\t root_path + \"home\"\n end",
"def after_sign_up_path_for(resource)\n user_path(resource)\n end",
"def after_sign_up_path_for(resource)\n user_path(resource)\n end",
"def after_sign_up_path_for(resource)\r\n root_path\r\n end",
"def account_url\n return new_user_session_url unless user_signed_in?\n return :user_dashboard_url\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n # context.respond_to?(:index) ? context.index : \"/users\"\n end",
"def after_inactive_sign_up_path_for(resource)\n users_sign_up_email_notice_path(email: resource.email)\n end",
"def base_path\n super.concat '/account_plans'\n end",
"def user_root_path\n users_root_path\n end",
"def after_sign_up_path_for(resource)\n stored_location_for(resource) || edit_user_registration_path\n end",
"def path\n ['cloud-service-auth', 'accounts', @id].join('/')\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(user)\n company_url(user.active_company)\n end",
"def after_sign_up_path_for(resource)\n home_user_path(resource)\n end"
] | [
"0.7342214",
"0.7208575",
"0.7208575",
"0.7208575",
"0.7208575",
"0.7208575",
"0.72034144",
"0.7187855",
"0.71851933",
"0.71851933",
"0.7151745",
"0.7103472",
"0.7103472",
"0.71002626",
"0.71002626",
"0.7090088",
"0.70668596",
"0.70622385",
"0.70227474",
"0.701897",
"0.6981119",
"0.69775355",
"0.6970644",
"0.6957335",
"0.69535923",
"0.69535923",
"0.6952369",
"0.69389826",
"0.6926664",
"0.69197375",
"0.6908496",
"0.69001985",
"0.6878569",
"0.6878569",
"0.68631566",
"0.68554735",
"0.6843958",
"0.68200445",
"0.68200445",
"0.68200445",
"0.6811842",
"0.6808035",
"0.68062717",
"0.6801017",
"0.67729765",
"0.6751609",
"0.67471075",
"0.67456776",
"0.673048",
"0.673048",
"0.6721262",
"0.67155033",
"0.6712895",
"0.66971886",
"0.6696238",
"0.6696238",
"0.6696238",
"0.6696238",
"0.6696238",
"0.6696238",
"0.6679159",
"0.66771066",
"0.6675915",
"0.665816",
"0.6657196",
"0.6657196",
"0.663949",
"0.6632364",
"0.66020983",
"0.65987784",
"0.6592162",
"0.65774137",
"0.65774137",
"0.65748847",
"0.6574225",
"0.65702456",
"0.65517175",
"0.65115905",
"0.6503173",
"0.65026367",
"0.6499337",
"0.64965606",
"0.64965606",
"0.64965606",
"0.64847815",
"0.648457"
] | 0.6995652 | 34 |
def cost league = League.find_by_id(params[:id]) render plain: league.cost end def people_in_league league = League.find_by_id(params[:id]) render plain: league.people_in_league end | def show
@user = User.find(session[:user_id])
@league = League.find_by(id: params[:id])
respond_to do |form|
form.html{render :show}
form.json{render json: @league}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team\n @team = Team.where('team_id = ?', params[:id])\n @active_stats = ActiveStat.where('team_id = ?', params[:id])\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def show\n @leaguemembers = League.find(params[:id]).users\n @matches = Match.where(:league_id => params[:id])\n \n end",
"def show\n @teamSponsors = TeamsSponsor.eager_load(:sponsor).where(:team_id => params[:id])\n @teamsRosters = Roster.includes(:profile => :rating).where(:team_id => params[:id]).order('profiles.last_name')\n @games = Game.eager_load(:home_team, :away_team, :field).where(\"home_team_id = ? OR away_team_id = ?\", params[:id], params[:id]) \n @team_rating = calculate_team_ratings(@teamsRosters) \n end",
"def show\n @league = League.find(params[:id]) #Find the League to show.\n\n @jackpot_league = @league.jackpots.first #Find the first jackpot related to the League\n\n @jackpots = @league.jackpots.recent_jackpot #Find all the Jackpots and order them\n\n @tickets = @league.tickets.recent_tickets #Find all the Tickets in League and Orden Them\n\n @members = @league.memberships #Find League Memberships\n end",
"def show\n people = @sitting.people\n @total_order = calculate_amount(people, 'order_amount')\n @total_paid = calculate_amount(people, 'paid_amount')\n @total_owing = @total_order - @total_paid\n end",
"def team_information\n @team = Team.find_by_user1(current_user.id)\n @teammate = Team.find_teammate(current_user.id)\n @user = current_user\n\n flash.now[:notice] = \"You need a teammember!\"\n render :controller => 'teams', :action => 'team_information'\n\n end",
"def show\n @tournament = Tournament.find(params[:id])\n\n @length = @tournament.participants.length\n @base = 1\n @rounds = 0\n while (@length > @base) do\n @base += @base\n @rounds += 1\n end\n @base /= 2\n\n @team = []\n @tournament.participants.each do |member|\n @team << member.username\n end\n\n Match.all.find_all{|match| match.tournament == @tournament}.each do |match|\n if match.joueur1 == current_user.username && match.statut && !(match.joueur2.nil?)\n @match = match\n elsif match.joueur2 == current_user.username && match.statut && !(match.joueur1.nil?)\n @match = match\n end\n end\n\n @prix = []\n @bk = @length * @tournament.pricepool\n if @length <= 10 && @length >= 0\n @prix << @bk\n else\n @prix << @bk * 70 / 100\n @prix << @bk * 30 / 100\n end\n\n @tournament.participants.each do |member|\n if member.points == @rounds && @rounds > 0 && Time.now > @tournament.date\n @tournament.vainqueur = member.username\n @tournament.participants.each do |participant|\n participant.points = 0\n end\n end\n end\n end",
"def show\n @team = Team.find(params[:team_id])\n @event = Event.find(params[:id])\n @hacks = Hack.joins(:team).where(:teams => { :id => params[:team_id] })\n @hackers = User.joins(:teams).where(:affiliations => {:team_id => params[:team_id]})\n\n @affiliation = Affiliation.joins(:user).joins(:team).where(:teams => {:id => params[:team_id]}).where(:users => { :id => current_user.id }).first\n @is_member = false\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @league }\n end\n end",
"def show_league(division_id, league)\n div_id = division_id[:id]\n @div_name = Division.find(div_id).name\n players = Playerdiv.where(:division_id => division_id)\n player = Array.new\n players.each do |p|\n player << p.player_id\n end\n\n l = Array.new\n for k in player\n # Get each players matches\n @matches = player_matches(k, div_id)\n\n # Check if there are any, if not set things to zero\n if @matches.blank?\n played = 0\n @matches = 0\n won = 0\n lost = 0\n drew = 0\n points = 0\n else\n # Loop through the matches to get points,wins,draws,losses\n points = 0\n won = 0\n lost = 0\n drew = 0\n\n @matches.each do |m|\n points = points + match_points(m, k)\n @result = match_result(m, k)\n\n if @result == \"won\"\n won = won + 1\n elsif @result == \"lost\"\n lost = lost + 1\n else\n drew = drew + 1\n end\n end\n played = @matches.count\n\n end\n\n # Get the players name\n player = Player.find(k)\n name = Player.name\n\n # Put it all in an associative array\n l << {:id => player.id, :Name => name, :Played => played, :Won => won, :Lost => lost, :Drew => drew, :Points => points}\n end\n\n # Sort it by league points\n @sorted_league = l.sort_by { |position| position[:Points] }.reverse!\n end",
"def team_information\n @team = Team.find_by_user1(session[:user_id])\n @teammate = Team.find_teammate(session[:user_id])\n @user = User.find(session[:user_id])\n\n flash.now[:notice] = \"You need a teammember!\"\n render :controller => 'teams', :action => 'team_information'\n end",
"def show\n @local_league = LocalLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @local_league }\n end\n end",
"def show\n @teams = Team.all\n @visiting_games = @team.visiting_games.where(\"tournament_id = ?\",@current_tournament.id)\n @local_games = @team.games.where(\"tournament_id = ?\",@current_tournament.id)\n @games = @local_games+@visiting_games\n @players = @team.players.where(\"tournament_id = ?\",@current_tournament.id)\n @scores = {}\n #@query = @team.score(@team.tournaments.find(1))\n @tournaments=@team.tournaments\n @team.tournaments.each do |tournament|\n @scores[tournament]=@team.score(tournament)\n end\n end",
"def show_team_info(team)\n t = $nbl_league.find_team(team)\n t.show_team_full_info\nend",
"def team\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html #team.html.erb\n end\n end",
"def index\n gon.yourID = current_user.id\n current_user.game == nil ? @games = Game.all : @games = Game.find(current_user.game.id)\n @team1 = @games.team1.users if @games.try :team1\n @team2 = @games.team2.users if @games.try :team2\n respond_to do |format|\n format.html\n format.json { render :json => { :games => @games.to_json(:include => [:users]),\n :user => current_user.game,\n :will => current_user.will,\n :team1 => @team1,\n :team2 => @team2 }\n }\n end\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(current_user.id)\n \n end",
"def show\n @teams = Team.all\n @team_member = Team.friendly.find(params[:id])\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def show\n @colleague = Colleague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colleague }\n end\n end",
"def show\n @game = Game.find(params[:id])\n @home_team = Team.find(@game.home_team_id)\n @away_team = Team.find(@game.away_team_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @school = @wrestler.school\n @tournament = @wrestler.tournament\n @wrestler_points_calc = CalculateWrestlerTeamScore.new(@wrestler)\n end",
"def show\n\n \t\t\trespond_with @team\n\n \t\tend",
"def team\n @team = Team.find(params[:team_id])\n set_date_and_year\n @results = Result.all(\n :conditions => [ \"team_id = ? and year = ? and competition_result = false and team_competition_result = false\", @team.id, @date.year ]\n )\n respond_to do |format|\n format.html\n format.json { render :json => @results.to_json }\n format.xml { render :xml => @results.to_xml }\n end\n end",
"def show\n @team = Team.find(params[:id])\n @users = @team.users.uniq{|user| user.id}\n @teams = Team.all\n @season_team = @team.season_teams.first\n# @hmatch = @season_team.home_matches\n# @amatch = @season_team.away_matches\n# @matches = @hmatch | @amatch\n# \n# @teams = @season.teams.uniq{|team| team.id}\n# @users = @season.users.uniq{|user| user.id}\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @ultimate_team = UltimateTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ultimate_team }\n end\n end",
"def roster\n @team = Team.find(params[:id], :include => :players)\n @players = @team.players\n end",
"def show\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def show\n if ! authorized?\n @person = Person.select(\"id, first_name, last_name, city, country\").with_deleted.find(params[:id])\n @teams = @person.teams.order active: :desc, created_at: :desc\n end\n end",
"def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end",
"def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end",
"def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end",
"def show\n @league = League.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @league }\n end\n end",
"def show\n @team = Team.find(params[:id])\n if @team.placeholder?\n redirect_to :root, notice: 'Inget riktigt lag.'\n return\n end\n @games = Game.where('home_id = ? OR away_id = ?', @team.id, @team.id).order(\"kickoff\")\n # Find all tips for the currently logged in user\n setup_user_tips_hash\n setup_winners_right_now\n calculate_odds\n\n @last_comment = Comment.order(\"updated_at DESC\").first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @tournament = Tournament.find(params[:id])\n @matches = @tournament.matches.sort\n #Retrieve the players in the order that they appear on the view\n @all_player_spots = GetPlayers.run(@tournament, @matches)\n\n case @tournament.size\n when 4\n if (@tournament.double_elim)\n render 'show_four_person_double_elim_tournament'\n else\n render 'show_four_person_tournament'\n end\n when 8\n if (@tournament.double_elim)\n render 'show_eight_person_double_elim_tournament'\n else\n render 'show_eight_person_tournament'\n end\n end\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(session[:user_id])\n \n end",
"def show\n @team = Team.find(params[:id])\n @teamRelations = TeamMemberRelation.where(team_id: @team.id)\n @users = Array.new\n @teamRelations.each do |r|\n @users << User.find(r.user_id)\n end\n @teamRoles = Hash.new\n @teamRelations.each do |r|\n @teamRoles[r.user_id] = TeamRole.find(r.team_role_id).roleTitle\n end\n end",
"def get_affiliation\n render( json: TeamAffiliation.find_by(season_id: params[:season_id], team_id: params[:id]) )\n end",
"def show\n @id = @my_team.team_id\n @team_name = Teams.find(@id)\n roster = RestClient.get(\"https://statsapi.web.nhl.com/api/v1/teams/#{@id}/roster\")\n @roster = JSON.parse(roster)[\"roster\"]\n end",
"def show\n #@teams = Team where\n @bracket = Bracket.find(params[:id])\n @teams = Team.where(\"age_group_id = ?\", @bracket[:age_group_id])\n @games = Game.where(\"bracket_id = ?\", @bracket[:id])\n\n @numTeams = @teams.count\n @numGames = @numTeams - 1\n end",
"def show\n @battle = Battle.find(params[:id])\n @trainer = Trainer.find(@battle.trainer_id)\n @enemy = Trainer.find(@battle.enemy_id)\n \n @trainer_active_pokemon = @trainer.pokemons.find(@trainer.active_pokemon_id)\n @enemy_active_pokemon = @enemy.pokemons.find(@enemy.active_pokemon_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @battle }\n end\n end",
"def show\n #@team = Team.find(params[:id])\n if @team.pool.blank?\n @pool_name = 'N/A'\n else\n @pool_name = @team.pool.name\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def index\n @leagues = League.includes(:teams)\n Rails.logger.debug \"********************************************************\"\n @leagues.each do |league|\n Rails.logger.debug league.inspect\n Rails.logger.debug league.teams.inspect\n end\n Rails.logger.debug \"********************************************************\" \n end",
"def update_teams2\n @teams2 = Team.where(:school_id => params[:school_id]).all\n render :partial => \"teams2\", :object => @teams2\n end",
"def show\n @fantasy_league = FantasyLeague.includes(:fantasy_teams, :fantasy_drafts).find(params[:id])\n end",
"def league; end",
"def show\n @user_teams = @game.team.user_teams\n end",
"def show\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink_league }\n end\n end",
"def team\n @team = Team.find(params[:team_id])\n set_date_and_year\n @results = Result.all(\n :conditions => [ \"team_id = ? and year = ? and competition_result = false and team_competition_result = false\", @team.id, @date.year ]\n )\n end",
"def show\n @team = Team.find(params[:team_id])\n @workout = @team.workouts.find(params[:workout_id])\n @practice = @workout.practices.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end",
"def show\n (kick and return) if not is_god?\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = @phase.team\n end",
"def show\n @game = Game.find(params[:game_id])\n @participant = Participant.find(params[:participant_id])\n respond_to do |format|\n format.html\n format.json { render json: @participant }\n end\n end",
"def show\n @team = Team.where(:id=>params[:id]).first\n end",
"def show\n @team = Team.find(params[:id])\n end",
"def show\n @team = Team.find(params[:id])\n end",
"def team\n @team = Team.where(id: params[:team_id]).first\n respond_to do |format|\n format.html do\n if @team.nil?\n flash[:notice] = \"No team with id #{params[:team_id]}\"\n return redirect_to(teams_path)\n end\n\n assign_team_results @team, @year\n render layout: !request.xhr?\n end\n\n format.json do\n return(render(status: :not_found, body: \"\")) unless @team\n assign_team_results @team, @year\n render json: @event_results.to_json\n end\n\n format.xml do\n return(render(status: :not_found, body: \"\")) unless @team\n assign_team_results @team, @year\n render xml: @event_results.to_xml\n end\n end\n end",
"def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def show\n\n @my_players = @team.player_list\n @players = @team.league.player_list.reject {|player_id| @my_players.include?(player_id)}\n @playerlist_ppg = @team.league.fantasy_stat.find_player_ppgs(@team.league.player_list)\n @playernames = @team.league.fantasy_stat.find_player_names(@players)\n @player_roles = @team.league.fantasy_stat.find_player_roles(@players)\n @player_ppg = @team.league.fantasy_stat.find_player_ppgs(@players)\n\n\n @player_avg = @team.league.fantasy_stat.player_ppg_average(@playerlist_ppg)\n @player_costs = @team.league.fantasy_stat.find_player_costs(@player_avg, @player_ppg)\n\n @filter = params[:position]\n @filter_array = [\"Top Lane\", \"AD Carry\", \"Mid Lane\", \"Support\", \"Jungler\"]\n if @filter != nil && @filter != \"All\"\n @filter_array =[params[:position]]\n end\n\n\n\n @my_playernames = @team.league.fantasy_stat.find_my_player_names(@my_players)\n @my_player_roles = @team.league.fantasy_stat.find_player_roles(@my_players)\n @my_player_ppg = @team.league.fantasy_stat.find_player_ppgs(@my_players)\n @my_player_costs = @team.league.fantasy_stat.find_player_costs(@player_avg, @my_player_ppg)\n\n\n\n\n sum = 0\n\n @my_player_costs.each do |cost|\n sum += cost\n end\n\n @salary_remaining = 50000 - sum\n\n\n\n\n if @my_players.size !=5\n @average_cost_per_player = (@salary_remaining/(5-@my_players.size))\n else\n @average_cost_per_player = 0\n end\n @needed_money = @team.league.cost - current_user.balance\n if @needed_money > 0 && @needed_money < 10\n @needed_money = 10\n end\n\n end",
"def rival(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n rival_id = team.matchup_win_percentage.min_by{|each_team, percentage| percentage}.first\n @teams.select { |each_team| each_team.team_id == rival_id }.first.team_name\n end",
"def show\n\t\t# People available to add to a team.\n\t\tnormal_users = User.normal.where(duplicate: false).order(:name)\n\t\t@users = normal_users.select { |u| !u.team && u.eligible? }\n\n\t\t@changes = @team.name_changes\n\n\t\t# n+1 :(\n\t\t@participations = @team.participations.order(:created_at).select { |p| p.game.completed? }\n\t\t@max_participation = @participations.max { |x, y| y.place <=> x.place }\n\t\t@games = Game.where(id: @participations.map(&:game_id))\n\tend",
"def show\n @teams = Team.all\n @group_stage_winners = GroupStageWinner.all\n @qf_winners = QfWinner.all\n @sf_winners = SfWinner.all\n @ko16_winners = Ko16Winner.all\n @final_winners = FinalWinner.all\n @users = User.all\n end",
"def show\n @teams = Team.all\n @group_stage_winners = GroupStageWinner.all\n @qf_winners = QfWinner.all\n @sf_winners = SfWinner.all\n @ko16_winners = Ko16Winner.all\n @final_winners = FinalWinner.all\n @users = User.all\n end",
"def show\n @course = Course.find(params[:course_id])\n @team = Team.find(params[:id])\n\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def show\n @game = current_participation.game\n @ownerships = @game.ownerships.includes(:territory, :participation)\n @territories = Territory.all\n \n render @game.state.downcase\n end",
"def show\n render json: @league, status: :ok\n end",
"def show\n person = People.find(session[:people_id], :include => [ 'experiences' ])\n @experience = person.experiences.detect { |e| e.beer_id == @beer.id }\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @beer.to_xml }\n end\n end",
"def show\n @coach = Coach.includes(:team).find(params[:id])\n end",
"def show\n team = Team.find_by(:id => params[:id])\n render :json => team\n end",
"def update_teams\n @teams = Team.where(:school_id => params[:school_id]).all\n render :partial => \"teams\", :object => @teams\n end",
"def show\n respond_with MatchDayTeam.find(params[:id])\n end",
"def show\n\t\t@team = Team.find(params[:id])\n\t\tquery = @team.name\n\n\t\t# Pulls news articles about each team through Google RSS\n\t\tdata = party_time(\"https://news.google.com/news/feeds?q=#{query.downcase.gsub(/\\s/, '+')}&output=rss\")\n\t\t@articles = data[\"rss\"][\"channel\"][\"item\"]\n\n\t\t# Pulls upcoming fixtures for this team\n\t\t@data2 = party_time(\"http://api.statsfc.com/premier-league/fixtures.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&team=#{query.downcase.gsub(/\\s/, '-')}&timezone=America/New_York&limit=5\")\n\n\t\t# Pulls past results for this team \n\t\t@data3 = party_time(\"http://api.statsfc.com/premier-league/results.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&team=#{query.downcase.gsub(/\\s/, '-')}&timezone=America/New_York&limit=5\")\n\tend",
"def show\n @player = Player.find(params[:id])\n @contracts = @player.contracts.order(\"contract_start_year desc\").includes(:subcontracts)\n @salary_progression = SalaryProgression.find_by_auction_value(@player.auction_value)\n\n if @player.is_contracted?\n @top_5_players_of_position = Player.where(\"position = ?\", @player.position).sort_by { |player| player.auction_value }.reverse.first(5)\n @top_5_average = @player.average_salaries(@top_5_players_of_position)\n @next_step = @player.next_salary_step(@player.this_year_salary)\n @franchise_cost = @player.which_is_higher_franchise_cost(@top_5_average, @next_step)\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end",
"def show\n @user = User.find(params[:id])\n @teams = TeamPlayer.where(:user_id => params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @game = Game.find(params[:id])\n @matches = @game.player_matchups\n @scores = @game.scores\n @match_points = @matches.collect { |mp| @game.match_scores(mp.first, mp.last) }\n @net_points = @game.net_points\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @person = Person.find(params[:id])\n @sorted = @person.game_sets.sort_by &:date\n \n #Get individual game averages\n @games1 = []\n @games2 = []\n @games3 = []\n @total = []\n @person.game_sets.each do |game_set|\n @games1 << game_set.games[0]\n @games2 << game_set.games[1]\n @games3 << game_set.games[2]\n @total << game_set.total\n \n end\n @game1_avg = Calculate.avg(@games1)\n @game2_avg = Calculate.avg(@games2)\n @game3_avg = Calculate.avg(@games3)\n \n #Get total pins of all time\n @total_pins = Calculate.total(@total)\n end",
"def show\n @team=Team.find(params[:id])\n end",
"def show\n laxid = params[:laxid]\n @team = Team.all.where(laxid: laxid).last[:team_name]\n puts @team\n end",
"def team\n @team = :true\n render '/home/landing'\n end",
"def show\n @total_money = @raffle.transactions.map(&:amount).reduce(:+)\n @raffle = Raffle.find(params[:id])\n respond_to do |format|\n format.html\n format.json do\n @raffle = Raffle.select_data(Raffle.where(id: params[:id])).first\n render json: @raffle\n end\n end\n end",
"def show\n respond_with(@team)\n end",
"def show\n @course = Course.find(params[:course_id])\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def show\n\t\t@team = Team.find(params[:id])\n\tend",
"def show\n @player = Player.find(params[:id])\n @team\n if params[:team_id]\n @team = Team.find(params[:team_id])\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def show\n #@bet_score = @match.bet_scores.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bet_score }\n end\n end",
"def show\n @thermo_oil_production = ThermoOilProduction.find(params[:id])\n @thermo_oil_production_years = ThermoOilProductionYear.find_all_by_thermoOilProduction_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thermo_oil_production }\n end\n end",
"def person\n @person = Person.find(params[:person_id])\n set_date_and_year\n @event_results = Result.all(\n :conditions => [ \"person_id = ? and year = ? and competition_result = false and team_competition_result = false\", @person.id, @date.year ]\n )\n @competition_results = Result.all(\n :include => { :scores => [ :source_result, :competition_result ] },\n :conditions => [ \"person_id = ? and year = ? and (competition_result = true or team_competition_result = true)\", @person.id, @date.year ]\n )\n render :layout => !request.xhr?\n end",
"def update\n @user_team = Team.where(\"league_id = ?\", @league.id)[0]\n respond_to do |format|\n if @league.update(league_params)\n format.html { redirect_to team_path(@user_team.id), notice: 'League was successfully updated.' }\n format.json { render :show, status: :ok, location: @league }\n else\n format.html { render :edit }\n format.json { render json: @league.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @prediction_game = PredictionGame.find(params[:id])\n @game = Game.find(@prediction_game.game_id)\n @predictor = Predictor.find(@prediction_game.predictor_id)\n @league = @prediction_game.league\n @teams = Team.all.where(:league=>@league)\n @games = Game.all.where(:league=>@league).order(\"event_time DESC\").paginate(:page => params[:page], :per_page => 4)\n @teama = Team.find(@game.teama_id)\n @teamh = Team.find(@game.teamh_id)\n\n if user_signed_in?\n @usertype = \"user\"\n @access = current_user\n\n if @access.customer_id \n\n Stripe.api_key = Rails.configuration.stripe[:secret_key]\n customer = Stripe::Customer.retrieve(current_user.customer_id)\n\n if customer.default_source\n\n @payment = true\n else\n\n @payment = false\n end\n\n end\n\n elsif predictor_signed_in?\n @usertype = \"predictor\"\n @access = current_predictor\n elsif admin_signed_in?\n @usertype = \"admin\"\n else\n @usertype = \"none\"\n end\n \n @action = 'predictions'\n \n end",
"def index\n @team = Team.find(params[:team_id])\n @players = @team.players\n end",
"def show\n session.delete(:return_path)\n @wrestlers = @school.wrestlers.includes(:deductedPoints,:matches,:weight,:school)\n @tournament = @school.tournament\n end",
"def show\n @team = Team.find(params[:id])\n @race_runners = @team.race_runners.order(year: :desc, number: :asc)\n @race_teams = @team.race_teams.order(year: :desc)\n @cyclists = @team.cyclists\n @ite_stage_results = IteStageResult.joins(race_runner: :race_team).where(:race_teams => {:team_id => params[:id]})\n @r_victories = @team.race_victories\n @rc_victories = IgRaceResult.joins(climber: :race_team).where(:race_teams => {:team_id => params[:id]}).order(year: :DESC)\n @rs_victories =IgRaceResult.joins(sprinter: :race_team).where(:race_teams => {:team_id => params[:id]}).order(year: :DESC)\n @ry_victories = IgRaceResult.joins(young: :race_team).where(:race_teams => {:team_id => params[:id]}).order(year: :DESC)\n @s_victories = @team.stage_victories\n @y_jersey = IgStageResult.joins(leader: :race_team).joins(:stage).where(:race_teams => {:team_id => params[:id]}).order(\"stages.year DESC, stages.ordinal DESC\")\n @c_jersey = IgStageResult.joins(climber: :race_team).joins(:stage).where(:race_teams => {:team_id => params[:id]}).order(\"stages.year DESC, stages.ordinal DESC\")\n @s_jersey = IgStageResult.joins(sprinter: :race_team).joins(:stage).where(:race_teams => {:team_id => params[:id]}).order(\"stages.year DESC, stages.ordinal DESC\")\n @yy_jersey = IgStageResult.joins(young: :race_team).joins(:stage).where(:race_teams => {:team_id => params[:id]}).order(\"stages.year DESC, stages.ordinal DESC\")\n\n\n @r_podium = YjStageResults.joins(race_runner: :race_team).joins(:stage).where(\"stages.is_last = true AND race_teams.team_id = ? AND pos <= 3\", params[:id]).order(\"year DESC\")\n\n @rt_victories = IgRaceResult.joins(:race_team).where(:race_teams => {:team_id => params[:id]}).order(year: :DESC)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def total_team_score(teams_id)\n total_score = 0\n @league_data.each do\n |team| \n # binding.pry\n if team.home_team_id == teams_id\n total_score += team.home_team_score\n elsif team.away_team_id == teams_id\n total_score += team.away_team_score\n end\n end\n return total_score\n end",
"def get_teams_by_league(league_id)\n response = parse_api_request(\"#{BASE_URL}teams/league/#{league_id}\")[\"teams\"]\nend"
] | [
"0.68495536",
"0.67788297",
"0.66406035",
"0.6617988",
"0.658224",
"0.65279543",
"0.6512413",
"0.6507493",
"0.64987785",
"0.6478145",
"0.63679284",
"0.6361654",
"0.63514453",
"0.6344323",
"0.63129306",
"0.6294987",
"0.6280963",
"0.6259406",
"0.6231762",
"0.6231762",
"0.621838",
"0.62067306",
"0.6187901",
"0.61847985",
"0.6183489",
"0.6151579",
"0.61493057",
"0.613965",
"0.61294246",
"0.6127397",
"0.6127397",
"0.6127397",
"0.6127397",
"0.611832",
"0.6117544",
"0.6107558",
"0.6093657",
"0.60772246",
"0.60698706",
"0.6064075",
"0.605854",
"0.6054456",
"0.60363907",
"0.60325724",
"0.60296875",
"0.60244083",
"0.6010157",
"0.60043836",
"0.6001886",
"0.5997513",
"0.5997141",
"0.5986806",
"0.5983423",
"0.59824",
"0.598132",
"0.598132",
"0.5974599",
"0.59635705",
"0.5954556",
"0.5954556",
"0.5954556",
"0.5954556",
"0.5954556",
"0.5954556",
"0.5947057",
"0.59466976",
"0.5946576",
"0.59378225",
"0.59378225",
"0.59373957",
"0.59252614",
"0.5924886",
"0.59248316",
"0.5921345",
"0.59208953",
"0.5915192",
"0.5911814",
"0.5903121",
"0.5895596",
"0.5893592",
"0.58866644",
"0.5885755",
"0.5881555",
"0.58801156",
"0.5876189",
"0.5874133",
"0.5869899",
"0.5867037",
"0.58511406",
"0.5846827",
"0.5841803",
"0.5839912",
"0.5837855",
"0.58356744",
"0.5833552",
"0.58316714",
"0.5827254",
"0.5826994",
"0.58260626",
"0.5824247"
] | 0.63398844 | 14 |
Return o generate new password | def password
@password ||= Password.new(password_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_new_password\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'\n password = ''\n 10.times { password << chars[rand(chars.size)] }\n self.update_attributes(:encrypted_password => User.encrypt(password, self.salt))\n UserMailer.deliver_forgot_password_mail(self, password)\n password\n end",
"def generate\n @password = (1..@length).map { (33 + rand(89)).chr }.join \n check_password_contents\n @password\n end",
"def create_new_password\n pass = generate_password\n set_password(pass)\n pass\n end",
"def generate_password\n if new_record?\n self.password = self.password_confirmation = /\\w{0,10}/.gen unless password\n end\n end",
"def generate_password\r\n return rand(36 ** 20).to_s(36)\r\n end",
"def generate_password\n self.password = random_string(32)\n self.e_password = Digest::SHA256.hexdigest(self.password)\n end",
"def generate_and_send_new_password\n new_password = \"\"\n chars = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#,.;:?%&\".split(//)\n (0..8).each do |i|\n new_password += chars.at(rand(chars.length))\n end\n self.update_attributes(:password => new_password)\n save!\n AdminMailer.password_reset(self, new_password).deliver\n new_password\n end",
"def make_up_password\n\to = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten\n\tpass = (0...12).map { o[rand(o.length)] }.join + \"@\"\n\tputs \"Using #{pass} for password\\n\"\n\treturn pass\nend",
"def generate_password\n self.password = \"1234\"\n end",
"def generate_password!(model:, **)\n model.password = SecureRandom.urlsafe_base64(8)\n end",
"def generate_password\n self.password = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{self.email}--#{self.id}\")\n end",
"def set_new_password \n new_passwd = generate_password()\n self.password = self.password_confirmation = new_passwd\n self.save!\n return new_passwd\n end",
"def generate(password)\n BCrypt::Password.create(secret + password).to_s\n end",
"def generate_password\n self.password = SecureRandom.urlsafe_base64(10)\n self.password_confirmation = self.password\n end",
"def generate_password\n password = [('a'..'z'), ('A'..'Z'),(0..9)].map { |i| i.to_a }.flatten\n (8...32).map { password[rand(password.length)] }.join\n end",
"def _my_mkpass()\n mymkpass = ''\n 9.to_i.times{ mymkpass << (65 + rand(25)).chr }\n return mymkpass\nend",
"def generate_password( length_of_pass, special_char )\n chars = []\n (\"a\"..\"z\").each {|ele| chars << ele}\n (\"A\"..\"Z\").each {|ele| chars << ele}\n (\"0\"..\"9\").each {|ele| chars << ele}\n if(special_char)\n [\"@\", \"!\", \"_\",].each {|ele| chars << ele}\n end\n newpass = \"\"\n 1.upto(length_of_pass) { |i| newpass << chars[rand(chars.size-1)] }\n #self.password\n self.unencrypted_password = newpass\n self.password_confirmation = newpass\n @unencrypted = true\n end",
"def generate_password\n [*('a'..'z'), *('A'..'Z'), *('0'..'9')].sample(8).join\n end",
"def random_password\r\n chars = (\"a\"..\"z\").to_a + (\"1\"..\"9\").to_a \r\n newpass = Array.new(8, '').collect{chars[rand(chars.size)]}.join\r\n end",
"def generate_password\n if password_confirmation.nil?\n self.password = Devise.friendly_token.first(8)\n end\n end",
"def random_password\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n password = ''\n #40.times { |i| password << chars[rand(chars.size-1)] }\n 15.times { |i| password << chars[rand(chars.size-1)] }\n self.password = password\n self.password_confirmation = password\n self.pwd = password\n self\n end",
"def generate_password\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z @ # $ & ! }\n (0...6).map{ charset.to_a[rand(charset.size)] }.join\n end",
"def random_new_password\n if self.random_password_length == 0\n nil\n else\n new_password = String.new\n for i in 0 .. self.random_password_length\n new_password += self.random_password_contains_of.scan(/./).sort_by {rand}.first\n end\n new_password\n end\n end",
"def generate_password\n generated_password = Devise.friendly_token.first(8)\n p generated_password\n self.password = generated_password\n end",
"def reset_password\n o = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten\n new_password = (0..6).map{ o[rand(o.length)] }.join\n self.password = new_password\n if self.save\n return new_password\n else\n return nil\n end\n end",
"def generatePassword\r\n logger.info(\"UserController::generatePassword::Params-----#{params}\")\r\n @activationCode =''\r\n if !params['id'].blank?\r\n @activationCode = params['id']\r\n end\r\n end",
"def generate_password\n require 'securerandom' unless defined?(SecureRandom)\n password = SecureRandom.hex(30)\n node.normal['mysql']['local_admins'][new_resource.user]['password'] = password\n password\n end",
"def random_password\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n password = ''\n 40.times { |i| password << chars[rand(chars.size-1)] }\n self.password = password\n self.password_confirmation = password\n self\n end",
"def generate_password(length=6)\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789'\n password = ''\n length.times { |i| password << chars[rand(chars.length)] }\n password\n end",
"def generate_password\n self.password = Devise.friendly_token.first(8)\n end",
"def generate_password\n pass = \"\"\n 20.times { pass += (rand(74) + 48).chr }\n\n begin\n Puppet.settings.write(:capass) { |f| f.print pass }\n rescue Errno::EACCES => detail\n raise Puppet::Error, \"Could not write CA password: %s\" % detail.to_s\n end\n\n @password = pass\n\n return pass\n end",
"def generate_temporary_password\n\n pw = Algol.password_salt\n # puts \">> User: generating a temporary password '#{pw}' <<\"\n update!({ password: User.encrypt(pw), auto_password: true })\n\n # expire all current/old temp passwords that weren't used\n pending_notices.all({ type: 'password' }).each { |n| n.expire! }\n\n notices.create({ type: 'password', data: pw })\n end",
"def password=(new_password); end",
"def generate_and_print_password\n password = Simp::Cli::Utils.generate_password\n logger.say ('~'*80).green + \"\\n\"\n logger.say 'NOTE: '.green.bold + \" The generated password is: \\n\\n\"\n logger.say ' ' + password.yellow.bold + \"\\n\\n\"\n logger.say ' >>>> Please remember this password! <<<<'.bold\n logger.say ' It will ' + '**NOT**'.bold + ' be written to the log or hieradata.'\n logger.say ('~'*80).green + \"\\n\"\n logger.say '*** Press enter to continue ***'.cyan.bold.blink\n ask ''\n password\n end",
"def generate_password\n ['test', 'guest'].sample\nend",
"def create_password(length)\n chars = ('a' .. 'z').to_a + ('1' .. '9').to_a + '%$?@!'.split(//)\n Array.new(length, '').collect { chars[rand(chars.size)] }.join\nend",
"def generate_password(length = 8)\n chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('1'..'9').to_a - ['o', 'O', 'i', 'I']\n Array.new(length) { chars[rand(chars.size)] }.join\n end",
"def new_pwd\n user=User.where(:username => params[:username])[0]\n \n if user==nil || Integer(user[:hash])!=Integer(params[:hash])\n render :update do |page|\n page<< \"alert('Invalid Code');\"\n end\n else\n alphas=Array.new\n i=0\n (\"a\"..\"z\").to_a.each do |l|\n alphas[i]=l\n i+=1\n end\n (\"A\"..\"Z\").to_a.each do |l|\n alphas[i]=l\n i+=1\n end\n (\"0\"..\"9\").to_a.each do |l|\n alphas[i]=l\n i+=1\n end\n \n @new_pwd= Array.new\n i=0\n while i<15\n @new_pwd[i]=alphas[rand(62)]\n i+=1\n end\n @new_pwd*=''\n user.password=hash_pwd(@new_pwd)\n user.save\n session[:current_user]=user\n end\n end",
"def get_password\n\tpwd1 = Password.get(\"New Password: \")\n\tpwd2 = Password.get(\"Retype New Password: \")\n\n\tbegin\n\t\traise if pwd1 != pwd2\n\t\trescue\n\t\t\tprint \"ERROR: Password mismatch!\\n\"\n\t\t\texit\n\tend\n\n\tbegin\n\t\tpwd1.check # check password strength\n\t\trescue\n\t\t\tprint \"ERROR: Password strength check failed: \" + $! + \"\\n\"\n\t\t\texit\n\tend\n\n\tsalt = rand.to_s.gsub(/0\\./, '')\n\tpass = pwd1.to_s\n\thash = \"{SSHA}\"+Base64.encode64(Digest::SHA1.digest(\"#{pass}#{salt}\")+salt).chomp!\n\treturn hash\nend",
"def create_password\n self.uuid = TempPassword.get_uuid\n self.hashed_uuid = Digest::SHA1.hexdigest(uuid)\n end",
"def mutate_bcrypt_password(_)\n '400$8$2d$f6ed5a490c441958$67f59aa61bc617849a3280b5e80f78607e53b5aa5807a44ddbc53e804e2e2a99'\n end",
"def password(length=20)\n SecureRandom.base64(length+2).tr('=', '')\n end",
"def generate_random_id\n len = 8\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newpass = \"\"\n 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }\n return newpass\n end",
"def new_password\n return @new_password\n end",
"def password= new_password\n new_password ||= SecureRandom::hex(8)\n @password = Password.create new_password\n self.password_digest = @password.to_s\n self.save\n end",
"def generate_password( len = 6 )\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z a c d e g h j k m n p q r v w x y z }\n (0...len).map{ charset.to_a[rand(charset.size)] }.join\nend",
"def create_hashed_password\n self.password = password.crypt(\"ChaveDoProvas\")\n end",
"def generate_password_token\n unless self.encrypted_password && !self.encrypted_password.blank?\n pwd = Devise.friendly_token[0,20]\n self.password = pwd\n set_reset_password_token\n end\n end",
"def make_password_reset_code\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def reset_password\n new_password = SecureRandom.hex(5)\n update_attributes!(:password => new_password )\n return new_password\n end",
"def generate_secret\n self.password = self.class.generate_secret\n end",
"def postgres_password(new_resource)\n new_resource.password == 'generate' ? secure_random : new_resource.password\n end",
"def postgres_password(new_resource)\n new_resource.password == 'generate' ? secure_random : new_resource.password\n end",
"def gen_random_user_pass()\n if datastore['USERNAME'] == ''\n # Generate random username\n datastore['USERNAME'] = rand_text_alpha(8+rand(8))\n end\n\n if datastore['PASSWORD'] == ''\n # Generate random password\n datastore['PASSWORD'] = rand_text_alpha(8+rand(8))\n end\n return\n end",
"def password_token\n rng = MT19937.new(Time.now.to_i)\n password = 16.times.map { rng.extract_byte }\n base64_encode_bytes(password)\nend",
"def random_code(len)\n #generat a random password consisting of strings and digits\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newcode = \"\"\n 1.upto(len) { |i| newcode << chars[rand(chars.size-1)] }\n return newcode\n end",
"def password\n Digest::MD5.hexdigest(uuid)[0..9]\n end",
"def generate\n bits = generate_password_bits\n puts bits.to_s(2)\n\n coordinates = bits_to_coordinates(bits)\n puts coordinates.inspect\n\n coordinates\n end",
"def generate_reset_password_token!\n characters = ('a'..'z').to_a + ('A'..'Z').to_a \n self.reset_password_sent_at = Time.zone.now.utc\n self.reset_password_token = (1..12).map{characters.sample}.join # Generate a 12-length random string\n save(:validate => false)\n end",
"def scramble_password\n if self.password_changed?\n self.password = Digest::MD5.hexdigest(self.password)\n end\n end",
"def reset_password\n self.password = self.class.random_hash(8)\n self.save_with_validation(false)\n self.password\n end",
"def set_temp_password\n self.password = SecureRandom.urlsafe_base64(6)\n end",
"def standard_password\n \"!@Cd5678\"\n end",
"def change_temp_password\n\tend",
"def new_password\n @new_password\n end",
"def random_password(size=10)\n random_string(size, :chars, 'ABCDEFGHJKLMNPQRSTUVWXYabcdefghkmnpqrstuvwxyz23456789#%^&$*i-_+=')\n end",
"def make_reset_code\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n self.save\n end",
"def set_random_password\n if password.blank?\n password = password_confirmation = BCrypt::Engine.generate_salt\n end\n end",
"def new_password; nil; end",
"def create_new_salt\n self.password_salt = [Array.new(6){rand(256).chr}.join].pack(\"m\").chomp\n end",
"def make_salt\n secure_hash(\"#Time.now.utc}--#{password}\")\n end",
"def new_password_field()\n\t\t# unit_test_no_generate: new_password_field, input.className(create_ats_regex_string(\"ats-newpwdfield\"))\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(input.className(create_ats_regex_string(\"ats-newpwdfield\")), __method__)\n\tend",
"def forgot_password\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def password_generator(size)\n chars = ('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a\n (chars.sample(size)) * ''\nend",
"def make_salt\n\t secure_hash(\"#{Time.now.utc}--#{password}\")\n\tend",
"def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end",
"def make_salt\n secure_hash(\"#{Time.now.utc}--#{password}\")\n end",
"def digest\n cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost\n BCrypt::Password.create(SecureRandom.urlsafe_base64, cost: cost)\n end",
"def password_change_new\n\n end",
"def generate_and_send_password\n self.reload\n update_attribute :password, ('a'..'z').to_a[rand(26)].to_s + (0...5).map{ [rand(10)] }.join\n post_data = Net::HTTP.post_form URI.parse('http://3001300.ru/create_client_from_bonus.php'),\n { \n 'email' => self.email,\n 'password' => self.password\n }\n mail = InformMail.create! client: self, body: \"#{MessageText.welcome.sms.encode} #{self.password}\".encode(\"cp1251\")\n end",
"def random_string2(str_length=4)\n chars = 'abcdef0123456789'\n password = ''\n str_length.times { password << chars[rand(chars.length)] }\n password\nend",
"def set_password\n @password = Password.last\n @new_password = Password.new\n end",
"def generate_password(l)\n vow = %w(a e i o u)\n con = %w(b c d f g h j k l m n p q r s t v x y z)\n\n pw = ''\n state = if rand < 0.8 then :c else :v end\n for i in 0..l\n case state\n when :v\n pw << vow[rand(vow.size)]\n state = :c if rand > 0.4\n when :c\n pw << con[rand(con.size)]\n state = :v if rand > 0.1\n end\n end\n return pw\n end",
"def hash_new_password\n self.password = BCrypt::Password.create(@new_password)\n end",
"def newPassword(newPass)\n\t\tDATABASE.edit(\"users\", \"password\", newPass, \"username\", @username)\n\tend",
"def set_password pass\n self.pass_salt = SHA256Salt.generate_random\n self.pass_hash = WodaHash.digest(self.pass_salt + pass).to_hex\n end",
"def hash_pass()\n self.pass=(BCrypt::Password.create(pass).to_s)\n end",
"def update_secret\n o = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten\n secret = (0...64).map{ o[rand(o.length)] }.join\n self.client_secret = Password.create(secret)\n self.save\n\n secret\n end",
"def get_hash\n return(uniquehash) if (uniquehash and uniquehash.length > 0)\n uniquehash = ApplicationController::random_password(10)\n self.save\n return uniquehash\n end",
"def reset_password\n password = self.object_id.to_s + rand.to_s\n create_new_salt\n self.password_hash = User.encrypted_password(password, self.password_salt)\n return password\n end",
"def rand_pass(length=8)\n return rand(36**length).to_s(36)\nend",
"def auto_generate_password\n case @generate_option\n when :never_generate\n return nil\n when :generate_no_query\n # Normally, :generate_no_query goes hand-in-hand with skipping\n # the query. However, if the Item's value was pre-assigned\n # and invalid, @skip_query will be set to false. This is so we\n # give the user an opportunity to fix the problem via a query.\n if @skip_query\n return Simp::Cli::Utils.generate_password\n else\n auto_default = 'yes'\n end\n when :generate_as_default\n auto_default = 'yes'\n when :no_generate_as_default\n auto_default = 'no'\n end\n\n if @minimize_queries\n # skip the 'Auto-generate the password?' query\n if auto_default == 'no'\n # assume auto-generation is not appropriate\n return nil\n else\n # assume auto-generation is appropriate\n password = generate_and_print_password\n end\n else\n password = nil\n @password_name = @key if @password_name.nil? or @password_name.empty?\n if agree( \"Auto-generate the #{@password_name} password? \" ){ |q| q.default = auto_default }\n password = generate_and_print_password\n end\n end\n password\n end",
"def generate_password_token!\n\t\tself.reset_password_token\t= generate_token\n\t\tself.reset_password_sent_at\t= Time.now\n\t\tsave!\n\tend",
"def new_password(data)\n data.strip!\n unless data =~ /^\\w{6,20}$/\n ask_password\n return\n end\n @display.echo_on\n @new_password = data\n ask_color\n end",
"def generate(\n key,\n seconds = 10,\n length = 64,\n char_pool = (32..126).map(&:chr).join.gsub(/\\s/, '')\n )\n char_pool_size = char_pool.size\n new_pw = (1..length.to_i).map{\n char_pool[SecureRandom.random_number(char_pool_size)]\n }.join\n \n if add(key, new_pw) \n get(key, seconds)\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 update_password(newpwd)\n self.password = Utils.sha1(newpwd + 'ad2012spot' + email)\n end",
"def password\n\n end",
"def edit_password; end",
"def generate(max_length = EasyPasswords::DEFAULT_MAX_LENGTH)\n fail \"Password minimal length is #{EasyPasswords::MIN_WORD_LENGTH}\" if max_length < EasyPasswords::MIN_WORD_LENGTH\n output = ''\n while output.size < (max_length - (EasyPasswords::MIN_WORD_LENGTH - 1))\n add_part(output, max_length)\n end\n output\n end",
"def password; end"
] | [
"0.8710023",
"0.8485628",
"0.8453982",
"0.844155",
"0.8274988",
"0.826289",
"0.82250094",
"0.8156477",
"0.8126085",
"0.811404",
"0.8072922",
"0.80485225",
"0.8037483",
"0.800008",
"0.7929134",
"0.79058325",
"0.7872217",
"0.7797423",
"0.7790051",
"0.7764938",
"0.77462035",
"0.7683116",
"0.76621515",
"0.7614191",
"0.75654835",
"0.75524634",
"0.7522578",
"0.7514628",
"0.74942625",
"0.74885756",
"0.7485002",
"0.74651515",
"0.7419398",
"0.74190813",
"0.7407393",
"0.7405928",
"0.7375866",
"0.7372865",
"0.7366082",
"0.7355139",
"0.72746634",
"0.7260507",
"0.7246141",
"0.7222496",
"0.7218191",
"0.71987796",
"0.7190964",
"0.71889365",
"0.7180027",
"0.7145532",
"0.7128571",
"0.711387",
"0.710968",
"0.70999575",
"0.7096476",
"0.70871073",
"0.70816785",
"0.70677525",
"0.70558333",
"0.70455295",
"0.7044558",
"0.70369023",
"0.7023494",
"0.70121115",
"0.7011083",
"0.70044297",
"0.69620836",
"0.6938949",
"0.6930567",
"0.6916707",
"0.6912215",
"0.69072294",
"0.6898852",
"0.6896048",
"0.6893393",
"0.6892688",
"0.6892688",
"0.68862617",
"0.6871274",
"0.6868917",
"0.6865954",
"0.6865638",
"0.6845445",
"0.68395704",
"0.68368524",
"0.68301266",
"0.68116057",
"0.68110675",
"0.68092483",
"0.6795497",
"0.6782333",
"0.6780652",
"0.677989",
"0.6770096",
"0.67572033",
"0.67507464",
"0.6740474",
"0.6738709",
"0.67340046",
"0.67255527",
"0.6722893"
] | 0.0 | -1 |
GET /testers GET /testers.json | def index
@testers = Tester.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @testers }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end",
"def listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def show\n @trainer = Trainer.find(params[:id])\n\n render json: @trainer.as_json(only: [:name], include: [:trainees])\n end",
"def index\n if current_authkey.authkey.eql?(\"#fl0wk27er\")\n @testers = Tester.all\n else\n redirect_to root_path\n end\n end",
"def index\n render status: :ok, json: @tests\n end",
"def index\n @retailers = Retailer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def show\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trainer }\n end\n end",
"def index\n respond_with(@collection) do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end",
"def index\n @requesters = Requester.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def buyers\n result = get_buyers(params, false)\n render json: result, status: 200\n end",
"def test_get_all_senders()\r\n # Parameters for the API call\r\n accept = '*/*'\r\n\r\n # Perform the API call through the SDK function\r\n result = self.class.controller.get_all_senders(accept)\r\n\r\n # Test response code\r\n assert_equal(@response_catcher.response.status_code, 200)\r\n\r\n # Test whether the captured response is as we expected\r\n assert_not_nil(result)\r\n assert_equal('[{\"id\":\"xEYgLPQZOpnel5aKBzyVXvAWJ\",\"senderName\":\"RELEANS\",\"phoneNumber\":\"+15105607102\",\"status\":1}]', @response_catcher.response.raw_body)\r\n end",
"def show\n @runner = Runner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runner }\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n @githubers = Githuber.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @githubers }\n end\n end",
"def tests(run_id)\n get(\"get_tests/#{run_id}\")\n end",
"def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end",
"def index\n @test_runs = TestRun.accessible_by(current_ability).order(\"updated_at DESC\").page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @test_runs }\n end\n end",
"def index\n @submitters = Submitter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @submitters }\n end\n end",
"def index\n @taste_testers = TasteTester.all\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def show\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_test }\n end\n end",
"def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend",
"def index\n @gt_metrix_tests = apply_scopes(GtMetrixTest).all\n\n render json: @gt_metrix_tests\n end",
"def index\n @waiters = @course.waiters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waiters }\n end\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def show\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taker }\n end\n end",
"def index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def tests\n @tests ||= load_json(test_plan_path)&.fetch(:tests) if test_plan_path\n end",
"def index\n @teamriders = Teamrider.all\n end",
"def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end",
"def taken\n @travels = Travels::Travel.taken.where(performer: current_user)\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n @teams = Team.all\n render json: @teams\n end",
"def index\n @teachers = Teacher.order(:tea_no).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teachers }\n end\n end",
"def show\n @team = Team.find(params[:id])\n @runners = @team.runners\n @count = @runners.length\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n @wrestlers = Wrestler.all\n end",
"def show\n render json: @test\n end",
"def index\n @teams = Team.all\n render :json => @teams\n end",
"def index\n @volunteers = Volunteer.order(:name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @name }\n end\n end",
"def index\n @trackers = Tracker.where(public: true)\n\n render json: @trackers\n end",
"def show_beer\n render json: BreweryDb::ShowBeer.new(params[:beerId]).results\n end",
"def show\n @reef_tank = ReefTank.find(params[:id])\n @watchers = Watcher.all\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reef_tank }\n end\n end",
"def index\n @recruiters = Recruiter.all\n render_json_serializer(@recruiters)\n end",
"def show\n @testis = Teste.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testis }\n end\n end",
"def index\n player = Player.all\n render json: players, status: 200\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def index\n @teams = Team.all.order(:name)\n if params[:all]\n json_response(TeamSerializer, @teams)\n else\n @teams_paginated = @teams.page(current_page, per_page).per(per_page)\n json_response(TeamSerializer, @teams_paginated, options(@teams))\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end",
"def index\n @talleres = Taller.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talleres }\n end\n end",
"def index\n @employers = Employer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employers }\n end\n end",
"def index\n @players = Player.all\n render json: @players, status: 200\n end",
"def show\n render status: :ok, json: @test\n end",
"def index\n\t\t@participants = Participant.all\n\n\t\trender json: @participants\n\tend",
"def get_travellers\n if current_user != nil\n @trip = Trip.find(params[:id])\n render json: @trip.trip_json\n else\n render json: session[:trip].trip_json\n end\n\n end",
"def show\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def show\n @id = @my_team.team_id\n @team_name = Teams.find(@id)\n roster = RestClient.get(\"https://statsapi.web.nhl.com/api/v1/teams/#{@id}/roster\")\n @roster = JSON.parse(roster)[\"roster\"]\n end",
"def index\n @trackers = Tracker.where(:user_id => current_user.id).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trackers }\n end\n end",
"def index\n begin\n # Beers of current user\n beers = @current_user.beers\n\n #Filter by name\n if params[:name].present?\n beers = beers.where(name: params[:name])\n end\n\n #Filter by abv\n if params[:abv].present?\n beers = beers.where(abv: params[:abv])\n end\n render json: BeerSerializer.new(beers).collection_attr_array\n rescue StandardError => e\n message = e.message\n end\n end",
"def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end",
"def index\n @prayers = Prayer.all\n render json: @prayers, status: 200 # you've got a serializer. Maybe you should use it.\n end",
"def index\n\t\t@teams = Team.order(\"name ASC\").all\n\n\t\t# Pulls upcoming fixtures in Premier League\n\t\t@data = party_time(\"http://api.statsfc.com/premier-league/fixtures.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&timezone=America/New_York&limit=10\")\n\n\t\t# Pulls top scorers in Premier League\n\t\t@data2 = party_time(\"http://api.statsfc.com/top-scorers.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&competition=premier-league&year=2013/2014&limit=10\")\t\n\n\t\t# Pulls news articles about the league through Google RSS\n\t\tdata = party_time(\"https://news.google.com/news/feeds?q=barclays+premier+league&output=rss\")\n\t\t@articles = data[\"rss\"][\"channel\"][\"item\"]\n\tend",
"def index\n if params[:name].present?\n @json = Punk::API.beers_name!(params[:name])\n elsif params[:abv_gt].present?\n @json = Punk::API.beers_abv_gt!(params[:abv_gt])\n elsif params[:abv_lt].present?\n @json = Punk::API.beers_abv_lt!(params[:abv_lt])\n else\n @json = Punk::API.all_beers!(params)\n end\n\n render json: {\n beers: @json\n }\n create(@json)\n end",
"def teams\n render json: @team_query\n end",
"def index\n @pt_trainers = Pt::Trainer.all\n end",
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def show\n @test = Test.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def index\n @ussers = Usser.all\n end",
"def index\n @prayers = Prayer.where(\"user_id = ?\", getUser())\n\n @prayer_requests = PrayerRequest.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prayers }\n end\n end",
"def index\n @retailers = Retailer.all\n end",
"def index\n @players = Player.all\n render json: @players\n end",
"def check_ranked_beer\n render json: Beer.find_by(beer_id: params[:beerId])\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n\t\t@teams = Team.all\n\t\trender '/teams/index.json.jbuilder'\n\tend",
"def get_tests_in_a_run(run_id)\n testrail_api_client.send_get(\"get_tests/#{run_id}\")\n end",
"def trainings\n render json: @plan.trainings\n end",
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def index\n @fixtures = Fixture.all\n\n respond_to do |format|\n format.json { render json: @fixtures }\n end\n end",
"def show\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testbed_owner }\n end\n end",
"def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def index\n @ties = Tie.all\n end"
] | [
"0.69367653",
"0.66942996",
"0.635389",
"0.6339862",
"0.6263857",
"0.6202649",
"0.61038965",
"0.6098523",
"0.60888034",
"0.60538757",
"0.59716266",
"0.59070766",
"0.59070766",
"0.59070766",
"0.5889392",
"0.5889392",
"0.5861978",
"0.5832927",
"0.5828665",
"0.5826435",
"0.5826435",
"0.5825977",
"0.58190256",
"0.58088726",
"0.5788292",
"0.57851726",
"0.5762217",
"0.5749691",
"0.5743646",
"0.5733108",
"0.57216936",
"0.5696629",
"0.569243",
"0.5692085",
"0.5686342",
"0.56619567",
"0.5659075",
"0.56549704",
"0.5648197",
"0.564077",
"0.5627383",
"0.56245476",
"0.5612738",
"0.5610846",
"0.5606681",
"0.56050545",
"0.5604137",
"0.56002605",
"0.5577951",
"0.5570821",
"0.556931",
"0.5556627",
"0.55559015",
"0.55557704",
"0.55550426",
"0.55482227",
"0.554366",
"0.55386007",
"0.55312896",
"0.55311984",
"0.55281913",
"0.5517123",
"0.5515291",
"0.55148643",
"0.5509155",
"0.5498966",
"0.54929966",
"0.54922646",
"0.54883385",
"0.5488087",
"0.54844767",
"0.5483988",
"0.54784334",
"0.5477701",
"0.5476368",
"0.5474861",
"0.547421",
"0.54734004",
"0.54672974",
"0.54657257",
"0.5465242",
"0.5465016",
"0.54615176",
"0.5458867",
"0.54554725",
"0.545502",
"0.5451826",
"0.5435995",
"0.5431746",
"0.5431746",
"0.54256934",
"0.54160947",
"0.54156065",
"0.54140425",
"0.54109323",
"0.54109174",
"0.5409301",
"0.5406647",
"0.5406647",
"0.5397214"
] | 0.759817 | 0 |
GET /testers/1 GET /testers/1.json | def show
@tester = Tester.find(params[:id])
if @tester != current_tester
redirect_to current_tester, notice: 'You are not allow to see other profiles.'
end
#redirect_to current_tester, notice: 'You are not allow to see other profiles.'
#respond_to do |format|
# format.html # show.html.erb
# format.json { render json: @tester }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def get_one\n test_data = @test.get_one\n return render json: test_data\n end",
"def show\n @trainer = Trainer.find(params[:id])\n\n render json: @trainer.as_json(only: [:name], include: [:trainees])\n end",
"def show\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trainer }\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def show\n @runner = Runner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runner }\n end\n end",
"def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end",
"def listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def index\n render status: :ok, json: @tests\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def show\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taker }\n end\n end",
"def show\n @test = Test.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def show\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_test }\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n if current_authkey.authkey.eql?(\"#fl0wk27er\")\n @testers = Tester.all\n else\n redirect_to root_path\n end\n end",
"def show\n @testis = Teste.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testis }\n end\n end",
"def show\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test10 }\n end\n end",
"def show\n render json: @test\n end",
"def show\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def show\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testbed_owner }\n end\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def show\n render status: :ok, json: @test\n end",
"def show\n @json = Punk::API.one_beer!(params[:id])\n render json: {\n beer: @json\n }\n create(@json)\n end",
"def show\n @submitter = Submitter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submitter }\n end\n end",
"def index\n @retailers = Retailer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end",
"def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end",
"def index\n @test_runs = TestRun.accessible_by(current_ability).order(\"updated_at DESC\").page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @test_runs }\n end\n end",
"def show\n @team = Team.find(params[:id])\n @runners = @team.runners\n @count = @runners.length\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end",
"def show\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend",
"def show\n @tktest = Tktest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tktest }\n end\n end",
"def show_beer\n render json: BreweryDb::ShowBeer.new(params[:beerId]).results\n end",
"def show\n @retailer = Retailer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer }\n end\n end",
"def show\n @retailer = Retailer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer }\n end\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def test\n render json: { test: 'Tested.' }\n end",
"def test\n render json: { test: 'Tested.' }\n end",
"def show\n @beer = Beer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beer }\n end\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end",
"def index\n @volunteers = Volunteer.order(:name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @name }\n end\n end",
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def index\n @submitters = Submitter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @submitters }\n end\n end",
"def show\n @reef_tank = ReefTank.find(params[:id])\n @watchers = Watcher.all\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reef_tank }\n end\n end",
"def taken\n @travels = Travels::Travel.taken.where(performer: current_user)\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def show\n @usertest = Usertest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usertest }\n end\n end",
"def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @testcase }\n end\n end",
"def index\n @githubers = Githuber.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @githubers }\n end\n end",
"def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend",
"def show\n @id = @my_team.team_id\n @team_name = Teams.find(@id)\n roster = RestClient.get(\"https://statsapi.web.nhl.com/api/v1/teams/#{@id}/roster\")\n @roster = JSON.parse(roster)[\"roster\"]\n end",
"def index\n respond_with(@collection) do |format|\n format.html # index.html.erb\n format.json { render json: @retailers }\n end\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @requesters = Requester.all\n end",
"def show\n @transporter = Transporter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transporter }\n end\n end",
"def show\n @retailer = Retailer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retailer }\n end\n end",
"def new\n @trainer = Trainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trainer }\n end\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def show\n @software_test = SoftwareTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @software_test }\n end\n end",
"def check_ranked_beer\n render json: Beer.find_by(beer_id: params[:beerId])\n end",
"def show\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @specie }\n end\n end",
"def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end",
"def show\n @testdb = Testdb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testdb }\n end\n end",
"def show\n render json: @testmonial\n end",
"def index\n @teachers = Teacher.order(:tea_no).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teachers }\n end\n end",
"def show\n @waiter = Waiter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @waiter }\n end\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def show\n @tower = Tower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tower }\n end\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def info(test_id, options={})\n args = {testId: test_id}.merge(options)\n get('testinfo', args)\n end",
"def show\n @tater = Tater.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tater }\n end\n end",
"def show\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweeter }\n end\n end",
"def get_test_plan\n @takt = Taktinfo.find(params[:id])\n @testplans = @takt.testplans.where(:format =>params[:testp])\n\n respond_to do |format|\n format.json{render json:@testplans.as_json(root:false),:callback =>params[:callback]}\n end\n end",
"def show\n team = Team.find_by(:id => params[:id])\n render :json => team\n end",
"def index\n @waiters = @course.waiters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waiters }\n end\n end",
"def index\n @taste_testers = TasteTester.all\n end",
"def index\n @recruiters = Recruiter.all\n render_json_serializer(@recruiters)\n end",
"def show\n render status: 200, json: Team.find(params[:id])\n end",
"def show\n @dtest = Dtest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dtest }\n end\n end",
"def show\n @porter = Porter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @porter }\n end\n end",
"def show\n @reviewer = Reviewer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reviewer }\n end\n end",
"def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trial }\n end\n end",
"def test_show_posts_user\n expected = 200\n user_id = 34\n response = Net::HTTP.get(URI.parse('http://localhost:3000/v1/users/'+user_id+'/posts'))\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 get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end",
"def show\n @antler = Antler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: AntlerPresenter.new(@antler) }\n end\n end",
"def show\n @test_summary = TestSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_summary }\n end\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n\t@instruction = Instruction.find( params[ :instruction_id ] )\n @testimonies = @instruction.testimonies.page( params[ :page ] ).per(20)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testimonies }\n end\n end",
"def index\n @talleres = Taller.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talleres }\n end\n end",
"def tests(run_id)\n get(\"get_tests/#{run_id}\")\n end"
] | [
"0.73209065",
"0.7289628",
"0.6448436",
"0.64104825",
"0.63615745",
"0.6324568",
"0.6324568",
"0.6265326",
"0.6211121",
"0.61205035",
"0.61042017",
"0.6085299",
"0.6078216",
"0.60519433",
"0.6051615",
"0.60374403",
"0.6033322",
"0.5939788",
"0.5939788",
"0.59379345",
"0.5936767",
"0.5924481",
"0.5872172",
"0.58497757",
"0.58397686",
"0.582495",
"0.5816054",
"0.5801597",
"0.57941264",
"0.5792628",
"0.57910466",
"0.5789729",
"0.5772305",
"0.5753383",
"0.5752047",
"0.5734755",
"0.5716483",
"0.57111645",
"0.5684512",
"0.5684512",
"0.5675335",
"0.5675335",
"0.5673803",
"0.5673803",
"0.5670973",
"0.56706625",
"0.56676376",
"0.56669587",
"0.5650899",
"0.56504214",
"0.56468505",
"0.5646639",
"0.5645504",
"0.5641328",
"0.5641127",
"0.56391656",
"0.5633846",
"0.56285435",
"0.56228536",
"0.56213164",
"0.56213164",
"0.56213164",
"0.56117344",
"0.5599943",
"0.5595047",
"0.55950093",
"0.5588666",
"0.55861104",
"0.5582436",
"0.55797815",
"0.55634636",
"0.5557798",
"0.55558723",
"0.5553008",
"0.5549024",
"0.55483675",
"0.55367917",
"0.5531739",
"0.5518853",
"0.55165",
"0.5505089",
"0.54993397",
"0.5464287",
"0.54617393",
"0.5461236",
"0.5460479",
"0.5459436",
"0.545615",
"0.54517823",
"0.5449963",
"0.5439928",
"0.5429181",
"0.54284614",
"0.5425965",
"0.5423729",
"0.54234624",
"0.5418971",
"0.5418594",
"0.54119086",
"0.54116994",
"0.5409945"
] | 0.0 | -1 |
GET /testers/new GET /testers/new.json | def new
@tester = Tester.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tester }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @trainer = Trainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trainer }\n end\n end",
"def new\n @taker = Taker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taker }\n end\n end",
"def new\n @team_test = TeamTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team_test }\n end\n end",
"def new\n @testis = Teste.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testis }\n end\n end",
"def new\n @test10 = Test10.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test10 }\n end\n end",
"def new\n @specie = Specie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specie }\n end\n end",
"def new\n @testbed_owner = TestbedOwner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testbed_owner }\n end\n end",
"def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @researcher }\n end\n end",
"def new\n @test = LoadTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test }\n end\n end",
"def new\n @tktest = Tktest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tktest }\n end\n end",
"def new\n @test_run = TestRun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_run }\n end\n end",
"def new\n @retailer = Retailer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer }\n end\n end",
"def new\n @test_suite = TestSuite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def new\n @retailer = Retailer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer}\n end\n end",
"def new\n @beer = Beer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer }\n end\n end",
"def new\n @beer = Beer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beer }\n end\n end",
"def new\n @submitter = Submitter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitter }\n end\n end",
"def new\n @testdb = Testdb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testdb }\n end\n end",
"def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end",
"def new\n @spawner = Spawner.new\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spawner }\n end\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end",
"def new\n @waiter = Waiter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @waiter }\n end\n end",
"def new\n @tater = Tater.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tater }\n end\n end",
"def new\n # @retailer = Retailer.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retailer }\n end\n end",
"def new\n @transporter = Transporter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transporter }\n end\n end",
"def new\n @tower = Tower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tower }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def new\n @t = T.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @t }\n end\n end",
"def new\r\n @usertable = Usertable.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @usertable }\r\n end\r\n end",
"def new\n @test_submission = TestSubmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @test_submission }\n end\n end",
"def new\n @test_class = TestClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_class }\n end\n end",
"def new\n @test_user = TestUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_user }\n end\n end",
"def new\n @githuber = Githuber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @githuber }\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html { redirect_to root_path}\n end\n\n end",
"def new\n @test_result = TestResult.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_result }\n end\n end",
"def new\n @tweeter = Tweeter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tweeter }\n end\n end",
"def new\n @porter = Porter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @porter }\n end\n end",
"def new\n @trenton = Trenton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trenton }\n end\n end",
"def new\n @fixture = Fixture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fixture }\n end\n end",
"def new\n @test_page = TestPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_page }\n end\n end",
"def new\n @test_post = TestPost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_post }\n end\n end",
"def new\n @finder = Finder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finder }\n end\n end",
"def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end",
"def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @teach = Teach.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teach }\n end\n end",
"def new\n @mytracker = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mytracker }\n end\n end",
"def new\n @volunteer = Volunteer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer }\n end\n end",
"def new\n @usertest = Usertest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usertest }\n end\n end",
"def new\n @litter = Litter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @litter }\n end\n end",
"def new\n @test_run = current_user.test_runs.new\n @scenario = Scenario.new\n @registration_scenario = @scenario.registration_scenario || Scenario.new\n @profile = Profile.new\n @target = Target.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_run }\n end\n end",
"def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end",
"def create\n @test = Test.create!(test_params)\n\n render json: @test\n end",
"def new\n @software_test = SoftwareTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @software_test }\n end\n end",
"def create\n @tester = Tester.new(params[:tester])\n\n respond_to do |format|\n format.html { redirect_to root_path}\n end\n end",
"def new\n @fixturestat = Fixturestat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fixturestat }\n end\n end",
"def new\n @student_test = StudentTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_test }\n end\n end",
"def new\n @flower = Flower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flower }\n end\n end",
"def new\n @fixture = Fixture.new\n\n respond_to do |format|\n format.json { render json: @fixture }\n end\n end",
"def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team }\n end\n end",
"def new\n @leader = Leader.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leader }\n end\n end",
"def new\n @ultimate_team = UltimateTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ultimate_team }\n end\n end",
"def new\n @lector = Lector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lector }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @interested = Interested.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interested }\n end\n end",
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @name = Name.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end",
"def new\n @reviewer = Reviewer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reviewer }\n end\n end",
"def new\n @name = Name.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end",
"def new\n @test_weight = TestWeight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_weight }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @scraper }\n end\n end",
"def new\n @tea = Tea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tea }\n end\n end",
"def new\n @tea = Tea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tea }\n end\n end",
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def new\n @drug_test = DrugTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @drug_test }\n end\n end",
"def new\n @especy = Especie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @especy }\n end\n end",
"def test_new\n get :new,\n :user_login => users(:aaron).login\n assert_response :success\n end",
"def new\n @creator_source = CreatorSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @creator_source }\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 new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alley }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html { render \"new\", :layout=>false}\n format.json { render json: @team }\n end\n end",
"def new\n @stuff = Stuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stuff }\n end\n end",
"def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end"
] | [
"0.6962197",
"0.6915781",
"0.67971915",
"0.6740493",
"0.67219055",
"0.66921794",
"0.66775817",
"0.6666965",
"0.66543376",
"0.66265124",
"0.66245407",
"0.6603341",
"0.6600335",
"0.65905786",
"0.6590227",
"0.6590227",
"0.6575504",
"0.65586287",
"0.6549298",
"0.6535533",
"0.6528643",
"0.65241086",
"0.6478175",
"0.6477319",
"0.6469272",
"0.64598924",
"0.6450609",
"0.6443088",
"0.6431571",
"0.64303064",
"0.642642",
"0.64114183",
"0.641123",
"0.6410865",
"0.6408851",
"0.64068",
"0.63979477",
"0.63958484",
"0.63930446",
"0.6384395",
"0.6371895",
"0.63702273",
"0.6353419",
"0.6353419",
"0.6348933",
"0.6348933",
"0.6348933",
"0.6348933",
"0.6340035",
"0.6340035",
"0.6340035",
"0.6340035",
"0.6340035",
"0.6340035",
"0.6340035",
"0.63394684",
"0.6337783",
"0.6330271",
"0.63291734",
"0.6325593",
"0.6323477",
"0.63140905",
"0.63096285",
"0.6306455",
"0.6306051",
"0.6305952",
"0.6302807",
"0.6300876",
"0.6300304",
"0.6297986",
"0.62954634",
"0.62927616",
"0.62918174",
"0.62918174",
"0.62918174",
"0.6283235",
"0.62773174",
"0.6273744",
"0.627325",
"0.627325",
"0.62707484",
"0.6269583",
"0.62511677",
"0.62426144",
"0.62425363",
"0.62406003",
"0.62365425",
"0.6234122",
"0.6234122",
"0.62339526",
"0.623014",
"0.6229947",
"0.6225471",
"0.6224246",
"0.62231064",
"0.62184244",
"0.6217528",
"0.62170225",
"0.62162864"
] | 0.7707012 | 1 |
POST /testers POST /testers.json | def create
@tester = Tester.new(params[:tester])
respond_to do |format|
if @tester.save
tester = @tester
session[:tester_id] = tester.id
format.html { redirect_to @tester, notice: 'Tester was successfully created.' }
format.json { render json: @tester, status: :created, location: @tester }
else
format.html { render action: "new" }
format.json { render json: @tester.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_testers\n\t\t@testers_data.shift\n\t\t@testers_data.each do |row|\n\t\t\ttester_id = row[0]\n\t\t\tfirst_name = row[1]\n\t\t\tlast_name = row[2] \n\t\t\tcountry = row[3]\n\t\t\tlast_login = row[4]\n\t\t\ttester = Tester.new(tester_id, first_name, last_name, country, last_login)\n\t\t\t@testers.push(tester)\n\t\tend\n\tend",
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def test!\n @@api.post(endpoint: self.endpoint + ['test'])\n end",
"def create\n @tester = Tester.new(params[:tester])\n\n respond_to do |format|\n format.html { redirect_to root_path}\n end\n end",
"def create\n @test = Test.create!(test_params)\n\n render json: @test\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @tester = Tester.new(params[:tester])\n\n if @tester.save\n flash[:notice] = \"성공적으로 신청이 완료되었습니다^^\"\n redirect_to root_path\n else\n flash[:error] = \"러너 등록에 실패했습니다.\"\n render action: \"new\"\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def new\n @tester = Tester.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tester }\n end\n end",
"def test_should_create_post_via_API_JSON\r\n get \"/logout\"\r\n post \"/forum_posts.json\", :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 topic = JSON.parse(response.body)\r\n assert topic['title'] == 'API Test Post', 'Incorrect topic title'\r\n assert topic['user_id'] == 1, 'Incorrect user id'\r\n assert topic['body'] == 'Test Post desc', 'Incorrect topic description' \r\n end",
"def create\n @trainer = Trainer.new(params[:trainer])\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, :notice => 'Trainer was successfully created.' }\n format.json { render :json => @trainer, :status => :created, :location => @trainer }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def v2_tests_post(test_detail, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: TestsApi#v2_tests_post ...\"\n end\n \n # verify the required parameter 'test_detail' is set\n fail \"Missing the required parameter 'test_detail' when calling v2_tests_post\" if test_detail.nil?\n \n # resource path\n path = \"/v2/tests\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json', 'application/xml', 'text/xml']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(test_detail)\n \n\n auth_names = []\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TestSummary')\n if Configuration.debugging\n Configuration.logger.debug \"API called: TestsApi#v2_tests_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def test_post_success_with_param\n post \"/\", {:data => @test_obj} do |response|\n assert response.ok?, \"Create test object failed\"\n assert_equal response.body, @test_obj.to_json, \"Did not get @test_obj back\"\n end\n end",
"def create\n @trainer = Trainer.new(params[:trainer])\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render json: @trainer, status: :created, location: @trainer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workshop = Workshop.new(workshop_params)\n puts \"====================================\"\n puts params['trainers']\n puts \"====================================\"\n trainers = params['trainers'].map do |id|\n Trainer.find(id)\n end\n @workshop.trainers << trainers\n\n\n respond_to do |format|\n if @workshop.save\n format.html { redirect_to @workshop, notice: 'Workshop was successfully created.' }\n format.json { render :show, status: :created, location: @workshop }\n else\n format.html { render :new }\n format.json { render json: @workshop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_post(params)\n mock_request = Rack::MockRequest.new(APP)\n mock_request.post(new_post_endpoint, { 'router.params' => params, format: :json })\n end",
"def create\n @test = current_user.tests.build(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to thank_you_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_invite_via_API_JSON\r\n get \"/logout\"\r\n post \"/invites.json\", :api_key => 'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response :created\r\n invite = JSON.parse(response.body)\r\n check_new_invite(invite) \r\n end",
"def create\n\n species = Faker::Games::Pokemon.name\n nickname = Faker::Name.first_name\n trainer = Trainer.find(params[:trainer_id])\n if trainer.pokemons.length < 6\n pokemon = Pokemon.create(nickname: nickname, species: species, trainer_id: params[:trainer_id])\n render json: pokemon\n else\n render json: {message: \"Pokemon cannot be created\"}, status: 400\n end\n end",
"def create\n @trainer = Trainer.new(trainer_params)\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @trainer }\n else\n format.html { render :new }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainer = Trainer.new(trainer_params)\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to @trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @trainer }\n else\n format.html { render :new }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n link = JSON.parse(response.body)\r\n check_new_link(link) \r\n end",
"def create\n @taste_tester = TasteTester.new(taste_tester_params)\n\n respond_to do |format|\n if @taste_tester.save\n format.html { redirect_to @taste_tester, notice: 'Taste tester was successfully created.' }\n format.json { render :show, status: :created, location: @taste_tester }\n else\n format.html { render :new }\n format.json { render json: @taste_tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_test = UserTest.new(user_test_params)\n\n respond_to do |format|\n if @user_test.save\n format.html { redirect_to admin_user_tests_path, notice: 'User test was successfully created.' }\n format.json { render :show, status: :created, location: @user_test }\n else\n format.html { render :new }\n format.json { render json: @user_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @user = User.new(users_params)\n @user.save\n @trainer = Trainer.new(trainer_params)\n @trainer.user_id = @user.id\n @trainer.created_at = @user.created_at\n @trainer.updated_at = @user.updated_at\n\n respond_to do |format|\n if @trainer.save\n format.html { redirect_to '/trainers', notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @trainer }\n else\n format.html { render :new }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scratcher = Scratcher.new(permitted_params)\n\n if @scratcher.save\n render json: @scratcher, status: :created, location: @scratcher\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def index\n render status: :ok, json: @tests\n end",
"def create\n @runtest = Runtest.new(runtest_params)\n\n respond_to do |format|\n if @runtest.save\n format.html { redirect_to @runtest, notice: 'Runtest was successfully created.' }\n format.json { render :show, status: :created, location: @runtest }\n else\n format.html { render :new }\n format.json { render json: @runtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jsontest = Jsontest.new(jsontest_params)\n\n respond_to do |format|\n if @jsontest.save\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully created.' }\n format.json { render :show, status: :created, location: @jsontest }\n else\n format.html { render :new }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_senders(sender_request, opts = {})\n data, _status_code, _headers = post_senders_with_http_info(sender_request, opts)\n data\n end",
"def post_request(request_data = {}, errback = DEFAULT_ERROR, &blk)\n req = create_test_request(request_data).post(request_data)\n hookup_request_callbacks(req, errback, &blk)\n end",
"def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def create\n @test_datum = TestDatum.new(test_datum_params)\n\n respond_to do |format|\n if @test_datum.save\n format.html { redirect_to @test_datum, notice: 'Test datum was successfully created.' }\n format.json { render :show, status: :created, location: @test_datum }\n else\n format.html { render :new }\n format.json { render json: @test_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pt_trainer = Pt::Trainer.new(pt_trainer_params)\n\n respond_to do |format|\n if @pt_trainer.save\n format.html { redirect_to @pt_trainer, notice: 'Trainer was successfully created.' }\n format.json { render :show, status: :created, location: @pt_trainer }\n else\n format.html { render :new }\n format.json { render json: @pt_trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"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 index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end",
"def create\n @testtest = Testtest.new(testtest_params)\n\n respond_to do |format|\n if @testtest.save\n format.html { redirect_to @testtest, notice: 'Testtest was successfully created.' }\n format.json { render :show, status: :created, location: @testtest }\n else\n format.html { render :new }\n format.json { render json: @testtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_create_iphone_report\n post(:create, \"reporter\"=>{\"uniqueid\"=>\"13506d733bc5372a3b818fdf29ef8fb7386b3dc3\", \"zipcode\"=>\"21012\", \"firstname\"=>\"David\", \"lastname\"=>\"Troy\", \"email\"=>\"dave@popvox.com\"},\n \"format\"=>\"iphone\",\n \"report\"=>{\"latlon\"=>\"39.025,-76.511:114\", \"title\"=>\"This is a test\", \"body\" => \"Body text\" } )\n assert_response :success\n assert_equal \"OK\", @response.body\n reporter = IphoneReporter.find_by_uniqueid(\"13506d733bc5372a3b818fdf29ef8fb7386b3dc3\")\n assert_equal \"David Troy\", reporter.name\n end",
"def create\n @test_suite = TestSuite.new(params[:test_suite])\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render json: @test_suite, status: :created, location: @test_suite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n teacher_exclusive\n @test = Test.create title: params[:title], test_date: params[:test_date], subject_id: params[:subject_id],teacher_id: @current_user.id\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: \"L'épreuve a été créée\"}\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testsuite = Testsuite.new(testsuite_params)\n\n respond_to do |format|\n if @testsuite.save\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully created.' }\n format.json { render :show, status: :created, location: @testsuite }\n else\n format.html { render :new }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_post = TestPost.new(test_post_params)\n\n respond_to do |format|\n if @test_post.save\n format.html { redirect_to @test_post, notice: 'Test post was successfully created.' }\n format.json { render :show, status: :created, location: @test_post }\n else\n format.html { render :new }\n format.json { render json: @test_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_suite = TestSuite.new(test_suite_params)\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render :show, status: :created, location: @test_suite }\n else\n format.html { render :new }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(params[:test])\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render json: @test, status: :created, location: @test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_all_the_dogs_are_in_one_pack\n @params = {\n packs: [\n {\n dogs: ['Spot', 'Fido', 'Rover'],\n location: 'San Francisco',\n },\n {\n dogs: ['Doggie', 'Lassie'],\n location: 'Canada',\n },\n ],\n }\n\n\n post \"/dogs\", params = @params\n assert_equal 'Spot, Fido, Rover, Doggie, and Lassie are all in one pack. Oh no!', last_response.body\n end",
"def test_create_lead\n client.expects(:request).with(:post, 'https://api.com/rest/sites/site-123/leads',\n '{\"email\":\"lead@gmail.com\"}', nil)\n\n client.create_lead(\"site-123\", {email: \"lead@gmail.com\"})\n end",
"def create\n @admin_retailer = Admin::Retailer.new(admin_retailer_params)\n\n respond_to do |format|\n if @admin_retailer.save\n format.html { redirect_to @admin_retailer, notice: 'Retailer was successfully created.' }\n format.json { render :show, status: :created, location: @admin_retailer }\n else\n format.html { render :new }\n format.json { render json: @admin_retailer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def create\n @retailer = Retailer.new(params[:retailer])\n\n respond_to do |format|\n if @retailer.save\n format.html { redirect_to @retailer, notice: \"Retailer was successfully created.\" }\n format.json { render json: @retailer, status: :created, location: @retailer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retailer.errors, status: :unprocessable_entry }\n end\n end\n end",
"def create\n @trucker = TruckerService.save(trucker_params)\n if response\n render json: @trucker, status: :created, location: [:api, @trucker]\n else\n render json: @trucker, status: :unprocessable_entity\n end\n end",
"def test_start_following_a_user\r\n post \"/follows.json?api_key=bobbyapikey&followee_id=3\" \r\n assert_response :created\r\n follow = JSON.parse(response.body) \r\n assert follow['follower_id'] == 6\r\n assert follow['followee_id'] == 3\r\n end",
"def create\n @testis = Teste.new(params[:testis])\n\n respond_to do |format|\n if @testis.save\n format.html { redirect_to @testis, notice: 'Teste was successfully created.' }\n format.json { render json: @testis, status: :created, location: @testis }\n else\n format.html { render action: \"new\" }\n format.json { render json: @testis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retailer = Retailer.new(params[:retailer])\n\n respond_to do |format|\n if @retailer.save\n format.html { redirect_to @retailer, notice: 'Retailer was successfully created.' }\n format.json { render json: @retailer, status: :created, location: @retailer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retailer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testing_ = Testing.new(testing__params)\n\n respond_to do |format|\n if @testing_.save\n format.html { redirect_to @testing_, notice: 'Testing was successfully created.' }\n format.json { render action: 'show', status: :created, location: @testing_ }\n else\n format.html { render action: 'new' }\n format.json { render json: @testing_.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @waiter = Waiter.new(params[:waiter])\n\n respond_to do |format|\n if @waiter.save\n format.html { redirect_to @waiter, notice: 'Waiter was successfully created.' }\n format.json { render json: @waiter, status: :created, location: @waiter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_run = TestRun.new(params[:test_run])\n\n respond_to do |format|\n if @test_run.save\n format.html { redirect_to @test_run, notice: 'Test run was successfully created.' }\n format.json { render json: @test_run, status: :created, location: @test_run }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_run.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_post = TestPost.new(params[:test_post])\n\n respond_to do |format|\n if @test_post.save\n format.html { redirect_to @test_post, notice: 'Test post was successfully created.' }\n format.json { render json: @test_post, status: :created, location: @test_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testing = Testing.new(testing_params)\n\n respond_to do |format|\n if @testing.save\n format.html { redirect_to @testing, notice: 'Testing was successfully created.' }\n format.json { render :show, status: :created, location: @testing }\n else\n format.html { render :new }\n format.json { render json: @testing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_designer_home\n\n post('index', {}, {})\n assert_response(:success)\n assert_template('tracker/index')\n\n post('index', {}, bob_designer_session)\n assert_response(:success)\n assert_template('tracker/designer_home')\n\n end",
"def create\n # @retailer = Retailer.new(params[:retailer])\n respond_to do |format|\n if @retailer.save\n format.html { redirect_to @retailer, notice: 'Retailer was successfully created.' }\n format.json { render json: @retailer, status: :created, location: @retailer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retailer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_group_invite_via_API_JSON\r\n \r\n end",
"def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def create\n @runner = Runner.new(runner_params)\n @runner.email.strip! # When you cut'n'paste in emails, they can come it with a space at the end!\n\n respond_to do |format|\n if @runner.save\n # log_in @runner // We used to login the runner right here, but create is now a Admin function\n format.html { redirect_to runners_path, notice: \"Profile for #{@runner.name} was successfully created.\" }\n format.json { render :show, status: :created, location: @runner }\n else\n format.html { render :new }\n format.json { render json: @runner.errors, status: :unprocessable_entity }\n end\n end\n\n #Assigning all existing plans to runner as individual runs\n PlannedRun.where(group_id: @runner.group_id).find_each do |plan|\n run = Run.new\n run.runner_id = @runner.id\n run.date = plan.date\n run.training_plan = plan.training_plan\n run.planned_run_id = plan.id\n run.save\n end\n end",
"def test_index \n post :index \n assert_response :success \n end",
"def test_params\n params.require(:test).permit(:name, :date, :teacher_id)\n end",
"def create\n @test10 = Test10.new(params[:test10])\n\n respond_to do |format|\n if @test10.save\n format.html { redirect_to @test10, notice: 'Test10 was successfully created.' }\n format.json { render json: @test10, status: :created, location: @test10 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test10.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testbed_owner = TestbedOwner.new(params[:testbed_owner])\n\n respond_to do |format|\n if @testbed_owner.save\n format.html { redirect_to @testbed_owner, notice: 'Testbed owner was successfully created.' }\n format.json { render json: @testbed_owner, status: :created, location: @testbed_owner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @testbed_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test\n render json: { test: 'Tested.' }\n end",
"def test\n render json: { test: 'Tested.' }\n end",
"def create\n @tktest = Tktest.new(params[:tktest])\n\n respond_to do |format|\n if @tktest.save\n format.html { redirect_to @tktest, notice: 'Tktest was successfully created.' }\n format.json { render json: @tktest, status: :created, location: @tktest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tktest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retailer = Retailer.new(retailer_params)\n\n respond_to do |format|\n if @retailer.save\n format.html { redirect_to @retailer, notice: 'Retailer was successfully created.' }\n format.json { render :show, status: :created, location: @retailer }\n else\n format.html { render :new }\n format.json { render json: @retailer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @papertest = Papertest.new(papertest_params)\n\n respond_to do |format|\n if @papertest.save\n format.html { redirect_to @papertest, notice: 'Papertest was successfully created.' }\n format.json { render :show, status: :created, location: @papertest }\n else\n format.html { render :new }\n format.json { render json: @papertest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def run_test\n # Make sure that params have been set\n raise_error('You need to pass some params to run the test. At least, an url or script') unless block_given?\n params = Hashie::Mash.new\n yield params\n raise_error('No params were passed to run_test method') if params.empty?\n\n response = connection.post do |req|\n req.url \"#{TEST_BASE}\"\n req.params['k'] = key\n req.params['f'] = @params.f\n params.each do |k, v|\n req.params[k] = v\n end\n end\n return not_available (response) unless response.status == 200\n @response = Response.new(self, Hashie::Mash.new(JSON.parse(response.body)))\n end",
"def create\n @trainees = TraineeBatch.new(params[:participants][:ids], params[:training_calendar_id])\n respond_to do |format|\n if @trainees.save\n format.html { redirect_to training_calendar_path(params[:training_calendar_id]), :notice => 'The participant(s) were successfully added.' }\n format.json { render :json => @trainees, :status => :created, :location => @trainees }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainees.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n path = \"/signers\"\n\n response, status = BeyondApi::Request.post(@session,\n path)\n\n handle_response(response, status)\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def create\n @renter = Renter.new(params[:renter])\n @locals = User.where(:city => @buyer.city)\n @users = @locals.random(5)\n respond_to do |format|\n if @renter.save\n @users.each do |user|\n RenterMailer.registration_welcome(@renter, user).deliver\n Renter.increment_counter(\"times_forwarded\", @renter.id)\n end\n format.html { redirect_to :submitted_page, :notice => 'Seller was successfully created.' }\n format.json { render :json => @renter, :status => :created, :location => @renter }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @renter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def create\n #raise an exception to see the hash values\n #raise params.inspect\n @runner = Runner.new(params[:runner])\n \n respond_to do |format|\n if @runner.save\n format.html { redirect_to(runners_path, :notice => 'Page was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @taker = Taker.new(params[:taker])\n\n respond_to do |format|\n if @taker.save\n format.html { redirect_to @taker, notice: 'Taker was successfully created.' }\n format.json { render json: @taker, status: :created, location: @taker }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mailer = Mailer.new(mailer_params)\n\n if @mailer.save\n render json: @mailer, status: :created, location: @mailer\n else\n render json: @mailer.errors, status: :unprocessable_entity\n end\n end",
"def create\n \t# add actions here\n # This action takes place in the test suite controller\n end",
"def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend",
"def create\n @team_test = TeamTest.new(params[:team_test])\n\n respond_to do |format|\n if @team_test.save\n format.html { redirect_to user_management_path(:dept_id=>Team.find(@team_test.team_id).department_id), notice: 'Team test was successfully created.' }\n format.json { render json: @team_test, status: :created, location: @team_test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @trainer = Trainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trainer }\n end\n end",
"def create\n @submitter = Submitter.new(params[:submitter])\n\n respond_to do |format|\n if @submitter.save\n format.html { redirect_to submitters_path }#, notice: 'Submitter was successfully created.' }\n format.json { render json: @submitter, status: :created, location: @submitter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @submitter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fixit_test = FixitTest.new(fixit_test_params)\n\n respond_to do |format|\n if @fixit_test.save\n format.html { redirect_to @fixit_test, notice: 'Fixit test was successfully created.' }\n format.json { render action: 'show', status: :created, location: @fixit_test }\n else\n format.html { render action: 'new' }\n format.json { render json: @fixit_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if params[:name].present?\n @json = Punk::API.beers_name!(params[:name])\n elsif params[:abv_gt].present?\n @json = Punk::API.beers_abv_gt!(params[:abv_gt])\n elsif params[:abv_lt].present?\n @json = Punk::API.beers_abv_lt!(params[:abv_lt])\n else\n @json = Punk::API.all_beers!(params)\n end\n\n render json: {\n beers: @json\n }\n create(@json)\n end",
"def create\n @instructor = Instructor.new(trainer_params)\n if @instructor.save\n render json: @instructor\n else\n render json: @instructor.errors\n end\n end",
"def create\n @runscope_test = RunscopeTest.new(runscope_test_params)\n\n respond_to do |format|\n if @runscope_test.save\n format.html { redirect_to @runscope_test, notice: 'Runscope test was successfully created.' }\n format.json { render :show, status: :created, location: @runscope_test }\n else\n format.html { render :new }\n format.json { render json: @runscope_test.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.62470764",
"0.62440044",
"0.60670966",
"0.59749275",
"0.595247",
"0.58003616",
"0.5776615",
"0.57670504",
"0.57129145",
"0.5675836",
"0.5675836",
"0.56390727",
"0.5621989",
"0.55856836",
"0.5566835",
"0.55240077",
"0.55219245",
"0.5514852",
"0.550431",
"0.5468431",
"0.54415214",
"0.54285663",
"0.54285663",
"0.54055905",
"0.54055905",
"0.5348685",
"0.53458977",
"0.53096884",
"0.5298595",
"0.5298399",
"0.5290277",
"0.528316",
"0.5263959",
"0.5263959",
"0.5263959",
"0.5263959",
"0.5263959",
"0.5263959",
"0.52603924",
"0.52549034",
"0.52478725",
"0.524398",
"0.52400315",
"0.5235485",
"0.52354795",
"0.5229801",
"0.52266496",
"0.52157134",
"0.5214141",
"0.52094775",
"0.5207738",
"0.520396",
"0.52029",
"0.51951534",
"0.5188933",
"0.5184618",
"0.51726604",
"0.5167942",
"0.51638997",
"0.51614064",
"0.51526296",
"0.51508206",
"0.51462495",
"0.5143521",
"0.5136237",
"0.5133266",
"0.513183",
"0.5122959",
"0.5122726",
"0.5117164",
"0.5116161",
"0.5115299",
"0.510821",
"0.5091216",
"0.5085542",
"0.5074449",
"0.50741166",
"0.507086",
"0.507086",
"0.5063926",
"0.50600225",
"0.5055749",
"0.5055553",
"0.50518966",
"0.5042989",
"0.5042336",
"0.5039344",
"0.5029333",
"0.50278616",
"0.5022083",
"0.5021487",
"0.5020359",
"0.5020235",
"0.50192595",
"0.5011651",
"0.501043",
"0.5007761",
"0.50068146",
"0.5001304",
"0.49993113"
] | 0.5996782 | 3 |
PUT /testers/1 PUT /testers/1.json | def update
@tester = Tester.find(params[:id])
respond_to do |format|
if @tester.update_attributes(params[:tester])
format.html { redirect_to @tester, notice: 'Tester was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @tester.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put_success\n put \"/blah\", @test_obj do |response|\n assert response.ok?, \"Update test object failed\"\n end\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @trainer = Trainer.find(params[:id])\n\n if @trainer.update(trainer_params)\n head :no_content\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\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(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @test = Test.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_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_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n if @test.update(test_params)\n render status: :ok, json: @test\n else\n self.send(:edit)\n end\n end",
"def update\n #@user = User.find(params[:id])\n \n if @trainer.update(trainer_params)\n render json: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\nend",
"def update\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n if @team_test.update_attributes(params[:team_test])\n format.html { redirect_to @team_test, notice: 'Team test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n if @test10.update_attributes(params[:test10])\n format.html { redirect_to @test10, notice: 'Test10 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test10.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to root_path, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jsontest.update(jsontest_params)\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully updated.' }\n format.json { render :show, status: :ok, location: @jsontest }\n else\n format.html { render :edit }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test1.update(test1_params)\n format.html { redirect_to @test1, notice: \"Test1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @test1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @test1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tester = Tester.find(params[:id])\n @tester.destroy\n\n respond_to do |format|\n format.html { redirect_to testers_url }\n format.json { head :no_content }\n end\n end",
"def put!\n request! :put\n end",
"def update\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n if @trainer.update_attributes(params[:trainer])\n format.html { redirect_to @trainer, :notice => 'Trainer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trainer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trainer = Trainer.find(params[:id])\n\n respond_to do |format|\n if @trainer.update_attributes(params[:trainer])\n format.html { redirect_to @trainer, notice: 'Trainer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n teacher_exclusive\n respond_to do |format|\n if @test.update title: params[:title], test_date: params[:test_date], teacher_id: @current_user.id\n format.html { redirect_to @test, notice: \"L'épreuve a été modifiée\" }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def update\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n if @testbed_owner.update_attributes(params[:testbed_owner])\n format.html { redirect_to @testbed_owner, notice: 'Testbed owner was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testbed_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testis = Teste.find(params[:id])\n\n respond_to do |format|\n if @testis.update_attributes(params[:testis])\n format.html { redirect_to @testis, notice: 'Teste was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n if @student_test.update_attributes(params[:student_test])\n format.html { redirect_to @student_test, notice: 'Student test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testtest.update(testtest_params)\n format.html { redirect_to @testtest, notice: 'Testtest was successfully updated.' }\n format.json { render :show, status: :ok, location: @testtest }\n else\n format.html { render :edit }\n format.json { render json: @testtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @runner = Runner.find(params[:id])\n\n respond_to do |format|\n if @runner.update_attributes(params[:runner])\n format.html { redirect_to @runner, notice: 'Runner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @runner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n @test_set = TestSet.find(params[:id])\n permitted_to! :update, @test_set.problem\n respond_to do |format|\n if @test_set.update_attributes(permitted_params)\n format.html { redirect_to @test_set, :notice => 'Test set was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def put(*args)\n request :put, *args\n end",
"def update\n respond_to do |format|\n if @taste_tester.update(taste_tester_params)\n format.html { redirect_to @taste_tester, notice: 'Taste tester was successfully updated.' }\n format.json { render :show, status: :ok, location: @taste_tester }\n else\n format.html { render :edit }\n format.json { render json: @taste_tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_test = TestTest.find(params[:id])\n\n respond_to do |format|\n if @test_test.update_attributes(params[:test_test])\n format.html { redirect_to(@test_test, :notice => 'TestTest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @publishers_test\n respond_to do |format|\n if @publishers_test.update(publishers_test_params)\n # @TODO: Changed url to redirecting\n # format.html { redirect_to @publishers_test, notice: 'Test was successfully updated.' }\n format.html { redirect_to @publisher, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @publishers_test }\n else\n format.html { render :edit }\n format.json { render json: @publishers_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test = @subject.tests.find_by_id(params[:id])\n if @test.update_attributes(params[:test])\n redirect_to user_subject_tests_path\n else\n render :action => \"edit\"\n end\n end",
"def test_change_status\n expected = 200\n post_id = 1\n data = {\n status: 1\n }\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s+'/status')\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to patient_path(@test.patient), notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trucker = TruckerService.save(trucker_params)\n if response\n render json: @trucker, status: :created, location: [:api, @trucker]\n else\n render json: @trucker, status: :unprocessable_entity\n end\n end",
"def test_should_update_profile\n # login_as(:patrick)\n # put :update, :id => profiles(:profile_00006).id, :profile => { }\n # assert_redirected_to profile_path(assigns(:profile))\n end",
"def test_update\n put :update, :id => User.first.id,\n\t\t\t :user =>{:name => 'farid',:email => 'farid@gmail.com',:pasword => '12345', :address => 'semarang'}\n assert_not_nil assigns(:user)\n assert_equal assigns(:user).name, 'updated name' \n assert_response :redirect\n assert_equal flash[:notice] = 'User was succesful Update' \n end",
"def update\n if @test.update(test_params)\n return render json: {message: 'Test was updated succesfully', error: false }\n else\n return render json: {message: 'Error: Test was not updated succesfully', error: true }\n end\n end",
"def update\n if @test.update(test_params)\n respond_to do |format|\n format.html { redirect_to admin_tests_path }\n format.json { render :show, status: :ok, location: admin_tests_path }\n end\n else\n respond_to do |format|\n format.html { render :edit, notice: \"Please do you test again. An unexpected error has occured!\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end \n end",
"def create_method\n :put_json\n end",
"def update\n\t\t\t\t\n\t\t\t\ttparams = params.require(:testimony).permit :quote,:author,:sort,:created_at,:updated_at\n\n\t\t\t\t@testimony = Testimony.find params[:id]\n\n\t\t\t\tif @testimony.update(tparams)\n\n\t\t\t\t\trender json: nil,status: 200\n\n\t\t\t\telse\n\n\t\t\t\t\trender json: nil,status: 422\n\n\t\t\t\tend\n\n\t\t\tend",
"def test_update_user()\n # Parameters for the API call\n\n metadata = JSON.parse('{'\\\n '\"email\": \"testrubyapi@user.com\",'\\\n '\"name\": \"ruby api user\",'\\\n '\"custom\": \"testdata\"'\\\n '}')\n\n campaign_model = CampaignModel.new()\n campaign_model.utm_source = \"Newsletter\"\n campaign_model.utm_medium = \"Email\"\n\n user_model = UserModel.new()\n user_model.modified_time = Time.now.utc.iso8601\n user_model.user_id = \"12345\"\n user_model.company_id = \"67890\"\n user_model.metadata = metadata\n user_model.campaign = campaign_model\n\n # Perform the API call through the SDK function\n self.class.controller.update_user(user_model)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 201)\n end",
"def update\n @testmonial = Testmonial.find(params[:id])\n\n if @testmonial.update(testmonial_params)\n head :no_content\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tester = Tester.new(params[:tester])\n \n\n respond_to do |format|\n if @tester.save\n tester = @tester\n session[:tester_id] = tester.id\n format.html { redirect_to @tester, notice: 'Tester was successfully created.' }\n format.json { render json: @tester, status: :created, location: @tester }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def update\n @test_user = TestUser.find(params[:id])\n\n respond_to do |format|\n if @test_user.update_attributes(params[:test_user])\n format.html { redirect_to @test_user, notice: 'Test user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test!\n @@api.post(endpoint: self.endpoint + ['test'])\n end",
"def update\n @waiter = Waiter.find(params[:id])\n\n respond_to do |format|\n if @waiter.update_attributes(params[:waiter])\n format.html { redirect_to @waiter, notice: 'Waiter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testing_.update(testing__params)\n format.html { redirect_to @testing_, notice: 'Testing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @testing_.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n if @test_run.update_attributes(params[:test_run])\n format.html { redirect_to @test_run, notice: 'Test run was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_run.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Prueba actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tktest = Tktest.find(params[:id])\n\n respond_to do |format|\n if @tktest.update_attributes(params[:tktest])\n format.html { redirect_to @tktest, notice: 'Tktest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tktest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n tp = test_params.merge!(plate_id: params[:plate_id])\n respond_to do |format|\n if @test.update(tp)\n format.html { redirect_to [@plate, @test], notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n if @testcase.update_attributes(params[:testcase])\n format.html { redirect_to @testcase, :notice => 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @testcase.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @test = TkdTest.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:tkd_test])\n format.html { redirect_to(@test, :notice => 'Test was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def update\n respond_to do |format|\n if @test_detail.update(test_detail_params)\n format.html { redirect_to @test_detail, notice: 'Test detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_detail }\n else\n format.html { render :edit }\n format.json { render json: @test_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client.update(client_params)\n render json: @client\n end",
"def update\n @test = Mg::Test.find(params[:id])\n\n if @test.update_attributes(params[:test])\n flash[:notice] = 'Test was successfully updated.'\n redirect_to mg_test_url :id => @test.id\n else\n render :action => \"edit\"\n end\n end",
"def put(*args, &block)\n self.client.put *args\n end",
"def update\n respond_to do |format|\n if @hero_seeker.update(hero_seeker_params)\n format.html { redirect_to @hero_seeker, notice: 'Hero seeker was successfully updated.' }\n format.json { render :show, status: :ok, location: @hero_seeker }\n else\n format.html { render :edit }\n format.json { render json: @hero_seeker.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 put(*args)\n request(:put, *args)\n end",
"def update\n respond_to do |format|\n if @sneaker.update(sneaker_params)\n Sneaker.reindex\n format.html { redirect_to @sneaker, notice: 'Sneaker was successfully updated.' }\n format.json { render :show, status: :ok, location: @sneaker }\n else\n format.html { render :edit }\n format.json { render json: @sneaker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @usertest = Usertest.find(params[:id])\n\n respond_to do |format|\n if @usertest.update_attributes(params[:usertest])\n format.html { redirect_to @usertest, notice: 'Usertest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usertest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainer.update(trainer_params)\n format.html { redirect_to @trainer, notice: 'Trainer was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainer }\n else\n format.html { render :edit }\n format.json { render json: @trainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n if @test_suite.update_attributes(params[:test_suite])\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jquery_test.update(jquery_test_params)\n format.html { redirect_to @jquery_test, notice: 'Jquery test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @jquery_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def update\n respond_to do |format|\n if @test_stuff.update(test_stuff_params)\n format.html { redirect_to @test_stuff, notice: 'Test stuff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_stuff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n respond_to do |format|\n if @testsuite.update(testsuite_params)\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully updated.' }\n format.json { render :show, status: :ok, location: @testsuite }\n else\n format.html { render :edit }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_instance.update(test_instance_params)\n format.html { redirect_to @test_instance, notice: 'Test instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_instance }\n else\n format.html { render :edit }\n format.json { render json: @test_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_test = Admin::Test.find(params[:id])\n\n respond_to do |format|\n if @admin_test.update_attributes(params[:admin_test])\n format.html { redirect_to(@admin_test, :notice => 'Test was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end",
"def test_should_update_membership\n login_as(:john)\n put :update, :id => 1, :membership => { }\n assert_response :redirect\n end",
"def update\n respond_to do |format|\n if @test_instance.update(test_instance_params)\n # jankety solution to set version properly\n @test_instance.update_version(true)\n\n format.html do\n redirect_to test_case_test_instances_url(@test_case),\n notice: 'Test instance was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @test_instance }\n else\n format.html { render :edit }\n format.json do\n render json: @test_instance.errors, status: :unprocessable_entity\n end\n end\n end\n end"
] | [
"0.61199856",
"0.60428333",
"0.6009719",
"0.599153",
"0.5939015",
"0.5874653",
"0.5859881",
"0.5837808",
"0.5810235",
"0.57881397",
"0.57473135",
"0.5744735",
"0.57092404",
"0.5698415",
"0.56830764",
"0.56617266",
"0.5657657",
"0.5647752",
"0.5647752",
"0.5647752",
"0.5647752",
"0.5647752",
"0.5647752",
"0.5647752",
"0.56271887",
"0.5590398",
"0.5589096",
"0.55730855",
"0.55730855",
"0.55666226",
"0.55531234",
"0.5542422",
"0.55365974",
"0.55354714",
"0.55267864",
"0.55261225",
"0.5500761",
"0.5492143",
"0.54581475",
"0.5454819",
"0.54487884",
"0.54307157",
"0.54199344",
"0.5403896",
"0.5391588",
"0.5390498",
"0.53902775",
"0.5389618",
"0.53849006",
"0.53824794",
"0.53626883",
"0.5359579",
"0.53577083",
"0.535642",
"0.5351684",
"0.53506887",
"0.53493226",
"0.5345161",
"0.5342828",
"0.53404844",
"0.5330508",
"0.53234434",
"0.5317849",
"0.53130835",
"0.53063834",
"0.53049225",
"0.52968085",
"0.52866066",
"0.5280633",
"0.5271562",
"0.52672225",
"0.52628714",
"0.52587587",
"0.5258548",
"0.52551574",
"0.5249201",
"0.5248724",
"0.52448314",
"0.5244323",
"0.52427775",
"0.5238254",
"0.5233959",
"0.5232285",
"0.5227357",
"0.52230877",
"0.5218751",
"0.52162415",
"0.5214081",
"0.52134913",
"0.5212293",
"0.5210774",
"0.5210277",
"0.5202619",
"0.52006257",
"0.5198743",
"0.5197192",
"0.51917785",
"0.51917785",
"0.5188269"
] | 0.6563973 | 1 |
DELETE /testers/1 DELETE /testers/1.json | def destroy
@tester = Tester.find(params[:id])
@tester.destroy
respond_to do |format|
format.html { redirect_to testers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Prueba eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testis = Teste.find(params[:id])\n @testis.destroy\n\n respond_to do |format|\n format.html { redirect_to testes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usertest = Usertest.find(params[:id])\n @usertest.destroy\n\n respond_to do |format|\n format.html { redirect_to usertests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run.destroy\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n teacher_exclusive\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: \"L'épreuve a été supprimée\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing_.destroy\n respond_to do |format|\n format.html { redirect_to testing_s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jsontest.destroy\n respond_to do |format|\n format.html { redirect_to jsontests_url, notice: 'Jsontest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testtest.destroy\n respond_to do |format|\n format.html { redirect_to testtests_url, notice: 'Testtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = LoadTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to load_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run = TestRun.find(params[:id])\n @test_run.destroy\n\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testdb = Testdb.find(params[:id])\n @testdb.destroy\n\n respond_to do |format|\n format.html { redirect_to testdbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testbed_owner = TestbedOwner.find(params[:id])\n @testbed_owner.destroy\n\n respond_to do |format|\n format.html { redirect_to testbed_owners_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_data_url, notice: 'Test datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n if @test.destroy\n return render json: { message: 'Test was removed succesfully.', error: false }\n else\n return render json: { message: 'Error :Something went wrong. Test was not removed.', error: true }\n end\n end",
"def destroy\n @test10 = Test10.find(params[:id])\n @test10.destroy\n\n respond_to do |format|\n format.html { redirect_to test10s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = Mg::Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_test = Admin::Test.find(params[:id])\n @admin_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @runner.destroy\n respond_to do |format|\n format.html { redirect_to runners_url, notice: 'Runner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @runner.destroy\n respond_to do |format|\n format.html { redirect_to runners_url, notice: 'Runner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n @test_run.destroy\n\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tktest = Tktest.find(params[:id])\n @tktest.destroy\n\n respond_to do |format|\n format.html { redirect_to tktests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dovetest.destroy\n respond_to do |format|\n format.html { redirect_to dovetests_url, notice: 'Dovetest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_set = TestSet.find(params[:id])\n permitted_to! :destroy, @test_set\n @test_set.destroy\n\n respond_to do |format|\n format.html { redirect_to test_sets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_test = TestTest.find(params[:id])\n @test_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dtest = Dtest.find(params[:id])\n @dtest.destroy\n\n respond_to do |format|\n format.html { redirect_to dtests_url, notice: t(:dest_test) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = TkdTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team_test = TeamTest.find(params[:id])\n @team_test.destroy\n\n respond_to do |format|\n format.html { redirect_to team_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @alram_test.destroy\n respond_to do |format|\n format.html { redirect_to alram_tests_url, notice: 'Alram test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drug_test = DrugTest.find(params[:id])\n @drug_test.destroy\n\n respond_to do |format|\n format.html { redirect_to drug_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_test.destroy\n respond_to do |format|\n format.html { redirect_to user_tests_url, notice: 'User test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @runtest.destroy\n respond_to do |format|\n format.html { redirect_to runtests_url, notice: 'Runtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jquery_test.destroy\n respond_to do |format|\n format.html { redirect_to jquery_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stuff.destroy\n respond_to do |format|\n format.html { redirect_to test_stuffs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testpat.destroy\n respond_to do |format|\n format.html { redirect_to testpats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url(subject_class_id: @test.subject_class_id), notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = Test.find_by_id(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to user_subject_tests_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t\t\t\n\t\t\t\tTestimony.find(params[:id]).destroy\n\n\t\t\t\trender json: nil,status: 200\n\t\t\t\n\t\t\tend",
"def destroy\n @trainer = Trainer.find(params[:id])\n @trainer.destroy\n\n respond_to do |format|\n format.html { redirect_to trainers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainer = Trainer.find(params[:id])\n @trainer.destroy\n\n respond_to do |format|\n format.html { redirect_to trainers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taste_tester.destroy\n respond_to do |format|\n format.html { redirect_to taste_testers_url, notice: 'Taste tester was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @testmonial.destroy\n\n head :no_content\n end",
"def destroy\n @client.delete(@name)\n end",
"def destroy\n @fixit_test.destroy\n respond_to do |format|\n format.html { redirect_to fixit_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_detail.destroy\n respond_to do |format|\n format.html { redirect_to test_details_url, notice: 'Test detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @publishers_test\n @publishers_test.destroy\n respond_to do |format|\n # @TODO: Commented next line\n # format.html { redirect_to publishers_tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testurl.destroy\n respond_to do |format|\n format.html { redirect_to testurls_url, notice: 'Testurl was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to test_suites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @httparty_test.destroy\n respond_to do |format|\n format.html { redirect_to httparty_tests_url, notice: 'Httparty test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_user = TestUser.find(params[:id])\n @test_user.destroy\n\n respond_to do |format|\n format.html { redirect_to test_users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_item.destroy\n respond_to do |format|\n format.html { redirect_to test_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testtype.destroy\n respond_to do |format|\n format.html { redirect_to testtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing.destroy\n respond_to do |format|\n format.html { redirect_to testings_url, notice: 'Testing was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @testsuite.destroy\n respond_to do |format|\n format.html { redirect_to testsuites_url, notice: 'Testsuite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainer = Trainer.find(params[:id])\n @trainer.destroy\n\n head :no_content\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @client.delete( name )\n end",
"def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to testcases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_file = TestFile.find(params[:id])\n @test_file.destroy\n\n respond_to do |format|\n format.html { redirect_to test_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trial.destroy\n respond_to do |format|\n format.html { redirect_to trials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_case.destroy\n respond_to do |format|\n format.html { redirect_to test_cases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_submission = TestSubmission.find(params[:id])\n @test_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to test_submissions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @waiter = Waiter.find(params[:id])\n @waiter.destroy\n\n respond_to do |format|\n format.html { redirect_to waiters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @performance_test = PerformanceTest.find(params[:id])\n @performance_test.destroy\n\n respond_to do |format|\n format.html { redirect_to performance_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @retailer = Retailer.find(params[:id])\n @retailer.destroy\n\n respond_to do |format|\n format.html { redirect_to retailers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @taker = Taker.find(params[:id])\n @taker.destroy\n\n respond_to do |format|\n format.html { redirect_to takers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @smoke_test = SmokeTest.find(params[:id])\n @smoke_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(smoke_tests_url) }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def destroy\n contest = @data_set.contest\n @data_set.destroy\n respond_to do |format|\n format.html { redirect_to admin_contest_url(contest), notice: 'Data set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n head :no_content\n end",
"def destroy\n @runner = Runner.find(params[:id])\n @runner.destroy\n \n respond_to do |format|\n format.html { redirect_to(runners_path, :notice => 'Page was successfully deleted.')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @updaterete = Updaterete.find(params[:id])\n @updaterete.destroy\n\n respond_to do |format|\n format.html { redirect_to updateretes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @patienttest.destroy\n respond_to do |format|\n format.html { redirect_to patienttests_url, notice: 'Patienttest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_two.destroy\n respond_to do |format|\n format.html { redirect_to test_twos_url, notice: 'Test two was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retailer = Retailer.find(params[:id])\n @retailer.destroy\n\n respond_to do |format|\n format.html { redirect_to retailers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teste_anamnese.destroy\n respond_to do |format|\n format.html { redirect_to teste_anamneses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_dep_collector.destroy\n respond_to do |format|\n format.html {redirect_to test_dep_collectors_url, notice: 'Test dep collector was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @reacttest.destroy\n respond_to do |format|\n format.html { redirect_to reacttests_url, notice: 'Reacttest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @papertest.destroy\n respond_to do |format|\n format.html { redirect_to papertests_url, notice: 'Papertest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.71065456",
"0.7083975",
"0.7083975",
"0.70367557",
"0.6883506",
"0.6862371",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.68592167",
"0.68464684",
"0.6819669",
"0.6817015",
"0.67892253",
"0.6787282",
"0.67779654",
"0.6773422",
"0.67543375",
"0.67452663",
"0.6735751",
"0.6721425",
"0.6717734",
"0.6710042",
"0.6695468",
"0.66904175",
"0.6669727",
"0.666858",
"0.666858",
"0.66588134",
"0.66541976",
"0.6653266",
"0.66401106",
"0.66389585",
"0.6638499",
"0.6637516",
"0.66343",
"0.66327375",
"0.6631887",
"0.6626004",
"0.6614667",
"0.66100717",
"0.660493",
"0.65966487",
"0.65846205",
"0.65796435",
"0.6573501",
"0.65701157",
"0.65676385",
"0.6546264",
"0.6532412",
"0.6532412",
"0.6531626",
"0.65304923",
"0.6528401",
"0.6526331",
"0.6525872",
"0.65254956",
"0.65163285",
"0.6506943",
"0.65065956",
"0.65016675",
"0.6499531",
"0.6495149",
"0.6482295",
"0.6481196",
"0.64786553",
"0.64774156",
"0.6476294",
"0.64761895",
"0.64663845",
"0.64565",
"0.64522684",
"0.64360356",
"0.64288455",
"0.64236575",
"0.64143336",
"0.64126676",
"0.6412084",
"0.64102226",
"0.6407544",
"0.6405704",
"0.6402171",
"0.63984597",
"0.63946986",
"0.6394071",
"0.6391485",
"0.6389466",
"0.63855237",
"0.63837314",
"0.6380782",
"0.6377235",
"0.63769794",
"0.63724387",
"0.6365525",
"0.6351619"
] | 0.77072614 | 1 |
aqui dependiendo el tipo de usuario en este caso Subscribed para live ppe, y dependiendo el browser es el que vamos a usar. | def user_by_browser_tdc
puts $brow.to_s
if $brow == 'chrome'
return { "email" => $user_sus_lc_tdc_cr, "password" => $pass_sus_lc_tdc_cr }
elsif $brow == "safari"
return { "email" => $user_sus_lc_tdc_saf, "password" => $pass_sus_lc_tdc_saf }
elsif $brow == "mozilla"
return { "email" => $user_sus_lc_tdc_moz, "password" => $pass_sus_lc_tdc_moz }
else
fail(msg='No entro el case de usuarios por browser y Sus TDC')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsSubscribed=(arg0)",
"def IsSubscribed=(arg0)",
"def subscribe_to_default_channels\n #User.find_by_username(\"brevidy\").channels.where(:recommended => true).each { |c| c.subscribe!(self) } unless Rails.env.test?\n end",
"def registered(user)\n self.rsvped?(user) || self.isHost?(user)\n end",
"def subscribed?(user)\n user.subscription.subscribed==true\n end",
"def subscribing?(other_user)\n subscribing.include?(other_user)\n end",
"def user_type; end",
"def on_users_account\n true\n end",
"def is_user?\n usertype == 'user'\n end",
"def suscription_on?\n is_subscribed == true\n end",
"def user_type\n\t\tif (current_user.type == 'Trainer')\n\t\t\ttrainer\n\t\telsif (current_user.type == 'Client')\n\t\t\tclient\n\t\t\t\n\t\tend\n\t\t\n\tend",
"def user_is_producer_of_channel?(channel_id)\n logged_in? && current_user.login == THUMBWEBS_AUTHORIZED_USER\nend",
"def user_provider; end",
"def initialize_website_user\n self.user_type = TYPE_WEBSITE\n self.update_user_code\n self.update_activation_code\n self.status = STATUS_UNACTIVE\n end",
"def proxy_user; end",
"def allow_registration?\n true\n end",
"def is_subscribed?(user)\n fan_channel_id_youtube = self.channel_id_youtube\n subscriber = user.subscribers.find_by(channel_id_youtube: fan_channel_id_youtube)\n sub_status = subscriber.nil? ? false : subscriber.is_subscribed # if subscriber exists in db, we show his status, else it's false anyway\n return sub_status\n end",
"def user_type\n if self.class.name == \"PubcookieUser\"\n type = self.identity_type == \"Student\" ? self.identity_type : \"UW Standard user\"\n else\n type = \"External user\"\n end\n type\n end",
"def subscribed?\n self.type == :subscribed\n end",
"def fireeagle_user\n\t\t@fireeagle_user||=client.user\n\tend",
"def is_subscribable?\n is_partner_subscription? || is_premium_subscription?\n end",
"def after_install\r\n users = ::GDO::User::GDO_User\r\n users.system\r\n end",
"def send_user_data(user)\n end",
"def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end",
"def fulfilled_without_acceptance\n UserNotifier.deliver_ready(self, user)\n end",
"def can_chat_with(user)\n\n end",
"def subscribed; end",
"def require_user\n end",
"def is_potential_user?\n\t\ttrue\n\tend",
"def signup_notification(user)\n\t\tsetup_email(user)\n\t\t subject self.site_name+\" : \"+I18n.t('mailer.signup_notification.subject')\n\t\t body :url => self.daurl+\"/admin/activate/#{user.activation_code}\",\n\t\t\t:site => self.site_name,\n\t\t\t:user_login => user.login,\n\t\t\t:user_password => user.password\n end",
"def users_waiting_for_authorization\n Skype.find_users_of_type \"USERS_WAITING_MY_AUTHORIZATION\"\n end",
"def on_twitter_engine_register_user(e, who, user, pass)\n pre = '<Twitter::Engine>'\n @log.info(\"#{pre} Registering user: #{who} (xmpp) => #{user} (twitter).\")\n end",
"def subscribe?\n self.type == :subscribe\n end",
"def step3\n user = session[:user]\n #for v1, always this will be the subscription basic 18$, for v2 this will change\n user.subscription_id = 1\n end",
"def vendor_user?\n \treturn self.user_category == \"vendor\"\n end",
"def sso_user_upn\n request.env[\"HTTP_EPPN\"] || (current_user && current_user.upn) || (current_user && current_user.email) \n end",
"def check_user_background\n self.status = Status::PENDING_ADMIN_ACTION if offender && offender.new_user?\n end",
"def apresentacao\n if @permissao === \"convidado\"\n puts \"o usuário selecionado possui a permissao de Convidado\"\n end\n if @permissao === \"autenticado\"\n puts \"o usuário selecionado possui a permissao de Autenticado\"\n end\n if @permissao === \"admin\"\n puts \"o usuário selecionado possui a permissao de Admin\"\n end\n end",
"def start_typing(_user)\n PubSub::Publisher.new.publish_for(user_participants.online.where.not(id: _user.id), 'start_typing', {source: {id: id}, user: _user.as_basic_json(:now)}, {foreground: true})\n end",
"def user_registered(user)\n @user = user\n\n mail to: \"pierre@sugaryourcoffee.de\",\n subject: \"[apptrack] New User has registered for apptrack\"\n end",
"def user_sign_up(user)\n @user = user\n\n set_attachments\n\n case APP_CONFIG['app_country']\n when 'AR'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - Nuevo usuario registrado\")\n when 'CO'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - Nuevo usuario registrado\")\n when 'MX'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - Nuevo usuario registrado\")\n end\n\n end",
"def checkIfAlreadyOnline\n # check the presence chat channel to see if the current users is subscribed to the channel\n # if the user is then render return true, else return false\n allUsers = Pusher.get('/channels/presence-chat/users')\n allUsers[:users].each do |userHash|\n return true if userHash.first.last == current_user.id.to_s\n end\n return false\n end",
"def subscribe_to_channel; end",
"def signup_notification(user)\n setup_email(user)\n @subject += I18n.t 'mailer.signup.subject'\n \n @body[:url] = \"http://www.dripplet.com/#{user.locale}/activate/#{user.activation_code}\"\n \n end",
"def users_types= value ; @users_types = value end",
"def user_for_vestal_versions; end",
"def faft_robot(user)\n end",
"def subscribed # :doc:\n # Override in subclasses\n end",
"def registration_required?\n not hosted?\nend",
"def registration_required?\n not hosted?\nend",
"def any_user *types\n types = types.flatten.select_labels.map(&:to_sym)\n types = types & ::CanTango.config.users.registered\n users = types.map do |type|\n meth = :\"current_#{type}\"\n send(meth) if respond_to?(meth) && (types.empty? || types.include?(type))\n end\n chosen_user = users.compact.first\n chosen_user || guest_user\n end",
"def status_getuser?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_GETUSER)\n return false\n end",
"def participa?(otro_user)\n cousers.include?(otro_user)\n end",
"def wants_to_subscribe?\n source_is_ffcrm? && has_list?\n end",
"def sendable(type)\n if type == :ios\n user.apn_device_tokens.map{|apn_device_token|\n APNS::Notification.new(apn_device_token.device_id, ios_version)\n }\n elsif type == :android\n sendable_android\n end\n end",
"def loaded_user\n user_type == 'MeetupUser' ? meetup_user : bridgetroll_user\n end",
"def pro_page?\n (session[:user_type] && session[:user_type] == USER_TYPES[:pro])\n end",
"def ws_administrator_request(admin, user, type, msg)\n\t\tsetup_email(User.find(admin))\n\t\tfrom User.find(user).email\n\t\tsubject self.site_name+\" : \"+type\n\t\tbody :msg => msg\n end",
"def no_browser # :nologin: :norobots:\n end",
"def web_auth\n\t\tauth ::UWeb\n\tend",
"def IsSubscribed()\r\n ret = _getproperty(1610743814, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def IsSubscribed()\r\n ret = _getproperty(1610743814, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def user_on\n session[:user_id] = '3980284084'\n end",
"def user_present(host, username)\n case host['platform']\n when /eos/\n on(host, \"useradd #{username}\")\n else\n host.user_present(username)\n end\n end",
"def wechat\n if wechat_user_solver.success?\n # is it a new user ?\n handle_after_sign_up! wechat_user_solver.data[:customer]\n sign_in_user wechat_user_solver.data[:customer]\n else\n failure\n end\n end",
"def bot_user?\n !@email.nil?\n end",
"def subscribers_dev\n if server_data\n @subscribers_dev ||= server_data[:subscribers_dev].map { |u| User.new(u[:core_id]) }\n else\n []\n end\n end",
"def authorize subscriber, node\n true\n end",
"def status_getuser!()\n @status = TAC_PLUS_AUTHEN_STATUS_GETUSER\n end",
"def notify_users_and_add_it\n return # disabled for now\n return true if remote?\n User.find_all_by_notify_on_new_torrents(true).each do |user|\n Notifier.send_new(user,self) if user.notifiable_via_jabber?\n user.watch(self) unless user.dont_watch_new_torrents?\n end\n end",
"def set_user; end",
"def subscribed?(u)\n @clients.has_key?(u.signature)\n end",
"def user_type\n # if self.is_vendor\n # \"vendor\"\n # else\n # \"customer\"\n # end\n\n self.is_vendor ? 'vendor' : 'customer'\n end",
"def is_registered?(user_or_email)\n if user_or_email.is_a?(String)\n Participant.where(:email => user_or_email, :event_id => self.id).count > 0\n else\n Participant.where(:owner_type => user_or_email.class.name, :owner_id => user_or_email.id,\n :event_id => self.id).count > 0\n end\n end",
"def require_puffer_user\n unless has_puffer_access?(puffer_namespace)\n redirect_to puffer.new_admin_session_url(:return_to => request.fullpath)\n return false\n end\n end",
"def signup_greeting(user, mode = :normal_signup)\n @user = user\n @need_password = (mode == :free_money_signup)\n swapidy_sendmail :to => @user.email, :subject => \"Welcome to Swapidy\"\n end",
"def application_type\n user_is_pro? ? \"store\" : \"user\"\n end",
"def subscribe(user)\n @clients[user.signature] = user\n end",
"def allowed_types\n [Tapir::Entities::User]\nend",
"def Network_site_login(email,passwd,type)\n \n # New Firefox instance creation\n driver = Selenium::WebDriver.for :firefox, :profile => \"Selenium\"\n ff = Watir::Browser.new driver\n #ff.window.resize_to(800, 600)\n #ff.maximize()\n \n #capabilities = Selenium::WebDriver::Remote::Capabilities.firefox #(:javascript_enabled => true, :proxy=> Selenium::WebDriver::Proxy.new(:http => \"localhost:5865\"))\n #driver = Selenium::WebDriver::Remote::Capabilities.firefox(:profile => \"Selenium\")\n #ff = Watir::Browser.new(:remote, :url => \"http://127.0.0.1:4444/wd/hub\", :desired_capabilities => capabilities)\n# ff = Selenium::Client::Driver.new \\\n# :host => \"localhost\",\n# :port => 4444,\n# :browser => \"*chrome\",\n# :timeout_in_second => 60,\n# :url => \"https://p.network.u-samp.com/\"\n#\n# ff.driver.start_new_browser_session(:captureNetworkTraffic => true)\n #firefox.exe -P Selenium\n #ff = custom C:\\Program Files\\Mozilla Firefox\\firefox.exe -P firefox_browser\n #ff.clear_cookies\n # Opening Usampadmin site\n #capabilities = Selenium::WebDriver::Remote::Capabilities.firefox #(:javascript_enabled => true, :proxy=> Selenium::WebDriver::Proxy.new(:http => \"localhost:5865\"))\n #ff = Watir::Browser.new(:remote, :url => \"http://127.0.0.1:4444/wd/hub\", :desired_capabilities => capabilities)\n #ff = Watir::Browser.new(:remote, :url => \"http://127.0.0.1:4444/wd/hub\", :desired_capabilities => capabilities)\n #ff = Watir::Browser.new(:remote, :desired_capabilities => capabilities)\n #ff = Watir::Browser.start(\"http://127.0.0.1:4444/wd/hub\", :firefox, :remote)\n ff.goto('https://p.network.u-samp.com/login.php')\n #ff.clear_cookies\n # Setting login credentials (email/password)\n if (type == 'Client')\n ff.radio(:value, \"Client\").set\n else\n ff.radio(:value,\"Publisher\").set\n end\n ff.text_field(:id, \"txtEmail\").set(email)\n ff.text_field(:id, \"txtPassword\").set(passwd)\n #Click login button\n \n puts \"Before loging to Network site\"\n \n ff.link(:id,\"btnLogin\").click\n sleep 5\n \n puts \"After loging to Network site\"\n \n # Checkpoint to verify that login was successful\n #ff.frame(:id,\"iframebox\").link(:text, \"Click Menu Item\").click ...\n #iframe id=\"iframebox\"\n #ff.text.should include(\"welcome\")\n# if (ff.contains_text('Welcome'))\n# puts \"Logged it to Network site\"\n# else\n# puts \"Sorry! System Failed to login to Network site\"\n# end\n return ff\n end",
"def test_non_ttc_user_signup\n u = new_non_ttc_user\n assert_rc u.res\n u.login\n assert_equal 3, u.res[\"user\"][\"settings\"][\"current_status\"]\n end",
"def subscribed?\n status == 1 || status == 2\n end",
"def nuevo_usuario\n @user = User.new(params[:user])\n @user.cantidad_bots = 1\n\n # Según tipo de registro\n if params[:tipo] == \"plus\"\n @user.registro = true\n end\n\n # Se agrega perfil de usuario (0)\n @user.perfil = 0\n if @user.valid?\n @user.save\n # Login automatico al registrar\n session[:login] = @user\n session[:last_seen] = Time.now\n UserMailer.welcome_email(@user).deliver\n redirect_to bot_path, :notice => \"Registro OK, Bienvenido\"\n else\n flash[:error] = \"Error en los datos ingresados\"\n render 'bots/registrar'\n end\n end",
"def eventunscrape?\n @user.is_admin?\n end",
"def create\n self.resource = warden.authenticate!(auth_options)\n def is_active?\n self.resource.etat\n end\n\n # Si le user n'est pâs activer il est \n if is_active?\n current_user.update(presence: true, date_derniere_connexion: Time.now.utc)\n if current_user.categorie == \"Admin\"\n redirect_to ecoles_liste_path, notice: \"Bienvenue !!!\"\n else\n redirect_to root_path, notice: \"Bienvenue !!!\"\n end\n else\n session.clear\n redirect_to user_session_path, notice: \"Désolé votre compte à été desactiver\"\n end\n end",
"def check_user_type\n if self.user_type.present?\n self.contractor = self.user_type.to_s.downcase.include? \"contractor\"\n else\n self.contractor = false\n end\n end",
"def publishable?(user)\n user.present? && !public?\n end",
"def check_user(type, type_id)\n\t\n\t\tif admin_authorized?\n\t\t\treturn true\n\t\tend\n\t\t\n\t\tcase type \n\t\t\twhen \"idea\"\n\t\t\t\t@user_id = Idea.find_by_id(type_id).user_id\n\t\t\twhen \"project\"\n\t\t\t\t@user_id = Project.find_by_id(type_id).user_id\n\t\t\twhen \"innovation\"\n\t\t\t\t@user_id = Innovation.find_by_id(type_id).user_id\n\t\t\telse\n\t\t\t\treturn false\n\t\tend\n\n\t\t\n\t\tif @user_id == current_user.id\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\t\t\n\tend",
"def set_supported_user\n @supported_user = User.find(params[:id])\n end",
"def required?\n user.registered_since?(self.class.config.registered_since)\n end",
"def usr_msg? convo, usr\n (usr.id == convo.user_id && convo.status == 'active') || (usr.id == convo.recipient_id && convo.recipient_status == 'active')\n end",
"def check_user\n if current_user.type != \"Buyer\" \n redirect_to root_url, :alert => \"Please create a buyer account to view this page\"\n end\n end",
"def user_provider=(_arg0); end",
"def user_consenting; end",
"def can_publish?\n !user.discourse_username.empty?\n end",
"def otr_api_call?\n current_user.present? && request.headers['X-0-Hub'] == '1'\n end",
"def argue_with_slackbot(client)\n client.on :message do |data|\n if data.user == \"USLACKBOT\"\n client.web_client.chat_postMessage(\n channel: data.channel, \n text: \"slackbot... what a dweeb.\", \n as_user: true,\n unfurl_links: false,\n unfurl_media: false\n )\n end\n end\n end",
"def check_in(uid)\n #TODO: Check if user is in it first\n self.user_channels.create(user_id: uid, timeout: DateTime.in(120))\n end",
"def user; end",
"def user; end"
] | [
"0.5871801",
"0.5871801",
"0.57581586",
"0.5740071",
"0.56957805",
"0.553048",
"0.5509807",
"0.544696",
"0.54287183",
"0.53649026",
"0.53642726",
"0.5326135",
"0.5317751",
"0.5289472",
"0.5276018",
"0.5273561",
"0.5259264",
"0.51999974",
"0.5195822",
"0.5180352",
"0.5162782",
"0.51518905",
"0.514058",
"0.5128347",
"0.5125769",
"0.51125324",
"0.51044875",
"0.5100033",
"0.5091357",
"0.5078515",
"0.50773335",
"0.50734717",
"0.5064568",
"0.5064121",
"0.5062321",
"0.50618154",
"0.5055745",
"0.50347567",
"0.50271153",
"0.50240356",
"0.50159633",
"0.50090086",
"0.5008232",
"0.5007733",
"0.50040144",
"0.4995056",
"0.49892995",
"0.49876878",
"0.49863443",
"0.49863443",
"0.49783072",
"0.4977987",
"0.49778658",
"0.4973317",
"0.49715889",
"0.4969777",
"0.49651197",
"0.49558738",
"0.49513388",
"0.49447098",
"0.49395722",
"0.49395722",
"0.49378482",
"0.4937319",
"0.49357522",
"0.49356043",
"0.49318182",
"0.49298304",
"0.49286819",
"0.4920761",
"0.49191818",
"0.49162713",
"0.49095592",
"0.49076888",
"0.4905907",
"0.49051037",
"0.49032387",
"0.48996735",
"0.4889079",
"0.4885885",
"0.48858124",
"0.4884384",
"0.48772836",
"0.48763138",
"0.48760605",
"0.48752907",
"0.48663306",
"0.48657623",
"0.48643354",
"0.48637795",
"0.48624003",
"0.4853113",
"0.48450795",
"0.48350716",
"0.48336893",
"0.48323014",
"0.48298535",
"0.4823979",
"0.4821192",
"0.4821192"
] | 0.5417414 | 9 |
Get/set the number of seconds between heartbeat events. | def heartbeat_rate( new_rate=nil )
@heartbeat_rate = new_rate.to_f if new_rate
return @heartbeat_rate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heartbeat_timeout\n data.heartbeat_timeout\n end",
"def seconds\n _nudge[2]\n end",
"def heartbeat_timeout; Float::INFINITY; end",
"def heartbeat_frequency\n server.cluster.heartbeat_interval\n end",
"def seconds\n @time\n end",
"def tests_poll_secs\n @game_info['tests_poll_secs']\n end",
"def seconds\n\t\t@seconds\n\tend",
"def in_seconds\n @seconds\n end",
"def tv_sec\n return @tv_sec\n end",
"def nsec\n 0\n end",
"def sec\n return @t_sec\n end",
"def tv_sec() end",
"def seconds() self end",
"def ticks_elapsed\n (@current_milliseconds / (@notify_frequency)).round\n end",
"def time_sec; Time.now.sec; end",
"def seconds\n ((@died_at - @time) / 1000).to_i\n end",
"def seconds\n self * 60\n end",
"def nowSeconds; Time.now.utc.to_i end",
"def keep_alive_time; end",
"def seconds_since_seen\n Time.now - (last_seen || Time.at(0))\n end",
"def seconds\n (Time.now - @start_time).to_i\n end",
"def sleep_value\n 20\n end",
"def hsec\n (self.to_f * 100).to_i\n end",
"def seconds\n value_parts[2]\n end",
"def seconds\n value_parts[2]\n end",
"def hbrecv_interval\n @connection.hbrecv_interval\n end",
"def seconds_since_midnight\n self.hour.hours + self.min.minutes + self.sec + (self.usec/1.0e+6)\n end",
"def ticks_left\n ((@milliseconds - @current_milliseconds) / (@notify_frequency)).round\n end",
"def setup_heartbeat_timer; end",
"def secs\n @msecs / SEC_TO_MS_F\n end",
"def seconds_since_midnight\n self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6)\n end",
"def seconds=(new_seconds)\n\t\t@seconds = new_seconds\n\tend",
"def seconds_until\n (start_time - Time.now).to_i\n end",
"def seconds_until\n (start_time - Time.now).to_i\n end",
"def idle_time_before_sleep_in_seconds=(value)\n @idle_time_before_sleep_in_seconds = value\n end",
"def seconds_since_midnight\n to_i - change(hour: 0).to_i + (usec / 1.0e+6)\n end",
"def last_downtime\n send_message!(Protocol::Device::GetInfo.new,\n wait_for: Protocol::Device::StateInfo) do |payload|\n payload.downtime.to_f / NSEC_IN_SEC\n end\n end",
"def secs\n self / 3600.0\n end",
"def seconds_behind_master\n raise \"This instance is not a slave\" unless master\n lag = slave_status[:seconds_behind_master]\n lag == 'NULL' ? nil : lag.to_i\n end",
"def last_heartbeat_date_time\n return @last_heartbeat_date_time\n end",
"def last_heartbeat_date_time\n return @last_heartbeat_date_time\n end",
"def seconds_since_last\n last.blank? ? 0 : (timestamp_server - last.timestamp_server)\n end",
"def seconds_left\n if @last_run\n [(@last_run + interval / 1000.0) - Time.now, 0].max\n else\n interval / 1000.0\n end\n end",
"def sec\n @sec ||= time_parts[2]\n end",
"def to_i\n return @tv_sec\n end",
"def to_seconds; @val end",
"def last_heartbeat_date_time=(value)\n @last_heartbeat_date_time = value\n end",
"def last_heartbeat_date_time=(value)\n @last_heartbeat_date_time = value\n end",
"def keep_alive_time=(_arg0); end",
"def hbsend_interval\n @connection.hbsend_interval\n end",
"def to_i\n @seconds\n end",
"def sleep\n @property_hash['sleep'] || 0\n end",
"def total_seconds\n (ends_at - Time.current).round\n end",
"def seconds\n @seconds.abs % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def tv_usec() end",
"def secs= value\n\t\t# рассчитанных после того, как он самостоятельно обновил self[:secs] \n\t\tself[:secs] = value # с предоставленным значением\n calc_ave # переопределить метод secs=, чтобы он вызывал calc_ave для обновления средних значений\n\tend",
"def seconds ; return aseconds % SPM ; end",
"def timeout_interrupt_tests_secs\n @game_info['timeout_interrupt_tests_secs']\n end",
"def seconds\n (duration + 0.4999).to_i\n end",
"def seconds\n (hour * 60 * 60) + (min * 60)\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end",
"def delay_time=(seconds)\n end",
"def sec() time[2] end",
"def sleep_time\n 60\n end",
"def idle_time_before_sleep_in_seconds\n return @idle_time_before_sleep_in_seconds\n end",
"def setup_heartbeat_timer\n @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do\n event_loop.post { connections.each(&:beat) }\n end\n end",
"def initialize\n @count = Time.secsIn25Mins\n end",
"def secs=value\n\tself[:secs] = value\n\tcalc_ave\n end",
"def seconds_remaining\n ends_at ? (ends_at - started_at).round : 0\n end",
"def initialize\n @seconds = 0\n end",
"def monitoring_interval\n data[:monitoring_interval]\n end",
"def monitoring_interval\n data[:monitoring_interval]\n end",
"def sec=(newsec)\n newsec = newsec.to_i\n raise ArgumentError, \"Invalid second: '#{newsec}'.\" if newsec < 0 or newsec > 60\n @t_sec = newsec.to_i\n end",
"def watch=(seconds)\n @watch = seconds.to_i\n end",
"def time_remaining\n\n end",
"def tick_tock\n @hour += 1\n @minute = 0\n @second = 0\n end",
"def duration\n @duration ||= tick * @data.values[0].length\n end",
"def tempo(beats_per_second)\n\t\tbeats_per_minute = beats_per_second * 60 \n\tend",
"def durations; end",
"def time_counter\n counter = Time.new.to_i - @time_counter\n return counter < 0 ? 0 : counter\n end",
"def heartbeat\n end",
"def increment_listened_times\n increment(:listened_times)\n end",
"def response_time\n metrics['Response Time'].round\n end",
"def tv_usec\n return @tv_usec\n end",
"def nanoseconds; end",
"def seconds_idle # :nodoc:\n return 0 if in_use?\n Concurrent.monotonic_time - @idle_since\n end",
"def time_remaining\n end",
"def total_seconds()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.TimeSpan_total_seconds(@handle.ptr)\n result\n end",
"def calc_play_seconds\n @time_days.to_i * 86400 + @time_hours.to_i * 3600 + @time_minutes.to_i * 60\n end",
"def wait_time\n self.measurement.wait_time\n end",
"def uptime\n @root.attributes[\"c\"].to_i\n end",
"def poll_heartbeat_timeout\n now = Hastur::Util.timestamp\n delta = now - @last_heartbeat\n\n # perform heartbeat check\n if delta > @heartbeat\n @logger.debug \"Sending heartbeat\"\n\n msg = Hastur::Message::HB::Agent.new(\n :from => @uuid,\n :data => {\n :name => \"hastur.agent.heartbeat\",\n :value => delta,\n :timestamp => now,\n :labels => {\n :version => Hastur::SERVER_VERSION,\n :period => @heartbeat,\n }\n }\n )\n _send(msg)\n\n @last_heartbeat = now\n end\n end",
"def offset_sec\n @offset\n end",
"def to_i\n self.in_seconds\n end",
"def initial_silence_timeout_in_seconds=(value)\n @initial_silence_timeout_in_seconds = value\n end",
"def implicit_wait=(seconds); end",
"def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration if ttl_in_seconds\n ttl_in_seconds\n end",
"def response_time\n @response_time\n end"
] | [
"0.720737",
"0.6780744",
"0.6528011",
"0.6522499",
"0.6507858",
"0.644698",
"0.6412443",
"0.6408729",
"0.64073503",
"0.64004695",
"0.6233638",
"0.6232942",
"0.62159145",
"0.60415936",
"0.6037389",
"0.6030602",
"0.600216",
"0.5993413",
"0.5991755",
"0.59816355",
"0.5965898",
"0.59514314",
"0.59033626",
"0.5886867",
"0.5886867",
"0.58833766",
"0.5858178",
"0.5849129",
"0.5848409",
"0.5844916",
"0.5837912",
"0.57927465",
"0.57889926",
"0.57889926",
"0.5788971",
"0.5777447",
"0.57760316",
"0.57704914",
"0.5760624",
"0.5745846",
"0.5745846",
"0.5739243",
"0.5735675",
"0.57237226",
"0.5713033",
"0.5711002",
"0.5705573",
"0.5705573",
"0.5701015",
"0.5698377",
"0.56951106",
"0.56712866",
"0.56639534",
"0.5652749",
"0.5647339",
"0.56338054",
"0.56275684",
"0.56206393",
"0.56157786",
"0.5615769",
"0.5614363",
"0.5614363",
"0.5614363",
"0.56038684",
"0.55934936",
"0.5586918",
"0.558227",
"0.55770606",
"0.5567624",
"0.5564985",
"0.5560642",
"0.5553463",
"0.5553164",
"0.5553164",
"0.55395067",
"0.5538292",
"0.5531739",
"0.5529578",
"0.5525826",
"0.5524314",
"0.55223656",
"0.55152977",
"0.5503266",
"0.54748064",
"0.5474767",
"0.5473544",
"0.5472607",
"0.5457985",
"0.5427903",
"0.5423717",
"0.5422831",
"0.54177856",
"0.5416414",
"0.5413822",
"0.541332",
"0.54101515",
"0.5406254",
"0.53912306",
"0.5382767",
"0.5381126"
] | 0.5915085 | 22 |
Get/set the number of seconds between events before a client is disconnected | def idle_timeout( new_timeout=nil )
@idle_timeout = new_timeout if new_timeout
return @idle_timeout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_timer\n if @connection.comm.connected? and Time.now - @var[:last_ping] >= 60\n begin\n _server_control(\"keepalive\")\n rescue\n _notice(\"The connection to the server has been lost\", :global)\n @connection.disconnect\n end\n end\nend",
"def client_disconnected\n end",
"def heartbeat_timeout\n data.heartbeat_timeout\n end",
"def event_epoch()\n # Flush out idle clients, if any\n @clients.each do |_,client|\n if Time.now - client.var[:last_ping] > 300\n client.socket.close\n client = @clients.delete(client.socket)\n dispatch :connection_reset, client, \"ping timeout\"\n end\n end\nend",
"def heartbeat_timeout; Float::INFINITY; end",
"def hbrecv_interval\n @connection.hbrecv_interval\n end",
"def keep_alive_time; end",
"def disconnect\n\t\t@state = STATE_OFFLINE\n\t\treturn 0\n\tend",
"def getconnectiontimeout()\r\n return getvalue(@@CONNECTION_TIMEOUT)\r\n end",
"def persistent_timeout(seconds); end",
"def timeout\n datastore['TIMEOUT']\n end",
"def connect_timeout\n @connect_timeout\n end",
"def comm_inactivity_timeout\n\t\tEventMachine::get_comm_inactivity_timeout @signature\n\tend",
"def get_connect_timeout\n @connect_timeout\n end",
"def last_downtime\n send_message!(Protocol::Device::GetInfo.new,\n wait_for: Protocol::Device::StateInfo) do |payload|\n payload.downtime.to_f / NSEC_IN_SEC\n end\n end",
"def client_close_timeout\n super\n end",
"def socket_disconnected\n end",
"def on_disconnected\n end",
"def first_data_timeout(seconds); end",
"def reset_liveness_timer\n @liveness_timer.cancel if @liveness_timer\n @liveness_timer = EventMachine::Timer.new(connection.heartbeat_interval + 0.1) do\n if connection.connected? && (connection.time_since_connection_confirmed_alive? >= connection.heartbeat_interval)\n msg = \"No activity seen from realtime in #{connection.heartbeat_interval}; assuming connection has dropped\";\n error = Ably::Exceptions::ConnectionTimeout.new(msg, Ably::Exceptions::Codes::DISCONNECTED, 408)\n connection.transition_state_machine! :disconnected, reason: error\n end\n end\n end",
"def connectionEnd(conn)\n port, host = conn.peeraddr[1,2]\n client = \"#{host}:#{port}\"\n puts \"#{client} has disconnected\"\n $counter=$counter -1\n puts $counter.to_s+\" clients connected\"\n $logger.info \"#{client} has connected\"\n $logger.info $counter.to_s+\" clients connected\"\n\nend",
"def set_timer\n SockJS.debug \"Setting @disconnect_timer to #{@disconnect_delay}\"\n @disconnect_timer ||= begin\n EM::Timer.new(@disconnect_delay) do\n SockJS.debug \"#{@disconnect_delay} has passed, firing @disconnect_timer\"\n @disconnect_timer_canceled = true\n\n @alive_checker.cancel if @alive_checker\n\n if self.opening? or self.open?\n # OK, so we're here, closing the open response ... but its body is already closed, huh?\n SockJS.debug \"@disconnect_timer: closing the connection.\"\n self.close\n SockJS.debug \"@disconnect_timer: connection closed.\"\n else\n SockJS.debug \"@disconnect_timer: doing nothing.\"\n end\n end\n end\n end",
"def connect_timeout(val = nil)\n if val\n @j_del.setConnectTimeout(val)\n self\n else\n @j_del.getConnectTimeout\n end\n end",
"def keep_alive_time=(_arg0); end",
"def disconnected?; connection_state == :disconnected end",
"def connect_timeout; end",
"def connect_timeout; end",
"def timeout_seconds\n return 1200\n end",
"def client_disconnected\n puts \"client #{current_user.email} disconnected\"\n current_player = current_user.player\n broadcast_message :player_exit, {\n id: current_player.id\n }\n current_player.is_online = false\n current_player.save\n end",
"def max_timeout\n self.device.max_timeout\n end",
"def nsec\n 0\n end",
"def read_timeout=(sec); end",
"def implicit_wait=(seconds); end",
"def server_timeout\n get_configuration 'server_timeout', @config\n rescue\n 60\n end",
"def get_timeouts\n @bridge.get_timeouts\n end",
"def get_timeouts\n @bridge.get_timeouts\n end",
"def get_timeouts\n @bridge.get_timeouts\n end",
"def global_timeout\n data.global_timeout\n end",
"def timeout_seconds\n transport_options.timeout_seconds\n end",
"def idle_timeout()\n if transport && (t = transport.remote_idle_timeout)\n Rational(t, 1000) # More precise than Float\n end\n end",
"def hbsend_interval\n @connection.hbsend_interval\n end",
"def event_wait_delay seconds\n ScriptActionHandler::HandlerResult::waitDelay seconds\n end",
"def connect_timeout=(_arg0); end",
"def client_timeout\n # Store the target and error in the blacklist.\n if @conf[:use_blacklist]\n blacklist_entry = @current_target.to_s\n @conf[:blacklist][blacklist_entry] = [408, \"Client Timeout\", nil, :client_timeout]\n ::EM.add_timer(@conf[:blacklist_time]) { @conf[:blacklist].delete blacklist_entry }\n end\n\n try_next_target 408, \"Client Timeout\", nil, :client_timeout\n end",
"def read_timeout\n @agent.read_timeout\n end",
"def timeout\n datastore['Timeout']\n end",
"def connect_timeout=(val)\n @j_del.setConnectTimeout(val)\n self\n end",
"def timeouts_set; end",
"def timeout_interrupt_tests_secs\n @game_info['timeout_interrupt_tests_secs']\n end",
"def time_remaining\n end",
"def hbrecv_count\n @connection.hbrecv_count\n end",
"def session_timeout\n 86400 # 1.day\n end",
"def increment_listened_times\n increment(:listened_times)\n end",
"def disconnecting?; connection_state == :disconnecting end",
"def down\n @down_at = Time.new\n @latency = nil\n disconnect if connected?\n end",
"def server_timing; end",
"def timeout_in_minutes\n data[:timeout_in_minutes]\n end",
"def udp_timeout\n super\n end",
"def shared_time_off\n return @shared_time_off\n end",
"def time_remaining\n\n end",
"def seconds\n _nudge[2]\n end",
"def read_timeout\n @read_timeout\n end",
"def idle_timeout; end",
"def idle_timeout; end",
"def initial_silence_timeout_in_seconds\n return @initial_silence_timeout_in_seconds\n end",
"def ignore_disconnect; end",
"def timeout\n @timeout\n end",
"def timeout\n @attributes[:timeout]\n end",
"def seconds_since_last\n last.blank? ? 0 : (timestamp_server - last.timestamp_server)\n end",
"def connecttimeout_ms=(value)\n Curl.set_option(:connecttimeout_ms, value_for(value, :int), handle)\n end",
"def request_timeout()\n @req_timeout\n end",
"def extra_dmdsecs\n \"\"\n end",
"def timeout_at; end",
"def untilTimeout()\n return Timer.timeRemaining(@name)\n end",
"def test_timeout\n session=enter_the_room(\"test_timeout\")[\"session\"]\n response=get_event(session, {:check_response => false})\n assert last_response.ok?\n assert response[\"result\"] == 'timeout'\n end",
"def daemonization_timed_out\n end",
"def server_inactivity_timeout(timeout, elapsed)\n LOGGER.error \"Disconnecting #{@remote.join(':')} after #{elapsed}s of inactivity (> #{timeout.inspect})\"\n @server_side = nil\n close_connection\n BeanstalkProxy.inactivity_error_callback.call(@remote.join(':'))\n end",
"def idle_time_before_sleep_in_seconds\n return @idle_time_before_sleep_in_seconds\n end",
"def read_timeout=(read_timeout); end",
"def set_comm_inactivity_timeout value\n\t\tEventMachine::set_comm_inactivity_timeout @signature, value\n\tend",
"def timed_out\n response['timed_out']\n end",
"def _timeout_in\n 1.minute\n end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def read_timeout; end",
"def observance_after\n @observance_after ||= upcoming_observances.second\n end",
"def server_ready_timeout\n Zartan::Config.new['server_ready_timeout'].to_i\n end",
"def reset_timer\n @conn_expires_at = Time.now + @keep_alive_timeout if @persistent\n end",
"def idletime\n @executor.getKeepAliveTime(java.util.concurrent.TimeUnit::SECONDS)\n end",
"def while_time_remaining; end",
"def get_response_time #:doc:\n ret = session[:prompt_time].nil? ? 0 : (1000 * (Time.now - session[:prompt_time])).round\n session[:prompt_time] = nil\n ret\n end",
"def on_disconnect_event(ctx)\n logger.debug(\"Client disconnect from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]}\")\n end",
"def ticks_left\n ((@milliseconds - @current_milliseconds) / (@notify_frequency)).round\n end",
"def default_timeout\n 3\n end",
"def timeout\n configuration.timeout\n end",
"def post_init\n self.pending_connect_timeout = @telnet_options[:connect_timeout]\n self.comm_inactivity_timeout = @telnet_options[:timeout]\n @@_telnet_connection_count += 1\n end"
] | [
"0.6761682",
"0.6715481",
"0.66451854",
"0.66307455",
"0.6350368",
"0.63447726",
"0.6332372",
"0.6096921",
"0.6010563",
"0.5963997",
"0.5936235",
"0.5924616",
"0.59192073",
"0.58639413",
"0.58632684",
"0.58441955",
"0.5837549",
"0.57999885",
"0.5792706",
"0.57898974",
"0.5777877",
"0.57564396",
"0.5743026",
"0.57311445",
"0.57298577",
"0.5727243",
"0.5727243",
"0.57151514",
"0.5708912",
"0.56799674",
"0.5677878",
"0.5673765",
"0.5669156",
"0.56532055",
"0.5650206",
"0.5650206",
"0.5650206",
"0.5642315",
"0.5609401",
"0.5608178",
"0.5605724",
"0.5603169",
"0.5600574",
"0.558114",
"0.557875",
"0.5566474",
"0.55544585",
"0.5549735",
"0.5547241",
"0.5508503",
"0.550813",
"0.5495788",
"0.5493433",
"0.5492448",
"0.54869384",
"0.5485538",
"0.5485295",
"0.5471582",
"0.54667276",
"0.54652905",
"0.5464175",
"0.5462586",
"0.54519653",
"0.54519653",
"0.5442371",
"0.5440872",
"0.5438511",
"0.5421576",
"0.54168624",
"0.5413767",
"0.5408126",
"0.54011905",
"0.5396975",
"0.5390345",
"0.53879875",
"0.53879243",
"0.5383721",
"0.5379593",
"0.53744936",
"0.5371054",
"0.536847",
"0.53624856",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5358999",
"0.5357235",
"0.5346379",
"0.5345082",
"0.5341976",
"0.5334213",
"0.53219163",
"0.5313845",
"0.5313763",
"0.5313636",
"0.53107107",
"0.5309196"
] | 0.0 | -1 |
Inheritance hook inheriting classes inherit their parents' routes table. | def inherited( subclass )
super
subclass.instance_variable_set( :@idle_timeout, self.idle_timeout.dup )
subclass.instance_variable_set( :@heartbeat_rate, self.heartbeat_rate.dup )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherited(subclass)\n super\n\n h = subclass.opts[:hash_branch_view_subdir_methods]\n opts[:hash_branch_view_subdir_methods].each do |namespace, routes|\n h[namespace] = routes.dup\n end\n end",
"def inherited(subclass)\n super\n nsr = subclass.opts[:namespaced_routes]\n opts[:namespaced_routes].each{|k, v| nsr[k] = v.dup}\n subclass::RodaRequest.instance_variable_set(:@namespaced_route_regexps, {})\n end",
"def route_tables\n @route_tables ||= init_route_tables\n end",
"def reset_routing_cache\n\t\t\t\t@inheritance.each {|sub| sub.reset_routing_cache} if @inheritance\n\t\t\tend",
"def base_route_segments\n table_name.to_s\n end",
"def routes\n raise NotImplementedError\n end",
"def anchored_routes; end",
"def full_route\n @parent ? (ancestors.reverse + [self]).map(&:route).join('/').squeeze('/') : route\n end",
"def _routes; end",
"def inherit_view_paths\n self.class.inherit_view_paths\n end",
"def route_sets; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def lookup_path_inherited(namespace, path, type); end",
"def route\n @base_controller.route if @base_controller\n end",
"def routes_map; end",
"def inherit_view_paths\n instance_variable_get('@inherit_view_paths') || instance_variable_set('@inherit_view_paths', [controller_path] + (superclass.inherit_view_paths rescue []))\n end",
"def freeze\n opts[:class_level_routes].freeze\n super\n end",
"def custom_routes; end",
"def inherited(base) #:nodoc:\n super(base)\n base.send :initialize_resources_class_accessors!\n base.send :create_resources_url_helpers!\n end",
"def inherit_view_paths\n instance_variable_get('@inherit_view_paths') || instance_variable_set('@inherit_view_paths', [controller_path] + (superclass.inherit_view_paths rescue []))\n end",
"def routes\n @routes || self.class.routes\n end",
"def inherited_tables\n tables = query(<<-SQL, 'SCHEMA')\n SELECT child.relname AS table_name,\n array_agg(parent.relname) AS inheritances\n FROM pg_inherits\n JOIN pg_class parent ON pg_inherits.inhparent = parent.oid\n JOIN pg_class child ON pg_inherits.inhrelid = child.oid\n GROUP BY child.relname, pg_inherits.inhrelid\n ORDER BY pg_inherits.inhrelid\n SQL\n\n tables.map do |(table, refs)|\n [table, Coder.decode(refs)]\n end.to_h\n end",
"def inherited( subclass )\n\t\tsuper\n\t\tStrelka::Discovery.log.info \"%p inherited by discoverable class %p\" % [ self, subclass ]\n\t\tStrelka::Discovery.add_inherited_class( subclass )\n\tend",
"def perform_routing(path, session, base_uri)\n perform_routing_with_parent(self, path, session, base_uri)\n end",
"def inherited(subclass); end",
"def inherited(child_class)\n HasFields.add_default_resolve_module(child_class)\n super\n end",
"def superclass() end",
"def namespace_inheritance; end",
"def namespace_inheritance; end",
"def refresh_route_tables!\n @route_tables = init_route_tables\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def setup_parentage\n parent_path_parts = request.path.split(\"/\")\n parent_path_parts.shift\n @parentage = Array.new\n parent_path_parts.each_slice(2) do |k,v|\n @parentage << k.classify.constantize.find(v.to_i) unless (k == \"events\" || v.nil?)\n end\n end",
"def populate_inheritance_heirarchy\n apps_and_templates = appTemplates + templates\n apps_and_templates.each do |temp| \n temp.attributes[:parent].to_s != '' ? app_or_temp = temp.attributes[:parent] :\n temp.attributes[:template].to_s != '' ? app_or_temp = temp.attributes[:template]:\n next\n next if app_or_temp == \"what the fuck?\"\n # if temp.attributes[:parent].is_a? String or temp.attributes[:template].is_a? String\n if not app_or_temp.empty?\n parent_template = self.templates.find { |template| template.name.downcase == app_or_temp.downcase }\n temp.child_of << parent_template\n parent_template.parent_of << temp\n end\n end \n end",
"def inherited(base)\n subclasses << base\n super(base)\n end",
"def _roda_after_10__class_level_routing(result)\n if result && result[0] == 404 && (v = result[2]).is_a?(Array) && v.empty?\n # Reset the response so it doesn't inherit the status or any headers from\n # the original response.\n @_response.send(:initialize)\n @_response.status = nil\n result.replace(_roda_handle_route do\n r = @_request\n opts[:class_level_routes].each do |request_meth, args, meth|\n r.instance_variable_set(:@remaining_path, @_original_remaining_path)\n r.public_send(request_meth, *args) do |*a|\n send(meth, *a)\n end\n end\n nil\n end)\n end\n end",
"def init_route_tables\n @@client.describe_route_tables.route_tables\n end",
"def inherited(subclass)\n super\n subclass.rules.update self.rules\n end",
"def inherited(subclass)\n result = super\n subclass.register Sinatra::Reloader\n result\n end",
"def inherited(klass); end",
"def inherited(klass); end",
"def load_all_routes(roda_app)\n roda_app.request.public\n\n if Bridgetown.env.development? &&\n !Bridgetown::Current.preloaded_configuration.skip_live_reload\n setup_live_reload roda_app\n end\n\n Bridgetown::Rack::Routes.sorted_subclasses&.each do |klass|\n klass.merge roda_app\n end\n end",
"def route_end\n inheritable_setting.route_end\n end",
"def external_routes; end",
"def inherited(subclass)\n subclass.definition_location = call_stack\n super\n register_submodel(subclass)\n subclass.permanent_model = true\n end",
"def real_remaining_path\n if defined?(@type_routing_extension)\n \"#{super}.#{@type_routing_extension}\"\n else\n super\n end\n end",
"def parent_route=(route)\n @parent_route = route\n routes.each{|r| r.parent_route = route}\n end",
"def path\n @path_klass.new(super)\n end",
"def inherited(resource)\r\n resource.class_eval do\r\n self.versions ||= {}\r\n self.helper_object = Object.new\r\n\r\n begin\r\n plural = name.demodulize.tableize\r\n self.path = lambda { |format|\r\n begin\r\n new.polymorphic_path [:resources, plural], :format => format\r\n rescue => e\r\n nil\r\n end\r\n }\r\n self.query_template = DEFAULT_COLLECTION_QUERY_TEMPLATE.dup\r\n self.model = name.sub(/^Restful\\b/, '').constantize\r\n finder :find, :all, :first, :last\r\n helper ApplicationHelper\r\n rescue ArgumentError, NameError => e\r\n nil\r\n end\r\n\r\n Restful::Resource.classes << self\r\n end\r\n end",
"def nested_classes\n super\n end",
"def subclasses; end",
"def subclasses; end",
"def dynamic_forwarding\n super\n end",
"def inherited(base); end",
"def inherited subclass\n Daylight::ResourceProxy[subclass]\n end",
"def static_forwarding\n super\n end",
"def initialize\n @routes = {}\n end",
"def inherited(subclass)\n super\n subclass.acts_as_cacheable_cache = acts_as_cacheable_cache\n subclass.acts_as_cacheable_time_to_live = acts_as_cacheable_time_to_live\n subclass.acts_as_cacheable_logger = acts_as_cacheable_logger\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def inherited(base)\n base.send :create_dynamic_classes\n super\n end",
"def routes\n Resources::Routes.new(self)\n end",
"def load_routes\n\n # get our routes\n routes = Rails.application.routes.routes.to_a\n\n # filter out internal routes, those outside our base context, and those with no name\n routes.reject!{ |r| r.internal or !r.defaults.key?( :controller ) or r.name.nil? }\n\n # finally, map everything to a simpler version\n self.routes = routes.map do |r|\n {\n controller: r.defaults[:controller],\n action: r.defaults[:action].to_sym,\n name: r.name,\n params: r.parts.reject{ |p| p == :format }\n }\n end\n\n end",
"def router\n @parent.router\n end",
"def base\n @parent ? @parent.model_instance.send(@name.to_s.pluralize) : model_class\n end",
"def base_path\n super.concat \"/services/#{@service['id']}/proxy/mapping_rules\"\n end",
"def set_url_base_on_parent!\n if self.class_type == 'variant'\n \"/assets/upload/variants/:id/:style/:basename.:extension\"\n elsif self.class_type == 'banner'\n \"/assets/upload/banner/:style/:basename.:extension\"\n elsif self.class_type == 'logo'\n \"/assets/upload/logo/:style/:basename.:extension\"\n end\n end",
"def inherits\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n begin\n # at line 432:4: 'extends' IDENTIFIER\n match( T__30, TOKENS_FOLLOWING_T__30_IN_inherits_285 )\n match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_inherits_287 )\n # --> action\n\n \t\n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end\n \n return \n end",
"def inherited(base)\n klasses << base\n end",
"def routes(&block); end",
"def routes(&block); end",
"def routes_normal\n return Array.new\n end",
"def inherited(subclass)\n super\n sk = sti_key\n sd = sti_dataset\n sdr = sti_dataset_root\n skm = sti_key_map\n smm = sti_model_map\n key = skm[subclass]\n ska = [key].reject { |k| k.blank? }\n subclass.instance_eval do\n @sti_key = sk\n @sti_key_array = ska\n @sti_subclasses_array = [skm[subclass]]\n @sti_dataset = sd\n @sti_key_map = skm\n @sti_model_map = smm\n @simple_table = nil\n @sti_dataset_root = sdr\n end\n sti_subclass_added(key, subclass)\n end",
"def inherited(subclass)\n # Register the subclass in a lookup table (shared class variable).\n model = model_for(subclass)\n @@representers[model] = subclass\n\n # Setup class-instance variables.\n subclass.class_eval do\n @modes = {}\n @paginators = {}\n @helpers = {}\n end\n end",
"def paths\n raise RuntimeError, 'Subclass responsibility'\n end",
"def path; super; end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def define_routable_methods router_class\n define_method router_class.route_name_method_name do \n router_class.route_name self\n end\n \n define_method router_class.url_method_name do \n router_class.url self\n end\n \n define_method router_class.path_method_name do \n router_class.path self\n end\n end",
"def namespace_end\n route_end\n @inheritable_setting = inheritable_setting.parent\n end",
"def superclass!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n\n type = SUPERCLASS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 333:4: 'superclass'\n match( \"superclass\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end",
"def descendant_method_missing(meth, *args, &blk)\n if meth.to_s.eql?('print_this')\n \"#{meth.to_s}_from_class\"\n else\n ParentModel.send(meth, *args, &blk)\n end\n end",
"def init_public_members\n super\n @move_route_forcing = false\n end",
"def inherited(subclass)\n subclass.instance_variable_set(\"@fields\", fields.dup)\n subclass.instance_variable_set(\"@relations\", relations.dup)\n end",
"def perm_ancestors\n super + [parent_resource]\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/cms',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/cms/,\n :title => 'Gestor contenidos',\n :description => 'Gestiona los contenidos',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content-types',\n :parent_path => '/admin/cms',\n \t :regular_expression => /^\\/admin\\/cms\\/content-types/, \n :title => 'Tipos de contenido' , \n :description => 'Manages the content types: creation and update of content types.',\n :fit => 3,\n :module => :cms},\n {:path => '/mctype/:type/:aspect',\n :parent_path => \"/mctypes\",\n :regular_expression => /^\\/mctype\\/.+\\/.+/, \n :title => 'Content type aspect configuration', \n :description => 'Edit the content type/aspect configuration',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/contents',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content/, \n :title => 'Contenidos', \n :description => 'Manages the contents',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/content\\/new/, \n :title => 'Crear contenido', \n :description => 'Create a new content: Choose the content type.',\n :fit => 2,\n :module => :cms},\n {:path => '/admin/cms/content/new/:content_type',\n :parent_path => \"/admin/cms/content/new/\",\n :regular_expression => /^\\/admin\\/cms\\/content\\/new\\/.+/, \n :title => 'Nuevo', \n :description => 'Create a new content: Complete data.',\n :fit => 3,\n :module => :cms}, \n {:path => '/admin/cms/content/edit/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/content\\/edit\\/.+/, \n :title => 'Editar contenido', \n :description => 'Editar contenido',\n :fit => 1,\n :module => :cms}, \n {:path => '/admin/cms/taxonomy',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/taxonomy/, \n :title => 'Taxonomías', \n :description => 'Manages the taxonomies: creation and update of taxonomies',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/terms/:taxonomy_id',\n :parent_path => \"/admin/cms/taxonomy\",\n :regular_expression => /^\\/admin\\/cms\\/terms\\/.+/, \n :title => 'Term',\n :description => 'Manage the terms of a taxonomy.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/templates',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/templates/, \n :title => 'Plantillas', \n :description => 'Manages templates: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/comments',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/comments/, \n :title => 'Comentarios', \n :description => 'Manages comments: creation and update of templates',\n :fit => 1,\n :module => :cms }, \n {:path => '/admin/cms/blocks',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/blocks/, \n :title => 'Bloques', \n :description => 'Manage the blocks. It allows to discover and configure modules blocks',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/views',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/views/, \n :title => 'Vistas', \n :fit => 1,\n :description => 'Manage the views: creation and update of views',\n :module => :cms},\n {:path => '/content/:page',\n :regular_expression => /^\\/content\\/.+/,\n :title => 'Content',\n :description => 'Shows a content',\n :fit => 1,\n :module => :cms},\n {:path => '/contents/category/:term_id',\n :regular_expression => /^\\/contents\\/category\\/.+/,\n :title => 'Contents by category',\n :description => 'Shows all the contents tagged with the category',\n :fit => 1,\n :module => :cms},\n {:path => '/admin/cms/menu-management',\n :parent_path => '/admin/cms',\n :regular_expression => /^\\/admin\\/cms\\/menu-management/, \n :title => 'Menu', \n :description => 'Manages the menus: creation and update of menus',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/menu-item-management/:menu_name',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/menu-item-management\\/.+/, \n :title => 'Elemento de menú',\n :description => 'Manage the items of a menu.',\n :fit => 1,\n :module => :cms },\n {:path => '/admin/cms/translate/content/:content_id',\n :parent_path => '/admin/cms/contents',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/content\\/.+/, \n :title => 'Traducir contenido', \n :description => 'Translate a content',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/menuitem/:menuitem_id',\n :parent_path => '/admin/cms/menu-management',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/menuitem\\/.+/, \n :title => 'Traducir elemento de menu', \n :description => 'Translate a menu item',\n :fit => 1,\n :module => :translation }, \n {:path => '/admin/cms/translate/term/:term_id',\n :parent_path => '/admin/cms/taxonomy',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/term\\/.+/, \n :title => 'Traducir término',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation },\n {:path => '/admin/cms/translate/template/:template_id',\n :parent_path => '/admin/cms/templates',\n :regular_expression => /^\\/admin\\/cms\\/translate\\/template\\/.+/, \n :title => 'Traducir plantilla',\n :description => 'Translate a term.',\n :fit => 1,\n :module => :translation } \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def route_index; end",
"def inherited(subclass)\n # Copy properties from parent to subclass\n resource_class.properties.each do |_name, config|\n subclass.property config.term, predicate: config.predicate, class_name: config.class_name\n end\n\n subclass.configure_model\n end",
"def router; end",
"def register_commands_with_router\n Imp::Command._subclasses.each do |klass|\n Imp::Router.register(klass.command_name, klass)\n end\n end"
] | [
"0.6609033",
"0.6291236",
"0.6236855",
"0.61690086",
"0.60309947",
"0.60240835",
"0.60034657",
"0.591703",
"0.59136224",
"0.5840695",
"0.58118296",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.57334244",
"0.57258815",
"0.5724235",
"0.5677084",
"0.56755465",
"0.56672645",
"0.5652224",
"0.55898863",
"0.5589845",
"0.5579262",
"0.5465269",
"0.5440008",
"0.54319",
"0.54294986",
"0.5428243",
"0.5410486",
"0.5410486",
"0.540098",
"0.54002416",
"0.5384683",
"0.5368437",
"0.53672886",
"0.5367163",
"0.53521127",
"0.5351496",
"0.5338116",
"0.5332315",
"0.5332315",
"0.53284943",
"0.5327284",
"0.53250194",
"0.5316831",
"0.530497",
"0.528918",
"0.5287115",
"0.52645344",
"0.5262994",
"0.5259522",
"0.5259522",
"0.5255627",
"0.52517146",
"0.5230649",
"0.52271444",
"0.52067107",
"0.52048934",
"0.5194972",
"0.5194972",
"0.5194972",
"0.51903844",
"0.5179289",
"0.51767",
"0.5176146",
"0.5164852",
"0.5137855",
"0.5135824",
"0.5127091",
"0.51265806",
"0.5116902",
"0.5116902",
"0.51138055",
"0.5107388",
"0.51048595",
"0.51047575",
"0.5098339",
"0.50973547",
"0.509699",
"0.509613",
"0.50882906",
"0.5063873",
"0.5056146",
"0.50427186",
"0.5039172",
"0.5020921",
"0.5020163",
"0.5020163",
"0.5019259",
"0.5007027",
"0.4997202",
"0.49951816"
] | 0.0 | -1 |
Called by Mongrel2::Handler when it starts accepting requests. Overridden to start up the heartbeat thread. | def start_accepting_requests
self.start_heartbeat
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_heartbeat\n\t\tself.log.info \"Starting heartbeat timer.\"\n\t\t@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do\n\t\t\tself.cull_idle_sockets\n\t\t\tself.ping_all_sockets\n\t\tend\n\tend",
"def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end",
"def start_accepting_requests\n\t\tself.log.info \"Starting the request loop.\"\n\t\tself.reactor.start_polling( ignore_interrupts: true )\n\tend",
"def start_heartbeat_if_needed\n logger.debug(\"start_heartbeat_if_needed - enter\")\n return if freq == 0\n return if @heartbeat_thread\n @heartbeat_thread = Thread.new do\n while true do\n heartbeat_command\n end\n end\n end",
"def setup_heartbeat_timer\n @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do\n event_loop.post { connections.each(&:beat) }\n end\n end",
"def setup_heartbeat_timer; end",
"def start\n\n # load config files\n @httpd_conf.load \n @mimes.load\n # initialze logger \n logger = Logger.new(@httpd_conf.logfile) \n Thread.abort_on_exception=true\n \n loop do\n puts \"Opening server socket to listen for connections\"\n\n # handle incoming request\n Thread.start(server.accept) do |client|\n worker = Worker.new(client,@httpd_conf,@mimes,logger) \n worker.handle_request\n end\n end\n\n end",
"def heartbeat\n end",
"def setup_heartbeat\n EM.add_periodic_timer(@options[:ping_time]) do\n @amq.fanout('heartbeat', :no_declare => @options[:secure]).publish(@serializer.dump(Ping.new(@identity, status_proc.call)))\n end\n true\n end",
"def restart\n\t\tself.stop_heartbeat\n\t\tsuper\n\t\tself.start_heartbeat\n\tend",
"def listen\n connect do\n routes.each do |queue|\n @client.subscribe(queue) do |args|\n run(queue, args)\n end\n end\n end\n while (!Thread.current[:shutdown]) do\n sleep(self.class.sleep_time)\n end\n end",
"def start\n lock.synchronize do\n return if started.value\n\n started.value = true\n workers[:maintenance] = Thread.new { loop { check_timeouts } }\n workers[:listener] = Thread.new { loop { listen } }\n end\n end",
"def subscribe_to_heartbeat\n @logger.trace \"setting up 'HEARTBEAT' subscriber\"\n subscribe(\"MOL.HEARTBEAT\") do |packet|\n node = @registry.safe_fetch_node(packet.sender)\n if node\n node.beat\n else\n # because the node is not registered with the broker, we have to assume that something broke down. we need to\n # force a publish to the node we just received the heartbeat from\n publish_discover_to_node_id(packet.sender)\n end\n end\n end",
"def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end",
"def run\n unless @heartbeat_type == :none\n super\n end\n end",
"def begin!\n start_server\n end",
"def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end",
"def setup_helpers\n Heartbeat.start\n SignalHandler.start\n end",
"def setup_helpers\n Heartbeat.start\n SignalHandler.start\n end",
"def run_server_thread; end",
"def beat\n Logger.trace \"beat heart #{Node.id} #{Time.now.to_i}\"\n notifier.async.publish(config.topic, Node.id, Router.endpoint, Time.now.to_i.to_s)\n end",
"def handle_heartbeat(packet)\n end",
"def start\n prepare_parser\n perform_request\n end",
"def heartbeat_thread_runner\n heartbeat = ImapDaemonHeartbeat.create(:tag => server_tag)\n while running?\n # Update the heartbeat.\n heartbeat.touch\n\n # Log Heroku / Librato stats.\n Log.librato(:measure, 'imap_client.thread.count', Thread.list.count)\n Log.librato(:measure, 'imap_client.work_queue.length', work_queue_length)\n Log.librato(:measure, 'imap_client.user_thread.count', user_threads_count)\n Log.librato(:measure, 'work_queue.latency', work_queue_latency)\n Log.librato(:sample, 'imap_client.total_emails_processed', total_emails_processed)\n\n light_sleep 10\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping heartbeat thread.\")\n heartbeat.delete if heartbeat\n end",
"def start\n self.load_plugins()\n @running = true\n \n while @running\n @servers.each do |server|\n unless server.is_connected\n if server.reconnect_delay_passed? && server.connect\n server.write(\"PASS #{@password}\") if @password\n server.write(\"NICK #{@nick}\")\n server.write(\"USER #{@username} hostname servername :#{@username}\")\n end\n end\n\n autoping()\n check_timer_plugins()\n \n @current_server = self.select()\n\n if @current_server\n msg = @current_server.read\n \n if msg != nil\n autojoin_on_recognize(server, msg)\n process_message(msg)\n end\n end\n end \n end\n end",
"def start\n if @supernode_table.empty?\n # The supernode table is empty, so this node is probably \n # starting and not promoted to supernode mode.\n \n # NOTE The +attempt_fetch_supernodes+ will block if no \n # supernode is found. Since supernodes should still work \n # even there is no other active supernodes, a thread is created\n # here. So it can still accept connections from other ordinary\n # nodes.\n Thread.new do \n # 1. Get supernodes from cache or bootstrap node\n Routing.log {|logger| logger.info(self.class) {'1. Getting SNs ...'}}\n sns = attempt_fetch_supernodes\n # 2. Connect to supernodes\n Routing.log {|logger| logger.info(self.class) {'2. Connecting to SNs ...'}}\n connect_supernodes(sns)\n end\n else\n # It is promoted to supernode mode.\n @supernode_table.supernodes.each do |sn|\n @lock.synchronize { @socks << sn.socket }\n end\n end\n\n # 3. Start the background threads\n @request_supernode_thread = start_request_supernodes_thread\n @compute_hits_thread = start_compute_hits_thread\n\n # 4. Create the server socket and handle incoming messages\n @server = TCPServer.open(@driver.config['listening_port'].to_i)\n @socks << @server\n @running = true\n while @running\n # Wait for messages from other nodes\n ready = select(@socks,nil,nil,@timeout)\n readable = ready[0]\n\n unless readable.nil?\n readable.each do |sock|\n if sock == @server # Accept new client\n client = @server.accept\n accepted = on_handshaking(client)\n if accepted\n @lock.synchronize { @socks << client }\n else\n client.close\n end\n elsif sock.eof? # Socket has disconnected\n Routing.log {|logger| logger.info(self.class) {'Socket has disconnected.'}}\n @lock.synchronize {@socks.delete(sock)}\n # Remove it if it is in supernode table\n @supernode_table.delete(sock.node) if @supernode_table.include?(sn.node)\n sock.close\n else # Message is ready for reading\n msg = @protocol.read_message(sock)\n unless msg.nil?\n @bandwidth_manager.downloaded(msg.bytesize,Time.now-message.ftime.to_time) unless @bandwidth_manager.nil?\n handle_message(msg,sock)\n else\n Routing.log {|logger| logger.error(self.class) {'The message read is nil.'}}\n end\n end\n end\n else # Timeout\n @socks.delete_if do |sock|\n sock.closed? # Discarded by supernode table\n end\n end\n end\n end",
"def start()\n #start listening\n @transport.monitor do |rmsg,header,payload|\n consume(rmsg,header,payload)\n end\n end",
"def start_handler\n end",
"def listen\r\n end",
"def start_server\n @watchman = Thread.new {\n while !@stopped\n @pool_mutex.synchronize\n socket = @server.accept\n @pool << Thread.new(socket) {|socket|\n serve(socket)\n }\n end \n }\n end",
"def handle_hello(payload)\n LOGGER.info { 'Connected' }\n @heartbeat_interval = payload[:d][:heartbeat_interval] / 1000\n @heartbeat_thread = Thread.new { heartbeat_loop }\n if @session.seq\n send_resume\n else\n send_identify\n end\n end",
"def start_heartbeat(key)\n stop_heartbeat\n @thread = Thread.new do\n perform_maintenance(key) if rand(100).zero?\n loop do\n sleep(CONCURRENT_HEARTBEAT)\n @redis.zadd(key, Time.now.to_i, @job_id, xx: true)\n end\n end\n end",
"def start\n Thread.abort_on_exception = true\n self.last_refresh = Time.now\n\n self.check_thread = Thread.new {\n while true do\n if Time.now - self.last_refresh >= self.check_interval\n AuctionTimer.check_auctions\n self.last_refresh = Time.now\n end\n\n sleep 1\n end\n }\n self\n end",
"def start\n _connect\n sleep 1\n end",
"def create_heartbeat\n heartbeat = Thread.new do\n begin\n hb = {:data => {:hb => true}, :user_id => nil}\n ActiveRecord::Base.connection_pool.with_connection do |connection|\n conn = connection.instance_variable_get(:@connection)\n loop do\n opened_boards = $redis.lrange(\"opened_board_ids\", 0, -1)\n puts 'Currently HeartBeating towards channels: #{opened_boards}'\n puts opened_boards\n opened_boards.each do |board_id|\n conn.async_exec \"NOTIFY boards_#{board_id}, '#{hb.to_json}'\"\n end\n sleep 20.seconds\n end\n end\n ensure\n end\n end\nend",
"def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end",
"def post_init\n req = \"GET #{@conn_obj.base_url}/#{@conn_obj.db_name}/_changes?feed=continuous&heartbeat=5000\\r\\n\\r\\n\"\n send_data req\n end",
"def start_handler\n\n\t\t# Maximum number of seconds to run the handler\n\t\tctimeout = 150\n\t\t\n\t\tif (exploit_config and exploit_config['active_timeout'])\n\t\t\tctimeout = exploit_config['active_timeout'].to_i\n\t\tend\n\t\n\t\t# Take a copy of the datastore options\n\t\trhost = datastore['RHOST']\n\t\tlport = datastore['LPORT']\n\t\t\n\t\t# Ignore this if one of the required options is missing\n\t\treturn if not rhost\n\t\treturn if not lport\n\t\n\t\t# Only try the same host/port combination once\n\t\tphash = rhost + ':' + lport.to_s\n\t\treturn if self.listener_pairs[phash]\n\t\tself.listener_pairs[phash] = true\n\n\t\t# Start a new handling thread\n\t\tself.listener_threads << Thread.new {\n\t\t\tclient = nil\n\t\t\t\n\t\t\tprint_status(\"Started bind handler\")\n\n\t\t\tif (rhost == nil)\n\t\t\t\traise ArgumentError, \n\t\t\t\t\t\"RHOST is not defined; bind stager cannot function.\",\n\t\t\t\t\tcaller\n\t\t\tend\n\n\t\t\tstime = Time.now.to_i\n\t\t\t\n\t\t\twhile (stime + ctimeout > Time.now.to_i)\n\t\t\t\tbegin\n\t\t\t\t\tclient = Rex::Socket::Tcp.create(\n\t\t\t\t\t\t'PeerHost' => rhost,\n\t\t\t\t\t\t'PeerPort' => lport.to_i,\n\t\t\t\t\t\t'Proxies' => datastore['Proxies'],\n\t\t\t\t\t\t'Context' =>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'Msf' => framework,\n\t\t\t\t\t\t\t\t'MsfPayload' => self,\n\t\t\t\t\t\t\t\t'MsfExploit' => assoc_exploit\n\t\t\t\t\t\t\t})\n\t\t\t\trescue Rex::ConnectionRefused\n\t\t\t\t\t# Connection refused is a-okay\n\t\t\t\trescue ::Exception\n\t\t\t\t\twlog(\"Exception caught in bind handler: #{$!}\")\n\t\t\t\tend\n\n\t\t\t\tbreak if client\n\n\t\t\t\t# Wait a second before trying again\n\t\t\t\tRex::ThreadSafe.sleep(0.5)\n\t\t\tend\n\n\t\t\t# Valid client connection?\n\t\t\tif (client)\n\t\t\t\n\t\t\t\t# Increment the has connection counter\n\t\t\t\tself.pending_connections += 1\n\t\t\t\t\n\t\t\t\t# Start a new thread and pass the client connection\n\t\t\t\t# as the input and output pipe. Client's are expected\n\t\t\t\t# to implement the Stream interface.\n\t\t\t\tconn_threads << Thread.new {\n\t\t\t\t\tbegin\n\t\t\t\t\t\thandle_connection(client)\n\t\t\t\t\trescue\n\t\t\t\t\t\telog(\"Exception raised from BindTcp.handle_connection: #{$!}\")\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\telse\n\t\t\t\twlog(\"No connection received before the handler completed\")\n\t\t\tend\n\t\t}\n\tend",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.open_transactions.positive?\n\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates if should_run?\n sleep(0.1)\n end\n end",
"def listen\n connect do\n routes.each do |route|\n @client.subscribe(route) do |args|\n run(route, args)\n end\n end\n \n loop do\n sleep 1\n end\n end\n end",
"def start\n _signals_trap\n _init_actors\n unpause\n Celluloid::Actor[:listen_adapter].async.start\n @thread = Thread.new { _wait_for_changes }\n end",
"def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end",
"def start_handler\n\tend",
"def setup\n EventBus.subscribe(Events::DOWN_ARE_NODES_ALIVE, self, :on_alive_request)\n info \"Startup\"\n Thread.new {\n OmfCommon.init(CONFIG[:env], communication: {url: CONFIG[:xmpp_url]}) {\n OmfCommon.comm.on_connected { |comm|\n info \"WiseOMF >> Connected to XMPP server\"\n # Test end???\n comm.on_interrupted {\n puts \"WiseOMF >> Interrupt!\"\n ResourceProxyManager.instance.handle_interrupt\n }\n }\n }\n }.run\n sleep(5)\n\n OmfRc::ResourceFactory.load_additional_resource_proxies('../lib')\n ResourceProxyManager.instance\n # Do nothing\n end",
"def main\n #server=TCPServer::new('10.0.0.60',port)\n @server=TCPServer::new(@port)\n $logger.debug \"Running on Port #{@port}\"\n begin\n if defined?(Fcntl::FD_CLOEXEC)\n @server.fcntl(Fcntl::FD_CLOEXEC,1)\n end\n @server.listen(5)\n #@sock=@server.accept_nonblock\n rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR\n IO.select([@server])\n retry\n end\n Analyzer.find(:all).each { |analyzer|\n # If on start if analyzer is in downstream mode and ingress then restart the processl\n if (analyzer.cmd_port.nil?) && ((analyzer.status == Analyzer::INGRESS) || (analyzer.status == Analyzer::DOWNSTREAM))\n port=get_port(analyzer.id)\n $logger.error \"We don't have a port number for #{analyzer.id}, assigning it #{port}\"\n analyzer.update_attributes({:cmd_port=>port})\n elsif (!analyzer.cmd_port.nil?) && ((analyzer.status == Analyzer::INGRESS) || (analyzer.status == Analyzer::DOWNSTREAM))\n @ports_analyzer[analyzer.cmd_port - @start_port]=analyzer.id\n $logger.debug \"Setting cmd port #{analyzer.cmd_port}\"\n end\n #analyzer.update_attributes({:status=>Analyzer::DISCONNECTED})\n }\n an_count=Analyzer.find(:all).size\n try_count=Array.new(an_count,0)\n while(1)\n Analyzer.find(:all).each { |analyzer|\n if (!analyzer.cmd_port.nil?)\n @ports_analyzer[analyzer.cmd_port - @start_port]=analyzer.id\n try_count[analyzer.id]=0 if try_count[analyzer.id].nil?\n $logger.debug \"Setting cmd port #{analyzer.cmd_port}\"\n end\n }\n time=Time.now()\n selected_socket_list=IO.select([@server],nil,nil,5)\n if (selected_socket_list.nil?)\n $logger.debug \"Nothing to send Do a heartbeat\"\n #logger.debugs @ports_analyzer.inspect()\n @ports_analyzer.each_index { |port_index|\n analyzer_id=@ports_analyzer[port_index]\n port=nil\n if !analyzer_id.nil?\n port=get_port(analyzer_id)\n end\n\n unless port.nil?\n try_count[analyzer_id] +=1\n request=Net::HTTP.new('localhost',port)\n $logger.debug \"Do a heartbeat on #{port}\"\n #tries=0\n flag=true\n begin\n #sleep 5\n #tries +=1\n $logger.debug \"TRY # #{try_count[analyzer_id]}\"\n\n response=request.get(\"/\")\n rescue Timeout::Error #Instrument not responding. Lets kill the process.\n flag=false\n anl=Analyzer.find(analyzer_id)\n if (!anl.nil?) && (!anl.pid.nil?) && (anl.pid != 0)\n Process.kill(\"TERM\", anl.pid)\n else\n SystemLog.log(\"Unable to start monitoring process for Analyzer: #{anl.name}\",nil,SystemLog::MESSAGE,analyzer_id)\n anl.update_attribute({:pid=>0})\n end\n rescue\n #sleep 5\n #$logger.debug \"Try again\"\n flag=false\n if (try_count[analyzer_id] > 5)\n try_count[analyzer_id]=0\n $logger.debug \"Restarting monitor for #{analyzer_id}\"\n SystemLog.log(\"(Re)Starting the monitor server #{Analyzer.find(analyzer_id).ip}\",nil,SystemLog::MESSAGE,analyzer_id)\n start_monitor(analyzer_id, port)\n end\n end\n if flag==true\n try_count[analyzer_id]=0\n end\n $logger.debug response.inspect()\n end\n diff=Time.now-time\n if diff < 5\n sleep (5-diff)\n end\n }\n else\n selected_socket=selected_socket_list[0].first()\n @sock=selected_socket.accept\n process()\n end\n end\n end",
"def enable_heartbeat(interval = 60, &blk)\n raise 'This API endpoint cannot be used over HTTP.' unless block_given?\n\n websocket.subscribe :setheartbeat, params: { interval: interval }, &blk\n end",
"def start_listener!\n memoize(\"#{args[:bind]}-#{args[:port]}\", :global) do\n build_listener do |req|\n begin\n msg = build_message(req)\n # Start with static path lookup since it's the\n # cheapest, then fallback to iterative globbing\n msg_queue = nil\n unless(msg_queue = message_queues[\"#{req.path}-#{req.method.to_s.downcase}\"])\n message_queues.each do |k,v|\n path_glob, http_method = k.split('-')\n if(req.method.to_s.downcase == http_method && File.fnmatch(path_glob, req.path))\n msg_queue = v\n end\n end\n end\n if(msg_queue)\n if(authorized?(msg))\n msg_queue[:queue] << msg\n if(msg_queue[:config][:auto_respond])\n code = msg_queue[:config].fetch(:response, :code, 'ok').to_sym\n response = msg_queue[:config].fetch(:response, :message, 'So long and thanks for all the fish!')\n req.respond(code, response)\n end\n else\n req.respond(:unauthorized, 'You are not authorized to perform requested action!')\n end\n else\n req.respond(:not_found, 'Requested path not found!')\n end\n rescue Zoidberg::DeadException\n raise\n rescue => e\n req.respond(:bad_request, \"Failed to process request -> #{e}\")\n puts \"#{e}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end\n end\n end",
"def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end",
"def start\n loop do\n begin\n socket = tcp_server.accept\n\n handle_request(socket)\n ensure\n socket.close\n end\n end\n end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def start_listening\n # We don't want to spawn an extra listener\n return if Thread === @ioloop_thread\n\n # Don't listen if socket is dead\n return if @dead_socket\n\n # Build forced / magic logic - welcome setting @me, ping response, etc.\n # Since we do these here, nobody can skip them and they're always first.\n setup_magic_handlers\n\n # Begin the listening thread\n @ioloop_thread = Thread.new {io_loop}\n @input_processor = Thread.new {process_input_loop}\n @privmsg_processor = Thread.new {process_privmsg_loop}\n\n # Let's begin the cycle by telling the server who we are. This should\n # start a TERRIBLE CHAIN OF EVENTS!!!\n handle(:outgoing_begin_connection, @username, @address, @realname)\n end",
"def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end",
"def post_init\n @builder, @parser = Hatetepe::Builder.new, Hatetepe::Parser.new\n @builder.on_write << method(:send_data)\n # @builder.on_write {|data| p \"|--> #{data}\" }\n @parser.on_response << method(:receive_response)\n\n @queue = []\n\n @app = proc {|request| send_request(request) }\n\n self.comm_inactivity_timeout = config[:timeout]\n self.pending_connect_timeout = config[:connect_timeout]\n\n start_tls if config[:ssl]\n end",
"def start\n # The announce timer\n # We attempt to announce this ruby sensor to the host agent.\n # In case of failure, we try again in 30 seconds.\n @announce_timer = @timers.now_and_every(30) do\n if host_agent_ready? && announce_sensor\n ::Instana.logger.debug \"Announce successful. Switching to metrics collection.\"\n transition_to(:announced)\n end\n end\n\n # The collect timer\n # If we are in announced state, send metric data (only delta reporting)\n # every ::Instana::Collector.interval seconds.\n @collect_timer = @timers.every(::Instana::Collector.interval) do\n if @state == :announced\n unless ::Instana::Collector.collect_and_report\n # If report has been failing for more than 1 minute,\n # fall back to unannounced state\n if (Time.now - @entity_last_seen) > 60\n ::Instana.logger.debug \"Metrics reporting failed for >1 min. Falling back to unannounced state.\"\n transition_to(:unannounced)\n end\n end\n ::Instana.processor.send\n end\n end\n\n # Start the background ruby sensor thread. It works off of timers and\n # is sleeping otherwise\n Thread.new do\n loop {\n if @state == :unannounced\n @collect_timer.pause\n @announce_timer.resume\n else\n @announce_timer.pause\n @collect_timer.resume\n end\n @timers.wait\n }\n end\n end",
"def start!\n http_server.start\n self\n end",
"def run\n\t\t# Empezamos a escuchar al servidor\n\t\tlisten\n\t\t# Empezamos a enviar al servidor\n\t\tsend\n\t\t# Revisamos el estado de la conexion\n\t\t# check_alvie\n\t\t# Al terminar cerramos los Threads\n\t\t@request.join if @request.alive?\n\t\t@response.join if @response.alive?\n\tend",
"def run\n @listeners.each {|name,s| \n s.run \n }\n\n $mongrel_sleeper_thread = Thread.new { loop { sleep 1 } }\n end",
"def process_heartbeat(message)\n @reactor.log(:debug, \"#{@klass_name}, Worker [#{@service_name}] received HB from broker at [#{@hb_received_at}].\")\n end",
"def start\n prepare\n loop do\n git_poller.poll\n sleep ws.config.daemon_polling_period\n end\n end",
"def start\n boot_app && @@queue.load_jobs\n @worker_list = []\n Belated.config.workers.times do |i|\n @worker_list << Thread.new { Worker.new(number: i.next) }\n end\n return unless Belated.config.connect\n\n connect!\n banner_and_info\n trap_signals\n @@queue.enqueue_future_jobs\n end",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def run!\n start_server!\n @server_thread = Thread.new do\n loop do\n Thread.start(@server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error \"#{e.class}: #{e.message}\"\n @logger.debug e.backtrace\n ensure\n closing_client = @client_mutex.synchronize do\n @clients.delete(socket)\n end\n # invoke callbacks for disconnect if there is a client to\n # disconnect\n emit(:client_disconnect, closing_client) if closing_client\n socket.close\n end\n end\n end\n end\n end",
"def serving_loop\n Thread.new { socket_loop }\n @manager.management_loop\n end",
"def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end",
"def start_acceptor!\n\t\t$threads << @acceptor = Thread.new() do\n\t\t\twhile true\n\t\t\t\tif new_connection = @server.accept\n\t\t\t\t\tputs \"New connection accepted: #{new_connection}\"\n\t\t\t\t\t@connections << new_connection #Save any inbound\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def start\n Thread.start do\n loop do\n begin\n self.register unless self.registered?\n rescue DRb::DRbConnError\n self.ring_server = nil\n rescue RuntimeError => e\n raise unless e.message == 'RingNotFound'\n end\n sleep @check_every\n end\n end\n end",
"def run\n @active_connections = 0\n @mutex = Mutex.new\n\n logger.info \"Starting server on #{server_configuration.bind}\"\n\n # Set up each listener and add it to an array ready for the event loop\n @active_descriptors = []\n @active_descriptors << establish_socket_server\n @active_descriptors << establish_file_descriptor_server\n @active_descriptors << setup_signal_traps\n\n write_pidfile\n\n # Enter the main loop\n select_loop\n end",
"def keep_alive; end",
"def keep_alive; end",
"def start_watchdog!\n while true\n sleep 10\n @stream_parser.begin_read unless @stream_parser.alive?\n end\n end",
"def start\n # the above only accepts 1 requiest. it will stop after receiving a request\n # in order to enable the server to accept more than 1 request, you need to create a loop\n loop do\n # this is an infinite loop.. this can now accept multiple vars and it will ahve separate objects per request\n # once the server socket is ready..\n # we need to tell the server socket that we're ready to accept a connection\n # the #accept method accepts the next incoming connection or it will block if there are no incoming connections at teh moment\n # it will #accept once it arrives\n # this is the socket / connetiont at we have to teh remote browser\n socket = @server.accept # THIS IS THE CLIENT SOCKET\n puts \"this is the socket var: \" + @socket.inspect\n # let's start the new conneciton inside a thread\n # NOTE: there's a big performance and memory penalty for creating a new thread => needs to put a bunch of memory\n # to increase the performance, they initialize threads and then store those threads in a $\"thread pool\" => ie. instead of initializign new threads, it leverages existing threads\n # doing what you did below slows down the server significantly\n # apache, nginx, unicorn => prefork model\n # => fork meaning it will fork right afte rthe server socket initialization (see above in TCPServer) => 2 parts: main server socket in the master process and we will make child processes by calling a method called fork. it copies the the main process and it will $share the sockets from the master process\n # to the child proceess\n Thread.new do\n # create a new isntance of the connneciton class\n connection = Connection.new(socket, @app) # now we have access to the rack application instance inside our Connection \n connection.process\n end\n end\n end",
"def start\n Socket.accept_loop(@tcpserver) do |connection|\n SLogger.debug(\"[server] accepted a new connection (#{connection})\")\n\n self.session.connection = connection\n self.handle_connection(connection)\n end\n rescue IOError\n Thread.exit\n end",
"def run\n trap_signals\n loop do\n break if signals_want_shutdown\n begin\n # IO.select returns either a triplet of lists with IO objects that\n # need attention or nil on timeout of 2 seconds.\n if needy = IO.select([server.socket, lifeline], nil, [server.socket, lifeline], 2)\n server.log.debug(\"Detected activity on: #{needy.inspect}\")\n # If the lifeline is active the server went down and we need to go\n # down as well.\n break if needy.flatten.any? { |io| !io.respond_to?(:accept_nonblock) }\n # Otherwise we handle incoming requests\n needy.flatten.each do |io|\n if io.respond_to?(:accept_nonblock)\n begin\n process_incoming_socket(*io.accept_nonblock)\n rescue Errno::EAGAIN, Errno::ECONNABORTED\n end\n end\n end\n end\n rescue EOFError, Errno::EAGAIN, Errno::EINTR, Errno::EBADF, IOError\n end\n end\n cleanup\n end",
"def start_server\n @signature = EM.start_server(@host, @port, @handler) do |connection|\n setup_connection_opts(connection)\n end\n log(:info, \"Started listener #{@signature} on tcp://#{@host}:#{@port} (separator=#{@separator.inspect}).\")\n super\n end",
"def raise_heartbeat_event\n raise_event(HeartbeatEvent.new(self))\n end",
"def start\n executor.post {read_loop}\n start_protocols\n super\n end",
"def define_listening\n end",
"def connection_completed\n ## start sending KEEP_ALIVE_MESSAGE\n puts 'sending keep_alive sending ...'\n EM::PeriodicTimer.new(KEEP_ALIVE_INTERVAL) { send_data KEEP_ALIVE_MESSAGE }\n end",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def start\n @server = TCPServer.open(@hostname, @port)\n loop do\n Thread.new(@server.accept) do |client|\n while message = client.gets\n fmp = ForeignMessageParser.new(message)\n Mailbox.append(fmp.to_event) if fmp.got_valid_message?\n end\n client.close\n end\n end\n end",
"def on_start\n yield self\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates\n sleep 0.1\n end\n end",
"def start\n # Generate Device Description XML file\n generate_xml_device_description\n\n # Start server for M-SEARCH request\n start_ssdp_server\n\n # Start server for HTTP request\n start_http_server\n\n # Send initial notification\n notify :alive\n\n # increase BOOTID\n @boot_id = (@boot_id + 1) % 2**31\n\n # and then set a periodic timer for future notifications\n @notify_timer = EM.add_periodic_timer(@notify_interval) { notify :alive }\n end",
"def set_heartbeat_timer(buffer)\n # Cancel @disconnect_timer.\n SockJS.debug \"Cancelling @disconnect_timer as we're about to send a heartbeat frame in 25s.\"\n @disconnect_timer.cancel if @disconnect_timer\n @disconnect_timer = nil\n\n @alive_checker.cancel if @alive_checker\n\n # Send heartbeat frame after 25s.\n @heartbeat_timer ||= EM::Timer.new(25) do\n # It's better as we know for sure that\n # clearing the buffer won't change it.\n SockJS.debug \"Sending heartbeat frame.\"\n begin\n self.finish\n rescue Exception => error\n # Nah these exceptions are OK ... let's figure out when they occur\n # and let's just not set the timer for such cases in the first place.\n SockJS.debug \"Exception when sending heartbeat frame: #{error.inspect}\"\n end\n end\n end",
"def register_polling_thread\n @poll_thread = Thread.new { poll }\n end",
"def handle_connection_response(response)\n handle_response(response.body)\n light_sleep(self.class.poll_interval)\n end",
"def start\n validate!\n start_message\n build_threads\n start_threads\n end",
"def post_init\n @healthcheck_poller = EventMachine.add_periodic_timer(CONNECTION_HEALTH_CHECK_INTERVAL) do\n if @intentionally_closed\n @healthcheck_poller.cancel\n elsif (@data_last_received_at) && ((Time.now - @data_last_received_at) >= NO_DATA_RECEIVED_TIMEOUT)\n no_data_received\n close_connection\n end\n end\n end",
"def start\n super\n log.trace \"splunk-http-eventcollector(start) called\"\n\n @http = Net::HTTP::Persistent.new('fluent-plugin-splunk-http-eventcollector', @proxy)\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify\n @http.override_headers['Content-Type'] = 'application/json'\n @http.override_headers['User-Agent'] = 'fluent-plugin-splunk-http-eventcollector/0.0.1'\n @http.override_headers['Authorization'] = \"Splunk #{@token}\"\n\n log.trace \"initialized for splunk-http-eventcollector\"\n end",
"def do_work\n scan!\n server.scan_semaphore.wait(server.cluster.heartbeat_interval)\n end",
"def starting\n log(\"GlobalChat2 Server Running\")\n start_pong_loop\n end",
"def listening?; end",
"def on_start\n end",
"def start\n @logger.debug { \"Opening server\" }\n @tcp_server = TCPServer.new(@ip, @port)\n @logger.debug { \"Listening to #{@ip} port #{@port}\n pointing #{ROOT_DIR}\" }\n\n answer_worker = AnswerWorker.new\n client = nil\n loop do\n begin\n client = @tcp_server.accept\n @logger.debug { \"Server accepted new request\" }\n answer_worker.start(client)\n rescue Interrupt => e\n @logger.debug { \"Closing program\" }\n exit\n rescue Exception => e\n @logger.debug { \"Exception caught:\" }\n @logger.debug { e }\n end\n end\n stop\n end",
"def housekeeping\n @mongo = Mongo::Connection.new\n log_yellow \"Launching housekeeping thread (YELLOW)\"\n while !@interrupted\n release_stale_reservations\n watchful_sleep 5\n end\n end",
"def start_keepalives\n @keepalive_timer.cancel if @keepalive_timer\n @keepalive_timer = EM::Synchrony.add_periodic_timer(KEEPALIVE_INTERVAL) do\n SpotifyWeb.run { api('sp/echo', 'h') }\n end\n end",
"def run\n @router_socket = Hastur::Util.connect_socket @ctx, ZMQ::DEALER, @routers, :linger => 1, :hwm => 10_000\n @poller.register_readable @router_socket\n\n set_up_local_ports\n\n Hastur.start\n @running = true\n\n last_system_stat_time = Time.now\n last_heartbeat_time = Time.now - 61\n\n while @running\n poll_noop\n poll_registration_timeout\n poll_ohai_info_timeout\n poll_heartbeat_timeout\n poll_ack_timeouts\n poll_plugin_pids\n poll_zmq rescue nil # Temp: 2012-05-02, should properly detect & log bad messages\n send_agent_stats unless @no_agent_stats\n\n if select([@udp_socket], [], [], 0.25)\n poll_udp\n end\n\n now = Time.now\n # agent doesn't use the Hastur background thead, send a heartbeat every minute\n if (now - last_heartbeat_time) >= 60\n Hastur.heartbeat(\"hastur.agent.process_heartbeat\")\n last_heartbeat_time = now\n end\n\n # send Linux stats every 10 seconds\n if (now - last_system_stat_time) >= 10 and File.exists?(\"/proc/net/dev\")\n Hastur::Agent::LinuxStats.run\n last_system_stat_time = now\n end\n end\n\n msg = Hastur::Message::Log.new :from => @uuid, :payload => \"Hastur Agent #{@uuid} exiting.\"\n _send(msg)\n\n @router_socket.close\n end",
"def run\n loop do\n memcached = Memcached.new # each client has its oun cache storage\n new_client = @tcp_Server.accept # when a new client connects to the server\n client_handler_id = rand(999999).to_s\n client_handler = ClientHandler.new(id: client_handler_id, clientSocket: new_client, memcached: memcached)\n @@clients << client_handler\n\n Thread.start(client_handler) do |handler| # open a new thread for each accepted connection\n # Here we inform the client of the connections. It's human made, so can be removed if not needed\n puts \"New connection established! Now #{@@clients.length()} clients :>\"\n puts \"WAITING FOR REQUESTS\"\n handler.send(\"Server: Connection established with Client Handler ID: #{client_handler_id}\")\n handler.send(\"Server: You are the client ##{@@clients.length()}\")\n handler.send(\"Server: You may introduce commands now\")\n listen_requests(handler) # allow communication\n end\n end.join\n end",
"def start!\n start\n blocking_thread.join\n end"
] | [
"0.7564895",
"0.72110647",
"0.6966699",
"0.688922",
"0.68513125",
"0.68230104",
"0.64901096",
"0.64671785",
"0.6271216",
"0.62344164",
"0.6221152",
"0.6127869",
"0.61002326",
"0.6076735",
"0.5988071",
"0.5980867",
"0.5975331",
"0.59176195",
"0.59176195",
"0.58216685",
"0.5803356",
"0.58013725",
"0.5784668",
"0.5777059",
"0.57460326",
"0.5742878",
"0.5739286",
"0.5724078",
"0.5717345",
"0.5709528",
"0.5696032",
"0.56908107",
"0.56907696",
"0.5687904",
"0.5666403",
"0.5665341",
"0.5661902",
"0.5652681",
"0.5652527",
"0.5641119",
"0.5637948",
"0.5635079",
"0.563257",
"0.56297857",
"0.5619826",
"0.56118006",
"0.5609795",
"0.5608063",
"0.56066173",
"0.5593808",
"0.5583706",
"0.55822664",
"0.5576789",
"0.5557699",
"0.55573165",
"0.5544504",
"0.55401415",
"0.5538528",
"0.5536417",
"0.5523043",
"0.5518841",
"0.5518841",
"0.5510701",
"0.5493764",
"0.5493075",
"0.54920274",
"0.54654723",
"0.5457399",
"0.5429542",
"0.5429542",
"0.54274017",
"0.54269964",
"0.54206216",
"0.5419673",
"0.54194355",
"0.5417346",
"0.5411399",
"0.54099315",
"0.540646",
"0.5398427",
"0.5396499",
"0.5395285",
"0.5391231",
"0.5390954",
"0.5375842",
"0.5374045",
"0.53687036",
"0.5365015",
"0.5363696",
"0.53556824",
"0.53555447",
"0.5353404",
"0.53522944",
"0.53476006",
"0.5346374",
"0.5342387",
"0.5341084",
"0.5340879",
"0.5334853",
"0.5332712"
] | 0.8145583 | 0 |
Called by Mongrel2::Handler when the server is restarted. Overridden to restart the heartbeat thread. | def restart
self.stop_heartbeat
super
self.start_heartbeat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_restart(&block); end",
"def restart\n client.restart\n end",
"def restart_server\n stop_server\n sleep 1\n start_server\n end",
"def start_heartbeat\n\t\tself.log.info \"Starting heartbeat timer.\"\n\t\t@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do\n\t\t\tself.cull_idle_sockets\n\t\t\tself.ping_all_sockets\n\t\tend\n\tend",
"def restart_soon\n @restart = true\n @shutdown = true\n end",
"def setup_heartbeat_timer; end",
"def heartbeat\n end",
"def reload\n restart_and_ping\n end",
"def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end",
"def restart()\n shutdown()\n start()\n end",
"def signal_restart_graceful\n @signal_operation_queue << :restart_graceful\n interrupt_server_polling_sleep\n nil\n end",
"def reload_server\n restart_server\n end",
"def signal_restart_forced\n @signal_operation_queue << :restart_forced\n interrupt_server_polling_sleep\n nil\n end",
"def shutdown\n\t\tself.stop_heartbeat\n\t\tsuper\n\tend",
"def restart_server(connection)\n signal :USR2\n\n connection.write \"GET / HTTP/1.1\\r\\n\\r\\n\" # trigger it to start by sending a new request\n\n wait_for_server_to_boot\n end",
"def restart\n raise _(\"Server restart is only supported on Linux\") unless MiqEnvironment::Command.is_linux?\n\n _log.info(\"Server restart initiating...\")\n update_attribute(:status, \"restarting\")\n\n shutdown_and_exit(RESTART_EXIT_STATUS)\n end",
"def restart!\n IbmCloudRest.post \"#{@uri}/_restart\"\n end",
"def drb_restart!\n Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }\n end",
"def restart!\n start!\n end",
"def restart; end",
"def restart\n if @time < @next_restart\n log.info \"synapse: at time #{@time} waiting until #{@next_restart} to restart\"\n return\n end\n\n @next_restart = @time + @restart_interval\n @next_restart += rand(@restart_jitter * @restart_interval + 1)\n\n # do the actual restart\n res = `#{opts['reload_command']}`.chomp\n unless $?.success?\n log.error \"failed to reload haproxy via #{opts['reload_command']}: #{res}\"\n return\n end\n log.info \"synapse: restarted nginx\"\n\n @restart_required = false\n end",
"def restart!\n JobRestarter.restart(self)\n end",
"def restart\n\trequire_relative '../../lib/falcon/command/supervisor'\n\t\n\tFalcon::Command::Supervisor[\"restart\"].call\nend",
"def restart\n request('restart')\n end",
"def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end",
"def restart\n\t\treturn nil unless self.running?\n\t\tProcess.kill 'SIGHUP', @pid\n\tend",
"def reload\n run \"touch #{current_path}/rack/tmp/restart.txt\"\n end",
"def setup_heartbeat_timer\n @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do\n event_loop.post { connections.each(&:beat) }\n end\n end",
"def restart\n\t\traise \"can't restart: not running\" unless self.reactor\n\n\t\tself.log.info \"Restarting\"\n\t\tif (( old_conn = @conn ))\n\t\t\tself.reactor.unregister( old_conn.request_sock )\n\t\t\t@conn = @conn.dup\n\t\t\tself.reactor.register( @conn.request_sock, :read, &self.method(:on_socket_event) )\n\n\t\t\tself.log.debug \" conn %p -> %p\" % [ old_conn, @conn ]\n\t\t\told_conn.close\n\t\tend\n\tend",
"def restart # :nodoc:\n put :restart\n end",
"def reload\n @reloaded = true\n restart\n end",
"def start_heartbeat_if_needed\n logger.debug(\"start_heartbeat_if_needed - enter\")\n return if freq == 0\n return if @heartbeat_thread\n @heartbeat_thread = Thread.new do\n while true do\n heartbeat_command\n end\n end\n end",
"def restart \n log \"Restarting\"\n puts config.inspect if config[:debug]\n \n @svns = (YAML.load_file config[:svns] rescue {})\n @atoms = (YAML.load_file config[:atoms] rescue {})\n\n @socket.close if @socket\n connect\n listen\n end",
"def stop_heartbeat\n\t\tself.reactor.remove_timer( @heartbeat_timer )\n\tend",
"def restart\n stop\n sleep 2\n start\n end",
"def reconnect lost_connection = false\n unless lost_connection\n send_command 'QUIT', [], 'Reconnecting'\n else\n $log.warn(\"IRCConnection.reconnect #{@name}\") { \"Lost connection.\" }\n end\n\n @reconnecting = true\n Events.delete_for @channels\n Events.delete_for @users\n\n EM.add_timer(Bot::Conf[:core][:reconwait]) do\n $log.warn(\"IRCConnection.reconnect #{@name}\") { \"Attempting to reconnect.\" }\n\n @config = Bot::Conf[:servers][name]\n super @config[:address], @config[:port]\n end\n end",
"def restart\n self.stop\n self.start\n end",
"def heartbeat\n @publisher.broadcast(:heartbeat)\n @sessions.expire\n rescue => e\n log.error(\"Cluster session cleanup failed: #{e}\")\n end",
"def restart\n if config.managed? && started?\n stop\n start\n end\n end",
"def reload\n restart\n end",
"def restart\n if booted then\n kill\n end\n start\n end",
"def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end",
"def restart!\n stop!\n start!\n end",
"def restart_server(connection, log: false)\n Process.kill :USR2, @pid\n connection.write \"GET / HTTP/1.1\\r\\n\\r\\n\" # trigger it to start by sending a new request\n wait_for_server_to_boot(log: log)\n end",
"def restart\n stop\n start\nend",
"def autorestart \n rebang = @rebang \n restart\n @suppress_rebang = rebang\n end",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def restart\n\tcall 'falcon:supervisor:restart'\nend",
"def app_restart\n return unless restart_required?\n callback(:app_restart) do\n notify(:app_restart)\n heroku.app_restart\n end\n end",
"def restart\n log('Attempting to restart')\n\n return not_enabled unless Vedeu.config.drb?\n\n if drb_running?\n log('Restarting')\n\n stop\n\n else\n log('Not running')\n\n end\n\n start\n end",
"def restart\n stop\n start\n end",
"def run\n unless @heartbeat_type == :none\n super\n end\n end",
"def restart\n log('Attempting to restart')\n\n return not_enabled unless Vedeu::Configuration.drb?\n\n if drb_running?\n log('Restarting')\n\n stop\n\n start\n\n else\n log('Not running')\n\n start\n\n end\n end",
"def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end",
"def restart\n stop\n sleep(1)\n start\n end",
"def restart\n stop\n sleep(1)\n start\n end",
"def restart_server(type, date)\n stop_server(type, date)\n start_server(type, date)\n end",
"def reload\n stop\n start\n end",
"def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end",
"def reconnect!\n end",
"def handle_heartbeat_ack(_payload)\n @heartbeat_acked = true\n end",
"def reconnect\n end",
"def restart; stop; start; end",
"def event_timer\n if @connection.comm.connected? and Time.now - @var[:last_ping] >= 60\n begin\n _server_control(\"keepalive\")\n rescue\n _notice(\"The connection to the server has been lost\", :global)\n @connection.disconnect\n end\n end\nend",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart_worker(wpid)\n info \"RESTARTING WORKER #{wpid}\"\n @mutex.synchronize do\n Process.kill(\"HUP\",wpid)\n mark_worker_as_stopped(wpid)\n @workers_restarting += 1\n end\n sleep Skynet::CONFIG[:WORKER_CHECK_DELAY]\n end",
"def restart_ticker(m)\n quiet_stop_ticker(m)\n quiet_start_ticker(m)\n m.reply \"Google RSS: Restarted\"\n end",
"def reconnect\n end",
"def reconnect\n end",
"def attempt_reconnect\n #The reconnect method called below is provided by EventMachine\n reconnect HOST, PORT\n end",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart\n stop\n start\n end",
"def restart\n stop; start\n end",
"def restart config={}\n stop\n start(config)\n end",
"def raise_heartbeat_event\n raise_event(HeartbeatEvent.new(self))\n end",
"def reconnect server, port\n\t\tEventMachine::reconnect server, port, self\n\tend",
"def hot_restart\n system \"kill -s USR2 #{pid} > /dev/null 2>&1\"\n end",
"def reboot!\n reboot_instance(_id) && reload!\n end",
"def handle_heartbeat(packet)\n end",
"def restart!\n lock\n\n begin\n if config.core_base\n @config.state = \"started\"\n write_config current_deployment_number, @config\n @logger.debug \"Restarting core\"\n @starter.restart! config.core_base\n @config.last_start_time = time\n end\n\n announce\n return status\n rescue Exception => e\n error_reason = \"Unable to restart: #{e}\"\n error_reason += \"\\n#{e.message}\" if e.class == Galaxy::HostUtils::CommandFailedError\n @logger.error error_reason\n raise error_reason\n ensure\n unlock\n end\n end",
"def restart_node\n stop_node\n sleep 1\n start_node\n end",
"def reset_liveness_timer\n @liveness_timer.cancel if @liveness_timer\n @liveness_timer = EventMachine::Timer.new(connection.heartbeat_interval + 0.1) do\n if connection.connected? && (connection.time_since_connection_confirmed_alive? >= connection.heartbeat_interval)\n msg = \"No activity seen from realtime in #{connection.heartbeat_interval}; assuming connection has dropped\";\n error = Ably::Exceptions::ConnectionTimeout.new(msg, Ably::Exceptions::Codes::DISCONNECTED, 408)\n connection.transition_state_machine! :disconnected, reason: error\n end\n end\n end",
"def heartbeat_frequency\n server.cluster.heartbeat_interval\n end",
"def run_on_changes(_)\n restart\n end",
"def redis_restart_on_change\n restart_on_change = configuration[:redis][:restart_on_change]\n restart_on_change = true if restart_on_change.nil? # nil is true so we have a default value.\n restart_on_change\n end",
"def shutdown_soon\n @restart = false\n @shutdown = true\n end",
"def restart\n raw \"RESTART\\r\\n\"\n end",
"def restart(app_name)\n deprecate # 07/31/2012\n delete(\"/apps/#{app_name}/server\").to_s\n end",
"def heartbeat_thread_runner\n heartbeat = ImapDaemonHeartbeat.create(:tag => server_tag)\n while running?\n # Update the heartbeat.\n heartbeat.touch\n\n # Log Heroku / Librato stats.\n Log.librato(:measure, 'imap_client.thread.count', Thread.list.count)\n Log.librato(:measure, 'imap_client.work_queue.length', work_queue_length)\n Log.librato(:measure, 'imap_client.user_thread.count', user_threads_count)\n Log.librato(:measure, 'work_queue.latency', work_queue_latency)\n Log.librato(:sample, 'imap_client.total_emails_processed', total_emails_processed)\n\n light_sleep 10\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping heartbeat thread.\")\n heartbeat.delete if heartbeat\n end",
"def restart\n r = REXML::Element.new 'body'\n r.attributes['rid'] = @http_rid += 1\n r.attributes['sid'] = @http_sid\n r.attributes['to'] = @jid.domain\n r.attributes['xmlns'] = 'http://jabber.org/protocol/httpbind'\n r.attributes['xmlns:xmpp'] = 'urn:xmpp:xbosh'\n r.attributes['xmpp:restart'] = 'true'\n s = post(r)\n unless s.name == 'body'\n raise 'Response body is no <body/> element'\n end\n receive_elements_with_rid(@http_rid, s.children)\n end",
"def restart(pid=nil)\n `cp #{APP_ROOT}/services/drb.log #{APP_ROOT}/services/drb.bak`\n `cp #{APP_ROOT}/services/dico.log #{APP_ROOT}/services/dico.bak`\n if !pid.nil?\n pid.each {|x| `kill -1 #{x}`}\n sleep(1)\n end\n `cd #{APP_ROOT};#{WHICH_RAKE} #{RAKE_FILE}[#{SHARD_ID},#{MAX_SHARD}] >#{APP_ROOT}/services/drb.log 2>&1 &`\n puts \"## Restarted\"\nend",
"def _reconn_prep()\n close_socket()\n if @parameters\n change_host()\n end\n @st.kill if @st # Kill ticker thread if any\n @rt.kill if @rt # Kill ticker thread if any\n @socket = nil\n end",
"def restart\n stop if is_running?\n start\n \n is_running?\n end",
"def refresh \n if (@parameters[:ensure].value == :running)\n provider.restart\n else\n debug \"Skipping restart; service is not running\"\n end\n end",
"def reset!\n reconnect!\n end",
"def reconnect\n @subject.reconnect!\n logger.info \"Connection #{connection_uri} reconnected.\"\n end",
"def refresh\n # Only restart if we're actually running\n if (@parameters[:ensure] || newattr(:ensure)).retrieve == :running\n provider.restart\n else\n debug 'Skipping restart; service is not running'\n end\n end"
] | [
"0.6904999",
"0.68003976",
"0.6763715",
"0.669449",
"0.6671425",
"0.66584456",
"0.6590591",
"0.6571508",
"0.6565373",
"0.65432674",
"0.6542003",
"0.6502352",
"0.64218545",
"0.63798964",
"0.6370832",
"0.636443",
"0.63335013",
"0.62856543",
"0.6281572",
"0.6279329",
"0.6245739",
"0.6225865",
"0.61874294",
"0.6166153",
"0.61444193",
"0.6116267",
"0.61159676",
"0.6107987",
"0.61064434",
"0.6089015",
"0.6075154",
"0.6072742",
"0.60717523",
"0.60638213",
"0.604249",
"0.6030615",
"0.602778",
"0.6025908",
"0.60238045",
"0.60078245",
"0.6007588",
"0.60070944",
"0.5984196",
"0.59820724",
"0.5980072",
"0.59714746",
"0.594465",
"0.594465",
"0.594465",
"0.5925124",
"0.59224164",
"0.5915626",
"0.5900019",
"0.58604395",
"0.58396137",
"0.58303255",
"0.58303255",
"0.5818039",
"0.580743",
"0.5801719",
"0.5787295",
"0.5762123",
"0.5761381",
"0.57553273",
"0.5752342",
"0.5749378",
"0.5749378",
"0.5743517",
"0.5741608",
"0.5738905",
"0.5738905",
"0.5726741",
"0.5720089",
"0.5720089",
"0.5720089",
"0.5710188",
"0.57012343",
"0.5693888",
"0.56931764",
"0.5688847",
"0.5678671",
"0.5673069",
"0.5665294",
"0.56599057",
"0.5656947",
"0.5649238",
"0.56464005",
"0.5644501",
"0.5635729",
"0.56301564",
"0.5626811",
"0.5623334",
"0.5613707",
"0.56123227",
"0.5605702",
"0.56056714",
"0.55930126",
"0.5579136",
"0.55703515",
"0.5566281"
] | 0.8183777 | 0 |
Called by Mongrel2::Handler when the server is shut down. Overridden to stop the heartbeat thread. | def shutdown
self.stop_heartbeat
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_heartbeat\n\t\tself.reactor.remove_timer( @heartbeat_timer )\n\tend",
"def signal_server_down\n interrupt_server_polling_sleep\n nil\n end",
"def shutdown\n @server_active = false\n end",
"def shut_down\n trigger(:shut_down_started)\n @server.stop(true) if @server\n @server_thread.join if @server_thread\n adapter.shut_down\n trigger(:shut_down_complete)\n end",
"def shutdown\n @server.shutdown\n end",
"def shutdown_handler(event)\n super\n\n stop_listener if @server_sig\n end",
"def shutdown\n @stopped = false\n end",
"def stop_server\n if ! @wbthread.nil? && @wbthread.alive?\n # signal server thread to quit\n Process.kill('USR1', Process.pid)\n # wait for it to actually quit\n # note: Sometimes it appears to hang here at this join, when there's something wrong with the server or client\n # when that happens just comment out to see more debug info what's wrong\n # you'll also get some spurious concurrency errors of course, but at least the problem will show up too\n @wbthread.join\n end\n end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shut_down\n end",
"def shutdown\n if PushmiPullyu.server_running?\n # using stderr instead of logger as it uses an underlying mutex which is not allowed inside trap contexts.\n warn 'Exiting... Interrupt again to force quit.'\n PushmiPullyu.server_running = false\n else\n exit!(1)\n end\n end",
"def stop\n @server.shutdown if @server\n end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n @manager.shutdow_service_server(self)\n end",
"def shutdown\n log(\"Shutting down...\")\n # We need to perform the shutdown in a new thread, because this method\n # gets called from within a trap context\n Thread.new {\n Sock.off\n stop_bot\n disconnect_db\n unblock_threads\n exit\n }\nrescue => e\n fatal(\"Failed to shut down bot: #{e}\")\n exit\nend",
"def shutdown\n stop\n end",
"def graceful_shutdown; end",
"def drb_stop!\n Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }\n end",
"def shutdown( msg=\"Server shutdown\" )\n\t\t$stderr.puts \"Shutting down: #{msg}\"\n\n\t\t@shutting_down = true\n\t\t@reactor.clear\n\n\t\t@listener.shutdown rescue nil\n\t\tself.disconnect_all_users( msg )\n\t\t@listener.close rescue nil\n\tend",
"def shutdown!\n shutdown\n end",
"def shutdown\n\t\tself.log.info \"Shutting down.\"\n\t\tself.reactor.stop_polling\n\t\t@conn.close\n\tend",
"def handle_shutdown\n # TODO: Handle shutdown\n end",
"def signal_stop_graceful\n @stop_state ||= :graceful\n interrupt_server_polling_sleep\n nil\n end",
"def stop\n @server.stop if @server.running?\n end",
"def shut_down\n @shutdown_lock.synchronize {\n return if @shutting_down\n @shutting_down = true\n }\n die NO_ERROR\n end",
"def shutdown\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def shutdown\n client.deregister_inbound_handler(Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel)\n end",
"def shutdown\n connection.write(\"shutdown\")\n end",
"def shutdown\n @running = false\n end",
"def stop_server\n @server_handler.stop_server\n end",
"def shutdown\n @logger.info \"Hastur agent shutting down normally.\"\n @running = false\n @router_socket.close\n @udp_socket.close\n @ctx.terminate\n end",
"def stop\n if @http_server\n # shuts down the server\n @http_server.shutdown\n \n # print goodbye message\n puts\n print_info 'BeEF server stopped'\n end\n end",
"def shutdown\nend",
"def stop\n EM.cancel_timer @notify_timer\n notify :byebye\n stop_ssdp_server\n\n sleep 2\n stop_http_server\n end",
"def shutdown\n end",
"def on_shutdown\n\t\tend",
"def stop\n @shutdown = true\n end",
"def graceful_shutdown\n socket_server.close unless socket_server.closed?\n @active_descriptors.delete(socket_server)\n @shutdown = true\n end",
"def shutdown\n @snmptrap.exit\n end",
"def shutdown?; end",
"def stop\n @server.close\n end",
"def stop\n return if not running?\n @running = false\n @server.shutdown\n end",
"def server_stop\n Process.kill 'INT', 0\n end",
"def shutdown\n @@servers.values.each do |server|\n server.disconnect\n server.scheduler.remove_all\n end\n end",
"def stop\n server = Communist.servers.delete(app.object_id) { |s| NullServer.new }\n if Communist.server.respond_to?(:shutdown)\n server.shutdown\n elsif Communist.server.respond_to?(:stop!)\n server.stop!\n else\n server.stop\n end\n @server_thread.join\n end",
"def stop_server\n if @server\n @server.shutdown\n @server_thread.join\n @server\n end\n end",
"def shutdown!\n _shutdown 'SIGKILL' unless dead?\n end",
"def shutdown!\r\n\t shutdown\r\n\t end",
"def shutdown\n @shutdown = true\n end",
"def shutdown\n @shutdown = true\n end",
"def shutdown\n send_recv( KJess::Request::Shutdown.new )\n end",
"def stop_server\n Thin::Server.kill(CloudCrowd.pid_path('server.pid'), 0)\n end",
"def stop\n @appserver.stop\n \n if @thread\n sleep 0.1 while @thread[:running]\n @thread.kill\n @thread = nil\n end\n end",
"def shutdown( msg=\"Server shutdown\" )\n\t\t$stderr.puts \"Shutting down: #{msg}\"\n\t\t@shuttingDown = true\n\t\t@reactor.clear\n\t\tbegin\n\t\t\t@socket.shutdown\n\t\trescue\n\t\tend\n\t\tdisconnectAllUsers( msg )\n\t\tbegin\n\t\t\t@socket.close\n\t\trescue\n\t\tend\n\tend",
"def down\n DRb.stop_service\n @status = :stopped\n @logger.info(\"slave stopped\")\n @logger.close\n end",
"def kill\n shutdown\n end",
"def stop\n puts \"== The Middleman is shutting down\"\n if !@options[:\"disable-watcher\"]\n Process.kill(::Middleman::WINDOWS ? :KILL : :TERM, @server_job)\n Process.wait @server_job\n @server_job = nil\n end\n end",
"def shutdown\n @conn.shutdown\n end",
"def unheartbeat(service_name)\n Thread.kill @@heartbeats[service_name]\n end",
"def shutdown\n log 'Exiting...'\n @shutdown = true\n end",
"def on_kill\n\n # Commit last changes\n commit(true)\n\n # Join to the delete worker and wait wile it is done\n @thr_del_worker.join unless @thr_del_worker.nil?\n\n $log.info(self) {'Shutting down...'}\n\n # Here the thread is almost shut down\n end",
"def stop_server\n unless @servsocket.closed?\n detach\n @servsocket.close\n end\n end",
"def stop_supervised\n Karafka::App.stop!\n\n # See https://github.com/dry-rb/dry-configurable/issues/93\n timeout = Thread.new { Karafka::App.config.shutdown_timeout }.join.value\n\n # We check from time to time (for the timeout period) if all the threads finished\n # their work and if so, we can just return and normal shutdown process will take place\n (timeout * SUPERVISION_CHECK_FACTOR).to_i.times do\n if consumer_threads.count(&:alive?).zero?\n Thread.new { Karafka.monitor.instrument('app.stopped') }.join\n return\n end\n\n sleep SUPERVISION_SLEEP\n end\n\n raise Errors::ForcefulShutdownError\n rescue Errors::ForcefulShutdownError => e\n Thread.new { Karafka.monitor.instrument('app.stopping.error', error: e) }.join\n # We're done waiting, lets kill them!\n consumer_threads.each(&:terminate)\n\n # exit! is not within the instrumentation as it would not trigger due to exit\n Kernel.exit! FORCEFUL_EXIT_CODE\n end",
"def shutdown\n\tend",
"def shutdown\n log.info 'Shutting down...'\n @shutdown = true\n end",
"def shutdown!\n shutdown\n kill_jobs\n end",
"def shutdown\n request('shutdown')\n end",
"def shutdown\n @event_loop.shutdown\n end",
"def stop_polling!; end",
"def shutdown\n shutdown_proxy\n exit_thread\n super\n end",
"def shutdown\n log 'Exiting...'\n Thread.list.each { |t| t[:shutdown] = true }\n @shutdown = true\n end",
"def on_worker_shutdown(&block); end",
"def kill\n server.kill\n end",
"def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end",
"def stop\n # use pid in controlling process, webrick in server process\n @webrick.shutdown if @webrick\n Process.kill('INT', @pid) if @pid\n end",
"def shutdown\n reset\n @agent.shutdown\n end",
"def shutdown\n @running = false\n \n super\n \n end",
"def shutdown\n @plugin_config.stop_plugins\n @plugin_config.unload_plugins\n @bus[\"/system/state/all_plugins_loaded\"].data = false;\n @bus[\"/log/info\"] << \"--- Shutting down #{@properties['config/product_name']} on #{Time.now.to_s}\"\n @core_thread.wakeup if @core_thread.stop?\n end",
"def close #:nodoc:\n @server.shutdown\n end",
"def shutdown\n @manager.shutdown_subscriber(self)\n end",
"def stop\n if running?\n @acceptor.raise(StopServer.new)\n @handlers = Array.new(@handlers)\n @options = Hash.new(@options)\n sleep(0.5) while @acceptor.alive?\n end\n end",
"def shutdown\n @shutdown = true\n exit if @sleeping\n end",
"def shutdown\n @done = true\n begin\n @node.wakeup\n rescue\n # best effort\n end\n @monitor_thread.join\n rescue => ex\n logger.warn(\"Failed to gracefully shutdown watcher for #{@node}\")\n end",
"def stop\n @logger.warn(\"stopping\")\n EM::stop_server(@http_server)\n @redis.close if @redis\n @transport.close if @transport\n super\n end",
"def cleanup\n super\n if(service)\n stop_service()\n print_status(\"Server stopped.\")\n end\n end",
"def shutdown_after(timeout); end",
"def stop\n\t\tsuper\n\n\t\tself.socket.shutdown( :WR )\n\tend"
] | [
"0.79765886",
"0.7400563",
"0.7303974",
"0.7200122",
"0.6892235",
"0.6854887",
"0.6834558",
"0.6832956",
"0.6822465",
"0.6822465",
"0.6822465",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6795474",
"0.67950827",
"0.6772762",
"0.67606026",
"0.67606026",
"0.67606026",
"0.67606026",
"0.67601347",
"0.6755972",
"0.67512184",
"0.67325115",
"0.67256004",
"0.67124945",
"0.6676477",
"0.66614133",
"0.66545653",
"0.66533995",
"0.6637214",
"0.6631791",
"0.6629962",
"0.66292304",
"0.66146183",
"0.66131747",
"0.6612571",
"0.66119605",
"0.6596145",
"0.6585999",
"0.65784264",
"0.6562611",
"0.65429413",
"0.6534363",
"0.65296847",
"0.65257645",
"0.65233284",
"0.6519177",
"0.6514315",
"0.6505075",
"0.6503742",
"0.64738923",
"0.64731485",
"0.64623594",
"0.6461001",
"0.64578074",
"0.6450731",
"0.6450731",
"0.6445093",
"0.6443128",
"0.64328784",
"0.6430041",
"0.6420986",
"0.6416064",
"0.6414451",
"0.6401721",
"0.6398924",
"0.6393617",
"0.63869077",
"0.6384329",
"0.6381568",
"0.63722366",
"0.63705933",
"0.636655",
"0.6357102",
"0.6345273",
"0.6341317",
"0.6335855",
"0.63333327",
"0.63153195",
"0.62995046",
"0.6293107",
"0.62930924",
"0.62877154",
"0.62811524",
"0.6280075",
"0.6275817",
"0.627428",
"0.6254008",
"0.6250899",
"0.62495834",
"0.62442106",
"0.6239957",
"0.62256795",
"0.62113416"
] | 0.7993101 | 0 |
Start a thread that will periodically ping connected sockets and remove any connections that don't reply | def start_heartbeat
self.log.info "Starting heartbeat timer."
@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do
self.cull_idle_sockets
self.ping_all_sockets
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _start_updates\n\n t = Thread.new do\n packet_manager = PacketManager.instance\n loop do\n # update pacekts\n list_updated = packet_manager.update_streams\n # send\n @clients.each_index do |i|\n c = @clients[i]\n list_updated.each do |p|\n begin\n send_stream(c, p)\n rescue => e\n @clients[i] = nil # to be removed\n PadoaukLog.info \"terminated connection from #{c.peeraddr.to_s}\", self\n c.close\n break # break list_updated.each\n end\n end\n end\n @clients.delete_if { |e| e == nil }\n\n Thread.stop\n end\n end\n\n add_task(t)\n\n end",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def ping_nodes\n\t\twhile true\n\t\t\tsleep(rand(60))\n\t\t\tn = rand(@neighbour_nodes.count)\n\t\t\tnode = @neighbour_nodes[n]\n\t\t\ts = UDPSocket.new\n\t\t\tbegin\n\t\t\t\tTimeout::timeout(10){ \n\t\t\t\t\tputs \"Pinging #{node}\"\n\t\t\t\t\tsend_message [\"PING\", @info], 0, node.host, node.port\n\t\t\t\t\t@waiting = true\n\t\t\t\t\twhile waiting?\n\t\t\t\t\t\tsleep(0.2)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue Timeout::Error => ex\n\t\t\t\tif waiting?\n\t\t\t\t\tputs \"Conenction to #{node} timed out, sending DROP_NODE to all remaining nodes\"\n\t\t\t\t\t@neighbour_nodes - [node]\n\t\t\t\t\t@neighbour_nodes.each do |n|\n\t\t\t\t\t\tsend_message [\"DROP_NODE\", node], 0, n.host, n.port\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Socket::Error => ex\n\t\t\t\tputs \"Connection to #{node} failed, trying again in 60 seconds\"\n\t\t\trescue => ex\n\t\t\t\tputs ex.message\n\t\t\tend\n\t\tend\n\tend",
"def send_ping\n @connections.each do |socket|\n begin\n socket << \":\\n\"\n rescue Reel::SocketError\n @connections.delete(socket)\n end\n end\n end",
"def killall\n begin\n\t @connections.each do |k,v| \n\t v[:thread].exit! unless v[:thread].nil?\n\t v.shutdown!\n\t end\n rescue Exception\n end\n initialize\n end",
"def start_server\n @watchman = Thread.new {\n while !@stopped\n @pool_mutex.synchronize\n socket = @server.accept\n @pool << Thread.new(socket) {|socket|\n serve(socket)\n }\n end \n }\n end",
"def ping_all_sockets\n\t\treturn if self.connections.empty?\n\n\t\tself.log.debug \"Pinging %d connected sockets.\" % [ self.connections.length ]\n\t\tself.connections.each do |sender_id, conn_ids|\n\t\t\tframe = Mongrel2::WebSocket::Frame.new( sender_id, conn_id, '', {}, 'heartbeat' )\n\t\t\tframe.opcode = :ping\n\t\t\tframe.fin = true\n\n\t\t\tself.log.debug \" %s/%d: PING\" % [ sender_id, conn_id ]\n\t\t\tself.conn.reply( frame )\n\t\tend\n\n\t\tself.log.debug \" done with pings.\"\n\tend",
"def reap\n stale_connections = synchronize do\n @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n end\n\n stale_connections.each do |conn|\n synchronize do\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end\n end",
"def run\n\t\n\t\twhile true \t\t\t\t\t\t# run forever\n\t\t\n\t\t\tready2read = sockets_ready_for_reading()\n\t\t\t\n\t\t\tnext if not ready2read \t\t\t# if nil, loop again\n\t\n\t\t\tputs \"<Debug> ready2read=#{ready2read.inspect}\" if $DEBUG\n\n\t\t\tready2read.each do |socket|\t\t\n\t\t\t\n\t\t\t\tif socket == @server_socket then\t# we have a new client\n\n\t\t\t\t\taccept_new_connection\n\n\t\t\t\telse \t\t\t\t\t\t\t# a client has a message\n\n\t\t\t\t\tconn = get_connection_by_socket(socket)\n\n\t\t\t\t\tif socket.eof? then \t# the socket was closed\n\n\t\t\t\t\t\tmessage = sprintf(\"190 %s@%s:%s now disconnected\\n\", \n\t\t\t\t\t\t\tconn.username, conn.host, conn.port)\n\t\t\t\t\t\tlog_message(message)\n\t\t\t\t\t\tbroadcast_message(message, conn)\n\t\t\t\t\t\tsocket.close\n\t\t\t\t\t\t@connection_array.delete(conn)\n\t\t\t\t\t\tlog_socket_info\n\n\t\t\t\t\telse\t\t\t\t\t# we have a message to process\n\t\t\t\t\t\n\t\t\t\t\t\tmessage = socket.gets.chomp!\n\t\t\t\t\t\tlog_string = sprintf(\"<log>:Message From: %s@%s:%s %s\", \n\t\t\t\t\t\t conn.username, conn.host, conn.port, message.inspect)\n\t\t\t\t\t\tlog_message(log_string)\n\t\t\t\t\t\tprocess_message(message, conn)\n\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\tend",
"def _reconn_prep()\n close_socket()\n if @parameters\n change_host()\n end\n @st.kill if @st # Kill ticker thread if any\n @rt.kill if @rt # Kill ticker thread if any\n @socket = nil\n end",
"def discovery_thread_runner\n while running?\n tags = ImapDaemonHeartbeat.where(\"updated_at >= ?\", 30.seconds.ago).map(&:tag)\n Log.info(\"There are #{tags.count} daemons running.\")\n\n self.server_rhash.site_tags = tags\n\n if server_rhash.size == 0\n light_sleep 1\n else\n light_sleep 10\n end\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping discovery thread.\")\n end",
"def irc_loop\n while true\n until @irc.dead_socket\n sleep 15\n @irc.handle(:irc_loop)\n Thread.pass\n end\n\n # Disconnected? Wait a little while and start up again.\n @nextserver = (@nextserver+1) % @servers.length\n sleep 30\n @irc.stop_listening\n self.connect_socket\n start_listening\n end\n end",
"def reap\n stale_connections = @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n\n stale_connections.each do |conn|\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end",
"def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end",
"def run\n while true\n begin\n res = select( @descriptors, nil, nil)\n if res != nil \n for sock in res[0]\n if sock == @serverSocket \n accept_new_connection\n elsif sock.eof? \n sock.close\n @user_info.delete(@user_info[@descriptors.index(sock)-1])\n @descriptors.delete(sock)\n else\n msg = sock.gets()\n puts msg\n user_info = @user_info[@descriptors.index(sock)-1]\n if (msg =~ /user_info:|source_info:|admin_info:/) and user_info.nil? \n eval_first_msg(msg,sock) \n elsif (msg =~ /user_info:|source_info:|admin_info:/) and !(user_info.nil?)\n sock.write(\"You are registered #{user_info[:nickname]}, do not try to deceive me\\n\")\n else\n response_request(msg,sock)\n end\n end\n end\n end\n rescue => e\n puts \"Somenthing wrong happened #{e}\"\n end\n end\n end",
"def cleanup \n # close the sockets \n @servers.each{ |server| server[:listner].stop }\n @monitor.close\n end",
"def ping(cmd)\n\tdst = cmd[0]\n next_hop = $next[dst]\n if next_hop == \"NA\" || next_hop == $hostname\n STDOUT.puts \"PING ERROR: HOST UNREACHABLE\"\n return\n end\n n = cmd[1].to_i\n delay = cmd[2].to_i\n client = $clients[next_hop]\n\n # This will iterate through the number of pings given on the command line. It will setup the \n # proper message for pingCallBack and adds the current time to the ping table with the key\n # of the sequence number. It will then check if ping_table has that key still (should be removed\n # by pingCallBack) so if it still exists, then the host was not reached.\n for seq_id in (0..(n - 1))\n msg = Msg.new\n msg.setConfig(\"type\", 3)\n msg.setConfig(\"code\", 0)\n msg.setMessage($hostname + \" \" + dst + \" \" + seq_id.to_s)\n $ping_table[seq_id.to_s] = $currtime\n sendMessage(client, msg)\n Thread.new {\n seq_id_ = seq_id\n sleep($ping_timeout)\n if $ping_table.has_key?(seq_id_.to_s)\n STDOUT.puts \"PING ERROR: HOST UNREACHABLE\"\n end\n $ping_table.delete(seq_id_.to_s)\n }\n sleep(delay)\n end\nend",
"def start_keepalive_thread\n @keepalive.kill if @keepalive.is_a?(Thread)\n @keepalive = Thread.new do\n loop do\n sleep 10\n @ssh.send_global_request('keepalive@openssh.com')\n end\n end\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def run\n loop do\n memcached = Memcached.new # each client has its oun cache storage\n new_client = @tcp_Server.accept # when a new client connects to the server\n client_handler_id = rand(999999).to_s\n client_handler = ClientHandler.new(id: client_handler_id, clientSocket: new_client, memcached: memcached)\n @@clients << client_handler\n\n Thread.start(client_handler) do |handler| # open a new thread for each accepted connection\n # Here we inform the client of the connections. It's human made, so can be removed if not needed\n puts \"New connection established! Now #{@@clients.length()} clients :>\"\n puts \"WAITING FOR REQUESTS\"\n handler.send(\"Server: Connection established with Client Handler ID: #{client_handler_id}\")\n handler.send(\"Server: You are the client ##{@@clients.length()}\")\n handler.send(\"Server: You may introduce commands now\")\n listen_requests(handler) # allow communication\n end\n end.join\n end",
"def discover_repeatedly(opts = {})\n @discovery_thread = Thread.new do\n\n @discovery = Discovery.new(opts[:nsqlookupds])\n\n loop do\n begin\n nsqds = nsqds_from_lookupd(opts[:topic])\n drop_and_add_connections(nsqds)\n rescue DiscoveryException\n # We can't connect to any nsqlookupds. That's okay, we'll just\n # leave our current nsqd connections alone and try again later.\n warn 'Could not connect to any nsqlookupd instances in discovery loop'\n end\n sleep opts[:interval]\n end\n\n end\n\n @discovery_thread.abort_on_exception = true\n end",
"def run\n trap_signals\n loop do\n break if signals_want_shutdown\n begin\n # IO.select returns either a triplet of lists with IO objects that\n # need attention or nil on timeout of 2 seconds.\n if needy = IO.select([server.socket, lifeline], nil, [server.socket, lifeline], 2)\n server.log.debug(\"Detected activity on: #{needy.inspect}\")\n # If the lifeline is active the server went down and we need to go\n # down as well.\n break if needy.flatten.any? { |io| !io.respond_to?(:accept_nonblock) }\n # Otherwise we handle incoming requests\n needy.flatten.each do |io|\n if io.respond_to?(:accept_nonblock)\n begin\n process_incoming_socket(*io.accept_nonblock)\n rescue Errno::EAGAIN, Errno::ECONNABORTED\n end\n end\n end\n end\n rescue EOFError, Errno::EAGAIN, Errno::EINTR, Errno::EBADF, IOError\n end\n end\n cleanup\n end",
"def enqueue_from_server\n @writter = Thread.new do \n while @online\n begin\n if @socket.eof?\n @socket.close\n puts \"Server is down, please press quit\"\n break\n end\n msg = @socket.gets.chop\n if msg =~ /Advice from channel/ \n @advices << msg\n else\n msg = \"=> #{msg}\"\n @response << msg\n end\n rescue => e\n puts \"Error writter Thread #{e}\"\n end\n end\n end\n end",
"def autoping\n @servers.each do |server|\n if server.last_saw_traffic_at + 300 < Time.now\n server.write(\"PING #{server.hostname}\")\n \n # Artificially set the last_saw_traffic_at value to now so that we don't flood the server\n server.last_saw_traffic_at = Time.now\n end\n end\n end",
"def discover_server_periodically\n @disconnected_connections.each do |key,connection|\n connection.establish_connection\n if connection.connection_status\n @backend_connections << connection\n connection.close_connection\n @disconnected_connections[key] = nil\n end\n end\n @disconnected_connections.delete_if { |key,value| value.nil? }\n @round_robin = (0...@backend_connections.length).to_a\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@replicaServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n client.close\n end\n end\n end",
"def turn_on\n connections.each(&:disconnect)\n @connections = []\n end",
"def ensure_connected! \n if @ssh_options[:timeout]\n total_timeout = @ssh_options[:timeout] * 2\n else\n total_timeout = 30\n end\n # puts \"Total timeout: #{total_timeout}\"\n @connections=[]\n hosts_to_connect = @hosts.inject(0) {|sum,h| sum += (h.connect_failed ? 0:1)}\n # puts \"#{hosts_to_connect} to connect\"\n @hosts.each do |host|\n if @connection_cache[host.name] || host.connected\n @connection_mutex.synchronize { @connections << {:connection=>@connection_cache[host.name], :host=>host} }\n host.connected=true\n elsif !host.connect_failed\n Thread.new {\n begin\n #puts \"Connecting #{host.name}\" \n c = Net::SSH.start(host.name, @user_name, @ssh_options)\n @connection_cache[host.name] = c\n @connection_mutex.synchronize { @connections << {:connection=>c, :host=>host} }\n host.connected=true\n #puts \"Connected #{host.name}\" \n rescue Exception => e\n host.connect_failed = true\n host.connected=false\n error \"Unable to connect to #{host.name}\\n#{e.message}\"\n @connection_mutex.synchronize {@connections << {:connection=>nil, :host=>host} }\n host.exception=e\n end \n }\n end\n end\n s = Time.now\n loop do\n l=0\n @connection_mutex.synchronize { l = @connections.length }\n break if l == hosts_to_connect\n sleep(0.1)\n if Time.now - s > total_timeout\n puts \"Warning -- total connection time expired\"\n puts \"Failed to connect:\"\n hosts.each do |h|\n unless h.connected\n puts \" #{h.name}\" \n h.connect_failed=true\n # TODO: Need to handle this situations much better. Attempt to kill thread and/or mark connection in cache as unreachable\n end\n end\n break\n end\n end \n end",
"def run\n Thread.new {\n loop do\n @server.update(1000)\n break if @terminate\n end\n }\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@fileServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n puts 'Thread pool full wait 5'\n sleep 5 \n client.close\n end\n end\n end",
"def run\n loop do\n if @workQ.size < (@pool_size-1)\n Thread.start(@directoryServer.accept) do | proxy |\n @workQ.push 1\n proxy_handler(proxy)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n proxy.close\n end\n end\n end",
"def check_idle_servers!\n\t\tmust_not_be_in_synchronize_block\n\t\t@lock.synchronize do\n\t\t\t@next_cleaning_time = Time.now - 60 * 60\n\t\t\t@cond.signal\n\t\tend\n\tend",
"def run_socket_thread\n @thread ||= Thread.new { run_socket_loop }\n end",
"def event_epoch()\n # Flush out idle clients, if any\n @clients.each do |_,client|\n if Time.now - client.var[:last_ping] > 300\n client.socket.close\n client = @clients.delete(client.socket)\n dispatch :connection_reset, client, \"ping timeout\"\n end\n end\nend",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def stop_polling!\n @pool.each { |_, t| Thread.kill(t) }\n @pool = {}\n end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n end\n\n @connections.delete_if(&:finished?)\n\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def run\n loop do\n # Wait for a client to connect and then create a thread for it\n Thread.new(@server.accept) do |client_socket|\n logger.info \"Accepted client: #{client_socket.peeraddr.join(':')}\"\n server_socket = TCPSocket.new(@server_host, @server_port)\n begin\n process_packets(client_socket, server_socket)\n rescue Exception => exp\n logger.error exp.to_s\n end\n logger.info \"Disconnected: #{client_socket.peeraddr.join(':')}\"\n server_socket.close\n client_socket.close\n end\n end\n end",
"def loop_forever\n running = true\n\n while wait_for_connection\n @logger.info(\"New client connected\")\n command, *arguments = next_message.split\n @logger.debug \"#{command} received\"\n response = case command\n when /^track$/i then track(arguments.first)\n when /^list$/i then list\n when /^release$/i then release(arguments.first)\n end\n\n write(response) unless response.nil?\n end\n rescue => e\n @logger.error(\"An error occurred when waiting for new connections!\\n\\t#{e.inspect}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\")\n end",
"def resurrect_dead_connections!\n connections.dead.each { |c| c.resurrect! }\n end",
"def cleaner_thread()\n return if HotConfig::TEST_MODE\n \n @log.info 'Started cleaner thread'\n\n Thread.new {\n begin\n loop do\n #@log.info 'Cleaner cleaning'\n #find all timed out\n timed_out = @data.records.find_all { |r| r.time.isover? }\n\n #remove them\n timed_out.each { |r| \n if r.state.active?\n @tables.remove(r.mac)\n r.state = HotState::PENDING\n reset_pending(r)\n \n @log.info \"Reset #{r} to PENDING\"\n else \n @data.records.delete(r)\n \n @log.info \"Cleaned #{r}\" \n end\n }\n \n save_data() if timed_out.length > 0 \n \n @log.info 'Cleaner done'\n sleep(CLEAN_INTERVAL)\n end\n catch \n @log.error \"Exception in cleaner thread: #{$!}\"\n end\n }\n end",
"def cleanup_handler\n\t\t# Kill any remaining handle_connection threads that might\n\t\t# be hanging around\n\t\tconn_threads.each { |thr|\n\t\t\tthr.kill\n\t\t}\n\tend",
"def cull_idle_sockets\n\t\tself.log.debug \"Culling idle sockets.\"\n\n\t\tearliest = Time.now - self.class.idle_timeout\n\n\t\tself.connection_times.each do |sender_id, times|\n\t\t\ttimes.each do |conn_id, lastframe|\n\t\t\t\tnext unless earliest > lastframe\n\n\t\t\t\tself.log.warn \"Timing out connection %s:%d: last seen %0.3fs ago.\" %\n\t\t\t\t\t[ sender_id, conn_id, Time.now - lastframe ]\n\n\t\t\t\t# Make a CLOSE frame\n\t\t\t\tframe = Mongrel2::WebSocket::Frame.close\n\t\t\t\tframe.set_status( CLOSE_EXCEPTION )\n\n\t\t\t\t# Use the connection directly so we can send a frame and close the\n\t\t\t\t# connection\n\t\t\t\tself.conn.send( sender_id, conn_id, frame.to_s )\n\t\t\t\tself.conn.send_close( sender_id, conn_id )\n\t\t\tend\n\t\tend\n\tend",
"def cleanup_handler\n stop_handler\n\n # Kill any remaining handle_connection threads that might\n # be hanging around\n conn_threads.each do |thr|\n begin\n thr.kill\n rescue\n nil\n end\n end\n end",
"def run\n loop {\n # Thread.start -> takes arguments that it yields to block for creating thread\n # # server#accept -> returns a new Socket object and Addrinfo object\n Thread.start(@server.accept) do |client| # each client thread\n nick_name = client.gets.chomp.to_sym\n # check if client connectiont already exists\n @connections[:clients].each do |other_name, other_client|\n if nick_name == other_name || client == other_client\n puts \"This username already exists\"\n Thread.kill self\n end\n end\n puts \"#{nick_name} #{client}\"\n @connections[:clients][nick_name] = client\n client.puts \"Connection established, Thank you for joining! Happy Chatting\"\n # listen for client messages\n listen_for_user_messages(nick_name, client)\n end\n }\n end",
"def cleanup_handler\n stop_handler\n\n # Kill any remaining handle_connection threads that might\n # be hanging around\n conn_threads.each { |thr|\n thr.kill rescue nil\n }\n end",
"def disconnect(opts=OPTS)\n while conn = @queue.pop(timeout: 0)\n disconnect_connection(conn)\n end\n fill_queue\n nil\n end",
"def start_listening\n\t\t@socket = UDPSocket.new\n\t\t@socket.bind(@info.host, @info.port)\n\t\twhile true\n\t\t\ttext, sender = @socket.recvfrom(1024)\n\n\t\t\t\targuments = Marshal.load(text)\n\t\t\t\tmsg_type = arguments.shift\n\t\t\t\t\n\t\t\t\tputs \"Received msg: #{msg_type}, #{arguments} from remote #{sender}\"\n\n\t\t\t\tif msg_type == \"GET\"\n\t\t\t\t\tkey, port = arguments\n\t\t\t\t\tget(key.to_i, sender[3], port)\n\t\t\t\telsif msg_type == \"PUT\"\n\t\t\t\t\tkey, value = arguments\n\t\t\t\t\tput(key.to_i, value)\n\t\t\t\telsif msg_type == \"PING\"\n\t\t\t\t\tnode = arguments.first\n\t\t\t\t\tsend_message [\"OK\"], 0, node.host, node.port\n\t\t\t\telsif msg_type == \"OK\"\n\t\t\t\t\t@waiting = false\n\t\t\t\telsif msg_type == \"NEW_NODE\"\n\t\t\t\t\tnew_node_info = arguments.first\n\t\t\t\t\tnew_network_node(new_node_info)\n\t\t\t\telsif msg_type == \"ADD_NODE\"\n\t\t\t\t\tinfo = arguments.first\n\t\t\t\t\t@neighbour_nodes << info\n\t\t\t\telsif msg_type == \"DROP_NODE\"\n\t\t\t\t\tinfo = arguments\n\t\t\t\t\tto_delete = @neighbour_nodes.select { |n| n.host == info.host and n.port == info.port}\n\t\t\t\t\t@neighbour_nodes - to_delete\n\t\t\t\telsif msg_type == \"RESOURCE_TABLE\"\n\t\t\t\t\t@resource_table = arguments.first\n\t\t\t\telsif msg_type == \"ADD_RESOURCE\"\n\t\t\t\t\tresource = arguments.first\n\t\t\t\t\t@resource_table.merge!(resource)\n\t\t\t\t\tputs \"#{resource.to_a}\"\n\t\t\t\t\tputs \"#{request_queue}\"\n\t\t\t\t\tresolve_queue(resource.to_a[0][0])\n\t\t\t\tend \n\t\tend\n\tend",
"def ping\n every(5) do\n send_ping\n end\n end",
"def cycle\n @initialized = true\n @socket = UDPSocket.new\n @socket.bind(@listen_address, @listen_port)\n \n initial_counters = {}\n \n if @counters_list_file && File.exist?(@counters_list_file)\n counter_keys = IO.read(@counters_list_file).split(\"\\n\")\n counter_keys.each do |key|\n initial_counters[key] = 0\n end\n end\n \n # block will be called when a request comes from the core\n # if exit is received the method will return\n network_loop(pipe, @socket, initial_counters) do |msg, counters, gauges|\n data = {}\n \n values = gauges\n \n counters.each do |k, v|\n values[k] = v / interval_in_seconds()\n end\n \n unless values.empty?\n if @host\n data['host'] = @host\n end\n \n data[@app] = {}\n data[@app][@res] = values\n end\n \n send_metrics(data)\n end\n \n end",
"def run!\n start_server!\n @server_thread = Thread.new do\n loop do\n Thread.start(@server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error \"#{e.class}: #{e.message}\"\n @logger.debug e.backtrace\n ensure\n closing_client = @client_mutex.synchronize do\n @clients.delete(socket)\n end\n # invoke callbacks for disconnect if there is a client to\n # disconnect\n emit(:client_disconnect, closing_client) if closing_client\n socket.close\n end\n end\n end\n end\n end",
"def disconnect\n @thread.kill\n @socket.close\n end",
"def disconnect!\n @reserved_connections.each do |name,conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect!\n end\n @connections = []\n end",
"def heartbeat_thread_runner\n heartbeat = ImapDaemonHeartbeat.create(:tag => server_tag)\n while running?\n # Update the heartbeat.\n heartbeat.touch\n\n # Log Heroku / Librato stats.\n Log.librato(:measure, 'imap_client.thread.count', Thread.list.count)\n Log.librato(:measure, 'imap_client.work_queue.length', work_queue_length)\n Log.librato(:measure, 'imap_client.user_thread.count', user_threads_count)\n Log.librato(:measure, 'work_queue.latency', work_queue_latency)\n Log.librato(:sample, 'imap_client.total_emails_processed', total_emails_processed)\n\n light_sleep 10\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping heartbeat thread.\")\n heartbeat.delete if heartbeat\n end",
"def start\n raise 'Smtpd instance was already started' unless stopped?\n @shutdown = false\n @@servicesMutex.synchronize do\n if Smtpd.in_service?(@port, @host)\n raise \"Port already in use: #{host}:#{@port}!\"\n end\n @tcpServer = TCPServer.new(@host, @port)\n @port = @tcpServer.addr[1]\n @@services[@host] = {} unless @@services.key?(@host)\n @@services[@host][@port] = self\n end\n @tcpServerThread = Thread.new do\n begin\n until @shutdown\n @connectionsMutex.synchronize do\n while @connections.size >= @maxConnections\n @connectionsCV.wait(@connectionsMutex)\n end\n end\n client = @tcpServer.accept\n Thread.new(client) do |myClient|\n @connections << Thread.current\n begin\n serve(myClient)\n rescue => detail\n # log fatal error while handling connection\n logger.fatal(detail.backtrace.join(\"\\n\"))\n ensure\n begin\n # always gracefully shutdown connection\n myClient.close\n rescue\n end\n @connectionsMutex.synchronize do\n @connections.delete(Thread.current)\n @connectionsCV.signal\n end\n end\n end\n end\n rescue => detail\n # log fatal error while starting new thread\n logger.fatal(detail.backtrace.join(\"\\n\"))\n ensure\n begin\n @tcpServer.close\n rescue\n end\n if @shutdown\n @connectionsMutex.synchronize do\n @connectionsCV.wait(@connectionsMutex) until @connections.empty?\n end\n else\n @connections.each { |c| c.raise 'stop' }\n end\n @tcpServerThread = nil\n @@servicesMutex.synchronize do\n @@services[@host].delete(@port)\n end\n end\n end\n self\n end",
"def start\n while @mStatus <= 0\n connect\n monitor\n sleep 5\n end\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@fileServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n client.close\n end\n end\n end",
"def graceful_shutdown\n socket_server.close unless socket_server.closed?\n\n until active_connections.zero?\n logger.debug \"#{active_connections} connections still active\"\n sleep 0.5\n end\n\n logger.debug \"No more active connections. Exiting'\"\n\n Process.exit(0)\n end",
"def listen\n Thread.new do\n while (true)\n socket = @server.accept\n puts \"connection from #{socket.peeraddr[2]} port #{socket.peeraddr[1]}\"\n @connections.add(socket.peeraddr[2], socket.peeraddr[1], socket)\n end\n end\n end",
"def connect_supernodes(sns)\n ping_msg = construct_ping\n group = ThreadGroup.new\n sns.each do |sn|\n t = Thread.new(sn) { |sn|\n sock = handshaking(sn)\n if !sock.nil? and ping(sock,ping_msg)\n @lock.synchronize { @socks << sock }\n end\n }\n group.add(t)\n end\n group.list.each { |t| t.join }\n end",
"def main\n #server=TCPServer::new('10.0.0.60',port)\n @server=TCPServer::new(@port)\n $logger.debug \"Running on Port #{@port}\"\n begin\n if defined?(Fcntl::FD_CLOEXEC)\n @server.fcntl(Fcntl::FD_CLOEXEC,1)\n end\n @server.listen(5)\n #@sock=@server.accept_nonblock\n rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR\n IO.select([@server])\n retry\n end\n Analyzer.find(:all).each { |analyzer|\n # If on start if analyzer is in downstream mode and ingress then restart the processl\n if (analyzer.cmd_port.nil?) && ((analyzer.status == Analyzer::INGRESS) || (analyzer.status == Analyzer::DOWNSTREAM))\n port=get_port(analyzer.id)\n $logger.error \"We don't have a port number for #{analyzer.id}, assigning it #{port}\"\n analyzer.update_attributes({:cmd_port=>port})\n elsif (!analyzer.cmd_port.nil?) && ((analyzer.status == Analyzer::INGRESS) || (analyzer.status == Analyzer::DOWNSTREAM))\n @ports_analyzer[analyzer.cmd_port - @start_port]=analyzer.id\n $logger.debug \"Setting cmd port #{analyzer.cmd_port}\"\n end\n #analyzer.update_attributes({:status=>Analyzer::DISCONNECTED})\n }\n an_count=Analyzer.find(:all).size\n try_count=Array.new(an_count,0)\n while(1)\n Analyzer.find(:all).each { |analyzer|\n if (!analyzer.cmd_port.nil?)\n @ports_analyzer[analyzer.cmd_port - @start_port]=analyzer.id\n try_count[analyzer.id]=0 if try_count[analyzer.id].nil?\n $logger.debug \"Setting cmd port #{analyzer.cmd_port}\"\n end\n }\n time=Time.now()\n selected_socket_list=IO.select([@server],nil,nil,5)\n if (selected_socket_list.nil?)\n $logger.debug \"Nothing to send Do a heartbeat\"\n #logger.debugs @ports_analyzer.inspect()\n @ports_analyzer.each_index { |port_index|\n analyzer_id=@ports_analyzer[port_index]\n port=nil\n if !analyzer_id.nil?\n port=get_port(analyzer_id)\n end\n\n unless port.nil?\n try_count[analyzer_id] +=1\n request=Net::HTTP.new('localhost',port)\n $logger.debug \"Do a heartbeat on #{port}\"\n #tries=0\n flag=true\n begin\n #sleep 5\n #tries +=1\n $logger.debug \"TRY # #{try_count[analyzer_id]}\"\n\n response=request.get(\"/\")\n rescue Timeout::Error #Instrument not responding. Lets kill the process.\n flag=false\n anl=Analyzer.find(analyzer_id)\n if (!anl.nil?) && (!anl.pid.nil?) && (anl.pid != 0)\n Process.kill(\"TERM\", anl.pid)\n else\n SystemLog.log(\"Unable to start monitoring process for Analyzer: #{anl.name}\",nil,SystemLog::MESSAGE,analyzer_id)\n anl.update_attribute({:pid=>0})\n end\n rescue\n #sleep 5\n #$logger.debug \"Try again\"\n flag=false\n if (try_count[analyzer_id] > 5)\n try_count[analyzer_id]=0\n $logger.debug \"Restarting monitor for #{analyzer_id}\"\n SystemLog.log(\"(Re)Starting the monitor server #{Analyzer.find(analyzer_id).ip}\",nil,SystemLog::MESSAGE,analyzer_id)\n start_monitor(analyzer_id, port)\n end\n end\n if flag==true\n try_count[analyzer_id]=0\n end\n $logger.debug response.inspect()\n end\n diff=Time.now-time\n if diff < 5\n sleep (5-diff)\n end\n }\n else\n selected_socket=selected_socket_list[0].first()\n @sock=selected_socket.accept\n process()\n end\n end\n end",
"def monitor_socket\n\t\tself.waiters = []\n\n\t\t# Spawn a new thread that monitors the socket\n\t\tself.dispatcher_thread = ::Thread.new {\n\t\t\twhile (true)\n\t\t\t\tbegin\n\t\t\t\t\trv = Rex::ThreadSafe.select([ self.sock.fd ], nil, nil, 2)\n\t\t\t\trescue\n\t\t\t\t\tdlog(\"Exception caught in monitor_socket: #{$!}\", 'meterpreter', LEV_1)\n\t\t\t\tend\n\n\t\t\t\tbegin\n\t\t\t\t\tpacket = receive_packet\n\t\t\t\trescue EOFError\n\t\t\t\t\tbreak\n\t\t\t\tend\n\n\t\t\t\tif (packet)\n\t\t\t\t\tdispatch_inbound_packet(packet)\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\tend",
"def realize_pending_connections! #:nodoc:\n return unless concurrent_connections\n\n server_list.each do |server|\n server.close if !server.busy?(true)\n server.update_session!\n end\n\n @connect_threads.delete_if { |t| !t.alive? }\n\n count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length\n count.times do\n session = @pending_sessions.pop or break\n # Increment the open_connections count here to prevent\n # creation of connection thread again before that is\n # incremented by the thread.\n @session_mutex.synchronize { @open_connections += 1 }\n @connect_threads << Thread.new do\n session.replace_with(next_session(session.server, true))\n end\n end\n end",
"def run\n @thread = Thread.start do\n loop do\n begin\n register unless registered?\n rescue DRb::DRbConnError\n @ring_server = nil\n rescue RuntimeError => e\n raise unless e.message == 'RingNotFound'\n end\n sleep @check_every\n end\n end\n end",
"def observe uris\n while true\n time_init = Time.now.to_i\n uris.each do |uri|\n puts \"Pinging #{uri}...\"\n request :uri=>uri\n end\n time = options.repository.time * 60 - (Time.now.to_i - time_init)\n puts \"Sleeping until #{Time.now + time}...\"\n sleep time\n end\n end",
"def poll_nodes\n # clear any list of nodes we already know about and start fresh\n @nodes.clear\n transmit Packet::Poll.new\n end",
"def reload_connections!\n hosts = sniffer.hosts\n __rebuild_connections :hosts => hosts, :options => options\n self\n rescue SnifferTimeoutError\n logger.error \"[SnifferTimeoutError] Timeout when reloading connections.\" if logger\n self\n end",
"def start\n if @supernode_table.empty?\n # The supernode table is empty, so this node is probably \n # starting and not promoted to supernode mode.\n \n # NOTE The +attempt_fetch_supernodes+ will block if no \n # supernode is found. Since supernodes should still work \n # even there is no other active supernodes, a thread is created\n # here. So it can still accept connections from other ordinary\n # nodes.\n Thread.new do \n # 1. Get supernodes from cache or bootstrap node\n Routing.log {|logger| logger.info(self.class) {'1. Getting SNs ...'}}\n sns = attempt_fetch_supernodes\n # 2. Connect to supernodes\n Routing.log {|logger| logger.info(self.class) {'2. Connecting to SNs ...'}}\n connect_supernodes(sns)\n end\n else\n # It is promoted to supernode mode.\n @supernode_table.supernodes.each do |sn|\n @lock.synchronize { @socks << sn.socket }\n end\n end\n\n # 3. Start the background threads\n @request_supernode_thread = start_request_supernodes_thread\n @compute_hits_thread = start_compute_hits_thread\n\n # 4. Create the server socket and handle incoming messages\n @server = TCPServer.open(@driver.config['listening_port'].to_i)\n @socks << @server\n @running = true\n while @running\n # Wait for messages from other nodes\n ready = select(@socks,nil,nil,@timeout)\n readable = ready[0]\n\n unless readable.nil?\n readable.each do |sock|\n if sock == @server # Accept new client\n client = @server.accept\n accepted = on_handshaking(client)\n if accepted\n @lock.synchronize { @socks << client }\n else\n client.close\n end\n elsif sock.eof? # Socket has disconnected\n Routing.log {|logger| logger.info(self.class) {'Socket has disconnected.'}}\n @lock.synchronize {@socks.delete(sock)}\n # Remove it if it is in supernode table\n @supernode_table.delete(sock.node) if @supernode_table.include?(sn.node)\n sock.close\n else # Message is ready for reading\n msg = @protocol.read_message(sock)\n unless msg.nil?\n @bandwidth_manager.downloaded(msg.bytesize,Time.now-message.ftime.to_time) unless @bandwidth_manager.nil?\n handle_message(msg,sock)\n else\n Routing.log {|logger| logger.error(self.class) {'The message read is nil.'}}\n end\n end\n end\n else # Timeout\n @socks.delete_if do |sock|\n sock.closed? # Discarded by supernode table\n end\n end\n end\n end",
"def run\n connect = false\n until connect do\n begin\n call { |server| @server = server ; start }\n rescue\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end",
"def heartbeat\n until @stop\n @empty.each(&:wakeup)\n @full.each(&:wakeup)\n sleep 0.1\n end\n end",
"def run\n\t\tputs \"Server waiting for conncetions\"\n\t\tloop do\n\t\t\tThread.start(@serverSocket.accept) do |conection|\n\t\t\t\t# Agregamos al cliente a la lista de conectados si este no\n\t\t\t\t# esta en la lista\n\t\t\t\t(@clients << conection) unless @clients.include? conection\n\t\t\t\t# Registramos la conexion por consola\n\t\t\t\tputs \"Conexion #{conection}\"\n\t\t\t\t# Avisamos de la conexion exitosa\n\t\t\t\tconection.puts \"i Conexion establecida\"\n\t\t\t\t# Enviamos la lista de servidores\n\t\t\t\tconection.puts \"m \" << Connections::SERVER_IP.join(\" \") if @master\n\t\t\t\tconection.puts \"s \" << @arry_ips.join(\" \") unless @master\n\t\t\t\t# Escuchamos los mensajes de la conexion\n\t\t\t\tlisten_user(conection)\n\t\t\t\t# Quitamos la conexion\n\t\t\t\t@clients.delete(conection)\n\t\t\t\t# Avisamos en consola de la desconeccion\n\t\t\t\tputs \"Desconexion #{conection}\"\n\t\t\t\t# Cerramos el socket\n\t\t\t\tconection.close\n\t\t\tend\n\t\tend.join\n\tend",
"def event_timer\n if @connection.comm.connected? and Time.now - @var[:last_ping] >= 60\n begin\n _server_control(\"keepalive\")\n rescue\n _notice(\"The connection to the server has been lost\", :global)\n @connection.disconnect\n end\n end\nend",
"def io_loop\n while true\n # if no data is coming in, don't block the socket!\n read_incoming_data if Kernel.select([@socket], nil, nil, 0)\n\n # Check for dead socket\n @dead_socket = true if @socket.eof?\n\n sleep 0.05\n end\n end",
"def cleaner_thread_proc\n while true\n delete_oldies(@diff_time)\n sleep(10)\n end\n end",
"def listen\n\t\t@response = Thread.new do\n\t\t\tloop do\n\t\t\t\t# Revisamos si se cerro la conexion\n\t\t\t\t# @server.eof?\n\t\t\t\t# @request.kill\n\t\t\t\t# @server.close\n\t\t\t\t# puts \"Reconectando...\"\n\t\t\t\t# reconect\n\t\t\t\t# Optenemos el mensaje del servidor\n\t\t\t\tmessage = @server.gets.chomp\n\t\t\t\t# Optenemos el tipo\n\t\t\t\tmessage_t = message[0]\n\t\t\t\t# Quitamos los dos primeros caracteres\n\t\t\t\tmessage.slice!(0..1)\n\t\t\t\t# Revisamos si es un mensaje o una nota a reproducir\n\t\t\t\tif message_t == \"i\"\n\t\t\t\t\t# Mostramos el mensaje en consola\n\t\t\t\t\tputs message\n\t\t\t\telsif message_t == \"n\"\n\t\t\t\t\t# Tomamos solo la nota y reproducimos su equivalente\n\t\t\t\t\t# Reproducimos la nota musical\n\t\t\t\t\tputs \"Nota no valida [q-p][a-l]!\" unless RMSound::note_play(message[0])\n\t\t\t\telsif message_t == \"s\"\n\t\t\t\t\t# Resivimos una lista de ips de un esclavo\n\t\t\t\t\t# Actualizamos la lista interna si esta por defecto\n\t\t\t\t\tif @ip_integrity == \"d\"\n\t\t\t\t\t\tputs \"Lista de IPs actualizada\"\n\t\t\t\t\t\t@ip_integrity = \"s\"\n\t\t\t\t\t\t@arry_ips = message.split(' ')\n\t\t\t\t\tend\n\t\t\t\telsif message_t == \"m\"\n\t\t\t\t\t# Resivimos una lista de ips de un maestro\n\t\t\t\t\t# Actualizamos la lista interna si esta por defecto\n\t\t\t\t\tif @ip_integrity != \"m\"\n\t\t\t\t\t\tputs \"Lista de IPs actualizada\"\n\t\t\t\t\t\t@ip_integrity = \"m\"\n\t\t\t\t\t\t@arry_ips = message.split(' ')\n\t\t\t\t\tend\n\t\t\t\telsif message_t == \"r\"\n\t\t\t\t\tputs message\n\t\t\t\telse\n\t\t\t\t\t# Mostramos el mensaje en consola\n\t\t\t\t\tputs \"Desconocido: \" << message\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def close\n parser_thread.kill if parser_thread # why if?\n poll_thread.kill\n socket.close if socket\n\n @status = DISCONNECTED\n end",
"def watchdog_thread\n @thr = Thread.new {\n while(true)\n watcher\n sleep(@interval)\n end\n }\n rescue\n false\n end",
"def pong_everyone\n #log \"trying to pong\"\n if @sockets.length > 0 && !self.stopped?\n #log \"ponging\"\n broadcast_message(nil, \"PONG\", [build_handle_list])\n #sleep 5\n clean_handles\n end\n end",
"def start_request_supernodes_thread\n Thread.new do \n # read the request interval\n interval = @driver.config['request_interval'].to_i\n # number of supernodes each time\n number = @driver.config['request_number'].to_i\n \n while true\n sleep(interval)\n # get supernodes sockets from supernode table\n socks = @supernode_table.supernodes\n # Sends +RequestSupernodes+ message. Because the number of socks is not\n # so large, and it doesn't wait for the response after sending, it sends\n # messages one by one here instead of using multiple threads.\n request_msg = Protocol::RequestSupernodes.new(number)\n request_msg.ctime = DateTime.now\n socks.each do |sock|\n request_supernodes(sock,request_msg)\n end\n end\n end\n end",
"def clear\n\t\tmust_be_in_synchronize_block\n\t\t@collection.each_value do |server|\n\t\t\tif server.started?\n\t\t\t\tserver.stop\n\t\t\tend\n\t\tend\n\t\t@collection.clear\n\t\t@next_cleaning_time = nil\n\tend",
"def discover\n @socket ||= new_socket\n\n listen\n\n if block_given? then\n loop do\n notification = @queue.pop\n\n yield notification\n end\n else\n sleep @timeout\n\n notifications = []\n notifications << @queue.pop until @queue.empty?\n notifications\n end\n ensure\n stop_listening\n @socket.close if @socket and not @socket.closed?\n @socket = nil\n end",
"def tcp_listener(output_queue)\n @logger.info(\"Starting syslog tcp listener\", :address => \"#{@host}:#{@port}\")\n @tcp = TCPServer.new(@host, @port)\n @tcp.do_not_reverse_lookup = true\n\n while !stop?\n socket = @tcp.accept\n @tcp_sockets << socket\n metric.increment(:connections)\n\n Thread.new(output_queue, socket) do |output_queue, socket|\n tcp_receiver(output_queue, socket)\n end\n end\n ensure\n close_tcp\n end",
"def run\n loop { sleep 5 while @feeds.alive? }\n end",
"def run servers\n\t\tservers.each do |server|\n\n\t\t\t@clientCount += 1\n\n\t\t\tclient = Kesh::Mumble::MumbleClient.new( server[:host], server[:port], server[:nick], @options )\n\t\t\t@connections[ client ] = server\n\n\t\t\tclient.register_handler :ServerSync, method( :on_connected )\n\t\t\tclient.register_handler :UserState, method( :on_user_state )\n\t\t\tclient.register_handler :UserRemove, method( :on_user_remove )\n\t\t\t# client.register_handler :UDPTunnel, method( :on_audio )\n\n\t\t\tclient.register_text_handler '!help', method( :cmd_help )\n\t\t\tclient.register_text_handler '!find', method( :cmd_find )\n\t\t\tclient.register_text_handler '!goto', method( :cmd_goto )\n\t\t\tclient.register_text_handler '!test', method( :cmd_test )\n\t\t\tclient.register_text_handler '!info', method( :cmd_info )\n\t\t\tclient.register_text_handler '!admin', method( :cmd_admin )\n\t\t\tclient.register_text_handler '!mute', method( :cmd_mute )\n\t\t\tclient.register_text_handler '!result', method( :cmd_result )\n\t\t\tclient.register_text_handler '!list', method( :cmd_list )\n\n\t\t\tclient.register_exception_handler method( :on_exception )\n\n\t\t\tload_roles_ini client\n\n\t\t\tcreate_new_match( client )\n\n\t\t\tclient.connect\n\n\t\t\tcreate_comment( client )\n\n\t\tend\n\n\t\t# Main loop\n\t\tuntil @shutdown do\n\n\t\t\tif ( Time.now - @lastCleanUp ) > 60 * 60\n\t\t\t\tremove_old_matches\n\t\t\t\t@lastCleanUp = Time.now\n\t\t\tend\n\n\n\t\t\tif ( Time.now - @lastTrack ) > 60 * 5\n\t\t\t\ttrack_matches\n\t\t\t\t@lastTrack = Time.now\n\t\t\tend\n\n\t\t\treturn true unless all_connected? # TODO: This is a very ugly way to reset all connections\n\n\t\t\tsleep 0.2\n\n\t\tend\n\n\t\treturn @restart\n\n\tend",
"def flush\n @sockets.each {|s| s.flush }\n end",
"def start_monitoring_connection\n @connection_monitor_thread ||= Thread.new{monitor_connection}\n @connection_monitor_thread.abort_on_exception = true\n end",
"def start\n loop do\n now = Time.now\n msg = \"%02d:%02d:%02d\" % [now.hour, now.min, now.sec]\n @mutex.synchronize {\n\t@clients.each { |c|\n # If the connection is closed while writing this could occur. Just\n # the nature of async systems.\n puts \"--- write failed\" unless c.write(msg)\n\t}\n }\n sleep(1)\n end\n end",
"def delete_polling_thread(key)\n Thread.kill(@pool[key]) if threads_key?(key)\n @pool.delete(key)\n end",
"def start\n Thread.new(interval, pool) do |i, p|\n while (true)\n sleep(i)\n p.reap\n end\n end\n end",
"def delete_polling_thread(key); end",
"def run_internal\n monitors = @monitors\n selector = @selector\n\n while true\n begin\n ready = selector.select @sleep_for\n rescue IOError => e\n Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue\n if monitors.any? { |mon| mon.value.closed? }\n STDERR.puts \"Error in select: #{e.message} (#{e.class})\"\n STDERR.puts e.backtrace\n\n monitors.reject! do |mon|\n if mon.value.closed?\n selector.deregister mon.value\n true\n end\n end\n\n retry\n else\n raise\n end\n end\n\n if ready\n ready.each do |mon|\n if mon.value == @ready\n @mutex.synchronize do\n case @ready.read(1)\n when \"*\"\n @input.each do |c|\n mon = nil\n begin\n begin\n mon = selector.register(c, :r)\n rescue ArgumentError\n # There is a bug where we seem to be registering an already registered\n # client. This code deals with this situation but I wish we didn't have to.\n monitors.delete_if { |submon| submon.value.to_io == c.to_io }\n selector.deregister(c)\n mon = selector.register(c, :r)\n end\n rescue IOError\n # Means that the io is closed, so we should ignore this request\n # entirely\n else\n mon.value = c\n @timeouts << mon if c.timeout_at\n monitors << mon\n end\n end\n @input.clear\n\n @timeouts.sort! { |a,b| a.value.timeout_at <=> b.value.timeout_at }\n calculate_sleep\n when \"c\"\n monitors.reject! do |submon|\n if submon.value == @ready\n false\n else\n submon.value.close\n begin\n selector.deregister submon.value\n rescue IOError\n # nio4r on jruby seems to throw an IOError here if the IO is closed, so\n # we need to swallow it.\n end\n true\n end\n end\n when \"!\"\n return\n end\n end\n else\n c = mon.value\n\n # We have to be sure to remove it from the timeout\n # list or we'll accidentally close the socket when\n # it's in use!\n if c.timeout_at\n @mutex.synchronize do\n @timeouts.delete mon\n end\n end\n\n begin\n if c.try_to_finish\n @app_pool << c\n clear_monitor mon\n end\n\n # Don't report these to the lowlevel_error handler, otherwise\n # will be flooding them with errors when persistent connections\n # are closed.\n rescue ConnectionError\n c.write_error(500)\n c.close\n\n clear_monitor mon\n\n # SSL handshake failure\n rescue MiniSSL::SSLError => e\n @server.lowlevel_error(e, c.env)\n\n ssl_socket = c.io\n begin\n addr = ssl_socket.peeraddr.last\n # EINVAL can happen when browser closes socket w/security exception\n rescue IOError, Errno::EINVAL\n addr = \"<unknown>\"\n end\n\n cert = ssl_socket.peercert\n\n c.close\n clear_monitor mon\n\n @events.ssl_error @server, addr, cert, e\n\n # The client doesn't know HTTP well\n rescue HttpParserError => e\n @server.lowlevel_error(e, c.env)\n\n c.write_error(400)\n c.close\n\n clear_monitor mon\n\n @events.parse_error @server, c.env, e\n rescue StandardError => e\n @server.lowlevel_error(e, c.env)\n\n c.write_error(500)\n c.close\n\n clear_monitor mon\n end\n end\n end\n end\n\n unless @timeouts.empty?\n @mutex.synchronize do\n now = Time.now\n\n while @timeouts.first.value.timeout_at < now\n mon = @timeouts.shift\n c = mon.value\n c.write_error(408) if c.in_data_phase\n c.close\n\n clear_monitor mon\n\n break if @timeouts.empty?\n end\n\n calculate_sleep\n end\n end\n end\n end",
"def shutdown_handler\n self.close unless self.closed?\n @sockets = []\n end",
"def listenLoop()\n x = Thread.new {\n i = 0\n while true\n i = i + 1\n puts \" \"\n print @name, \" Listen Loop Round: \", i\n puts \" \"\n jsonIN = @socket.recv(65536)\n puts \" \"\n print @name, \" \", Time.now, \" has received a Message: \", jsonIN\n puts \" \"\n parsed = JSON.parse(jsonIN)\n if @netWorkMember\n self.respond(parsed)\n else\n puts \"Not a member of a Network, No Response\"\n end\n end\n }\n end",
"def _maybe_reconnect()\r\n\t\tif @request_count >= @reconnect_interval\r\n\t\t\t$LOG.debug(\"Completed #{@request_count} requests using this connection, reconnecting...\")\r\n\t\t\t_close_socket(@connection)\r\n\t\t\t@node_id, @connection = _reconnect()\r\n end\r\n end",
"def send_queue\n worker_threaded do\n while @connected\n @queue_lock.synchronize do\n @queue.each do |to, queue|\n break if @frame.exceeded?\n if reply = queue.pop\n send_socket_reply(reply)\n end\n end\n @queue.select! { |to,queue| !queue.empty? }\n @queue = Hash[@queue.sort_by { |to,queue| queue.penalty }]\n end\n sleep @frame.sleeptime\n end\n end\n end",
"def start_pong_loop\n Thread.new do\n loop do\n sleep 5\n # log \"pong all\"\n pong_everyone\n # log \"pong logsave\"\n save_chat_log\n end\n end\n end",
"def clear_reloadable_connections!\n @reserved_connections.each do |name, conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect! if conn.requires_reloading?\n end\n @connections = []\n end",
"def listenLoop()\n x = Thread.new{\n i = 0\n while true\n i = i + 1\n puts \" \"\n print @name, \" Listen Loop Round: \", i\n puts \" \"\n jsonIN = @s.recv(65536)\n puts \" \"\n print @name, \" \", Time.now, \" has receaved a Message: \", jsonIN\n puts \" \"\n parsed = JSON.parse(jsonIN)\n if @netWorkMember\n self.respond( parsed )\n else\n puts \"Not a member of a Network hence I will not respond\"\n end\n end\n }\n end",
"def another_main_loop\n t = Thread.new do\n while true\n a = @ios.keys\n ret = select(a,[],a,1)\n if ret.nil?\n @sec.each do |k,v|\n v.call\n end\n else\n r,w,e = ret\n\n remove_queue = Array.new\n\n r.each do |x|\n ret = @ios[x].call(x)\n if ret == false\n remove_queue.push(x)\n end\n end\n\n remove_queue.each do |x|\n puts 'removing ' + x.to_s\n @ios.delete(x)\n end\n \n e.each do |x|\n puts 'error: ' + x.to_s\n raise\n end\n end\n end\n end\n return t\n end",
"def routeChecker(target_id)\n Thread.new {\n pingMsg = {:type => \"PING\", :target_id => target_id, :sender_id => @guid, :ip_address => @localInetAddr.ip, \\\n :port => @localInetAddr.port}.to_json\n nh, m, n = nextCheckHop(target_id)\n if nh.ip != nil\n @socket.send pingMsg, 0, nh.ip, nh.port\n t = Time.now.sec\n t2 = t + 10\n @checkAckWait[nh.guid] = 0\n while t < t2\n if @checkAckWait[nh.guid] == 2\n break\n end\n k = Time.now.sec\n if k != t\n t += 1\n end\n end\n end\n removeAddr(nh.guid)\n }\n end"
] | [
"0.6908667",
"0.6601436",
"0.65812236",
"0.6537906",
"0.6459771",
"0.6271921",
"0.62182313",
"0.6136586",
"0.6116255",
"0.6054305",
"0.6037109",
"0.60358876",
"0.60267687",
"0.59418344",
"0.5920807",
"0.5912509",
"0.590164",
"0.5844894",
"0.58414453",
"0.5837747",
"0.5834702",
"0.58066046",
"0.5801521",
"0.57859135",
"0.57635695",
"0.5756329",
"0.57369995",
"0.57266694",
"0.57234156",
"0.5712102",
"0.57054603",
"0.57018346",
"0.5692339",
"0.5671147",
"0.56685233",
"0.56585103",
"0.5647661",
"0.5639957",
"0.56380713",
"0.56369025",
"0.5634462",
"0.5624165",
"0.5623761",
"0.5615729",
"0.56089354",
"0.5606743",
"0.56055164",
"0.5604222",
"0.5602947",
"0.56020015",
"0.559932",
"0.5593675",
"0.55921113",
"0.5590392",
"0.55866414",
"0.5582717",
"0.55774224",
"0.5571052",
"0.556613",
"0.5559749",
"0.55567056",
"0.55486053",
"0.55420136",
"0.55397624",
"0.5539638",
"0.55350757",
"0.5531212",
"0.5526895",
"0.5523913",
"0.5521699",
"0.54941696",
"0.5466878",
"0.54635996",
"0.5459507",
"0.54448295",
"0.54445565",
"0.5442316",
"0.5417205",
"0.5416548",
"0.54164374",
"0.5413047",
"0.5411485",
"0.54090786",
"0.5404086",
"0.5401714",
"0.5399738",
"0.539954",
"0.53964347",
"0.53950036",
"0.53888327",
"0.53608847",
"0.5353163",
"0.53524786",
"0.5348693",
"0.53472316",
"0.53457546",
"0.5336764",
"0.53356534",
"0.5335196",
"0.5334905"
] | 0.5352473 | 93 |
Tell the heartbeat thread to exit. | def stop_heartbeat
self.reactor.remove_timer( @heartbeat_timer )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit\n ExitThread(0)\n end",
"def exit!\n @exiting = true\n @queue.push :__delivery_thread_exit_signal__\n end",
"def exit!\n @exiting = true\n @queue.push :__delivery_thread_exit_signal__\n end",
"def shutdown\n Thread.new do\n log_info 'Worker exiting...'\n end\n Kernel.exit\n end",
"def shutdown\n\t\tself.stop_heartbeat\n\t\tsuper\n\tend",
"def on_kill\n\n # Commit last changes\n commit(true)\n\n # Join to the delete worker and wait wile it is done\n @thr_del_worker.join unless @thr_del_worker.nil?\n\n $log.info(self) {'Shutting down...'}\n\n # Here the thread is almost shut down\n end",
"def end_hegemon_auto_thread\n @_end_hegemon_auto_thread = true\n @_hegemon_auto_thread.join unless @_hegemon_auto_thread==Thread.current\n @_hegemon_auto_thread = nil\n end",
"def shutdown\n log 'Exiting...'\n Thread.list.each { |t| t[:shutdown] = true }\n @shutdown = true\n end",
"def stop_monitor\n @thread&.exit\n end",
"def shutdown\n ensure_threads_running!\n\n @timer_thread && @timer_thread.exit\n @queue << [:shutdown, nil]\n @worker_thread && @worker_thread.join\n\n nil\n end",
"def shutdown\n @shutdown = true\n exit if @sleeping\n end",
"def shutdown\n puts \"shutting down\"\n @run = false\n thread_list.each do |thread|\n thread.raise ExitError\n end\n end",
"def shutdown\n log 'Exiting...'\n @shutdown = true\n end",
"def shutdown\n sleep 0.3\n say coloured('POWERING DOWN MOTORS...', :RED)\n sleep 0.2\n say coloured('FLUSHING DATABANKS...', :RED)\n sleep 0.4\n say coloured('GOOD BYE', :GREEN)\n exit\nend",
"def quit(msg = false)\n thread[:socket].close\n thread[:socket] = nil\n debug \"[DEBUG] User #{thread[:user]} disconnected.\"\n \"221 Laterz\"\n end",
"def shutdown\n shutdown_message\n @threads.each(&:shutdown)\n @_threads_real.each(&:exit)\n end",
"def stop\n Thread.new { log \"Exiting...\" }\n @exit = true\n end",
"def stop\n Thread.new { log \"Exiting...\" }\n @exit = true\n end",
"def stop\n Thread.new { log \"Exiting...\" }\n @exit = true\n end",
"def check_out\n @server[\"/worker\"].put({\n :name => @name,\n :terminated => true\n })\n log 'exiting'\n end",
"def terminate\n @thread.terminate if @thread\n end",
"def shutdown\n shutdown_message\n @actions.each(&:shutdown)\n @threads.each(&:exit)\n end",
"def shutdown\n lock do\n @keep_running = false\n @condition.signal\n end\n\n @thread.join\n force_flush\n @exporter.shutdown\n end",
"def halt\n\t\tself.shutting_down = true\n\t\tself.consumer.channel.close\n\tend",
"def cleanup\n if running?\n logger.info \"Cleaning up agent, queue size: #{@queue.size}, thread running: #{@thread.alive?}\"\n @allow_reconnect = false\n queue_metric('exit')\n begin\n with_timeout(EXIT_FLUSH_TIMEOUT) { @thread.join }\n rescue Timeout::Error\n if @queue.size > 0\n logger.error \"Timed out working agent thread on exit, dropping #{@queue.size} metrics\"\n else\n logger.error \"Timed out PirateMetrics Agent, exiting\"\n end\n end\n end\n @thread = nil\n end",
"def exit\n case @status\n when :sleep\n wake_resume(:exit)\n when :run\n throw :exit\n end\n end",
"def exit\n @main_loop = false\n end",
"def shutdown\r\n\t\t\tsay \"#{name}: Exiting...\"\r\n\t\t\t@shutdown = true\r\n\t end",
"def shutdown!\n _shutdown 'SIGKILL' unless dead?\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def shutdown\n if PushmiPullyu.server_running?\n # using stderr instead of logger as it uses an underlying mutex which is not allowed inside trap contexts.\n warn 'Exiting... Interrupt again to force quit.'\n PushmiPullyu.server_running = false\n else\n exit!(1)\n end\n end",
"def flash_card_th_exit\n\n #Terminal flash card thread, if running\n Thread.list.each {|t|\n\n if t[:thread_method_name].to_s == \"flash_card_th\"\n $test_logger.log(\"Sending exit flag for flash card thread..\")\n\n #Set flag\n t[:to_exit] = true\n\n #Wait for thread to exit\n t.join\n\n $test_logger.log(\"Flash card thread exited!\")\n end\n }\n\n end",
"def shutdown\n @running = false\n end",
"def shutdown\n logger.info('Shutting down ...')\n @lock.synchronize do\n @shutdown = true\n end\n\n reset\n exit\n end",
"def shutdown\n @stopped = false\n end",
"def delete\n @thread.exit\n end",
"def exit_now\n\t\tputs \"Goodbye!\"\n\tend",
"def exit\n @server.check_out(@host) unless @server.nil?\n end",
"def terminate\n @done = true\n if @thread\n t = @thread\n @thread = nil\n t.value\n end\n end",
"def stop_thread; end",
"def delayed_exit\n sleep 0.1\n exit\n end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown\n @done = true\n end",
"def shutdown\n @done = true\n end",
"def shutdown(timeout = 300)\n @running = false\n @thread.join(timeout) if @thread and @thread.alive?\n end",
"def at_exit\n\n\t\tend",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def finish\n @thread.kill if @thread; @thread = nil\n @cleanup.call if @cleanup; @cleanup = nil\n FileUtils.rm sock_name\n end",
"def shutdown\n @snmptrap.exit\n end",
"def shutdown\n @done = true\n begin\n @node.wakeup\n rescue\n # best effort\n end\n @monitor_thread.join\n rescue => ex\n logger.warn(\"Failed to gracefully shutdown watcher for #{@node}\")\n end",
"def force_terminate\n @puppet_thread.exit unless @puppet_thread.nil?\n end",
"def kill\n return true if inline\n\n @thread.raise(Shutdown, \"Shutdown due to kill request for worker: #{name}\") if @thread.alive?\n end",
"def shutdown\n connection.write(\"shutdown\")\n end",
"def on_worker_shutdown(&block); end",
"def exit\n check_running\n @running = false\n @dispatchers.each(&:exit)\n @pool.exit\n end",
"def kill\n shutdown\n end",
"def close\n send_termination_event\n end",
"def exit!() end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def local_quit(body)\n ### send notice of disconnection?\n Kernel.exit\nend",
"def worker_end(worker)\n end",
"def quit!\n @done = true\n @quit = true\n\n # If quit! is called from other than a command, we need to interrupt the\n # breakpoint listener thread\n unless @debug_thread\n @breakpoint_tracker.debug_channel.send nil\n @breakpoint_listener.join\n end\n end",
"def shutdown\n end",
"def shutdown\n sysout(\"System going for shutdown\")\n #Do I/O (save to file for example)\n puts(\"Food Item Tracker Terminated\")\n end",
"def shutdown\n sysout(\"System going for shutdown\")\n #Do I/O (save to file for example)\n puts(\"Food Item Tracker Terminated\")\n end",
"def shutdown\n @logger.info \"Hastur agent shutting down normally.\"\n @running = false\n @router_socket.close\n @udp_socket.close\n @ctx.terminate\n end",
"def shutdown!\n shutdown\n end",
"def shutdown?; end",
"def c_quit()\n \tputs \"closing mucs\"\n\tcb = proc { \n\t\tsleep 5\n\t\treturn 1\n\t}\n#\t@muc.each {|chan,mucobj| }\n#\tEventMachine::defer (cb, proc {|r| on_quit(r)})\n\tend",
"def mark_as_exit\n @exit = true\n end",
"def on_worker_exit(worker)\n mutex.synchronize do\n @pool.delete(worker)\n if @pool.empty? && !running?\n stop_event.set\n stopped_event.set\n end\n end\n end",
"def quit!\n command \"quit\" if alive?\n ensure\n @alive = false\n @socket = nil\n File.delete(@socket_path) if File.exist?(@socket_path)\n end",
"def shutdown()\n @mutex.synchronize do\n @isRunning = false\n end\n if !@waitThread.nil?\n Thread.kill(@waitThread)\n end\n @threads.each do |t|\n Thread.kill(t)\n end\n @logs.each do |k, v|\n v.close\n end\n exit\nend",
"def shutdown\n log(\"Shutting down...\")\n # We need to perform the shutdown in a new thread, because this method\n # gets called from within a trap context\n Thread.new {\n Sock.off\n stop_bot\n disconnect_db\n unblock_threads\n exit\n }\nrescue => e\n fatal(\"Failed to shut down bot: #{e}\")\n exit\nend",
"def shutdown\n @shutdown = true\n end",
"def shutdown\n @shutdown = true\n end",
"def shut_down\n @shutdown_lock.synchronize {\n return if @shutting_down\n @shutting_down = true\n }\n die NO_ERROR\n end",
"def shutdown!\r\n\t shutdown\r\n\t end",
"def shutdown\n send_recv( KJess::Request::Shutdown.new )\n end",
"def shutdown\n reset\n @agent.shutdown\n end",
"def shutdown_after(timeout); end",
"def quit!\n @quit = true\n\n # If quit! is called from other than a command, we need to interrupt the\n # breakpoint listener thread\n unless @debug_thread\n @breakpoint_tracker.debug_channel.send nil\n @breakpoint_listener.join\n end\n end",
"def shutdown\n @event_loop.shutdown\n end",
"def close\n puts \"Goodbye comeback soon!\"\n exit\nend",
"def shut_down\n @keep_running = false\n if (RUBY_PLATFORM == \"java\")\n @mp.stop\n else\n wipe_out\n @thread.exit\n end\n end",
"def shutdown\n Log.info \"Initiate shutdown\"\n\n Timeout.timeout(5) do\n trait[:essentials].each do |obj|\n obj.shutdown if obj.respond_to?(:shutdown)\n end\n\n puts \"Ramazement is over, have a nice day.\"\n\n exit\n end\n rescue Timeout::Error\n puts \"Shutdown timed out, issuing exit!\"\n exit!\n end",
"def shutdown\n end",
"def shutdown\n stop\n end",
"def shutdown\n if @pid\n return if @status\n\n @mutex.synchronize do\n %w[HUP TERM KILL].each do |signal|\n logger.debug { \"sending #{signal} to #{@pid}\" }\n\n return unless running? # jruby doesn't seem to get @status ?\n\n begin\n kill(signal)\n rescue Errno::ESRCH\n return true\n end\n\n @exit_cond.wait(5) # check running? on next pass\n end\n end\n\n unless @exit_watching_thread.join(3) == @exit_watching_thread\n logger.warn { \"exit watching thread didn't exit after 3 sec\" }\n end\n\n @pid = @exit_watching_thread = nil\n\n logger.debug { \"@status: #{@status}\" }\n end\n true\n end"
] | [
"0.73675245",
"0.7190835",
"0.7190835",
"0.6891319",
"0.68544877",
"0.6777421",
"0.67723155",
"0.6766893",
"0.67489594",
"0.6716462",
"0.6660128",
"0.66244155",
"0.65971047",
"0.6585011",
"0.656145",
"0.654679",
"0.65341944",
"0.65341944",
"0.65341944",
"0.6514709",
"0.6466726",
"0.6460793",
"0.6456997",
"0.6456067",
"0.6430234",
"0.6423736",
"0.64221275",
"0.6413422",
"0.64001745",
"0.6399052",
"0.6396455",
"0.63555515",
"0.6354397",
"0.63511944",
"0.63424975",
"0.6341685",
"0.6334535",
"0.6317055",
"0.63124067",
"0.6283258",
"0.6263922",
"0.62521243",
"0.62521243",
"0.62521243",
"0.6243096",
"0.6243096",
"0.6214389",
"0.62066317",
"0.6203917",
"0.6203917",
"0.6203917",
"0.6203917",
"0.6203917",
"0.6203917",
"0.6203917",
"0.62006545",
"0.619049",
"0.6184832",
"0.61838996",
"0.61784816",
"0.61779636",
"0.6176009",
"0.6174988",
"0.6167076",
"0.61644816",
"0.6149984",
"0.6147968",
"0.6147968",
"0.6147968",
"0.6147968",
"0.6144475",
"0.61361605",
"0.6122521",
"0.61223733",
"0.61179644",
"0.61179644",
"0.6117782",
"0.61056453",
"0.6092758",
"0.6088997",
"0.6073701",
"0.60729986",
"0.6069377",
"0.60656565",
"0.6057088",
"0.6049342",
"0.6049342",
"0.6047479",
"0.60434407",
"0.60404503",
"0.6033671",
"0.6033659",
"0.60244966",
"0.60174865",
"0.6012216",
"0.5997248",
"0.59941715",
"0.5981781",
"0.5980926",
"0.5976338"
] | 0.6660239 | 10 |
Disconnect any sockets that haven't sent any frames for at least SOCKET_IDLE_TIMEOUT seconds. | def cull_idle_sockets
self.log.debug "Culling idle sockets."
earliest = Time.now - self.class.idle_timeout
self.connection_times.each do |sender_id, times|
times.each do |conn_id, lastframe|
next unless earliest > lastframe
self.log.warn "Timing out connection %s:%d: last seen %0.3fs ago." %
[ sender_id, conn_id, Time.now - lastframe ]
# Make a CLOSE frame
frame = Mongrel2::WebSocket::Frame.close
frame.set_status( CLOSE_EXCEPTION )
# Use the connection directly so we can send a frame and close the
# connection
self.conn.send( sender_id, conn_id, frame.to_s )
self.conn.send_close( sender_id, conn_id )
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_idle_sockets\n return if closed?\n return unless max_idle_time\n\n @lock.synchronize do\n i = 0\n while i < @available_connections.length\n connection = @available_connections[i]\n if last_checkin = connection.last_checkin\n if (Time.now - last_checkin) > max_idle_time\n connection.disconnect!(reason: :idle)\n @available_connections.delete_at(i)\n @populate_semaphore.signal\n next\n end\n end\n i += 1\n end\n end\n end",
"def disconnect!(timeout: 120)\n start_time = ::Gitlab::Metrics::System.monotonic_time\n\n while (::Gitlab::Metrics::System.monotonic_time - start_time) <= timeout\n break if pool.connections.none?(&:in_use?)\n\n sleep(2)\n end\n\n pool.disconnect!\n end",
"def disconnect\n @thread.kill\n @socket.close\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n @authed = false\n end\n end",
"def disconnect\n if @socket\n @socket.close\n @socket = nil\n end\n end",
"def disconnect \n # If the socket's open, close it \n @logger.info \"Disconnecting from Asterisk Manager...Goodbye!\" \n @socket.close if !@socket.nil?\n \n # Reset flags\n @connected = false\n @logged_in = false\n end",
"def disconnect\n raise \"Not connected. did you forget to call connect?\" unless @_socket\n @_socket.close\n @_socket = nil\n print \"Disconnected\\n\" if @_verbose\n EtherShell::ShellDsl.nothing\n end",
"def disconnect()\n @connection.stop()\n @timer.stop()\n @broadcast.stop()\n end",
"def disconnect\n @write_socket.close\n @read_socket.close\n @write_socket = nil\n @read_socket = nil\n @rc_r = false\n @rc_W = false\n end",
"def disconnect\n @socket.close\n end",
"def disconnect\n @socket.close if @socket && !@socket.closed?\n @socket = nil\n self\n end",
"def socket_disconnected\n end",
"def disconnect(reason)\n if @socket.is_a?(OpenSSL::SSL::SSLSocket)\n @socket.sysclose()\n else\n begin \n @socket.close_read\n rescue IOError => e\n # Ignore, perhaps we shouldn't ignore.\n end\n\n begin \n @socket.close_write\n rescue IOError => e\n # Ignore, perhaps we shouldn't ignore.\n end\n end\n end",
"def disconnect(opts=OPTS)\n while conn = @queue.pop(timeout: 0)\n disconnect_connection(conn)\n end\n fill_queue\n nil\n end",
"def disconnect!\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect!\n end\n @connections = []\n @available.clear\n end",
"def abort_sockets\n sockets.delete_if { |sock|\n\n begin\n sock.close\n rescue ::Exception\n end\n true\n }\n end",
"def close(timeout=10)\n # Prevent any new connections from being handed out\n self.pool_size = 0\n start_time = Time.now\n while (Time.now - start_time) < timeout\n sleep 1\n @mutex.synchronize do\n return if @connections.empty?\n @logger.info \"#{@name}: Waiting to close, #{@connections.size} connections are still in use\"\n end\n end\n @logger.warn \"#{@name}: Timed out while waiting to close, #{@connections.size} connections are still in use\"\n end",
"def graceful_shutdown\n socket_server.close unless socket_server.closed?\n\n until active_connections.zero?\n logger.debug \"#{active_connections} connections still active\"\n sleep 0.5\n end\n\n logger.debug \"No more active connections. Exiting'\"\n\n Process.exit(0)\n end",
"def close(timeout = false)\n # Return immediately if the server isn't listening\n return unless @ml.locked?\n \n # Ask the loop to close\n @close_in.putc 'x' # Tell select to close\n\n \n # Wait for loop to end\n elapsed_time = 0\n while @ml.locked? do\n sleep(0.05)\n elapsed_time += 0.05\n\n # If a timeout is given, try killing threads at this point\n if timeout && elapsed_time > timeout\n @clients.each {|id, thread| thread.kill() }\n end\n end\n end",
"def unbind\n log(:info, :socket, 'disconnected')\n end",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def disconnect!\n @reserved_connections.each do |name,conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect!\n end\n @connections = []\n end",
"def disconnect\n @tcp_socket.close\n end",
"def disconnect!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect!\n end\n @connections.clear\n @available.clear\n end\n end",
"def close\n parser_thread.kill if parser_thread # why if?\n poll_thread.kill\n socket.close if socket\n\n @status = DISCONNECTED\n end",
"def disconnect\n @server = nil\n @status = :disconnected\n end",
"def disconnect\n @comm.disconnect(delete_affiliations: true)\n logger.info \"Disconnecting #{hrn}(#{uid}) in #{DISCONNECT_WAIT} seconds\"\n EM.add_timer(DISCONNECT_WAIT) do\n @comm.disconnect\n end\n end",
"def local_disconnect(body)\n @connection.disconnect\n _network_init\n _notice \"disconnected\", :global\nend",
"def disconnect\n @thread.exit\n @client.disconnect\n @channels.clear\n end",
"def finish\n begin\n @socket.close\n rescue\n end\n on_disconnected\n end",
"def graceful_shutdown\n socket_server.close unless socket_server.closed?\n @active_descriptors.delete(socket_server)\n @shutdown = true\n end",
"def close_idle_connections(idle_time) # in sec\n @http_client.keep_alive_timeout = idle_time # set timeout value\n close_expired_connections\n end",
"def close_idle_connections(idle_time) # in sec\n @http_client.keep_alive_timeout = idle_time # set timeout value\n close_expired_connections\n end",
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def clear()\n @sock.recv(65535)\n end",
"def disconnect\n return unless @connected\n if @socket && !@socket.closed?\n @socket.close \n log(:debug, \"Socket successfully disconnected\")\n @connected = false\n return true\n end\n end",
"def disable_tunnel_timeouts\n return unless @timeout_timer\n @timeout_timer.cancel\n @timeout_timer = nil\n end",
"def disconnect_all\n @connections.clear\n @readers.clear\n end",
"def drain\n while select([@socket], nil, nil, 0)\n mesg, _, _, _ = @socket.recvmsg\n raise EOFError unless mesg\n end\n end",
"def disconnect( socket )\n flag = super socket\n _connect if flag\n return flag\n end",
"def close_connection\n cls if connected?\n stop_read_loop\n stop_write_loop\n @socket.close if @socket\n @socket = nil\n @connected = false\n end",
"def on_disconnect(socket)\n Utils.logger.info(\"[Client Disconnected: #{socket.inspect}]\")\n end",
"def disconnected(event = :failed) # :nodoc:\n task.emit(event)\n connection_space.deregister_peer(self)\n\n wait_link_alive_sync.synchronize do\n @connection_state = :disconnected\n @send_queue.clear\n @send_queue.push nil\n @send_thread.join\n @send_queue, @send_thread = nil\n socket.close if !socket.closed?\n @socket = nil\n\n wait_link_alive_cond.broadcast\n end\n\n self.clear\n Distributed.info \"#{self}: disconnected (#{event})\"\n end",
"def disconnect()\r\n @callbacks.each { |block| block.call }.clear()\r\n @conn.close if @conn\r\n @conn = nil\r\n end",
"def _close_socket\n raise \"no wrapped socket\" unless @socket\n return if @socket.closed?\n @socket.shutdown rescue nil\n @socket.read_nonblock(4*1024*1024) rescue nil # flush any in-flight crud\n @socket.close rescue nil\n end",
"def reset_connection\n #close if \n @socket_server = nil\n connect\n end",
"def disconnect_all\n refine_exceptions do\n do_disconnect_all\n end\n end",
"def close_socket\n @stop = true\n end",
"def disconnect(identifiers)\n remote_connections.where(identifiers).disconnect\n end",
"def server_inactivity_timeout(timeout, elapsed)\n LOGGER.error \"Disconnecting #{@remote.join(':')} after #{elapsed}s of inactivity (> #{timeout.inspect})\"\n @server_side = nil\n close_connection\n BeanstalkProxy.inactivity_error_callback.call(@remote.join(':'))\n end",
"def on_close(event)\n logger.debug 'Socket closed'\n @connected = false\n @socket = nil\n dispatch('command' => 'session_ended')\n end",
"def on_close(event)\n logger.debug 'Socket closed'\n @connected = false\n @socket = nil\n dispatch('command' => 'session_ended')\n end",
"def event_epoch()\n # Flush out idle clients, if any\n @clients.each do |_,client|\n if Time.now - client.var[:last_ping] > 300\n client.socket.close\n client = @clients.delete(client.socket)\n dispatch :connection_reset, client, \"ping timeout\"\n end\n end\nend",
"def disconnect(reason = nil, timeout = 5)\n # Quit and wait for replies from server\n @bot.quit(reason)\n sleep(timeout)\n end",
"def close\n @sockets.each do |sock|\n sock.close\n end\n @host = @port = nil\n @sockets.clear\n @checked_out.clear\n end",
"def disconnect\n @streams.each { |_, stream| try { stream.finalize } }\n @conn.Disconnect()\n end",
"def check_tunnel_timeout\n if tunnel_timeout?\n W 'Tunnel timeout. Disconnecting from server.'\n disable_tunnel_timeouts\n close_connection_after_writing\n end\n end",
"def disconnect\n if threaded[:connection]\n threaded[:connection].disconnect\n threaded[:connection] = nil\n end\n end",
"def recvall(timeout: nil)\n recvn(1 << 63, timeout: timeout)\n rescue ::Pwnlib::Errors::EndOfTubeError, ::Pwnlib::Errors::TimeoutError\n @buffer.get\n end",
"def close_tcp_sockets()\n\n if (@tcp_sockets.length > 0)\n\n @tcp_sockets.each do |tcp_socket|\n begin\n tcp_socket.close\n rescue Exception => e\n puts \"close_tcp_sockets:exception: #{e}\"\n end\n end\n\n end\n\n end",
"def unbind\n log.debug { \"Disconnected.\" }\n callback :disconnected\n EM.add_timer(@connection_attempts) do\n @connection_attempts += 1\n reconnect(@host, @port)\n post_init\n end\n end",
"def disconnect_ssh_tunnel\n @logger.debug('closing SSH tunnel..')\n\n @ssh.shutdown! unless @ssh.nil?\n @ssh = nil\n end",
"def disconnect\n Threaded.sessions.values.each(&:disconnect)\n end",
"def shutdown\n @socket = nil\n @thr.join if @thr\n @thr = nil\n end",
"def close\n log \"Closing connection\", level: :warning\n close_stream\n close_socket\n stop_reader\n set_state :disconnected\n notify_error DisconnectError.new(\"Connection was closed\")\n\n # stop timer\n # as we're running inside the timer, code after stop_timer() will not be called,\n # unless it's in the ensure block\n stop_timer\n end",
"def close_socket()\n begin\n # Need to set @closed = true before closing the socket\n # within the @read_semaphore thread\n @closed = true\n @read_semaphore.synchronize do\n @socket.close\n end\n rescue\n #Ignoring if already closed\n end\n @closed\n end",
"def detect_random_calls_to_reject\n if GuiConfig.random_disconnect_enable\n max_length = GuiConfig.random_disconnect_length\n flatten_calls.each do |call|\n next if call[:duration].to_i <= max_length\n\n @terminate_calls.merge!(call[:local_tag] => call) if rand(100) < 10\n end\n end\n end",
"def idle_trim!(timeout); end",
"def disconnect_all_users( msg )\n\t\t@users.each do |user|\n\t\t\t@reactor.unregister( user.socket )\n\t\t\tuser.disconnect( msg )\n\t\tend\n\t\t@users.clear\n\tend",
"def logout\n raise SocketError, \"Socket must be opened before logging out\" if !@socket or @socket.closed?\n\n xml = new_epp_request\n\n xml.root << command = Node.new(\"command\")\n\n command << login = Node.new(\"logout\")\n command << Node.new(\"clTRID\", SecureRandom.uuid)\n\n response = Hpricot::XML(send_request(xml.to_s))\n\n handle_response(response, 1500)\n end",
"def disconnectAllUsers( msg )\n\t\t@users.each {|user|\n\t\t\t@reactor.unregister( user.socket )\n\t\t\tuser.disconnect( msg )\n\t\t}\n\t\t@users.clear\n\tend",
"def discard!\n # This should be overridden by concrete adapters.\n #\n # Prevent @connection's finalizer from touching the socket, or\n # otherwise communicating with its server, when it is collected.\n end",
"def destroy_connection\r\n\tbegin\r\n\t\t@sock.close if @sock\r\n\tensure\r\n\t\t@connected=false\r\n\tend\r\n end",
"def close\n @socket.close\n @socket=\"\"\n end",
"def disconnect\n send_packet(MQTT::Packet::Disconnect.new)\n @state = :disconnected\n close_connection_after_writing\n end",
"def close\n @socket.close unless closed?\n end",
"def shutdown\n @data_socket.close\n @ack_socket.close\n @client.disconnect! rescue nil\n end",
"def cleanup\n if @main_loop_thread\n @main_loop_thread_lock.synchronize do\n @graceful_termination_pipe[1].close rescue nil\n end\n @main_loop_thread.join\n end\n @server_sockets.each_value do |info|\n socket = info[:socket]\n type = get_socket_address_type(info[:address])\n\n begin\n socket.close if !socket.closed?\n rescue Exception => e\n # Ignore \"stream closed\" error, which occurs in some unit tests.\n # We catch Exception here instead of IOError because of a Ruby 1.8.7 bug.\n if e.to_s !~ /stream closed/ && e.message.to_s !~ /stream closed/\n raise e\n end\n end\n if type == :unix\n filename = info[:address].sub(/^unix:/, '')\n File.unlink(filename) rescue nil\n end\n end\n @owner_pipe.close rescue nil\n end",
"def disconnect_all\n raise NotImplementedError\n end",
"def close\n server_list.each { |server| server.close_channels }\n loop(0) { busy?(true) }\n server_list.each { |server| server.close }\n default_gateway.shutdown! if default_gateway\n end",
"def stop_packet_writer\n log \"Stopping packet writer...\"\n wait_for = 10\n\n begin\n timeout(wait_for) do\n sleep 0.2 until @packets.empty?\n end\n rescue Timeout::Error\n log \"Packet buffer not empty after #{wait_for} seconds. Trying to stop listener...\"\n stop_listener\n end\n\n @packet_writer.kill if writing_packets?\n @packet_writer = nil\n log \"Packet writer stopped.\"\n\n @capture_file.close\n\n !writing_packets?\n end",
"def disconnect\n @on_disconnected.call if @on_disconnected\n @enable_reconnection = false\n @ws.close\n end",
"def graceful_shutdown(timeout: true)\n @stopping = true\n\n Thread.new do\n GrpcKit.logger.debug('graceful shutdown')\n @mutex.synchronize { @sessions.each(&:drain) }\n\n begin\n sec = timeout ? @shutdown_timeout : 0\n Timeout.timeout(sec) do\n sleep 1 until @sessions.empty?\n end\n rescue Timeout::Error => _\n GrpcKit.logger.error(\"Graceful shutdown is timeout (#{@shutdown_timeout}sec). Perform shutdown forceibly\")\n shutdown_sessions\n end\n end\n end",
"def disconnecting?; connection_state == :disconnecting end",
"def close_tcp_sockets()\n logger.info \"close_tcp_sockets:start: tcp sockets list = #{@tcp_sockets}\"\n\n if (@tcp_sockets.length > 0)\n\n @tcp_sockets.each do |tcp_socket|\n begin\n tcp_socket.close\n rescue Exception => e\n logger.error \"close_tcp_sockets:exception: #{e}\"\n end\n end\n\n end\n\n logger.info 'close_tcp_sockets:end: Completed'\n\n end",
"def stop\n @socket.close\n ensure\n cleanup\n end",
"def close\n frame = Hash.new\n frame['command'] = 'close'\n @close_txnr=self.frame_write(@socket, frame)\n #TODO: ought to properly wait for a reply etc. The serverclose will make it work though\n sleep @retransmission_timeout\n return @buffer\n ensure\n @socket.close\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def disconnect\n @connection.close if connected?\n @connection = nil\n end",
"def cleanup \n # close the sockets \n @servers.each{ |server| server[:listner].stop }\n @monitor.close\n end",
"def disconnect\n unless @server.nil?\n @server.cmd \"quit\"\n @server.close\n end\n @authenticated = false\n @server = nil\n end",
"def reset_liveness_timer\n @liveness_timer.cancel if @liveness_timer\n @liveness_timer = EventMachine::Timer.new(connection.heartbeat_interval + 0.1) do\n if connection.connected? && (connection.time_since_connection_confirmed_alive? >= connection.heartbeat_interval)\n msg = \"No activity seen from realtime in #{connection.heartbeat_interval}; assuming connection has dropped\";\n error = Ably::Exceptions::ConnectionTimeout.new(msg, Ably::Exceptions::Codes::DISCONNECTED, 408)\n connection.transition_state_machine! :disconnected, reason: error\n end\n end\n end",
"def remove_dead_socket(socket)\n @sockets.delete socket\n ct = @socket_keys[socket]\n handle = @handle_keys[ct]\n @handles.delete handle\n @handle_keys.delete ct\n @socket_keys.delete socket\n end",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def close\n if @socket\n @socket.close\n\n # Spotify doesn't send the disconnect frame quickly, so the callback\n # gets run immediately\n EventMachine.add_timer(0.1) { on_close(nil) }\n end\n true\n end",
"def close\n @sock.close if @sock && !@sock.closed?\n @sock = nil\n @retry = nil\n @status = \"NOT CONNECTED\"\n end",
"def set_timer\n SockJS.debug \"Setting @disconnect_timer to #{@disconnect_delay}\"\n @disconnect_timer ||= begin\n EM::Timer.new(@disconnect_delay) do\n SockJS.debug \"#{@disconnect_delay} has passed, firing @disconnect_timer\"\n @disconnect_timer_canceled = true\n\n @alive_checker.cancel if @alive_checker\n\n if self.opening? or self.open?\n # OK, so we're here, closing the open response ... but its body is already closed, huh?\n SockJS.debug \"@disconnect_timer: closing the connection.\"\n self.close\n SockJS.debug \"@disconnect_timer: connection closed.\"\n else\n SockJS.debug \"@disconnect_timer: doing nothing.\"\n end\n end\n end\n end",
"def close\n send(\"DONE\")\n @socket.close\n end"
] | [
"0.6893426",
"0.6375546",
"0.6176038",
"0.61718494",
"0.61718494",
"0.61693037",
"0.60364634",
"0.60205466",
"0.60091364",
"0.59411675",
"0.59056914",
"0.58360547",
"0.5812672",
"0.579687",
"0.57572174",
"0.5739143",
"0.5730113",
"0.5686966",
"0.5680631",
"0.5609806",
"0.5573994",
"0.55009466",
"0.5493349",
"0.5490298",
"0.54546505",
"0.5427646",
"0.5402448",
"0.54015964",
"0.5399218",
"0.53797257",
"0.53713167",
"0.5370692",
"0.53606516",
"0.53606516",
"0.53514415",
"0.5339993",
"0.53256154",
"0.5316867",
"0.52974397",
"0.52887535",
"0.52819985",
"0.5264543",
"0.5262821",
"0.5259819",
"0.5255366",
"0.5253996",
"0.52320683",
"0.5223841",
"0.5223317",
"0.519584",
"0.51957685",
"0.5186245",
"0.5186245",
"0.51760614",
"0.51678896",
"0.5157497",
"0.5144263",
"0.5141011",
"0.5140645",
"0.51377857",
"0.51322174",
"0.5113823",
"0.51133865",
"0.51074415",
"0.51029366",
"0.5091861",
"0.50880814",
"0.50871366",
"0.50823295",
"0.5081264",
"0.50705594",
"0.5068617",
"0.5063731",
"0.5062947",
"0.5059717",
"0.5050032",
"0.5042802",
"0.50056297",
"0.50036454",
"0.49930403",
"0.49815997",
"0.49732345",
"0.49680734",
"0.4964295",
"0.49624392",
"0.49600226",
"0.4957589",
"0.49575847",
"0.49561357",
"0.49561357",
"0.4944178",
"0.4938763",
"0.4937858",
"0.49345195",
"0.49307206",
"0.49296036",
"0.49268848",
"0.48983636",
"0.48923206",
"0.48748168"
] | 0.70669025 | 0 |
Send a PING frame to all connected sockets. | def ping_all_sockets
return if self.connections.empty?
self.log.debug "Pinging %d connected sockets." % [ self.connections.length ]
self.connections.each do |sender_id, conn_ids|
frame = Mongrel2::WebSocket::Frame.new( sender_id, conn_id, '', {}, 'heartbeat' )
frame.opcode = :ping
frame.fin = true
self.log.debug " %s/%d: PING" % [ sender_id, conn_id ]
self.conn.reply( frame )
end
self.log.debug " done with pings."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_ping\n @connections.each do |socket|\n begin\n socket << \":\\n\"\n rescue Reel::SocketError\n @connections.delete(socket)\n end\n end\n end",
"def pong_everyone\n #log \"trying to pong\"\n if @sockets.length > 0 && !self.stopped?\n #log \"ponging\"\n broadcast_message(nil, \"PONG\", [build_handle_list])\n #sleep 5\n clean_handles\n end\n end",
"def ping message=nil\n if message\n message = (message.to_s.b + (0.chr * 8)).slice(0, 8)\n else\n now = Time.now\n message = [now.to_i, now.usec].pack('NN')\n end\n @pings << message\n g = Frame.new FrameTypes::PING, 0, 0, message\n send_frame g\n end",
"def ping!\n send_message [IGNORE, 4, \"ping\"].pack(\"cNA4\")\n end",
"def magic_ping(event); @socket.puts \"PONG :#{event.message}\"; end",
"def ping\n every(5) do\n send_ping\n end\n end",
"def flush(timeout=60)\n # Schedule sending a PING, and block until we receive PONG back,\n # or raise a timeout in case the response is past the deadline.\n pong = @pongs.new_cond\n @pongs.synchronize do\n @pongs << pong\n\n # Flush once pong future has been prepared\n @pending_queue << PING_REQUEST\n @flush_queue << :ping\n with_nats_timeout(timeout) do\n pong.wait(timeout)\n end\n end\n end",
"def ping(m=nil)\n @socket << \"PING #{m}\".strip\n end",
"def send_ping\n if @version.version > Bitcoin::Protocol::BIP0031_VERSION\n @latency_ms = LATENCY_MAX\n @ping_nonce = rand(0xffffffff)\n @ping_time = Time.now\n log.debug { \"<< ping (#{@ping_nonce})\" }\n send_data(Protocol.ping_pkt(@ping_nonce))\n else\n # set latency to 5 seconds, terrible but this version should be obsolete now\n @latency_ms = (5*1000) \n log.debug { \"<< ping\" }\n send_data(Protocol.ping_pkt)\n end\n end",
"def send_to_all(message)\n EM.next_tick do\n settings.sockets.each do |s|\n s.send(message.to_json)\n end\n end\n end",
"def remote_ping(sender, body)\n _notice \"PING?/PONG! (#{sender})\", :notice\n _remote_control(sender, 'pong',\n @var[:presence][@connection.comm.our_keyhash].join(' '))\nend",
"def ping(body = '')\n if @handler\n @handler.pingable? ? @handler.send_frame(:ping, body) && true : false\n else\n raise WebSocketError, \"Cannot ping before onopen callback\"\n end\n end",
"def send_all(event, data)\n\t\tEM.next_tick {\n\t\t\t@sockets.each do |s|\n\t\t\t\ts.send(event, data) \n\t\t\tend\n\t\t}\n\tend",
"def ping\n check_connection\n @protocol.ping_command\n self\n end",
"def ping!\n @session.ping!\n end",
"def process_ping\n @pending_queue << PONG_RESPONSE\n @flush_queue << :ping\n pong = @pongs.new_cond\n @pongs.synchronize { @pongs << pong }\n end",
"def ping\n @conn.ping\n end",
"def flush\n @sockets.each {|s| s.flush }\n end",
"def ping!\n @transmission_state.enqueue_ping\n end",
"def ping(&blk)\n if block_given?\n websocket.subscribe :ping, &blk\n else\n http.get :ping\n end\n end",
"def pong\n to_send = [ 0b10001010, 0, \"\" ]\n @connection.write to_send.pack \"C2A0\"\n end",
"def update_ping\n put 'ping'\n end",
"def handle_ping(client, ccf)\n @socket.send_strings [client, ccf, PONG]\n end",
"def autoping\n @servers.each do |server|\n if server.last_saw_traffic_at + 300 < Time.now\n server.write(\"PING #{server.hostname}\")\n \n # Artificially set the last_saw_traffic_at value to now so that we don't flood the server\n server.last_saw_traffic_at = Time.now\n end\n end\n end",
"def pbroadcast(message, callback)\n connections.each { |c| c.ping(message, &callback) }\n end",
"def answer_pings\n\t\t@ping_thread = Thread.new do \n\t\t\tbegin\n\t\t\t\tloop do \n\t\t\t\t\tpkt = @tap.recv\n\t\t\t\t\tp pkt\n=begin\t\t\t\t\t\n\t\t\t\t\ticmp = icmp_offset(pkt)\n\t\t\t\t\tif icmp and pkt[icmp] == \"\\x08\" #type == Echo Request\n\t\t\t\t\t\tpkt[icmp, 1] = \"\\x00\"\n\t\t\t\t\t\tpkt[26, 4], pkt[30, 4] = pkt[30, 4], pkt[26, 4]\n\t\t\t\t\t\t@tap.inject(pkt)\n\t\t\t\t\tend\n=end\t\t\t\n\t\t\t\tend\n\t\t\trescue Object\n\t\t\t\t$stderr.puts $!\n\t\t\t\t$stderr.puts $@\n\t\t\t\tKernel.exit(1)\n\t\t\tend\n\t\tend\n\tend",
"def ping() \n \"Pong from #{Socket.gethostname}\"\n end",
"def ping\n send_command(\"ping\")\n end",
"def answer_pings\n\t\t@ping_thread = Thread.new do \n\t\t\tbegin\n\t\t\t\tloop do \n\t\t\t\t\tpkt = @tap.recv\n\t\t\t\t\ticmp = icmp_offset(pkt)\n\t\t\t\t\tif icmp and pkt[icmp] == \"\\x08\" #type == Echo Request\n\t\t\t\t\t\tpkt[icmp, 1] = \"\\x00\"\n\t\t\t\t\t\tpkt[26, 4], pkt[30, 4] = pkt[30, 4], pkt[26, 4]\n\t\t\t\t\t\t@tap.inject(pkt)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Object\n\t\t\t\t$stderr.puts $!\n\t\t\t\t$stderr.puts $@\n\t\t\t\tKernel.exit(1)\n\t\t\tend\n\t\tend\n\tend",
"def test_ping\n\t@tt.sock.send(@ping, 0)\n=begin\n\t\tpong = @tt.ping_reply\n\t\tassert_equal(42, pong.length)\n\t\tassert_equal(pong[0, 6], @tt.tap_mac)\n\t\tassert_equal(pong[30, 4], @ping[26, 4])\n\t\tassert_equal(pong[26, 4], @ping[30, 4])\n=end\n\tend",
"def test_ping\n\t@tt.sock.send(@ping, 0)\n=begin\n\t\tpong = @tt.ping_reply\n\t\tassert_equal(42, pong.length)\n\t\tassert_equal(pong[0, 6], @tt.tap_mac)\n\t\tassert_equal(pong[30, 4], @ping[26, 4])\n\t\tassert_equal(pong[26, 4], @ping[30, 4])\n=end\n\tend",
"def test_ping_basic\n @tt.sock.send(@ping, 0)\n pong = @tt.ping_reply\n assert_equal(42, pong.length)\n assert_equal(pong[0, 6], @tt.tap_mac)\n assert_equal(pong[30, 4], @ping[26, 4])\n assert_equal(pong[26, 4], @ping[30, 4])\n end",
"def send_pending_data\n needs_looping = true\n while needs_looping\n needs_looping = false\n pending_data.delete_if do |socket, chunks|\n if chunks.empty?\n # nothing left to send for this socket\n next\n end\n\n buffer = chunks.shift\n while !chunks.empty? && (buffer.size + chunks[0].size < DATA_CHUNK_SIZE)\n buffer.concat(chunks.shift)\n end\n Server.debug \"sending #{buffer.size} bytes to #{socket}\"\n\n begin\n written = socket.write_nonblock(buffer)\n rescue Interrupt\n raise\n rescue Errno::EAGAIN\n Server.debug \"cannot send: send buffer full\"\n chunks.unshift(buffer)\n next\n rescue Exception => e\n Server.warn \"disconnecting from #{socket}: #{e.message}\"\n e.backtrace.each do |line|\n Server.warn \" #{line}\"\n end\n socket.close\n next(true)\n end\n\n remaining = buffer.size - written\n if remaining == 0\n Server.debug \"wrote complete chunk of #{written} bytes to #{socket}\"\n # Loop if we wrote the complete chunk and there\n # is still stuff to write for this socket\n needs_looping = !chunks.empty?\n else\n Server.debug \"wrote partial chunk #{written} bytes instead of #{buffer.size} bytes to #{socket}\"\n chunks.unshift(buffer[written, remaining])\n end\n false\n end\n end\n end",
"def ping(sock,msg=nil)\n unless msg.nil? or msg.type == Protocol::MessageType::PING\n Routing.log { |logger| logger.error(self.class) { \"Not a PING message.\"}}\n return false\n end\n if msg.nil?\n msg = construct_ping\n end\n bytes = @protocol.send_message(sock,msg)\n @bandwidth_manager.uploaded(bytes,Time.now-msg.ftime.to_time) unless @bandwidth_manager.nil?\n Routing.log {|logger| logger.info(self.class) { \"PING message is sent. Size: #{bytes} bytes.\"}}\n true\n end",
"def start_pong_loop\n Thread.new do\n loop do\n sleep 5\n # log \"pong all\"\n pong_everyone\n # log \"pong logsave\"\n save_chat_log\n end\n end\n end",
"def answer_pings\n @ping_thread = Thread.new do\n begin\n loop do\n pkt = @tap.recv\n icmp = icmp_offset(pkt)\n if icmp and pkt[icmp] == \"\\x08\" # type == Echo Request\n pkt[icmp, 1] = \"\\x00\" # type == Echo Reply\n pkt[26, 4], pkt[30, 4] = pkt[30, 4], pkt[26, 4] # reverse IPs\n @tap.inject(pkt)\n end\n end\n rescue Object\n $stderr.puts $!\n $stderr.puts $@\n Kernel.exit(1)\n end\n end\n end",
"def send_ping(target_node_id, host, port)\n ping = Ping.new(to: To.from_host_port(host, port), \n from: From.new(\n sender_ip: IPAddr.new(@host).to_i,\n sender_udp_port: @udp_port,\n sender_tcp_port: @tcp_port),\n expiration: Time.now.to_i + MESSAGE_EXPIRATION_IN)\n ping_msg = Message.pack(ping, private_key: @private_key)\n send_msg(ping_msg.encode_message, host, port)\n @peer_store.update_ping(target_node_id, ping_msg.message_hash)\n end",
"def pong(body = '')\n if @handler\n @handler.pingable? ? @handler.send_frame(:pong, body) && true : false\n else\n raise WebSocketError, \"Cannot ping before onopen callback\"\n end\n end",
"def ping(session_id)\n execute_command('ping', :session_id => session_id)\n end",
"def ping_nodes\n\t\twhile true\n\t\t\tsleep(rand(60))\n\t\t\tn = rand(@neighbour_nodes.count)\n\t\t\tnode = @neighbour_nodes[n]\n\t\t\ts = UDPSocket.new\n\t\t\tbegin\n\t\t\t\tTimeout::timeout(10){ \n\t\t\t\t\tputs \"Pinging #{node}\"\n\t\t\t\t\tsend_message [\"PING\", @info], 0, node.host, node.port\n\t\t\t\t\t@waiting = true\n\t\t\t\t\twhile waiting?\n\t\t\t\t\t\tsleep(0.2)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue Timeout::Error => ex\n\t\t\t\tif waiting?\n\t\t\t\t\tputs \"Conenction to #{node} timed out, sending DROP_NODE to all remaining nodes\"\n\t\t\t\t\t@neighbour_nodes - [node]\n\t\t\t\t\t@neighbour_nodes.each do |n|\n\t\t\t\t\t\tsend_message [\"DROP_NODE\", node], 0, n.host, n.port\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Socket::Error => ex\n\t\t\t\tputs \"Connection to #{node} failed, trying again in 60 seconds\"\n\t\t\trescue => ex\n\t\t\t\tputs ex.message\n\t\t\tend\n\t\tend\n\tend",
"def flush\n @socket.flush if @socket\n end",
"def flush\n @socket&.flush\n end",
"def on_ping(x)\n end",
"def broadcast\n queued_data = JSON.generate(@send_queue.shift)\n @sockets.each do |socket|\n socket.send queued_data\n end\n end",
"def ping\n\t\t# MAC address / serial\n\t\tlogger.debug(\"PING called\")\n\n\t\trender_event\n\tend",
"def peer_send(peer,message)\r\n\t\t\tpeer.socket.puts(message)\r\n\t\tend",
"def transmit packets, delay: 0.1\r\n Ionian::Socket.new host: \"#{SOUNDWEB_IP}:#{SOUNDWEB_PORT}\" do |socket|\r\n packets.each do |packet|\r\n socket.write packet.pack(packet.map { 'C' }.join)\r\n socket.flush\r\n sleep delay\r\n end\r\n end\r\nend",
"def ping\n sanity_check\n @handle.ping\n end",
"def ping(cmd)\n\tdst = cmd[0]\n next_hop = $next[dst]\n if next_hop == \"NA\" || next_hop == $hostname\n STDOUT.puts \"PING ERROR: HOST UNREACHABLE\"\n return\n end\n n = cmd[1].to_i\n delay = cmd[2].to_i\n client = $clients[next_hop]\n\n # This will iterate through the number of pings given on the command line. It will setup the \n # proper message for pingCallBack and adds the current time to the ping table with the key\n # of the sequence number. It will then check if ping_table has that key still (should be removed\n # by pingCallBack) so if it still exists, then the host was not reached.\n for seq_id in (0..(n - 1))\n msg = Msg.new\n msg.setConfig(\"type\", 3)\n msg.setConfig(\"code\", 0)\n msg.setMessage($hostname + \" \" + dst + \" \" + seq_id.to_s)\n $ping_table[seq_id.to_s] = $currtime\n sendMessage(client, msg)\n Thread.new {\n seq_id_ = seq_id\n sleep($ping_timeout)\n if $ping_table.has_key?(seq_id_.to_s)\n STDOUT.puts \"PING ERROR: HOST UNREACHABLE\"\n end\n $ping_table.delete(seq_id_.to_s)\n }\n sleep(delay)\n end\nend",
"def onping(&blk); super; end",
"def pong(s, m)\n @socket << \"PONG #{s} #{m}\"\n end",
"def ping(request)\n if request.message =~ /PING$/i\n request.answer 'PONG'\n end\n end",
"def ping\n end",
"def ping (on: hosts, quiet: false)\n log.info \"ping\", quiet: quiet do\n hash_map(hosts) do |host|\n host.ping\n end\n end\n end",
"def receive_ping\n done\n end",
"def ping\n with_client do |client|\n client.ping\n end\n end",
"def flush_all\n # It can take a long time to flush all of the messages\n # on a server, so we'll set the read timeout to something\n # much higher than usual.\n connection.with_additional_read_timeout(60) do\n resp = send_recv( KJess::Request::FlushAll.new )\n return KJess::Response::End === resp\n end\n end",
"def ping\n\t\tputs \"Pinging #{@ip} ...\"\n\t\tsystem \"ping #{ip_string}\"\n\tend",
"def on_ping(connection, servers)\n end",
"def pong(*servers)\n send_data(\"PONG #{servers.join(' ')}\")\n end",
"def ping\n result = RhizomePingJob.new(@rhizome).perform_now\n\n if result[:connected]\n flash[:success] = \"Pinged <strong>#{result[:name]}</strong>!<br />\" <<\n \"Here's what I got:<br />\" <<\n \"<pre>#{JSON.pretty_generate(result)}</pre>\"\n else\n flash[:danger] = \"It appears that <strong>#{result[:name]}</strong> is not connected...<br />\" <<\n \"Here's what I know:<br />\" <<\n \"<pre>#{JSON.pretty_generate(result)}</pre>\"\n end\n\n redirect_to rhizomes_url\n end",
"def sendBroadCast(blank, msg)\n for addr in @routing_table.keys\n if @routing_table[addr][\"node_id\"] != blank\n @socket.send msg, 0, @routing_table[addr][\"ip_address\"], @routing_table[addr][\"port\"]\n end\n end\n end",
"def send_queue\n worker_threaded do\n while @connected\n @queue_lock.synchronize do\n @queue.each do |to, queue|\n break if @frame.exceeded?\n if reply = queue.pop\n send_socket_reply(reply)\n end\n end\n @queue.select! { |to,queue| !queue.empty? }\n @queue = Hash[@queue.sort_by { |to,queue| queue.penalty }]\n end\n sleep @frame.sleeptime\n end\n end\n end",
"def ping\n client.ping\n end",
"def patch_ping\n patch 'ping'\n end",
"def send_others(event, data)\n\t\tEM.next_tick {\n\t\t\t@sockets.each do |s|\n\t\t\t\ts.send(event, data) if s != self\n\t\t\tend\n\t\t}\n\tend",
"def send_message(message)\n socket.enqueue_packet(message)\n end",
"def process_pong\n # Take first pong wait and signal any flush in case there was one\n @pongs.synchronize do\n pong = @pongs.pop\n pong.signal unless pong.nil?\n end\n @pings_outstanding -= 1\n @pongs_received += 1\n end",
"def push packet\n begin\n @socket_server.write packet\n rescue Errno::ECONNRESET => e\n p e.message\n close\n reset_connection\n rescue Errno::EPIPE => e\n p e.message\n close\n reset_connection\n rescue Errno::ECONNREFUSED => e\n p e.message\n close\n reset_connection\n end\n end",
"def notify_all_players(command, args)\n client_socket.game.each_player do |player|\n player.send_command(command, *args)\n end\n end",
"def bixsby_say_to_all(message)\n @connections[:clients].each do |client_session, client|\n p client\n formatted_response = package_response(client_session, message)\n client.puts(formatted_response)\n end\n end",
"def run\n until @socket.eof? do\n line = @socket.gets\n\n # Makes sure your bot doesn't timeout!\n if line.match(PING_MSG)\n say \"PONG #{ $~[1]}\"\n else\n bot_main(line)\n end\n end\n end",
"def _start_updates\n\n t = Thread.new do\n packet_manager = PacketManager.instance\n loop do\n # update pacekts\n list_updated = packet_manager.update_streams\n # send\n @clients.each_index do |i|\n c = @clients[i]\n list_updated.each do |p|\n begin\n send_stream(c, p)\n rescue => e\n @clients[i] = nil # to be removed\n PadoaukLog.info \"terminated connection from #{c.peeraddr.to_s}\", self\n c.close\n break # break list_updated.each\n end\n end\n end\n @clients.delete_if { |e| e == nil }\n\n Thread.stop\n end\n end\n\n add_task(t)\n\n end",
"def ping; end",
"def send_message(data, flag, host, port)\n\t\tsocket = UDPSocket.new\n\t\tserialized = Marshal.dump(data)\n\t\tsocket.send serialized, flag, host, port\n\t\tsocket.close\n\t\tputs \"Sending #{data} to #{host}:#{port}\"\n\t\tsleep(0.025)\n\tend",
"def send data\n data = [data.bytesize, *data.bytes].pack 'NC*'\n\n @socket.send data, 0\n end",
"def send\n bytes_sent = 0\n update_header\n\n Logger.info \"head: #{header.inspect}\"\n Logger.info \"body: #{message.inspect}\"\n\n for i in 0..(chunk_count-1)\n self.header.header_length = header_length_for_chunk(i)\n bytes_sent += send_chunk chunks[i]\n end\n\n PendingRequest.create self, @connection\n\n bytes_sent\n end",
"def notify\n socket.write('x')\n end",
"def ping(str)\n heartbeat(0b10001001, str)\n end",
"def send(message)\n socket.send(message, 0, address, port)\n end",
"def ping(opts = {})\n data, _status_code, _headers = ping_with_http_info(opts)\n data\n end",
"def ping(*args)\n get '/invoke/wm.server/ping'\n end",
"def remote_pong(sender, body)\n presence = _pop_token(body)\n req = @var.delete :ping_request\n if req\n _notice(\"Ping reply from #{sender}: #{((Time.now - req) * 1000).to_i}ms\",\n :notice)\n end\n if [ 'online', 'away' ].include?(presence)\n _adjust_presence(presence, _user_keyhash(sender), '', body, true)\n end\nend",
"def ping()\n #This is a stub, used for indexing\n end",
"def pong(sock,msg=nil)\n unless msg.nil? or msg.type == Protocol::MessageType::PONG\n Routing.log {|logger| logger.error(self.class) { 'Not a PONG message.'}}\n return false\n end\n if msg.nil?\n msg = construct_pong\n end\n bytes = @protocol.send_message(sock,msg)\n @bandwidth_manager.uploaded(bytes,Time.now-msg.ftime.to_time) unless @bandwidth_manager.nil?\n Routing.log {|logger| logger.info(self.class) { \"PONG message is sent. Size: #{bytes} bytes.\"}}\n true\n end",
"def send_message_on_socket(packed_message, socket)\n begin\n total_bytes_sent = socket.send(packed_message)\n if total_bytes_sent != packed_message.size\n packed_message.slice!(0, total_bytes_sent)\n while packed_message.size > 0\n byte_sent = socket.send(packed_message)\n total_bytes_sent += byte_sent\n packed_message.slice!(0, byte_sent)\n end\n end\n total_bytes_sent\n rescue => ex\n socket.close\n raise ConnectionFailure, \"Operation failed with the following exception: #{ex}:#{ex.message}\"\n end\n end",
"def on_ping(m)\n post PONG, m[0] ? m[0] : (@prefix ? @prefix.nick : \"\")\n end",
"def ping\n self.last_ping = Time.now\n end",
"def poison()\n\t puts \"ARP Poisining started...\"\n\t\t while true do\n\t\t \t@v_packet.to_w(@ifname)\n\t\t \tsleep(1)\n\t\t \t@r_packet.to_w(@ifname)\n\t\t \tsleep(1)\n\t\t end\n\tend",
"def ping(t)\n \n end",
"def on_ping nonce\n log.debug { \">> ping (#{nonce})\" }\n send_data(Protocol.pong_pkt(nonce)) if nonce\n end",
"def ping\n @ping = Time.now\n end",
"def send_pending; end",
"def connect_supernodes(sns)\n ping_msg = construct_ping\n group = ThreadGroup.new\n sns.each do |sn|\n t = Thread.new(sn) { |sn|\n sock = handshaking(sn)\n if !sock.nil? and ping(sock,ping_msg)\n @lock.synchronize { @socks << sock }\n end\n }\n group.add(t)\n end\n group.list.each { |t| t.join }\n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def handle_ping_message(message)\n # The last part of the PING message is the so-called \"challenge\". The server expects that we reply\n # back with this exact string. Therefore we extract it here.\n challenge = message.split(\" \").last\n\n # We send back an IRC \"PONG\" message with the challenge that came from the server.\n irc_send \"PONG #{challenge}\"\nend",
"def sending(message, repeat)\n @req = Thread.new do\n count = 0\n repeat.times do\n count += 1\n @server.puts message\n puts \"Amount Of Requests #{count}\"\n end\n end\n end",
"def send_raw(data)\n socket.send_raw data\n end",
"def on_ping nonce\n log \">> ping (#{nonce})\"\n send_data(Bitcoin::Protocol.pong_pkt(nonce)) if nonce\n end",
"def ping(server, target = '')\n send_data(\"PING #{server} #{target}\".strip)\n end"
] | [
"0.71765536",
"0.64182895",
"0.64092845",
"0.62453675",
"0.62212956",
"0.61426455",
"0.6081005",
"0.5954288",
"0.59502035",
"0.59472543",
"0.59466946",
"0.5917659",
"0.5876896",
"0.577325",
"0.5772197",
"0.5748139",
"0.5626021",
"0.5625602",
"0.56120896",
"0.56100816",
"0.55795044",
"0.55498785",
"0.554973",
"0.5525393",
"0.55226433",
"0.5512212",
"0.5484729",
"0.5462966",
"0.5460571",
"0.5415846",
"0.5415846",
"0.5406264",
"0.5404961",
"0.540187",
"0.53705484",
"0.5348399",
"0.5343209",
"0.5337863",
"0.5336133",
"0.5312235",
"0.53058606",
"0.52974474",
"0.5277439",
"0.52593005",
"0.5255539",
"0.5235697",
"0.52346665",
"0.5233332",
"0.5219167",
"0.5215538",
"0.5212604",
"0.5209698",
"0.52020276",
"0.5182929",
"0.5173404",
"0.5144683",
"0.51114017",
"0.51083905",
"0.5096062",
"0.5095278",
"0.50949395",
"0.5089821",
"0.5076173",
"0.5073134",
"0.50639844",
"0.50626",
"0.50608724",
"0.5057349",
"0.50417185",
"0.50358605",
"0.503104",
"0.50275487",
"0.50229305",
"0.49892703",
"0.49798483",
"0.49781114",
"0.4970797",
"0.49647322",
"0.49558592",
"0.49536213",
"0.49477124",
"0.49445567",
"0.49093935",
"0.49031475",
"0.4902402",
"0.4893421",
"0.4890343",
"0.48890474",
"0.48845133",
"0.48823377",
"0.48793584",
"0.48791406",
"0.48784196",
"0.48763755",
"0.48654306",
"0.4862844",
"0.4852711",
"0.4848566",
"0.4848171",
"0.48390853"
] | 0.7254184 | 0 |
addition num1,num2 num1 and num2 are arguments | def addition num1,num2 #num1 and num2 are known as parameters
puts num1 + num2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(num1, num2)\r\n num1 + num2\r\n end",
"def add(num_1, num_2)\n\tresult = num_1 + num_2\n\treturn result\nend",
"def add(num_1, num_2)\n\treturn num_1 + num_2\nend",
"def add\n\t number_1 + number_2\n end",
"def addition (num1, num2)\n\tnum1 + num2\nend",
"def add(num1, num2)\n return num1 + num2\n end",
"def add(num_1, num_2)\n num_1+num_2\nend",
"def add(num1,num2)\n\treturn num1 + num2\nend",
"def add(num_1, num_2)\n num_1+num_2\nend",
"def additionm(num_1,num_2)\n return num_1 + num_2\nend",
"def add (num_1, num_2)\n\n num_1 + num_2\n\nend",
"def add(num_1, num_2)\n num_1 + num_2\nend",
"def add (num_one, num_two)\n num_one + num_two\nend",
"def add ( num_1, num_2)\n num_1.to_i + num_2.to_i\nend",
"def addition(num1, num2)\n num1 + num2\nend",
"def add(num_one, num_two)\n num_one + num_two\nend",
"def sum num1, num2\n\ttotal = num1 + num2\n\treturn total\nend",
"def add num1, num2\n num1 + num2\nend",
"def add (num1, num2)\n num1 + num2\nend",
"def add_num(num1,num2)\r\n return num1 + num2\r\nend",
"def add(num1,num2)\n result = num1 + num2\nend",
"def add(num1,num2)\n result = num1 + num2\nend",
"def add(num_1, num_2)\n puts num_1 + num_2\nend",
"def add(num1,num2)\n num1+num2\nend",
"def add(num1,num2)\n num1 + num2\nend",
"def add(num_1, num_2)\n\tnum_1 = 2\n\tnum_2 = 3\n\tnum_1 + num_2\nend",
"def add(num_1, num_2)\n\tnum_1.to_i + num_2.to_i\n#add(2, 4)\nend",
"def addition(num_one, num_two)\n return num_one + num_two\nend",
"def addition(num1, num2)\n return num1 + num2\nend",
"def add(num_1, num_2)\n sum = num_1 + num_2\nend",
"def add_nums(num_1,num_2)\n\treturn num_1.to_i + num_2.to_i\nend",
"def add(num1, num2)\n num1+num2\nend",
"def add(num1,num2)\n num1 + num2 \nend",
"def add(number_1, number_2)\n number_1 + number_2\nend",
"def add(num_1, num_2)\n #your code here\n \treturn num_1 + num_2\nend",
"def addition(num1, num2)\n num1.to_i + num2.to_i\nend",
"def add(n1,n2)\n\tn1+n2\nend",
"def add (number1, number2)\n number1 +number2\nend",
"def addition(num_1, num_2)\n num_1 + num_2\n return num_1 + num_2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n num1 + num2\nend",
"def add(num1, num2)\n result = num1 + num2\nend",
"def add(num1, num2)\n result = num1 + num2\nend",
"def add_numbers(number1, number2)\n return sum\nend",
"def add(num_one, num_two)\n return num_one + num_two\nend",
"def add(num_one, num_two)\n return num_one + num_two\nend",
"def add(num_one, num_two)\n return num_one + num_two\nend",
"def add(num_one, num_two)\n return num_one + num_two\nend",
"def add_num(num_1, num_2)\n return num_1.to_i + num_2.to_i\nend",
"def sum_these_numbers(num1, num2)\n num1 + num2\nend",
"def add (first_number , second_number)\n return first_number + second_number\nend",
"def add(num1, num2)\n sum = num1 + num2\n return sum\nend",
"def add(n1, n2)\n\tn1 + n2\nend",
"def add(num_1, num_2)\n\tnum_1.to_i + num_2.to_i\n# add(10, 5)\nend",
"def add(first_num, second_num)\n @result = (first_num + second_num)\nend",
"def plus(number, other)\n\tnumber + other\nend",
"def add(num_1, num_2)\n #your code here\n \treturn (num_1 + num_2)\nend",
"def add( first_number, second_number )\n return first_number + second_number\nend",
"def add_nums(num_1, num_2)\n return num_1.to_i + num_2.to_i\nend",
"def add_nums(num_1, num_2)\n return num_1.to_i + num_2.to_i\nend",
"def addition(num1, num2)\n return num1 + num2 # return keyword terminates method \n end",
"def add(num1, num2)\n return num1 + num2\nend",
"def add(num1, num2)\n return num1 + num2\nend",
"def add(num1, num2)\n return num1 + num2\nend",
"def total(num1, num2)\n num1 + num2\nend",
"def addition_method(num1, num2)\n\tputs num1 + num2\nend",
"def add(num1, num2)\n puts num1 + num2\nend",
"def add(num_1, num_2)\n p num_1 + num_2\nend",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def sum_these_numbers(num1,num2)\n p num1 + num2\nend",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def add(first_number, second_number)\n return first_number + second_number\nend",
"def add(number_one, number_two)\n return number_one + number_two\nend",
"def add(number1, number2)\n number1 + number2\nend",
"def add(number1, number2)\n number1 + number2\nend",
"def add(number_1, number_2)\n return number_1 + number_2\nend",
"def add(num_one,num_two)\n puts \"#{num_one} + #{num_two} = #{num_one + num_two}\"\nend",
"def sum(num1, num2)\n return num1 + num2\nend",
"def add_nums(num1,num2)\n p num1 + num2\nend",
"def add(val1, val2) val1 + val2 end",
"def add(number1, number2)\n number1+number2\nend",
"def add(num1,num2)\n\tputs \"num1 has the value : #{ num1 }\"\n\tputs \"num2 has the value : #{ num2 }\"\n\tresults = num1 + num2\n\tputs \"results is then: #{ results}\"\nend",
"def total(num1, num2)\n puts num1 + num2\nend",
"def add_numbers(num1, num2)\n p num1 + num2\nend",
"def add(number_1, number_2)\n p number_1 + number_2\nend",
"def sum_it(num1, num2)\n return num1 + num2\nend",
"def numbers(num1, num2)\n puts \"#{num1} + #{num2}\"\n return num1 + num2\nend",
"def addition(num1, num2)\n p num1 + num2\nend",
"def sum_nums(num1, num2)\n puts num1 + num2\nend",
"def add(first_num, second_num)\n first_num.to_f + second_num.to_f\nend",
"def sum(num1, num2)\n num1 * num2\nend",
"def sum(number1, number2)\ntotal = number1 + number2 \nend",
"def sum(num1, num2)\n puts num1 + num2\nend",
"def add\n @input1 = params[:input1]\n @input2 = params[:input2]\n @input1 = @input1.to_i\n @input2 = @input2.to_i\n @add = @input1 + @input2\n end"
] | [
"0.8480702",
"0.83641124",
"0.8307389",
"0.8301309",
"0.82921886",
"0.82118493",
"0.81877893",
"0.81766295",
"0.8175005",
"0.8156116",
"0.8143135",
"0.8138902",
"0.81191194",
"0.8062816",
"0.8059181",
"0.8053745",
"0.8021621",
"0.8003152",
"0.7982453",
"0.7970628",
"0.7958727",
"0.7958727",
"0.7958524",
"0.79519784",
"0.79503274",
"0.7945145",
"0.7942624",
"0.7941014",
"0.7932646",
"0.7925739",
"0.792304",
"0.7918159",
"0.79159755",
"0.7899296",
"0.7898004",
"0.78940946",
"0.788456",
"0.78821075",
"0.7873878",
"0.78722507",
"0.78722507",
"0.78722507",
"0.78722507",
"0.78722507",
"0.78722507",
"0.78693867",
"0.78693867",
"0.78593636",
"0.78532314",
"0.78532314",
"0.78532314",
"0.78532314",
"0.7849118",
"0.78373575",
"0.7837149",
"0.783681",
"0.7821361",
"0.7813601",
"0.7790686",
"0.77803254",
"0.7779146",
"0.77582574",
"0.7744437",
"0.7744437",
"0.7741025",
"0.7740694",
"0.7740694",
"0.7740694",
"0.77384466",
"0.7734439",
"0.77285284",
"0.7724502",
"0.7707737",
"0.7705043",
"0.769034",
"0.7688553",
"0.7688553",
"0.7688553",
"0.76869804",
"0.7682238",
"0.7682238",
"0.7680164",
"0.7677096",
"0.76753926",
"0.7674296",
"0.76722693",
"0.76653254",
"0.7659557",
"0.76254785",
"0.7602817",
"0.75877684",
"0.7584753",
"0.75757456",
"0.7572581",
"0.7569744",
"0.7558892",
"0.7556862",
"0.75515974",
"0.75431156",
"0.75271195"
] | 0.79337364 | 28 |
Needed to properly handle undo. | def preloadJoint(type)
dir = File.dirname(__FILE__)
path = File.join(dir, "joints/#{type}.skp")
cd = Sketchup.active_model.definitions.load(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def undo\n\t\t\n\tend",
"def undo\n\t\t\n\tend",
"def undo\n\t\t\t\t\n\t\t\tend",
"def onTransactionUndo(_)\n return if !tool_active? || @undone\n\n @undone = true # prevent recursion\n Sketchup.undo # call a second undo since new operation has already started\n update_comp\n refresh_html\n end",
"def undo\n $log.debug \" got UNDO call #{@pointer}, sz:#{@actions.size} \"\n return if @pointer == 0\n @reject_update = true\n @pointer -=1 #if @pointer > 0\n @source.repaint_required true\n @reject_update = false\n edit = @actions[@pointer]\n perform_undo edit\n end",
"def dont_undo\n @should_undo = false\n return nil\n end",
"def can_undo?; @last_done >= 0; end",
"def undo\n\t\tundoCommandList.each do |commandItem|\n\t\t\tcommandItem.undo\n\t\tend\n\tend",
"def undo()\n return @history.pop\n end",
"def undo\n if(@history != nil)\n @history.undo\n end\n end",
"def undo\n return unless applied = self.applied\n\n applied.undo\n\n self.applied = applied.parent\n self.pending = applied\n end",
"def undo\n\t\t@memo.call\n\tend",
"def undo\n raise \"Can't undo unless there are commands in past\" unless can_undo?\n\n @actions[@last_done].undo\n @last_done -= 1\n\n nil\n end",
"def undo\n {\n method: \"DOM.undo\"\n }\n end",
"def undo\n\t\t@moves.undo\n\tend",
"def undo_button_was_pushed()\n @undo_command.undo\n end",
"def undo_button_was_pushed()\n @undo_command.undo\n end",
"def undo\n\t\t@space.entities.delete @clone\n\t\t\n\t\t@already_added = false\n\tend",
"def undo_changes\r\n return synchronize( true )\r\n end",
"def undo\n if current_ident == @undo.last\n # reset\n self.current_db_value = current_question[\"question\"].value\n @undo.pop\n update_toolbar\n else\n old = @all_failed_questions.assoc(@undo.last)\n return unless old\n self.current_question = old[1]\n end\n end",
"def undo\n\t\tif @moves.last != nil\n\t\t\t@redo.push(@moves.pop)\n\t\t\treturn @redo.last\n\t\tend\n\t\treturn [[[0,0]],\"outOfBound\"]\n\tend",
"def undo\n fan.medium\n end",
"def undo\n fan.medium\n end",
"def undo\n if !(isAtBeginning)\n @actions[@index].applyOpposite\n @index -= 1\n end\n end",
"def undo\n\t\t@space.entities.delete @ui_entity\n\tend",
"def undo cursor\n if @diffHistoryPosition < @diffHistory.size\n @diffHistoryPosition = 0 if @diffHistoryPosition < 0\n diff = @diffHistory[@diffHistoryPosition]\n patch diff, :unpatch\n cursor.moveToLine diff.cursorBefore[0]\n cursor.moveToColumn diff.cursorBefore[1]\n @diffHistoryPosition += 1\n return :success\n end\n :failure\n end",
"def notifyUndoUpdate\n updateCommand(Wx::ID_UNDO) do |ioCommand|\n if (@UndoStack.empty?)\n ioCommand[:Title] = 'Undo'\n ioCommand[:Enabled] = false\n else\n lLastOperationTitle = @UndoStack[-1].Title\n ioCommand[:Title] = \"Undo #{lLastOperationTitle}\"\n ioCommand[:Enabled] = true\n end\n end\n end",
"def undo_penalty\n 2 ** self.undo_count\n end",
"def undo!\n bb = @stack.pop\n set_black(bb[:black])\n set_white(bb[:white])\n end",
"def undo \n if(@hasExecuted==true and (File::exist?(@newPath)))\n FileUtils.cp_r(@newPath, @ogPath)\n FileUtils::rm_r(@newPath)\n @hasExecuted=false\n end\n end",
"def putback()\n\t\treturn UndoScan.new\n\tend",
"def mark_undoable_state\n {\n method: \"DOM.markUndoableState\"\n }\n end",
"def undo\n fan.off\n end",
"def undoEmpty?\n return @undoStack.empty? \n end",
"def perform_redo act\n row = act.row\n col = act.index0\n $log.debug \" REDO processing #{act} \"\n case act.type\n when :INSERT\n @source.list[row].insert(col, act.text)\n when :DELETE\n row = act.row\n col = act.index0\n howmany = act.index1 - col\n @source.list[row].slice!(col,howmany)\n when :DELETE_LINE\n #$log.debug \" UNDO redo got deleteline #{row} \"\n #@source.list.delete_at row\n # changed on 2010-05-23 12:21 since was not handling mult delete\n case act.text\n when Array\n act.text.size.times { @source.list.delete_at row }\n when String\n @source.list.delete_at row\n end\n when :INSERT_LINE\n case act.text\n when Array\n index = row\n act.text.each_with_index{|r,i| @source.list.insert index+i, r}\n when String\n @source.list.insert row, act.text\n end\n else\n $log.warn \"unhandled change type #{act.type} \"\n end\n end",
"def undo_dirty_event!\n decrement_version!\n @_dirty_events.pop\n\n self\n end",
"def undo\n light.off\n end",
"def undo\n light.on\n end",
"def undo\n transaction do\n undoables = self.class.find(:not_undone, :all, :to => self.id, :include => :changes)\n raise Stale unless undoables.include? self\n undoables.each do |op|\n op.changes.each { |change| change.undo }\n op.undone = true\n op.save!\n end\n end\n end",
"def onMaterialUndoRedo(materials, material)\n end",
"def undo\n @workout.undo\n redirect_to workout_path(@workout),\n notice: t('.success')\n end",
"def undo \n if(@hasExecuted==true and (File::exist?(@newPath)))\n File::delete(@newPath)\n @hasExecuted=false\n end\n end",
"def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) \n end",
"def undo()\r\n #need to manipulate strings by taking file name off of OldFilePath and adding it onto NewFilePath\r\n oldname = @OldFilePath.basename\r\n @NewFilePath = \"#{@NewFilePath}/#{oldname}\"\r\n origfolder = @OldFilePath.dirname\r\n @OldFilePath = origfolder\r\n\r\n FileUtils.mv(@NewFilePath, @OldFilePath)\r\n end",
"def undo\n\t\tremake = CreateFileCommand.new(filePath, fileContent)\n\t\tremake.execute\n\tend",
"def undo(frame)\n @xorify.unpack( undo_bypass(frame) )\n end",
"def redo\n $log.debug \"UNDO GOT REDO call #{@pointer}, #{@actions.size} \"\n return if @pointer >= @actions.size\n @reject_update = true\n edit = @actions[@pointer]\n perform_redo edit\n @source.repaint_required true\n @pointer +=1 #if @pointer > 0\n @reject_update = false\n end",
"def rollback()\n #This is a stub, used for indexing\n end",
"def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) # 2010-09-11 13:01 \n end",
"def undo\n if done\n @text = text.sub(DONE_REGEX, '').strip\n @done = false\n end\n end",
"def setUndoOnClick\n @undoButton.onClick(){\n @gridUi.undo\n }\n end",
"def can_undo?\n !send_message(:CANUNDO).zero?\n end",
"def windowWillReturnUndoManager(window)\n self.managedObjectContext.undoManager\n end",
"def windowWillReturnUndoManager(window)\n self.managedObjectContext.undoManager\n end",
"def windowWillReturnUndoManager(window)\n self.managedObjectContext.undoManager\n end",
"def rl_add_undo(what, start, _end, text)\r\n temp = alloc_undo_entry(what, start, _end, text)\r\n temp.next = @rl_undo_list\r\n @rl_undo_list = temp\r\n end",
"def revert(evt)\n version = Version.find(evt[:id])\n if version.reify\n version.reify.save!\n else\n version.item.destroy\n end\n is_redo = evt[:redo] == 'true'\n trigger :flash, :notice => undo_notice(is_redo, version)\n trigger :reload_grid\n render :nothing => true\n end",
"def can_undo(possible)\n #@tool_buttons[:undo].enabled = possible\n end",
"def undo!(append: Logidze.append_on_undo)\n version = log_data.previous_version\n return false if version.nil?\n\n switch_to!(version.version, append: append)\n end",
"def make_undo_link\n view_context.link_to 'Undo that please!', undo_path(@article.versions.last), method: :post\n end",
"def redo()\n if(@listeRedo.length > 0)\n @listeUndo << @listeRedo.pop()\n end\n\t\treturn @listeUndo.last()\n end",
"def windowWillReturnUndoManager(window)\n self.managedObjectContext.undoManager\n end",
"def undo!(modifier = nil, options_or_version = nil)\n undo(modifier, options_or_version)\n save!\n end",
"def revert\n end",
"def undo\n\n if @upload.nil?\n notify_user(:alert, \"Record not found!\")\n redirect_to uploads_url\n return\n end\n\n @upload.reset\n @upload.update(file_status_type: FileStatusType.find_by(name: \"Reverted\"))\n\n notify_user(:notice, \"Upload has been reverted.\")\n\n # show the original upload\n redirect_to(upload_url(@upload))\n\n end",
"def undo_update\n # CreateDefaultRoles.where(:type_code => 'very_shiny').first.delete\n end",
"def undo(value)\n merge(undo: value.to_s)\n end",
"def undo task, is_num\n\t\t\tif is_num\n\t\t\t\tif !@completed_tasks[task.to_i].nil?\n\t\t\t\t\t@tasks[task.to_i] = @completed_tasks[task.to_i]\n\t\t\t\t\t@completed_tasks.delete(task.to_i)\n\t\t\t\t\t@completed_count-=1\n\t\t\t\t\t@tasks = Hash[@tasks.sort]\n\t\t\t\t\tputs \"Undo completeing #{@tasks[task.to_i]}.\"\n\t\t\t\telse\n\t\t\t\t\tputs \"Task \\##{task} not in list.\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\thash = Hash.new\n\t\t\t\t@completed_tasks.each do |k,v|\n\t\t\t\t\thash[k] = v.downcase\n\t\t\t\tend\n\t\t\t\tif hash.value?(task.downcase)\n\t\t\t\t\tnum = hash.key(task.downcase)\n\t\t\t\t\t@tasks[num] = @completed_tasks[num]\n\t\t\t\t\t@completed_tasks.delete(num)\n\t\t\t\t\t@completed_count-=1\n\t\t\t\t\t@tasks = Hash[@tasks.sort]\n\t\t\t\t\tputs \"Undo completeing #{@tasks[num]}.\"\n\t\t\t\telse\n\t\t\t\t\tputs \"Task #{task} is not in list.\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tupdate\n\t\tend",
"def rollback\n end",
"def restore; end",
"def undo(all = false)\n @operations.find(:not_undone, (all ? :last : :first)).undo\n end",
"def undo\n case @last_level\n when ON\n @light.on\n when OFF\n @light.off\n else\n @light.dim @last_level\n end\n end",
"def undo\n case @last_level\n when ON\n @light.on\n when OFF\n @light.off\n else\n @light.dim @last_level\n end\n end",
"def undo\n if(File.exist?(@newName) and @hasExecuted == true)\n File.rename(@newName, @filepath)\n @hasExecuted=false\n end\n end",
"def test_undo_quick_start\n job 'jobbist'\n\n start 'jobbist'\n pause\n start\n message = undo\n assert_message(lines(undid_prefix('quick_start'),\n undid_restart_quickly('jobbist')),\n message)\n\n job 'background'\n background 'background'\n\n stop_day\n start_day\n start 'jobbist'\n pause\n start\n\n message = undo\n assert_message(lines(undid_prefix('quick_start'),\n undid_pausing_start_quickly('background')),\n message)\n\n # For laughs, undo way back.\n assert_match(undid_re('pause'), undo) # undo pause\n assert(@session.running?('jobbist'))\n assert(@session.paused?('background'))\n\n assert_match(undid_re('start'), undo) # undo start jobbist\n assert(@session.stopped?('jobbist'))\n assert(@session.running?('background'))\n \n assert_match(undid_re(\"start_day\"), undo) # undo start_day\n assert(@session.stopped?('jobbist'))\n assert(@session.stopped?('background'))\n\n assert_match(undid_re('stop_day'), undo) # undo stop_day\n # This puts us back to the pause of jobbist because the start\n # was undone.\n assert(@session.paused?('jobbist'))\n\n assert(@session.jobs['background'].is_background?)\n assert_match(undid_re('background'), undo) # undo background\n assert_equal(false, @session.jobs['background'].is_background?)\n\n assert_match(undid_re(\"job\"), undo) # undo job\n assert_equal(false, @session.jobs.has_key?('background'))\n\n assert_match(undid_re('pause'), undo) # pause jobbist\n assert(@session.running?('jobbist'))\n\n assert_match(undid_re('start'), undo) # start jobbist\n assert(@session.active_records.empty?)\n assert(@session.records.empty?)\n\n assert_match(undid_re('job'), undo) # job 'jobbist'\n assert(@session.jobs.empty?)\n end",
"def can_redo\n false\n end",
"def redo\n if(@history != nil)\n @history.redo\n end\n end",
"def rl_revert_line(count, key)\r\n if @rl_undo_list.nil?\r\n rl_ding()\r\n else\r\n while (@rl_undo_list)\r\n rl_do_undo()\r\n end\r\n if (@rl_editing_mode == @vi_mode)\r\n @rl_point = @rl_mark = 0 # rl_end should be set correctly\r\n end\r\n end\r\n 0\r\n end",
"def do_preparation_tool_undo(wdialog, pstr_a=[])\n\t\treturn false if (!valid)\n\t\treturn false if ( (!pstr_a.is_a?(Array)) || (pstr_a.empty?) )\t \n\t\tif NameRegionTool.instance.has_multiple_regions?\n\t\t\tdo_select_region_name wdialog, :callback => 'execute_preparation_tool_undo', :callback_params => pstr_a[0]\n\t\telse\n\t\t\t#only one region\n\t\t\texecute_preparation_tool_undo wdialog, pstr_a\n\t\tend\n\tend",
"def rollback; end",
"def rollback; end",
"def rollback; end",
"def rollback; end",
"def rollback; end",
"def undolist\n @ranks = Rank.only_deleted.reverse\n end",
"def undo buffer\n @frames[buffer].undo buffer\n end",
"def undo_changes\n @statistics[:rejected] += 1\n \n # restore state of previous solution\n case @last_change\n when :offset\n @current_offset[@changed_sc] = @previous_offset\n when :speed\n @current_speed[@changed_coord] = @previous_speed\n else\n raise \"Don't know how to undo a '#{@last_change}' change!\"\n end\n \n # delta-restore the value of the solution\n for coord, old_value in @delta_contribution\n current_value = @coord_contribution[coord]\n @direction_sum[coord.left_to_right] -= current_value\n @coord_contribution[coord] = old_value\n @direction_sum[coord.left_to_right] += old_value\n end\n \n store_current_value\n \n raise \"Restoration of previous solution failed after change in #{@last_change}:\\n\" +\n \"expected value #{@current_value_check} got #{@current_value}\" if (1 - @current_value_check / @current_value).abs > EPS\n end",
"def windowWillReturnUndoManager(window)\n return self.managedObjectContext.undoManager\n end",
"def undo_update\n # <%= class_name %>.where(:type_code => \"very_shiny\").first.delete\n end",
"def rollback\n # implement in subclasses\n end",
"def redoPrevious\n if !@undoRedo.redoStack.empty?\n n2 = @undoRedo.redoStack.pop()\n n1 = @undoRedo.redoStack.pop()\n\n @undoRedo.undoStack << n2\n @undoRedo.undoStack << n1\n \n \n ajoutPont(n2,n1)\n end\n\n return self\n end",
"def rl_undo_command(count, key)\r\n if (count < 0)\r\n return 0 # Nothing to do.\r\n end\r\n while (count>0)\r\n if (rl_do_undo())\r\n count-=1\r\n else\r\n rl_ding()\r\n break\r\n end\r\n end\r\n 0\r\n end",
"def undo_record(&block)\n VER.warn 'Buffer is Read-only' if readonly\n undoer ? undoer.record_multi(&block) : yield(self)\n ensure\n self.pristine = false\n end",
"def undo()\r\n oldname = @FilePath.basename\r\n @CopiedFilePath = \"#{@CopiedFilePath}/#{oldname}\"\r\n origfolder = @FilePath.dirname\r\n @FilePath = origfolder\r\n FileUtils.mv(@CopiedFilePath, @FilePath)\r\n end",
"def undo_message(is_redo, record)\n \"Last change #{is_redo ? 're' : 'un'}done for #{record_name(record)}.\"\n end",
"def dirty; end",
"def undo_update\n # CreateDefaultAdminUser.where(:type_code => 'very_shiny').first.delete\n end",
"def redo\n\t\t@moves.redo\n\tend",
"def can_redo?; @last_done < (@actions.size - 1); end",
"def on_button_was_pushed(slot)\n @on_commands[slot].execute\n @undo_command = @on_commands[slot]\n end",
"def on_button_was_pushed(slot)\n @on_commands[slot].execute\n @undo_command = @on_commands[slot]\n end"
] | [
"0.8342604",
"0.8342604",
"0.8096284",
"0.74099743",
"0.7370062",
"0.7285018",
"0.7250229",
"0.7147068",
"0.7091712",
"0.7046041",
"0.6973567",
"0.69717723",
"0.69685024",
"0.6950134",
"0.69033325",
"0.69011426",
"0.69011426",
"0.68342555",
"0.6821937",
"0.68106717",
"0.6802466",
"0.67433655",
"0.67433655",
"0.6696419",
"0.66678715",
"0.66311204",
"0.6593099",
"0.6575911",
"0.65337986",
"0.6529543",
"0.6516167",
"0.6501644",
"0.650107",
"0.64978",
"0.64939845",
"0.6471121",
"0.64191675",
"0.6407651",
"0.6403283",
"0.63888633",
"0.63870746",
"0.6365581",
"0.6364417",
"0.6358326",
"0.63566667",
"0.6351982",
"0.63476515",
"0.6346262",
"0.62880355",
"0.6241977",
"0.6230427",
"0.6194011",
"0.6181894",
"0.6181894",
"0.6181894",
"0.6160877",
"0.61542714",
"0.6129309",
"0.61252844",
"0.61231124",
"0.6119418",
"0.61139625",
"0.6111651",
"0.6103952",
"0.60977805",
"0.6095538",
"0.6094462",
"0.6055142",
"0.6033781",
"0.60308707",
"0.60288554",
"0.6006125",
"0.6006125",
"0.60046923",
"0.59973353",
"0.59936637",
"0.5986403",
"0.598319",
"0.5977146",
"0.5964879",
"0.5964879",
"0.5964879",
"0.5964879",
"0.5964879",
"0.5955663",
"0.59549314",
"0.5952621",
"0.59301215",
"0.59295875",
"0.5918819",
"0.5899283",
"0.58624387",
"0.58552283",
"0.58316463",
"0.582989",
"0.5806474",
"0.5805929",
"0.58034617",
"0.5803026",
"0.5788287",
"0.5788287"
] | 0.0 | -1 |
This is called when the user types a value into the VCB | def onUserText(text, view)
# The user may type in something that we can't parse as a length
# so we set up some exception handling to trap that
begin
value = text.to_l
rescue
# Error parsing the text
UI.beep
value = nil
Sketchup.set_status_text '', SB_VCB_VALUE
end
return unless value
case @state
when 1
# update the width
vec = @pts[1] - @pts[0]
if vec.length > 0.0
vec.length = value
@pts[1] = @pts[0].offset(vec)
view.invalidate
increment_state
end
when 2
# update the height
vec = @pts[3] - @pts[0]
if vec.length > 0.0
vec.length = value
@pts[2] = @pts[1].offset(vec)
@pts[3] = @pts[0].offset(vec)
increment_state
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_input key_value\n\n @key_value = key_value.to_sym\n changed\n notify_observers self\n\n end",
"def drb_input!\n Vedeu.bind(:_drb_input_) do |data, type|\n Vedeu.log(type: :drb, message: \"Sending input (#{type})\")\n\n case type\n when :command then Vedeu.trigger(:_command_, data)\n when :keypress then Vedeu.trigger(:_keypress_, data)\n else Vedeu.trigger(:_keypress_, data)\n end\n end\n end",
"def doKeyPress( value )\r\n begin\r\n maxLength = @o.maxLength\r\n if (maxLength != -1 && value.length > maxLength)\r\n original_value = value\r\n value = original_value[0..maxLength]\r\n element.log \" Supplied string is #{suppliedValue.length} chars, which exceeds the max length (#{maxLength}) of the field. Using value: #{value}\"\r\n end\r\n rescue\r\n # probably a text area - so it doesnt have a max Length\r\n maxLength = -1\r\n end\r\n for i in 0..value.length-1 \r\n #sleep element.typingspeed # typing speed\r\n c = value[i,1]\r\n #element.log \" adding c.chr \" + c #.chr.to_s\r\n @o.value = \"#{(@o.value.to_s + c)}\" #c.chr\r\n @o.fireEvent(\"onKeyDown\")\r\n @o.fireEvent(\"onKeyPress\")\r\n @o.fireEvent(\"onKeyUp\")\r\n end\r\n \r\n end",
"def onUserText(text, view)\r\n # The user may type in something that we can't parse as a length\r\n # so we set up some exception handling to trap that\r\n begin\r\n value = text.to_l\r\n rescue\r\n # Error parsing the text\r\n UI.beep\r\n value = nil\r\n Sketchup::set_status_text \"\", SB_VCB_VALUE\r\n end\r\n return if !value\r\n # puts \"user text = \" + value.inspect\r\n case @state\r\n when STATE_MOVING\r\n # update the offset of the window or door\r\n @offset = value\r\n find_end_points\r\n view.invalidate\r\n draw_obj\r\n Sketchup.active_model.select_tool(nil)\r\n end\r\nend",
"def onUserText(text, view)\n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n value = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n value = nil\n Sketchup.set_status_text '', SB_VCB_VALUE\n end\n # Process here.\n @numSegments = value\n end",
"def onUserText(text, view)\r\n # The user may type in something that we can't parse as a length\r\n # so we set up some exception handling to trap that\r\n begin\r\n value = text.to_l\r\n rescue\r\n # Error parsing the text\r\n UI.beep\r\n value = nil\r\n Sketchup::set_status_text \"\", SB_VCB_VALUE\r\n end\r\n return if !value\r\n \r\n if (@state == STATE_MOVING && @selection)\r\n vec_back = @start_input_point.position - @pt_to_move\r\n vec = vec_back.reverse\r\n vec.length = value\r\n @pt_to_move = @start_input_point.position + vec\r\n move_points(vec_back)\r\n move_points(vec)\r\n view.invalidate\r\n draw(view)\r\n done\r\n end\r\nend",
"def on_change(value)\n \n end",
"def value\n @knob.typed_value\n end",
"def onUserText(text, view)\r\n # The user may type in something that we can't parse as a length\r\n # so we set up some exception handling to trap that\r\n begin\r\n value = text.to_l\r\n rescue\r\n # Error parsing the text\r\n UI.beep\r\n value = nil\r\n Sketchup::set_status_text \"\", SB_VCB_VALUE\r\n end\r\n return if !value\r\n \r\n # update the offset of the window or door\r\n @offset = value\r\n find_end_points\r\n view.invalidate\r\n self.draw_obj\r\n Sketchup.active_model.select_tool(nil)\r\nend",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_Text(value)\n set_input(\"Text\", value)\n end",
"def set_Vote(value)\n set_input(\"Vote\", value)\n end",
"def set_Vote(value)\n set_input(\"Vote\", value)\n end",
"def set_SearchValue(value)\n set_input(\"SearchValue\", value)\n end",
"def onUserText(text, view)\r\n # The user may type in something that we can't parse as a length\r\n # so we set up some exception handling to trap that\r\n begin\r\n value = text.to_l\r\n rescue\r\n # Error parsing the text\r\n UI.beep\r\n value = nil\r\n Sketchup::set_status_text \"\", SB_VCB_VALUE\r\n end\r\n return if !value\r\n \r\n if (@state == STATE_PICK_NEXT)\r\n # update the length of the wall\r\n vec = @pts[1] - @pts[0]\r\n if( vec.length > 0.0 )\r\n vec.length = value\r\n @pts[1] = @pts[0].offset(vec)\r\n view.invalidate\r\n self.update_state\r\n end\r\n end\r\nend",
"def get_user_input\n Termbox.tb_poll_event(@event)\n ascii_to_symbol @event[:ch]\n end",
"def run\n loop do\n new_value = @serial_port.gets\n unless (@value == new_value) \n @value = new_value\n changed\n notify_observers(@value) \n end\n end\n end",
"def on_byte_input( &callback )\n\t\traise LocalJumpError, \"no block given\" unless callback\n\t\tself.byte_input_callback = callback\n\tend",
"def set_KeyValue(value)\n set_input(\"KeyValue\", value)\n end",
"def onUserText(text, view)\n return if @last_comp_moved == nil\n \n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n distance = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n puts \"Cannot convert #{text} to a Length\"\n distance = nil\n Sketchup::set_status_text \"\", SB_VCB_VALUE\n end\n return if !distance\n \t\n #\tputs \"moving via VCB: \" << distance.to_s\n \t\n \t# put everything bakc the way we started\n \tif @state == 1 \n \t\tself.reset(view)\n \tend\t\n \tSketchup.undo\t\n \t\n \tif @length < 0 \n \t\tdistance = distance * -1\n \tend\n \t\n \t@ci = @last_comp_moved\n #\tputs \"@gv: \" << @gv.to_s\n \tmov_vec = @gv.clone\n \tmov_vec.transform!(@ci.transformation.inverse)\n \tmov_vec.length = distance\n #\tputs \"mov_vec: \" << mov_vec.to_s\n \tmove_it(mov_vec)\n \tself.reset(view)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def key_up(*args, device: T.unsafe(nil)); end",
"def set_text_input(input); end",
"def selected_changed\n return if searchable\n update_input\n end",
"def controlTextDidChange(notification)\n value = notification.object.stringValue\n\n if value.length == 20\n p \"controlTextDidChange and length is 20: #{value}\"\n self.apiKey = value\n\n NSNotificationCenter.defaultCenter.postNotificationName(\n 'com.cimenu.CIMenu.preferences.token.changed',\n object:nil,\n userInfo:value)\n end\n end",
"def doKeyPress ( o , suppliedValue )\n # o is an object, we assume the calling method has verified its ok....\n\n # we need to check the length of the box here, as script overrides the length attribute of the text box\n # http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/maxlength.asp\n\n fname = getFunctionName()\n #log fname + ' doing keypress on field: ' + o.name.to_s\n value = suppliedValue.to_s\n begin\n maxLength = o.maxLength\n if value.length > maxLength\n value = suppliedValue[0 .. maxLength ]\n log fname + \" Supplied string is #{suppliedValue.length} chars, which exceeds the max length (#{maxLength}) of the field. Using value: #{value}\"if $debuglevel >=0\n end\n rescue\n # its probably a text area - so it doesnt have a max Length\n maxLength = -1\n end\n\n for i in 0 .. value.length-1 \n sleep @typingspeed # typing speed\n c = value[i]\n #log \" adding c.chr \" + c.chr.to_s\n o.value = o.value.to_s + c.chr\n o.fireEvent(\"onKeyPress\")\n if waitForIE( NOWAITFORIE ) \n # we dont do anything if its good....\n else\n return false, [fname + \" problem loading the page\"]\n end\n end\n end",
"def handle_key ch\n $log.debug \"inside handle key of field with #{ch}\"\n @repaint_required = true \n case ch\n when 32..126\n putc ch\n when 27 # cannot bind it, so hardcoding it here\n restore_original_value\n else\n ret = super\n return ret\n end\n 0 # 2008-12-16 23:05 without this -1 was going back so no repaint\n end",
"def start_typing(data); end",
"def start_typing(data); end",
"def on_key(ch)\n end",
"def edit_value(val)\n if data_type == \"string\"\n self.text_raw_value = val\n elsif data_type == \"number\"\n self.number_raw_value = val\n end\n # Note: *_validated_value field is set in the set_validated_values\n # validator.\n end",
"def update\n\t\tupdate_keypress\n\tend",
"def imedidata_rave_connection_data_enter(field, value)\n #if link_account_button\n case field.downcase\n when 'rave account'\n option = rave_account_dropdown_options.detect { |item| item.value == value}\n option.click unless option.nil?\n when 'password'\n password_text.set value\n #TODO: when 'role'\n else\n raise \"Option: #{field} is not supported.\"\n end\n #end\n end",
"def change_keyboard_control! (**hash)\n super(*value_param(KB, hash))\n end",
"def set_value value\n if allows? value\n @set_value_handler.call value\n end\n end",
"def new_text_input\n end",
"def set_Callback(value)\n set_input(\"Callback\", value)\n end",
"def selected_changed\n return if searchable\n update_input\n trigger :change\n @input.blur unless multiple\n end",
"def value\n wait_until_exists\n @text_field.value\n end",
"def test_post\n skip if on_sea_lion?\n\n events = [[0x56,true], [0x56,false], [0x54,true], [0x54,false]]\n string = '42'\n\n search_box.set 'AXFocused', true\n app.post events\n\n assert_equal string, search_box.value\n\n ensure # reset for next test\n search_box.set 'AXValue', ''\n end",
"def on_keypress &b\n on :keypress, &b\n end",
"def on_enter\n #@original_value = getvalue.dup rescue getvalue\n @original_value = @buffer.dup # getvalue.dup rescue getvalue\n super\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def text_input; end",
"def handle_key ch\n super\n end",
"def enter_po_number(po_number)\n po_number_textbox.send_keys(po_number)\n end",
"def onUserText(text, view)\r\n parsed = text.to_f #do not use parse_length function\r\n if (parsed < 1)\r\n parsed = 1\r\n end\r\n if (parsed > (2*PhlatScript.cutFactor))\r\n parsed = 2*PhlatScript.cutFactor\r\n end\r\n if (!parsed.nil?)\r\n @depth = parsed\r\n Sketchup::set_status_text(\"#{@depth.to_s}%\", SB_VCB_VALUE)\r\n# puts \"New Plunge Depth \" + @depth.to_s\r\n end\r\n end",
"def text_field; end",
"def _set_buffer value #:nodoc:\n @repaint_required = true\n @datatype = value.class\n @delete_buffer = @buffer.dup\n @buffer = value.to_s.dup\n # don't allow setting of value greater than maxlen\n @buffer = @buffer[0,@maxlen] if @maxlen && @buffer.length > @maxlen\n @curpos = 0\n # hope @delete_buffer is not overwritten\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, @delete_buffer) # 2010-09-11 13:01 \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :INSERT, 0, @buffer) # 2010-09-11 13:01 \n self # 2011-10-2 \n end",
"def set_SearchForUser(value)\n set_input(\"SearchForUser\", value)\n end",
"def set_Volume(value)\n set_input(\"Volume\", value)\n end",
"def cli=(value); end",
"def set_VoteSmartID(value)\n set_input(\"VoteSmartID\", value)\n end",
"def set_VoteSmartID(value)\n set_input(\"VoteSmartID\", value)\n end",
"def _stomp_input_text(*args)\n Log.debug(\"[GRIDIUM::Element] Clearing \\\"#{value}\\\" from element: (#{self})\")\n element.clear\n sleep @text_padding_time\n Log.debug(\"[GRIDIUM::Element] Typing: #{args} into element: (#{self}).\")\n element.send_keys(*args)\n sleep @text_padding_time\n end",
"def set_VideoType(value)\n set_input(\"VideoType\", value)\n end",
"def what(v)\n @v=v\n end",
"def after_setting_value_callback; end",
"def on_value(&blk)\n opts[:on_value] = blk\n end",
"def on_input_ok\n @@text = @edit_window.text\n return_scene\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Search(value)\n set_input(\"Search\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def set_Word(value)\n set_input(\"Word\", value)\n end",
"def text_field_enter(value)\n control = @field.all(:css, 'input[type=\"text\"]').first\n control.set \"#{value}\"\n end",
"def onUserText(text, view)\n # We only accept input when the state is 1 (i.e. getting the second point)\n # This could be enhanced to also modify the last line created if a length\n # is entered after creating a line.\n # return if not @state == 1\n # return if not @ip2.valid?\n UI.messagebox(\"#{@state}\")\n\n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n value = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n puts \"Cannot convert #{text} to a Length\"\n value = nil\n Sketchup::set_status_text \"\", SB_VCB_VALUE\n end\n return if !value\n\n # Compute the direction and the second point\n pt1 = @ip1.position\n vec = @ip2.position - pt1\n if( vec.length == 0.0 )\n UI.beep\n return\n end\n vec.length = value\n pt2 = pt1 + vec\n\n # Create a line\n self.create_geometry(pt1, pt2, view)\n end",
"def key_change(key)\r\n\tputs \"what is new value you wish to input for #{key}\"\r\n\tnew_input = gets.chomp\r\n\tClient_info[key] = new_input\r\nend",
"def value=(new_value)\n\t\t@value = new_value\n\t\tinform_obeservers\n\tend",
"def key_down_event _value\n send_cmd(\"key_down_event #{_value}\")\n end",
"def process_box value\n box_type = AXValueGetType(value)\n ptr = Pointer.new BOX_TYPES[box_type]\n AXValueGetValue(value, box_type, ptr)\n ptr[0]\n end",
"def set_Receiver(value)\n set_input(\"Receiver\", value)\n end",
"def pbTextEntry(helptext,minlength,maxlength,variableNumber)\n $game_variables[variableNumber] = pbEnterText(helptext,minlength,maxlength)\n $game_map.need_refresh = true if $game_map\nend",
"def on_enter\n #@original_value = getvalue.dup rescue getvalue\n @original_value = @buffer.dup # getvalue.dup rescue getvalue\n $log.debug \" FIELD ORIGINAL VALUE is null in on_enter\" unless @original_value\n $log.debug \" on_enter: setting original_value to #{@original_value}\"\n super\n end",
"def keypress_handler(scancode)\n i = scancode & 0x7f\n x = SCREEN_W() - 100 * 3 + (i % 3) * 100\n y = SCREEN_H() / 2 + (i / 3 - 21) * 10\n color = scancode & 0x80 != 0 ? makecol(255, 255, 0) : makecol(128, 0, 0)\n rectfill(screen, x, y, x + 95, y + 8, color)\n str = ustrzncpy(scancode_to_name(i), 12)\n textprintf_ex(screen, font, x + 1, y + 1, makecol(0, 0, 0), -1, str)\nend",
"def set_Message(value)\n set_input(\"Message\", value)\n end",
"def set_Message(value)\n set_input(\"Message\", value)\n end",
"def set_Message(value)\n set_input(\"Message\", value)\n end",
"def set_Message(value)\n set_input(\"Message\", value)\n end",
"def value(value)\n\t\t@value=value\n\tend",
"def command *args, &block\n if event? :PRESS\n bind :PRESS, *args, &block\n else\n bind :CHANGED, *args, &block\n end\n end",
"def onUserText(text, view)\n # We only accept input when the state is 1 (i.e. getting the second point)\n # This could be enhanced to also modify the last line created if a length\n # is entered after creating a line.\n return if not @state == 1\n return if not @ip2.valid?\n \n # The user may type in something that we can't parse as a length\n # so we set up some exception handling to trap that\n begin\n value = text.to_l\n rescue\n # Error parsing the text\n UI.beep\n puts \"Cannot convert #{text} to a Length\"\n value = nil\n Sketchup::set_status_text \"\", SB_VCB_VALUE\n end\n return if !value\n\n # Compute the direction and the second point\n pt1 = @ip1.position\n vec = @ip2.position - pt1\n if( vec.length == 0.0 )\n UI.beep\n return\n end\n vec.length = value\n pt2 = pt1 + vec\n\n # Create a line\n self.create_geometry(pt1, pt2, view)\n self.reset(view)\nend"
] | [
"0.67211837",
"0.61385584",
"0.6081012",
"0.60395366",
"0.60167617",
"0.5975911",
"0.5957361",
"0.58478045",
"0.5790815",
"0.5788589",
"0.5788589",
"0.5788589",
"0.57644635",
"0.57644635",
"0.5698706",
"0.56936586",
"0.5597294",
"0.55867267",
"0.5567435",
"0.5524521",
"0.5514112",
"0.55091655",
"0.55091655",
"0.55091655",
"0.55091655",
"0.55088407",
"0.5506477",
"0.54894733",
"0.54663557",
"0.54542553",
"0.54261994",
"0.5417534",
"0.5409571",
"0.5406709",
"0.5406709",
"0.5404475",
"0.53576994",
"0.5354713",
"0.53171664",
"0.5304914",
"0.52983487",
"0.5288713",
"0.52818394",
"0.5280042",
"0.52662456",
"0.52580875",
"0.52531683",
"0.5236233",
"0.52349335",
"0.52349335",
"0.5230491",
"0.5205675",
"0.5202416",
"0.5184353",
"0.5172568",
"0.5165784",
"0.51584804",
"0.51487297",
"0.514797",
"0.5144882",
"0.5144882",
"0.5130988",
"0.51247203",
"0.5122991",
"0.5118051",
"0.5117818",
"0.5100608",
"0.5096368",
"0.5096368",
"0.5096368",
"0.5096368",
"0.5096368",
"0.5096368",
"0.5096368",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5087458",
"0.5081162",
"0.5079204",
"0.5078212",
"0.5074577",
"0.506854",
"0.50649387",
"0.50502425",
"0.5049421",
"0.50458586",
"0.50435495",
"0.5042073",
"0.5042073",
"0.5042073",
"0.5042073",
"0.50384367",
"0.50333357",
"0.503221"
] | 0.60324246 | 4 |
Using a private method to encapsulate the permissible parameters is a good pattern since you'll be able to reuse the same permit list between create and update. Also, you can specialize this method with peruser checking of permissible attributes. | def school_class_params
params.require(:school_class).permit(:title, :room_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 permitted_params\n policy(resource || resource_class.new).send(\"permitted_#{action_name}_attributes\")\n end",
"def permitted_create_params\n fail NotImplementedError\n end",
"def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end",
"def strengthen_params!(method_name)\n permitting_model_name = self.class.instance_variable_defined?(:@permitting_model_name) && self.class.instance_variable_get(:@permitting_model_name)\n target_model_name = (permitting_model_name || self.class.name.sub(/.+::/, '').sub(/Controller$/, '')).singularize.underscore.tr('/', '_').to_sym\n permitted_attributes = self.class.instance_variable_defined?(:@permitted_attributes) && self.class.instance_variable_get(:@permitted_attributes)\n\n method_parameters = method(method_name).parameters\n method_parameters.each do |type, key|\n trimmed_key = key.to_s.sub(/_params\\z/, '').to_sym\n if (trimmed_key == target_model_name) && permitted_attributes\n params.require(trimmed_key) if %i[req keyreq].include?(type)\n params[trimmed_key] = params[trimmed_key].try :permit, *permitted_attributes if params.key? trimmed_key\n end\n end\n end",
"def permitted_params\n @implementation_class ||= implementation_class\n\n res = @implementation_class.permitted_params\n @implementation_class.refine_permitted_params res\n end",
"def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end",
"def permitted_params\n res = attribute_names.map(&:to_sym) - %i[disabled user_id created_at updated_at tracker_id tracker_history_id\n admin_id]\n refine_permitted_params res\n end",
"def permitters\n @_parametrizr_permitters || {}\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 permitted_update_params\n fail NotImplementedError\n end",
"def permitted_params\n if is_singleton?\n singleton_permitted_params\n else\n params.require(:data).permit(allowed_resource_params.to_a)\n end\n end",
"def permitted?; end",
"def set_permit\n @vehiclepermit = Permit.find(params[:id])\n authorize @vehiclepermit\n end",
"def permit(type,options={})\n raise NameError.new(\"duplicate ability definition\") if @ability.key? type\n ability_object = GraphQL::Authorization::AbilityType.new(type,nil,{})\n if options.key?(:except) && options.key?(:only)\n raise ArgumentError.new(\"you cannot specify white list and black list\")\n end\n if options[:except]\n ability_object.access(type.fields.keys.map(&:to_sym) - options[:except])\n elsif options[:only]\n ability_object.access(options[:only])\n end\n ability_object.execute options[:execute]\n if block_given?\n #note Proc.new creates a proc with the block given to the method\n ability_object.instance_eval(&Proc.new)\n end\n @ability[type] = ability_object\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def set_permit\n @permit = Permit.find(params[:id])\n end",
"def permit_attributes\n params.require(resource_as_param_key).permit(*permitted_attributes)\n end",
"def request_permitted?(item)\n true\n end",
"def create\n\n vehicle = Vehicle.find_by(license_number: permit_params[:vehicle_attributes][:license_number])\n if current_user.faculty?\n @vehiclepermit = current_user.vehiclepermit.build(permit_params.merge(date_entered: Date.today, \n entered_by: current_user.faculty.first_name + \" \" + current_user.faculty.last_name))\n @vehiclepermit.update(vehicle: vehicle)\n elsif current_user.student?\n @vehiclepermit = current_user.vehiclepermit.build(permit_params.merge(date_entered: Date.today,\n entered_by: current_user.student.first_name + \" \" + current_user.student.last_name))\n @vehiclepermit.update(vehicle: vehicle)\n end\n authorize @permit\n\n respond_to do |format|\n if @vehiclepermit.save\n format.html { redirect_to @vehiclepermit, notice: 'Permit was successfully created.' }\n format.json { render :show, status: :created, location: @vehiclepermit }\n else\n format.html { render :new }\n format.json { render json: @vehiclepermit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_permit\n @permit = Permit.find(params[:id])\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def analise_privacidade_params\n #params.require(:analise_privacidade).permit(:rede_social, :url_rede_social, :descricao_analise, tipo_coumunicacoes_attributes: [:id, :tipo_comunicacao, :observacao])\n \n \n params.require(:analise_privacidade).permit!\n \n \n \n \n \n end",
"def permitted\n {attrib_name => spec.permitted}\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 formulary_params\n allow = [:responsable_llenado,:cod01,:cod02,:ape01,:ape04,:ape07,:ape02,:ape05,:ape03,:ape06,:api01,:api04,:api02,:ssb01,:api03,:cao01,:cao04,:cao07,:cao10,:tit01,:cao02,:cao05,:cao08,:cao11,:cao03,:cao06,:cao09,:cao12,:uni01,:uni02,:uni03,:ben01,:ben02,:per01,:per02,:user_id]\n params.require(:formulary).permit(allow)\n end",
"def permitted_params\n @permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\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 permitted_params(action, kind=nil)\n params.require(model_name).permit!\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 form_params\n params.require(:funding_request).permit(FundingRequest.allowable_params)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def expected_permitted_parameter_names; end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def permission_policy_params\n params.require(:permission_policy).permit(:name, :io1, :io2, :io3, :io4)\n end",
"def access_control_params\n params.require(:access_control).permit(:uuid, :role_id, :ability_to_create_stream, :ability_to_create_discussion, :ability_to_comment, :ability_to_create_question, :ability_to_create_answer, :ability_to_administrate)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def params_not_permitted\n logger.warn('exception: params not permitted')\n render plain: \"403 ForbiddEn\", status: 403\n end",
"def borrowership_params\n params\n .require(:borrowership)\n .permit(*policy(@borrowership || Borrowership.new).permitted_attributes)\n end",
"def unpermitted_parameters\n fail 'Define me!'\n end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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.require(:user).permit(*policy(@user || User).permitted_attributes)\n end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def user_params\n params.require(:user).permit(current_ability.permitted_attributes(:manage, @user))\n end",
"def vip_privilege_params\n params[:vip_privilege].permit!\n end",
"def is_permitted_for?( user )\n ( user.id == self.user.id ) or ( user.privileged? )\n end",
"def permitted_params_from_policy(object_or_class, key)\n _params = permitted_params[key]\n _attributes = policy(object_or_class).permitted_attributes\n ::ActionController::Parameters.new(_params).permit(*_attributes)\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 specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def user_params\n params.permit(User::UPDATABLE_ATTRIBUTES)\n end",
"def post_card_params\n params[:post_card].permit!\n end",
"def tam_policy_params\n params.require(:tam_policy).permit(TamPolicy.allowable_params)\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def permit(*keys)\n select { |key, _| keys.include?(key) }\n end",
"def users_params\n\t\tparams.require(:user).permit(User::PERMIT_ATTRIBUTES)\n\tend",
"def permit_params_on_create *keys\n filter_strong_params :permit, [:create], keys\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def create_permitted?\n acting_user.administrator?\n end",
"def permitted=(_arg0); end",
"def allow_params_authentication!; end",
"def privilege_params\n params.require(:privilege).permit(:qDrive, :addSong, :editSong, :deleteSong, :grantPermission, :addUser, :editUser, :deleteUser)\n end",
"def user_params\n allowed_params = [:username, :email, :jabber_id, :jabber_otr_fingerprint, :avatar]\n allowed_params << [:password, :password_confirmation] unless params[:user][:password].blank?\n allowed_params << [:role] if current_user.moderator_or_admin?\n allowed_params << [:tenant_ids => []] if current_user.admin?\n allowed_params << [:user_ids => []] if current_user.moderator_or_admin?\n params.require(:user).permit(allowed_params)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def safe_params\n safe_attributes = %i[name key]\n params.require(:role).permit(safe_attributes)\n end",
"def defect_params\n params.require(:defect).permit(Defect.allowable_params)\n end",
"def object_params\n params.require(resource.name.underscore.to_sym)\n .permit(resource_params)\n end",
"def resource_params\n deserialized_params.permit!\n end",
"def sanitize_params\n if valid_lease?\n sanitize_lease_params\n elsif valid_embargo?\n sanitize_embargo_params\n elsif !wants_lease? && !wants_embargo?\n sanitize_unrestricted_params\n else\n @attributes\n end\n end",
"def resource_params\n # TODO DANGER!\n params.require(@resource_class.name.underscore.to_sym).permit!\n end",
"def update_params\n params.require(:permission_template)\n .permit(:release_date, :release_period, :release_varies, :release_embargo,\n :visibility, :workflow_id, :metadata_context_id,\n access_grants_attributes: %i[access agent_id agent_type id])\n end",
"def permition_params\n params.require(:permition).permit(:act, :information_system_id, :parameter)\n end",
"def resource_params\n params.require(resource_name).permit(*permitted_params)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def permit?(action)\n case action\n # -- list\n when :list\n permit?(:list_cases)\n\n # -- create\n when :create\n source? && @settings.working_hours?\n when :create_assignment\n agent? || enroller? || governor?\n when :create_note\n agent? || enroller?\n\n # -- edit\n when :edit\n agent? || governor? || enroller?\n when :edit_address\n agent? || source?\n when :edit_contact\n agent? || source?\n when :edit_address_geography\n source?\n when :edit_household\n agent? || governor? || permit?(:edit_household_source)\n when :edit_household_source\n permit?(:edit_household_ownership) || permit?(:edit_household_proof_of_income)\n when :edit_household_size\n agent? || governor?\n when :edit_household_ownership\n (agent? || source?) && requirement?(R::HouseholdOwnership)\n when :edit_household_proof_of_income\n (agent? || source?) && !requirement?(R::HouseholdProofOfIncomeDhs)\n when :edit_household_dhs_number\n (agent? || governor?) && proof_of_income?(P::Dhs)\n when :edit_household_size\n agent? || governor?\n when :edit_household_income\n (agent? || governor?) && proof_of_income?(P::Dhs)\n when :edit_supplier_account\n (agent? || source?) && requirement?(R::SupplierAccountPresent)\n when :edit_supplier\n agent? || (source? && !supplier?)\n when :edit_supplier_account_active_service\n agent? && requirement?(R::SupplierAccountActiveService)\n when :edit_food\n (source? || agent?) && requirement?(R::FoodDietaryRestrictions)\n when :edit_benefit\n agent? || enroller?\n when :edit_benefit_amount\n (agent? || enroller?)\n when :edit_benefit_contract\n (agent?) && requirement?(R::ContractPresent)\n when :edit_documents\n agent?\n when :edit_admin\n agent?\n\n # -- view\n when :view\n agent? || source? || enroller?\n when :view_details\n permit?(:view)\n when :view_details_status\n agent? || enroller?\n when :view_details_enroller\n agent?\n when :view_supplier_account\n permit?(:view) && requirement?(R::SupplierAccountPresent)\n when :view_food\n permit?(:view) && requirement?(R::FoodDietaryRestrictions)\n when :view_household_size\n (agent? || enroller?)\n when :view_household_ownership\n permit?(:view) && requirement?(R::HouseholdOwnership)\n when :view_household_proof_of_income\n (agent? || enroller?) && !requirement?(R::HouseholdProofOfIncomeDhs)\n when :view_household_dhs_number\n (agent? || enroller?) && proof_of_income?(P::Dhs)\n when :view_household_income\n (agent? || enroller?) && proof_of_income?(P::Dhs)\n when :view_supplier_account_active_service\n (agent? || enroller?) && requirement?(R::SupplierAccountActiveService)\n\n # -- actions\n when :convert\n agent?\n when :referral\n agent?\n when :complete\n agent? || enroller?\n\n # -- destroy\n when :destroy\n agent?\n when :destroy_assignment\n agent?\n\n # -- archive\n when :archive\n agent?\n else\n super\n end\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def update_sanitized_params\n\t\t\tif \"#{resource_name}\" == \"lecturer\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|lecturer| lecturer.permit(:name, :email,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :department)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|lecturer| lecturer.permit(:name, :current_password,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :department,\n\t\t\t\t\t\t:profile_image, :profile_image_cache)\n\t\t\t\t}\n\t\t\telsif \"#{resource_name}\" == \"student\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|student| student.permit(:name, :email,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :faculty, :major, :semester,\n\t\t\t\t\t\t:advising, :probation)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|student| student.permit(:name, :current_password,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :faculty, :major, :semester,\n\t\t\t\t\t\t:advising, :probation, :profile_image,\n\t\t\t\t\t\t:profile_image_cache)\n\t\t\t\t}\n\t\t\telsif \"#{resource_name}\" == \"teaching_assistant\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|teaching_assistant| teaching_assistant.permit(:name,\n\t\t\t\t\t\t:email, :password, :password_confirmation,\n\t\t\t\t\t\t:graduated_from, :graduated_year, :degree,\n\t\t\t\t\t\t:university, :department)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|teaching_assistant| teaching_assistant.permit(:name,\n\t\t\t\t\t\t:current_password, :password, :password_confirmation,\n\t\t\t\t\t\t:graduated_from, :graduated_year, :degree,\n\t\t\t\t\t\t:university, :department, :profile_image,\n\t\t\t\t\t\t:profile_image_cache)\n\t\t\t\t}\n\t\t\tend\n\t\tend",
"def permit_params(*args, &block)\n param_key = config.param_key.to_sym\n\n controller do\n define_method :permitted_params do\n belongs_to_param = active_admin_config.belongs_to_param\n create_another_param = :create_another if active_admin_config.create_another\n\n permitted_params =\n active_admin_namespace.permitted_params +\n Array.wrap(belongs_to_param) +\n Array.wrap(create_another_param)\n\n params.permit(*permitted_params, param_key => block ? instance_exec(&block) : args)\n end\n\n private :permitted_params\n end\n end",
"def resource_params\n permition = @klazz.attribute_names - [:created_at, :updated_at]\n @metadata.items.each do |entity|\n permition << {\"many_#{entity.name}_attributes\".to_sym =>\n [:id] + entity.many_field.map{|field| field.name.to_sym} - [:created_at, :updated_at]}\n end\n params.require(@resource_sym).permit(*permition)\n end",
"def allowed?\n raise NotImplementedError, 'please implement #allowed? '\\\n \"for #{self.class.name} which should decide if the action is allowed, \"\\\n 'based on the given attributes'\n end",
"def permitted_params\n []\n end",
"def ability_params\n params.require(:ability).permit(:child_id, :skill_id, :status)\n end",
"def permits\n @permits ||= builders.inject({}) do |permits, builder|\n debug \"++ Permit Builder: #{builder_class builder}\"\n built_permits = permits_built_with(builder)\n\n if built_permits\n debug \"== Permits built: #{built_permits.size}\"\n permits[builder] = built_permits\n end\n\n permits\n end\n end",
"def permitUser\n @member_permitted_name=Member.where(:id=>params[:id]).first.first_name\n Member.update(params[:id], :permitted => 1)\n flash[:notice] = \"User #{@member_permitted_name} allowed to book multiple rooms\"\n redirect_to(:action => 'index' )\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end"
] | [
"0.70143116",
"0.7008805",
"0.6857186",
"0.67885876",
"0.6709359",
"0.6684028",
"0.6672611",
"0.665639",
"0.6641643",
"0.6623889",
"0.661969",
"0.65919864",
"0.65918124",
"0.6576327",
"0.65567094",
"0.6537578",
"0.65306634",
"0.65237343",
"0.6518953",
"0.6488868",
"0.6474093",
"0.6467465",
"0.64324456",
"0.6432158",
"0.64211947",
"0.6420966",
"0.63792545",
"0.63792545",
"0.63613397",
"0.63600874",
"0.63514125",
"0.6351016",
"0.6349099",
"0.6349099",
"0.6345149",
"0.63386977",
"0.6332402",
"0.63162",
"0.63149375",
"0.6292758",
"0.6283278",
"0.62718457",
"0.62596524",
"0.62592953",
"0.6255646",
"0.62484217",
"0.62473065",
"0.62215585",
"0.62134576",
"0.6213196",
"0.62054235",
"0.62054235",
"0.61996245",
"0.6196269",
"0.61917996",
"0.6188738",
"0.6181633",
"0.6170303",
"0.61664456",
"0.61524296",
"0.6143382",
"0.61390305",
"0.6122421",
"0.6120536",
"0.6119658",
"0.6117704",
"0.61174554",
"0.6115627",
"0.61108506",
"0.6096805",
"0.6091522",
"0.6091522",
"0.6091522",
"0.6091522",
"0.60882586",
"0.6085014",
"0.6080531",
"0.6080348",
"0.6072007",
"0.6065439",
"0.6063691",
"0.60554755",
"0.60539305",
"0.60368747",
"0.6035591",
"0.6035341",
"0.6002283",
"0.5997763",
"0.59954417",
"0.59819067",
"0.59785664",
"0.5977979",
"0.5963987",
"0.5963524",
"0.5957078",
"0.59570104",
"0.59515566",
"0.5951296",
"0.59495676",
"0.59461063",
"0.5942083"
] | 0.0 | -1 |
children is an array of length 4 representing the child nodes of the node. index 0 is northeast (higher long and lat), 1 is south east, 2 is south west, 3 is north west | def initialize(longitude, latitude, location_id, parent)
@longitude = longitude
@latitude = latitude
@location_id = location_id
@parent = parent
@children = [nil,nil,nil,nil]
@total_leaves = if location_id.nil? then 0 else 1 end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n empty_squares.map { |pos| make_new_node(pos) }\n end",
"def children\n list = Array.new\n (0..2).each do |x|\n (0..2).each do |y|\n pos = [x,y]\n list << create_node(pos) if @board.empty?(pos)\n end\n end\n return list\n end",
"def make_children\n possible = []\n possible.push([@x+2, @y+1]).push([@x+2, @y-1]).push([@x+1, @y+2]).\n push([@x+1, @y-2]).push([@x-1, @y+2]).push([@x-1, @y-2]).\n push([@x-2, @y+1]).push([@x-2, @y-1])\n\n children = possible.select { |coord| coord[0] >= 0 && coord[0] <= 7 && coord[1] >= 0 && coord[1] <= 7 }\n\n children = children.map { |coord| Square.new(coord[0], coord[1], self) }\n @children = children\n end",
"def children\n new_board = Array(3) { Array (3) }\n root = PolyTreeNode.new(new_board)\n possible_moves =\n end\nend",
"def children\n out = [] \n (0..2).each do |row|\n (0..2).each do |col|\n pos = [row, col]\n out << next_move_node(pos) if @board.empty?(pos)\n end\n end\n out\n end",
"def children\n res = []\n @board.rows.each_with_index do |row, x|\n row.each_with_index { |item, y| res << [x,y] }\n end\n res\n end",
"def children\n out_edges.each{|e| e.dest}\n end",
"def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end",
"def children\n children_nodes = Array.new\n i = 0\n while i < self.board.rows.length\n j = 0\n while j < self.board.rows.length\n if self.board.empty?([i,j])\n duped_board = self.board.dup\n duped_board.[]=([i,j],self.next_mover_mark) \n duped_node = self.class.new(duped_board,self.alternate_mark,[i,j])\n children_nodes << duped_node\n end\n j += 1\n end\n i += 1\n end\n return children_nodes\n end",
"def children\n node.children\n end",
"def get_child_positions\n @children.map { |x| x.idx }\n end",
"def children\n children = []\n children << up_child unless up_child.nil?\n children << down_child unless down_child.nil?\n children << left_child unless left_child.nil?\n children << right_child unless right_child.nil?\n children\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children\n # find array of empty positions on board (children candidates)\n\n # create node by duping board and putting next_mover_mark in one of the empty positions\n\n end",
"def get_children\n \t@children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def _children\n @children\n end",
"def make_children(depth_layer)\n @childless.each do |node|\n coords = generate_children_coordinates(node.x, node.y)\n coords.each do |x,y|\n child = Move.new(x,y,depth_layer,[],node)\n node.children ||= []\n node.children << child\n @node_count += 1\n end\n end\n #generate coordinates for children\n #creates child nodes with child coordinates, appropriate depth attribute, appropriate parent node attribute)\n end",
"def children\n nodes = []\n @board.rows.each_with_index do |row, row_idx|\n row.each_index do |col_idx|\n pos = [row_idx, col_idx]\n next unless @board[pos].nil?\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n nodes << TicTacToeNode.new(new_board, this_mark, pos)\n end\n end\n nodes\n end",
"def children\n child_array = []\n board.rows.each_index do |row|\n board.rows[row].each_index do |col|\n pos = [row, col]\n if board[pos].nil?\n new_board = board.dup\n new_board[pos] = next_mover_mark\n child_array << self.class.new(new_board, switch_mark(next_mover_mark), pos)\n end\n end\n end\n child_array\n end",
"def children\n# debugger\n open_positions = []\n children = []\n @board.rows.each_index do |i|\n (0..2).each do |j|\n open_positions << [i, j] if @board.rows[i][j] == nil\n end\n end\n open_positions.each do |pos|\n new_board = @board.rows.dup\n child_board = Board.new(new_board)\n child_board[pos] = next_mover_mark\n new_mark = next_mover_mark\n new_mark == :x ? new_mark = :o : new_mark = :x\n children << TicTacToeNode.new(new_board, new_mark, prev_move_pos =)\n end\n return children \n end",
"def children\n empty_pos = []\n (0..2).each do |row_i|\n (0..2).each do |col_i|\n pos =[row_i,col_i]\n empty_pos << pos if @board.empty?(pos) \n end\n end\n empty_pos.map do |pos|\n next_mark = (@next_mover_mark == :x ? :o : :x)\n new_node = TicTacToeNode.new(@board.dup,next_mark,pos) \n new_node.board[pos] = @next_mover_mark\n new_node\n end\n end",
"def children\n building_children = [] # creepy\n board.rows.each_with_index do |row, i|\n row.each_with_index do |tile, j|\n if tile.nil?\n current_board = board.dup\n current_board[[i, j]] = @next_mover_mark\n next_mark = @next_mover_mark == :x ? :o : :x\n building_children << TicTacToeNode.new(current_board, next_mark, [i, j])\n end\n end\n end\n building_children\n end",
"def generate_children_coordinates(x,y)\n child_coordinates = []\n MOVEMENT_DIFF.each do |dx, dy|\n move = [x+dx, y+dy]\n child_coordinates << move if within_limits?(move)\n end\n child_coordinates\n end",
"def children(max_distance=@default_distance)\n @children[0] = [@entity] if @children[0].empty?\n add_relatives(@children,1,max_distance,:children)\n @children\n end",
"def children\n children = []\n board.rows.each_index do |row|\n board.rows[row].each_index do |col|\n pos = [row, col]\n if board[pos].nil?\n new_board = board.dup\n new_board[pos] = next_mover_mark\n children << self.class.new(new_board, switch_mark(next_mover_mark), pos)\n end\n end\n end\n children\n end",
"def children\n\n children_array = []\n @board.rows.each_index do |row_idx|\n @board.rows[row_idx].each_index do |col_idx|\n if @board[[row_idx, col_idx]].nil?\n dup_board = @board.dup\n dup_board[[row_idx, col_idx]] = @next_mover_mark\n next_next_mark = switch_mark\n children_array << TicTacToeNode.new(dup_board, next_next_mark, [row_idx, col_idx])\n end\n end\n end\n children_array\n end",
"def children\n node_arr = []\n (0..2).each do |row|\n (0..2).each do |col|\n if @board.empty?([row, col])\n updated_board = @board.dup\n updated_board[[row, col]] = @next_mover_mark\n updated_positions = @prev_move_pos.dup\n updated_positions += [row, col]\n node_arr << TicTacToeNode.new(updated_board, @next_mover_mark == :o && :x || :o, updated_positions) \n end\n end\n end\n node_arr\n end",
"def children\n nodes = []\n\n self.get_empty_posns.each do |posn| \n updated_board = @board.dup\n updated_board[posn] = @next_mover_mark\n next_mark = @next_mover_mark == :x ? :o : :x\n new_node = TicTacToeNode.new(updated_board, next_mark, posn) \n nodes << new_node\n end\n\n nodes\n end",
"def children\n children = []\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |square, j|\n pos = [i,j]\n if @board.empty?(pos)\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n mark = (@next_mover_mark == :x ? :o : :x)\n children << add_child(TicTacToeNode.new(new_board, mark, pos))\n end\n end\n end\n children\n end",
"def get_children(children, level, array)\n return if children.nil?\n\n children.each do |child|\n \n blocked = (child.blocked == \"true\") ? \"BLOCKED\" : \"\" # syntax highlighting matches 'BLOCKED' word\n display_str = \" \" * (level*2) + \"#{child.formatted_i_d}: #{StringUtils.html2text(child.name)}\"\n array << \"#{display_str.rjust(display_str.length, ' ').ljust(65, ' ')} #{formatted_story_state(child.schedule_state).ljust(15, ' ')} #{blocked}\\n\"\n get_children(child.children, level+1, array)\n end\n end",
"def children\n\n array = []\n (0..2).each do |row|\n (0..2).each do |col|\n if @board[row][col].empty?\n array << @board[row][col]\n end\n end\n end\n\n array.each do |pos|\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n prev_mov_pos = pos\n node = TicTacToeNode.new(new_board, pos)\n end\n\n end",
"def children\n\t\tmoves = [ [@x+2, @y+1], [@x+2, @y-1], [@x-2, @y+1], [@x-2, @y-1],\n [@x+1, @y+2], [@x+1, @y-2], [@x-1, @y+2], [@x-1, @y-2] ]\n moves.map { |position| Knight.new( position, @history ) }\n\tend",
"def children\n @children ||= []\n end",
"def children\n children = []\n @board.rows.each_with_index do |row, r_idx|\n row.each_index do |c_idx|\n kid_board = @board.dup\n pos = [r_idx, c_idx]\n if kid_board.empty?(pos)\n kid_board[pos] = @next_mover_mark\n children << TicTacToeNode.new(kid_board, next_mark, pos)\n end\n end\n end\n children\n end",
"def children\n children = []\n @board.rows.each do |row|\n row.each_with_index do |mark, col|\n pos = rows[col]\n p pos\n if @board[pos].empty?\n new_board = @board.dup\n new_board[row,col] = next_mover_mark\n children << TicTacToeNode.new(new_board, next_mover_mark, [row,col])\n end\n end\n end\n end",
"def children\n new_children = []\n 3.times do |row|\n 3.times do |col|\n pos = [row, col]\n if @board.empty?(pos)\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n new_node = TicTacToeNode.new(new_board, next_mark, pos)\n new_children << new_node\n end\n end\n end\n\n new_children\n end",
"def get_region_children(options={})\n url_s=@@zillow_webservice_url+'GetRegionChildren.htm?zws-id='+@zwsid\n if options[:city]!=nil then\n url_s=url_s+'&city='+options[:city].to_s\n end\n if options[:state]!=nil then\n url_s=url_s+'&state='+options[:state].to_s\n end\n if options[:country]!=nil then\n url_s=url_s+'&country='+options[:country].to_s\n end\n if options[:rid]!=nil then\n url_s=url_s+'&rid='+options[:rid].to_s\n end\n if options[:childtype]!=nil then\n url_s=url_s+'&childtype='+options[:childtype].to_s\n end\n fetch_result(url_s)\n end",
"def get_children\n @children\n end",
"def children\n children_nodes = []\n (3).times do |i|\n (3).times do |j|\n if @board[[i, j]].nil?\n temp_board = @board.dup\n temp_board[[i, j]] = next_mover_mark\n next_mover_mark = temp_board[[i, j]] == :x ? :o : :x\n children_nodes << TicTacToeNode.new(temp_board, next_mover_mark, [i, j])\n end\n end\n end\n children_nodes\n end",
"def children\n nodes = []\n board.rows.each_with_index do |row, r_index|\n row.each_with_index do |cell, c_index|\n if cell.nil?\n new_board = board.dup\n new_board[[r_index, c_index]] = next_mover_mark\n nodes << TicTacToeNode.new(new_board, get_next_mover, [r_index, c_index])\n end\n end\n end\n\n nodes\n end",
"def children\n child_nodes = []\n\n [0, 1, 2].each do |row|\n [0, 1, 2].each do |col|\n pos = [row, col]\n\n if self.board.empty?(pos)\n new_board = self.board.dup\n new_board[pos] = self.next_mover_mark\n new_next_mover = (self.next_mover_mark == :x) ? :o : :x\n new_node = TicTacToeNode.new(new_board, new_next_mover, pos)\n\n child_nodes << new_node\n end\n end\n end\n\n child_nodes\n end",
"def tree_children\n\n tree[2]\n end",
"def children\n childs = []\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if @board.empty?(pos)\n duped_board = @board.dup\n duped_board.[]=(pos, @next_mover_mark)\n childs << TicTacToeNode.new(duped_board, self.class.toggle(@next_mover_mark), pos)\n end\n end\n end\n childs\n\n end",
"def children\n childs = []\n # grid = @board.dup\n # grid[[i,j]] = next_mover_mark\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |el, j|\n grid = @board.dup\n grid[[i,j]] = next_mover_mark if @board.empty?([i,j])\n prev_mov_pos = [i,j] if @board.empty?([i,j])\n childs << TicTacToeNode.new(grid, next_mover_mark == :x ? :o : :x, prev_mov_pos) \n end\n end\n childs\n end",
"def children\n attributes.fetch(:children)\n end",
"def children\n children_arr = []\n @board.rows.each_index do |i|\n @board.rows.each_index do |j|\n if @board.empty?([i, j])\n children_arr << TicTacToeNode.new(@board.dup, @next_mover_mark, @board[i, j])\n end\n end\n end\n children_arr\n end",
"def children\n @children\n end",
"def children\n @children\n end",
"def build_internal_nodes\n names.each do |tmp_geo_area|\n recurse_nodes(tmp_geo_area.parent_names, tmp_geo_area)\n end\n end",
"def children\n all_children = []\n \n (0..2).each do |row|\n (0..2).each do |col|\n if @board.rows[row][col].nil?\n new_board = @board.dup\n new_board.rows[row][col] = @next_mover_mark\n all_children << TicTacToeNode.new(new_board, other_mark,[row,col])\n end\n \n end\n end\n \n all_children\n end",
"def children\n @root.children & @initial_contents\n end",
"def children\n arr = []\n # # debugger\n max_index = self.board.rows.length\n (0...max_index).each do |row_i|\n (0...max_index).each do |col_i|\n pos = [row_i, col_i]\n if @board.empty?(pos)\n new_board = @board.dup \n new_board[pos] = next_mover_mark\n prev_move_pos = pos\n next_mover_mark == :x ? next_mover_mark = :o : next_mover_mark = :x\n child = TicTacToeNode.new(new_board, next_mover_mark, prev_move_pos)\n arr << child\n end\n end\n end\n arr\n end",
"def children\n children = []\n\n (0..2).each do |x| \n (0..2).each do |y| \n\n pos = [x, y]\n\n next unless board.empty?(pos)\n duped_board = board.dup \n\n duped_board[pos] = self.next_mover_mark\n new_mark = (self.next_mover_mark == :x ? :o : :x)\n\n node = TicTacToeNode.new(duped_board, new_mark, pos)\n\n children << node\n end \n end \n\n children \n end",
"def children() []; end",
"def create_children(&block)\n if block.(self, cv = ntants)\n unless @depth == 0\n @children = cv.map{|vupper, vlower| Node.new(vupper, vlower, @depth - 1)}\n @children.each{|child| child.create_children &block}\n end\n end\n end",
"def augment_children(child_base_nodes)\n if child_base_nodes.size < (sz = self.class.min_children)\n child_base_nodes = child_base_nodes.dup\n child_base_nodes[sz..-1] = [] # Fill with nil\n end\n child_base_nodes.map.with_index do |child, child_index|\n child_name = self.class.child_index_to_name(child_index, child_base_nodes.size)\n if (klass = remap_child(child, child_name))\n klass.new(child, parent: self, index: child_index)\n else\n child\n end\n end\n end",
"def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end",
"def children\n children = []\n @board.rows.each_with_index do |row, row_idx|\n row.each_with_index do |col, col_idx|\n if @board.empty?([row_idx, col_idx])\n dup_board = @board.dup\n dup_board[[row_idx, col_idx]] = @next_mover_mark\n child_node = TicTacToeNode.new(dup_board, other_mark(@next_mover_mark), [row_idx, col_idx])\n children << child_node\n end\n end\n end\n children\n end",
"def children\n children = []\n next_next_mover_mark = [:x, :o].reject { |mark| mark == next_mover_mark }.first\n\n @board.rows.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n pos = [row_idx, col_idx]\n if @board.empty?(pos)\n child_board = @board.dup\n child_board[pos] = @next_mover_mark\n children << TicTacToeNode.new(child_board, next_next_mover_mark, pos)\n end\n end\n end\n children\n end",
"def children\n Array.new\n end",
"def children\n children = []\n empty_tiles = find_empty_tiles\n empty_tiles.each do |pos|\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n new_mark = @next_mover_mark == :x ? :o : :x\n children << TicTacToeNode.new(new_board,new_mark,pos)\n end\n children\n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def children\n _children\n end",
"def children\n child_arr = []\n empty_positions.each do |pos|\n new_board = @board.dup\n # debugger\n new_board[pos] = @next_mover_mark\n next_mark = @next_mover_mark == :x ? :o : :x\n child_arr << TicTacToeNode.new(new_board, next_mark, pos)\n end\n child_arr\n end",
"def children\n positions = []\n\n (0..2).to_a.each do |row|\n (0..2).to_a.each do |col|\n if @board.empty?([row,col])\n dup_board = @board.dup\n dup_board.[]=([row,col], next_mover_mark)\n\n if @next_mover_mark == :x\n new_next_mover_mark = :o\n else\n new_next_mover_mark = :x\n end\n\n new_prev_move_pos = [row,col]\n positions << TicTacToeNode.new(dup_board, new_next_mover_mark, new_prev_move_pos)\n end\n end\n end\n\n positions\n end",
"def process_child_nodes(node); end",
"def children\n array = []\n @board.rows.each do |row|\n @board.row.each do |el|\n if el.empty?\n new_board = @board.dup\n new_board[row][el] = @next_mover_mark\n prev_move = [row, el]\n new_node = TicTacToeNode.new(new_board, alternate_mover_mark, prev_move)\n array << new_node\n end\n end\n end\n array\n end",
"def children\n mark = @next_mover_mark\n mark == :x ? mark = :o : mark = :x\n children_arr = []\n @board.rows.each.with_index do |row, ind1|\n row.each.with_index do |space, ind2|\n pos = [ind1, ind2]\n if @board.empty?(pos)\n new_board = board.dup\n new_board[pos] = @next_mover_mark\n child_node = TicTacToeNode.new(new_board, mark, pos)\n children_arr.push(child_node)\n \n end\n end\n end\n children_arr\n end",
"def children\n board.rows.flatten.each do |pos|\n if pos.nil?\n end\n end\nend",
"def children\n children_tree.values\n end",
"def children\n children_tree.values\n end",
"def children\n children = []\n (0..2).each do |row|\n (0..2).each do |col|\n pos = [row,col]\n if @board.empty?(pos)\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n @next_mover_mark == :x ? child_mark = :o : child_mark = :x\n child = TicTacToeNode.new(new_board, child_mark, pos)\n children << child\n end\n end\n end\n children\n end",
"def moves_as_children(node)\n possible_moves(node.data).each do |move|\n node.children << Node.new(move, node)\n end\n end",
"def children; []; end",
"def children\n children = [] \n @board.rows.each_with_index do |row, idx_1|\n row.each_with_index do |space, idx_2|\n pair = [idx_1, idx_2]\n if @board.empty?(pair)\n @board[pair] = :x\n node = TicTacToeNode.new(@board.dup, :o, pair)\n children << node\n end\n end\n end\n children\n end",
"def children\n children = []\n\n (0..2).each do |x|\n (0..2).each do |y|\n if @board.empty?([x, y])\n new_board = @board.dup\n new_board[[x, y]] = @next_mover_mark\n child_mark = @next_move_marker\n if @next_move_marker == :o\n child_mark = :x\n else\n child_mark = :o\n end\n child_node = TicTacToeNode.new(new_board, child_mark, [x, y])\n children << child_node\n end\n end\n end\n\n return children\n end",
"def children\n childs = []\n board.rows.each_with_index do |row, i|\n print row\n p i\n row.each_with_index do |square, j|\n if board.empty?([i, j])\n new_board = @board.dup\n new_board[i, j] = @next_mover_mark\n new_mark = ((next_mover_mark == :x) ? :o : :x)\n childs << TicTacToeNode(new_board, new_mark, [i, j])\n end\n end\n end\n childs\n end",
"def children_get()\n @children\n end",
"def children\n rows = @board.rows\n children_arr = []\n rows.each_with_index do |row, i|\n row.each_with_index do |tile, j|\n new_board = Board.new(rows.deep_dup)\n if board.empty?([i,j])\n new_board[[i, j]] = @next_mover_mark\n children_arr << TicTacToeNode.new(new_board, @prev_mover_mark, [i,j])\n end\n end\n end\n children_arr\n end",
"def children\n rows\n end",
"def children\n children_result = []\n\n empty_positions = []\n (0..2).each do |idx1|\n (0..2).each do |idx2|\n empty_positions << [idx1,idx2] if @board.empty?([idx1,idx2])\n end\n end\n\n empty_positions.each do |pos|\n dup_board = @board.dup\n dup_board[pos] = next_mover_mark\n\n next_move = (next_mover_mark == :x) ? :o : :x\n children_result << TicTacToeNode.new(dup_board,next_move,pos)\n end\n\n children_result\n end",
"def children\n children = []\n (0..2).each do |row|\n (0..2).each do |col|\n position = [row, col]\n next unless board.empty?(position)\n new_board = board.dup\n new_board[position] = next_mover_mark\n mark = (next_mover_mark == :x ? :o : :x)\n\n children << TicTacToeNode.new(new_board, mark, position)\n end\n end\n children\n end",
"def children\n \n board.rows.each_with_index do |row, row_idx|\n row.each_with_index do |ele, col_idx|\n if board.empty?([row_idx, col_idx])\n copy = board.dup\n copy[[row_idx, col_idx]] = next_mover_mark\n next_next_mover_mark = next_mover_mark == :x ? :o : :x\n @children << TicTacToeNode.new(copy, next_next_mover_mark, prev_move_pos = [row_idx, col_idx] )\n end\n end \n end\n @children\n end"
] | [
"0.6933356",
"0.6536344",
"0.64713585",
"0.64663315",
"0.6465529",
"0.64368016",
"0.6424321",
"0.64213395",
"0.6316889",
"0.6188804",
"0.6143499",
"0.6129925",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6064687",
"0.60624766",
"0.6058408",
"0.6058408",
"0.6058408",
"0.6058408",
"0.6046085",
"0.6037658",
"0.5976068",
"0.5961908",
"0.59400356",
"0.593936",
"0.5935213",
"0.59282666",
"0.59281015",
"0.59190357",
"0.5911159",
"0.5907422",
"0.58911777",
"0.58852655",
"0.58722246",
"0.58649015",
"0.58599746",
"0.58590686",
"0.58542854",
"0.5850657",
"0.58362895",
"0.5835021",
"0.5834781",
"0.5826967",
"0.58237934",
"0.5814898",
"0.58120936",
"0.5805453",
"0.5795091",
"0.5791919",
"0.57857823",
"0.5781841",
"0.57760906",
"0.57760906",
"0.57759345",
"0.5771779",
"0.57716626",
"0.575931",
"0.5759052",
"0.5756281",
"0.574524",
"0.5742514",
"0.57388014",
"0.5737537",
"0.573647",
"0.57345134",
"0.5734345",
"0.5732305",
"0.5732305",
"0.5729525",
"0.57289165",
"0.5728549",
"0.5726451",
"0.5726065",
"0.572571",
"0.57224613",
"0.572093",
"0.572093",
"0.5717177",
"0.5716035",
"0.5714169",
"0.57104844",
"0.5695558",
"0.5694531",
"0.56874436",
"0.5683892",
"0.56824833",
"0.56782633",
"0.5667961",
"0.56600744"
] | 0.5662716 | 99 |
Validates different types based on regexp and such | def validate(type,input)
if input.nil? then return false end
if !(input.is_a? String) then return false end
case type
when 'Integer'
return !(input.match(INTEGER_FORMAT).nil?)
when 'String'
return (input.length <= 1024)
when 'Mail'
return !(input.match(MAIL_FORMAT).nil?)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_type(type, context:); end",
"def valid_input?(owner, value)\n if value.nil?\n raise StandardError.new(\"Cannot validate null value\")\n end\n \n # Convert to string first\n value = value.to_s\n \n # Match depending on type\n case type\n when 'string' then true\n when 'integer' then !value.match(/^-?\\d+$/).nil?\n when 'decimal' then !value.match(/^-?\\d+(\\.\\d+)?$/).nil?\n when 'length' then !value.match(/^-?\\d+(px)?$/).nil?\n when 'color' then !value.match(/^#[0-9A-F]{6}$/i).nil?\n when 'percent' then !value.match(/^-?\\d+%$/).nil?\n end\n end",
"def valid_string_and_reg_ex?(char_string, reg_exp)\n str_flag = is_string?(char_string)\n regex_flag = is_reg_exp?(reg_exp) \n puts \"First argument should be a String.\" unless(str_flag)\n puts \"Second argument should be a Regular Expression.\" unless(regex_flag)\n str_flag && regex_flag\nend",
"def check_regex\n return true if resource_type_attribute.nil?\n\n regex = resource_type_attribute.validation_regex\n res = true\n if !regex.blank? and !value.blank?\n res = value.match(regex)\n end\n\n return res\n end",
"def verify_types(test_data)\n test_types = test_data[Org::ORG_RECORD_TYPES.name]\n errors = []\n test_types = [{ Org::ORG_RECORD_TYPE.name => ''}] unless test_types\n test_types.each_with_index do |test_type, index|\n text_values_match?(test_type[Org::ORG_RECORD_TYPE.name], element_value(org_record_type_input(index)), errors)\n end\n errors\n end",
"def type *val\n return @chars_allowed if val.empty?\n\n dtype = val[0]\n #return self if @chars_allowed # disallow changing\n if dtype.is_a? Regexp \n @chars_allowed = dtype\n return self\n end\n dtype = dtype.to_s.downcase.to_sym if dtype.is_a? String\n case dtype # missing to_sym would have always failed due to to_s 2011-09-30 1.3.1\n when :integer, Integer\n @chars_allowed = /\\d/\n when :numeric, :float, Numeric, Float\n @chars_allowed = /[\\d\\.]/ \n when :alpha\n @chars_allowed = /[a-zA-Z]/ \n when :alnum\n @chars_allowed = /[a-zA-Z0-9]/ \n else\n raise ArgumentError, \"Field type: invalid datatype specified. Use :integer, :numeric, :float, :alpha, :alnum \"\n end\n self\n end",
"def validate_data_type(value_type)\n type = get_data_type\n value = get_value(value_type)\n\n begin\n error = ''\n case type\n when \"ip\"\n unless value =~ IPHelper::IP_REGEX\n error = \"Invalid IP address\"\n end\n when \"ip_range\"\n unless IPHelper.is_valid_string?(value)\n error = \"Invalid IP address range\"\n end\n when \"numeric\"\n unless /^\\d*\\.{0,1}\\d*$/.match(value.to_s)\n error = \"Invalid number\"\n end\n when \"netmask\"\n unless IPAddress.valid_ipv4_netmask?(value)\n error = \"Invalid netmask\"\n end\n when \"string\"\n unless value.size < 256\n error = \"The length of this field exceeds 255 characters\"\n end\n when \"text\"\n error = ''\n when \"product_key\"\n unless /^([a-zA-Z0-9]{5})-([a-zA-Z0-9]{5})-([a-zA-Z0-9]{5})-([a-zA-Z0-9]{5})-([a-zA-Z0-9]{5})$/.match(value)\n error = \"Invalid product key\"\n end\n when \"boolean\"\n unless value.is_a?(TrueClass) || value.is_a?(FalseClass)\n error = \"Invalid boolean value\"\n end\n when \"list\"\n if value == nil || value == \"\"\n error = \"Empty box!\"\n end\n when \"csv\"\n error = ''\n when \"password\"\n error = value.include?('|') ? \"Passwords cannot contain the pipe '|' character.\" : ''\n when \"ip_list\"\n ips = value.gsub(/,/, ';').split(';').map(&:strip).reject(&:empty?)\n invalid_ips = ips.any? do |ip|\n !(ip =~ IPHelper::IP_REGEX)\n end\n\n if ips.size == 0 || invalid_ips\n error = \"Invalid IP list\"\n end\n end\n error\n rescue Exception => ex\n $logger.error \"Error validating field #{html_form_id} - #{ex.to_s}: #{ex.backtrace}\"\n return \"Server error - invalid field\"\n end\n end",
"def regex_matcher(string, type)\n return false if string.nil?\n case type\n when \"email\"\n string.match(/^\\w+@\\w+\\.com$/)\n when \"mobile\"\n string.match(/^\\d{10}$/)\n when \"ip\"\n valid_part_count = 0\n ip_array = string.split(\".\")\n ip_array.each do |part|\n if (part.match(/^\\d{1,3}$/) and part.to_i <= 255 and part.to_i >= 0)\n valid_part_count += 1\n end\n end\n if valid_part_count == 4\n return true\n else\n return false\n end\n when \"URL\"\n string.match(/[(http)(https)]:\\/\\/(www.)?\\w+\\.\\w+/)\n end\nend",
"def validate(obj, type); end",
"def validated_parser_type(type); end",
"def valid_types\n [:common, :email, :ipn]\n end",
"def validate expression, types, pname\n raise_without_self \"#{pname} should not be nil!\", HOWT unless expression\n \"#{pname} should not be empty!\" if expression.to_s.empty?\n unless types.include? expression.class\n raise_without_self \"#{pname} should be #{types} but is '#{expression.class.name}'!\", HOWT\n end\n end",
"def valid_signup_form_input?(input, type)\n # reason to do this with not symbols or vv?\n # better to use =~ somehow?\n case type\n when :n, :s\n !input.match(/^[[:alpha:]\\- ]+$/)\n when :e\n !input.match(/^[\\w.]+@\\w+(\\.[[:alpha:]]+){1,2}$/) || User.exists?(email: input)\n when :u\n !input.match(/^\\w{5,15}$/) || User.exists?(username: input)\n when :p\n !input.match(/^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[\\w\\$!#&]{8,15}$/)\n else\n puts \"## wrong input type ##\"\n # how do this for the programmer?\n end\n end",
"def nonregular_type; end",
"def check_regex value, validator\n return unless regexp? value\n\n regex = value.value\n unless secure_regex?(regex)\n warn :model => @current_model,\n :warning_type => \"Format Validation\",\n :warning_code => :validation_regex,\n :message => \"Insufficient validation for '#{get_name validator}' using #{regex.inspect}. Use \\\\A and \\\\z as anchors\",\n :line => value.line,\n :confidence => :high\n end\n end",
"def valid_plugin_input?(input)\n VALID_PATTERNS.any? { |regex| regex.match? input }\n end",
"def supports_regexp?\n true\n end",
"def supports_regexp?\n true\n end",
"def is_valid_data_with_format?(date, reg_ex_date, obj_type)\n is_string?(date) ? (string_contains_reg_exp?(date, reg_ex_date) ? invalid_date_error_type(\"format\", obj_type) : true) : invalid_date_error_type(\"data type\", obj_type)\nend",
"def accept? text\r\n !text.match(@regexp).nil?\r\n end",
"def validate_name_parts\n name_part_types.each do |type|\n next if send \"valid_#{type}?\"\n errors.add type, \"valid #{type} required\"\n end\nend",
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def valid_input_type?\n case @search_type\n when \"Pokemon Name\", \"Type\"\n !@search_menu_input.match?(/\\d/) \n when \"Pokedex Number\"\n !@search_menu_input.match?(/\\D/)\n end\n end",
"def valid?(value, types)\n types.any? do\n case _1\n when :array then true if value.is_a?(Array)\n when :boolean then true # in Ruby everything is a boolean\n when :float then true if value.is_a?(Float) || value.is_a?(Integer)\n when :hash then true if value.is_a?(Hash)\n when :integer then true if value.is_a?(Integer)\n when :string then true if value.is_a?(String)\n when :symbol then true if value.is_a?(Symbol)\n when Class then true if value.is_a?(_1) # for custom checks\n else\n raise \"unknown flag type #{_1.inspect}\"\n end\n end\n end",
"def regex?\n @name.is_a?(Regexp)\n end",
"def allowed?(val)\n case ftype\n when 'string', 'url'\n val.is_a?(String)\n when 'number'\n val.is_a?(Integer) || val.is_a?(Float)\n when 'sample'\n allowable_field_types.collect { |aft| aft.sample_type.id }.member? val.sample_type_id\n when 'item'\n allowable_field_types.collect { |aft| aft.object_type.id }.member? val.object_type_id\n end\n end",
"def valid?(input, type)\n if type == :play\n !(input !~ /[RPSrps]/) && input.length == 1\n elsif type == :again\n !(input !~ /[YNyn]/)\n end\nend",
"def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end",
"def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end",
"def match_regex\n if !self.value.blank? && self.regex\n errors.add(:value, 'is a invalid value') unless self.value =~ Regexp.new(self.regex)\n end\n end",
"def is_invalid?(v, type)\n case type\n when 'json' then !v.is_a?(Hash)\n when 'date' then !v.is_a?(Date)\n when 'datetime' then !v.is_a?(DateTime)\n when 'number' then !v.is_a?(Numeric)\n when TrueFalse then !v.is_a?(TrueFalse)\n else v.respond_to?(:valid?) ? !v.valid? : v.nil?\n end\n end",
"def valid?(type, value, type_name = nil)\n if value.is_a? type\n return true\n elsif !!value == value && type == TrueClass #check for boolean\n return true\n else\n raise \"Error: #{type_name || type.name} was excepted. #{value.class.name} was recieved\"\n end\n end",
"def valid_number?(num)\n num.to_s unless num.is_a? String\n /\\A[+-]?\\d+(\\.[\\d]+)?\\z/.match num\nend",
"def regexp?(elora, die=nil)\n die = @proofsheet.die(elora.inherited_namespace, elora.absolute_xpath) if not die\n validity = true # default /.*/ so default valid is true\n if die\n if die.regexp\n if not md = die.regexp.match(content(elora))\n validity = false\n error = \"REGEXP '#{content(elora)}' /#{die.regexp.source}/\"\n @errors << [die.namespace, die.xpath, error]\n end\n end\n end\n return validity\n end",
"def parse_and_validate_date_if_necessary(value, type)\n # note: cannot use 'case type' as that expands to === which checks for instances of rather than type equality\n if type == Date\n expect(value).to match(/^\\d{4}-\\d{2}-\\d{2}$/)\n Date.strptime(value, \"%Y-%m-%d\")\n elsif type == DateTime\n expect(value).to match(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/)\n DateTime.strptime(value, \"%Y-%m-%dT%H:%M:%SZ\")\n else\n value\n end\n end",
"def validate_value_against_type(property_value, property_type)\n return if property_value.nil?\n errmsg = \"Invalid property value (#{property_value}: #{property_value.class.name}) for type (#{property_type})\"\n case property_type\n when 'INT'\n raise errmsg unless property_value.is_a?(Integer)\n when 'FLOAT'\n raise errmsg unless (property_value.is_a?(Float) || property_value.is_a?(Integer))\n when 'BOOL'\n raise errmsg unless (property_value.is_a?(TrueClass) || property_value.is_a?(FalseClass))\n when 'DATE'\n raise errmsg unless property_value.is_a?(Date)\n when 'TIMESTAMP'\n raise errmsg unless property_value.is_a?(DateTime)\n when 'STRING'\n raise errmsg unless property_value.is_a?(String)\n else\n raise \"Unknown property type: #{property_type}\"\n end\n end",
"def type=(val)\n\n dtype = val\n #return self if @chars_allowed # disallow changing\n # send in a regexp, we just save it.\n if dtype.is_a? Regexp \n @chars_allowed = dtype\n return self\n end\n dtype = dtype.to_s.downcase.to_sym if dtype.is_a? String\n case dtype # missing to_sym would have always failed due to to_s 2011-09-30 1.3.1\n when :integer, Integer\n @chars_allowed = /\\d/\n when :numeric, :float, Numeric, Float\n @chars_allowed = /[\\d\\.]/ \n when :alpha\n @chars_allowed = /[a-zA-Z]/ \n when :alnum\n @chars_allowed = /[a-zA-Z0-9]/ \n else\n raise ArgumentError, \"Field type: invalid datatype specified. Use :integer, :numeric, :float, :alpha, :alnum \"\n end\n self\n end",
"def basic_type_check(time, minutes)\n raise 'Unexpected type passed for time variable - should be string' unless time.is_a? String\n raise 'Unexpected type passed for additional_minutes variable - should be integer' unless minutes.is_a? Integer\nend",
"def validates_format_of(content)\n /\\b(?:(?:(?:ai|ae|ao|a|à|ei|eo|e|ia|iai|ie|io|i|oai|oa|oe|oi|o|ò|-)?(?:(?:b|dr|d|f|g|h|j|k|l|mb|mp|m|ndr|ntr|nts|nd|nj|ng|nk|nt|n|p|r|s|tr|ts|t|v|z)(?:'?(?:ai|ae|ao|a|à|ei|eo|e|ia|iai|ie|io|i|oai|oa|oe|oi|o|ò)|-))*(?:b|dr|d|f|g|h|j|k|l|mb|mp|m|ndr|ntr|nts|nd|nj|ng|nk|nt|(?:\\w+)n'n|n|p|r|s|tr|ts|t|v|z)(?:ao|ae|a-|a|à|eo|e|i-|ia|ie|io|oay|oa|oe|o-|o|ò|oy|iay|ey|ay|y))|ah|an|ar|eh|e|i|oh|ô|ao|eo|e|ia|ie|io)\\b/i =~ content\n end",
"def validate_regex_validation()\n if self.regex_validation != nil\n begin\n re = Regexp.new( self.regex_validation )\n rescue RegexpError\n errors.add( :regex_validation, \"is invalid.\" )\n end\n end\n end",
"def validate_string_attributes\n validation_regex.each_key do |m|\n t = valid_string_match?(\n send(m).to_s,\n validation_regex[m][:regex],\n validation_regex[m][:mandatory]\n )\n raise \"#{self.class} error #{m} : #{send(m)}\" unless t == true\n end\n end",
"def check_numericity\n check_patterns(@income.to_s)\n check_patterns(@age.to_s)\n end",
"def checkTypo(arg,regex)\r\n return !(arg=~regex)\r\nend",
"def validate_input # :nodoc:\n raise ComplexMatcherError.new(\"name can't be nil\") if @name.nil?\n raise ComplexMatcherError.new(\"regexp can't be nil\") if @regexp.nil?\n end",
"def allow_matcher; end",
"def check_input(input)\n if /\\D/.match(input)\n false\n else\n true \n end\nend",
"def test_invalid_characters_in_name\n type = Type.new(:name => \"Do not allow < or > in the name\")\n assert !type.valid?\n assert type.errors.invalid?(:name)\n end",
"def check_type (num)\n # convert to float if validated number contains a decimal\n if num =~ /\\./\n return num = Float(num)\n else\n return num = Integer(num)\n end\nend",
"def check_type(type, value)\n return unless type && value && !value.is_a?(type)\n\n \"should be of type #{type} but is of type #{value.class}\"\n end",
"def allow_value_matcher; end",
"def is_valid?(types, item)\n types.each do |type|\n if type == :ipv4\n return true if ipv4?(item)\n elsif type == :domain\n return true if domain?(item)\n elsif type == :hash\n return true if hash?(item)\n elsif type == :classification\n return true if classification?(item)\n elsif type == :tag\n return true if tag?(item)\n elsif type == :bool\n return true if bool?(item)\n elsif type == :ssl_field\n return true if ssl_field?(item)\n elsif type == :whois_field\n return true if whois_field?(item)\n elsif type == :tracker_type\n return true if tracker_type?(item)\n end\n end\n return false\n end",
"def validate_string( str )\r\n if str.kind_of?(String)\r\n return true\r\n else\r\n puts \"#{self.class}:check_string: Error: Input must be a string.\"\r\n return false\r\n end\r\n end",
"def coerce(pattern)\n case pattern\n when String, Symbol, Proc\n pattern\n when Regexp\n Regexp.new(pattern.to_s)\n else\n raise ValidationCoercion, \"Wrong type, got #{pattern.class}\"\n end\n end",
"def validateType\n unless Agent_Types.include?(@type)\n raise \"value #{@type} is not a valid agent type value\"\n end\n end",
"def match?(type, code=nil)\n\t\tif code.nil?\n\t\t\t@type==type\n\t\telsif code.is_a?(Regexp)\n\t\t\t@type==type && @code =~ code\n\t\telse\n\t\t\t@type==type && @code==code\n\t\tend\n\tend",
"def validate_field_types\n database_field_names.each do |field|\n field_info = self.class.get_table_info.select {|hash| hash[\"name\"] == field}.first\n check_field_value_matches_data_type(field_info, field) \n end\n @errors\n end",
"def regexp?(value, option = nil)\n if option.is_a?(Regexp)\n options = {:regexp => option}\n else\n options = option\n end \n return true if value.nil? and not required(options) \n return false unless value.is_a?(String)\n raise TypeError.new(\"option :regexp is not Regexp.\") unless options[:regexp].is_a?(Regexp)\n return options[:regexp].match(value)\n end",
"def accept? ctype\n unless self.class.force_mime_type\n ctype = Regexp.escape ctype\n ctype = ctype.gsub(\"\\\\*\", \"[^/]*\")\n matcher = %r{#{ctype}}\n end\n\n !!self.class.mime_types.find do |mt|\n if matcher\n mt =~ matcher\n else\n mt == ctype\n end\n end\n end",
"def regex?\n @name.is_a?(Regexp)\n end",
"def valid_looking_string?(str)\n str =~ /\\d/\n end",
"def regexp; end",
"def regexp; end",
"def valid_format_email_or_phone?\n email_or_phone =~ email_fromat || email_or_phone =~ mobile_fromat || email_or_phone.blank?\n end",
"def page_formats_contraint\n Regexp.new page_formats * '|'\n end",
"def valid_type?(type)\n super || extended_types.include?(type)\n end",
"def validate?(value_type)\n @error = ''\n @error = validate_data_type(value_type)\n\n if @error == ''\n @error = validate_value(value_type)\n end\n (@error == '')\n end",
"def validate_inputs(env, rec, args)\n # check size\n return false unless inputs.size == args.size\n\n # check type\n inputs.each_with_index do |input, i|\n input = get_type(env, input, rec)\n unless input.match(env, args[i])\n return false\n end\n end\n return true\n end",
"def valid_string?(string)\n if string.class == String\n string\n else\n false\n end\nend",
"def __typedeaf_valid_type?(value, type)\n return value.is_a? type\n end",
"def is_strtype?(); @type == GRT_STRTYPE; end",
"def validate_line_value(line_value, validators)\n okay = true\n if validators && !validators.empty?\n okay = false\n validators.each do |v|\n okay = true and break if v.class.to_s == 'Regexp' and line_value =~ v\n okay = true and break if v.class.to_s == 'String' and line_value == v\n okay = true and break if v.respond_to?(:call) and v.call(line_value)\n end\n end\n okay\n end",
"def matches_options?(type, regexp)\n case type\n when :option_name then options.any? { |n, _| regexp =~ n }\n when :option_value then options.any? { |_, v| regexp =~ v }\n when :command_name then regexp =~ options[:command]\n end\n end",
"def string_or_numeric!(v)\n case v\n when ''\n nil\n when String, Numeric\n true\n else\n raise Error, \"unexpected value received: #{v.inspect}\"\n end\n end",
"def recognized_pattern?(pattern)\n [FalseClass, TrueClass, String, \n Regexp, Waw::Validation::Validator, StaticController::AbstractMatcher].any?{|c| c===pattern}\n end",
"def valid?(value)\n @type_checker.valid?(value)\n end",
"def validate(noun)\n return false if noun.is_proper?\n\n s = noun.to_s\n return false if s.nil?\n return false if s.length <= 1\n\n @@patterns.each do |pattern|\n return false if s =~ pattern\n end\n\n return true\n end",
"def test_is_nummeric\n assert(StringChecker.is_numeric?(\"+20\"))\n assert(StringChecker.is_numeric?(\"-020\"))\n assert(StringChecker.is_numeric?(\"123\"))\n assert(StringChecker.is_numeric?(\"0123\"))\n assert(!StringChecker.is_numeric?(\"1.2\"))\n assert(!StringChecker.is_numeric?(\"asdf\"))\n assert(!StringChecker.is_numeric?(\" \"))\n end",
"def datetime_pattern(field)\n pattern1 = field.scan(/[0-9]\\//)\n pattern2 = field.scan(/[0-9]\\-/)\n pattern3 = field.scan(/[0-9] /)\n pattern4 = field.scan(/[0-9] [A-Z][a-z][a-z] [0-9]|[0-9]-[A-Z][a-z][a-z]-[0-9]|[0-9] [a-z][a-z][a-z] [0-9]|[0-9]-[a-z][a-z][a-z]-[0-9]/)\n if(pattern1.size == 2||pattern2.size == 2||pattern3.size == 2||pattern4.size != 0)\n return true\n else\n return false\n end\nend",
"def valids(name = nil, type = nil)\n return @validate.valids(name, type)\n end",
"def valid_type(type, default: nil)\n type ||= default\n\n t = type.to_s\n type = case t\n when /^i(m(p(o(r(t)?)?)?)?)?$/\n :import\n when /^e(x(p(o(r(t)?)?)?)?)?$/\n :export\n else\n raise Errors::InvalidPluginType.new('Invalid plugin type', 'unrecognized')\n end\n\n type.to_sym\n end",
"def valid_num?(input)\n integer?(input) || float?(input)\nend",
"def validate_parameter_type\n if PRIMITIVE_PARAMETER_TYPES.include? self.parameter_type || self.parameter_type === 'Object'\n true\n elsif self.parameter_type.include?('[') # compound types have brackets []\n # extract primitives from complex type\n raw_primitives = self.parameter_type.split('[').last\n raw_primitives.gsub!(/]\\??/, '')\n primitives = raw_primitives.split(',').map(&:strip)\n if self.parameter_type.start_with?('Array')\n # there is only one primitive type from the control list\n unless primitives.size === 1 && PRIMITIVE_PARAMETER_TYPES.include?(primitives.first)\n errors.add(:parameter_type, \"has an invalid primitive type: #{(primitives - PRIMITIVE_PARAMETER_TYPES).join(', ')}\")\n end\n elsif self.parameter_type.start_with?('Map')\n # there are two primitive types, and the intersection is the same as the unique list of primitives\n unless primitives.size === 2 && (primitives & PRIMITIVE_PARAMETER_TYPES === primitives.uniq)\n errors.add(:parameter_type, \"has an invalid primitive type: #{(primitives - PRIMITIVE_PARAMETER_TYPES).join(', ')}\")\n end\n else\n errors.add(:parameter_type, \"has an invalid complex type: #{self.parameter_type.split('[').first}\")\n end\n else\n errors.add(:parameter_type, \"has an invalid value: #{self.parameter_type}\")\n end\n end",
"def validateVertexPattern(to_match)\n\t\t# Pattern to check for special charectors\n\t\tpattern = /[A-Za-z]/ \n\t\treturn to_match =~ pattern\n\tend",
"def valid_number?(num)\n integer?(num) || float?(num)\nend",
"def _validate_test_type(t)\n supported_test_types = Specification::DSL::SUPPORTED_TEST_TYPES.map(&:to_s)\n unless supported_test_types.include?(t.to_s)\n results.add_error('test_type', \"The test type `#{t}` is not supported. \" \\\n \"Supported test type values are #{supported_test_types}.\")\n end\n end",
"def process_typestr(str, table, allow_size=true)\n str = str.strip\n \n match = str.match(TYPE_REGEXP)\n unless match\n raise \"Unknown type format: '#{str}'\"\n end\n\n # Extract values from match data\n ident = match[1]\n is_array = match[2] != nil\n array_size = match[3]\n references = match[4]\n\n # If array size is specified, convert from string -> int\n if array_size != nil \n unless allow_size\n raise \"Not allowed to specify array size in: '#{str}'\"\n end\n\n array_size = Integer(array_size)\n end\n\n # If references are used, record the number of them\n if references != nil\n raise \"Reference type unsupported\"\n references = references.size\n end\n \n # Look up basic type\n type = table.get_type(ident)\n if type == nil\n raise \"Unrecognized type '#{ident}'\"\n end\n\n # If array is used, encapsulate type within array type\n if is_array\n if array_size != nil\n type = ArrayType.new(type, array_size)\n else\n type = ArrayType.new(type)\n end\n end\n\n # Wrap type in AddressType for each reference used\n if references != nil\n (1..references).each do\n type = AddressType.new(type)\n end\n end\n\n return type\nend",
"def validates_not_string(atts, opts={})\n validatable_attributes(atts, opts) do |a,v,m|\n next unless v.is_a?(String)\n next m if m\n (sch = db_schema[a] and typ = sch[:type]) ? \"is not a valid #{typ}\" : \"is a string\"\n end\n end",
"def test_one_arg\n assert_true ArrayPatternMatcher.new(1) === [1]\n assert_true ArrayPatternMatcher.new(Integer) === [1]\n assert_true ArrayPatternMatcher.new(/\\s/) === [' ']\n assert_true ArrayPatternMatcher.new(String) === [' ']\n assert_false ArrayPatternMatcher.new(Integer) === []\n assert_false ArrayPatternMatcher.new(Integer) === [' ']\n assert_false ArrayPatternMatcher.new(String) === ' '\n assert_false ArrayPatternMatcher.new(Array) === ' '\n end",
"def validate_content_type( valid )\n raise Atom::HTTPException, \"HTTP response contains no Content-Type!\" if not self.content_type or self.content_type.empty?\n\n media_type = self.content_type.split(\";\").first\n\n unless valid.member? media_type.downcase\n raise Atom::WrongMimetype, \"unexpected response Content-Type: #{media_type.inspect}. should be one of: #{valid.inspect}\"\n end\n end",
"def is_string?(); @type == GRT_STRING; end",
"def valid_birthdate(input)\n# if input.length == 8 && input.match(/^[0-9]+[0-9]$/) my code\n# SK code:\n if(input.length == 8 && !input.match(/^[0-9]+[0-9]$/).nil?)\n true\n else\n false\n end\nend",
"def check_value!(value)\n # Allow nil and Strings to fall back on the validations for typecasting\n case value\n when nil, String, expected_type\n value\n else\n raise TypeError, \"#{@name} expected #{expected_type.inspect} but got #{value.inspect}\"\n end\n end",
"def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)\n StringPattern.validate(text: string_to_validate, pattern: to_s, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)\n end",
"def validate_content_type!\n return if request.content_type == \"application/json\"\n return if request.get? && request.content_type == \"text/plain\"\n return if !request.get? && request.content_type == \"application/x-www-form-urlencoded\"\n\n raise ActionController::BadRequest, \"Invalid content type\"\n end",
"def vdate_tan(attr)\n # by default must be present\n validates_presence_of attr\n \n # check for the length, TAN/PAN both have to be 10 character long \n validates_length_of attr , :is => 10 , :message => \"^TAN is of exaclty 10 characters \"\n \n # pattenr matching such that FIRST 4 - Char , Next 5 - Digit\n # and last one is CHAR again in 10 chracters of the PAN number \n validates_format_of attr ,\n :with => /[A-Z]{4}\\d{5}[A-Z]{1}/ ,\n :message => \"^invalid TAN format, First four alphabets, next five numerals and last again alpahbet e.g.AAAA55555A\"\nend",
"def check_type(val, type)\n if val.class != type\n raise TypeError\n end\nend",
"def assert_type(type, length, precision, scale)\n if type == 'longvarchar'\n return \"character varying(#{length})\"\n end\n\n if type == 'time'\n return \"time with time zone\"\n end\n\n if type == 'tinyint' || type == 'integer'\n return \"integer\"\n end\n\n if type == 'char'\n return \"\\\"char\\\"\"\n end\n\n if type == 'decimal'\n return \"numeric(#{precision},#{scale})\"\n end\n\n if type == 'date'\n return \"date\"\n end\n\nend",
"def validation_regex\n /\\s*validates(?:\\s+|_\\w+\\s+)(?:\\S|\\s)+/\n end",
"def term_valid?(term)\n term.is_a?(String)\n end"
] | [
"0.68802184",
"0.6839543",
"0.6527269",
"0.64993024",
"0.64837825",
"0.6456251",
"0.641913",
"0.63899815",
"0.6378739",
"0.63780916",
"0.63386846",
"0.6270964",
"0.6194017",
"0.6101317",
"0.60903764",
"0.6088762",
"0.60780627",
"0.607773",
"0.6049135",
"0.60403526",
"0.60158277",
"0.60015273",
"0.60015273",
"0.5977408",
"0.5966117",
"0.5962291",
"0.5947702",
"0.59326965",
"0.59298164",
"0.59298164",
"0.58914",
"0.58788383",
"0.5872758",
"0.58618456",
"0.58551633",
"0.5845792",
"0.58437246",
"0.58284897",
"0.58177274",
"0.5816255",
"0.58127946",
"0.5811759",
"0.58096164",
"0.58026975",
"0.5802174",
"0.5790858",
"0.57835627",
"0.5777925",
"0.5761445",
"0.57385206",
"0.5733617",
"0.571584",
"0.5707179",
"0.57060575",
"0.57051575",
"0.5702416",
"0.56955916",
"0.5694782",
"0.569288",
"0.5691814",
"0.5686714",
"0.5686243",
"0.5686243",
"0.5685648",
"0.5671864",
"0.5669279",
"0.5642294",
"0.56356084",
"0.5631114",
"0.56248724",
"0.56107",
"0.5609735",
"0.56038654",
"0.55915886",
"0.5590473",
"0.558668",
"0.5586167",
"0.5583771",
"0.55833614",
"0.55828726",
"0.55827725",
"0.5582724",
"0.55540484",
"0.5546571",
"0.5542085",
"0.55416805",
"0.5540907",
"0.5540503",
"0.55384505",
"0.5537528",
"0.5536457",
"0.5534966",
"0.55269283",
"0.55258316",
"0.5512581",
"0.55084115",
"0.5507763",
"0.5505525",
"0.5503619",
"0.5498126"
] | 0.7350269 | 0 |
Perform Author: Aman Date: 30/05/2019 Reviewed By: | def perform
fail 'unimplemented perform'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submission_decision_author(submission)\n @submission = submission\n\n @authors_text = @submission.get_authors_submitted.map{ |a| a.full_name }.join(', ')\n @title_text = @submission.get_text_submitted.title rescue ''\n\n @journal = @submission.journal\n @user = @submission.user\n @submission_url = submission_url(submission)\n @submission_editor_url = e_submission_url(submission)\n @submission_reviewer_url = r_submission_url(submission)\n\n @decision = @submission.lsr.decision_2 || @submission.lsr.decision_1_cold || @submission.lsr.decision_1\n\n if @decision\n case @decision.decision\n when 'take_for_consideration'\n# subject = \"#{@journal.slug}##{submission.id} The paper was taken for consideration | Статья принята к рассмотрению\"\n subject = \"##{@submission.id} Taken for consideration. Journal Gyroscopy and Navigation | Принято к рассмотрению. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_take_for_consideration' }\n\t\t end\n when 'reject_without_consideration'\n# subject = \"#{@journal.slug}##{submission.id} The paper was rejected without consideration | Статья отклонена без рассмотрения\"\n subject = \"##{@submission.id} Rejected without consideration. Journal Gyroscopy and Navigation | Отклонено без рассмотрения. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_reject_without_consideration' }\n\t\t end\n when 'reject'\n# subject = \"#{@journal.slug}##{submission.id} The paper was rejected | Статья отклонена\"\n subject = \"##{@submission.id} Paper rejected. Journal Gyroscopy and Navigation | Статья отклонена. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_reject' }\n\t\t end\n when 'revise'\n# subject = \"#{@journal.slug}##{submission.id} The paper must be revised | Статью надо доработать\"\n subject = \"##{@submission.id} Paper must be revised. Journal Gyroscopy and Navigation | Статью надо доработать. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_revise' }\n\t\t end\n when 'accept'\n# subject = \"#{@journal.slug}##{submission.id} The paper was accepted | Статья принята\"\n subject = \"##{@submission.id} Paper accepted. Journal Gyroscopy and Navigation | Статья принята. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_accept' }\n\t\t end\n when 'wait_decision'\n # Add email for transition to this this state???\n nil\n end\n end\n end",
"def performed_by(params = {})\n #TODO\n end",
"def reviewed_by=(value)\n @reviewed_by = value\n end",
"def paper\n reviewer_recommendations_task.paper\n end",
"def author; @author; end",
"def author; @author; end",
"def resolved_author; end",
"def author; end",
"def review_committee_decision\n application_review_decision_type.title if application_review_decision_type\n end",
"def assessment_type_author\n frm.div(:class=>\"tier2\").table(:index=>$frame_index)[1][1].text\n end",
"def reviewed_by\n return @reviewed_by\n end",
"def author\n [author_developer.name_and_email, author_date, author_date_gmt_offset]\n end",
"def users_role_with_this_submission(user)\n if self.corresponding_author == user\n return 'Corresponding Author'\n elsif self.coauthors.include?(user)\n return 'Coauthor'\n elsif self.reviewers.include?(user)\n return 'Reviewer'\n elsif section_editors.include?(user)\n return 'Section Editor'\n else\n return 'This user is not associated with this manuscript'\n end \n end",
"def author\n @info[:Author]\n end",
"def author\n\t\t@author\n\tend",
"def review; end",
"def author\n if @submission.user != current_user.sk\n render 'errors/access_refused' and return\n end\n end",
"def author\n quote_of_the_day[second_to_last_index(quote_of_the_day, \"~\")..quote_of_the_day.rindex(\"~\")].gsub(/(\\A~\\s*|\\s*~\\z)/, \"\")\n end",
"def review\n end",
"def author\n @author\n end",
"def review(*)\n super.tap do\n __debug_sim('REVIEWER initiates review of the submission.')\n end\n end",
"def process_created_review(review_payload)\n pr_name = review_payload['repository']['full_name'].to_s\n pr_number = review_payload['pull_request']['number'].to_s\n comment_user = review_payload['review']['user']['id'].to_s\n approvals = evaluate_review_state(review_payload['review']['state'])\n current_commit_hash = review_payload['pull_request']['head']['sha'].to_s\n\n submit_status(pr_name, pr_number, current_commit_hash, comment_user, approvals)\n end",
"def generate_department_review_title \n review_type = self.scorable_type\n case review_type\n when \"GovernmentScore\"\n self.title = \"#{self.user.name}'s Government Review\"\n when \"ParkScore\"\n self.title = \"#{self.user.name}'s Parks Review\"\n when \"SchoolScore\"\n self.title = \"#{self.user.name}'s Schools Review\"\n when \"PoliceScore\"\n self.title = \"#{self.user.name}'s Police Review\"\n when \"PublicScore\"\n self.title = \"#{self.user.name}'s Public Works Review\"\n end\n end",
"def release_summary title = nil\n datestamp_title = title ? Time.now.strftime(\"(%-m/%d) #{title}:\") : Time.now.strftime(\"%-m/%d:\")\n\n if done_cards.empty?\n datestamp_title + \" Nada. 😢\"\n else\n ([datestamp_title] + done_cards.map { |card| '- ' + card['note'] }).join \"\\n\"\n end\nend",
"def reviewer_report_task_phase\n get_reviews_phase = paper.phases.where(name: 'Get Reviews').first\n get_reviews_phase || phase\n end",
"def review\n @review\n end",
"def pre_submission_date_status\n 'New Announcement'\n end",
"def author\n file.version.author.name\n end",
"def get_author_transaction\n if outflow then\n \"Outflow: #{outflow.concept}\"\n else\n movement ? \"Movimiento: #{movement.concept}\" : 'N/A'\n end\n end",
"def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{date_of_accomplishment} was the year of #{name}. #{major_accomplishment.capitalize},\n\tdoes that ring a bell? That was all thanks to #{name}. \\n \n\t#{thesis} \\n\n\tMuch more could be said of #{name}. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend",
"def reference_document\n if document.blank?\n \"None Assigned\"\n else\n document.refno+\" : \"+document.title+\" : dated \"+document.letterdt.strftime(\"%d-%b-%Y\").to_s\n end\n end",
"def author\n page.version.author.name\n end",
"def educational_attainment; end",
"def review(review)\n @review = review\n @abstract = review.abstract_doc\n User.with_role(:admin).each do |user|\n mail(to: user.email, subject: 'All reviews submitted for abstract titled '+@abstract.title)\n end\n end",
"def reviewed_date_time\n return @reviewed_date_time\n end",
"def author\n @author ||= Readability::Document.new(@html).author\n end",
"def created_by\r\n\t\t\t \t\"Lachezar Kostov and Dimitar Bakardzhiev\"\r\n\t\t end",
"def prt\n puts \"Federalist #@fedno\"\n puts \"Title: \" + @title.join(\" \")\n puts \"Publication: \" + @publication.join(\" \")\n puts \"Author: \" + @author.join(\" \")\n \n end",
"def creator\n \"Made by ROUINEB Hamza. 2016\"\n end",
"def reviewers\n \"Here's the current list of JOSS reviewers: https://github.com/openjournals/joss/blob/master/docs/reviewers.csv\"\nend",
"def inner_author\n @commit.author\n end",
"def interview_committee_decision\n application_interview_decision_type.title if application_interview_decision_type\n end",
"def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{year_of_accomplishment} was the year of #{name}. #{major_accomplishment},\n\tdoes that ring a bell? That was all thanks to #{name}. #{thesis} \n\t\\n\n\tMuch more could be said of #{name}, but I believe in brevity. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend",
"def print_created_by\n puts 'Created by James (#1) Bronzan'\n end",
"def author \n user.firstname + ' ' + user.lastname\n end",
"def show\n @performer = current_user.performer\n end",
"def review_complete(params)\n # validate these parameters. If this passes, we can safely import.\n params = validate_review_completed_parameters(params)\n self.analyst_id = params[\"analyst_id\"]\n self.analyst_fullname = params[\"analyst_fullname\"]\n self.analyst_approval_datetime = params[\"analyst_approval_datetime\"]\n self.analyst_transaction_id = params[\"analyst_transaction_id\"]\n self.analyst_internal_status_id = params[\"analyst_internal_status_id\"]\n self.decision_code = params[\"decision_code\"]\n self\n end",
"def author\n recipe.author\n end",
"def author\n recipe.author\n end",
"def created_by\r\n\t\t\treturn \"Laura OMalley\"\r\n\t\tend",
"def name_of_person_of_ticket\n self.viewer.name\n \n end",
"def title_of_active_review\n conflicting_request_issue.try(:review_title)\n end",
"def author() headers['author'] end",
"def user_name\n reviewee.name\n end",
"def performers\n find_related_frbr_objects( :is_performed_by, :which_roles?) \n end",
"def performers\n find_related_frbr_objects( :is_performed_by, :which_roles?) \n end",
"def add_review\n login_as(User.where(role_id: 1).first.name)\n expect(page).to have_content 'User: ' + User.where(role_id: 1).first.name\n\n expect(page).to have_content 'TestAssignment'\n\n click_link 'TestAssignment'\n expect(page).to have_content 'Submit or Review work for TestAssignment'\n expect(page).to have_content \"Others' work\"\n\n click_link \"Others' work\"\n expect(page).to have_content 'Reviews for \"TestAssignment\"'\n\n choose 'topic_id'\n click_button 'Request a new submission to review'\n\n click_link 'Begin'\n\n fill_in 'responses[0][comment]', with: 'HelloWorld'\n select 3, from: 'responses[0][score]'\n click_button 'Submit Review'\n expect(page).to have_content 'Your response was successfully saved.'\n click_link 'Logout'\n end",
"def assign_reviewer(new_reviewer)\n new_reviewer = new_reviewer.gsub(/^\\@/, \"\")\n editor = issue.body.match(/\\*\\*Editor:\\*\\*\\s*.@(\\S*)/)[1]\n new_body = issue.body.gsub(/\\*\\*Reviewer:\\*\\*\\s*(@\\S*|Pending)/i, \"**Reviewer:** @#{new_reviewer}\")\n github_client.add_collaborator(@nwo, new_reviewer)\n puts \"NWO: #{@nwo}\"\n puts \"ISSUE ID: #{@issue_id}\"\n puts \"TITLE: #{issue.title}\"\n puts \"BODY: #{new_body}\"\n puts \"ASSIGNEES #{[new_reviewer, editor]}\"\n github_client.update_issue(@nwo, @issue_id, issue.title, new_body, :assignees => [])\n update_assigness([new_reviewer, editor])\nend",
"def bookAuthor\n\t\tarr =[]\n\t\tcurrent_user.reads.each do |f|\n\t\t\tbook = Book.find_by_id(f.book_id)\n\t\t\tauthor = book.authorFirst + \" \" + book.authorLast\n\t\t\tarr.push(author)\n\t\tend\n\t\t@h = Hash.new(0)\n\t\t\tarr.each do |word|\n\t\t\t@h[word.to_sym] += 1\n\t\tend\n\t\tgenre = @h.sort_by{|word,count| count}\n\t\tgenre = genre.reverse # Hash highest the genre picked the most\n\n\t\tarr2 =[]\n\t\tgenre.each do |key,value|\n\t\t\tarr2.push(key)\n\t\tend\n\t\tif(arr2.size > 1)\n\t\t\t@popAuthor = arr2.at(0)\n\t\telse\n\t\t\t@popAuthor = \"Adventure\"\n\t\tend\n\tend",
"def show\n\n @all_annotation_string = ''\n Annotation.where(passage_id: @passage.id).each do |annot|\n @all_annotation_string = @all_annotation_string + \"#{annot.element}@-@#{annot.original_spanish}@-@#{annot.annotation_content}$-$\"\n end\n @all_annotation_string = @all_annotation_string.gsub(/\\R+/, ' ')\n\n\n #==================================================================\n #DO NOT ALLOW TO READ IF NOT GRANTED PRIVILEGE\n #DO NOT LINK TO EDIT IF NOT GRANTED PRIVILEGE\n privilege = PassageShare.find_by(recieving_user_id: @current_user.id, passage_id: @passage.id)\n\n\n if (@passage.user_id == @current_user.id)\n author = true\n else\n author = false\n end\n\n if author || privilege\n else \n redirect_back fallback_location: '/'\n end\n\n if author || privilege.edit_privilege\n @has_editing_privilege = true\n else \n @has_editing_privilege = false\n end\n #==================================================================\n\n #==================================================================\n #RETRIEVE AUTHOR OF CURRENT PASSAGE\n if author\n @author = @current_user\n else\n @author = User.find(@passage.user_id)\n end\n #==================================================================\n\n #==================================================================\n #RETRIEVE HISTORY OF UPDATES FOR CURRENT PASSAGE AND USERS THAT MADE THEM\n @update_history = UpdateTrack.where(passage_id: @passage.id).order(\"created_at DESC\")\n @participating_users = {}\n @time_since = {}\n @update_history.each do |update|\n @time_since[update.id] = update_elapse_count(update[:created_at])\n @participating_users[update.id] = User.find(update.last_user_id)\n end \n #==================================================================\n end",
"def description_complexity(pr)\n pull_req = pull_req_entry(pr[:id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end",
"def get_author()\n @author\n end",
"def acquired_on\n @object.most_recent_acquired_by_date.try(:strftime, '%-m/%-d/%Y')\n end",
"def title\n if review?\n confidential? ? \"#{name} (Private Review)\" : \"#{name} (Shared Review)\"\n elsif verification?\n \"#{name} (Verification)\"\n elsif groups?\n \"#{name} (Group)\"\n elsif private_type?\n \"#{name} (Private)\"\n elsif government?\n \"#{name} (Government)\"\n else\n \"#{name} (Administrator)\"\n end\n end",
"def initialize(title, author,year=\"unknown\", edition=\"unknown\")\n @title = title\n @author = author\n @checked_out = false\n @current_patron = nil\n @year_published = year\n @edition = edition\n @reviews = {}\n end",
"def track_performer_ids\n param_role_extractor(:track_contributors, :performers)\n end",
"def display_goal\n puts \"\\nYOUR CURRENT GOAL IS: #{self.description}\".light_white\n if self.target_date\n puts \"\\nTARGET DATE TO REACH YOUR GOAL: #{self.target_date.strftime('%-d %B %Y')}\".light_white\n end\n if self.attainable\n puts \"\\nWHY I CAN ACHIEVE THIS GOAL: #{self.attainable}\".light_white\n end\n if self.relevant\n puts \"\\nWHY THIS GOAL MATTERS: #{self.relevant}\".light_white\n end\n end",
"def read_review\n index = 0\n puts \"Here are the reviews and ratings for: #{@title}\"\n @ratings.each {|rating_num|\n puts \"Rating: #{rating_num}\"\n puts \"Review: #{@reviews[index]}\"\n index += 1\n }\n end",
"def under_review_status\n 'Under Review'\n end",
"def process_git_log_into_author_summary\n distribute_entries_to_authors( load_git_log_entries( path_to_git_repo ) )\n return prepare_rows_for_author_summary_csv\n end",
"def vacate_at_attorney_review(mtv_judge, drafting_attorney, lit_support_user)\n # These are ready to be reviewed by the decision drafting attorney on the vacate stream\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"denied\")\n judge_addresses_mtv(jam_task, \"denied\", nil, lit_support_user)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"dismissed\")\n judge_addresses_mtv(jam_task, \"dismissed\", nil, lit_support_user)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"straight_vacate\", drafting_attorney)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"vacate_and_readjudication\", drafting_attorney)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"vacate_and_de_novo\", drafting_attorney)\n end\n end",
"def details\n @article = Article.find(params[:article_id])\n revisions = @course.tracked_revisions.where(article_id: @article.id).order(:date)\n @first_revision = revisions.first\n @last_revision = revisions.last\n editor_ids = revisions.pluck(:user_id).uniq\n @editors = User.where(id: editor_ids)\n end",
"def generate_reviewer_selection_list()\n self.design_review_results.sort_by { |rr| rr.role.display_name }\n end",
"def workflow_comment_attribution(comment)\n commenter = comment.agent.proxy_for\n commenter_display = current_user == commenter ? 'You' : \"#{commenter.display_name} (#{commenter.email})\"\n \"#{commenter_display} commented on #{comment.created_at.strftime('%B %-d, %Y')}\"\n end",
"def pr_description\n danger_file.warn('Please provide a summary in the Pull Request description') if danger_file.github.pr_body.length < 3 && danger_file.git.lines_of_code > 10\n end",
"def manual_review_needed_template\n 'manual_review_needed'\n end",
"def\n get_author()\n @author\n end",
"def reviews_reviewsstory_label\n $tracer.trace(__method__)\n return ToolTag.new(div.className(\"/gi-post/\").h1.className(\"/game-name/\"), __method__)\n end",
"def essay_writer(title, topic, date, thesis_statement, pronoun)\n if pronoun == \"male\"\n who = \"He\" \n whose = \"His\"\n whom = \"Him\"\n \n elsif pronoun == \"female\"\n who = \"She\"\n whose = \"Her\"\n whom = \"Her\"\n \n else\n who = \"It\"\n whose = \"Its\"\n whom = \"Its\"\n end\n \n return who + \" was an important person in \" + date.to_s + \". \" + who + \" did a lot. I want to learn more about him. \" + thesis_statement + \" \" + topic.to_s + \"'s contribution is important.\"\n \nend",
"def author\n \"#{user.firstname} #{user.lastname}\"\n end",
"def weekly_digest(user)\n \n attachments.inline['whitelogo.png'] = File.read(Rails.root.join('app/assets/images/whitelogo.png'))\n \n @user = user\n @introduction = \"Type an introduction here somehow\"\n @first_item = \"Comment.find(target.comment)\"\n @second_item = \"Comment.find(target.comment)\"\n @third_item = \"Comment.find(target.comment)\"\n \n end",
"def seller\n author\n end",
"def purpose\n end",
"def by_author\n user = find_obj_or_goto_index(\n model: User, obj_id: params[:by_author].to_s,\n index_path: name_descriptions_path\n )\n return unless user\n\n query = create_query(:NameDescription, :by_author, user: user)\n show_selected_name_descriptions(query)\n end",
"def attorney_case_reviews\n tasks.map(&:attorney_case_reviews).flatten\n end",
"def oh_crap_i_forgot(title, person, location, date, thesis, major_accomplishment, pronoun)\n pronoun = 'male' ? p_use = 'he' : p_use = 'she'\n date < 1000 ? e_or_l = 'early era' : e_or_l = 'late era'\n\n puts \"#{title} : The Story of #{person}\"\n puts \" \"\n puts \"In #{e_or_l} #{location}, #{person} was a pretty big deal. #{thesis}. #{pronoun.capitalize} changed the very fabric of #{location} when #{pronoun} #{major_accomplishment}.\"\n puts \" \"\n puts \"All in all, #{e_or_l} #{location} would not have been so successful without #{person}, nor would #{location} be the way it is today without those contributions.\"\n puts \"By Mikee.\"\nend",
"def time\n Time.parse(inner_author.date.to_s)\n end",
"def print_created_by\n return \"This game was created by Kevin Tripp.\"\n end",
"def review_results_by_role_name\n self.design_review_results.sort_by { |rr| rr.role.display_name }\n end",
"def create_weblog_explain; \"Create a brand new weblog.\"; end",
"def attribution\n user = roles.creator.first&.user\n user = roles.administrator.not_creator.first&.user if user.blank?\n return [] if user.blank?\n\n text = user&.name(false)\n orcid = user.identifier_for_scheme(scheme: 'orcid')\n if orcid.present?\n text += format(' - <strong>ORCID:</strong> <a href=\"%{orcid_url}\" target=\"_blank\">%{orcid}</a>',\n orcid_url: orcid.value, orcid: orcid.value_without_scheme_prefix)\n end\n text\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 meta_author\n # Change the value below between the quotes.\n \"Team Tation\"\n end",
"def pre_initiation_date_status\n 'Pre-announcement'\n end",
"def details\n\t\t\"#{self.title} - #{self.due_date} - #{self.is_completed}\"\n\tend",
"def approved_by\n if approved?\n I18n::t(:dean, :scope => [:model, :plan])\n elsif approval\n approval.approved_by\n end\n end",
"def headings\n # NOTE: \"Comments\" is shared between both sets\n if self.new_review_format\n [\"Role Competence\",\"Consulting Skills\",\"Teamwork\", \"Contributions\", \"Comments\"]\n else\n [\"Tech\",\"Client\", \"Ownership\", \"Leadership\", \"OldTeamwork\", \"Attitude\", \"Professionalism\", \"Organizational\", \"Innovative\", \"Comments\"]\n end\n end",
"def meta_author\n \"Ahmed Nadar\"\n end",
"def author\n user\n end",
"def submission_title\n self.submission.title(false)\n end",
"def name_descriptions_by_author # :nologin: :norobots:\n if user = params[:id] ? find_or_goto_index(User, params[:id].to_s) : @user\n query = create_query(:NameDescription, :by_author, :user => user)\n show_selected_name_descriptions(query)\n end\n end"
] | [
"0.57207245",
"0.5714492",
"0.55773956",
"0.55771905",
"0.557615",
"0.557615",
"0.55631787",
"0.5537123",
"0.5510056",
"0.55007625",
"0.54789996",
"0.5440919",
"0.5426688",
"0.5418197",
"0.53833264",
"0.5369164",
"0.5347817",
"0.5331972",
"0.5326178",
"0.53240234",
"0.53229916",
"0.5317596",
"0.5266518",
"0.52650476",
"0.5256508",
"0.5237731",
"0.523623",
"0.52271104",
"0.5219071",
"0.5214262",
"0.5209141",
"0.5168917",
"0.51680607",
"0.5154402",
"0.51475513",
"0.5138232",
"0.5123867",
"0.512328",
"0.51162684",
"0.51091695",
"0.5104833",
"0.50972784",
"0.50914025",
"0.508924",
"0.5080931",
"0.50767535",
"0.5064851",
"0.50386524",
"0.50386524",
"0.50326955",
"0.502455",
"0.50210494",
"0.5011578",
"0.50037724",
"0.49942777",
"0.49942777",
"0.49765784",
"0.49748123",
"0.4973476",
"0.49705568",
"0.49681184",
"0.49524128",
"0.49471116",
"0.4943276",
"0.49406746",
"0.4936164",
"0.49348783",
"0.49339864",
"0.49335045",
"0.49245194",
"0.4918974",
"0.4917626",
"0.49165696",
"0.49138883",
"0.49106833",
"0.49097395",
"0.49094358",
"0.49063805",
"0.49024165",
"0.48970285",
"0.48925576",
"0.4887861",
"0.4885652",
"0.48851472",
"0.48847896",
"0.4878919",
"0.48765767",
"0.48699197",
"0.4869054",
"0.48679182",
"0.48670718",
"0.48644271",
"0.4864416",
"0.48599097",
"0.48591805",
"0.48508868",
"0.48458534",
"0.48407835",
"0.4839916",
"0.48377675",
"0.48360738"
] | 0.0 | -1 |
Validate and sanitize Author: Aman Date: 30/05/2019 Reviewed By: | def validate_and_sanitize
r = validate
return r unless r.success?
r = validate_parameters
return r unless r.success?
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_author()\n if not self.check_metatags('author')\n return false\n end\n author = @@metadata['author'].gsub(/\\./,'_').gsub(/\\&/,'').gsub(/\\-/,'_').gsub(/\\s/,'_').gsub(/\\,/,'_').gsub(/\\_\\_/,'_')\n I18n.enforce_available_locales = false\n I18n.transliterate(author).downcase # Normalising\n end",
"def normalize_author(hsh)\n str = hsh['author']\n tokens = repair_and_tokenize_author_text(str)\n authors = []\n current_auth = []\n begin_auth = 1\n tokens.each {|tok|\n if tok =~ /^(&|and)$/i\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n end\n current_auth = []\n begin_auth = 1\n next\n end\n if begin_auth > 0\n current_auth << tok\n begin_auth = 0\n next\n end\n if tok =~ /,$/\n current_auth << tok\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n current_auth = []\n begin_auth = 1\n end\n else\n current_auth << tok\n end\n }\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth.strip unless auth.strip == \"-\" || auth.strip.blank?\n end\n hsh['authors'] = authors if !authors.empty?\n normalize('author',hsh)\n hsh\n end",
"def normalize_author(hsh)\n str = hsh['author']\n tokens = repair_and_tokenize_author_text(str)\n authors = []\n current_auth = []\n begin_auth = 1\n tokens.each {|tok|\n if tok =~ /^(&|and)$/i\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n end\n current_auth = []\n begin_auth = 1\n next\n end\n if begin_auth > 0\n current_auth << tok\n begin_auth = 0\n next\n end\n if tok =~ /,$/\n current_auth << tok\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n current_auth = []\n begin_auth = 1\n end\n else\n current_auth << tok\n end\n }\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth unless auth.strip == \"-\"\n end\n hsh['authors'] = authors\n hsh\n end",
"def author\n quote_of_the_day[second_to_last_index(quote_of_the_day, \"~\")..quote_of_the_day.rindex(\"~\")].gsub(/(\\A~\\s*|\\s*~\\z)/, \"\")\n end",
"def author\n name.split(/[\\/-]/).first\n end",
"def verbatim_author(author_year)\n return nil if author_year.blank?\n author_year.gsub(/\\,+\\s*\\d\\d\\d\\d/, '')\n end",
"def parse_author_names_and_suffix author_names_string\n author_names_and_suffix = AuthorName.import_author_names_string author_names_string.dup\n if author_names_and_suffix[:author_names].empty? && author_names_string.present?\n errors.add :author_names_string, \"couldn't be parsed. Please post a message on http://groups.google.com/group/antcat/, and we'll fix it!\"\n self.author_names_string = author_names_string\n raise ActiveRecord::RecordInvalid.new self\n end\n author_names_and_suffix\n end",
"def check_author\n if self.author.blank?\n self.author = 'anon'\n end\n end",
"def author\n @author ||=\n convert_content(item_attributes!.author) ||\n convert_content(item_attributes!.creator) ||\n \"\"\n end",
"def validate_author author\n raise ArgumentError.new(\"Author must be an Unloq::Author or Unloq::Recipient\") unless author.is_a?(Unloq::Entity)\n end",
"def author_string\n if !self.verbatim_author.nil?\n self.verbatim_author\n elsif !self.source_id.nil?\n self.source.authority_name\n else\n nil\n end\n end",
"def author\n if @author.nil?\n @author = FeedTools::Author.new\n author_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"atom10:author\",\n \"atom03:author\",\n \"atom:author\",\n \"author\",\n \"managingEditor\",\n \"dc:author\",\n \"dc:creator\"\n ])\n unless author_node.nil?\n @author.raw = FeedTools::XmlHelper.try_xpaths(\n author_node, [\"text()\"], :select_result_value => true)\n @author.raw = FeedTools::HtmlHelper.unescape_entities(@author.raw)\n unless @author.raw.nil?\n raw_scan = @author.raw.scan(\n /(.*)\\((\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\)/i)\n if raw_scan.nil? || raw_scan.size == 0\n raw_scan = @author.raw.scan(\n /(\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\s*\\((.*)\\)/i)\n unless raw_scan.size == 0\n author_raw_pair = raw_scan.first.reverse\n end\n else\n author_raw_pair = raw_scan.first\n end\n if raw_scan.nil? || raw_scan.size == 0\n email_scan = @author.raw.scan(\n /\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b/i)\n if email_scan != nil && email_scan.size > 0\n @author.email = email_scan.first.strip\n end\n end\n unless author_raw_pair.nil? || author_raw_pair.size == 0\n @author.name = author_raw_pair.first.strip\n @author.email = author_raw_pair.last.strip\n else\n unless @author.raw.include?(\"@\")\n # We can be reasonably sure we are looking at something\n # that the creator didn't intend to contain an email address\n # if it got through the preceeding regexes and it doesn't\n # contain the tell-tale '@' symbol.\n @author.name = @author.raw\n end\n end\n end\n if @author.name.blank?\n @author.name = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:name/text()\",\n \"atom03:name/text()\",\n \"atom:name/text()\",\n \"name/text()\",\n \"@name\"\n ], :select_result_value => true)\n )\n end\n if @author.email.blank?\n @author.email = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:email/text()\",\n \"atom03:email/text()\",\n \"atom:email/text()\",\n \"email/text()\",\n \"@email\"\n ], :select_result_value => true)\n )\n end\n if @author.url.blank?\n @author.url = FeedTools::HtmlHelper.unescape_entities(\n FeedTools::XmlHelper.try_xpaths(author_node, [\n \"atom10:url/text()\",\n \"atom03:url/text()\",\n \"atom:url/text()\",\n \"url/text()\",\n \"atom10:uri/text()\",\n \"atom03:uri/text()\",\n \"atom:uri/text()\",\n \"uri/text()\",\n \"@href\",\n \"@uri\",\n \"@href\"\n ], :select_result_value => true)\n )\n end\n if @author.name.blank? && !@author.raw.blank? &&\n !@author.email.blank?\n name_scan = @author.raw.scan(\n /\"?([^\"]*)\"? ?[\\(<].*#{@author.email}.*[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n if @author.name.blank?\n name_scan = @author.raw.scan(\n /.*#{@author.email} ?[\\(<]\"?([^\"]*)\"?[\\)>].*/)\n if name_scan.flatten.size == 1\n @author.name = name_scan.flatten[0].strip\n end\n end\n end\n @author.name = nil if @author.name.blank?\n @author.raw = nil if @author.raw.blank?\n @author.email = nil if @author.email.blank?\n @author.url = nil if @author.url.blank?\n if @author.url != nil\n begin\n if !(@author.url =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@author.url)\n @author.url = FeedTools::UriHelper.resolve_relative_uri(\n @author.url, [author_node.base_uri, self.base_uri])\n end\n rescue\n end\n end\n if FeedTools::XmlHelper.try_xpaths(author_node,\n [\"@gr:unknown-author\"], :select_result_value => true) == \"true\"\n if @author.name == \"(author unknown)\"\n @author.name = nil\n end\n end\n end\n # Fallback on the itunes module if we didn't find an author name\n begin\n @author.name = self.itunes_author if @author.name.nil?\n rescue\n @author.name = nil\n end\n end\n return @author\n end",
"def normalize_author_name(auth_toks)\n return '' if auth_toks.empty?\n str = auth_toks.join(\" \")\n if str =~ /(.+),\\s*(.+)/\n str = \"#{$1} #{$2}\"\n end\n str.gsub!(/\\.\\-/, '-')\n str.gsub!(/[\\,\\.]/, ' ')\n str.gsub!(/ +/, ' ')\n str.strip!\n\n if (str =~ /^[^\\s][^\\s]+(\\s+[^\\s]|\\s+[^\\s]\\-[^\\s])+$/)\n new_toks = str.split(/\\s+/)\n new_order = new_toks[1...new_toks.length];\n new_order << new_toks[0]\n str = new_order.join(\" \")\n end\n\n str.gsub!(/^[^A-Za-z0-9]+/, '')\n str.gsub!(/[^A-Za-z0-9]+$/, '')\n return str\n end",
"def author_tag(text); end",
"def nice_author(author)\n return nice_author(\"#{$2} #{$1}\") if author =~ /^(.+),\\s+(.+)$/\n return nice_author(\"#{$1} #{$2}\") if author =~ /^(.+)\\.(.+)$/\n return author.titleize\nend",
"def author_name\n if read_attribute('comment_body') =~ COMMENT_BODY_PARSER\n $1\n elsif created_by and created_by.sfcontact\n created_by.sfcontact.name\n end\n end",
"def check_author\n return unless self.is_author\n\n self.name = BLARG_CONFIG['admin']['name']\n self.email = BLARG_CONFIG['admin']['email']\n self.url = BLARG_CONFIG['blog']['url']\n self.is_human = BLARG_CONFIG['comments']['is_human_answer']\n end",
"def author\n @author ||= Readability::Document.new(@html).author\n end",
"def author_exuid\n author && author.to_param\n end",
"def normalize_author_name(auth_toks)\n return '' if auth_toks.empty?\n str = auth_toks.join(\" \")\n if str =~ /(.+),\\s*(.+)/\n str = \"#{$1} #{$2}\"\n end\n str.gsub!(/\\.\\-/, '-')\n str.gsub!(/[\\,\\.]/, ' ')\n str.gsub!(/ +/, ' ')\n str.strip!\n\n if (str =~ /^[^\\s][^\\s]+(\\s+[^\\s]|\\s+[^\\s]\\-[^\\s])+$/)\n new_toks = str.split(/\\s+/)\n new_order = new_toks[1...new_toks.length];\n new_order << new_toks[0]\n str = new_order.join(\" \")\n end\n return str\n end",
"def get_author\n a = cached_author_year.to_s.gsub(/,\\s\\(?\\d+\\)?\\s\\[\\d+\\]|,\\s\\(?\\d+\\)?/, '')\n a = a.gsub('(', '') if a.starts_with?('(') && !a.include?(')')\n return a\n end",
"def author_attributes=(author_name)\n if !author_name.empty?\n first_name = author_name.split(' ').first\n last_name = author_name.split(' ').last\n\n self.author = Author.find_or_create_by(first_name: first_name, last_name: last_name)\n end\n end",
"def author=(author)\n @author = author.to_s.strip\n end",
"def clean_up(curFed)\n clean_author(curFed)\n clean_title_pub(curFed)\n end",
"def author; end",
"def resolved_author; end",
"def squeeze_author(str)\n str.gsub(/([A-Z]\\.) (?=[A-Z]\\.)/, '\\\\1')\n end",
"def parse_author(author:)\n return nil if author.nil?\n\n parts = author.split('|')\n { author: parts.first, organization: parts.last }\n end",
"def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n traverse_element('link',\n '{http://www.w3.org/1999/xhtml}link') {|e|\n begin\n next unless e.fetch_attr('rev').downcase == 'made'\n author = e.fetch_attribute('title').strip\n return author if !author.empty?\n rescue IndexError\n end\n } \n\n if channel = find_element('{http://purl.org/rss/1.0/}channel')\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n\n nil\n end",
"def author_name\n if author\n author.full_name\n else\n 'No Author Found'\n end\n end",
"def normalize_author_identity(first_name, middle_name, last_name, institution)\n \"First: #{first_name} Middle: #{middle_name} Last: #{last_name} Institution: #{institution}\"\n end",
"def sanitize\n self.summary = sanitize_string(summary)\n self.description = sanitize_string(description)\n self.post_install_message = sanitize_string(post_install_message)\n self.authors = authors.collect {|a| sanitize_string(a) }\n end",
"def author_string\n auth = nil\n if authors.size > 0 # Build based on People \n case authors.size\n when 1\n auth = authors.first.last_name # self.author\n when 2 \n auth = authors.map(&:last_name).join(\" & \")\n when 3...100\n auth = authors[0..-1].map(&:last_name).join(\", \") + \" & \" + authors.last.last_name\n end\n else # Build based on string\n auth = self.author\n end\n auth\n end",
"def name_author_year(string)\n s = string.split\n name = s.shift\n notes = nil\n notes ||= s.pop if s[-1] == (\"Emend.\" || \"Syn.\" || \"Homo.\" || \"check\")\n year = nil\n year ||= s.pop if (s[-1] =~ /\\A\\d+\\Z/ && s[-1].length == 4)\n authors = nil\n authors = s.join(\" \") if s.size > 0\n [name, authors, year, notes]\n end",
"def format_autonym(name, author, _rank, deprecated)\n words = name.split\n if author.blank?\n format_name(name, deprecated)\n elsif words[-7] == words[-1]\n [\n format_name(words[0..-7].join(\" \"), deprecated),\n author,\n words[-6],\n format_name(words[-5], deprecated),\n words[-4],\n format_name(words[-3], deprecated),\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n elsif words[-5] == words[-1]\n [\n format_name(words[0..-5].join(\" \"), deprecated),\n author,\n words[-4],\n format_name(words[-3], deprecated),\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n elsif words[-3] == words[-1]\n [\n format_name(words[0..-3].join(\" \"), deprecated),\n author,\n words[-2],\n format_name(words[-1], deprecated)\n ].join(\" \")\n else\n format_name(name, deprecated) + \" \" + author\n end\n end",
"def author; @author; end",
"def author; @author; end",
"def author_name\n author.full_name if author\n end",
"def add_author(name)\n aux = name.split\n autor = Author.new(aux[1..-1].join(\" \"),aux[0][0].capitalize)\n @Author << autor \n end",
"def author_year\n au = author_year_string\n return nil if au.nil?\n (self.parens == true) ? \"(#{au})\" : au\n end",
"def author \n user.firstname + ' ' + user.lastname\n end",
"def author\n if not user.present? or (user.first_name.blank? and user.last_name.blank?)\n \"Anonymous\"\n else\n [user.try(:first_name), user.try(:last_name)].reject(&:blank?).join(' ')\n end\n end",
"def titleize_proper_names\n self.author = self.author.titleize\n self.editor = self.editor.titleize if self.editor\n self.buyed_from = self.buyed_from.titleize if self.buyed_from\n end",
"def author_to_marc(a)\n author = ''\n author << a.von + ' ' unless a.von.blank?\n author << a.last\n author << ' ' + a.suffix unless a.suffix.blank?\n author << ', ' + a.first\n author\n end",
"def author(version = Origen.app.version.prefixed)\n version = VersionString.new(version)\n version = version.prefixed if version.semantic?\n capture = false\n File.readlines(\"#{Origen.root}/doc/history\").each do |line|\n line = line.strip\n if capture\n if capture && line =~ /^#+ by (.*) on (.*(AM|PM))/\n user = Origen.fsl.find_by_name(Regexp.last_match(1))\n return user if user\n\n return Regexp.last_match(1)\n end\n else\n if line =~ /Tag:/\n line = line.gsub('\\\\', '')\n if line =~ /^#+ Tag: #{version}$/ ||\n line =~ />Tag: #{version}</\n capture = true\n end\n end\n end\n end\n nil\n end",
"def derive_authors_year\n add_author_year(author_year_string) \n end",
"def author\n @author ||= begin\n UnfuddleAPI::People.find(self[:author_id]).username\n rescue\n ''\n end\n end",
"def set_AuthorName(value)\n set_input(\"AuthorName\", value)\n end",
"def author\n [author_developer.name_and_email, author_date, author_date_gmt_offset]\n end",
"def author() headers['author'] end",
"def fix_autonym(name, author, rank)\n last_word = name.split.last.gsub(/[()]/, \"\")\n if (match = author.to_s.match(\n /^(.*?)(( (#{ANY_SUBG_ABBR}|#{ANY_SSP_ABBR}) #{last_word})+)$/\n ))\n name = \"#{name}#{match[2]}\"\n author = match[1].strip\n words = match[2].split\n while words.any?\n next_rank = parse_rank_abbreviation(words.shift)\n words.shift\n make_sure_ranks_ordered_right!(rank, next_rank)\n rank = next_rank\n end\n end\n [name, author, rank]\n end",
"def author\n \"#{user.firstname} #{user.lastname}\"\n end",
"def author_with_parens\n au = author_string\n return nil if au.nil?\n (self.parens == true) ? \"(#{au})\" : au\n end",
"def sanitize_content\n self.title = helpers.sanitize(self.title)\n self.user_name = helpers.sanitize(self.user_name)\n end",
"def citation_author\n surname = authors.first.last_name\n initials = authors.first.initials\n\n if authors.size > 1\n return \"#{surname} et al.\"\n else\n return \"#{surname}, #{initials}\"\n end\n end",
"def author?\n !author.nil? && !author.empty?\n end",
"def get_author_name_or_blank\n ret = \"\"\n ret += firstname unless firstname.blank?\n ret += \" \" unless firstname.blank? or name.blank?\n ret += name unless name.blank?\n ret\n end",
"def author\n\t\t@author\n\tend",
"def parse_userlevel_author(msg, remove: false)\n name, msg = parse_term(msg, quoted: ['author id'], remove: true)\n if !name.empty? && is_num(name)\n name = name.strip.to_i\n else\n name, msg = parse_string_or_id(msg, quoted: ['by', 'author'], final: ['by'], remove: true)\n name.strip! if name.is_a?(String)\n end\n remove ? [name, msg] : name\nrescue\n remove ? ['', msg] : ''\nend",
"def author\n @author\n end",
"def validate_the_author_of_the_post(post)\n if !is_the_author_of_the_post(post)\n puts \">>>>>> Validation failed: Un-author action is prohibited!\"\n redirect_to post_path\n end\n end",
"def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n traverse_element('link',\n '{http://www.w3.org/1999/xhtml}link') {|e|\n begin\n next unless e.fetch_attr('rev').downcase == 'made'\n author = e.fetch_attribute('title').strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n\n if channel = find_element('{http://purl.org/rss/1.0/}channel')\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n\n ['http://www.w3.org/2005/Atom', 'http://purl.org/atom/ns#'].each {|xmlns|\n each_child {|top|\n next unless top.elem?\n if top.name == \"{#{xmlns}}feed\"\n if feed_author = find_element(\"{#{xmlns}}author\")\n feed_author.traverse_element(\"{#{xmlns}}name\") {|e|\n begin\n author = e.extract_text.strip\n return author if !author.empty?\n rescue IndexError\n end\n }\n end\n end\n }\n }\n\n nil\n end",
"def formatAuthName(auth)\n str = \"\"\n fname, lname = auth.text_at(\"./fname\"), auth.text_at(\"./lname\")\n if lname && fname\n str = \"#{lname}, #{fname}\"\n mname, suffix = auth.text_at(\"./mname\"), auth.text_at(\"./suffix\")\n mname and str += \" #{mname}\"\n suffix and str += \", #{suffix}\"\n elsif fname\n str = fname\n elsif lname\n str = lname\n elsif auth.text_at(\"./email\") # special case\n str = auth.text_at(\"./email\")\n else\n str = auth.text.strip\n str.empty? and return nil # ignore all-empty author\n puts \"Warning: can't figure out author #{auth}\"\n end\n return str\nend",
"def author_year_string\n au = [author_string, self.year].compact.join(\", \")\n return nil if au.size == 0\n au\n end",
"def author_params\n params.require(:author).permit(:name, :surname, :email, :slug, :notes)\n end",
"def author\n @info[:Author]\n end",
"def parse_authors(author)\n authors = author.split(\", \")\n authors.each do |author|\n author.strip\n end\n return authors\n end",
"def extract_author(an_array)\n author_string_index = an_array.index{|s| s.start_with?(\"Author:\")}\n author_string = an_array[author_string_index]\n return author_string.gsub('Author:','').strip\nend",
"def extract_author(obj)\n author = {}\n if obj.is_a?(String)\n if obj.present?\n given_name, family_name = obj.split(' ', 2)\n author[:given_name] = given_name if given_name.present?\n author[:family_name] = family_name if family_name.present?\n end\n else\n name = obj['name'] || obj['@id'] || ''\n given_name, family_name = name.split(' ', 2)\n family_name = obj['familyName'] if obj['familyName'].present?\n given_name = obj['givenName'] if obj['givenName'].present?\n affiliation = obj['affiliation']\n if affiliation.present?\n if affiliation.is_a?(String)\n author[:affiliation] = affiliation\n else\n affiliation = affiliation.dereference if affiliation.respond_to?(:dereference)\n author[:affiliation] = affiliation['name'] if affiliation && affiliation['name'].present?\n end\n end\n orcid = obj['identifier'] || obj['@id']\n author[:orcid] = orcid if orcid.present? && orcid.include?('orcid.org')\n author[:given_name] = given_name if given_name.present?\n author[:family_name] = family_name if family_name.present?\n end\n\n author\n end",
"def author_hash; end",
"def author_params\n params.require(:author).permit(:name, :description, :slug)\n end",
"def validate\n if self.body.empty? || self.body =~ /^\\s+$/\n errors.add(:body, \"^Please enter your annotation\")\n end\n if !MySociety::Validate.uses_mixed_capitals(self.body)\n errors.add(:body, '^Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')\n end\n end",
"def author_params\n params.require(:author).permit(:Author_name)\n end",
"def get_author\n puts \"Search Author. Enter 4 letters\".red\n puts \">\".magenta.bold\n r = gets[0..3].chomp\n puts \"Searching... #{r}\".red\n i = 0\n @@book_class.each do | book |\n book.author.chomp\n x = book.author.chomp\n answer = /#{r}/i =~ x\n # puts answer\n if answer != nil\n # puts x\n puts \"Author: #{x}\"\n # pp \"id: #{book.book_id}, title #{book.title}\".chomp #, date due: #{book.due_date}\n end\n end\n i +1\n end",
"def set_author\n @author = Author.friendly.find(params[:author_name])\n end",
"def author\n @author ||= get_author\n end",
"def pretty_author(user, options = {})\n content_tag :span, :class => \"author vcard\" do\n content_tag :span, :class => \"fn\" do\n user.name rescue \"Admin\"\n end\n end\n end",
"def clean_isbn(isbn)\n\tclean_isbn = isbn.delete(\"-\").delete(\" \")\n\tif clean_isbn.length == 10 && clean_isbn.numeric?\n\t\tputs \"That's a nice, clean isbn.\"\n\t\t#pass to get Reviews\n\t\tget_Reviews(clean_isbn)\n\telse\n\t\tputs\n\t\tputs \"--------------------------\"\n\t\tputs \"Please validate your ISBN. Make sure it's 10 digits long and contains no letters or special characters:\"\n\t\tget_isbn\n\tend\nend",
"def author_check(revision,repo)\n `svnlook author -r #{revision} #{repo}`\n end",
"def get_author()\n @author\n end",
"def author_name\n \"#{author.first_name} #{author.last_name}\"\n end",
"def author_worthy?\n notes?\n end",
"def author_params\n params.require(:author).permit(:fq, :internet_id, :first_name, :last_name, :tenure_status, :scopus_author_id, :author_position, :hindex, :dept_id, :dept_name)\n end",
"def author_params\n params.require(:author).permit(:surname, :firstname, :birthdate, :sex, :title)\n end",
"def authors()\n authors_or_editors(@text[:author].to_names) if @text[:author]\n end",
"def author\n commenter.try(:name)\n end",
"def publisher\n if @publisher.nil?\n @publisher = FeedTools::Author.new\n @publisher.raw = FeedTools::HtmlHelper.unescape_entities( \n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"webMaster/text()\",\n \"dc:publisher/text()\"\n ], :select_result_value => true))\n\n unless @publisher.raw.blank?\n raw_scan = @publisher.raw.scan(\n /(.*)\\((\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\)/i)\n if raw_scan.nil? || raw_scan.size == 0\n raw_scan = @publisher.raw.scan(\n /(\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b)\\s*\\((.*)\\)/i)\n unless raw_scan.size == 0\n publisher_raw_pair = raw_scan.first.reverse\n end\n else\n publisher_raw_pair = raw_scan.first\n end\n if raw_scan.nil? || raw_scan.size == 0\n email_scan = @publisher.raw.scan(\n /\\b[A-Z0-9._%-\\+]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\\b/i)\n if email_scan != nil && email_scan.size > 0\n @publisher.email = email_scan.first.strip\n end\n end\n unless publisher_raw_pair.nil? || publisher_raw_pair.size == 0\n @publisher.name = publisher_raw_pair.first.strip\n @publisher.email = publisher_raw_pair.last.strip\n else\n unless @publisher.raw.include?(\"@\")\n # We can be reasonably sure we are looking at something\n # that the creator didn't intend to contain an email address if\n # it got through the preceeding regexes and it doesn't\n # contain the tell-tale '@' symbol.\n @publisher.name = @publisher.raw\n end\n end\n end\n\n @publisher.name = nil if @publisher.name.blank?\n @publisher.raw = nil if @publisher.raw.blank?\n @publisher.email = nil if @publisher.email.blank?\n @publisher.url = nil if @publisher.url.blank?\n if @publisher.url != nil\n begin\n if !(@publisher.url =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@publisher.url)\n channel_base_uri = nil\n unless self.channel_node.nil?\n channel_base_uri = self.channel_node.base_uri\n end\n @publisher.url = FeedTools::UriHelper.resolve_relative_uri(\n @publisher.url, [channel_base_uri, self.base_uri])\n end\n rescue\n end\n end \n end\n return @publisher\n end",
"def authorstring\n @authorstring ||= self.authors.collect { |a| a.last }.sort.to_sentence(:last_word_connector => ' и ')\n @authorstring\n end",
"def author_params\n params.require(:author).permit(:name, :poetry_header, :about_text, :friendly_header, :order_number,\n :author_id, :additional_info, :last_poem_placeholder, :need_placeholder,\n :title, :subtitle)\n end",
"def author value = nil\n return @author if value.nil?\n @author = value\n end",
"def test_authors\n auths = [\n \"Jepson, J.E.,Makarkin, V.N., & Jarzembowski, E.A.\", # 0\n \"Ren, D & Meng, X-m.\", # 1\n \"Ren, D and Meng, X-m.\", # 2\n \"Smith, J.H. and Jones, Y.K.\", # 3 \n \"Thomas jr. D.B.\", # 4\n \"Wighton, D.C., & Wilson, M.V.H.\", # 5\n \"Heyden, C.H.G. von & Heyden, L.F.J.D. von\", # 6 \n \"Zhang, B., et al.\", # 7\n \" Zhang, J.F. \", # 8\n \"Hong, Y-C.\", # 9 \n \"Yan, E.V.\", # 10\n \"Foo A, Bar ZA, Smith-Blorf A\", # 11\n \"Smith and Barnes\", # 12\n \"Smith & Barnes\", # 13 \n \"Smith\", # 14 \n \"Smith, Jones and Simon\", # 15\n \"Van Duzee\", # 16\n \"Walker, F.\", # 17\n \"Watson, T. F., D. Langston, D. Fullerton, R. Rakickas, B. Engroff, R. Rokey, and L. Bricker\", # 18\n \"Wheeler, A. G., Jr. and T. J. Henry.\", # 19\n \"Wheeler, A. G., Jr., B. R. Stinner, and T. J. Henry\", # 20\n \"Wilson, L. T. and A. P. Gutierrez\", # 21\n \"Torre-Bueno, J. R. de la\", # 22\n \"Vollenhoven, S. C. S.\", # 23\n \"Usinger, R. L. and P. D. Ashlock\", # 24\n \"van den Bosch, R. and K. Hagen\", # 25\n \"Slater, J. A. and J. E. O'Donnell\", # 26\n \"O'Donnell, J.E. and Slater, J. A.\", # 27\n \"Van Steenwyk, R. A., N. C. Toscano, G. R. Ballmer, K. Kido, and H. T. Reynolds\", # 28\n \"Ward, C. R., C. W. O'Brien, L. B. O'Brien, D. E. Foster, and E. W. Huddleston\", # 29\n \"McPherson, R. M., J. C. Smith, and W. A. Allen\", # 30\n \"Oatman, E. R., J. A. McMurty, H. H. Shorey, and V. Voth\", # 31\n \"Ferrari, E. von \", # 32\n \"Whitaker J. O., Jr., D. Rubin and J. R. Munsee\", # 33\n \"Palisot de Beauvois, A. M. F. J.\", # 34\n \"Maa, T.-C. and K.-S. Lin\", # 35\n \"Costa Lima, A. M. da, C. A. Campos Seabra, and C. R. Hathaway\", # 36\n \"Falcon, L. A., R. van den Bosch, C. A. Ferris, L. K. Stromberg, L. K. Etzel, R. E. Stinner, and T. F. Leigh\", # 37\n \"Kinzer, R. E., J. W. Davis, Jr., J. R. Coppedge, and S. L. Jones\", # 38\n \"Doesburg, P. H. van, Jr. \", # 39\n \"Arias J. R., Young D. G.\" # 40 \n ]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[40])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Arias', 'Young'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{J R}, %w{D G}] , t.names[0..1].collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[39])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Doesburg'], t.names.collect{|n| n[:last_name] }\n assert_equal \"van Jr.\", t.names[0][:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[38])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Kinzer', 'Davis', 'Coppedge', 'Jones'], t.names.collect{|n| n[:last_name] }\n assert_equal \"Jr.\", t.names[1][:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[37])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Falcon', 'van den Bosch', 'Ferris', 'Stromberg', 'Etzel', 'Stinner', 'Leigh'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{L A}, %w{R}, %w{C A}] , t.names[0..2].collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[36])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Costa Lima', 'Campos Seabra', 'Hathaway'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{A M}, %w{C A}, %w{C R}] , t.names.collect{|n| n[:initials] }\n assert_equal \"da\" , t.names.first[:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[35])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Maa', 'Lin'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{T -C}, %w{K -S}] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[32])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Ferrari'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{E}] , t.names.collect{|n| n[:initials] }\n assert_equal ['von'] , t.names.collect{|n| n[:suffix] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[31])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal ['Oatman', 'McMurty', 'Shorey', 'Voth'], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{E R}, %w{J A}, %w{H H}, %w{V}] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[30])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"McPherson\", \"Smith\", \"Allen\"], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{R M}, %w{J C}, %w{W A}] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[29])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Ward\", \"O'Brien\", \"O'Brien\", \"Foster\", \"Huddleston\" ], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{C R}, %w{C W}, %w{L B}, %w{D E}, %w{E W}] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[28])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Van Steenwyk\", \"Toscano\", \"Ballmer\", \"Kido\", \"Reynolds\" ], t.names.collect{|n| n[:last_name] }\n assert_equal [%w{R A}, %w{N C}, %w{G R}, %w{K}, %w{H T}] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[27])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"O'Donnell\", \"Slater\" ], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"J\", \"E\"],[\"J\", \"A\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[26])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Slater\", \"O'Donnell\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"J\", \"A\"],[\"J\", \"E\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[25])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"van den Bosch\", \"Hagen\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"R\"],[\"K\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[24])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Usinger\", \"Ashlock\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"R\", \"L\"],[\"P\", \"D\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[23])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Vollenhoven\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"S\", \"C\", \"S\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[22])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Torre-Bueno\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"J\", \"R\"]] , t.names.collect{|n| n[:initials] }\n assert_equal \"de la\", t.names.first[:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[21])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Wilson\", \"Gutierrez\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"L\", \"T\"], [\"A\", \"P\"]] , t.names.collect{|n| n[:initials] }\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[20])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Wheeler\", \"Stinner\", \"Henry\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"A\", \"G\"], [\"B\", \"R\"], [\"T\", \"J\"]] , t.names.collect{|n| n[:initials] }\n assert_equal \"Jr.\", t.names.first[:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[19])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Wheeler\", \"Henry\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"A\", \"G\"], [\"T\", \"J\"]] , [t.names.first[:initials], t.names.last[:initials]]\n assert_equal \"Jr.\", t.names.first[:suffix]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[18])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal [\"Watson\", \"Langston\", \"Fullerton\", \"Rakickas\", \"Engroff\", \"Rokey\", \"Bricker\"], t.names.collect{|n| n[:last_name] }\n assert_equal [[\"T\", \"F\"], [\"L\"]] , [t.names.first[:initials], t.names.last[:initials]]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[17])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 1, t.names.size\n assert_equal \"Walker\", t.names[0][:last_name]\n assert_equal [\"F\"], t.names[0][:initials]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[16])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 1, t.names.size\n assert_equal \"Van Duzee\", t.names[0][:last_name]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[15])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 3, t.names.size\n assert_equal \"Smith\", t.names[0][:last_name]\n assert_equal \"Jones\", t.names[1][:last_name]\n assert_equal \"Simon\", t.names[2][:last_name]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[14])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 1, t.names.size\n assert_equal \"Smith\", t.names[0][:last_name]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[13])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 2, t.names.size\n assert_equal \"Smith\", t.names[0][:last_name]\n assert_equal \"Barnes\", t.names[1][:last_name]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[12])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 2, t.names.size\n assert_equal \"Smith\", t.names[0][:last_name]\n assert_equal \"Barnes\", t.names[1][:last_name]\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[0])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 3, t.names.size\n assert_equal \"Jepson\", t.names[0][:last_name]\n assert_equal \"JE\", t.names[0][:initials].join\n assert_equal \"Jarzembowski\", t.names[2][:last_name]\n assert_equal \"EA\", t.names[2][:initials].join\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[1])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 2, t.names.size\n assert_equal \"Ren\", t.names[0][:last_name]\n assert_equal \"D\", t.names[0][:initials].join\n assert_equal \"Meng\", t.names[1][:last_name]\n assert_equal \"X-m\", t.names[1][:initials].join\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[9])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 1, t.names.size\n assert_equal \"Hong\", t.names[0][:last_name]\n assert_equal \"Y-C\", t.names[0][:initials].join\n\n lexer = Taxonifi::Splitter::Lexer.new(auths[11])\n assert t = lexer.pop(Taxonifi::Splitter::Tokens::Authors)\n assert_equal 3, t.names.size\n assert_equal \"Foo\", t.names[0][:last_name]\n assert_equal \"A\", t.names[0][:initials].join\n assert_equal \"Bar\", t.names[1][:last_name]\n assert_equal \"ZA\", t.names[1][:initials].join\n assert_equal \"Smith-Blorf\", t.names[2][:last_name]\n assert_equal \"A\", t.names[2][:initials].join\n end",
"def\n get_author()\n @author\n end",
"def author\n \"#{user.name} (#{user.login})\"\n end",
"def unpublished?\n /\\b(nom prov|comb prov|sensu lato|ined)\\b/i =~ author&.delete(\".\")\n end",
"def set_AuthorUsername(value)\n set_input(\"AuthorUsername\", value)\n end",
"def sanitize_bio(bio)\n permit_scrubber = Rails::Html::PermitScrubber.new\n permit_scrubber.tags = %w(h3 h4 p ul li ol strong em span sup sub)\n sanitize bio, tags: %w(h3 h4 p ul li ol strong em span sup sub), scrubber: permit_scrubber\n end",
"def meta_author\n \"Ahmed Nadar\"\n end",
"def highwire_author_format(name)\n if name.include? ','\n name.split(',').reverse.join(' ').strip\n else\n name\n end\n end",
"def cleanTitle(str)\n str.nil? and return str\n r = Sanitize.clean(str).strip\n str.empty? and return str\n r = (r[0].match(/[^\\w]/)) ? r[1..-1].strip : r\n r.sub(/^(The|A|An) /i, '').capitalize\nend",
"def call\n parsed_author_names.map do |name|\n AuthorName.where(name: name).find { |case_sensitive_name| case_sensitive_name.name == name } ||\n AuthorName.new(name: name, author: Author.new)\n end\n end",
"def author\n @author ||= AuthorDrop.new(:page => page, :site => site)\n end"
] | [
"0.67398804",
"0.6682663",
"0.65829086",
"0.6436085",
"0.6432133",
"0.6413618",
"0.6316629",
"0.6260948",
"0.62156755",
"0.612929",
"0.6127945",
"0.610913",
"0.610774",
"0.61058235",
"0.60904783",
"0.6090337",
"0.604314",
"0.60429925",
"0.60406935",
"0.59963185",
"0.59697384",
"0.59574395",
"0.5952729",
"0.59495705",
"0.59328854",
"0.59005255",
"0.58879155",
"0.58865595",
"0.58675957",
"0.5866103",
"0.58632344",
"0.58276474",
"0.5826656",
"0.5816121",
"0.58011484",
"0.5799508",
"0.5799508",
"0.5770377",
"0.57697207",
"0.57692224",
"0.57587767",
"0.57516617",
"0.5736268",
"0.57181144",
"0.57088155",
"0.56821907",
"0.5680179",
"0.5672921",
"0.56638813",
"0.56626964",
"0.5660564",
"0.56433976",
"0.56238633",
"0.5622436",
"0.5610547",
"0.56030715",
"0.56020844",
"0.5596367",
"0.5587762",
"0.5564678",
"0.5553383",
"0.55515915",
"0.55495095",
"0.5549465",
"0.5544002",
"0.55434567",
"0.5540198",
"0.55198866",
"0.55182695",
"0.55128425",
"0.55116457",
"0.5510576",
"0.5508718",
"0.5487094",
"0.5486261",
"0.54825234",
"0.5481883",
"0.54756755",
"0.5473156",
"0.54702735",
"0.5467198",
"0.54612994",
"0.546062",
"0.54593587",
"0.5456794",
"0.5453295",
"0.5452442",
"0.5451904",
"0.54514635",
"0.54380924",
"0.54372543",
"0.54256165",
"0.5402308",
"0.5401215",
"0.5401048",
"0.5395997",
"0.53954655",
"0.53954005",
"0.5394784",
"0.53926665",
"0.5378501"
] | 0.0 | -1 |
Validate input params Author: Aman Date: 30/05/2019 Reviewed By: | def validate_parameters
r = validate_payment_nonce_uuid
return r unless r.success?
error_identifiers = []
error_identifiers << 'invalid_first_name' if @first_name.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@first_name) || @first_name.length > 255)
error_identifiers << 'invalid_last_name' if @last_name.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@last_name) || @last_name.length > 255)
error_identifiers << 'invalid_company' if @company.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@company) || @company.length > 255)
error_identifiers << 'invalid_email' if @email.present? &&
(!Util::CommonValidateAndSanitize.is_valid_email?(@email))
error_identifiers << 'invalid_phone' if @phone.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@phone) || @phone.length > 255)
error_identifiers << 'invalid_fax' if @fax.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@fax) || @fax.length > 255)
error_identifiers << 'invalid_website' if @website.present? &&
(!Util::CommonValidateAndSanitize.is_valid_domain?(@website) || @website.length > 255)
return error_with_identifier('invalid_api_params',
'ra_c_c_vp_1',
error_identifiers
) if error_identifiers.present?
@customer_details[:first_name] = @first_name if @first_name.present?
@customer_details[:last_name] = @last_name if @last_name.present?
@customer_details[:company] = @company if @company.present?
@customer_details[:email] = @email if @email.present?
@customer_details[:phone] = @phone if @phone.present?
@customer_details[:fax] = @fax if @fax.present?
@customer_details[:website] = @website if @website.present?
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_params?; end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def check_params; true; end",
"def validate_params(hash)\n hash.include?('title') and hash.include?('body') and hash.include?('category')\n end",
"def validate_review_completed_parameters(params)\n raise MissingTransactionId if params[\"id\"].to_s.length == 0\n raise InvalidTransactionId if !validate_transaction_id(params[\"id\"])\n\n raise MissingAnalystId if params[\"analyst_id\"].to_s.length == 0\n raise InvalidAnalystId if !validate_analyst_id(params[\"analyst_id\"])\n raise MissingAnalystFullname if params[\"analyst_fullname\"].to_s.length == 0\n raise InvalidAnalystFullname if !validate_analyst_fullname(params[\"analyst_fullname\"])\n\n raise MissingAnalystApprovalDate if params[\"analyst_approval_datetime\"].to_s.length == 0\n raise InvalidAnalystApprovalDate if !validate_date(params[\"analyst_approval_datetime\"])\n raise MissingAnalystTransactionId if params[\"analyst_transaction_id\"].to_s.length == 0\n raise MissingAnalystInternalStatusId if params[\"analyst_internal_status_id\"].to_s.length == 0\n raise MissingAnalystDecisionCode if params[\"decision_code\"].to_s.length == 0\n raise InvalidAnalystDecisionCode if !validate_decision_code(params[\"decision_code\"])\n return params\n end",
"def valid?(params)\n true\n end",
"def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end",
"def validate_params\n puts\n puts \"You're about to import data in your '#{Rails.env}' instance.\"\n puts \"You'll use the following source files:\"\n puts \" users: #{options['users'] || '-'} \"\n puts \" projects: #{options['projects'] || '-'}\"\n puts \" issues: #{options['issues'] || '-'}\"\n puts\n puts \"/!\\\\ Make sure to have a backup of your database before continuing.\"\n puts\n print 'Is this ok ? [y/n]: '\n STDOUT.flush\n ok = STDIN.gets.chomp!\n exit 2 if ok != 'y'\n puts\n end",
"def valid_params_request?; end",
"def validate_question params\n\n end",
"def validate_review_completed_parameters(params)\n raise MissingTransactionId if params[\"id\"].to_s.length == 0\n raise InvalidTransactionId if !validate_transaction_id(params[\"id\"])\n\n raise MissingAnalystId if params[\"analyst_id\"].to_s.length == 0\n raise InvalidAnalystId if !validate_analyst_id(params[\"analyst_id\"])\n raise MissingAnalystFullname if params[\"analyst_fullname\"].to_s.length == 0\n raise InvalidAnalystFullname if !validate_analyst_fullname(params[\"analyst_fullname\"])\n\n raise MissingAnalystApprovalDate if params[\"analyst_approval_datetime\"].to_s.length == 0\n raise InvalidAnalystApprovalDate if !validate_date(params[\"analyst_approval_datetime\"])\n raise MissingAnalystTransactionId if params[\"analyst_transaction_id\"].to_s.length == 0\n raise MissingAnalystInternalStatusId if params[\"analyst_internal_status_id\"].to_s.length == 0\n raise MissingAnalystDecisionCode if params[\"decision_code\"].to_s.length == 0\n raise InvalidAnalystDecisionCode if !validate_decision_code(params[\"decision_code\"])\n return params\n end",
"def validate params\n validate_params(params)\n validate_coordinates\n validate_color\n validate_dimension\n end",
"def validate_create_params!(params); end",
"def validate_parameters\n check_for_valid_filepath if (@repository.parameters[:file])\n\n check_number_of_parameters(:coord, 2)\n check_number_of_parameters(:delta, 2)\n check_number_of_parameters(:time, 2)\n check_number_of_parameters(:range, 2)\n check_number_of_parameters(:section, 2)\n end",
"def valid?\n @errors << :title if !@title.is_a?(String) || @title.empty?\n @errors << :author if !@author.is_a?(String) || @author.empty?\n @errors << :release_date unless @release_date.is_a?(Date)\n @errors << :publisher if !@publisher.is_a?(String) || @publisher.empty?\n @errors << :isbn unless @isbn.is_a?(Integer) && @isbn < 10**10 && @isbn >= 10**9\n \n @errors.empty?\n end",
"def validate_params_present!\n raise ArgumentError, \"Please provide one or more of: #{ACCEPTED_PARAMS}\" if params.blank?\n end",
"def validate_params\n assert_provided env, 'Missing \"env\"'\n assert_provided action, 'Missing \"action\"'\n\n case action\n when 'import'\n assert_provided path, 'Missing \"path\"'\n\n when 'export'\n assert_provided path, 'Missing \"path\"'\n\n when 'read'\n assert_provided name, 'Missing \"name\"'\n\n when 'rename'\n assert_provided name, 'Missing \"name\"'\n assert_provided to, 'Missing \"to\"'\n\n end\n\n assert_env_is_configured env\n end",
"def validate_params?\n true # TODO: add validation\n end",
"def validate_paramters\n raise Scorekeeper::MissingParameterException if @income.nil? || @zipcode.nil? || @age.nil?\n end",
"def validations\n valid_page_number? if page_number\n valid_period_name? if period_param\n valid_date? if date_param\n end",
"def validate_parameter(*param)\n param.each do |a|\n return false unless a && (a.to_s =~ /^\\{.*\\}$/) == nil && a != '' && a != {}\n end\n end",
"def validate(ctx, params:, **)\n is_valid =\n params.is_a?(Hash) &&\n params[\"info\"].is_a?(Hash) &&\n params[\"info\"][\"email\"]\n \n is_valid # return value matters!\n end",
"def check_title_and_description(params)\n if params[:title] == nil\n @errors << \"Title can't be empty\"\n end\n if params[:description] == nil\n @errors << \"You need to add description\"\n elsif params[:description].length < 20\n @errors << \"description can't be less than 20 characters\"\n end\nend",
"def valid # rubocop:disable Metrics/AbcSize\n errors = []\n warnings = []\n\n %w{name version}.each do |field|\n next unless params[field.to_sym].nil?\n\n errors.push(\"Missing profile #{field} in #{ref}\")\n end\n\n if %r{[\\/\\\\]} =~ params[:name]\n errors.push(\"The profile name (#{params[:name]}) contains a slash\" \\\n \" which is not permitted. Please remove all slashes from `inspec.yml`.\")\n end\n\n # if version is set, ensure it is correct\n if !params[:version].nil? && !valid_version?(params[:version])\n errors.push(\"Version needs to be in SemVer format\")\n end\n\n %w{title summary maintainer copyright license}.each do |field|\n next unless params[field.to_sym].nil?\n\n warnings.push(\"Missing profile #{field} in #{ref}\")\n end\n\n # if license is set, ensure it is in SPDX format or marked as proprietary\n if !params[:license].nil? && !valid_license?(params[:license])\n warnings.push(\"License '#{params[:license]}' needs to be in SPDX format or marked as 'Proprietary'. See https://spdx.org/licenses/.\")\n end\n\n [errors, warnings]\n end",
"def validate\n \n \n end",
"def validate params\n validate_params(params)\n validate_dimension\n end",
"def check_params\n true\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 validate\n if self.body.empty? || self.body =~ /^\\s+$/\n errors.add(:body, \"^Please enter your annotation\")\n end\n if !MySociety::Validate.uses_mixed_capitals(self.body)\n errors.add(:body, '^Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')\n end\n end",
"def valid?()\n if( requiredFieldsPresent? )\n # check each condition, saving off error if one exists (ugh...)\n @errors << \"byr is not valid #{@args[\"byr\"]}\" if !byrValid?(@args[\"byr\"])\n @errors << \"iyr is not valid #{@args[\"iyr\"]}\" if !iyrValid?(@args[\"iyr\"])\n @errors << \"eyr is not valid #{@args[\"eyr\"]}\" if !eyrValid?(@args[\"eyr\"])\n @errors << \"hgt is not valid #{@args[\"hgt\"]}\" if !hgtValid?(@args[\"hgt\"])\n @errors << \"hcl is not valid #{@args[\"hcl\"]}\" if !hclValid?(@args[\"hcl\"])\n @errors << \"ecl is not valid #{@args[\"ecl\"]}\" if !eclValid?(@args[\"ecl\"])\n @errors << \"pid is not valid #{@args[\"pid\"]}\" if !pidValid?(@args[\"pid\"])\n end\n @errors.empty?\n end",
"def verify_parameters\n # TODO: rails 3 and activemodel validation\n parts = (params[:mask].to_s.split('@', 2) + [params[:nick], params[:url]])\n if parts.length != 4 || params.any?(&:blank?)\n render :text => \"Invalid submission\", :status => 400\n return false\n end\n end",
"def valid?\n return false unless (valid_string? @title) &&\n (valid_string? @author) &&\n (valid_date? @release_date) &&\n (valid_string? @publisher) &&\n (valid_integer? @isbn)\n true\n end",
"def validate(ctx, params:, **)\n is_valid =\n params.is_a?(Hash) &&\n params[\"info\"].is_a?(Hash) &&\n params[\"info\"][\"email\"]\n\n is_valid # return value matters!\n end",
"def prepare(params)\n check_like_value(:keywords, params)\n check_array_value(:subjects, params)\n check_array_value(:media_types, params)\n check_array_value(:durations, params)\n check_single_value(:account_id, params)\n check_numeric_value(:per_page, params, 20)\n check_numeric_value(:page, params, 1)\n check_single_value(:workflow_state, params, \"active\")\n end",
"def validate\r\n\r\n end",
"def validate_args (args)\n\t# todo\nend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid_add_entry_req\n if !params[:add_entry_req].nil?\n add_er_vals = params[:add_entry_req].values\n add_er_vals.each_slice(3) do |incoming_qual, grade, info|\n if (!incoming_qual.empty? && grade.empty?) ||\n (incoming_qual.empty? && (!grade.empty? || !info.empty?))\n return false\n end\n end\n end\n return true\n end",
"def param_is_valid?\n robot_facings = @robot.class.const_get(:AVAIABLE_FACING).map(&:to_s)\n\n !(@args =~ /^\\d+,\\d+,(#{robot_facings.join('|').upcase})+$/).nil?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate_param(param)\n\t\t\terror = {}\n\t\t\tif param.form_structure_id == nil\n\t\t\t\terror[:formName] = \"Please specify\"\n\t\t\t\treturn error\n\t\t\tend\n\t\t\tform = FormStructure.find(param.form_structure_id)\n\t\t\tif form.nil?\n\t\t\t\terror[:formName] = \"Please specify\"\n\t\t\t\treturn error\n\t\t\tend\n\t\t\tif param.is_many_to_one_count\n\t\t\t\tvalidate_many_to_one_count(form, error, param)\n\t\t\telsif param.is_many_to_one_instance\n\t\t\t\tvalidate_many_to_one_instance(form, error, param)\n\t\t\telse\n\t\t\t\tvalidate_normal_question(error, param)\n\t\t\tend\n\n\t\tend",
"def validate\n end",
"def validate(args = {})\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid_for_params_auth?; end",
"def valid?(params)\n # Make sure the website is a passed in param.\n unless params['website'] && given?(params['website'])\n return false\n end\n\n # Make sure the width is a passed in param.\n unless params['width'] && given?(params['width'])\n return false\n end\n\n # Make sure the height is a passed in param.\n unless params['height'] && given?(params['height'])\n return false\n end\n\n true\nend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def read_and_validate_params\n if @name_args.length < 1\n show_usage\n exit 1\n end\n\n if config[:hostname].nil? ||\n config[:username].nil? ||\n config[:flavor].nil? ||\n config[:password].nil? ||\n config[:main_network_adapter].nil?\n show_usage\n exit 1\n end\n\n if config[:guest_dhcp].eql? false\n if config[:guest_ip].nil? ||\n config[:guest_gateway].nil? ||\n config[:guest_netmask].nil? ||\n config[:guest_nameserver].nil?\n ui.fatal \"When using a static IP, you must specify the IP, Gateway, Netmask, and Nameserver\"\n exit 1\n end\n end\n\n end",
"def validate(entry)\n\tputs \"----------\"\n\tputs entry\n\treturn false if not validate_year(entry[\"byr\"], \"byr\", 1920, 2002)\n\treturn false if not validate_year(entry[\"iyr\"], \"iyr\", 2010, 2020)\n\treturn false if not validate_year(entry[\"eyr\"], \"eyr\", 2020, 2030)\n\treturn false if not validate_hgt(entry[\"hgt\"])\n\treturn false if not validate_color(entry[\"hcl\"])\n\treturn false if not validate_ecl(entry[\"ecl\"])\n\treturn false if not validate_pid(entry[\"pid\"])\n\tputs \"valid\"\n\treturn true\nend",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate_params(params)\n errors = []\n errors << if params.key?('asking_price') && params.key?('down_payment')\n validate(asking_price: params['asking_price'], down_payment: params['down_payment']) do |val_errors|\n val_errors << validate_minimum_down_payment(params['asking_price'], params['down_payment'])\n end\n end\n\n errors << if params.key?('payment_schedule')\n validate(payment_schedule: params['payment_schedule']) do |val_errors|\n val_errors << validate_payment_schedule_types(params['payment_schedule'])\n end\n end\n\n errors << if params.key?('amortization_period')\n validate(amortization_period: params['amortization_period']) do |val_errors|\n val_errors << validate_amortization_period(params['amortization_period'])\n end\n end\n\n errors << if params.key?('payment_amount')\n validate(payment_amount: params['payment_amount'])\n end\n\n errors << if params.key?('interest_rate')\n validate(interest_rate: params['interest_rate'])\n end\n\n errors = errors.flatten.compact\n errors.blank? ? [] : \"Validation failed: #{errors.join(', ')}\"\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def check_params(params)\n\n\t\tself.assign_attributes(params)\n\t\tself.check\n\t\treturn false unless @valid\n\t\treturn self\n\tend",
"def validateParams \r\n\t \r\n\t \tif !@data.nil? && !@key.nil? && !@cipher.nil?\r\n\t\t\treturn true\r\n\t \telse\r\n\t\t\treturn false \t\r\n\t \tend\r\n\t \t\r\n\t end",
"def oAuthValidate\r\n logger.info(\"UserController::oAuthValidate::Params:----#{params}\")\r\n \r\n end",
"def validated?; end",
"def validate\n raise ArgumentError, \"Params emtpy\" if @params.nil? \n @errors = []\n @errors << 'reason must be provided' if @params.reason.nil? \n @errors << 'txn_id must be provided' if @params.txn_id.nil? \n @errors << 'order.id must be provided' if @params.order.id.nil? \n @errors << 'order.total must be provided' if @params.order.total.nil? \n @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? \n @errors << 'order.tax must be provided' if @params.order.tax.nil? \n\n raise ZipMoney::RequestError.new(\"Following error(s) occurred while making request, please resolve them to make the request: #{@errors}\") if @errors.any?\n end",
"def valid_parionsdirect_account_params?\n status = true\n if @pseudo.blank? || @firstname.blank? || @lastname.blank? || @email.blank? || @password.blank? || @password_confirmation.blank? || @birthdate.blank?\n status = false\n end\n\n return status\n end",
"def validation; end",
"def validation; end",
"def validate(params)\n Request.new(params).validate(params)\n end",
"def valid_edit_entry_reqs\n if !params[:edit_entry_req].nil?\n edit_reqs_vals = params[:edit_entry_req].values\n edit_reqs_vals.each_slice(3) do |grade, info, remove|\n if grade.empty?\n return false\n end\n end\n end\n return true\n end",
"def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend",
"def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend",
"def validate_params\n assert_provided env, 'Missing \"env\"'\n assert_provided action, 'Missing \"action\"'\n\n case action\n when 'import'\n assert_provided path, 'Missing \"path\"'\n\n when 'export'\n assert_provided path, 'Missing \"path\"'\n\n end\n\n assert_env_is_configured env\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n missing_parameters = []\n required_fields.each do |param|\n missing_parameters << param.to_s unless self.send(param)\n end\n raise RTurk::MissingParameters, \"Parameters: '#{missing_parameters.join(', ')}'\" unless missing_parameters.empty?\n end",
"def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end",
"def valid_params_request?\n true\n end",
"def valid_params_request?\n true\n end",
"def links_valid_params(params)\n if params[:link_name].strip == \"\" || params[:link_description].strip == \"\" || params[:category_name].strip == \"\"\n false\n else\n true\n end\n end",
"def validate_order params\n return false unless params[:email].present? && params[:email] =~ /[^@]+@[^@]+/\n # cheapo regex for email, not really trying to filter, just catch typos: missing or too many @s.\n return false if params[:tel].present? && params[:tel].gsub(/\\D/,'').length < 7\n # a lot of spam bots post phone numbers as random series of letters. this is a cheap way of\n # catching that without having to print a captcha or ask a question.\n return true\n end",
"def validate\n validates_presence([:title, :body])\n end",
"def validate_params\n if process_object && process_object[\"required_params\"]\n process_object[\"required_params\"].each do |param|\n if !params_hash.has_key?(param)\n errors.add(:params, \"Step: #{step} - Missing mandatory param #{param}\")\n end\n end\n end\n end",
"def is_valid(params)\n i = 0\n while params.length > i\n p params[i]\n if params[i] == nil || params[i] == \"\"\n session[:error] = \"Du missade en parameter! Försök igen.\"\n redirect('/error')\n end\n i += 1\n end\n end",
"def valid?\n return false if !@id.nil? && @id.to_s.length < 1\n return false if !@updated_date.nil? && @updated_date.to_s.length < 1\n return false if !@issued_date.nil? && @issued_date.to_s.length < 1\n true\n end",
"def validate_args(course, yoe_text)\n unless Config.read(\"courses\").has_key?(course)\n raise ArgumentError, %Q{Invalid course name \"#{course}\"}\n end\n\n yoe = yoe_text.to_i\n unless valid_years.include?(yoe)\n raise ArgumentError, %Q{Invalid year of entry \"#{yoe_text}\"}\n end\n end",
"def valid_input?\n @spec = Spec.new\n # Spec validation (with @spec.valid?) will catch invalid zip codes\n zip_code = params[:zip_code]\n @spec.zip_code = zip_code\n # There are a good number of zip codes for which there is no information\n location = GeoDatum.find_by_zip_code(zip_code)\n if @spec.valid? and not zip_code.blank? and location.nil?\n @spec.errors.add(:zip_code, \"does not exist in our database\")\n end\n # The age string should convert to valid integers\n unless params[:min_age].valid_int? and params[:max_age].valid_int?\n @spec.errors.add_to_base(\"Age range is invalid\")\n end\n # The zip code is necessary if miles is provided and vice versa\n miles = params[:miles]\n if (!miles.blank? and zip_code.blank?) || (!zip_code.blank? and miles.blank?)\n @spec.errors.add_to_base(\"zip code and miles have to be specified together\")\n end\n \n # Check for invalid location radius if present\n @spec.errors.add_to_base(\"Location radius is invalid\") if !miles.blank? && !miles.valid_float?\n \n \n # The input is valid iff the errors object is empty\n @spec.errors.empty?\n end",
"def validate\n REQUIRED_PARAMS.each do |param|\n raise RequiredParameterError, \"Overlay GithubRepo missing required paramater: #{param}\" if (send(param).nil? || send(param).empty?)\n end\n\n # If we are using a publisher, check required publisher params\n if @use_publisher\n REQUIRED_PUBLISHER_PARAMS.each do |param|\n raise RequiredParameterError, \"Overlay GithubRepo missing required paramater: #{param}\" if (send(param).nil?)\n end\n end\n end",
"def validated; end",
"def validate_params(params, url)\n missing = []\n params.keys.each do |p|\n if @required_config[get_current_url] and @required_config[get_current_url].keys.include? p\n if params[p] == \"\"\n missing << @required_config[get_current_url][p]\n end\n end\n end\n if missing.any?\n raise \"Parameters #{missing.inspect} must be set to non empty value while posting to #{url}. Please provide.\"\n end\n end",
"def check_updated_params(params)\n p params\n self.assign_attributes(params)\n p self\n @new_appt = false\n\n if self.check_future && self.check_overlap\n @valid = true\n else\n @valid = false\n end\n @valid\n p @valid\n end",
"def valid?(params = {})\n params.each_value do |arr|\n arr.each do |key, value|\n # hasOtherName always will be correct\n next if key == 'hasOtherName'\n # If the array is empty or the data that has is invalid return false\n # return false if the array is empty\n return false if value.class == Array && value.empty?\n # return false if the information is not correct\n return false if value.class == Array && invalid_interactions?(value)\n next if value.class == Array\n # If the string is empty data not valid\n return false if value == ''\n end\n end\n true\n end",
"def validate_params\n if !@to.nil? && !@to.is_numeric?\n add_error(code: 400, error: 'The parameter to, be must a number')\n elsif (@from.is_a? String) && !@from.is_numeric?\n add_error(code: 400, error: 'The parameter from, be must a number')\n end\n end",
"def validate_transaction_creation_parameters(params, whitelist)\n\n # delets all non-whitelisted params, and returns a safe list.\n params = trim_whitelisted(params, whitelist)\n\n # Return proper errors if parameter is missing:\n raise MissingEmail if params[\"email\"].to_s.length == 0\n # raise MissingSSN if params[\"ssn\"].to_s.length == 0\n raise MissingPassportOrSSN if (params[\"ssn\"].to_s.length == 0 and\n params[\"passport\"].to_s.length == 0)\n raise MissingLicenseNumber if (params[\"license_number\"].to_s.length == 0 and\n params[\"passport\"].to_s.length == 0)\n raise MissingFirstName if params[\"first_name\"].to_s.length == 0\n raise MissingLastName if params[\"last_name\"].to_s.length == 0\n raise MissingResidency if params[\"residency\"].to_s.length == 0\n raise MissingBirthDate if params[\"birth_date\"].to_s.length == 0\n raise MissingClientIP if params[\"IP\"].to_s.length == 0\n raise MissingReason if params[\"reason\"].to_s.length == 0\n raise MissingLanguage if params[\"language\"].to_s.length == 0\n\n # Validate the Email\n raise InvalidEmail if !validate_email(params[\"email\"])\n\n # User must provide either passport or SSN. Let's check if\n # one or the other is invalid.\n\n # Validate the SSN\n # we eliminate any potential dashes in ssn\n params[\"ssn\"] = params[\"ssn\"].to_s.gsub(\"-\", \"\").strip\n # raise InvalidSSN if !validate_ssn(params[\"ssn\"])\n raise InvalidSSN if params[\"ssn\"].to_s.length > 0 and\n !validate_ssn(params[\"ssn\"])\n # Validate the Passport\n # we eliminate any potential dashes in the passport before validation\n params[\"passport\"] = params[\"passport\"].to_s.gsub(\"-\", \"\").strip\n raise InvalidPassport if params[\"passport\"].to_s.length > 0 and\n !validate_passport(params[\"passport\"])\n\n # Validate the DTOP id:\n raise InvalidLicenseNumber if !validate_dtop_id(params[\"license_number\"]) and\n params[\"passport\"].to_s.length == 0\n\n raise InvalidFirstName if !validate_name(params[\"first_name\"])\n raise InvalidMiddleName if !params[\"middle_name\"].nil? and\n !validate_name(params[\"middle_name\"])\n raise InvalidLastName if !validate_name(params[\"last_name\"])\n raise InvalidMotherLastName if !params[\"mother_last_name\"].nil? and\n !validate_name(params[\"mother_last_name\"])\n\n raise InvalidResidency if !validate_residency(params[\"residency\"])\n\n # This validates birthdate\n raise InvalidBirthDate if !validate_birthdate(params[\"birth_date\"])\n # This checks minimum age\n raise InvalidBirthDate if !validate_birthdate(params[\"birth_date\"], true)\n raise InvalidClientIP if !validate_ip(params[\"IP\"])\n raise InvalidReason if params[\"reason\"].to_s.strip.length > 255\n raise InvalidLanguage if !validate_language(params[\"language\"])\n\n return params\n end",
"def validate_transaction_creation_parameters(params, whitelist)\n\n # delets all non-whitelisted params, and returns a safe list.\n params = trim_whitelisted(params, whitelist)\n\n # Return proper errors if parameter is missing:\n raise MissingEmail if params[\"email\"].to_s.length == 0\n # raise MissingSSN if params[\"ssn\"].to_s.length == 0\n raise MissingPassportOrSSN if (params[\"ssn\"].to_s.length == 0 and\n params[\"passport\"].to_s.length == 0)\n raise MissingLicenseNumber if (params[\"license_number\"].to_s.length == 0 and\n params[\"passport\"].to_s.length == 0)\n raise MissingFirstName if params[\"first_name\"].to_s.length == 0\n raise MissingLastName if params[\"last_name\"].to_s.length == 0\n raise MissingResidency if params[\"residency\"].to_s.length == 0\n raise MissingBirthDate if params[\"birth_date\"].to_s.length == 0\n raise MissingClientIP if params[\"IP\"].to_s.length == 0\n raise MissingReason if params[\"reason\"].to_s.length == 0\n raise MissingLanguage if params[\"language\"].to_s.length == 0\n\n # Validate the Email\n raise InvalidEmail if !validate_email(params[\"email\"])\n\n # User must provide either passport or SSN. Let's check if\n # one or the other is invalid.\n\n # Validate the SSN\n # we eliminate any potential dashes in ssn\n params[\"ssn\"] = params[\"ssn\"].to_s.gsub(\"-\", \"\").strip\n # raise InvalidSSN if !validate_ssn(params[\"ssn\"])\n raise InvalidSSN if params[\"ssn\"].to_s.length > 0 and\n !validate_ssn(params[\"ssn\"])\n # Validate the Passport\n # we eliminate any potential dashes in the passport before validation\n params[\"passport\"] = params[\"passport\"].to_s.gsub(\"-\", \"\").strip\n raise InvalidPassport if params[\"passport\"].to_s.length > 0 and\n !validate_passport(params[\"passport\"])\n\n # Validate the DTOP id:\n raise InvalidLicenseNumber if !validate_dtop_id(params[\"license_number\"]) and\n params[\"passport\"].to_s.length == 0\n\n raise InvalidFirstName if !validate_name(params[\"first_name\"])\n raise InvalidMiddleName if !params[\"middle_name\"].nil? and\n !validate_name(params[\"middle_name\"])\n raise InvalidLastName if !validate_name(params[\"last_name\"])\n raise InvalidMotherLastName if !params[\"mother_last_name\"].nil? and\n !validate_name(params[\"mother_last_name\"])\n\n raise InvalidResidency if !validate_residency(params[\"residency\"])\n\n # This validates birthdate\n raise InvalidBirthDate if !validate_birthdate(params[\"birth_date\"])\n # This checks minimum age\n raise InvalidBirthDate if !validate_birthdate(params[\"birth_date\"], true)\n raise InvalidClientIP if !validate_ip(params[\"IP\"])\n raise InvalidReason if params[\"reason\"].to_s.strip.length > 255\n raise InvalidLanguage if !validate_language(params[\"language\"])\n\n return params\n end",
"def validate_required\n [\n :project_name,\n :status,\n :requester_id,\n :subject_expert_id,\n :sponsor_id,\n :vision,\n :goal,\n :description,\n :scope,\n :advice_required,\n :program_id,\n :train_id,\n :funding_method,\n :cost_center,\n :funding_status,\n :budget_allocated,\n :priority,\n :start_date,\n :end_date,\n :risk_rating,\n :risks,\n :projected_revenue,\n ].each do |field|\n if self.attributes[field.to_s].nil? || self.attributes[field.to_s].blank?\n # intentionally vague!\n add_validation 'All fields are required to perform further validations'\n return false\n end\n end\n true\n end",
"def valid_vote\n\t\tif ( vote_params[:rating].present? && \n\t\t\t\t vote_params[:length].present? && \n\t\t\t\t vote_params[:difficulty].present? )\n\t\t\tif ( vote_params[:rating].to_i.between?(1, 10) && \n\t\t\t\t\t LENGTH.include?( vote_params[:length].to_i ) && \n\t\t\t\t\t vote_params[:difficulty].to_i.between?(1, MAX_DIFFICULTY) )\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\tflash[:danger] = \"One or more invalid vote parameters.\"\n\t\t\t\tredirect_to problem_path(current_problem)\n\t\t\tend\t\n\t\telse\n\t\t\tflash[:danger] = \"You need to include all three parameters in your vote.\"\n\t\t\tredirect_to problem_path(current_problem)\n\t\tend\n end",
"def assert_valid\n raise ValidationError, \"no name\" unless name\n raise ValidationError, \"no version\" unless version\n raise ValidationError, \"no summary\" unless summary\n #raise ValidationError, \"no maintainer\" unless maintainer\n #raise ValidationError, \"no homepage\" unless homepage\n end",
"def params_valid?\n \n #if the user isn't signed in or there aren't any parameters, the params \n #aren't valid\n if !user_signed_in? || !params_present? \n return false\n end\n \n #Check whether a submission for the given language exists and whether it\n #belongs to the current user.\n submission = Submission.where(id: params[:submission_id], language_id: params[:language_id])\n \n submission.present? && current_user.id == submission.first.user_id\n end",
"def validate_params!(env_vars, extra_vars, playbook_path, roles_path)\n assert_hash!(env_vars)\n assert_hash!(extra_vars)\n assert_path!(playbook_path)\n assert_path!(roles_path)\n end",
"def validate?(params)\n _validate?(params)\n end",
"def mods_assets_update_validation\n i = 0\n desc_metadata = params[:asset][:descMetadata]\n unless desc_metadata.nil?\n while desc_metadata.has_key? \"person_#{i}_computing_id\".to_sym\n if desc_metadata[\"person_#{i}_first_name\".to_sym][\"0\"].blank? or desc_metadata[\"person_#{i}_last_name\".to_sym][\"0\"].blank?\n flash[:error] = \"The First and Last names are required for all authors.\"\n return false\n end\n i += 1\n end\n end\n return true\n end",
"def validation_submission(params)\n\n possible_errors = Array.new\n\n aa_seq_array = is_sequence_empty(params[:aa_sequence], params[:aa_fasta])\n puts \"aa_seq_array => #{aa_seq_array}\"\n # if user submit more than 20 sequence at time, return error immediately\n if !aa_seq_array.nil? and aa_seq_array.length > 20\n possible_errors << \"You submitted more than 20 amino acid sequences. While, we only accept 20 amino acid sequences or less per submission.\"\n return possible_errors\n end\n\n nt_seq_array = is_sequence_empty(params[:nt_sequence], params[:nt_fasta])\n puts \"nt_seq_array => #{nt_seq_array}\"\n if !nt_seq_array.nil? and nt_seq_array.length > 20\n possible_errors << \"You submitted more than 20 nucleotide sequences. While, we only accept 20 nucleotide sequences or less per submission.\"\n return possible_errors\n end\n\n\n if aa_seq_array.nil? or nt_seq_array.nil?\n possible_errors << \"Either your amino acid sequence or nucleotide sequence are empty\"\n return possible_errors\n end\n\n # Check aa sequence \n aa_sequence_hash = Hash.new\n header_array = Array.new\n accession_no_array = Array.new\n invalid_definition = \"\"\n invalid_sequence = \"\"\n aa_seq_array.each do |fasta_sequence|\n query = Bio::FastaFormat.new( fasta_sequence )\n aa_sequence_definition = parse_definition(query.definition)\n\n aa_sequence = validate_seq(query.to_seq.seq,\"aa\") # fail return nil; success return 0\n # puts \"validation aa_sequence => #{aa_sequence}\"\n if aa_sequence_definition.nil?\n invalid_definition += \"#{query.definition}\\n\"\n end\n\n if aa_sequence.nil?\n invalid_sequence += \"#{query.definition}\\n\"\n end\n\n if !aa_sequence_definition.nil? and !aa_sequence.nil?\n aa_sequence_hash[aa_sequence_definition[0]] = query.to_seq.seq\n\n header_array << aa_sequence_definition[0].strip\n accession_no_array << aa_sequence_definition[1].strip\n end\n \n end\n \n if invalid_definition.length > 0 or invalid_sequence.length > 0\n # something wrong with aa sequence field\n invalid_submission_msg = \"Your following amino acid sequences are not following our submission rules\\n\"\n if invalid_definition.length > 0\n invalid_submission_msg += \"Failed fasta format:\\n #{invalid_definition}\"\n end\n if invalid_sequence.length > 0\n invalid_submission_msg += \"Failed amino acid sequence:\\n #{invalid_sequence}\"\n end\n\n possible_errors << invalid_submission_msg\n\n return possible_errors\n\n end\n\n # check uniqueness of header\n duplicate_header = check_uniqueness_of_header(header_array)\n if duplicate_header.length != 0\n invalid_submission_msg = \"Your following amino acid sequences have duplicate header:\\n\"\n duplicate_header.each do |d_header|\n invalid_submission_msg += \"#{d_header}\\n\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n # check if the accession number is validate or not\n # we only check the correctness of aa accession number; not gene; since we only care one accession number\n invalid_accession_num = validate_accession_numbers(accession_no_array, \"aa\")\n if invalid_accession_num.length != 0\n invalid_submission_msg = \"Your following amino acid sequences have invalid accession number from NCBI. Please check NCBI protein database:<br>\"\n invalid_accession_num.each do |accession_no|\n invalid_submission_msg += \"#{accession_no}<br>\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n ########################################################################################\n # Check nt sequence\n nt_sequence_hash = Hash.new\n header_array = Array.new\n accession_no_array = Array.new\n invalid_definition = \"\"\n invalid_sequence = \"\"\n nt_seq_array.each do |fasta_sequence|\n query = Bio::FastaFormat.new( fasta_sequence )\n nt_sequence_definition = parse_definition(query.definition)\n nt_sequence = validate_seq(query.to_seq.seq,\"nt\")\n \n # puts \"validation nt_sequence => #{nt_sequence}\"\n if nt_sequence_definition.nil?\n invalid_definition += \"#{query.definition}\\n\"\n end\n\n if nt_sequence.nil?\n invalid_sequence += \"#{query.definition}\\n\"\n end\n\n if !nt_sequence_definition.nil? and !nt_sequence.nil?\n nt_sequence_hash[nt_sequence_definition[0]] = query.to_seq.seq\n\n header_array << nt_sequence_definition[0].strip\n accession_no_array << nt_sequence_definition[1].strip\n end\n end\n\n if invalid_definition.length > 0 or invalid_sequence.length > 0\n # something wrong with aa sequence field\n invalid_submission_msg = \"Your following nucleotide sequences are not following our submission rules\"\n if invalid_definition.length > 0\n invalid_submission_msg += \"Failed fasta format:\\n #{invalid_definition}\"\n end\n if invalid_sequence.length > 0\n invalid_submission_msg += \"Failed nucleotide sequence:\\n #{invalid_sequence}\"\n end\n\n possible_errors << invalid_submission_msg\n return possible_errors\n end\n \n duplicate_header = check_uniqueness_of_header(header_array)\n if duplicate_header.length != 0\n invalid_submission_msg = \"Your following nucleotide sequences have duplicate header:\\n\"\n duplicate_header.each do |d_header|\n invalid_submission_msg += \"#{d_header}\\n\"\n end\n \n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n invalid_accession_num = validate_accession_numbers(accession_no_array, \"nt\")\n if invalid_accession_num.length != 0\n invalid_submission_msg = \"Your following nucleotide sequences have invalid accession number from NCBI. Please check NCBI protein database:<br>\"\n invalid_accession_num.each do |accession_no|\n invalid_submission_msg += \"#{accession_no}<br>\"\n end\n\n possible_errors << invalid_submission_msg\n \n return possible_errors\n end\n\n\n\n # check missing sequence\n missing_aa_sequence, missing_nt_sequence = check_matchness(aa_sequence_hash,nt_sequence_hash)\n # puts \"missing_aa_sequence => #{missing_aa_sequence}\"\n # puts \"missing_nt_sequence => #{missing_nt_sequence}\"\n missing_seq_string = \"\"\n if missing_aa_sequence.length > 0\n missing_seq_string += \"You are missing following amino acid sequence based on your nucleotide sequence:\\n\"\n missing_aa_sequence.each do |aa_seq_name|\n missing_seq_string += \"#{aa_seq_name}\\n\"\n end\n end\n\n if missing_nt_sequence.length > 0\n missing_seq_string += \"You are missing following nucleotide sequence based on your amino acid sequence:\\n\"\n missing_nt_sequence.each do |nt_seq_name|\n missing_seq_string += \"#{nt_seq_name}\\n\"\n end\n end\n\n if missing_seq_string.length > 0\n possible_errors << missing_seq_string\n end\n\n\n\n # if error, return error\n # else, return aa_array and nt_array \n if possible_errors.length > 0\n return possible_errors\n else\n aa_nt_array = Hash.new\n aa_nt_array[\"aa\"] = aa_seq_array\n aa_nt_array[\"nt\"] = nt_seq_array\n return aa_nt_array\n end\n\n end",
"def validate\n \n raise ArgumentError, \"Params emtpy\" if @params.nil? \n @errors = []\n @errors << 'charge must be provided' if @params.charge.nil? \n @errors << 'currency_code must be provided' if @params.currency_code.nil? \n @errors << 'order_id must be provided' if @params.order_id.nil? \n @errors << 'order must be provided' if @params.order.nil? \n @errors << 'order.id must be provided' if @params.order.id.nil? \n @errors << 'order.total must be provided' if @params.order.total.nil? \n @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? \n @errors << 'order.tax must be provided' if @params.order.tax.nil? \n @errors << 'order detail must be provided' unless @params.order.detail.length > 0 \n\n validate_item_details @params.order.detail if @params.order.detail.length > 0 \n\n raise ZipMoney::RequestError.new(\"Following error(s) occurred while making request, please resolve them to make the request: #{@errors}\") if @errors.any?\n end"
] | [
"0.7024727",
"0.6987122",
"0.6628124",
"0.6600039",
"0.6598607",
"0.64964336",
"0.64749897",
"0.64416945",
"0.6434939",
"0.64314103",
"0.63845956",
"0.6336999",
"0.63078034",
"0.62965655",
"0.62453014",
"0.62178195",
"0.62049085",
"0.6152431",
"0.6144182",
"0.61429733",
"0.6138311",
"0.6107099",
"0.6099678",
"0.60933805",
"0.6084876",
"0.6074874",
"0.60620695",
"0.60608524",
"0.6002139",
"0.5996978",
"0.5992238",
"0.5984817",
"0.597455",
"0.59735996",
"0.59718645",
"0.5961179",
"0.59528744",
"0.59506255",
"0.59493756",
"0.5946365",
"0.5946095",
"0.5942465",
"0.5941138",
"0.59375143",
"0.59352106",
"0.59202546",
"0.59202546",
"0.59185904",
"0.5908749",
"0.59069633",
"0.5903337",
"0.59028286",
"0.5901658",
"0.5901658",
"0.5901658",
"0.5901658",
"0.58901966",
"0.5879924",
"0.5875306",
"0.5872732",
"0.58450556",
"0.58413345",
"0.58395827",
"0.58253866",
"0.5818291",
"0.5818291",
"0.58168864",
"0.5815995",
"0.5812318",
"0.5811623",
"0.5810308",
"0.58015776",
"0.57967705",
"0.57917404",
"0.5789727",
"0.5789727",
"0.5785497",
"0.5775974",
"0.5768482",
"0.57631624",
"0.57619154",
"0.576057",
"0.5759728",
"0.57528657",
"0.5752129",
"0.57488126",
"0.5744464",
"0.5742082",
"0.5740277",
"0.5738895",
"0.57373905",
"0.57373905",
"0.5733607",
"0.5731975",
"0.5729145",
"0.57188076",
"0.57185525",
"0.5714965",
"0.5703908",
"0.56983227",
"0.56959534"
] | 0.0 | -1 |
Validate payment_nonce_uuid if present Author: Aman Date: 30/05/2019 Reviewed By: | def validate_payment_nonce_uuid
return success if @payment_nonce_uuid.blank?
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_1',
['invalid_payment_nonce_uuid']
) unless Util::CommonValidateAndSanitize.is_string?(@payment_nonce_uuid)
@gateway_nonce = GatewayNonce.get_from_memcache(@payment_nonce_uuid)
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_2',
['invalid_payment_nonce_uuid']
) if @gateway_nonce.blank?
@ost_payment_token = @gateway_nonce.ost_payment_token
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_3',
['invalid_payment_nonce_uuid']
) if (@ost_payment_token.client_id != @client.id) ||
(@gateway_nonce.status != GlobalConstant::GatewayNonce.active_status) ||
(@ost_payment_token.customer_id.present?)
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_nonce?(nonce, timestamp, consumer_key)\n \n end",
"def validate_nonce(request, value, seconds_to_timeout=5*60)\n t = ActiveSupport::Base64.decode64(value).split(\":\").first.to_i\n nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout\n end",
"def validate(response)\n # Invalid if the zuora timestamp is more than 300 seconds ago\n timestamp = from_zuora_time(response[\"timestamp\"].to_i)\n return false if timestamp < Time.now - 300\n # Match the signature with the signature from zuora\n create(response[\"id\"], response[\"timestamp\"], response[\"token\"]).signature == response[\"responseSignature\"]\n end",
"def validate_gateway_nonce\n return error_with_identifier('invalid_api_params',\n 'w_g_sn_vgn_1',\n ['invalid_gateway_nonce']\n ) unless Util::CommonValidateAndSanitize.is_string?(@gateway_nonce)\n @gateway_nonce = @gateway_nonce.to_s\n\n return error_with_identifier('invalid_api_params',\n 'w_g_sn_vgn_1',\n ['expired_token']\n ) if GatewayNonce.where(ost_payment_token_id: @ost_payment_token.id, gateway_type: @gateway_type).exists?\n\n success\n end",
"def valid_signature?\n params['verifier'] == Digest::MD5.hexdigest([ params['id'], params['snuid'], params['currency'], Offerpal.secret_key ].join(':'))\n end",
"def validate_nonce(secret_key, request, value, seconds_to_timeout = T.unsafe(nil)); end",
"def validate_uuid(uuid)\n unless uuid.is_a?(String)\n @log.error \"UUID is not a string\"\n return false\n end\n\n unless !!/^\\S{8}-\\S{4}-4\\S{3}-[89abAB]\\S{3}-\\S{12}$/.match(uuid.to_s)\n @log.error \"UUID is not a valid V4 UUID\"\n return false\n end\n return true\n end",
"def valid_uuid_format?(uuid)\n !!(uuid =~ /^[A-Za-z0-9_\\-]{16,}$/)\n end",
"def seems_valid?\n return true if nil_uuid?\n return seems_valid_microsoft? if variant_microsoft?\n return false if undefined_version? && variant_rfc_4122?\n if variant_rfc_4122?\n version == 1 ? reasonable_time? : !undefined_version?\n else\n nil\n end\n end",
"def valid_nonce?(request)\n\n # check if a valid session\n return false if not valid_session?(request)\n return false if @nonce.nil?\n return false if not request.post?\n\n # get nonce from request\n request_nonce = request['nonce']\n return false if request_nonce.nil?\n \n # verify nonce\n request_nonce.eql? @nonce\n \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 valid? headers, params\n timestamp = get_timestamp headers\n\n message = create_message params[\"token\"], params[\"trx_id\"], params[\"monto\"], timestamp\n authorization = Authorization.new(@env)\n signature = authorization.sign(message)\n signature == pp_signature(headers)\n\n end",
"def valid_undashed_uuid?(value)\n value =~ /\\A[[:xdigit:]]{32}\\z/\n end",
"def valid?\n return false if @author_email.nil?\n return false if @repository_url.nil?\n return false if @sha.nil?\n pattern = Regexp.new(\"^[a-fA-F0-9]{40}$\")\n return false if @sha !~ pattern\n true\n end",
"def nonce; end",
"def validate_token_no_tmp_datetime(token)\n valid_vals = []\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now)\n (1..self.class.ga_timedrift).each do |cc|\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.ago(30*cc))\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.in(30*cc))\n end\n\n if valid_vals.include?(token.to_i)\n return true\n else\n return false\n end\n end",
"def test_nonce_not_current\n string = \"0123456789ABCDEF\"\n\n nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)\n assert_equal false, nonce1, \"Nonces over a day in the past should be rejected\"\n\n nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)\n assert_not_equal false, nonce2, \"Nonces under a day in the past should be rejected\"\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 verification_token_valid?\n (self.verification_sent_at + 4.hours) > Time.now.utc\n end",
"def guard_process_payment_from_created; true; end",
"def guard_process_payment_from_created; true; end",
"def is_uuid?(uuid)\n uuid =~ /[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}/i\n end",
"def validate_post_owner(params)\n if params[\"id\"]\n return true\n else\n return false\n end\n end",
"def nonce\n auth_info[\"nonce\"] || \"\"\n end",
"def token_valid?(client_nonce, token)\n gen_time, _dontcare = encryptor(client_nonce).decode(token)\n\n time_diff = Time.now - Time.at(time_to_block(gen_time))\n time_diff < valid_interval && time_diff > 0\n rescue ArgumentError\n false\n end",
"def nonce=(_arg0); end",
"def validate_for_card\n tt = self.transaction_type.to_i\n \n # mandatory: transaction_type must != (30, 31, 32, 34, 35)\n append_error(:cc_number, \"cc_number must not be set for tagged transactions\") if [30,31,32,34,35].include?(tt)\n \n # amount, cardholder_name always mandaory\n mandatory = [:amount, :cardholder_name]\n \n # card_number & expiry_date mandatory for all except 50, 54\n # pan mandatory for only 50, 54\n mandatory << ([50,54].include?(tt) ? :pan : [:cc_number, :cc_expiry])\n mandatory.flatten!\n\n # reference_no mandatory for 60\n mandatory << :reference_no if tt == 60\n \n # auth_number mandatory for (02, 03, 11, 12, 13)\n mandatory << :authorization_num if [02, 03, 11, 12, 13].include?(tt)\n \n check_mandatory(mandatory)\n end",
"def uuid?(uuid)\n uuid_regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/\n uuid_regex.match?(uuid.to_s.downcase)\nend",
"def id_me_user_uuid\n if user_uuid && !user_uuid.length.in?([20, 21, 22, 23, 32])\n errors.add(:user_uuid, \"(#{user_uuid}) is not a proper length\")\n end\n end",
"def valid_orcid_id?(id)\n if id =~ /[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9,X]{4}/\n id = id.delete('-')\n id[15] == orcid_checksum(id)\n else\n false\n end\n end",
"def check(payment)\n retval\n end",
"def is_checksum_valid?(received_params)\n paytmparams = Hash.new\n\n keys = received_params.keys\n keys.each do |k|\n paytmparams[k] = received_params[k]\n end\n\n checksum_hash = paytmparams[\"CHECKSUMHASH\"]\n paytmparams.delete(\"CHECKSUMHASH\")\n\n Rails.logger.debug \"HERE\"\n Rails.logger.debug \"paytmparams #{paytmparams}\"\n Rails.logger.debug \"checksum_hash #{checksum_hash}\"\n Rails.logger.debug \"PAYTM_MERCHANT_KEY #{ENV[\"PAYTM_MERCHANT_KEY\"]}\" \n \n return new_pg_verify_checksum(paytmparams, checksum_hash, ENV[\"PAYTM_MERCHANT_KEY\"])\n end",
"def validate!\n Cybersource::Security.validate_signature!(@fields['signature'], signed_data)\n raise PaymentFailed unless payment_success?\n\n self\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 valid_id?(value)\n value.is_a?(String) && value.match?(UUID_PATTERN)\n end",
"def validate_lock_customer_account\n\n end",
"def valid?\n return false if !@description.nil? && @description.to_s.length > 255\n return false if @routing_number.nil?\n return false if @routing_number.to_s.length > 9\n return false if @routing_number.to_s.length < 9\n return false if @account_number.nil?\n return false if @account_number.to_s.length > 17\n return false if @account_type.nil?\n account_type_validator = EnumAttributeValidator.new('String', [\"company\", \"individual\"])\n return false unless account_type_validator.valid?(@account_type)\n return false if @signatory.nil?\n return false if @signatory.to_s.length > 30\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^bank_[a-zA-Z0-9]+$/)\n return false if !@signature_url.nil? && @signature_url !~ Regexp.new(/^https:\\/\\/lob-assets\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if @date_created.nil?\n return false if @date_modified.nil?\n return false if @object.nil?\n object_validator = EnumAttributeValidator.new('String', [\"bank_account\"])\n return false unless object_validator.valid?(@object)\n true\n end",
"def test_custom_nonce\n now = Time.now.to_i\n \n oauth_params = OAUTH_REQ_PARAMS.merge(:timestamp => now)\n assert_equal %{oauth_timestamp=\"#{now}\"}, %{oauth_timestamp=\"#{SOAuth.header('http://lonelyvegan.com/', oauth_params).match(now.to_s)[0]}\"}\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_gateway_nonce\n return r unless r.success?\n\n r = validate_gateway_type\n return r unless r.success?\n\n success\n end",
"def nonce\n Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first\n end",
"def validator(response, task_information)\n !response.body_utf8.match(/The login information you entered does not match an account on record. Please try again./i)\n end",
"def card_number_valid?\n if card_number\n card_number =~ /\\A\\d{13,16}\\z/\n else\n true\n end\n end",
"def valid_response?\n return false unless response\n\n valid_hmac? && valid_amount? && valid_account?\n end",
"def test_validate_pass_0d321d14653d0_returns_true\r\n\t\tassert_equal(true, validate_isbn?(\"0-321-14653-0\"))\r\n\tend",
"def test_validate_pass_0d321d14653d0_returns_true\r\n\t\tassert_equal(true, validate_isbn?(\"0-321-14653-0\"))\r\n\tend",
"def validate_worldpay_return_parameters(orderKey, paymentAmount, paymentCurrency, paymentStatus, mac)\n mac_secret = worldpay_mac_secret\n data = orderKey + paymentAmount + paymentCurrency + paymentStatus + mac_secret\n digest = Digest::MD5.hexdigest(data)\n digest.to_s.eql? mac\n end",
"def validate_token\n if self.transaction_token_created_at + 720.minutes > Time.now\n true\n else\n false\n end\n end",
"def nonce\n Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first\n end",
"def valid_token(card_type: T.unsafe(nil)); end",
"def content_security_policy_nonce; end",
"def verify_iss; end",
"def verify_iss; end",
"def test_custom_nonce\n nonce = Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\\W/, '')\n \n oauth_params = OAUTH_REQ_PARAMS.merge(:nonce => nonce)\n assert_equal %{oauth_nonce=\"#{nonce}\"}, %{oauth_nonce=\"#{SOAuth.header('http://lonelyvegan.com/', oauth_params).match(nonce)[0]}\"}\n end",
"def check_developer_orcid!\n return false unless params[:name].blank? && params[:email].blank? && params[:test_domain].blank? && !params[:orcid].blank?\n @orcid = params[:orcid]\n orcid_choose_tenant_or_login!\n true\n end",
"def test_validate_pass_978d0d13d149505d0_returns_true\r\n\t\tassert_equal(true, validate_isbn?(\"978-0-13-149505-0\"))\r\n\tend",
"def test_validate_pass_978d0d13d149505d0_returns_true\r\n\t\tassert_equal(true, validate_isbn?(\"978-0-13-149505-0\"))\r\n\tend",
"def validate_checksum?\n self[:checksum] !~ /time/\n end",
"def check_nonce!(hash:, nonce:, target_bits: 20)\n digest = Digest::SHA256.hexdigest(hash.to_s + nonce.to_s)\n raise BlockError \"Block nonce is wrong!\" unless digest.to_i(16) < 2 ** (256 - target_bits)\n true\n end",
"def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\n end",
"def nonce\n @nonce ||= Digest::SHA1.hexdigest random_string + timestamp\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 signature_is_valid?\n node = @ar.at_css('xmlns|SignedInfo',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#')\n\n node = node.canonicalize\n\n signature = @ar.at_css(\n 'xmlns|SignatureValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content\n\n signature = Base64.decode64(signature)\n\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def valid_card_verification_value?(cvv)\n cvv.to_s =~ /^\\d{#{card_verification_value_length(@card_brand)}}$/\n end",
"def cnonce\n SecureRandom.hex 16\n end",
"def content_security_policy_nonce_directives; end",
"def content_security_policy_nonce_directives; end",
"def validate_and_sanitize\n r = validate\n return invalid_credentials_response('a_ar_b_vas_1') unless r.success?\n\n @parsed_request_time = Time.at(@request_timestamp.to_i)\n\n return invalid_credentials_response(\"um_vac_1\") unless @parsed_request_time && (@parsed_request_time.between?(Time.now - expiry_window, Time.now + expiry_window))\n\n @request_parameters.permit!\n\n [\"signature\"].each do |k|\n @request_parameters.delete(k)\n end\n\n success\n end",
"def signature_valid?; end",
"def nonce\n ((Time.now.to_f * 1000000).to_i << 10).to_s\n end",
"def check_signature\n signature == \"ElfChnk\\x00\"\n end",
"def validate_rut\n return true if self.rut.to_s.blank?\n\n self.rut = self.rut.to_s.gsub(\".\", \"\")\n\n if self.rut.to_s.match(/^(|\\d{1,8}-(\\d{1}|K|k))$/).nil?\n errors.add(:rut, :invalid_rut_format)\n return false\n end\n\n number_verif_digit = self.rut.to_s.gsub(\".\", \"\").split(\"-\")\n\n if number_verif_digit.size != 2\n errors.add(:rut, :invalid_rut_format)\n return false\n end\n\n number = number_verif_digit.first\n digit = number_verif_digit.last\n digit = 10 if number_verif_digit.last.downcase == \"k\"\n\n serie = [2,3,4,5,6,7]\n sum = 0\n\n number.split(\"\").reverse.each_with_index do |n, i|\n serie_value = serie[i]\n serie_value = serie[i - serie.size] if serie_value.nil?\n sum += n.to_i * serie_value\n end\n\n result = 11 - (sum % 11)\n result = 0 if result == 11\n\n if result != digit.to_i\n errors.add(:rut, :invalid_verification_digit)\n return false\n end\n\n return true\n end",
"def create_entry_in_gateway_nonce\n @gateway_nonce_record = GatewayNonce.new(\n uuid: get_uuid,\n ost_payment_token_id: @ost_payment_token.id,\n nonce: @gateway_nonce,\n status: GlobalConstant::GatewayNonce.active_status,\n gateway_type: @gateway_type\n )\n @gateway_nonce_record.save!\n success\n end",
"def valid?\n p = build_payment\n p.valid?\n end",
"def content_security_policy_nonce=(_arg0); end",
"def valid?\n return false unless given_signature\n Relax::Query.unescape_value(correct_signature) == given_signature\n end",
"def is_valid(params)\n account_valid = true\n\n if params[:cardholder_name].blank?\n errors[:cardholder_name] << \"cannot be blank.\"\n account_valid = false\n end\n\n if params[:cardholder_email].blank?\n errors[:cardholder_email] << \"cannot be blank.\"\n account_valid = false\n end\n\n if params[:account][:stripe_cc_token].blank?\n errors[:base] << \"- Could not get a valid response from Stripe.com\"\n account_valid = false\n end\n\n return account_valid\n end",
"def validate_signature(key_public, signature, timestamp)\r\n # RSA Decryption (Formula: M = C^e mod n)\r\n timestamp = timestamp.to_i % key_public[1].to_i\r\n signature = signature.to_i\r\n decipher = signature.to_bn.mod_exp(key_public[0].to_i,key_public[1].to_i)\r\n return true if (decipher == timestamp)\r\n return false\r\nend",
"def authorizable_cc_payment?\n adyen_cc_payment? && amount != 0\n end",
"def content_security_policy_nonce_generator; end",
"def content_security_policy_nonce_generator; end",
"def verify_credit_card\n @credit_card = ActiveMerchant::Billing::CreditCard.new(\n :type => \"visa\",\n :number => \"3024007148673576\",\n :verification_value => \"123\",\n :month => 1,\n :year => Time.now.year+1,\n :first_name => \"Greg\",\n :last_name => \"Barber\"\n )\n\n unless @credit_card.valid?\n @credit_card.errors.full_messages.each do |message|\n # errors.add_to_base message\n $stdout.puts \"777777777777777777777777777777777777\"\n $stdout.puts \"777777777777777777777777777777777777 message: \" + message\n $stdout.puts \"777777777777777777777777777777777777\"\n end\n end\n render :layout => false, :inline => \"Error: credit card is not valid. #{credit_card.errors.full_messages.join('. ')}\"\n end",
"def uuid?(str)\n !!(str && str.size == 36 && str.match(/\\A\\h{8}-\\h{4}-\\h{4}-\\h{4}-\\h{12}\\z/))\n end",
"def valid_token?\n five_minutes_ago = DateTime.now - 5.minutes\n params[:timestamp].to_i > five_minutes_ago.to_i &&\n params[:token] == Scalingo::SsoController.generate_authentication_token(params[:id], params[:timestamp])\n end",
"def card_is_not_expired?\n if self.card_expiry_month != nil\n if self.card_expiry_year == Time.now.strftime(\"%Y\").to_i && self.card_expiry_month < Time.now.strftime(\"%-m\").to_i\n errors.add(:card_expiry_month, \"must be valid\")\n end\n end\n end",
"def test_icvc13_pass_A_returns_false\r\n\t\tassert_equal(false, isbn13_checksum_valid_character?(\"A\"))\r\n\tend",
"def valid?(line_token)\n\t\tline_token[0] == 'VOTE' && line_token[1].scan(/\\D/).empty? && line_token[2].scan(/^Campaign:[a-zA-Z]+/).any? && line_token[3].scan(/^Validity:(during|pre|post)/) && line_token[4].scan(/^Choice:[a-zA-Z]+/).any?\n\tend",
"def valid_signature?(params)\n (Time.at(params['ts'].to_i) > 30.minutes.ago) &&\n params['sig'] == signed_request_params(params['ts'])['sig']\n end",
"def meta_valid?(payload)\n payload['iss'] != meta[:iss] || payload['aud'] != meta[:aud]\n end",
"def test_successful_purchase_with_emv_credit_card_in_uk\n assert response = @gateway.purchase(@amount, @emv_credit_cards[:uk], @options)\n assert_success response\n assert_equal 'charge', response.params['object']\n assert response.params['paid']\n assert_match CHARGE_ID_REGEX, response.authorization\n end",
"def check_signature\n signature == \"\\x2a\\x2a\\x00\\x00\"\n end",
"def valid_south_african_id_number; end",
"def valid_payload(payload)\n if expired(payload) || payload['iss'] != meta[:iss] || payload['aud'] != mata[:aud]\n false\n else\n true\n end\n end",
"def content_security_policy_nonce_directives=(_arg0); end",
"def content_security_policy_nonce_directives=(_arg0); end",
"def verify_jti; end",
"def verify_jti; end",
"def assert\n raise 'The card number is not valid ' unless yield\n end",
"def validate_uuids\n unless Material.valid?(param_uuids)\n return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Invalid Material UUIDs' }]}, status: :unprocessable_entity\n end\n end",
"def validate_uuids\n unless Material.valid?(param_uuids)\n return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Invalid Material UUIDs' }]}, status: :unprocessable_entity\n end\n end",
"def valid_card(card_type: T.unsafe(nil)); end"
] | [
"0.6798067",
"0.6088441",
"0.6086424",
"0.608403",
"0.59804237",
"0.5917215",
"0.5785835",
"0.57154334",
"0.5712858",
"0.5705686",
"0.56677246",
"0.5593132",
"0.55722463",
"0.5552786",
"0.55427426",
"0.5502488",
"0.5471665",
"0.54157007",
"0.536569",
"0.5360557",
"0.5360557",
"0.5354091",
"0.5349724",
"0.5343536",
"0.5335833",
"0.53273624",
"0.5321359",
"0.5320762",
"0.5299792",
"0.5284082",
"0.52799803",
"0.5270877",
"0.52650213",
"0.52558887",
"0.52504027",
"0.52306527",
"0.5225758",
"0.5211002",
"0.5196108",
"0.519293",
"0.51881415",
"0.51799065",
"0.51751775",
"0.51597506",
"0.51597506",
"0.5156104",
"0.5150402",
"0.5146789",
"0.51392376",
"0.5136018",
"0.51189333",
"0.51189333",
"0.5118083",
"0.51142144",
"0.51088357",
"0.51088357",
"0.5107653",
"0.5103019",
"0.50947946",
"0.50947946",
"0.5077815",
"0.50596917",
"0.5056516",
"0.5051263",
"0.505016",
"0.505016",
"0.5050005",
"0.5048612",
"0.5046254",
"0.5040173",
"0.50401205",
"0.5037079",
"0.50294095",
"0.50285816",
"0.5026183",
"0.5018337",
"0.5005937",
"0.49942294",
"0.49887806",
"0.49887806",
"0.4986105",
"0.4983951",
"0.4983732",
"0.4982088",
"0.49755898",
"0.4966339",
"0.4964783",
"0.49631056",
"0.49612156",
"0.4961208",
"0.49601945",
"0.49542633",
"0.4945098",
"0.4945098",
"0.4942186",
"0.4942186",
"0.4940375",
"0.4938385",
"0.4938385",
"0.49342912"
] | 0.7954449 | 0 |
Format service response Author: Aman Date: 30/05/2019 Reviewed By: | def service_response_data
fail 'unimplemented method service_response_data'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatAPA\n (prettyOutput(@authors.map { |x| x.to_s }) + \"(\" + @datee.year.to_s + \") \" + @title +\n \"\\n\\t(\" + @edition.to_s + \") \" +\n \"(\" + @editionnumber.to_s + \") \" +\n @url)\n end",
"def format_response response \n translate_response_hash_keys response_to_hash(response)\n end",
"def formatted_response\n self.response\n end",
"def format_response(response)\n result = \" Response:\\n\"\n\n result += format_response_headers response.headers\n result += format_response_body response.body\n\n result\n end",
"def format_service_response\n formatted_response = @service_response\n\n if formatted_response.success?\n formatted_response.data = get_formatter_class.send(params['action'], formatted_response.data.dup)\n end\n\n # puts \"\\nFinal formatted response : #{formatted_response.inspect}\"\n render_api_response(formatted_response)\n end",
"def author() headers['author'] end",
"def format_service\n\n end",
"def format_response\n return '' if data.nil? || data.empty?\n\n case data\n when Hash\n message = data[:message] ? data[:message] : ' '\n docs = data[:documentation_url]\n error = create_error_summary\n message << error if error\n message << \"\\nSee: #{docs}\" if docs\n message\n when String\n data\n end\n end",
"def format_response(payload); end",
"def format_response(payload); end",
"def print_response_details(response)\n # Parse the mutate response to print details about the entities that\n # were created by the request.\n suffix = \"_result\"\n response.mutate_operation_responses.each do |result|\n result.to_h.select {|k, v| v }.each do |name, value|\n if name.to_s.end_with?(suffix)\n name = name.to_s.delete_suffix(suffix)\n end\n\n puts \"Created a(n) #{::Google::Ads::GoogleAds::Utils.camelize(name)} \" \\\n \"with #{value.to_s.strip}.\"\n end\n end\nend",
"def show_authors(result)\n author_array = []\n if result['Items'].present?\n flag = 0\n authorString = []\n result['Items'].each do |item|\n if item['Group'].present?\n if item['Group'] == \"Au\"\n # let Don and Michelle know what this cleaner function does\n newAuthor = processAPItags(item['Data'].to_s)\n # i'm duplicating the semicolor - fix\n newAuthor.gsub!(\"<br />\", \"; \")\n authorString.push(newAuthor)\n flag = 1\n end\n end\n end\n if flag == 1\n return truncate_article authorString.join(\"; \").html_safe\n end\n end\n contributors = result.fetch('RecordInfo', {}).fetch('BibRecord', {}).fetch('BibRelationships', {}).fetch('HasContributorRelationships', [])\n if not contributors.empty?\n contributors.each do |contributor|\n namefull = contributor.fetch('PersonEntity', {}).fetch('Name', {}).fetch('NameFull', nil)\n if namefull\n url_vars = {\"q\" => '\"' + namefull.gsub(\",\", \"\").gsub(\"%2C\", \"\").to_s + '\"', \"search_field\" => \"author\"}\n link2 = generate_next_url_newvar_from_hash(url_vars)\n author_link = '<a href=\"' + request.fullpath.split(\"?\")[0] + \"?\" + link2 + '\">' + namefull.to_s + '</a>'\n author_array.push(author_link)\n end\n\n end\n return author_array.join(\"; \").html_safe\n end\n return ''\n end",
"def author\n [author_developer.name_and_email, author_date, author_date_gmt_offset]\n end",
"def format_results(list, newer_than, format = nil)\n # Output\n out = ''\n\n # Filter out the cover field which is entirely local\n final = list.dup.map {|bk| bk.delete('cover'); bk }\n\n str_newer = newer_than.to_s.split(%r{T})[0]\n out = \"#{final.length} new/updated books since #{str_newer}:\\n\\n\"\n case format\n when /json/\n out = Oj.dump(final)\n when /xml/\n out = Ox.dump(final, :effort => :tolerant)\n when /yaml/\n out = final.to_yaml\n when /rss/\n out = make_rss(final, out)\n else\n # Remove the date part after the T (timezone and hours)\n #\n final.each do |bk|\n series = bk['series']\n if series == ''\n title = bk['title']\n else\n title = \"#{bk['title']} (#{series}, ##{bk['series_index']})\"\n end\n out += \"Authors: %-25.25s\\tTitle: %s\\n\" % [bk['authors'], title]\n end\n end\n out\nend",
"def format\n # order_id\n order_id = self.order_id\n # delivery_time\n delivery_time_start = self.serving_datetime.strftime('%I:%M')\n delivery_time_end = (self.serving_datetime + 30*60).strftime('%I:%M%p')\n delivery_time = delivery_time_start + \"-\" + delivery_time_end\n # delivery_date\n delivery_date = self.serving_datetime.to_date\n # feedback_submitted\n self.feedback ? feedback_submitted = true : feedback_submitted = false\n # order_items\n order_items = []\n self.order_items.each do |item|\n order_item_id = item.id\n name = item.meal.name\n order_items.push(\n {\n order_item_id: order_item_id,\n name: name\n }\n )\n end\n\n # return object\n {\n order_id: order_id,\n delivery_date: delivery_date,\n delivery_time: delivery_time,\n feedback_submitted: feedback_submitted,\n order_items: order_items\n }\n end",
"def response_title_in_words(response, options={})\n if response.new_record?\n \"%{name} wants to add a %{type} now\".t % {\n :name => response.person ? link_to(h(response.person.username_or_name),\n person_path(response.person)) : response.sender_email,\n :type => response.class.human_name,\n }\n else\n \"%{name} replied %{time} ago\".t % {\n :name => response.person ? link_to(h(response.person.username_or_title_and_full_name), \n person_path(response.person), options[:pcard] ? {:class => \"pcard\", :rel => member_url([@tier, response.person], :pcard)} : {}) : response.sender_email,\n :type => response.class.human_name,\n :time => time_ago_in_words_span_tag(response.created_at)\n }\n end\n end",
"def process_result (result)\n\t\t\tif result[\"release_date\"] && !result[\"release_date\"].eql?(\"\")\n\t\t\t\tdate_obj = Date.parse(result[\"release_date\"])\n\t\t\t\tresult[\"date\"] = date_obj.to_formatted_s(:long)\n\t\t\telse \n\t\t\t\tresult[\"date\"] = \"None\"\n\t\t\tend\n\t\t\treturn result\n\t\tend",
"def formats; end",
"def formats; end",
"def format_response(response, method)\n case method\n when \"get\"\n JSON.parse(response[:formatted_records])\n # response example:\n # [{\"work_item_id\"=>1,\n # \"description\"=>\"user research\",\n # \"guide\"=>\"ruby\",\n # \"status\"=>\"in-progress\",\n # \"username\"=>\"wkhalifa\",\n # \"archived\"=>1}]\n when \"post\"\n [response[:generated_fields][0].to_h]\n # response example:\n # [{:long_value=>21}]\n when \"put\"\n []\n else\n raise \"Configuration method. Must provide: get, post, or put.\"\n end\n end",
"def format_acknowledgements()\n s = \"<ul>\"\n if @book.style.attribute?\n s << \"<li>Layout and style '#{@book.style.name}' provided by \"\n if @book.style.author_url\n s << \"<a href='#{@book.style.author_url}'>#{@book.style.author}</a>\"\n else\n s << @book.style.author\n end\n s << \".\"\n s << \"</ul><ul>\"\n end\n @book.style.assets.each do |a|\n next unless a.attribute?\n next unless a.name\n s << \"<li>\"\n if a.collection_url\n s << \"<a href='#{a.collection_url}'>#{a.name}</a>\"\n elsif a.name\n s << a.name\n end\n s << \" is provided by \"\n if a.author_url\n s << \"<a href='#{a.author_url}'>#{a.author}</a>\"\n elsif a.author\n s << a.author\n else\n s << \"anonymous\"\n end\n if a.collection\n s << \" as part of \"\n s << \"#{a.collection}\"\n end\n s << \".</li>\"\n end\n s << \"</ul>\"\n end",
"def format_ap_date(date_obj)\n date_obj = DateTime.parse(date_obj) unless date_obj.is_a? DateTime\n\n if [*3..7].include? date_obj.month # months 3,4,5,6,7 are written as is in AP\n date_obj.strftime('%B %-d, %Y')\n elsif date_obj.month == 9 # Sept. is special\n date_obj.strftime('%bt. %-d, %Y')\n else # 3 letter abbr with .\n date_obj.strftime('%b. %-d, %Y')\n end\nend",
"def authors\n\t#params[:diff] = params[:diff].eql?\"true\"\n \trespond_in_format Marginalia.authors(params[:id],params[:diff])\n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format_auto_reminder(body, class_date)\n body.gsub!(/\\%class_location/, class_date.library_class.location)\n body.gsub!(/\\%class/, \"#{class_date.library_class.title} \\u2014 #{class_date.to_formatted_datetime}\")\n end",
"def format\n case result_item.format\n when \"Book\", :book_item\n \"book\" \n when :dissertation\n \"dissertation\"\n else\n \"journal\"\n end\n end",
"def watermark_formatted_text\n struct = export_as_mla_structure(parent_presenter)\n wrapped = wrap_text(struct[:author] + '___' + struct[:title], 150)\n parts = wrapped.split('___')\n [{ text: parts[0] },\n { text: parts[1], styles: [:italic] },\n { text: \"\\n\" + wrap_text(struct[:publisher], 150) },\n { text: \"\\nDownloaded on behalf of #{request_origin}\" }\n ]\n end",
"def formatted_json_response(opts={})\n [\n \"# HTTP #{response.status}\",\n canonicalize_json(response.body, opts),\n '' # make baseline file end with newline\n ].join(\"\\n\")\n end",
"def author_to_marc(a)\n author = ''\n author << a.von + ' ' unless a.von.blank?\n author << a.last\n author << ' ' + a.suffix unless a.suffix.blank?\n author << ', ' + a.first\n author\n end",
"def highwire_author_format(name)\n if name.include? ','\n name.split(',').reverse.join(' ').strip\n else\n name\n end\n end",
"def create_abstract(result)\n abstract = \"#{result['publicationName']} – \"\n result['creators'].each_with_index do |creator, i|\n abstract += \" and\" if i > 0\n abstract += \" #{creator['creator']}\"\n end\n return abstract\n end",
"def extract_author(obj)\n author = {}\n if obj.is_a?(String)\n if obj.present?\n given_name, family_name = obj.split(' ', 2)\n author[:given_name] = given_name if given_name.present?\n author[:family_name] = family_name if family_name.present?\n end\n else\n name = obj['name'] || obj['@id'] || ''\n given_name, family_name = name.split(' ', 2)\n family_name = obj['familyName'] if obj['familyName'].present?\n given_name = obj['givenName'] if obj['givenName'].present?\n affiliation = obj['affiliation']\n if affiliation.present?\n if affiliation.is_a?(String)\n author[:affiliation] = affiliation\n else\n affiliation = affiliation.dereference if affiliation.respond_to?(:dereference)\n author[:affiliation] = affiliation['name'] if affiliation && affiliation['name'].present?\n end\n end\n orcid = obj['identifier'] || obj['@id']\n author[:orcid] = orcid if orcid.present? && orcid.include?('orcid.org')\n author[:given_name] = given_name if given_name.present?\n author[:family_name] = family_name if family_name.present?\n end\n\n author\n end",
"def show\n# authorize_staff unless api_request?\n\n @fundamental_announcement = Fundamental::Announcement.find(params[:id])\n \n last_modified = @fundamental_announcement.updated_at\n\n render_not_modified_or(last_modified) do\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamental_announcement, methods: [ :author_name ] }\n end\n end\n end",
"def publish_date_and_explanation(errata)\n bold = errata.publish_date_explanation == 'custom'\n # This is very ugly, sorry! (fixme)\n html = ''\n html << '<div class=\"compact\">'\n html << '<b>' if bold\n html << [h(errata.publish_date_for_display),\"<small style='color:#888'>(#{errata.publish_date_explanation})</small>\"].compact.join('<br/>')\n html << '</b>' if bold\n html << '<br/>'\n html << \"<small>#{time_ago_future_or_past(errata.publish_or_ship_date_if_available)}</small>\" if errata.publish_or_ship_date_if_available\n html << '</div>'\n html.html_safe\n end",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def format_response(response)\n items = []\n body = JSON.parse(response.body)\n if response.code.to_i == 200\n body['items'].each do |item|\n items << { title: item['title'], link: item['link'], snippet: item['snippet'] }\n end\n else\n items << format_errors(body)\n end\n items\n end",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def details\n format_description(@description) + \"site name: \" + format_name\n end",
"def headings\n # NOTE: \"Comments\" is shared between both sets\n if self.new_review_format\n [\"Role Competence\",\"Consulting Skills\",\"Teamwork\", \"Contributions\", \"Comments\"]\n else\n [\"Tech\",\"Client\", \"Ownership\", \"Leadership\", \"OldTeamwork\", \"Attitude\", \"Professionalism\", \"Organizational\", \"Innovative\", \"Comments\"]\n end\n end",
"def to_s\n \"Last Modified: #{@modifiedAt}\\nStatus: #{@status}\\nAssigned to: #{@owner}\\nSubject: #{@subject}\\n#{@preview}\"\n end",
"def formatted_client_display_info\n output_info = []\n output_info << \"Name: #{@name}\"\n output_info << \"Age: #{@age}\"\n output_info << \"Children: #{@number_of_children}\"\n output_info << \"Pets: #{self.number_of_pets}\"\n @pets.each { |k, pet| output_info << \" #{pet.name} is #{pet.age}, and likes to play with... #{pet.toys}\" }\n # add a blank line\n output_info << \" \"\n return output_info\n end",
"def response_to_h(resp) # :nodoc:\n resp = resp.body.gsub(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n\n # unfold folded fields\n # A newline followed by one or more spaces is treated as a\n # single space\n resp.gsub!(/\\n +/, \" \")\n\n #replace CF spaces with underscores\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/)\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n return {:error => resp } if (resp =~ /^#/ and resp =~/does not exist\\.$/) or (resp =~ /Transaction \\d+ is not related to Ticket/)\n\n # convert fields to key value pairs\n ret = {}\n resp.each_line do |ln|\n next unless ln =~ /^.+?:/\n ln_a = ln.split(/:/,2)\n ln_a.map! {|item| item.strip}\n ln_a[0].downcase!\n ret[ln_a[0]] = ln_a[1]\n end\n\n return ret\n end",
"def format_email_user_info(body, user)\n body.gsub!(/\\%name/,user.fullname)\n body.gsub!(/\\%email/,user.email)\n body.gsub!(/\\%phone/,user.phone)\n body.gsub!(/\\%program/,user.program)\n body.gsub!(/\\%school/,user.school)\n body.gsub!(/\\%status/,user.status)\n suggestion = Suggestion.where(:username => user.username).order(\"created_at\").last\n unless suggestion.nil?\n body.gsub!(/\\%suggestion/, suggestion.suggestion)\n end\n return body\n end",
"def formatted_date\n \tobject.created_at.strftime(\"%R - %B %e, %Y \")\n end",
"def format_response(response)\n case\n when response == 'OK'\n true\n when response =~ /^ACK/\n ack = format_ack(response)\n logger.warn ack\n \n ack\n when response.split.size == 1\n # set value -> value\n Hash[*(response.split.*2)]\n else\n # remove first response: \"OK\"\n response = response.split\n response.pop\n\n Hash[*response.collect{|x| x.gsub(/:$/,'')}]\n end\n end",
"def adapt_response(response)\n formatted = Lyg::HttpResponse.new(response.code)\n\n response.raw_headers.each do |key, value|\n formatted.headers[key] = value\n end\n\n response.cookies.each do |key, value|\n formatted.cookies[key] = value\n end\n\n formatted.content = response.body\n return formatted\n end",
"def author\n @info[:Author]\n end",
"def show\n #author_string\n author_count = @book.book_authors.count\n author_map = @book.book_authors.each_with_index.map{|a, i|\n if i < author_count -1\n if a.first_name.blank?\n \"#{a.last_name} & \"\n else\n \"#{a.last_name}, #{a.first_name.strip.first}. & \"\n end\n else\n if a.first_name.blank?\n \"#{a.last_name}\"\n else\n \"#{a.last_name}, #{a.first_name.strip.first}.\"\n end\n end\n }.compact\n @author_string = author_map.join(\"\")\n @be = \"#{@book.book_edition}, \" unless @book.book_edition.blank?\n #@first = \"#{@author_string} #{@book.publication_year.strftime('%Y')},\"\n #@ital = @book.book_title#Applied solid mechanics\n #@rest = \", #{@book.book_edition}, #{@book.publisher_name}, #{@book.publisher_city}.\"\n @ref = \"#{@author_string} #{@book.publication_year.strftime('%Y')}, <i>#{@book.book_title}</i>, #{@be}#{@book.publisher_name}, #{@book.publisher_city}.\"\n end",
"def formatted_name(data)\n '' << data[:Title] << ' ' <<\n initials(data[:\"First Names\"]) <<\n data[:Surname]\n end",
"def format_resource(client, service_template, options)\n response = client.get(\"#{RESOURCE_PATH}/#{service_template}\")\n\n if CloudClient.is_error?(response)\n [response.code.to_i, response.to_s]\n else\n if options[:json]\n [0, response.body]\n elsif options[:yaml]\n [0, JSON.parse(response.body).to_yaml(:indent => 4)]\n else\n str = '%-20s: %-20s'\n str_h1 = '%-80s'\n\n document = JSON.parse(response.body)['DOCUMENT']\n template = document['TEMPLATE']['BODY']\n reg_time = OpenNebulaHelper.time_to_str(\n template['registration_time']\n )\n\n CLIHelper.print_header(\n str_h1 % \"SERVICE TEMPLATE #{document['ID']} INFORMATION\"\n )\n\n puts Kernel.format str, 'ID', document['ID']\n puts Kernel.format str, 'NAME', document['NAME']\n puts Kernel.format str, 'USER', document['UNAME']\n puts Kernel.format str, 'GROUP', document['GNAME']\n puts Kernel.format str, 'REGISTRATION TIME', reg_time\n\n puts\n\n CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)\n\n ['OWNER', 'GROUP', 'OTHER'].each do |e|\n mask = '---'\n permissions_hash = document['PERMISSIONS']\n mask[0] = 'u' if permissions_hash[\"#{e}_U\"] == '1'\n mask[1] = 'm' if permissions_hash[\"#{e}_M\"] == '1'\n mask[2] = 'a' if permissions_hash[\"#{e}_A\"] == '1'\n\n puts Kernel.format str, e, mask\n end\n\n puts\n\n CLIHelper.print_header(str_h1 % 'TEMPLATE CONTENTS', false)\n puts JSON.pretty_generate(template)\n\n 0\n end\n end\n end",
"def print_user_badges(user_data)\n puts \"-\" * 70\n puts \"Badge Name\".ljust(60) + \"Date\".ljust(10)\n puts \"-\" * 70\n\n # loop through all badges and format the date into something readable\n user_data[\"badges\"].each do |badge|\n puts badge[\"name\"].slice(0, 60).ljust(60) + badge[\"earned_date\"].slice(0, 10).split(\"-\").join(\"/\").ljust(10)\n end\n\n puts \"-\" * 70\nend",
"def format_response(operation_results)\n {\n \"results\" => operation_results\n }\n end",
"def to_s\n \"#{@title}\\n#{@date.to_s}\\n\\n#{@body}\"\n end",
"def format(content)\n content\n end",
"def get_full_name\n # [Steve, 20140725] Too long/repetitive: \"#{description} #{header_year} - #{get_federation_type}\"\n description\n end",
"def header article\r\n\t\t\"{ \\\"HS\\\":{\"\r\n\tend",
"def to_s\n \"#{book.title} of #{book.author} when #{order_date}\"\n end",
"def details\n\t\"#{assigned_to} - #{status} - #{start_date} - #{description} - #{location} - #{Client.find(client_id).name}\"\nend",
"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 reply_calendar_contents\n \"BEGIN:VCALENDAR\nPRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN\nCALSCALE:GREGORIAN\nVERSION:2.0\nMETHOD:REPLY\nBEGIN:VTIMEZONE\nTZID;X-RICAL-TZSOURCE=TZINFO:America/Argentina/Buenos_Aires\nBEGIN:STANDARD\nDTSTART:20090314T230000\nRDATE:20090314T230000\nTZOFFSETFROM:-0200\nTZOFFSETTO:-0300\nTZNAME:ART\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nCREATED;VALUE=DATE-TIME:20091217T155557Z\nDTEND;TZID=America/Argentina/Buenos_Aires;VALUE=DATE-TIME:20091227T010000\nSTATUS:CONFIRMED\nLAST-MODIFIED;TZID=America/Argentina/Buenos_Aires;VALUE=DATE-TIME:2009121\n 7T173400\nDTSTART;TZID=America/Argentina/Buenos_Aires;VALUE=DATE-TIME:20091227T0000\n 00\nATTENDEE;CN=PoketyPoke;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:barbarazopp\n o@gmail.com\nUID:1693CA3B-C528-4E5A-87FB-CDFAEC0EC662\nORGANIZER:mailto:nasif.lucas@gmail.com\nDESCRIPTION:\nSUMMARY:testing.. Event\nSEQUENCE:3\nLOCATION:\nEND:VEVENT\nEND:VCALENDAR\".strip\nend",
"def format_result(result)\n result\n end",
"def user_returned_date\n (updated_at).strftime(\"%d/%m/%Y\")\n end",
"def api_date; utc.strftime(API_TIME_FORMAT); end",
"def details\n format_description(@description, 25) + \"event dates: \" + format_date(@start_date,@end_date)\n end",
"def parse_result(result)\n genus = nil\n spec = nil\n infra_sp = nil\n infra_g = nil\n authorships = []\n uni = nil\n attributes = {}\n warns = nil\n quality = 0\n norm = nil\n if result.key?('details')\n result['details'].each do |hash|\n hash.each do |k, v|\n next if v.nil? # specific_epithet seems to do this occassionally and I don't know why. :|\n k = k.underscore.downcase # Looks like the format changed from this_style to thisStyle; change it back!\n next if k == 'annotation_identification'\n next if k == 'ignored'\n if k == 'infraspecific_epithets'\n attributes['infraspecific_epithet'] = v.map { |i| i['value'] }.join(' ; ')\n v.each do |i|\n add_authorship(authorships, i)\n end\n else\n begin\n attributes[k] = v['value']\n rescue => e\n @process.warn(\"ERROR: no '#{k}' value for attributes: #{v.inspect}\")\n raise e\n end\n add_authorship(authorships, v)\n end\n end\n end\n end\n if result.key?('canonicalName')\n canonical = result['canonicalName']\n canon =\n if canonical.is_a?(String)\n canonical\n elsif canonical.is_a?(Hash)\n if canonical.key?('valueRanked')\n canonical['valueRanked']\n elsif canonical.key?('value')\n canonical['value']\n elsif canonical.key?('extended')\n canonical['extended']\n elsif canonical.key?('simple')\n canonical['simple']\n elsif canonical.key?('full')\n canonical['full']\n end\n end\n end\n if result['parsed']\n warns = if result.key?('qualityWarnings')\n result['qualityWarnings'].map { |a| a[1] }.join('; ')\n end\n quality = result['quality'] ? result['quality'].to_i : 0\n norm = result['normalized'] ? result['normalized'] : nil\n else\n warns = 'UNPARSED'\n quality = 0\n canon = result['verbatim']\n end\n norm = result['verbatim'] if norm.blank?\n if norm.size > 250\n norm = canon\n authorships.each do |authorship|\n norm += \" #{authorship[:first]}, et. al\"\n norm += \" #{authorship[:year]}\" if authorship[:year]\n end\n norm = norm[0..249] if norm.size > 250 # Forced to simply truncate it if we couldn't parse it.\n end\n norm = result['verbatim'] if norm.blank?\n\n attributes.merge(\n normalized: norm,\n canonical: canon,\n authorship: authorships.flat_map { |a| a[:authors].blank? ? [] : a[:authors].map { |n| n&.tr(';', '|') } }.join('; '),\n warnings: warns,\n parse_quality: quality,\n year: authorships.map { |a| a[:year] }.compact.sort.first # Yeeesh! We take the earliest year (we only get one!)\n )\n end",
"def reviewers\n \"Here's the current list of JOSS reviewers: https://github.com/openjournals/joss/blob/master/docs/reviewers.csv\"\nend",
"def formatted_body\n\t\tcase self.text\n\t\t\twhen \"space_created\"\n\t\t\t\treturn \"Space created, \\'#{self.reference.name}\\'\"\n\t\t\twhen \"discussion_created\"\n\t\t\t\treturn self.reference.body\n\t\t\twhen \"comment_created\"\n\t\t\t\treturn self.reference.body\n\t\tend\t\t\n\tend",
"def to_s\n \"#{self.title} - #{self.author} - #{self.date}\"\n end",
"def to_s\n\t\tres = \"\\nname: \" + name.to_s + \"\\nid: \" + id.to_s + \"\\nservice: \" + service.to_s + \"\\ntitle: \" + title.to_s + \"\\nthumbnail: \" + thumbnail.to_s + \"\\nhref: \" + href.to_s\n\t\tres\n\tend",
"def author\n quote_of_the_day[second_to_last_index(quote_of_the_day, \"~\")..quote_of_the_day.rindex(\"~\")].gsub(/(\\A~\\s*|\\s*~\\z)/, \"\")\n end",
"def format_repsonse( result, error, id )\n\t\tquote = '\"'\n\t\t\t'{ \"result\" : ' + result.to_json + \n\t\t\t\t', \"error\":\"' + error.to_s + \n\t\t\t\t'\", \"id\": ' + quote + id.to_s + quote + ' }'\n\t\tend",
"def format(tweet)\n if tweet.text.match(/@partyprinter tubestatus/)\n Tubestatus\n elsif tweet.text.match(/@partyprinter bardscene.*/)\n Bardscene\n else\n Tweet\n end\n \n end",
"def serialize\n {\n title: amendment.title,\n body: amendment.body,\n author: coauthorship_user&.name\n }\n end",
"def formatter; end",
"def formatter; end",
"def formatter; end",
"def format_success_response_data(data)\n if data.present? && @api_response_formatter_class.present?\n format_obj = @api_response_formatter_class.new(data)\n format_obj.perform\n {'formatted_response' => format_obj, 'raw_data' => data}\n else\n data\n end\n end",
"def format_result(result)\n result\n end",
"def email_update_header\n col = 18\n hdr = \"------------------------------------------------------------------------\\n\" +\n 'Design : '.rjust(col) + self.oi_instruction.design.directory_name + \"\\n\" +\n 'Category : '.rjust(col) + self.oi_instruction.oi_category_section.oi_category.name + \"\\n\" +\n 'Step : '.rjust(col) + self.oi_instruction.oi_category_section.name + \"\\n\" +\n 'Team Lead : '.rjust(col) + self.oi_instruction.user.name + \"\\n\" +\n 'Designer : '.rjust(col) + self.user.name + \"\\n\" +\n 'Date Assigned : '.rjust(col) + self.created_on.format_dd_mon_yy('timestamp') + \"\\n\" +\n 'Complete : '.rjust(col)\n if self.complete?\n hdr += \"Yes\\n\" +\n 'Completed On : '.rjust(col) + self.completed_on.format_dd_mon_yy('timestamp') + \"\\n\"\n else\n hdr += \"No\\n\"\n end\n\n if self.oi_instruction.oi_category_section.urls.size > 0\n label = true\n self.oi_instruction.oi_category_section.urls.each do |url|\n \n if label\n hdr += 'References : '.rjust(col)\n label = false\n else\n hdr += ' : '.rjust(col)\n end\n \n if url[:text] != ''\n hdr += url[:text] + \"\\n\" + ' : '.rjust(col) + url[:url] + \"\\n\"\n else\n hdr += url[:url] + \"\\n\"\n end\n \n end\n end\n\n hdr += \"------------------------------------------------------------------------\\n\"\n\n \n hdr\n \n end",
"def format_text(result)\n final_names = \"\"\n counter = 0\n result.each_with_index do |names, counter|\n if counter < result.length - 1\n final_names += \"#{names[0]} #{names[1]}, \"\n else\n final_names += \"#{names[0]} #{names[1]}\"\n end\n end\n if result.length == 1\n birthday_phrase = \"A jeKnowledge deseja um feliz aniverário a: #{final_names} continua o óptimo trabalho!\"\n else\n birthday_phrase = \"A jeKnowledge deseja um feliz aniversário a: #{final_names} continuem o óptimo trabalho!\"\n end\n end",
"def format_data(data, private_allowed)\n # Store all formatted data in this array\n formatted_data = []\n\n # Format name with flags\n # Name Mark Diez (student, employee, staff)\n # IAM ID 1234566\n if !data[\"basic_info\"].empty?\n data[\"basic_info\"].each do |info|\n name = \"*Name* \" + info[\"dFullName\"]\n\n flags = []\n if info[\"isEmployee\"]\n flags.push \"employee\"\n end\n if info[\"isHSEmployee\"]\n flags.push \"hs employee\"\n end\n if info[\"isFaculty\"]\n flags.push \"faculty\"\n end\n if info[\"isStudent\"]\n flags.push \"student\"\n end\n if info[\"isStaff\"]\n flags.push \"staff\"\n end\n if info[\"isExternal\"]\n flags.push \"external\"\n end\n flags = \" _(\" + flags.join(\", \") + \")_\"\n name += flags\n\n formatted_data.push name\n formatted_data.push \"*IAM ID* #{info[\"iamId\"]}\"\n if private_allowed\n formatted_data.push \"*Student ID* #{info[\"studentId\"]}\" unless info[\"studentId\"] == nil\n formatted_data.push \"*PPS ID* #{info[\"ppsId\"]}\" unless info[\"ppsId\"] == nil\n end\n end\n end\n\n # Format Kerberos information\n # Login ID msdiez, anotherid, ...\n if !data[\"kerberos_info\"].empty?\n ids = []\n data[\"kerberos_info\"].each do |info|\n id = info[\"userId\"] == nil ? \"Not Listed\" : info[\"userId\"]\n ids.push id\n end\n\n formatted_data.push \"*Login ID* \" + ids.join(\", \")\n else\n login_id = \"*Login ID* Not Listed\"\n formatted_data.push login_id\n end\n\n\n # Format contact information\n # E-mail my@email.com, my@otheremail.com\n # Office kerr 186, social science 133, ...\n if !data[\"contact_info\"].empty?\n email = []\n office = []\n data[\"contact_info\"].each do |info|\n email.push info[\"email\"] unless info[\"email\"] == nil\n office.push info[\"addrStreet\"] unless info[\"addrStreet\"] == nil\n end\n formatted_data.push \"*E-mail* \" + email.join(\", \")\n formatted_data.push \"*Office* \" + office.join(\", \")\n else\n formatted_data.push \"*E-mail* Not Listed\"\n formatted_data.push \"*Office* Not Listed\"\n end\n\n # Format ODR information\n # ODR Affiliation DSSIT: STD4 (Casual)\n require 'pp'\n pp data\n if !data['odr_info'].empty?\n data['odr_info'].each do |info|\n odr = '*ODR Affiliation* '\n odr += info['deptDisplayName'] + ': ' unless info['deptDisplayName'].nil?\n odr += info['titleDisplayName'] unless info['titleDisplayName'].nil?\n\n formatted_data.push odr\n end\n end\n\n # Format PPS information\n # PPS Affiliation DSSIT: STD4\n if !data['pps_info'].empty?\n data['pps_info'].each do |info|\n dept_name = info['deptDisplayName'] || 'Unknown Department'\n dept_code = info['deptCode'] || 'Unknown Department Code'\n title_name = info['titleDisplayName'] || 'Unknown Title'\n title_code = info['titleCode'] || 'Unknown Title Code'\n position_type = info['positionType'] || 'Unknown Position Type'\n employee_class = info['emplClassDesc'] || 'Unknown Employee Class'\n\n formatted_data.push \"*PPS Affiliation*\"\n formatted_data.push \" Department: #{dept_name} (#{dept_code})\"\n formatted_data.push \" Title: #{title_name} (#{title_code}) (#{position_type})\"\n formatted_data.push \" Employee Class: #{employee_class}\"\n end\n end\n\n # Format student information\n # Student Affiliation Computer Science (Undergraduate, Junior)\n if !data['student_info'].empty?\n data['student_info'].each do |info|\n student = '*Student Affiliation* '\n student += info['majorName'] + ' ('\n student += info['levelName'].scan(/\\S+/)[0] # Only grab the first word\n student += ', ' + info['className'] + ')'\n\n formatted_data.push student\n end\n end\n\n return formatted_data.join(\"\\n\")\n end",
"def created_by\r\n\t\t\t \t\"Lachezar Kostov and Dimitar Bakardzhiev\"\r\n\t\t end",
"def format!; end",
"def render_booklet(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n end\n r += p.title.detex.titlecase + \". \"\n r += text_for_field(\"Howpublished\", p, :postfix => \", \")\n r += text_for_field(\"Address\", p, :postfix => \", \")\n r += month_for_field(\"Month\", p, :postfix => \" \")\n r += text_for_field(\"Year\", p, :prefix => \" \", :postfix => \". \")\n r += text_for_field(\"Note\", p, :prefix => \" \", :postfix => \". \").detex\n return r\nend",
"def add_cited_by_response(result, request)\n # While scopus provides an \"inwardurl\" in the results, this just takes\n # us to the record detail page. We actually want to go RIGHT to the\n # list of cited-by items. So we create our own, based on Scopus's\n # reversed engineered predictable URLs. \n\n count = result[\"citedbycount\"]\n label = ServiceTypeValue[:cited_by].display_name_pluralize.downcase.capitalize \n if count && count == 1\n label = ServiceTypeValue[:cited_by].display_name.downcase.capitalize\n end\n cited_by_url = cited_by_url( result )\n \n request.add_service_response(:service=>self, \n :display_text => \"#{count} #{label}\", \n :count=> count, \n :url => cited_by_url, \n :service_type_value => :cited_by)\n\n end",
"def format_conversion\n { account_id: self.account_id.to_s, app_id: self.app_id.to_s, actor_id: self.actor_id.to_s, properties: self.properties, time: self.updated_at}\n rescue => e\n Rails.logger.error(\"**** ERROR **** #{e.message}\")\n {}\n end",
"def formats\n format\n end",
"def created_by\r\n\t\t\treturn \"Laura OMalley\"\r\n\t\tend",
"def generic_Generate_Response(initial,headers,body)\n\ts=initial\n\ts << \"\\r\\n\" << headers # headers start in second line\n\tif body.length>0\n\t\ts << \"\\r\\n\" << body # body start after a blank line, first \\r\\n is for change line from headers, second is for blank line\n\tend\n\treturn s\nend",
"def formatAuthName(auth)\n str = \"\"\n if auth.at(\"lname\") && auth.at(\"fname\")\n str = auth.at(\"lname\").text.strip + \", \" + auth.at(\"fname\").text.strip\n auth.at(\"mname\") and str += \" \" + auth.at(\"mname\").text.strip\n auth.at(\"suffix\") and str += \", \" + auth.at(\"suffix\").text.strip\n elsif auth.at(\"fname\")\n str = auth.at(\"fname\").text\n elsif auth.at(\"lname\")\n str = auth.at(\"lname\").text\n else\n puts \"Warning: can't figure out author #{auth}\"\n str = auth.text\n end\n return str\nend",
"def print_header\n \"#{\"Sl.\"} #{\"Description\".ljust(20)} #{\"Created time\".ljust(10)} #{\"Due by\".ljust(10)} #{\"Status\"}\"\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def format\n @format\n end",
"def pretty\n out = ''\n\n self.each do |line|\n out << line.line + ' : ' + line.commit + \"\\n\"\n out << ' ' + line.summary + \"\\n\"\n out << \" author:\\n\"\n out << ' ' + line.author + \"\\n\"\n out << ' ' + line.author_email + \"\\n\"\n out << ' @ ' + line.author_timestamp + \"\\n\"\n out << ' ' + line.author_timezone + \"\\n\"\n out << \"\\n\"\n out << \" committer:\\n\"\n out << ' ' + line.committer + \"\\n\"\n out << ' ' + line.committer_email + \"\\n\"\n out << ' @ ' + line.committer_timestamp + \"\\n\"\n out << ' ' + line.committer_timezone + \"\\n\"\n out << \"\\n\"\n end\n\n out\n end"
] | [
"0.66949934",
"0.6087984",
"0.6036213",
"0.603541",
"0.59979963",
"0.5923853",
"0.5872426",
"0.5838555",
"0.5817929",
"0.5817929",
"0.5706972",
"0.5640516",
"0.55819917",
"0.5543374",
"0.54951483",
"0.54870194",
"0.5483332",
"0.54500383",
"0.54500383",
"0.5435443",
"0.54294276",
"0.5417295",
"0.54067767",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5399134",
"0.5395919",
"0.53884035",
"0.53806865",
"0.5366083",
"0.5356523",
"0.53426564",
"0.5330312",
"0.5323846",
"0.5322606",
"0.53106",
"0.5301844",
"0.5300248",
"0.52745974",
"0.5264214",
"0.5260558",
"0.5235667",
"0.5228637",
"0.5222785",
"0.52047896",
"0.51981",
"0.5197572",
"0.51926553",
"0.51906246",
"0.5188114",
"0.5186531",
"0.51534164",
"0.51521754",
"0.5141075",
"0.51384825",
"0.51378256",
"0.5132421",
"0.5129935",
"0.5119166",
"0.51153815",
"0.511318",
"0.5105413",
"0.5097641",
"0.50971013",
"0.50947833",
"0.5092097",
"0.508696",
"0.5085364",
"0.50801826",
"0.50786865",
"0.5074579",
"0.5073225",
"0.50730234",
"0.506439",
"0.5059199",
"0.5044223",
"0.5044223",
"0.5044223",
"0.5038613",
"0.5037262",
"0.5035556",
"0.5029965",
"0.502276",
"0.5020114",
"0.50090134",
"0.5006924",
"0.4998541",
"0.499847",
"0.4990859",
"0.4989661",
"0.49831352",
"0.49814463",
"0.49805644",
"0.49782988",
"0.4976077",
"0.49717194"
] | 0.0 | -1 |
Retrieves cards that are in both deck and collection where deck qty != collection qty | def quantity_diff_query(coll_id, tracked_deck_id)
Card.joins(:external_deck_instances).joins(:collection_card_instances)
.where("collection_id = ? and external_deck_id = ? and
external_deck_instances.quantity !=
collection_card_instances.quantity and
collection_card_instances.quantity = 1",
coll_id, tracked_deck_id
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deck_not_collection_query(coll_id, tracked_deck_id)\n\t\tcards_in_collection = Card.joins(:collection_card_instances)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.where(\"collection_id = ?\", coll_id)\n\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t.select(\"cards.id\").to_sql\n\t\tCard.joins(:external_deck_instances)\n\t\t\t\t.where(\"external_deck_id = ? and\n\t\t\t\t\t\t\t\tcards.id NOT IN (#{cards_in_collection})\", tracked_deck_id\n\t\t\t\t\t\t\t)\n\tend",
"def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end",
"def unique_collection_card\n !!!Collection.find_by(\n card_id: self.card_id,\n user_id: self.user_id,\n magic_set_id: self.magic_set_id,\n premium: self.premium,\n wishlist: self.wishlist,\n condition: self.condition\n )\n end",
"def collection_quantity(collection, card)\n return false unless collection && card\n\n if in_collection?(collection, card)\n collection.collected_cards.find_by(card_id: card.id)\n end\n end",
"def filter_cards(cards)\n cards = Array(cards) unless cards.respond_to?(:count) \n return cards.select { |card| Card.get(card.id).nil? } #TODO: move this to method\n end",
"def trump_cards\n @cards.select {|c| c.suit == @trump_suit}\n end",
"def available_cards(correct_card_ids)\n # Exclude cards that have already been successfully answered\n self.cards.reject do |card|\n puts \"correct_card_ids = #{correct_card_ids}\"\n correct_card_ids.include?(card.id)\n end\n end",
"def recipe_cards\n RecipeCard.all.select {|recipe_card| recipe_card.recipe == self}\n end",
"def subtractSet(chosenCards)\n @cardsOnTable.each { |c|\n if c = chosenCards[0]\n @cardsOnTable.delete_at(0)\n elsif c = chosencards[1]\n @cardsOnTable.delete_at(1)\n elsif c = chosenCards[2]\n @cardsOnTable.delete_at(2)\n end\n }\n end",
"def cards_in_deck\n Card.where(game_id: @game.id, owner: 0).size\n end",
"def candies\n # all_candies = Candy.all\n Candy.all.select do |candy|\n candy.bucket == self && candy.name.downcase != \"penny\"\n end\n\n # my_candies.reject do |candy|\n # candy.name.downcase == \"penny\"\n # end\n end",
"def retrieve_cards(category)\n self.unused_cards = Card.where(category: Category.find_by(name: category)).where.not(id: self.used_cards).pluck(:id).shuffle if self.unused_cards.empty?\n return [Card.find(self.unused_cards[0]), Card.find(self.unused_cards[1])]\n end",
"def cards_in_category(sel_category)\n @cards.select do |card|\n card.category == sel_category\n end\n end",
"def dust_needed(tracked_deck)\n\t\tdeck_not_collection_cards = deck_not_collection_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tquantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tdust_total(quantity_diff_cards) + dust_total(deck_not_collection_cards)\n\tend",
"def cards\n RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n end",
"def select_card(dck)\n # sample the deck array, returns a suit return the value obj and sample\n dck.sample.each_with_object({}) do |suit, obj|\n crd = suit[1].to_a.sample\n suit = suit[0]\n obj[suit] = { crd[0] => crd[1] }\n # remove card from deck\n dck = dck.each do |val|\n val.each do |k, v|\n if k == suit\n # mutate the deck\n v.reject! { |key, _| key == crd[0] }\n end\n end\n end\n end\nend",
"def my_recipe_cards\n RecipeCard.all.select do |recipecard|\n recipecard.recipe == self\n end\n end",
"def budget_cards(budget)\n budget.cards.uniq\n end",
"def what_decks\n\t\tb = Bridge.where(card_id:self.id)\n\t\tdeck_ids = []\n\t\tb.each do |bridge|\n\t\t\tdeck_ids.push(bridge.deck_id)\n\t\tend\n\t\tdeck_list = []\n\t\tdeck_ids.each do |id|\n\t\t\tdeck_list.push(Deck.find(id))\n\t\tend\n\t\treturn deck_list\n\tend",
"def recipe_cards\n RecipeCard.all.select { |recipe_card| recipe_card.user == self}\n end",
"def recipecards\n RecipeCard.all.select do | card |\n card.user == self\n end\n end",
"def ownedCards\n \tcus_owned_by_user = cards_users.where(is_shared: false)\n\n \t# Have a list of CardsUsers, but want a list of Owned Cards\n \towned_cards = []\n \tcus_owned_by_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\towned_cards.push(card)\n \tend\n \towned_cards\n end",
"def candidate_items\n sku_items.select {|i| i.paid_quantity > 0}\n end",
"def cards_in_category(category)\n # Accumulate cards that match the input category using\n @cards.find_all do |card|\n card.category == category\n end\n end",
"def faceup\n cards.find_all {|card| !(card.facedown?) }.sort\n end",
"def cards_by_suit\n @cards_by_suit ||= @cards.group_by(&:suit)\n end",
"def borrowable_items\n# items.where(\"borrower_id = 0\")\n Item.all.where(\"borrower_id = 0 and lender_id != :owner\", {owner: self.id})\n end",
"def get_boxes_used(quantity)\n boxes = []\n ticket_boxes.each do |ticket_box|\n historical_active = ticket_box.historical_box_active\n unless historical_active.available == 0\n if quantity > historical_active.available\n quantity -= historical_active.available\n boxes.push(ticket_box.id)\n elsif quantity <= historical_active.available\n boxes.push(ticket_box.id)\n return boxes\n end\n end\n end\n end",
"def find_basket_with_space\n basket_with_space = Basket.all.select { |b| b.apples.length < b.capacity }\nend",
"def remove_cards\n\t\t@cards.slice!(0,2)\n\tend",
"def filter_mutually_exclusive_discounts\n superset = Set.new\n discount_lines.each { |dl| superset |= dl.mutually_exclusive_with }\n superset.each do |x|\n mx = discount_lines.select { |dl| dl.mutually_exclusive_with.member?(x) }\n .sort_by(&:price_adjustment)\n # Keep the best.\n mx.shift\n # Delete the rest.\n mx.each { |dl| discount_lines.delete(dl) }\n end\n end",
"def sharedCards\n \tcus_shared_with_user = cards_users.where(user_id: self.id, is_shared: true)\n\n \t# Have a list of CardsUsers, but want a list of Shared Cards\n \tshared_cards = []\n \tcus_shared_with_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\tshared_cards.push(card)\n \tend\n \tshared_cards\n end",
"def test_cards_are_unique\n #build a fresh deck to test\n\t @testDeck = Card.find(:all)\n\t \n\t $i=0\n\t while $i < @testDeck.count do\n\t\t$k=0\n\t \twhile $k < @testDeck.count do\n\t\t\tif @testDeck[$i].value == @testDeck[$k].value && @testDeck[$i].suit == @testDeck[$k].suit && $i!=$k\n\t\t\t\tassert false, \"A double card has been found\"\n\t\t\telse\n\t\t\t\tassert true\n\t\t\tend #end if\n\t\t\t$k+=1\n\t\tend #end inner loop\n\t\t$i+=1\n\t end #end outer loop\n end",
"def disenchantGoldens\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1]\n\t\t\textras = card.removeAll\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def unplayed_cards\n player_cards.select { |c| c.unplayed? }\n end",
"def pop_cards(num_pops)\r\n #p @deck_todisp.size\r\n num_pops.times{|ix| @deck_todisp.pop}\r\n if @briscola and @card_briscola_todisp and @deck_todisp.size == 0\r\n #if @card_briscola_todisp and @realgame_num_cards == 0\r\n # no more cards on deck, pick the briscola\r\n @card_briscola_todisp.visible = false\r\n end\r\n #p @deck_todisp.size\r\n end",
"def recipe_cards \n RecipeCard.all.select do |recipe|\n recipe.user == self\n end \n end",
"def cards_left_to_collect\n card_ids = UserCard.select {|card| card[\"user_id\"] == self.id}\n remaining = Card.all.count - card_ids.map { |card| card[\"card_id\"] }.uniq.count\n if remaining == 0\n puts \"=====================================================================\"\n puts \"Congratulations, you have completed the Superhero card album!!\"\n puts \"=====================================================================\"\n else\n puts \"=====================================================================\"\n puts \"You still have #{remaining} cards left to collect...\"\n puts \"=====================================================================\"\n end\n end",
"def collision\n carts.each do |cart_a|\n carts.each do |cart_b| \n if cart_a.position == cart_b.position && cart_a != cart_b\n return [cart_a, cart_b]\n end\n end\n end\n\n nil\n end",
"def collisions\n results = []\n\n carts.each do |cart_a|\n carts.each do |cart_b| \n if cart_a.position == cart_b.position && cart_a != cart_b\n results << [cart_a, cart_b]\n end\n end\n end\n\n results\n end",
"def cards_in_category(category)\n # want to return an array of cards that only has :STEM category\n # run through array and check if ':STEM' matches the last\n # element in the array\n @cards.select {|card| card.category == category}\n end",
"def under_five(cart)\n\tcart.all? do |item|\n\t\titem.all? do |name, data|\n\t\t\tdata[:price] <= 5\n\t\tend\n\tend\nend",
"def discard(card)\n discard_pile << card\n end",
"def find_user_recipe_cards\n RecipeCard.all.map{|rcard| rcard if rcard.user_O == self}.compact\n\n end",
"def remove_card\n cards.shift\n return cards\n end",
"def get_cards(deck)\n\n end",
"def mustsee\n # must use this 2 steps becausesqlite doe snot support right joins or the join i needed\n seen = Critic.where([\"user_id = ?\",self.id]).select('movie_id').map{|m| m.movie_id}.join(',')\n Movie.where(\"id NOT IN (#{seen})\")\n end",
"def recipe_cards\n user_recipecards = RecipeCard.all.select do |recipecard|\n recipecard.user == self\n end\nend",
"def unique_cards(game_deck, faces, suits)\n faces.each do |face|\n suits.each do |suit|\n c = Card.new(face,suit)\n card_value_determiner(c)\n game_deck.deck << c\n end\n end\nend",
"def prune(items)\n wants = []\n # owners = []\n items.each do |item|\n # owners << item.user\n item.user.wants.each do |want|\n if want.possession.trade_id == self.id\n wants << want.possession\n end\n end\n end\n # wants = []\n # owners.each do |owner|\n # owner.wants.each do |want|\n # if want.possession.trade_id == self.id\n # wants << want.possession\n # end\n # end\n # end\n items.each do |item|\n if !wants.include?(item)\n items.delete(item)\n end\n end\n items\n end",
"def flush?\n cards_by_suit.any? {|_, v| v.count >= cards_needed}\n end",
"def relevant_itemsets\n frequent_itemsets.reject do |itemset|\n itemset[:items].intersection(files).empty? || itemset[:items].subset?(files)\n end\n end",
"def recipe_cards #return array of recipecards with this recipe\n RecipeCard.all.select do |card|\n card.recipe == self\n end\n #to test in pry, use instance ex. r1.recipe_cards\n end",
"def find_categories\n categories = @deck.cards.group_by do |card|\n card.category\n end\n categories.keys\n end",
"def get_relevant_drawings(args={})\n nums = args[:nums]\n bonus = args[:bonus]\n \n drawings = Drawing.find_by_game_nums_and_bonus(@game.id,nums,bonus)\n\n #strip out records with no prize\n drawings.reject{|d| !has_prize({bonus_match: d.has_bonus_match(bonus),matches: d.matches_count(nums), game_slug: @game.slug })}\n end",
"def test_adding_and_removing\n c = Cart.create\n assert_difference(c.cart_items, :size, 3) do\n [1, 3, 4].each do |i|\n assert c.add(i)\n end\n end\n \n assert_equal Book.find([1,3,4]), c.books\n \n [1, 3, 4].each do |i|\n assert c.remove(i)\n end\n assert_equal [], c.reload.cart_items\n end",
"def remove_card_row_cards\n card_row.each do |gc|\n gc.discard! if gc && gc.position < self.card_row_discard_size\n end\n end",
"def cards_by_rank(ranks)\n @cards.select { |card| ranks.include?(card.rank) }\n end",
"def consolidate_cart(cart)\n new_cart = []\ncart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item],new_cart)\n if current_item\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] == current_item[:item]\n new_cart_item[:count]+=1 \n end\n end\n else\n grocery_item[:count] = 1 \n new_cart << grocery_item\nend\nend\nnew_cart\nend",
"def flush\n my_hand.group_by(&:suit).select { |_, hand_of_suit| hand_of_suit.count == 5 }.values.flatten\n end",
"def collection_cards_by_row_and_col(rows:, cols:)\n table = CollectionCard.arel_table\n all_collection_cards.where(\n table[:row].gteq(rows[0])\n .and(\n table[:row].lteq(rows[1]),\n )\n .and(\n table[:col].gteq(cols[0]),\n )\n .and(\n table[:col].lteq(cols[1]),\n ),\n ).ordered_row_col\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def find_liked_not_already_in_owned_collections(user, options = {})\n subjoin = sprintf(\"%s lca JOIN %s c ON c.id = lca.collection_id AND c.user_id = %d\",\n ListingCollectionAttachment.quoted_table_name,\n Collection.quoted_table_name,\n user.id)\n # fetch at least 100 to try to get a good set of liked listings that aren't necessarily already in collections\n per = 100 if per.blank? || per < 100\n relation = Listing.liked_by(user, page: 1, per: per). # only considers visible listings\n joins(\"LEFT JOIN (#{subjoin}) ON #{quoted_table_name}.id = lca.listing_id\").\n where('lca.id IS NULL')\n [:per, :includes].each do |meth|\n relation = relation.send(meth, options[meth]) if options[meth]\n end\n relation\n end",
"def consolidate_cart(cart)\n index = 0\n new_cart = []\n \n cart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item], new_cart)\n if current_item\n new_cart_index = 0\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] === current_item[:item]\n new_cart_item[:count] += 1\n end\n new_cart_index += 1\n end\n else\n grocery_item[:count] = 1\n new_cart << grocery_item\n end\n index += 1\n end\n new_cart\nend",
"def find_same_rank_not_wild(givencard)\n result = []\n for card in @cards do\n if card.same_rank?(givencard) && (!card.wild?)\n result << card\n end \n end\n return result\n end",
"def high_ranking_cards\n\n cards.select do |card|\n card.rank >= 11\n end\n\n end",
"def remaining_cards\r\n @deck_of_cards.each do |card|\r\n card.output_card\r\n end\r\n end",
"def recipes\n RecipeCard.all.select do |recipe_card|\n recipe_card.recipe == self\n end\n end",
"def choose_card(pile)\n cards.find { |card| card.value != :eight && pile.valid_play?(card) } ||\n cards.find { |card| card.value == :eight }\n end",
"def duplicated_cards\n Cache.hash_get_all(\"#{@batch_id}_duplicated_cards\").presence || {}\n end",
"def comics_owned\n comics_array = self.comics.map do |comic|\n comic\n end\n comics_array.uniq\n end",
"def drawCards!(n)\n\t\treturn @cards.pop(n)\n end",
"def without_set_blocks(options)\n piece = options[:piece]\n game = options[:game]\n\n collection = clone\n collection.sets.map! { |set| set.without_blocks(piece: piece, game: game) }\n collection\n end",
"def find_unseen\n unseen.replace(full_deck)\n (my_hand + op_hand + my_lands.values +\n op_lands.values + discards.values).flatten.each do |c|\n i = unseen.index(c) or next\n unseen.delete_at(i)\n end\n end",
"def find_like_samples(collection_a, collection_b)\n collection_a.parts.map!(&:sample) & collection_b.parts.map!(&:sample)\n end",
"def products_not_used\n @products_not_used ||= object\n .products\n .select { |p| p.inventory_id == current_inventory.id && !p.used? }\n end",
"def test_reshuffle_discard_into_draw\n # drain the draw pile into the discard pile\n while !@manager.draw_pile.is_empty?\n @manager.discard_top_card\n end\n assert_equal([], @manager.draw_pile.cards)\n assert_not_equal([], @manager.discard_pile.cards)\n\n @manager.reshuffle_discard_into_draw\n\n # draw pile should have cards and discard pile should be empty again\n assert_equal([], @manager.discard_pile.cards)\n assert_not_equal([], @manager.draw_pile.cards)\n end",
"def check_items_balances\n details.select(&:marked_for_destruction?)\n .all?(&:valid_for_destruction?)\n end",
"def desk_cards\n desk = []\n self.public_deal.each do |i|\n desk.push(i)\n end\n self.hand_deal.each do |i|\n desk.push(i)\n end\n desk\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 cull_old_ids\n saved_ids = @ids.keys.reverse.take(@max_ids)\n @ids.select! do |k, v|\n saved_ids.include? k\n end\n end",
"def pile_cards\n players = [@player1, @player2]\n if type == :basic\n players.each do |player|\n @spoils_of_war << player.deck.cards[0]\n player.deck.remove_card\n end\n elsif type == :war\n players.each do |player|\n @spoils_of_war << player.deck.cards[0..2]\n 3.times do\n player.deck.remove_card\n end\n @spoils_of_war = @spoils_of_war.flatten\n end\n elsif type == :mutually_assured_destruction\n players.each do |player|\n 3.times do\n player.deck.remove_card\n end\n end\n # replace 'No Winner' with nil so it can be tested in award_spoils\n @turn_winner = nil\n end\n end",
"def poolplay_team_objects\n self.teams.select { |team| !team.playoffs }\n end",
"def same_or_dif? card_arr\n card_arr.uniq.size != 2\nend",
"def check_stock_qty(ids, qtys, requisition_qty)\n return false if ids.blank? or qtys.blank? or ids.size != qtys.size\n return false if requisition_qty != qtys.map{|x| x.to_i}.reduce(:+) #false if requisition qty and checkout qty NOT equal\n ids.each do |id| \n qtys.each do |qty|\n stock_item = RequisitionCheckoutx.warehouse_class.find_by_id(id.to_i)\n if stock_item.stock_qty < qty.to_i or qty.blank? or id.blank?\n return false\n end\n end\n end \n return true \n end",
"def course_selections_with_college_offers\n self.course_selections.where.not(college_offer: :rejected).order(:student_choice)\n end",
"def add_collected_query\n return if options[:collection_ids].present? || !collected?\n body.must(:query_string, \"collections.id\" => \"*\")\n end",
"def deal_cards(old_deck, num_cards)\n hand = old_deck.sample(num_cards)\n new_deck = old_deck - hand\n return [hand, new_deck]\nend",
"def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.select do |card|\n shoe << card\n end\n end\n shoe\nend",
"def opposing_deck\n data[\"opposing_deck\"]\n end",
"def get_multiples(number)\n cards = []\n\n @cards_by_score.each_key do |card|\n if @card_scores.count(card.score) == number\n cards << card\n end\n end\n\n cards\n\n end",
"def part1(clues, aunts)\n result = Array.new aunts\n clues.each do |clue|\n #filter aunts that do not match the key:value in clue\n key = clue.keys.first\n result.reject! {|a| a.has_key? key and clue[key] != a[key] }\n\n #puts \"Using #{key} as the filter, there are now #{aunts.length} remaining possibilities\"\n end\n result[0]\nend",
"def claimed(plyr_id = nil)\n cards.find_all {|card| card.claimed? && (plyr_id.nil? || (card.set.player == plyr_id.to_i)) }.sort\n end",
"def remove_invalid_decks\n @decks.select! do |deck|\n deck.is_a?(ZombieBattleground::Api::Models::Deck) &&\n deck.valid? &&\n deck.errors.size.zero?\n end\n end",
"def flush_cards(cards)\n\t\thsh = {}\n\t\tcards.each {|c| hsh[c.suit] ||= []; hsh[c.suit] << c}\n\t\tret = []\n\t\thsh.each {|suit, suit_cards| ret = suit_cards if suit_cards.size > ret.size}\n\t\tret.sort_by {|x| x.sort_value}\n\tend",
"def hit \n card = self.cards_deck.pop\n return card\n end",
"def fetchAllUsersByRejectedPurged(collection)\n query = Hash.new()\n query = {\n :$or => [\n {\n \"approval_status.code\" => -1\n },\n {\n \"approval_status.code\" => -2\n }\n ]\n } \n return collection.find(query)\n end",
"def call\n cube = []\n\n deck = Deck.find(context.deck_id)\n\n deck.card_decks.each do |card_deck|\n (1..card_deck.occurences_in_main_deck).each do\n cube.push(card_deck.card_id)\n end\n end\n\n tirages = []\n # reste = []\n\n while cube.length > 14\n tirage = cube.sample(15)\n tirage.each do |card_id|\n cube.delete_at(cube.find_index(card_id))\n end\n tirages.push(tirage)\n end\n context.tirages = tirages\n # reste = cube\n end",
"def items_seller(limit = 5)\n customer.items.all(conditions: \"id <> #{id}\", limit: limit)\n end",
"def get_high_cards(cards)\n @cards_by_score.each_key do |card|\n if cards.length < 5 && !cards.include?(card)\n cards << card\n end\n end\n end"
] | [
"0.68230206",
"0.5959882",
"0.58532596",
"0.5819215",
"0.55439067",
"0.5456701",
"0.54545224",
"0.53686583",
"0.5356306",
"0.53508294",
"0.534702",
"0.53214866",
"0.529456",
"0.5200646",
"0.52005833",
"0.5157011",
"0.51557565",
"0.51116216",
"0.5102882",
"0.5072869",
"0.50661635",
"0.5062135",
"0.504062",
"0.5027348",
"0.49964267",
"0.4993201",
"0.49914476",
"0.49643502",
"0.4944756",
"0.49361214",
"0.4929177",
"0.49269974",
"0.49091238",
"0.48992246",
"0.48941818",
"0.4892161",
"0.48755816",
"0.4874779",
"0.4862382",
"0.4862262",
"0.48595116",
"0.48534542",
"0.48414746",
"0.48360112",
"0.48285186",
"0.47901496",
"0.4783187",
"0.47681937",
"0.47653005",
"0.4756745",
"0.4742527",
"0.47393233",
"0.47318175",
"0.47303033",
"0.47299927",
"0.47224504",
"0.47080755",
"0.4705268",
"0.46923932",
"0.46852276",
"0.46809837",
"0.46638015",
"0.46596798",
"0.46587774",
"0.46535254",
"0.46512666",
"0.46483937",
"0.46378642",
"0.4636341",
"0.4625188",
"0.46190178",
"0.4608242",
"0.4605004",
"0.4602792",
"0.45982257",
"0.45971316",
"0.45955136",
"0.45939037",
"0.45915917",
"0.45843768",
"0.45819938",
"0.45691878",
"0.4560183",
"0.45600623",
"0.45567307",
"0.45548603",
"0.45514968",
"0.45503134",
"0.45458466",
"0.45439473",
"0.45390555",
"0.4538247",
"0.45372334",
"0.45360196",
"0.45344263",
"0.4524972",
"0.45188576",
"0.45160156",
"0.45157072",
"0.4510328"
] | 0.69170415 | 0 |
Retrieves cards that are in the deck but not collection | def deck_not_collection_query(coll_id, tracked_deck_id)
cards_in_collection = Card.joins(:collection_card_instances)
.where("collection_id = ?", coll_id)
.select("cards.id").to_sql
Card.joins(:external_deck_instances)
.where("external_deck_id = ? and
cards.id NOT IN (#{cards_in_collection})", tracked_deck_id
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end",
"def filter_cards(cards)\n cards = Array(cards) unless cards.respond_to?(:count) \n return cards.select { |card| Card.get(card.id).nil? } #TODO: move this to method\n end",
"def all_not_wild\n result = []\n for card in @cards\n result << card unless card.wild? \n end\n return result\n end",
"def unplayed_cards\n player_cards.select { |c| c.unplayed? }\n end",
"def available_cards(correct_card_ids)\n # Exclude cards that have already been successfully answered\n self.cards.reject do |card|\n puts \"correct_card_ids = #{correct_card_ids}\"\n correct_card_ids.include?(card.id)\n end\n end",
"def retrieve_cards(category)\n self.unused_cards = Card.where(category: Category.find_by(name: category)).where.not(id: self.used_cards).pluck(:id).shuffle if self.unused_cards.empty?\n return [Card.find(self.unused_cards[0]), Card.find(self.unused_cards[1])]\n end",
"def cards_in_deck\n Card.where(game_id: @game.id, owner: 0).size\n end",
"def get_cards(deck)\n\n end",
"def show\n cards = @deck.cards\n cards = cards.where(is_disabled: false)\n @cards = cards.shuffle\n end",
"def trump_cards\n @cards.select {|c| c.suit == @trump_suit}\n end",
"def ownedCards\n \tcus_owned_by_user = cards_users.where(is_shared: false)\n\n \t# Have a list of CardsUsers, but want a list of Owned Cards\n \towned_cards = []\n \tcus_owned_by_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\towned_cards.push(card)\n \tend\n \towned_cards\n end",
"def discard(card)\n discard_pile << card\n end",
"def has_lost?\n @deck.cards == []\n end",
"def reset_discard_pile(deck)\n @cards = []\n @cards << deck.take_card\n while @cards[0].color == 'Wild' || @cards[0].number.is_a?(String)\n deck.cards.unshift(@cards.pop)\n @cards << deck.take_card\n end\n @cards\n end",
"def remaining_cards\r\n @deck_of_cards.each do |card|\r\n card.output_card\r\n end\r\n end",
"def faceup\n cards.find_all {|card| !(card.facedown?) }.sort\n end",
"def find_unseen\n unseen.replace(full_deck)\n (my_hand + op_hand + my_lands.values +\n op_lands.values + discards.values).flatten.each do |c|\n i = unseen.index(c) or next\n unseen.delete_at(i)\n end\n end",
"def remove_cards\n\t\t@cards.slice!(0,2)\n\tend",
"def what_decks\n\t\tb = Bridge.where(card_id:self.id)\n\t\tdeck_ids = []\n\t\tb.each do |bridge|\n\t\t\tdeck_ids.push(bridge.deck_id)\n\t\tend\n\t\tdeck_list = []\n\t\tdeck_ids.each do |id|\n\t\t\tdeck_list.push(Deck.find(id))\n\t\tend\n\t\treturn deck_list\n\tend",
"def remove_invalid_decks\n @decks.select! do |deck|\n deck.is_a?(ZombieBattleground::Api::Models::Deck) &&\n deck.valid? &&\n deck.errors.size.zero?\n end\n end",
"def cards\n RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n end",
"def candies\n # all_candies = Candy.all\n Candy.all.select do |candy|\n candy.bucket == self && candy.name.downcase != \"penny\"\n end\n\n # my_candies.reject do |candy|\n # candy.name.downcase == \"penny\"\n # end\n end",
"def find_same_rank_not_wild(givencard)\n result = []\n for card in @cards do\n if card.same_rank?(givencard) && (!card.wild?)\n result << card\n end \n end\n return result\n end",
"def discard_card(player)\n if player.player_hand.size == 0\n return nil\n elsif player.player_hand.size == 1\n return player.player_hand.hand_to_list.first\n elsif player.player_hand.wildcards.size > 0\n wildcards = player.player_hand.wildcards\n rand_index = rand(wildcards.size)\n return wildcards.fetch(rand_index)\n else\n rand_index = rand(player.player_hand.size)\n return player.player_hand.hand_to_list.fetch(rand_index)\n end\n end",
"def lost?\n @deck.cards.length == 0\n end",
"def discard_card(player)\n if player.player_hand.size == 0\n return nil\n elsif player.player_hand.size == 1\n return player.player_hand.hand_to_list.first\n else\n rand_index = rand(player.player_hand.size)\n return player.player_hand.hand_to_list.fetch(rand_index)\n end\n end",
"def budget_cards(budget)\n budget.cards.uniq\n end",
"def disabled_categories(card)\n card_benefits = []\n card.benefits.each{|b| card_benefits << b.category}\n card_benefits & categories\n end",
"def check_discards_in_hand?(player, turn, done)\n expected_hand = expected_hand(player, turn)\n\n discard_list = done.discards.map{|squad|\n squad.list_of_cards\n }.flatten\n \n if !discard_list.all?{|card| expected_hand.include?(card)}\n raise Cheating, \"Player is discarding cards not in his/her hand!\"\n else\n true\n end\n end",
"def check_discards_removed_from_hand?(player, turn, done)\n played_cards = all_discards(done)\n\n player_hand = player.player_hand.hand_to_list\n\n played_cards.each{|card|\n if player_hand.include?(card)\n raise Cheating, \"Player is not discarding the cards he/she is playing!\"\n end\n }\n true\n end",
"def first_not_wild\n for card in @cards\n return card unless card.wild?\n end\n return nil\n end",
"def no_cards_image \n scryfall.card_code_number('sok', 84)['image_uris']['large']\n end",
"def remove_card\n cards.shift\n return cards\n end",
"def empty?\n cards.empty?\n end",
"def empty?\n self.cards.empty?\n end",
"def flush?(cards)\n suit = cards[0].suit\n cards.each do |card|\n return false if card.suit != suit\n end\n true\n end",
"def recipecards\n RecipeCard.all.select do | card |\n card.user == self\n end\n end",
"def empty?\n @cards.empty?\n end",
"def empty?\n @cards.empty?\n end",
"def claimed(plyr_id = nil)\n cards.find_all {|card| card.claimed? && (plyr_id.nil? || (card.set.player == plyr_id.to_i)) }.sort\n end",
"def my_recipe_cards\n RecipeCard.all.select do |recipecard|\n recipecard.recipe == self\n end\n end",
"def cards_by_suit\n @cards_by_suit ||= @cards.group_by(&:suit)\n end",
"def random_remaining_card\n correct_guesses_array = self.guesses.where(correctness: true)\n correct_guess_id_array = correct_guesses_array.map do |guess|\n guess.card_id\n end\n if correct_guess_id_array == []\n cards = self.deck.cards\n else\n cards = self.deck.cards.where('id not in (?)', correct_guess_id_array)\n end\n cards.sample\n end",
"def all_discards(done)\n discard_list = done.discards.map{|squad|\n squad.list_of_cards\n }.flatten\n \n fighter_list = done.attacks.map{|attack|\n attack.fighter.list_of_cards\n }.flatten\n\n bomber_list = done.attacks.map{|attack|\n attack.bomber.list_of_cards\n }.flatten\n \n played_cards = discard_list + fighter_list + bomber_list + [done.card]\n played_cards.sort\n end",
"def get_card\n all_cards = self.deck.cards\n correct_cards = self.guesses.where(correct: true).map { |guess| guess.card }\n (all_cards - correct_cards).shuffle.sample\n end",
"def recipe_cards\n RecipeCard.all.select {|recipe_card| recipe_card.recipe == self}\n end",
"def cards(options = { :filter => :open })\n return @cards if @cards\n @cards = Client.get(\"/boards/#{id}/cards\").json_into(Card)\n end",
"def recipe_cards\n RecipeCard.all.select { |recipe_card| recipe_card.user == self}\n end",
"def find_categories\n categories = @deck.cards.group_by do |card|\n card.category\n end\n categories.keys\n end",
"def opposing_deck\n data[\"opposing_deck\"]\n end",
"def discardable\n []\n end",
"def hit(deck)\n rand_card = deck.sample # pulls a random card from the playing deck.\n deck.delete(rand_card)\nend",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def get_card\n @deck.pop\n end",
"def pop_cards(num_pops)\r\n #p @deck_todisp.size\r\n num_pops.times{|ix| @deck_todisp.pop}\r\n if @briscola and @card_briscola_todisp and @deck_todisp.size == 0\r\n #if @card_briscola_todisp and @realgame_num_cards == 0\r\n # no more cards on deck, pick the briscola\r\n @card_briscola_todisp.visible = false\r\n end\r\n #p @deck_todisp.size\r\n end",
"def unique_collection_card\n !!!Collection.find_by(\n card_id: self.card_id,\n user_id: self.user_id,\n magic_set_id: self.magic_set_id,\n premium: self.premium,\n wishlist: self.wishlist,\n condition: self.condition\n )\n end",
"def cards_left_to_collect\n card_ids = UserCard.select {|card| card[\"user_id\"] == self.id}\n remaining = Card.all.count - card_ids.map { |card| card[\"card_id\"] }.uniq.count\n if remaining == 0\n puts \"=====================================================================\"\n puts \"Congratulations, you have completed the Superhero card album!!\"\n puts \"=====================================================================\"\n else\n puts \"=====================================================================\"\n puts \"You still have #{remaining} cards left to collect...\"\n puts \"=====================================================================\"\n end\n end",
"def get_categories\n @cards.each do |card|\n if !@categories.include?(card.category)\n @categories << card.category\n end\n end\n @categories\n end",
"def sharedCards\n \tcus_shared_with_user = cards_users.where(user_id: self.id, is_shared: true)\n\n \t# Have a list of CardsUsers, but want a list of Shared Cards\n \tshared_cards = []\n \tcus_shared_with_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\tshared_cards.push(card)\n \tend\n \tshared_cards\n end",
"def index\n @cards = @deck.cards.all\n end",
"def createDeck\n deck = []\n for suit in @@cardSuits\n for symbol in @@symbolVals.keys\n if symbol != \"AA\"\n deck << Card.new(symbol, suit)\n end\n end\n end\n\n return deck\n end",
"def choose_cards(turn, player)\n if turn.turn_card_on_deck?\n rand_num = rand(2)\n list_of_cards = case\n when rand_num == 0: Array.new.push(turn.turn_get_a_card_from_deck)\n when rand_num == 1: turn.turn_get_cards_from_stack(1)\n end\n else\n list_of_cards = turn.turn_get_cards_from_stack(1)\n end\n list_of_cards.concat(turn.turn_get_cards_from_stack(1))\n end",
"def played_cards\n player_cards.select { |c| c.played? }\n end",
"def all_treasure_cards\n treasure_cards = []\n cards.each do |c|\n if c.cardmapping.is_treasure == true \n treasure_cards << c \n end\n end\n return treasure_cards\n end",
"def without_individual_blocks(options)\n piece = options[:piece]\n game = options[:game]\n board = game.board\n\n collection = clone\n\n collection.coordinates.reject! do |coordinate|\n at_position = board.at_square(coordinate.square_name) \n piece.ally?(at_position) \n end\n\n collection\n end",
"def flush_cards(cards)\n\t\thsh = {}\n\t\tcards.each {|c| hsh[c.suit] ||= []; hsh[c.suit] << c}\n\t\tret = []\n\t\thsh.each {|suit, suit_cards| ret = suit_cards if suit_cards.size > ret.size}\n\t\tret.sort_by {|x| x.sort_value}\n\tend",
"def desk_cards\n desk = []\n self.public_deal.each do |i|\n desk.push(i)\n end\n self.hand_deal.each do |i|\n desk.push(i)\n end\n desk\n end",
"def cards_in_category(sel_category)\n @cards.select do |card|\n card.category == sel_category\n end\n end",
"def duplicated_cards\n Cache.hash_get_all(\"#{@batch_id}_duplicated_cards\").presence || {}\n end",
"def select_card(dck)\n # sample the deck array, returns a suit return the value obj and sample\n dck.sample.each_with_object({}) do |suit, obj|\n crd = suit[1].to_a.sample\n suit = suit[0]\n obj[suit] = { crd[0] => crd[1] }\n # remove card from deck\n dck = dck.each do |val|\n val.each do |k, v|\n if k == suit\n # mutate the deck\n v.reject! { |key, _| key == crd[0] }\n end\n end\n end\n end\nend",
"def return *hands\n hands.each do |hand_or_cards|\n cards = (hand_or_cards.is_a?(CardDecks::Hand) ? hand_or_cards.cards : Array.wrap(hand_or_cards))\n @used += cards\n @inhand.delete_if {|c| cards.include?(c) }\n @hands.each {|h| h.cards.delete_if {|c| cards.include?(c) } }\n end\n end",
"def index\n @deck_of_cards = DeckOfCard.all\n end",
"def getCardById(deck,id)\n deck.each do |card|\n return card if card.id == id\n end\n return nil\nend",
"def remove_card_row_cards\n card_row.each do |gc|\n gc.discard! if gc && gc.position < self.card_row_discard_size\n end\n end",
"def find_user_recipe_cards\n RecipeCard.all.map{|rcard| rcard if rcard.user_O == self}.compact\n\n end",
"def empty\n @cards.shift(@cards.size)\n end",
"def drawCards!(n)\n\t\treturn @cards.pop(n)\n end",
"def without_wildcards\n @without_wildcards ||= cards.reject { |card| card == '*' }\n end",
"def hit \n card = self.cards_deck.pop\n return card\n end",
"def readied_cards\n if readyable?\n cards.readied\n else\n cards\n end\n end",
"def get_deck\r\n session[:deck] || Deck.new(:title => \"untitled deck\")\r\n end",
"def index\n @cards = @deck.cards\n end",
"def cards\n @cards\n end",
"def cards_in_category(category)\n # want to return an array of cards that only has :STEM category\n # run through array and check if ':STEM' matches the last\n # element in the array\n @cards.select {|card| card.category == category}\n end",
"def uncaptured_pieces(player_color)\n pieces.includes(:game).where('color = ? and captured = false', player_color).to_a\n end",
"def busted?(cards)\n\nend",
"def get_rounds_cards\n # get all the cards from this round's deck\n @cards = self.deck.cards\n end",
"def full_deck\n Game::LANDS.collect do |land|\n (['Inv'] * 3 + (2 .. 10).to_a).collect do |value|\n Game::Card.new(value, land)\n end\n end.flatten\n end",
"def return_cards\n @hand = []\n end",
"def pull(card)\n card = self.cards.delete(card)\n raise \"Cannot find card. May already have been dealt\" unless card\n return card\n end",
"def remaining_candidates\n @candidate_deck - candidates\n end",
"def recipe_cards \n RecipeCard.all.select do |recipe|\n recipe.user == self\n end \n end",
"def uses_deck?\n uses_deck\n end",
"def flip_deck\n if @deck.empty?\n if @recycle_count < @recycle_limit\n @deck = @discard.reverse.collect {|c| c.flip}\n @discard = CardArray.new\n @recycle_count += 1\n else\n nil\n end\n else\n @discard.push @deck.pop\n end\n @discard.first.flip\n end",
"def find_deck\n\t\tcurrent_user.decks.find(params[:deck_id])\n\t\t#Deck.find(params[:deck_id])\n\tend",
"def discard\n\n # organize hand into sorted array of cards\n #### METHOD\n\n puts \"here is your hand #{hand}\"\n\n puts 'what cards? you can only discard 3.'\n\n #the player returns [2,3]\n ##### METHOD\n\n # find hand[2], hand[3] and remove from hand\n ##### METHOD\n\n # hand currently has 3 cards\n\n # hand << deck.deal(2)\n\n #RETURNS new hand\n\n\n #....player1.hand = the new hand\n end",
"def flush?\n cards_by_suit.any? {|_, v| v.count >= cards_needed}\n end",
"def not_losers\n players.reject { |p| p.hand.overkill? }\n end",
"def has_lost?\n return false if @deck.cards.length != 0\n true\n end",
"def deal_cards(deck, playing_cards)\n return if deck.length == 0\n\n #initializing deck.\n if playing_cards.length == 0\n for count in 0...12\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n return\n end\n\n if (valid_table(playing_cards)).length == 0\n #continually adds cards until there is a set or there are no more cards.\n while ((valid_table(playing_cards)).length == 0) && deck.length > 0\n #print(\"\\n Empty: #{(valid_table(playingCards)).length == 0} \\n\")\n for count in 0...3\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n end\n elsif playing_cards.length < 12\n # Adds cards if there is a set but less than 12 playing cards.\n for count in 0...3\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n\n end\n\nend"
] | [
"0.7606907",
"0.71900344",
"0.70573133",
"0.69579625",
"0.6838108",
"0.65207887",
"0.64346135",
"0.6410397",
"0.63013524",
"0.6232891",
"0.62307066",
"0.61847264",
"0.61731243",
"0.6142808",
"0.61351234",
"0.611484",
"0.6111583",
"0.6087007",
"0.6083565",
"0.6060248",
"0.60210097",
"0.59327686",
"0.59151006",
"0.58745164",
"0.58678323",
"0.5861155",
"0.58495057",
"0.5825615",
"0.57903963",
"0.5790028",
"0.57601887",
"0.5751316",
"0.5745744",
"0.5741836",
"0.5732087",
"0.57291156",
"0.5709314",
"0.5705207",
"0.5705207",
"0.5701208",
"0.5689515",
"0.56873584",
"0.56871897",
"0.567159",
"0.5650134",
"0.5628068",
"0.56216025",
"0.5610028",
"0.56006706",
"0.55992407",
"0.55972946",
"0.55937827",
"0.55891544",
"0.55891484",
"0.5585214",
"0.55807084",
"0.5575071",
"0.55730647",
"0.55680585",
"0.556741",
"0.5544109",
"0.554215",
"0.553789",
"0.55296576",
"0.55293435",
"0.5514375",
"0.5512031",
"0.55053353",
"0.5504635",
"0.55013084",
"0.5487048",
"0.5483745",
"0.5474608",
"0.54700536",
"0.5469506",
"0.5452794",
"0.5450966",
"0.54503095",
"0.54424495",
"0.5432708",
"0.54322743",
"0.5422381",
"0.5414834",
"0.5410417",
"0.54037",
"0.54025584",
"0.54006076",
"0.5394492",
"0.53924507",
"0.5389798",
"0.5388958",
"0.5388246",
"0.5387377",
"0.53865236",
"0.53760594",
"0.5368545",
"0.5358146",
"0.53543526",
"0.5350236",
"0.5348126"
] | 0.72905326 | 1 |
Totals number of cards missing for tracked deck | def num_cards_owned(tracked_deck)
quantity_same_cards = quantity_same_query(coll_id, tracked_deck_id(tracked_deck))
quantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))
same_card_count = quantity_same_cards.inject(0) do |quantity, card|
quantity + card_quantity(card)
end
same_card_count + quantity_diff_cards.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_cards\n cards.count\n end",
"def numCards\n\t\t@cards.reduce(0) {|memo, card| memo += card.copies}\n\tend",
"def count\n @deck.count\n end",
"def count\n @deck.size\n end",
"def cards_in_deck\n Card.where(game_id: @game.id, owner: 0).size\n end",
"def no_of_cards\r\n @card_list.no_of_cards\r\n end",
"def no_of_cards\r\n @card_list.no_of_cards\r\n end",
"def available_cards\n (@deck.size + board.size)\n end",
"def count\n @cards.length\n end",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def count\n @cards.count\n end",
"def count\n @cards.size\n end",
"def count\n @cards.size\n end",
"def test_deck_card_counts\n print \"\\nOriginal Deck:\\n#{@deck.to_s}\\n\"\n assert_equal(52, @cards.length, \"Num Cards\")\n end",
"def no_of_cards\n @cards.length\n end",
"def number_readied\n readied_cards.count\n end",
"def count\n @cards.length\n end",
"def count\n cards.count\n end",
"def count_rulings(card)\n ruling_arr = scryfall.rulings(card['id']) \n \"(#{ruling_arr.length})\"\n end",
"def quantity(card)\n external_deck_instances.find_by(card_id: card.id).quantity\n end",
"def count\n return cards.length \n end",
"def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend",
"def count\n @cards.count\n end",
"def count\n @cards.count\n end",
"def count\n @cards.count\n end",
"def test_initial_card_count \n assert_equal(52, @deck.count)\n assert_equal(52, @deck.cards.length)\n end",
"def cards_left\n @deck.length\n end",
"def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend",
"def num_players_missing\n num_players - game_players.count\n end",
"def card_quantity(card)\n\t\tExternalDeckInstance.find_by(card_id: card.id).quantity\n\tend",
"def cards_left\n @deck.length\n end",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def missing_count\n @missing_count ||= current_patient.records.status(Record::MISSING).count\n end",
"def dust_needed(tracked_deck)\n\t\tdeck_not_collection_cards = deck_not_collection_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tquantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tdust_total(quantity_diff_cards) + dust_total(deck_not_collection_cards)\n\tend",
"def cards_has_required_count\n return if errors.messages.size.zero? &&\n cards.sum(&:amount) == DECK_REQUIRED_CARDS_COUNT\n\n errors.add(:cards, 'cards must add up to 30')\n end",
"def suit_count(cards)\n\t\t[\"C\",\"D\",\"H\",\"S\"].collect{|ch| cards.count{|card| card.suite == ch}}\n\tend",
"def calculate_total(cards)\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n total\n end",
"def remaining_cards\r\n @deck_of_cards.each do |card|\r\n card.output_card\r\n end\r\n end",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def size\n return @cardsShown.length\n end",
"def cards\n questions.count + answers.count\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def num_hidden\n @hidden_cards.size\n end",
"def completion\n\t\t@cards[0..TOTAL_UNIQUE_CARDS-1].reduce(0) {|memo, card| card.complete? ? memo + 1 : memo} / TOTAL_UNIQUE_CARDS.to_f\n\tend",
"def count_cut\n bottom_card = $deck.last\n bottom_card = 53 if ['A', 'B'].include? bottom_card # joker's value is 53\n $deck = [$deck.slice(bottom_card, $deck.length - bottom_card - 1), $deck.slice(0, bottom_card), $deck.last].flatten\nend",
"def uncovered_count\n not_covered_enough.select do |_, hits|\n CoverageStat.coverage_percent(hits).zero?\n end.size\n end",
"def calculate_total\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n @total = total\n end",
"def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end",
"def length\n cards.length\n end",
"def size\n deck.size\n end",
"def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end",
"def game_value(cards)\n sum = 0\n cards.each do |card|\n sum += card.game_value\n end\n sum\nend",
"def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend",
"def all_cards(user)\n user.cards.count\n end",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def test_deck_size_emptyDeck\n deck = Deck.new\n 81.times {deck.draw}\n assert_equal(0, deck.size, \"Expected size of 81.\")\n end",
"def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def size\n @cards.size\n end",
"def size\n @cards.size\n end",
"def total_cards\n @total = PkCard.count\n render json: @total\n end",
"def amount_missing_on_deliverables\n # Bisect the issues because NOT IN isn't reliable\n all_issues = self.project.issues.all\n return 0 if all_issues.empty?\n\n deliverable_issues = self.project.issues.find(:all, :conditions => [\"deliverable_id IN (?)\", self.deliverables.collect(&:id)])\n\n missing_issues = all_issues - deliverable_issues\n\n time_logs = missing_issues.collect(&:time_entries).flatten\n \n return time_logs.collect(&:cost).sum\n end",
"def missing\n num = 0\n each do |cell|\n num += 1 if cell.value.to_i == 0\n end\n num\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end",
"def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend",
"def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend",
"def size\n return @cards.length\n end",
"def incomplete_count\n incomplete.count\n end",
"def calculate_total(cards)\n total = 0\n cards.each do |c|\n if (1..10).include?(c.last.to_i)\n total += c.last.to_i\n elsif c.last == 'K' || c.last == 'Q' || c.last == 'J'\n total += 10\n elsif c.last == 'A'\n if total > 10\n total += 1\n else\n total += 11\n end\n end\n end\n total\nend",
"def test_card_length_equals_card_count \n assert_equal(@deck.cards.length, @deck.count)\n end",
"def calculate_total(cards)\n total = 0\n value_of_cards = cards.map{|e| e[1]}\n value_of_cards.each do |value|\n if value == \"A\"\n total += 11\n elsif value.to_i == 0\n total +=10 # handle J, Q, K\n else\n total += value.to_i\n end\n # corrct Ace condition\n if total > 21\n value_of_cards.select{|e| e == \"A\"}.count.times do\n total -= 10\n end\n end\n end\n total\nend",
"def total_lines\n hunks.sum(:old_count) + hunks.sum(:new_count)\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def test_deck_display_size_emptyDeck\n deck = Deck.new\n 81.times {deck.draw}\n print \"Expected size of 0: Found \"\n deck.display_size\n end",
"def calculate_total(cards)\n\tarr = cards.map { |e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value|\n\t\tif value == 'A'\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #only works for J, Q, K\n\t\t\ttotal += 10\n\t\telse\n\t\t\ttotal += value.to_i\n\t\tend\n\tend\n\t#Code to make Aces work\n\tarr.select{|e| e == \"A\"}.count.times do\n\t\ttotal -=10 if total > 21\n\tend\n\n\tif arr.include?(\"A\") && total > 21\n\t\ttotal -= 10\n\tend\n\n\ttotal\nend",
"def size\n @cards.size\n end",
"def cards_left_to_collect\n card_ids = UserCard.select {|card| card[\"user_id\"] == self.id}\n remaining = Card.all.count - card_ids.map { |card| card[\"card_id\"] }.uniq.count\n if remaining == 0\n puts \"=====================================================================\"\n puts \"Congratulations, you have completed the Superhero card album!!\"\n puts \"=====================================================================\"\n else\n puts \"=====================================================================\"\n puts \"You still have #{remaining} cards left to collect...\"\n puts \"=====================================================================\"\n end\n end",
"def total(cards)\n values = cards.map { |card| card[1] } # this map method iterates through each card ([S, V]) and returns the value of the card from the second spot in the individual card array\n\n sum = 0 # initialize the sum variable that will be used to total the card values\n values.each do |value| # iterate through each value\n if value == \"A\" # if the card is an Ace, add 11 to the sum\n sum += 11\n elsif value.to_i == 0 # if the card's value is 0 when converted to an int, that means it is a face card and should be worth 10\n sum += 10\n else\n sum += value.to_i # otherwise, convert the value to an integer and add that to the sum\n end\n end\n\n # adjust aces if sum is greater than 21\n values.select { |value| value == \"A\" }.count.times do # iterate through the card values array, finding the aces.\n sum -= 10 if sum > MAX_VALUE # If the sum is greater than 21, subtract 10 from each ace, making the aces only worth 1\n end\n\n sum # return the sum\nend",
"def missingmodulecount\n $number_of_missing_modules = @missingmodules.count().to_s\nend",
"def amount_kills\n mutations.select(&:success?).length\n end",
"def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end",
"def length\n\t\treturn @cards.length\n\tend",
"def unfilled_meals_count\n required_meals.values.reduce(:+)\n end",
"def remaining_slots\n @count = 0\n self.booked_customers.each do |booked_customer|\n @count += booked_customer.number_students.to_i\n end\n return self.cap - @count\n\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def cards_played_size \n a = @played\n a.delete_if { |key, value| value == nil }\n a.length\n end",
"def disenchantGoldens\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1]\n\t\t\textras = card.removeAll\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def take_from_deck(number_of_cards)\n @deck_position ||= @deck.each\n cards_taken = 0\n # @hand += @deck_position.take(number_of_cards)\n begin\n number_of_cards.times do |i| \n @hand << @deck_position.next \n cards_taken += 1\n end\n rescue StopIteration => e\n # not good, i know, but there is nothing to do here\n end\n cards_taken\n end",
"def ts_holds_count\n ts_holds = holds.where.not(status: ['cancelled'])\n ts_holds.present? ? ts_holds.sum(:quantity) : nil\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def amount_missing_on_issues\n time_logs = TimeEntry.where(project_id: self.project.id)\n\n return time_logs.collect(&:cost).sum\n end",
"def card_stats\n stats = {\n colors: {\n W: 0,\n U: 0,\n B: 0,\n R: 0,\n G: 0,\n C: 0,\n M: 0,\n total: 0\n },\n types: {\n creature: { count: 0, subtypes: {} },\n enchantment: { count: 0, subtypes: {} },\n instant: { count: 0, subtypes: {} },\n land: { count: 0, subtypes: {} },\n sorcery: { count: 0, subtypes: {} },\n planeswalker: { count: 0, subtypes: {} },\n artifact: { count: 0, subtypes: {} },\n },\n cmc: {\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n 5 => 0,\n 6 => 0,\n },\n counts: {\n creature: 0,\n nonCreature: 0,\n land: 0,\n nonLand: 0,\n },\n rarity: {\n common: 0,\n uncommon: 0,\n rare: 0,\n mythic: 0,\n special: 0,\n bonus: 0\n },\n cards: 0,\n }\n\n cards = self.cards\n # Iterates over every card and updates stats object\n cards.each do |card|\n multiplier = card.deck_quantity(id).quantity\n\n # Increment total cards\n stats[:cards] += multiplier\n\n\n # Card types, they have been stringified so we must parse them\n card_types = card.card_types\n types = stats[:types]\n\n\n # Counts the card types\n card_types.each do |type|\n lower_type = type.downcase().to_sym\n \n if types[lower_type]\n types[lower_type][:count] += multiplier\n end\n \n \n # Counts the card subTypes\n card.subtypes&.each do |subtype|\n lower_subtype = subtype.downcase().to_sym\n\n if types[lower_type] && types[lower_type][:subtypes] && types[lower_type][:subtypes][lower_subtype]\n types[lower_type][:subtypes][lower_subtype] += multiplier\n elsif types[lower_type] && types[lower_type][:subtypes]\n types[lower_type][:subtypes][lower_subtype] = multiplier\n end\n end\n end\n\n\n # Counts multicolored cards and individual colors\n if card.color_identity.length > 1\n stats[:colors][:M] += multiplier\n end\n\n \n\n # Artifacts do not have colors, so we increment colorless\n if (card.color_identity.length === 0) \n stats[:colors][:C] += multiplier\n stats[:colors][:total] += multiplier\n end\n \n \n \n # Otherwise we update the color identity\n card.color_identity.each { |color|\n stats[:colors][color.to_sym] += multiplier\n stats[:colors][:total] += multiplier\n }\n\n\n # if the card is a land we just need to up the land count. Otherwise we set a few more counts\n if (card.card_type.include?('Basic Land')) \n stats[:counts][:land] += multiplier\n else\n stats[:counts][:nonLand] += multiplier\n\n \n # Updates counts for creatures and nonCreatures\n if card_types.include?('Creature')\n stats[:counts][:creature] += multiplier\n else\n stats[:counts][:nonCreature] += multiplier\n end\n\n # Gets converted mana cost counts\n card_cmc = card.converted_mana_cost\n \n # Increments 1 mana for 1 or 0 cmc\n if (card_cmc <= 1) \n stats[:cmc][1] += multiplier\n \n # Increments 6 mana for 6 or more cmc\n elsif (card_cmc >= 6) \n stats[:cmc][6] += multiplier\n \n # Otherwise we increment what's in-between as long as it's not a land\n else\n stats[:cmc][card_cmc.to_i] += multiplier\n end\n \n # counts card rarity, doesn't include basic lands\n stats[:rarity][card.rarity.to_sym] += multiplier\n end\n\n\n end\n\n stats\n end",
"def carbs_consumed\n\t\t@snack_carbs.values.reduce(0, :+)\n\tend",
"def card_quantity(card)\n c = instance_of(card.id)\n c.nil? ? 0 : c.quantity\n end",
"def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend",
"def deck_of_cards\n deck_hash = {h2: 2, h3: 3, h4: 4, h5: 5, h6: 6, h7: 7, h8: 8, h9: 9, h10: 10, hj: 10, hq: 10, hk: 10, ha: 11,\n d2: 2, d3: 3, d4: 4, d5: 5, d6: 6, d7: 7, d8: 8, d9: 9, d10: 10, dj: 10, dq: 10, dk: 10, da: 11,\n s2: 2, s3: 3, s4: 4, s5: 5, s6: 6, s7: 7, s8: 8, s9: 9, s10: 10, sj: 10, sq: 10, sk: 10, sa: 11,\n c2: 2, c3: 3, c4: 4, c5: 5, c6: 6, c7: 7, c8: 8, c9: 9, c10: 10, cj: 10, cq: 10, ck: 10, ca: 11}\nend",
"def number_of_bankruptcies\n self.bankruptcies.select{|x| \"not-discharged-not-completed\" == x[\"discharge_status\"] }.count\n end",
"def ship_count\n count = []\n @rows.each do |row|\n count << row.count('s')\n end\n count.reduce(:+)\n end",
"def total_set_cards\n @total = PkCard.where(set: params[:set]).count\n render json: @total\n end"
] | [
"0.74861246",
"0.73736274",
"0.73668736",
"0.7309849",
"0.72209054",
"0.69569254",
"0.69569254",
"0.695109",
"0.6945925",
"0.6934842",
"0.6934842",
"0.6934842",
"0.6919808",
"0.6892707",
"0.6892707",
"0.6891934",
"0.688746",
"0.683361",
"0.68086827",
"0.6789684",
"0.6787599",
"0.6783668",
"0.6782497",
"0.67672265",
"0.67432123",
"0.67432123",
"0.67432123",
"0.67310554",
"0.6677677",
"0.6666632",
"0.6631176",
"0.66100246",
"0.65976155",
"0.6580737",
"0.6565098",
"0.6562512",
"0.6559028",
"0.65230554",
"0.6510678",
"0.646764",
"0.6432032",
"0.64114624",
"0.6398079",
"0.6378257",
"0.63515335",
"0.6330339",
"0.63043976",
"0.62968844",
"0.62947005",
"0.6282918",
"0.62796426",
"0.6275297",
"0.62741464",
"0.62665635",
"0.6257587",
"0.62547135",
"0.6252485",
"0.62492067",
"0.62456733",
"0.6232168",
"0.6232168",
"0.62279433",
"0.62118477",
"0.62113154",
"0.6208072",
"0.6200241",
"0.61998373",
"0.61950773",
"0.61942977",
"0.6180108",
"0.617779",
"0.6175893",
"0.6167056",
"0.61662644",
"0.6155592",
"0.6154782",
"0.61459374",
"0.61439645",
"0.61277807",
"0.6126002",
"0.6118904",
"0.6115809",
"0.61057955",
"0.61053675",
"0.6096046",
"0.6090564",
"0.60883087",
"0.60864884",
"0.60838366",
"0.60834867",
"0.6070917",
"0.6066147",
"0.60562277",
"0.6042454",
"0.60420084",
"0.6041975",
"0.6037635",
"0.60352004",
"0.60148484",
"0.600967"
] | 0.7677884 | 0 |
Returns quantity of specified card | def card_quantity(card)
ExternalDeckInstance.find_by(card_id: card.id).quantity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantity(card)\n external_deck_instances.find_by(card_id: card.id).quantity\n end",
"def card_quantity(card)\n c = instance_of(card.id)\n c.nil? ? 0 : c.quantity\n end",
"def collection_quantity(collection, card)\n return false unless collection && card\n\n if in_collection?(collection, card)\n collection.collected_cards.find_by(card_id: card.id)\n end\n end",
"def total_cards\n cards.count\n end",
"def quantity\n return @ucItemNumber.value\n end",
"def multiply_quantity(user, card)\n # todo check statement whether card is json or Card object\n card = Card.last(user_id: user.id, scryfall_id: card['id'])\n price = remove_dot(card.usd_price) \n product = Money.new(price) * card.quantity\n product.format\n end",
"def inventory(card)\n unless current_user \n '0'\n else \n Card.last(scryfall_id: card['id'], user_id: current_user.id)\n end\n end",
"def quantity\n read_integer('quantity')\n end",
"def get_card_value(card)\n card_number = get_card_number(card)\n if card_number == 'K' || card_number == 'J' || card_number == 'Q'\n card_number = 10\n elsif card_number == 1\n card_number = 11\n end\n return card_number\nend",
"def remaining_number\n card.remaining_number\n end",
"def __card_value( card )\n\tnumber = card.split( '' )[ 0 ]\n\n\tif 'T' == number\n\t\tnumber = 10\n\telsif 'J' == number\n\t\tnumber = 11\n\telsif 'Q' == number\n\t\tnumber = 12\n\telsif 'K' == number\n\t\tnumber = 13\n\telsif 'A' == number\n\t\tnumber = 14\n\tend\n\n\treturn number\nend",
"def value \r\n value = 0\r\n @cards.each do |card|\r\n value += card.value\r\n end\r\n if value > 21\r\n value = 0\r\n @cards.each do |card|\r\n if card.value == 11\r\n value += 1\r\n else\r\n value += card.value\r\n end\r\n end\r\n end\r\n value\r\n end",
"def quantity\n quantity_initial - quantity_consumed\n end",
"def card_value(card)\n basic_value = card.to_i\n if card.start_with?(\"A\")\n basic_value = 11\n elsif basic_value == 0\n basic_value = 10\n end\n basic_value\n end",
"def count\n cards.count\n end",
"def card_value(cards_value, cards)\n cards_value = 0\n players_cards_length = cards.length\n players_cards_info = cards[0 .. cards.length]\n cards.each {|y, x| cards_value = cards_value + x }\n return cards_value\n end",
"def total_item_number\n @quantity * product.result_n\n end",
"def size\n cards.size\n end",
"def count\n @cards.count\n end",
"def card_totals(selected_cards)\n total_value = 0\n selected_cards.each do |card|\n card_value = card[0]\n if card_value.to_i > 0\n total_value += card_value.to_i\n elsif ['J', 'Q', 'K'].include?(card_value)\n total_value += 10\n elsif card_value == \"A\" && total_value > 10\n total_value += 1\n elsif card_value == \"A\" && total_value < 10\n total_value += 11\n end\n end\n total_value\nend",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def no_of_cards\n @card_list.no_of_cards\n end",
"def no_of_cards\r\n @card_list.no_of_cards\r\n end",
"def no_of_cards\r\n @card_list.no_of_cards\r\n end",
"def inventory_quantity\n return @cItemPossess.text.to_i\n end",
"def get_size(card_name)\n if @sizes\n begin\n size_key = /[<{\\[](.+)[>}\\]]/.match(card_name)[1].to_sym\n if @sizes.has_key? size_key\n size = @sizes[size_key] \n else\n if size_key.to_s.to_i != 0\n size = size_key.to_s.to_i\n else\n size = @sizes[:default]\n end\n end\n rescue Exception => e\n size = @sizes[:default]\n end\n else\n size = (/[<{\\[](\\d+)[>}\\]]/.match(card_name) || DEFAULT_SIZE )[1].to_i\n end\n size\n end",
"def count\n @cards.size\n end",
"def count\n @cards.size\n end",
"def item_quantity(item_id)\n details.select {|v| v.item_id === item_id}.inject(0) {|s, v| s += v.quantity }\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def quantity\n 1\n end",
"def quantity\n 1\n end",
"def quantity\n hash[\"Quantity\"]\n end",
"def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end",
"def count\n @cards.length\n end",
"def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend",
"def size\n @cards.size\n end",
"def size\n @cards.size\n end",
"def value(card)\n suit = card.to_s.split(//).first\n value = card.to_s.delete(suit)\n if value.to_i == 0\n value == \"A\" ? value = 11 : value = 10\n else\n value = value.to_i\n end\n value\nend",
"def count\n @cards.count\n end",
"def count\n @cards.count\n end",
"def count\n @cards.count\n end",
"def length\n cards.length\n end",
"def item_count\n\t\tquery(\"* marked:'quantityText'\", :text)[0]\n\tend",
"def count\n return cards.length \n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end",
"def size\n @cards.size\n end",
"def single_card_value(card)\n case card[1].strip\n when \"2\"..\"10\" then card[1].to_i\n when \"J\", \"Q\", \"K\" then 10\n when \"A\" then 11\n end\nend",
"def total(cards)\n values = cards.map { |card| card[1] } # this map method iterates through each card ([S, V]) and returns the value of the card from the second spot in the individual card array\n\n sum = 0 # initialize the sum variable that will be used to total the card values\n values.each do |value| # iterate through each value\n if value == \"A\" # if the card is an Ace, add 11 to the sum\n sum += 11\n elsif value.to_i == 0 # if the card's value is 0 when converted to an int, that means it is a face card and should be worth 10\n sum += 10\n else\n sum += value.to_i # otherwise, convert the value to an integer and add that to the sum\n end\n end\n\n # adjust aces if sum is greater than 21\n values.select { |value| value == \"A\" }.count.times do # iterate through the card values array, finding the aces.\n sum -= 10 if sum > MAX_VALUE # If the sum is greater than 21, subtract 10 from each ace, making the aces only worth 1\n end\n\n sum # return the sum\nend",
"def qty()\n 1\n end",
"def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end",
"def value()\n sum = 0\n # Partition the array by string and integer then reverse to put aces at back\n @cards.partition{|x| x.is_a? String}.map(&:sort).flatten.reverse_each do |i|\n if [\"Q\", \"J\", \"K\"].include?(i)\n sum += 10\n elsif i == \"A\"\n if sum + 11 > 21\n sum += 1\n else\n sum += 11\n end\n else \n sum += i\n end\n end \n return sum\n end",
"def calculate_total(cards)\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n total\n end",
"def quantity_of(purchase)\n item = find_item(purchase)\n if item.nil?\n 0\n else\n item.quantity\n end\n end",
"def numCards\n\t\t@cards.reduce(0) {|memo, card| memo += card.copies}\n\tend",
"def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend",
"def calculate_total(cards)\n total = 0\n cards.each do |c|\n if (1..10).include?(c.last.to_i)\n total += c.last.to_i\n elsif c.last == 'K' || c.last == 'Q' || c.last == 'J'\n total += 10\n elsif c.last == 'A'\n if total > 10\n total += 1\n else\n total += 11\n end\n end\n end\n total\nend",
"def count\n @cards.length\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def count\n @deck.count\n end",
"def display_card_total(total)\n puts \"Your cards add up to #{total}\"\nend",
"def product\n @card_product\n end",
"def getValue(card_number)\n # get card rank\n rank = case card_number % 13\n when 0, 11, 12 then 10\n when 1 then 11\n else card_number % 13 \n end\n \n return rank\n \nend",
"def get_a_card(card_number)\n @cards[card_number]\n end",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def deposit_quantity\n money.to_d.divmod(market.settle_price(currency)).first\n end",
"def calculate_total(cards)\n\tarr = cards.map { |e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value|\n\t\tif value == 'A'\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #only works for J, Q, K\n\t\t\ttotal += 10\n\t\telse\n\t\t\ttotal += value.to_i\n\t\tend\n\tend\n\t#Code to make Aces work\n\tarr.select{|e| e == \"A\"}.count.times do\n\t\ttotal -=10 if total > 21\n\tend\n\n\tif arr.include?(\"A\") && total > 21\n\t\ttotal -= 10\n\tend\n\n\ttotal\nend",
"def no_of_cards\n @cards.length\n end",
"def calculate_total(cards)\n total = 0\n value_of_cards = cards.map{|e| e[1]}\n value_of_cards.each do |value|\n if value == \"A\"\n total += 11\n elsif value.to_i == 0\n total +=10 # handle J, Q, K\n else\n total += value.to_i\n end\n # corrct Ace condition\n if total > 21\n value_of_cards.select{|e| e == \"A\"}.count.times do\n total -= 10\n end\n end\n end\n total\nend",
"def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end",
"def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend",
"def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end",
"def item_quantity(id)\n return 0 if @locked\n\n return @items[GameData::Item[id].id] || 0\n end",
"def card_value(card_symbol, deck_hash)\n deck_hash[card_symbol]\nend",
"def size\n return @cards.length\n end",
"def find_value_for(resource, quantity)\n quantity * resources[resource]\n end",
"def count\n @deck.size\n end",
"def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend",
"def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend",
"def counting_quantity\n product.allow_fractional_quantity? ? 1 : quantity.to_i\n end",
"def number_readied\n readied_cards.count\n end",
"def calculate_total\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n @total = total\n end",
"def sell_quantity\r\n 100000000000\r\n end",
"def get_hand_value(hand)\n hand_values = hand.map { |card| card[0]} \n \n total = 0\n #check if there are any Aces\n hand_values.each do |value|\n if value == 'A'\n total += 11\n elsif value.to_i == 0 # this is for J, Q, K\n total += 10\n else\n total += value.to_i\n end\n end\n # To accomodate Aces, subtract 10 from the total per Ace if the total is >21\n hand_values.select{|value| value == \"A\"}.count.times do \n total -= 10 if total >21\n end\n total\nend",
"def quantity\n consumables.size\n end",
"def total_cards\n @total = PkCard.count\n render json: @total\n end",
"def display_card_total(card_total)\n puts \"Your cards add up to #{card_total}\"\n card_total\nend",
"def calculate_totals(cards) \n card_values = cards.map{|card| card[1]}\n total_socre = 0\n card_values.each do |value|\n if value == \"Ace\"\n total_socre += 11\n elsif value.to_i == 0\n total_socre += 10\n else\n total_socre += value.to_i\n end\n end\n#correct for Aces\n card_values.select {|e| e == \"Ace\"}.count.times do\n total_socre -= 10 if total_socre > 21\n end\n total_socre\nend",
"def size\n Stal.solve(redis, [\"SCARD\", key])\n end",
"def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend",
"def rank_of_card_at(index)\n cards[index].rank\n end",
"def total_quantity\n cached_qty_bank.to_f + cached_qty_consigned.to_f\n end",
"def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def game_value(cards)\n sum = 0\n cards.each do |card|\n sum += card.game_value\n end\n sum\nend",
"def item_number(item)\n article = article_from_item(item)\n article ? article.quantity : 0\n end",
"def add_card(card)\r\n\t\tcards << card\r\n\t\tcalc_value\r\n\tend",
"def value\n card_value = @rank\n if @rank == :A\n card_value = 11\n elsif @rank == :K || @rank == :Q || @rank == :J\n card_value = 10\n end\n card_value\n end",
"def cards_needed\n [@size, 5].min\n end"
] | [
"0.868132",
"0.845202",
"0.72160846",
"0.681336",
"0.67579466",
"0.67109716",
"0.6603903",
"0.65365624",
"0.6526348",
"0.65229255",
"0.6468193",
"0.6458887",
"0.6439727",
"0.6416867",
"0.6377191",
"0.63370013",
"0.6326407",
"0.632178",
"0.631865",
"0.63165057",
"0.6311675",
"0.6311675",
"0.6311675",
"0.63116246",
"0.63116246",
"0.6305952",
"0.62864",
"0.62819105",
"0.62819105",
"0.62818086",
"0.6266527",
"0.62560695",
"0.62330353",
"0.62235874",
"0.6201636",
"0.61960703",
"0.61945343",
"0.6190976",
"0.6190976",
"0.61873966",
"0.6187304",
"0.6187304",
"0.6187304",
"0.61798126",
"0.6163512",
"0.61609393",
"0.61464894",
"0.61370283",
"0.613229",
"0.6130424",
"0.61301506",
"0.6120991",
"0.6119314",
"0.6116459",
"0.6114699",
"0.6104579",
"0.6094165",
"0.60924166",
"0.60910296",
"0.6081384",
"0.6079187",
"0.60737556",
"0.60658646",
"0.6060344",
"0.60486174",
"0.6039474",
"0.603867",
"0.60310936",
"0.6014944",
"0.60096747",
"0.6000043",
"0.5996304",
"0.5991186",
"0.59851116",
"0.5982855",
"0.5979772",
"0.5976396",
"0.5968308",
"0.5965565",
"0.59644437",
"0.59628975",
"0.59579986",
"0.59500086",
"0.59492856",
"0.5947752",
"0.59331113",
"0.59309703",
"0.59187305",
"0.5918095",
"0.59138894",
"0.59092",
"0.5901784",
"0.5897601",
"0.5896957",
"0.5890822",
"0.58878225",
"0.5874312",
"0.5866295",
"0.5854",
"0.5853551"
] | 0.8411033 | 2 |
Calculates dust needed to craft remainder of deck | def dust_needed(tracked_deck)
deck_not_collection_cards = deck_not_collection_query(coll_id, tracked_deck_id(tracked_deck))
quantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))
dust_total(quantity_diff_cards) + dust_total(deck_not_collection_cards)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def craft(dust, cards)\n\t\tn = 0\n\t\tfor card in cards\n\t\t\tif !card.complete?\n\t\t\t\tmissing = card.numMissing\n\t\t\t\tif missing * card.craft_cost <= dust\n\t\t\t\t\tdust -= missing * card.craft_cost\n\t\t\t\t\tcard.addCopies(missing)\n\t\t\t\t\tn += missing\n\t\t\t\telsif card.craft_cost <= dust\n\t\t\t\t\tdust -= card.craft_cost\n\t\t\t\t\tcard.addCopy\n\t\t\t\t\tn += 1\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn dust, n\n\tend",
"def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend",
"def disenchantGoldens\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1]\n\t\t\textras = card.removeAll\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def dust_value(card_rarity)\n\t\tcase card_rarity\n\t\twhen \"Free\"\n\t\t\treturn 0\n\t\twhen \"Common\"\n\t\t\treturn 40\n\t\twhen \"Rare\"\n\t\t\treturn 100\n\t\twhen \"Epic\"\n\t\t\treturn 400\n\t\twhen \"Legendary\"\n\t\t\treturn 1600\n\t\tend\n\tend",
"def craftRarest(dust)\n\t\tif complete? \n\t\t\tcraft(dust, @cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1].reverse)\n\t\telse\n\t\t\tcraft(dust, @cards[0..TOTAL_UNIQUE_CARDS-1].reverse)\n\t\tend\n\tend",
"def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end",
"def calc_damage d_r, d_k, roll_hist, tn\n calc_damage_data d_r,d_k, roll_hist, tn, 10, @base_rolls\n calc_damage_data d_r,d_k, roll_hist, tn, 9, @mastery_rolls\n end",
"def disenchantExtras\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards\n\t\t\textras = card.removeExtras\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def shield_cal(user)\n shield_mobile = amount_of_ships(user, @shield_ship_id) * 5\n level_shield = user_science_level(user, @shield_science_id) \n shield_defend = 0\n if (user == @defender)\n shield_big = amount_of_facilities(@big_shield_id ) * 500\n shield_small = amount_of_facilities(@smal_shield_id ) * 100\n shield_defend = shield_big + shield_small\n end\n return (shield_mobile + shield_defend) * (1 + 0.1 * level_shield)\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def wound(damage)\n remaindmg = damage-@shields\n if damage > @shields\n @shields = 0\n @health -= remaindmg \n elsif @shields >= damage\n @shields -= damage\n else\n @health -= damage\n end\n if @health <= 0\n @health = 0\n end\n end",
"def damage\n @damage ||= [(@power * (rand + 0.5)).to_i - @defender.toughness, 0].max\n end",
"def wound(damage)\n if (@shield >= damage)\n @shield -= damage\n else \n remaining_damage = damage - @shield\n @shield = 0\n if (@health - remaining_damage) > 0 \n @health -= remaining_damage\n else\n @health = 0\n end\n end\nend",
"def attack\n total_for(:attack) \n end",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def buyPack\n\t\t@collection.addPack(@store.buyPack)\n\n\t\textras_dust, n_extras = @collection.disenchantExtras\n\t\tgoldens_dust, n_goldens = @collection.disenchantGoldens\n\n\t\t@dust += extras_dust + goldens_dust\n\t\t@disenchanted += n_extras + n_goldens\n\n\t\t@dust, n_crafted = @collection.craftRarest(@dust)\n\t\t@crafted += n_crafted\n\t\tnew_cards = Store::CARDS_PER_PACK + n_crafted - (n_extras + n_goldens)\n\t\t@cards += new_cards\n\t\t@cards_record.push(@cards)\n\t\t@purchased += 1\n\t\treturn new_cards\n\tend",
"def dodge_bonus\n 0\n end",
"def fuel_needed(mass)\n return (mass / 3) - 2\nend",
"def redeem\n new_bottles = free_bottles_and_caps(@bottles, @caps)\n @bottles = new_bottles + leftover_bottles(@bottles)\n @caps = new_bottles + leftover_caps(@caps)\n @total_bottles += new_bottles\n redeem if redeemable?\nend",
"def compute_damage\r\n return rand(1..6) * @weapon_level\r\n end",
"def calculate_taxes\n\n character_name = player_character.base_card.name\n\n case character_name\n when 'merchant'\n colour = 'green'\n\n when 'king'\n colour = 'yellow'\n when 'warlord'\n colour = 'red'\n else\n colour = 'blue'\n end\n purple_district = districts_on_game.where(\"colour = 'purple'\")\n colour_recount = cards.districts.where(\"state = 'ONGAME' AND colour = ?\", colour).count + (purple_district.exists?([\"name = 'school_magic'\"])? 1:0)\n end",
"def vulnerable_undertrick_points\n if !made?\n p = -100 * modifier\n if result < -1\n return p += (result + 1) * 300 if doubled?\n return p += (result + 1) * 600 if redoubled?\n return p += (result + 1) * 100\n end\n p\n else\n 0\n end\n end",
"def dmg( d_type, dmg, ap, srpe_att, char_att )\n d = dmg\n\n # surprise attacks do more damage\n if srpe_att\n d = d * 1.5\n end\n\n # when you see it coming, there is a chance that you get to evade part of the damage\n if !srpe_att && (rand(100) + 1 < @c_evade)\n d = d / 1.25; # consider redesigning this feature, the original value was way to strong, temp reducing the divider\n end\n\n # modify damage based on your resistances to the different types\n case d_type\n when :standard\n d -= @c_class == 'Knight' ? 10 : 0 # Warriors get a special resistance to standard damage\n when :magic\n d -= @c_class == 'Wizard' ? 10 : 1 # Magi get a special resistance to magic damage\n when :earth\n d -= 1\n when :fire\n d -= 1\n when :water\n d -= 1\n when :wind\n d -= 1\n when :shadow\n d -= @c_class == 'Shinobi' ? 10 : 1 # Rogue get a special resistance to shadow damage\n when :ice\n d -= 1\n when :lightning\n d -= 1\n when :dark\n d -= 1\n when :light\n d -= 1\n when :psionic\n d -= 1\n else\n d -= 0\n end\n\n # modify damage based on armor worn\n if @armor == 'Leather'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (2 - ap)\n end\n elsif @armor == 'Chain mail'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (6 - ap)\n end\n elsif @armor == 'Full Plate'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (12 - ap)\n end\n end\n\n # make sure we don't give them hp when they block it\n if d < 0\n d = 0;\n end\n\n # apply the damage\n @c_hp = @c_hp - d\n\n # display results\n if d == 0\n puts 'You suffered no damage from the attack, way to go!'\n elsif @c_hp <= 0\n @c_lvl -= 1\n puts \"You #{ @c_name } have perished. You respawn back at town square but have suffered loss in level. You are now level #{ @c_lvl }\"\n else\n puts \"You have suffered #{ d } wounds and now have #{ @c_hp } health left\"\n end\n\n # NOTE: this is becoming to painful, removing until we figure out\n # how to handle all the different combos for the counter attack\n # if @c_hp > 0 && !srpe_att && (rand(100) + 1 < @c_counter)\n # if @c_class == 'Knight' && @weapon == 'Short Sword'\n # char_att.dmg(:physical, rand(10) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Longsword'\n # char_att.dmg(:physical, rand(20) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Battle Axe'\n # char_att.dmg(:physical, rand(11) + 10, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Fireball'\n # char_att.dmg(:fire, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Ice Spikes'\n # char_att.dmg(:ice, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Crushing Grasp'\n # char_att.dmg(:magic, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Tanto'\n # char_att.dmg(:magic, rand(6) + 6, 6, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Ninjato'\n # char_att.dmg(:magic, rand(12) + 6, 3, false)\n # end\n # end\n end",
"def calculate\n @calculated = true\n \n @weapon = Weapon.find(weapon_id)\n @armour = Armour.find(armour_id)\n \n # hp\n @base_hp = 20 + (level * 5) + (((base_end - 10) * level) / 2.5).round\n @dmg_taken = 0\n \n @intimidate = 0\n @discipline = 0\n @judgement = 0\n\n @can_train = true\n \n # load modifiers\n load_mods\n apply_mods\n \n # calculated values used in attack / dodge rolls\n @str_mod = (@str - 10) / 2\n @agi_mod = (@agi / 2).floor\n @int_mod = ((@int - 10) / 2).floor\n @x_mod = (@x / 2).floor\n\n \n @crit_range = 5 + @agi_mod + (@int_mod / 2)\n @str_dmg = (@str_mod + ((@str_mod * level) * 0.05)).ceil\n\n @dodge_percent = @agi_mod + @x_mod + (@int_mod / 2)\n @armour.is_light ? @dodge_percent += 5 : @dodge_percent -= 3\n @deflect_percent = (@str_mod / 2).floor + (@int_mod / 2)\n \n if @armour.is_heavy\n @deflect_percent += 7 # add 7% bonus for heavy armour\n else\n @dodge_percent += 5 # add 5% bonus for light armour\n @judgement += 1\n end\n \n # skill mods\n @intimidate += @str_mod + @int_mod\n @discipline += @str_mod + @int_mod\n @judgement += @int_mod\n \n @generated = 0\n @state = 1\n @intimidated = false\n @prepared = false\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def calc_defender_damage(initial_damage, hp_damage)\n dmg = initial_damage - hp_damage\n if guarding?\n dmg /= (super_guard ? 4 : 2)\n end\n dmg\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def cap_redeem(num_bottles)\n\tnum_bottles/4\nend",
"def shield_cal(user)\n amount = amount_of_ships(user, @shield_ship_id)\n level_shield=user_science_level(user, @shield_science_id) \n if (user == @defender)\n #add shield\n # ANLAGEN NOCH EINBINDEN!!!!!!\n end\n return 10000\n end",
"def compute_damage\n\t\treturn rand(1..6) * @weapon_level\n\tend",
"def shield_bonus\n 0\n end",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def dps\n self.total_damage.to_f / self.encounter.duration_in_seconds\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def compute_damage\n return rand(1..6)\n end",
"def daily_thievery\r\n\t\t@inventory += (@thieves)*3\r\n\tend",
"def roll_damage\n\t\tGurpsUtils.d(6) * 8 # Relative velocity 2 mps\n\tend",
"def compute_damage\r\n return rand(1..6)\r\n end",
"def compute_damage\n \treturn rand(1..6)\n end",
"def compute_damage\n return rand(1..6)\n end",
"def attack_effect_dispersion\r\n if self.damage.abs > 0\r\n amp = [self.damage.abs * 15 / 100, 1].max\r\n self.damage += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n end",
"def rent_percept_for_renter\n rent_value = 0\n self.accessories.each{|accessory|\n rent_value += ((accessory.base + accessory.tarif)*( 1 + (accessory.tax/100) ))\n }\n return rent_value\n end",
"def serial_wtf\n # given a value to be deducted from the total, calculate a new ave_cost_per_vol for serials\n old_ic_serials = 0;\n old_sql = \"SELECT COUNT(*) AS c FROM holdings_htitem WHERE item_type = 'serial' AND access = 'deny'\";\n @@conn.query(old_sql) do |row|\n old_ic_serials = row['c'].to_i;\n break;\n end\n old_total_cost = old_ic_serials * @avg_cost_per_vol;\n\n # need the number of *matching* volumes among which to distribute new cost\n new_ic_serials = 0;\n new_sql = %w[SELECT COUNT(*) AS c\n FROM holdings_htitem_H AS h3,\n holdings_htitem AS h2\n WHERE h3.volume_id = h2.volume_id\n AND h2.item_type = 'serial'\n AND h2.access = 'deny'].join(' ');\n @@conn.query(new_sql) do |count_row|\n new_ic_serials = count_row['c'].to_i;\n break;\n end\n\n new_ave_cost_per_vol = (old_total_cost) / new_ic_serials;\n return new_ave_cost_per_vol;\n end",
"def calc_odds(hand, result)\n current = hand_value(hand)\n return 1.0 if current == result\n return 0.0 if current >= 17\n\n # Remove hand cards from full shute\n cards = new_shute\n hand.each {|c| cards.delete_at(cards.index(c))}\n\n odds = 0.0\n CARDS.each do |c|\n odds_of_card = odds_of(cards, c)\n if odds_of_card > 0.0\n hand.push c\n odds_of_result = calc_odds(hand, result)\n odds += odds_of_card * odds_of_result\n hand.pop\n end\n end\n\n return odds\nend",
"def collect_treasure\n @gold_coins += 1\n if @gold_coins % 10 == 0\n level_up\n end\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def calculate_net_calories(foods,exercises)\n\t\ttotal_intake = 0\n\t\ttotal_burn = 0\n\t\tfoods.each do |food|\n\t\t\ttotal_intake += food.calories\n\t\tend\n\t\texercises.each do |exercise|\n\t\t\ttotal_burn += exercise.calories\n\t\tend\n\t\treturn total_intake-total_burn\n\tend",
"def remaining_slots\n @count = 0\n self.booked_customers.each do |booked_customer|\n @count += booked_customer.number_students.to_i\n end\n return self.cap - @count\n\n end",
"def compute_damage\n return rand(1..6)\n end",
"def compute_damage\n return rand(1..6)\n end",
"def turn\n # start with simplest model of food consumption and creation\n if @food_production >= @population\n food_surplus = @food_production - @population\n else\n food_deficit = @population - @food_production\n end\n\n if food_surplus\n @food_storage += food_surplus\n elsif food_deficit\n if @food_storage >= food_deficit\n @food_storage -= food_deficit\n else\n shortage = food_deficit - @food_storage\n @food_storage = 0\n @population -= shortage # that many people starve\n end\n end\n\n @population += (@population * @@fertility_rate).floor\n end",
"def roll_attack\n set_attack_info\n\n @dice_pool = [@dice_pool, 16].min\n\n if @dice_pool > 0\n @roll_result = Hazard.from_string \"s#{@dice_pool}d6\"\n @hits = @roll_result.rolls.select{ |d| d >= @opponent_armor }\n else\n raise \"@dice_pool == 0 for #{@attacker.to_s}\"\n end\n\n if @hits.count > 0\n @opponent_saves_result = Hazard.from_string \"s#{@hits.count}d6\"\n @opponent_saves = @opponent_saves_result.rolls.select{ |d| d >= @opponent_save }\n end\n\n @final_hits = [@hits.count - (@opponent_saves&.count || 0), 0].max\n end",
"def total_saturated\n food.saturated * quantity\n end",
"def roll_damage\n # Broadsword\n rolled = roll('2d4')\n if @strength > 17\n return rolled + 2\n elsif @strength > 15\n return rolled + 1\n else\n return rolled\n end\n end",
"def roll_dices\n @dices = Hazard.s2d6\n end",
"def compute_damage\n rand(1..6)\n end",
"def die\n @dead = true\n @level = 1\n @visibleTreasures.each {|t| CardDealer.instance.giveTreasureBack(t)}\n @visibleTreasures.clear\n @hiddenTreasures.each {|t| CardDealer.instance.giveTreasureBack(t)}\n @hiddenTreasures.clear\n end",
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end",
"def depreciated_msrp_used_car (deprec_mspr: depreciated_msrp(msrp:, year:),damages:, mileage:)\n depreciation_rate = 0.05\n mileage_depreciation = (mileage/10000) * 0.01\n current_year = 2014\n depreciated_msrp(msrp:, year:)\n msrp * (1 - (depreciation_rate * (current_year-year)))\nend",
"def rest\n @total_damage = @total_damage - 0.1 * strength\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def get_calories_burnt(dist, wt, hp, gain)\n \ttotal_calories = cal_per_pound_per_mile(dist, wt, hp) + calories_elevation_gain(gain) \n end",
"def cost\n deductible * RATE\n end",
"def attack_resolver(attacker, defender)\n damage = (attacker.power * rand).to_i\n defender.update(current_health: (defender.current_health - damage).clamp(0,defender.max_health))\n damage\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def undisbursed_amount_factor\n disbursement_remaining.to_f / Country.max_disbursement_remaining\n end",
"def compute_damage\nreturn rand(1..6) * @weapon_lvl\nend",
"def current_treasure_balance\n current_hand_treasure_balance + (self.treasure || 0)\n end",
"def perfect_material_efficiency\n (0.02 * self.blueprint.waste_factor * quantity).ceil\n end",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def deposit\n if admin_use\n 0\n elsif estimated_numbers < 20\n 150\n elsif estimated_numbers < 40\n 300\n else\n 600\n end\n end",
"def duns_number; end",
"def take_damage(_amount)\n\t\t@temp_hp -= _amount\n\t\tif (temp_hp < 0)\n\t\t\t@current_hp += @temp_hp\n\t\t\t@temp_hp = 0\n\t\tend\n\t\tleftover = @current_hp\n\t\t@current_hp = 0 if @current_hp < 0\n\t\tleftover\n\tend",
"def treasure_drop(enemy)\n if rand(100) < enemy.treasure_prob\n treasure = $data_items[enemy.item_id] if enemy.item_id > 0\n treasure = $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0\n treasure = $data_armors[enemy.armor_id] if enemy.armor_id > 0\n end\n return treasure\n end",
"def get_damage\n 1 + Random.rand(3)\n end",
"def union_dues_amount\n if (uniondues == true)\n return ( find_base_wage() * SystemVariable.value(:union_dues) ).floor\n else\n return 0\n end\n end",
"def required_gold(equip)\n equip.price / 4\n end",
"def total_blocks\n weapon_class_ids = self.equipped_weapons.reduce([]) do |acc, weapon|\n acc + weapon.weapon_class_ids\n end\n skills_hash = skills_ranks_hash\n total = self.equipped_weapons.length + skills_bonus(skills_hash, :bonus_blocks, weapon_class_ids)\n \"#{total} + #{self.equipped_weapons.length} panic block(s) for half your next offense budget\"\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end",
"def rental_car_cost(d)\n total = d * 40\n\n if d >= 3 && d < 7\n total - 20\n elsif d >= 7\n total - 50\n else\n total\n end\nend",
"def overall_KDR\n overall_deaths = 0\n overall_kills = 0\n @player_champs_list.each do |champ|\n overall_deaths += champ.total_deaths\n overall_kills += champ.total_kills\n end\n overall_deaths > 0 ? (overall_kills.to_f / overall_deaths).round(2) : overall_kills.to_f\n end",
"def total_sodium\n food.sodium * quantity\n end",
"def take_damage(damage)\n damage_taken = 0\n dodge_roll = rand((self.agility + ((self.dodgeFlag && 1 || 0) * DODGE_ACTIVATE_VALUE)) .. DODGE_RANGE_UPPER)\n if !dodge_roll.between?(DODGE_RANGE_LOWER, DODGE_RANGE_UPPER)\n damage_taken = damage - (damage * (self.defense / 100.0)).to_i\n self.health -= damage_taken\n self.dodgeFlag = false;\n self.save\n end\n damage_taken\n end",
"def suitable_quaters\n required_amount * 2\n end",
"def get_damage_string\n \"1d3\"\n end",
"def total_drinking\n breast_feedings.sum(:quantity)\n end",
"def debit_amount\n sum( debits )\n end",
"def total_demand_for_electricity\n final_demand_for_electricity +\n non_final_demand_for_electricity +\n electricity_losses_if_export_is_zero\n end",
"def d6_damage\n dmg = 0\n if (match = damage.match /\\A\\s*\\d*(\\s*\\+?\\s*(\\d*)[dw]6(\\/\\d+)?)\\s*\\Z/)\n dmg = (match[2].blank? ? 1 : match[2]).to_i\n unless match[3].nil?\n dmg = \"#{dmg}#{match[3]}\"\n end\n end\n dmg\n end",
"def try( d=0 )\r\n\t\t\t@damaged += d\r\n\t\t\t@damaged = [ 0, @damaged ].max\r\n\t\t\t@damaged = [ @damaged, 20 ].min\r\n\t\t\treturn true if @damaged == 0\r\n\t\t\treturn false if @damaged == 20\r\n\t\t\tch = Die.roll(20)\r\n\t\t\treturn true if ch > @damaged\r\n\t\t\t@damaged = 20\r\n\t\t\treturn false\r\n\t\tend",
"def purchase_unit_factor\n return 1 if unit_id == inventory_unit_id\n return 1 / (pack_size || 1) if inventory_unit_id == pack_unit_id\n return 1 / (pack_size || 1) / (subpack_size || 1) if inventory_unit_id == subpack_unit_id\n 1\n end",
"def calculate_calories(bodyweight)\n\ttotal_calories = bodyweight * 13\n\treturn total_calories\nend",
"def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end",
"def calculate_with_fuel\n s = 0\n res = calculate\n until res.zero?\n s += res\n @mass = res\n res = calculate\n end\n s\n end",
"def total_digestate_potash\n\t\t(calculations.collect(&:calc_digestate_potash).sum).round 3\n\tend",
"def dices\n\t\t@rollAgain = 0\n\t\t@goalParam = 0\n\tend",
"def total_food_produced\n total_food_from_corn_field = 0\n total_food_from_wheat_field = 0\n total_food_produced = total_food_from_corn_field + total_food_from_wheat_field\n #i wonder why the program did not read the earlier variable that I had set\n #loop through all the fields to understand the crops from all the fields\n #It should also tell you how much total food you have produced up until this point.\n @@all_fields.each do |individual_field|\n #if corn field multiply acres by 20\n if individual_field.field_type == \"corn\"\n #add that new number to total_food_produced variable\n total_food_from_corn_field += (20 * individual_field.field_size) \n total_food_produced += (20 * individual_field.field_size) \n #print how much food you got from the corn field\n p \"you have collected #{total_food_from_corn_field} from your #{individual_field.field_type} field\"\n #if wheat field multiply acres by 30\n elsif individual_field.field_type == \"wheat\"\n #add that new number to total_food_produced variable\n total_food_from_wheat_field += individual_field.field_size * 30\n total_food_produced += (30 * individual_field.field_size) \n #print how much food you got from the wheat field\n p \"you have collected #{total_food_from_wheat_field} from your #{individual_field.field_type} field\"\n end \n total_food_from_corn_field = 0\n total_food_from_wheat_field = 0\n end \n total_food_produced\n end"
] | [
"0.7306968",
"0.7062871",
"0.67312354",
"0.6250499",
"0.6203436",
"0.6071911",
"0.5998456",
"0.59247434",
"0.58888775",
"0.5837822",
"0.5813173",
"0.576703",
"0.5750905",
"0.57507527",
"0.5738145",
"0.5713314",
"0.5705598",
"0.5689485",
"0.568548",
"0.56659275",
"0.5660439",
"0.56588244",
"0.5650135",
"0.5646257",
"0.5645337",
"0.5645337",
"0.5641141",
"0.56350815",
"0.56343883",
"0.5633725",
"0.5629187",
"0.56277466",
"0.5626611",
"0.5623241",
"0.5612291",
"0.5609637",
"0.56068057",
"0.55787385",
"0.55782574",
"0.5576338",
"0.55759543",
"0.5571438",
"0.5565046",
"0.55643994",
"0.55640167",
"0.55613405",
"0.55523777",
"0.5539879",
"0.5538726",
"0.5534673",
"0.553267",
"0.55319",
"0.55319",
"0.5529467",
"0.551787",
"0.55170345",
"0.55165786",
"0.55011797",
"0.5495107",
"0.5488536",
"0.548741",
"0.5477629",
"0.54727405",
"0.5464815",
"0.54644424",
"0.5461972",
"0.5455511",
"0.5451813",
"0.5448395",
"0.5442449",
"0.5441726",
"0.5439088",
"0.54359955",
"0.54352033",
"0.5432359",
"0.54267913",
"0.5424987",
"0.5415799",
"0.54140574",
"0.53853977",
"0.5384418",
"0.5374206",
"0.53716594",
"0.536919",
"0.53678113",
"0.5361359",
"0.5359842",
"0.53478384",
"0.5344867",
"0.5338211",
"0.5337538",
"0.53322065",
"0.5330857",
"0.5329352",
"0.5322591",
"0.53214794",
"0.53078204",
"0.5301414",
"0.52993447",
"0.52981555"
] | 0.7039593 | 2 |
Returns user's collection ID | def coll_id
current_user.collection.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_collection_id()\r\n return @coll_id\r\n end",
"def id\n @collection.id\n end",
"def set_collection\n @collection = User.find(current_user.id).collections.find(params[:id])\n end",
"def set_collection\n @collection = current_user.collections.find(params[:id])\n end",
"def set_collection\n @collection = current_user.collections.find_by(id: params[:id]) if current_user\n end",
"def set_collection_user\n @collection_user = CollectionUser.find(params[:id])\n end",
"def set_collection\n @collection = user_collections.detect{ |c| c.id.to_s == params[:id] }\n end",
"def set_user_collection\n @user_collection = UserCollection.find(params[:id])\n end",
"def stored_collection_id\n is_member_of = object_relations.uri_predicate(:is_member_of)\n has_description = object_relations.uri_predicate(:has_description)\n collection_id ||\n ead_id ||\n object_relations.relationships[is_member_of].first.try{|m| m.gsub(\"info:fedora/\", \"\")} ||\n object_relations.relationships[has_description].first.try{|m| m.gsub(\"info:fedora/\", \"\")}\n end",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def collection_id\n @collection_id ||= (\n n = val_to_id(@xml.at('/ead/eadheader/eadid').text)\n n.empty? ? @file_id : n\n )\n end",
"def collection\n mongo_session[collection_name]\n end",
"def set_users_collection\n @users_collection = Users::Collection.find(params[:id])\n end",
"def collection\n database[collection_name]\n end",
"def collection\n mongo_session[collection_name]\n end",
"def collection\n @collection ||= PublicEarth::Db::Collection.find_by_id!(collection_id)\n end",
"def get_collection_name()\r\n result = nil\r\n if @coll_id #if coll_id is false, than collection_service is used by environment\r\n info = Transformer::KeyBuilder.collection_info(@env_id, @coll_id)\r\n result = @db_interface.get_hash_value(info, Transformer::KeyBuilder::NAME_KEY)\r\n end\r\n return result\r\n end",
"def current_users_collections\n if current_user.respond_to?(:collections)\n current_user.collections.to_a\n else\n Collection.all\n end\n end",
"def index\n @@is_current_user_admin = signed_in? && current_user[:admin]\n\n @current_user_collections = if signed_in?\n (\n Collection.where(user_id: current_user).map do |collection|\n [collection.name, collection.id]\n end\n )\n end\n\n end",
"def select_collection(name)\n\t\t@collection = @userdb.collection(name)\n\tend",
"def collector\n ep = collection_event_parameters\n ep.user if ep\n end",
"def collection_id\n super.map { |url| URI(url).path.sub('/', '') }\n end",
"def user_id\n @current_user.id\n end",
"def ead_id\n URI.parse(self.collection_uri).path.split(\"/\").last unless self.collection_uri.nil?\n end",
"def show\n\n @collection = @current_user.collections.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collection }\n end\n end",
"def user\n @mongodb_uri && @mongodb_uri.credentials[:user]\n end",
"def collection\n @collection ||= self.db.collection(self.collection_name)\n end",
"def auth_user_id\n auth[:user_id]\n end",
"def collection\n @user = User.find params[:id]\n\t if (@user.id == current_user_or_guest_id)\n response_service.title = \"My Whole Collection\"\n @empty_msg = \"Nothing here yet...but that's what the #{view_context.link_to_submit 'Cookmark Button', '/popup/starting_step2'} is for!\".html_safe\n @active_menu = :collections\n else\n response_service.title = \"#{@user.handle}'s Collection\"\n @empty_msg = \"They haven't collected anything?!? Why not Share something with them?\"\n @active_menu = :friends\n end\n smartrender unless do_stream UserCollectionCache\n end",
"def id\r\n return @user.id\r\n end",
"def id\n @data[:user_id]\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n @user_id ||= self.user ? self.user.to_global_id : nil\n end",
"def user_id\n @current_user.id if !@current_user.nil? && users.include?(@current_user)\n users.first.id\n end",
"def user_id\n username\n end",
"def current_user_id\n 1\n end",
"def current_user_id\n info['user']['id']\n end",
"def find_collection\n @collection = Collection.find(params[:id])\n end",
"def user_id\n self.user.id unless user.nil?\n end",
"def userid\n userids&.first\n end",
"def index\n @collections = current_user.collections\n end",
"def current_user_id\n @server.current_user_id\n end",
"def id\n self.user_id\n end",
"def user_id\n user.id\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 fetchUserByID(collection, userName)\n query = Hash.new()\n query = {\n :username => userName,\n \"approval_status.code\" => 1 \n }\n return collection.find(query)\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 collection\n @collection ||= mongo.collection(Boom.config.attributes[\"mongodb\"][\"collection\"])\n end",
"def collection_name\n __evaluate__(storage_options[:collection])\n end",
"def orchestrate_collection_name\n ocollection\n end",
"def orchestrate_collection_name\n ocollection\n end",
"def get_user_collections()\n uri = build_uri('info/collections')\n @tools.process_get_request(uri, @user_obj.encrypted_login, @user_pwd).body\n end",
"def collection_name\n @collection_name ||= self.to_s.tableize.gsub(/\\//, '.')\n end",
"def user_id; 1; end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def user_id_for(user)\n find(user.id, user.login)\n end",
"def get_collection_key(args)\n\tapi_url = \"#{base_url}/#{args[:collection]}/#{args[:key]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend",
"def full_collection_name\n \"#{app_id}.#{name}\"\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def user_id\n self.user.id\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def id\n doc['_id']\n end",
"def find_in_collection(id)\n collection.find_by_id(id)\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:id])\n end",
"def set_collection\n @collection = Collection.find(params[:collection_id])\n end",
"def get_collection(database_id:, collection_id:)\n path = '/databases/{databaseId}/collections/{collectionId}'\n .gsub('{databaseId}', database_id)\n .gsub('{collectionId}', collection_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"collectionId\"')\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::Collection\n )\n end",
"def user_id\n @raw['user']['id']\n end",
"def collection_path\n self.class.collection_path\n end",
"def collection_details(db, coll_name)\n if (result = db.collection('__METADATA__').find_one('_id' => coll_name)) == nil\n raise \"collection does not exist\"\n end\n return result\n end",
"def get_mongo_id\n 'mongo-myMongo'\n end",
"def GetUserId(user)\r\n \r\n mongoSession = Moped::Session.new(['127.0.0.1:27017']) # our mongo database is local\r\n mongoSession.use(\"enhabit\") # this is our current database\r\n\r\n begin\r\n queryObj = Hash.new\r\n queryObj[\"Username\"] = user\r\n \r\n account = Array.new\r\n mongoSession.with(safe: true) do |session|\r\n account = session[:accounts].find(queryObj).to_a\r\n end\r\n \r\n if account.count == 0\r\n return nil\r\n else\r\n return account[0][\"UserId\"]\r\n end\r\n rescue Moped::Errors::OperationFailure => e\r\n return nil\r\n end\r\nend",
"def collection_site\n return unless medical_identifiers.size == 1\n site = medical_identifiers.first.site\n return if site.nil?\n site.site_type == Site::SiteType::COLLECTION ? site : nil\n end",
"def collection_ids\n # Get the ids of the existing collections from the form.\n collection_ids = Hash(collections_for_registration).values.map { |elem| elem.fetch(:id) }\n if collection_radio == \"create\"\n collection_ids << create_collection(model.externalIdentifier)\n elsif collection[:collection].present? # guard against empty string\n collection_ids << collection[:collection]\n end\n collection_ids\n end",
"def id\n @uid\n end",
"def curAuth\n current_user.role_ids[0]\n end",
"def collections_coll\n settings.db['collections']\n end",
"def collection_name; end",
"def collection_name; end"
] | [
"0.787871",
"0.75485414",
"0.7346955",
"0.7140479",
"0.71065795",
"0.70943207",
"0.706617",
"0.6924091",
"0.6712702",
"0.65566456",
"0.6532065",
"0.6513397",
"0.65081376",
"0.6499959",
"0.6488324",
"0.64867777",
"0.64555883",
"0.6444607",
"0.6385404",
"0.6370033",
"0.6331714",
"0.63212913",
"0.63061",
"0.626639",
"0.62490886",
"0.623423",
"0.6233074",
"0.6218121",
"0.6202765",
"0.61869705",
"0.6180668",
"0.61763066",
"0.61763066",
"0.61763066",
"0.61763066",
"0.61763066",
"0.61763066",
"0.6173477",
"0.61371803",
"0.6125768",
"0.61034954",
"0.6086223",
"0.6066553",
"0.6061655",
"0.6059883",
"0.6052341",
"0.60384554",
"0.60297483",
"0.601606",
"0.60079634",
"0.60029006",
"0.5998636",
"0.59880584",
"0.5985572",
"0.598538",
"0.598538",
"0.596592",
"0.59573054",
"0.59495956",
"0.5938136",
"0.5938136",
"0.5927395",
"0.59053427",
"0.58981717",
"0.5896997",
"0.5896997",
"0.5896997",
"0.5889645",
"0.5883946",
"0.5883946",
"0.5883946",
"0.5883946",
"0.5881761",
"0.5875906",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.5873047",
"0.58714354",
"0.58714354",
"0.58625644",
"0.5861597",
"0.58401257",
"0.5819904",
"0.58152723",
"0.5812575",
"0.58120626",
"0.5810891",
"0.5803701",
"0.57958114",
"0.57957983",
"0.5793893",
"0.5785251",
"0.5785251"
] | 0.86051685 | 0 |
Returns tracked deck ID | def tracked_deck_id(tracked_deck)
tracked_deck.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_guessed_card\n current_round.guesses.last.card_id\nend",
"def card_id\n card.id\n end",
"def deck\n \"TK DECK\"\n end",
"def current_card\n @deck.cards[0]\n end",
"def current_card\n @deck.cards[@turns.count]\n end",
"def game_id\n @id\n end",
"def game_id\n service.game_id\n end",
"def current_card\n deck.cards[@number_correct]\n end",
"def current_card\n @deck.cards[count]\n end",
"def track_id\n @ole.trackID\n end",
"def track_id\n @ole.trackID\n end",
"def track_id\n @ole.trackID\n end",
"def track_id\n @ole.trackID\n end",
"def find_deck\n\t\tcurrent_user.decks.find(params[:id])\n\t\t#Deck.find(params[:deck_id])\n\tend",
"def card_set_id(c)\n CardSet.find_by(name: c['card_set']).id\nend",
"def facture_id\n @facture_id ||= data[:id][0..31]\n end",
"def get_id()\n return @id\n end",
"def track_to_id\n self.computer_id = (entertrack - 10000000)\n end",
"def GetCardId(db, setId, name, id)\n\treturn db.execute(\"\n\t\tSELECT\n\t\t\tCardId \n\t\tFROM \n\t\t\tCard\n\t\tWHERE\n\t\t\tName = ? AND SetId = ? AND Id = ?\n\t\t;\",[\n\t\t\tname, \n\t\t\tsetId,\n\t\t\tid,\t\t\n\t\t])\nend",
"def find_deck\n\t\tcurrent_user.decks.find(params[:deck_id])\n\t\t#Deck.find(params[:deck_id])\n\tend",
"def last_id()\n #This is a stub, used for indexing\n end",
"def get_deck\r\n session[:deck] || Deck.new(:title => \"untitled deck\")\r\n end",
"def set_card_id\n\t\tself.card_id = self.deck.flashcards.count + 1\n\tend",
"def id\n @id ||= Time.now.utc.to_i\n end",
"def get_id()\n return @id\n end",
"def get_game_id()\n res = @db.query(\"SELECT MAX(GameID) FROM SavedGames;\");\n row = res.fetch_row\n row[0].to_i\n end",
"def id\n return @playing_girl ? @id_girl : @id_boy\n end",
"def get_card()\n card = @cards[@deck_index % @max_deck_mod]\n @deck_index += 1\n if @deck_index == @max_deck_mod\n #recreate shoe\n puts \"\\n\\n****CREATING NEW DECK****\\n\\n\"\n create_deck(@num_decks )\n end\n return card\n end",
"def get_current_rev\n\t\t\tid = read_command_output( 'hg', '-q', 'identify' )\n\t\t\treturn id.chomp\n\t\tend",
"def get_card\n @deck.pop\n end",
"def get_id(symbol)\n return 0 if symbol == :__undef__\n\n pokemon = @data.index { |data| data[0].db_symbol == symbol }\n return pokemon || 0\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def card_identification\n message.fields[6].strip\n end",
"def id\n @id ||= Chunk.random_id\n end",
"def edit\n @current_deck = Deck.find(params[:id])\n end",
"def get_id()\n @id\n end",
"def get_id()\n @id\n end",
"def getId()\n\t\t\treturn @_id\n\t\tend",
"def get_id\n @id ||= 0\n @id += 1\n @id\n end",
"def get_player_id\n\t\t@player_id\n\tend",
"def id\n @__metadata__.key || @id\n end",
"def getCardById(deck,id)\n deck.each do |card|\n return card if card.id == id\n end\n return nil\nend",
"def track\n departure.track_number || TRACK_PLACEHOLDER\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def set_deck\n @deck = Deck.find(params[:id])\n end",
"def number\n return suggested_play_order || identifier\n end",
"def id\n @grit_commit.id\n end",
"def get_id\n\t\treturn id\n\tend",
"def tracker_key\n Card.config.google_analytics_tracker_key || google_analytics_keys.first\nend",
"def set_deck\n @deck = Deck.find(params[:deck_id])\n end",
"def id; frame[:id]; end",
"def id\n unitid.to_i\n end",
"def ref_id\n 300_000_000 + data[0].to_i\n end",
"def id\n @grit_commit.id\n end",
"def oid\n id(get_oid())\n end",
"def id()\n #This is a stub, used for indexing\n end",
"def druid\n id.split(/:/).last\n end",
"def getDeck(name = @cur_deck_name)\n\n end",
"def local_id; end",
"def get_id(symbol)\n return 0 if symbol == :__undef__\n\n data = @data.index { |item| item.db_symbol == symbol }\n data || 0\n end",
"def _id\n self.__source.persisted? || self.__source.embedded? ? self.__source._id.to_s : nil\n end",
"def tracking_id\n settings.tracking_id\n end",
"def tuid\n self.player_id.to_s + self.team_id.to_s\n end",
"def id_number; end",
"def card\n\t @dance_card\n\tend",
"def winner_prize_id\n @game.detect {|f| !f[:bot] }[:prize][:id]\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def object_id() end",
"def track_number\n @ole.TrackNumber\n end",
"def find_noteable_id\n GithubImport::IssuableFinder.new(project, note).database_id\n end",
"def real_id\n @id\n end",
"def real_id\n @id\n end",
"def generate_packet_id\n self.class.current_id ||= 0\n self.class.current_id += 1\n end",
"def api_id\n chip_api.tmp_api_id\n end",
"def game_key\n service.game_key\n end",
"def get_next_game_id\n log_everything(\"Get next game id\")\n # get current registered game id\n retrieved_game_id_number = craft_firebase_command(\"minesweeper/game_id.json\").to_i\n game_id = retrieved_game_id_number + 1\n\n # update game id (increment by 1)\n craft_firebase_command(\"minesweeper/game_id.json\", \"PUT\", game_id)\n\n # return current game id\n game_id\nend",
"def next\n\t self.class.where(\"deck_id == ?\", deck_id).where(\"id > ?\", id).first\n\tend",
"def id\n @gid\n end",
"def get_card (random_num)\n\t\t@deck[random_num]\n\tend",
"def get_card\n all_cards = self.deck.cards\n correct_cards = self.guesses.where(correct: true).map { |guess| guess.card }\n (all_cards - correct_cards).shuffle.sample\n end",
"def digitool_id\n return nil if @mods.nil?\n return @mods.digitool_ids.first\n end",
"def get_id\n return @m_id\n end",
"def get_id\n return @m_id\n end",
"def get_id\n return @m_id\n end",
"def get_id\n return @m_id\n end",
"def get_id\n return @m_id\n end",
"def hand_over_dealer\r\n puts \"Dealer getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @dealer_deck[@random_card] = random_card_val # to dealer\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@dealer_deck = #{@dealer_deck}\"\r\n end",
"def get summoner_id\n perform_request(api_url(\"matchhistory/#{summoner_id}\"))\n end",
"def led_suit\n @game.king.split(\"_\")[0]\n end",
"def id\n hid\n end",
"def set_deck\n @deck = Deck.find(params[:deck_id])\n end",
"def id\n wallet_token\n end",
"def take_card\n @deck.shift\n end"
] | [
"0.6738969",
"0.6412447",
"0.62486315",
"0.61921483",
"0.6138566",
"0.61309654",
"0.61103064",
"0.6102644",
"0.6070289",
"0.6045724",
"0.6045724",
"0.6045724",
"0.6045724",
"0.5985913",
"0.594382",
"0.5891126",
"0.5863037",
"0.586269",
"0.5846808",
"0.58039325",
"0.57911664",
"0.57613343",
"0.57380337",
"0.57235134",
"0.57156104",
"0.57064503",
"0.57056576",
"0.570337",
"0.56775403",
"0.5669023",
"0.5636732",
"0.5622642",
"0.5622642",
"0.5622642",
"0.56077564",
"0.56059927",
"0.5567021",
"0.5559871",
"0.5559871",
"0.55596966",
"0.5554996",
"0.5521124",
"0.5517498",
"0.55118597",
"0.55104524",
"0.55090684",
"0.55090684",
"0.55090684",
"0.55090684",
"0.55090684",
"0.55090684",
"0.5505016",
"0.5500743",
"0.5485915",
"0.5474725",
"0.5468769",
"0.5461421",
"0.54522425",
"0.5441671",
"0.5439344",
"0.54328084",
"0.5430193",
"0.5429933",
"0.54272765",
"0.5425221",
"0.5422578",
"0.54209983",
"0.542037",
"0.5414424",
"0.5405294",
"0.5403425",
"0.538875",
"0.538453",
"0.538453",
"0.5384522",
"0.5380438",
"0.5380118",
"0.53757197",
"0.53757197",
"0.53750926",
"0.53748333",
"0.537007",
"0.5368111",
"0.53675026",
"0.5360034",
"0.53569055",
"0.5353286",
"0.5351204",
"0.5346848",
"0.5346848",
"0.5346848",
"0.5346848",
"0.5346848",
"0.53462636",
"0.5345392",
"0.5344746",
"0.5343752",
"0.53424215",
"0.5340028",
"0.5339533"
] | 0.8802808 | 0 |
Returns dust total for cards | def dust_total(cards)
cards.inject(0) do |dust_total, card|
dust_total + dust_value(card.rarity)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def craft(dust, cards)\n\t\tn = 0\n\t\tfor card in cards\n\t\t\tif !card.complete?\n\t\t\t\tmissing = card.numMissing\n\t\t\t\tif missing * card.craft_cost <= dust\n\t\t\t\t\tdust -= missing * card.craft_cost\n\t\t\t\t\tcard.addCopies(missing)\n\t\t\t\t\tn += missing\n\t\t\t\telsif card.craft_cost <= dust\n\t\t\t\t\tdust -= card.craft_cost\n\t\t\t\t\tcard.addCopy\n\t\t\t\t\tn += 1\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn dust, n\n\tend",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def dust_needed(tracked_deck)\n\t\tdeck_not_collection_cards = deck_not_collection_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tquantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))\n\t\tdust_total(quantity_diff_cards) + dust_total(deck_not_collection_cards)\n\tend",
"def total\n total = 0\n aces = 0\n @hand.each do |card|\n case card[0]\n when 2..10 then total += card[0]\n when 'A' then aces += 1\n else total += 10\n end\n end\n total += add_aces(total, aces)\n total\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n return total\nend",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n total\nend",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def total\n total = with_product_discounts\n total = with_basket_discounts(total)\n return \"£#{total}\"\n end",
"def disenchantGoldens\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1]\n\t\t\textras = card.removeAll\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def initial_round\n card_total = deal_card + deal_card\n display_card_total(card_total)\n card_total\nend",
"def total_drinking\n breast_feedings.sum(:quantity)\n end",
"def dust_value(card_rarity)\n\t\tcase card_rarity\n\t\twhen \"Free\"\n\t\t\treturn 0\n\t\twhen \"Common\"\n\t\t\treturn 40\n\t\twhen \"Rare\"\n\t\t\treturn 100\n\t\twhen \"Epic\"\n\t\t\treturn 400\n\t\twhen \"Legendary\"\n\t\t\treturn 1600\n\t\tend\n\tend",
"def total(cards)\n values = cards.map { |card| card[1] } # this map method iterates through each card ([S, V]) and returns the value of the card from the second spot in the individual card array\n\n sum = 0 # initialize the sum variable that will be used to total the card values\n values.each do |value| # iterate through each value\n if value == \"A\" # if the card is an Ace, add 11 to the sum\n sum += 11\n elsif value.to_i == 0 # if the card's value is 0 when converted to an int, that means it is a face card and should be worth 10\n sum += 10\n else\n sum += value.to_i # otherwise, convert the value to an integer and add that to the sum\n end\n end\n\n # adjust aces if sum is greater than 21\n values.select { |value| value == \"A\" }.count.times do # iterate through the card values array, finding the aces.\n sum -= 10 if sum > MAX_VALUE # If the sum is greater than 21, subtract 10 from each ace, making the aces only worth 1\n end\n\n sum # return the sum\nend",
"def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend",
"def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend",
"def saldo_total\n ias = object\n .inventory_articles\n .select { |ia| ia.inventory_id == current_inventory.id }\n\n return 0 unless ias.length > 0\n\n ias.first.count\n end",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def total_cards\n cards.count\n end",
"def total_debt\n self.amount\n end",
"def display_card_total(total)\n puts \"Your cards add up to #{total}\"\nend",
"def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend",
"def dollar_total\n total / 100.0\n end",
"def total_yards\n data[:total_yards]\n end",
"def sum_of_charges\n Transaction.where(card_id: self.id).sum(:amount)\n end",
"def current_total_amount\n\n if calculate_total(session[:player_cards]).to_i == BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:player_cards]).to_i > BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:dealer_cards]).to_i > BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i == BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:player_cards]).to_i > calculate_total(session[:dealer_cards]).to_i\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i > calculate_total(session[:player_cards]).to_i\n session[:player_pot] -= session[:player_bet].to_i \n else\n session[:player_pot]\n end # ends if statement\n end",
"def subtotal\n debt_claim_items.reject(&:marked_for_destruction?).sum(&:debt)\n end",
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end",
"def security_deposit_sum\n @cart.security_deposit\n end",
"def total_vat_amount\n hash[\"TotalDutiesPrice\"]\n end",
"def total\n total_no_shipping = super\n total = nil\n if total_no_shipping == 0\n total = 0\n else#total_no_shipping != 0\n total = total_no_shipping + 10\n end\n return total\n end",
"def total_debt\n Money.new(all_debts.sum { |_, debt| debt }, 'PLN')\n end",
"def display_card_total(card_total)\n puts \"Your cards add up to #{card_total}\"\n card_total\nend",
"def cards_total(cards) #private method, so could not be used in test\n total = 0 #unitilized variable\n for card in cards\n total += card.value\n end # return statment was in middle of for loop\n return \"You have a total of\" + total.to_s #no implicit conversion of Integer into String\n\nend",
"def current_subtotal\n debt_claim_items.reject(&:marked_for_destruction?).sum(&:current_debt)\n end",
"def total_before_disc_amount\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/_lblBeforeDiscountsAmount$/\"),\n format_method(__method__))\n end",
"def total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end",
"def total_amount_before_modifier\n sale_amount + discount_amount + tax_amount + shipping_amount\n end",
"def customer_credits_total\n applied_credits.map {|h| h[:amount]}.flatten.reduce(:+).to_i || 0\n end",
"def total_before_disc_amount\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/_TotalBeforeDiscountsLabel$/\"),\n format_method(__method__))\n end",
"def calculate_taxes\n\n character_name = player_character.base_card.name\n\n case character_name\n when 'merchant'\n colour = 'green'\n\n when 'king'\n colour = 'yellow'\n when 'warlord'\n colour = 'red'\n else\n colour = 'blue'\n end\n purple_district = districts_on_game.where(\"colour = 'purple'\")\n colour_recount = cards.districts.where(\"state = 'ONGAME' AND colour = ?\", colour).count + (purple_district.exists?([\"name = 'school_magic'\"])? 1:0)\n end",
"def display_card_total(player_hand, dealer_hand, dealer_turn)\n\tplayer_total = get_player_total(player_hand).to_s\n\tdealer_total = get_dealer_total(dealer_hand,dealer_turn).to_s\n\t\n\tputs\n\tputs \"Total\" + (\" \" * (8 - player_total.length)) + player_total + (\" \" * (17 - dealer_total.length)) + dealer_total\n\nend",
"def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend",
"def calculate_total(cards)\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n total\n end",
"def calculate_totals(cards) \n card_values = cards.map{|card| card[1]}\n total_socre = 0\n card_values.each do |value|\n if value == \"Ace\"\n total_socre += 11\n elsif value.to_i == 0\n total_socre += 10\n else\n total_socre += value.to_i\n end\n end\n#correct for Aces\n card_values.select {|e| e == \"Ace\"}.count.times do\n total_socre -= 10 if total_socre > 21\n end\n total_socre\nend",
"def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def calculate_total\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n @total = total\n end",
"def total_cash(petshop)\n return petshop[:admin][:total_cash]\n end",
"def game_value(cards)\n sum = 0\n cards.each do |card|\n sum += card.game_value\n end\n sum\nend",
"def card_stats\n stats = {\n colors: {\n W: 0,\n U: 0,\n B: 0,\n R: 0,\n G: 0,\n C: 0,\n M: 0,\n total: 0\n },\n types: {\n creature: { count: 0, subtypes: {} },\n enchantment: { count: 0, subtypes: {} },\n instant: { count: 0, subtypes: {} },\n land: { count: 0, subtypes: {} },\n sorcery: { count: 0, subtypes: {} },\n planeswalker: { count: 0, subtypes: {} },\n artifact: { count: 0, subtypes: {} },\n },\n cmc: {\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n 5 => 0,\n 6 => 0,\n },\n counts: {\n creature: 0,\n nonCreature: 0,\n land: 0,\n nonLand: 0,\n },\n rarity: {\n common: 0,\n uncommon: 0,\n rare: 0,\n mythic: 0,\n special: 0,\n bonus: 0\n },\n cards: 0,\n }\n\n cards = self.cards\n # Iterates over every card and updates stats object\n cards.each do |card|\n multiplier = card.deck_quantity(id).quantity\n\n # Increment total cards\n stats[:cards] += multiplier\n\n\n # Card types, they have been stringified so we must parse them\n card_types = card.card_types\n types = stats[:types]\n\n\n # Counts the card types\n card_types.each do |type|\n lower_type = type.downcase().to_sym\n \n if types[lower_type]\n types[lower_type][:count] += multiplier\n end\n \n \n # Counts the card subTypes\n card.subtypes&.each do |subtype|\n lower_subtype = subtype.downcase().to_sym\n\n if types[lower_type] && types[lower_type][:subtypes] && types[lower_type][:subtypes][lower_subtype]\n types[lower_type][:subtypes][lower_subtype] += multiplier\n elsif types[lower_type] && types[lower_type][:subtypes]\n types[lower_type][:subtypes][lower_subtype] = multiplier\n end\n end\n end\n\n\n # Counts multicolored cards and individual colors\n if card.color_identity.length > 1\n stats[:colors][:M] += multiplier\n end\n\n \n\n # Artifacts do not have colors, so we increment colorless\n if (card.color_identity.length === 0) \n stats[:colors][:C] += multiplier\n stats[:colors][:total] += multiplier\n end\n \n \n \n # Otherwise we update the color identity\n card.color_identity.each { |color|\n stats[:colors][color.to_sym] += multiplier\n stats[:colors][:total] += multiplier\n }\n\n\n # if the card is a land we just need to up the land count. Otherwise we set a few more counts\n if (card.card_type.include?('Basic Land')) \n stats[:counts][:land] += multiplier\n else\n stats[:counts][:nonLand] += multiplier\n\n \n # Updates counts for creatures and nonCreatures\n if card_types.include?('Creature')\n stats[:counts][:creature] += multiplier\n else\n stats[:counts][:nonCreature] += multiplier\n end\n\n # Gets converted mana cost counts\n card_cmc = card.converted_mana_cost\n \n # Increments 1 mana for 1 or 0 cmc\n if (card_cmc <= 1) \n stats[:cmc][1] += multiplier\n \n # Increments 6 mana for 6 or more cmc\n elsif (card_cmc >= 6) \n stats[:cmc][6] += multiplier\n \n # Otherwise we increment what's in-between as long as it's not a land\n else\n stats[:cmc][card_cmc.to_i] += multiplier\n end\n \n # counts card rarity, doesn't include basic lands\n stats[:rarity][card.rarity.to_sym] += multiplier\n end\n\n\n end\n\n stats\n end",
"def calculate_total(cards)\n\tarr = cards.map { |e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value|\n\t\tif value == 'A'\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #only works for J, Q, K\n\t\t\ttotal += 10\n\t\telse\n\t\t\ttotal += value.to_i\n\t\tend\n\tend\n\t#Code to make Aces work\n\tarr.select{|e| e == \"A\"}.count.times do\n\t\ttotal -=10 if total > 21\n\tend\n\n\tif arr.include?(\"A\") && total > 21\n\t\ttotal -= 10\n\tend\n\n\ttotal\nend",
"def credit_amount\n sum( credits )\n end",
"def remaining_total\n total\n end",
"def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end",
"def total\n self.inject(0) { |t, calculator| t + (calculator.active? ? calculator.price(@cart) : 0) }\n end",
"def totalamount\n\t\tcopies * 5\n\tend",
"def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend",
"def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end",
"def total_pay\n total = 0\n @serie_items.each do |item|\n # next if item.quantity.nil?\n total += item.quantity * item.creation.price\n end\n return total\n end",
"def total\n @total\n end",
"def total_debit_amount\n amount_sum_for(:debit?)\n end",
"def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend",
"def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end",
"def calculate_total(cards)\n total = 0\n cards.each do |c|\n if (1..10).include?(c.last.to_i)\n total += c.last.to_i\n elsif c.last == 'K' || c.last == 'Q' || c.last == 'J'\n total += 10\n elsif c.last == 'A'\n if total > 10\n total += 1\n else\n total += 11\n end\n end\n end\n total\nend",
"def pre_discount_total\n sum(:pre_discount_total)\n end",
"def total_credit_amount\n amount_sum_for(:credit?)\n end",
"def prepaid_liabilities_total\n voucher_groups.inject(Money.new(0)) { |sum, vg| sum + ( vg.cogs * vg.quantity ) }\n end",
"def pl_total\n @printer << \"You have #{session[:player].hand_total}\" if !session[:player].blackjack?\n @printer << \"You bust.\" if session[:player].bust?\n if session[:player].blackjack?\n @printer << \"BlackJack!\" \n session[:player].make_lucky\n end\n nil\n end",
"def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end",
"def total; end",
"def attack\n total_for(:attack) \n end",
"def total_duties_price\n hash[\"TotalDutiesPrice\"]\n end",
"def disenchantExtras\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards\n\t\t\textras = card.removeExtras\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def index\n @debit_cards = DebitCard.all\n @total_amount =DebitCard.total\n @transaction_number = @debit_cards.length\n if @total_amount <= 50\n @bad_total = \"WTF new shoes, now you can't pay the mortgage!!\"\n end\n end",
"def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].sum\n credits = [customer_credits_total, promo_code_total].sum\n discounts = [membership_discount_total, quantity_discount_total].sum\n\n total = line_items + fees - credits - discounts\n [total, 0].max\n end",
"def card_totals(selected_cards)\n total_value = 0\n selected_cards.each do |card|\n card_value = card[0]\n if card_value.to_i > 0\n total_value += card_value.to_i\n elsif ['J', 'Q', 'K'].include?(card_value)\n total_value += 10\n elsif card_value == \"A\" && total_value > 10\n total_value += 1\n elsif card_value == \"A\" && total_value < 10\n total_value += 11\n end\n end\n total_value\nend",
"def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend",
"def discounted_total\n line_item.total_in_cents - discount_amount\n end",
"def total\n charges.map { |x| x.total_cost.to_f }.inject(:+)\n end",
"def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend",
"def cumulative_total_before_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.price\n end#each\n return amount\nend",
"def pretotal\n total\n end",
"def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end",
"def value \r\n value = 0\r\n @cards.each do |card|\r\n value += card.value\r\n end\r\n if value > 21\r\n value = 0\r\n @cards.each do |card|\r\n if card.value == 11\r\n value += 1\r\n else\r\n value += card.value\r\n end\r\n end\r\n end\r\n value\r\n end",
"def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end",
"def membership_discount_total\n membership_fixed_total + membership_percent_total\n end",
"def total\n total = 0\n self.menu_items.each do |item|\n total += item.price\n end\n \"$#{total}\"\n end",
"def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def total\n filter = params[:filter]\n\n @total_cards = Card.filter_query(filter).count\n end",
"def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end",
"def remaining_slots\n @count = 0\n self.booked_customers.each do |booked_customer|\n @count += booked_customer.number_students.to_i\n end\n return self.cap - @count\n\n end",
"def total\n if @products == {}\n return 0 \n else\n m = 0\n @products.values.each do |v|\n m += v\n end\n\n sum = (m + (m * 0.075)).round(2)\n return sum\n end\n end",
"def total_discount(items)\n 0\n end"
] | [
"0.7352754",
"0.7171395",
"0.7079808",
"0.68658787",
"0.67936575",
"0.67681825",
"0.6722632",
"0.6616248",
"0.65452385",
"0.65284073",
"0.6528178",
"0.652529",
"0.6524382",
"0.65076166",
"0.6506992",
"0.6503395",
"0.64710736",
"0.64354193",
"0.64199483",
"0.63819104",
"0.6379664",
"0.63420606",
"0.63178027",
"0.63095325",
"0.62172914",
"0.61922044",
"0.6191484",
"0.6183856",
"0.6181676",
"0.6177229",
"0.6171985",
"0.61520386",
"0.6130369",
"0.6126952",
"0.6125759",
"0.61171496",
"0.61070836",
"0.60998034",
"0.60992956",
"0.6098692",
"0.6096372",
"0.6082745",
"0.606869",
"0.6066559",
"0.60657746",
"0.6065702",
"0.60588336",
"0.60569227",
"0.6056413",
"0.6056057",
"0.6036924",
"0.60363",
"0.60333097",
"0.6033188",
"0.6028759",
"0.6016835",
"0.5997673",
"0.59872466",
"0.5983328",
"0.5977307",
"0.5975393",
"0.5974137",
"0.5970996",
"0.596175",
"0.5960623",
"0.5957938",
"0.5945155",
"0.5943415",
"0.59343034",
"0.59293365",
"0.59214634",
"0.59175116",
"0.5907112",
"0.59015775",
"0.58991826",
"0.5896239",
"0.589445",
"0.5892574",
"0.5885356",
"0.5883541",
"0.58752894",
"0.58713967",
"0.5863985",
"0.58628196",
"0.586164",
"0.5861526",
"0.58375454",
"0.5835066",
"0.5827682",
"0.58260024",
"0.58218944",
"0.5819729",
"0.58138853",
"0.581141",
"0.5809872",
"0.5808994",
"0.58087504",
"0.58056545",
"0.58045304",
"0.5803296"
] | 0.8612727 | 0 |
Returns the dust value associated with card's rarity | def dust_value(card_rarity)
case card_rarity
when "Free"
return 0
when "Common"
return 40
when "Rare"
return 100
when "Epic"
return 400
when "Legendary"
return 1600
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend",
"def randomRarity\n\t\tr = Random.rand\n\t\tfor rarity in RARITIES\n\t\t\tif r < DISTRIBUTION[rarity]\n\t\t\t\treturn rarity\n\t\t\tend\n\t\tend \n\tend",
"def rarity\r\n 6\r\n end",
"def getRarity(defindex = \"\")\n item = nil\n item = $itemh[\"items_game\"][\"items\"][defindex]\n if(!item.nil?)\n if(!item[\"item_rarity\"].nil?)\n return item[\"item_rarity\"].to_s\n else\n return \"common\"\n end\n else\n return \"common\"\n end\nend",
"def rdmg\n arm = Speacial_Status['Armor']\n return arm[@id] != nil && arm[@id]['rdmg'] != nil ? arm[@id]['rdmg'] : 0\n end",
"def rcrt\n arm = Speacial_Status['Armor']\n return arm[@id] != nil && arm[@id]['rcrt'] != nil ? arm[@id]['rcrt'] : 0\n end",
"def rarity\n self.sets.first[1]\n end",
"def dmg\n arm = Speacial_Status['Armor']\n return arm[@id] != nil && arm[@id]['dmg'] != nil ? arm[@id]['dmg'] : 0\n end",
"def get_color_rarity\n if self.rating[\"ratingRecommendation\"].include?('Buy')\n self.rating_color = 'greenish'\n elsif self.rating[\"ratingRecommendation\"] == \"Neutral\"\n self.rating[\"ratingRecommendation\"] = \"Hold\"\n self.rating_color = 'yellowish'\n else\n self.rating_color = 'redish'\n end\n end",
"def crt\n arm = Speacial_Status['Armor']\n return arm[@id] != nil && arm[@id]['crt'] != nil ? arm[@id]['crt'] : 0\n end",
"def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end",
"def value\n card_value = @rank\n if @rank == :A\n card_value = 11\n elsif @rank == :K || @rank == :Q || @rank == :J\n card_value = 10\n end\n card_value\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def getCombatLevel\n super + @myCultistCard.getSpecialValue\n end",
"def rent_percept_for_renter\n rent_value = 0\n self.accessories.each{|accessory|\n rent_value += ((accessory.base + accessory.tarif)*( 1 + (accessory.tax/100) ))\n }\n return rent_value\n end",
"def card\n\t @dance_card\n\tend",
"def rating\n return @rating\n end",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def hand_value\n\t\treturn evaluate_hand(@hand)\n\tend",
"def dexterity_bonus\n @character.dexterity_modifier\n end",
"def value\n return @value if @value\n\n return @value = 900 if royal_flush?\n return @value = 800 + high_card_bonus if straight_flush?\n return @value = 700 + high_card_bonus if four_of_a_kind?\n return @value = 600 + high_card_bonus if full_house?\n return @value = 500 + high_card_bonus if flush?\n return @value = 400 + high_card_bonus if straight?\n return @value = 300 + high_card_bonus if three_of_a_kind?\n return @value = 200 + high_card_bonus if two_pairs?\n return @value = 100 + high_card_bonus if pair?\n @value = self.cards.map {|card| card.value}.inject(:+)\n end",
"def rating\n r = 0\n if self[:power_rating]\n r = self[:power_rating].to_f\n else\n r = PHASES.inject(0) {|sum, ph| sum += (self[\"power#{ph}_rating\".to_sym] || 0).to_f}\n end\n raise \"Can't find a rating for #{self[:name]}\" if r == 0\n r\n end",
"def randomCard\n\t\trarity = randomRarity\n\t\tgolden = randomGold(rarity)\n\t\tmakeCard(rarity, golden)\n\tend",
"def raw_score (creative_quality)\n raw_score = 0\n self.question_responses\n .select{|el| raw_score += el.question_choice.score if el.question_choice.creative_quality.name === creative_quality}\n raw_score\n end",
"def __card_value( card )\n\tnumber = card.split( '' )[ 0 ]\n\n\tif 'T' == number\n\t\tnumber = 10\n\telsif 'J' == number\n\t\tnumber = 11\n\telsif 'Q' == number\n\t\tnumber = 12\n\telsif 'K' == number\n\t\tnumber = 13\n\telsif 'A' == number\n\t\tnumber = 14\n\tend\n\n\treturn number\nend",
"def rating\n @rating\n end",
"def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end",
"def makeCard(rarity, golden)\n\t\tcase rarity\n\t\twhen :common\n\t\t\tgolden ? GoldenCommonCard.rand : CommonCard.rand\n\t\twhen :rare\n\t\t\tgolden ? GoldenRareCard.rand : RareCard.rand\n\t\twhen :epic\n\t\t\tgolden ? GoldenEpicCard.rand : EpicCard.rand\n\t\twhen :legendary\n\t\t\tgolden ? GoldenLegendaryCard.rand : LegendaryCard.rand\n\t\telse\n\t\t\traise \"unrecognized rarity\"\n\t\tend\n\tend",
"def getBasicValue\n combatLevel \n end",
"def score\n return 0 unless valid?\n 100 * card_value_decimal * 15 ** 5\n end",
"def get_card_value(card)\n card_number = get_card_number(card)\n if card_number == 'K' || card_number == 'J' || card_number == 'Q'\n card_number = 10\n elsif card_number == 1\n card_number = 11\n end\n return card_number\nend",
"def card_value(card_symbol, deck_hash)\n deck_hash[card_symbol]\nend",
"def value(card)\n suit = card.to_s.split(//).first\n value = card.to_s.delete(suit)\n if value.to_i == 0\n value == \"A\" ? value = 11 : value = 10\n else\n value = value.to_i\n end\n value\nend",
"def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end",
"def relevancy\n product_response[\"Classification\"][\"relevancyScore\"].to_i\n end",
"def randomRare\n\t\tgolden = randomGold(:rare)\n\t\tmakeCard(:rare, golden)\n\tend",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def rating\n response[\"rating\"]\n end",
"def card_value(card)\n basic_value = card.to_i\n if card.start_with?(\"A\")\n basic_value = 11\n elsif basic_value == 0\n basic_value = 10\n end\n basic_value\n end",
"def discount_value\n return '20' if taxons.find_by(id: 126) # Taxon 20% Descuento\n return '25' if taxons.find_by(id: 128) # Taxon 25% Descuento\n return '30' if taxons.find_by(id: 127) # Taxon 30% Descuento\n return '33' if taxons.find_by(id: 134) # Taxon 33% Descuento\n end",
"def inspect\n \"#{value} of #{suit}\"\n end",
"def rating\r\n\t\t@rating\r\n\tend",
"def rating #Getter\n @rating\n end",
"def value_of( pos )\n @deck[ pos ].value\n end",
"def the_draw_card_value(deck_value, deck_card_name, cards, cards_value, random)\n #need to push to get value out...\n cards_value = cards_value + deck_value[random.to_i]\n deck_value.delete_at(random.to_i)\n return cards_value\n end",
"def getValue(rank)\n\tif /\\d/.match(rank)\n\t\treturn rank.to_i\n\telsif rank == 'Ace'\n\t\treturn 11\n\telse\n\t\treturn 10\n\tend\nend",
"def value(hand)\n # Sorting hack to get aces at the very end so we count them last\n hand.sort_by { |c| c.to_i != 0 ? c : c[0] - 81 }.reverse().inject(0) do |total,cur|\n if cur.to_i != 0\n total + cur # 2-10 case\n elsif [\"J\",\"Q\",\"K\"].include? cur\n total + 10 # J,Q, or K\n elsif cur == \"A\"\n if (total+11) > 21\n total + 1 # Count ace as 1\n else\n total+11 # Count ace as 11\n end\n end\n end\n end",
"def size_bonus\n @character.race.size.modifier\n end",
"def getCombatLevel\n tr_types = @visibleTreasures.map(&:kind)\n if tr_types.include? TreasureKind::NECKLACE\n return @visibleTreasures.inject(@level){ |sum,x| sum += x.maxBonus }\n else\n return @visibleTreasures.inject(@level){ |sum,x| sum += x.minBonus }\n end\n end",
"def rating\n details.at(\"div.imdbRating span[itemprop='ratingValue']\").text.to_f rescue nil\n end",
"def credit_rating\n Credit_Ratings.credit_chart(credit_score)\n end",
"def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend",
"def score\n 3*@tally + 5*@strength + 2*@wealth + @food + 30*@monsters_killed\n end",
"def rating\n 0\n end",
"def get_near_death_value\n return @character.near_death_percent / 100.0\n end",
"def get_metal_value(metal)\t\n\ts, g, i = get_single_value \n\tif (metal == \"Silver\")\n\t\treturn s\n\telsif (metal == \"Gold\")\n\t\treturn g\n\telsif (metal == \"Iron\")\n\t\treturn i\n\telse\n\t\tretun nil\n\tend\nend",
"def shiny_rate\n 16\n end",
"def max_quarry_discount\n victory_points\n end",
"def card_quantity(card)\n c = instance_of(card.id)\n c.nil? ? 0 : c.quantity\n end",
"def random_card\n # @deck[1].rank\n size = @deck.size\n \"#{@deck[rand(size)].rank} #{@deck[rand(size)].suit}\"\n end",
"def inventory(card)\n unless current_user \n '0'\n else \n Card.last(scryfall_id: card['id'], user_id: current_user.id)\n end\n end",
"def hand_value\n @hand_value = @player_hand.hand.flatten.map { |x| Integer(x) rescue nil}.compact.inject(:+)\n end",
"def score\n @cards.map(&:value).inject(:+)\n end",
"def danger_temp\n 45\n end",
"def get_score (cards)\n\t\tscore = 0\n\t\tcards.each do |card|\n\t\t\tmeasure = card[0]\n\t\t\tscore += @score[measure]\n\t\tend\n\t\tscore\n\tend",
"def shield_bonus\n 0\n end",
"def charity\n\t\tamount * (charity_percentage.to_f / 100)\n\tend",
"def rarity_id(c)\n Rarity.find_by(name: c['rarity']).id\nrescue NoMethodError\n Rarity.find_by(name: 'Common').id\nend",
"def effective_val(a, d)\n # Check whether the attacker is effective against the defender d\n if get_effective_against(a).include?(d.type)\n 2.0\n elsif get_effective_against(d).include?(a.type) || (a.type == d.type && a.type==KudomonTypes::PSYCHIC)\n 0.5\n else\n 1.0\n end\n end",
"def card_value\n card_values = cards.map { |card| card.straight_value }\n [4, 3, 2].each do |num|\n if card_values.any? { |value| card_values.count(value) == num }\n return card_values.select { |value| card_values.count(value) == num }.max\n end\n end\n card_values.max\n end",
"def hp_rate\r\n @hp.to_f / mhp\r\n end",
"def current_hand_treasure_balance\n balance = 0\n current_player.hand.all_treasure_cards.each do |c|\n balance = balance + ( c.cardmapping.treasure_amount || 0 )\n end\n return balance\n end",
"def random_card\n return @deck[rand(@deck.length)]\n end",
"def point_value\n return 500 if flush?\n return 300 if three_kind?\n return 200 if two_kind?\n return highest_card.numeric_rank\n end",
"def value\n property.net_operating_income / property.cap_rate\n end",
"def current_treasure_balance\n current_hand_treasure_balance + (self.treasure || 0)\n end",
"def dodge_bonus\n 0\n end",
"def get_card()\n @shoe.get_card()\n end",
"def rating\n rating_calculator.rate(raters)\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def rating\n rating_id.get_object.name\n end",
"def getCombatLevel\n combatLevel = @level\n @visibleTreasures.each { |treasure| combatLevel += treasure.getBonus}\n combatLevel\n end",
"def current_value\n @top_card.value\n end",
"def getValue(card_number)\n # get card rank\n rank = case card_number % 13\n when 0, 11, 12 then 10\n when 1 then 11\n else card_number % 13 \n end\n \n return rank\n \nend",
"def disc_number\n @ole.DiscNumber\n end",
"def card_quantity(card)\n\t\tExternalDeckInstance.find_by(card_id: card.id).quantity\n\tend",
"def test_value\n testCard = Card.new(:Jack)\n\n assert_equal(3, @LiarHand.value(testCard), 'Jack card value returned incorrect for <LiarHand>')\n assert_equal(11, @IdiotHand.value(testCard), 'Jack card value returned incorrect for <IdiotHand>')\n\n assert_equal(5, @LightHand.value(testCard), 'Jack card value returned incorrect for <LightHand>')\n assert_equal(3, @SpiderHand.value(testCard), 'Jack card value returned incorrect for <SpiderHand>')\n end",
"def yards_per_skein\n data[:yards_per_skein]\n end",
"def rarity\r\n case @operator\r\n when \"=\"\r\n 5\r\n when \"!\"\r\n 1\r\n when \"!*\"\r\n 0\r\n when \">=\"\r\n @level \r\n when \"<=\"\r\n 6 - @level\r\n else\r\n 0\r\n end\r\n end",
"def calculate_taxes\n\n character_name = player_character.base_card.name\n\n case character_name\n when 'merchant'\n colour = 'green'\n\n when 'king'\n colour = 'yellow'\n when 'warlord'\n colour = 'red'\n else\n colour = 'blue'\n end\n purple_district = districts_on_game.where(\"colour = 'purple'\")\n colour_recount = cards.districts.where(\"state = 'ONGAME' AND colour = ?\", colour).count + (purple_district.exists?([\"name = 'school_magic'\"])? 1:0)\n end",
"def disenchantExtras\n\t\tdust = 0\n\t\tn = 0\n\t\tfor card in @cards\n\t\t\textras = card.removeExtras\n\t\t\tdust += card.disenchant_value * extras\n\t\t\tn += extras\n\t\tend\n\t\treturn dust, n\n\tend",
"def value \r\n value = 0\r\n @cards.each do |card|\r\n value += card.value\r\n end\r\n if value > 21\r\n value = 0\r\n @cards.each do |card|\r\n if card.value == 11\r\n value += 1\r\n else\r\n value += card.value\r\n end\r\n end\r\n end\r\n value\r\n end",
"def get_humanized_card(card)\n card_value = get_card_number(card)\n card_value = case card_value\n when 1 then 'Ace'\n when 'K' then 'King'\n when 'Q' then 'Queen'\n when 'J' then 'Jack'\n else card_value\n end\n return \"#{card_value} of #{get_card_suit(card).capitalize}\"\nend",
"def total_saturated\n food.saturated * quantity\n end",
"def total_yards\n data[:total_yards]\n end",
"def rate\n return @rate\n end",
"def hand_value (hand)\n hand_value = 0\n hand.each do |card|\n case card.value\n when /[2-9]|[1][0]/ \n hand_value += card.value.to_i \n when /[JQK]/\n hand_value += 10\n when \"A\"\n hand_value += 11\n if hand_value > 21\n hand_value -= 10 \n end \n end\n end\n hand_value\n end",
"def rcrt\n wpn = Speacial_Status['Weapon']\n return wpn[@id] != nil && wpn[@id]['rcrt'] != nil ? wpn[@id]['rcrt'] : 0\n end",
"def current_originality_rating\n if self.get_upvotes(:vote_scope => 'rate_originality').size > 0\n self.get_likes(:vote_scope => 'rate_originality').sum(:vote_weight) / self.get_upvotes(:vote_scope => 'rate_originality').size\n else\n \"no ratings yet\"\n end\n end",
"def get_damage_string\n \"1d3\"\n end"
] | [
"0.6842959",
"0.6626873",
"0.644227",
"0.627616",
"0.6265986",
"0.6092428",
"0.6080056",
"0.60292",
"0.5972159",
"0.5930678",
"0.5930015",
"0.58792806",
"0.5839148",
"0.58099556",
"0.5759916",
"0.5751199",
"0.5737049",
"0.5681297",
"0.5677197",
"0.5670033",
"0.5638383",
"0.5633594",
"0.56207955",
"0.56007534",
"0.5565954",
"0.55581796",
"0.55457413",
"0.5541648",
"0.5529549",
"0.55270964",
"0.5483501",
"0.54828197",
"0.54634273",
"0.5450685",
"0.544997",
"0.5448129",
"0.54466015",
"0.5432672",
"0.5416522",
"0.5385275",
"0.5365187",
"0.5360332",
"0.5356174",
"0.53498137",
"0.53444743",
"0.5344418",
"0.5337205",
"0.5335126",
"0.5332546",
"0.53223443",
"0.5319944",
"0.5312419",
"0.53094596",
"0.53015655",
"0.52972776",
"0.52938306",
"0.5288604",
"0.5283495",
"0.5282765",
"0.5282701",
"0.5270165",
"0.52635044",
"0.52575696",
"0.5251484",
"0.5247276",
"0.5246829",
"0.5237241",
"0.5236811",
"0.5236186",
"0.5223473",
"0.5223089",
"0.521878",
"0.52175134",
"0.5213496",
"0.5207722",
"0.5203126",
"0.51974237",
"0.51947325",
"0.5194595",
"0.51939416",
"0.5191855",
"0.5190496",
"0.5187321",
"0.5180628",
"0.5177485",
"0.51719266",
"0.5170295",
"0.5165405",
"0.5158649",
"0.515679",
"0.5154207",
"0.5150591",
"0.5146815",
"0.5146622",
"0.5146308",
"0.5141117",
"0.51405627",
"0.5140048",
"0.51358896",
"0.513218"
] | 0.8876473 | 0 |
Dynamic title based on page | def full_title(page_title = '')
base_title = "Hearth Helper"
if page_title.empty?
base_title
else
page_title + " - " + base_title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_page_title\n case @title\n when 'Winter', 'Spring', 'Summer', 'Fall'\n parent_content = Content.new(@parent_path)\n @page_title = @title + ' ' + parent_content.title\n else\n @page_title = @title\n end\n end",
"def page_title\n end",
"def title(page_title)\n \tcontent_for(:title) { page_title }\n \tend",
"def page_title\n title = content_for?(:title) ? \" - #{content_for(:title)}\" : \"\"\n \"Todobadour#{title}\"\n end",
"def page_title; end",
"def title\n if detail_page?\n \"#{resource.name} - #{menu.name} - #{website_tag.name}\"\n else\n \"#{menu.name} - #{website_tag.name}\" \n end \n end",
"def title(page_title)\n content_for :title do\n page_title\n end\n end",
"def render_page_title\n @page_title ? \"#{@page_title}_#{SiteName}\" : SiteName rescue \"SITE_NAME\"\n end",
"def page_title(title)\n content_for_wrapper(:page_title, title)\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def page_title(title)\n content_for :page_title, title\n end",
"def page_title\n @page_title = \"Nursing System\"\n end",
"def gen_title(page_title)\n puts @me.valid_user?\n if !@me.valid_user?\n site_title=\"Delta Kappa Epsilon - Sigma Tau\"\n else\n site_title=\"DKE Server\"\n end\n if (page_title!=\"\")\n return \"#{site_title} | #{page_title}\" \n else\n return site_title\n end\n end",
"def page_title(title)\n \"gbchaosmaster#{\" | #{title}\" unless title.blank?}\"\n end",
"def page_title(page_title)\n content_for_layout :page_title, page_title\n end",
"def title(page_title)\n\t content_for(:title) { page_title }\n\tend",
"def set_page_title(title)\n\t\t@page_title = @current_action.titleize + title\n\tend",
"def set_page_title\n @page_title = \"Race Results Management\"\n end",
"def page_title(title, some_user=nil, model_name=nil)\n content_for :page_title do\n @page_title = \"\"\n if some_user\n if user_signed_in? && some_user.id == current_user.id\n @page_title = \"Your \"\n else\n @page_title = \"#{some_user.full_name}'s \"\n end\n end\n\n @page_title += model_name || title\n end\n end",
"def page_title\n title = @page_title ? \"/ #{@page_title}\" : ''\n content_tag(:title, 'GONDI.tv ' + title)\n end",
"def page_title( this_title = nil )\n content_for( :title ) { \"#{ SITE_ID }: #{ this_title.nil? ? I18n.t( controller.controller_name + '.title' ) : this_title }\" }\n end",
"def title(page_title)\n @title = page_title\n content_for(:title) { page_title }\n end",
"def title_help \n\n\t\t#Define general page title\n\t\tbase_title = \"Rex Ruby on Rails Learning | PagesHelper\"\n\t\tif(@title.nil?)\n\t\t\tbase_title\n\t\telse\n\t\t\tbase_title = \"Rex Ruby on Rails Learning | #{@title} | PagesHelper\"\n\t\tend\n\tend",
"def title\n base_title = \"CloudSpokes Coding Challenges\"\n if @page_title.nil?\n base_title\n else\n \"#{base_title} - #{@page_title}\"\n end\n end",
"def title(page_title, show_title: true)\n content_for(:title) { h(page_title.to_s) }\n @show_title = show_title\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def page_title\n \n page_title = @renderer.title title()\n \n puts \"[Cutlist.page_title]: #{page_title}\" if $cutlister_debug\n \n page_title\n \n end",
"def page_title title= nil\n\t\tif title\n\t\t\tcontent_for(:page_title) { \"#{title} - 2da.re\" }\n\t\t\treturn title\n\t\telse\n\t\t\tcontent_for?(:page_title) ? content_for(:page_title) : \"Ready 2da.re?\"\n\t\tend\n\tend",
"def title(page_title = nil)\n if page_title\n content_for(:title) do\n page_title\n end\n else\n content_for(:title) do\n \"DateIdeas.ca\"\n end\n end\n end",
"def set_page_title\n\t\t@page_title = \"#{self.action_name.capitalize}: Abstract /\" <<\n\t\t\t\" #{Abstract.sections.find{|a|a[:controller] == self.class.name.demodulize}[:label]}\"\n\tend",
"def title(page_title)\n content_for(:title) { page_title }\n\n end",
"def page_title\n \t\"PatTalk\"\n end",
"def page_title\n @page_title || TaliaCore::SITE_NAME\n end",
"def get_page_title\n uri = request.request_uri\n section = uri.split(\"/\").last\n title = case section\n # these should be consistent now\n when \"questions\" then \"Key Questions\"\n when \"publications\" then \"Publication Information\"\n when \"arms\" then \"Study Arms\"\n when \"design\" then \"Study Design\"\n when \"baselines\" then \"Baseline Characteristics\"\n when \"outcomes\" then \"Outcome Setup\"\n when \"results\" then \"Results\"\n when \"adverse\" then \"Adverse Events\"\n when \"quality\" then \"Study Quality\"\n else \"\"\n end\n return title\n end",
"def render_page_title\n (content_for(:page_title) if content_for?(:page_title)) || @page_title || application_name\n end",
"def page_title\n if controller_name == 'pages'\n title = t \"#{action_name}_page\"\n \"#{app_name} | #{title}\" # e.g.: 'Ror4 | Home'\n else\n if @page_title.nil?\n \"#{app_name} | #{t controller_name}-#{t action_name}\" # e.g.: 'Ror4 | groups-index'\n else\n \"#{app_name} | #{t @page_title}\" # e.g.: 'Ror4 | Show group Manager'\n end\n end\n end",
"def page_title() nil end",
"def page_title(page_title = nil)\n @page_title ||= page_title\n @page_title.nil? ? \"Carers: #{action_name}\" : \"#{@page_title} @ Lort Smith\"\n end",
"def page_title(page_title, klass=nil)\n unless page_title.blank?\n content_for :page_title do\n content_tag(:h1, page_title, :id => 'page_title', :class => klass)\n end\n end\n end",
"def title(page_title)\n content_for(:title) do\n \"#{page_title} - #{MySettings.company_full_name}\"\n end\n end",
"def manageable_page_title(title = nil)\n @title = title unless title.nil?\n @title || \"Untitled Page\"\n end",
"def page_title(title = nil)\n if title\n content_for(:page_title) { title }\n else\n content_for?(:page_title) ? content_for(:page_title) : APP_CONFIG[:site_name] # or a hard-coded default\n end\n end",
"def page_title\n title = t(\"#{controller_name}.#{action_name}.title\")\n html = <<-HTML\n <div class=\"page-header\">\n <h1>#{title}</h1>\n </div>\n HTML\n html.html_safe\n end",
"def page_title\n title = \"Amplify\"\n title.prepend(\"#{@page_title} | \") if @page_title\n title\n end",
"def page_title(page_title)\n unless page_title.blank?\n content_for :page_title do\n content_tag(:h1, page_title, :id => 'page_title')\n end\n end\n end",
"def title(page_title)\n base_title = \"Blog Secret Santa\" \n content_for(:title) { \"#{page_title} | #{base_title}\" }\n content_for(:heading) { page_title }\n end",
"def title(page_title, show_title = true)\n content_for(:title) { h(page_title.to_s) }\n @show_title = show_title\n end",
"def title\n base_title = \"My Site\"\n unless @title.nil?\n \"#{base_title} | #{@title}\"\n else\n base_title\n end\n\n end",
"def page_title\n return \"#{this_webapp.webapp_name} - #{@page_title}\" if @page_title\n return \"#{this_webapp.webapp_name}\"\n end",
"def set_page_title\n if params['listing_user_id']\n @page_title = \"My Tours\"\n else\n @page_title = \"All Tours\"\n end\n end",
"def title(page_title = '')\n\t\tbase_title = \"AB Online Shop\"\n\t\tif page_title.empty?\n\t\t\tbase_title\n\t\telse\n\t\t\tpage_title + \" | \" + base_title\n\t\tend\n\tend",
"def set_title\n unless self.title\n if self.parent\n if last_untitled_page = self.parent.children.where(:title => /Untitled /i).asc(:title).last\n last_untitled_number = last_untitled_page.title.split(\" \").last.to_i\n self.title = \"Untitled #{last_untitled_number+1}\"\n else\n self.title = \"Untitled 1\"\n end\n else\n self.title = \"Untitled 1\"\n end\n end\n end",
"def title(page_title)\n content_for :page_title, page_title.to_s.html_safe\n end",
"def page_title\n if @title.present?\n I18n.t('page_title', :page_title => @title, :blog_title => blog_title)\n else\n I18n.t('home_title', :blog_title => blog_title)\n end\n end",
"def page_title\n \"swinfo for #{item}\"\n end",
"def page_title\n case\n when @post\n \"#{@post.title} - Ben Hoad\"\n when @tag\n \"Tagged with ##{@tag} - Ben Hoad\"\n else\n \"Ben Hoad\"\n end\n end",
"def page_title\n page.title\n end",
"def title(page_title)\n\t\t\tmode = \"[DEV] \" unless ::Rails.env.production?\n\t\t\tcontent_for(:title) { mode.to_s + page_title + \" | \" }\n\t\tend",
"def check_title\n @page_title = \"FauxTwitter\"\n end",
"def set_page_title(title)\n @page_title = title\n end",
"def page_title\n if controller.controller_name == \"dashboards\" && params.key?(\"id\")\n \"Nifty #{Dashboard.get(params[:id]).name}\"\n elsif controller.controller_name == \"widgets\" && params.key?(\"dashboard_id\")\n \"Nifty #{Dashboard.get(params[:dashboard_id]).name} Widgets\"\n else\n \"Nifty Monitoring Dashboard\"\n end\n end",
"def full_title(page_title)\n page_title.blank? ? \"My Defi Pie\" : \"My Defi Pie | #{page_title}\"\n end",
"def title\n @title ||= begin\n if site_title && page_title != site_title\n page_title + TITLE_SEPARATOR + site_title\n elsif site_description && site_title\n site_title + TITLE_SEPARATOR + site_title_extention_or_description\n else\n page_title || site_title\n end\n end\n\n return page_number + @title if page_number\n\n @title\n end",
"def show\r\n @page_title = @page.title\r\n end",
"def titler\n if @title.nil?\n $application_name\n else\n \"#{$application_name} : #{@title}\"\n end\n end",
"def pagetitle(page)\n \"Page #{page}\"\nend",
"def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end",
"def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end",
"def title(title_name)\n h.content_tag :h2 do\n title_name.present? ? title_name : \"Perfis\"\n end\n end",
"def page_title\n \"#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}\"\n end",
"def set_title\n @title = \"#{controller_name}.#{action_name}.title\"\n end",
"def base_title(page_title = '')\n base_title = \"Sergio Mironescu\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def pageTitle\n (self || Home.new).title\n end",
"def title_tag_content(page_title: '')\n base_title = COMPETITIONS_CONFIG[:application_name]\n page_title.empty? ? base_title : \"#{page_title} | #{base_title}\"\n end",
"def page_title\n nil\n end",
"def title\n @title ||= heirarchy.full_name\n end",
"def title\n if @title.nil?\n BASE_TITLE\n else\n \"#{BASE_TITLE} | #{@title}\"\n end\n end",
"def title\n page.title\n end",
"def title\n base_title = \"Golo\"\n if@title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end",
"def site_title\n if content_for?(:title)\n \"#{content_for(:title)} - \"\n elsif ['static'].include?(controller_name)\n if action_name == 'home'\n ''\n else\n \"#{action_name.humanize} - \"\n end\n elsif @breadcrumbs && @breadcrumbs.any?\n \"#{@breadcrumbs.last[:name]} - \"\n elsif controller_name\n \"#{controller_name.humanize} - \"\n else\n ''\n end + \"PaN Training Catalogue\"\n end",
"def title\n @global_page.title\n end",
"def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end",
"def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end",
"def title\n base_title = \"Operation Paws for Homes\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end",
"def header_text(page_title)\n page_title || @@base_title\n end",
"def show\n @page_title = \"Our lessons\"\n end",
"def full_title(page_title)\n \t\tif page_title.empty?\n \t\t\tsite_name\n \t\telse\n \t\t\t\"#{page_title} | #{site_name}\"\n \t\tend\n \tend",
"def title\n [super().presence, homepage.title].compact.join(' - ')\n end",
"def page_title\n \"CMVC #{type} #{defect_name}\"\n end",
"def full_title(page_title)\r\n\tbase_title = \"whichizrite\"\r\n\tif page_title.empty?\r\n\t\tbase_title\r\n\telse\r\n\t\t\"#{base_title} | #{page_title}\"\r\n\tend\r\nend",
"def name; (page.title rescue ''); end",
"def name; (page.title rescue ''); end",
"def title\n return super if block_given?\n\n @title || if show?\n content_tag('span', presenter.heading, itemprop: \"name\")\n else\n @view_context.link_to_document @document, counter: @counter, itemprop: 'name'\n end\n end",
"def assign_page_title\n @page_title ||= resource_wizard_step_title(resource, step)\n end",
"def full_title(page_title)\n\t\tpage_title = PAGE_TITLE \n \tbase_title = BASE_TITLE\n if page_title.empty?\n base_title\n else\n \"#{page_title} | #{base_title}\"\n end\n end",
"def title\n @title ||= hash.fetch('title') { |key|\n raise \"Page id=#{id} is missing #{key}\"\n }\n end",
"def page_title!(title)\n @_page_title = title\n end"
] | [
"0.8088156",
"0.79689336",
"0.795719",
"0.7869999",
"0.78503656",
"0.7845735",
"0.7842397",
"0.7827057",
"0.7817457",
"0.77954257",
"0.77954257",
"0.77676636",
"0.7762432",
"0.776083",
"0.77586496",
"0.7753236",
"0.7731216",
"0.7724707",
"0.77206916",
"0.7694032",
"0.7690274",
"0.76764774",
"0.7663412",
"0.7662698",
"0.7658309",
"0.7651028",
"0.7649151",
"0.7649151",
"0.7649151",
"0.7649151",
"0.76488215",
"0.7645578",
"0.76423454",
"0.76339316",
"0.7628555",
"0.762476",
"0.76164234",
"0.76102734",
"0.7609596",
"0.7604576",
"0.76023793",
"0.75972354",
"0.75917935",
"0.75911707",
"0.75874525",
"0.7587206",
"0.7573649",
"0.75703716",
"0.75470245",
"0.7542584",
"0.75323415",
"0.7524929",
"0.75216883",
"0.75152725",
"0.7511965",
"0.7507443",
"0.74926835",
"0.7482039",
"0.7481914",
"0.7469006",
"0.7461394",
"0.7459466",
"0.7437468",
"0.7429203",
"0.742442",
"0.74223924",
"0.74220794",
"0.741885",
"0.7416203",
"0.74151736",
"0.7410312",
"0.7399595",
"0.73986804",
"0.73934007",
"0.73894525",
"0.7388227",
"0.7387594",
"0.73866415",
"0.7375227",
"0.7362109",
"0.7360573",
"0.7358749",
"0.7353933",
"0.7350953",
"0.7349897",
"0.734138",
"0.734138",
"0.73398393",
"0.73285407",
"0.7327454",
"0.7321824",
"0.73178923",
"0.73144263",
"0.7305054",
"0.7300305",
"0.7300305",
"0.72918296",
"0.7290537",
"0.72849524",
"0.7280562",
"0.7278647"
] | 0.0 | -1 |
Returns the current month | def current_month
Date.today.strftime("%B")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_month\n Time.now.strftime(\"%^b\")\n end",
"def time_month; Time.now.month; end",
"def current_month\n colspan = @options[:previous_month] || @options[:next_month] ? 3 : 7 # span across all 7 days if previous and next month aren't shown\n\n show_month(@days.first, @options[:current_month], :colspan => colspan, :class => \"current\")\n end",
"def month\n months = %w{January February March April May June July August September October November December}\n months[Time.now.month - 1]\n end",
"def this_month\n day(Time.now)\n end",
"def month\n return @month\n end",
"def month\n Thread.current[:datet_mode] = :months\n return @t_month\n end",
"def month() end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end",
"def month\n @month || self.starts_at.month\n end",
"def month\n start_on.strftime(MONTH_NAME)\n end",
"def month\n return @month\n end",
"def month\n set_function_and_argument(:month, nil)\n end",
"def month\n start_date&.strftime('%b %Y')\n end",
"def month; end",
"def month; end",
"def start_of_month\n Date.new(self.strftime('%Y').to_i, self.strftime('%m').to_i, 1)\n end",
"def month\n created.strftime '%m'\n end",
"def month\n MONTHS[@created_at.month-1]\n end",
"def month\n self.class.get_month(@bits)\n end",
"def month\n self.founded.strftime(\"%B\")\n end",
"def current_month?\n self.month == calendar_month\n end",
"def month\n end",
"def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end",
"def the_month\n self.koyomi_month\n end",
"def change_to_beginning_of_month\n @month.to_date.beginning_of_month\n end",
"def is_current_month(date)\n currentMonth = Time.now.month\n dateMonth = date.month\n dateMonth.between?(currentMonth, currentMonth)\n end",
"def day_of_month\n start_on.day.to_s\n end",
"def month\n @date_time_value.month\n end",
"def month\n @date_time_value.month\n end",
"def current\n #throw ::Year.all.inspect\n #throw ::Month.find(:first, :conditions => {:month_calendaryear => Time.now.year, :month_number => Time.now.month}).year\n ::Month.find(:first, :conditions => {:month_calendaryear => Time.now.year, :month_number => Time.now.month}).year\n end",
"def test_28_stores_current_month_if_given_no_arguments\n cal = Cal.new()\n assert_equal(\"May\", cal.month)\n end",
"def January ; Date::MONTHNAMES.index(\"January\"); end",
"def date_next_month(month)\n t = Time.now\n m = month || t.month + 1\n Time.utc(t.year, m, 1)\n end",
"def month\r\n return @hm\r\n end",
"def month\n @month.to_s.rjust(2, '0')\n end",
"def month\n self.range('month')\n end",
"def month\n return self.to_a[IDX_MONTH]\n end",
"def first_of_month\n Date.new(self.year, self.month)\n end",
"def days_in_current_month\n\t\t\tcurrent_month = Time.now.month\n\t\t\tcurrent_year = Time.now.year\n\n\t\t\treturn Time.days_in_month(current_month, current_year)\n\t\tend",
"def month=(_arg0); end",
"def month_number\n date.month\n end",
"def name_of_month\n MONTH_NAMES[self.month - 1]\n end",
"def month_str\n ret = Datet.months(:trans => true)[@t_month]\n if args and args[:short]\n ret = ret.slice(0, 3)\n end\n \n return ret\n end",
"def start_of_month\n @start_of_month ||= date_calc.start_of_month(year, merch_month)\n end",
"def months\n Thread.current[:datet_mode] = :months\n return self\n end",
"def mon() @m_date.mon end",
"def this_month(options={})\n today = Time.now\n this_month = today.beginning_of_month\n\n between(this_month.beginning_of_day.to_i, today.end_of_day.to_i, options)\n end",
"def first_of_month\n @first_of_month ||= Date.new(@year, @month)\n end",
"def month_name\n return @@month_names[@t_month]\n end",
"def month_name\n I18n.t('date.month_names')[month_number].camelize\n end",
"def beginning_of_month\n self.class.new year, month, 1\n end",
"def month_to_name\n month = Date.new(Time.now.year, purchased_at_month.to_i)\n month.strftime(\"%B\")\n end",
"def month_name(the_date)\n Date::MONTHNAMES[the_date.month]\n end",
"def monthly\n end",
"def month(date)\n [MONTHS[date.month - 1], year(date)].join(', ')\n end",
"def month_name\n report_date.strftime(\"%B\")\n end",
"def date\n Date.civil(year, month, 1)\n end",
"def month=(value)\n @month = value\n end",
"def rsmonth(month)\n case month\n when 1\n return 'januar'\n when 2\n return 'februar'\n when 3\n return 'mart'\n when 4\n return 'april'\n when 5\n return 'maj'\n when 6\n return 'jun'\n when 7\n return 'jul'\n when 8\n return 'avgust'\n when 9\n return 'septembar'\n when 10\n return 'oktobar'\n when 11\n return 'novembar'\n when 12\n return 'decembar'\n end\nend",
"def first_day_of_month(date_time=Time.now)\n date_time.beginning_of_month\n end",
"def get_month(year, month)\n entries = month_entries(@pages, year, month) \n\n budget_month = BudgetMonth.new(entries, year, month)\n\n budget_month\n end",
"def months; self * MONTH; end",
"def beginning_of_month\n first_hour(change(day: 1))\n end",
"def mn(month)\n n = Date::ABBR_MONTHNAMES.index(month) || Date::MONTHNAMES.index(month)\n return month unless n\n\n n.to_s.rjust 2, \"0\"\n end",
"def current_date()\r\n return Time.new.strftime(\"%Y-%m-%d\")\r\n end",
"def get_month(month)\n month = month.to_s\n month.length == 2 ? month : \"0#{month}\"\n end",
"def beginning_of_year\n change(month: 1).beginning_of_month\n end",
"def expiration_month\n @months = [\"01\",\"02\",\"03\",\"04\",\"05\",\"06\",\"07\",\"08\",\"09\",\"10\",\"11\",\"12\"]\n end",
"def month\n @year = params[:year].to_i\n @month = params[:month].to_i\n @first_day = @event.first_day_of_month(@year, @month)\n @last_day_of_month = Date.new(@year, @month, 1).end_of_month\n end",
"def name_of_month(style = :full)\n @time.strftime(style == :full ? \"%B\" : \"%b\")\n end",
"def get_current_semester\n time = Time.new\n if time.month >= 3 && time.month < 10\n time.year.to_s + '08'\n else\n (time.year + 1).to_s + '01'\n end\n end",
"def monthly(options = {})\n branch options.merge(every: :month)\n end",
"def monthly(options = {})\n branch options.merge(every: :month)\n end",
"def last_of_month\n # See if the month is December\n @last_of_month ||= if @month == 12\n # If so, return the day before the first of next year.\n Date.new(@year + 1, 1 ) - 1\n else\n # If not, return the day before the first of next month.\n Date.new(@year , @month + 1) - 1\n end\n end",
"def month\n sunday = @monday + 6\n return 1 if sunday.month == 1 && sunday.year == @year\n return 12 if @monday.month == 12 && @monday.year == @year\n (@monday + 2).month\n end",
"def get_english_month(idx)\n Date::MONTHNAMES[idx]\n end",
"def month_depot\n \"#{depot.name} \"+\"#{issue_date.strftime(\"%b\")} \"+\"#{issue_date.year}\"\n end",
"def previous\n if @date.month - 1 == 0\n Month.new(12,@date.year-1)\n else\n Month.new(@date.month-1,@date.year)\n end\n end",
"def months() 30 * days end",
"def month_label\n \"#{label}\"\n end",
"def months\n self.to_i * 2_592_000\n end",
"def merch_month\n # TODO: This is very inefficient, but less complex than strategic guessing\n # maybe switch to a binary search or something\n @merch_month ||= (1..12).detect do |num|\n date_calc.end_of_month(start_of_year.year, num) >= date && date >= date_calc.start_of_month(start_of_year.year, num)\n end\n end",
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def beginning_of_month\n #self - ((self.mday-1).days + self.seconds_since_midnight)\n change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)\n end",
"def end_of_month\n self.class.new year, month + 1, 0\n end",
"def this_month_dates\n {\n init_date: Date.today.beginning_of_month.to_s,\n end_date: Date.today.end_of_month.to_s\n }\n end",
"def month_names; end",
"def next_month(from)\n from.next_month.change(day: 1)\n end",
"def month_name(number); end",
"def months ; self * 30.days ; end",
"def roman_month(date)\n date[1]\n end",
"def month_name\r\n return MONTH_NAMES[@hm]\r\n end",
"def timeframe_months\n if self.end_date.present?\n number = (self.end_date.year * 12 + self.end_date.month) - (Date.today.year * 12 + Date.today.month)\n else\n number = 0\n end\n \"#{number} #{'month'.pluralize(number).capitalize}\"\n end",
"def monthly_params\n @current_resource ||= @month\n end",
"def month? = unit == 'month'",
"def current_period_start_date\n Date.new(Date.today.year, Date.today.month, current_day_start_date)\n end",
"def day_of_month\n ordinal = case @time.day\n when 1 then \"st\"\n when 2 then \"nd\"\n when 3 then \"rd\"\n else \"th\"\n end\n \"#{@time.day}#{ordinal}\"\n end"
] | [
"0.85755014",
"0.82750607",
"0.82561046",
"0.8227698",
"0.7905204",
"0.7657554",
"0.7653123",
"0.7520926",
"0.751522",
"0.7468684",
"0.7428697",
"0.7398828",
"0.73548764",
"0.7280612",
"0.7273064",
"0.7248864",
"0.7248864",
"0.7236135",
"0.72231627",
"0.71911114",
"0.71835196",
"0.7175931",
"0.71641445",
"0.71565235",
"0.71056867",
"0.7024486",
"0.7023696",
"0.70183724",
"0.6934117",
"0.68988496",
"0.68988496",
"0.68925226",
"0.68659925",
"0.6830423",
"0.6819371",
"0.68064606",
"0.678867",
"0.6784288",
"0.67728055",
"0.67663145",
"0.6754643",
"0.6731736",
"0.67246187",
"0.6716121",
"0.6649763",
"0.6633675",
"0.66235375",
"0.66226393",
"0.6620469",
"0.6614904",
"0.6611446",
"0.6607451",
"0.66034305",
"0.6602338",
"0.6601728",
"0.6600607",
"0.6587995",
"0.65054417",
"0.6490022",
"0.64832187",
"0.6437425",
"0.641379",
"0.64101654",
"0.6390482",
"0.63891196",
"0.63161856",
"0.630417",
"0.63022983",
"0.62994486",
"0.62934035",
"0.6277912",
"0.6269309",
"0.62676424",
"0.62589496",
"0.62589496",
"0.62556434",
"0.6241368",
"0.62402594",
"0.6234337",
"0.6202795",
"0.61969686",
"0.61929387",
"0.61865836",
"0.6185366",
"0.6169452",
"0.6169452",
"0.6154586",
"0.6149944",
"0.61456364",
"0.61427075",
"0.61391217",
"0.61389136",
"0.6131938",
"0.6123682",
"0.6121553",
"0.6104718",
"0.60827255",
"0.60709774",
"0.6064005",
"0.60464144"
] | 0.8837745 | 0 |
def set_request_format_json request.format = :json end | def current_user
if auth_token && !@current_user
if @current_user = User.find_by_auth_token(auth_token)
@current_user = nil if @current_user.auth_token_expired?
end
end
@current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_default_format\n request.format = :json\n end",
"def set_default_format\n request.format = 'json'\n end",
"def set_default_format\n request.format = 'json'\n end",
"def set_default_response_format\n\t\t request.format = :json\n\t\tend",
"def set_default_response_format\n request.format = :json\n end",
"def set_default_response_format\n request.format = :json\n end",
"def default_format_json\n if(request.headers['HTTP_ACCEPT'].nil? && params[:format].nil?) ||\n (request.headers['HTTP_ACCEPT'] != 'application/xml' && params[:format] != 'xml')\n request.format = 'json'\n end\n end",
"def set_default_format_json\n if params[:format] && params[:format] != 'json'\n head :bad_request\n else\n request.format = 'json' unless params[:format]\n end\n end",
"def set_default_response_format\n request.format = :json\n end",
"def request_json\n @request.headers[\"Content-Type\"] = 'application/json'\n @request.headers[\"Accept\"] = 'application/json'\n end",
"def set_format\n request.format = :json if params[:api_token].present? && params[:format].blank?\n end",
"def set_default_response_format\n request.format = :json unless params[:format]\n end",
"def format\n :json\n end",
"def set_format\n request.format = 'json' unless params[:controller].include? 'admin'\n end",
"def response_format\n @response_format || :json\n end",
"def check_request_format\n unless request.content_type == 'application/json'\n error = ErrorSerializer.serialize({ format: \"Invalid request format. Only JSON requests are supported.\" })\n render json: error, status: :unsupported_media_type\n end\n end",
"def json\n Oj.to_json(@req)\n end",
"def json_api_request(request_method, action, parameters = {}, session = nil, flash = nil)\n @request.headers['ACCEPT'] = 'application/vnd.api+json'\n @request.headers['CONTENT_TYPE'] = 'application/vnd.api+json'\n extra_headers = parameters[:headers] || {}\n extra_headers.each do |key, value|\n @request.headers[key] = value\n end\n parameters.delete :headers\n parameters[:format] = :json_api unless parameters&.key? :format\n __send__(request_method, action, params: parameters, session: session, flash: flash)\nend",
"def json_request?\n request.format.json?\n end",
"def to_json(*_args)\n @request.to_json\n end",
"def to_json(*_args)\n @request.to_json\n end",
"def json_request?()\n request.format.json?\n end",
"def ensure_json_request\n return if params[:format] == 'json' || request.headers['Accept'] =~ /json/\n head :not_acceptable\n end",
"def json_request?\n request.format.json?\n end",
"def json_request?\n request.format.json?\n end",
"def json_request?\n request.format.json?\n end",
"def json_request?\n request.format.json?\n end",
"def json_request?\n request.format.json?\n end",
"def update_params\n super.tap do |params|\n params[:request_format] = :json\n params[:expected_response] = Net::HTTPOK\n end\n end",
"def header_accepts_json\n { \"Accepts\" => \"application/json\" }\n end",
"def json\n add option: \"-json\"\n end",
"def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end",
"def format_request(payload); end",
"def format_request(payload); end",
"def as_json(_options = {})\n {:http_client_request => to_hash}\n end",
"def with_json(json)\n @headers['Content-Type'] ||= 'application/json'\n with_body(json)\n end",
"def json(hash = {})\n content_type 'application/json'\n Yajl::Encoder.encode(hash, {:pretty => true, :indent => ' '})\nend",
"def accept_json\n logger.debug(request.accept)\n unless request.accept? 'application/json'\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end\n rescue NoMethodError => e\n #error in sinatra 1.4.4 (https://github.com/sinatra/sinatra/issues/844, https://github.com/sinatra/sinatra/pull/805)\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end",
"def ensure_json_content_type\n request.headers['Content-Type'] =~ /application\\/json/\n end",
"def json(obj)\n content_type :json\n obj.to_json\n end",
"def json_params\n params.require(:json).permit(:type, :data)\n end",
"def interface\n respond_to do |format|\n format.json {}\n end\n end",
"def header_content_json\n { \"Content-Type\" => \"application/json\" }\n end",
"def create_json_request(code)\n parameters = {\n \t\"code\" => code,\n\t\"level\" => self.level,\n\t\"format\" => \"json\",\n\t\"info\" => self.op\n }\n end",
"def set_json_api_header\n response.set_header(\"Content-Type\", \"application/vnd.api+json\")\n end",
"def mime_type\n \"application/json\".freeze\n end",
"def json(body)\n content_type \"application/json\"\n body.to_json\n end",
"def set_default_format\n if request.format.symbol.nil? || request.format.to_s == '*/*'\n logger.debug \"[ApplicationController] Request format set to #{request.format.to_s.inspect}, forcing 'text/plain'\"\n request.format = :text\n end\n end",
"def json_data\n json_format = params[:json_format] or 'default'\n case json_format\n when 'basic'\n collection.map {|p| {'id' => p.id, 'name' => p.name}}.to_json\n else\n collection.to_json()\n end\n end",
"def as_json(options={})\n\t\tsuper(only: [:usage,:body])\n\tend",
"def json?\n raw_options[:format] == :json\n end",
"def rendering_json?(p = nil)\n p ||= params\n fmt = p[:format].to_s.downcase\n (fmt == 'json') || (respond_to?(:request) && request.format.json?)\n end",
"def adjust_format_for_iphone\n request.format = :iphone if iphone_request?\n end",
"def adjust_format_for_iphone\n request.format = :iphone if iphone_request?\n end",
"def json_format\n object.to_json(\n only: [:id, :title, :key_information, :description],\n methods: [:photo_url, :net_mrp, :mrp_per_unit],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address, :logo_url, :store_rating, :store_distance]\n }\n }\n )\n end",
"def default_headers\n {\n :content_type => :json,\n :accept => :json\n }\n end",
"def as_json(*_args)\n as_extended_json\n end",
"def adjust_format_for_iphone \n request.format = :iphone if iphone_request?\n end",
"def as_json(_options = {})\n {:method => method, :path => path, :remote_addr => remote_addr, :request_id => request_id}\n end",
"def to_json(*options)\n as_json(*options).to_json(*options)\n \tend",
"def request_with_json(method, url, json)\n unless json.kind_of?(String)\n json = json.to_json\n end\n\n # peeked at the rack implementation to figure out the necessary\n # keys here.\n self.send(method, url, nil,\n 'CONTENT_TYPE' => 'application/json',\n 'CONTENT_LENGTH' => json.length,\n 'rack.input' => StringIO.new(json))\n end",
"def set_facebook_request_format\n if in_canvas? && !in_iframe?\n request.format = :fbml\n end\n end",
"def jsonify(input); end",
"def json_serialize\n end",
"def json(input)\n JSON.dump(input)\n end",
"def configure_connection(conn)\n conn.headers['Accept'] = [JSON_TYPE]\n\n conn.response :json, content_type: JSON_TYPE\n end",
"def and_jsonapi\n self.jsonapi = true\n\n self\n end",
"def make_json_request(mode, options = {})\n options = { mode: mode,\n apikey: @api_key,\n output: 'json' }.merge(options)\n path = \"/api\"\n uri = URI::join(URI.parse(@server), path)\n uri.query = URI.encode_www_form( options )\n JSON.parse(Net::HTTP.get(uri))\n end",
"def to_json(*attrs); super self.class.params; end",
"def to_json(*attrs); super self.class.params; end",
"def to_json(*attrs); super self.class.params; end",
"def as_json(_opts={})\n raise NotImplementedError\n end",
"def json_data\n json_format = params[:json_format] || 'default'\n case json_format\n when 'basic'\n collection.map { |u| { 'id' => u.id, 'name' => u.email } }.to_json\n else\n address_fields = [:firstname, :lastname, :address1, :address2, :city, :zipcode, :phone, :state_name, :state_id, :country_id]\n includes = { only: address_fields, include: { state: { only: :name }, country: { only: :name } } }\n\n collection.to_json(only: [:id, :email], include:\n { bill_address: includes, ship_address: includes })\n end\n end",
"def json(data={}, options={})\n response[CONTENT_TYPE] = APPLICATION_JSON\n response.status = options[:status] if options.has_key?(:status)\n response.write self.class.json_serializer.dump(data)\n end",
"def json_params\n begin\n JSON.parse(request.body.read)\n rescue\n halt 400, serialize_error('Invalid JSON.')\n end\n end",
"def use_json_locale_for_xhr\n I18n.locale = 'json' if request.xhr?\n end",
"def render_json\n end",
"def json\n \"#{self.to_s}&json=true\"\n end",
"def prefer_json?\n prefered_http_accept == \"application/json\"\n end",
"def json_data\n json_format = params[:json_format] or 'default'\n case json_format\n when 'basic'\n collection.map { |v| { 'id' => v.product.id, 'name' => v.product.name }}.uniq { |i| i['id'] }.to_json\n when 'autocomplete'\n collection.map { |v| {\n :data => {\n :id => v.id,\n :product_id => v.product.id,\n :name => v.fullname,\n :sku => v.sku,\n :count_on_hand => v.count_on_hand,\n :image_url => (v.images.count > 0 ? v.images.first.attachment.url(:mini) : nil)\n },\n :value => v.fullname,\n :result => v.fullname\n }\n }.to_json\n else\n collection.to_json(:include => {:variants => {:include => {:option_values => {:include => :option_type},\n :images => {:only => [:id], :methods => :mini_url}}},\n :images => {:only => [:id], :methods => :mini_url}, :master => {}})\n end\n end",
"def format=(new_format)\n valid_formats = [:json, :xml]\n raise ArgumentError, \"Invalid format. Supported formats: #{valid_formats.join(', ')}.\" unless valid_formats.include?(new_format.to_sym)\n @format = new_format\n refresh_config_for_api_objects!\n @format\n end",
"def as_json(options={})\n options[:include] = {\n :organisation => {},\n :locations => { \n methods: :geometry,\n include: :accessibilities\n },\n :taxonomies => { methods: :slug },\n :meta => {},\n :contacts => {},\n :local_offer => {},\n :send_needs => {},\n :suitabilities => {},\n :cost_options => {},\n :regular_schedules => {},\n :links => {}\n }\n super\n end",
"def json?\n content_type == \"application/json\"\n end",
"def as_json_type9\n as_json({\n only: [\n :id,\n :key,\n :name,\n :permit_tag_list,\n :name_input_at,\n ],\n include: {\n emotions: Actb::Emotion.json_type13,\n },\n methods: [\n :avatar_path,\n :rating,\n :skill_key,\n :description,\n :twitter_key,\n :actb_created_after_days,\n :session_lock_token,\n ],\n })\n end",
"def json_input?\n return request.content_type == 'application/json'\n end",
"def extension\r\n\t\t\"json\"\r\n\tend",
"def render(*)\n respond_to do |format|\n format.jsonapi { super }\n format.json { super }\n end\n end",
"def json_request(verb, path, body = {}, headers = {})\n headers['Content-Type'] = 'application/json'\n result = @http.send_request(verb, path, body, headers)\n result = Oj.safe_load(result) if result.is_a? String\n result\n end",
"def check_format\n redirect_to root_url unless params[:format] == 'json' || request.headers[\"Accept\"] =~ /json/\n end",
"def default_headers\n {:accept => \"application/json\", :content_type => \"application/json\"}\n end",
"def json\n {}\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => '',\n :client => self.client.first_name + ' ' + self.client.last_name,\n :name => self.name,\n# :description => self.description || \"\",\n :start => start_datetime.rfc822,\n :start_window => start_window.rfc822,\n :end => '',\n :allDay => '',\n# :recurring => false,\n :url => Rails.application.routes.url_helpers.job_request_path(id)\n } \n end",
"def to_json\n request.clone.to_json\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 json(str)\n @headers[Rack::CONTENT_TYPE] = ContentType::JSON\n write(str)\n end",
"def tojson\n\t\tend",
"def as_json options=nil\n options ||= {}\n options[:methods] = ((options[:methods] || []) + [:studentsAmount, :ceo, :ceo_id, :is_member, :logo_file, :access_requested])\n super options\n end",
"def marshal(request_object)\n JSON.pretty_generate(request_object.to_h)\n end",
"def to_json\n\n end",
"def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end",
"def to_json(*options)\n\t\tas_json(*options).to_json(*options)\n\tend"
] | [
"0.8735248",
"0.86770344",
"0.86574763",
"0.8134119",
"0.81194925",
"0.81194925",
"0.81113845",
"0.80337226",
"0.801793",
"0.7883056",
"0.7813645",
"0.779202",
"0.74033487",
"0.7020352",
"0.66627717",
"0.66150296",
"0.65191454",
"0.65140676",
"0.6500225",
"0.64760005",
"0.64760005",
"0.64627224",
"0.6449997",
"0.64279586",
"0.64279586",
"0.64279586",
"0.64279586",
"0.64279586",
"0.6392921",
"0.63691646",
"0.6341256",
"0.6296582",
"0.6248117",
"0.6248117",
"0.6180103",
"0.6174724",
"0.6163858",
"0.61616653",
"0.61596537",
"0.6136459",
"0.6125579",
"0.6123654",
"0.6081693",
"0.60535353",
"0.60490185",
"0.6009821",
"0.60056746",
"0.5993645",
"0.5989807",
"0.5969853",
"0.59501123",
"0.5946562",
"0.5943805",
"0.5943805",
"0.59141076",
"0.59108055",
"0.59057575",
"0.5903139",
"0.59018767",
"0.5898996",
"0.58846366",
"0.5860814",
"0.58553267",
"0.585338",
"0.58365583",
"0.58207583",
"0.5820685",
"0.5810166",
"0.57999355",
"0.57999355",
"0.57999355",
"0.5792769",
"0.57869256",
"0.57862604",
"0.5785522",
"0.5784674",
"0.57758963",
"0.5773621",
"0.576434",
"0.5760569",
"0.57496154",
"0.5739243",
"0.5726817",
"0.571346",
"0.57132345",
"0.57067305",
"0.5706331",
"0.5702323",
"0.57016444",
"0.5687821",
"0.56866443",
"0.5680268",
"0.5679753",
"0.5657561",
"0.564817",
"0.56475574",
"0.5645398",
"0.5645192",
"0.5645008",
"0.56353354",
"0.56231093"
] | 0.0 | -1 |
Set this to be true if you want to update entity user object without setting a title | def bypass_title_validation?
bypass_title_validation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @user_name = args[:user_name] if args.key?(:user_name)\n end",
"def update!(**args)\n @user_name = args[:user_name] if args.key?(:user_name)\n end",
"def user_attributes=(attrs)\n self.user = User.where(attrs).first_or_initialize(attrs) \n @show_exists_message = !user.new_record?\n end",
"def conditionally_update\n return true unless params[:user]\n @user.update(user_params)\n end",
"def check_author\n if self.author.blank?\n self.author = 'anon'\n end\n end",
"def set_readonly_user(opts)\n opts = check_params(opts,[:ro_user_info])\n super(opts)\n end",
"def first_time_user=(value)\n @first_time_user = !!value\n end",
"def update!(**args)\n @username = args[:username] if args.key?(:username)\n end",
"def update!(**args)\n @username = args[:username] if args.key?(:username)\n end",
"def update!(**args)\n @username = args[:username] if args.key?(:username)\n end",
"def fill_up_user_update\n # return true if !self.class.column_names.include? 'updated_by_id'\n return true if !UserInfo.current_user_id\n\n # self.updated_by_id = UserInfo.current_user_id\n true\n end",
"def save\n super if self.user_id.present?\n # Else do nothing (dont call save)\n end",
"def update_user\n end",
"def update!(**args)\n @user_info = args[:user_info] if args.key?(:user_info)\n end",
"def set_create_user(opts)\n opts = check_params(opts,[:user_info])\n super(opts)\n end",
"def update?\n return true if user.present? && user == article.user\n end",
"def update\n @user.update_attributes!(user_params)\n \n render nothing: true, status: :no_content\n end",
"def update_user\n\t\tunless current_user.id == @prototype.user.id\n\t\t\tredirect_to root_path\n\t\tend\n\tend",
"def edit_username(user, username)\n manager = UserManager.new\n if manager.user_exists?(username)\n return false\n else\n manager.remove( :username => user.username )\n user.username = username\n session[\"username\"] = username\n session[\"user\"] = user\n user.save_data\n end\n end",
"def update!(**args)\n @domain_name = args[:domain_name] if args.key?(:domain_name)\n @is_user_name_editable = args[:is_user_name_editable] if args.key?(:is_user_name_editable)\n @user_name = args[:user_name] if args.key?(:user_name)\n end",
"def edit\n @title = \"Edit user\"\n end",
"def edit\n @title = \"Edit user\"\n end",
"def set_user!(user)\n\t\tself.user_id = user.id\n\t\tself.save!\n\tend",
"def make_first_user_admin\n return unless User.count.zero?\n\n self.is_admin = true\n self.approved = true\n end",
"def sync_username\n if self.username.to_s.blank? and !self.email.to_s.blank?\n self.username = self.email\n end\n end",
"def set_user\n @user = User.where(:username => params[:id]).first!\n end",
"def update!(**args)\n @disabled_user_deletion = args[:disabled_user_deletion] if args.key?(:disabled_user_deletion)\n @disabled_user_signup = args[:disabled_user_signup] if args.key?(:disabled_user_signup)\n end",
"def update!(**args)\n @disabled_user_deletion = args[:disabled_user_deletion] if args.key?(:disabled_user_deletion)\n @disabled_user_signup = args[:disabled_user_signup] if args.key?(:disabled_user_signup)\n end",
"def update!(**args)\n @user_id = args[:user_id] if args.key?(:user_id)\n end",
"def update!(**args)\n @user_id = args[:user_id] if args.key?(:user_id)\n end",
"def update!(**args)\n @user_id = args[:user_id] if args.key?(:user_id)\n end",
"def update_user_if_save_version\n self.user = User.current if save_version?\n end",
"def update?\n user == identity.user\n end",
"def editable_by?(user)\n user && self.user_id == user.id\n end",
"def editable_by?(user)\n user && self.user_id == user.id\n end",
"def set_author_name\n # Handles toggling between fake and real names (at edit)\n if anonymouse_changed?\n if self.anonymouse?\n self.author_name = Faker::Name.name\n else\n self.author_name = self.user.name\n end\n end\n # Handles\n if !self.anonymouse?\n self.author_name = self.user.name\n end\n end",
"def update?\n\t\t@comment.user == @user\n\tend",
"def update?\n raise CustomErrors::PermissionError unless record.id == user.id\n\n Regular.new(record)\n end",
"def editable_by?(user)\n\t\tuser && user == author\n\tend",
"def set_user; end",
"def user_name_set(name)\n self.username.set name if nil_or_empty?(username[:value])\n end",
"def update!(**args)\n @display_name = args[:display_name] if args.key?(:display_name)\n @is_anonymous = args[:is_anonymous] if args.key?(:is_anonymous)\n end",
"def update!(**args)\n @display_name = args[:display_name] if args.key?(:display_name)\n @is_anonymous = args[:is_anonymous] if args.key?(:is_anonymous)\n end",
"def user_id=(new_id)\n if allow_editing?\n @user_id = ForeignKey.new(id: new_id, class_name: User)\n @user_name = user.name\n end\n end",
"def blank_username\n self.username = ''\n end",
"def set_user_name_field(user_name)\n end",
"def user=(username)\n contact = if username.is_a?(User)\n username.id\n else\n username\n end\n @tainted = true\n end",
"def nullify!(user=nil)\n self.update_attribute(:body, nil) if self.editable_by?(user)\n end",
"def set_user_and_verify #TODO: Make this common to both items and tags\n @user = User.find_by(id: params[:user_id])\n if @user.blank?\n head :forbidden\n end\n end",
"def update!(**args)\n @is_current_user = args[:is_current_user] if args.key?(:is_current_user)\n @person_name = args[:person_name] if args.key?(:person_name)\n end",
"def modified_by(user)\n #none by default\n end",
"def modified_by(user)\n #none by default\n end",
"def update!(**args)\n @postini_user_id = args[:postini_user_id] if args.key?(:postini_user_id)\n end",
"def update!(**args)\n @postini_user_id = args[:postini_user_id] if args.key?(:postini_user_id)\n end",
"def remove_readonly_user(opts)\n opts = check_params(opts,[:ro_user_info])\n super(opts)\n end",
"def edit\n set_user\n end",
"def updatable_by?(user, parent = nil)\n raise \"#{self.class}#updatable_by?(user, parent = nil) must be overridden\"\n end",
"def update_username(username)\n @username = username\n end",
"def editable?\n new_record? || !user_id.nil?\n end",
"def update?\n !user.nil? and ((user.id == record.user.id) or user.admin?)\n end",
"def set_user\n @form_user = User.new(:email => self.user_email, :first_name => self.user_first_name,\n :last_name => self.user_last_name)\n @user = User.where(:email => self.user_email).first\n @new_user = false\n if @user.nil?\n @new_user = true\n @user = @form_user\n end\n end",
"def created_by=(user)\n write_attribute(:created_by, user.id) unless user.nil? or user.id.nil?\n end",
"def check_user_id\n if self.user_id.nil?\n set_user_id\n end\n end",
"def update?\n user_is_owner_or_admin?\n end",
"def update?\n !user.nil? && user.admin?\n end",
"def update\n @update_success = @user.update(user_params)\n super\n end",
"def authorizes_to_edit_user_admin_field?(user, options = {})\n user.admin? && user.id != options[:user_id]\n end",
"def set_AuthorUsername(value)\n set_input(\"AuthorUsername\", value)\n end",
"def edit\n if params[:id].present?\n @user = User.find(params[:id])\n else\n super\n end\n end",
"def set_create_user_fields\n user_id = AuditModule.get_current_user.uid\n self.created_by = user_id\n self.updated_by = user_id\n end",
"def set_username_validation\n\t if @do_username_validation != false\n\t\t @do_username_validation = true\n\t end\n end",
"def update?\n user.admin?\n end",
"def user_id\n self.title_and_name\n end",
"def show\n @user = User.find(params[:id])\n @title = @user.name + \" \" + @user.surname\n if current_user == @user\n @this_user = true\n else\n @this_user = false\n end\n# @this_user = current_user == @user ? true : false\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def update\n if @current_user.update(user_params)\n if @current_user.saved_change_to_attribute?(\"first_name\") || @current_user.saved_change_to_attribute?(\"last_name\")\n redirect_to home_path, notice: \"Your name has been updated successfully.\"\n elsif @current_user.saved_change_to_attribute?(\"order_categories_by\")\n redirect_to categories_path, notice: \"Journal sorting changed.\"\n else\n redirect_back(fallback_location: root_path)\n end\n else\n render action: 'edit'\n end\n end",
"def username_changed?\n is_changed?(:username)\n end",
"def update_presence_false\n current_user.update(presence: false, date_derniere_deconnexion: Time.now.utc)\n end",
"def create?\n\t\t!@user.nil?\n\tend",
"def username=(value)\n write_attribute(:username, value)\n reset_persistence_token if username_changed?\n end",
"def set_readwrite_user(opts)\n opts = check_params(opts,[:rw_user_info])\n super(opts)\n end",
"def get_user\r\n \tself.user = update_user\r\n end",
"def create?\n @user != nil\n end",
"def username= new_username\n @username = new_username\n end",
"def update?\n user_is_owner? || user_is_admin?\n end",
"def force_write_user\n return true if no_user_validation\n\n # Special handling for editable reports and dynamic models with no_master_association set\n if respond_to?(:user_id) && respond_to?(:current_user) && (\n !self.class.respond_to?(:no_master_association) || self.class.no_master_association\n )\n return write_attribute :user_id, current_user.id\n end\n\n logger.debug \"Forcing save of user in #{self}\"\n return if respond_to?(:master) && !master\n\n mu = master_user\n unless mu.is_a?(User) && mu.persisted?\n master = '[not defined]' unless respond_to? :master\n raise \"bad user (for master #{master}) being pulled from master_user \" \\\n \"(#{mu.is_a?(User) ? '' : 'not a user'}#{mu && mu.persisted? ? '' : ' not persisted'})\"\n end\n\n write_attribute :user_id, mu.id\n end",
"def set_user\n if self.question and self.question.user\n self.user = self.question.user\n end\n end",
"def editable_by?(user)\n \tuser && user == owner\n\tend",
"def saved?\n user_id?\n end",
"def update!(**args)\n @deleted_user = args[:deleted_user] if args.key?(:deleted_user)\n @known_user = args[:known_user] if args.key?(:known_user)\n @unknown_user = args[:unknown_user] if args.key?(:unknown_user)\n end",
"def edit\n @user.build_user_profile unless @user.user_profile\n end",
"def set_admin\n if User.count == 1\n self.statut = \"admin\"\n self.save\n end\n end",
"def update!(**args)\n @login_user = args[:login_user] if args.key?(:login_user)\n end",
"def update!(**args)\n @login_user = args[:login_user] if args.key?(:login_user)\n end",
"def set_user\n @user = User.unscoped.find(params[:id])\n end",
"def user(*args)\n super(*args) || build_user\n end",
"def new_username=(value)\n @new_username = (value.nil? ? value : value.upcase)\n end",
"def create_or_unhide\n if has_missing_params?([:user_name])\n # incomplete/invalid HTTP params\n render 'shared/http_status', locals: { code: '422', message:\n HttpStatusHelper::ERROR_CODE['message']['422'] }, status: 422\n return\n end\n\n # Check if that user_name is taken\n user = User.find_by_user_name(params[:user_name])\n if user.nil?\n create\n else\n user.update(hidden: false)\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: 200\n end\n end",
"def set_user\n @user = User.find(params[:last_name] || params[:id])\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 confirm!\n # add if else here in case user already existed and is updating/changing data (email etc),\n # shouldn't add_profile again if profile already exists. can determine with a user db 'nil' value...\n unless self.profile\n add_profile\n end\n super\n end",
"def title\n object.user.full_name\n end"
] | [
"0.63977045",
"0.63977045",
"0.62198687",
"0.61778176",
"0.6164568",
"0.6129842",
"0.6080536",
"0.60312086",
"0.60312086",
"0.60312086",
"0.6021958",
"0.60059375",
"0.60019237",
"0.5987889",
"0.59604645",
"0.593959",
"0.5919393",
"0.5909238",
"0.59076786",
"0.58976203",
"0.5887316",
"0.5887316",
"0.588187",
"0.5875466",
"0.5864209",
"0.58500326",
"0.5823216",
"0.5823216",
"0.58155984",
"0.58155984",
"0.58155984",
"0.5805208",
"0.58036447",
"0.57997346",
"0.57997346",
"0.5788951",
"0.57860374",
"0.57748383",
"0.5768598",
"0.5766136",
"0.5758822",
"0.5756707",
"0.5756707",
"0.57488",
"0.5748366",
"0.57334715",
"0.57300955",
"0.57240474",
"0.5718505",
"0.57087284",
"0.5706224",
"0.5706224",
"0.56875336",
"0.56875336",
"0.568322",
"0.5657211",
"0.56557715",
"0.5647306",
"0.5645055",
"0.5644043",
"0.5641289",
"0.56324077",
"0.5624381",
"0.56238776",
"0.5617294",
"0.5616054",
"0.5615312",
"0.5610163",
"0.5608229",
"0.5602938",
"0.5599265",
"0.55959994",
"0.55944216",
"0.5583847",
"0.5575531",
"0.5564991",
"0.55642545",
"0.5555103",
"0.55526584",
"0.5551106",
"0.55471396",
"0.5546815",
"0.5545025",
"0.554166",
"0.55413985",
"0.5538783",
"0.55180913",
"0.5515665",
"0.55147517",
"0.55117065",
"0.55101305",
"0.55094165",
"0.55094165",
"0.5506202",
"0.5485254",
"0.54850435",
"0.5484104",
"0.54803634",
"0.5472921",
"0.5457109",
"0.54521483"
] | 0.0 | -1 |
We implement this because it's required by DealOwner | def email_domain
user.email_domain
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(deal)\n @deal = deal\n super\n end",
"def bought_by(new_owner)\r\n self.owner = new_owner\r\n self.to_inactive\r\n end",
"def ink_deal\n if @ink_deal\n @ink_deal\n else\n @ink_deal = promotion.ink_deal\n end\n end",
"def pre_pay_offered\n end",
"def private; end",
"def chargeable?; true; end",
"def owner; end",
"def owner; end",
"def redeem\n #TO BE IMPLEMENTED\n end",
"def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end",
"def after_redeem() end",
"def deal;end",
"def dividends_for_entity(entity, holder, per_share)\n return 0 if entity.corporation? && entity.capitalization == :full && holder == @game.share_pool\n\n super\n end",
"def contract; end",
"def contract; end",
"def offer\n # TODO: implement\n end",
"def make_deal!\n if deal_with_other_offers \n if selling?\n Deal.create!(:buyer_id => self.reciever_id, :seller_id => self.sender_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n else\n Deal.create!(:buyer_id => self.sender_id, :seller_id => self.reciever_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n end\n\n sender_listing = sender.listing_from_textbook(textbook_id)\n sender_listing.destroy if sender_listing.nil? == false\n\n reciever_listing = reciever.listing_from_textbook(textbook_id)\n reciever_listing.destroy if reciever_listing.nil? == false\n else\n return false\n end\n end",
"def deal\n self.player.receive_card hit \n self.dealer.receive_card hit \n self.player.receive_card hit \n self.dealer.receive_card hit \n end",
"def sell_pending\n end",
"def get_deal\n @deal = Deal.find(params[:deal_id])\n end",
"def deal_cards\n\t\t\tend",
"def celebration; end",
"def start_deal\n @deal_count = 0\n end",
"def strategy; end",
"def set_deal\n @deal = Deal.find_by(id: params[:id])\n end",
"def company_bought(company, buyer); end",
"def create\n authorize! :create, Deal\n \n @deal = Deal.new(deal_params)\n @deal.pb_member_id = @current_user.id\n respond_to do |format|\n if @deal.save\n @deal.update_top_industry\n format.html { redirect_to deals_path, notice: 'DEAL đã được tạo thành công!' }\n format.json { render :show, status: :created, location: @deal }\n else\n format.html { render :new }\n format.json { render json: @deal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def owner\n self.company.present? ? self.company.owner : self\n end",
"def deal_card\n\t\tCard.deal_new(self)\n\t\tupdate_total\n\tend",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def set_deal\n @deal = Deal.find(params[:id])\n end",
"def promotion\r\n\r\n end",
"def update_deal_costs(deal)\n end",
"def buy?(buyer)\r\n if buyer.credits < self.price or not self.active or buyer == self.owner\r\n false\r\n return\r\n end\r\n owner.credits += self.price\r\n buyer.credits -= self.price\r\n self.owner.remove_owned(self)\r\n self.owner = buyer \r\n buyer.add_owned(self)\r\n self.active = false\r\n true \r\n end",
"def award; end",
"def pending_offers_as_buyer\n self.offers_as_buyer.pending\n end",
"def fulfill_order(line_item_id, carrier, tracking)\n order = ShopifyOrder.find_by name: line_item_id\n unique_data = {\n order_id: order.id,\n tracking_company: carrier_map(carrier),\n }\n # find or initialize a fulfilment with the associated order and carrier\n begin\n fulfillment = ShopifyAPI::Fulfillment.find(:first, params: unique_data)\n fulfillment.tracking_numbers = (fulfillment.tracking_numbers + [tracking]).uniq\n fulfilment.save\n rescue ActiveResource::ResourceNotFound\n ShopifyAPI::Fulfillment.create(unique_data.merge({\n line_items: order.line_items.map{|line_item| { id: line_item['id'] }},\n notify_customer: true,\n tracking_numbers: [tracking],\n }))\n end\n\n # using the setter/getter methods results in MethodMissing errors, so interact\n # with the attribute hash instead\n\n\nend",
"def action(**args)\n\t\t\targs[:player].decide(:consider_purchase, property: self) if args[:player].balance >= cost unless @owner\n\t\t\tsuper\n\t\tend",
"def new\n respond_with(deal)\n end",
"def set_dealership\n @dealership = Dealership.find(params[:id])\n end",
"def isolated; end",
"def isolated; end",
"def starship; end",
"def investor\n end",
"def set_dealership\n @dealership = Dealership.find(params[:id])\n end",
"def item_owner\n items.first.owner\n end",
"def set_vendor_fulfillment\n @vendor_fulfillment = @order.vendor_fulfillments.find_by_id(params[:id])\n end",
"def shipped\n \n end",
"def prepareForReuse; end",
"def actual_accommodation\r\n return self.accommodation_histories.last\r\n end",
"def affichage_player\n\n\n end",
"def attemp_buying\n\n end",
"def leading_card\n \tCard.find_by(owner_id: id )\n end",
"def party_owner\n if !self.account_id.nil?\n self.account.name\n elsif !self.vendor_id.nil?\n self.vendor.name\n elsif !self.user_id.nil?\n \"Personal Contact\"\n else\n \"-\"\n end\n end",
"def item_owner\n self\n end",
"def deal\n @hand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n end",
"def refutal()\n end",
"def validate_ownership\n buyer_items.each { |item| item.validate_owner seller }\n seller_items.each { |item| item.validate_owner buyer }\n end",
"def auto_dispute_order_details\n nil\n end",
"def owned?() end",
"def offer\n nil\n end",
"def offer\n nil\n end",
"def describe_their_ownership\n\t\tif self.forsale\n\t\t\treturn \"is selling a\" \n\t\telsif self.wanted \n\t\t\treturn \"wants to buy a\" \n else \n\t \t\treturn \"owns \" \n\t end \n\tend",
"def card\n\t @dance_card\n\tend",
"def initialize\r\n @name = \"Dealer\" # assign dealer object name to \"Dealer\"\r\n @cards = []\r\n end",
"def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end",
"def commence\n raise NotImplementedError\n end",
"def offer\n self\n end",
"def create\n @deal = Deal.new(params[:deal])\n @company = Company.find_by_user_id(current_user.id)\n @deal.company_id = @company.id\n respond_to do |format|\n if @deal.save\n format.html { redirect_to(@deal, :flash => {:success => 'Deal successfully created.'}) }\n format.xml { render :xml => @deal, :status => :created, :location => @deal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @deal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def charge_detail(charge)\n raise \"This method has to be defined on the concrete implementations\"\n end",
"def owner; h.owner; end",
"def offer\n end",
"def offer\n end",
"def offer\n end",
"def probers; end",
"def credits; end",
"def show\n respond_with(deal)\n end",
"def handle; end",
"def change_entity(_action)\n return @current_entity = company_pending_par.owner if company_pending_par\n\n if (bids = @bids[@auctioning_company]).any?\n # There are still remaining bids on a limited auction. The\n # lowest-bidding remaining player goes next.\n @current_entity = bids.min_by(&:price).entity\n else\n # If we just exited a limited auction, move to the player after the\n # one who triggered it.\n @current_entity = @auction_triggerer if @auction_triggerer\n\n loop do\n @current_entity = next_entity\n break if !@current_entity.passed? || all_passed?\n end\n end\n end",
"def franchisee_royalty_pay_slip\n \n end",
"def donors_setup\n end",
"def offenses; end",
"def offenses; end",
"def offenses; end",
"def can_auction?(_company)\n true\n end",
"def trade; end",
"def negotiate_best_deal?\n nil\n end",
"def company; end",
"def company; end",
"def prepare\n super\n end",
"def before_create\n select = \"#{Company.table_name}.id\"\n \n # serialized adjustments. initialize the array.\n self.adjustments = []\n \n case payable_type\n when \"OrderEntityCost\" \n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{OrderEntityCost.table_name} AS oec ON oec.order_entity_id = oe.id\"\n c = \"oec.id = #{payable_id}\" \n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.name\n when \"OrderEntity\"\n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n c = \"oe.id = #{payable_id}\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.label + ' charge' #<-- OrderTypeEntity.label [Pickup Agent, Carrier, Delivery-agent, etc]\n when \"CompanySalesAccount\"\n j = \"LEFT OUTER JOIN #{Account.table_name} AS a ON a.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{CompanySalesAccount.table_name} AS csa ON csa.account_id = a.id\"\n c = \"csa.id = #{payable_id}\"\n self.name = \"Commission\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id \n end\n end",
"def set_book_deal\n @book_deal = BookDeal.find(params[:id])\n end",
"def proxy_owner\n @owner\n end",
"def personal_mechanic_of\n self.cars_serviced.map{|car| car.car_owner}\nend",
"def market\n end",
"def hit(deck)\n deck.deal_card(self)\n end"
] | [
"0.62048924",
"0.568874",
"0.56704336",
"0.5668886",
"0.5549394",
"0.55223525",
"0.5502812",
"0.5502812",
"0.54942054",
"0.54335773",
"0.54231644",
"0.5380253",
"0.53558564",
"0.53518426",
"0.53518426",
"0.53448105",
"0.5335708",
"0.53322595",
"0.53130704",
"0.5287886",
"0.52797633",
"0.52614486",
"0.5260281",
"0.5248633",
"0.52323264",
"0.522837",
"0.5226742",
"0.52110016",
"0.5206683",
"0.5205819",
"0.5205819",
"0.5205819",
"0.5205819",
"0.5205819",
"0.5205819",
"0.5205819",
"0.51651394",
"0.5154811",
"0.5150892",
"0.5128165",
"0.5127877",
"0.51017946",
"0.5097626",
"0.5092027",
"0.5072748",
"0.50700474",
"0.50700474",
"0.50459415",
"0.5045092",
"0.5043047",
"0.5031737",
"0.5026678",
"0.5025436",
"0.50251174",
"0.5015766",
"0.5011877",
"0.5006214",
"0.5004846",
"0.50019157",
"0.49944046",
"0.49923676",
"0.49682477",
"0.49662247",
"0.4957606",
"0.49573973",
"0.4953992",
"0.4953992",
"0.49503657",
"0.4948325",
"0.49480185",
"0.4939978",
"0.49384096",
"0.4935869",
"0.49350297",
"0.49348775",
"0.4934574",
"0.49324802",
"0.49324802",
"0.49324802",
"0.49312976",
"0.492994",
"0.4924525",
"0.49223894",
"0.49211746",
"0.49177924",
"0.49177074",
"0.49169505",
"0.49169505",
"0.49169505",
"0.4910236",
"0.49046403",
"0.4903495",
"0.49012262",
"0.49012262",
"0.4899111",
"0.48969403",
"0.48954967",
"0.48946127",
"0.4892201",
"0.48905534",
"0.48884726"
] | 0.0 | -1 |
This method retrieves current logged in user details. | def current_user
@curr_user=User.find(session[:user_id])
rescue ActiveRecord::RecordNotFound
user = User.create
session[:user_id] = user.id
@curr_user = user
user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend",
"def get_current_user\n @user = User.find(params[:user_id])\n # @user = current_user\n end",
"def current_user\n load_session\n @current_user\n end",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend",
"def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end",
"def getUser\n render json: @current_user, status: 200\n end",
"def current_user\n\t\tif session[:user_id].present?\n\t\t\tUser.find(session[:user_id])\n\t\tend\n\tend",
"def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def current_user\n\t\t\tUser.find_by_id(session[:user_id])\n\t\tend",
"def current_user\n\n \tif session[:user_id].present?\n \t\tUser.find(session[:user_id])\n\n \tend\n\n end",
"def info()\n get(:session, {:method => \"user.getInfo\"})\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def get_user\n\t\tif !session[:user_id]\n\t\t\t@user = nil\n\t\telse\n\t\t\t@user = User.find(session[:user_id])\n\t end\n\tend",
"def current_user\n\t\tUser.find_by(:id => session[:user_id])\n\tend",
"def get_user \n\t\treturn User.find(self.user_id)\n\tend",
"def current_user\n\tif session[:user_id].present?\n\t\tUser.find(session[:user_id])\t\n\tend\nend",
"def get_user\n @current_user = current_user\n end",
"def get_cur_user\n @user = nil\n if is_logged_in session\n @user = User.find_by_sunet(session[:user_hash][\"username\"])\n end\n render json: @user\n end",
"def get_cur_user\n @user = nil\n if is_logged_in session\n @user = User.find_by_sunet(session[:user_hash][\"username\"])\n end\n render json: @user\n end",
"def current_user\n if session[:user_id]\n user = User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find_by(id: session[:user_id])\n end\n end",
"def current_user\n return unless session[:user_id]\n User.find(session[:user_id])\n end",
"def get_current_user\n if session[:user_id].blank?\n redirect_to :login\n else\n @current_user = User.find(session[:user_id])\n end\n end",
"def get_current_user\n unless session[:user_id].blank?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n end\n end",
"def get_current_user\n request(Route.new(:GET, '/users/@me'))\n end",
"def current_user\n get(\"/v1/users/me\")\n end",
"def current_user\n if valid_session?\n User.find(session[:user_id])\n end\n end",
"def current_user\n auth_token = request.headers['HTTP_AUTH_TOKEN']\n puts auth_token\n @current_user ||= User.find_by(auth_token: auth_token)\n #puts @current_user.name + \" is logged in\"\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end",
"def get_current_user\n unless session[:user_id]\n @current_user = nil\n return\n end\n @current_user = User.first(:conditions => {:id => session[:user_id] })\n end",
"def current_user\n\t\t@current_user ||= User.find(session[:user_id]) if session[:user_id]\n\t\tputs @current_user\t\n\tend",
"def current_user\n @user = User.find(session[:user_id])\n end",
"def get_current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[\"user_id\"])\n end\n end",
"def current_user\n\t\tif !@current_user\n\t\t\t@current_user = User.find_by(id: session[:user_id])\n\t\tend\n\t\t@current_user\n\tend",
"def get_user\n @user = current_user\n end",
"def user_info\n auth_hash['user_info']\n end",
"def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend",
"def current_user\n get_from_options_or_controller(:current_user)\n end",
"def current_user\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n end\n end",
"def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] \n #return this user if session[:user_id] that is stored in our session hash if so then find the user in our database and display it, \n # the @current_user is handy if the user already exist and we do not want the user id keep heiting the database every time \n end",
"def user_info\n response = from_server \"api/user.json\"\n response.data\n end",
"def current_user\n if session[:user_id]\n puts \"session user_id #{session[:user_id]}\"\n User.find(session[:user_id])\n end\nend",
"def current_user\n @user = User.find_by(id: session[:user_id])\n end",
"def current_user(id = session[:user_id])\n User.get_one id\n end",
"def current_user\n User.find_by(uid: session[:user]) if logged_in?\n end",
"def current_user\n # find a user by id based on the stored :user_id cookie\n User.find_by_id(session[:user_id])\n end",
"def current_user\n session[:user]\n end",
"def user_info\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n\n respond_to do |format|\n name = @current_user.name\n username = @current_user.username\n format.json {\n render json: {\n :name => name,\n :username => username,\n }.to_json, status: 200\n }\n end\n end",
"def user\n return Etc.getlogin\n end",
"def current_user\n # User.find would throw an error if we cannot find the user\n User.find_by({ id: session[:user_id] })\n end",
"def show\n {\n id: @current_user.id,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name,\n email: @current_user.email,\n role_name: @current_user.super_admin ? 'Super Admin' : @current_user.role.try(:name),\n permissions: Permissions::Builder.user_permissions(@current_user)\n }\n end",
"def current_user\n @user = User.find(@session.user_id)\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def client_side_current_user\n if session[:user_id]\n User.select([:first_name, :last_name, :email]).find session[:user_id]\n end\n end",
"def current_user\n if session[:user_id].present?\n @current_user = User.find_by(uid: session[:user_id])\n # session.clear if @current_user.nil?\n return @current_user\n end\n end",
"def current_user\n\t\tif session[:user_id]\n\t\t @current_user = User.find(session[:user_id])\n\t\telse\n\t\t @current_user = nil\n\t\tend\n\t\t @current_user\n end",
"def current_user\n User.find(session[:user_id])\n end",
"def current_user\n User.find(session[:user_id])\n end",
"def actual_user\n User.find_by_id(session[:user_id])\n end",
"def current_user\n user_id = get_log_in_session\n if user_id\n get_user(user_id)\n else\n user = get_user(cookies.signed['user_id'])\n if user&.authenticated?(:remember, cookies[:remember_token])\n set_log_in_session user\n user\n end\n end\n end",
"def current_user\n if session[:user_id] \n @current_user = User.find(session[:user_id])\n end\n end",
"def userinfo\n if @user.nil?\n nil\n elsif @password.nil?\n @user\n else\n @user + ':' + @password\n end\n end",
"def current_user\n user = User.find_by(id: session[:user_id])\n end",
"def get_current_user\n if @current_user\n return @current_user\n else\n @current_user = User.find_by(id: session[:user_id])\n end\n end",
"def show\n {\n id: @current_user.id,\n email: @current_user.email,\n access_token: @current_user.access_token\n }\n end",
"def current_user\n\tputs \"*** current_user ***\"\n\tif session[:user_id]\n\t\t@current_user = User.find(session[:user_id])\n\t\tputs \"@current_user: #{@current_user}\"\n\telse\n\t\t@current_user = nil\n\t\tputs \"@current_user: #{@current_user}\"\n\tend\nend",
"def current_user\n 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 current_user\n puts \"******* current_user *******\"\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n puts \"@current_user: #{@current_user.inspect}\"\n end",
"def current_user\n current_session.user\n end",
"def get_user_details\n\t\tid = params[:id]\n\t\tTheCityAdmin::AdminApi.connect(Rcplugin::CITY_ADMIN_SECRET,Rcplugin::CITY_USER_TOKEN)\n\t\t@user = TheCityAdmin::User.load_by_id(id)\n\tend",
"def current_user\n\tif session[:user_id]\n\t@current_user = User.find(session[:user_id])\n\tend\nend",
"def getLoggedInUser\n if session[:user_id]\n return User.find(session[:user_id])\n else\n return nil\n end\n end",
"def current_user\n session.user\n end",
"def get_user\n \n # Retrieve user id if stored in a cookies\n # @TODO Secure ID when stored in cookies\n if cookies[:user]\n return User.find(cookies[:user])\n\n # Retrieve user id if stored in session\n elsif session[:user]\n return User.find(session[:user])\n\n # No user logged in\n else\n return nil\n end\n\n end",
"def current_user\n return nil unless session[:user_id]\n User.get(session[:user_id])\nend",
"def current_user\n\n sql = \"SELECT * FROM users WHERE id = $1;\"\n \n results = run_sql(sql, [session[:user_id]]) \n return results.first\n end",
"def get_logged_user()\n begin\n #logger.warn \"session[:logged_user_id]=#{session[:logged_user_id].inspect}\"\n if session[:logged_user_id]\n @current_user ||= User.find(session[:logged_user_id])\n end\n rescue\n logger.warn \"Oups I'can't find user with id=#{session[:logged_user_id].inspect}\"\n nil\n end\n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n @current_user if logged_in?\n end",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def current_user\n User.find(session[:user_id]) if session[:user_id]\n end",
"def get_current_user\n return Account.find_by(user_name: session[:current_user].user_name)\n end",
"def current_user #used in many methods to pull in the current user stored in sessions. \n \tUser.find(session[:user_id]) if session[:user_id]\n end",
"def getUser()\n\t\treturn @user\n\tend",
"def current_user\n session[:usr_id]\n end"
] | [
"0.82055825",
"0.7853838",
"0.77531147",
"0.773002",
"0.7723319",
"0.7723319",
"0.7722386",
"0.77183783",
"0.7692591",
"0.76631725",
"0.76631725",
"0.7636778",
"0.7634264",
"0.7606512",
"0.7590906",
"0.7590906",
"0.7589315",
"0.75891536",
"0.7568034",
"0.756519",
"0.75640917",
"0.75456613",
"0.75456613",
"0.7537827",
"0.75324494",
"0.7519577",
"0.75069225",
"0.7500409",
"0.75003004",
"0.74842155",
"0.748274",
"0.7481635",
"0.74763846",
"0.7474653",
"0.7473041",
"0.7473041",
"0.7473041",
"0.74682426",
"0.7464878",
"0.74647677",
"0.7462724",
"0.7459886",
"0.74440616",
"0.7432579",
"0.7431483",
"0.7428996",
"0.742887",
"0.74240476",
"0.7418172",
"0.74158263",
"0.7414612",
"0.7412769",
"0.7409757",
"0.74032813",
"0.7398925",
"0.7398641",
"0.7396899",
"0.7395969",
"0.7383586",
"0.7379821",
"0.7378887",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73729503",
"0.73699653",
"0.7369506",
"0.7368845",
"0.7365352",
"0.7365352",
"0.7362947",
"0.73618674",
"0.7359021",
"0.7351036",
"0.7348116",
"0.73475534",
"0.73381066",
"0.73376316",
"0.73297757",
"0.73290676",
"0.73270476",
"0.73268914",
"0.73256165",
"0.7325291",
"0.7322945",
"0.7318846",
"0.7317459",
"0.73172444",
"0.7317085",
"0.7310832",
"0.7310832",
"0.7308211",
"0.7308211",
"0.7307573",
"0.7307063",
"0.7306928",
"0.730605"
] | 0.0 | -1 |
Validation check before performing validations. | def authorize
unless User.find_by_id(session[:user_id])
redirect_to :log_in, :notice => "Please log in"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate!\n # pass\n end",
"def validate\n # add errors if not validate\n end",
"def validate\r\n validate! rescue false\r\n end",
"def validate\n end",
"def validate\r\n\r\n end",
"def validate\n \n \n end",
"def validation; end",
"def validation; end",
"def run_validations\n true\n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def check_validity!\n # nothing\n end",
"def validate\n valid?\n end",
"def validate!\n\t\t\t\treturn true\n\t\t\tend",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validate\r\n @invalid=false\r\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate\n @invalid=false\n end",
"def validated?; end",
"def validate\n\n end",
"def validate\n self._errors = {}\n self.run_hook :validate\n not self.errors?\n end",
"def validate!\n super()\n self\n end",
"def validate!\n true\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validated; end",
"def _before_validation\n end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def validate\n true\n end",
"def validate\n raise NoMethodError, \"must define method 'validate'\"\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n errors.clear\n self.class.validator.invoke self\n end",
"def valid?\n validate\n end",
"def valid; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def do_validation \n return true if self.ok\n set_ok\n self.ok\n end",
"def validate\n errors.clear\n instance_exec(&validate_block) if validate_block && get\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate!\n validate_redis\n validate_workers\n validate_options\n end",
"def extra_validations\n success\n end",
"def pre_validation\n\n\n end",
"def validator; end",
"def validate\n super \n end",
"def validate\n validate_root\n validate_associated\n valid?\n end",
"def is_valid; end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def run_validations!\n run_callbacks(:validation) do\n super\n end\n end",
"def validate!\n validator.validate(data: data, schema: schema, logger: validation_logger)\n end",
"def validate\n @condition = nil\n @error = \"No validation implemented for #{self.class}#validate\"\n end",
"def validate!\n validate_patches!\n validate_new_branch_name! if new_branch?\n validate_permissions!\n end",
"def pre_validation\n\n end",
"def validate?\n !@valid.nil?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n fail 'sub class to implement'\n end",
"def run_validation(vmode)\n validate(vmode)\n self\n end",
"def check!\n self.normalize!\n __check_method\n __check_params\n end",
"def valid?\n return validate\n end",
"def valid?\n true && super\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end",
"def valid?(_) true end",
"def valid?(_) true end",
"def valid?\n self.errors = Mongomatic::Errors.new\n do_callback(:before_validate)\n check_required_fields\n validate\n do_callback(:after_validate)\n self.errors.empty?\n end",
"def validate\n self.class.validations.each do |(method, args, opts)|\n send(method, *args) if !opts[:if] || instance_exec(&opts[:if])\n end\n end",
"def check\n \n end",
"def check\n \n end",
"def validate\n validator_class.new(self).validate\n end",
"def is_valid?\n end",
"def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end",
"def validate\n validate_amount\n validate_game\n validate_period\n end",
"def is_valid\n\tend",
"def is_valid\n\tend",
"def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n begin\n validate\n true\n rescue\n false\n end\n end",
"def valid?\n run_validation\n @errors.empty?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def is_valid\n return true\n end",
"def validate\n @validated = validated_statically? unless validated?\n @validated = validated_dynamically? unless validated?\n @validated\n end",
"def validate\n super\n end",
"def _always_valid!\n @always_valid = true\n self\n end",
"def valid?\n super\n errors.empty?\n end",
"def valid?\n\t\t\t\ttrue\n\t\t\tend",
"def validates?\n reset\n @passed = catch :validation_done do\n validate\n pass\n end\n end",
"def validate_me(validator)\n validator.validate self, checks\n end"
] | [
"0.78240395",
"0.77709126",
"0.7769439",
"0.77296275",
"0.7666529",
"0.757846",
"0.75652814",
"0.75652814",
"0.75516564",
"0.7513819",
"0.7513819",
"0.7513819",
"0.7513819",
"0.7509371",
"0.7503909",
"0.7470459",
"0.7462313",
"0.7462313",
"0.7462313",
"0.74321747",
"0.73659974",
"0.73659974",
"0.73659974",
"0.7297813",
"0.729546",
"0.7285906",
"0.726112",
"0.72451824",
"0.723386",
"0.7187625",
"0.7187625",
"0.7187625",
"0.71806854",
"0.71771246",
"0.7165133",
"0.714941",
"0.71308637",
"0.7109552",
"0.7103425",
"0.7102878",
"0.7099271",
"0.70905656",
"0.70905656",
"0.70905656",
"0.70905656",
"0.70905656",
"0.70806354",
"0.7056411",
"0.7038472",
"0.70271605",
"0.70174617",
"0.70123184",
"0.70115656",
"0.70040244",
"0.6990653",
"0.6980288",
"0.6978785",
"0.69334465",
"0.69046444",
"0.6896243",
"0.6879827",
"0.68783873",
"0.6869291",
"0.68690324",
"0.6861543",
"0.6861543",
"0.6858276",
"0.6855174",
"0.68469965",
"0.6841298",
"0.6830277",
"0.68151",
"0.6787701",
"0.67863697",
"0.67863697",
"0.67836666",
"0.6779907",
"0.6765517",
"0.6765517",
"0.6765208",
"0.675425",
"0.6749781",
"0.67468244",
"0.6745033",
"0.6745033",
"0.67416483",
"0.67351824",
"0.67351824",
"0.67351824",
"0.67351824",
"0.6726133",
"0.67255133",
"0.672369",
"0.6720619",
"0.6719354",
"0.6713001",
"0.669716",
"0.669397",
"0.6671818",
"0.66705257",
"0.6665065"
] | 0.0 | -1 |
Table view data source | def numberOfSectionsInTableView(tableView)
@month.keys.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @contents = DataTable.all\n\n \n end",
"def index\n @datatable = ComplainsDatatable.new view_context\n end",
"def index\n @datat_table_data = DatatTableDatum.all\n end",
"def data_source=(val)\n PPCurses.implements_protocol( val, %w(number_of_rows_in_table object_value_for ))\n @data_source = val\n @selected_row = 0\n \n # Determine frame size from datasource data\n height = @data_source.number_of_rows_in_table(self)\n width = 0 \n for i in 0..@data_source.number_of_rows_in_table(self)-1\n x = @data_source.object_value_for(self, 0, i).length\n if x > width then width = x end\n end\n \n # Add an extra line for the column header\n # and ====== divider \n height += 2\n \n sz = Size.new( width, height )\n setFrameSize( sz )\n \n end",
"def show\n @table_header = @project.table_header\n @records = @project.get_table_class.all\n end",
"def index\n @tbdata = Tbdatum.all\n end",
"def contents\n super || DataTable.new(1, 1, '')\n end",
"def index\n @sub_data_tables = SubDataTable.all\n end",
"def index\n @data_sources = DataSource.all\n end",
"def table options = {} \n render_partial :table, template_locals(:table_row, options)\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def index\n @tm_table_columns = TmTableColumn.all\n end",
"def data_tables\n @data_tables ||= @holdings_page.search('#rightcol')\n end",
"def show_tsd_super_table\n @data_list = DataList.find(params[:id])\n @all_tsd_files = JSON.parse(open(\"http://readtsd.herokuapp.com/listnames/json\").read)[\"file_list\"]\n @tsd_file = params[:tsd_file].nil? ? @all_tsd_files[0] : params[:tsd_file]\n render \"tsd_super_tableview\"\n end",
"def index\n @source_data_pfrs = SourceDataPfr.all\n end",
"def ar_index_table_data\n returning(\"\") do |result|\n \n for resource in @resources\n columns= [ar_label(resource)]\n\n controller.ardata.fields.for_index.each_with_index do |column_title, index|\n next if not @display_current_ar_index_table_column[index]\n columns << ar_get_resource_value(resource, column_title[0])\n end\n\n columns << ar_show_link(resource) if controller.ardata.links.include? :show\n columns << ar_edit_link(resource) if controller.ardata.links.include? :edit\n columns << ar_destroy_link(resource) if controller.ardata.links.include? :destroy\n\n columns= columns.map{|elem| content_tag :td, elem}.join(\"\\n \")\n columns= \"\\n #{columns}\\n \"\n\n result << \"\\n #{content_tag(:tr, columns, :class => cycle(\"even\", \"odd\")) }\\n\" \n end\n\n #Die!! Array :) See ar_index_table_headers\n @display_current_ar_index_table_column= nil\n end\n end",
"def init_table(data=[], options={})\n # TODO : create data array from the df and vector data. So that\n # we can directly use the array.(No need to create df or vector and\n # generate the html table using to_html)\n if data.is_a?(Array)\n data_name = 'series_data'+ SecureRandom.uuid\n data =\n if data.all? { |e| e.class==Array }\n Daru::DataFrame.rows(data, name: data_name)\n else\n Daru::Vector.new(data, name: data_name)\n end\n end\n # options[:data] = data_in_array unless data_in_array.empty?\n @table = Daru::DataTables::DataTable.new(options)\n @data = data\n @table\n end",
"def tableView(aTableView, willDisplayCell:cell, forTableColumn:aTableColumn, row:rowIndex)\n cell.setRepresentedObject(@videoCollection[rowIndex])\n end",
"def table\n end",
"def index\n @rows = Row.all\n end",
"def index\n\n @data = Datum.all\n end",
"def pp_data(db, table, data = nil)\n if data == nil\n data = view_table(db, table)\n end\n pp_string = ''\n\n data.each do |entry|\n entry.each do |id, val| \n if id.is_a? String\n pp_string += \"#{id}: #{val}\\t| \" \n end \n end\n pp_string += \"\\n\"\n end\n pp_string\nend",
"def table_for(value, options = {}, &block)\n view(value, options.merge(:as => :table), &block)\n end",
"def tableView(tableView, objectValueForTableColumn:column, row:index)\n filteredData[index].send(column.identifier)\n end",
"def index\n @dataset_data = DatasetDatum.all\n end",
"def tableView(tableView, rowViewForRow:row)\n FBSidePanelTableRowView.new\n end",
"def index\n @connection_table_columns = ConnectionTableColumn.all\n end",
"def table_list(objetos, show_all_actions = true, options = {})\n render :partial => '/admin/shared/table_list', :locals => { :objetos => objetos, :show_all_actions => show_all_actions, :options => options }\n end",
"def view(options = {})\n\t \tget_records('-view', {}, options)\n\t end",
"def datagrid_table(report, *args)\n datagrid_renderer.table(report, *args)\n end",
"def set_up_table_view\n self.table_view\n _table_view = self.create_table_view_from_data(self.table_data)\n adjusted_frame = self.view.bounds\n adjusted_frame.size.width = app_delegate.panels.leftVisibleWidth\n _table_view.frame = adjusted_frame\n self.view = UIView.new\n self.view.addSubview(_table_view)\n end",
"def rows\n RowCollection.new(@data)\n end",
"def tableView(tableView, viewForTableColumn:tableColumn, row:row)\n cell = tableView.makeViewWithIdentifier(tableColumn.identifier, owner:self)\n item = self.items.objectAtIndex(row)\n cell.from = item.from\n cell.subject = item.subject\n cell.date = item.date\n cell.brief = item.brief\n cell.selected = false\n cell\n end",
"def rows\n render 'rows.html'\n end",
"def set_data_table\n @data_table = DataTable.find(params[:id])\n end",
"def student_table\n table = frm.table(:class=>\"listHier lines nolines\").to_a\n end",
"def student_table\n table = frm.table(:class=>\"listHier lines nolines\").to_a\n end",
"def index\n @data_tables = DataTable.all\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @data_tables.as_json(only: [:title, :username, :name, :email, :hometown]) }\n # end\n end",
"def index\n @datasource = Datasource.new\n @datasources = Datasource.all\n end",
"def index\n \n get_table_name #method for table_names and model_names \n\n get_table_column_name # method for table_name, column_names and model_name \n\n get_table_data # method for table data\n\n @model_data = []\n \n @model_data = @model_name.order(sort_column + \" \" + sort_direction).page(params[:page]).per(10)\n\n respond_to do |format|\n\t format.html\n\t format.json\n \tend\n\n end",
"def rows\n @rows\n end",
"def index\n @task_tables = TaskTable.all\n end",
"def index\n\t\t@tables = Table.all\n\tend",
"def _table; @table end",
"def rows\n return @rows if @rows\n if execute && result['rows']\n @rows ||= result['rows'].map{|v| ViewRow.new(v, model)}\n else \n [ ]\n end\n end",
"def index\n authorize! :index, User\n @datatable = UsersDatatable.new view_context\n end",
"def index\n instance_variable_set(resource(:tableize), @model.all)\n end",
"def index\n @pivot_tbls = PivotTbl.all\n end",
"def rows\r\n @all_rows\r\n end",
"def index\n @live_data = LiveDatum.all\n end",
"def index\n @tableros = Tablero.all\n end",
"def index\n @prescription_rows = PrescriptionRow.all\n end",
"def index\n @product_tables = ProductTable.all\n end",
"def on_table(params = {})\n table = Yummi::Table::new params\n table.data = self\n return table\n end",
"def table_content\n table activity_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [110, 175, 175, 80]\n end\n end",
"def make_table(options={})\n get_table(options).rows\n end",
"def data\n datacolumns.reduce({}) do |t, col|\n t[col.name] = col.data; t\n end\n end",
"def EXCEL_TABLE(objects, *arguments)\n DebugTable.new(objects, arguments, :tsv)\n end",
"def tables view: nil\n client.list_tables(\n instance_path,\n view: view\n )\n end",
"def data_tables\n @data_tables ||= @profile_page.search('table#yfncsumtab').to_s.gsub(\"\\n\",'')\n end",
"def list_tables\n data.keys\n end",
"def index\n @data_source_types = DataSourceType.all\n end",
"def table_content\n # This makes a call to gift_rows and gets back an array of data that will \n # populate the columns and rows of a table I then included some styling to \n # include a header and make its text bold. I made the row background colors \n # alternate between grey and white Then I set the table column widths\n table gift_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [180, 180, 180]\n end\n end",
"def index\n @trading_summaries_grid = initialize_grid(TradingSummary.all)\n end",
"def index\n @history_data = HistoryDatum.all\n end",
"def data(options = {})\n add_required_columns(options[:required_columns])\n @rows ||= aggregate\n end",
"def index\n @project_datum_columns = ProjectDatumColumn.all\n end",
"def table_of(things,opts={})\n kind = things.first.table_name\n # columns = things.first.visible_columns\n add_class_to_html_options(opts, kind)\n content_tag(\n :table,\n render(:partial => \"/#{kind}/table_row\", :collection => things),\n opts\n )\n end",
"def index\n @tables = Table.all\n end",
"def index\n @tables = Table.all\n end",
"def index\n @tables = Table.all\n end",
"def index\n @tables = Table.all\n end",
"def table_data\n @building_groups.reduce([]) do |table, bg|\n table << energy_row(bg)\n end\n end",
"def index\n @daw_tablas = DawTabla.all\n end",
"def index\n @data_ukts = DataUkt.all\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def create_view(name, source)\n source = source.sql if source.is_a?(Dataset)\n execute(\"CREATE VIEW #{name} AS #{source}\")\n end",
"def index\n @template_data = TemplateDatum.all\n end",
"def get_data\n raise \"This method should be overriden to return the JSON data for a concrete table\"\n end",
"def index\n @dataunits = Dataunit.all\n end",
"def rows\n if @rows.empty?\n start_time = Time.now.to_f\n if should_cache? and cached?\n load_table_from_cache\n else\n create_table \n cache if should_cache?\n end\n end_time = Time.now.to_f\n @table_time = end_time - start_time \n end\n \n @rows\n end",
"def row; end",
"def show\n unless @table.has_resource_label?\n @table.resource_label = @table.resource_label_default\n @table.save\n end\n\n @columns = columns(@table)\n\n @page = TogodbPage.find_by_table_id(@table.id)\n unless @page\n @page = create_page\n end\n\n set_metadata(@table)\n set_roles(@table)\n\n @column = TogodbColumn.new(table_id: @table.id)\n set_datasets\n\n @tables = @user.configurable_tables\n @class_map = ClassMap.by_table(@table)\n end",
"def table_array\r\n @table_array\r\n end",
"def index\n @train_data = TrainDatum.all\n end",
"def datatable\n if @datatable.count == 0 && datafile != nil\n @datatable.push(datafile)\n end\n\n @datatable\n end",
"def index\n @mytbls = Mytbl.all\n end",
"def index\n @coleccion = Tabla.all\n end",
"def to_table\n @doc.make_table(data, table_options)\n end",
"def index\n @clientes = current_user.vendedor ? current_user.vendedor.clientes : Cliente.all\n\n\t\trespond_to do |format|\n format.html { render layout: \"dataTables\" }\n\t\t\tformat.csv { send_data @clientes.to_csv }\n end\n end",
"def show_dataset\n @dataset = Dataset.find(params[:dataset_id])\n @data = (ActiveRecord::Base.connection.select_all(\"SELECT * from dataset_#{@dataset.id} ORDER BY id ASC\")).to_json\n render :inline => @data\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json:DisDatasourceDatatable.new(view_context) }\n end\n end",
"def display\n\t\tdisplay_headers\n\t\t@rows.each do |row|\n\t\t\tdisplay_row(row)\n\t\tend\n\tend",
"def index\n @technical_data = TechnicalDatum.all\n end",
"def index\n @tvs = Tv.all\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: DataTable::Nodes.new(view_context) }\n end\n end"
] | [
"0.7092971",
"0.67255116",
"0.66212237",
"0.64762366",
"0.62949526",
"0.6291978",
"0.62858194",
"0.6163798",
"0.61115223",
"0.6096364",
"0.5997748",
"0.5997748",
"0.5997748",
"0.5997748",
"0.5985078",
"0.5895799",
"0.58901",
"0.5889067",
"0.58595294",
"0.58509016",
"0.5840576",
"0.5820738",
"0.58117014",
"0.5793571",
"0.5775189",
"0.5770213",
"0.5770176",
"0.57441473",
"0.5725217",
"0.57049155",
"0.56965256",
"0.5681041",
"0.5675781",
"0.5670651",
"0.56574345",
"0.56290823",
"0.56270283",
"0.5618776",
"0.56123626",
"0.56123626",
"0.5585296",
"0.5582864",
"0.55814385",
"0.55811954",
"0.55768645",
"0.5576489",
"0.557298",
"0.55650663",
"0.5564789",
"0.5564414",
"0.55556977",
"0.555435",
"0.55517",
"0.55488616",
"0.5537714",
"0.5536125",
"0.5534024",
"0.55283546",
"0.5523181",
"0.55199707",
"0.55194837",
"0.55128455",
"0.5512018",
"0.5511998",
"0.54976904",
"0.5479329",
"0.5478175",
"0.5468672",
"0.5458172",
"0.5443936",
"0.543698",
"0.5433366",
"0.5433366",
"0.5433366",
"0.5433366",
"0.5417983",
"0.5408868",
"0.5402469",
"0.5402303",
"0.5402303",
"0.5402303",
"0.53936034",
"0.53935647",
"0.53933203",
"0.5392148",
"0.5388741",
"0.5383498",
"0.53701943",
"0.5363835",
"0.535607",
"0.5348428",
"0.53478515",
"0.53380084",
"0.53325075",
"0.53301007",
"0.53244567",
"0.53228486",
"0.532247",
"0.5316738",
"0.5311475",
"0.53107876"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.