query
stringlengths 7
9.5k
| document
stringlengths 10
1.07M
| negatives
sequencelengths 19
19
| metadata
dict |
---|---|---|---|
Delete a 'Copy Pods Resources' script phase if present | def remove_copy_resources_script_phase_from_target(native_target)
build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) }
return unless build_phase.present?
native_target.build_phases.delete(build_phase)
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 remove_copy_xcframeworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, COPY_XCFRAMEWORKS_PHASE_NAME)\n end",
"def uninstall_ruby\n directory ::File.join(options['prefix'], 'builds', new_resource.name) do\n action :delete\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 before_destroy\n # cwd: utunes_app\n logger.info(\"=======> before_destroy invoked!\")\n\n version_str = sprintf(\"%.2d\", version )\n bundle_title = \"hc12_v#{version_str}\"\n \n bundle_folder = \"lib/bundles\"\n bundle_name=\"build_\" + bundle_title\n bundle_fq_name = bundle_folder + \"/\" + bundle_name\n \n logger.info(\"rm -R #{bundle_fq_name}\")\n logger.info( %x[rm -R #{bundle_fq_name}] )\n \n end",
"def delete\n check_config(require_destination: true)\n cartage.display \"Removing packages from #{name}...\"\n delete_file Pathname(\"#{cartage.final_name}-release-hashref.txt\")\n delete_file cartage.final_release_metadata_json\n cartage.plugins.request_map(:build_package, :package_name).each do |name|\n delete_file name\n end\n end",
"def copy_and_clean(source, destination, spec)\n specs_by_platform = group_subspecs_by_platform(spec)\n destination.parent.mkpath\n Cache.write_lock(destination) do\n FileUtils.rm_rf(destination)\n FileUtils.cp_r(source, destination)\n Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!\n Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!\n end\n end",
"def delete_service_files(resource)\n file get_service_script_name(resource) do\n action :delete\n only_if { get_service_script_name != nil }\n end\nend",
"def clean_pod_sources\n return unless installation_options.clean?\n return if installed_specs.empty?\n pod_installers.each(&:clean!)\n end",
"def remove_existing_google_plist\n to_remove = @project.files.find { |file| file.path =~ G_PLIST}\n @project.targets.each do |target|\n target.resources_build_phase.remove_file_reference(to_remove)\n end if to_remove\n end",
"def set_run_script_to_always_run_when_no_input_or_output_files_exist(project:)\n project.targets.each do |target|\n run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }\n cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?(\"[CP\") }\n cocoapods_run_script_build_phases.each do |run_script|\n next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?\n run_script.always_out_of_date = \"1\"\n end\n end\n project.save\nend",
"def remove_nim_resources\n Log.log_info('In remove_nim_resources')\n @targets.each do |target|\n Log.log_debug('target=' + target)\n nim_lpp_source_resource = get_flrtvc_name(:NIM_res, target)\n exists = Nim.lpp_source_exists?(nim_lpp_source_resource)\n Log.log_debug('exists=' +\n exists.to_s)\n if exists\n Nim.remove_lpp_source(nim_lpp_source_resource)\n Log.log_debug('Removing NIM resource ' +\n nim_lpp_source_resource)\n else\n Log.log_debug('Already removed NIM resource ' +\n nim_lpp_source_resource)\n end\n end\n end",
"def add_missing_copy_phase!(dry_run: false)\n # Check if upgrade is needed\n # If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project\n phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == \"FastlaneRunnerCopySigned\" }.first\n\n old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == \"cd \\\"${SRCROOT}\\\"\\ncd ../..\\ncp \\\"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\\\" .\\n\" }.first\n\n return true if dry_run && phase_copy_sign.nil?\n\n return false if dry_run\n\n # Proceed to upgrade\n old_phase_copy_sign.remove_from_project unless old_phase_copy_sign.nil?\n\n unless phase_copy_sign\n # Create a copy files build phase\n phase_copy_sign = self.fastlane_runner_target.new_copy_files_build_phase(\"FastlaneRunnerCopySigned\")\n phase_copy_sign.dst_path = \"$SRCROOT/../..\"\n phase_copy_sign.dst_subfolder_spec = \"0\"\n phase_copy_sign.run_only_for_deployment_postprocessing = \"0\"\n targetBinaryReference = self.fastlane_runner_target.product_reference\n phase_copy_sign.add_file_reference(targetBinaryReference)\n\n # Set \"Code sign on copy\" flag on Xcode for fastlane_runner_target\n targetBinaryReference.build_files.each { |target_binary_build_file_reference|\n target_binary_build_file_reference.settings = { \"ATTRIBUTES\": [\"CodeSignOnCopy\"] }\n }\n end\n\n target_project.save\n end",
"def clean_up\n FileUtils.rm(\n Dir.glob('build/{src,lib}.{rb,c,js}') +\n Dir.glob('build/ruby2d-opal.{rb,js}') +\n Dir.glob('build/app.c')\n )\nend",
"def delete_current_if_forcing!\n return unless @new_resource.force \n return unless remove_on_force? \n return unless get_current_release_version == artifact_version || previous_version_numbers.include?(artifact_version)\n\n recipe_eval do\n log \"artifact_deploy[delete_current_if_forcing!] #{artifact_version} deleted because remove_on_force is true\" do\n level :info\n end \n\n directory ::File.join(new_resource.deploy_to, 'releases', artifact_version) do\n recursive true\n action :delete\n end\n end\nend",
"def shift_existing_assets\n run \"rm -rf #{last_assets_path} && mkdir -p #{shared_assets_path} #{last_assets_path} && mv #{shared_assets_path} #{last_assets_path.join('assets')} && mkdir -p #{shared_assets_path} && #{link_assets}\"\n end",
"def delete\n selector = resource.dig(:spec, :selector, :matchLabels).map { |k, v| \"#{k}=#{v}\" }.join(\",\")\n\n # delete the job\n super\n\n # delete the pods\n client = @deploy_group.kubernetes_cluster.client # pod api is not part of the extension client\n pods = client.get_pods(label_selector: selector, namespace: namespace)\n pods.each { |pod| client.delete_pod pod.metadata.name, pod.metadata.namespace }\n end",
"def reset_package_resource_files\n \n end",
"def delete_launchd_script(date)\n File.delete(launchd_script_filename(date))\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates or update a shell script build phase for the given target. | def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0')
build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
build_phases.find { |phase| phase.name && phase.name.end_with?(script_phase_name) }.tap { |p| p.name = script_phase_name if p } ||
native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase|
UI.message("Adding Build Phase '#{script_phase_name}' to project.") do
phase.name = script_phase_name
unless show_env_vars_in_log.nil?
phase.show_env_vars_in_log = show_env_vars_in_log
end
native_target.build_phases << phase
end
end
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 shell_script_build_phase(name, script, &block)\n phase = ShellScriptBuildPhase.new(&block)\n phase.name = name\n phase.script = script\n build_phases << phase\n phase\n end",
"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 add_carthage_copy_phase(target)\n shell_script_name = 'Carthage copy-frameworks Run Script'\n target_names = target.shell_script_build_phases.map(&:name)\n unless target_names.include?(shell_script_name)\n shell_script = target.new_shell_script_build_phase shell_script_name\n shell_script.shell_path = '/bin/bash'\n shell_script.shell_script = '/usr/local/bin/carthage copy-frameworks'\n shell_script.input_paths = [CARTHAGE_FRAMEWORK_PATH]\n end\n end",
"def pre_shell_script_build_phase(name, script, &block)\n phase = ShellScriptBuildPhase.new(&block)\n phase.name = name\n phase.script = script\n pinned_build_phases << phase\n phase\n end",
"def build\n if phase.has_key?('build')\n execute(\"build\", phase['build'])\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_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 install_env_script(opts={})\n target = opts[:to] || raise(\"Need :to parameter\")\n\n script = 'env.sh'\n dirs = { 'PATH' => { 'insert' => path_dirs_for_distro(:couch_too => true),\n 'append' => [] },\n }\n\n # XXX: Code duplication from :configure.\n dirs['DYLD_LIBRARY_PATH'] = {'insert' => [\"#{target}/lib\"]} if DISTRO[0] == :osx\n\n template = ERB.new(File.open(\"#{HERE}/templates/#{script}.erb\").read())\n FileUtils.mkdir_p(target)\n File.open(\"#{target}/#{script}\", 'w') do |outfile|\n outfile.write(template.result(binding))\n outfile.close\n end\nend",
"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 shim_script target\n <<-EOS.undent\n #!/bin/bash\n exec \"#{prefix}/Current/bin/#{target}\" \"$@\"\n EOS\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 build_script\n File.join(data_dir, 'build-script')\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 add_build_phase_to_project_target(object_id)\n # Add the new build phase to the main project target if it doesn't already exist\n build_target_id, build_target_values = object_for_project_target\n build_target_values['buildPhases'].push(object_id) unless build_target_values['buildPhases'].include?(object_id)\n end",
"def write_shell_script(stack: , jruby_version: , ruby_stdlib_version: )\n source_folder = \"rubies/#{stack}\"\n FileUtils.mkdir_p(source_folder)\n\n file = \"#{source_folder}/jruby-#{jruby_version}.sh\"\n puts \"Writing #{file}\"\n File.open(file, 'w') do |file|\n file.puts <<~FILE\n #!/bin/sh\n\n # Sets OUTPUT_DIR, CACHE_DIR, and STACK\n source `dirname $0`/../common.sh\n source `dirname $0`/common.sh\n\n docker run -v $OUTPUT_DIR:/tmp/output -v $CACHE_DIR:/tmp/cache -e VERSION=#{jruby_version} -e RUBY_VERSION=#{ruby_stdlib_version} -t hone/jruby-builder:$STACK\n FILE\n end\nend",
"def make_shell_command(source)\n make_executable(\"#!/bin/sh\\n\" + source)\n end",
"def my_post_build_step\n puts 'post-build step!'\nend",
"def build\n cd_and_sh( pkg_dir, build_commands )\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the resource output paths for all given input paths. | def resource_output_paths(resource_input_paths)
resource_input_paths.map do |resource_input_path|
base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'
extname = File.extname(resource_input_path)
basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)
output_extension = Target.output_extension_for_resource(extname)
File.join(base_path, File.basename(basename, extname) + output_extension)
end.uniq
end | [
"def filepaths\n list = []\n list << \"Scenario.pione\"\n list += inputs\n list += outputs\n return list\n end",
"def output_files\n input_files\n end",
"def paths\n map{ |dir| Pathname.new(dir) }\n end",
"def absolute_output_directories\n settings[:output].map do |dir|\n Pathname.new(File.absolute_path(dir))\n end\n end",
"def expanded_resources\n files = []\n resources.each do |pattern|\n pattern = pod_destroot + pattern\n pattern.glob.each do |file|\n files << file.relative_path_from(config.project_pods_root)\n end\n end\n files\n end",
"def possible_paths_for(mappings)\n root_mappings.map{|root|\n mappings.first.map{|inner|\n mappings.last.map{|outer|\n ::File.join(root, inner, outer, '/') }}}.flatten\n end",
"def asset_paths\n paths = @parts.values.map(&:asset_path)\n paths << File.dirname(script) if script\n paths << File.dirname(stylesheet) if stylesheet\n paths.compact.uniq\n end",
"def write_output_resources\n @outputs.flatten.compact.each do |output|\n path = File.join(@working_directory, output.name)\n FileCache.put(path, output.uri)\n end\n end",
"def set_input_output_paths(phase, input_paths_by_config, output_paths_by_config)\n if input_output_paths_use_filelist?(phase)\n [input_paths_by_config, output_paths_by_config].each do |hash|\n hash.each do |file_list, files|\n generator = Generator::FileList.new(files)\n Xcode::PodsProjectGenerator::TargetInstallerHelper.update_changed_file(generator, file_list.file_list_path)\n end\n end\n\n phase.input_paths = nil\n phase.output_paths = nil\n phase.input_file_list_paths = input_paths_by_config.each_key.map(&:file_list_relative_path).uniq\n phase.output_file_list_paths = output_paths_by_config.each_key.map(&:file_list_relative_path).uniq\n else\n input_paths = input_paths_by_config.values.flatten(1).uniq\n output_paths = output_paths_by_config.values.flatten(1).uniq\n TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)\n\n phase.input_paths = input_paths\n phase.output_paths = output_paths\n phase.input_file_list_paths = nil\n phase.output_file_list_paths = nil\n end\n end",
"def final_paths\n final_letters.map { |fl| Path.new([fl]) } + destination.final_paths\n end",
"def all_paths\n pt = self.paths\n pt[:+] + pt[:-]\n end",
"def input_paths(asset_module, format)\n asset_module.assets(format).map{|asset| asset.absolute_path}\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def resource_paths\n if @resource_paths.nil?\n paths_by_path = {}\n lines.each do |line|\n path_name = ResourcePath.path_from(line)\n paths_by_path[path_name] ||= ResourcePath.new(path_name)\n paths_by_path[path_name].add_request(line)\n end\n @resource_paths = paths_by_path.values\n end\n @resource_paths\n end",
"def input_paths(test:)\n extensions = %w(input txt)\n suffix = test ? '-sample' : ''\n days = [\"day-#{day}\", sprintf(\"day-%02i\", day)]\n\n filenames = extensions.\n flat_map { |ext| days.map { |day| \"#{day}#{suffix}.#{ext}\" } }\n\n directories = days.flat_map { |day| [year, File.join(year, day)] }\n directories\n .flat_map { |d| filenames.map { |f| [d, f] } }\n .map { |(d, fn)| File.join(d, fn) }\n end",
"def expanded_clean_paths\n files = []\n clean_paths.each do |pattern|\n pattern = pod_destroot + pattern\n pattern.glob.each do |file|\n files << file\n end\n end\n files\n end",
"def paths(arrs)\n arrs.inject([[]]) do |paths, arr|\n flatten(arr.map {|e| paths.map {|path| path + [e]}}, 1)\n end\n end",
"def all_paths\n list(\".\").map { |path| expand_path(path) }\n end",
"def resources_path_names=(_arg0); end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the framework input paths for the given framework paths | def embed_frameworks_input_paths(framework_paths, xcframeworks)
input_paths = framework_paths.map(&:source_path)
# Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices
xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.each do |xcframework|
name = xcframework.name
input_paths << "#{Pod::Target::BuildSettings.xcframework_intermediate_dir(xcframework)}/#{name}.framework/#{name}"
end
input_paths
end | [
"def embed_frameworks_output_paths(framework_paths, xcframeworks)\n paths = framework_paths.map do |framework_path|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}\"\n end.uniq\n # Static xcframeworks are not copied to the build dir\n # so only include dynamic artifacts that will be copied to the build folder\n xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{xcframework.name}.framework\"\n end\n paths + xcframework_paths\n end",
"def filepaths\n list = []\n list << \"Scenario.pione\"\n list += inputs\n list += outputs\n return list\n end",
"def load_paths\n %w(lib app/models app/controllers app/metal app/helpers test/helpers).collect { |d| check_subdirectory(d) }.push(path).flatten.compact\n end",
"def framework_directories\n return @framework_dirs unless @framework_dirs.nil?\n framework_path = File.join(@root_path, 'frameworks')\n if File.exists?(framework_path)\n @framework_dirs = Dir.entries(framework_path).reject do |x|\n (/^\\./ =~ x) || !File.directory?(File.join(framework_path,x))\n end\n else\n @framework_dirs = []\n end\n\n return @framework_dirs\n end",
"def input_paths(test:)\n extensions = %w(input txt)\n suffix = test ? '-sample' : ''\n days = [\"day-#{day}\", sprintf(\"day-%02i\", day)]\n\n filenames = extensions.\n flat_map { |ext| days.map { |day| \"#{day}#{suffix}.#{ext}\" } }\n\n directories = days.flat_map { |day| [year, File.join(year, day)] }\n directories\n .flat_map { |d| filenames.map { |f| [d, f] } }\n .map { |(d, fn)| File.join(d, fn) }\n end",
"def load_paths\r\n report_nonexistant_or_empty_plugin! unless valid?\r\n \r\n returning [] do |load_paths|\r\n load_paths << lib_path if has_lib_directory?\r\n load_paths << app_paths if has_app_directory?\r\n end.flatten\r\n end",
"def input_paths(asset_module, format)\n asset_module.assets(format).map{|asset| asset.absolute_path}\n end",
"def paths(platform_name)\n platform(platform_name).paths\n end",
"def resource_output_paths(resource_input_paths)\n resource_input_paths.map do |resource_input_path|\n base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'\n extname = File.extname(resource_input_path)\n basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)\n output_extension = Target.output_extension_for_resource(extname)\n File.join(base_path, File.basename(basename, extname) + output_extension)\n end.uniq\n end",
"def component_paths platform\n @component_paths||={} \n @component_paths['pc']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//,/\\/common/).pathmap('%d')\n @component_paths['common']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//).pathmap('%d')\n return @component_paths[platform]+@component_paths['common']\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def bundle_paths\n self.bundles.collect {|name, reqs| path_for_bundle(name) }\n end",
"def paths\n tree_path = File.join(File.dirname(__FILE__), 'rails_tree')\n [\"\", \"multitest\", \"results\"].inject([tree_path]) do |result, suffix|\n result << File.join(result[-1], suffix)\n end[1..3]\n end",
"def lookup_paths\n if list = ENV['RUBY_LIBRARY']\n list.split(/[:;]/)\n #elsif File.exist?(path_file)\n # File.readlines(path_file).map{ |x| x.strip }.reject{ |x| x.empty? || x =~ /^\\s*\\#/ }\n elsif ENV['GEM_PATH']\n ENV['GEM_PATH'].split(/[:;]/).map{ |dir| File.join(dir, 'gems', '*') }\n elsif ENV['GEM_HOME']\n ENV['GEM_HOME'].split(/[:;]/).map{ |dir| File.join(dir, 'gems', '*') }\n else\n warn \"No Ruby libraries.\"\n []\n end\n end",
"def loadable_files\n app_components.inject([]) do |paths, type|\n paths += Dir[dir_for(type) / '**/*.rb'] if slice_paths.key?(type)\n paths += Dir[app_dir_for(type) / '**/*.rb'] if app_paths.key?(type)\n paths\n end \n end",
"def framework_names\n return @cache_framework_names unless @cache_framework_names.nil?\n\n ret = next_library.nil? ? [] : next_library.framework_directories\n ret += framework_directories\n return @cache_framework_names = ret.compact.uniq.sort\n end",
"def require_paths\n raw_data['require_paths'] || []\n end",
"def default_assembly_paths\n paths = []\n paths.concat %w( bin ).map{ |dir| \"#{root_path}/#{dir}\"}.select{ |dir| File.directory?(dir) }\n end",
"def input_file_specs_for_ls\n @input_file_specs.flat_map do |spec|\n path = Pathname.new(spec)\n if path.directory?\n full_path = path.join('*').to_s\n else\n full_path = spec\n end\n # this works even when full_path is a glob\n File.expand_path(full_path)\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the framework output paths for the given framework paths | def embed_frameworks_output_paths(framework_paths, xcframeworks)
paths = framework_paths.map do |framework_path|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}"
end.uniq
# Static xcframeworks are not copied to the build dir
# so only include dynamic artifacts that will be copied to the build folder
xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{xcframework.name}.framework"
end
paths + xcframework_paths
end | [
"def embed_frameworks_input_paths(framework_paths, xcframeworks)\n input_paths = framework_paths.map(&:source_path)\n # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices\n xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.each do |xcframework|\n name = xcframework.name\n input_paths << \"#{Pod::Target::BuildSettings.xcframework_intermediate_dir(xcframework)}/#{name}.framework/#{name}\"\n end\n input_paths\n end",
"def framework_directories\n return @framework_dirs unless @framework_dirs.nil?\n framework_path = File.join(@root_path, 'frameworks')\n if File.exists?(framework_path)\n @framework_dirs = Dir.entries(framework_path).reject do |x|\n (/^\\./ =~ x) || !File.directory?(File.join(framework_path,x))\n end\n else\n @framework_dirs = []\n end\n\n return @framework_dirs\n end",
"def resource_output_paths(resource_input_paths)\n resource_input_paths.map do |resource_input_path|\n base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'\n extname = File.extname(resource_input_path)\n basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)\n output_extension = Target.output_extension_for_resource(extname)\n File.join(base_path, File.basename(basename, extname) + output_extension)\n end.uniq\n end",
"def framework_names\n return @cache_framework_names unless @cache_framework_names.nil?\n\n ret = next_library.nil? ? [] : next_library.framework_directories\n ret += framework_directories\n return @cache_framework_names = ret.compact.uniq.sort\n end",
"def paths\n tree_path = File.join(File.dirname(__FILE__), 'rails_tree')\n [\"\", \"multitest\", \"results\"].inject([tree_path]) do |result, suffix|\n result << File.join(result[-1], suffix)\n end[1..3]\n end",
"def filepaths\n list = []\n list << \"Scenario.pione\"\n list += inputs\n list += outputs\n return list\n end",
"def frameworks_root\n File.join(contents_root, 'Frameworks')\n end",
"def default_assembly_paths\n paths = []\n paths.concat %w( bin ).map{ |dir| \"#{root_path}/#{dir}\"}.select{ |dir| File.directory?(dir) }\n end",
"def paths(platform_name)\n platform(platform_name).paths\n end",
"def target_frameworks\n if netcore?\n tfw = @proj_xml_node.css('Project PropertyGroup TargetFramework').inner_text\n tfws = @proj_xml_node.css('Project PropertyGroup TargetFrameworks').inner_text\n nfws = if tfw.nil? || tfw == '' then tfws else tfw end\n fws = nfws.split(';')\n else\n [ target_framework ]\n end\n end",
"def frameworks\n objects.select {|obj| obj.last['name'].include?('framework') unless obj.last['name'].nil? }\n end",
"def load_paths\n %w(lib app/models app/controllers app/metal app/helpers test/helpers).collect { |d| check_subdirectory(d) }.push(path).flatten.compact\n end",
"def component_paths platform\n @component_paths||={} \n @component_paths['pc']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//,/\\/common/).pathmap('%d')\n @component_paths['common']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//).pathmap('%d')\n return @component_paths[platform]+@component_paths['common']\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def paths_from_software_gems\n @paths_from_software_gems ||=\n Array(Config.software_gems).inject([]) do |array, name|\n if (spec = Gem::Specification.find_all_by_name(name).first)\n array << File.expand_path(spec.gem_dir)\n end\n\n array\n end\n end",
"def bundle_paths\n self.bundles.collect {|name, reqs| path_for_bundle(name) }\n end",
"def build_framework\n unless Merb::Config[:framework]\n %w[view model controller helper mailer part].each do |component|\n Merb.push_path(component.to_sym, Merb.root_path(\"app/#{component}s\"))\n end\n Merb.push_path(:application, Merb.root_path(\"app/controllers/application.rb\"))\n Merb.push_path(:config, Merb.root_path(\"config\"), nil)\n Merb.push_path(:environments, Merb.dir_for(:config) / \"environments\", nil)\n Merb.push_path(:lib, Merb.root_path(\"lib\"), nil)\n Merb.push_path(:log, Merb.log_path, nil)\n else\n Merb::Config[:framework].each do |name, path|\n Merb.push_path(name, Merb.root_path(path.first), path[1])\n end\n end\n end",
"def load_paths\r\n report_nonexistant_or_empty_plugin! unless valid?\r\n \r\n returning [] do |load_paths|\r\n load_paths << lib_path if has_lib_directory?\r\n load_paths << app_paths if has_app_directory?\r\n end.flatten\r\n end",
"def absolute_output_directories\n settings[:output].map do |dir|\n Pathname.new(File.absolute_path(dir))\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates a projects native targets to include on demand resources specified by the supplied parameters. Note that currently, only app level targets are allowed to include on demand resources. | def update_on_demand_resources(sandbox, project, native_targets, file_accessors, parent_odr_group,
target_odr_group_name)
category_to_tags = {}
file_accessors = Array(file_accessors)
native_targets = Array(native_targets)
# Target no longer provides ODR references so remove everything related to this target.
if file_accessors.all? { |fa| fa.on_demand_resources.empty? }
old_target_odr_group = parent_odr_group[target_odr_group_name]
old_odr_file_refs = old_target_odr_group&.recursive_children_groups&.each_with_object({}) do |group, hash|
hash[group.name] = group.files
end || {}
native_targets.each do |native_target|
native_target.remove_on_demand_resources(old_odr_file_refs)
update_on_demand_resources_build_settings(native_target, nil => old_odr_file_refs.keys)
end
old_target_odr_group&.remove_from_project
return
end
target_odr_group = parent_odr_group[target_odr_group_name] || parent_odr_group.new_group(target_odr_group_name)
current_file_refs = target_odr_group.recursive_children_groups.flat_map(&:files)
added_file_refs = file_accessors.flat_map do |file_accessor|
target_odr_files_refs = Hash[file_accessor.on_demand_resources.map do |tag, value|
tag_group = target_odr_group[tag] || target_odr_group.new_group(tag)
category_to_tags[value[:category]] ||= []
category_to_tags[value[:category]] << tag
resources_file_refs = value[:paths].map do |resource|
odr_resource_file_ref = Pathname.new(resource).relative_path_from(sandbox.root)
tag_group.find_file_by_path(odr_resource_file_ref.to_s) || tag_group.new_file(odr_resource_file_ref)
end
[tag, resources_file_refs]
end]
native_targets.each do |native_target|
native_target.add_on_demand_resources(target_odr_files_refs)
end
target_odr_files_refs.values.flatten
end
# if the target ODR file references were updated, make sure we remove the ones that are no longer present
# for the target.
remaining_refs = current_file_refs - added_file_refs
remaining_refs.each do |ref|
native_targets.each do |user_target|
user_target.resources_build_phase.remove_file_reference(ref)
end
ref.remove_from_project
end
target_odr_group.recursive_children_groups.each { |g| g.remove_from_project if g.empty? }
attributes = project.root_object.attributes
attributes['KnownAssetTags'] = (attributes['KnownAssetTags'] ||= []) | category_to_tags.values.flatten
project.root_object.attributes = attributes
native_targets.each do |native_target|
update_on_demand_resources_build_settings(native_target, category_to_tags)
end
end | [
"def add_resource_file_to_target(file, targetName, project)\n project.native_targets.each do |target|\n if target.name == targetName\n target.add_resources([file])\n end\n end\nend",
"def add_resources_to_project(test_targets=false)\n return unless has_resources?\n add_files_to_project(@resources_to_add)\n @resources_to_add.each do |file_path|\n file_to_add = @new_file_group.new_file(file_path)\n @project.native_targets.each do |target|\n if test_targets || !target.test_target_type?\n target.resources_build_phase.add_file_reference(file_to_add)\n end\n end\n end\n end",
"def add_on_demand_resources(native_target, app_spec)\n dependent_targets = target.dependent_targets_for_app_spec(app_spec)\n parent_odr_group = native_target.project.group_for_spec(app_spec.name)\n\n # Add ODRs of the app spec dependencies first.\n dependent_targets.each do |pod_target|\n file_accessors = pod_target.file_accessors.select do |fa|\n fa.spec.library_specification? ||\n fa.spec.test_specification? && pod_target.test_app_hosts_by_spec[fa.spec]&.first == app_spec\n end\n target_odr_group_name = \"#{pod_target.label}-OnDemandResources\"\n UserProjectIntegrator::TargetIntegrator.update_on_demand_resources(target.sandbox, native_target.project,\n native_target, file_accessors,\n parent_odr_group, target_odr_group_name)\n end\n\n # Now add the ODRs of our own app spec declaration.\n file_accessor = target.file_accessors.find { |fa| fa.spec == app_spec }\n target_odr_group_name = \"#{target.subspec_label(app_spec)}-OnDemandResources\"\n UserProjectIntegrator::TargetIntegrator.update_on_demand_resources(target.sandbox, native_target.project,\n native_target, file_accessor,\n parent_odr_group, target_odr_group_name)\n end",
"def set_target_dependencies\n frameworks_group = project.frameworks_group\n test_only_pod_targets = pod_targets.dup\n aggregate_targets.each do |aggregate_target|\n is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) &\n [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?\n is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' }\n\n aggregate_target.search_paths_aggregate_targets.each do |search_paths_target|\n aggregate_target.native_target.add_dependency(search_paths_target.native_target)\n end\n\n aggregate_target.pod_targets.each do |pod_target|\n test_only_pod_targets.delete(pod_target)\n configure_app_extension_api_only_for_target(aggregate_target) if is_app_extension\n\n unless pod_target.should_build?\n add_resource_bundles_to_native_target(pod_target, aggregate_target.native_target)\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n next\n end\n\n aggregate_target.native_target.add_dependency(pod_target.native_target)\n configure_app_extension_api_only_for_target(pod_target) if is_app_extension\n\n add_dependent_targets_to_native_target(pod_target.dependent_targets,\n pod_target.native_target, is_app_extension,\n pod_target.requires_frameworks? && !pod_target.static_framework?,\n frameworks_group)\n unless pod_target.static_framework?\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n end\n end\n end\n # Wire up remaining pod targets used only by tests and are not used by any aggregate target.\n test_only_pod_targets.each do |pod_target|\n unless pod_target.should_build?\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n next\n end\n unless pod_target.static_framework?\n add_dependent_targets_to_native_target(pod_target.dependent_targets,\n pod_target.native_target, false,\n pod_target.requires_frameworks?, frameworks_group)\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n end\n end\n end",
"def add_files_to_project(files = @files_to_add)\n files.each do |file_path|\n file_to_add = @new_file_group.new_file(file_path)\n @project.native_targets.each do |target|\n # If the name of the target contains the target flag, we'll add the file.\n # If no target flag was passed, it will be added to all targets.\n if target.name[@target_name]\n target.add_file_references([file_to_add])\n end\n end\n end\n end",
"def add_resources_to_target(paths, target)\n filter_resource_file_references(paths) do |compile_phase_refs, resource_phase_refs|\n # Resource bundles are only meant to have resources, so install everything\n # into the resources phase. See note in filter_resource_file_references.\n target.add_resources(resource_phase_refs + compile_phase_refs)\n !compile_phase_refs.empty?\n end\n end",
"def target_resources=(value)\n @target_resources = value\n end",
"def remove_nim_resources\n Log.log_info('In remove_nim_resources')\n @targets.each do |target|\n Log.log_debug('target=' + target)\n nim_lpp_source_resource = get_flrtvc_name(:NIM_res, target)\n exists = Nim.lpp_source_exists?(nim_lpp_source_resource)\n Log.log_debug('exists=' +\n exists.to_s)\n if exists\n Nim.remove_lpp_source(nim_lpp_source_resource)\n Log.log_debug('Removing NIM resource ' +\n nim_lpp_source_resource)\n else\n Log.log_debug('Already removed NIM resource ' +\n nim_lpp_source_resource)\n end\n end\n end",
"def add_test_targets\n target.test_specs.map do |test_spec|\n spec_consumer = test_spec.consumer(target.platform)\n test_type = spec_consumer.test_type\n product_type = target.product_type_for_test_type(test_type)\n name = target.test_target_label(test_spec)\n platform_name = target.platform.name\n language = target.uses_swift_for_spec?(test_spec) ? :swift : :objc\n product_basename = target.product_basename_for_spec(test_spec)\n embedded_content_contains_swift = target.dependent_targets_for_test_spec(test_spec).any?(&:uses_swift?)\n test_native_target = project.new_target(product_type, name, platform_name,\n target.deployment_target_for_non_library_spec(test_spec), nil,\n language, product_basename)\n test_native_target.product_reference.name = name\n\n target.user_build_configurations.each do |bc_name, type|\n test_native_target.add_build_configuration(bc_name, type)\n end\n\n test_native_target.build_configurations.each do |configuration|\n configuration.build_settings.merge!(custom_build_settings)\n # target_installer will automatically add an empty `OTHER_LDFLAGS`. For test\n # targets those are set via a test xcconfig file instead.\n configuration.build_settings.delete('OTHER_LDFLAGS')\n # target_installer will automatically set the product name to the module name if the target\n # requires frameworks. For tests we always use the test target name as the product name\n # irrelevant to whether we use frameworks or not.\n configuration.build_settings['PRODUCT_NAME'] = name\n # target_installer sets 'MACH_O_TYPE' for static frameworks ensure this does not propagate\n # to test target.\n configuration.build_settings.delete('MACH_O_TYPE')\n # Use xcode default product module name, which is $(PRODUCT_NAME:c99extidentifier)\n # this gives us always valid name that is distinct from the parent spec module name\n # which allow tests to use either import or @testable import to access the parent framework\n configuration.build_settings.delete('PRODUCT_MODULE_NAME')\n # We must codesign iOS XCTest bundles that contain binary frameworks to allow them to be launchable in the simulator\n unless target.platform == :osx\n configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'YES'\n configuration.build_settings['CODE_SIGNING_ALLOWED'] = 'YES'\n end\n # For macOS we do not code sign the XCTest bundle because we do not code sign the frameworks either.\n if target.platform == :osx\n configuration.build_settings['CODE_SIGN_IDENTITY'] = ''\n elsif target.platform == :ios\n configuration.build_settings['CODE_SIGN_IDENTITY'] = 'iPhone Developer'\n end\n # Ensure swift stdlib gets copied in if needed, even when the target contains no swift files,\n # because a dependency uses swift\n configuration.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES' if embedded_content_contains_swift\n end\n\n remove_pod_target_xcconfig_overrides_from_target(target.test_spec_build_settings_by_config[test_spec.name], test_native_target)\n\n # Test native targets also need frameworks and resources to be copied over to their xctest bundle.\n create_test_target_embed_frameworks_script(test_spec)\n create_test_target_copy_resources_script(test_spec)\n\n # Generate vanilla Info.plist for test target similar to the one Xcode generates for new test target.\n # This creates valid test bundle accessible at the runtime, allowing tests to load bundle resources\n # defined in podspec.\n additional_entries = spec_consumer.info_plist\n path = target.info_plist_path_for_spec(test_spec)\n create_info_plist_file(path, test_native_target, '1.0', target.platform, :bndl, :additional_entries => additional_entries)\n\n test_native_target\n end\n end",
"def include_targets=(value)\n @include_targets = value\n end",
"def add_placeholder_target\n native_target = project.new_aggregate_target(target.label, [], target.platform.name, deployment_target)\n target.user_build_configurations.each do |bc_name, type|\n native_target.add_build_configuration(bc_name, type)\n end\n unless target.archs.empty?\n native_target.build_configurations.each do |configuration|\n configuration.build_settings['ARCHS'] = target.archs\n end\n end\n native_target\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 newNativeTarget(name, dependencies, buildConfigurationList, productType, explicitFileType)\n uuid = newObject('PBXNativeTarget', {\n 'buildConfigurationList' => buildConfigurationList,\n 'buildPhases' => [],\n 'buildRules' => [],\n 'dependencies' => dependencies,\n 'name' => self.strip_ext(name),\n 'productName' => self.strip_ext(name),\n 'productReference' => newProductFileReference(explicitFileType, name),\n 'productType' => productType,\n 'comment' => \"target #{name}\"\n })\n \n @p['objects'][self.project]['targets'].push(uuid)\n \n uuid\n end",
"def add_target(cmd)\n value = new_resource.to_target\n cmd << \"--to-target @#{value}\" if value\n cmd\nend",
"def set_targets arg\n raise \"Target list is nil\" if arg.nil?\n raise \"Target list is empty\" if arg.empty?\n t_list = Set[]\n arg.each { |tgt|\n # Need to append suffix based on link_type -- do later\n # if it ends in .o or .so, add build_type suffix\n tgt += \"_#{@build_type}\" if tgt =~ /.(?:o|a|so)$/o\n list = find_target tgt\n raise \"Target #{tgt} not found\" if list.nil? || list.empty?\n raise \"Target #{tgt} not unique: #{list}\" if list.size > 1\n t_list << list.first\n }\n log = Build.logger\n if t_list == @targets\n log.warn \"Target list unchanged\"\n else\n @targets = t_list\n log.debug \"Target list changed to:\"\n @targets.each { |t| puts( \" %s\" % t.path ) }\n end\n\n end",
"def run_all\n \n projects.each do |project|\n project.targets.each do |target|\n config = target.config('Debug')\n UI.info((\"*\" * 80))\n UI.info \"Building #{project.name} - #{target.name} - #{config.name}\"\n UI.info((\"*\" * 80))\n config.builder.build\n end\n end\n \n end",
"def associate(params)\n\t\tparams.each do |hdrfile, srcfiles|\n\t\t\thdrfile = canonicalizeFilepath(Pathname.new(hdrfile), Pathname.pwd())\n\t\t\tsrcfiles = canonicalizeFilepaths(srcfiles.map {|filepath| Pathname.new(filepath)}, Pathname.pwd())\n\t\t\tsrcfiles.each do |srcfile|\n\t\t\t\ttype, modbase = BuildEnv::entityType(srcfile)\n\t\t\t\tBuildEnv::addLinkDeps hdrfile, BuildEnv::srcOrBuild2build(System::mod2obj(srcfile.dirname().join(modbase)))\n\t\t\tend\n\t\tend \n\tend",
"def add_targets args\n args.each { |t|\n raise \"Bad object (expected Target): #{t.class.name}\" if !t.is_a? Target\n raise \"Duplicate target: #{t.path}\" if @all_targets.key? t.path\n @all_targets[ t.path ] = t\n Build.logger.debug \"Added target: %s\" % t.path\n }\n end",
"def apple_resource_targets\n filter_targets(@targets, 'apple_resource')\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find or create a 'Copy Pods Resources' build phase | def add_copy_resources_script_phase
unless target.includes_resources?
native_targets.each do |native_target|
TargetIntegrator.remove_copy_resources_script_phase_from_target(native_target)
end
return
end
script_path = target.copy_resources_script_relative_path
input_paths_by_config = {}
output_paths_by_config = {}
if use_input_output_paths
target.resource_paths_by_config.each do |config, resource_paths|
input_paths_key = XCFileListConfigKey.new(target.copy_resources_script_input_files_path(config),
target.copy_resources_script_input_files_relative_path)
input_paths_by_config[input_paths_key] = [script_path] + resource_paths
output_paths_key = XCFileListConfigKey.new(target.copy_resources_script_output_files_path(config),
target.copy_resources_script_output_files_relative_path)
output_paths_by_config[output_paths_key] = TargetIntegrator.resource_output_paths(resource_paths)
end
end
native_targets.each do |native_target|
# Static library targets cannot include resources. Skip this phase from being added instead.
next if native_target.symbol_type == :static_library
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path,
input_paths_by_config,
output_paths_by_config)
end
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 create_copy_resources_script\n path = library.copy_resources_script_path\n UI.message \"- Generating copy resources script at #{UI.path(path)}\" do\n resources = library.file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten\n resources << bridge_support_file if bridge_support_file\n generator = Generator::CopyResourcesScript.new(resources)\n generator.save_as(path)\n add_file_to_support_group(path)\n end\n end",
"def create_copy_resources_script\n path = target.copy_resources_script_path\n generator = Generator::CopyResourcesScript.new(target.resource_paths_by_config, target.platform)\n update_changed_file(generator, path)\n add_file_to_support_group(path)\n end",
"def resources_build_phase\n find_or_create_build_phase_by_class(PBXResourcesBuildPhase)\n end",
"def add_missing_copy_phase!(dry_run: false)\n # Check if upgrade is needed\n # If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project\n phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == \"FastlaneRunnerCopySigned\" }.first\n\n old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == \"cd \\\"${SRCROOT}\\\"\\ncd ../..\\ncp \\\"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\\\" .\\n\" }.first\n\n return true if dry_run && phase_copy_sign.nil?\n\n return false if dry_run\n\n # Proceed to upgrade\n old_phase_copy_sign.remove_from_project unless old_phase_copy_sign.nil?\n\n unless phase_copy_sign\n # Create a copy files build phase\n phase_copy_sign = self.fastlane_runner_target.new_copy_files_build_phase(\"FastlaneRunnerCopySigned\")\n phase_copy_sign.dst_path = \"$SRCROOT/../..\"\n phase_copy_sign.dst_subfolder_spec = \"0\"\n phase_copy_sign.run_only_for_deployment_postprocessing = \"0\"\n targetBinaryReference = self.fastlane_runner_target.product_reference\n phase_copy_sign.add_file_reference(targetBinaryReference)\n\n # Set \"Code sign on copy\" flag on Xcode for fastlane_runner_target\n targetBinaryReference.build_files.each { |target_binary_build_file_reference|\n target_binary_build_file_reference.settings = { \"ATTRIBUTES\": [\"CodeSignOnCopy\"] }\n }\n end\n\n target_project.save\n end",
"def _copy_extra_resources(to_path)\n FileUtils.cp('readme-banner.jpg', to_path)\n FileUtils.cp_r('documentation/resources', to_path)\n end",
"def create_test_target_copy_resources_script(test_spec)\n path = target.copy_resources_script_path_for_spec(test_spec)\n host_target_spec_names = target.app_host_dependent_targets_for_spec(test_spec).flat_map do |pt|\n pt.specs.map(&:name)\n end.uniq\n resource_paths_by_config = target.user_build_configurations.each_with_object({}) do |(config_name, config), resources_by_config|\n resources_by_config[config_name] = target.dependent_targets_for_test_spec(test_spec, :configuration => config).flat_map do |pod_target|\n spec_paths_to_include = pod_target.library_specs.map(&:name)\n spec_paths_to_include -= host_target_spec_names\n spec_paths_to_include << test_spec.name if pod_target == target\n pod_target.resource_paths.values_at(*spec_paths_to_include).flatten.compact\n end\n end\n unless resource_paths_by_config.each_value.all?(&:empty?)\n generator = Generator::CopyResourcesScript.new(resource_paths_by_config, target.platform)\n update_changed_file(generator, path)\n add_file_to_support_group(path)\n end\n end",
"def set_run_script_to_always_run_when_no_input_or_output_files_exist(project:)\n project.targets.each do |target|\n run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }\n cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?(\"[CP\") }\n cocoapods_run_script_build_phases.each do |run_script|\n next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?\n run_script.always_out_of_date = \"1\"\n end\n end\n project.save\nend",
"def add_earlgrey_copy_files_script(user_project, test_target)\n user_project.targets.each do |target|\n earlgrey_copy_files_phase_name = 'EarlGrey Copy Files'\n if target.name == test_target\n earlgrey_copy_files_exists = false\n target.copy_files_build_phases.each do |copy_files_phase|\n if copy_files_phase.name = earlgrey_copy_files_phase_name\n earlgrey_copy_files_exists = true\n end\n end\n\n if earlgrey_copy_files_exists == false\n new_copy_files_phase = target.new_copy_files_build_phase(earlgrey_copy_files_phase_name)\n new_copy_files_phase.dst_path = '$(TEST_HOST)/../'\n new_copy_files_phase.dst_subfolder_spec = '0'\n file_ref =\n user_project.products_group.new_file('${SRCROOT}/Pods/EarlGrey/EarlGrey-1.0.0/EarlGrey.framework')\n file_ref.source_tree = 'SRCROOT'\n build_file = new_copy_files_phase.add_file_reference(file_ref, true)\n build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }\n user_project.save()\n end\n end\n end\nend",
"def common_build\n copy_gems\n end",
"def maybe_local_pod(name)\n if use_local_sources()\n pod name, :path => '../..'\n end\nend",
"def resources_build_phase\n phase = build_phases.find { |bp| bp.class == PBXResourcesBuildPhase }\n unless phase\n phase = project.new(PBXResourcesBuildPhase)\n build_phases << phase\n end\n phase\n end",
"def add_carthage_copy_phase(target)\n shell_script_name = 'Carthage copy-frameworks Run Script'\n target_names = target.shell_script_build_phases.map(&:name)\n unless target_names.include?(shell_script_name)\n shell_script = target.new_shell_script_build_phase shell_script_name\n shell_script.shell_path = '/bin/bash'\n shell_script.shell_script = '/usr/local/bin/carthage copy-frameworks'\n shell_script.input_paths = [CARTHAGE_FRAMEWORK_PATH]\n end\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 podify_project(project_path, &inner_handler)\n project = Xcodeproj::Project.open(project_path)\n project.native_targets.each do |target|\n target target.name do\n project project_path\n inherit! :search_paths\n\n unless target.extension_target_type?\n puts \"Adding all pods to #{target.name}\"\n all_pods\n end\n\n if target.product_type == 'com.apple.product-type.application' && target.build_settings(\"Calabash\")\n puts \"Adding Calabash to #{target.name} for Calabash configuration\"\n pod 'Calabash', :configurations => ['Calabash']\n end\n\n pods_for_target(target.name)\n yield(target) if block_given?\n end\n end\nend",
"def copy_required_project_resources(test_configuration)\n cleanup(test_configuration)\n if test_configuration[:unit]\n # copy main package.json from project directory in order to use it in the unit-test\n # docker container\n parent_directory = File.dirname(File.expand_path('..', __FILE__))\n FileUtils.cp(\"#{parent_directory}/package.json\", \"#{@test_dir}/unit\")\n end\n end",
"def new_copy_files_build_phase(name = nil)\n phase = project.new(PBXCopyFilesBuildPhase)\n phase.name = name\n build_phases << phase\n phase\n end",
"def flutter_macos_podfile_setup; end",
"def build_environment_resources(environment, system_exec)\n puts \"Building all required resources for environment '#{environment.environment_name}'\"\n\n if environment.is_drupal_environment?\n build_css_and_js_for_drupal\n environment.create_template_resources\n end\n\n copy_project_dependencies_for_awestruct_image\n build_base_docker_images(environment, system_exec)\n build_environment_docker_images(environment, system_exec)\n\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the embed frameworks build phase from embedded targets | def remove_embed_frameworks_script_phase_from_embedded_targets
return unless target.requires_host_target?
native_targets.each do |native_target|
if AggregateTarget::EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include? native_target.symbol_type
TargetIntegrator.remove_embed_frameworks_script_phase_from_target(native_target)
end
end
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 create_embed_frameworks_phase(project, t)\n \n t.build_phases.delete_if { |phase| \n phase.to_s == 'Embed Frameworks'\n }\n\n embed_frameworks_build_phase = project.new(\n Xcodeproj::Project::Object::PBXCopyFilesBuildPhase\n )\n\n embed_frameworks_build_phase.name = 'Embed Frameworks'\n embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks\n t.build_phases << embed_frameworks_build_phase\n return embed_frameworks_build_phase\nend",
"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 create_app_target_embed_frameworks_script(app_spec)\n path = target.embed_frameworks_script_path_for_spec(app_spec)\n framework_paths_by_config = target.user_build_configurations.each_with_object({}) do |(config_name, config), paths_by_config|\n paths_by_config[config_name] = target.dependent_targets_for_app_spec(app_spec, :configuration => config).flat_map do |pod_target|\n spec_paths_to_include = pod_target.library_specs.map(&:name)\n spec_paths_to_include << app_spec.name if pod_target == target\n pod_target.framework_paths.values_at(*spec_paths_to_include).flatten.compact.uniq\n end\n end\n xcframeworks_by_config = target.user_build_configurations.each_with_object({}) do |(config_name, config), paths_by_config|\n paths_by_config[config_name] = target.dependent_targets_for_app_spec(app_spec, :configuration => config).flat_map do |pod_target|\n spec_paths_to_include = pod_target.library_specs.map(&:name)\n spec_paths_to_include << app_spec.name if pod_target == target\n pod_target.xcframeworks.values_at(*spec_paths_to_include).flatten.compact.uniq\n end\n end\n\n unless framework_paths_by_config.each_value.all?(&:empty?) && xcframeworks_by_config.each_value.all?(&:empty?)\n generator = Generator::EmbedFrameworksScript.new(framework_paths_by_config, xcframeworks_by_config)\n update_changed_file(generator, path)\n add_file_to_support_group(path)\n end\n end",
"def create_embed_frameworks_script\n path = target.embed_frameworks_script_path\n generator = Generator::EmbedFrameworksScript.new(target.framework_paths_by_config)\n update_changed_file(generator, path)\n add_file_to_support_group(path)\n end",
"def create_test_target_embed_frameworks_script(test_spec)\n path = target.embed_frameworks_script_path_for_spec(test_spec)\n host_target_spec_names = target.app_host_dependent_targets_for_spec(test_spec).flat_map do |pt|\n pt.specs.map(&:name)\n end.uniq\n framework_paths_by_config = target.user_build_configurations.each_with_object({}) do |(config_name, config), paths_by_config|\n paths_by_config[config_name] = target.dependent_targets_for_test_spec(test_spec, :configuration => config).flat_map do |pod_target|\n spec_paths_to_include = pod_target.library_specs.map(&:name)\n spec_paths_to_include -= host_target_spec_names\n spec_paths_to_include << test_spec.name if pod_target == target\n pod_target.framework_paths.values_at(*spec_paths_to_include).flatten.compact.uniq\n end\n end\n xcframeworks_by_config = target.user_build_configurations.each_with_object({}) do |(config_name, config), paths_by_config|\n paths_by_config[config_name] = target.dependent_targets_for_test_spec(test_spec, :configuration => config).flat_map do |pod_target|\n spec_paths_to_include = pod_target.library_specs.map(&:name)\n spec_paths_to_include -= host_target_spec_names\n spec_paths_to_include << test_spec.name if pod_target == target\n pod_target.xcframeworks.values_at(*spec_paths_to_include).flatten.compact.uniq\n end\n end\n unless framework_paths_by_config.each_value.all?(&:empty?) && xcframeworks_by_config.each_value.all?(&:empty?)\n generator = Generator::EmbedFrameworksScript.new(framework_paths_by_config, xcframeworks_by_config)\n update_changed_file(generator, path)\n add_file_to_support_group(path)\n end\n end",
"def keep_source_code_for_prebuilt_frameworks!\n DSL.dont_remove_source_code = true\n end",
"def remove_static_framework_duplicate_linkage(static_framework_pods)\n puts \"Removing duplicate linkage of static frameworks\"\n\n Dir.glob(File.join(PODS_TARGET_SUPPORT_FILES_DIR, \"Pods-*\")).each do |path|\n pod_target = path.split('-', -1).last\n\n static_framework_pods.each do |target, pods|\n next if pod_target == target\n frameworks = pods.map { |pod| identify_frameworks(pod) }.flatten\n\n Dir.glob(File.join(path, \"*.xcconfig\")).each do |xcconfig|\n lines = File.readlines(xcconfig)\n\n if other_ldflags_index = lines.find_index { |l| l.start_with?('OTHER_LDFLAGS') }\n other_ldflags = lines[other_ldflags_index]\n\n frameworks.each do |framework|\n other_ldflags.gsub!(\"-framework \\\"#{framework}\\\"\", '')\n end\n\n File.open(xcconfig, 'w') do |fd|\n fd.write(lines.join)\n end\n end\n end\n end\n end\nend",
"def frameworks_build_phase\n find_or_create_build_phase_by_class(PBXFrameworksBuildPhase)\n end",
"def frameworks_build_phase\n phase = build_phases.find { |bp| bp.class == PBXFrameworksBuildPhase }\n unless phase\n phase= project.new(PBXFrameworksBuildPhase)\n build_phases << phase\n end\n phase\n end",
"def restrict_frameworks\n remove_from_config('require \"rails/all\"')\n remove_from_config('require_relative \"boot\"')\n remove_from_env_config(\"development\", \"config.active_storage.*\")\n frameworks = <<~RUBY\n require \"rails\"\n require \"active_model/railtie\"\n require \"active_job/railtie\"\n require \"active_record/railtie\"\n require \"action_controller/railtie\"\n require \"action_mailer/railtie\"\n require \"action_view/railtie\"\n require \"rails/test_unit/railtie\"\n RUBY\n environment = File.read(\"#{app_path}/config/application.rb\")\n File.open(\"#{app_path}/config/application.rb\", \"w\") { |f| f.puts frameworks + \"\\n\" + environment }\n end",
"def embed_frameworks_output_paths(framework_paths, xcframeworks)\n paths = framework_paths.map do |framework_path|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}\"\n end.uniq\n # Static xcframeworks are not copied to the build dir\n # so only include dynamic artifacts that will be copied to the build folder\n xcframework_paths = xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.map do |xcframework|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{xcframework.name}.framework\"\n end\n paths + xcframework_paths\n end",
"def cleanUpDeploymentTargets(installer)\n installer.pods_project.targets.each do |target|\n target.build_configurations.each do |config|\n config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'\n end\n end\nend",
"def use_frameworks!(flag = true)\n current_target_definition.use_frameworks!(flag)\n end",
"def turn_prebuilt_hmap_off_for_pod_targets\n $prebuilt_hmap_for_pod_targets = false\n end",
"def set_target_dependencies\n frameworks_group = project.frameworks_group\n test_only_pod_targets = pod_targets.dup\n aggregate_targets.each do |aggregate_target|\n is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) &\n [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?\n is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' }\n\n aggregate_target.search_paths_aggregate_targets.each do |search_paths_target|\n aggregate_target.native_target.add_dependency(search_paths_target.native_target)\n end\n\n aggregate_target.pod_targets.each do |pod_target|\n test_only_pod_targets.delete(pod_target)\n configure_app_extension_api_only_for_target(aggregate_target) if is_app_extension\n\n unless pod_target.should_build?\n add_resource_bundles_to_native_target(pod_target, aggregate_target.native_target)\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n next\n end\n\n aggregate_target.native_target.add_dependency(pod_target.native_target)\n configure_app_extension_api_only_for_target(pod_target) if is_app_extension\n\n add_dependent_targets_to_native_target(pod_target.dependent_targets,\n pod_target.native_target, is_app_extension,\n pod_target.requires_frameworks? && !pod_target.static_framework?,\n frameworks_group)\n unless pod_target.static_framework?\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n end\n end\n end\n # Wire up remaining pod targets used only by tests and are not used by any aggregate target.\n test_only_pod_targets.each do |pod_target|\n unless pod_target.should_build?\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n next\n end\n unless pod_target.static_framework?\n add_dependent_targets_to_native_target(pod_target.dependent_targets,\n pod_target.native_target, false,\n pod_target.requires_frameworks?, frameworks_group)\n add_pod_target_test_dependencies(pod_target, frameworks_group)\n end\n end\n end",
"def remove_framework_from_xcodeproj(framework_name)\n\n # Delete framework files\n source_dir_path = File.dirname(source_project_path)\n result_dir_path = File.join(source_dir_path, framework_name)\n \n if File.exist?(result_dir_path)\n FileUtils.rm_r(result_dir_path)\n end\n\n # Remove framework target from xcodeproj\n project = Xcodeproj::Project.open(source_project_path)\n\n target_to_remove = project.targets.select { |target| target.name == framework_name }.first\n\n if not target_to_remove.nil? \n # Build phases\n target_to_remove.build_phases.each { |phase| \n phase.clear \n phase.clear_build_files\n phase.remove_from_project\n }\n\n if not target_to_remove.build_configuration_list.nil? \n target_to_remove.build_configuration_list.remove_from_project\n end\n\n target_to_remove.remove_from_project\n end\n\n # Remove framework files group\n project.groups.select { |group| group.path == framework_name or group.name == framework_name }.each { |framework_group| \n framework_group.clear\n framework_group.remove_from_project\n }\n\n project.files.each { |file| \n if file.path == framework_name + \".framework\"\n file.remove_from_project\n end\n }\n\n project.frameworks_group.groups.each { |framework_group| \n if framework_group.name == 'iOS'\n framework_group.files.each { |file|\n if file.name == 'Foundation.framework'\n file.remove_from_project\n framework_group.clear\n framework_group.remove_from_project\n end\n }\n end\n }\n\n project.objects.select { |object| object.isa == \"PBXBuildFile\" }.each { |e| \n if e.file_ref.nil?\n e.remove_from_project\n end\n }\n\n project.save\n end",
"def bundle_framework(framework_name)\n framework_id, framework_values = object_for_name(framework_name)\n \n # create a new file wrapper for in the copy build phase\n framework_in_build_phase_id = generate_object_id\n framework_in_build_phase_values = {\n 'isa' => 'PBXBuildFile',\n 'fileRef' => framework_id\n }\n add_object(framework_in_build_phase_id, framework_in_build_phase_values)\n \n # get or define the Copy Frameworks build phase\n build_phase = object_for_name('Copy Frameworks')\n if build_phase.nil?\n build_phase_id, build_phase_values = new_framework_copy_build_phase\n # add the new build phase to the objects\n add_object(build_phase_id, build_phase_values)\n \n # add the new build phase to the project target\n add_build_phase_to_project_target(build_phase_id)\n else\n build_phase_id, build_phase_values = build_phase\n end\n # add the framework to the build phase\n add_object_to_build_phase(framework_in_build_phase_id, build_phase_id)\n end",
"def exclude_simulator_archs(installer)\n Pod::UI.puts \"Fixing Xcode 12 duplicate architectures\"\n\n installer.pods_project.targets.each do |target|\n target.build_configurations.each do |config|\n config.build_settings['EXCLUDED_ARCHS[sdk=*simulator*]'] = 'arm64 arm64e armv7 armv7s armv6 armv8'\n end\n end\n\n installer.pods_project.save\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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_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 store_script_phase(options)\n option_keys = options.keys\n unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS\n unless unrecognized_keys.empty?\n raise StandardError, \"Unrecognized options `#{unrecognized_keys}` in shell script `#{options[:name]}` within `#{name}` target. \" \\\n \"Available options are `#{Specification::ALL_SCRIPT_PHASE_KEYS}`.\"\n end\n missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - option_keys\n unless missing_required_keys.empty?\n raise StandardError, \"Missing required shell script phase options `#{missing_required_keys.join(', ')}`\"\n end\n script_phases_hash = get_hash_value('script_phases', [])\n if script_phases_hash.map { |script_phase_options| script_phase_options[:name] }.include?(options[:name])\n raise StandardError, \"Script phase with name `#{options[:name]}` name already present for target `#{name}`.\"\n end\n options[:execution_position] = :any unless options.key?(:execution_position)\n unless Specification::EXECUTION_POSITION_KEYS.include?(options[:execution_position])\n raise StandardError, \"Invalid execution position value `#{options[:execution_position]}` in shell script `#{options[:name]}` within `#{name}` target. \" \\\n \"Available options are `#{Specification::EXECUTION_POSITION_KEYS}`.\"\n end\n script_phases_hash << options\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 admin_update\n @phase = Phase.find(params[:id])\n authorize @phase\n \n @phase.description = params[\"phase-desc\"]\n @current_tab = params[:r] || 'all-templates'\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, r: @current_tab), notice: success_message(_('phase'), _('saved'))\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[:alert] = 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 redirect_to admin_show_phase_path(@phase, r: @current_tab)\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 update_by_phase\n case @phase\n when 0 then phase_preturn\n when 1 then phase_cursor\n when 2 then phase_command\n when 3 then phase_action\n when 4 then phase_decision\n when 5 then phase_animation\n when 6 then phase_menu\n when 7 then phase_endturn\n end\n end",
"def update_by_phase\n case @phase\n when 0 then phase_preturn\n when 1 then phase_cursor\n when 2 then phase_command\n when 3 then phase_decision\n when 4 then phase_action\n when 5 then phase_animation\n when 6 then phase_menu\n when 7 then phase_endturn\n end\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_target\n raise NotImplementedError\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 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 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 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 integrate!\n UI.section(integration_message) do\n target.test_specs_by_native_target.each do |native_target, test_specs|\n add_embed_frameworks_script_phase(native_target)\n add_copy_resources_script_phase(native_target)\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(test_specs), native_target)\n end\n specs = target.non_test_specs\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(specs), target.native_target)\n end\n end",
"def create_phases\n @lifecycle_phases = LifecyclePhase.find_all_by_lifecycle_id(self.lifecycle_id)\n @lifecycle_phases.each do |lp|\n ProjectPhase.create_from_lifecycle_phase(lp.id, self)\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 set_run_script_to_always_run_when_no_input_or_output_files_exist(project:)\n project.targets.each do |target|\n run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }\n cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?(\"[CP\") }\n cocoapods_run_script_build_phases.each do |run_script|\n next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?\n run_script.always_out_of_date = \"1\"\n end\n end\n project.save\nend",
"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 pod_install_required?(podfile_folder)\n podfile_folder = File.expand_path podfile_folder\n podfile_path = File.join podfile_folder, 'Podfile'\n raise ArgumentError, \"No Podfile at #{podfile_folder}\" unless File.readable?(podfile_path)\n\n # Podfile must be evalled in its current directory in order to resolve\n # the require_relative at the top.\n podfile = Dir.chdir(podfile_folder) { Pod::Podfile.from_file podfile_path }\n\n # From here on we expect pod install to succeed. We just check whether it's\n # necessary. The Podfile.from_file call above can raise if the Podfile\n # contains errors. In that case, pod install will also fail, so we allow\n # the exception to be raised instead of returning true.\n\n lockfile_path = File.join podfile_folder, 'Podfile.lock'\n manifest_path = File.join podfile_folder, 'Pods', 'Manifest.lock'\n\n # Don't regenerate the lockfile\n raise CocoapodsHelperException, \"#{lockfile_path} missing or not readable.\" unless File.readable?(lockfile_path)\n\n return true unless File.readable?(manifest_path)\n\n # This validates the Podfile.lock for yaml formatting at least and makes\n # the lockfile hash available to check the Podfile checksum later.\n lockfile = Pod::Lockfile.from_file Pathname.new lockfile_path\n lockfile_contents = File.read lockfile_path\n\n begin\n # diff the contents of Podfile.lock and Pods/Manifest.lock\n # This is just what is done in the \"[CP] Check Pods Manifest.lock\" script\n # build phase in a project using CocoaPods. This is a stricter requirement\n # than semantic comparison of the two lockfile hashes.\n return true unless lockfile_contents == File.read(manifest_path)\n\n # compare checksum of Podfile with checksum in Podfile.lock in case Podfile\n # updated since last pod install/update.\n return false if lockfile.to_hash[\"PODFILE CHECKSUM\"] == podfile.checksum\n rescue StandardError, Pod::PlainInformative => e\n # Any error from Pod::Lockfile.from_file or File.read after verifying a\n # file exists and is readable. pod install will regenerate these files.\n UI.error e.message\n return true\n end\n\n # Don't regenerate the lockfile.\n raise CocoapodsHelperException, \"Podfile checksum #{podfile.checksum} does not match PODFILE CHECKSUM in Podfile.lock.\"\n end",
"def pod_dry_run\n print \"Pod dry run...\"\n repos = resolved_repos.join \",\"\n result = system \"pod lib lint #{@configuration.podspec_file} --allow-warnings --sources=#{repos}\"\n raise \"** Pod dry run failed **\" if !result\n puts \"Done\"\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 verify_podfile_exists!\n unless config.podfile\n raise Informative, \"No `Podfile' found in the project directory.\"\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 ensureScriptsAreUpdated()\n scriptsJSON = JSON.parse(File.read(@scriptsJSONpath))\n currentVersion = scriptsJSON['currentScriptsVersion']\n\n puts \"Checking for an update to Monolith Scripts. Configure this in Scripts/config.json\"\n remoteScriptsJSON = remoteScriptsJSONContents()\n remoteVersion = remoteScriptsJSON['currentScriptsVersion']\n\n if Gem::Version.new(remoteVersion) > Gem::Version.new(currentVersion)\n puts \"Version #{remoteVersion} of Monolith Scripts are available. You have #{currentVersion}\"\n puts \"Installing new version\"\n if downloadNewScripts(scriptsJSON, remoteScriptsJSON)\n buildCRC32sForScripts(scriptsJSON)\n return true\n end\n end\n\n # signify no scripts were updated\n return false\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 check\n missing_packages = (build_dependencies(config.build_dependencies) || []).select do |package|\n test_command = package_test_command(package)\n Pkgr.debug \"sh(#{test_command})\"\n ! system(test_command)\n end\n\n unless missing_packages.empty?\n install_command = package_install_command(missing_packages)\n if config.auto\n puts \"-----> Installing missing build dependencies: #{missing_packages.join(\", \")}\"\n package_install = Mixlib::ShellOut.new(install_command)\n package_install.logger = Pkgr.logger\n package_install.run_command\n package_install.error!\n else\n Pkgr.warn(\"Missing build dependencies detected. Run the following to fix: #{install_command}\")\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 pre_shell_script_build_phase(name, script, &block)\n phase = ShellScriptBuildPhase.new(&block)\n phase.name = name\n phase.script = script\n pinned_build_phases << phase\n phase\n end",
"def add_missing_copy_phase!(dry_run: false)\n # Check if upgrade is needed\n # If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project\n phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == \"FastlaneRunnerCopySigned\" }.first\n\n old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == \"cd \\\"${SRCROOT}\\\"\\ncd ../..\\ncp \\\"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\\\" .\\n\" }.first\n\n return true if dry_run && phase_copy_sign.nil?\n\n return false if dry_run\n\n # Proceed to upgrade\n old_phase_copy_sign.remove_from_project unless old_phase_copy_sign.nil?\n\n unless phase_copy_sign\n # Create a copy files build phase\n phase_copy_sign = self.fastlane_runner_target.new_copy_files_build_phase(\"FastlaneRunnerCopySigned\")\n phase_copy_sign.dst_path = \"$SRCROOT/../..\"\n phase_copy_sign.dst_subfolder_spec = \"0\"\n phase_copy_sign.run_only_for_deployment_postprocessing = \"0\"\n targetBinaryReference = self.fastlane_runner_target.product_reference\n phase_copy_sign.add_file_reference(targetBinaryReference)\n\n # Set \"Code sign on copy\" flag on Xcode for fastlane_runner_target\n targetBinaryReference.build_files.each { |target_binary_build_file_reference|\n target_binary_build_file_reference.settings = { \"ATTRIBUTES\": [\"CodeSignOnCopy\"] }\n }\n end\n\n target_project.save\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 compile\n if always_update\n info(\"Updating policy lock using `chef update`\")\n run_command(\"chef update #{escape_path(policyfile)}\")\n end\n if File.exist?(lockfile)\n info(\"Installing cookbooks for Policyfile #{policyfile} using `chef install`\")\n else\n info(\"Policy lock file doesn't exist, running `chef install` for \"\\\n \"Policyfile #{policyfile}...\")\n end\n run_command(\"chef install #{escape_path(policyfile)}\")\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Elevator, Sorts elevators based on the number of stops they have | def elevator
elevators.sort_by { |e| e.stop_count }.first
end | [
"def compute_list\n if elevator_direction == 'UP'\n floor_list.sort\n elsif elevator_direction == 'DOWN'\n floor_list.sort\n floor_list.reverse\n end\n floor_list\n end",
"def elevator\n\t\t@elevators.each do |e|\n\t\t\t@people.each do |person|\n\t\t\t\tif ((e.current == @floor_num) && (person.end_location != @floor_num))\n\t\t\t\t\tputs \"Getting on elevator..\"\n\t\t\t\t\t@number_of_people -= 1\n\t\t\t\t\te.increase_cap\n\t\t\t\t\tif e.capacity >= e.max\n\t\t\t\t\t\tputs \"Elevator is full!\"\n\t\t\t\t\t\treturn false\n\t\t\t\t\tend\n\t\t\t\t\t@number_of_elevators = 1\n\t\t\t\t\te.to_s\n\t\t\t\t\treturn true\n\t\t\t\telsif person.end_location == @floor_num\n\t\t\t\t\te.decrease_cap\n\t\t\t\t\t@number_of_people += 1\n\t\t\t\t\treturn false\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\t\t@number_of_elevators = 0\n\t\tputs \"No Elevators Available\"\n\tend",
"def sort!\n @number_of_trips.sort!{|p1, p2| p1.trip_distance <=> p2.trip_distance}\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 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 direct_free_elevators\n free_elevators = @elevators.select{|elev| elev.empty?}\n free_elevators.each do |elev|\n best_direction = find_direction_for_elevator elev\n\n case best_direction\n when :up\n elev.going_up = true\n when :down\n elev.going_up = false\n else\n elev.go_to_resting_floor\n end\n @floors[elev.current_floor].enter_elevator elev\n end\n end",
"def elevators_at_floor(floor)\n\t\televators.select{|elevator| elevator.floor.eql? floor}\n\tend",
"def main_sort_running_order; end",
"def prepare_departure(elev, curr_floor)\n\t\tup_people = curr_floor.going_up\n\t\tdown_people = curr_floor.going_down\n\t\t#If an elevator has nobody in it and is on a floor with people, it will try to take as many people as possible in the direction they want\n\t\tif elev.no_people? && !curr_floor.no_people?\n\t\t\tif up_people.count > down_people.count\n\t\t\t\telev.set_status(\"up\")\n\t\t\telse\n\t\t\t\telev.set_status(\"down\")\n\t\t\tend\n\t\tend\n\t\t#It then takes whoever is going in the same direction as it\n\t\tif elev.status == \"down\" || curr_floor.number == @floors.count - 1\n\t\t\tdepartures = down_people\n\t\telse\n\t\t\tdepartures = up_people\n\t\tend\n\t\treturn departures\n\tend",
"def group_travellers\n #-------------------------------------------------------------------------------------------------------------------\n # If drivers are going by themselves, remove them from the algorithm and give them a route later.\n #-------------------------------------------------------------------------------------------------------------------\n\n drivers = []\n drivers_going_alone = []\n\n total_capacity = 0\n\n @drivers.each do |driver|\n total_capacity += driver.number_of_passengers\n\n if driver.number_of_passengers == 0\n drivers_going_alone << driver\n else\n drivers << driver\n end\n end\n\n if @passengers.length > total_capacity\n raise \"Too many passengers for the number of seats. Over by #{@passengers.length - total_capacity} seat(s)}.\"\n end\n\n #-------------------------------------------------------------------------------------------------------------------\n # Remove passengers from the algorithm who have a preference of going with somebody.\n #-------------------------------------------------------------------------------------------------------------------\n\n passengers = []\n driver_passenger_whitelist = Hash.new\n\n @passengers.each do |passenger|\n passenger_has_preference = false\n\n @trip.driver_passenger_whitelist.each do |preference|\n if passenger.to_s == preference[1].to_s\n if driver_passenger_whitelist[preference[0]].nil?\n driver_passenger_whitelist[preference[0]] = []\n end\n\n driver_passenger_whitelist[preference[0]] << preference[1]\n passenger_has_preference = true\n end\n end\n\n unless passenger_has_preference\n passengers << passenger\n end\n end\n\n #-------------------------------------------------------------------------------------------------------------------\n # Pair the passengers and drivers\n #-------------------------------------------------------------------------------------------------------------------\n\n pairing = Hash.new\n\n drivers.each do |driver|\n pairing[driver] = []\n end\n\n passengers.each do |passenger|\n min_deviation = 1000000\n min_deviation_pair = nil\n\n drivers.each do |driver|\n deviation = deviated_distance_from_path(driver.longitude, driver.latitude, @destination_longitude, @destination_latitude, passenger.longitude, passenger.latitude)\n\n if deviation < min_deviation\n min_deviation = deviation\n min_deviation_pair = [driver, passenger]\n end\n end\n\n if pairing[min_deviation_pair[0]].nil?\n pairing[min_deviation_pair[0]] = []\n end\n\n pairing[min_deviation_pair[0]] << min_deviation_pair[1]\n end\n\n #-------------------------------------------------------------------------------------------------------------------\n # Re-allocate passengers for vehicles that are over capacity.\n #-------------------------------------------------------------------------------------------------------------------\n\n # Add passengers to the drivers that were in the whitelist\n driver_passenger_whitelist.each do |driver, passengers|\n pairing[driver].concat passengers\n end\n\n # Create a hash that stores the drivers and their corresponding capacities\n driver_capacities = Hash.new\n drivers.each do |driver|\n driver_capacities[driver] = driver.number_of_passengers\n end\n\n # Determine which drivers are over capacity and have extra seats\n drivers_over_capacity = []\n drivers_with_extra_seats = []\n\n pairing.each do |driver, passengers|\n if !driver_passenger_whitelist[driver].nil? && driver_passenger_whitelist[driver].length > driver_capacities[driver]\n raise \"Too many passengers in the whitelist for #{driver.name}\"\n end\n\n if passengers.length > driver_capacities[driver]\n drivers_over_capacity << driver\n elsif passengers.length < driver_capacities[driver]\n drivers_with_extra_seats << driver\n end\n end\n\n # Move passenger from over capacity vehicles to ones that have extra seats\n until drivers_over_capacity.empty?\n shortest_distances = PriorityQueue.new(&lambda{|x, y| (x <=> y) == -1})\n\n pairing[drivers_over_capacity[-1]].each do |passenger|\n # Ignore passengers in whitelist\n passenger_in_whitelist = false\n\n unless driver_passenger_whitelist[drivers_over_capacity[-1]].nil?\n driver_passenger_whitelist[drivers_over_capacity[-1]].each do |whitelist_passenger|\n if passenger.to_s == whitelist_passenger.to_s\n passenger_in_whitelist = true\n break\n end\n end\n end\n\n if passenger_in_whitelist\n next\n end\n\n # Add distances to queue\n drivers_with_extra_seats.each do |driver_with_extra_seats|\n deviated_distance = deviated_distance_from_path(@destination_longitude, @destination_latitude, driver_with_extra_seats.longitude, driver_with_extra_seats.latitude, passenger.longitude, passenger.latitude)\n shortest_distances.push([driver_with_extra_seats, drivers_over_capacity[-1], passenger], deviated_distance)\n end\n end\n\n match = shortest_distances.pop\n pairing[match[1]].delete(match[2])\n pairing[match[0]] << match[2]\n\n if pairing[match[1]].length <= driver_capacities[match[1]]\n drivers_over_capacity.pop\n end\n\n if pairing[match[0]].length >= driver_capacities[match[0]]\n drivers_with_extra_seats.delete(match[0])\n end\n end\n\n #-------------------------------------------------------------------------------------------------------------------\n # Create the trip object with the routes (they won't have a path).\n #-------------------------------------------------------------------------------------------------------------------\n\n pairing.each do |driver, passengers|\n route = RouteContainer.new(nil, driver)\n\n passengers.each do |passenger|\n route.add_passenger(passenger)\n end\n\n @trip.add_route(route)\n end\n\n drivers_going_alone.each do |driver|\n route = RouteContainer.new(nil, driver)\n @trip.add_route(route)\n end\n\n @trip\n end",
"def next_destination_up(elevator)\n destination = nil\n waiter_floor_idx = waiter_floor_up(elevator[:car].floor_idx)\n stop_floor_idx = next_stop_up(elevator[:car].stops, elevator[:car].floor_idx)\n if stop_floor_idx.nil?\n destination = waiter_floor_idx\n elsif waiter_floor_idx.nil?\n destination = stop_floor_idx\n else\n destination = [stop_floor_idx, waiter_floor_idx].min\n end\n destination\n end",
"def sort_drivers_by_miles\n\t\t@drivers.sort_by { |key,driver| -driver.trip_total_miles }\n\tend",
"def index\n @elevators = Elevator.all\n end",
"def pickup_passengers\n pickup_count = 0\n @floors[@floor_idx].leave_waitlist do |passenger|\n if ((going_up? && (passenger.destination > @floor_idx)) || (going_down? && (passenger.destination < @floor_idx))) && !full?\n @riders[:count] += 1\n @riders[:weight] += passenger.weight\n occupants << passenger\n set_stop(passenger.destination)\n passenger.on_elevator(Simulator::time, @id)\n advance_elevator_time(LOAD_TIME)\n pickup_count += 1\n true\n end\n end\n advance_elevator_time(DOOR_WAIT_TIME)\n Logger::msg(Simulator::time, LOGGER_MODULE, @id, Logger::INFO, \"picked up #{pickup_count} on #{@floor_idx}\") if !pickup_count.zero?\n pickup_count\n end",
"def call_elevator elevator_number=0\n\t\t@elevators[elevator_number].add_to_floors_to_visit @floor_number\n\tend",
"def Sort()\n\t @flows.sort!{|x,y| x.start<=>y.start}\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 closest_offices = office_locations.near(coordinates, 4000)\n closest_offices += office_locations\n self.sorted_offices = closest_offices.uniq || []\n sorted_offices.blank? ? [] : sorted_offices.each { |office| office.calculate_distance(coordinates) }\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def whois(domain)\n raise InvalidDomainError unless domain.to_s =~ /\\.nz\\z/i\n\n fetch_content domain\n self\n end",
"def whois_output\n return @whois_output if !@whois_output.blank?\n @whois_output = has_domain_and_server? ? server.raw_response!(domain) : ''\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 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 whois\n @whois ||= ::Whois.lookup(name)\n end",
"def ruby_whois (send_string, host)\r\n# p send_string + \" .. \" + host\r\n if host.index(\".\") == nil\r\n host = \"whois.\"+host+\".net\"\r\n end\r\n add_string = \"\"\r\n add_string = \"n \" if host == \"whois.arin.net\"\r\n add_string = \"n ! \" if send_string.index(\"NET\") == 0\r\n s = TCPSocket.open(host,43) \r\n s.write(add_string+send_string+\"\\n\")\r\n ret = \"\"\r\n while s.gets do\r\n ret += $_\r\n end\r\n s.close\r\n return ret\r\n rescue # rescue logic if not found\r\n ret=\"Not found\"\r\n return ret\r\n end",
"def gethost(nick)\n if @users[nick] and @users[nick][:host]\n @users[nick][:host]\n else\n Thread.new do\n sleep(1)\n whois(nick)\n end\n wait_for(type: :code_whoisuser, nick: nick)\n end\n @users[nick][:host]\n end",
"def whois(user)\n make_request(:get, \"/admin/whois/#{user}\").parsed_response\n end",
"def whois\n query = Query.new(@replies[:whois])\n messages = replies_for(query) { @commands.whois(self) }\n\n return @network.implementation::Whois.new(*messages)\n end",
"def whois(n, s=nil)\n @socket << \"WHOIS #{[s,n].compact.join(' ')}\"\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 hook_reply_serv(irc, code, *data)\n \n return unless (whois = @whois[sn = irc.server.name])\n \n case code\n when 318,401 # ERR_NOSUCHNICK / ENDOFWHOIS\n @whois_lock = false\n \n when 311\n whois[:mask] = \"#{data[0]}!#{data[1]}@#{data[2]}\"\n\n # Ident info.\n when @whoisidentified_code[sn] # WHOISIDENTIFIED\n whois[:is_identified] = true\n whois[:account_using_nick] = IRC::Address.normalize(data[1]) # record account name\n end\n \n end",
"def info\n self.class.call('domain.host.info', @hostname)\n end",
"def domain_list\n command = %w(virsh list --all)\n domains = {}\n output, success = run command\n error 'Failed to get domain list! Is you libvirt service running?' unless success\n output.split(\"\\n\").each do |line|\n line_array = line.split\n id = line_array[0]\n name = line_array[1]\n state = line_array[2..-1]\n next unless id and name and state\n id = id.chomp.strip\n name = name.chomp.strip\n state = state.join(' ').chomp.strip\n next if id == 'Id'\n domain_hash = {}\n domain_hash['state'] = state\n domain_hash['id'] = id unless id == '-'\n domains[name] = domain_hash\n end\n domains\n end",
"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 raw_domain_info\n @raw_domain_info ||= query\n end",
"def get_domain_expiration(domain)\n uri = URI('https://jsonwhois.com/api/v1/whois')\n uri.query = URI.encode_www_form(domain: domain)\n req = Net::HTTP::Get.new(uri)\n req['Authorization'] = \"Token token=#{config[:apikey]}\"\n\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|\n http.request(req)\n end\n\n json = JSON.parse(res.body)\n DateTime.parse(json['expires_on'])\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def reprocess_items!\n @path_array = nil\n self.direct_items.each { |item| item.reprocess_child_items! }\n self.children.each { |category| category.reprocess_items! }\n end",
"def collection_edit_tree_recurse(node)\n node['children'].each_with_index do |child, i|\n item = @model.find(child['id'])\n item.update(parent_id: node['id'], sort_order: i)\n\n collection_edit_tree_recurse(child) if child['children']\n end\n end",
"def update_children_if_parent_changed\n if @dirty_parent\n reprocess_items!\n end\n end",
"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 process_root(node)\n node.update(children: node.children.map { |c| accept(c) }.compact)\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 recursively_post_process_tree!(ke)\n # Nothing to do\n end",
"def apply_children\n \n end",
"def rebuild_nested_sets\n\t\troot.send(:perform_tree_rebuild, root.id, 0)\n\tend",
"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 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 walk_and_update_node_children(node, &block)\n node.children = block.call(node.children)\n node.children.map do |n|\n walk_and_update_node_children(n, &block) \n end\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 reprocess_child_items!\n self.child_items.delete_all\n create_child_items\n end",
"def each_with_level &block\n # @todo A bit of a hack that I would like to fix one day...\n @root.attribute(:children).each do |element|\n recursive_each_with_level element, 1, block\n end\n end",
"def nested_li(objects)\n output = \"\"\n path = [nil]\n objects.each do |o|\n if o.parent_id != path.last\n # we are on a new level, did we descend or ascend?\n if path.include?(o.parent_id)\n # remove wrong wrong tailing paths elements\n while path.last != o.parent_id\n path.pop\n output += \"\\n</ul>\"\n end\n else\n path << o.parent_id\n output += \"\\n<ul>\"\n end\n end\n output += \"\\n<li>#{yield o}</li>\"\n end\n #pop off unfinished paths elements\n while path.length > 1\n path.pop\n output += \"\\n</ul>\"\n end\n return output.html_safe\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 wrap(html, &blk)\n each do |j|\n new_parent = Nokogiri.make(html, &blk)\n j.replace(new_parent)\n nest = new_parent\n if nest.child\n nest = nest.child until nest.child.nil?\n end\n j.parent = nest\n end\n self\n end",
"def process_tree_with_renew\n @process_tree = nil\n process_tree\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def test_remove_title_tag\n assert_textile '', '<title>this is the title</title>'\n end",
"def strip_title\n unless self.title.blank?\n self.title = self.title.gsub(/^\\s*/, '')\n end\n end",
"def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end",
"def remove_title(lyric)\n lines = lyric.lines\n lines.shift\n lines = remove_empty_lines_from_beginning(lines)\n lines.join\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 cleanup_title(songLine)\n\t#arrays for storing things to be removed from the title\n\tstop_words = [\" a \", \" an \", \" and \", \" by \", \" for \", \" from \", \" in \", \" of \" , \" on \", \" or \", \" out \", \" the \", \" to \", \" with \"]\n\tremove_pattern = [\"\\(\", \"\\[\", \"\\{\", \"\\\\\", \"\\/\", \"\\_\", \"\\-\", \"\\:\", \"\\\"\", \"\\`\", \"\\+\", \"\\=\", \"\\*\", \"feat\\.\"]\n\n\ttitle = songLine.sub(/^.+>/,'') #extracts song title: replaces every char up to the last '>' character with \"nothing\"\n\t\n\t#loops through title removing anything to the left of the characters (and the characters themselves) from the remove_pattern array\n\tfor i in remove_pattern do\n\t\ttitle = title.sub(/#{Regexp.escape(i)}.*/,'')\n\tend\n\n\ttitle = title.gsub(/[?¿!¡.;&@%#|]/,'') # removes all required punctuation\n\n\tif(title.match(/[^'\\w\\s]/)) #removes all non-english words\n\t\ttitle = ''\n\tend\t\n\n\ttitle = title.downcase #sets title to all lowercase\n\n\n\t#loop to filter out the stop words\n\tfor i in stop_words do\n\t\ttitle = title.sub(i,\" \") # replace stop word with a space character - doesn't account for stop word at start or end of title since these couldnt be caught in infinite loops\n\tend\n\n\treturn title\nend",
"def replace_empty_title\n if self.title == ''\n self.title = \"untitled\"\n end\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 remove_quotes_from_title\n string_title = self.title\n string_title[0] = '' if string_title[0] == '\"' or string_title[0] == \"'\"\n string_title[string_title.length - 1] = '' if string_title.last == '\"' or string_title.last == \"'\"\n self.title = string_title.strip\n nil\n end",
"def is_title\n false\n end",
"def strip_whitespace\n self.title = self.title.strip\n end",
"def set_title_text(title)\n if self.root?\n if @content.nil? || @content.empty? || (lines = @content.split(\"\\n\")).length == 1\n #Set the entire content to the title\n @content = title\n else\n #Set the first line of the content to the title\n @content = lines[1..-1].unshift(title).join(\"\\n\")\n end\n title\n end\n end",
"def strip_subtitle\n URLify.strip_subtitle(self)\n end",
"def cleanup_title(line)\nbegin\n\t\tline += \"\\n\"\t\t\t# Add the endline character back after spliting on it\n\n\t\t# Force the encoding to utf-8 to avoid issues with non english characters\n\t\tline.force_encoding 'utf-8'\n\n\t\t# do something for each line\n\t\t# use regexp to remove junk before the title\n\t\tbefore_title_re = /.*>/\n\t\tline.sub!(before_title_re, \"\")\n\t\ttitle = line\n\n\t\t# us regexp to remove junk after main song title\n\t\tafter_title_re = /(\\(|\\[|\\{|\\\\|\\/|_|-|:|\"|`|\\+|=|\\*|feat\\.).*/\n\t\ttitle.sub!(after_title_re, \"\")\n\n\t\t# Remove punctuation from titles, perform global replace (gsub!)\n\t\t# Remove ? ¿ ! ¡ . ; & @ % # |\n\t\tpunc_re = /(\\?|¿|!|¡|\\.|;|&|@|%|#|\\|)/\n\t\ttitle.gsub!(punc_re, \"\")\n\n\t\t# Remove non english characters by finding all lines with only desired characters\n\t\tenglish_re = /^(\\w|'|\\s)+\\n$/\n\t\tif line =~ english_re\n\t\t\tvalid = true\n\t\telse\n\t\t\t# If the line contains non english characters, set it to nil and change\n\t\t\t# the valid flag to false\n\t\t\tvalid = false\n\t\t\tline = nil\n\t\tend\n\n\t\t# Only continue processing if valid is true\n\n\t\ttitle.downcase! if valid\t# Set to lowercase if the line is valid\n\n\t return title\t\t\t\t\t\t\t# return the processed title (can be nil)\n\n\trescue\n\t\tSTDERR.puts \"Could not open file\"\n\t\texit 4\n\tend \t\t# end rescue\nend",
"def normalise_title(raw_title)\n TitleNormaliser.normalise_title(raw_title)\n end",
"def strip_blanks\n self.title = self.title.strip\n end",
"def generate_law_title\n text = self.description.dup\n text = self.name.dup if !text.present?\n\n remove = []\n remove << self.registration_number_original if self.registration_number_original.present?\n remove << self.law_description if self.law_description.present?\n remove << PREFIX\n remove << POSTFIX \n\n remove.flatten.each do |x|\n text.gsub!(x, '')\n end\n if text.present?\n self.law_title = text if text.present?\n else\n self.law_title = self.name\n end\n end",
"def set_title\n self.title = File.basename(original_filename.to_s, ext) if title.blank?\n end",
"def uniquify\n super\n self.short_title = title\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Queue a verify API call in the Hydra. | def valid?
@hydra.queue(request('verify'))
end | [
"def verify_callback(*) end",
"def verify!\n do_verification(:abort_process)\n end",
"def add_verify(&block)\n @verify_function = block\n end",
"def verify\n @bathroom.verify\n end",
"def mock_verify\n @mock.mock_verify\n end",
"def verify_call(*args)\n validate_eligible\n validate_order\n validate_signature(args)\n @actual_count += 1\n perform_yielding(args)\n return_value(args)\n end",
"def verify payload\n 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 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 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_signature\n verify_with_certificates []\n end",
"def verify_callback=(verify_callback); end",
"def verify\n account = Account.find_by_id_and_verification_key(params[:id], params[:verification_key])\n if account\n if account.is_pending_activation?\n account.activate!\n else\n account.is_not_pending_recovery!\n end\n head :ok\n else\n head :not_found\n end\n end",
"def verify(domain)\n Mailgun.submit :put, \"#{domain_url(domain)}/verify\"\n end",
"def flexmock_verify\n flexmock_created_mocks.each do |m|\n m.flexmock_verify\n end\n end",
"def check verify = false, add_lease = false\n data = Net::HTTP.start(@server_url.host, @server_url.port) do |http|\n http.read_timeout = 7200\n response, data = http.post \"/uri/#{cap}?t=check&verify=#{verify}&add-lease=#{add_lease}&output=JSON\", nil\n data\n end\n data = JSON.parse data\n data[\"results\"]\n end",
"def add_api_verifier; end",
"def verify(target_dir = '.')\n initialize_commands\n apply_globals\n @wire_commands.run_verify(target_dir)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def total_payment\r\n checks.inject(0.00){|sum, check| sum += check.check_amount.to_f}\r\n end",
"def update_total_amount\n sum = 0\n @items.each do |item|\n sum += item.get_price\n end\n @total_amount = sum\n @net_payable = @total_amount\n end",
"def total_amount\n t = amount\n t += sub_transactions.sum(:amount) if recurring_period\n t\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 total_paid\n total = 0\n self.paid.each do |coin, how_many|\n total += coin * how_many\n end\n total\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_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_sum\n total = 0\n self.purchases.each do |purchase|\n sum = 0\n purchase.items.each do |item|\n sum += item.amount\n end\n total += sum\n end\n total\n end",
"def total\n all_amount = @items.map(&:price).sum\n all_adjustments = @adjustments.sum { |a| a[:amount] }\n\n all_amount + all_adjustments\n end",
"def amount_paid\n accepted_payments.sum(:amount).to_f\n end",
"def total_price\n @total_price ||= sum_price - active_discounts.map(&:amount).inject(&:+)\n end",
"def sum\n total = 0.0\n discounts = apply_specials.flatten\n Transactions.where(checkout_id: @checkout_id).each do |t|\n total += Product[id: t[:product_id]][:price]\n end\n discounts.each do |d|\n total -= d[:price]\n end\n total.round(2)\n end",
"def get_total_fee\r\n @meeting_fee + get_events_fee + get_relays_fee\r\n end",
"def set_total_and_amount_available\n if self.account_movement_payments.any? ##no todos los movimientos tienen pagos\n unless confirmado?\n self.total = self.account_movement_payments.user_payments.sum(:total) ##el total del movimiento no debe cambiar para un mov confirmado\n end\n self.amount_available = self.total - self.account_movement_payments.system_payments.sum(:total)\n end\n end",
"def sum_payments\n contracts.sum{ |c| c.payments.sum(&:amount)}\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 paid_total\n components.reject {|c| c.kind == 'bonus'}.reduce(SpookAndPuff::Money.zero){|a, c| a + c.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 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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mount_command :: string > string | def mount_command(path)
"udisksctl mount --block-device #{path}"
end | [
"def guest_mount(guest_device)\n\t\tssh('mount', guest_device, VMMountPoint)\n\tend",
"def mount! volume\n return :mounted if successful_remote_command?(\"mount #{volume.device} #{volume.mount_point}\")\n end",
"def pipe_to(command1, command2) \n command1 + ' | ' + command2 \n end",
"def mount(mount_name, params)\n dupe_check!(mount_name, params)\n local = mkmountpoint(params[:local])\n volname = params[:volname] || mount_name\n cmd = \"#{sshfs_cmd} \" \\\n \"#{Shellwords.escape(params[:remote])} \" \\\n \"#{Shellwords.escape(local)} \" \\\n \"-o volname=\\\"#{Shellwords.escape(volname)}\\\" \" \\\n \"#{SSHFS_FLAGS.join(' ')} \" \\\n \"-p #{(params[:port] || 22).to_i}\"\n puts \"Mounting \\\"#{mount_name}\\\"\\n\" \\\n \" * #{params[:remote]} on #{local} as \\\"#{volname}\\\"\"\n STDERR.puts \"> #{cmd}\" if @verbose\n system(cmd)\n end",
"def storage_mount\n unless @storage[:mounted].nil? || @storage[:mounted] == true\n system(@storage[:mount_command])\n end\n\n @storage[:mounted] = true unless @storage[:mounted].nil?\n @storage[:awake] = true unless @storage[:awake].nil?\n end",
"def mount(device, directory, options = '')\n FileUtils.mkdir_p(directory)\n\n cmd = \"#{COMMANDS[:mount]} #{device} #{directory}\"\n cmd << \" -o #{options}\" unless options.empty?\n\n Command.execute_rc_log(cmd)\n end",
"def exec_command(command, packet)\n\n begin\n\t result = `#{command}`\n\trescue Exception => e\n\t result = e.to_s\n\tend \n\t \n\t#send result back to client\n\tsend_data(result, packet)\n\t\n\tlisten()\n\t\nend",
"def mount_to(path)\n opt(:mount, path)\n end",
"def shell_command(command)\n s = command.map {|word| shell_single_word(word) }.join(' ')\n ShellEscaped.new_no_dup(s)\n end",
"def shell!(command)\n system(devbox_command(command)) || raise(\"Command failed: #{command}\")\n end",
"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 fetch_command(command); end",
"def split_commands(cmd_line); end",
"def shell_command(command)\n command.map {|word| shell_single_word(word) }.join(' ')\n end",
"def remount_with_option(option)\n options = if using_explicit_options?\n self.options + ',' + option\n else\n option\n end\n mountcmd '-o', options, resource[:name]\n end",
"def sh command\n system command\n end",
"def execute_command(command)\n raw(*command)\n end",
"def shell_commands(cmd, args); end",
"def pipe_file(command, input = nil, output = nil) \n res = command\n res << \" <#{input}\" if input and not input.empty?\n res << \" >#{output}\" if output and not output.empty?\n res\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
unmount_command :: string > string | def unmount_command(path)
"udisksctl unmount --block-device #{path}"
end | [
"def unmount! volume\n return :unmounted if successful_remote_command?(\"umount #{volume.device}\")\n end",
"def unmount(mount_name, params)\n local = Pathname.new(params[:local]).expand_path\n info = active_mounts[local]\n raise \"No active mount-point found for #{local}\" if info.nil?\n STDERR.puts \"No active SSHFS process found for #{local}\" if info[:pid] == \"None found\"\n cmd = \"umount #{Shellwords.escape(local)}\"\n puts \"Unmounting \\\"#{mount_name}\\\" (#{local})\"\n STDERR.puts \"> #{cmd}\" if @verbose\n raise \"Unmount error, skipping removal of mount-point.\" unless system(cmd)\n rmmountpoint(local)\n end",
"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 unmount_device(device)\n Chef::Log.info \"Unmounting #{device} from #{MOUNT_POINT}\"\n execute_command(\"umount #{MOUNT_POINT}\")\n end",
"def unmount(path)\n client.delete(\"/v1/sys/mounts/#{encode_path(path)}\")\n return true\n end",
"def unmount_device(device, mount_point)\n Chef::Log.info \"Unmounting #{device} from #{mount_point}\"\n execute_command(\"umount #{mount_point}\")\n end",
"def umount_mount(resource_name)\n ChefSpec::Matchers::ResourceMatcher.new(:mount, :umount, resource_name)\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 detach\n execute %(hdiutil detach \"#{mount_path}\")\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 delete_packer_vbox_disk(options)\n vdi_file = options['clientdir']+\"/packer/\"+options['vm']+\"/\"+options['name']+\"/images/\"+options['name']+\".vdi\"\n message = \"Information:\\tDetermining UUID for VDI file for #{options['name']}\"\n command = \"#{options['vboxmanage']} list hdds |egrep '^Location|^UUID' |grep -2 '#{vdi_file}'\"\n output = execute_command(options,message,command)\n if output.match(/#{vdi_file}/)\n disk_uuid = output.split(\"\\n\")[0].split(\":\")[1].gsub(/\\s+/,\"\")\n message = \"Information:\\tDeleting VDI file for #{options['name']}\"\n command = \"#{options['vboxmanage']} closemedium disk #{disk_uuid} --delete\"\n execute_command(options,message,command)\n end\n return\nend",
"def umount(mountpoint)\n puts \"Hänge Drive aus\"\n system(\"umount #{mountpoint}\") or fail \"Konnte Drive nicht aushängen\"\n end",
"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 volume_mount_unmount?(instance, username, volume)\n mount = INSTANCE_VOLUME_MOUNT_POINT\n file_name = VOLUME_TEST_FILE_NAME\n file_contents = VOLUME_TEST_FILE_CONTENTS\n vdev = @volume_service.volumes.find_by_id(volume.id)\n .attachments.first['device']\n vdev << '1'\n\n log_partitions(instance, username)\n\n commands = [\n [\"echo -e \\\"127.0.0.1\\t$HOSTNAME\\\" | sudo tee -a /etc/hosts\", nil], # to fix problems with sudo and DNS resolution\n ['sudo partprobe -s', nil],\n [\"[ -d '#{mount}' ] || sudo mkdir #{mount}\", ''],\n [\"sudo mount #{vdev} #{mount}\", ''],\n [\"sudo sh -c 'echo -n #{file_contents} > #{mount}/#{file_name}'\", ''],\n [\"sudo cat #{mount}/#{file_name}\", file_contents],\n [\"sudo umount #{mount}\", '']\n ]\n\n error_log(instance.logger, 'info', \"Mounting volume '#{volume.name}' (#{volume.id})...\", true)\n\n error_log(instance.logger, 'info', 'Mounting from inside the instance...', true)\n with_ssh(instance, username) do |ssh|\n commands.each do |command, expected|\n result = ssh.exec!(command).chomp\n if expected.nil?\n error_log(instance.logger, 'info', \"#{command} yielded '#{result}'\")\n elsif result != expected\n error_log(\n instance.logger,\n 'error',\n \"Failure while running '#{command}':\\n\\texpected '#{expected}'\\n\\tgot '#{result}'\",\n true\n )\n return false # returns from volume_mount_unmount?\n end\n end\n end\n true\n end",
"def umount(path)\n execute(\"umount --lazy #{path}\")\n FileUtils.rm_rf(\"#{mount_point}/#{path}\")\n end",
"def remove_command(name)\n @embedded_commands.delete(name.to_sym)\n end",
"def vmunmount\n raise \"No VM currently mounted\" if !@vm\n @vm.unmount\n @vm = nil\n @vmRoot = nil\n end",
"def cleanup_cmd\n #Empty the previous local transfer folder\n FileUtils.rm_rf(config[:local_transfer_path]) if config[:local_transfer_path]\n\n case shell\n when \"bourne\"\n cmd = [\n sudo(\"rm -rf #{config[:remote_transfer_path]}\"),\n sudo(\"mkdir -p #{config[:remote_transfer_path]}\"),\n sudo(\"chmod 777 #{config[:remote_transfer_path]}\")\n ].join(\"\\n\").concat(\"\\n\").gsub(/^ {10}/, '')\n\n when \"powershell\"\n cmd = <<-CMD.gsub(/^ {10}/, \"\")\n rmdir -Recurse -Force -ea 0 #{config[:remote_transfer_path]} | out-null\n exit 0\n CMD\n else\n raise \"[#{self}] Unsupported shell: #{shell}\"\n end\n Util.wrap_command(cmd, shell)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def index\n @testers = Tester.all\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 list\n http.get(\"/takers\") do |response|\n respond_with_collection(response)\n end\n end",
"def index\n @test_takers = TestTaker.all.page(params[:page]).per(10)\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 viewers\n stats = Stats.new(\"Success\", params[:code], {\n viewers: @link.viewers\n })\n render json: stats\n end",
"def index\n render status: :ok, json: @tests\n end",
"def index\n @teachers = Teacher.all\n render json: @teachers\n end",
"def index\n @testjsons = Testjson.all\n end",
"def index\n @tees = Tee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tees }\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 @testbed = Testbed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testbed }\n end\n end",
"def index\n @beers = Beer.all\n\n render json: @beers\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 beers_list\n \t@url = 'https://api.punkapi.com/v2/beers' \t\t\n \tresponse = RestClient.get beer_url\n \tjson_response = JSON.parse response.body\n\n \tcreate_list = ::Beers::Create.call(\n \t\tuser: @current_user,\n \t\tbeers_data: json_response\n \t)\n \t\n \trender json: create_list.beers, adapter: :json_api, each_serializer: BeerSerializer\n end",
"def all_runners(options = {})\n get('/runners/all', query: options)\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @requesters = Requester.all\n end",
"def index\n @teachers = Teacher.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teachers }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def new\n @newtest = Newtest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @newtest }\n end\n end",
"def new\n @testbed = Testbed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testbed }\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 new\n @testspec = Testspec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testspec }\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 @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\r\n @peter = Peter.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @peter }\r\n end\r\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 @test_team = TestTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_team }\n end\n end",
"def new\n @old_test_case = OldTestCase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @old_test_case }\n end\n end",
"def new\n @selftest = Selftest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selftest }\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 @creator = Creator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @creator }\n end\n end",
"def create\n @newtest = Newtest.new(params[:newtest])\n\n respond_to do |format|\n if @newtest.save\n format.html { redirect_to @newtest, :notice => 'Newtest was successfully created.' }\n format.json { render :json => @newtest, :status => :created, :location => @newtest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @newtest.errors, :status => :unprocessable_entity }\n end\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 @specimen_test = SpecimenTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specimen_test }\n end\n end",
"def new\n @pest = Pest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pest }\n end\n end",
"def new\n @one_test = OneTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @one_test }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def update\n respond_to do |format|\n if @test_taker.update(test_taker_params)\n format.html { redirect_to @test_taker, notice: 'Test taker was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_taker }\n else\n format.html { render :edit }\n format.json { render json: @test_taker.errors, status: :unprocessable_entity }\n end\n end\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 update\n @one_test = OneTest.find(params[:id])\n\n respond_to do |format|\n if @one_test.update_attributes(params[:one_test])\n format.html { redirect_to @one_test, notice: 'One test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testjson.update(testjson_params)\n format.html { redirect_to @testjson, notice: 'Testjson was successfully updated.' }\n format.json { render :show, status: :ok, location: @testjson }\n else\n format.html { render :edit }\n format.json { render json: @testjson.errors, status: :unprocessable_entity }\n end\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_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 update\n @selftest = Selftest.find(params[:id])\n\n respond_to do |format|\n if @selftest.update_attributes(params[:selftest])\n format.html { redirect_to @selftest, notice: 'Selftest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @selftest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testbed = Testbed.find(params[:id])\n\n respond_to do |format|\n if @testbed.update_attributes(params[:testbed])\n format.html { redirect_to @testbed, notice: 'Testbed was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testbed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testspec = Testspec.find(params[:id])\n\n respond_to do |format|\n if @testspec.update_attributes(params[:testspec])\n format.html { redirect_to @testspec, notice: 'Testspec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testspec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_runner(runner, options = {})\n put(\"/runners/#{runner}\", body: options)\n end",
"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\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to tests_path, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specimen_test = SpecimenTest.find(params[:id])\n\n respond_to do |format|\n if @specimen_test.update_attributes(params[:specimen_test])\n format.html { redirect_to @specimen_test, notice: 'Specimen test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specimen_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n\n redirect_to :action => :index\n end",
"def update\n if @testset.update(testset_params)\n render :show, status: :ok\n else\n render json: @testset.errors, status: :unprocessable_entity\n end\n end",
"def update\n @teams_test = TeamsTest.find(params[:id])\n\n respond_to do |format|\n if @teams_test.update_attributes(params[:teams_test])\n format.html { redirect_to @teams_test, notice: 'Teams test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @teams_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_friendship\n login_as(:jane)\n put :update, :user_id => users(:jane).id, :id => 1, :friendship => { }\n\n assert_response :success\n end",
"def update\n beer = Beer.find(params[:id])\n beer.update(beer_params)\n render json: beer\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def destroy\n @one_test = OneTest.find(params[:id])\n @one_test.destroy\n\n respond_to do |format|\n format.html { redirect_to one_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_path }\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 @testbed = Testbed.find(params[:id])\n @testbed.destroy\n\n respond_to do |format|\n format.html { redirect_to testbeds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @drontest.destroy\n respond_to do |format|\n format.html { redirect_to drontests_url, notice: 'Drontest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_taker.destroy\n respond_to do |format|\n format.html { redirect_to test_takers_url, notice: 'Test taker 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 }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mineral_test.destroy\n respond_to do |format|\n format.html { redirect_to mineral_tests_url, notice: 'Mineral test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_test = UserTest.find(params[:id])\n @user_test.destroy\n\n respond_to do |format|\n format.html { redirect_to user_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @selftest = Selftest.find(params[:id])\n @selftest.destroy\n\n respond_to do |format|\n format.html { redirect_to selftests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rest_test = RestTest.find(params[:id])\n @rest_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(rest_tests_url) }\n format.xml { head :ok }\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 @back_bone_test = BackBoneTest.find(params[:id])\n @back_bone_test.destroy\n\n respond_to do |format|\n format.html { redirect_to back_bone_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing_.destroy\n respond_to do |format|\n format.html { redirect_to testing_s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diagnostic_test = DiagnosticTest.find(params[:id])\n @diagnostic_test.destroy\n\n respond_to do |format|\n format.html { redirect_to client_diagnostic_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @personal_test = PersonalTest.find(params[:id])\n @personal_test.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mytest = Mytest.find(params[:id])\n @mytest.destroy\n\n respond_to do |format|\n format.html { redirect_to mytests_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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 heartbeat_start\n @heart = Thread.new do\n Logging.ndc.clear\n Logging.ndc.push('heartbeat-thread')\n while true\n notify_change('test_alive')\n sleep(@config_manager['test.heartbeat.frequency'])\n end\n Logging.ndc.pop\n end\n end",
"def heartbeat\n end",
"def start_heartbeat\n @heartbeat = @server_heartbeat.accept\n if Heartbeat::THREADSAFE\n @heartbeat_thread = Heartbeat.new(self, @heartbeat)\n else\n ended_file # Cache this file name before forking\n @heartbeat_pid = fork do\n loop do\n begin\n @heartbeat.write(\"OK\\n\")\n rescue Errno::EPIPE => e\n if File.exist?(ended_file)\n FileUtils.rm_f(ended_file)\n exit 0\n else\n if monitor_running?\n Origen.log.error 'Communication with the simulation monitor has been lost (though it seems to still be running)!'\n else\n Origen.log.error 'The simulation monitor has stopped unexpectedly!'\n end\n exit 1\n end\n end\n sleep 5\n end\n end\n end\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 start_heart_beat\n if threading?\n Thread.abort_on_exception = true\n @heart_beat ||= Thread.new &run_loop\n else\n run_loop.call\n end\n end",
"def process_heartbeat\n if Time.now > @next_heartbeat\n send_heartbeat()\n @next_heartbeat = next_heartbeat\n end\n nil\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_heartbeat(frequency = HEARTBEAT_FREQUENCY)\n require \"eventmachine\"\n \n EM.next_tick do\n EM::PeriodicTimer.new(frequency) do\n Bountybase.metrics.heartbeat!\n end\n end\n end",
"def update_heartbeat\n if @heartbeat_updated_at.nil? || elapsed(@heartbeat_updated_at) >= HEARTBEAT_FREQUENCY\n queue.record_worker_heartbeat\n @heartbeat_updated_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n end\n end",
"def run\n unless @heartbeat_type == :none\n super\n end\n end",
"def send_heartbeat\n send_message DCell::Message::Heartbeat.new\n @heartbeat = after(self.class.heartbeat_rate) { send_heartbeat }\n end",
"def start_listener_thread\n polling_interval = MQ_CONFIG['preservation']['polling_interval_in_minutes']\n Thread.new do\n while true\n initialize_listeners\n logger.debug \"Going to sleep for #{polling_interval} minutes...\"\n sleep polling_interval.minutes\n end\n end\n #I've read here: https://www.agileplannerapp.com/blog/building-agile-planner/rails-background-jobs-in-threads\n #that each thread started in a Rails app gets its own database connection so when the thread terminates we need\n #to close any database connections too.\n ActiveRecord::Base.connection.close\nend",
"def initialize(server)\n queue_prefix = config['prefix'] || ''\n @server = server\n @thread = Thread.new do\n if defined?(java.lang.Thread)\n java.lang.Thread.current_thread.name = 'Heartbeat'\n end\n \n loop do\n with_queue(\"#{queue_prefix}heartbeat\") do |heartbeat_queue|\n logger.debug \"Send heartbeat\"\n message = {\n 'host_info' => host_info,\n 'timestamp' => Time.now.utc,\n 'running_daemons' => @server.daemons.length\n }\n heartbeat_queue.send_message(Base64.encode64(message.to_json))\n sleep(60)\n end\n end\n end\n end",
"def setup_helpers\n Heartbeat.start\n SignalHandler.start\n end",
"def start\n run_server\n accept_clients\n end",
"def start_listener_thread\n polling_interval = MQ_CONFIG['preservation']['polling_interval_in_minutes']\n logger.debug \"Starting listener treads\"\n t = Thread.new do\n while true\n initialize_listeners\n logger.debug \"Going to sleep for #{polling_interval} minutes...\"\n sleep polling_interval.minutes\n end\n end\n logger.debug t.group.inspect\n logger.debug \"num_of_threads = #{t.group.list.size}\"\n #I've read here: https://www.agileplannerapp.com/blog/building-agile-planner/rails-background-jobs-in-threads\n #that each thread started in a Rails app gets its own database connection so when the thread terminates we need\n #to close any database connections too.\n ActiveRecord::Base.connection.close\nend",
"def send_heartbeat\n if tcp_connection_established? && !@handling_skipped_hearbeats && @last_server_heartbeat\n if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2)) && !reconnecting?\n logger.error \"[amqp] Detected missing server heartbeats\"\n self.handle_skipped_hearbeats\n end\n send_frame(Protocol::HeartbeatFrame)\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def on_restart(&block); end",
"def restart!\n CouchRest.post \"#{@uri}/_restart\"\n rescue RestClient::ServerBrokeConnection\n # Shouldn't really happen, but does in CouchDB 1.0.0\n end",
"def restart_server\n stop_server\n sleep 1\n start_server\n end",
"def restart_soon\n @restart = true\n @shutdown = true\n end",
"def on_hangup\n\t\tself.log.info \"Hangup signal.\"\n\t\tself.restart\n\tend",
"def restart!\n CouchSpring.post \"#{uri}/_restart\"\n end",
"def heartbeat\n end",
"def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end",
"def restart()\n shutdown()\n start()\n end",
"def restart\n @timer = VM.tick # Generate an event immediately after restart\n end",
"def restart\n\t\tself.restarting = true\n\t\tself.log.warn \"Restarting...\"\n\n\t\tif Symphony.config.reload\n\t\t\tself.log.info \" config reloaded\"\n\t\telse\n\t\t\tself.log.info \" no config changes\"\n\t\tend\n\n\t\tself.log.info \" resetting queue\"\n\t\tSymphony::Queue.reset\n\t\tself.queue.shutdown\n\tend",
"def restart\n return true if @shutdown == false\n @log.info self.class.to_s + \": Restarting after shutdown\"\n @shutdown = false\n start_threads(@num_threads)\n end",
"def server_restart(shell)\n shell.status \"Restarting Mongrel(s) ...\"\n\n mongrel_cluster 'cluster::restart'\n\n shell.status \"Mongrel(s) restarted.\"\n end",
"def shutdown\n\t\tself.stop_heartbeat\n\t\tsuper\n\tend",
"def drb_restart!\n Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }\n end",
"def restart!\n CouchDB.post \"#{uri}/_restart\"\n 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 request(:restart)\n end",
"def restart!\n JobRestarter.restart(self)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called by Mongrel2::Handler when the server is shut down. Overridden to stop the heartbeat thread. | def shutdown
self.stop_heartbeat
super
end | [
"def stop_heartbeat\n\t\t@heartbeat[ :shutdown ] = true\n\t\t@heartbeat.run.join if @heartbeat.alive?\n\tend",
"def heartbeat_stop\n @heart.kill\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\t\tmonitor_thread.kill\n\tend",
"def stop\n return unless running?\n\n # If stopping the server takes too much time, just kill\n # the thread directly.\n begin\n Timeout.timeout(5) do\n Application.quit!(@thread[:server], @thread[:handler_name])\n end\n rescue; end\n\n @thread.kill\n @notifier.terminate\n Application.clear_connections\n Celluloid::Logger.info('Celluloid::Dashboard server stopped.')\n end",
"def shutdown\n @server.shutdown\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( reason=\"No reason given.\" )\n\t\tself.reset_signal_handlers\n\t\tself.log.warn \"Server shutdown: #{reason}\"\n\n\t\t@connections.keys.each do |addr|\n\t\t\tconn = @connections.delete( addr )\n\t\t\tself.stop_observing( conn.session )\n\t\t\tVerse.terminate_connection( addr, reason )\n\t\tend\n\n\t\t@state = :shutdown\n\tend",
"def drb_stop!\n Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }\n end",
"def stop\n @server.stop if @server.running?\n end",
"def teardown!\n @server.stop if @server.running?\n end",
"def shutdown\n stop\n @webrick.shutdown\n end",
"def shutdown\n client.deregister_inbound_handler(Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpServerChannel)\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 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 @snmptrap.exit\n end",
"def stop \r\n DRb.stop_service\r\n @log.info(\"DRb server stopped on : #{@drb_server_uri}\") \r\n end",
"def server_stop\n Process.kill 'INT', 0\n end",
"def shutdown!\n @manager.disconnect(@raw_conn)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def cull_idle_sockets\n\t\tself.log.debug \"Culling idle sockets.\"\n\n\t\tearliest = Time.now - SOCKET_IDLE_TIMEOUT\n\n\t\tself.connections.each do |(sender_id, conn_id), lastframe|\n\t\t\tnext unless earliest > lastframe\n\n\t\t\t# Make a CLOSE frame\n\t\t\tframe = Mongrel2::WebSocket::Frame.close\n\t\t\tframe.set_status( CLOSE_EXCEPTION )\n\n\t\t\t# Use the connection directly so we can send a frame and close the\n\t\t\t# connection\n\t\t\tself.conn.reply( frame )\n\t\t\tself.conn.send_close( sender_id, conn_id )\n\t\tend\n\tend",
"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 kill_dead_connections\n Thread.new do\n loop do\n @threads.delete_if do |t|\n if Time.now - t[:stamp] > 400\n t[:socket].close\n t.kill\n debug \"[DEBUG] Killed inactive connection.\"\n true\n end\n end\n sleep 20\n end\n end \n end",
"def disconnect\n raise \"Not connected!\" unless @socket\n @socket.close\n @socket = nil\n end",
"def disconnect\n @thread.kill\n @socket.close\n end",
"def kill_dead_connections\n Thread.new do\n loop do\n @threads.delete_if do |t|\n if ((Time.now.to_i - t[:stamp].to_i) > @options.timeout.to_i)\n t[:session].print \"421 Connection Timed Out - open a new connection\" << LNBR unless t[:session].nil?\n t.kill\n t = nil\n true\n end\n end\n puts \"Open Threads in @threads: \" + @threads.inspect\n puts \"Open Threads: \" + Thread.list.inspect\n sleep (@options.timeout.to_i / 5)\n end\n end \n end",
"def close_stale_sockets!\n check_count_invariants\n return unless max_idle_time\n\n mutex.synchronize do\n i = 0\n while i < queue.length\n connection = queue[i]\n if last_checkin = connection.last_checkin\n if (Time.now - last_checkin) > max_idle_time\n connection.disconnect!\n queue.delete_at(i)\n @pool_size -= 1\n next\n end\n end\n i += 1\n end\n end\n ensure\n check_count_invariants\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 socket_disconnected\n end",
"def stop!(timeout = 2.00)\n @listeners.each do |k, v|\n @@protocols[k].stop!(v)\n end\n \n # If there are connections still registered, let those close before\n # we kill the server.\n accum, step = 0, 0.2\n unless @connections.empty?\n EM.add_periodic_timer(step) do\n EM.stop if @connections.empty? || accum >= timeout\n accum += step\n end\n else\n EM.stop if EM.reactor_running?\n end\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 disconnect\n close_connection_after_writing\n change_state STATE.Disconnecting\n create_timer(2) do\n # if connection is not disconnected within 2s, set state as disconnected\n change_state STATE.Disconnected unless disconnected?\n end\n end",
"def disconnect\n EM.next_tick { @connection.close_connection }\n end",
"def disconnect(send_msg = true)\n # Stop reading packets from the socket first\n @read_thread.kill if @read_thread && @read_thread.alive?\n @read_thread = nil\n\n return unless connected?\n\n # Close the socket if it is open\n if send_msg\n packet = MQTT::Packet::Disconnect.new\n send_packet(packet)\n end\n @socket.close unless @socket.nil?\n handle_close\n @socket = nil\n end",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def clear_connections\n # Using a SymbolProc here does not work\n # rubocop:disable Style/SymbolProc\n self.class.c_locker.synchronize { self.class.io_connection_dic.delete_if { |c| c.closed? } }\n # rubocop:enable Style/SymbolProc\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 ProxyMachine.inactivity_error_callback.call(@remote.join(':'))\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def ping_all_sockets\n\t\tself.log.debug \"Pinging all connected sockets.\"\n\n\t\tself.connections.each do |(sender_id, conn_id), hash|\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 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 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 send_all(message)\n @clients.each do |websocket, client|\n websocket.send message\n end\n puts \"send_all: #{message}\"\n end",
"def ping(args)\r\n @server.write('PONG :' + args[:id])\r\n @pings += 1\r\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 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_ping\n ping = Ping.new(identity, status_proc.call, identity)\n amq.fanout('heartbeat', :no_declare => true).publish(dump_packet(ping))\n end",
"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 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 flush(timeout=10)\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 MonotonicTime::with_nats_timeout(timeout) do\n pong.wait(timeout)\n end\n end\n end",
"def send_pong!\n _send_frame(:pong)\n end",
"def ping data=nil\n encode data, PING\n end",
"def send_handshake\n @socket.puts({id: @id, bot_count: @bots.size }.to_json)\n end",
"def pong\n to_send = [ 0b10001010, 0, \"\" ]\n @connection.write to_send.pack \"C2A0\"\n end",
"def send_pong\n sender = WebSocket::Frame::Outgoing::Server.new(version: @handshake.version, type: :pong)\n write(sender.to_s)\n end",
"def handle_ping(client, ccf)\n @socket.send_strings [client, ccf, PONG]\n end",
"def ping\n subscribe(PING_CHANNEL).callback {\n unsubscribe(PING_CHANNEL)\n }\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def validate_pattern_type(v); end",
"def is_string_or_regexp!(obj, obj_name)\n allow!(obj, [String, Regexp], \"#{obj_name} should be a String or Regexp\")\n end",
"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_regex; end",
"def validate_data_validation_type(v); end",
"def validate_regexp(value)\n Regexp.new(value)\n rescue RegexpError => e\n raise ValidationError, \"invalid regexp: #{e.message}\"\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 validate( value )\n @base_type ? @base_type.validate(internalize(value)) : true\n end",
"def validate_types obj, val_type, path\r\n type = get_object_type obj\r\n case val_type\r\n when :integer\r\n if type == :integer\r\n return\r\n end\r\n when :number\r\n if type == :integer || type == :number\r\n return\r\n end\r\n when :string\r\n if type == :string\r\n return\r\n end\r\n # when :nil # mikan\r\n # when :bool # mikan\r\n else # object or fixed string\r\n if val_type.kind_of? String\r\n # val is specified by String\r\n if type == :string\r\n if obj == val_type\r\n return\r\n end\r\n end\r\n else\r\n if type.to_sym == val_type\r\n validate_object( obj, val_type, path + val_type.to_s )\r\n return\r\n end\r\n end\r\n end\r\n error( \"#{path}: type mismatch, #{type} for #{val_type}\\n\" )\r\n end",
"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 is_string_or_regexp!(obj, obj_name)\n if !obj.is_a?(String) && !obj.is_a?(Regexp)\n raise ArgError, \"#{obj_name} should be a String or Regexp\"\n end\n end",
"def validate_format_of( value, regex, caller_options = {} )\n options = @@options.merge( caller_options )\n\n return options[:allow_nil] if value.nil?\n\n return true if regex.match( value.to_s ) rescue Exception\n\n return false\n end",
"def verify_types(test_data)\n test_types = test_data[CoreOrgData::ORG_RECORD_TYPES.name]\n errors = []\n test_types = [{CoreOrgData::ORG_RECORD_TYPE.name => ''}] unless test_types\n test_types.each do |test_type|\n index = test_types.index test_type\n text_values_match?(test_type[CoreOrgData::ORG_RECORD_TYPE.name], element_value(org_record_type_input(index)), errors)\n end\n errors\n end",
"def validated_parser_type(type); end",
"def validate_parameter_value_by_type\n has_validation_error = false\n case self.parameter_type\n when 'String'\n unless self.parameter_value.start_with?('\"') && self.parameter_value.end_with?('\"')\n has_validation_error = true\n end\n when 'Int'\n unless self.parameter_value.is_a?(Integer)\n has_validation_error = true\n end\n when 'Float'\n unless self.parameter_value.is_a?(Float)\n has_validation_error = true\n end\n when 'File'\n unless self.parameter_value.start_with?('\"gs://')\n has_validation_error = true\n end\n else\n true # complex data types are too complicated to validate, so punt\n end\n if has_validation_error\n errors.add(:parameter_value, \"is not a valid #{self.parameter_type} value: #{self.parameter_value}.\")\n end\n end",
"def song_type_valid_format\n if song_type.present? and not song_type.match(/^(?:[^\\W_]|\\s)*$/)\n errors.add :genere_name , \"must not contain any special characters.\"\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def check_nonce(p0) end",
"def valid_nonce?\n !request.check_nonce(response.basic).zero?\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_nonce(secret_key, request, value, seconds_to_timeout = T.unsafe(nil)); end",
"def valid?\n UUID_REGEX.match?(uuid)\n 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?\n UUID_REGEX.match?(uuid)\n end",
"def has_nonce?\n nonce && !nonce.to_s.empty?\n end",
"def verify_donor # {email: '*@*.com', last_4: '1234', exp_month: '4', exp_year: '2014'}\n if auth = params[:donor_verification]\n subscriber = Subscriber.where(email: auth[:email].to_s).includes(:donor).first\n donor = subscriber.try(:donor)\n if donor && donor.card && (Rails.env.development? || donor.card.valid_credentials?(auth[:last_4], auth[:exp_month], auth[:exp_year]))\n @current_subscriber = subscriber\n set_subscriber_cookie(@current_subscriber, (Rails.env.development? ? :development : :card))\n true\n else\n false\n end\n else\n false\n end\n end",
"def check_nonce\n @oauth_nonce = OauthNonce.create_or_update(params[:oauth_nonce].to_s)\n end",
"def uuid?\n !match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/).nil?\n end",
"def valid_rut_verifier?(raw_rut)\n rut = normalize_rut(raw_rut)\n return false unless rut.present? && valid_rut_values?(rut)\n\n r = rut[0..(rut.size - 2)]\n get_verifier(r) == rut[-1]\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_uuid?(uuid)\n if UUID_RE.match(uuid)\n true\n else\n false\n end\n end",
"def verify_uuid(uuid,data)\n\t\tgenerate_uuid(data) == uuid\n\tend",
"def verify_signer\n\n if @signed_by_address != @owner_address\n return validation_error(\n 's_wam_aa_4',\n 'unauthorized_access_response',\n ['invalid_signature'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end",
"def valid_cc_number\n return false if self.expiration_year.nil? || self.expiration_month.nil?\n if self.credit_card_number.nil? || credit_card.type.nil?\n errors.add(:credit_card_number, \"is not valid\")\n return false\n end\n true\n 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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 not_in_deck(deck_id, cards, dataset)\n deck_cards = DeckCard.where(deck_id: deck_id)\n\n dataset\n .exclude(\n cards[:id] => deck_cards.select(:card_id),\n )\n end",
"def cards_in_category(cat)\n @cards.find_all { |card_in_deck| card_in_deck.category == cat}\n end",
"def collection_filter_buyer_carts(object)\n if current_user.is_buyer?\n object = object.state(:buyer_build, :ordered, :closed)\n object = object.exclude_subcarts\n\n # TODO this should be a scope \"not the pending cart\"\n ids = current_user.meta.pending_carts.ids\n object = object.where.not(id: ids)\n end\n\n object\n end",
"def contains cards\n @cards.contains cards\n end",
"def trump_cards\n @cards.select {|c| c.suit == @trump_suit}\n end",
"def find_app_premium_cart_usage_record_inconsistencies\n error_usage_cart_app_gear_ids = []\n error_usage_cart_urec_gear_ids = []\n app_cart_hash = {}\n $app_gear_hash.each { |gear_id, gear_info| app_cart_hash[gear_id] = gear_info if gear_info['premium_carts'] and !gear_info['premium_carts'].empty? }\n app_cart_gear_ids = app_cart_hash.keys\n usage_cart_gear_ids = $usage_cart_hash.keys\n missing_cart_gear_ids = (usage_cart_gear_ids - app_cart_gear_ids) + (app_cart_gear_ids - usage_cart_gear_ids)\n (usage_cart_gear_ids & app_cart_gear_ids).each do |gear_id|\n if app_cart_hash[gear_id]['premium_carts'].sort != $usage_cart_hash[gear_id]['cart_name'].sort\n missing_cart_gear_ids << gear_id\n end\n end\n puts \"Checking gears with premium cartridge in applications collection but not in usage_records and viceversa: \" + (missing_cart_gear_ids.empty? ? \"OK\" : \"FAIL\") if $verbose\n\n premium_carts = get_premium_carts\n missing_cart_gear_ids.each do |gear_id|\n if app_cart_hash[gear_id]\n query = {'_id' => BSON::ObjectId(app_cart_hash[gear_id]['app_id'])}\n else\n query = {'name' => $usage_cart_hash[gear_id]['app_name']}\n end\n query['gears._id'] = BSON::ObjectId(gear_id)\n selection = {:fields => [\"component_instances.cartridge_name\"], :timeout => false}\n app_carts = []\n OpenShift::DataStore.find(:applications, query, selection) do |app|\n app['component_instances'].each do |ci|\n app_carts << ci['cartridge_name'] if premium_carts.include?(ci['cartridge_name'])\n end\n end \n app_carts.sort!\n\n usage_carts = []\n query = {'gear_id' => BSON::ObjectId(gear_id), 'usage_type' => UsageRecord::USAGE_TYPES[:premium_cart]}\n selection = {:fields => [\"event\", \"cart_name\"], :timeout => false}\n OpenShift::DataStore.find(:usage_records, query, selection) do |urec|\n next if !UsageRecord::EVENTS.values.include?(urec['event'])\n if urec['event'] == UsageRecord::EVENTS[:end]\n usage_carts.delete(urec['cart_name'])\n else\n usage_carts << urec['cart_name']\n end\n end\n usage_carts.sort!\n\n if app_carts != usage_carts\n puts \"Re-checking for gear '#{gear_id}'...FAIL\\t\" if $verbose\n if (app_carts - usage_carts).length > 0\n error_usage_cart_app_gear_ids << gear_id\n print_message \"Found premium carts #{(app_carts - usage_carts).join(',')} for gear Id '#{gear_id}' but could not find corresponding usage records.\"\n else\n error_usage_cart_urec_gear_ids << gear_id\n print_message \"Found usage records for premium carts #{(usage_carts - app_carts).join(',')} with gear Id '#{gear_id}' but could not find corresponding gear with premium carts in the application.\"\n end\n end\n end\n [error_usage_cart_app_gear_ids, error_usage_cart_urec_gear_ids]\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 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 compare_cards_nums (selected_card, remaining_cards)\n\n matching_cards=remaining_cards.select{|remaining_card| selected_card == remaining_card[1]}\n remaining_cards = remaining_cards - matching_cards\n\n return matching_cards, remaining_cards\n\nend",
"def cards_in_category(sel_category)\n @cards.select do |card|\n card.category == sel_category\n end\n end",
"def cards_closed\n ids = cards_opened_ids\n\n if ids.nil?\n Card.all\n else\n Card.where.not(:real_id => cards_opened_ids)\n end\n end",
"def remove_all argument\n if argument.kind_of? Suit\n @cards = @cards.find_all{|card| !card.suit.eql?(argument) }\n end\n if argument.kind_of? Rank\n @cards = @cards.find_all{|card| !card.rank.eql?(argument) }\n end\n self\n end",
"def check_sets\n complete_sets = []\n @hand.collect { |card| card[0] }.uniq.each do |set_num|\n if @hand.collect { |card| card[0] }.count(set_num) == Deck.set_data(set_num)[2]\n complete_sets << set_num\n end\n end\n return complete_sets\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end",
"def not_in_deck(deck_id, cards, dataset)\n deck_cards = DeckCard.where(deck_id: deck_id)\n\n dataset\n .exclude(\n cards[:id] => deck_cards.select(:card_id),\n )\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 cards_closed\n ids = cards_opened_ids\n\n if ids.nil?\n Card.all\n else\n Card.where.not(:real_id => cards_opened_ids)\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 enabled_cards\n nic_info.cards.reject(&:disabled)\n end",
"def cards?\n\t\t@deck.deck.empty?\n\tend",
"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 cards_in_category(cat)\n @cards.find_all { |card_in_deck| card_in_deck.category == cat}\n end",
"def discardHiddenCards?()\n\t\t#Checks if we have at least 4 cards in our hand.\n\t\tif checkSize()\n\t\t\ti = 0 #Index to get to the last 4 cards of your hand.\n\t\t\tj = 0 #Index to discard all 4 cards.\n\t\t\ttemp = Card.new(0, \"\")\n\t\t\t#Checking to see if the 1st and 4th cards match numbers.\n\t\t\tif checkMatchNum()\n\t\t\t\t#Iterating to the 4 cards we want to discard.\n\t\t\t\twhile i < @hand.length - 4\n\t\t\t\t\ttemp = @hand.shift()\n\t\t\t\t\t@hand.push(temp) #Putting cards we don't want back in our deck.\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\t\t#Discards 4 cards.\n\t\t\t\twhile j < 4\n\t\t\t\t\t@hand.pop()#Discarding cards.\n\t\t\t\t\tj += 1 \n\t\t\t\tend\n\t\t\t\tdiscardHiddenCards?() #Now that you discarded cards, have to check again if there's new stuff to discard.\n\t\t\tend\n\t\tend\n\t\tif checkSize()\n\t\t\ti = 0 #Index to get to the last 4 cards of your hand.\n\t\t\tj = 0 #Index to skip two 'middle' cards of the last four.\n\t\t\t#Checking to see if the 1st and 4th card match suits.\n\t\t\tif checkMatchSuit()\n\t\t\t\t#Iterating to the middle two cards\n\t\t\t\twhile i < @hand.length - 3\n\t\t\t\t\ttemp = @hand.shift()\n\t\t\t\t\t@hand.push(temp)\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\t\t@hand.pop() #Discards the middle two cards.\n\t\t\t\t@hand.pop()\n\t\t\t\t@hand.push(@hand.pop())\n\t\t\t\tdiscardHiddenCards?() #Now that you discarded cards, have to check again if there's new stuff to discard.\n\t\t\tend\n\t\tend\n\tend",
"def discard(card)\n discard_pile << card\n end",
"def contains cards\n @cards.contains 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 wilds\n (@cards || []).select(&:wild?)\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 add_random_card_not_in(cards, used)\n\t\tloop do\n\t\t\tcard = random_card\n\t\t\tunless used.any_set(card)\n\t\t\t\tcards << card\n\t\t\t\tused << card\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend",
"def remove_cards\n\t\t@cards.slice!(0,2)\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def total_number_of_cards_in(decks)\n cards = 0\n decks.each do |deck|\n cards += deck.cards.length\n end\n return cards\n end",
"def cardsRemaining\n @deck.length\n end",
"def count\n @deck.count\n end",
"def count\n @deck.size\n end",
"def report_card_count\n total = 0\n self.oi_instructions.each { |inst| total += inst.report_card_count }\n total\n end",
"def total_due_for_group(decks)\n due = 0\n decks.each do |deck|\n if deck.cards_due?\n due += deck.cards.due.length\n end\n end\n return due\n end",
"def number_correct\n @correct_card_array.count\n end",
"def count_cards_with_suit suit\n count = 0;\n @cards.each do |card|\n count +=1 if card.suit.eql?(suit)\n end\n count\n end",
"def num_stock_cards\n @stock.size\n end",
"def total\n total = 0\n\n collected_cards.each { |card| total = total + card.quantity }\n\n total\n end",
"def available_cards\n (@deck.size + board.size)\n end",
"def report_card_count\n total = 0\n self.oi_assignments.each { |assignment| total += 1 if assignment.oi_assignment_report }\n total\n end",
"def count\n @cards.count\n end",
"def number_readied\n readied_cards.count\n end",
"def quantity(card)\n external_deck_instances.find_by(card_id: card.id).quantity\n end",
"def test_deck_count_cards\n card_1 = Card.new(\"What is the capital of Alaska?\", \"Juneau\")\n card_2 = Card.new(\"The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?\", \"Mars\")\n card_3 = Card.new(\"Describe in words the exact direction that is 697.5° clockwise from due north?\", \"North north west\")\n deck = Deck.new([card_1, card_2, card_3])\n assert_equal 3, deck.count\n end",
"def num_cards_due\n if cards_due?\n self.due_count = self.cards.due.length\n else\n 0\n end\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns user's collection ID | def coll_id
current_user.collection.id
end | [
"def get_collection_id\n @coll_id\n end",
"def get_collection_id()\r\n return @coll_id\r\n end",
"def collection_id\n path.split(\"/\").last\n end",
"def site_collection_id\n return @site_collection_id\n end",
"def get_object_collection_id(object, target)\n # Find or create the collection\n collection_pid = Collection.new.get_or_create_collection_pid(object, target)\n object_error_and_exit(object, 'could not assign to a collection') if collection_pid.nil?\n collection_pid\n end",
"def get_collection_id\n params[:controller] == \"atrium_collections\" ? params[:id] : params[:collection_id]\n end",
"def extract_collection_id(env)\n attributes_collection =\n env.attributes.fetch(:member_of_collections_attributes) { nil }\n\n # Determine if the work is being created in one and only one collection.\n return unless attributes_collection && attributes_collection.size == 1\n\n # Extract the collection id from attributes_collection,\n collection_id = attributes_collection.first.second['id']\n\n # Do not apply permissions to work if collection type is configured not to\n collection = Hyrax.config.collection_class.find(collection_id)\n return unless Hyrax::CollectionType.for(collection: collection).share_applies_to_new_works?\n\n # Save the collection id in env for use in apply_permission_template_actor\n env.attributes[:collection_id] = collection_id\n end",
"def site_collection_id=(value)\n @site_collection_id = value\n end",
"def collection\n mongo_client[collection_name]\n end",
"def collection(user, collection, *args)\n Collection.new self, get(:users, user, :collections, collection, *args)\n end",
"def collection_path\n current_user ? user_collection_path(current_user) : home_path\n end",
"def collection\n mongo_session[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 current_user_id\n return @current_user[:id]\n end",
"def current_collection(collection_name)\n @current_collection ||= get_repository_admin_code(collection_name) unless collection_name.nil?\n end",
"def collection_id\n super.map { |url| URI(url).path.sub('/', '') }\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns tracked deck ID | def tracked_deck_id(tracked_deck)
tracked_deck.id
end | [
"def get_deck_id\n if deck_id.nil?\n init_deck_id\n deck_id\n else\n deck_id\n end\n end",
"def last_guessed_card\n current_round.guesses.last.card_id\nend",
"def track(deck)\n saved_external_decks.create(external_deck_id: deck.id)\n end",
"def card_id\n card.id\n end",
"def init_deck_id\n path = '/api/deck/new/shuffle/?deck_count=1'\n json_resp = make_API_call(path)\n # getting our deck id from the response hashmap\n deck_id = json_resp['deck_id']\n update_attribute(:deck_id, deck_id)\n end",
"def current_card\n @deck.cards[@turns.count]\n end",
"def game_id\n service.game_id\n end",
"def track_id\n @ole.trackID\n end",
"def current_card\n @deck.cards[@round]\n end",
"def id\n raw_player['account_id']\n end",
"def get_deck\n return @deck\n end",
"def find_last_card_used()\n self.credit_cards.sort_by{|x| x.id}.last\n end",
"def facture_id\n @facture_id ||= data[:id][0..31]\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 last_insynced_id(user)\n buzz_insyncs.select('buzz_id').find_by_user_id(user.id).try(:buzz_id) || 0\n end",
"def now_id(battler)\n return battler.now_action.nil? ? 0 : battler.now_action.id\n end",
"def set_card_id\n\t\tself.card_id = self.deck.flashcards.count + 1\n\tend",
"def battler_id\n return (@battler == nil ? 0 : @battler.id)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns dust total for cards | def dust_total(cards)
cards.inject(0) do |dust_total, card|
dust_total + dust_value(card.rarity)
end
end | [
"def total\n total = 0\n\n collected_cards.each { |card| total = total + card.quantity }\n\n total\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 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 initial_round\n total = deal_card + deal_card\n display_card_total(total)\n total\nend",
"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 get_dealer_total(dealer_hand,dealer_turn)\n\tputs \"==>in #{__method__.to_s}\" if $DEBUG\n\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\tdealer_total = get_hand_total(dealer_hand)\n\tend\n\treturn dealer_total\nend",
"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 card_value\n return 0\n end",
"def debt\n subtotal - _normed_balance\n end",
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_dealers_hand}, #{card_value} \\n\")\n }\n\n# ### This method returns sum of dealer's hand\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n end",
"def initial_round\n first = deal_card\n second = deal_card\n sum = first + second\n display_card_total(sum)\n return sum\nend",
"def discount_amount_from_cart\n\t\t\t$tracer.trace(__method__)\n\t\t\treturn ToolTag.new(table.className(\"subtotals\").tbody.find.tr.className(\"discount\"), __method__)\n\t\tend",
"def total_calories\n desserts.reduce(0) {|total, dessert| total + dessert.calories}\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 total_yards\n data[:total_yards]\n end",
"def get_total_disc_num\n Input.cart.line_items.each do |item|\n if item.variant.product.vendor == DISCOUNT_VENDOR\n PAID_ITEM_COUNT = PAID_ITEM_COUNT + item.quantity\n end\n end\n DISCOUNTED_ITEM_COUNT = (PAID_ITEM_COUNT/ITEM_NUM_TO_FREE).floor\nend",
"def total\n amount\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 cardValue(card)\n royals = ['J', 'Q', 'K']\n val = card[1]\n if val == 'A'\n if (@handVal > 10)\n return 1\n else\n @hasAce = true\n return 11\n end\n elsif (royals.include? val)\n val = 10\n end\n return val\n end",
"def calculate_synergy_value(card_to_compare_against)\n return 0 if card_to_compare_against&.animal != synergy_type\n\n synergy_value\n end",
"def card_value\n the_value = 0\n case @rank\n when :ace \n the_value = 1\n when :two \n the_value = 2\n when :three\n the_value = 3\n when :four\n the_value = 4\n when :five\n the_value = 5\n when :six\n the_value = 6\n when :seven\n the_value = 7\n when :eight\n the_value = 8\n when :nine\n the_value = 9\n else\n the_value = 10\n end\n return the_value\n end",
"def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end",
"def evaluate_non_ace_card(card)\n card.face_card? ? 10 : card.value\n end",
"def defense_rating\r\n ( -1 * self.armor_class - 100 ) / 5\r\n end",
"def card_value\n return 0\n end",
"def hand_rating\n \"Royal Flush\"\n end",
"def cards_by_rarity(rarity)\n all_cards(rarity: rarity).to_a\n end",
"def card_rarities\n load_cards_data['rarities']\n end",
"def get_hand_score\n @score\n end",
"def hand_value\n\t\treturn evaluate_hand(@hand)\n\tend",
"def suit_value\n deck.suits[suit]\n end",
"def score\n SCORES.each do |name, evaluation|\n return name if send(evaluation)\n end\n \"High Card\"\n end",
"def dexterity_bonus\n @character.dexterity_modifier\n end",
"def rh_factor\n fetch('blood.rh_factor')\n end",
"def randomCard\n\t\trarity = randomRarity\n\t\tgolden = randomGold(rarity)\n\t\tmakeCard(rarity, golden)\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current month | def current_month
Date.today.strftime("%B")
end | [
"def current_month\n DateTime.now.strftime(\"%Y-%m-01\")\n end",
"def current_month\n Time.now.strftime(\"%^b\")\n end",
"def current_month\n find_switch :days\n end",
"def month\n return @month\n end",
"def month\n return @month\n end",
"def month() end",
"def current_day\n return Time.now.strftime \"%d.%m\"\n end",
"def next_month\n 1.month.since(Date.today).beginning_of_month\n end",
"def is_current_month?( month )\n current_month = Date::MONTHNAMES[ Time.now.month ]\n current_month == month\nend",
"def start_of_this_month\n start_of_month( today )\n end",
"def month\n set_function_and_argument(:month, nil)\n end",
"def current_month?(date)\n Date.new(date.year, date.month, 1) == @month\n end",
"def current_beginning_of_month_day\n @current_beginning_of_month_day ||= begin\n if params && params['month'] && params['year']\n Date.parse(\"01/#{params['month']}/#{params['year']}\")\n end\n end\n 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 published_at.beginning_of_month\n end",
"def month\n MONTHS[@created_at.month-1]\n end",
"def current_month?\n self.month == calendar_month\n end",
"def month_name; Date::MONTHNAMES[month]; end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resets the deck to its initial state | def reset!
@cards = load_cards
end | [
"def reset_deck\n @current_user.initialize_deck\n render :success\n end",
"def handreset\n @cards = Array.new\n end",
"def reset!\n @hands.each(&:discard!)\n @cards += @used\n @used = []\n end",
"def reset\n # delete all old cards, then reload deck\n cards.each {|card| Card.delete card }\n reload\n # create new cards\n Cardface.all.each do |cf|\n c_new = Card.new :cardface_id => cf.id, :facedown_position => cf.id\n cards << c_new\n c_new.save!\n end\n save!\n end",
"def reset\n\t\t\t@drawnCards = []\n\t\tend",
"def reset_cards\n\t\t\tunless @pooled_cards.empty?\n\t\t\t\traise StandardError.new(\"pooled card isn't empty.\")\n\t\t\tend\n\t\t\t@pooled_cards = @used_cards.shuffle\n\t\t\t@used_cards = @used_cards.clear\n\t\tend",
"def shuffle\n @top_of_deck = 0\n @deck = @deck.shuffle\n end",
"def reset_table\r\n @curr_round = 'preflop'\r\n @community_cards = []\r\n @deck = Deck.new\r\n @pot = 0\r\n @current_bet = @minimum_bet\r\n @players.each { |player| player.reset_self }\r\n end",
"def reset!\n @hoard = nil\n @creating = nil\n @guards = nil\n end",
"def reset()\n @board.clear()\n @board.setup()\n @currentGame = @currentGame + 1;\n @turn = @player1\n @board.printBoard()\n @turn.promptAction()\n\n end",
"def start_game\n @deck = Decks.new(@deck_num)\n @deck.shuffle\n end",
"def new_deck\n if deck\n save\n else\n self.deck = Deck.new\n save && deck.shuffle\n end\n end",
"def reset\n\t\t@@board = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n\t\t@@used = 0\n\t\t@@winner = \"\"\n\t\t@@turn = 0\n\tend",
"def reset_hand\n @hand = []\n end",
"def resetRound\n @players.each do |player|\n player.resetPlayerForNewRound\n end\n @players.clear\n @dealer.clearHands\n @deck.shuffle\n @quitters = []\n @round_num += 1 # update round number\n end",
"def reset_game\n\t\t\t@players.each do |player|\n\t\t\t\tif player.cash <= 0\n\t\t\t\t\tputs \"Sorry #{player.name}, but you'll have to sit this out. You don't have any money left.\"\n\t\t\t\tend\n\t\t\t\tplayer.reset\n\t\t\tend\n\t\t\t@dealer.reset\n\t\t\t@turn = 0\n\t\tend",
"def reset()\n @board = Board.new(rows, cols)\n @turn = 1\n @winner = 0\n @winCase = \"\"\n end",
"def reset\n @state = nil\n @name = []\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /displays/1 GET /displays/1.json | def show
@display = Display.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @display }
end
end | [
"def index\n @displays = Display.all\n end",
"def show\n @experiment_display = ExperimentDisplay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @experiment_display }\n end\n end",
"def show\n @experiment_hardware = ExperimentHardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @experiment_hardware }\n end\n end",
"def get_display(display_id)\n get \"commandcenter/displays/#{display_id}\"\n end",
"def show\n @http_automation = HttpAutomation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @http_automation }\n end\n end",
"def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end",
"def show\n @experiment_visual = ExperimentVisual.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_visual }\n end\n end",
"def show\n @experiment_aural = ExperimentAural.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_aural }\n end\n end",
"def show\n @experiment_control = ExperimentControl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_control }\n end\n end",
"def show\n @experiment_biomechanical = ExperimentBiomechanical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment_biomechanical }\n end\n end",
"def show\n @experiment_software = ExperimentSoftware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @experiment_software }\n end\n end",
"def show\n @system = System.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system }\n end\n end",
"def show\n @heat_type = HeatType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heat_type }\n end\n end",
"def show\n @system = System.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system }\n end\n end",
"def show\n @hardware_type = HardwareType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hardware_type }\n end\n end",
"def show\n @hardwaretype = Hardwaretype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hardwaretype }\n end\n end",
"def show\n @host_type = HostType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @host_type }\n end\n end",
"def show\n @visualList = Visual.all\n @visual = Visual.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @visual }\n end\n end",
"def show\n @cellular = Cellular.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cellular }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /displays/new GET /displays/new.json | def new
@display = Display.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @display }
end
end | [
"def new\n @experiment_display = ExperimentDisplay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @experiment_display }\n end\n end",
"def new\n @display_name = DisplayName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @display_name }\n end\n end",
"def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end",
"def new\n @launch = Launch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @launch }\n end\n end",
"def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cloud }\n end\n end",
"def new\n @page_id = params[:id]\n @display_item = DisplayItem.new\n @display_item.page_id = @page_id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @display_item }\n end\n end",
"def new\n @system = System.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @system }\n end\n end",
"def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cloud }\n end\n end",
"def new\n @heat_type = HeatType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heat_type }\n end\n end",
"def new\n\tputs \"new\"\n @resource = Resource.new\n\n respond_to do |format|\n format.json { render json: @resource }\n#\t format.html { render html: @resources }\n end\n end",
"def new\n @host = Host.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @host }\n end\n end",
"def new\n @system = System.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.js # new.js.erb\n format.json { render json: @system }\n end\n end",
"def new\n @server = Server.new\n @creating_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n\n end\n end",
"def new\n @display = Display.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @display }\n end\n end",
"def new\n @human = Human.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @human }\n end\n end",
"def new\n @human = Human.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @human }\n end\n end",
"def new\n @history_site = HistorySite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @history_site }\n end\n end",
"def new\n @present = Present.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @present }\n end\n end",
"def new\n @experiment_visual = ExperimentVisual.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @experiment_visual }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /displays/1 PUT /displays/1.json | def update
@display = Display.find(params[:id])
respond_to do |format|
if @display.update_attributes(params[:display])
format.html { redirect_to @display, :notice => 'Display was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @display.errors, :status => :unprocessable_entity }
end
end
end | [
"def update_display(display_id, opts = {})\n put \"commandcenter/displays/#{display_id}\", opts\n end",
"def update\n @experiment_display = ExperimentDisplay.find(params[:id])\n\n respond_to do |format|\n if @experiment_display.update_attributes(params[:experiment_display])\n format.html { redirect_to @experiment_display, :notice => 'Experiment display was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @experiment_display.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @display.update(display_params)\n format.html { redirect_to @display, notice: 'Display was successfully updated.' }\n format.json { render :show, status: :ok, location: @display }\n else\n format.html { render :edit }\n format.json { render json: @display.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_screen(display_id, screen_id, opts = {})\n put \"commandcenter/displays/#{display_id}/screens/#{screen_id}\", opts\n end",
"def update\n respond_to do |format|\n if @real_time_display.update(real_time_display_params)\n format.html { redirect_to @real_time_display, notice: 'Real time display was successfully updated.' }\n format.json { render :show, status: :ok, location: @real_time_display }\n else\n format.html { render :edit }\n format.json { render json: @real_time_display.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @display = Display.find(params[:id])\n\n respond_to do |format|\n if @display.update_attributes(params[:display])\n flash[:notice] = 'Display was successfully updated.'\n format.html { redirect_to(@display) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @display.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @system_overview.update(system_overview_params)\n format.html { redirect_to @system_overview, notice: 'System overview was successfully updated.' }\n format.json { render :show, status: :ok, location: @system_overview }\n else\n format.html { render :edit }\n format.json { render json: @system_overview.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_scene(display_id, scene_id, opts = {})\n put \"commandcenter/displays/#{display_id}/scenes/#{scene_id}\", opts\n end",
"def update\n @display = Display.find(params[:id])\n\n respond_to do |format|\n if @display.update_attributes(params[:display])\n flash[:notice] = 'Display mis a jour!.'\n format.html { redirect_to(@display) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @display.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n params.permit!\n @display_item = DisplayItem.find(params[:id])\n\n respond_to do |format|\n if @display_item.update_attributes(params[:display_item])\n format.html { redirect_to @display_item, notice: 'Display item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @display_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @species = Species.find(params[:id])\n @species.update_attributes(params[:species])\n \n respond_with(@species, :location => admin_species_path(@species))\n end",
"def index\n @displays = Display.all\n end",
"def update\n @species = Species.find(params[:id])\n\n if @species.update(species_params)\n head :no_content\n else\n render json: @species.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @display_unit.update(display_unit_params)\n render :show, status: :ok, location: @display_unit\n else\n render json: @display_unit.errors, status: :unprocessable_entity\n end\n end",
"def update\n @heat_type = HeatType.find(params[:id])\n\n respond_to do |format|\n if @heat_type.update_attributes(params[:heat_type])\n format.html { redirect_to @heat_type, notice: 'Heat type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @display_name = DisplayName.find(params[:id])\n\n respond_to do |format|\n if @display_name.update_attributes(params[:display_name])\n format.html { redirect_to @display_name, notice: 'Display name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @display_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @experiment_hardware = ExperimentHardware.find(params[:id])\n\n respond_to do |format|\n if @experiment_hardware.update_attributes(params[:experiment_hardware])\n format.html { redirect_to @experiment_hardware, :notice => 'Experiment hardware was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @experiment_hardware.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @spectro = Spectro.find(params[:id])\n\n respond_to do |format|\n if @spectro.update_attributes(params[:spectro])\n format.html { redirect_to @spectro, notice: 'Spectro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spectro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @display_frame.update(display_frame_params)\n format.html { redirect_to @display_frame, notice: 'Display frame was successfully updated.' }\n format.json { render :show, status: :ok, location: @display_frame }\n else\n format.html { render :edit }\n format.json { render json: @display_frame.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /displays/1 DELETE /displays/1.json | def destroy
@display = Display.find(params[:id])
@display.destroy
respond_to do |format|
format.html { redirect_to displays_url }
format.json { head :no_content }
end
end | [
"def destroy\n @experiment_display = ExperimentDisplay.find(params[:id])\n @experiment_display.destroy\n\n respond_to do |format|\n format.html { redirect_to experiment_displays_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @display = Display.find(params[:id])\n @display.destroy\n\n respond_to do |format|\n format.html { redirect_to(displays_url) }\n format.xml { head :ok }\n end\n end",
"def delete_display(display_id)\n delete \"commandcenter/displays/#{display_id}\"\n end",
"def destroy\n @real_time_display.destroy\n respond_to do |format|\n format.html { redirect_to real_time_displays_url, notice: 'Real time display was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @display_name = DisplayName.find(params[:id])\n @display_name.destroy\n\n respond_to do |format|\n format.html { redirect_to display_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heat_type = HeatType.find(params[:id])\n @heat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @displaydatum.destroy\n respond_to do |format|\n format.html { redirect_to displaydata_url, notice: 'Displaydatum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @display_item = DisplayItem.find(params[:id])\n @display_item.destroy\n\n respond_to do |format|\n format.html { redirect_to display_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanoid.destroy\n respond_to do |format|\n format.html { redirect_to humanoids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @human = Human.find(params[:id])\n @human.destroy\n\n respond_to do |format|\n format.html { redirect_to humans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @define = Define.find(params[:id])\n @define.destroy\n\n respond_to do |format|\n format.html { redirect_to defines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spectro = Spectro.find(params[:id])\n @spectro.destroy\n\n respond_to do |format|\n format.html { redirect_to spectros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @notice_display = NoticeDisplay.find(params[:id])\n @notice_display.destroy\n\n respond_to do |format|\n format.html { redirect_to notice_displays_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @http_automation = HttpAutomation.find(params[:id])\n @http_automation.destroy\n\n respond_to do |format|\n format.html { redirect_to http_automations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measure_type.destroy\n respond_to do |format|\n format.html { redirect_to measure_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @displasium = Displasium.find(params[:id])\n @displasium.destroy\n\n respond_to do |format|\n format.html { redirect_to displasia_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment_aural = ExperimentAural.find(params[:id])\n @experiment_aural.destroy\n\n respond_to do |format|\n format.html { redirect_to experiment_aurals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List the house contract based on the houseid/userid/roleId combination | def contracts
#if isAuth(@userhouselink.house) # only house owner or admin can delete
id = params[:id]
print "contracts id=" + id.to_s
#houseId_userId_roleNumber
houseId,userId,role = id.to_s.split("_")
print "houseId=" + houseId.to_s + ", userId=" + userId.to_s + ", role=" + role.to_s
if(houseId && userId && role)
@user_house_contracts = UserHouseContract.where(:house_id => houseId, :user_id => userId, :role => role)
else
@errMsg = "Invalid input format."
print @errMsg
render 'error', :status => :unprocessable_entity
end
#
#end
end | [
"def list_contracts\n #contracts_list = Contract.find_by_id(id).location_a_id\n \n Contract.where(\"customer_id = \" + id.to_s )\n end",
"def index\n @loanables = current_user.loanables.includes(:loan_contracts).all\n end",
"def index\n\t\t@company = Company.find(params[:company_id])\n\t\t@user = @company.users.find(params[:user_id])\n\t\t@contracts = @user.contracts\n\tend",
"def index\n @user = User.find(params[:user_id])\n @user_contracts = @user.user_contracts\n end",
"def index\n @employment_contracts = EmploymentContract.where([\"company_id = :u\", { u: params[:company_id] }])\n end",
"def show_lawyer_list\n authorize!(:show_lawyer_list,current_user) unless current_user.role?:secretary\n #session[:verified_secretary_id1] = params[:service_provider_id]\n if params[:search].nil?\n @employees = Employee.paginate :page => params[:page], :order => 'employees.created_at DESC', :per_page=>20, :include=>[:user=>[:role,:service_provider_employee_mappings]]\n else\n @employees = Employee.get_employees(params)\n end\n end",
"def household_users\n User.where(id: household_user_ids)\n end",
"def index\n @ag_household_members = Ag::HouseholdMember.all\n end",
"def index\n @household_members = HouseholdMember.all\n end",
"def index\n @user = current_user\n @contract_items = ContractItem.all\n end",
"def index\n \n if (@current_user.role == \"admin\")\n @rcadmin_contractors = Rcadmin::Contractor.all\n else\n @rcadmin_contractors = current_admin.non_retails\n end\n end",
"def list\n authorize!(:list,current_user) unless current_user.role?:lawfirm_admin or current_user.role?:livia_admin\n session[:company_id] = params[:company_id]\n if current_user.role?:lawfirm_admin\n @company=current_user.company_id\n @designations = CompanyLookup.company_and_type(@company,'Designation')\n else\n @company = Company.find(params[:company_id])\n @designations = CompanyLookup.company_and_type(@company.id,'Designation')\n end\n end",
"def index\n @cabinet_ownerships = Ownership.all\n end",
"def list_houses_for_user(user_instance)\n house_list = House.where(\"price <= #{user_instance.budget}\").order(\"price DESC\") \nend",
"def index\n @user_household_ledgers = UserHouseholdLedger.all\n end",
"def list_agents(user_instance)\n puts \"Listing agents who satisfy your budege\"\n agents = list_houses_agent(user_instance)\n\n puts \"Which agent do you want to choose?\"\n agent = valid_agent_name(user_instance, agents)\n user_instance = Buyer.find_by(id: user_instance.id)\n\n puts \"Visting house list:\"\n agent_list_houses(agent)\n\n visit_house(user_instance, agent)\nend",
"def index\n\t if current_user.household == nil\n\t \t@households = Household.all\n\t else redirect_to household_path(current_user.household)\n\t end\n\tend",
"def index\n @loan_applications = LoanApplication.where(user_id: params[:user_id])\n end",
"def orgList\n\tvieworgs = $client.organizations.fetch!\n\tvieworgs.each { |x| puts x.id puts x.name }\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the applicableArchitectures property value. Contains properties for Windows architecture. | def applicable_architectures
return @applicable_architectures
end | [
"def applicable_architectures=(value)\n @applicable_architectures = value\n end",
"def return_selectable_architectures()\n return ARCH_ALL\n end",
"def all_architectures\n architectures + extra_architectures\n end",
"def detect_architecture()\r\n\t\tprint_status(\"Attempting to automatically detect the architecture\")\r\n\t\tres = send_serialized_request(\"osarch.bin\")\r\n\t\tif (res.body =~ /(i386|x86)/i)\r\n\t\t\tarch = $1\r\n\t\t\tif (arch =~ /i386|x86/i)\r\n\t\t\t\treturn ARCH_X86\r\n\t\t\t\t# TODO, more\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def architecture\n if @architecture.nil? or @architecture == \"native\"\n # Default architecture should be 'native' which we'll need to ask the\n # system about.\n if program_in_path?(\"dpkg\")\n @architecture = %x{dpkg --print-architecture 2> /dev/null}.chomp\n if $?.exitstatus != 0 or @architecture.empty?\n # if dpkg fails or emits nothing, revert back to uname -m\n @architecture = %x{uname -m}.chomp\n end\n else\n @architecture = %x{uname -m}.chomp\n end\n end\n\n case @architecture\n when \"x86_64\"\n # Debian calls x86_64 \"amd64\"\n @architecture = \"amd64\"\n when \"aarch64\"\n # Debian calls aarch64 \"arm64\"\n @architecture = \"arm64\"\n when \"noarch\"\n # Debian calls noarch \"all\"\n @architecture = \"all\"\n end\n return @architecture\n end",
"def actual_arch\n arch = nil\n\n if explicit_arch.nil? == false\n arch = explicit_arch\n elsif datastore['ARCH']\n arch = datastore['ARCH']\n elsif assoc_exploit\n arch = assoc_exploit.target_arch || ARCH_X86\n end\n\n # If we still have an invalid architecture, then we suck.\n if arch.nil?\n raise NoCompatiblePayloadError, \"An architecture could not be determined by the generic payload\"\n elsif arch.kind_of?(String)\n arch = [ arch ]\n end\n\n return arch\n end",
"def determine_system_architecture\n arch = query('uname -m').gsub(/i\\d86/, 'x86')\n\n warn(\"Unable to determine target architecture\") if arch.empty?\n\n Entry.new('Arch', arch)\n end",
"def architectures\n @in_memory.keys.sort\n end",
"def get_architecture_name\n return ARCHITECTURES[architecture]\n end",
"def architecture\n data[:architecture]\n end",
"def architecture=(value)\n @architecture = value\n end",
"def architecture # rubocop:disable Lint/DuplicateMethods\n @architecture ||= @name.match(PLATFORM_REGEX)[3]\n end",
"def architecture\n `uname -m`.strip\n end",
"def detect_arch\n case self.distro.downcase\n when \"ubuntu\" then\n ((self.node.arch =~ /x86_64/) ? \"amd64\" : \"i386\")\n when \"fedora\" then\n ((self.node.arch =~ /x86_64/) ? \"amd64\" : \"i686\")\n end\n end",
"def registry_system_architecture\n applied_arch = ( architecture == :machine ) ? machine_architecture : architecture\n ( applied_arch == :x86_64 ) ? 0x0100 : 0x0200\n end",
"def architecture\n data.architecture\n end",
"def canonical_arch\n Config::CONFIG['arch'].sub(/[\\.0-9]*$/, '')\n end",
"def target_arch\n (target and target.arch) ? target.arch : (arch == []) ? nil : arch\n end",
"def target_arch\n (target and target.arch) ? target.arch : (arch == []) ? nil : arch\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the applicableArchitectures property value. Contains properties for Windows architecture. | def applicable_architectures=(value)
@applicable_architectures = value
end | [
"def applicable_architectures\n return @applicable_architectures\n end",
"def return_selectable_architectures()\n return ARCH_ALL\n end",
"def architecture=(value)\n @architecture = value\n end",
"def all_architectures\n architectures + extra_architectures\n end",
"def set_Architecture(value)\n set_input(\"Architecture\", value)\n end",
"def architecture_name=(value)\n @architecture_name = value\n end",
"def detect_architecture()\r\n\t\tprint_status(\"Attempting to automatically detect the architecture\")\r\n\t\tres = send_serialized_request(\"osarch.bin\")\r\n\t\tif (res.body =~ /(i386|x86)/i)\r\n\t\t\tarch = $1\r\n\t\t\tif (arch =~ /i386|x86/i)\r\n\t\t\t\treturn ARCH_X86\r\n\t\t\t\t# TODO, more\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def architecture\n if @architecture.nil? or @architecture == \"native\"\n # Default architecture should be 'native' which we'll need to ask the\n # system about.\n if program_in_path?(\"dpkg\")\n @architecture = %x{dpkg --print-architecture 2> /dev/null}.chomp\n if $?.exitstatus != 0 or @architecture.empty?\n # if dpkg fails or emits nothing, revert back to uname -m\n @architecture = %x{uname -m}.chomp\n end\n else\n @architecture = %x{uname -m}.chomp\n end\n end\n\n case @architecture\n when \"x86_64\"\n # Debian calls x86_64 \"amd64\"\n @architecture = \"amd64\"\n when \"aarch64\"\n # Debian calls aarch64 \"arm64\"\n @architecture = \"arm64\"\n when \"noarch\"\n # Debian calls noarch \"all\"\n @architecture = \"all\"\n end\n return @architecture\n end",
"def determine_system_architecture\n arch = query('uname -m').gsub(/i\\d86/, 'x86')\n\n warn(\"Unable to determine target architecture\") if arch.empty?\n\n Entry.new('Arch', arch)\n end",
"def normalize_architecture(architecture)\n case architecture\n when \"amd64\"\n \"x86_64\"\n when \"i86pc\", \"i686\"\n \"i386\"\n when \"sun4u\", \"sun4v\"\n \"sparc\"\n else\n architecture\n end\n end",
"def check_platforms\n default_platform_attrs = ProductModel.platforms.stringify_keys\n self.design_platform = default_platform_attrs.merge(booleanize_hashs(design_platform))\n self.customize_platform = default_platform_attrs.merge(booleanize_hashs(customize_platform))\n end",
"def choose_platform_set(config, reason, desired_platforms, library_properties)\n\n # if there are no properties or no architectures, defer entirely to desired platforms\n if library_properties.nil? || library_properties.architectures.nil? || library_properties.architectures.empty?\n # verify that all platforms exist\n desired_platforms.each { |p| assured_platform(reason, p, config) }\n return inform_multiline(\"No architectures listed in library.properties, using configured platforms\") do\n desired_platforms.each { |p| puts \" #{p}\" } # this returns desired_platforms\n end\n end\n\n if library_properties.architectures.include?(\"*\")\n return inform_multiline(\"Wildcard architecture in library.properties, using configured platforms\") do\n desired_platforms.each { |p| puts \" #{p}\" } # this returns desired_platforms\n end\n end\n\n platform_architecture = config.platform_info.transform_values { |v| v[:board].split(\":\")[1] }\n supported_platforms = platform_architecture.select { |_, a| library_properties.architectures.include?(a) }\n\n if config.is_default\n # completely ignore default config, opting for brute-force library matches\n # OTOH, we don't need to assure platforms because we defined them\n return inform_multiline(\"Default config, platforms matching architectures in library.properties\") do\n supported_platforms.keys.each do |p| # rubocop:disable Style/HashEachMethods\n puts \" #{p}\"\n end # this returns supported_platforms\n end\n end\n\n desired_supported_platforms = supported_platforms.select { |p, _| desired_platforms.include?(p) }.keys\n desired_supported_platforms.each { |p| assured_platform(reason, p, config) }\n inform_multiline(\"Configured platforms that match architectures in library.properties\") do\n desired_supported_platforms.each do |p|\n puts \" #{p}\"\n end # this returns supported_platforms\n end\nend",
"def canonicalize_arch(arch, arm64: \"arm64\", x86: \"x86_64\")\n case arch\n when \"aarch64\", \"arm64\"\n arm64\n when \"x86_64\"\n x86\n else\n raise \"Unknown arch #{arch} for platform #{platform}\"\n end\nend",
"def supports?(environment, architecture)\n if self.info[:environment] == environment && self.info[:architecture] == architecture\n return true\n end\n\n arguments = [self.fullID]\n cmdOptions = {\n \"--target-architecture\" => architecture,\n \"--target-environment\" => environment,\n \"--truth\" => true\n }\n\n if @account\n cmdOptions[\"-T\"] = @account.token\n end\n\n # TODO: provider path\n result = Occam::Worker.perform(\"manifests\", \"run\", arguments, cmdOptions)\n JSON.parse(result[:data], :symbolize_names => true)\n end",
"def registry_system_architecture\n applied_arch = ( architecture == :machine ) ? machine_architecture : architecture\n ( applied_arch == :x86_64 ) ? 0x0100 : 0x0200\n end",
"def architecture # rubocop:disable Lint/DuplicateMethods\n @architecture ||= @name.match(PLATFORM_REGEX)[3]\n end",
"def platforms=(value)\n @platforms = value\n end",
"def actual_arch\n arch = nil\n\n if explicit_arch.nil? == false\n arch = explicit_arch\n elsif datastore['ARCH']\n arch = datastore['ARCH']\n elsif assoc_exploit\n arch = assoc_exploit.target_arch || ARCH_X86\n end\n\n # If we still have an invalid architecture, then we suck.\n if arch.nil?\n raise NoCompatiblePayloadError, \"An architecture could not be determined by the generic payload\"\n elsif arch.kind_of?(String)\n arch = [ arch ]\n end\n\n return arch\n end",
"def detect_arch\n case self.distro.downcase\n when \"ubuntu\" then\n ((self.node.arch =~ /x86_64/) ? \"amd64\" : \"i386\")\n when \"fedora\" then\n ((self.node.arch =~ /x86_64/) ? \"amd64\" : \"i686\")\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the applicableDeviceTypes property value. Contains properties for Windows device type. | def applicable_device_types
return @applicable_device_types
end | [
"def applicable_device_types=(value)\n @applicable_device_types = value\n end",
"def applicable_device_type\n return @applicable_device_type\n end",
"def list_devicetypes\n Executor.execute(command_for('list', '-j', 'devicetypes')) do |json|\n SimCtl::List.new(json['devicetypes'].map { |devicetype| DeviceType.new(devicetype) })\n end\n end",
"def device_types(types)\n types\n end",
"def applicable_device_type=(value)\n @applicable_device_type = value\n end",
"def devices\n @devices ||= available_input_types.map{|input_type| input_type.devices }.flatten\n end",
"def GetDeviceTypes\n # common linux device types available on all architectures\n common_dev_types = [\"eth\", \"tr\", \"vlan\", \"br\", \"tun\", \"tap\", \"bond\"]\n\n # s390 specific device types\n s390_dev_types = [\"hsi\", \"ctc\", \"escon\", \"ficon\", \"iucv\", \"qeth\", \"lcs\"]\n\n # device types which cannot be present on s390 arch\n s390_unknown_dev_types = [\n \"arc\",\n \"bnep\",\n \"dummy\",\n \"fddi\",\n \"myri\",\n \"usb\",\n \"wlan\",\n \"ib\"\n ]\n\n # ia64 specific device types\n ia64_dev_types = [\"xp\"]\n\n dev_types = deep_copy(common_dev_types)\n\n if Arch.s390\n dev_types = Convert.convert(\n Builtins.merge(dev_types, s390_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n else\n if Arch.ia64\n dev_types = Convert.convert(\n Builtins.merge(dev_types, ia64_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n end\n\n dev_types = Convert.convert(\n Builtins.merge(dev_types, s390_unknown_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n end\n\n Builtins.foreach(dev_types) do |device|\n if !Builtins.contains(\n Builtins.splitstring(Ops.get(@DeviceRegex, \"netcard\", \"\"), \"|\"),\n device\n )\n Builtins.y2error(\n \"%1 is not contained in DeviceRegex[\\\"netcard\\\"]\",\n device\n )\n end\n end\n\n deep_copy(dev_types)\n end",
"def platform_types\n get(\"platform-types\")[\"types\"]\n end",
"def device_type\n return @device_type\n end",
"def platform_types\n @platform_types.to_hash\n end",
"def device_statuses\n return @device_statuses\n end",
"def available_types\n # TODO pull this from DB or config\n [\n :kiosk,\n :ride,\n :store,\n :restaurant\n ]\n end",
"def devices\n @devices ||= available_output_types.map{|output_type| output_type.devices }.flatten\n end",
"def device_categories\n return @device_categories\n end",
"def cpu_types\n @cpu_types\n end",
"def windows10_devices\n return @windows10_devices\n end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def get_supported_file_types\n response = api.get(url_misc('supported-file-types'))\n response\n end",
"def devices_by_name\n @devices_by_name ||= (\n available_input_types.each_with_object( Hash.new ) do |input_type,hash|\n hash.merge!( input_type.devices_by_name )\n end\n )\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the applicableDeviceTypes property value. Contains properties for Windows device type. | def applicable_device_types=(value)
@applicable_device_types = value
end | [
"def applicable_device_type=(value)\n @applicable_device_type = value\n end",
"def applicable_device_types\n return @applicable_device_types\n end",
"def supported_devices=(devices)\n supported_devices = SUPPORTED_DEVICES[devices]\n settings['TARGETED_DEVICE_FAMILY'] = supported_devices\n end",
"def device_types(types)\n types\n end",
"def supported_attribute_types=(value)\n @supported_attribute_types = value\n end",
"def applicable_device_type\n return @applicable_device_type\n end",
"def set_UsageTypes(value)\n set_input(\"UsageTypes\", value)\n end",
"def device_type=(value)\n @device_type = value\n end",
"def set_Types(value)\n set_input(\"Types\", value)\n end",
"def target_types=(value)\n @target_types = value\n end",
"def media_types=(value)\n @media_types = value\n end",
"def supported_provisioning_types=(value)\n @supported_provisioning_types = value\n end",
"def list_devicetypes\n Executor.execute(command_for('list', '-j', 'devicetypes')) do |json|\n SimCtl::List.new(json['devicetypes'].map { |devicetype| DeviceType.new(devicetype) })\n end\n end",
"def client_app_types=(value)\n @client_app_types = value\n end",
"def windows10_devices=(value)\n @windows10_devices = value\n end",
"def intune_devices=(value)\n @intune_devices = value\n end",
"def GetDeviceTypes\n # common linux device types available on all architectures\n common_dev_types = [\"eth\", \"tr\", \"vlan\", \"br\", \"tun\", \"tap\", \"bond\"]\n\n # s390 specific device types\n s390_dev_types = [\"hsi\", \"ctc\", \"escon\", \"ficon\", \"iucv\", \"qeth\", \"lcs\"]\n\n # device types which cannot be present on s390 arch\n s390_unknown_dev_types = [\n \"arc\",\n \"bnep\",\n \"dummy\",\n \"fddi\",\n \"myri\",\n \"usb\",\n \"wlan\",\n \"ib\"\n ]\n\n # ia64 specific device types\n ia64_dev_types = [\"xp\"]\n\n dev_types = deep_copy(common_dev_types)\n\n if Arch.s390\n dev_types = Convert.convert(\n Builtins.merge(dev_types, s390_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n else\n if Arch.ia64\n dev_types = Convert.convert(\n Builtins.merge(dev_types, ia64_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n end\n\n dev_types = Convert.convert(\n Builtins.merge(dev_types, s390_unknown_dev_types),\n :from => \"list\",\n :to => \"list <string>\"\n )\n end\n\n Builtins.foreach(dev_types) do |device|\n if !Builtins.contains(\n Builtins.splitstring(Ops.get(@DeviceRegex, \"netcard\", \"\"), \"|\"),\n device\n )\n Builtins.y2error(\n \"%1 is not contained in DeviceRegex[\\\"netcard\\\"]\",\n device\n )\n end\n end\n\n deep_copy(dev_types)\n end",
"def device_categories=(value)\n @device_categories = value\n end",
"def devices=(value)\n @devices = value\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the committedContainedApps property value. The collection of contained apps in the committed mobileAppContent of a windowsUniversalAppX app. | def committed_contained_apps
return @committed_contained_apps
end | [
"def contained_apps\n return @contained_apps\n end",
"def committed_contained_apps=(value)\n @committed_contained_apps = value\n end",
"def contained_apps=(value)\n @contained_apps = value\n end",
"def managed_apps\n return @managed_apps\n end",
"def apps\n return @apps\n end",
"def compliant_apps_list\n return @compliant_apps_list\n end",
"def mobile_apps\n return @mobile_apps\n end",
"def installed_apps\n return @installed_apps\n end",
"def all_apps\n manifest[:applications]\n end",
"def detected_apps\n return @detected_apps\n end",
"def applications\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qApp FROM qryResults GROUP BY qApp ORDER BY qApp')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qApp']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Applications error (#{e.message}).\")\n end\n end\n\n return list\n end",
"def child_apps\n return @child_apps\n end",
"def include_applications\n return @include_applications\n end",
"def client_applications\n return @client_applications\n end",
"def sub_app_list\n if batch_connect.sub_app_list.size == 1\n batch_connect.sub_app_list\n else\n batch_connect.sub_app_list.select { |app| app.sub_app == sub_app_name }\n end\n end",
"def dock_apps(user = CURRENTUSER)\n\n\tplist = CFPropertyList::List.new(:file => \"/Users/#{user}/Library/Preferences/com.apple.dock.plist\")\n\tresults=CFPropertyList.native_types(plist.value)\n\tapps=[]\n\tfor key, value in results['persistent-apps']\n\t\tfor key, value in key\n\t\t\tif value.class == Hash\n\t\t\t\tfor x, y in value\n\t\t\t\t\tif x == \"file-label\"\n\t\t\t\t\t\tapps.push(y)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn apps\nend",
"def apps_single_app_mode_list\n return @apps_single_app_mode_list\n end",
"def known_client_applications\n return @known_client_applications\n end",
"def apps\n @apps ||= Kibo::System.heroku(\"apps\", :quiet).\n split(/\\n/).\n reject { |line| line.empty? || line =~ /=== / }.\n map { |line| line.split(\" \").first }\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the committedContainedApps property value. The collection of contained apps in the committed mobileAppContent of a windowsUniversalAppX app. | def committed_contained_apps=(value)
@committed_contained_apps = value
end | [
"def contained_apps=(value)\n @contained_apps = value\n end",
"def committed_contained_apps\n return @committed_contained_apps\n end",
"def managed_apps=(value)\n @managed_apps = value\n end",
"def contained_apps\n return @contained_apps\n end",
"def apps=(value)\n @apps = value\n end",
"def include_applications=(value)\n @include_applications = value\n end",
"def apps_block_windows_store_originated_apps=(value)\n @apps_block_windows_store_originated_apps = value\n end",
"def installed_apps=(value)\n @installed_apps = value\n end",
"def applications=(value)\n @applications = value\n end",
"def compliant_apps_list=(value)\n @compliant_apps_list = value\n end",
"def known_client_applications=(value)\n @known_client_applications = value\n end",
"def child_apps=(value)\n @child_apps = value\n end",
"def mobile_apps=(value)\n @mobile_apps = value\n end",
"def client_applications=(value)\n @client_applications = value\n end",
"def detected_apps=(value)\n @detected_apps = value\n end",
"def targeted_managed_app_configurations=(value)\n @targeted_managed_app_configurations = value\n end",
"def pre_authorized_applications=(value)\n @pre_authorized_applications = value\n end",
"def applications=(list)\n if list.class == Array\n list = List.new(list)\n list.each_with_index do |value, index|\n if value.is_a?(Hash)\n list[index] = Application.new(value)\n end\n end\n end\n @applications = list\n end",
"def documents_block_managed_documents_in_unmanaged_apps=(value)\n @documents_block_managed_documents_in_unmanaged_apps = value\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instantiates a new windowsUniversalAppX and sets the default values. | def initialize()
super
@odata_type = "#microsoft.graph.windowsUniversalAppX"
end | [
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsUniversalAppXContainedApp\"\n end",
"def initialize(application_name)\n @application_name = application_name\n\n # Get the message id's for the Skype Control messages\n @api_discover_message_id =\n Win32::RegisterWindowMessage('SkypeControlAPIDiscover')\n @api_attach_message_id =\n Win32::RegisterWindowMessage('SkypeControlAPIAttach')\n\n instance = Win32::GetModuleHandle(nil)\n\n @window_class = Win32::WNDCLASSEX.new\n @window_class[:style] = Win32::CS_HREDRAW | Win32::CS_VREDRAW\n @window_class[:lpfnWndProc] = method(:message_pump)\n @window_class[:hInstance] = instance\n @window_class[:hbrBackground] = Win32::COLOR_WINDOW\n @window_class[:lpszClassName] =\n FFI::MemoryPointer.from_string 'ruby-skype'\n\n @window = Win32::CreateWindowEx(Win32::WS_EX_LEFT,\n FFI::Pointer.new(@window_class.handle),\n 'ruby-skype',\n Win32::WS_OVERLAPPEDWINDOW,\n 0, 0, 0, 0, Win32::NULL, Win32::NULL,\n instance, nil)\n end",
"def from_null\n new(0) #Zero never is a valid window ID. Even the root window has another ID.\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsInformationProtectionDesktopApp\"\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsAppXAppAssignmentSettings\"\n end",
"def create_dummy_window\n wy = @help_window.height\n ww = Graphics.width / 2\n wh = Graphics.height - wy\n @dummy_window = Window_Base.new(0, wy, ww, wh)\n @dummy_window.viewport = @viewport\n end",
"def create_main_ui\n @main_ui = MainUI.new(@viewport)\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsWebApp\"\n end",
"def initialize(*args)\n initialize_rails_with_watir *args\n end",
"def initialize()\n props = project_properties\n \n @app_id = props[:id]\n @app_name = props[:name]\n @app_is_desktop = props[:desktop]\n end",
"def init\n p 9\n window_root = screen[:root];\n p window_root\n mask = XCB::CW_EVENT_MASK;\n values= ary2pary([ ROOT_WINDOW_EVENT_MASK]);\n p 8\n cookie = XCB::change_window_attributes_checked(connection, window_root, mask, values);\n p cookie\n p connection\n \n error = XCB::request_check(connection, cookie);\n \n XCB::flush(connection);\n p 8\n if error.to_ptr != FFI::Pointer::NULL\n p 88\n on_abort(0)\n end\n \n manage_existing() \n end",
"def test_default\n w = Window_Selectable_Implemented.new(0,0,160,128,$data_items.compact)\n @windows.push(w)\n end",
"def create_base_ui\n @base_ui = UI::GenericBase.new(@viewport, button_texts)\n end",
"def create_librairies_window\n @librairies_window = Window_LibrairiesCommand.new(SUBWINDOW_X, LIBRAIRIES_WINDOW_Y)\n end",
"def initialize(app_root, options = {})\n\t\tsuper()\n\t\t@app_root = app_root\n\t\t@canonicalized_app_root = canonicalize_path(app_root)\n\t\t@options = sanitize_spawn_options(options)\n\t\t@lower_privilege = @options[\"lower_privilege\"]\n\t\t@lowest_user = @options[\"lowest_user\"]\n\t\t@environment = @options[\"environment\"]\n\t\tself.max_idle_time = DEFAULT_APP_SPAWNER_MAX_IDLE_TIME\n\t\tassert_valid_app_root(@app_root)\n\t\tdefine_message_handler(:spawn_application, :handle_spawn_application)\n\tend",
"def init!\n @app = APP_SLICE || ''\n end",
"def test_default\n w = Window_Confirmation.new(0,0,320,nil)\n @windows.push(w)\n return true\n end",
"def create_base_ui\n @base_ui = UI::GenericBase.new(@viewport, button_texts)\n auto_adjust_button\n end",
"def window\n @window ||= UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the identityName property value. The Identity Name. | def identity_name
return @identity_name
end | [
"def identity_name=(value)\n @identity_name = value\n end",
"def identity\n if identity_attr = self.class.identity_attr\n send(identity_attr)\n else\n name\n end\n end",
"def name\n \"identity\"\n end",
"def identity(name = nil)\n if name\n @identity = name\n else\n @identity || :id\n end\n end",
"def identity()\n\t\t\treturn @metadata.attributes[:identity].to_i\n\t\tend",
"def identity\n return @identity\n end",
"def name\n n = read_attribute(:name)\n return 'using OpenID' if using_open_id? and n.blank?\n n\n end",
"def username_from_openid_identity(identity)\n identity.split('/').last\n end",
"def name\n @name || object_id.to_s\n end",
"def package_identity_name\n return @package_identity_name\n end",
"def identity_resource_identifier\n return @identity_resource_identifier\n end",
"def entity_name\n @entity[:name]\n end",
"def package_identity_name=(value)\n @package_identity_name = value\n end",
"def identifier\n read_attribute(:name).downcase.gsub(/[^a-z0-9\\-]+/, '')\n end",
"def user_name\n return User.find(user_id).name\n end",
"def name_id\r\n self.response_doc.xpath(\"//saml:Subject/saml:NameID\", 'saml' => \"urn:oasis:names:tc:SAML:2.0:assertion\").text\r\n end",
"def user_name\n return @user_name\n end",
"def identity_type\n return @identity_type\n end",
"def name\n return nil unless model\n\n model.name\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the identityName property value. The Identity Name. | def identity_name=(value)
@identity_name = value
end | [
"def set_name(vmname)\n execute(:set_name, VMID: vm_id, VMName: vmname)\n end",
"def package_identity_name=(value)\n @package_identity_name = value\n end",
"def set_Name(value)\n set_input(\"Name\", value)\n end",
"def set_Identity(value)\n set_input(\"Identity\", value)\n end",
"def identity=(value)\n @identity = value\n end",
"def identity(name = nil)\n if name\n @identity = name\n else\n @identity || :id\n end\n end",
"def set_OpenIDName(value)\n set_input(\"OpenIDName\", value)\n end",
"def set_name(value)\n jrdd.setName(value)\n value\n end",
"def on_premises_sam_account_name=(value)\n @on_premises_sam_account_name = value\n end",
"def set_IdentityID(value)\n set_input(\"IdentityID\", value)\n end",
"def set_name(name, id = @id)\n @client.request_session(\n {\n 'player_set_name' => '',\n 'id' => id,\n 'name' => name,\n 'app_version' => @version\n },\n @sid\n )\n end",
"def set_NewIdentity(value)\n set_input(\"NewIdentity\", value)\n end",
"def set_name\n self.update(name: \"Xtra-Large Washer ##{self.id}\") unless self.name\n end",
"def display_name_set(name)\n display_name.set(name)\n end",
"def name=(value)\n value = self.class.sanitize_name(value)\n self[:_id] = value.upcase\n super(value)\n end",
"def set_node_name(node_id:, name:)\n {\n method: \"DOM.setNodeName\",\n params: { nodeId: node_id, name: name }.compact\n }\n end",
"def name=(key_name)\n raise ArgumentError, t(\"key_name_type\") unless key_name.is_a?(String)\n\n @name = key_name\n end",
"def setLabelName(labelName)\n\t\t\n\t\t\t\t\t@labelName = labelName\n\t\t\t\n\t\t\t\tend",
"def identity_name\n return @identity_name\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the identityPublisherHash property value. The Identity Publisher Hash. | def identity_publisher_hash
return @identity_publisher_hash
end | [
"def identity_publisher_hash=(value)\n @identity_publisher_hash = value\n end",
"def pub_hash\n pub\n end",
"def verified_publisher_id\n return @verified_publisher_id\n end",
"def subscriber_hash(email)\n # Simple hash of the email address.\n Digest::MD5.hexdigest(email)\n end",
"def publisher_id\n @@publisher_id\n end",
"def verified_publisher_id\n return @verified_publisher_id\n end",
"def digest\n Digest::SHA1.hexdigest(@pub.to_der)\n end",
"def publicId\n @pubid\n end",
"def verified_publisher\n return @verified_publisher\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def hash\n if @hash_value.nil?\n @hash_value = (name.hash * 53) ^ version.hash\n end\n @hash_value\n end",
"def hash!\n\t\t@@email.downcase!\n\t\thash = Digest::MD5.hexdigest(@@email)\n\t\treturn hash\n\tend",
"def app_publisher\n return @app_publisher\n end",
"def hash\n data = [store.id, user.id, timestamp].join('$')\n Base64.encode64(OpenSSL::HMAC.digest('SHA256', store.private_key, data)).chomp\n end",
"def publisher_name\n return @publisher_name\n end",
"def computed_signature\n @computed_signature ||=\n Base64.strict_encode64(\n OpenSSL::HMAC.digest('sha256', @event.subscriber.secret_key, payload)\n )\n end",
"def get_hash\n msg.hash\n end",
"def sha1_hash\n return @sha1_hash\n end",
"def hash\n @timestamp.hash\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the identityPublisherHash property value. The Identity Publisher Hash. | def identity_publisher_hash=(value)
@identity_publisher_hash = value
end | [
"def identity_publisher_hash\n return @identity_publisher_hash\n end",
"def publisher_id=(pub_id)\n @@publisher_id = pub_id\n end",
"def publisher=(value)\n @publisher = value\n end",
"def verified_publisher_id=(value)\n @verified_publisher_id = value\n end",
"def verified_publisher_id=(value)\n @verified_publisher_id = value\n end",
"def binary_sig_hash=(blob)\n # This is only a setter because of the initial choice to do things\n # eagerly. Can become an attr_accessor when we move to lazy eval.\n @binary_sig_hash = blob\n @sig_hash = hex(blob)\n end",
"def sha1_hash=(value)\n @sha1_hash = value\n end",
"def pub_hash\n pub\n end",
"def verified_publisher=(value)\n @verified_publisher = value\n end",
"def outgoing_command_hasher=(hasher)\n @out_command_hasher = hasher\n end",
"def app_publisher=(value)\n @app_publisher = value\n end",
"def hashes=(value)\n @hashes = value\n end",
"def setHash(obj)\n @hash = @hashFunc.digest(obj)\n end",
"def incoming_command_hasher=(hasher)\n @in_command_hasher = hasher\n end",
"def set_hash_id_instance(salt)\n @hid = Hashids.new(salt, 12)\n end",
"def subscriber_hash(email)\n # Simple hash of the email address.\n Digest::MD5.hexdigest(email)\n end",
"def publisher_id\n @@publisher_id\n end",
"def hash= hash\n `window.location.hash = hash`\n end",
"def copy_publisher\n self.publisher_id = self.series.publisher_id\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the identityResourceIdentifier property value. The Identity Resource Identifier. | def identity_resource_identifier
return @identity_resource_identifier
end | [
"def identity_resource_identifier=(value)\n @identity_resource_identifier = value\n end",
"def resource_id\n return @resource_id\n end",
"def resource_identity\n new_resource.identity.to_s\n rescue => e\n \"unknown identity (due to #{e.class})\"\n end",
"def resource_id=(value)\n @resource_id = value\n end",
"def get_id \n self.resource_id\n end",
"def resourceid \n [account, kind, identifier].join ':'\n end",
"def resource_id\n '%s:%s' % [resource_type, id]\n end",
"def resource_id\n return \"%s:%s\" % [self.resource_type, self.id]\n end",
"def identifier\n rdf_resource.to_s\n end",
"def provider_resource_id\n return @provider_resource_id\n end",
"def polymorphic_id_for(resource)\n value_for(resource).id\n end",
"def amazon_resource_id\n return @amazon_resource_id\n end",
"def primary_userid\n string_property(:rnp_key_get_primary_uid)\n end",
"def physical_resource_id\n \"#{self.class.name.split('::').last}-#{Carnivore.uuid}\"\n end",
"def identifier\n identifier = self[:identifier]\n if identifier.blank?\n identifier = self[:identifier] = UUID.generate\n end\n identifier\n end",
"def id\n return resource[:id].to_s if resource[:id].present? && resource[:id]&.is_a?(::Valkyrie::ID)\n return \"\" unless resource.respond_to?(:alternate_ids)\n\n resource.alternate_ids.first.to_s\n end",
"def identifier\n @json['projectRole']['meta']['identifier']\n end",
"def identity()\n\t\t\treturn @metadata.attributes[:identity].to_i\n\t\tend",
"def primary_key\n @resource_options.fetch :primary_key, :\"#{singular_resource_name}_id\"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the identityResourceIdentifier property value. The Identity Resource Identifier. | def identity_resource_identifier=(value)
@identity_resource_identifier = value
end | [
"def resource_id=(value)\n @resource_id = value\n end",
"def identity_resource_identifier\n return @identity_resource_identifier\n end",
"def amazon_resource_id=(value)\n @amazon_resource_id = value\n end",
"def target_resource_id=(value)\n @target_resource_id = value\n end",
"def provider_resource_id=(value)\n @provider_resource_id = value\n end",
"def identifier=(value)\n setId(value)\n end",
"def identifier=(value)\n @identifier = value\n end",
"def identifier=(value) #:nodoc:\n @identifier = value\n end",
"def imageidentifier=(identifier)\n self.add_option(key: :imageidentifier, value: identifier)\n identifier\n end",
"def imageidentifier=(identifier)\n @instructions[:imageidentifier] = identifier\n identifier\n end",
"def enterprise_cloud_print_resource_identifier=(value)\n @enterprise_cloud_print_resource_identifier = value\n end",
"def enterprise_cloud_print_mopria_discovery_resource_identifier=(value)\n @enterprise_cloud_print_mopria_discovery_resource_identifier = value\n end",
"def resource=(value)\n @resource = value\n end",
"def identity_metadata=(identity_metadata)\n @identity_metadata = identity_metadata\n end",
"def resource_app_id=(value)\n @resource_app_id = value\n end",
"def identifier=(arg)\n _unwrap.identifier = Nanoc::Core::Identifier.from(arg)\n end",
"def product_bundle_identifier=(identifier)\n settings['PRODUCT_BUNDLE_IDENTIFIER'] = identifier\n end",
"def resource_scope_id=(value)\n @resource_scope_id = value\n end",
"def set_identifiers\n identifier.tap do |i|\n i.value = user.icn\n i.system = SYSTEM_ID\n i.type = identifier_type\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the identityVersion property value. The identity version. | def identity_version
return @identity_version
end | [
"def identity_version=(value)\n @identity_version = value\n end",
"def version_id\n return @version_id\n end",
"def version_number\n return @version_number\n end",
"def version_id\n self.get_column(\"VersionId\")\n end",
"def version_number\n @version_number\n end",
"def version_id\n data.version_id\n end",
"def version\n version_property ? version_property.ruby_value : nil\n end",
"def version_number\n version && version.to_f\n end",
"def version_id=(value)\n @version_id = value\n end",
"def version\n metadata_item(\"version\")\n end",
"def version_code\n return @version_code\n end",
"def identity()\n\t\t\treturn @metadata.attributes[:identity].to_i\n\t\tend",
"def getVersion()\n aid = basic_openattr(@id,\"OMX_VERSION\")\n attrOut = FFI::MemoryPointer.new(H5Types.hsize_t)\n sv = get_type(aid)\n oo = basic_readattr(aid,sv,attrOut)\n raise InvalidFile.new(\"OMX_VERSION Attribute not found\") if oo < 0\n return(attrOut.read_string())\n end",
"def __version_property\n @__version_property ||= :version\n end",
"def getVersion()\n @obj.getVersion()\n end",
"def acc_version\n identifiers.acc_version\n end",
"def version_id\n self.get_column(\"Entry_ID/Version\")\n end",
"def version_property\n @version_property ||= RiCal::PropertyValue::Text.convert(self, \"2.0\")\n end",
"def application_version\n return @application_version\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the identityVersion property value. The identity version. | def identity_version=(value)
@identity_version = value
end | [
"def version_id=(value)\n @version_id = value\n end",
"def version=(value)\n @version = value\n end",
"def version=(value)\n @version = value\n end",
"def version_number=(value)\n @version_number = value\n end",
"def version_number=(value)\n @version_number = value\n end",
"def setVersion(version)\r\n\t\t\t\t\t@version = version\r\n\t\t\t\tend",
"def set_Version(value)\n set_input(\"Version\", value)\n end",
"def signature_version=(value)\n @signature_version = value\n end",
"def version=(version)\n mutate_config(:version) { version.dup }\n end",
"def version=(version) # :nodoc:\n @fields['version'] = version.to_s\n end",
"def set_version\n config[SET_VERSION]\n end",
"def identity_version\n return @identity_version\n end",
"def set_version\n self.version = 0\n end",
"def requested_access_token_version=(value)\n @requested_access_token_version = value\n end",
"def ip_version=(value)\n @ip_version = value\n end",
"def identity=(value)\n @identity = value\n end",
"def version=(version)\n raise ArgumentError, \"Invalid SOAP version: #{version}\" unless SOAP::Versions.include? version\n @version = version\n end",
"def set_version(active_version)\r\n fail \"Version must be a positive integer\" unless version.to_s.is_positive_integer?\r\n fail \"Can't set negative version\" if active_version < 0\r\n fail \"This version of a description does not exist\" unless descriptions.size >= active_version\r\n\r\n @version = active_version-1\r\n end",
"def application_version=(value)\n @application_version = value\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the isBundle property value. Whether or not the app is a bundle. | def is_bundle
return @is_bundle
end | [
"def bundled?\n $BUNDLE || ENV.key?(\"BUNDLE\")\n end",
"def is_bundle=(value)\n @is_bundle = value\n end",
"def bundle_exists?\n File.exists? self.bundle_dir\n end",
"def bundler?\n enabled?(:bundler)\n end",
"def bundle?\n @product_composition.human == \"MultipleComponentRetailProduct\"\n end",
"def bundler?\n @bundler ||= File.exist?(\"#{ Dir.pwd }/Gemfile\")\n end",
"def should_bundle?\n StudyFileBundle::REQUIRE_BUNDLE.include?(file_type)\n end",
"def cached_bundle?(name)\n cached_bundles.include?(name.to_s)\n end",
"def bundle\n return @bundle\n end",
"def bundle\n self.class.bundle\n end",
"def not_priced?\n bundle? || has_variants?\n end",
"def is_bundle_parent?\n if self.study_file_bundle.present?\n self.study_file_bundle.parent == self\n else\n false\n end\n end",
"def bundle_name; bundle.bundle_name; end",
"def product_bundle_member?\n self.product_bundles.any?\n end",
"def bundle\n @bundle ||= Bundle.load(@path)\n end",
"def bundle_identifier\n @app.bundleIdentifier\n end",
"def bundle_id\n return @bundle_id\n end",
"def bundle_identifier\n app.bundle_identifier\n end",
"def bundle_id\n plist['bundleid'] if plist['bundleid'] != ''\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the isBundle property value. Whether or not the app is a bundle. | def is_bundle=(value)
@is_bundle = value
end | [
"def is_bundle\n return @is_bundle\n end",
"def bundle=(value)\n @bundle = value\n end",
"def bundled?\n $BUNDLE || ENV.key?(\"BUNDLE\")\n end",
"def set_bundle(bundle, tags)\n args = [\"bundle=#{u(bundle)}\", \"tags=#{u(tags)}\"]\n get('tags/bundles/set?' << args.join('&'))\n nil\n end",
"def set_bundle(name, tags)\n options = { :bundle => name, :tags => tags }\n doc = process_request(API_URL_SET_BUNDLE + options.to_query)\n doc.at('result').inner_html == 'ok'\n end",
"def bundle_id=(value)\n @bundle_id = value\n end",
"def bundles=(value)\n @bundles = value\n end",
"def should_bundle?\n StudyFileBundle::REQUIRE_BUNDLE.include?(file_type)\n end",
"def bundler?\n enabled?(:bundler)\n end",
"def bundle?\n @product_composition.human == \"MultipleComponentRetailProduct\"\n end",
"def bundle_exists?\n File.exists? self.bundle_dir\n end",
"def product_bundle_identifier=(identifier)\n settings['PRODUCT_BUNDLE_IDENTIFIER'] = identifier\n end",
"def bundle\n self.class.bundle\n end",
"def allow_bundle_names\n @attributes[:allow_bundle_names]\n end",
"def cached_bundle?(name)\n cached_bundles.include?(name.to_s)\n end",
"def bundle_for(bundle_name)\n bundle_name = bundle_name.to_sym\n @bundles ||= {}\n return @bundles[bundle_name] ||= Bundle.new(bundle_name, environment_for(bundle_name))\n end",
"def bundle\n @bundle ||= Bundle.load(@path)\n end",
"def bundler?\n @bundler ||= File.exist?(\"#{ Dir.pwd }/Gemfile\")\n end",
"def no_bundler\n @bundler = false\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the minimumSupportedOperatingSystem property value. The minimum operating system required for a Windows mobile app. | def minimum_supported_operating_system
return @minimum_supported_operating_system
end | [
"def minimum_supported_operating_system=(value)\n @minimum_supported_operating_system = value\n end",
"def mobile_os_minimum_version\n return @mobile_os_minimum_version\n end",
"def minimum_required_os_version\n return @minimum_required_os_version\n end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def minimum_supported_windows_release\n return @minimum_supported_windows_release\n end",
"def minimum_supported_windows_release=(value)\n @minimum_supported_windows_release = value\n end",
"def major_os\n @major_os ||= major_version_component(@os)\n return @major_os\n end",
"def mobile_os_minimum_version=(value)\n @mobile_os_minimum_version = value\n end",
"def min_sdk_version\n info.try(:[], 'MinimumOSVersion')\n end",
"def operating_system\n return @operating_system\n end",
"def mobile_os_maximum_version\n return @mobile_os_maximum_version\n end",
"def minimum_required_os_version=(value)\n @minimum_required_os_version = value\n end",
"def operating_system_version\n return @operating_system_version\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def minimum_warning_os_version\n return @minimum_warning_os_version\n end",
"def os\n # WMP 6.4\n if classic?\n case version.to_a[3]\n when 3564, 3925 then \"Windows 98\"\n when 3857 then \"Windows 9x\"\n when 3936 then \"Windows XP\"\n when 3938 then \"Windows 2000\"\n else \"Windows\"\n end\n\n # WMP 7/7.1\n elsif version.to_a[0] == 7\n case version.to_a[3]\n when 3055 then \"Windows 98\"\n else \"Windows\"\n end\n\n # WMP 8 was also known as \"Windows Media Player for Windows XP\"\n elsif version.to_a[0] == 8\n \"Windows XP\"\n\n # WMP 9/10\n elsif version.to_a[0] == 9 || version.to_a[0] == 10\n case version.to_a[3]\n when 2980 then \"Windows 98/2000\"\n when 3268, 3367, 3270 then \"Windows 2000\"\n when 3802, 4503 then \"Windows XP\"\n else \"Windows\"\n end\n\n # WMP 11/12\n elsif version.to_a[0] == 11 || version.to_a[0] == 12\n case version.to_a[2]\n when 9841, 9858, 9860,\n 9879 then \"Windows 10\"\n when 9651 then \"Windows Phone 8.1\"\n when 9600 then \"Windows 8.1\"\n when 9200 then \"Windows 8\"\n when 7600, 7601 then \"Windows 7\"\n when 6000, 6001, 6002 then \"Windows Vista\"\n when 5721 then \"Windows XP\"\n else \"Windows\"\n end\n else\n \"Windows\"\n end\n end",
"def get_target_platform\r\n return get_java_property('os.name')\r\n end",
"def operating_system_name\n @operating_system_name\n end",
"def platform_version\n version = capabilities['platformVersion']\n version.nil? ? nil : version.to_s\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the minimumSupportedOperatingSystem property value. The minimum operating system required for a Windows mobile app. | def minimum_supported_operating_system=(value)
@minimum_supported_operating_system = value
end | [
"def minimum_supported_windows_release=(value)\n @minimum_supported_windows_release = value\n end",
"def minimum_supported_operating_system\n return @minimum_supported_operating_system\n end",
"def mobile_os_minimum_version=(value)\n @mobile_os_minimum_version = value\n end",
"def minimum_required_os_version=(value)\n @minimum_required_os_version = value\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def operating_system=(value)\n @operating_system = value\n end",
"def minimum_required_os_version\n return @minimum_required_os_version\n end",
"def mobile_os_minimum_version\n return @mobile_os_minimum_version\n end",
"def minimum_supported_windows_release\n return @minimum_supported_windows_release\n end",
"def minimum_warning_os_version=(value)\n @minimum_warning_os_version = value\n end",
"def operating_system_version=(value)\n @operating_system_version = value\n end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def min_sdk_version\n info.try(:[], 'MinimumOSVersion')\n end",
"def unsupported_o_sversion_devices=(value)\n @unsupported_o_sversion_devices = value\n end",
"def mobile_os_maximum_version=(value)\n @mobile_os_maximum_version = value\n end",
"def windows10_devices=(value)\n @windows10_devices = value\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def windows_mobile_restriction=(value)\n @windows_mobile_restriction = value\n end",
"def operating_system_name=(value)\n @operating_system_name = value\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the old profile page had review filter on the main profile page. These are the params used to come across in the query string. Here I'm redirecting to the new profile reviews page, WITHOUT those parameters...I am not attempting to translate the old param values in the the new ones. | def redirect_old_review_filters
old_params = [:min_rating, :N, :Ne, :Nf, :Nrc, :Ns, :page, :sort]
if old_params.inject(false) { |memo, key| memo |= params.has_key?(key) }
permanent_redirect_to :profile_mode => @profile_mode,
:screen_name => params[:screen_name],
:controller => 'profile_reviews', :action => 'index', :N => params[:N]
return false
end
end | [
"def posting_filter\nx\n review = ReviewType.find(params[\"review_type_id\"])\n\n if review.name != 'Placement'\n redirect_to(:action => 'post_review',\n :design_id => params[\"design_id\"],\n :review_type_id => params[\"review_type_id\"])\n else\n flash[:design_id] = params[\"design_id\"]\n flash[:review_type_id] = params[\"review_type_id\"]\n redirect_to(:action => 'placement_routing_post')\n end\n\n end",
"def cleanup_parameters\n\n changed = false\n original_size = params.to_unsafe_h.size\n\n # Eliminate \"noise\" parameters (usually generated from the advanced search\n # form), including 'op=\"AND\"' since this is always the default logical\n # operation.\n params.delete_if { |k, v| k.blank? || v.blank? }\n %w(utf8).each { |k| params.delete(k) }\n params.delete(:op) if params[:op] == 'AND'\n reset_search = (params.delete(:commit) == 'Search')\n debug_session = params.delete(:debug_session)\n\n # Update session if indicated.\n case debug_session.to_s.downcase\n when 'true' then session[:debug_session] = true\n when 'false' then session.delete(:debug_session)\n end\n\n # If parameters were removed, redirect to the corrected URL.\n changed ||= (params.to_unsafe_h.size != original_size)\n will_redirect if changed\n\n end",
"def redirect_users\n uri = URI(params[:launch_presentation_return_url].to_s)\n uri.query ||= \"\"\n case params[:with_msg]\n when \"lti_msg\"\n new_param = [\"lti_msg\", \"Most things in here don't react well to bullets.\"]\n when \"lti_log\"\n new_param = [\"lti_log\", \"One ping only.\"]\n when \"err_msg\"\n new_param = [\"lti_errormsg\", \"Who's going to save you, Junior?!\"]\n when \"err_log\"\n new_param = [\"lti_errorlog\", \"The floor's on fire... see... *&* the chair.\"]\n else\n new_param = []\n end\n new_query_ar = URI.decode_www_form(uri.query) << new_param\n uri.query = URI.encode_www_form(new_query_ar)\n redirect_to uri.to_s\n end",
"def cleanup_parameters\n\n changed = false\n original_size = params.to_unsafe_h.size\n\n # Eliminate \"noise\" parameters (usually generated from the advanced search\n # form), including 'op=\"AND\"' since this is always the default logical\n # operation.\n params.delete_if { |k, v| k.blank? || v.blank? }\n %w(utf8).each { |k| params.delete(k) }\n params.delete(:op) if params[:op] == 'AND'\n params.delete(:commit)\n debugging = params.delete(:virgo_debug)\n\n # Update session if indicated.\n case debugging.to_s.downcase\n when 'true' then session[:virgo_debug] = true\n when 'false' then session.delete(:virgo_debug)\n end\n\n # If parameters were removed, redirect to the corrected URL.\n changed ||= (params.to_unsafe_h.size != original_size)\n will_redirect if changed\n\n end",
"def set_review_status # :norobots:\n pass_query_params\n id = params[:id]\n desc = NameDescription.find(id)\n if is_reviewer?\n desc.update_review_status(params[:value])\n end\n redirect_to(:action => 'show_name', :id => desc.name_id,\n :params => query_params)\n end",
"def set_review_status # :norobots:\n pass_query_params\n id = params[:id].to_s\n desc = NameDescription.find(id)\n if is_reviewer?\n desc.update_review_status(params[:value])\n end\n redirect_to(:action => 'show_name', :id => desc.name_id,\n :params => query_params)\n end",
"def filter_redirect; end",
"def cleanup_pagination\n original_count = params.keys.size\n\n # Eliminate :offset if not still paginating.\n if params[:offset].present?\n params.delete(:offset) unless params[:start] || params[:prev_id]\n end\n\n # If parameters were removed, redirect to the corrected URL.\n will_redirect unless params.keys.size == original_count\n end",
"def strip_reheat_params(env)\n return unless param = Storehouse.reheat_param\n\n query = env['QUERY_STRING']\n query = query.gsub(/#{param}=?([^&]+)?&?/, '')\n env['QUERY_STRING'] = query\n end",
"def cleanup_parameters\n original_count = params.keys.size\n\n # Eliminate \"noise\" parameters.\n params.delete_if { |k, v| k.blank? || v.blank? }\n %w[utf8 commit].each { |k| params.delete(k) }\n\n # If parameters were removed, redirect to the corrected URL.\n will_redirect unless params.keys.size == original_count\n end",
"def sanitize_page_params\n params[:per_page] = params[:per_page].to_i\n params[:go_to_page] = params[:go_to_page].to_i\n end",
"def vanity_query_parameter_filter\n query_params = request.query_parameters\n if request.get? && query_params[:_vanity] # rubocop:todo Style/GuardClause\n hashes = Array(query_params.delete(:_vanity))\n Vanity.playground.experiments.each do |_id, experiment|\n if experiment.respond_to?(:alternatives)\n experiment.alternatives.each do |alt|\n if hashes.delete(experiment.fingerprint(alt))\n experiment.chooses(alt.value)\n break\n end\n end\n end\n break if hashes.empty?\n end\n path_parts = [url_for, query_params.to_query]\n redirect_to(path_parts.join('?'))\n end\n end",
"def legacy_redirect\n community = Community.where(\"lower(legacy_url) = ?\", params[:legacy_community_name].to_s.downcase).first\n \n if community\n redirect_to community, status: 301\n elsif college = College.where(\"lower(short_name) = ?\", params[:legacy_college_name].to_s.downcase).first\n redirect_to college, status: 301\n else\n flash[:notice] = \"The link you clicked is out of date! We couldn't figure out where you wanted to go...\"\n redirect_to listings_url, status: 301\n end\n end",
"def redirect_hash_facet_params\n if params[:f].respond_to?(:transform_values) && params[:f].values.any? { |x| x.is_a?(Hash) }\n original_f_params = params[:f].to_unsafe_h\n corrected_params = {}\n\n corrected_params[:f] = original_f_params.transform_values do |value|\n value.is_a?(Hash) ? value.values : value\n end\n\n redirect_to helpers.safe_params_merge_url(corrected_params), :status => :moved_permanently\n end\n end",
"def redirect_to_review\n post = Post.find_by_id params[:id]\n post = Post.from_param params[:id] unless post\n redirect_to view_context.post_review_path_helper(post), status: :moved_permanently if post && post.type == 'Review' && ((post.treatment_review_id.present? && params[:treatment_summary_id].blank?) || (post.doctor_review_id.present? && params[:doctor_summary_id].blank?))\n end",
"def legacy\n redirect_to(params.update(action:'main'))\n end",
"def add_facet_params_and_redirect(field, value)\n new_params = add_facet_params(field, value)\n\n # Delete page, if needed. \n new_params.delete(:page)\n\n # Delete any request params from facet-specific action, needed\n # to redir to index action properly. \n Blacklight::Solr::FacetPaginator.request_keys.values.each do |paginator_key| \n new_params.delete(paginator_key)\n end\n new_params.delete(:id)\n\n url = params_for_url (new_params[:q].empty? ? new_params[:f] : new_params[:q].merge(new_params[:f]))\n if field.include? Blacklight.config[:facet][:a_to_z][:common_key_name]\n return url + \"&catalog_facet.prefix=\" + value\n else\n return url\n end\n end",
"def filter_redirect=(_arg0); end",
"def add_facet_params_and_redirect(field, value)\n new_params = add_facet_params(field, value)\n\n # Delete page, if needed. \n new_params.delete(:page)\n\n # Delete :qt, if needed - added to resolve NPE errors\n new_params.delete(:qt)\n\n # Delete any request params from facet-specific action, needed\n # to redir to index action properly. \n Blacklight::Solr::FacetPaginator.request_keys.values.each do |paginator_key| \n new_params.delete(paginator_key)\n end\n new_params.delete(:id)\n\n # Force action to be index. \n new_params[:action] = \"index\"\n\n new_params\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
params.require(:venue).permit(:name, :street, :city, :state, :country, :latitude, :longitude, :popularity_rating) | def venue_params
params.require(:venue).permit(:name, :street, :city, :state, :country, :latitude, :longitude, :popularity_rating)
end | [
"def venue_search_params\n params.permit(:venue_ids, :keyword)\n end",
"def region_params\n params.require(:region).permit!\n end",
"def match_state_params\n params.require(:match_state).permit(:title)\n end",
"def user_params\n params.require(:restaurant).permit(:name, :owner, :phone, \n :address, :reserveCap, :sundayOpen, :sundayClose, :mondayOpen, \n :mondayClose, :tuesdayOpen, :tuesdayClose, :wednesdayOpen,\n :wednesdayClose, :thursdayOpen, :thursdayClose, :fridayOpen,\n :fridayClose, :saturdayOpen, :saturdayClose, :password, \n :password_confirmation)\n end",
"def videogame_params \n params.require(:videogame).permit(:name, :release_date, :average_rating, :genre_id, :developer_id, :description, :system_req, :picture) \n end",
"def snake_search_params\n params.permit(:id, :name, :year, :sex, :species)\n end",
"def search_params\n params[:unit_price] = params[:unit_price].delete('.').to_i if params[:unit_price]\n params.permit(:id, :name, :description, :unit_price, :merchant_id, :created_at, :updated_at)\n # end\n\n end",
"def offense_params\n params.require(:offense).permit(:ip_address, :host_name, :email, :phone)\n end",
"def rating_params\n\t\tparams.require(:rating).permit(:ratable, :score, :user)\n\tend",
"def product_params\n params.require(:product).permit(:name, :price, :released_on)\n end",
"def vegetables_params()\n\t\tparams.require(:vegetable).permit(:name, :variety, :color, :time, :plantation_id)\n\tend",
"def event_params\n params.require(:event).permit :title,\n :location,\n :start_time,\n :end_time,\n :description\n end",
"def review_params\n params.require(:review).permit(:pet_rating,:pet_content,:user_rating, :user_content)\n end",
"def request_params\n params.require(:submission_viewing_event).permit(:map_id, :round, :link)\n end",
"def band_params_name\n params.require(:band).permit(:band_member_name)\n end",
"def create_pokemon_params\n params.require(:pokemon).permit(:id, :num, :name, :img, :height, :weight, :candy, :candy_count, :egg, :avg_spawns, :spawn_time)\n end",
"def apartment_params\n params.require(:apartment).permit(:street, :apto_number, :city, :postal_code, :state, :country, :manager_name, :manager_phone_number, :contact_hours)\n end",
"def player_state_search_params\n params.permit(:player_state_ids, :keyword)\n end",
"def edit_pokemon_params\n params.require(:pokemon).permit(:name, :img, :height, :weight, :candy, :candy_count, :egg, :avg_spawns, :spawn_time)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialiser. Cells are the cells in the object Children are other objects | def initialize(cells)
@cells = cells
@children = []
end | [
"def init_cells\n\t\t\traise \"#{self.class} has not implemented a cell initializer\"\n\t\tend",
"def initialize(cell)\n super(cell)\n end",
"def initialize_cells\n (0...@height * @width).each do |n|\n @cells[n / @width] ||= []\n @cells[n / @width][n % @width] = MazeCell.new(n % @width, n / @width)\n end\n end",
"def initialize\n @cells = Array.new(Grid.size) { Array.new(Grid.size) }\n Grid.size.times do |row_index|\n Grid.size.times do |column_index|\n coordinates = Coordinates.new(row_index, column_index)\n @cells[row_index][column_index] = Cell.new(coordinates)\n end\n end\n end",
"def setup_cells\n # The max_cols and max_rows are determined based on the window\n # dimensions passed into the GosuCell.configure_dimensions\n # method during window init\n @rows = GosuCell.max_rows\n @cols = GosuCell.max_cols\n\n @cells = []\n\n @rows.times do |row_index|\n row = []\n \n @cols.times do |col_index|\n row << GosuCell.new( row_index, col_index )\n end\n\n @cells << row\n end\n\n # Flatten the nested cell arrays so that drawing ops have a\n # slightly optimized way to iterate over all cells\n @cell_draw_array = @cells.flatten\n end",
"def initialize(cell, tentCell)\n super(cell, tentCell)\n end",
"def initialize(cellTent, cellTree)\n super(cellTent, cellTree)\n end",
"def load_cells()\n\t\t(0..@m-1).each do |row|\n\t\t\t(0..@n-1).each do |col| \n\t\t\t\t@cells [row] [col] = Cell.new(col,row)\n\t\t\tend\n\t\tend\n\tend",
"def initialize(cell, rowOrColumn)\n @column = rowOrColumn\n @cell = cell\n @row = rowOrColumn\n super()\n end",
"def cells\n @cells ||= []\n end",
"def initialize(cells, fState, type)\n\t\t@cellsPos = []\n\t\tcells.each{ |cell|\n\t\t\t@cellsPos.push({\"x\"=>cell.row,\"y\"=>cell.col})\n\t\t}\n\t\t@firstState = fState\n\t\t@type = type\n\tend",
"def initialise_cell_array\n\t\t@cells = []\n\t\t@room_map = {}\n\t\t@corridor_map = {}\n\t\t@corridor_seeds = []\n\t\t(0..width).each do |i|\n\t\t\t@cells[i] = []\n\t\t\t(0..height).each do |j|\n\t\t\t\t@cells[i][j] = Cell.new(i,j, Cell::UNALLOCATED)\n\t\t\tend\n\t\tend\n\tend",
"def initialise_cell_array\n @cells = []\n @room_map = {}\n @corridor_map = {}\n @corridor_seeds = []\n (0..width).each do |i|\n @cells[i] = []\n (0..height).each do |j|\n @cells[i][j] = Cell.new(i, j, Cell::UNALLOCATED)\n end\n end\n end",
"def initialize(cell, parent)\n @cell = cell # MazeCell object\n @parent = parent # MazeSolverCell object\n end",
"def initialize(nRow, nCol, gridAnswers, withAnswers=false)\n\t\tProcessStatus.send(\"Initialisation de la grille de jeu\")\n\t\t@gridAnswers=gridAnswers\n\t\t@rows = (0..nRow-1).map {|x|\n\t\t\t(0..nCol-1).map { |y|\n\t\t\t\tif @gridAnswers.at(x).at(y)==\"A\"\n\t\t\t\t\tCell.new(state: :tree,frozen: false,row: x,column: y)\n\t\t\t\telsif @gridAnswers.at(x).at(y)==\"T\" && withAnswers\n\t\t\t\t\tCell.new(state: :tent,frozen: false,row: x,column: y)\n\t\t\t\telsif @gridAnswers.at(x).at(y)==\"_\" && withAnswers\n\t\t\t\t\tCell.new(state: :grass,frozen: false,row: x,column: y)\n\t\t\t\telse\n\t\t\t\t\tCell.new(state: :white,frozen: false,row: x,column: y)\n\t\t\t\tend\n\t\t\t}\n\t\t}\n\t\t@cols = @rows.transpose\n\tend",
"def initialize(cells)\n\t\tself.cells = cells\n\n\t\t# Make the reverse link: each cell knows what constraints\n\t\t# applies to it.\n\t\tcells.each do |cell|\n\t\t cell.add_constraint(self)\n\t\tend\n\t end",
"def populate_cells\n @width.each do |letter|\n @height.each do |number|\n cell_coords = \"#{letter}#{number}\"\n @cells[cell_coords] = Cell.new(cell_coords)\n end\n end\n end",
"def create_cells\n # Make empty array\n @cells = Array.new(@width) { Array.new(@height) }\n for x in 0...@width\n for y in 0...@height\n # Put new cell in each element of array\n @cells[x][y] = Cell.new(x, y)\n end\n end\n end",
"def create_cells\n (\"A\"..@height).each do |rows|\n (1..@width.to_i).each do |column|\n k=\"#{rows}#{column}\"\n cells[k]=Cell.new(k)\n end\n end\n cells\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For every `redirect_from` entry, generate a redirect page | def generate_redirect_from(doc)
doc.redirect_from.each do |path|
doc.site.pages << RedirectPage.redirect_from(doc, path)
end
end | [
"def generate_redirect_from(doc)\n doc.redirect_from.each do |path|\n page = RedirectPage.redirect_from(doc, path)\n redirects[page.redirect_from] = page.redirect_to\n end\n end",
"def generate_redirect_from(doc)\n doc.redirect_from.each do |path|\n page = RedirectPage.redirect_from(doc, path)\n doc.site.pages << page\n redirects[page.redirect_from] = page.redirect_to\n end\n end",
"def generate_redirects(site)\n (site.posts.docs + site.pages + site.docs_to_write).select{|x| x.data.key? 'redirects' }.each do |p|\n p.data['redirects'].each do |r| \n redirect = RedirectPage.new(site, site.source, r, p.url)\n redirect.render(site.layouts, site.site_payload)\n redirect.write(site.dest)\n site.pages << redirect\n end \n end\n end",
"def get_redirects_for(result_map, redirects)\n\t\t\tresult_map.each do |rm|\n\t\t\t\tredirects.each do |r|\n\t\t\t\t\trm[:redirected] = r[\"to\"] if r[\"from\"] == rm[:search_term] || r[\"from\"] == rm[:normalized]\n\t\t\t\tend\n\t\t\tend\n\t\t\tresult_map\n\t\tend",
"def every_redirect_page\n every_page do |page|\n yield page if (block_given? && page.redirect?)\n end\n end",
"def redirect\n redirect_model = get_model(config['redirect_model_slug'])\n if redirect_model\n redirect_model.entries.each do |entry|\n rules = entry.custom_fields_recipe['rules']\n match = entry[rules.first['name']]\n redirect_url = entry[rules.last['name']]\n if controller.request.fullpath =~ /#{match}/\n match_data = /#{match}/.match(controller.request.fullpath)\n /#{match}/.named_captures.each do |key,value|\n redirect_url.gsub!(/\\$#{key}/, match_data[key])\n end\n controller.redirect_to redirect_url and return\n end\n end\n end\n end",
"def follow_redirects\n while last_response.status == 302\n follow_redirect!\n end\n end",
"def meta_redirects\n each_meta_redirect.to_a\n end",
"def each_view_redirects(&block)\n views.each_pair do |view, values|\n @view = view\n values[\"redirects\"].each do |redirect|\n navigate_to_view redirect\n yield redirect\n end\n end\n end",
"def filter_redirect; end",
"def save_webpage_redirects\n redirections.each do |redirection|\n redirect_url = redirection.headers[:location]\n webpage_redirect = WebpageRedirect.new(url: redirect_url)\n @webpage_response.webpage_redirects << webpage_redirect\n end\n end",
"def each_view_redirects(&block)\n views.each_pair do |view, values|\n @view = view\n values[\"redirects\"].each do |redirect|\n yield redirect\n end\n end\n end",
"def redirect_to *xs\n redirect url_to(*xs)\n end",
"def handle_redirect(response, hash, depth, &block)\n fail 'Too many redirections.' if depth > 9\n\n endpoint = response.headers['Location']\n .match(%r{^(https://.+\\.[a-z]+)/}).to_a[1]\n\n depth += 1\n # I tried to blindly follow redirection path, but it omits the job ID.\n # hash[:path] = path\n handle_request(hash, endpoint, depth, &block)\n end",
"def redirect_to_pages\n respond_to do |format|\n format.html { redirect_to(page_list_url) }\n format.xml { head :ok }\n end\n end",
"def direct_link\n link = params[:link];\n if ( link.blank? )\n add_error(\"EMPTY DIRECT LINK\");\n redirect_to :controller=>\"general\";\n return;\n end\n begin\n as = ApplicationState.unmarshal(link.strip);\n logger.info \"******* as=#{as.to_hash().to_s}\"\n logger.info \"******* as=#{as.redirect_to_hash().to_s}\"\n # TODO see that as.user equals the current user, and hadle in-equality.\n redirect_to :controller=>\"mt_company\", :action=>\"mt_req_show\", :id=>\"330\" #as.redirect_to_hash();\n return;\n rescue Exception => e\n add_error( e.message );\n add_error( \"<pre>#{params[:link]}</pre>\")\n add_error(\"BAD DIRECT LINK\");\n redirect_to :controller=>\"general\";\n end\n end",
"def redirect\n @redirect = RedirectFollower.new(original_url) \n end",
"def index\n @redirects = Redirect.all\n end",
"def follow_redirect!\n unless last_response.redirect?\n raise Error.new(\"Last response was not a redirect. Cannot follow_redirect!\")\n end\n\n get(last_response[\"Location\"])\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Responds to request with show_ok status and resource | def show_ok(resource:)
render json: resource, status: :ok, include: show_includes
end | [
"def show_ok\n controller.show_ok(resource: resource)\n end",
"def ok\n respond_with :ok, status: :ok\n end",
"def call\n return show_ok if resource_found?\n\n show_not_found\n end",
"def update_ok(resource:)\n render json: resource, status: :ok\n end",
"def ok_request object, options=nil\n render json: object,\n root: :data,\n status: :ok,\n include: options\n end",
"def ok_response\n {\n statusCode: 200,\n headers: {'Content-Type': 'application/json'},\n body: {ok: true}.to_json\n }\nend",
"def respond_with(status: nil, resource: nil)\n context.status = status\n context.resource = resource\n end",
"def is_ok?\n code == 200\n end",
"def render_success_json(status)\n if status == :no_content\n head :no_content\n else\n render :show, status: status, location: show_path\n end\n end",
"def ok?\n @status == 200\n end",
"def update_ok\n controller.update_ok(resource: resource)\n end",
"def good_request(resource)\r\n status_line = \"HTTP/1.1 200 OK\\r\\n\"\r\n size = resource.size\r\n entity_headers = \"Content-Type: text/html\\r\\nContent-Length: #{size}\\r\\n\"\r\n contents = resource\r\n responding = status_line + entity_headers + \"\\r\\n\" + contents\r\nend",
"def be_request_ok\n BeStatus.new(200)\nend",
"def render_reponse_for_long_url(long_url)\n\n respond_to do |format|\n if long_url.present?\n format.html {\n redirect_to urls_showlongurl_path(long_url: long_url.long_url)\n }\n format.json { \n render json: {\n \"message\" => \"successful\",\n \"status\" => \"200,ok\",\n \"long_url\"=> long_url.long_url\n },status: :ok \n }\n \n else\n format.html {\n flash[:message] = \"Not Found\"\n redirect_to urls_longurl_path\n }\n format.json {\n render json: {\n \"message\" => \"Not found\",\n \"status\" => \"404\"\n } , status: :not_found\n }\n end \n end\n end",
"def show\n @dummy_resource = DummyResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dummy_resource }\n end\n end",
"def make_ok_return(data)\n content_type :json\n status 200\n data.to_json\n end",
"def responds_with(message, result); end",
"def show\n respond_with subscriber\n end",
"def ok_response(asset, env); end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
compare parent to both left, right kids, recursively checking down the tree | def child_compare(parent)
unless parent.nil?
if parent.left.nil? && parent.right.nil?
nil
elsif parent.right.nil?
if parent.rating > parent.left.rating
swap(parent.left, parent)
end
else
if parent.rating > parent.left.rating || parent.rating > parent.right.rating
if parent.left.rating < parent.right.rating
swap(parent.left, parent)
child_compare(parent.left)
else
swap(parent.right, parent)
child_compare(parent.right)
end
end
end
end
end | [
"def child_compare(parent)\n\t\tunless parent.nil?\n\t\t\tif parent.left.nil? && parent.right.nil?\n\t\t\t\tnil\n\t\t\telsif parent.right.nil?\n\t\t\t\tif parent.value > parent.left.value\n\t\t\t\t\tswap(parent.left, parent)\n\t\t\t\tend\n\t\t\telse\t\t\n\t\t\t\tif parent.value > parent.left.value || parent.value > parent.right.value\n\t\t\t\t\tif parent.left.value < parent.right.value\n\t\t\t\t\t\tswap(parent.left, parent)\n\t\t\t\t\t\tchild_compare(parent.left)\n\t\t\t\t\telse\n\t\t\t\t\t\tswap(parent.right, parent)\n\t\t\t\t\t\tchild_compare(parent.right)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def parent_compare(child, parent)\n\t\tunless parent.nil?\n\t\t\tif child.value < parent.value\n\t\t\t\tswap(child, parent)\n\t\t\t\tparent_compare(child, child.parent)\n\t\t\tend \n\t\tend\n\tend",
"def asgn_left?\n OP_ASSIGN.include?(parent_type) && parent.node.children.first.equal?(node)\n end",
"def parent_causes_cycle\n traverse_down {|rq| return true if rq.id == parent_id}\n return false\n end",
"def check_if_parent(all_jobs, child, parent)\n #return false if child == nil or parent == nil\n while child != nil\n return true if all_jobs[child][\"parent\"] == parent\n child = all_jobs[child[\"parent\"]]\n end\n return false\nend",
"def hasChildren\n if (@left == nil) && (@right == nil)\n return 0\n elsif (@left != nil) && (@right != nil)\n return 2\n else\n return 1\n end\n end",
"def am_right?\n @parent && @parent.right == self\n end",
"def same_parent?(other)\n same_scope?(other) && parent_id == other.ordered_tree_node.parent_id\n end",
"def is_parent_greater_than_child(index, parent)\n @tree[parent].rating > @tree[index].rating\n end",
"def check_parent\n\t\tunless @root\n\t\t\tunless @parent.nil?\n\t\t\t\treturn @parent.value\n\t\t\tend\n\t\t\treturn false\n\t\tend\n\tend",
"def is_left_child?\n return false if is_root?\n self == parent.left_child\n end",
"def tree_equal?(other)\n self == other && children == other.children\n end",
"def current_parent?(parent)\n parent == current_parent\n end",
"def is_ancestor_of?(other)\n other.left > left && other.left <= right\n end",
"def update_parent(side)\n if @parent.left == self\n @parent.left = side\n else\n @parent.right = side\n end\n end",
"def child\n if (@left.nil? && @right.nil?) || (!@left.nil? && !@right.nil?)\n puts 'not one childed'\n elsif @left.nil?\n @right\n elsif @right.nil?\n @left\n end\n end",
"def parent_of?(node)\n node && node == tlq(false) || node == trq(false) || node == blq(false) || node == brq(false)\n end",
"def child_of?(parent); end",
"def check_left\n\t\tunless @left_child.nil?\n\t\t\treturn @left_child.value\n\t\tend\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the AWS SQS Client | def sqs
@sqs ||= Aws::SQS::Client.new
end | [
"def sqs\n @sqs ||= Aws::SQS::Client.new\n end",
"def aws_sns_client\n return @aws_sns_client if @aws_sns_client\n\n @aws_sns_client = Aws::SNS::Client.new(region: self.class.sms_aws_region)\n end",
"def sqs\n @sqs ||= Chore::Queues::SQS.sqs_client\n end",
"def new_sqs_client type\n ::AWS::SQS.new aws_identity(type)\n end",
"def sqs(opts = {})\n config = {\n stub_responses: false,\n credentials: Auth.creds\n }\n config = config.merge(opts.select { |k| config.key?(k) })\n\n @sqs ||= Aws::SQS::Client.new(config)\n end",
"def s3_client\n region = @options[:region] || ENV[\"AWS_REGION\"]\n @s3_client ||= Aws::S3::Client.new(region: region)\n end",
"def aws_client\n @aws_client ||= begin\n klass = self.class.aws_client_class\n klass && klass.new(\n region: options[:region],\n profile: options[:profile]\n )\n end\n end",
"def s3_client\n @s3 ||= Aws::S3::Client.new\n end",
"def s3_client\n @s3_client ||= Aws::S3::Client.new(\n access_key_id: @access_key_id,\n secret_access_key: @secret_access_key,\n region: @region\n )\n end",
"def aws_logs_client\n return @aws_logs_client if @aws_logs_client\n\n @aws_logs_client = Aws::CloudWatchLogs::Client.new(region: self.class.sms_aws_region)\n end",
"def client\n Aws.config.update(region: s3_configuration[:region])\n\n @s3_client ||= Aws::S3::Resource.new(resource_params)\n end",
"def client\n @asg ||= Aws::AutoScaling::Client.new(region: ENV['aws_region'])\n end",
"def initialize (aws_access_key_id, aws_secret_access_key, queue_name, params = {})\n\n @aws_access_key_id = aws_access_key_id\n @aws_secret_access_key = aws_secret_access_key\n @queue_name = queue_name\n\n @sqs = RightAws::SqsGen2.new(aws_access_key_id, aws_secret_access_key, params)\n\n @queue = @sqs.queue @queue_name\n end",
"def sqs_client_config\n params = {\n region: options[:mq_aws_region],\n endpoint: options[:mq_aws_sqs_endpoint],\n access_key_id: options[:mq_aws_access_key_id],\n secret_access_key: options[:mq_aws_secret_access_key]\n }\n params.compact\n end",
"def aws_client\n Mnemosyne::Clients::RDS.instance\n end",
"def sns\n @sns ||= Aws::SNS::Client.new(\n http_idle_timeout: @sns_keep_alive_timeout,\n http_continue_timeout: @sns_continue_timeout\n )\n end",
"def create_a_queue(sqs_client)\n puts '** Creating SQS queue... **'\n q = sqs_client.create_queue(:queue_name => 'sqs_testing')\n unless q[:queue_url].nil?\n puts '** Created SQS queue... **'\n return q\n else\n @results = {\n :reason => \"Couldn't create SQS queue\", :detail => \"\" }.to_yaml\n return nil\n end\n end",
"def run_me\n region = \"us-west-2\"\n queue_name = \"my-queue\"\n message_body = \"This is my message.\"\n\n sts_client = Aws::STS::Client.new(region: region)\n\n # For example:\n # 'https://sqs.us-west-2.amazonaws.com/111111111111/my-queue'\n queue_url = \"https://sqs.\" + region + \".amazonaws.com/\" +\n sts_client.get_caller_identity.account + \"/\" + queue_name\n\n sqs_client = Aws::SQS::Client.new(region: region)\n\n puts \"Sending a message to the queue named '#{queue_name}'...\"\n\n if message_sent?(sqs_client, queue_url, message_body)\n puts \"Message sent.\"\n else\n puts \"Message not sent.\"\n end\nend",
"def delete\n BetterSqs.logger.info \"Deleting message from SQS queue.\"\n queue_client.delete self\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the AWS SNS Client | def sns
@sns ||= Aws::SNS::Client.new(
http_idle_timeout: @sns_keep_alive_timeout,
http_continue_timeout: @sns_continue_timeout
)
end | [
"def aws_sns_client\n return @aws_sns_client if @aws_sns_client\n\n @aws_sns_client = Aws::SNS::Client.new(region: self.class.sms_aws_region)\n end",
"def sns_client_config\n params = {\n region: options[:mq_aws_region],\n endpoint: options[:mq_aws_sns_endpoint],\n access_key_id: options[:mq_aws_access_key_id],\n secret_access_key: options[:mq_aws_secret_access_key]\n }\n params.compact\n end",
"def aws_client\n Mnemosyne::Clients::RDS.instance\n end",
"def ssm_client\n @ssm_client ||= initialize_ssm_client\n end",
"def new_sqs_client type\n ::AWS::SQS.new aws_identity(type)\n end",
"def aws_client\n @aws_client ||= begin\n klass = self.class.aws_client_class\n klass && klass.new(\n region: options[:region],\n profile: options[:profile]\n )\n end\n end",
"def aws_logs_client\n return @aws_logs_client if @aws_logs_client\n\n @aws_logs_client = Aws::CloudWatchLogs::Client.new(region: self.class.sms_aws_region)\n end",
"def sqs\n @sqs ||= Aws::SQS::Client.new\n end",
"def sqs\n @sqs ||= Aws::SQS::Client.new\n end",
"def s3_client\n region = @options[:region] || ENV[\"AWS_REGION\"]\n @s3_client ||= Aws::S3::Client.new(region: region)\n end",
"def s3_client\n @s3 ||= Aws::S3::Client.new\n end",
"def s3_client\n @s3_client ||= Aws::S3::Client.new(\n access_key_id: @access_key_id,\n secret_access_key: @secret_access_key,\n region: @region\n )\n end",
"def client\n @asg ||= Aws::AutoScaling::Client.new(region: ENV['aws_region'])\n end",
"def create_client\n client_options = {\n region: 'us-east-1'\n }\n Aws::S3::Client.new(client_options)\n end",
"def client\n Aws.config.update(region: s3_configuration[:region])\n\n @s3_client ||= Aws::S3::Resource.new(resource_params)\n end",
"def cloudwatchevents_client\n log_warning('error connecting to AWS events') do\n @cloudwatchevents_client ||= Aws::CloudWatchEvents::Client.new\n end\n end",
"def client\n @client ||= Aws::EC2::Client.new(\n region: ENV['AWS_REGION'],\n access_key_id: ENV['AWS_ACCESS_KEY_ID'],\n secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']\n )\n end",
"def get_aws(name)\n topics.fetch(name)\n rescue KeyError\n puts \"No SNS topic named #{name}\"\n exit\n end",
"def get_sns_topics\n\n\tsns = AWS::SNS.new(access_key_id: $access_key, secret_access_key: $secret_key)\n\ttopics = sns.topics\n\n\ttopics\n\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
METHOD to validate user operator | def valid_operator(user_operator)
possible_operators = [ "add", "+", "subtract", "-", "multiply", "x", "*", "divide", "/" ]
possible_operators.include?(user_operator)
end | [
"def validate_data_validation_operator(v); end",
"def validates_operator(operator, rhs, atts, opts=OPTS)\n validatable_attributes_for_type(:operator, atts, opts){|a,v,m| validation_error_message(m, operator, rhs) if v.nil? || !v.public_send(operator, rhs)}\n end",
"def test_operator_valid\n assert @rpn.operator?('+')\n assert @rpn.operator?('-')\n assert @rpn.operator?('/')\n assert @rpn.operator?('*')\n end",
"def operator_validate(operations,chosen_operator)\n if operations[:addition].include?(chosen_operator)\n chosen_operator = \"+\"\n elsif operations[:subtraction].include?(chosen_operator)\n chosen_operator = \"-\"\n elsif operations[:multiplication].include?(chosen_operator)\n chosen_operator = \"*\"\n elsif operations[:division].include?(chosen_operator)\n chosen_operator = \"/\"\n elsif operations[:exponent].include?(chosen_operator)\n chosen_operator = \"^\"\n elsif operations[:modulo].include?(chosen_operator)\n chosen_operator = \"%\"\n else \n print \" Error, invalid entry. Please re-enter selection: \"\n reinput = gets.chomp.downcase\n operator_validate(operations,reinput)\n end\nend",
"def operator?\n valid_operators.include?(self)\n end",
"def operator(op, arg, columns, opts=OPTS)\n raise Error, \"invalid operator (#{op}) used when creating operator validation\" unless suffix = OPERATORS[op]\n\n prefix = case arg\n when String\n \"str\"\n when Integer\n \"int\"\n else\n raise Error, \"invalid argument (#{arg.inspect}) used when creating operator validation\"\n end\n\n @generator.validation({:type=>:\"#{prefix}_#{suffix}\", :columns=>Array(columns), :arg=>arg}.merge!(opts))\n end",
"def check_operator(op)\n if !@operators.include?(op)\n return 0\n end\n return 1\n end",
"def validates?(operand)\n # not really sure about this next line. It may be useful to allow each\n # rule to handle what to do with the operand itself.\n #\n # return false if thing.class.to_s != self.operator_class\n return Object.const_get(self.operator_class).send(self.operator.to_sym, operand, self.arguments.split('|'))\n end",
"def argument_with_operator?(argument); end",
"def input_is_operator?(input)\n [\"+\", \"-\", \"*\", \"/\", \"**\"].include?(input)\n end",
"def okay_operator?(operator)\n if operator == \"+\" || operator == \"add\"\n operator = :+\n elsif operator == \"-\" || operator == \"subtract\" || operator == \"minus\"\n operator = :-\n elsif operator == \"*\" || operator == \"times\" || operator == \"multiply\"\n operator = :*\n elsif operator == \"/\" || operator == \"divide\"\n operator = :/\n elsif operator == \"^\" || operator == \"power\" || operator == \"exponent\"\n operator = :**\n else\n puts \"That is not a valid operator\"\n end\nend",
"def oper\n if @lexer.token.match @K[:eq]\n @lexer.accept '=='\n elsif @lexer.token.match @K[:n_eq]\n @lexer.accept '!='\n else\n raise Exception.new \"syntax error, unexpected operator: '#{@lexer.token}'\"\n end\n end",
"def is_operator?(x)\n #x.size == 1 && ( x == '+' || x == '-' || x == '*' || x =='/')\n x =~ /^[\\+\\-\\*\\/]$/\nend",
"def validate\n # @expression && !@expression.blank?\n if !@expression || @expression.blank?\n return\n elsif !Calculator.valid?(@expression)\n @expression = nil\n @mode = :invalid\n end\n end",
"def operator(operator, first_number, second_number)\n #operand = operator.to_sym --> use for later to simplify\n case @user_operator\n when \"+\"\n @answer = first_number + second_number\n puts \"The answer is: #{@answer}\"\n when \"-\"\n @answer = first_number - second_number\n puts \"The answer is: #{@answer}\"\n when \"*\"\n @answer = first_number * second_number\n puts \"The answer is: #{@answer}\"\n when \"/\"\n @answer = first_number / second_number\n puts \"The answer is: #{@answer}\"\n else\n puts \"Please use a correct value\"\n end\n #puts first_number.public_send(operand, second_number) --> save for later\n end",
"def valid_operand?(operand)\n if operand.respond_to?(:valid?)\n operand.valid?\n else\n true\n end\n end",
"def operator_conforms?(operator, field)\n true\n end",
"def operator_function \n puts \"What is the operator? +, -, /, *?\"\n @operator = gets.strip \n operator_case_test\nend",
"def operator?(token)\n return true if ['+', '-', '/', '*'].include?(token)\n false\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
one represents the percentage of characters in the string that are lowercase letters, one the percentage of characters that are uppercase letters, and one the percentage of characters that are neither. You may assume that the string will always contain at least one character. | def letter_percentages(str)
percentages = {}
str_length = str.length.to_f
percentages[:lowercase] = ((str.count('a-z') / str_length) * 100).round(1)
percentages[:uppercase] = ((str.count('A-Z') / str_length) * 100).round(1)
percentages[:neither] = 100 - percentages[:lowercase] - percentages[:uppercase]
percentages
end | [
"def lettercaseRatio str\n n_up = 0\n str.split(\"\").each {|i| if i.upcase == i then n_up += 1 end}\n por_up = n_up / str.length.to_f * 100.0\n printf(\"lowercase: %.2f uppercase: %.2f\\n\",100.0 - por_up, por_up)\nend",
"def letter_percentages(str)\n count_lowercase = 0\n count_uppercase = 0\n count_neither = 0\n\n str.each_char do |char|\n if %w(1 2 3 4 5 6 7 8 9 0).include?(char)\n count_neither += 1\n elsif ('A'..'Z').include?(char)\n count_uppercase += 1\n elsif ('a'..'z').include?(char)\n count_lowercase += 1\n else\n count_neither += 1\n end\n\n end\n\n percent_lowercase = (count_lowercase.to_f / str.length) * 100\n percent_uppercase = (count_uppercase.to_f / str.length) * 100\n percent_neither = (count_neither.to_f / str.length) * 100\n\n hsh = {\n lowercase: percent_lowercase,\n uppercase: percent_uppercase,\n neither: percent_neither\n }\nend",
"def letter_percentages(string)\n case_hash = { lowercase: 0, uppercase: 0, neither: 0 }\n\n string.each_char do |char|\n case\n when char =~ /[A-Z]/ then case_hash[:uppercase] += 1\n when char =~ /[a-z]/ then case_hash[:lowercase] += 1\n else case_hash[:neither] += 1\n end\n end\n\n characters = string.length.to_f\n case_hash.keys.each do |key|\n case_hash[key] /= characters\n case_hash[key] *= 100\n end\n\n case_hash\nend",
"def letter_percentages(str)\n hash = { \"lowercase\" => 0, \"uppercase\" => 0, \"neither\" => 0 }\n leng = str.size\n hash[\"lowercase\"] = (str.count('a-z').fdiv(leng)) * 100\n hash[\"uppercase\"] = (str.count('A-Z').fdiv(leng)) * 100\n hash[\"neither\"] = (str.count('^a-zA-Z').fdiv(leng)) * 100\n\n hash\nend",
"def frequency(string,char)\n\t\tstring.count(char) / string.length.to_f\n\tend",
"def character_percent\n\t\t1.0 * self.characters.count / Character.count * 100.0\n\tend",
"def non_ascii_characters_ratio(tweet)\n return tweet.gsub(\" \", \"\").chars.count { |char| char.ord > 127 }.to_f / tweet.gsub(\" \", \"\").length\nend",
"def letter_case_count(str)\n lowercase_str = 'a-z'\n uppercase_str = 'A-Z'\n neither_str = '^A-Za-z'\n\n lowercase_count = str.count(lowercase_str)\n uppercase_count = str.count(uppercase_str)\n neither_count = str.count(neither_str)\n\n puts \"{ lowercase: #{lowercase_count}, uppercase: #{uppercase_count}, neither: #{neither_count} }\"\nend",
"def solve s\n s.chars.map{|letter| letter.upcase == letter ? 'upper' : 'lower'}.count('upper') > 0.5*s.length ? s.upcase : s.downcase\nend",
"def letter_case_count(str)\r\n lower = str.chars.select{|char| char.match?(/[a-z]/)}.size\r\n upper = str.chars.select{|char| char.match?(/[A-Z]/)}.size\r\n neither = str.chars.select{|char| char.match?(/[^A-Z]/i)}.size\r\n hash = {lower: lower, upper: upper, neither: neither}\r\nend",
"def score\n string.upcase.chars.sum do |char| \n LETTERS.include?(char) ? calculate_letter_score(char) : 0\n end\n end",
"def appearences\n\t\"How many times does the letter 'a' appear in this string?\".count('a')\nend",
"def sillycase(str)\n midpoint = (str.length/2.0).ceil\n p midpoint\n first_half = str[0...midpoint].downcase\n p first_half\n second_half = str[midpoint..-1].upcase\n p second_half\n return first_half + second_half\nend",
"def bar(string)\n string = string.delete(' ')\n counts = count_letters(string)\n string.chars.map do |letter|\n counts[letter] / STICKER[letter]\n end.max\nend",
"def string_reduce(str)\n \n # Count the number of a's, b's, and c's in the string\n a,b,c = 0,0,0\n str.length.times do |i|\n case str[i,1]\n when \"a\"; a += 1\n when \"b\"; b += 1\n when \"c\"; c += 1\n end\n end\n \n # if two of the a,b,c are 0, return the string length. \n # otherwise, check if the evenness of a, b, and c are all the same\n (a+b==0 or b+c==0 or a+c==0) ? (return str.length) : ((a%2==b%2 and b%2==c%2) ? (return 2) : (return 1))\n \nend",
"def letter_case_count_bk(str)\n res = {}\n res[:lowercase] = str.count(\"a-z\")\n res[:uppercase] = str.count(\"A-Z\")\n res[:neither] = str.size() - (res[:lowercase] + res[:uppercase])\n res\nend",
"def freq(char, string)\n return (0 .. string.length - 1).find_all { |i| string[i,1] == char }.length\nend",
"def first_non_repeating_letter(str)\n return '' if str.empty? || str.chars.uniq.size <= str.size/2\n str.chars.each { |e| return e if str.downcase.count(e.downcase) == 1 }\nend",
"def calc_camel_case(\n string:\n )\n string_array = string.split('')\n result = (string_array[0].eql? string_array[0].downcase) ? 1 : 0\n # scan all characters for upper case\n string_array.each { |char| result += 1 if char.eql? char.upcase }\n # Return result\n result\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We skip check when: association isn't a `HasOne` or `HasMany` association has `through` option associated class doesn't exist | def preconditions
%i[
has_one
has_many
].include?(association.macro) && association.through_reflection.nil? && association.klass
rescue StandardError
false
end | [
"def has_valid_association model, field\n (association = model.reflect_on_association(field)) &&\n association &&\n !association.options.has_key?(:through)\n end",
"def unused_preload_associations_for?(klass, association)\n Bullet.collected_unused_eager_association_notifications.select do |notification|\n notification.base_class == klass.to_s && notification.associations.include?(association)\n end.present?\n end",
"def detecting_unpreloaded_association_for?(klass, association)\n Bullet.collected_n_plus_one_query_notifications.select do |notification|\n notification.base_class == klass.to_s && notification.associations.include?(association)\n end.present?\n end",
"def preconditions\n !association.polymorphic? &&\n association.through_reflection.nil? &&\n association.klass.present? &&\n association.macro != :has_and_belongs_to_many &&\n association.klass.table_exists?\n rescue NameError\n false\n end",
"def check_unused_preload_associations; end",
"def unused_preload_associations_for?(klazz, association)\n unused_preload_associations[klazz].present? && unused_preload_associations[klazz].include?(association)\n end",
"def through\n set_possibly_nil_attribute(:through) do\n unless @association.nil?\n if [:has_one, :has_many].include?(@association.macro)\n through = @association.options[:through]\n unless through.nil?\n @application.klass_by_name(through.to_s.classify)\n end\n end\n end\n end\n end",
"def should_visit?(association)\n !(association.is_a?(ActiveRecord::Reflection::ThroughReflection) ||\n association.macro == :belongs_to ||\n (@models_traversed.key?(association.klass.name) &&\n @models_traversed[association.klass.name].present?))\n end",
"def unused_preload_associations_for?(klazz, association)\n unused_preload_associations[klazz].present? && unused_preload_associations[klazz].include?(association)\n end",
"def eager_graph_check_association(model, association)\n if association.is_a?(SQL::AliasedExpression)\n SQL::AliasedExpression.new(check_association(model, association.expression), association.alias)\n else\n check_association(model, association)\n end\n end",
"def association?(name)\n ! reflect_on_association(name.to_sym).nil?\n end",
"def ignored_association?(association)\n ignored_associations.include? association.to_sym\n end",
"def has_manies(options = {})\n options.assert_valid_keys(:exclude_has_many_throughs)\n self.reflect_on_all_associations.select do |assoc|\n result = (assoc.has_many? || assoc.has_and_belongs_to_many?) \n if options[:exclude_has_many_throughs]\n result && !assoc.options.include?(:through)\n else\n result\n end\n end\n end",
"def detect_through_associations\n reflections.each do |association, reflection|\n next if ignored_association?(association) || version_association?(association)\n self.through_associations << reflection.options.symbolize_keys[:through].try(:to_sym)\n end\n self.through_associations = through_associations.compact.uniq.reject {|association| ignored_association?(association) }\n end",
"def is_foreign_key?\n association.present?\n end",
"def associated_model_class\n self.associated_model.present? ? self.associated_model.constantize : nil\n end",
"def association?(method_name)\n self.class.has_one.include? method_name\n end",
"def association_can_delete?\n return self.uninitialized_association_member? && self.associations.count == 1\n end",
"def referenced_one?\n _association && _association.is_a?(Association::Referenced::HasOne)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Boot Firefox, go to loginpage, wait for user to login, and return cookies | def cookies_from_selenium
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://min.e-boks.dk/logon.aspx?logontype=oces"
loop do
break if driver.title =~ %r(^e-Boks )
sleep 1
end
cookies = driver.manage.all_cookies
driver.quit
cookies
end | [
"def login\n if TestChamber.user_cookies\n refresh_browser_cookies\n else\n ui_login\n end\n end",
"def login\n @browser.login\n end",
"def login\n @browser.click(@loginmgr.login_btn, :wait_for => :page)\n @browser.select_frame \"relative=top\"\n end",
"def start_firefox\n rt_count = 1\n waittime = 10\n @log.debug(\"Firefox Start::Running Firefox\")\n\t\tbegin\n\t\t\tif @user_choices[:firefox_profile]\n\t\t\t\t@ff = FireWatir::Firefox.new(:waitTime => waittime, :profile => @user_choices[:firefox_profile])\n\t\t\telse\n\t\t\t\t@ff = FireWatir::Firefox.new(:waitTime => waittime)\n\t\t\tend\n\t\t\t@ff.wait\n @log.debug(\"Firefox Start::Success\")\n unless @logged_in\n @log.debug(\"Basic Authorization::Login thread started\")\n Thread.new { self.logon }\n @logged_in = TRUE\n end if @user_choices[:dut].length > 2\n @ff.goto(@user_choices[:dut][0].ip)\n sleep 3 if @user_choices[:dut].length > 2\n @ff.link(:text, \"Manual Setup\").click if @ff.contains_text(\"What would you like to do?\")\n return true\n\t\trescue => ex\n if rt_count < 4\n @log.debug(\"Firefox Start::Firefox didn't start, or no connection to the JSSH server on port 9997 was validated, on attempt #{rt_count}. Trying again...\")\n waittime += 5\n rt_count += 1\n retry\n else\n @log.fatal(\"Firefox Start::Giving up. Last error received: #{ex}\")\n return false\n end\n\t\tend\n end",
"def emulate_javascript_set_cookie\n @browser.get(HOST + \"Login.asp\")\n @browser.get(HOST + \"Search.asp\")\n end",
"def sign_in\n # @browser.goto \"about.me\"\n # sleep(@step_delay)\n @browser.goto \"about.me/login\"\n sleep(@step_delay)\n @browser.text_field(id: 'login').set(@username)\n @browser.text_field(id: 'password').set(@password)\n @browser.checkbox(id: 'remember').clear\n @browser.button(class: 'button-submit').click\n sleep(@step_delay)\n end",
"def doLogin()\n print \"Please enter your login credentials\\n\" if @debug\n @browser.link(:id, 'gb_70').click\n @browser.text_field(:name, 'q').wait_until_present\n end",
"def login_from_cookies\n if persistent_login?\n @login_from_cookies = true\n\n run_callbacks :login do\n session[:uid] = cookies[:uid]\n generate_new_token\n session[:ulogin] = cookies[:ulogin]\n session[:uid]\n end\n else\n cookie_manager.clear\n nil\n end\n end",
"def login(user_config)\n\n return nil if (user_config['user'] == nil || user_config['pass'] == nil)\n\n # Go to Login Page\n agent = Mechanize.new\n agent.user_agent_alias = 'Mac Safari'\n\n page = agent.get LOGIN_URL\n return nil if !form[0] \n\n # submit form with username and password\n page = agent.post(LOGIN_URL, {'player_email' => user_config['user'], \n 'player_password' => user_config['pass']})\n\n # Collect / return cookie value (LIKE THIS?)\n agent.cookie_jar(:domain => '.web4.castleagegame.com')\n # Extra Credit: persist cookie to database\n rescue Exception => ex\n puts \"Error in login! Error: #{ex.class}, Message: #{ex.message}\"\n end",
"def login\n\t\tnavigate(@login_path)\n\n\t\tlogin_form = find_by_xpath(@signin_xpath)\n\t\tlogin_field = find_by_id('login_field')\n\t\tpassword_field = find_by_id('password')\n\n\t\tlogin_field.send_keys(@username); sleep 1\n\t\tpassword_field.send_keys(@password); sleep 1\n\n\t\tlogin_form.click; sleep 15\n\tend",
"def Surveyhead_login(email,passwd)\n\n # New IE instance creation\n driver = Selenium::WebDriver.for :firefox, :profile => \"Selenium\"\n ff = Watir::Browser.new driver\n #ff.maximize\n\n ff.goto('http://www.p.surveyhead.com')\n # Setting login credentials (email/password)\n #ff.link(:id,\"memLogin\").click\n ff.text_field(:name, \"txtEmail\").set(email)\n ff.text_field(:name, \"txtPassword\").set(passwd)\n\n ff.button(:value,\"Login\").click\n sleep 15\n if(ff.link(:id,\"sb-nav-close\").exists?)\n\t ff.link(:id,\"sb-nav-close\").click\n end\n sleep 5\n \n if(ff.div(:id=>\"loadingSurveys\").exists?)\n\t while ff.div(:id=>\"loadingSurveys\").visible? do\n\t\t sleep 0.5\n\t\t puts \"waiting for surveys to load\"\n\t end\n end\n \n raise(\"Sorry! System Failed to login to Usampadmin\") unless ff.link(:text,'Logout').exists?\n return ff\n\n end",
"def mcs_Login_second_browser(username, password) # Logins same user on second browser\r\n # Login into second browser\r\n $browser2.text_field(:id, \"Email\").when_present.set(username)\r\n $browser2.text_field(:id, \"Password\").when_present.set(password)\r\n $browser2.send_keys :enter\r\n sleep(3)\r\n if $browser2.html.include? \"You currently have Ci open in another browser elsewhere\"\r\n\tputs \"Already Login on Another Browser\"\r\n\t$browser2.div(:class => 'boxshadow-black user-app').when_present.click\r\n end\r\n mcs_text_assertion_second_browser('Start Second Browser','Home - Sony MCS')\r\n sleep(3)\r\n mcs_second_browser_logout()\r\nend",
"def Surveyhead_sm_login(email,passwd)\n \n # New IE instance creation\n driver = Selenium::WebDriver.for :firefox, :profile => \"Selenium\"\n ff = Watir::Browser.new driver\n #ff.maximize\n\n # Opening Usampadmin site\n ff.goto('http://www.sm.p.surveyhead.com')\n\n # Setting login credentials (email/password)\n ff.text_field(:name, \"txtEmail\").set(email)\n ff.text_field(:name, \"txtPassword\").set(passwd)\n #Click login button\n ff.button(:value, \"Login\").click\n sleep 15\n if(ff.link(:id,\"sb-nav-close\").exists?)\n\t ff.link(:id,\"sb-nav-close\").click\n end\n sleep 5\n \n if(ff.div(:id=>\"loadingSurveys\").exists?)\n\t while ff.div(:id=>\"loadingSurveys\").visible? do\n\t\t sleep 0.5\n\t\t puts \"waiting for surveys to load\"\n\t end\n end\n \n \n # Checkpoint to verify that login was successful\n raise(\"Sorry! System Failed to login to Usampadmin\") unless ff.link(:text,'Logout').exists?\n return ff\n end",
"def login\n unless @logged_in\n @log.info(\"Try to login\")\n @server.call('User.login', {'login'=>@login, 'password'=>@password, 'remember'=>1})\n # workaround Bugzilla's broken cookies handling was removed\n if @server.cookie =~ /Bugzilla_logincookie=([^;]+)/\n @logged_in = true\n end\n end\n end",
"def do_login\n @login_results = login\n @cookie = @login_results.headers['Set-Cookie']\n end",
"def login(username = \"root\", password = \"root\")\n # open login page\n open \"auth/login\"\n wait_for_text_present($page_titles[\"auth_login\"])\n\n # type username & password\n type(\"login\", username)\n type(\"password\", password)\n\n # log in\n click \"commit\"\n wait_for_page_to_load \"30000\"\n end",
"def web_login\r\n cookie = generate_web_cookie(admin: true)\r\n\r\n # On good passwords, the router redirect us to the /html/content.asp\r\n # homepage. Otherwise, it throws us back to the '/' login page. Thus\r\n # consider the ASP page our valid login marker\r\n invalid_login_marker = \"var pageName = '/'\"\r\n valid_login_marker = \"var pageName = '/html/content.asp'\"\r\n\r\n username = datastore['HttpUsername']\r\n password = datastore['HttpPassword']\r\n\r\n res = send_request_cgi(\r\n 'method' => 'POST',\r\n 'uri' => '/index/login.cgi',\r\n 'cookie' => cookie,\r\n 'vars_post' => {\r\n 'Username' => username,\r\n 'Password' => hash_password(password)\r\n }\r\n )\r\n fail_with(Failure::Unreachable, \"Connection timed out\") if res.nil?\r\n\r\n unless res.code == 200\r\n fail_with(Failure::NotFound, \"Router returned unexpected HTTP code #{res.code}\")\r\n end\r\n\r\n return res.get_cookies if res.body.include? valid_login_marker\r\n\r\n if res.body.include? invalid_login_marker\r\n fail_with(Failure::NoAccess, \"Invalid web interface credentials #{username}:#{password}\")\r\n else\r\n fail_with(Failure::UnexpectedReply, \"Neither valid or invalid login markers received\")\r\n end\r\n end",
"def login(config)\n\n puts \"Loading cookies...\"\n $agent.cookie_jar.load('cookies.yml')\n raise RuntimeError, \"Cookies no longer valid\" unless logged_in?\n\nrescue \n puts \"#{$!}... logging in...\"\n page = $agent.get(\"http://www.tumblr.com/login\")\n form = page.form_with(:action => '/login')\n form.email = config[:email]\n form.password = config[:password]\n $agent.submit(form)\n puts \"done; saving cookies...\"\n $agent.cookie_jar.save_as('cookies.yml') # Save the cookies\nend",
"def pixiv_login\n\n self.post_mechanize = Mechanize.new\n uri = URI.parse \"http://pixiv.net/\"\n \n if !File.exist? \"#{RAILS_ROOT}/tmp/pixiv.cookie\"\n pixiv_form\n else\n post_mechanize.cookie_jar.load \"#{RAILS_ROOT}/tmp/pixiv.cookie\"\n if post_mechanize.cookies.first.expired?\n pixiv_form\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Download all messages on a folder page. | def process_page(folderpage, folderpath, folderpath_hidden, agent)
folderpage.search('//div[@id="messages"]/ul/li/dl').each do |msg|
elm = msg.xpath('.//dt/label/input').first
if elm["name"] != "did"
$stderr.puts "Error. HTML may have changed, and script needs updating."
$stderr.puts reason
exit 1
end
did = elm["value"]
title = msg.xpath('.//dt/label/span').first.content
sender = msg.xpath('.//dd[@class="content"]/span').first.content
links = msg.xpath('.//dd[@class="content"]/ul/li/a')
date = msg.xpath('.//dd[@class="actions"]/span').first.content.split('-').reverse.join('-')
puts " - found Document ID: #{did} from #{date} (\"#{sender} - #{title}\")"
links.each do |link|
doctitle = title
doctitle = "#{title} (#{link["title"]})" if link["title"] != title # Attachment
query_args = link["href"].split('?', 2)[1]
duid = query_args.match(/duid=(\w+)&/).captures.first
url = "https://download.e-boks.dk/privat/download.aspx?#{query_args.gsub('&', '&')}" # don't ask - the link is pseudo-escaped from e-boks's side
file = "#{did}-#{duid}.pdf"
if File.exist? "#{folderpath_hidden}/#{file}"
puts " already downloaded, skipping."
next
else
puts " downloading #{did} (#{doctitle})"
File.open("#{folderpath_hidden}/#{file}", "w") { |f| f.write agent.get_file(url) }
doctitle.gsub!(/\//, ':')
# Determine filename, uniquifying if necessary
filename = "#{date} - #{sender} - #{doctitle}"
i = 2
while File.exist?("#{folderpath}/#{filename}.pdf")
filename = "#{date} - #{sender} - #{doctitle} (#{i})"
i += 1
end
if SYMLINK
File.symlink(".documents/#{file}", "#{folderpath}/#{filename}.pdf")
else
File.link("#{folderpath_hidden}/#{file}", "#{folderpath}/#{filename}.pdf")
end
end
end
end
end | [
"def download_messages(dir)\n @page = @agent.get(\"http://www.multimedia.movistar.es/do/mail/folder/view?page=0&order=ascending&field=arrival\")\n id = nil\n @page.parser.search('tr[@class=\"messagesList\"]').each do |node|\n begin\n id = node['id']\n\n from = node.children[8].content.strip\n from = from[2, from.size-1] # remove international prefix\n\n\n file = @agent.get(\"/do/mail/message/viewAttachment?msgId=#{id}&part=2\")\n \n if extension = file.filename.match(/\\.(jpg|gif|jpeg|png)\\\"?$/)\n target_file = File.join(dir, \"#{Time.now.to_i}_#{from}.#{extension[1]}\")\n file.save_as(target_file)\n end\n \n @agent.post(\"/do/mail/message/delete?ref=list&deleteNow=true\", {\"msgIds\" => id, \"destfid\" => \"\", \"field\" => \"\", \"order\" => \"ascending\"})\n \n yield(from) if block_given?\n rescue Exception => e\n puts \"Error while processing a MMS\"\n puts e.message\n e.backtrace.each do |line|\n puts \" #{line}\"\n end\n end\n end\n end",
"def fetch_messages(folder, archive_folder, batch_limit, href_regex, reporter=nil, &proc)\n messages = []\n \n if folder == archive_folder # don't descend into archive folder\n log.info \"skipping folder '#{folder}' because it's the archive folder\"\n return messages\n end\n \n # first, retrieve messages in the current folder, and return if we hit the limit\n message_hrefs = folder.message_hrefs href_regex\n log.info \"Total number of messages in folder '#{folder}' is: #{message_hrefs.size}\"\n \n message_hrefs.each do |message|\n begin\n message.raw # trigger the fetch of the raw data\n messages << message\n yield message if proc\n return messages if messages.size >= batch_limit\n rescue Exception => e\n log.warn \"There was a problem retrieving message from Exchange: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\")\n reporter.call(e) if reporter\n end\n end\n \n begin\n # then descend into the current folder's subfolders\n folder.folders.each do |sub_folder|\n return messages if messages.size >= batch_limit\n messages += fetch_messages(sub_folder, archive_folder, batch_limit-messages.size, href_regex, &proc)\n end\n rescue Exception => e\n log.warn \"There was a problem listing subfolders with Exchange: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\")\n reporter.call(e) if reporter\n return messages\n end\n \n messages\n end",
"def download_folder\n folder = params[:fold]\n # Delete old .zip files\n FileUtilsC.delete_files_by_types(folder[0..folder.rindex('/') - 1], ['.zip'])\n\n if !folder.blank?\n # Zip folder and send zip file to client\n zipfile_name = BrowsingFile.zip_folder folder\n send_file zipfile_name, type: 'application/zip', x_sendfile: true\n end\n end",
"def fetch_folder_contents\n code, reason, headers, uripath, graph = @session.get_folder(uri)\n parse_folder_description(graph)\n end",
"def downloadMessages\n ary = getHpks\n total = 0\n ary.each do |hpk|\n mbx = Mailbox.new hpk\n download = mbx.read_all\n total += download.length\n deleteMessages(mbx, download)\n end\n end",
"def list_all_folders\n\n begin\n list = imap.list('*', '*')\n rescue Net::IMAP::NoResponseError => e\n # No response, what ever\n rescue Net::IMAP::ByeResponseError => e\n # Bye response, what ever\n rescue => e\n puts \"[#{Time.now}] ! Error: #{e}, retrying.\"\n imap_reconnect\n retry\n end\n\n list\n end",
"def index\n path = @client.folder_from_path(@user_folder_name)\n @folder_items = @client.folder_items(path)\n @folder_items.each {|i| puts i.name}\n end",
"def index\n @download_folders = @club.download_folders\n \n @page_title = \"Download Folder Listing\"\n @site_section = \"clubs\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @download_folders }\n end\n end",
"def send_folder(path)\n response = self.create_section_response\n section = DocumentSection.from_path(path)\n Dir.chdir(DocumentFile::DOC_FILE_PATH + path) do |dir|\n if (readmes = Dir.glob(\"read*me.{html,htm,txt}\", File::FNM_CASEFOLD)).size > 0\n section.readme = {\n :type => (File.extname(readmes[0]) == \".txt\" ? \"text-plain\" : \"text-html\"), \n :text => File.read(readmes[0]), \n :file => readmes[0]\n }\n end\n end #Dir.chdir\n response[:sections] << section\n return response\n end",
"def download_all_for_game(gid)\r\n download_xml_for_game(gid)\r\n download_batters_for_game(gid)\r\n download_inning_for_game(gid)\r\n download_media_for_game(gid)\r\n download_notification_for_game(gid)\r\n download_onbase_for_game(gid)\r\n download_pitchers_for_game(gid)\r\n end",
"def download!\n folder = \"tmp/#{self.order_code}_\" + Time.now.strftime('%Y%m%d%H%M%S%L')\n files = []\n\n # check if the directory existence\n # create the directory if it does not exist yet\n Dir::mkdir(folder) if Dir[folder].empty?\n\n xml_file = to_xml(folder)\n\n files << xml_file\n \n self.order_items.each_with_index do |o_i, index|\n next if o_i.photo.nil? || o_i.photo.image_file_name.nil?\n\n o_photo_url = o_i.photo.image.url\n\n o_photo = open(o_photo_url, &:read)\n\n File.open(\"#{folder}/#{index}_#{o_i.photo.image_name}\", 'wb') do |file|\n file << o_photo\n end\n\n files << \"#{folder}/#{index}_#{o_i.photo.image_name}\"\n end\n \n File.open(\"#{folder}/message.txt\", 'wb') do |file|\n file << \"\"\n end\n files << \"#{folder}/message.txt\"\n\n ## zip\n Zip::File.open(\"#{folder}.zip\", Zip::File::CREATE) do |zipfile|\n files.each do |file|\n zipfile.add(file.split(\"/\").last, file)\n end\n end\n\n FileUtils.rm_rf(folder)\n\n \"#{folder}.zip\"\n end",
"def fetch_unread_items(folder)\n item_view = ItemView.new(10) # FIXME: some huge number like 5000, but the JS app is too slow for that\n item_view.property_set = EMAIL_SUMMARY_PROPERTY_SET\n folder.find_items(SearchFilter::IsEqualTo.new(EmailMessageSchema::IsRead, false), item_view).items.to_a\n end",
"def all_mail_threads(**args)\n params = parameters(args) do\n required_params :folder\n optional_params :folder, :start, :limit\n end\n request(:get, 'mailbox/mailThreads', params)\n end",
"def messages(*args)\n if new_record?\n raise Errors::FolderNotFound.new(@id, \"Folder does only exist locally\")\n else\n if !@conn_id.nil? && !@location.nil? && selectable?\n self.class.message_class.all(@conn_id, @location.path, *args)\n else\n []\n end\n end\n end",
"def folder_entries(folder, include_read: false, page: nil)\n EntriesPagination.folder_entries folder, self, include_read: include_read, page: page\n end",
"def downloadAllPages()\n which = params[:which]\n html_files = \"./public/meds/out/2013/#{which}/html/*.html\"\n pdf_file = \"./public/meds/out/2013/#{which}/PRINTALL.pdf\"\n pdf_file = \"./public/meds/out/2013/printit.pdf\"\n htmltopdf(which, html_files, pdf_file, true, true)\n end",
"def read_emails(folder,keyword,atrans,acftrans)\r\n view = framework.threads.spawn(\"ButtonClicker\", false) {\r\n click_button(atrans,acftrans)\r\n }\r\n command = \"Get-Emails \\\"#{keyword}\\\" \\\"#{folder}\\\"\"\r\n execute_outlook_script(command)\r\n end",
"def folder_documents(path)\n make_request(:get,\"#{folders_url(path)}/documents.xml\")\n end",
"def each_message_dir\n dirlist.each do |name|\n yield MessageDir.existing(name)\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /userfiles/1 DELETE /userfiles/1.json | def destroy
@userfile.destroy
respond_to do |format|
format.html { redirect_to userfiles_url, notice: 'Userfile was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @user_file = UserFile.find(params[:id])\n @user_file.destroy\n\n respond_to do |format|\n format.html { redirect_to user_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_file.destroy\n respond_to do |format|\n format.html { redirect_to user_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @userfile = Userfile.find(params[:id])\n @userfile.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_data_file.destroy\n respond_to do |format|\n format.html { redirect_to user_data_files_url }\n format.json { head :no_content }\n end\n end",
"def delete(user)\n Rails.logger.debug \"Call to photo.delete\"\n if !self.file.blank?\n Util.delete_image(self.file) #Delete the image file from the image server\n end\n reqUrl = \"/api/photo/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_delete_request(reqUrl,user['email'],user['password'])#Make the DELETE request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n return true, rest_response #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n end",
"def destroy\n @ufile = Ufile.find(params[:id])\n @ufile.destroy\n\n respond_to do |format|\n format.html { redirect_to ufiles_url }\n format.json { head :no_content }\n end\n end",
"def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n response = @session.do_post build_url(\"/fileops/delete\", params)\n parse_response(response)\n end",
"def destroy\n @user_import_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_import_files_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jsonfile = Jsonfile.find(params[:id])\n @jsonfile.destroy\n\n respond_to do |format|\n format.html { redirect_to(jsonfiles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_export_file.destroy\n\n respond_to do |format|\n format.html { redirect_to user_export_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_story_file.destroy\n respond_to do |format|\n format.html { redirect_to user_story_files_url, notice: 'User story file was successfully destroyed.' }\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 @treq_file = TreqFile.find(params[:id])\n @treq_file.destroy\n\n respond_to do |format|\n format.html { redirect_to treq_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @fileupload = Fileupload.find(params[:id])\r\n\r\n File.delete(\"#{RAILS_ROOT}/public/files/#{@fileupload.username+'_'+@fileupload.filename}\")\r\n @fileupload.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(fileuploads_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n puts \"delete --\" * 10\n result = access_token.delete(\"/api/v1/file_assets/#{params[:id]}\")\n\n display_api_response( result )\n \n respond_to do |format|\n format.html { redirect_to(file_assets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @up_file = UpFile.find(params[:id])\n @up_file.destroy\n\n respond_to do |format|\n format.html { redirect_to up_files_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n if id.is_a? Array then\n id = id.join(',')\n end\n\n make_post_call('/files/delete?file_ids=%s' % [id]).status == \"OK\"\n end",
"def deleteFileFromServer(filepath)\n filepath = filepath[1, filepath.length - 1] \n address = @@host + \"/user/\" + @@conf[\"username\"] + \"/device/\" + @@conf[\"dev_name\"] + \"/files/\" + filepath\n \n res = HttpRequest.new(:delete, address).send(@@host) \n puts res\n puts \"CODE: \" + res.code\n\nend",
"def destroy\n @user_cookbook_file.destroy\n respond_to do |format|\n format.html { redirect_to user_cookbook_files_url, notice: 'User cookbook file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fills the object with data coming from the API Params: +data+:: +Hash+ of data coming from the API | def fill_with_data(data)
if data.include? "id"
@id = data["id"]
end
if data.include? "project"
@project = data["project"]
end
if data.include? "customer"
@customer = data["customer"]
end
if data.include? "token"
@token = data["token"]
end
if data.include? "url"
@url = data["url"]
end
if data.include? "authorized"
@authorized = data["authorized"]
end
if data.include? "name"
@name = data["name"]
end
if data.include? "currency"
@currency = data["currency"]
end
if data.include? "return_url"
@return_url = data["return_url"]
end
if data.include? "cancel_url"
@cancel_url = data["cancel_url"]
end
if data.include? "custom"
@custom = data["custom"]
end
if data.include? "sandbox"
@sandbox = data["sandbox"]
end
if data.include? "created_at"
@created_at = data["created_at"]
end
self
end | [
"def fill_with_data(data)\n if data.include? \"id\"\n @id = data[\"id\"]\n end\n if data.include? \"project\"\n @project = data[\"project\"]\n end\n if data.include? \"event\"\n @event = data[\"event\"]\n end\n if data.include? \"request_url\"\n @request_url = data[\"request_url\"]\n end\n if data.include? \"request_method\"\n @request_method = data[\"request_method\"]\n end\n if data.include? \"response_body\"\n @response_body = data[\"response_body\"]\n end\n if data.include? \"response_code\"\n @response_code = data[\"response_code\"]\n end\n if data.include? \"response_headers\"\n @response_headers = data[\"response_headers\"]\n end\n if data.include? \"response_time_ms\"\n @response_time_ms = data[\"response_time_ms\"]\n end\n if data.include? \"status\"\n @status = data[\"status\"]\n end\n if data.include? \"created_at\"\n @created_at = data[\"created_at\"]\n end\n if data.include? \"release_at\"\n @release_at = data[\"release_at\"]\n end\n \n self\n end",
"def fill_with_data(data)\n if data.include? \"id\"\n @id = data[\"id\"]\n end\n if data.include? \"project\"\n @project = data[\"project\"]\n end\n if data.include? \"name\"\n @name = data[\"name\"]\n end\n if data.include? \"amount\"\n @amount = data[\"amount\"]\n end\n if data.include? \"currency\"\n @currency = data[\"currency\"]\n end\n if data.include? \"metadata\"\n @metadata = data[\"metadata\"]\n end\n if data.include? \"interval\"\n @interval = data[\"interval\"]\n end\n if data.include? \"trial_period\"\n @trial_period = data[\"trial_period\"]\n end\n if data.include? \"return_url\"\n @return_url = data[\"return_url\"]\n end\n if data.include? \"cancel_url\"\n @cancel_url = data[\"cancel_url\"]\n end\n if data.include? \"sandbox\"\n @sandbox = data[\"sandbox\"]\n end\n if data.include? \"created_at\"\n @created_at = data[\"created_at\"]\n end\n \n self\n end",
"def fill_with_data(data)\n if data.include? \"id\"\n @id = data[\"id\"]\n end\n if data.include? \"project\"\n @project = data[\"project\"]\n end\n if data.include? \"url\"\n @url = data[\"url\"]\n end\n if data.include? \"name\"\n @name = data[\"name\"]\n end\n if data.include? \"amount\"\n @amount = data[\"amount\"]\n end\n if data.include? \"currency\"\n @currency = data[\"currency\"]\n end\n if data.include? \"metadata\"\n @metadata = data[\"metadata\"]\n end\n if data.include? \"request_email\"\n @request_email = data[\"request_email\"]\n end\n if data.include? \"request_shipping\"\n @request_shipping = data[\"request_shipping\"]\n end\n if data.include? \"return_url\"\n @return_url = data[\"return_url\"]\n end\n if data.include? \"cancel_url\"\n @cancel_url = data[\"cancel_url\"]\n end\n if data.include? \"sandbox\"\n @sandbox = data[\"sandbox\"]\n end\n if data.include? \"created_at\"\n @created_at = data[\"created_at\"]\n end\n \n self\n end",
"def initialize_data\n @data = parse_body || {}\n end",
"def initialize(data={})\n self.data = data || {}\n end",
"def initialize(data)\n @time = Time.at(data['dt'])\n @main = data['weather'][0]['main']\n @description = data['weather'][0]['description']\n @icon = \"https://openweathermap.org/img/w/#{data['weather'][0]['icon']}.png\"\n @emoji = OpenWeatherMap::Constants::CONDITION_CODE[data['weather'][0]['icon'].tr('n', 'd')]\n @temperature = data['main']['temp']\n @temp_min = data['main']['temp_min'].to_f\n @temp_max = data['main']['temp_max'].to_f\n @pressure = data['main']['pressure'].to_f\n @humidity = data['main']['humidity'].to_f\n @wind = {\n speed: data['wind']['speed'],\n direction: data['wind']['deg']\n }\n @clouds = data['clouds']['all'].to_f\n @rain = data['rain'].nil? ? nil : {\n one_hour: data['rain']['1h'],\n three_hours: data['rain']['3h']\n }\n @snow = data['snow'].nil? ? nil : {\n one_hour: data['snow']['1h'],\n three_hours: data['snow']['3h']\n }\n end",
"def build_from_database(data)\n return nil if data.blank?\n \n # Create an instance of the object\n obj = self.new(data['data'])\n obj.raw_data = data\n obj\n end",
"def process_data(data)\n case data\n when Hash then Resource.new(agent, data)\n when Array then data.map { |hash| process_data(hash) }\n when nil then nil\n else data\n end\n end",
"def data\n @data ||= Elong::API::Hotel::Data.new(@client)\n end",
"def build_datastore(data); \n @datastore = JSON.parse(data)\n end",
"def build_params(data, auth = false)\n data.merge!(mkey: FiveDL.token)\n data.merge!(apiname: username, apikey: password) if auth\n { body: data }\n end",
"def build_data(data)\n header = build_header\n header.merge(data)\n end",
"def initialize(data = {})\n return if !data.is_a?(Hash) || data.empty?\n\n @credential = Credential.generate_multiple([data['Credential']])\n @user_agent = data['UserAgent']\n end",
"def set_default_empty_data\n self.data ||= {}\n end",
"def populate_data\n response = @canvas_api.get(\"users/#{@canvas_id}/profile\")\n @name ||= response.body['name']\n @email ||= response.body['primary_email']\n @canvas_id ||= response.body['id']\n end",
"def build_datastore(data);\n @datastore = JSON.parse(data)\n end",
"def set_api_response_data\n users_list = []\n @users.each do |u|\n ukd = @user_kyc_details[u.id]\n ukd_present = ukd.present?\n users_list << {\n user_id: u.id,\n case_id: ukd_present ? @user_kyc_details[u.id].id : 0,\n email: u.email,\n registration_timestamp: u.created_at.to_i,\n is_kyc_submitted: ukd_present.to_i,\n whitelist_status: ukd_present ? @user_kyc_details[u.id].whitelist_status : nil,\n action_to_perform: action_to_perform(ukd)\n }\n end\n\n meta = {\n page_number: @page_number,\n total_records: @total_filtered_users,\n page_payload: {\n },\n page_size: @page_size,\n filters: @allowed_filters,\n sortings: @sortings,\n }\n\n data = {\n meta: meta,\n result_set: 'users_list',\n users_list: users_list\n }\n\n @api_response_data = data\n\n end",
"def initialize(id, name, site, link, data)\n # should the data come from the database it will be ready\n status = (id != nil && name != nil && site != nil && link != nil && data != nil)\n @buff_site = site\n @data = Struct::Manga_data_values.new(name, link, id, status, nil, data, nil, nil, nil)\n if @data[:status]\n @data[:website] = Web_data.instance.is_site_compatible?(site, false)\n end\n end",
"def fill_IDs(data)\n id = allocate_ID\n if data[\"svd\"][\"uri\"]\n data[\"svd\"][\"is_new\"] = false\n else\n data[\"svd\"][\"id\"] = id\n data[\"svd\"][\"is_new\"] = true\n id = id + 1\n end\n if data[\"label\"][\"value\"]\n data[\"label\"][\"id\"] = id\n id = id + 1\n end\n if data[\"features\"].length > 0\n data[\"description\"][\"id\"] = id\n id = id + 1\n end\n if data[\"scientific_names\"].length > 0\n data[\"scientific_names\"].each do |name| \n name[\"id\"] = id\n id = id + 1\n end\n end\n Rails.logger.debug(data)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the customer linked to the authorization request. Params: +options+:: +Hash+ of options | def customer(options = nil)
request = Request.new(@client)
path = "/authorization-requests/" + CGI.escape(@id) + "/customers"
data = {
}
response = Response.new(request.get(path, data, options))
return_values = Array.new
body = response.body
body = body["customer"]
customer = Customer(self._client)
return_values.push(customer.fill_with_data(body))
return_values[0]
end | [
"def customer(options = nil)\n request = Request.new(@client)\n path = \"/invoices/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end",
"def customer(options = nil)\n request = Request.new(@client)\n path = \"/subscriptions/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end",
"def get_customer_profile(options)\n requires!(options, :customer_profile_id)\n\n request = build_request(:get_customer_profile, options)\n commit(:get_customer_profile, request)\n end",
"def get_customer_payment_profile(options)\n requires!(options, :customer_profile_id)\n requires!(options, :customer_payment_profile_id)\n\n request = build_request(:get_customer_payment_profile, options)\n commit(:get_customer_payment_profile, request)\n end",
"def collect_customer_details(identity, options = {})\n path = sub_url('/billing_requests/:identity/actions/collect_customer_details', {\n 'identity' => identity,\n })\n\n params = options.delete(:params) || {}\n options[:params] = {}\n options[:params]['data'] = params\n\n options[:retry_failures] = false\n\n begin\n response = make_request(:post, path, options)\n\n # Response doesn't raise any errors until #body is called\n response.tap(&:body)\n rescue InvalidStateError => e\n if e.idempotent_creation_conflict?\n case @api_service.on_idempotency_conflict\n when :raise\n raise IdempotencyConflict, e.error\n when :fetch\n return get(e.conflicting_resource_id)\n end\n end\n\n raise e\n end\n\n return if response.body.nil?\n\n Resources::BillingRequest.new(unenvelope_body(response.body), response)\n end",
"def collect_customer_details(identity, options = {})\n path = sub_url('/billing_requests/:identity/actions/collect_customer_details', 'identity' => identity)\n\n params = options.delete(:params) || {}\n options[:params] = {}\n options[:params]['data'] = params\n\n options[:retry_failures] = false\n\n begin\n response = make_request(:post, path, options)\n\n # Response doesn't raise any errors until #body is called\n response.tap(&:body)\n rescue InvalidStateError => e\n if e.idempotent_creation_conflict?\n case @api_service.on_idempotency_conflict\n when :raise\n raise IdempotencyConflict, e.error\n when :fetch\n return get(e.conflicting_resource_id)\n else\n raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'\n end\n end\n\n raise e\n end\n\n return if response.body.nil?\n\n Resources::BillingRequest.new(unenvelope_body(response.body), response)\n end",
"def customer_id\n response = @gateway.get_customer(@options)\n unless response.authorization.nil?\n omit('Not enough information to run test')\n end\n response.authorization\n end",
"def customer(customer_id:)\n path = '/api/customer/get'\n\n private_get(path, { customerId: customer_id })\n end",
"def customer_by_ref(customer_ref)\n client.get \"customers/#{inst_id}/byRef?merchantRef=#{customer_ref}\"\n end",
"def get_tokenized_billing_info(options)\n get_gateway options[:system]\n timeout(30) do\n @net_response = @gateway.retreive_customer_info options\n end\n @net_response\n end",
"def customer\n return @customer\n end",
"def find(customer_id, token_id, options = nil)\n request = Request.new(@client)\n path = \"/customers/\" + CGI.escape(customer_id) + \"/tokens/\" + CGI.escape(token_id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"token\"]\n \n \n obj = Token.new(@client)\n return_values.push(obj.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def get_customer_profile\n authenticate_request!\n json_response(current_customer)\n end",
"def account_info(options = {})\n request :signed, :get, :account, options\n end",
"def list_customers(options={})\n customers = []\n list_customers_each(options) { |c| customers << c }\n customers\n end",
"def authenticate_customer \n label = request_label(:authenticate_customer, customer_id)\n \n @http_request_bundler.add(\n label, \n @url + \"/authenticate_customer\", \n :get,\n head: headers,\n query: { provider_id: provider_id, customer_id: customer_id, customer_token: customer_token }\n ).status!(label)\n end",
"def get_customer_shipping_address(options)\n requires!(options, :customer_profile_id)\n requires!(options, :customer_address_id)\n\n request = build_request(:get_customer_shipping_address, options)\n commit(:get_customer_shipping_address, request)\n end",
"def account_info(options = {})\n request :account, :get, 'account', options\n end",
"def vault_customer\n return nil if customer_details.id.nil?\n @gateway.customer.find(customer_details.id)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new authorization request for the given customer ID. Params: +customer_id+:: ID of the customer +options+:: +Hash+ of options | def create(customer_id, options = nil)
request = Request.new(@client)
path = "/authorization-requests"
data = {
"name"=> @name,
"currency"=> @currency,
"return_url"=> @return_url,
"cancel_url"=> @cancel_url,
"custom"=> @custom,
'customer_id'=> customer_id
}
response = Response.new(request.post(path, data, options))
return_values = Array.new
body = response.body
body = body["authorization_request"]
return_values.push(self.fill_with_data(body))
return_values[0]
end | [
"def create_customer(options = {})\n post = {}\n\n add_customer_data(post, options)\n add_address_data(post, options)\n\n commit(:post, '/customers', post)\n end",
"def create_customer(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = post(\"customers\",options)\n if response['success']\n response['results']['customer']\n else\n response\n end\n end",
"def create_authorization(options={})\n post \"/authorizations\", :body => options\n end",
"def create_for_customer(customer_id, options = nil)\n request = Request.new(@client)\n path = \"/invoices\"\n data = {\n \"name\"=> @name, \n \"amount\"=> @amount, \n \"currency\"=> @currency, \n \"metadata\"=> @metadata, \n \"request_email\"=> @request_email, \n \"request_shipping\"=> @request_shipping, \n \"return_url\"=> @return_url, \n \"cancel_url\"=> @cancel_url, \n 'customer_id'=> customer_id\n }\n\n response = Response.new(request.post(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"invoice\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def customer(options = nil)\n request = Request.new(@client)\n path = \"/authorization-requests/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end",
"def create\n @customer_request = CustomerRequest.new(customer_request_params)\n\n respond_to do |format|\n if @customer_request.save\n format.html { redirect_to @customer_request, notice: 'Customer request was successfully created.' }\n format.json { render :show, status: :created, location: @customer_request }\n else\n format.html { render :new }\n format.json { render json: @customer_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enable_customer(options = {})\n requires! options, :customer_number\n\n request = build_request(__method__, options)\n commit(__method__, request)\n end",
"def create_subscription(options, customer_attributes={})\n options.merge({:customer_attributes => customer_attributes}) unless customer_attributes.blank?\n response = Hashie::Mash.new(self.class.post(\"/subscriptions.json\", :body => options))\n return response.subscription unless response.subscription.blank?\n response\n end",
"def create\n params.require(:customer_id)\n\n customer = Customer.find_by(id: params[:customer_id])\n render json: 'Customer ID not found.', status: :not_acceptable and return if customer.nil?\n\n referral = Referral.create do |r|\n r.customer = customer\n end\n\n if referral.save\n render json: build_sign_up_link(referral.key), status: :created\n else\n render json: 'There was a problem with the referral creation.', status: :bad_request\n end\n end",
"def create(customer_id, source, options = nil)\n request = Request.new(@client)\n path = \"/customers/\" + CGI.escape(customer_id) + \"/tokens\"\n data = {\n \"metadata\"=> @metadata, \n 'source'=> source\n }\n\n response = Response.new(request.post(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"token\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def assign_customer(customer_id, options = nil)\n request = Request.new(@client)\n path = \"/invoices/\" + CGI.escape(@id) + \"/customers\"\n data = {\n 'customer_id'=> customer_id\n }\n\n response = Response.new(request.post(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end",
"def authorize(options)\n hash = { transaction: { type: :auth_only,\n amount: options.fetch(:amount),\n customer_profile_id: options.fetch(:customer_profile_id),\n customer_payment_profile_id: options.fetch(:customer_payment_profile_id) }}\n response = gateway.create_customer_profile_transaction(hash)\n transaction_id = response.success? ? response.params['direct_response']['transaction_id'] : nil\n [transaction_id, response]\n end",
"def create_access_token(customer_id,\r\n body,\r\n idempotency_key = nil)\r\n # Prepare query url.\r\n _path_url = '/customers/{customer_id}/access-tokens'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'customer_id' => customer_id\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'ServiceRefererName' => Configuration.service_referer_name,\r\n 'Content-Type' => 'application/json',\r\n 'idempotency-key' => idempotency_key\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: body.to_json\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 400\r\n raise ErrorException.new(\r\n 'Invalid request',\r\n _context\r\n )\r\n elsif _context.response.status_code == 401\r\n raise ErrorException.new(\r\n 'Invalid API key',\r\n _context\r\n )\r\n elsif _context.response.status_code == 404\r\n raise ErrorException.new(\r\n 'An informed resource was not found',\r\n _context\r\n )\r\n elsif _context.response.status_code == 412\r\n raise ErrorException.new(\r\n 'Business validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 422\r\n raise ErrorException.new(\r\n 'Contract validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 500\r\n raise ErrorException.new(\r\n 'Internal server error',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n CustomersAccessTokensResponse.from_hash(decoded)\r\n end",
"def create_customer\n @customer = ::Customer.create!(client_id: @client.id,\n status: GlobalConstant::Customer.active_status,\n details: @customer_details\n )\n success\n end",
"def initialize(customer_id:, options: {})\n @customer_id = customer_id\n @event_id, @ip_address, @ip_forwared_for,\n @payload, @expire_at = options.values_at(:event_id, :ip_address, :ip_forwared_for, :payload, :expire_at)\n\n @token_identifier = options[:token_identifier] || random_token_identifier(options[:token_identifier_prefix])\n @issued_at = options[:issued_at] || (Time.now.to_f * 1000).to_i\n end",
"def create_customer(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/customers',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def create\n @customer = @client.customers.create(customer_params)\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def customer_signup\n customer = Customer.new(customer_params)\n if customer.save\n # The following methods belong to Knock::AuthTokenController\n # See https://github.com/nsarno/knock/blob/master/app/controllers/knock/auth_token_controller.rb\n authenticate\n create\n else\n render json: customer.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def create\n request_params = customer_transaction_params\n customer_type, customer_id = request_params.delete('customer_type_and_id').split('.')\n request_params['customer_type'] = customer_type\n request_params['customer_id'] = customer_id\n @customer_transaction = CustomerTransaction.new(request_params)\n\n respond_to do |format|\n if @customer_transaction.save\n format.html { redirect_to @customer_transaction, notice: 'Customer transaction was successfully created.' }\n format.json { render :show, status: :created, location: @customer_transaction }\n else\n @customers = User.all + Company.all\n format.html { render :new }\n format.json { render json: @customer_transaction.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find an authorization request by its ID. Params: +authorization_request_id+:: ID of the authorization request +options+:: +Hash+ of options | def find(authorization_request_id, options = nil)
request = Request.new(@client)
path = "/authorization-requests/" + CGI.escape(authorization_request_id) + ""
data = {
}
response = Response.new(request.get(path, data, options))
return_values = Array.new
body = response.body
body = body["authorization_request"]
obj = AuthorizationRequest.new(@client)
return_values.push(obj.fill_with_data(body))
return_values[0]
end | [
"def search_request_by_id(id)\n @search_requests[id]\n end",
"def find(id,options={})\n options.reverse_merge! :from => collection_url\n request_options = options.slice(:query, :headers)\n \n url = build_url(options[:from],id)\n if result = handle_response(self.get(url, request_options),url)\n e = self.new(result)\n e.url = url\n e\n end\n end",
"def find_request \n @request = Request.find(params[:id])\n end",
"def find_request(rid)\n Requests.find_by(rid: rid)\n end",
"def authorization\n @request_id ||= @request.env[\"oauth.authorization\"] || @request.params[\"authorization\"]\n end",
"def authorization_id\n @authorization_id ||= begin\n join = AuthJoin.by_user_object_id(:key => id).first\n join && join[:auth_object_id]\n end\n end",
"def find_authorizable_id\n @call_params[:path] = \"/#{@call_params[:path]}\" unless @call_params[:path].start_with? '/'\n @client.call(self.class, __callee__.to_s, @call_params)\n end",
"def add_identification_authorization(request, authorization, options)\n options[:paymentId] = authorization\n request[:orderId] = options[:order_id] if options[:order_id]\n end",
"def get_record_by_id(opt = {})\r\n unless opt[:id] && opt[:output_type]\r\n raise ArgumentError.new(\"Missing arguments. :id and :output_type required. :output_id_type and :output optional\")\r\n end\r\n params = {'cmd' => 'get_record_by_cpath_id', 'q' => opt[:id],\r\n 'output' => opt[:output_type]}\r\n params['output_id_type'] = opt[:output_id_type] if opt[:output_id_type]\r\n\r\n response = @conn.get do |req|\r\n req.url @requestURL,\r\n req.params = params\r\n end\r\n return response\r\n end",
"def find_resource(id = nil)\n id ||= respond_to?(:params) && params.is_a?(Hash) && params[:id]\n resource_service.find id\n end",
"def find_by_id(client, id, options: {})\n\n self.new(parse(client.get(\"/project_memberships/#{id}\", options: options)).first, client: client)\n end",
"def get_id(options)\r\n id = options[:id]\r\n\r\n id\r\n end",
"def get_request( id )\n url = \"#{self.url}/#{id}?auth=#{self.authtoken}\"\n status, response = rest_get( url )\n return status, response['details'] if ok?( status ) && response['details']\n return status, ''\n end",
"def authorized_for(options)\n action = options.delete(:auth_action) || options[:action]\n object = options.delete(:auth_object)\n user = User.current\n controller = options[:controller] || params[:controller]\n controller_name = controller.to_s.gsub(/::/, \"_\").underscore\n id = options[:id]\n permission = options.delete(:permission) || [action, controller_name].join('_')\n\n if object.nil?\n user.allowed_to?({ :controller => controller_name, :action => action, :id => id }) rescue false\n else\n authorizer = options.delete(:authorizer) || Authorizer.new(user)\n authorizer.can?(permission, object) rescue false\n end\n end",
"def find(id, resource = nil, request_method = RequestMethods::GET, format = 'json')\n if id.nil?\n return nil\n else\n request_url = self.build_request_url( resource, id ) \n return self.find!(request_url, request_method, format)\n end\n end",
"def find_item_request(options)\n search_type, search_value = nil, nil\n options.each_pair do |key, value|\n if @@valid_search_types.include? key.to_s.upcase\n if search_type || search_value\n raise ArgumentError.new(\"Only one search criteria at a time is allowed: '#{options}'\")\n end\n\n search_type, search_value = key, value\n end\n end\n unless search_type && search_value\n raise ArgumentError.new(\"Missing valid search type and value: '#{options}'\")\n end\n\n request exact_search_request_hash(search_type, search_value), need_auth_id(self.patron_barcode, self.patron_library_symbol)\n end",
"def find_by_id(obj_id, options = {})\n default_options = {\n \"attachments\" => true\n }\n\n options = default_options.merge(options)\n\n url = url(obj_id) << options_string(options)\n rest_res = RestClient.get(url)\n\n doc = Yajl::Parser.parse(rest_res, :symbolize_keys => true)\n\n if options[\"attachments\"]\n attachments = decode_attachments(doc[:_attachments])\n doc.delete(:_attachments)\n end\n\n self.class.inflate_object(doc, attachments)\n rescue RestClient::ResourceNotFound => rnf\n nil\n rescue Exception => e\n raise CouchDBAngry.new(e)\n end",
"def find_by_id(sess, id, options = {})\r\n q = create_query(sess)\r\n q.query.ListIDList.Add(id)\r\n find(sess, :first, q, options)\r\n end",
"def find_document(options)\n id = options[:id]\n name = options[:name]\n \n self.documents.find do |document|\n if id.not_nil?\n document.id == id\n elsif name.not_nil?\n document.name == name\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move the given register to temporary storage and rewrite reads from it to point to the new location. | def spill(reg)
spill_move = Move.new(reg, SPILL_REG, true)
@moves.each do |move|
move.src = SPILL_REG if move.src == reg
end
@moves << spill_move
end | [
"def mov_reg_to_addr addr, reg\n @mem[addr] = @reg[reg]\n end",
"def mov_reg_addr_to_reg dst, src\n @reg[dst] = @mem[@reg[src]]\n end",
"def with_reg(node)\n register = @registers.detect {|name, available| available}[0]\n @registers[register] = false\n code = print_node(node[:lvalue], self) + [\"movq %rax, #{register}\"] + print_node(node[:rvalue], self) + yield(register)\n @registers[register] = true\n code\n end",
"def mov_imm_to_reg reg, imm\n @reg[reg] = imm\n end",
"def mov_imm_to_reg_addr reg, imm\n @mem[@reg[reg]] = imm\n end",
"def shiftRight(register)\n\tregister.unshift(0).pop\nend",
"def copyWriteToRead\n [@IfIdRegister, @IdExRegister, @ExMemRegister, @MemWbRegister].each do |register|\n register.read = register.write.clone\n register.read[:control] = register.write[:control].clone if register.write[:control]\n end\n end",
"def pop_reg reg\n @fisk.pop reg.to_register\n end",
"def with_register name = \"temp\"\n reg = register(name)\n yield reg\n release_register reg\n end",
"def atomic_replace\n @mutex.synchronize do\n @new_registry = @exported_registry.clone\n\n begin\n yield(@new_registry)\n ensure\n @exported_registry = @new_registry\n end\n end\n\n nil\n end",
"def call_move(reg_key, addr, i_reg, m_spec)\n to_addr = get_mem_addr(addr, i_reg)\n from_addr = @registers['I1'].word.to_i\n\n (0..(m_spec - 1)).each do |i|\n @computer.memory.write(to_addr + i, @computer.memory.read(from_addr + i))\n end\n end",
"def read_register(reg_or_val, options = {})\n write_register(reg_or_val, options.merge(write: false))\n end",
"def shiftLeft(register)\n\tregister.shift\n\tregister.push(0)\nend",
"def setr(a, b, c)\n @registers[c] = @registers[a]\n end",
"def mov(wf, dest_reg, src_reg)\n r = reg_to_pair(src_reg)\n w = reg_to_pair(dest_reg)\n u = src_reg_to_alu_op(src_reg)\n dest_bank = dest_reg_to_bank(dest_reg)\n\n wf.play 'rdGPAddr', r, r, r, _\n wf.play 'rdGP', x, x, x, _\n wf.play 'wrGPAddr', w, w, w, _\n wf.play dest_bank, _, x, _, _\n wf.play 'aluOp', u, u, u, _\n wf.play 'aluOut', x, x, x, _\n wf.play '-endUncond', _, _, _, x\nend",
"def lock_reg(reg)\n c = @by_reg[reg.to_sym]\n c.locked=true if c\n c\n end",
"def save_registry()\n unless @processed == @regsaved\n unless (@busy_writing_registry.locked?)\n # deep_copy hash, to save the registry independant from the variable for thread safety\n # if deep_clone uses Marshall to do a copy,\n regdump = Marshal.dump(@registry)\n regsize = @registry.size\n Thread.new {\n begin\n @busy_writing_registry.lock\n unless (@registry_local_path)\n @blob_client.create_block_blob(@container, registry_path, regdump)\n @logger.info(\"processed #{@processed} events, saving #{regsize} blobs and offsets to remote registry #{registry_path}\")\n else\n File.open(@registry_local_path+\"/\"+@pipe_id, 'w') { |file| file.write(regdump) }\n @logger.info(\"processed #{@processed} events, saving #{regsize} blobs and offsets to local registry #{registry_local_path+\"/\"+@pipe_id}\")\n end\n @last = Time.now.to_i\n @regsaved = @processed\n rescue Exception => e\n @logger.error(\"Oh my, registry write failed\")\n @logger.error(\"#{e.message}\")\n ensure\n @busy_writing_registry.unlock\n end\n }\n else\n @logger.info(\"Skipped writing the registry because previous write still in progress, it just takes long or may be hanging!\")\n end\n end\n end",
"def resolveXCH\r\n puts \"Before Swap, Register A: \" + @RegA.to_s + \"\\tRegister B: \" + @RegB.to_s\r\n temp = @RegA\r\n @RegA = @RegB\r\n @RegB = temp\r\n puts \"After Swap, Register A: \" + @RegA.to_s + \"\\tRegister B: \" + @RegB.to_s\r\n end",
"def reg_write_ra(regtype)\n if :xregs == regtype\n ra\n else\n raise \"Unsupported register type: #{regtype}\"\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allocate storage for local variables on the stack. | def locals(&blk)
@stack_usage ||= 0
num_locals = blk.arity
# Allocate stack space
locals = (0...num_locals).map do |i|
offset = -(@stack_usage+i+1)
PlusRegister.new j, (offset & 0xFFFF)
end
@stack_usage += num_locals
SUB sp, num_locals
yield *locals
# Deallocate stack space
ADD sp, num_locals
@stack_usage -= num_locals
end | [
"def local_variables() end",
"def create_local_variables_map \n @local_variables = {};\n end",
"def push_local\n <<-CODE\n next_int;\n stack_push(fast_fetch(c->locals, _int));\n CODE\n\n # \"next_int; stack_push(fast_fetch(cpu_current_locals(state, c), _int));\"\n end",
"def push_variables_stack\n @stack.push_variables(@locales_int, @locales_float, @locales_boolean, @locales_string,\n @temporales_locales_int, @temporales_locales_float, @temporales_locales_boolean, @temporales_locales_string)\n @locales_int = {}\n @locales_float = {}\n @locales_boolean = {}\n @locales_string = {}\n @temporales_locales_int = {}\n @temporales_locales_float = {}\n @temporales_locales_boolean = {}\n @temporales_locales_string = {}\n end",
"def local_variables()\n eval( 'local_variables', self )\n end",
"def stack(new_scope = T.unsafe(nil)); end",
"def local_var(aparam)\n # +2 instead of +1 because %ecx is pushed onto the stack in main,\n # In any variadic function we push :numargs from %ebx into -4(%ebp)\n \"-#{PTR_SIZE*(aparam+2)}(%ebp)\"\n end",
"def new_local(name)\n name = name.name if name.is_a? Identifier\n @variables[name] = @parent.store_new_local(name)\n end",
"def new_local(name)\n name = name.name if name.is_a? Identifier\n @variables[name] = @parent.store_new_local(name)\n end",
"def set_local\n <<-CODE\n next_int;\n t1 = stack_pop();\n // printf(\"Set local %d to %s\\\\n\", _int, _inspect(t1));\n t2 = c->locals;\n if(t2->gc_zone == 0) {\n sassert(_int < NUM_FIELDS(t2) && \"locals tuple sized wrong\");\n fast_unsafe_set(t2, _int, t1);\n } else {\n tuple_put(state, t2, _int, t1);\n }\n stack_push(t1);\n CODE\n end",
"def set_local_from_fp\n <<-CODE\n next_int;\n k = (native_int)_int;\n next_int;\n\n t1 = c->stack_top[c->fp - _int];\n\n t2 = cpu_current_locals(state, c);\n if(t2->gc_zone == 0) {\n sassert(k < NUM_FIELDS(t2) && \"locals tuple sized wrong\");\n fast_unsafe_set(t2, k, t1);\n } else {\n tuple_put(state, t2, k, t1);\n }\n CODE\n end",
"def allocate_regs\n walk_and_mark(@compiler.risc_instructions)\n pointer = @compiler.risc_instructions\n while(pointer)\n names = assign(pointer)\n names.each {|name| release_after(pointer, name)}\n pointer = pointer.next\n end\n end",
"def increase_scope()\n $current_scope += 1\n $variables << {}\nend",
"def definir_var_local\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n\n return_value = DefinirVarLocalReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __LPAR121__ = nil\n __RPAR123__ = nil\n __EOL124__ = nil\n var_local120 = nil\n body_var_local122 = nil\n\n\n tree_for_LPAR121 = nil\n tree_for_RPAR123 = nil\n tree_for_EOL124 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 131:4: var_local LPAR body_var_local RPAR EOL\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_definir_var_local_577 )\n var_local120 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local120.tree )\n end\n\n __LPAR121__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_definir_var_local_579 )\n if @state.backtracking == 0\n tree_for_LPAR121 = @adaptor.create_with_payload( __LPAR121__ )\n @adaptor.add_child( root_0, tree_for_LPAR121 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_body_var_local_IN_definir_var_local_581 )\n body_var_local122 = body_var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, body_var_local122.tree )\n end\n\n __RPAR123__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_definir_var_local_583 )\n if @state.backtracking == 0\n tree_for_RPAR123 = @adaptor.create_with_payload( __RPAR123__ )\n @adaptor.add_child( root_0, tree_for_RPAR123 )\n\n end\n\n __EOL124__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_definir_var_local_585 )\n if @state.backtracking == 0\n tree_for_EOL124 = @adaptor.create_with_payload( __EOL124__ )\n @adaptor.add_child( root_0, tree_for_EOL124 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n\n end\n\n return return_value\n end",
"def allocate\n <<-CODE\n _lit = stack_pop();\n stack_push(NEW_OBJECT(Qnil, N2I(_lit)));\n CODE\n end",
"def local_vars\n self[@cfunction][:local_vars]\n end",
"def locals_at l_block\n used =[]\n # call assigns the return register, but as it is in l_block, it is not asked.\n assigned = [ Register::RegisterReference.new(Virtual::RegisterMachine.instance.return_register) ]\n l_block.reachable.each do |b|\n b.uses.each {|u|\n (used << u) unless assigned.include?(u)\n }\n assigned += b.assigns\n end\n used.uniq\n end",
"def locals_at l_block\n used =[]\n # call assigns the return register, but as it is in l_block, it is not asked.\n assigned = [ RegisterReference.new(Register::RegisterMachine.instance.return_register) ]\n l_block.reachable.each do |b|\n b.uses.each {|u|\n (used << u) unless assigned.include?(u) \n }\n assigned += b.assigns\n end\n used.uniq\n end",
"def locals; end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given file, look up matching application | def select_app file_name
ftype = file_type( file_name ).downcase
@app_map[ ftype ]
end | [
"def select_app file_name\n\t\tftype = file_type file_name\n\t\t@app_map[ ftype ]\n\t\t#this takes the file name and calls file type\n\t\t#receives the 'normalized' file extension\n\t\t#using it as a key into @app_map ro see which app to run\n\tend",
"def select_app file_name \n ftype = file_type( file_name ).downcase\n @app_map[ ftype ]\n end",
"def find snippet\n apps.select do |app|\n app.filename.include? snippet\n end\n end",
"def find file\n manifest.find file\n end",
"def find_apf( path_and_file = self.file_name_and_contents.path_and_file)\n match_apf = []\n regexp = /^t([^ \\#]+)( *$| )/\n File_name_and_contents.new( path_and_file ).contents.each do |line|\n if line.match(regexp) != nil\n if line.match(regexp)[1] != nil \n match_apf << ( self.file_name_and_contents.path_and_file.sub(/\\/.+/, '') + '/' + line.match(regexp)[1].chomp + '.apf' ) \n end\n end\n end\n match_apf\n end",
"def detect(dir = Dir.pwd)\n candidates = @registry.find_all do |pack|\n pack.applicable? dir\n end\n\n raise NotFound if candidates.empty?\n raise AmbiguousApp if candidates.length > 1\n\n candidates.first\n end",
"def script_finder(script_name) \n\n fileName = \"db/script.db\"\n fileMode = \"r\"\n \n begin \n file = File.new(fileName, fileMode)\n \n # read file content\n content = file.readlines \n \n # get one line in file content\n # content.each { |line| puts \"line : #{line}\"}\n\n for line in content\n # find match string\n\n if line.match(script_name) \n puts line.split('\"')[1]\n end\n end \n\n # close file \n file.close \n rescue\n puts \"file not open error\"\n\n end\nend",
"def read_market_app_regexes(path_to_file)\n market_app_regexes = {}\n File.open(path_to_file).readlines.each do |line|\n line.strip!\n unless line.start_with? '#' or line.empty?\n splitted = line.split(':')\n next unless splitted.size == 2\n market = splitted[0]\n app = splitted[1]\n market_app_regexes[market] = Set.new if market_app_regexes[market].nil?\n market_app_regexes[market].add app\n end\n end\n market_app_regexes\n end",
"def search\n Dir.glob(@config.target_file_pattern, File::FNM_CASEFOLD).each do |file_path|\n next if FileTest.directory?(file_path)\n\n extension = get_extension(file_path)\n tokens = get_tokens(file_path, extension)\n search_romaji(extension, tokens, file_path)\n end\n\n nil\n end",
"def app_files_matching_patterns\n matching = []\n app_dir = File.join(destination_directory, 'app')\n detection_rules.each do |rule|\n rule.each do |glob, pattern|\n next unless String === pattern\n full_glob = File.join(app_dir, glob)\n files = StagingPlugin.scan_files_for_regexp(app_dir, full_glob, pattern)\n matching.concat(files)\n end\n end\n matching\n end",
"def match path\n\n public_path = \"/\"\n\n segments = path.split \"/\"\n segments.shift # the first segment is empty since path has a leading slash\n\n while segment = segments.first and directory? File.join( public_path, segment )\n public_path = File.join public_path, segments.shift\n end\n\n if segment = segments.first and extension = component?( File.join( public_path, segment ) )\n application = segment\n segments.shift\n elsif extension = component?( File.join( public_path, \"index.vwf\" ) ) # TODO: configuration parameter for default application name\n application = \"index.vwf\" # TODO: configuration parameter for default application name\n elsif extension = component?( File.join( public_path, \"index.dae\" ) ) # TODO: delegate list of supported types to #component # TODO: configuration parameter for default application name\n application = \"index.dae\" # TODO: configuration parameter for default application name\n elsif extension = component?( File.join( public_path, \"index.unity3d\" ) ) # TODO: delegate list of supported types to #component # TODO: configuration parameter for default application name\n application = \"index.unity3d\" # TODO: configuration parameter for default application name\n end\n\n if extension\n\n instance = segments.shift if instance?( segments.first )\n private_path = File.join( segments.shift segments.length ) unless segments.empty?\n\n Match.new [ public_path, application, instance, private_path ]\n\n end\n\n # TODO: which parts are URL paths and which are filesystem paths? don't use File.join on URL paths\n\n end",
"def detect_app_name\n app_files = app_files_matching_patterns\n\n # We may have multiple releases. Look for app names where we also have a script in bin/ to boot them\n interesting_app_files = app_files.select do |app_file|\n app_name = File.basename(app_file)[0..-5] # Remove the .rel suffix\n File.exists? \"app/bin/#{app_name}\"\n end\n\n appname = if interesting_app_files.length == 1\n File.basename(interesting_app_files.first)[0..-5] # Remove the .rel suffix\n elsif interesting_app_files.length == 0\n raise \"No valid Erlang releases with start scripts found. Cannot start application.\"\n else\n raise \"Multiple Erlang releases with different names found. Cannot start application. (Found: #{interesting_app_files.inspect})\"\n end\n\n # TODO - Currently staging exceptions are not handled well.\n # Convert to using exit status and return value on a case-by-case basis.\n raise \"Unable to determine Erlang startup command\" unless appname\n appname\n end",
"def find_match_index (fileArray, match_string)\n fileArray.each_index {|index|\n if fileArray[index].include?(match_string)\n return index # no error checking, SO MAKE SURE THE MATCH EXISTS IN YOUR FILE\n end}\nend",
"def find_requirable_file(file)\n root = full_gem_path\n\n require_paths.each do |lib|\n base = \"#{root}/#{lib}/#{file}\"\n Gem.suffixes.each do |suf|\n path = \"#{base}#{suf}\"\n return path if File.file? path\n end\n end\n\n return nil\n end",
"def app_file\n c = caller_files.first\n c = $0 if !c || c.empty?\n c\n end",
"def interpret_app(path)\n File.basename(path)\n end",
"def file_match(file)\n raise ArgumentError, \"Filename cannot be nil\" if file.nil?\n {:filename => file, :matched => file, :line => 1, :column => 1}\n end",
"def scrapeFilesForLauncherActivity()\r\n\tsmali_files||=[]\r\n\tDir.glob('original/smali*/**/*.smali') do |file|\r\n\t checkFile=File.read(file)\r\n\t if (checkFile.include?\";->onCreate(Landroid/os/Bundle;)V\")\r\n\t\tsmali_files << file\r\n\t\tsmalifile = file\r\n\t\tactivitysmali = checkFile\r\n\t end\r\n\tend\r\n\ti=0\r\n\tprint \"[*] Please choose from one of the following:\\n\"\r\n\tsmali_files.each{|s_file|\r\n\t\tprint \"[+] Hook point \",i,\": \",s_file,\"\\n\"\r\n\t\ti+=1\r\n\t}\r\n\thook=-1\r\n\twhile (hook < 0 || hook>i)\r\n\t\tprint \"\\nHook: \"\r\n\t\thook = STDIN.gets.chomp.to_i\r\n\tend\r\n\ti=0\r\n\tsmalifile=\"\"\r\n\tactivitysmali=\"\"\r\n\tsmali_files.each{|s_file|\r\n\t\tif (i==hook)\r\n\t\t\tcheckFile=File.read(s_file)\r\n\t\t\tsmalifile=s_file\r\n\t\t\tactivitysmali = checkFile\r\n\t\t\tbreak\r\n\t\tend\r\n\t\ti+=1\r\n\t}\r\n\treturn [smalifile,activitysmali]\r\nend",
"def run file_name \n\t\tapplication = select_app file_name \n\t\tsystem \"#{application} #{file_name}\" \n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize class, and set default strategy to :user | def initialize
super
@strategy = :user
end | [
"def initialize(strategy)\n @strategy = strategy\n end",
"def configure_user_search_strategy(strategy)\n @user_search_strategy =\n case strategy.to_s\n when \"default\"\n GitHub::Ldap::UserSearch::Default.new(self)\n when \"global_catalog\"\n GitHub::Ldap::UserSearch::ActiveDirectory.new(self)\n else\n GitHub::Ldap::UserSearch::Default.new(self)\n end\n end",
"def initialize user\n @user = user\n end",
"def initialize(user, data)\n\t\t\tsuper(user)\n\t\t\tinit(data)\n\t\tend",
"def strategy=(strategy)\n case strategy\n when :user, :search\n @strategy = strategy\n end\n end",
"def strategy\n @strategy ||= @strategy_klass.new(self)\n end",
"def set_default_user(user)\n @_default_user = user\n end",
"def initialize(user, type = :all)\n @user = user\n @type = type\n end",
"def initialize_advertiser_user\n self.user_type = TYPE_ADVERTISER\n self.update_user_code\n self.status = STATUS_ACTIVE\n end",
"def init\n\n\t\terror_handler \"Invalid Login.\" if not @user\n\n\tend",
"def initialize(user_base_object: nil, table_name: nil)\n if table_name\n self.table_name = table_name\n self.user_base_object = UserBase.class_from_table_name(table_name)&.new\n else\n self.user_base_object = user_base_object\n end\n end",
"def set_authenticator\n self.authenticator ||= User::Authenticator::LOCAL\n\n # Set a random password if none exists. This should only be the case for an\n # unpersisted Omniauth user.\n self.password_digest ||= SecureRandom.base64\n end",
"def user(options = {})\n as_user = options[:as_user] || :user\n @user = user_factory(as_user)\nend",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.security.userSource\"\n end",
"def initialize(strategy = :none, *args)\n args << {} unless args.last.is_a?(Hash)\n @strategy = strategy\n case @strategy\n when :oauth\n raise ArgumentError, \"The :oauth strategy requires two or four arguments - consumer_key, consumer_secret, access_key and access_secret.\" unless [3,5].include?(args.size)\n if args.size == 5\n @consumer_key, @consumer_secret, @access_key, @access_secret, @options = *args\n else\n @consumer_key, @consumer_secret, @options = *args\n end\n when :basic\n raise ArgumentError, \"The :basic strategy requires two arguments - screen_name and password.\" unless args.size == 3\n @screen_name, @password, @options = *args\n when :none\n raise ArgumentError, \"The :none strategy does not take any mandatory arguments, only options.\" unless args.size == 1\n @options = *args\n else\n raise ArgumentError, \"Valid strategies are :oauth, :basic and :none.\"\n end\n\n @options = TwitterDispatch::Dispatcher.default_options.merge(@options)\n end",
"def initialize\n # user_id => user\n @users = {}\n end",
"def initialize(user_id)\n @user_id = user_id || 'self'\n end",
"def initialize(user, cost_strategy, group = nil)\n raise(IllegalPriceSensitiveUser, user) if user.dependent?\n\n @inner = user\n @cost_strategy = cost_strategy\n @group = group\n @load_curve = Curve.new(Array.new(Merit::POINTS, 0.0))\n end",
"def initialize(user)\n user ||= User.new\n\n # TODO: Basic User Abilities\n can :create, Contact\n\n return if user.has_role? :banned\n\n # Restrictable Visitor Abilities\n can :create, Account\n\n return unless user.persisted?\n\n # Authenticated User Abilties\n grant_account_abilities(user)\n grant_organisation_abilities(user)\n grant_version_abilities(user)\n\n return unless user.has_role? :admin\n\n # Admin User Abilities\n can [:read, :inspect], PaperTrail::Version\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the Twitter lookup strategy to :search or :user | def strategy=(strategy)
case strategy
when :user, :search
@strategy = strategy
end
end | [
"def configure_user_search_strategy(strategy)\n @user_search_strategy =\n case strategy.to_s\n when \"default\"\n GitHub::Ldap::UserSearch::Default.new(self)\n when \"global_catalog\"\n GitHub::Ldap::UserSearch::ActiveDirectory.new(self)\n else\n GitHub::Ldap::UserSearch::Default.new(self)\n end\n end",
"def configure_search_strategy(strategy = nil)\n # configure which strategy should be used to validate user membership\n configure_membership_validation_strategy(strategy)\n\n # configure which strategy should be used for member search\n configure_member_search_strategy(strategy)\n end",
"def lazy_search_twitter()\n @refresh_url = \"#{@api_endpoint_twitter}#{@response['refresh_url']}\" unless (@response.nil? || @response['refresh_url'].nil? || @response['refresh_url'].empty?)\n if @refresh_url\n #FIXME persist the refresh url - server restart would be a pain elsewise\n search_url = \"#{@refresh_url}&result_type=#{@result_type}&rpp=#{@results_per_page}\"\n @log.info \"lazy search using '#{search_url}'\" #workaround to get refresh url logged w/ the Daemons gem\n @response = http_get search_url\n else\n @log.debug \"regular search using '#{@search_term}'\"\n @response = search_twitter()\n end\n end",
"def configure_member_search_strategy(strategy = nil)\n @member_search_strategy =\n case strategy.to_s\n when \"classic\"\n GitHub::Ldap::MemberSearch::Classic\n when \"recursive\"\n GitHub::Ldap::MemberSearch::Recursive\n when \"active_directory\"\n GitHub::Ldap::MemberSearch::ActiveDirectory\n else\n # fallback to detection, defaulting to recursive strategy\n if active_directory_capability?\n GitHub::Ldap::MemberSearch::ActiveDirectory\n else\n GitHub::Ldap::MemberSearch::Recursive\n end\n end\n end",
"def show\n @word = Word.find(params[:id])\n if current_user.authentications[2]==\"twitter\"\n @tweet_search = current_user.twitter.search(@word.word)\n else\n @tweet_search\n end\n end",
"def set_Twitter(value)\n set_input(\"Twitter\", value)\n end",
"def twitter\n get_authorization(:twitter)\n end",
"def respondToSearches(config, catalog, twitter)\n\tmax = config.searchesSinceId\n\t\n\t# load the list of satellite names to search for\n\tsatellite_queries = config.searchTerms\n\tif satellite_queries == nil then return config.searchesSinceId end\n\t\n\t# assemble the list of names into a single OR query w/each name quoted\n\tsearchQuery = satellite_queries.map {|name| \"\\\"#{name}\\\"\"}.join(' OR ')\n\t\n\tbegin\n\t\tsearchResults = twitter.search(searchQuery, :since_id => config.searchesSinceId, :result_type => \"recent\")\n\t\tsearchResults.each do |tweet|\n\t\t\tif tweet.id > max then max = tweet.id end\n\t\t\tif (tweetAuthor = getTweetAuthor(tweet)) == 'WheresThatSat' then next end\n\t\t\t\n\t\t\t# skip any results that refer to us: they're handled as Mentions\n\t\t\tif tweet.text.match(/@WheresThatSat/i) then next end\n\t\t\t\n\t\t\tbegin\n\t\t\t\tgeo = parseTweetPlaceTag(tweet)\n\t\t\trescue RuntimeError => err\n\t\t\t\ttwitter.update(format(\"@%s %s\", tweetAuthor, err), :in_reply_to_status_id => tweet.id)\n\t\t\t\t$logger.info {\"#{tweetAuthor}, #{tweet.id}, #{tweet.created_at.utc}, \\\"#{err}\\\"\"}\n\t\t\t\tnext\n\t\t\tend\n\t\t\t\n\t\t\trespondToContent(catalog, twitter, tweet.text, tweet.id, tweet.created_at.utc,\n\t\t\t\t\ttweetAuthor, geo, false, satellite_queries)\n\t\tend\n\trescue Twitter::Error => e\n\t\t$logger.error {e}\n\tend\n\treturn max\nend",
"def twitter_handle(handle = nil)\n handle || Flakey.configuration.twitter_handle\n end",
"def autocomplete_suggesters!(config)\n config.autocomplete_path = 'suggest'\n config.autocomplete_suggester = 'defaultSuggest'\n super(config, '%sSuggest')\n end",
"def autocomplete_suggesters!(config)\n config.autocomplete_path = 'suggest'\n config.autocomplete_suggester = 'suggest'\n super(config, '%s_suggest')\n end",
"def twitter_identity\n @twitter_identity ||= has_provider_auth('twitter')\n end",
"def twitter_api\n httpauth = Twitter::HTTPAuth.new(twitter_username, twitter_password)\n Twitter::Base.new(httpauth)\n end",
"def connect_twitter\r\n redirect_to \"/auth/twitter?path=#{params['path']}\"\r\n end",
"def load_twitter_account\n # FIXME would this be better placed in the models?\n @twitter_account = @workspace ? @workspace.twitter_account || @workspace.create_twitter_account :\n @user.twitter_account || @user.create_twitter_account\n end",
"def twitter_auth_cache\n self.auth_profiles.where(provider: 'twitter').first\n end",
"def oauth #:nodoc:\n @oauth ||= Bountybase.config.twitter[Bountybase.instance] ||\n begin\n E \"Cannot find twitter configuration for\", Bountybase.instance\n raise \"Cannot find twitter configuration\"\n end\n end",
"def autocomplete_suggesters!(config)\n config.autocomplete_path = 'suggest'\n config.autocomplete_suggester = 'suggest' # TODO: TBD?\n super(config)\n end",
"def default_strategies(*strategies); end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a specified user from Twitter | def twitter_user
@twitter_user ||= TwitterClient.new.user(@user)
end | [
"def get_twitter_user\r\n begin\r\n\t return $client.user(twitter_id.to_i)\r\n\t rescue Twitter::Error\r\n\t return nil\r\n\t end\r\n end",
"def get_user_detail_by_twitter_id(twitter_id)\n @user = User.find(:select=>\"*\",:conditions=>[\"twitter_id=#{twitter_id}\"])\n return @user\n end",
"def tweet_user(tweet) \n if ! tweet.is_a?(String)\n base = tweet.has_key?(:from_user) ? tweet[:from_user] : tweet[:user][:screen_name]\n else\n base = tweet\n end\n base =~ /^@/ ? base : \"@#{base}\"\n end",
"def get_user_from_tweet(tweet_id)\r\n begin\r\n return $client.status(tweet_id.to_i).user.id\r\n rescue Twitter::Error\r\n return nil\r\n end\r\nend",
"def get_user_id_by_twitter_id(twitter_id)\n @user = User.find(:first ,:select=>\"id\",:conditions=>[\"twitter_id=?\",twitter_id])\n return @user.id\n end",
"def fetch_user\n twitter_user = twitter_client.user(screen_name)\n Lead.from_twitter(twitter_user)\n end",
"def fetch_user\n user = Twitter.user(screen_name)\n Lead.from_twitter(user)\n end",
"def get_profile( twitter_id ) \n if twitter_id.class == Fixnum\n data = Net::HTTP.get_response('twitter.com', \"/users/show.json?user_id=#{twitter_id}\").body\n else\n data = Net::HTTP.get_response('twitter.com', \"/users/show/#{twitter_id}.json\").body\n end\n \n # we convert the returned JSON data to native Ruby\n # data structure - a hash\n result = JSON.parse(data)\n \n # if the hash has 'Error' as a key, we raise an error\n if result.has_key? \"error\"\n raise TwitterError.new result[\"error\"]\n end\n result\n end",
"def get_login_by_twitter_id(twitter_id)\n @user = User.find(:first ,:select=>\"login\",:conditions=>[\"twitter_id=?\",twitter_id])\n return @user.login\n end",
"def find_twitter_handle\n self.match(/(\\@\\w+)/i)\n return $1\n end",
"def twitter\n get_authorization(:twitter)\n end",
"def twitter_screen_name_clash\n auth = session['devise.twitter_data']\n raise ActiveResource::UnauthorizedAccess.new('Unauthorized') unless auth\n\n if params[:username]\n auth.chosen_user_name = params[:username]\n render and return if User.exists? username: params[:username]\n @user = User.create_user_from_twitter_oauth(auth)\n unless handle_oauth_login\n flash[:alert] = @user.errors.to_a[0] if @user.errors\n redirect_to new_user_registration_path\n end\n end\n end",
"def get_twitter(npo)\n\t\trequire 'net/http'\n\t\trequire 'rexml/document'\n\n begin\n\n res = Net::HTTP.get(URI.parse(\"http://api.twitter.com/1/users/show.xml?screen_name=#{npo.twitter}\"))\n document = REXML::Document.new(res)\n\n if document.root.elements[2]\n document.root.elements[2].expanded_name == 'error' ? nil : npo.twitter\n end\n rescue\n nil\n end\n\tend",
"def get_username(tweet)\n return tweet.attrs[:user][:screen_name]\n end",
"def blogger_twitter_username\n if blogger and blogger.respond_to?(:twitter_username)\n blogger.twitter_username\n end\n end",
"def returnFromAuth\n session[:screen_name] = oauth_hash['info']['nickname']\n session[:twitter_id] = oauth_hash['uid'].to_i\n # binding.pry\n\n user = User.find_or_create_by(twitter_id:(session[:twitter_id]))\n\n if user\n redirect_to \"/users/#{session[:screen_name]}/edit\"\n end\n end",
"def getTweetAuthor(tweet)\n\treturn tweet.from_user || tweet.user.screen_name\nend",
"def user data\n Services::Twitter::User.new do |u|\n u.twitter_id = data.id\n u.name = data.name\n u.picture_url = data.profile_image_url_https\n u.screen_name = data.screen_name\n end\n end",
"def twitter_url_for(username)\n \"http://twitter.com/#{username}\"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse out a percentage (as a float) | def parse(text)
text.gsub(/[\s%]/, '').strip.to_f
end | [
"def percentage_to_float(percentage_string, percentage_divider = 100, decimal_delimiter = \".\")\n string_value = filter_non_number_characters(percentage_string, decimal_delimiter)\n value = string_value.to_f / percentage_divider\n return value\nend",
"def percent2PercentVal(text)\n return (text.sub(/,/,\".\").to_f/100.0).to_s\n end",
"def percent(percentage)\n delta(exact_value * (percentage / 100.0))\n end",
"def pct(whole, part) (100 * part.to_f / whole).round(1).to_s + \"%\" end",
"def proper_fraction_to_float(proper_fraction)\n float = proper_fraction.split('/').first.to_f/proper_fraction.split('/').last.to_f\n end",
"def fmt_percentage\n do_percentage\n end",
"def percentage(value)\n self.abs.fdiv(value) * 100\n end",
"def percent\n p = (number(2).to_f * 0.006103516).round\n if p > 100\n error \"Not percent: #{p}\"\n end\n p\n end",
"def parse_percentage_expression\n regex = /(?<percentage>-?[\\d.]+)% (?<operator>(off?|on)) (?<expr>.*$)/\n match = @expression.match(regex)\n\n if match\n operator = match.named_captures[\"operator\"]\n percentage = match.named_captures[\"percentage\"]\n expr = match.named_captures[\"expr\"]\n\n percentage_expr = \"#{expr} * #{percentage.to_f/100}\"\n\n case operator\n when 'of'\n @expression = percentage_expr\n when 'off'\n @expression = \"#{expr} - (#{percentage_expr})\"\n when 'on'\n @expression = \"#{expr} + (#{percentage_expr})\"\n end\n end\n end",
"def percentage(value)\n unless value.is_a?(Sass::Script::Number) && value.unitless?\n raise ArgumentError.new(\"#{value} is not a unitless number\")\n end\n Sass::Script::Number.new(value.value * 100, ['%'])\n end",
"def percent\n \"%0.1f%%\" % (to_f * 100)\n end",
"def validate_format_percentage(name, value)\n DataTypeValidator.validate name, Float, value, ->(arg) { arg >= 0.0 && arg <= 1.0 }\n end",
"def percent!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n\n type = PERCENT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 163:11: '%'\n match( 0x25 )\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 percent!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 24 )\n\n type = PERCENT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 162:11: '%'\n match( 0x25 )\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__, 24 )\n\n end",
"def convert_percent(n)\n\t\t\"%06.2f\".%(n).split('.').join\n\tend",
"def percent!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 17)\n\n type = PERCENT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 359:10: '\\\\%'\n match(?\\%)\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__, 17)\n\n end",
"def vol_perc\n if match = @args[:props][\"volume\"].to_s.match(/(\\d+):\\s*(\\d+)%/)\n return match[2].to_i\n end\n \n raise \"Could not figure out the volume.\"\n end",
"def percent_of(total)\n format '%.2f%%', self / total.to_f * 100\n end",
"def value\n @percent\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private method to load API service | def load_api_service
@api_service = ApiService.new
end | [
"def initialize\n @services = load\n end",
"def api\n @api ||= PrismicService.init_api\n end",
"def data_service\n DataServicesApi::Service.new(url: api_service_url)\n end",
"def api\n\t\t@api ||= PrismicService.init_api\n\tend",
"def load_cached_api\n api = nil\n\n if File.exists?(self.class::API_CACHE)\n File.open(self.class::API_CACHE) do |file|\n api = Marshal.load(file)\n end\n else\n api = @client.discovered_api(self.class::API_NAME, self.class::API_VERSION)\n File.open(self.class::API_CACHE, 'w') do |file|\n Marshal.dump(api, file)\n end\n end\n\n api\n end",
"def service_require\n ruby_file_path @api, service_name_full\n end",
"def initialize\n super \n @@api = initialize_api\n end",
"def data_service\n DataServicesApi::Service.new\n end",
"def load_service\n @service = Service.find(params[:id])\n end",
"def getHttpService; raise NotImplementedError; end",
"def load_from_api(attrs)\n load(attrs, true)\n end",
"def initialize\n load_references\n load_services\n end",
"def api_client\n Api::Client.new\n end",
"def init_service_by_id(id)\n require_relative 'service'\n return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)\n end",
"def reload_services\n api('ReloadServices')\n end",
"def load_api_config api_version\n lib = File.dirname(File.dirname(__FILE__))\n path = \"#{lib}/api_config/#{service_name}-#{api_version}.yml\"\n YAML.load(File.read(path))\n end",
"def api_client\n @api_client ||= initialize_api_client\n end",
"def getHttpService; @service; end",
"def load_services\n @services = []\n raw_reference.each do |type, services|\n services.each do |name, data|\n s = Driver::Service.new\n s.name = name\n s.uri_hint = data['uri_hint']\n s.path = data['path']\n s.form = data['form']\n s.schema = data['schema']\n s.search_schema = data['search_schema']\n s.read_only = data['read_only'] ? true : false\n s.endpoints = data['endpoints']\n s.type = type\n s.instance_variable_set :@url, data['url'] if data['url']\n @services.push s\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For when Mailchimp is testing that our webhook works | def confirm_webhook
render :json => "ok", :status => 200
end | [
"def webhook_test()\n\n query_parameters = {}\n query_parameters['apikey'] = @api_key\n query_parameters['apisecret'] = @api_secret\n\n resource_path = 'api/v2/webhook/test'\n get_request(resource_path, query_parameters, nil)\n end",
"def test\n Rails.logger.debug \"Chargify Webhook test!\"\n render :nothing => true, :status => 200\n end",
"def authenticate\n webhook_key = FfcrmMailchimp.config.webhook_key\n webhook_key.present? && params[\"webhook_key\"] == webhook_key\n end",
"def webhook\n puts params\n\n status 200\n end",
"def test_notification(webhook_key=SLACK_WEBHOOK_KEY, base_url=SLACKSPACE_BASE_URL)\n #puts \"TEST_NOTIFICATION WEBHOOK_KEY #{webhook_key}\"\n \trequest_json(\"https://monitoring.api.rackspacecloud.com/v1.0/#{tennant_id}/test-notification\", :post, <<-EEOOFF)\n {\n \"type\": \"webhook\",\n \"details\": {\n \"url\": \"#{base_url}slack/webhook?key=#{webhook_key}\"\n }\n }\n \tEEOOFF\n end",
"def webhook_for_vanilla_pay_notification\n # DO SOMETHING\n end",
"def test_webhook(webhook_id)\n get \"webhooks/#{webhook_id}/test\"\n true # An exception will be raised if any error occurs\n end",
"def webhook\n webhook_data = params[:payload]\n\n if GoCardless.webhook_valid?(webhook_data)\n # Do something with webhook_data, save to DB, log etc\n # For example, if you had a model called Bills and you want\n # to update each of the incoming bills\n # webhook_data.bills.each do |b|\n # bill = Bills.find_by_bill_id(b[:id])\n # bill.status = b[:status]\n # bill.save\n # end\n else\n # log the error\n end\n\n render nothing: true, status: 200\n end",
"def create\n if params['mailchimpkey'].present? && params['mailchimpkey'] == ENV['MAILCHIMP_WEBHOOK_SECRET_KEY']\n @mailchimp_update = MailchimpUpdate.new(\n email: params['data']['email'],\n update_type: params['type'],\n fired_at: params['fired_at'],\n raw_content: params.to_json,\n reason: params['data']['reason'] || nil\n )\n\n respond_to do |format|\n if @mailchimp_update.save\n format.html { redirect_to @mailchimp_update, notice: 'Mailchimp update was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mailchimp_update }\n\n else\n Rails.logger.warn('MailchimpUpdatesController#create: Received new update with bad secret key.')\n head '400'\n end\n end\n end\n end",
"def check_if_request_is_from_chargebee(_params) \n if _params['webhook_key'] != \"DEMO_KEY\"\n render status: 403, json: {\"error_msg\" => \"webhook_key is not correct\"}\n return false\n end\n return true\n end",
"def sinatra_hook\n @webhook || Proc.new {}\n end",
"def webhooks\n puts \"*************** inside webhooks ************************\"\n puts \"***params: \" + params.inspect\n puts \"*********************************************************\"\n # Check to insure valid freshbooks api request.\n if params[:system] == \"https://skunkwerxperformanceautomotivellc.freshbooks.com\"\n puts \"**************** inside params[:system] ***************\"\n puts \"***params: \" + \" - \" + params.inspect + \" - \"\n # Callback Verify action for all webhook methods;\n if params[\"name\"] == \"callback.verify\"\n puts \"****************** inside callback.verify **************\"\n puts \"***params[:verifier]: \" + params[:verifier]\n puts \"********************************************************\"\n callback_verify(params[:verifier])\n end\n # Freshbooks sends notification on item create, update and destroy.\n if params[\"key\"] == \"item.create\"\n puts \"********************* inside item.create **************\"\n puts \"***params[:object_id] : \" + params[:object_id]\n item_create(params[:object_id])\n puts \"******************************************************\"\n end\n\n if params[\"key\"] == \"item.update\"\n puts \"********************* inside item.update **************\"\n puts \"***params[:object_id] : \" + params[:object_id]\n item_update(params[:object_id])\n puts \"******************************************************\"\n end\n\n if params[\"key\"] == \"item.delete\"\n puts \"********************* inside item.delete ***************\"\n puts \"***params[:object_id] : \" + params[:object_id]\n item_delete(params[:object_id])\n puts \"******************************************************\"\n end\n # Send response status ok.\n head 200\n end\n end",
"def add_webhook\n get_api\n resp = {}\n begin\n resp = @api.lists(api_id).webhooks.create(\n body: {\n url: Rails.application.routes.url_helpers.webhooks_api_v0_mailchimp_list_url(\n id, \n only_path: false, \n host: APP_CONFIG[\"mailing-url\"].gsub(\"http://\",\"\")\n ),\n events: decode(webhook_configuration)[\"events\"],\n sources: decode(webhook_configuration)[\"sources\"]\n }\n ).body\n rescue Gibbon::MailChimpError => e\n Rails.logger.info \"Mailchimp webhook failed with error: #{e}\"\n resp = { \"id\" => nil, errors: get_errors(e.body) }\n end\n\n if resp[\"id\"].nil?\n self.errors.add(:base, resp[:errors])\n else\n new_config = decode(webhook_configuration)\n new_config[:id] = resp[\"id\"]\n update_attribute(:webhook_configuration, encode(new_config))\n update_attribute(:receive_notifications, true)\n end\n end",
"def webhook\n reason = params[\"type\"]\n customer_id = params[\"data\"][\"object\"][\"customer\"]\n ContactMailer.send_stripe_info(customer_id, reason).deliver\n head 200\n end",
"def init_webhooks\n unless Rails.env.test?\n new_customer_callback_url = Figaro.env.root_uri + '/hooks/new_customer_callback'\n uninstall_callback_url = Figaro.env.root_uri + '/hooks/app_uninstalled_callback'\n\n new_customer_webhook = ShopifyAPI::Webhook.new(topic: 'customers/create', format: 'json', address: new_customer_callback_url)\n uninstall_webhook = ShopifyAPI::Webhook.new(topic: 'app/uninstalled', format: 'json', address: uninstall_callback_url)\n\n new_customer_webhook.save\n uninstall_webhook.save\n end\n end",
"def webhook\n if request.get?\n # return a 200. this is used to setup the webhook\n render :text => 'Webhook Endpoint'\n end\n\n if request.post?\n # log the json data for record keeping\n logger.info(request.raw_post)\n # handle json body\n raw_data = JSON.parse(request.raw_post)\n data = {}\n data['messageTime'] = raw_data['messageTime'].to_time.to_formatted_s(:long_ordinal)\n data['confirmation_number'] = raw_data['message'][0]['confirmationNumber']\n data['order_number'] = raw_data['message'][0]['orders'][0]['order_number']\n data['email'] = raw_data['message'][0]['email']\n data['fullname'] = raw_data['message'][0]['fullname']\n\n # use email to find correct transaction\n transaction = Transaction.find_by_email(data['email'])\n\n if !transaction.participant_registration.nil?\n # handle payment for a participant registration\n transaction.participant_registration.paid = true\n transaction.participant_registration.save(false)\n end\n\n if !transaction.team_registration.nil?\n # handle payment for a team registration\n transaction.team_registration.paid = true\n transaction.team_registration.save(false)\n end\n\n if !transaction.payment.nil?\n # handle payment for a team registration\n transaction.payment.paid = true\n transaction.payment.save(false)\n end\n\n # mark the transaction as complete\n transaction.complete = true\n transaction.save\n\n # send receipt email\n TransactionMailer.deliver_receipt(transaction, data)\n\n # return success message\n render :text => 'Success'\n end\n end",
"def setup_shopify_webhook(topic, meth)\n unless ShopifyAPI::Webhook.count(topic: topic) > 0\n address = send :webhook_url, meth\n ShopifyAPI::Webhook.create topic: topic, address: address, format: 'json'\n end\n end",
"def test_live_api_secondary_ok\n mock_clients bad_req_code, nil\n name = ENV['TEST_NAME']\n email = ENV['TEST_EMAIL']\n\n assert !name.nil?\n assert !email.nil?\n\n email_addr = EmailAddress.new(name, email)\n email_addr_text = \"#{name} <#{email}>\"\n\n request_hash = {}\n request_hash['from'] = email_addr_text\n request_hash['to'] = email_addr_text\n request_hash['cc'] = email_addr_text\n request_hash['bcc'] = email_addr_text\n request_hash['subject'] = 'Moisiadis Email API Test'\n request_hash['content'] = 'Sent with the Moisiadis Email API using Mailgun'\n\n expected_hash = {}\n expected_hash['from'] = email_addr\n expected_hash['to'] = [email_addr]\n expected_hash['cc'] = [email_addr]\n expected_hash['bcc'] = [email_addr]\n expected_hash['subject'] = request_hash['subject']\n expected_hash['content'] = request_hash['content']\n\n assert_equal expected_response(ok_code, expected_hash), ambiguous_request(request_hash)\n end",
"def webhooks\n \n data = JSON.parse(params['json'])\n# puts \"\"\n# puts data.inspect\n # if it's an authorization webhook.\n if data['type'].include?(\"member.authorization\")\n\n # fetch the user for this webhook.\n user = User.find_by(kpass_id: data['data']['object']['member']['id'])\n \n # if we found the user in our sample app..\n if user.present?\n \n\n # if the webhook is telling us they've been approved..\n if data['type'] == \"member.authorization.approved\"\n\n # for some reason if we save user with password the session is kicked out\n\n\n # update the username of the user, since we should have access to it now\n user.username = data['data']['object']['member']['username']\n # user.password = 'batterypop' #devise throws exception without a password upon save\n user.birthday = data['data']['object'][\"member\"][\"birthday\"]\n user.gender = data['data']['object'][\"member\"][\"gender\"]\n user.username_avatar_age_gender = data['data']['object'][\"keys\"][\"username_avatar_age_gender\"]\n user.access_to_moderated_chats = data['data']['object'][\"keys\"][\"access_to_moderated_chats\"]\n user.youtube_and_3rdparty_videos = data['data']['object'][\"keys\"][\"batterypop_youtube_and_3rdparty_videos\"]\n user.publish_public_profile = data['data']['object'][\"keys\"][\"batterypop_publish_public_profile\"]\n\n user.save\n\n\n\n # if the webhook is telling us that our authorization has been revoked..\n elsif data['type'] == \"member.authorization.revoked\"\n\n # destroy the user.\n # user.destroy\n anonymize_user(user)\n\n # if the webhook is telling us that the parent of an under-13 user has\n # denied our ability to see personal information for this user..\n elsif data['type'] == \"member.authorization.rejected\"\n\n # destroy the user.\n # user.destroy\n anonymize_user(user)\n end\n\n end\n\n end\n\n # communicate back to kpass that we've received the webhook.\n render json: [true]\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "subscribe", "fired_at": "20090326 21:35:57", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054", | def customer_mailchimp_subscribed
{
:list_id => data['list_id'],
:fired_at => params['fired_at'],
:mailchimp_id => data['id'],
:email => data['email'],
:email_type => data['email_type'],
:merges => data['merges'],
:ip_opt => params['ip_opt'],
:ip_signup => params['ip_signup'],
:human => "#{data['email']} subscribed to Mailchimp list with ID #{data['list_id']}"
}
end | [
"def subscription_data\n {}\n end",
"def http_raw_notify_data\n {\n \"id\"=>\"b9879d2b-052f-4a0a-8a3f-3e72049e4d19\", \n \"event\"=>\"invoice_paid\", \n \"payload\"=> invoice_data\n }.to_json\n end",
"def customer_mailchimp_unsubscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :campaign_id => data['campaign_id'],\n :human => \"#{data['email']} unsubscribed from Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def subscribe_frame d, h\n h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack])\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end",
"def sse_event(id, data)\r\n \"id:#{id}\\ndata:#{data}\\n\\n\"\r\nend",
"def handle_subscribed(data)\n request_id, subscription_id = data\n\n trigger(:subscribed, request_id, subscription_id)\n end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def list_subscriptions(list_id)\n get(\"contactList/#{list_id}/subscribe\")\n end",
"def subscribe_for_notification()\n begin\n eventFilters = ['/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS']\n bodyParams = {\n eventFilters: eventFilters,\n deliveryMode: {\n transportType: 'WebHook',\n address: DELIVERY_ADDRESS\n },\n expiresIn: 3600\n }\n endpoint = \"/restapi/v1.0/subscription\"\n resp = $platform.post(endpoint, payload: bodyParams)\n if (resp.status == 200)\n puts (resp.body)\n puts (\"Subscription id: \" + resp.body['id'])\n puts (\"Ready to receive incoming SMS via WebHook.\")\n else\n puts (\"Webhook creation failed.\")\n puts (resp.body)\n end\n rescue StandardError => e\n puts e\n end\nend",
"def subscribe(list)\n l = ActsAsIcontact::List.find(list)\n s = ActsAsIcontact::Subscription.new(:contactId => id, :listId => l.id)\n s.save\n end",
"def subscribe_frame d, h\n h[:ack] = 'auto' unless h[:ack] == 'client'\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end",
"def subid\n unsubscribe[:subid]\n end",
"def get_users_playlists_subscribed\n send_request 'getUserPlaylistsSubscribed'\n end",
"def getNotificationListField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/list/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def subscription_id\n @event.attributes[:subscription_id]\n end",
"def listOfSubscribedEvents (bookieEmail)\r\n events = @BetESS.fMapOfAllEvents\r\n subscribedEvents = @BetESS.fGetSubscribedEventsFrom(bookieEmail)\r\n\r\n puts \"\\t\\tSubscribed Events:\"\r\n subscribedEvents.each {|eventID| puts \"#{events[eventID].toString}------\"}\r\n puts \"########\"\r\n end",
"def data_from_event_name(event_name)\n received_messages.find { |item| item['type'] == 'event' && item['event'] == event_name}\n end",
"def get_subscriptions\n subscriptions = []\n\n # Load the checks\n file = File.read(CHECKS)\n checks = JSON.parse(file)\n\n for check in checks\n subscriptions |= check[\"subscribers\"]\n end\n\n return subscriptions\nend",
"def send_schedule_event(api_url, api_key, schedule_id, event_id)\n on_call_response = Curl.get(\"#{api_url}/schedules/#{schedule_id}/on-calls?flat=true\") do |http|\n http.headers['Authorization'] = \"GenieKey #{api_key}\"\n end\n\n on_call_recipients = JSON.parse(on_call_response.body)['data']['onCallRecipients']\n\n if on_call_recipients.length == 0\n send_event(\"#{event_id}\", items: [{'value': 'N/A'}])\n else\n on_call_items = []\n on_call_recipients.each do |person|\n # Remove the @mintel.com from the alias\n person_name = person.split('@')[0]\n item_entry = {'label': '', 'value': person_name}\n on_call_items.push(item_entry)\n end\n send_event(\"#{event_id}\", items: on_call_items)\n end\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "unsubscribe", "fired_at": "20090326 21:40:57", "data[action]": "unsub", "data[reason]": "manual", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054", | def customer_mailchimp_unsubscribed
{
:list_id => data['list_id'],
:fired_at => params['fired_at'],
:mailchimp_id => data['id'],
:email => data['email'],
:email_type => data['email_type'],
:merges => data['merges'],
:ip_opt => params['ip_opt'],
:campaign_id => data['campaign_id'],
:human => "#{data['email']} unsubscribed from Mailchimp list with ID #{data['list_id']}"
}
end | [
"def unsubscribe(info)\n\t\tend",
"def handle_unsubscribed(data)\n request_id, subscription_id = data\n\n trigger(:unsubscribed, request_id, subscription_id)\n end",
"def unsubscribe_from_list(user, list)\n delete(\"/#{user}/#{list}/subscribers.json\")\n end",
"def list_unsubscribe(*variables)\n set_single('h:List-Unsubscribe', variables.map { |var| \"<#{var}>\" }.join(','))\n end",
"def un_subscribe #unsubscribe is a reserved ruby word do not change\n\n # An unsubscribe email address is of the form <unsubscribe_token>@unsubscribe.zangzing.com\n # we use Mail::Address to parse the addresses and the domain\n # If the to or from addresses are invalid emails, an exception will be raised\n to = Mail::Address.new( params[:to].to_slug.to_ascii.to_s )\n from = Mail::Address.new( params[:from].to_slug.to_ascii.to_s )\n unsub_token = to.local\n\n if unsub_token == 'unsubscribe'\n #unsubscribe from address\n @subs = Subscriptions.find_by_email( from.address )\n else\n #unsubscribe using token\n @subs = Subscriptions.find_by_unsubscribe_token( unsub_token )\n end\n\n if @subs\n @subs.unsubscribe\n zza.track_event(\"email.unsubscribe.received\", {:email => @subs.email, :to => params[:to], :from => params[:from] })\n Rails.logger.info \"MAIL UNSUBSCRIBE: #{@subs.email} unsubscribed by email\"\n end\n render :nothing => true, :status=> :ok\n end",
"def handle_unsubscribe(client, data)\n request_id, subscription_id = data\n\n trigger(:unsubscribe, client, request_id, subscription_id)\n end",
"def subid\n unsubscribe[:subid]\n end",
"def unsubscribe_from_list\n Gibbon::Request.lists(Rails.application.secrets.mailchimp_cold_email_list_id).members(lower_case_md5_hashed_email_address).update(body: { status: 'unsubscribed'} )\n rescue Gibbon::MailChimpError => e\n logger.error \"Mailchimp error while unsubscribing customer: #{e.detail}\" unless e.body['status'] == 404\n true\n end",
"def create_unsubscribes(data)\n # `data` should be a list of hashes, with each hash containing *at least* an `address` key.\n split_return = []\n if data.length >= 1000 then\n resp, resp_l = create_unsubscribes data[999..-1]\n split_return.push(resp)\n split_return.concat(resp_l)\n data = data[0..998]\n elsif data.length == 0 then\n return nil, []\n end\n\n valid = []\n # Validate the unsubscribes given\n while not data.empty? do\n unsubscribe = data.pop\n # unsubscribes MUST contain a `address` key.\n if not unsubscribe.include? :address then\n raise Mailgun::ParameterError.new \"Unsubscribe MUST include a :address key: #{unsubscribe}\"\n end\n\n unsubscribe.each do |k, v|\n # Hash values MUST be strings.\n # However, unsubscribes contain an array of tags\n if v.is_a? Array\n unsubscribe[k] = v.map(&:to_s)\n elsif !v.is_a? String\n unsubscribe[k] = v.to_s\n end\n end\n\n valid.push unsubscribe\n end\n\n response = @client.post(\"#{@domain}/unsubscribes\", valid.to_json, { \"Content-Type\" => \"application/json\" })\n return response, split_return\n end",
"def unsubscribe(list_uid, subscriber_uid)\n\n client = Client.new({\n 'method': Client::METHOD_PUT,\n 'url': Base.config.api_url(sprintf('lists/%s/subscribers/%s/unsubscribe', list_uid, subscriber_uid)),\n })\n client.request\n end",
"def unsubscribe_frame f, h\n id = f.is_a?(OnStomp::Components::Frame) ? f[:id] : f\n create_frame('UNSUBSCRIBE', [{:id => id}, h]).tap do |f|\n raise ArgumentError, 'subscription ID could not be determined' unless f.header?(:id)\n end\n end",
"def unsubscribe\n email = Base64.decode64(params[:token])\n Subscription.where(email: email).destroy_all\n end",
"def get_unsubscribed_list(id)\n unsubscribed = self.client.lists.members({:id => id, :status => \"unsubscribed\"})\n # This does not return an 'errors' field\n \n 0 == unsubscribed['total'] ? [] : unsubscribed['data'].map { |d| d['email'] }\n end",
"def unsubscribe\n mailchimp = Gibbon::API.new\n result = mailchimp.lists.unsubscribe({\n :id => ENV[\"MAILCHIMP_LIST_ID\"],\n :email => {:email => self.email},\n :delete_member => true, # this is NOT the default value\n :send_notify => true,\n :send_goodbye => true\n })\n Rails.logger.info(\"Unsubscribed #{self.email} from MailChimp\") if result\n end",
"def unsubscribe(list_id, current_email, options = {})\n options = apply_defaults_to({:delete_member => true}.merge(options))\n call(\"listUnsubscribe\", list_id, current_email, *options.values_at(:delete_member, :send_goodbye, :send_notify))\n end",
"def unsubscribe_from_all(id_or_email)\n make_json_api_request :post, \"v2/#{account_id}/subscribers/#{CGI.escape id_or_email}/unsubscribe_all\"\n end",
"def unsubscribed(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Recipients/Unsubscribed\", params: params)\n end",
"def unsubscribe_url\n nil\n end",
"def unsubscribe_from_channel; end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "profile", "fired_at": "20090326 21:31:21", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054", | def customer_mailchimp_profile_updated
{
:list_id => data['list_id'],
:fired_at => params['fired_at'],
:mailchimp_id => data['id'],
:email => data['email'],
:email_type => data['email_type'],
:merges => data['merges'],
:ip_opt => params['ip_opt'],
:human => "#{data['email']} updated Mailchimp profile information."
}
end | [
"def trackgen_info;\treturn @json_data['trackgen_info'];\tend",
"def parse_profile_data_json(profile_string)\n profile_hash_org = MultiJson.decode(profile_string)['profile-list']['researcher-profile']\n profile_hash = {\n :firstname => profile_hash_org['first-name'],\n :lastname => profile_hash_org['last-name'],\n }\n puts \"Final hash with profile data from JSON\"\n pp profile_hash\n return profile_hash\n end",
"def get_user_timeline_as_hash( id=nil, login=@login, password=@password )\n json_data = get_user_timeline( login, password, id, 'json', count )\n hash_data = JSON.parse( json_data )\n timeline = Array.new\n i = 0\n\n #debugger\n hash_data.each do |data|\n timeline[i] = Hash.new\n timeline[i][:name] = data['user']['name']\n timeline[i][:icon_url] = data['user']['profile_image_url']\n timeline[i][:text] = data['text']\n i += 1\n end\n timeline\n end",
"def event_endpoint_parsed_response\n [\n {\n 'created' => 1503597602000,\n 'id' => '242801028',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1508454000000,\n 'updated' => 1503597602000,\n 'utc_offset' => -14400000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 28,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/242801028/',\n 'manual_attendance_count' => 0,\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506360598000,\n 'duration' => 7200000,\n 'id' => '243654482',\n 'name' => 'Come Learn to Code!',\n 'status' => 'upcoming',\n 'time' => 1510875000000,\n 'updated' => 1506360640000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 3,\n 'venue' =>\n {'id' => 24975001,\n 'name' => 'ODU Innovation Center',\n 'lat' => 36.8532600402832,\n 'lon' => -76.29104614257812,\n 'repinned' => false,\n 'address_1' => '501 Boush St',\n 'city' => 'Norfolk',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '23510',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243654482/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361286000,\n 'duration' => 7200000,\n 'id' => '243655170',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1513899000000,\n 'updated' => 1506361286000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655170/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361383000,\n 'duration' => 7200000,\n 'id' => '243655210',\n 'name' => 'Come learn to code!',\n 'status' => 'upcoming',\n 'time' => 1516318200000,\n 'updated' => 1506361383000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n # \"venue\"=>\n # {\"id\"=>24975001,\n # \"name\"=>\"ODU Innovation Center\",\n # \"lat\"=>36.8532600402832,\n # \"lon\"=>-76.29104614257812,\n # \"repinned\"=>false,\n # \"address_1\"=>\"501 Boush St\",\n # \"city\"=>\"Norfolk\",\n # \"country\"=>\"us\",\n # \"localized_country_name\"=>\"USA\",\n # \"zip\"=>\"23510\",\n # \"state\"=>\"VA\"},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655210/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n }\n ]\nend",
"def user_data(access_token) \n\n access_token.options[:mode] = :header\n \n # Make signed request to retrieve profile data as JSON\n # ATTN the contributor ID string is hardcoded here for now\n begin\n response = access_token.get('/9999-2411-9999-4111', :headers => {'Accept'=>'application/json'})\n rescue ::OAuth2::Error => e\n raise e.response.inspect\n end\n userhash = MultiJson.decode(response.body)\n userhash['profile-list']['researcher-profile']['uri'] = 'http://localhost:8080/9999-2411-9999-4111'\n userhash['profile-list']['researcher-profile']['profile_format'] = 'application/json'\n\n puts \"userhash=\"\n pp userhash\n return userhash[\"profile-list\"][\"researcher-profile\"]\n end",
"def getNotificationListField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/list/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def facebook_uid\n @json['uid']\n end",
"def profile_details=(list)\n if list.class == Array\n list = List.new(list)\n list.each_with_index do |value, index|\n if value.is_a?(Hash)\n list[index] = ProfileDetail.new(value)\n end\n end\n end\n @profile_details = list\n end",
"def get_event_name_list(event_hash)\n event_array = events_hash[\"resultsPage\"][\"results\"][\"event\"].map do |event|\n event[\"displayName\"]\n end\nend",
"def list_arrays_assigned_to_profile(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/arrays\", args)\nend",
"def adapt_fb_profile_data(fb_profile)\n \n data = {}\n\n case fb_profile['gender']\n when 'male'\n data.store(:gender,'0')\n when 'female'\n data.store(:gender,'1')\n else\n data.store(:gender,'0')\n end \n\n if fb_profile.has_key?('hometown')\n data.store(:country_of_origin, fb_profile['hometown']['name'])\n else\n data.store(:country_of_origin, '')\n end\n \n return data\n\n end",
"def data\n @data ||= if payload.is_a?(Hash)\n if claim && payload.key?('data')\n payload['data']\n else\n payload.except(*CLAIM_KEYS.map(&:to_s))\n end\n else\n payload\n end\n end",
"def get_detail_data(key, start = \"0\", num = \"1000\")\n ids = R.lrange(\"req:\" + key, start.to_i, start.to_i + num.to_i)\n \n data = []\n ids.each do |id|\n o = R.get(id)\n oo = JSON(o)\n t = oo['t']\n z = oo['z']\n\n data << {\n :id => id,\n :url => oo['u'],\n :time_ms => t.to_f / 1000000.0,\n :size_bytes => z.to_i,\n :show_more => \"http://localhost:4567/u/#{id}\"\n }\n end\n \n # data.sort{|x,y| y[:time] <=> x[:time] }.to_json\n data.to_json\nend",
"def load_profile(token)\n profile = GoogleService.user_info(token)\n email_field = profile[\"emails\"].select do |email| \n email[\"type\"] == \"account\"\n end\n\n email = email_field[0][\"value\"] if email_field && email_field.size > 0\n\n {:displayName => profile[\"displayName\"],\n :image => profile[\"image\"][\"url\"],\n :url => profile[\"url\"],\n :email => email} \n end",
"def extract_properties(data)\n data.reject {|k, v| k.to_s.last(2) == \"id\" || [\"created_at\", \"updated_at\"].include?(k)}\n end",
"def parse_event_fields(response)\n event_fields = attributes_to_hash(response, \"//customField\", \"id\", \"//listItem\", \"name\")\n end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def json_data; end",
"def profile\n @profile ||= begin\n profile_xml = repository.datastream(:pid => pid, :dsid => dsid)\n profile_xml.gsub! '<datastreamProfile', '<datastreamProfile xmlns=\"http://www.fedora.info/definitions/1/0/management/\"' unless profile_xml =~ /xmlns=/\n doc = Nokogiri::XML(profile_xml)\n h = doc.xpath('/management:datastreamProfile/*', {'management' => \"http://www.fedora.info/definitions/1/0/management/\"} ).inject({}) do |sum, node|\n sum[node.name] ||= []\n sum[node.name] << node.text\n sum\n end\n h.select { |key, value| value.length == 1 }.each do |key, value|\n h[key] = value.first\n end\n\n h\n rescue\n {}\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "upemail", "fired_at": "20090326\ 22:15:09", "data[list_id]": "a6b5da1054", "data[new_id]": "51da8c3259", | def customer_mailchimp_email_updated
{
:list_id => data['list_id'],
:fired_at => params['fired_at'],
:new_mailchimp_id => data['id'],
:new_email => data['new_email'],
:old_email => data['old_email'],
:human => "#{data['email']} updated their email address on Mailchimp, from '#{data['old_email']}' to '#{data['new_email']}'."
}
end | [
"def email_cleaned\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :campaign_id => data['campaign_id'],\n :email => data['email'],\n :reason => data['reason'],\n :human => \"#{data['email']} was cleaned from Mailchimp list with ID #{data['list_id']}. Reason: '#{data['reason']}'\"\n }\n end",
"def http_raw_notify_data\n {\n \"id\"=>\"b9879d2b-052f-4a0a-8a3f-3e72049e4d19\", \n \"event\"=>\"invoice_paid\", \n \"payload\"=> invoice_data\n }.to_json\n end",
"def getNotificationListField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/list/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def customer_mailchimp_unsubscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :campaign_id => data['campaign_id'],\n :human => \"#{data['email']} unsubscribed from Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def customer_mailchimp_profile_updated\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :human => \"#{data['email']} updated Mailchimp profile information.\"\n }\n end",
"def getNotificationField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def customer_mailchimp_subscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :ip_signup => params['ip_signup'],\n :human => \"#{data['email']} subscribed to Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def parse_event_fields(response)\n event_fields = attributes_to_hash(response, \"//customField\", \"id\", \"//listItem\", \"name\")\n end",
"def event_endpoint_parsed_response\n [\n {\n 'created' => 1503597602000,\n 'id' => '242801028',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1508454000000,\n 'updated' => 1503597602000,\n 'utc_offset' => -14400000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 28,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/242801028/',\n 'manual_attendance_count' => 0,\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506360598000,\n 'duration' => 7200000,\n 'id' => '243654482',\n 'name' => 'Come Learn to Code!',\n 'status' => 'upcoming',\n 'time' => 1510875000000,\n 'updated' => 1506360640000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 3,\n 'venue' =>\n {'id' => 24975001,\n 'name' => 'ODU Innovation Center',\n 'lat' => 36.8532600402832,\n 'lon' => -76.29104614257812,\n 'repinned' => false,\n 'address_1' => '501 Boush St',\n 'city' => 'Norfolk',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '23510',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243654482/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361286000,\n 'duration' => 7200000,\n 'id' => '243655170',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1513899000000,\n 'updated' => 1506361286000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655170/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361383000,\n 'duration' => 7200000,\n 'id' => '243655210',\n 'name' => 'Come learn to code!',\n 'status' => 'upcoming',\n 'time' => 1516318200000,\n 'updated' => 1506361383000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n # \"venue\"=>\n # {\"id\"=>24975001,\n # \"name\"=>\"ODU Innovation Center\",\n # \"lat\"=>36.8532600402832,\n # \"lon\"=>-76.29104614257812,\n # \"repinned\"=>false,\n # \"address_1\"=>\"501 Boush St\",\n # \"city\"=>\"Norfolk\",\n # \"country\"=>\"us\",\n # \"localized_country_name\"=>\"USA\",\n # \"zip\"=>\"23510\",\n # \"state\"=>\"VA\"},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655210/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n }\n ]\nend",
"def delivery_details; message[:delivery_details]; end",
"def getNotificationMemberField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/member/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def clean_email_getproperties(result)\n result.delete(:create_date)\n result.delete(:date_stamp)\n result.delete(:ip_address)\n result.delete(:email_id)\n cleaned_custom_fields = []\n result[:custom_fields][:custom_field].each { |element|\n cleaned_custom_fields << element if !element[:field_name].eql? 'DateStamp' and !element[:field_name].eql? 'IPAddress'\n }\n result[:custom_fields][:custom_field] = cleaned_custom_fields\n result\n end",
"def addl_emails\n self.dig_for_array(\"addlEmails\")\n end",
"def element_to_result(e)\n result = Hash.new\n result['date'] = e.updated_at.strftime(\"%d-%m-%Y %H:%M\")\n result['user'] = e.user.email\n result['interaction'] = e.interaction.resource_type\n result\n end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def getNotificationBoardField(notificationId, field)\n\tresponse = RestClient.get(\"https://api.trello.com/1/notifications/\"+notificationId+\"/board/\"+field+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def convert_log_entry(le)\n {\n id: le[\"id\"],\n type: le[\"type\"],\n created_at: Time.parse(le[\"created_at\"]),\n incident_id: le[\"incident\"][\"id\"],\n agent_type: le[\"agent\"] && le[\"agent\"][\"type\"],\n agent_id: le[\"agent\"] && le[\"agent\"][\"id\"],\n channel_type: le[\"channel\"] && le[\"channel\"][\"type\"],\n user_id: le[\"user\"] && le[\"user\"][\"id\"],\n notification_type: le[\"channel\"] && le[\"channel\"][\"notification\"] && le[\"channel\"][\"notification\"][\"type\"],\n assigned_user_id: le[\"assigned_user\"] && le[\"assigned_user\"][\"id\"]\n }\n end",
"def data_from_notification_name(notification_name)\n received_messages.find { |item| item['seq'] == nil && item['method'] == notification_name}\n end",
"def filter(event)\r\norderid =event.get(\"orderid\")\r\nproduct = event.get(\"product\")\r\ndescription = event.get(\"description\")\r\nprice = event.get(\"price\")\r\nordertime = event.get(\"ordertime\")\r\norderDetails ={\r\n \"orderid\" => orderid,\r\n \"product\" => product,\r\n \"description\" => description,\r\n \"price\" => price,\r\n \"ordertime\" => ordertime\r\n}\r\nevent.set('orderDetails',orderDetails)\r\nevent.remove('orderid')\r\nevent.remove('product')\r\nevent.remove('description')\r\nevent.remove('price')\r\nevent.remove('ordertime')\r\nreturn [event] \r\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "cleaned", "fired_at": "20090326 22:01:00", "data[list_id]": "a6b5da1054", "data[campaign_id]": "4fjk2ma9xd", "data[reason]": "hard", | def email_cleaned
{
:list_id => data['list_id'],
:fired_at => params['fired_at'],
:campaign_id => data['campaign_id'],
:email => data['email'],
:reason => data['reason'],
:human => "#{data['email']} was cleaned from Mailchimp list with ID #{data['list_id']}. Reason: '#{data['reason']}'"
}
end | [
"def format_campaigns(data)\n Hash[data.map do |item|\n [item[0], Hash[\n 'clicks', item[1],\n 'cost', item[2],\n 'cpc', item[3],\n 'ctr', item[4]\n ]\n ]\n end]\n end",
"def campaign_status\n {\n :list_id => data['list_id'],\n :campaign_id => data['id'],\n :subject => data['subject'],\n :status => data['status'],\n :reason => data['reason'],\n :human => \"Campaign Status (ID: #{data['id']}) - Subject: '#{data['subject']}', Status: '#{data['status']}', Reason: '#{data['reason']}'\"\n }\n end",
"def event_endpoint_parsed_response\n [\n {\n 'created' => 1503597602000,\n 'id' => '242801028',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1508454000000,\n 'updated' => 1503597602000,\n 'utc_offset' => -14400000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 28,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/242801028/',\n 'manual_attendance_count' => 0,\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506360598000,\n 'duration' => 7200000,\n 'id' => '243654482',\n 'name' => 'Come Learn to Code!',\n 'status' => 'upcoming',\n 'time' => 1510875000000,\n 'updated' => 1506360640000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 3,\n 'venue' =>\n {'id' => 24975001,\n 'name' => 'ODU Innovation Center',\n 'lat' => 36.8532600402832,\n 'lon' => -76.29104614257812,\n 'repinned' => false,\n 'address_1' => '501 Boush St',\n 'city' => 'Norfolk',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '23510',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243654482/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361286000,\n 'duration' => 7200000,\n 'id' => '243655170',\n 'name' => 'Come Learn To Code!',\n 'status' => 'upcoming',\n 'time' => 1513899000000,\n 'updated' => 1506361286000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n 'venue' =>\n {'id' => 24628300,\n 'name' => '1701',\n 'lat' => 36.844764709472656,\n 'lon' => -75.97899627685547,\n 'repinned' => false,\n 'address_1' => '1701 Baltic Avenue',\n 'city' => 'Virginia Beach',\n 'country' => 'us',\n 'localized_country_name' => 'USA',\n 'zip' => '',\n 'state' => 'VA'},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655170/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n },\n {\n 'created' => 1506361383000,\n 'duration' => 7200000,\n 'id' => '243655210',\n 'name' => 'Come learn to code!',\n 'status' => 'upcoming',\n 'time' => 1516318200000,\n 'updated' => 1506361383000,\n 'utc_offset' => -18000000,\n 'waitlist_count' => 0,\n 'yes_rsvp_count' => 2,\n # \"venue\"=>\n # {\"id\"=>24975001,\n # \"name\"=>\"ODU Innovation Center\",\n # \"lat\"=>36.8532600402832,\n # \"lon\"=>-76.29104614257812,\n # \"repinned\"=>false,\n # \"address_1\"=>\"501 Boush St\",\n # \"city\"=>\"Norfolk\",\n # \"country\"=>\"us\",\n # \"localized_country_name\"=>\"USA\",\n # \"zip\"=>\"23510\",\n # \"state\"=>\"VA\"},\n 'group' =>\n {'created' => 1483543375000,\n 'name' => 'Operation Code: Hampton Roads',\n 'id' => 21767819,\n 'join_mode' => 'open',\n 'lat' => 36.900001525878906,\n 'lon' => -76.20999908447266,\n 'urlname' => 'Operation-Code-Hampton-Roads',\n 'who' => 'coders',\n 'localized_location' => 'Norfolk, VA',\n 'region' => 'en_US'},\n 'link' => 'https://www.meetup.com/Operation-Code-Hampton-Roads/events/243655210/',\n 'description' =>\n \"<p>Operation Code is an initiative to introduce veterans to the software development community. In this group, we will work together to design a website for aggregating veteran resources.</p> <p>No experience is necessary to join. In fact, we encourage those who want to learn how to code to join us! If you are a developer and would like to provide mentorship, we would greatly appreciate your participation, as well.</p> <p>In this meetup, we will discuss the progress that we've made and the next items on our list to complete. When the team is clear about the objectives, we will break into teams for pair programming and continue to build our website.</p> <p>Feel free to contact Larry Burris if you have any questions.</p> \",\n 'visibility' => 'public'\n }\n ]\nend",
"def customer_mailchimp_email_updated\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :new_mailchimp_id => data['id'],\n :new_email => data['new_email'],\n :old_email => data['old_email'],\n :human => \"#{data['email']} updated their email address on Mailchimp, from '#{data['old_email']}' to '#{data['new_email']}'.\"\n }\n end",
"def customer_mailchimp_unsubscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :campaign_id => data['campaign_id'],\n :human => \"#{data['email']} unsubscribed from Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def victims_responded_line_items\n # campaign.victims.each {|victim| @victims = victim.opened? ? victim : nil}\n\n [[\"UID\", \"Email\", \"Sent\", \"Clicked\", \"Opened\", \"Password\", \"Time\"]] +\n @victims_responded.map do |victim|\n [victim.uid, \n victim.email_address, \n victim.sent.to_s, \n victim.clicked?.to_s, \n victim.opened?.to_s, \n victim.password?.to_s, \n victim.updated_at.to_s ]\n end\n end",
"def check_time_constraints_payload(record, resp_data)\n # We never return time_constraints = null\n assert_equal record.time_constraints.count, resp_data[\"time_constraints\"].count\n for i in 0..record.time_constraints.count-1 do\n #puts record.time_constraints[i].to_json\n #puts resp_data[\"time_constraints\"][i]\n check_payload(resp_data[\"time_constraints\"][i],\n record.time_constraints[i],\n [:key_id, :start_time, :end_time, :start_offset, :end_offset], nil, nil)\n end\n end",
"def extract_event_detail( sql_response )\n details = sql_response.split(';')\n standard_points = details[0].to_f\n time_swam_detail = details[1].split(':')\n time_swam = Timing.new( time_swam_detail[2], time_swam_detail[1], time_swam_detail[0] )\n meeting_id = details[2].to_i\n scheduled_date = Date.parse( details[3] )\n { :standard_points => standard_points, :time_swam => time_swam, :meeting_id => meeting_id, :scheduled_date => scheduled_date }\n end",
"def event_receiver\n data_parsed = JSON.parse(request.raw_post)\n\n data_parsed.each do |info|\n campaign_user = CampaignUser.find_by(id: info['campaign_user_id'])\n campaign_user.update(status: info['event']) if campaign_user\n end\n head :no_content\n end",
"def filter_data(discussion)\n { count: discussion['highest_post_number'],\n posts: discussion['post_stream']['posts'].map do |post|\n { post_number: post['post_number'],\n username: post['username'],\n datetime: post['created_at'],\n text: post['cooked']\n }\n end\n }\n end",
"def day_data\n {\n \"type\" => MapString.new,\n \"accum\" => MapString.new,\n \"prob\" => MapString.new\n }\n end",
"def customer_mailchimp_subscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :ip_signup => params['ip_signup'],\n :human => \"#{data['email']} subscribed to Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def customer_mailchimp_profile_updated\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :human => \"#{data['email']} updated Mailchimp profile information.\"\n }\n end",
"def example_flowsheet\n %(\n {\n \"Meta\": {\n \"DataModel\": \"Flowsheet\",\n \"EventType\": \"New\",\n \"EventDateTime\": \"2020-10-28T15:54:21.139Z\",\n \"Test\": true,\n \"Source\": {\n \"ID\": \"7ce6f387-c33c-417d-8682-81e83628cbd9\",\n \"Name\": \"Redox Dev Tools\"\n },\n \"Destinations\": [\n {\n \"ID\": \"af394f14-b34a-464f-8d24-895f370af4c9\",\n \"Name\": \"Redox EMR\"\n }\n ],\n \"Message\": {\n \"ID\": 5565\n },\n \"Transmission\": {\n \"ID\": 12414\n },\n \"FacilityCode\": null\n },\n \"Patient\": {\n \"Identifiers\": [\n {\n \"ID\": \"0000000001\",\n \"IDType\": \"MR\"\n },\n {\n \"ID\": \"e167267c-16c9-4fe3-96ae-9cff5703e90a\",\n \"IDType\": \"EHRID\"\n },\n {\n \"ID\": \"a1d4ee8aba494ca\",\n \"IDType\": \"NIST\"\n }\n ],\n \"Demographics\": {\n \"FirstName\": \"Timothy\",\n \"MiddleName\": \"Paul\",\n \"LastName\": \"Bixby\",\n \"DOB\": \"2008-01-06\",\n \"SSN\": \"101-01-0001\",\n \"Sex\": \"Male\",\n \"Race\": \"White\",\n \"IsHispanic\": null,\n \"MaritalStatus\": \"Married\",\n \"IsDeceased\": null,\n \"DeathDateTime\": null,\n \"PhoneNumber\": {\n \"Home\": \"+18088675301\",\n \"Office\": null,\n \"Mobile\": null\n },\n \"EmailAddresses\": [],\n \"Language\": \"en\",\n \"Citizenship\": [],\n \"Address\": {\n \"StreetAddress\": \"4762 Hickory Street\",\n \"City\": \"Monroe\",\n \"State\": \"WI\",\n \"ZIP\": \"53566\",\n \"County\": \"Green\",\n \"Country\": \"US\"\n }\n },\n \"Notes\": [],\n \"Contacts\": [\n {\n \"FirstName\": \"Barbara\",\n \"MiddleName\": null,\n \"LastName\": \"Bixby\",\n \"Address\": {\n \"StreetAddress\": \"4762 Hickory Street\",\n \"City\": \"Monroe\",\n \"State\": \"WI\",\n \"ZIP\": \"53566\",\n \"County\": \"Green\",\n \"Country\": \"US\"\n },\n \"PhoneNumber\": {\n \"Home\": \"+18088675303\",\n \"Office\": \"+17077543758\",\n \"Mobile\": \"+19189368865\"\n },\n \"RelationToPatient\": \"Mother\",\n \"EmailAddresses\": [\n \"barb.bixby@test.net\"\n ],\n \"Roles\": [\n \"Emergency Contact\"\n ]\n }\n ]\n },\n \"Visit\": {\n \"VisitNumber\": \"1234\",\n \"AccountNumber\": null,\n \"VisitDateTime\": null,\n \"Location\": {\n \"Type\": null,\n \"Facility\": null,\n \"Department\": null,\n \"Room\": null,\n \"Bed\": null\n }\n },\n \"Observations\": [\n {\n \"DateTime\": \"2015-08-13T21:08:57.581Z\",\n \"Value\": \"110.00\",\n \"ValueType\": \"Numeric\",\n \"Units\": \"mmHg\",\n \"Code\": \"Systolic\",\n \"Codeset\": \"RedoxEMR\",\n \"Description\": null,\n \"Status\": null,\n \"Notes\": [\n \"Observation note.\"\n ],\n \"Observer\": {\n \"ID\": \"12312\",\n \"IDType\": null,\n \"FirstName\": \"Jimmy\",\n \"LastName\": \"JimJam\"\n },\n \"ReferenceRange\": {\n \"Low\": null,\n \"High\": null,\n \"Text\": null\n },\n \"AbnormalFlag\": null\n },\n {\n \"DateTime\": \"2015-08-13T21:08:57.581Z\",\n \"Value\": \"90.00\",\n \"ValueType\": \"Numeric\",\n \"Units\": \"mmHg\",\n \"Code\": \"Diastolic\",\n \"Codeset\": \"RedoxEMR\",\n \"Description\": null,\n \"Status\": null,\n \"Notes\": [],\n \"Observer\": {\n \"ID\": \"12312\",\n \"IDType\": null,\n \"FirstName\": \"Jimmy\",\n \"LastName\": \"JimJam\"\n },\n \"ReferenceRange\": {\n \"Low\": null,\n \"High\": null,\n \"Text\": null\n },\n \"AbnormalFlag\": null\n },\n {\n \"DateTime\": \"2015-08-13T21:08:57.581Z\",\n \"Value\": \"55\",\n \"ValueType\": \"Numeric\",\n \"Units\": \"beats/min\",\n \"Code\": \"Diastolic\",\n \"Codeset\": \"RedoxEMR\",\n \"Description\": null,\n \"Status\": null,\n \"Notes\": [],\n \"Observer\": {\n \"ID\": \"12312\",\n \"IDType\": null,\n \"FirstName\": \"Jimmy\",\n \"LastName\": \"JimJam\"\n },\n \"ReferenceRange\": {\n \"Low\": null,\n \"High\": null,\n \"Text\": null\n },\n \"AbnormalFlag\": null\n }\n ]\n }\n )\nend",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def filter_messages(json, start_date, end_date)\n return json if start_date.nil? && end_date.nil?\n to_ret = Array.new\n json.each do | message |\n message_date = Date.strptime(message[\"created_at\"].to_s, '%s')\n if message_date >= start_date && message_date <= end_date\n to_ret << message\n end\n end\n return to_ret\nend",
"def request_data(code)\n request_data = {\n \"request\" => {\n \"passengers\" => {\n \"adultCount\" => \"1\"\n },\n \"slice\" => [\n {\n \"origin\" => \"OMA\",\n \"destination\" => code,\n \"date\" => (Date.today + 1).to_s\n }\n ],\n \"solutions\" => \"1\"\n }\n }\nend",
"def build_attachments(webhook)\n #puts \"BUILD_ATTACHMENTS webhook #{webhook}\"\n state = webhook['details']['state']\n state_color = case state\n when 'CRITICAL'; 'danger'\n when 'WARNING'; 'warning'\n when 'OK'; 'good'\n end\n target = webhook['details']['target']\n timestamp = Time.at(webhook['details']['timestamp'].to_i/1000).to_s\n entity_label = webhook['entity']['label']\n entity_ip_address =\n if (webhook['entity']['ip_addresses'].nil?)\n entity_ip_address=\"not available\"\n else\n entity_ip_address = webhook['entity']['ip_addresses']['default']\n end\n check_label = webhook['check']['label']\n #check_details = webhook['check']['details'].to_yaml\n alarm_label = webhook['alarm']['label']\n \n [\n {\n \"fallback\" => \"Your browser does not support full display of the Rackspace alarm.\",\n \n \"color\" => state_color,\n \n #\"pretext\" => \"Optional text that appears above the attachment block\",\n \n #\"author_name\" => \"Bobby Tables\",\n #\"author_link\" => \"http://flickr.com/bobby/\",\n #\"author_icon\" => \"http://flickr.com/icons/bobby.jpg\",\n \n \"title\" => state,\n #\"title_link\" => \"https://api.slack.com/\",\n \n #\"text\" => JSON.pretty_generate(webhook) #\"Optional text that appears within the attachment\",\n \n \"fields\" => [\n {\n \"title\" => \"Target\",\n \"value\" => target,\n \"short\" => true\n },\n {\n \"title\" => \"Timestamp\",\n \"value\" => timestamp,\n \"short\" => true\n },\n {\n \"title\" => \"Entity\",\n \"value\" => entity_label,\n \"short\" => true\n },\n {\n \"title\" => \"IP\",\n \"value\" => entity_ip_address,\n \"short\" => true\n },\n {\n \"title\" => \"Check\",\n \"value\" => check_label,\n \"short\" => true\n },\n {\n \"title\" => \"Alarm\",\n \"value\" => alarm_label,\n \"short\" => true\n }\n ],\n \n #\"image_url\" => \"http://my-website.com/path/to/image.jpg\",\n #\"thumb_url\" => \"http://example.com/path/to/thumb.png\"\n }\n ]\n end",
"def element_to_result(e)\n result = Hash.new\n result['date'] = e.updated_at.strftime(\"%d-%m-%Y %H:%M\")\n result['user'] = e.user.email\n result['interaction'] = e.interaction.resource_type\n result\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
"type": "campaign", "fired_at": "20090326 21:31:21", "data[id]": "5aa2102003", "data[subject]": "Test Campaign Subject", "data[status]": "sent", "data[reason]": "", "data[list_id]": "a6b5da1054" | def campaign_status
{
:list_id => data['list_id'],
:campaign_id => data['id'],
:subject => data['subject'],
:status => data['status'],
:reason => data['reason'],
:human => "Campaign Status (ID: #{data['id']}) - Subject: '#{data['subject']}', Status: '#{data['status']}', Reason: '#{data['reason']}'"
}
end | [
"def format_campaigns(data)\n Hash[data.map do |item|\n [item[0], Hash[\n 'clicks', item[1],\n 'cost', item[2],\n 'cpc', item[3],\n 'ctr', item[4]\n ]\n ]\n end]\n end",
"def sent_campaign_list_simple(options = { start: 0, limit: 100 })\n list = sent_campaign_list(options)\n list.map do |item|\n {\n subject: item[:settings][:subject_line],\n title: item[:settings][:title],\n sent_on: item[:send_time].to_datetime,\n archive_url: item[:archive_url]\n }\n end\n end",
"def email_cleaned\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :campaign_id => data['campaign_id'],\n :email => data['email'],\n :reason => data['reason'],\n :human => \"#{data['email']} was cleaned from Mailchimp list with ID #{data['list_id']}. Reason: '#{data['reason']}'\"\n }\n end",
"def customer_mailchimp_subscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :ip_signup => params['ip_signup'],\n :human => \"#{data['email']} subscribed to Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def campaigns\n response = get 'campaigns'\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def campaign(id)\n make_json_api_request :get, \"v2/#{account_id}/campaigns/#{id}\"\n end",
"def add_campaign(payload)\n post(url_(\"campaign\"), payload)\n end",
"def get_campaigns\n get('/fcb30500-7b98-476f-810d-463a0b8fc3df')\n end",
"def sent_campaign_list(options = { start: 0, limit: 100 })\n list_params = { sort_field: 'send_time', sort_dir: 'DESC', list_id: mc_id }\n list_params[:offset] = options[:start] ? options[:start] : 0\n list_params[:count] = options[:limit] ? options[:limit] : 100\n list_params[:folder_id] = options[:folder_id] if options[:folder_id]\n\n results = api.campaigns.retrieve(params: list_params)\n results.body[:campaigns]\n rescue Gibbon::MailChimpError => e\n Rails.logger.info \"=== Error sent_campaign_list for list #{mc_id} : #{e.message}\"\n\n []\n end",
"def find_campaign_by_web_id(campaign_web_id)\n campaigns['data'].find {|c| c[\"web_id\"] == campaign_web_id}\n end",
"def customer_mailchimp_email_updated\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :new_mailchimp_id => data['id'],\n :new_email => data['new_email'],\n :old_email => data['old_email'],\n :human => \"#{data['email']} updated their email address on Mailchimp, from '#{data['old_email']}' to '#{data['new_email']}'.\"\n }\n end",
"def add_ids_to_campaignmember(obj,instance_url,access_token)\n json_payload = nil\n campaign_id = obj[\"event\"][\"id\"]\n contact_email = obj[\"profile\"][\"email\"]\n contact_fn = escape_characters(obj[\"profile\"][\"first_name\"])\n contact_ln = escape_characters(obj[\"profile\"][\"last_name\"])\n contact_email = obj[\"order\"][\"email\"] if contact_email.nil?\n contact_email = escape_characters(contact_email)\n checked_in = nil\n checked_in = \"Responded\" if obj[\"checked_in\"]\n campaign_search_string =\n url_encode(\n \"FIND {#{campaign_id}}\" \\\n \" IN ALL FIELDS\" \\\n \" RETURNING Campaign(Id)\")\n contact_search_string =\n url_encode(\n \"FIND {#{contact_fn}\" \\\n \" AND #{contact_ln}\" \\\n \" AND #{contact_email}}\" \\\n \" IN ALL FIELDS\" \\\n \" RETURNING Contact(Id)\")\n campaign_base_uri = \"#{instance_url}/services/data/v29.0/search/?q=#{campaign_search_string}\"\n begin\n campaign_query_response = rest_call(\"get\",campaign_base_uri,json_payload,access_token)\n @json_campaign = JSON.parse(campaign_query_response)[0]\n end until !@json_campaign.nil?\n contact_base_uri = \"#{instance_url}/services/data/v29.0/search/?q=#{contact_search_string}\"\n contact_query_response = rest_call(\"get\",contact_base_uri,json_payload,access_token)\n json_contact = JSON.parse(contact_query_response)[0]\n unless json_contact.nil?\n obj.store(\"ContactId\",json_contact[\"Id\"])\n obj.store(\"CampaignId\",@json_campaign[\"Id\"])\n obj.store(\"Status\",checked_in) unless checked_in.nil?\n else\n obj = nil\n end\n return obj\n end",
"def customer_mailchimp_unsubscribed\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :campaign_id => data['campaign_id'],\n :human => \"#{data['email']} unsubscribed from Mailchimp list with ID #{data['list_id']}\"\n }\n end",
"def send_schedule_event(api_url, api_key, schedule_id, event_id)\n on_call_response = Curl.get(\"#{api_url}/schedules/#{schedule_id}/on-calls?flat=true\") do |http|\n http.headers['Authorization'] = \"GenieKey #{api_key}\"\n end\n\n on_call_recipients = JSON.parse(on_call_response.body)['data']['onCallRecipients']\n\n if on_call_recipients.length == 0\n send_event(\"#{event_id}\", items: [{'value': 'N/A'}])\n else\n on_call_items = []\n on_call_recipients.each do |person|\n # Remove the @mintel.com from the alias\n person_name = person.split('@')[0]\n item_entry = {'label': '', 'value': person_name}\n on_call_items.push(item_entry)\n end\n send_event(\"#{event_id}\", items: on_call_items)\n end\nend",
"def collect_data(emails_json)\n emails = []\n recipients = {}\n emails_json.each do |email_json|\n subject = process_subject(email_json['subject'])\n emails.push(Email.new(timestamp: email_json['timestamp'], subject: subject))\n email_json['recipients'].uniq.each do |recipient_email|\n if !recipients.key?(recipient_email)\n recipients[recipient_email] = Recipient.find_or_initialize_by(email: recipient_email)\n end\n recipients[recipient_email].counter_unique_subject_words += subject.uniq.size \n emails.last.recipients << recipients[recipient_email]\n end\n end\n [emails, recipients]\n end",
"def get_delivered_campaign()\n\t\t\t\tif !@result.nil?\n\t\t\t\t\tif @result.has_key?(:messagesdelivered)\n\t\t\t\t\t\tif @result[:messagesdelivered].length > 0\n\t\t\t\t\t\t\tcampaigns = Array.new\n\t\t\t\t\t\t\t@result[:messagesdelivered].each do |item|\n\t\t\t\t\t\t\t\titem[:threatsinfomap].each do |elem|\n\t\t\t\t\t\t\t\t\tcampaigns.push(elem[:campaignid]) unless elem[:campaignid].nil?\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tcampaigns.compact!\n\t\t\t\t\t\t\tcampaigns.uniq!\n\t\t\t\t\t\t\treturn campaigns if campaigns.length > 0\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def get_campaign_info(id)\n return handle_error('Empty campaign id') unless id.to_i > 0\n send_request(\"campaigns/#{id}\")\n end",
"def campaign_dictionary(project)\n campaigns = project.campaigns.map do |c|\n {\n campaign_hash: c.campaign_hash,\n cookie_lifetime: c.cookie_lifetime,\n parameter_name: c.parameter_name,\n parameter_value: c.parameter_value\n }\n end\n end",
"def data\n @data ||= if payload.is_a?(Hash)\n if claim && payload.key?('data')\n payload['data']\n else\n payload.except(*CLAIM_KEYS.map(&:to_s))\n end\n else\n payload\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns whether the commit that triggered this hook is the first commit on the branch. | def initial_commit?
return @initial_commit unless @initial_commit.nil?
@initial_commit = !Overcommit::Utils.execute(%w[git rev-parse HEAD~]).success?
end | [
"def default_branch?\n event['ref'] == \"refs/heads/#{event['repository']['default_branch']}\"\n end",
"def latest_commit?\n local = `cd #{@directory} && git log --pretty=%H -n 1`.chomp\n if `cd #{@directory} && git status`.chomp.match(/On branch (.*)\\n/)\n branch = $1\n else\n raise Error, \"Unable to determine the local repository branch.\"\n end\n remote = `cd #{@directory} && git ls-remote 2> /dev/null | grep refs/heads/#{branch} `.chomp.split(/\\s+/).first\n if local.length == 40 && remote.length == 40\n local == remote\n else\n raise Error, \"Unable to determine local & remote commits\"\n end\n end",
"def first_commit\n self.repo.git.rev_list({:reverse => true}, \"master\").split(\"\\n\").first\n end",
"def has_local_commits?\n @cli.status?(0, \"git rev-list --quiet master\")\n end",
"def branch_checkout?\n @args[2].to_i == 1\n end",
"def getNewestCommit\n if @commits.size > 0\n return @commits.last[0]\n end\n return false\n end",
"def detached_head?\n rebased_branch.empty?\n end",
"def nothing_to_commit?\n @git.status do |file, status|\n return false unless status.empty?\n end\n return true\n end",
"def one?\n when_branches.one?\n end",
"def can_commit?()\n return @branch_keys.get( Indices::COMMIT_IDENTIFIER ).eql?( @master_keys.get( Indices::COMMIT_IDENTIFIER ) )\n end",
"def commit_in_valid_branch?\n # If two refs are entirely different commit histories, the API responds\n # with a 404. Rescue Octokit::NotFound in this case.\n begin\n default_compare = @client.compare @repo[:full_name],\n @repo[:default_branch], @commit[:sha]\n rescue Octokit::NotFound\n default_compare = nil\n end\n\n # The compare status should be \"identical\" or \"behind\" if the commit is in\n # the default branch\n if default_compare.nil? ||\n !(%w(identical behind).include?(default_compare[:status]))\n\n # If the commit is not in the default branch, check the gh-pages branch\n begin\n gh_pages_compare = @client.compare @repo[:full_name], \"gh-pages\",\n @commit[:sha]\n rescue Octokit::NotFound\n gh_pages_compare = nil\n end\n return false if !gh_pages_compare\n return false if !%w(identical behind).include? gh_pages_compare [:status]\n end\n\n true\n end",
"def merge_commit?\n !squash?\n end",
"def merge_commit?(commit)\n commit.message.match(/^Merge branch/)\nend",
"def mastered?\n !!committees.find { |committee| committee.name == goal }\n end",
"def existe_commit? (commit_hash)\n `git --git-dir='#{@path_to_repo}' rev-list #{commit_hash} 2>&1`; existe=$?.success?\n existe\n end",
"def first_revision?\n self.revision_number == 1\n end",
"def fast_forward?\n rebased_commits.empty?\n end",
"def has_remote_commits?\n @cli.run \"git fetch origin\"\n @cli.status?(0, \"git rev-list --quiet origin/master\")\n end",
"def building?\n !!commits.detect {|commit| commit.building? }\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to create an array of event times. Will use this to create array of start_at times and endat times | def make_event_times_array(dates_array, hour, min)
event_times = Array.new
dates_array.each_index do |index|
event_times[index] = create_event_time(dates_array[index],hour, min)
end
return event_times
end | [
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def get_times_array\n return @events.collect {|element| element.event.time }\n end",
"def get_times\n work_time = [@starts.h, @ends.round_up]\n meeting_times = []\n @meetings.each do |meeting|\n meeting_time = Array.new(2)\n meeting_time[0] = hour_offset(@starts.h, meeting.starts.h) + \n minute_offset(meeting.starts.m)\n meeting_time[1] = hour_offset(@starts.h, meeting.ends.h) + \n minute_offset(meeting.ends.m)\n meeting_times << meeting_time\n end if @meetings\n \n times = [work_time, meeting_times]\n end",
"def get_times_array(padding = true)\n times = (padding) ? [start_dt - 1.hour] : [start_dt]\n\n # and including every 1/2 hour until one hour after the selected end time\n loop do\n tmp = times.last + 30.minutes\n (padding) ? (tmp == (end_dt + 1.hour)) ? break : '' : (tmp == end_dt) ? break : ''\n times.push(tmp)\n end\n return times\n end",
"def selectable_times\n midnight = Time.zone.now.at_beginning_of_day\n time_start = midnight.since(start_time)\n time_end = midnight.since(end_time)\n increments = [time_start].tap { |array| array << array.last + 15.minutes while array.last < time_end }\n end",
"def time_array\n return [self.hour, self.min, self.sec]\n end",
"def get_start_times\n times = []\n self.start_time.split('%').each do |t|\n times.push(DateTime.strptime(t, '%m-%d-%Y %H:%M'))\n end\n times\n end",
"def get_runtime_timestamps\n all_events = events.to_a\n start_time = DateTime.parse(all_events.first['timestamp'])\n completion_time = DateTime.parse(all_events.last['timestamp'])\n [start_time, completion_time]\n end",
"def exc_times\n\t\tstart_dt = self.start_datetime\n\t\tend_dt = DateTime.now()\n\t\texc_time = (end_dt.to_i - start_dt.to_i) / 3600 # get time of execution in hours\n\t\t# return as array\n\t\t[end_dt, exc_time]\n\tend",
"def times_array(padding = true)\n @times_array ||= get_times_array(padding)\n end",
"def array_time_helper(st, et)\n st_min = st%60\n st_hour = st/60\n et_min = et%60\n et_hour = et/60\n day = st_hour/24\n d = int_to_day(day)\n return [[d],st_hour%24*100+st_min, et_hour%24*100+et_min]\n \n end",
"def create_event_array(start_at_array, end_at_array, event_name, activity_id)\n\t\tevents_array = Array.new\n\n\t\tstart_at_array.each_index do |index|\n\t\t\tevent_hash = Hash.new\n\n\t\t\tevent_hash[:start_at] = start_at_array[index]\n\t\t\tevent_hash[:end_at] = end_at_array[index]\n\t\t\tevent_hash[:name] = event_name\n\t\t\tevent_hash[:activity_id] = activity_id\n\n\t\t\tevents_array[index]= event_hash\n\t\tend\n\n\t\treturn events_array\n\tend",
"def recalc_times(starting_at=0, list=@events)\n t = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n list[starting_at .. -1].each do |e|\n t += e.delta_time\n e.time_from_start = t\n end\n end",
"def generate_time\n\t\tret = Array.new\n\t\tcount unless @fileinfo[:count]\n\t\ttrigger unless @fileinfo[:trigger]\n\t\tsampling unless @fileinfo[:sampling]\n\n\t\t(0..@fileinfo[:count] - @fileinfo[:trigger] - 1).each {|i| \n\t\t\tret << (i * @fileinfo[:sampling] * 1e-6)\n\t\t}\n\t\treturn ret\n\tend",
"def output_events\n @events.map do |event|\n adjusted_event = event.clone\n adjusted_event.at += @start_time\n adjusted_event\n end\n end",
"def times\n @stamps\n end",
"def datetime_ranges\n return [] if days.empty? || time_range[:start] == 0\n ranges = []\n days.each do |day|\n ranges << (day.to_time + time_range[:start]..\n day.to_time + time_range[:end])\n end\n ranges\n end",
"def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end",
"def start_times\n relevant_events_scope.\n interval_starts.\n unscope(:order).\n order(:video_time).\n pluck(:video_time)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to combine :start_at and :end_at to make hash for each event and put them in an array. | def create_event_array(start_at_array, end_at_array, event_name, activity_id)
events_array = Array.new
start_at_array.each_index do |index|
event_hash = Hash.new
event_hash[:start_at] = start_at_array[index]
event_hash[:end_at] = end_at_array[index]
event_hash[:name] = event_name
event_hash[:activity_id] = activity_id
events_array[index]= event_hash
end
return events_array
end | [
"def output_events\n @events.map do |event|\n adjusted_event = event.clone\n adjusted_event.at += @start_time\n adjusted_event\n end\n end",
"def getevents\n start_time = Time.at(params[:start].to_i)\n end_time = Time.at(params[:end].to_i)\n events = []\n TimeBlock.where(:starttime => (start_time...end_time)).each do |t|\n e = t.event\n events << {:id => e.id, :description => e.description, :title => e.title, :allDay => false, :start => t.starttime, :end => t.endtime, :resource => e.id.to_s}\n end\n render :json => events\n\n end",
"def events_in start_date, end_date=nil\n if end_date.nil? && !start_date.is_a?(Timespan)\n timespan = Timespan.day_end start_date\n end\n if start_date.is_a? Timespan\n timespan = start_date\n end\n if start_date && end_date\n timespan = Timespan.new start_date, end_date\n end\n\n events_in_time = @calendars.map.with_index do |calendar, idx|\n # Collect Kalindar::Events in that time\n events = calendar.events.map do |event|\n occurrences_in(event, timespan).map {|e| Kalindar::Event.new e }\n end.flatten\n\n # Set modification and calendar field.\n is_first = idx == 0\n events.each do |e|\n e.modifiable = is_first\n e.calendar = calendar\n end\n events\n end.flatten\n\n # Collect occurences by date.\n unfold_dates events_in_time, timespan\n end",
"def background_events\n @events = Array.new\n colors_hash = { \"9:00\" => \"#D5B8EE\", \"11:30\" => \"FFFFFF\", \"14:00\" => \"#E5E7B6\" }\n params[:start] = Date.parse(params[:start])\n params[:end] = Date.parse(params[:end])\n (params[:start]..params[:end]).each do |date|\n colors_hash.each do |time, event_color|\n start_date = \"#{date} #{time}\".to_datetime\n end_date = start_date + 2.hours + 30.minutes\n @events << { start: start_date, end: end_date, rendering: 'background', color: event_color}\n end\n end\n respond_to do |format|\n format.json{ render json: @events.as_json}\n end\n end",
"def set_events_array\n @events_array = []\n @timesheets.each do |timesheet|\n @events_array << { title: \"Timesheet ##{timesheet.id}\",\n start: timesheet.payroll.start_date.strftime('%Y, %m, %d'),\n end: (timesheet.payroll.end_date + 1).strftime('%Y, %m, %d'),\n allDay: true }\n end\n end",
"def map_events\n mapped_timeline = Timeline.new\n self.each do |time,events|\n mapped_timeline[time] = events.map{|event| yield event }\n end\n mapped_timeline\n end",
"def make_event_times_array(dates_array, hour, min)\n\t\tevent_times = Array.new\n\n\t\tdates_array.each_index do |index|\n\t\t\n\t\t\tevent_times[index] = create_event_time(dates_array[index],hour, min)\n\t\tend\n\n\t\treturn event_times\n\tend",
"def all_events\n calendar = Icalendar::Calendar.parse(CalendarLoader.body).first\n calendar.events.flat_map do |event|\n Time.zone = 'London'\n event.dtstart = event.dtstart.in_time_zone\n event.dtend = event.dtend.in_time_zone\n\n # I really hope there never needs to be an event more than 100 years into\n # the future\n event.occurrences_between(Date.today - 100.years, Date.today + 100.years).map do |occurrence|\n event_occurrence = event.clone\n event_occurrence.dtstart = occurrence.start_time\n event_occurrence.dtend = occurrence.end_time\n event_occurrence\n end\n end\nend",
"def events_between(date_start, date_end, start = event_start)\n\n events = []\n current_date = date_start\n\n while current_date <= date_end\n current_date = next_event_after(current_date, start)\n if current_date <= date_end\n event = {start_date: current_date, end_date: current_date + duration}\n yield(event) if block_given?\n events << event\n end\n # add one day so it doesn't return the same day\n # probably shouldn't need to do this\n current_date += 1\n end\n\n events\n end",
"def calc_event_rows\n @events_start = [{},{},{},{},{},{},{}]\n @events_end = [{},{},{},{},{},{},{}]\n @event_span = [{},{},{},{},{},{},{}]\n (0..(num_days-1)).each do |day|\n if !events[day].nil?\n events[day].each do |event|\n if !event.all_day\n if event.start_time < (date + day.days)\n start_row = 0\n else\n start_row = (event.start_time.seconds_since_midnight / (60*30)).to_i\n end\n if @events_start[day].member?(start_row)\n @events_start[day][start_row] << event\n else\n @events_start[day][start_row] = [event]\n end\n if event.end_time >= (date + (day+1).days)\n end_row = NUM_HALF_HOURS-1\n else\n end_row = ((event.end_time.seconds_since_midnight-1) / (60*30)).to_i\n end\n if @events_end[day].member?(end_row)\n @events_end[day][end_row] << event\n else\n @events_end[day][end_row] = [event]\n end\n @event_span[day][event] = end_row - start_row + 1\n end\n end\n end\n end\n end",
"def unfold_dates events, timespan\n events.inject({}) do |hash, event|\n (event.dtstart.to_date .. event.dtend.to_date).each do |day|\n if timespan.spans?(day) && !(event.dtstart != event.dtend && event.dtend.class == Date && event.dtend == day)\n (hash[day] ||= []) << event\n end\n end\n hash\n end\n end",
"def split(range = nil)\n if self.record_category and self.activity?\n entry_end = self.end_timestamp || Time.now\n time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp\n end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end\n list = Array.new\n while time < end_time\n new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min\n list << [time, new_end, self]\n time = new_end\n end\n else\n return [self.timestamp, nil, self]\n end\n list\n end",
"def date_regions\n times = eventdates.collect{|dt| [dt.startdate, dt.enddate]}.flatten().uniq().sort();\n dates = eventdates().sort_by{|k| k.startdate};\n\n contents = [];\n working_set = [];\n headers = [];\n\n times.each do |time|\n working_set.reject! {|date| !((date.startdate <= time) && (date.enddate > time))};\n\n while(!dates.empty? && (dates.first.startdate <= time) && (dates.first.enddate > time))\n working_set << dates.shift();\n end\n \n if(!working_set.empty?)\n headers << time;\n contents << Array.new(working_set);\n end\n end\n\n return headers, contents;\n end",
"def map_events!\n each do |time,events|\n self[time] = events.map{|event| yield event }\n end\n end",
"def get_locations\n data = parse_url\n locations = Array.new\n \n data[\"event\"].each do |item|\n location = Hash.new\n location[\"name\"] = \"#{item['name']}: #{item['start_date']} (#{item['start_time']}) - #{item['end_date']} (#{item['end_time']})\"\n location[\"lat\"] = item[\"latitude\"]\n location[\"long\"] = item[\"longitude\"]\n \n locations.push(location)\n end\n \n return locations\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def event_instances_by_date\n hash = {}\n EventInstance.where(schedule_id: id).each do |ei|\n hash[ei.start_date.to_i] = ei\n end\n hash\n end",
"def composite_dates\n if params[:event]\n if params[:event][:start_date].present?\n # We adjust the given datetimes so that they are considered to happen in the given zone, if there is one. \n # If none is given, everything happen within the configured time zone for the application.\n date = Time.zone.parse(params[:event][:start_date])\n timezone = ActiveSupport::TimeZone.new(params[:event][:timezone]) if params[:event][:timezone].present?\n timezone ||= Time.zone\n \n # This is done without changing the apparent time: it is already correct with the given zone and no translation is required.\n date = date.change(offset: timezone) if timezone\n if params[:event][:start_time].present?\n start_time = Tod::TimeOfDay.parse(params[:event][:start_time])\n params[:event][:start] = start_time.on(date, timezone)\n end\n if params[:event][:finish_time].present?\n finish_time = Tod::TimeOfDay.parse(params[:event][:finish_time])\n params[:event][:finish] = finish_time.on(date, timezone)\n end\n end\n end\n end",
"def events(range_begin = nil, range_end = nil, time_filters_in_secs = [])\n #\n # If range_begin is nil, use from_time attribute from the model.\n #\n range_begin = range_begin || self.from_time\n range_begin = Event.convert_to_datetime(range_begin).beginning_of_day.to_i\n\n #\n # If range_end is nil, use recurrence_end attribute from the model.\n # note: range_end may still be nil if no recurrence_end is specified\n # note: range_end is exclusive. substract with DAY_IN_SECONDS to\n # become inclusive (see arshaw fullcalendar docs)\n #\n range_end = Event.convert_to_datetime(range_end).end_of_day.to_i - DAY_IN_SECONDS if range_end\n range_end = [range_end, self.recurrence_end.try(:end_of_day).try(:to_i)].compact.min\n\n arr = []\n self.fetch_events_time(range_begin, range_end).each do |e|\n event_from_time_in_secs = e +\n (self.from_time.hour * HOUR_IN_SECONDS) +\n (self.from_time.min * MINUTE_IN_SECONDS)\n event_thru_time_in_secs = event_from_time_in_secs + self.duration\n\n unless time_filters_in_secs.include? event_from_time_in_secs\n arr << Event.new(self, event_from_time_in_secs, event_thru_time_in_secs)\n end\n end\n\n arr\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /microposts POST /microposts.json | def create
@micropost = current_user.microposts.build(micropost_params)
respond_to do |format|
if @micropost.save
format.html { redirect_to root_url(:anchor => "ideas"), notice: 'Micropost was successfully created.' }
format.json { render :show, status: :created, location: @micropost }
else
format.html { render :new }
format.json { render json: @micropost.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @micropost = Micropost.new(micropost_params)\n\n if @micropost.save\n render json: @micropost\n else\n render json: @micropost.errors, status: :unprocessable_entity\n end\n end",
"def create\n @micropost = current_user.microposts.new(micropost_params)\n\n if @micropost.save\n render :show, status: :created, location: @micropost\n else\n render json: @micropost.errors, status: :unprocessable_entity\n end\n end",
"def create\n @micropost = current_user.microposts.new(micropost_params)\n respond_to do |format|\n if @micropost.save\n format.html do\n redirect_to @micropost, notice: t('created', name: 'Micropost')\n end\n format.json { render :show, status: :created, location: @micropost }\n else\n format.html { render :new }\n format.json do\n render json: @micropost.errors,\n status: :unprocessable_entity\n end\n end\n end\n end",
"def list\n render json: User.find(params[:id]).microposts\n end",
"def index\n @microposts = Micropost.all\n render json: @microposts\n end",
"def create\n @title = 'Microposts'\n @new_post = current_user.microposts.build(params[:micropost])\n if @new_post.save\n @user = User.find(current_user.id)\n feed = @user.feed\n @microposts = feed.page(params[:current_page]).per(5)\n end\n respond_to do |format|\n format.html { redirect_to '/wall' }\n format.js\n end\n end",
"def create\n @micrropost = Micrropost.new(params[:micrropost])\n\n respond_to do |format|\n if @micrropost.save\n format.html { redirect_to @micrropost, notice: 'Micrropost was successfully created.' }\n format.json { render json: @micrropost, status: :created, location: @micrropost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micrropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micropostt = Micropostt.new(micropostt_params)\n\n respond_to do |format|\n if @micropostt.save\n format.html { redirect_to @micropostt, notice: 'Micropostt was successfully created.' }\n format.json { render :show, status: :created, location: @micropostt }\n else\n format.html { render :new }\n format.json { render json: @micropostt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micopost = Micopost.new(micopost_params)\n\n respond_to do |format|\n if @micopost.save\n format.html { redirect_to @micopost, notice: 'Micopost was successfully created.' }\n format.json { render :show, status: :created, location: @micopost }\n else\n format.html { render :new }\n format.json { render json: @micopost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rails_tutorial_toy_micropost = RailsTutorial::Toy::Micropost.new(rails_tutorial_toy_micropost_params)\n\n respond_to do |format|\n if @rails_tutorial_toy_micropost.save\n format.html { redirect_to @rails_tutorial_toy_micropost, notice: 'Micropost was successfully created.' }\n format.json { render :show, status: :created, location: @rails_tutorial_toy_micropost }\n else\n format.html { render :new }\n format.json { render json: @rails_tutorial_toy_micropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micsropost = Micsropost.new(params[:micsropost])\n\n respond_to do |format|\n if @micsropost.save\n format.html { redirect_to @micsropost, notice: 'Micsropost was successfully created.' }\n format.json { render json: @micsropost, status: :created, location: @micsropost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micsropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @micropost = Micropost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @micropost }\n end\n end",
"def create\n @microposttest = Microposttest.new(microposttest_params)\n\n respond_to do |format|\n if @microposttest.save\n format.html { redirect_to @microposttest, notice: 'Microposttest was successfully created.' }\n format.json { render :show, status: :created, location: @microposttest }\n else\n format.html { render :new }\n format.json { render json: @microposttest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_micropost = Admin::Micropost.new(admin_micropost_params)\n\n respond_to do |format|\n if @admin_micropost.save\n format.html { redirect_to @admin_micropost, notice: 'Micropost was successfully created.' }\n format.json { render :show, status: :created, location: @admin_micropost }\n else\n format.html { render :new }\n format.json { render json: @admin_micropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @new_micropost = NewMicropost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_micropost }\n end\n end",
"def new\n @micrropost = Micrropost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @micrropost }\n end\n end",
"def create\n @micoropost = Micoropost.new(params[:micoropost])\n\n respond_to do |format|\n if @micoropost.save\n format.html { redirect_to @micoropost, notice: 'Micoropost was successfully created.' }\n format.json { render json: @micoropost, status: :created, location: @micoropost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micoropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micoropost = Micoropost.new(micoropost_params)\n\n respond_to do |format|\n if @micoropost.save\n format.html { redirect_to @micoropost, notice: 'Micoropost was successfully created.' }\n format.json { render :show, status: :created, location: @micoropost }\n else\n format.html { render :new }\n format.json { render json: @micoropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @micropostts = Micropostt.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the lesson at which a student left off | def update_left_off(lesson_id)
update_attribute(:left_off, lesson_id)
end | [
"def use_advance_on_unchanged_progress\n previous_student = dup\n previous_student.assign_attributes(lesson: lesson_was, lesson_part: lesson_part_was)\n previous_student.advance.attributes.slice('lesson', 'lesson_part')\n end",
"def kick_out\n @students = students.shift\n end",
"def check_after_update\n if student.blank? || student.school != user.school\n update( student: Student.first_student(user.school))\n end\n end",
"def update\n @current_lesson = @progress.lesson\n next_lesson = @current_lesson.next(@current_lesson)\n @progress.lesson = next_lesson\n respond_to do |format|\n if @progress.update(progress_params)\n format.html { redirect_to \"/students/#{@progress.student.id}\", notice: 'Progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @progress }\n else\n format.html { render :edit }\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_scheduledlessons\n starts_on = Time.now\n course.lessons.all(order: :position).each do |lesson|\n unless scheduled_course.scheduled_lessons.where('lesson_id= ? and enrolment_id = ?',lesson.id, id ).first\n ScheduledLesson.create(student_user_id: self.student_user_id, enrolment_id: self.id, scheduled_course_id: scheduled_course.id, lesson_id: lesson.id )\n end\n end\n end",
"def update\n @service_learning_course = ServiceLearningCourse.find(params[:course_id]) rescue nil\n @student_to_add = Student.find_by_anything(params[:extra_enrollee][:student_anything]) rescue nil\n @student_to_add = @student_to_add.first if @student_to_add.is_a?(Array)\n if @student_to_add.nil?\n flash[:error] = \"Could not find a matching student. Please try again.\"\n redirect_to(students_service_learning_course_path(@unit, @quarter, @service_learning_course)) and return\n end\n \n if params[:extra_enrollee][:course].blank? # Add this student as At Large\n @extra_enrollee = ServiceLearningCourseExtraEnrollee.new()\n @extra_enrollee.person_id = @student_to_add.id\n @extra_enrollee.service_learning_course_id = @service_learning_course.id\n if @service_learning_course.enrollees.include? @student_to_add\n flash[:error] = \"#{@student_to_add.fullname} is already enrolled in this course.\"\n redirect_to(students_service_learning_course_path(@unit, @quarter, @service_learning_course)) and return\n end\n else\n @extra_enrollee = CourseExtraEnrollee.new()\n @course_to_add = @service_learning_course.courses.find(params[:extra_enrollee][:course])\n if @course_to_add.course.all_enrollees.include? @student_to_add\n flash[:error] = \"#{@student_to_add.fullname} is already enrolled in this course.\"\n redirect_to(students_service_learning_course_path(@unit, @quarter, @service_learning_course)) and return\n end\n @extra_enrollee.person_id = @student_to_add.id\n @extra_enrollee.ts_year = @course_to_add.ts_year\n @extra_enrollee.ts_quarter = @course_to_add.ts_quarter\n @extra_enrollee.course_branch = @course_to_add.course_branch\n @extra_enrollee.course_no = @course_to_add.course_no\n @extra_enrollee.dept_abbrev = @course_to_add.dept_abbrev\n @extra_enrollee.section_id = @course_to_add.section_id\n end\n\n if @extra_enrollee.save\n flash[:notice] = \"Added #{@extra_enrollee.person.fullname} to course.\"\n redirect_to(students_service_learning_course_path(@unit, @quarter, @service_learning_course))\n else\n flash[:error] = \"Could not find a matching student. Please try again.\"\n redirect_to(students_service_learning_course_path(@unit, @quarter, @service_learning_course))\n end\n end",
"def set_student\n @user = User.find(current_user.id)\n @user.admin=false\n @user.lecturer=false\n @user.save\n redirect_to \"/\", notice: \"You have been updated to a student\"\n end",
"def update\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n format.html { redirect_to [@course,@lesson], :notice => 'Lesson was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = current_user.courses.find(params[:course_id])\n @course_lesson = @course.course_lessons.find(params[:id])\n respond_to do |format|\n if @course_lesson.update_attributes(params[:course_lesson])\n format.html { redirect_to @course, notice: 'Course lesson was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_lesson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def lpu_set_based_assigning\n learners = Learner.find_all_by_admin_id_and_assessment_id(current_user.id,params[:id],:conditions => \"lesson_status = 'not attempted' AND type_of_test_taker = 'learner'\")\n old_assessment = Assessment.find_by_id(params[:id])\n new_assessment = Assessment.find_by_id(params[:test_id_to_replace_with])\n learners.each{|learner|\n learner.update_attribute(:assessment_id, new_assessment.id)\n qb_list,question_list = create_question_list(new_assessment)\n learner.update_attribute(:entry, qb_list)\n learner.update_attribute(:question_status_details, \"\")\n new_assessment.update_attribute(:total_learners, new_assessment.total_learners + 1)\n old_assessment.update_attribute(:total_learners, old_assessment.total_learners - 1)\n }\n end",
"def update(time_passed)\n @invincibility -= time_passed\n end",
"def update\n @student = Student.find(params[:student_id])\n @lunchdetention = @student.lunchdetentions.find(params[:id])\n\n respond_to do |format|\n if @lunchdetention.update_attributes(params[:lunchdetention])\n format.html { redirect_to :back, notice: 'lunchdetention was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lunchdetention.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lesson = current_user.organization.lessons.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n flash[:notice] = 'Lesson was successfully updated.'\n format.html { redirect_to(@lesson) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_standings\n system(\"clear\")\n puts \"#{previous_player} spelled #{fragment}.\"\n puts \"#{previous_player} gets a letter!\"\n\n losses[previous_player] += 1\n\n if losses[previous_player] == MAX_LOSS_COUNT\n puts \"#{previous_player} has been eliminated!\"\n end\n\n display_standings\n\n sleep(2)\n end",
"def update\n if !@ok\n redirect_to '/dashboard'\n return\n else\n @lesson.title = params[:title]\n @lesson.description = params[:description]\n @lesson.subject_id = params[:subject_id]\n @lesson.tags = params[:tags_value]\n @lesson.save_tags = true\n if @lesson.save\n @lesson.modify\n else\n @errors = convert_lesson_error_messages @lesson.errors\n end\n end\n end",
"def student_change(student_id)\n logger.debug \"student_change called\"\n # put everything in a hash for use in the view.\n @studentchanges = Hash.new\n @studentchanges[\"student\"] = Student.find(student_id)\n startdate = Date.today - (Integer(current_user.history_back) rescue 100)\n enddate = Date.today + (Integer(current_user.history_forward) rescue 7)\n # override for testing only\n #startdate = Date.parse('4-4-2018')\n #enddate = Date.parse('5-4-2018')\n @studentchanges[\"startdate\"] = startdate\n @studentchanges[\"enddate\"] = enddate\n\n # provide ability to display userids ( = email address)\n @users = User\n .select(:id, :email)\n .all\n @user_names = {}\n @users.each do |o|\n @user_names[o.id] = o.email\n end\n # now collate the changes\n # slotes o interest - in the date range\n myslots = Slot.select(:id).where(timeslot: startdate..enddate)\n # all lessons in those slots\n mylessons = Lesson.select(:id).where(slot_id: myslots)\n # all roles for this student in these lessons\n myroles = Role.select(:id, :lesson_id).where(student_id: student_id, lesson_id: mylessons)\n myroleslessonsids = myroles.map {|o| o.lesson_id} # for code efficiency later\n # now reduce to only lessons that have this student\n mylessons = mylessons.select { |o| myroleslessonsids.include?(o.id) ? true : false }\n #now get full details on these relevant lessons - slot info required in display \n mylessons = Lesson\n .joins(:slot)\n .where(id: mylessons.map {|o| o.id})\n .includes(:slot)\n # lookup table into lessons to reduce db activity.\n mylessonsindex = {} # key = session id , value is index in lessons object array \n mylessons.each_with_index do |v, i|\n mylessonsindex[v.id] = i\n end\n # ditto lookup table for tutroles\n myrolesindex = {} # key = session id , value is index in lessons object array \n myroles.each_with_index { |v, i| myrolesindex[v.id] = i }\n # go and get the relevent changes from the change table \n changelessons = Change.where(table: 'Lesson', rid: mylessons.map {|o| o.id})\n changeroles = Change.where(table: 'Role', rid: myroles.map {|o| o.id})\n changestudent = Change.where(table: 'Student', rid: student_id)\n # generate the data for display - go through each category\n #byebug\n makeDsp = lambda{|h, o| \n h['user'] = @user_names[o.user]\n h['modified'] = o.modified\n h['table'] = o.table\n h['field'] = o.field\n h['id'] = o.id\n h['value'] = o.value\n h\n }\n @dsp = Array.new\n changelessons.each do |o|\n h = makeDsp.call(Hash.new(), o)\n h['timeslot'] = mylessons[mylessonsindex[o.rid]].slot.timeslot\n h['location'] = mylessons[mylessonsindex[o.rid]].slot.location\n @dsp.push(h)\n end\n changeroles.each do |o| \n h = makeDsp.call(Hash.new(), o)\n h['timeslot'] = mylessons[mylessonsindex[myroles[myrolesindex[o.rid]].lesson_id]].slot.timeslot\n h['location'] = mylessons[mylessonsindex[myroles[myrolesindex[o.rid]].lesson_id]].slot.location\n @dsp.push(h)\n end\n # only dealing with a single student\n #byebug\n if changestudent.length > 0\n changestudent.each do |this|\n h = makeDsp.call(Hash.new(), this)\n h['timeslot'] = ''\n h['location'] = ''\n @dsp.push(h)\n end\n end\n # sort in modified date order\n @dsp = @dsp.sort_by{ |q| q['modified']}.reverse\n # now store all these changes in passed display data\n @studentchanges[\"data\"] = @dsp\n @studentchanges\n end",
"def runremovelessonfromslot(lesson)\n this_error = \"\"\n # Processing the chain.\n #--------------------- role (actually lesson)-----------------------------\n this_error = get_role_chain_and_block(lesson, {'all' => true})\n return this_error if this_error.length > 0\n #person_type = role.is_a?(Role) ? 'student' : 'tutor'\n #--------------------- check all lessons are empty ----------------------\n (0..@block_roles.length-1).each do |i|\n if @block_roles[i].tutroles.count > 0\n this_error += \" Tutors in this lesson\"\n end\n if @block_roles[i].roles.count > 0\n this_error += \" Students in this lesson\"\n end\n if this_error.length > 0\n return \"You cannot remove lessons as \" + this_error\n end\n end\n #--------------------------- update db ------------------------------\n begin\n Role.transaction do\n (0..@block_roles.length-1).each do |i|\n #@block_roles[i].update!(lesson_id: block_lessons[i].id) # change to the database\n @block_roles[i].destroy! # change to the database\n # all saved safely, now need to update the browser display (using calendar messages)\n # the object_id will now change (for both move and copy as the inbuild\n # lesson number will change.\n end\n if @role_breakchainlast # break the chain.\n @role_breakchainlast.update!(next: nil)\n end\n end\n rescue ActiveRecord::RecordInvalid => exception\n logger.debug \"rollback exception: \" + exception.inspect\n #this_exception = exception\n logger.debug \"Transaction failed!!!\"\n this_error = \"Transaction failed!!! \" + exception.inspect\n end\n if this_error.length > 0\n logger.debug \"unprocessable entity(line 117): \" + this_error \n return this_error\n end\n #--------------------------- update dom ------------------------------\n @domchangerun = Array.new\n @block_roles.each_with_index do |o, i|\n logger.debug \"block_role (\" + i.to_s + \"): \" + o.inspect\n @domchangerun[i] = Hash.new\n @domchangerun[i]['action'] = 'removeLesson'\n @domchangerun[i]['object_type'] = 'lesson'\n @domchangerun[i]['new_slot_domid'] = o.slot.location[0,3] +\n o.slot.timeslot.strftime(\"%Y%m%d%H%M\") +\n 'l' + o.slot.id.to_s\n @domchangerun[i]['object_id'] = @domchangerun[i]['new_slot_domid'] + \n 'n' + o.id.to_s\n end\n # No breakchainlast updates necessary for display. \n ############ now need to add processing for screen update #################\n # Now do the breakchainlast\n if @role_breakchainlast # break the chain.\n # Need to display the linkage change on the display\n # @role_breakchainlast is the role\n # display is an update (not a removal) so must rerender\n # build using the role\n o = @role_breakchainlast # lesson object\n @domchangebreakchainlast = Hash.new\n @domchangebreakchainlast['action'] = 'replace' \n @domchangebreakchainlast['object_type'] = 'lesson'\n @domchangebreakchainlast['new_slot_id'] = o.slot.location[0,3] +\n o.slot.timeslot.strftime(\"%Y%m%d%H%M\") +\n 'l' + o.slot_id.to_s\n @domchangebreakchainlast['object_id'] = @domchangebreakchainlast['new_slot_id'] +\n 'n' + o.id.to_s\n # This is rendering a lesson\n @domchangebreakchainlast['html_partial'] = \n render_to_string(\"calendar/_schedule_lesson_ajax.html\",\n :formats => [:html], :layout => false,\n :locals => {:slot => @domchangebreakchainlast['new_slot_id'],\n :lesson => o,\n :thistutroles => o.tutroles,\n :thisroles => o.roles\n })\n end\n #--------------------------- update screens ------------------------------\n # saved safely, now need to update the browser display (using calendar messages)\n # collect the set of screen updates and send through Ably as single message\n domchanges = Array.new\n (0..@block_roles.length-1).each do |i|\n domchanges.push(@domchangerun[i])\n end\n domchanges.push(@domchangebreakchainlast)\n ably_rest.channels.get('calendar').publish('json', domchanges)\n #(0..@block_roles.length-1).each do |i|\n # ably_rest.channels.get('calendar').publish('json', @domchangerun[i])\n #end\n # Now send out the updates to the stats screen\n # collect the set of stat updates and send through Ably as single message\n statschanges = Array.new\n (0..@block_roles.length-1).each do |i|\n statschanges.push(get_slot_stats(@domchangerun[i]['new_slot_domid']))\n end\n ably_rest.channels.get('stats').publish('json', statschanges)\n #(0..@block_roles.length-1).each do |i|\n # get_slot_stats(@domchangerun[i]['new_slot_domid'])\n #end\n # everything is completed successfully.\n respond_to do |format|\n format.json { render json: @domchange, status: :ok }\n end\n return \"\"\n end",
"def lose_a_point\n\n self.score -= 1\n\n end",
"def update_im_student\n prepare_im_student unless im_student\n im_student.get_student_attributes\n im_student.save\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |