query
stringlengths 7
6.41k
| document
stringlengths 12
28.8k
| metadata
dict | negatives
sequencelengths 30
30
| negative_scores
sequencelengths 30
30
| document_score
stringlengths 5
10
| document_rank
stringclasses 2
values |
---|---|---|---|---|---|---|
Assigns m to the rank attribute of this object. | def rank=(m)
@rank = m % (1 << size)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank=(m)\n @rank = m % factorial(size)\n end",
"def rank=(value)\n @rank = value\n end",
"def set_rank\n @rank = Rank.find(params[:id])\n end",
"def set_rank\n @rank = Rank.find(params[:id])\n end",
"def set_rank\n @rank = Rank.find(params[:id])\n end",
"def setRank _obj, _args\n \"_obj setRank _args;\" \n end",
"def set_Rank(value)\n set_input(\"Rank\", value)\n end",
"def upgrade_rank\n if self.rank.nil? || self.rank.rank == 0\n rank1 = Rank.find_by_rank(1)\n self.update_attribute(:rank_id, rank1.id) unless rank1.nil?\n end\n end",
"def re_rank\n all_member.each(&:uncache_rank_key)\n next_rank = 0\n all_member.\n sort_by(&:rank_key).\n each do |member|\n member.ordinal = next_rank\n next_rank += 1\n end\n end",
"def update_rank\n self.score = calculate_score\n self.save\n end",
"def set_ranking(value)\n\t\t@ranking = value\n\tend",
"def rank\n\t\trr = self.clone\n\t\trr.row_reduce_below\n\t\trr.rank_rr\n\tend",
"def rank\n return @rank\n end",
"def setUnitRank _obj, _args\n \"_obj setUnitRank _args;\" \n end",
"def set_rank_comment\n @rank_comment = RankComment.find(params[:id])\n end",
"def rank=(rank)\n r = rank.to_s.downcase.strip\n if !GEOG_RANKS.include?(r) \n raise GeogError, \"#{r} is not a valid rank.\"\n end\n @rank = r\n end",
"def assign_rank(rank)\n\t\tif rank.starts_with?(\"W\", \"w\")\n\t\t\tstring = \"Win\"\n\t\telsif rank.starts_with?(\"L\", \"l\")\n\t\t\tstring = \"Loss\"\n\t\telse\n\t\t\tstripped = rank.to_i.to_s\n\t\t\tstring = \"#{stripped}th\"\n\t\t\tstring = \"#{stripped}st\" if stripped.ends_with?(\"1\")\n\t\t\tstring = \"#{stripped}nd\" if stripped.ends_with?(\"2\")\n\t\t\tstring = \"#{stripped}rd\" if stripped.ends_with?(\"3\")\n\t\t\tstring = \"#{stripped}th\" if stripped.ends_with?(\"11\")\n\t\tend\n\t\tself.rank = string\n\tend",
"def set_rank\n RANKS_HASH.each do |rank, range|\n update_column(:singles_rank, rank.to_s.humanize) if singles_points&.between?(range.first, range.last)\n update_column(:doubles_rank, rank.to_s.humanize) if doubles_points&.between?(range.first, range.last)\n update_column(:womens_singles_rank, rank.to_s.humanize) if womens_singles_points&.between?(range.first, range.last)\n update_column(:womens_doubles_rank, rank.to_s.humanize) if womens_doubles_points&.between?(range.first, range.last)\n end\n end",
"def set_ranking\n @ranking = Ranking.find(params[:id])\n end",
"def rank; end",
"def rank; end",
"def rank\n @rank > 10 ? 10 : @rank\n end",
"def set_relative_rank\n ranked_week_calculations_for_season = PlayerCalculation.for_user(@player_calculation.user_id).rank_by_weekly_load # .for_season(@player_calculation.season)\n i = ranked_week_calculations_for_season.length\n ranked_week_calculations_for_season.each do |calc|\n calc.update(season_rank: i)\n calc.save!\n i = i - 1\n end\n return\n end",
"def set_rank_participant\n @rank_participant = RankParticipant.find(params[:id])\n end",
"def marines_rank; end",
"def update_rank\n age_in_days = (created_at - Time.new(1970,1,1)) / 1.day.seconds\n new_rank = points + age_in_days\n update_attribute(:rank, new_rank)\n end",
"def update_ranks\n i = 0\n rank = 0\n ncon = nil\n Contributor.all_with_ncontributions.each do |contributor|\n i += 1\n if contributor.ncontributions != ncon\n rank = i\n ncon = contributor.ncontributions\n end\n contributor.update_attribute(:rank, rank) if contributor.rank != rank\n end\n end",
"def assign_ranks(name, ranks)\r\n\t\tranks = ranks.to_f\r\n\t\tif !class_skills.include?(name) \r\n\t\t\tranks = ranks/2\r\n\t\tend\r\n\t\tif skills.include?(name) \r\n\t\t#increment skill character already has\r\n\t\t\tskills[skills.index(name)].ranks += ranks\r\n\t\telsif list.include? name \r\n\t\t#copy base skill from list to character's skills then increment that skill's ranks\r\n\t\t\tskills.push(list[list.index(name)].dup)\r\n\t\t\tskills[skills.index(name)].ranks += ranks\r\n\t\telse \r\n\t\t#skill doesn't exist in database make a new skill only for the character\r\n\t\t\tskills.push(SkillModel.new(name,\"\"))\r\n\t\t\tskills[skills.index(name)].ranks += ranks\r\n\t\tend\r\n\tend",
"def update_rank\n age_in_days = (created_at - Time.new(1970,1,1)) / (60 * 60 * 24) # 1 day in seconds\n new_rank = points + age_in_days\n \n update_attribute(:rank, new_rank)\n end",
"def rank\n @data['rank']\n end"
] | [
"0.76152587",
"0.74578905",
"0.7070407",
"0.68718636",
"0.68718636",
"0.6750307",
"0.6563231",
"0.6545335",
"0.6447588",
"0.6442698",
"0.6391471",
"0.637754",
"0.624146",
"0.6186321",
"0.6159849",
"0.61410445",
"0.6118293",
"0.60740626",
"0.60497576",
"0.60390943",
"0.60390943",
"0.6017828",
"0.6016487",
"0.59435475",
"0.593709",
"0.5936853",
"0.5918513",
"0.5892057",
"0.5883885",
"0.5864615"
] | 0.7990546 | 0 |
Returns the full path to where the bin wrapper script should be created. If Ruby was installed with a prefix or suffix it will be inflected and added to the name of the executable. If the prefix is, for instance, `mac' an executable like +macrake+ will be installed. With a suffix like `19' the name will be +rake19+. | def bin_wrapper_file
rbconfig('ruby_install_name').match /^(.*)ruby(.*)$/
File.join(Config.bin_dir, "#{$1}#{@bin_name}#{$2}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ruby_bin\n @ruby_bin ||= begin\n c = ::Config::CONFIG\n File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']\n end\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def bin_path(_opts)\n '/bin'\n end",
"def binary\n @binary ||= begin\n if brewed?\n # If the python is brewed we always prefer it!\n # Note, we don't support homebrew/versions/pythonXX.rb, though.\n Formula.factory(@name).opt_prefix/\"bin/python#{@min_version.major}\"\n else\n # Using the ORIGINAL_PATHS here because in superenv, the user\n # installed external Python is not visible otherwise.\n which(@name, ORIGINAL_PATHS.join(':'))\n end\n end\n end",
"def ruby_bin_path\n #config_section.ruby_bin_path || ENV['_'] =~ /ruby/ ||\n require 'rbconfig'\n File.expand_path(Config::CONFIG['RUBY_INSTALL_NAME'], Config::CONFIG['bindir'])\n end",
"def build_ruby\n bin = RbConfig::CONFIG[\"RUBY_INSTALL_NAME\"] || RbConfig::CONFIG[\"ruby_install_name\"]\n bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')\n File.join(RbConfig::CONFIG['bindir'], bin)\n end",
"def bin_path\n '/usr/local/bin'.p\n end",
"def path_to_bin(name = nil)\n home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'\n bin = Util.normalize_path(File.join(home, 'bin'))\n fail 'JAVA_HOME environment variable does not point to a valid JRE/JDK installation.' unless File.exist? bin\n Util.normalize_path(File.join(bin, name.to_s))\n end",
"def ruby_path\n ext = ((RbConfig::CONFIG['ruby_install_name'] =~ /\\.(com|cmd|exe|bat|rb|sh)$/) ? \"\" : RbConfig::CONFIG['EXEEXT'])\n File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + ext).sub(/.*\\s.*/m, '\"\\&\"')\n end",
"def ruby_interpreter_path\n Pathname.new(\n File.join(Config::CONFIG[\"bindir\"],\n Config::CONFIG[\"RUBY_INSTALL_NAME\"]+Config::CONFIG[\"EXEEXT\"])\n ).realpath\n end",
"def bin_dir *args\n root.join('bin', *args).to_s\n end",
"def magick_bin_name(name)\n if !(/mingw/ =~ RUBY_PLATFORM).nil?\n \"C:/src/cygwin/bin/#{name}.exe\"\n else\n name\n end\n end",
"def bin\n return \"#{@protk_dir}/bin\"\n end",
"def bin\n File.join(@root, 'bin')\n end",
"def executable(type)\n type = type.to_s\n exe_path = File.join(File.dirname(RbConfig.ruby), \"#{type}.exe\")\n bat_path = File.join(File.dirname(RbConfig.ruby), \"#{type}.bat\")\n ruby_path = File.join(File.dirname(RbConfig.ruby), type)\n\n if Gem.win_platform?\n if File.exist?(exe_path)\n return \"\\\"#{exe_path}\\\"\"\n elsif File.exist?(bat_path)\n return \"\\\"#{bat_path}\\\"\"\n end\n elsif File.exist?(ruby_path)\n return ruby_path\n end\n\n # Fall back to PATH lookup if known path does not exist\n type\n end",
"def bin(name)\n self.path.join('bin',name.to_s).to_s\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def prefix\n if brewed?\n # Homebrew since a long while only supports frameworked python\n HOMEBREW_PREFIX/\"opt/#{name}/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}\"\n elsif from_osx?\n # Python on OS X has been stripped off its includes (unless you install the CLT), therefore we use the MacOS.sdk.\n Pathname.new(\"#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}\")\n else\n # What Python knows about itself\n Pathname.new(`#{binary} -c 'import sys;print(sys.prefix)'`.strip)\n end\n end",
"def bin_path\n @bin_path ||= begin\n path = settings[:bin] || \"bin\"\n path = Pathname.new(path).expand_path(root).expand_path\n SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }\n path\n end\n end",
"def embedded_bin(bin)\n windows_safe_path(\"#{install_dir}/embedded/bin/#{bin}\")\n end",
"def python_binary\n ::File.join('', 'usr', 'bin', system_package_name)\n end",
"def scripts_folder\n HOMEBREW_PREFIX/\"share/pypy#{abi_version}\"\n end",
"def which_path(bin_name)\n bin_path = `which #{bin_name}`.strip\n bin_path.empty? ? nil : bin_path\n end",
"def path_with_prepended_ruby_bin\n env_path = ENV[\"PATH\"].dup || \"\"\n existing_paths = env_path.split(File::PATH_SEPARATOR)\n existing_paths.unshift(RbConfig::CONFIG[\"bindir\"])\n env_path = existing_paths.join(File::PATH_SEPARATOR)\n env_path.encode(\"utf-8\", invalid: :replace, undef: :replace)\n end",
"def bin_file(name)\n File.join bin_dir, name\n end",
"def ruby_path\n File.join(%w(bindir RUBY_INSTALL_NAME).map{|k| RbConfig::CONFIG[k]})\n end",
"def get_bundle_install_name(bundle_dir, binary)\n\tcurrent_dir = \"#{bundle_dir}/#{BUNDLE_MAIN_EXE_PATH}\"\n\trelative_path = Pathname.new(binary).relative_path_from(Pathname.new(current_dir)).to_s\n\trelative_path = \"@executable_path/#{relative_path}\"\n\treturn relative_path\nend"
] | [
"0.7111921",
"0.7059077",
"0.7059077",
"0.7059077",
"0.6998277",
"0.6925362",
"0.68864805",
"0.68615395",
"0.6830671",
"0.6787042",
"0.67210263",
"0.66533256",
"0.6649281",
"0.66133916",
"0.6545067",
"0.6545034",
"0.64978826",
"0.646433",
"0.646433",
"0.646433",
"0.6437297",
"0.6412892",
"0.64017683",
"0.63692915",
"0.6368694",
"0.63528174",
"0.63000447",
"0.6249753",
"0.62489873",
"0.62373954"
] | 0.76473564 | 0 |
Creates the bin wrapper script in bin_wrapper_file. | def create_bin_wrapper!
Utils.log(:debug, "Creating bin wrapper `#{bin_wrapper_file}'")
File.open(bin_wrapper_file, 'w') { |f| f << to_ruby }
File.chmod(0755, bin_wrapper_file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin_wrapper_file\n rbconfig('ruby_install_name').match /^(.*)ruby(.*)$/\n File.join(Config.bin_dir, \"#{$1}#{@bin_name}#{$2}\")\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def wrap bin_file, pythonpath\n bin_file = Pathname.new bin_file\n libexec_bin = Pathname.new libexec/'bin'\n libexec_bin.mkpath\n mv bin_file, libexec_bin\n bin_file.write <<-EOS.undent\n #!/bin/sh\n PYTHONPATH=\"#{pythonpath}:$PYTHONPATH\" \"#{libexec_bin}/#{bin_file.basename}\" \"$@\"\n EOS\n end",
"def wrapper_script(wrapper_script, action_path, target_path, servers)\n lb = line_break\n env = @platform_info[\"environment_set\"]\n cmt = @platform_info[\"comment_char\"]\n script_name = File.basename(action_path)\n if windows?\n win_path = @nsh.dos_path(target_path)\n ext = \"bat\"\n script_path = \"#{win_path}\\\\#{script_name}\"\n else\n ext = \"sh\"\n script_path = \"#{target_path}/#{script_name}\"\n end\n log \"Executing via wrapper script:\"\n wrapper_script.chomp!(\"\\r\") \n if wrapper_script.include?(\"%%\")\n wrapper_script.gsub!(\"%%\", script_path)\n else\n wrapper_script += \" #{script_path}\"\n wrapper_script += lb\n end\n new_path = create_temp_action(wrapper_script, \"wrapper_#{precision_timestamp}.#{ext}\")\n log \"\\t Target: #{new_path}\"\n log \"\\t Wrapper: #{wrapper_script}\"\n result = @nsh.ncp(servers, action_path, target_path)\n log \"\\t Copy Results: #{result}\"\n new_path\n end",
"def create_script(wrap=false)\n script = CompiledMethod::Script.new(self)\n\n # Setup the scoping.\n ss = StaticScope.new(Object)\n ss.script = script\n\n if wrap\n @scope = StaticScope.new(Module.new, ss)\n else\n @scope = ss\n end\n\n sc = Rubinius::Type.object_singleton_class(MAIN)\n sc.method_table.store :__script__, self, :public\n VM.reset_method_cache :__script__\n\n script\n end",
"def bin_file(name)\n File.join bin_dir, name\n end",
"def ensure_bin_wrapper_for(gem_dir, bin_dir, *gems)\n if bin_dir && File.directory?(bin_dir)\n gems.each do |gem|\n if gemspec_path = Dir[File.join(gem_dir, 'specifications', \"#{gem}-*.gemspec\")].last\n spec = Gem::Specification.load(gemspec_path)\n spec.executables.each do |exec|\n executable = File.join(bin_dir, exec)\n puts \"Writing executable wrapper #{executable}\"\n File.open(executable, 'w', 0755) do |f|\n f.write(executable_wrapper(spec, exec))\n end\n end\n end\n end\n end\n end",
"def build_wrapper_script(os_platform, shebang, properties)\n msg = \"Environment variables from BRPM\"\n wrapper = \"srun_wrapper_#{@rpm.precision_timestamp}\"\n cmd = shebang[\"cmd\"]\n target = File.basename(@params[\"SS_script_file\"])\n cmd = cmd.gsub(\"%%\", target) if shebang[\"cmd\"].end_with?(\"%%\")\n cmd = \"#{cmd} #{target}\" unless shebang[\"cmd\"].end_with?(\"%%\")\n if os_platform =~ /win/\n properties[\"RPM_CHANNEL_ROOT\"] = @rpm.dos_path(properties[\"RPM_CHANNEL_ROOT\"])\n properties[\"VL_CHANNEL_ROOT\"] = properties[\"RPM_CHANNEL_ROOT\"]\n wrapper = \"#{wrapper}.bat\"\n script = \"@echo off\\r\\necho |hostname > junk.txt\\r\\nset /p HOST=<junk.txt\\r\\nrm junk.txt\\r\\n\"\n script += \"echo ============== HOSTNAME: %HOST% ==============\\r\\n\"\n script += \"echo #{msg} \\r\\n\"\n properties.each{|k,v| script += \"set #{k}=#{v}\\r\\n\" }\n script += \"echo Execute the file\\r\\n\"\n script += \"cd %RPM_CHANNEL_ROOT%\\r\\n\"\n script += \"#{cmd}\\r\\n\"\n script += \"timeout /T 500\\r\\necho y | del #{target}\\r\\n\"\n else\n wrapper = \"#{wrapper}.sh\"\n script = \"echo \\\"============== HOSTNAME: `hostname` ==============\\\"\\n\"\n script += \"echo #{msg} \\n\"\n properties.each{|k,v| script += \"export #{k}=\\\"#{v}\\\"\\n\" }\n script += \"echo Execute the file\\n\"\n script += \"cd $RPM_CHANNEL_ROOT\\n\"\n script += \"#{cmd}\\n\" \n script += \"sleep 2\\nrm -f #{target}\" \n end\n fil = File.open(File.join(@output_dir, wrapper),\"w+\")\n fil.puts script\n fil.flush\n fil.close\n File.join(@output_dir, wrapper)\nend",
"def bin\n File.join(@root, 'bin')\n end",
"def ensure_bin_wrapper_for(gem_dir, bin_dir, *gems)\n if bin_dir && File.directory?(bin_dir)\n gems.each do |gem|\n if gemspec_path = Dir[File.join(gem_dir, 'specifications', \"#{gem}-*.gemspec\")].last\n spec = Gem::Specification.load(gemspec_path)\n spec.executables.each do |exec|\n executable = File.join(bin_dir, exec)\n message \"Writing executable wrapper #{executable}\"\n File.open(executable, 'w', 0755) do |f|\n f.write(executable_wrapper(spec, exec))\n end\n end\n end\n end\n end\n end",
"def build_deploy_info_file\n\n deploy_info = get_deploy_info.to_yaml\n info_filepath = \"#{self.scripts_path}/info\"\n\n @shell.make_file info_filepath, deploy_info\n\n @shell.symlink info_filepath, \"#{self.root_path}/info\"\n end",
"def generate_script\n init = Nyaplot.generate_init_code\n path = File.expand_path(\"../templates/static_script.erb\", __FILE__)\n template = File.read(path)\n ERB.new(template).result(binding)\n end",
"def install_binfile(from, op_file, target)\n tmp_file = Tempfile.new('facter-binfile')\n\n ruby = if !InstallOptions.ruby.nil?\n InstallOptions.ruby\n else\n File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])\n end\n\n File.open(from) do |ip|\n File.open(tmp_file.path, 'w') do |op|\n op.puts \"#!#{ruby}\"\n contents = ip.readlines\n contents.shift if contents[0] =~ /^#!/\n op.write contents.join\n end\n end\n\n if windows? && InstallOptions.batch_files\n installed_wrapper = false\n\n if File.exist?(\"#{from}.bat\")\n install(\"#{from}.bat\", File.join(target, \"#{op_file}.bat\"), mode: 0o755, preserve: true, verbose: true)\n installed_wrapper = true\n end\n\n if File.exist?(\"#{from}.cmd\")\n install(\"#{from}.cmd\", File.join(target, \"#{op_file}.cmd\"), mode: 0o755, preserve: true, verbose: true)\n installed_wrapper = true\n end\n\n unless installed_wrapper\n tmp_file2 = Tempfile.new('facter-wrapper')\n cwv = <<-SCRIPT\n @echo off\n SETLOCAL\n if exist \"%~dp0environment.bat\" (\n call \"%~dp0environment.bat\" %0 %*\n ) else (\n SET \"PATH=%~dp0;%PATH%\"\n )\n ruby.exe -S -- facter %*\n SCRIPT\n File.open(tmp_file2.path, 'w') { |cw| cw.puts cwv }\n install(tmp_file2.path, File.join(target, \"#{op_file}.bat\"), mode: 0o755, preserve: true, verbose: true)\n\n tmp_file2.unlink\n end\n end\n install(tmp_file.path, File.join(target, op_file), mode: 0o755, preserve: true, verbose: true)\n tmp_file.unlink\n end",
"def build_ruby\n bin = RbConfig::CONFIG[\"RUBY_INSTALL_NAME\"] || RbConfig::CONFIG[\"ruby_install_name\"]\n bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')\n File.join(RbConfig::CONFIG['bindir'], bin)\n end",
"def patch_wrapper_script(prog)\n\t\twrapper_script_header = <<-WRAPPER_SCRIPT_HEADER\n#!/bin/bash\n\nexport LANG=en_US.UTF-8\nexport LANGUAGE=en_US.UTF-8\nexport LC_ALL=en_US.UTF-8\n\nCOMMONSDIR=\"#{HOMEBREW_PREFIX.join('opt', 'hets-commons')}\"\nPROGDIR=\"#{prefix}\"\nPROG=\"#{prog}\"\n\n[[ -z ${HETS_JNI_LIBS} ]] && \\\\\n\t\t HETS_JNI_LIBS=\"#{HOMEBREW_PREFIX.join('opt', 'factplusplus')}\"\nWRAPPER_SCRIPT_HEADER\n\n\t\t# Replace the header until (including) the line starting with PROG=\n\t\tinreplace(bin.join(prog), /\\A.*PROG=[^\\n]*$/m, wrapper_script_header)\n inreplace(bin.join(prog), 'BASEDIR', 'COMMONSDIR')\n inreplace(bin.join(prog), /PELLET_PATH=.*$/, \"PELLET_PATH=#{HOMEBREW_PREFIX.join('opt', 'pellet', 'bin')}\")\n inreplace(bin.join(prog), /^\\s*exec\\s+([\"']).*COMMONSDIR[^\\/]*/, 'exec \\1${PROGDIR}')\n end",
"def create_wrapper!(template_root)\n wrapper = Tempfile.new('lxc-wrapper').tap do |file|\n template = Vagrant::Util::TemplateRenderer.new(\n 'sudoers.rb',\n #:template_root => Vagrant::LXC.source_root.join('templates').to_s,\n #:template_root => \"/usr/share/vagrant/gems/gems/vagrant-lxc-1.1.0/templates\",\n :template_root => template_root,\n :cmd_paths => build_cmd_paths_hash,\n #:pipework_regex => \"#{ENV['HOME']}/\\.vagrant\\.d/gems/gems/vagrant-lxc.+/scripts/pipework\"\n :pipework_regex => \"/usr/share/vagrant/gems/gems/vagrant-lxc.+/scripts/pipework\"\n )\n file.puts template.render\n end\n wrapper.close\n wrapper.path\n end",
"def write_create_symlinks_script(symlinks)\n File.open(SYMLINKS_SCRIPT, 'w') do |f|\n f.puts '#!/system/bin/sh'\n f.puts ''\n f.puts 'cd $(dirname $0)'\n f.puts ''\n f.puts \"single_file_binaries=\\\"#{symlinks.join(' ')}\\\"\"\n f.puts ''\n f.puts 'for i in $single_file_binaries; do'\n f.puts 'ln -s coreutils $i;'\n f.puts 'done'\n f.puts ''\n f.puts 'cd -'\n end\n FileUtils.chmod '+x', SYMLINKS_SCRIPT\n end",
"def ensure_bin_wrapper_for(gem_dir, bin_dir, *gems)\n options = gems.last.is_a?(Hash) ? gems.last : {}\n options[:no_minigems] ||= []\n if bin_dir && File.directory?(bin_dir)\n gems.each do |gem|\n if gemspec_path = Dir[File.join(gem_dir, 'specifications', \"#{gem}-*.gemspec\")].last\n spec = Gem::Specification.load(gemspec_path)\n enable_minigems = !options[:no_minigems].include?(spec.name)\n spec.executables.each do |exec|\n executable = File.join(bin_dir, exec)\n message \"Writing executable wrapper #{executable}\"\n File.open(executable, 'w', 0755) do |f|\n f.write(executable_wrapper(spec, exec, enable_minigems))\n end\n end\n end\n end\n end\n end",
"def bin(name, opts)\n if opts[:go]\n import = opts[:go]\n path = File.join(BIN, import.split('/').last)\n file(path) { run \"go install #{import}\" }\n define_method(name) do\n Rake::Task[path].invoke\n path\n end\n elsif opts[:brew]\n formula = opts[:brew]\n define_method(name) do\n run \"hash #{name} || brew install #{formula}\"\n name\n end\n end\nend",
"def installBIN(from, opfile)\r\n\r\n tmp_dir = nil\r\n for t in [\".\", \"/tmp\", \"c:/temp\", $bindir]\r\n stat = File.stat(t) rescue next\r\n if stat.directory? and stat.writable?\r\n tmp_dir = t\r\n break\r\n end\r\n end\r\n\r\n fail \"Cannot find a temporary directory\" unless tmp_dir\r\n tmp_file = File.join(tmp_dir, \"_tmp\")\r\n\r\n File.open(from) do |ip|\r\n File.open(tmp_file, \"w\") do |op|\r\n ruby = File.join($realbindir, $ruby)\r\n op.puts \"#!#{ruby}\"\r\n op.write ip.read\r\n end\r\n end\r\n\r\n opfile += \".rb\" if CONFIG[\"target_os\"] =~ /mswin/i\r\n File::install(tmp_file, File.join($bindir, opfile), 0755, true)\r\n File::unlink(tmp_file)\r\nend",
"def buildup_template_file(basename, header, hash)\n type = hash[:type] || :script\n filename = filename_for(basename, type)\n\n if File.exist? filename\n exit 0 unless prompt(\"* '#{filename}' already exists, overwrite it? (y/n): \") =~ /^y$/i\n end\n File.open(filename, \"w\") {|file|\n file << \"#!/usr/bin/env ruby\"\n file << \"\\n\"\n file << \"# coding: #{get_encoding}\"\n file << \"\\n\" * 2\n file << get_commented_text(header)\n file << \"\\n\" * 2\n\n case type\n when :script\n file << TEMPLATE_SCRIPT\n when :test\n file << TEMPLATE_TEST_UNIT\n when :rspec\n file << TEMPLATE_RSPEC\n end\n\n file.chmod SCRIPT_MOD\n\n puts \"* Successfully generated: #{filename}\"\n }\n end",
"def generate_shell\n # shell\n file_name = \"run_All.sh\"\n printf(\"@I:generate %s\\n\",file_name)\n f = open(\"#{file_name}\",\"w\")\n f.printf(\"#\\!\\/bin\\/sh\\n\")\n comment = \"Run Script for ConnectChecker\" \n Common.print_file_header(f,\"#{comment}\",$TOOL,$VERSION,\"##\")\n f.printf(\"FICE=%s\\n\",File.dirname(__FILE__))\n f.printf(\"CONNECT_CHECKER=\\$\\{FICE\\}\\/ConnectChecker.rb\\n\")\n f.printf(\"\\n\")\n f.printf(\"for EXPECT_FILE in \\\\\\n\")\n case $MODE\n when \"All\"\n f.printf(\" %s\\/product.expect \\\\\\n\",dir_name)\n when \"Each\"\n @InstInfo.sort_by{|a|\n a.InstanceName\n }.each{|inst|\n f.printf(\" %s \\\\\\n\",inst.ExpectFile.gsub(\"\\(\",\"\\\\\\(\").gsub(\"\\)\",\"\\\\\\)\"))\n }\n end\n f.printf(\"\\n\")\n f.printf(\"do\\n\")\n ice_opt = \"\"\n @ICE_OPT.each{|str|\n ice_opt = ice_opt + \" \" + str\n }\n f.printf(\"\\truby -w \\$\\{CONNECT_CHECKER\\} -expect \\$\\{EXPECT_FILE\\} -device %s -ice %s\\n\",@DEV_OPT,ice_opt)\n f.printf(\"\\done\\n\")\n f.close\n FileUtils.chmod(0744,\"#{file_name}\")\n end",
"def build_script\n File.join(data_dir, 'build-script')\n end",
"def create_bin_stubs(stubs)\n results = stubs.map do |stub|\n run_command 'spring binstub', stub unless File.exist? \"#{Dir.pwd}/bin/#{stub}\"\n end\n !results.any? or results.all? { |result| result }\n end",
"def bin_path\n @bin_path ||= begin\n path = settings[:bin] || \"bin\"\n path = Pathname.new(path).expand_path(root).expand_path\n SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }\n path\n end\n end",
"def run\n Execution.block 'Creating a custom file', @target, 'root' do |b|\n b.always_run true\n b.run \"mkdir -p #{::File.dirname(@target)}\"\n ::File.open(@target, 'w+') { |file| file.write @content }\n b.run \"chown #{@owner}:#{@owner} #{::File.dirname(@target)}\"\n b.run \"chown #{@owner}:#{@owner} #{@target}\"\n b.run \"chmod #{unix_mode} #{@target}\"\n end\n end",
"def write_script name, contents\n script_file = \"#{self.scripts_path}/#{name}\"\n\n @shell.make_file script_file, contents,\n :flags => '--chmod=ugo=rwx' unless @shell.file? script_file\n end",
"def generate_binary(msfvenom_path, payload, options)\n dirname = File.dirname(\"tmp\")\n unless File.directory?(\"tmp\")\n FileUtils.mkdir_p(\"tmp\")\n print_status(\"tmp directory created.\")\n end\n\n cmd = 'ruby '+msfvenom_path+' -p '+payload+' -f c '+options+' > tmp/bin'+self.uuid+'.c'\n\n print_status(\"Delegating to msfvenom to generate payload binary: \")\n print_status(\" \"+cmd)\n\n return %x[ #{cmd} ]\n end",
"def fake_embedded_bin(name)\n bin = File.join(software.install_dir, 'embedded', 'bin')\n\n FileUtils.mkdir_p(bin)\n FileUtils.ln_s(Bundler.which(name), File.join(bin, name))\n end"
] | [
"0.73506254",
"0.7183065",
"0.7183065",
"0.7183065",
"0.66861516",
"0.57090926",
"0.56985825",
"0.5689301",
"0.56490105",
"0.5602203",
"0.55913746",
"0.558095",
"0.5565157",
"0.555904",
"0.5514169",
"0.54756874",
"0.5470731",
"0.54510725",
"0.53776884",
"0.53558725",
"0.5343988",
"0.53390616",
"0.532043",
"0.5314953",
"0.52848464",
"0.52075344",
"0.516669",
"0.5153767",
"0.5153449",
"0.5149671"
] | 0.8945799 | 0 |
Adds the given list of project names to the exclusion set of this updater. | def exclude(project_list)
project_list.each { |p| @excluded_projects[p] = true }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclude(*names)\n project(*(map(&:name) - names))\n end",
"def exclude(*files)\n @exclude += files.flatten\n self\n end",
"def exclusions\n project.exclusions + %w(\n **/.git\n **/.hg\n **/.svn\n **/.gitkeep\n )\n end",
"def ignore_only=(names)\n @ignore = [names].flatten\n end",
"def exclude(*files)\n files = to_artifacts(files)\n @excludes |= files\n @excludes |= files.reject { |f| f =~ /\\*$/ }.map { |f| \"#{f}/*\" }\n self\n end",
"def exclude(*files)\n @paths[''].exclude *files\n self\n end",
"def excludes(*paths)\n self.excluded_files.concat(expand_globs(paths))\n end",
"def add_files_to_clean(*filenames)\n @clean_list.include(filenames)\n Cleaner.global_clean_list.include(filenames)\n end",
"def excluded_files() = []",
"def plugin_exclusions=( args )\n\t\t@plugin_exclusions = Array( args )\n\tend",
"def excluding_topics_list=(names)\n self.excludes_topics.clear\n names.split(',').each do |name|\n topic = Topic.find_by_name(name.downcase.strip)\n self.excludes_topics << topic if topic\n end\n end",
"def excludes\n @excludes ||= []\n end",
"def excluded?(project_name)\n @excluded_projects.has_key?(project_name)\n end",
"def ignore(*globs)\n @ignore.concat(globs) unless globs.empty?\n @ignore\n end",
"def exclude(*files)\n filter.exclude *files\n self\n end",
"def include_all_except(*args) \n set_option_array_values(:include_all_except, *args)\n end",
"def hg_ignore_files( *pathnames )\n\t\t\tpatterns = pathnames.flatten.collect do |path|\n\t\t\t\t'^' + Regexp.escape(path) + '$'\n\t\t\tend\n\t\t\ttrace \"Ignoring %d files.\" % [ pathnames.length ]\n\n\t\t\tIGNORE_FILE.open( File::CREAT|File::WRONLY|File::APPEND, 0644 ) do |fh|\n\t\t\t\tfh.puts( patterns )\n\t\t\tend\n\t\tend",
"def update!(**args)\n @exclude = args[:exclude] if args.key?(:exclude)\n end",
"def update!(**args)\n @exclude = args[:exclude] if args.key?(:exclude)\n end",
"def exclude_opts\n excludes.map { |exclude_pattern|\n \"--exclude='#{exclude_pattern}'\"\n }.join(' ')\n end",
"def cloudformation_exclude(*names)\n names.each do |name|\n @task.exclude(:cfn, name)\n end\n end",
"def ignore!(*globs)\n @ignore.replace(globs)\n @ignore\n end",
"def ignore(*paths)\n paths.each do |path|\n if path.is_a? Array\n config.ignore.concat path\n else\n config.ignore << path\n end\n end \n end",
"def update_ignores\n @ignore_users |= WhitelistedUser.all.map(&:user_id)\n end",
"def ignore(*globs)\n @watchlist.ignore(globs) unless globs.empty?\n end",
"def exclude\n @_exclude ||= Set.new %w(test spec tmp features config public db).map{ |path| Padrino.root(path) }\n end",
"def ignores(*file_paths)\n self.ignore_paths += file_paths\n end",
"def ignore!(*globs)\n @watchlist.ignore!(globs)\n end",
"def apply_exclusions paths\n paths.reject do |path|\n excludes.any? do |pattern|\n globs = pattern.split(\"\\\\\")\n components = path.split(\"/\")\n\n # Inno Setup includes a feature in which you can anchor excludes at\n # the root by starting the exclude with a \"\\\". Since I don't want\n # to make this more complicated than I have to, I'm not implementing\n # this feature at this time.\n if globs[0] == \"\"\n raise \"Can't handle anchored exclude #{pattern}\"\n end\n \n globs_match_strings_anywhere? globs, components\n end\n end\n end",
"def projects=(projs)\n return false unless projs.is_a? Array\n removed = @projects - projs\n added = projs - @projects\n @text << \" \" << added.map{|t| \"+#{t}\"}.join(\" \")\n removed.each {|r| @text.gsub!(\" +#{r}\",\"\")}\n @projects=projs\n end"
] | [
"0.68831885",
"0.67353773",
"0.62806255",
"0.62071306",
"0.61030465",
"0.60448426",
"0.5999561",
"0.5841393",
"0.57208943",
"0.5714696",
"0.56601846",
"0.56022626",
"0.55809677",
"0.55491906",
"0.5537801",
"0.55049354",
"0.54737276",
"0.5453259",
"0.5453259",
"0.5447674",
"0.5433716",
"0.5405372",
"0.5380218",
"0.5369882",
"0.53568625",
"0.5349697",
"0.534834",
"0.53400105",
"0.5334151",
"0.53317326"
] | 0.72182447 | 0 |
Returns true if the given project is in the exclusion set of this updater; returns false otherwise. | def excluded?(project_name)
@excluded_projects.has_key?(project_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_allowed(project)\n Chef::Cache::KNOWN_PROJECTS.include? project\n end",
"def is_project_disabled(proj)\n ## check project\n return true if proj.nil?\n\n ## check proj custom field\n proj_cf = ProjectCustomField.find_by_name(\"Hangouts Chat Webhook Disabled\")\n return true if proj_cf.nil?\n\n ## check proj custom value\n proj_cv = proj.custom_value_for(proj_cf)\n\n ## proj_cv is null\n return false if proj_cv.nil?\n\n return false if proj_cv.value == '1'\n\n return false\n end",
"def member_of?(project)\n !roles_for_project(project).detect { |role| role.member? }.nil?\n end",
"def project?(p)\r\n projects.include?(p)\r\n end",
"def exclude?\n self.exclude == true || self.class.excluded_accounts.include?(self.account_number)\n end",
"def exclude(project_list)\n project_list.each { |p| @excluded_projects[p] = true }\n end",
"def is_for_project?\n not self.project.nil?\n end",
"def project?\n ! @project.nil?\n end",
"def leave_manages_project?(project, include_backups = true)\r\n\t\t\t\t\treturn LeavesHolidaysManagements.management_rules_list(self, 'receiver', 'is_managed_by', project, [], include_backups).any?\r\n\t\t\tend",
"def exclude?(production)\n !include?(production)\n end",
"def has_project?\n !project_id.nil? && project.visible\n end",
"def excluded?(path)\n\t\t\t@excludes.each do |exclusion|\n\t\t\t\tif path.match(exclusion)\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn false\n\t\tend",
"def user_project_admin?\n project = Project.getActive\n admin_emails = project[:data]['adminEmails']\n admin_emails.include?(current_user.email) &&\n (\n !current_user.user_role ||\n current_user.user_role.name != 'admin'\n )\n end",
"def excluded?(site, name)\r\n @config['exclude'].include? name\r\n end",
"def modifiable_by?(current_user)\n # current_user.all_projects.pluck(:id).include?(self.sticky.project_id)\n sticky.project.modifiable_by?(current_user)\n end",
"def member_of?(project)\n role_for_project(project).member?\n end",
"def project?\n true\n end",
"def excludes_file?(file)\n excluded_files.include?(file)\n end",
"def check_own_project_and_redirect?\n unless current_user.projects.ids.include? params[:project_id].to_i\n flash[:danger] = 'Access denied. You do not own that project.'\n redirect_to projects_path\n return true\n end\n false\n end",
"def in_excluded_files(filename)\n unless @options[:exclude].nil? || @excluded_files.empty?\n @excluded_files.each do |excluded_file|\n return true if filename.eql? \"#{excluded_file}\"\n end\n false\n end\n false\n end",
"def package_project_valid?\n Project.first(:code => metadata[\"dmd-project\"], :account => {:code => metadata[\"dmd-account\"]}) != nil\n end",
"def exclude?(table)\n @excludes.each do |excl|\n return true if table.apprmatch(excl)\n end\n return false\n end",
"def check_if_work_dir_excluded\n File.open('.git/info/exclude').each_line.any? do |line|\n line ==\"#{work_dir(true)}\\n\"\n end\n end",
"def project_exists?(name)\n projects.include?(name)\n end",
"def is_managed_in_project?(project)\r\n\t\t\t\tLeavesHolidaysManagements.management_rules_list(self, 'sender', 'is_managed_by', project).any?\r\n\t\t\tend",
"def exclusions\n project.exclusions + %w(\n **/.git\n **/.hg\n **/.svn\n **/.gitkeep\n )\n end",
"def invited_user_does_not_have_pending_application_to_project\n\t\t if invited_user.has_pending_application_to_project?(project)\n\t\t\t\terrors[:base] << \"#{invited_user.username} has a pending application to this project.\"\n\t\t\tend\n\t\tend",
"def belongs_to_project?(project)\n (source_type == \"project\") &&\n (project_id == project.id)\n end",
"def is_managed_by_leave_admin?(project)\r\n\t\t\t\treturn self.can_create_leave_requests && !self.is_managed_in_project?(project) && self.leave_manages_project?(project, false) && !self.is_contractor && !self.is_leave_admin?(project) && !self.is_system_leave_admin?\r\n\t\t\tend",
"def excluded?(file)\n file = File.join(Dir.pwd, file) unless file.start_with?('/')\n Codeqa.configuration.excludes.any?{ |pattern| match_path?(pattern, file) }\n end"
] | [
"0.6702821",
"0.65350467",
"0.6459527",
"0.64529914",
"0.64078003",
"0.63656276",
"0.6254842",
"0.62057394",
"0.6198769",
"0.61850864",
"0.6083902",
"0.60369515",
"0.5985252",
"0.5933135",
"0.59222806",
"0.58516645",
"0.5798777",
"0.57894695",
"0.5750773",
"0.57204574",
"0.57125956",
"0.5674943",
"0.5674296",
"0.56589943",
"0.5641597",
"0.56288826",
"0.5622529",
"0.562245",
"0.55939937",
"0.55930734"
] | 0.74364233 | 0 |
Returns true if there are actions that have not been applied to the platform (including actions in derivative builds); returns false otherwise. | def pending_actions?
return true if @log.pending_actions?
@derivative_builds.each do |d|
return true if d.pending_actions?
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actions?\n non_empty?(@actions)\n end",
"def has_actions?\n if self.actions == []\n return false\n else\n return true\n end\n end",
"def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end",
"def empty?\n @actions.empty?\n end",
"def all_ok?\n tm = TactBattleManager\n all_sh_ok = tm.shared_act_ok? && @tb_state != :wait\n tbu_all_ok = @tb_actions[:all] < all_action_lmt && @tb_state != :wait\n tm.use_shared_actions? ? all_sh_ok : tbu_all_ok\n end",
"def undocumented_commands?\n !undocumented_commands.empty?\n end",
"def action?\n action_channel.in_use?\n end",
"def actions_available?(user)\n actions_allowable?(user)\n end",
"def single_actions?\n false\n end",
"def use_event_attributes?\n !skip_actions && !skip_after && actions.all? && actions.length == 1 && first.machine.action_hook?\n end",
"def action_defined?\n # ReputationThreshold.action_defined?(self.action, self.tier)\n !self.action_points.nil?\n end",
"def available_action?(action_name); end",
"def has_action?(action)\n @actions.include? action\n end",
"def unknown?\n !dir? && !file? && !symlink? && !device?\n end",
"def only_action_instances?\n only? :action_instances\n end",
"def banned?\n global_steps = self.class.global_actions.map { |(action, rule)| Step.new(self, rule, action) }\n !Runner.new(global_steps).pass?\n end",
"def installable?\n uninstallable_reasons.empty?\n end",
"def special_action?\n SPECIAL_ACTIONS.include?(action.to_sym)\n end",
"def can_post_install?\n return false unless has_os?\n\n ![\"vmware_esxi\", \"hyperv\", \"suse11\", \"suse12\"].include?(os_image_type.downcase)\n end",
"def actions\n return (@attributes & 0x40 == 0x40)\n end",
"def not_applicable?\n @current_state == Psc::ScheduledActivity::NA\n end",
"def manually_awarded?\n actable_type.nil? && actable.nil?\n end",
"def private_app_no?\r\n make_sure_apps_page unless @driver.current_url =~ /.*apps.*/\r\n disabled_or_not_upload = new_app_locator(:upload_a_zip_btn).attribute('disabled') \r\n disabled_or_not_paste = new_app_locator(:paste_git_repo_input).attribute('disabled') \r\n if disabled_or_not_paste && disabled_or_not_upload\r\n puts \"+ <action> private_app_no? NO\"\r\n return true\r\n end\r\n puts \"+ <action> private_app_no? YES\"\r\n return false\r\n end",
"def empty?\n return txactions.empty?\n end",
"def check_attack_condition?\n # attack button enabled and attack button is pressed\n return ($game_system.attack_button && Input.trigger?(Input::Attack))\n end",
"def available_actions\n fail NotImplementedError\n end",
"def has_action?(name)\n !!find_action_by_name(name)\n end",
"def allowed?\n # If the agent's busy state will clear this turn, this action\n # could happen. We intentionally don't send a \"disallowed\"\n # notification for the action. It's not cancelled, nor is it\n # dispatched successfully. It's just waiting for a later tick to\n # do one of those two things.\n return false if @agent.state[\"busy\"] > 1\n\n # A dilemma: if we cancel now when no actions are queued, then\n # any action queued this turn (e.g. from an\n # EveryXActionsIntention) won't be executed -- we said this\n # intention wasn't happening. If we *don't* return false in the\n # \"allowed?\" phase then we'll wind up sending out a cancel\n # notice every turn when there are no actions. So we add a\n # \"silent\" info option to the normal-every-turn cancellations,\n # but we *do* allow-then-cancel even in perfectly normal\n # circumstances.\n true\n end",
"def done?\n @possibles.all? do |ops_modifiers, count|\n count.zero? || !all_ops_modifiers_qualify?(ops_modifiers, count)\n end\n end",
"def isnt_an_action_command?(cmd)\n !!(/^(get|find|is|assert|element|setImplicitWaitTimeout|setScriptTimeout|newSession).*/.match(cmd))\n end"
] | [
"0.7307512",
"0.7282279",
"0.6832453",
"0.6501673",
"0.6432667",
"0.63622",
"0.62694204",
"0.6254466",
"0.6243115",
"0.6218956",
"0.62068635",
"0.6188491",
"0.6115419",
"0.607482",
"0.6071691",
"0.6066297",
"0.6063726",
"0.6057236",
"0.6054853",
"0.60479695",
"0.60404646",
"0.6012254",
"0.5994919",
"0.5986103",
"0.59547216",
"0.59332794",
"0.5926235",
"0.58866906",
"0.58816874",
"0.586115"
] | 0.73041517 | 1 |
Enqueues a derivative build based on the specified project (which is typically, but not necessarily, an installation profile). Does nothing if the project does not contain any makefile whose name coincides with the name of the project. | def prepare_derivative_build(project)
mf = project.makefile
return false if mf.nil?
debug "Preparing derivative build for #{mf.basename}"
submake = Makefile.new(mf)
subplatform = Platform.new(@platform.local_path)
subplatform.contrib_path = @platform.dest_path(project)
new_updater = Updater.new(submake, subplatform, site)
new_updater.exclude(project.extensions)
new_updater.exclude(@platform.profiles)
@derivative_builds << new_updater
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_projects(options = {})\n exclude(@core_projects) # Skip core projects\n processed = Array.new(excluded) # List of names of processed projects\n dep_queue = Array.new # Queue of Drupid::Project objects whose dependencies must be checked. This is always a subset of processed.\n\n @makefile.each_project do |makefile_project|\n dep_queue << makefile_project if sync_project(makefile_project)\n processed += makefile_project.extensions\n end\n\n unless options[:nofollow]\n # Recursively get dependent projects.\n # An invariant is that each project in the dependency queue has been processed\n # and cached locally. Hence, it has a version and its path points to the\n # cached copy.\n while not dep_queue.empty? do\n project = dep_queue.shift\n project.dependencies.each do |dependent_project_name|\n unless processed.include?(dependent_project_name)\n debug \"Queue dependency: #{dependent_project_name} <- #{project.extended_name}\"\n new_project = Project.new(dependent_project_name, project.core)\n dep_queue << new_project if sync_project(new_project)\n @makefile.add_project(new_project)\n processed += new_project.extensions\n end\n end\n end\n end\n\n # Determine projects that should be deleted\n pending_delete = @platform.project_names - processed\n pending_delete.each do |p|\n proj = platform.get_project(p)\n log.action(DeleteAction.new(platform, proj))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing deletion.\"\n else\n log.error \"#{proj.extended_name}: use --force to force deletion or install Drush >=6.0.\"\n end\n elsif proj.installed?(site)\n if @force_changes\n owarn \"Deleting an installed/enabled project.\"\n else\n log.error \"#{proj.extended_name} cannot be deleted because it is installed\"\n end\n end\n end\n end",
"def add_build!(project: nil, build: nil)\n not_implemented(__method__)\n end",
"def _install\n args = Array.new\n # If the project contains a makefile, it is a candidate for a derivative build.\n # In such case, protect 'libraries', 'modules' and 'themes' subdirectories\n # from deletion.\n if component.makefile\n args << '-f' << 'P /libraries/***' # this syntax requires rsync >=2.6.7.\n args << '-f' << 'P /modules/***'\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'P /themes/***'\n end\n if component.drupal?\n args = Array.new\n args << '-f' << 'R /profiles/default/***' # D6\n args << '-f' << 'R /profiles/minimal/***' # D7\n args << '-f' << 'R /profiles/standard/***' # D7\n args << '-f' << 'R /profiles/testing/***' # D7\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'R /sites/all/README.txt'\n args << '-f' << 'R /sites/default/default.settings.php'\n args << '-f' << 'P /sites/***'\n end\n args << '-a'\n args << '--delete'\n component.ignore_paths.each { |p| args << \"--exclude=#{p}\" }\n dst_path = platform.local_path + platform.dest_path(component)\n dont_debug { dst_path.mkpath }\n args << component.local_path.to_s + '/'\n args << dst_path.to_s + '/'\n begin\n runBabyRun 'rsync', args\n rescue => ex\n odie \"Installing or updating #{component.name} failed: #{ex}\"\n end\n end",
"def sync_project(project)\n return false unless _fetch_and_patch(project)\n\n # Does this project contains a makefile? If so, enqueue a derivative build.\n has_makefile = prepare_derivative_build(project)\n\n # Ignore libraries that may be installed inside this project\n pp = @platform.local_path + @platform.dest_path(project)\n @libraries_paths.each do |lp|\n if lp.fnmatch?(pp.to_s + '/*')\n project.ignore_path(lp.relative_path_from(pp))\n @log.notice(\"Ignoring #{project.ignore_paths.last} inside #{project.extended_name}\")\n end\n end\n\n # Does the project exist in the platform? If so, compare the two.\n if @platform.has_project?(project.name)\n platform_project = @platform.get_project(project.name)\n # Fix project location\n new_path = @platform.dest_path(project)\n if @platform.local_path + new_path != platform_project.local_path\n log.action(MoveAction.new(@platform, platform_project, new_path))\n if (@platform.local_path + new_path).exist?\n if @force_changes\n owarn \"Overwriting existing path: #{new_path}\"\n else\n log.error(\"#{new_path} already exists. Use --force to overwrite.\")\n end\n end\n end\n # Compare versions and log suitable actions\n _compare_versions project, platform_project\n else\n # If analyzing the platform does not allow us to detect the project (e.g., Fusion),\n # we try to see if the directory exists where it is supposed to be.\n proj_path = @platform.local_path + @platform.dest_path(project)\n if proj_path.exist?\n begin\n platform_project = PlatformProject.new(@platform, proj_path)\n _compare_versions project, platform_project\n rescue => ex\n log.action(UpdateProjectAction.new(@platform, project))\n if @force_changes\n owarn \"Overwriting existing path: #{proj_path}\"\n else\n log.error(\"#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}\")\n end\n end\n else # new project\n log.action(InstallProjectAction.new(@platform, project))\n end\n end\n return (not has_makefile)\n end",
"def process_project_dependencies\n BRIX11.log_warning(\"missing #process_project_dependencies implementation for #{self.to_s}\")\n end",
"def pending_builds(project: nil)\n not_implemented(__method__)\n end",
"def archive_build_if_necessary(target_directory)\n # Nothing here in superclass\n end",
"def install_projects\n if @project.include? ','\n projects = @project.split ','\n projects.each do |p|\n @project = p\n check_core\n install_project \n puts\n end \n else\n check_core\n install_project\n end\n end",
"def scratch_build\n begin\n distgit_pkg.build\n rescue => e\n puts \"Warning: scratch build failed: #{e}\".bold.red\n end\n end",
"def scratch_build\n begin\n distgit_pkg.build\n rescue => e\n puts \"Warning: scratch build failed: #{e}\".bold.red\n end\n end",
"def build_me\n # Download all softwares in parallel\n download\n build\n end",
"def build_gem; end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend",
"def common_build\n copy_gems # in make/gems.rb\n end",
"def build(rakeTask)\n\t\t#we've called ourselves after updating prereqs and running them; now do our work\n\t\t\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes non-file prereq tasks, so do our own\n\t\t\tlinker().link(:objs => linkDepsOrdered(), :target => target())\n\t\tend\n\tend",
"def build(project_name, auto_install, proxy_option)\n # On verifie la presence de ZenTest\n Utils.verify_gem_presence(\"ZenTest\", auto_install, proxy_option)\n # On lance la generation\n puts \" Building ZenTest report...\"\n zentest_report = File.open(\"#{Continuous4r::WORK_DIR}/zentest-body.html\", \"w\")\n zentest_report.write(ZenTestFormatter.new.to_html)\n zentest_report.close\n end",
"def common_build\n copy_gems\n end",
"def common_build\n copy_gems\n end",
"def installDeps(copy)\n deps = Buildr.artifacts(project('infra').compile.dependencies).map(&:to_s)\n deps << project('infra').package.to_s\n\t\t EXTRA_JARS.each do |jar|\n\t\t\t\t\tdeps << jar\n\t\t\t\tend\n deps = skipDeps(deps)\n\n classpathFile = File.new(GT4LIB + '/gndms-dependencies.xml', 'w')\n classpathFile.syswrite('<?xml version=\"1.0\"?>' + \"\\n\" + '<project><target id=\"setGNDMSDeps\"><path id=\"service.build.extended.classpath\">' + \"\\n\")\n depsFile = File.new(GT4LIB + '/gndms-dependencies', 'w')\n deps.select { |jar| jar[0, GT4LIB.length] != GT4LIB }.each { |file| \n basename = File.basename( file )\n newname = GT4LIB+'/'+basename\n if (copy)\n puts 'cp: \\'' + file + '\\' to: \\'' + newname + '\\''\n cp(file, newname)\n puts 'yay'\n chmod 0644, newname\n else\n puts 'ln_sf: \\'' + file + '\\' to: \\'' + newname + '\\''\n chmod 0644, file\n ln_sf(file, newname)\n end\n depsFile.syswrite(basename + \"\\n\") \n classpathFile.syswrite('<pathelement location=\"' + basename + '\" />' + \"\\n\")\n }\n depsFile.close\n classpathFile.syswrite('</path></target></project>' + \"\\n\\n\")\n classpathFile.close\n end",
"def build(rakeTask)\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes a non-file prereq task\n\t\t\tstaticLibMaintainer().addOrUpdate(:lib => target(), :objs => filePrereqs)\n\t\t\tstaticLibMaintainer().index(target())\n\t\tend\n\tend",
"def compile_project\n debug_msg \" compiling #{@project_name}\"\n system(HHC_PATH, @project_name)\n end",
"def custom\n Athenry::build.target(\"install_pkgmgr\", \"update_everything\", \"rebuild\", \"update_configs\", \"install_overlays\", \"install_sets\", \"rebuild\")\n end",
"def build\n safesystem \"autoreconf -vfi\"\n configure :prefix => prefix\n make\n end",
"def configure(project)\n @project = project\n printf 'checking for a BSD-compatible install.. '\n if Platform.is_windows?\n puts 'not found'\n else\n @path = search() or throw 'No installer found'\n printf @path + \"\\n\"\n end\n end",
"def build(project_name, auto_install, proxy_option)\n # On verifie la presence de flog\n Utils.verify_gem_presence(\"flog\", auto_install, proxy_option)\n require 'rubygems'\n require 'flog'\n # On lance la generation\n puts \" Building flog report...\"\n FileUtils.mkdir(\"#{Continuous4r::WORK_DIR}/flog\")\n files = Array.new\n files << Dir.glob(\"app/**/*.rb\")\n files << Dir.glob(\"lib/**/*.rb\")\n files << Dir.glob(\"test/**/*.rb\")\n files << Dir.glob(\"spec/**/*.rb\")\n files.flatten!\n files.each do |filename|\n puts \"Processing #{filename}...\"\n begin\n flogger = Flog.new(\"-a -c -d\")\n flogger.flog(filename)\n output_dir = \"#{Continuous4r::WORK_DIR}/flog/#{filename.split(\"/\")[0..-2].join(\"/\")}\"\n FileUtils.mkdir_p(output_dir, :verbose => false) unless File.directory?(output_dir)\n output_flog_file = File.open(\"#{Continuous4r::WORK_DIR}/flog/#{filename.split('.')[0]}.txt\", \"w\")\n flogger.report(output_flog_file)\n output_flog_file.close\n rescue Exception => e\n puts \"Error processing #{filename} : #{e.to_s}\"\n end\n end\n pages = Array.new\n Dir.glob(\"#{Continuous4r::WORK_DIR}/flog/**/*.txt\").each do |filename|\n page = parse(File.read(filename))\n if page\n page.filename = filename\n pages << page\n end\n end\n pages.each do |page|\n save_html(page.to_html, page.path)\n end\n save_html(ERB.new(File.read(File.join(File.dirname(__FILE__), \"site/flog.html.erb\"))).result(binding))\n end",
"def build\n if phase.has_key?('build')\n execute(\"build\", phase['build'])\n end\n end",
"def initialize(programName, build, config)\n @programName = Makr.cleanPathName(programName)\n super(ProgramTask.makeName(@programName), config)\n @build = build\n\n # first we make dependency on the target program file\n @targetDep = @build.getOrMakeNewTask(@programName) {FileTask.new(@programName, false)}\n addDependencyUnique(@targetDep)\n @targets = [@programName]\n\n # now add another dependency task on the config\n @configDep = @build.getOrMakeNewTask(ConfigTask.makeName(@name)) {ConfigTask.new(ConfigTask.makeName(@name))}\n addDependencyUnique(@configDep)\n\n @extraStaticLibs = Array.new # for static libs specified by user\n @useStaticLibsGroup = true\n @useGoldLinker = false\n\n Makr.log.debug(\"made ProgramTask with @name=\\\"\" + @name + \"\\\"\")\n end",
"def copy_project_dependencies_for_awestruct_image\n\n puts \"- Copying project dependencies into '_docker/awestruct' for build...\"\n\n parent_gemfile = File.open '../Gemfile'\n parent_gemlock = File.open '../Gemfile.lock'\n\n target_gemfile = FileHelpers.open_or_new('awestruct/Gemfile')\n target_gemlock = FileHelpers.open_or_new('awestruct/Gemfile.lock')\n #Only copy if the file has changed. Otherwise docker won't cache optimally\n FileHelpers.copy_if_changed(parent_gemfile, target_gemfile)\n FileHelpers.copy_if_changed(parent_gemlock, target_gemlock)\n\n puts \"- Successfully copied project dependencies into '_docker/awestruct' for build.\"\n\nend",
"def deploy\n unless ITEMS[:project].has_value? SETTINGS[:project]\n raise \"Invalid project: #{SETTINGS[:project]}.\"\n end\n\n # Call the original deploy method.\n orig_deploy\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"
] | [
"0.56846815",
"0.55912864",
"0.5513589",
"0.5494061",
"0.5298636",
"0.52209896",
"0.51895136",
"0.51471674",
"0.51296264",
"0.51296264",
"0.51268595",
"0.5103079",
"0.50922805",
"0.50228286",
"0.50168514",
"0.5005818",
"0.5002301",
"0.5002301",
"0.4996874",
"0.49364513",
"0.49161083",
"0.48834077",
"0.48670208",
"0.48647183",
"0.48579007",
"0.4843253",
"0.48410544",
"0.4837198",
"0.48107737",
"0.4789447"
] | 0.6949515 | 0 |
Tries to reconcile the makefile with the platform by resolving unmet dependencies and determining which projects must be installed, upgraded, downgraded, moved or removed. This method does not return anything. The result of the synchronization can be inspected by accessing Drupid::Updaterlog. This method does not modify the platform at all, it only preflights changes and caches the needed stuff locally. For changes to be applied, Drupid::Updaterapply_changes must be invoked after this method has been invoked. If :nofollow is set to true, then this method does not try to resolve missing dependencies: it only checks the projects that are explicitly mentioned in the makefile. If :nocore is set to true, only contrib projects are synchronized; otherwise, Drupal core is synchronized, too. See also: Drupid::Updaterapply_changes Options: nofollow, nocore, nolibs | def sync(options = {})
@log.clear
@platform.analyze
# These paths are needed because Drupal allows libraries to be installed
# inside modules. Hence, we must ignore them when synchronizing those modules.
@makefile.each_library do |l|
@libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path
end
# We always need a local copy of Drupal core (either the version specified
# in the makefile or the latest version), even if we are not going to
# synchronize the core, in order to extract the list of core projects.
if get_drupal
if options[:nocore]
blah "Skipping core"
else
sync_drupal_core
end
else
return
end
sync_projects(options)
sync_libraries unless options[:nolibs]
# Process derivative builds
@derivative_builds.each do |updater|
updater.sync(options.merge(:nocore => true))
@log.merge(updater.log)
end
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_projects(options = {})\n exclude(@core_projects) # Skip core projects\n processed = Array.new(excluded) # List of names of processed projects\n dep_queue = Array.new # Queue of Drupid::Project objects whose dependencies must be checked. This is always a subset of processed.\n\n @makefile.each_project do |makefile_project|\n dep_queue << makefile_project if sync_project(makefile_project)\n processed += makefile_project.extensions\n end\n\n unless options[:nofollow]\n # Recursively get dependent projects.\n # An invariant is that each project in the dependency queue has been processed\n # and cached locally. Hence, it has a version and its path points to the\n # cached copy.\n while not dep_queue.empty? do\n project = dep_queue.shift\n project.dependencies.each do |dependent_project_name|\n unless processed.include?(dependent_project_name)\n debug \"Queue dependency: #{dependent_project_name} <- #{project.extended_name}\"\n new_project = Project.new(dependent_project_name, project.core)\n dep_queue << new_project if sync_project(new_project)\n @makefile.add_project(new_project)\n processed += new_project.extensions\n end\n end\n end\n end\n\n # Determine projects that should be deleted\n pending_delete = @platform.project_names - processed\n pending_delete.each do |p|\n proj = platform.get_project(p)\n log.action(DeleteAction.new(platform, proj))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing deletion.\"\n else\n log.error \"#{proj.extended_name}: use --force to force deletion or install Drush >=6.0.\"\n end\n elsif proj.installed?(site)\n if @force_changes\n owarn \"Deleting an installed/enabled project.\"\n else\n log.error \"#{proj.extended_name} cannot be deleted because it is installed\"\n end\n end\n end\n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def up_to_date?(targets, command, deps, env, options = {})\n Array(targets).each do |target|\n cache_key = get_cache_key(target)\n\n unless Rscons.phony_target?(target)\n # target file must exist on disk\n unless File.exist?(target)\n if options[:debug]\n puts \"Target #{target} needs rebuilding because it does not exist on disk\"\n end\n return false\n end\n end\n\n # target must be registered in the cache\n unless @cache[\"targets\"].has_key?(cache_key)\n if options[:debug]\n puts \"Target #{target} needs rebuilding because there is no cached build information for it\"\n end\n return false\n end\n\n unless Rscons.phony_target?(target)\n # target must have the same checksum as when it was built last\n unless @cache[\"targets\"][cache_key][\"checksum\"] == lookup_checksum(target)\n if options[:debug]\n puts \"Target #{target} needs rebuilding because it has been changed on disk since being built last\"\n end\n return false\n end\n end\n\n # command used to build target must be identical\n unless @cache[\"targets\"][cache_key][\"command\"] == Digest::MD5.hexdigest(command.inspect)\n if options[:debug]\n puts \"Target #{target} needs rebuilding because the command used to build it has changed\"\n end\n return false\n end\n\n cached_deps = @cache[\"targets\"][cache_key][\"deps\"] || []\n cached_deps_fnames = cached_deps.map { |dc| dc[\"fname\"] }\n if options[:strict_deps]\n # depedencies passed in must exactly equal those in the cache\n unless deps == cached_deps_fnames\n if options[:debug]\n puts \"Target #{target} needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies\"\n end\n return false\n end\n else\n # all dependencies passed in must exist in cache (but cache may have more)\n unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?\n if options[:debug]\n puts \"Target #{target} needs rebuilding because there are new dependencies\"\n end\n return false\n end\n end\n\n # set of user dependencies must match\n user_deps = env.get_user_deps(target) || []\n cached_user_deps = @cache[\"targets\"][cache_key][\"user_deps\"] || []\n cached_user_deps_fnames = cached_user_deps.map { |dc| dc[\"fname\"] }\n unless user_deps == cached_user_deps_fnames\n if options[:debug]\n puts \"Target #{target} needs rebuilding because the set of user-specified dependency files has changed\"\n end\n return false\n end\n\n # all cached dependencies must have their checksums match\n (cached_deps + cached_user_deps).each do |dep_cache|\n unless dep_cache[\"checksum\"] == lookup_checksum(dep_cache[\"fname\"])\n if options[:debug]\n puts \"Target #{target} needs rebuilding because dependency file #{dep_cache[\"fname\"]} has changed\"\n end\n return false\n end\n end\n end\n\n true\n end",
"def apply_changes(options = {})\n raise \"No changes can be applied because there are errors.\" if log.errors? and not options[:force]\n log.apply_pending_actions\n @derivative_builds.each { |updater| updater.apply_changes(options.merge(:no_lockfile => true)) }\n @log.clear\n @derivative_builds.clear\n end",
"def _compare_versions(makefile_project, platform_project)\n update_action = UpdateProjectAction.new(platform, makefile_project)\n case makefile_project <=> platform_project\n when 0 # up to date\n # Check whether the content of the projects is consistent\n begin\n diff = makefile_project.file_level_compare_with platform_project\n rescue => ex\n odie \"Failed to verify the integrity of #{makefile_project.extended_name}: #{ex}\"\n end\n p = (makefile_project.drupal?) ? '' : ' (' + (platform.contrib_path + makefile_project.target_path).to_s + ')'\n if diff.empty?\n @log.notice(\"#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}\")\n elsif makefile_project.has_patches?\n log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Patched'))\n log.notice \"#{makefile_project.extended_name}#{p} will be patched\"\n log.notice(diff.join(\"\\n\"))\n else\n log.action(update_action)\n if @force_changes\n owarn \"Mismatch with cached copy: overwriting local copy.\"\n else\n log.error(\"#{platform_project.extended_name}#{p}: mismatch with cached copy:\\n\" + diff.join(\"\\n\"))\n end\n end\n when 1 # upgrade\n log.action(update_action)\n when -1 # downgrade\n log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Update'))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing downgrade.\"\n else\n log.error(\"#{platform_project.extended_name}: use --force to downgrade or install Drush >=6.0.\")\n end\n elsif platform_project.drupal?\n if @platform.bootstrapped?\n if @force_changes\n owarn \"Downgrading a bootstrapped Drupal platform.\"\n else\n log.error(\"#{platform_project.extended_name} cannot be downgraded because it is bootstrapped (use --force to override)\")\n end\n end\n elsif platform_project.installed?(site)\n if @force_changes\n owarn \"Downgrading an installed/enabled project.\"\n else\n log.error(\"#{platform_project.extended_name}#{p} must be uninstalled before downgrading (use --force to override)\")\n end\n end\n when nil # One or both projects have no version\n # Check whether the content of the projects is consistent\n begin\n diff = makefile_project.file_level_compare_with platform_project\n rescue => ex\n odie \"Failed to verify the integrity of #{component.extended_name}: #{ex}\"\n end\n if diff.empty?\n log.notice(\"#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}\")\n else\n log.action(update_action)\n log.notice(diff.join(\"\\n\"))\n if platform_project.has_version? and (not makefile_project.has_version?)\n if @force_changes\n owarn \"Upgrading #{makefile_project.name} to unknown version.\"\n else\n log.error(\"Cannot upgrade #{makefile_project.name} from known version to unknown version\")\n end\n end\n end\n end\n end",
"def all\n fetch\n FileUtils.cd File.dirname(__FILE__) do\n uncommitted_chamges = `git diff`.strip\n ahead_origin = `git log origin/master...HEAD --right-only 2> /dev/null | grep '^commit'`.strip\n behind_origin = `git log origin/master...HEAD --left-only 2> /dev/null | grep '^commit'`.strip\n\n if uncommitted_chamges != \"\"\n say \"You have uncommitted changes in your local tree. Cannot automatically upgrade.\"\n elsif ahead_origin != \"\"\n say \"You have unpushed changes in your local tree. Cannot automatically upgrade.\"\n elsif options[:force] || behind_origin != \"\"\n say \"You are missing some upstream changes.\"\n if options[:force] || !no?(\"Would you like to upgrade? (Y/n)\")\n run \"git pull origin master\"\n end\n else\n say \"No upstream changes to pull\"\n end\n end\n end",
"def sync_project(project)\n return false unless _fetch_and_patch(project)\n\n # Does this project contains a makefile? If so, enqueue a derivative build.\n has_makefile = prepare_derivative_build(project)\n\n # Ignore libraries that may be installed inside this project\n pp = @platform.local_path + @platform.dest_path(project)\n @libraries_paths.each do |lp|\n if lp.fnmatch?(pp.to_s + '/*')\n project.ignore_path(lp.relative_path_from(pp))\n @log.notice(\"Ignoring #{project.ignore_paths.last} inside #{project.extended_name}\")\n end\n end\n\n # Does the project exist in the platform? If so, compare the two.\n if @platform.has_project?(project.name)\n platform_project = @platform.get_project(project.name)\n # Fix project location\n new_path = @platform.dest_path(project)\n if @platform.local_path + new_path != platform_project.local_path\n log.action(MoveAction.new(@platform, platform_project, new_path))\n if (@platform.local_path + new_path).exist?\n if @force_changes\n owarn \"Overwriting existing path: #{new_path}\"\n else\n log.error(\"#{new_path} already exists. Use --force to overwrite.\")\n end\n end\n end\n # Compare versions and log suitable actions\n _compare_versions project, platform_project\n else\n # If analyzing the platform does not allow us to detect the project (e.g., Fusion),\n # we try to see if the directory exists where it is supposed to be.\n proj_path = @platform.local_path + @platform.dest_path(project)\n if proj_path.exist?\n begin\n platform_project = PlatformProject.new(@platform, proj_path)\n _compare_versions project, platform_project\n rescue => ex\n log.action(UpdateProjectAction.new(@platform, project))\n if @force_changes\n owarn \"Overwriting existing path: #{proj_path}\"\n else\n log.error(\"#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}\")\n end\n end\n else # new project\n log.action(InstallProjectAction.new(@platform, project))\n end\n end\n return (not has_makefile)\n end",
"def updateDeps(rakeTask)\n\t\t#no-op\n\tend",
"def updateDeps(rakeTask)\n\t\treturn true\n\tend",
"def updateDeps(rakeTask)\n\t\treturn true\n\tend",
"def prepare_derivative_build(project)\n mf = project.makefile\n return false if mf.nil?\n debug \"Preparing derivative build for #{mf.basename}\"\n submake = Makefile.new(mf)\n subplatform = Platform.new(@platform.local_path)\n subplatform.contrib_path = @platform.dest_path(project)\n new_updater = Updater.new(submake, subplatform, site)\n new_updater.exclude(project.extensions)\n new_updater.exclude(@platform.profiles)\n @derivative_builds << new_updater\n return true\n end",
"def add_standard_buildr_tasks\n add_standard_bundler_tasks\n desc 'Download all artifacts application if buildfile'\n command(:buildr_artifacts) do\n if File.exist?('buildfile')\n begin\n rbenv_exec('buildr artifacts:sources artifacts clean')\n rescue\n # ignored\n end\n end\n end\n\n desc 'Propose an update to dependency for all downstream projects in a automerge branch. Specify parameters DEPENDENCIES and VERSION'\n command(:propose_dependency_update, :in_app_dir => false) do |app|\n dependencies = Zim::Config.parameter_by_name('DEPENDENCIES').split(',')\n target_version = Zim::Config.parameter_by_name('VERSION')\n branch_key = Zim::Config.parameters['BRANCH_KEY'] || ''\n\n run(:real_clean, app)\n in_app_dir(app) do\n branches = (Zim.current_suite.application_by_name(app).tag_value('zim:branches') || current_default_branch).split(',')\n branches.each do |branch|\n git_checkout(branch)\n propose_dependency_update(app, branch_key, dependencies, target_version, branch)\n end\n end\n end\n end",
"def updateDeps(rakeTask)\n\t\tprevLinkDeps = []\n\t\tlinkDeps = linkDepsOrdered() - [mainObjFilepath()]\n\t\twhile !(linkDeps - prevLinkDeps).empty?()\n\t\t\t(linkDeps - prevLinkDeps).each do |dep|\n\t\t\t\tif BuildEnv::isBuilt?(dep)\n\t\t\t\t\tRake::Task[Builder::updateDepsTaskName(dep)].invoke()\n\t\t\t\tend\n\t\t\tend\n\t\t\tprevLinkDeps = linkDeps\n\t\t\tlinkDeps = linkDepsOrdered() - [mainObjFilepath()]\n\t\tend\n\n\t\tlinkDeps.each {|dep| addPrereq dep}\n\t\tbuildTask = Rake::Task[\"#{target()}\"]\n\t\tbuildTask.reenable()\n\t\tbuildTask.invoke() #run again, starting with our updated prereqs list\n\tend",
"def resolve_dependencies!\n return unless Config.resolve? && targets.any?\n\n puts 'resolving dependencies...'\n each_threaded(targets) do |target|\n Depends.resolve(target, self)\n end\n end",
"def check!\n # does not inherit any dependencies (super.check will inherit)\n Dependencies.new(configuration) do |d|\n d.remote.directory(configuration[:deploy_to]).or(\"`#{configuration[:deploy_to]}' does not exist.\")\n d.remote.writable(configuration[:deploy_to], :via => :sudo).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n d.remote.command(\"svn\")\n d.remote.match(\"cd #{repository_dir}; svn info|grep URL\", configuration[:repository])\n end\n end",
"def define_perforce_tasks\n warn :define_perforce_tasks if $DEBUG\n\n desc \"branch the project from dev to version dir\"\n task :branch do\n original_dir = File.basename(Dir.pwd)\n\n Dir.chdir \"..\"\n\n target_dir = File.directory?(version) ? version : original_dir\n branching = target_dir == original_dir && target_dir != version\n pkg = File.basename(Dir.pwd)\n\n begin\n p4_integrate original_dir, version if branching\n validate_manifest_file version\n p4_submit \"Branching #{pkg} to version #{version}\" if branching\n rescue => e\n warn e\n p4_revert version\n raise e\n end\n\n Dir.chdir version\n end\n\n task :prerelease => :branch\n\n task :postrelease => :announce do\n system 'rake clean'\n end\n\n desc \"Generate historical flog/flay data for all releases\"\n task :history do\n p4_history\n end\n end",
"def install_build_dependencies(build_dependencies) # rubocop:disable Metrics/AbcSize\n http = []\n pkgutil = []\n noasks = [\"instance=overwrite\", \"partial=nocheck\", \"runlevel=nocheck\", \"idepend=nocheck\", \"rdepend=nocheck\", \"space=nocheck\", \"setuid=nocheck\", \"conflict=nocheck\", \"action=nocheck\", \"basedir=default\"]\n noask_command = noasks.map { |noask| \"echo '#{noask}' >> /var/tmp/noask\" }.join('; ')\n\n build_dependencies.each do |build_dependency|\n if build_dependency =~ /^http.*\\.gz/\n # Fetch, unpack, install...this assumes curl is present.\n package = build_dependency.sub(/^http.*\\//, '')\n http << \"tmpdir=$(#{mktemp}); (cd ${tmpdir} && curl --silent --show-error --fail -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)\"\n else\n # Opencsw dependencies. At this point we assume that pkgutil is installed.\n pkgutil << build_dependency\n end\n end\n\n command = ''\n unless pkgutil.empty?\n command << \"/opt/csw/bin/pkgutil -y -i #{pkgutil.join(\"\\s\")}; \"\n end\n\n unless http.empty?\n command << \"echo -n > /var/tmp/noask; #{noask_command}; \"\n command << http.join('; ')\n end\n\n command\n end",
"def update\n unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist?($VP + 'no-update')\n system('git fetch origin') if Time.now - File.mtime($VP + '.git/FETCH_HEAD') > 604800 rescue nil\n end\nend",
"def should_build?\n return true if tagged_build?\n return should_build_nightly? if ENV['IS_NIGHTLY']\n\n # Find the oldest common revision between HEAD's parent and our\n # default branch.\n #\n # HEAD's parent may _be_ our default branch, or the commit before\n # `master` if we've forked to a branch off it. More than likely,\n # though, `HEAD^1` is some commit in our stream of history, and will\n # be sufficient to find the starting point of divergence, if such a\n # point exists.\n #\n # If HEAD is a merge commit on `master`, then HEAD^1 points to the\n # previous commit on `master`, which should clearly be completely\n # separate from the branch that was merged, and hence the fork point\n # will be the point of divergence.\n oldest_shared_revision = sh(\"git merge-base '#{DEFAULT_BRANCH}' 'HEAD^1'\")\n\n # Get all files that changed between the fork point and HEAD\n changed_files = git_log_between(oldest_shared_revision, 'HEAD').unique_lines\n\n # 1. Check if any packages we care about changed\n if changed_files.include?('package.json') &&\n npm_native_package_changed?(oldest_shared_revision, 'HEAD')\n puts \"some dependency matching #{NPM_DEP_NAME_REGEXP.inspect} changed\"\n return true\n end\n\n # 2. Check if any files we care about changed\n if native_file_changed?(changed_files)\n puts 'some native file changed'\n return true\n end\n\n # 3. If we haven't decided to build yet, we aren't going to.\n puts 'build skippable'\n false\nend",
"def _check_for_updates\n @update_info = CCProcess.complete(\"sdk-manage --target --upgradable '#{@name}'\")\n @last_update_check = Time.now\n rescue CCProcess::Failed\n \"\"\n end",
"def verify_and_repair(mode=:debug, verbose=false)\n valid_deps = find_dependencies rescue nil\n fetch_dependencies(verbose) if valid_deps.nil?\n rebuild_dependency_list nil, verbose\n rebuild_preview verbose\n end",
"def run!\n prune_ignored!\n\n if results.empty?\n # the only way we get here without having raised NoTargets is if\n # we're checking for upgrades and there were none.\n puts 'there is nothing to do'\n exit\n end\n\n puts ''\n puts \"#{yellow \"Targets (#{results.length}):\"} #{results.map(&:to_s).join(' ')}\"\n\n return unless prompt('Proceed with installation')\n\n results.each do |result|\n if Config.download?\n Download.new(result).download\n else\n Download.new(result).extract\n end\n end\n\n return unless Config.build?\n\n results.each do |result|\n Build.new(result.name).build\n end\n end",
"def remove_duplicate_dependencies(installer)\n \n applicationTargets = [\n 'Pods-Base-Project',\n ]\n libraryTargets = [\n 'Pods-AnalyticsManager',\n ]\n\n embedded_targets = installer.aggregate_targets.select { |aggregate_target|\n libraryTargets.include? aggregate_target.name\n }\n embedded_pod_targets = embedded_targets.flat_map { |embedded_target| embedded_target.pod_targets }\n host_targets = installer.aggregate_targets.select { |aggregate_target|\n applicationTargets.include? aggregate_target.name\n }\n\n # We only want to remove pods from Application targets, not libraries\n host_targets.each do |host_target|\n host_target.xcconfigs.each do |config_name, config_file|\n host_target.pod_targets.each do |pod_target|\n if embedded_pod_targets.include? pod_target\n pod_target.specs.each do |spec|\n if spec.attributes_hash['ios'] != nil\n frameworkPaths = spec.attributes_hash['ios']['vendored_frameworks']\n else\n frameworkPaths = spec.attributes_hash['vendored_frameworks']\n end\n if frameworkPaths != nil\n frameworkNames = Array(frameworkPaths).map(&:to_s).map do |filename|\n extension = File.extname filename\n File.basename filename, extension\n end\n frameworkNames.each do |name|\n puts \"Removing #{name} from OTHER_LDFLAGS of target #{host_target.name}\"\n config_file.frameworks.delete(name)\n end\n end\n end\n end\n end\n xcconfig_path = host_target.xcconfig_path(config_name)\n config_file.save_as(xcconfig_path)\n end\n end\n\nend",
"def common_build\n puts \"common_build dir=#{pwd} #{SHOES_TGT_ARCH}\"\n #mkdir_p \"#{TGT_DIR}/ruby\"\n #cp_r \"#{EXT_RUBY}/lib/ruby/#{RUBY_V}\", \"#{TGT_DIR}/ruby/lib\"\n %w[req/ftsearch/lib/* req/rake/lib/*].each do |rdir|\n FileList[rdir].each { |rlib| cp_r rlib, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}\" }\n end\n %w[req/ftsearch/ext/ftsearchrt req/chipmunk/ext/chipmunk].\n #%w[req/binject/ext/binject_c req/ftsearch/ext/ftsearchrt req/bloopsaphone/ext/bloops req/chipmunk/ext/chipmunk].\n each { |xdir| copy_ext xdir, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}/#{SHOES_TGT_ARCH}\" }\n\n gdir = \"#{TGT_DIR}/lib/ruby/gems/#{RUBY_V}\"\n {'hpricot' => 'lib', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n #{'hpricot' => 'lib', 'json' => 'lib/json/ext', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n spec = eval(File.read(\"req/#{gemn}/gemspec\"))\n mkdir_p \"#{gdir}/specifications\"\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/lib\"\n FileList[\"req/#{gemn}/lib/*\"].each { |rlib| cp_r rlib, \"#{gdir}/gems/#{spec.full_name}/lib\" }\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/#{xdir}\"\n FileList[\"req/#{gemn}/ext/*\"].each { |elib| copy_ext elib, \"#{gdir}/gems/#{spec.full_name}/#{xdir}\" }\n cp \"req/#{gemn}/gemspec\", \"#{gdir}/specifications/#{spec.full_name}.gemspec\"\n end\n end",
"def update_all_packages(options = {})\n return true if update_all_packages_impl(options)\n \n return false if options[:no_proxy]\n update_all_packages options.merge(:no_proxy => true)\n end",
"def update(*gem_names)\n target_gems = gem_names.select { |gem_name| installed?(gem_name) }\n return if target_gems.empty?\n\n run('update', *target_gems, '--conservative')\n end",
"def update\n ws.config.interactive = false\n Autoproj::CLI::Update.new(ws).run(\n [], reset: :force,\n packages: true,\n config: true,\n deps: true,\n osdeps_filter_uptodate: true,\n osdeps: false\n )\n @update_failed = false\n true\n rescue StandardError => e\n # if this is true, the only thing the daemon\n # should do is update the workspace on push events,\n # no PR syncing and no triggering of builds\n # on PR events\n @update_failed = Time.now\n Autoproj.error e.message\n false\n end",
"def _install\n args = Array.new\n # If the project contains a makefile, it is a candidate for a derivative build.\n # In such case, protect 'libraries', 'modules' and 'themes' subdirectories\n # from deletion.\n if component.makefile\n args << '-f' << 'P /libraries/***' # this syntax requires rsync >=2.6.7.\n args << '-f' << 'P /modules/***'\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'P /themes/***'\n end\n if component.drupal?\n args = Array.new\n args << '-f' << 'R /profiles/default/***' # D6\n args << '-f' << 'R /profiles/minimal/***' # D7\n args << '-f' << 'R /profiles/standard/***' # D7\n args << '-f' << 'R /profiles/testing/***' # D7\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'R /sites/all/README.txt'\n args << '-f' << 'R /sites/default/default.settings.php'\n args << '-f' << 'P /sites/***'\n end\n args << '-a'\n args << '--delete'\n component.ignore_paths.each { |p| args << \"--exclude=#{p}\" }\n dst_path = platform.local_path + platform.dest_path(component)\n dont_debug { dst_path.mkpath }\n args << component.local_path.to_s + '/'\n args << dst_path.to_s + '/'\n begin\n runBabyRun 'rsync', args\n rescue => ex\n odie \"Installing or updating #{component.name} failed: #{ex}\"\n end\n end",
"def fetch_update\n remote_branch = ErrorEmittingExecutor.execute(\"git branch -r --list origin/#{BRANCH_NAME}\")\n if remote_branch == 'origin/cocina-level2-updates'\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS} #{GIT_BRANCH_FETCH_REFS}\")\n else\n ErrorEmittingExecutor.execute(\"git fetch origin #{GIT_MAIN_FETCH_REFS}\", exit_on_error: true)\n end\nend",
"def apply\n debug \"Applying patch at #{Dir.pwd}\"\n raise \"Patch not fetched.\" if !(@cached_location and @cached_location.exist?)\n patch_levels = ['-p1', '-p0']\n patched = false\n output = ''\n # First try with git apply\n patch_levels.each do |pl|\n begin\n runBabyRun 'git', ['apply', '--check', pl, @cached_location], :redirect_stderr_to_stdout => true\n runBabyRun 'git', ['apply', pl, @cached_location], :redirect_stderr_to_stdout => true\n patched = true\n break\n rescue => ex\n output << ex.to_s\n end\n end\n if not patched\n patch_levels.each do |pl|\n begin\n runBabyRun 'patch', ['--no-backup-if-mismatch', '-f', pl, '-d', Dir.pwd, '-i', @cached_location], :redirect_stderr_to_stdout => true\n patched = true\n break\n rescue => ex\n output << ex.to_s\n end\n end\n end\n if not patched\n if descr and descr != @cached_location.basename.to_s\n d = \" (#{descr})\"\n else\n d = ''\n end\n raise \"Patch #{@cached_location.basename}#{d} could not be applied.\\n\" + output\n end\n return true\n end"
] | [
"0.6326895",
"0.60620624",
"0.58456486",
"0.57640713",
"0.56247467",
"0.54863507",
"0.5342582",
"0.53028053",
"0.53020346",
"0.53020346",
"0.52525216",
"0.5239834",
"0.5223528",
"0.52124864",
"0.51764524",
"0.5151317",
"0.51455724",
"0.51380175",
"0.51168764",
"0.50993544",
"0.505994",
"0.50592124",
"0.5044882",
"0.5034423",
"0.50167626",
"0.5011719",
"0.50049853",
"0.49865746",
"0.49624407",
"0.49209332"
] | 0.68297696 | 0 |
Synchronizes Drupal core. Returns true if the synchronization is successful; returns false otherwise. | def sync_drupal_core
if @platform.drupal_project
_compare_versions @makefile.drupal_project, @platform.drupal_project
else
log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def sync!\n begin \n FileUtils.touch lock_file_name\n\n rsync_type = seq_complete? ? 'final' : 'partial'\n logger.info \"Starting #{rsync_type} rsync...\"\n\n source_dir = Shellwords.escape(\"#{run_dir}/\")\n dest_dir = Shellwords.escape(File.join(Conf.global_conf[:safe_location_dir], run_name))\n\n Rsync.run(source_dir, dest_dir, '-raP') do |result|\n\n if result.success?\n result.changes.each do |change|\n logger.info \"#{change.filename} (#{change.summary})\"\n end\n logger.info \"#{result.changes.count} change(s) sync'd.\"\n logger.info \"End of #{rsync_type} rsync.\"\n else\n raise Errors::RsyncProcessError.new(\n \"'rsync' exited with nonzero status (#{rsync_type} rsync), motivation: #{result.error}\")\n end\n end\n\n rescue => e\n logger.error \"#{e.class} encountered while performing the sync'ing step\"\n logger.error e.message\n logger.error \"trace:\\n#{e.backtrace.join(\"\\n\")}\"\n Mailer.notify_admins(self, 'sync', e)\n ensure\n FileUtils.rm lock_file_name if File.exists?(lock_file_name)\n end\n end",
"def updatedb\n ohai \"Updating Drupal database...\"\n blah \"Platform: #{self.platform.local_path}\"\n res = true\n site_list = (self.site) ? [self.site] : self.platform.site_names\n site_list.each do |s|\n site_path = self.platform.sites_path + s\n debug \"Site path: #{site_path}\"\n unless site_path.exist?\n debug \"Skipping #{site_path} because it does not exist.\"\n next\n end\n blah \"Updating site: #{s}\"\n res = Drush.updatedb(site_path) && res\n end\n return res\n end",
"def travis_sync\n res = $travis_conn.post 'user/453045/sync'\n res.travis_raise\n res.success?\nend",
"def sync\n run 'sync', :quiet => true\n end",
"def execute_sync\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Sync)\n end",
"def run_autosync\n begin\n self.status = _(\"Synchronizing organisations.\")\n self.update_organisation_cache\n \n self.status = _(\"Synchronizing worktime.\")\n self.update_worktime_cache\n \n self.status = _(\"Automatic synchronization done.\")\n rescue => e\n self.status = sprintf(_(\"Error while auto-syncing: %s\"), e.message)\n puts Knj::Errors.error_str(e)\n ensure\n @sync_thread = nil\n end\n end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def fsync\n end",
"def fsync\n end",
"def sync\n # We replicate our state to the management node(s)\n management_nodes = find_management_nodes\n management_nodes.each do |mng_node|\n remote_db = mng_node.get_node_db\n from_success = @our_node.replicate_from(local_node_db, mng_node, remote_db)\n to_success = @our_node.replicate_to(local_node_db, mng_node, remote_db)\n if from_success && to_success && !our_node.is_management\n break\n end\n end\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def sync\r\n\t\tsend('SYN', '0 0')\r\n\t\treturn 1\r\n\tend",
"def sync\n end",
"def sync\n end",
"def sync_data(class_name)\n sync_class = class_name.constantize\n sync_results = []\n threads = remote_nodes.collect do |node|\n # Thread the sync for each node so that one node failure does\n # not interfere with other nodes.\n Thread.fork do\n sync_results << begin\n sync_class.new(local_node, node).sync\n rescue\n # allow sync_class to log exception details\n false\n end\n end\n end\n threads.each(&:join)\n sync_results.all?\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def sync; end",
"def sync(_location_conf, _sync_existing)\n return false\n end",
"def ensure_sync_state\n unless @ensured_sync_state\n ReplicationInitializer.new(session).ensure_sync_state\n @ensured_sync_state = true\n end\n end",
"def sync\n announcing 'Syncing Portage Tree' do\n chroot 'sync'\n end\n send_to_state('build', 'sync')\n end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def insync?(is)\n return true\n end",
"def do_sync_up(api_client, data)\n if clab_id\n # update the linked clab record\n logger.info \"#{self} updating #{clab_obj}\"\n obj = api_client.public_send('put', clab_id, data)\n else\n # create a new clab record and link it\n logger.info \"#{self} creating new clab object\"\n obj = api_client.public_send('post', data)\n self.clab_id = obj['id']\n logger.info \"#{self} created #{clab_obj}\"\n end\n t = obj['lastUpdated']\n self.clab_last_update = t ? DateTime.iso8601(t).to_time : DUMMY_TIMESTAMP\n sync_success\n true\n rescue RuntimeError => e\n sync_fail e.to_s\n false\n end",
"def sync_project_members\n unless connection_to_cluster\n cluster.log(\"No connection to cluster\",project)\n return false\n end\n if project.active?\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n if member.allowed?\n cluster.log(\"\\t Access for #{member.login} is allowed\", project)\n activate_member(member, member_state_on_cluster)\n elsif member.suspended?\n cluster.log(\"\\t Access for #{member.login} is suspended\", project)\n suspend_member(member, member_state_on_cluster)\n elsif member.denied?\n cluster.log(\"\\t Access for #{member.login} is denied\", project)\n deactivate_member(member, member_state_on_cluster)\n end\n end\n elsif project.blocked? || project.suspended?\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n suspend_member(member, member_state_on_cluster)\n end\n else\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n drop_member(member, member_state_on_cluster)\n end\n end\n end"
] | [
"0.6161641",
"0.61300874",
"0.59196985",
"0.58364224",
"0.58020186",
"0.5712556",
"0.57095176",
"0.56359845",
"0.5625886",
"0.56258696",
"0.56258696",
"0.562284",
"0.562284",
"0.55773866",
"0.55654985",
"0.5514116",
"0.5500065",
"0.5500065",
"0.5480415",
"0.54795945",
"0.54795945",
"0.54795945",
"0.5444058",
"0.5433789",
"0.54310066",
"0.5408958",
"0.5403378",
"0.5391617",
"0.5364654",
"0.5339887"
] | 0.7660241 | 0 |
Synchronizes projects between the makefile and the platform. Options: nofollow | def sync_projects(options = {})
exclude(@core_projects) # Skip core projects
processed = Array.new(excluded) # List of names of processed projects
dep_queue = Array.new # Queue of Drupid::Project objects whose dependencies must be checked. This is always a subset of processed.
@makefile.each_project do |makefile_project|
dep_queue << makefile_project if sync_project(makefile_project)
processed += makefile_project.extensions
end
unless options[:nofollow]
# Recursively get dependent projects.
# An invariant is that each project in the dependency queue has been processed
# and cached locally. Hence, it has a version and its path points to the
# cached copy.
while not dep_queue.empty? do
project = dep_queue.shift
project.dependencies.each do |dependent_project_name|
unless processed.include?(dependent_project_name)
debug "Queue dependency: #{dependent_project_name} <- #{project.extended_name}"
new_project = Project.new(dependent_project_name, project.core)
dep_queue << new_project if sync_project(new_project)
@makefile.add_project(new_project)
processed += new_project.extensions
end
end
end
end
# Determine projects that should be deleted
pending_delete = @platform.project_names - processed
pending_delete.each do |p|
proj = platform.get_project(p)
log.action(DeleteAction.new(platform, proj))
if which('drush').nil?
if @force_changes
owarn "Forcing deletion."
else
log.error "#{proj.extended_name}: use --force to force deletion or install Drush >=6.0."
end
elsif proj.installed?(site)
if @force_changes
owarn "Deleting an installed/enabled project."
else
log.error "#{proj.extended_name} cannot be deleted because it is installed"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def sync_project(project)\n return false unless _fetch_and_patch(project)\n\n # Does this project contains a makefile? If so, enqueue a derivative build.\n has_makefile = prepare_derivative_build(project)\n\n # Ignore libraries that may be installed inside this project\n pp = @platform.local_path + @platform.dest_path(project)\n @libraries_paths.each do |lp|\n if lp.fnmatch?(pp.to_s + '/*')\n project.ignore_path(lp.relative_path_from(pp))\n @log.notice(\"Ignoring #{project.ignore_paths.last} inside #{project.extended_name}\")\n end\n end\n\n # Does the project exist in the platform? If so, compare the two.\n if @platform.has_project?(project.name)\n platform_project = @platform.get_project(project.name)\n # Fix project location\n new_path = @platform.dest_path(project)\n if @platform.local_path + new_path != platform_project.local_path\n log.action(MoveAction.new(@platform, platform_project, new_path))\n if (@platform.local_path + new_path).exist?\n if @force_changes\n owarn \"Overwriting existing path: #{new_path}\"\n else\n log.error(\"#{new_path} already exists. Use --force to overwrite.\")\n end\n end\n end\n # Compare versions and log suitable actions\n _compare_versions project, platform_project\n else\n # If analyzing the platform does not allow us to detect the project (e.g., Fusion),\n # we try to see if the directory exists where it is supposed to be.\n proj_path = @platform.local_path + @platform.dest_path(project)\n if proj_path.exist?\n begin\n platform_project = PlatformProject.new(@platform, proj_path)\n _compare_versions project, platform_project\n rescue => ex\n log.action(UpdateProjectAction.new(@platform, project))\n if @force_changes\n owarn \"Overwriting existing path: #{proj_path}\"\n else\n log.error(\"#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}\")\n end\n end\n else # new project\n log.action(InstallProjectAction.new(@platform, project))\n end\n end\n return (not has_makefile)\n end",
"def freeze_to_repository\n FileUtils.mkdir_p(File.dirname(output_dir))\n File.open(output_dir, 'w') {|fd| fd.puts repository}\n @out.puts \"Project skeleton #{name.inspect} \" <<\n \"has been frozen to #{repository.inspect}\"\n end",
"def connect_common_tasks\n desc \"Build the code narrative HTML\"\n ::Rake::Task.define_task(:codnar => \"codnar_weave\")\n desc \"Remove woven HTML documentation\"\n ::Rake::Task.define_task(\"clobber_codnar\") { rm_rf(@output) }\n ::Rake::Task.define_task(:clobber => \"clobber_codnar\")\n end",
"def sync\n announcing 'Syncing Portage Tree' do\n chroot 'sync'\n end\n send_to_state('build', 'sync')\n end",
"def sync_code_dir\n fs_commands = { 'commit': '{\"commit-all\": true}', 'force-sync': \"\" }\n fs_commands.each do |fs_cmd, data|\n curl = %W[\n curl\n -X POST\n --cert $(puppet config print hostcert)\n --key $(puppet config print hostprivkey)\n --cacert $(puppet config print localcacert)\n -H \"Content-type: application/json\"\n https://#{master}:8140/file-sync/v1/#{fs_cmd}\n -d '#{data}'\n ].join(\" \")\n\n on(master, curl)\n end\n end",
"def sync\n run 'sync', :quiet => true\n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def autorun_cmd(repo_name)\n [\"cp -Rf #{STARTDIR}/components/autogen/#{repo_name}/* .\",\n \"touch Makefile\"]\nend",
"def run_autosync\n begin\n self.status = _(\"Synchronizing organisations.\")\n self.update_organisation_cache\n \n self.status = _(\"Synchronizing worktime.\")\n self.update_worktime_cache\n \n self.status = _(\"Automatic synchronization done.\")\n rescue => e\n self.status = sprintf(_(\"Error while auto-syncing: %s\"), e.message)\n puts Knj::Errors.error_str(e)\n ensure\n @sync_thread = nil\n end\n end",
"def define_perforce_tasks\n warn :define_perforce_tasks if $DEBUG\n\n desc \"branch the project from dev to version dir\"\n task :branch do\n original_dir = File.basename(Dir.pwd)\n\n Dir.chdir \"..\"\n\n target_dir = File.directory?(version) ? version : original_dir\n branching = target_dir == original_dir && target_dir != version\n pkg = File.basename(Dir.pwd)\n\n begin\n p4_integrate original_dir, version if branching\n validate_manifest_file version\n p4_submit \"Branching #{pkg} to version #{version}\" if branching\n rescue => e\n warn e\n p4_revert version\n raise e\n end\n\n Dir.chdir version\n end\n\n task :prerelease => :branch\n\n task :postrelease => :announce do\n system 'rake clean'\n end\n\n desc \"Generate historical flog/flay data for all releases\"\n task :history do\n p4_history\n end\n end",
"def copy_files_to_target\n COMMON_RAMMER_FILES.each do |file|\n source = File.join(\"#{@gem_path}/lib/modules/common/\",file)\n FileUtils.cp(source,\"#{@project_name}\")\n $stdout.puts \"\\e[1;32m \\tcreate\\e[0m\\t#{file}\"\n end\n end",
"def sync_project_branches(repoName)\n projectBranches = get_repository_project_branches(repoName)\n projectBranches.each do |branch|\n self.log(INFO, repoName, \"Synchronize project branch #{branch}\")\n sync_addon_branch_to_blessed_repo(repoName, \"origin/#{branch}\", branch, true)\n end\n end",
"def setup_projects\n # noop\n end",
"def create_project\n unless options.force\n abort \"'#{project}' already exists\" if File.exist?( project ) \n end\n\n # copy over files from the master project data diretory in crate\n files = project_files\n files.keys.sort.each do |dir|\n mkdir dir\n files[dir].sort.each do |file|\n cp file \n end\n end\n end",
"def execute\n #require 'erb'\n\n root = Dir.pwd\n\n #has_profile = POM::Profile.find(root)\n has_profile = Dir.glob('profile{,.yml,.yaml,.rb}', File::FNM_CASEFOLD).first\n\n if has_profile and not $FORCE #if POM::Profile.find(root) and not $FORCE\n $stderr << \"PROFILE already exists. Use --force option to allow overwrite.\\n\"\n exit -1\n end\n\n require_rubygems\n\n require 'readme'\n require 'gemdo/gemspec'\n\n #prime = { \n # 'name' => File.basename(root),\n # 'version' => '0.0.0',\n # 'requires' => [],\n # 'summary' => \"FIX brief one line description here\",\n # 'contact' => \"FIX name <email> or uri\",\n # 'authors' => \"FIX names of authors here\",\n # 'repository' => \"FIX master public repo uri\"\n #}\n\n #current = Dir.glob('**/*', File::FNM_DOTMATCH)\n\n #if !File.exist?('.ruby')\n # File.open('.ruby', 'w'){|f| f << `ruby -v`}\n #end\n\n #has_package = Gemdo::Rubyspec.find(root)\n\n #if has_profile && !$FORCE\n # $stderr.puts \"Looks like your project is already built on a gemdo.\"\n # $stderr.puts \"To re-create the metadata files use the --force option.\"\n # return\n #end\n\n #name = File.basename(root)\n\n project = POM::Project.new(root)\n\n #name = project.name || File.basename(root)\n# profile = project.profile\n\n #if !has_package\n # #metadata.new_project\n # metadata.name = File.basename(root)\n # metadata.version = '0.0.0'\n # metadata.codename = 'FIXME A version codename is optional'\n #end\n\n# profile.summary = \"FIXME brief one line description here\"\n# profile.contact = \"FIXME name <#{ENV['EMAIL']}>\"\n# profile.authors << \"FIXME list of author's names here\"\n# profile.homepage = \"FIXME: http://your_website.org\"\n #profile.resources.repository = \"FIXME: master public repo uri\"\n\n if resources.empty?\n resources << Dir.glob('*.gemspec').first\n resources << Dir.glob('README{,.*}').first\n end\n\n resources.compact!\n\n resources.each do |file|\n case file\n when /\\.gemspec$/\n text = File.read(file)\n gemspec = /^---/.match(text) ? YAML.load(text) : Gem::Specification.load(file)\n project.import_gemspec(gemspec)\n when /^README/i\n readme = Readme.load(file)\n project.import_readme(readme)\n else\n text = File.read(file)\n obj = /^---/.match(text) ? YAML.load(text) : text\n case obj\n when ::Gem::Specification\n project.import_gemspec(obj)\n when String\n project.import_readme(obj)\n #when Hash\n #metadata.mesh(obj)\n else\n puts \"Cannot convert #{file} (skipped)\"\n end\n end\n end\n\n #project.root = root\n\n # load any meta entries that may already exist\n #project.reload unless options[:replace]\n\n #profile_file = profile.file ? profile.file : File.join(root,'PROFILE')\n\n #if $TRIAL\n #else\n # #if $FORCE or !(has_package or has_profile)\n # metadata.backup!\n # metadata.save! #(package_file)\n # #end\n #end\n\n text = project.profile.render\n \n if $TRIAL\n puts text\n else\n File.open('Profile', 'w'){ |f| f << text }\n\n puts \"'Profile' has been created or updated. Please review\"\n puts \"this file carefully and edit as needed.\\n\"\n end\n\n\n #diff = Dir.glob('**/*', File::FNM_DOTMATCH) - current\n #diff = diff.select{ |f| File.file?(f) }\n\n #if diff.empty?\n # puts \"Nothing has been done.\"\n #else\n # diff.each do |f|\n # puts \" #{f}\"\n # end\n #end\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def create_mirror\n puts \"## Create mirror for project #{@name}\"\n # TODO : Check that all required data is here!\n load_attributes\n\n @config = Ow2mirror::Config.new(@workspace, @name)\n @config.load_attributes\n\n puts \"### Attributes\"\n pp @attributes\n\n puts \"### Configuration\"\n pp @config\n\n puts \"### Clone\"\n puts \"- Mirroring stuff from #{@source_project} source project to #{@target_project}...\"\n cd(folder)\n\n puts \" - Working in the folder #{pwd}\"\n\n # Get the repositories with their name and gitorious git URL\n # TODO :Make it in a generic way (load class from name)...\n\n source = {}\n source[:username] = @config.attributes['source']['username']\n source[:password] = @config.attributes['source']['password']\n source[:url] = @config.attributes['source']['url']\n source[:project] = @attributes['source']\n source_client = Ow2mirror::Client::GitoriousClient.new(source)\n sources = source_client.repositories(@source_project)\n\n target = {}\n target[:username] = @config.attributes['destination']['username']\n target[:password] = @config.attributes['destination']['password']\n target[:url] = @config.attributes['destination']['url']\n target[:project] = @attributes['target']\n target_client = Ow2mirror::Client::GithubClient.new(target)\n\n puts \" - Retrieved the following repositories from sources:\"\n sources.each do |repository|\n puts \" - #{repository[:name]} @ #{repository[:giturl]}\"\n end\n\n repos = []\n\n # For each repository, create the new one on the destination host\n # TODO : Filter from user choices...\n puts \" - Process repositories:\"\n sources.each do |repository|\n cd(folder)\n\n name = repository[:name]\n git = repository[:giturl]\n\n puts \" - Working on repository #{name} - #{git}\"\n puts \" - Clone source locally into #{name}\"\n\n Ow2mirror::Command.git(\"clone --bare --mirror #{git}\")\n\n folder = repository_folder(name)\n\n puts \" - cd to #{folder}\"\n if File.directory?(repository_folder(repository)) and File.exist?(repository_folder(repository))\n # No folder means that something failed...\n end\n\n cd(folder)\n\n target_repo = (@prefix.nil? or @prefix.empty?) ? name : \"#{@prefix}-#{name}\"\n\n puts \" - Target repository is #{target_repo}\"\n\n remote = target_client.create(@attributes['target'], target_repo, \"Official mirror of OW2 repository #{name} hosted at #{git}\")\n Ow2mirror::Command.git(\"remote add #{@config.attributes['destination']['type']} #{remote}\")\n\n Ow2mirror::Command.git(\"config remote.#{@config.attributes['destination']['type']}.mirror true\")\n\n # cache repo\n repos << {:name => name, :source => git, :destination => remote}\n\n end\n\n puts \"#### Clone summary\"\n puts \"- Generated repositories:\"\n pp repos\n\n save\n save_repos repos\n\n @workspace.add_project(@name)\n\n mirror\n end",
"def check_overwrite(list)\n return if force?\n return if prompt?\n return if skip?\n #return if session.overwrite? # TODO: not so sure overwirte? option is a good idea.\n\n if newproject? && !output.glob('**/*').empty? # FIXME?\n abort \"New project isn't empty. Use --force, --skip or --prompt.\"\n end\n\n clobbers = []\n list.each do |action, loc, tname, fname, opts|\n tpath = loc + tname\n fpath = output + fname\n if fpath.file? #fpath.exist?\n clobbers << relative_to_output(fname)\n end\n end\n\n if !clobbers.empty?\n puts \" \" + clobbers.join(\"\\n \")\n abort \"These files would be overwritten. Use --force, --skip or --prompt.\" # TODO: implement --skip\n end\n end",
"def mirror\n puts \"## Mirror\"\n @config = Ow2mirror::Config.new(@workspace, @name)\n @config.load_attributes\n\n puts \"- Mirroring repositories for project #{@name}...\"\n repositories.each do |repository|\n puts \" - Mirroring repository #{repository}...\"\n mirror_repository(repository['name'])\n end\n end",
"def master!\n @master = true\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 print_usage\n\t\nprint <<OEM\nusage: codeSync [-v] <project file>\n\n -v Verbose output\n <project file> File that sets connection and sync settings (see example below)\n\n(version #{APP[:version]} - #{APP[:build]})\n\nThis is a mac utility that uses rsync to immediately synchronize file\nchanges to a server or remote computer, as you work.\n\nNOTE: Since it uses rsync to communicate with the server, it is important\nto setup private/public keys: http://bit.ly/PcTRK\n(IF YOU DO NOT you will be prompted for your password for each file change.)\n\nCodeSync uses a project file (see example below) for the server connection\nsettings and which directories to keep in sync.\n\nEXAMPLE PROJECT FILE\n\n # Server details\n server=\"remoteserver.com\"\n username=\"johndoe\"\n\n # Base directories to sync from/to\n remote_basedir=\"/home/johndoe/svn/\"\n local_basedir=\"/work/projects/remote\"\n\n # The directories to sync, relative to the base directories\n sync_dirs=[ \"/static/js\",\n \"/static/css\",\n \"/gui/jsp\" ] \n # sync_dirs=[ ] # This will sync the entire base directories\n\n # Directories to exclude, relative to the base directory\n # Example: If syncing the entire trunk, you can exclude the build directory\n # since it contains a lot of unnecessary and large files\n exclude_dirs = [ \"dist\", \"build\", \"_codegen\" ]\n\n # The contents of these directories will only sync \"up\" to the server.\n # This means the contents will never be downloaded from the server\n # but files added or changed locally will be sent to the server\n sync_up=[ \"/static/img\" ]\n\nOEM\n\nend",
"def preclean_project\n # Clean-up non-useful files (if any)\n clean_msg = `make clean 2>&1`\n @log_file.puts \"\\nNettoyage du répertoire :\\n\\n#{clean_msg}\"\n \n # I want to be sure...\n FileUtils::rm_f Dir.glob(\"*.o\")\n FileUtils::rm_f Dir.glob(\"*~\")\n end",
"def process_github_clones\n repos = get_github_repos_already_cloned\n repos.each do |r|\n # SMELL: does not work if the working copy directory does\n # not match the repo name\n clone_path = configatron.dir + r.name\n set_upstream(clone_path, r.parent.html_url)\n end\nend",
"def sync_libraries\n debug 'Syncing libraries'\n processed_paths = []\n @makefile.each_library do |lib|\n sync_library(lib)\n processed_paths << lib.target_path\n end\n # Determine libraries that should be deleted from the 'libraries' folder.\n # The above is a bit of an overstatement, as it is basically impossible\n # to detect a \"library\" in a reliable way. What we actually do is just\n # deleting \"spurious\" paths inside the 'libraries' folder.\n # Note also that Drupid is not smart enough to find libraries installed\n # inside modules or themes.\n Pathname.glob(@platform.libraries_path.to_s + '/**/*').each do |p|\n next unless p.directory?\n q = p.relative_path_from(@platform.local_path + @platform.contrib_path)\n # If q is not a prefix of any processed path, or viceversa, delete it\n if processed_paths.find_all { |pp| pp.fnmatch(q.to_s + '*') or q.fnmatch(pp.to_s + '*') }.empty?\n l = Library.new(p.basename)\n l.local_path = p\n log.action(DeleteAction.new(@platform, l))\n # Do not need to delete subdirectories\n processed_paths << q\n end\n end\n end",
"def publish(options={})\n options = options.rekey(&:to_s)\n\n raise \"no username\" unless username\n\n sitemap = options['sitemap'] || config.sitemap\n filter = options['filter'] || config.rsync_filter\n delete = options['delete'] || config.rsync_delete\n optargs = options['extra'] || config.rsync_extra\n\n case sitemap\n when Hash\n when Array\n sitemap.inject({}) do |h, (s, d)|\n h[s] = d; h\n end\n else\n sitemap = { sitemap.to_s => '.' }\n end\n\n sitemap.each do |from, to|\n if !File.directory?(from)\n raise ArgumentError, \"Non-existant publishing directory -- #{from}.\"\n end\n end\n\n sitemap.each do |source, subdir|\n if subdir and subdir != '.'\n destination = File.join(unixname, subdir)\n else\n destination = unixname\n end\n\n dir = source.to_s.chomp('/') + '/'\n url = \"#{username}@rubyforge.org:/var/www/gforge-projects/#{destination}\"\n\n op = [\"-rLvz\"] # maybe -p ?\n op << \"-n\" if trial?\n op << \"-v\" if not quiet?\n op << \"-q\" if quiet?\n op << \"--progress\" if trace?\n op << \"--del-after\" if delete\n op << optargs if optargs\n\n # custom filter\n op << \"--filter='. #{filter}'\" if filter\n\n # create special rubyforge filter (.rsync-filter), if needed.\n create_rsync_filter(source)\n\n # per dir-merge filter\n op << \"--filter=': .rsync-filter'\"\n\n op = op.flatten + [dir, url]\n\n cmd = \"rsync \" + op.join(' ') # \"rsync #{op.to_params}\"\n\n # rsync supports a trial mode. let it through?\n #if trial?\n # puts cmd\n #else\n system cmd #UploadUtils.rsync(options)\n #end\n end\n end",
"def commit_and_merge\n Dir.glob(\"**/*~\").each do |filename|\n if File.file?(filename)\n File.delete(filename)\n end\n end\n cd(@project_name) do\n now = Time.now.to_s\n g = Git.open('.')\n g.add('.')\n g.commit(\"generated #{now}\")\n g.branch('master').checkout\n\n # it's safer to have the user do the rebase so tell them how\n puts 'If the files on the \"generated\" branch are ok, then run:'\n puts\n puts ' git rebase generated master'\n puts\n puts 'to update your master branch with the new generated files.'\n puts 'Note, if there are merge problems, resolve them then run:'\n puts\n puts ' git rebase --continue'\n puts\n end\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def define_codnar_task\n @spec.files.each do |file|\n configurations = Rake.split_configurations(file)\n Codnar::Rake::SplitTask.new([ file ], configurations) unless configurations == []\n end\n Codnar::Rake::WeaveTask.new(\"doc/root.html\", @weave_configurations)\n end"
] | [
"0.6683863",
"0.56792456",
"0.55468845",
"0.55014586",
"0.53844863",
"0.53599584",
"0.5348983",
"0.5344964",
"0.5250378",
"0.52189976",
"0.5210855",
"0.51804537",
"0.51100457",
"0.506904",
"0.50681186",
"0.5058532",
"0.5052056",
"0.5048105",
"0.5027533",
"0.50235605",
"0.50130635",
"0.50008607",
"0.49722794",
"0.4963634",
"0.49289772",
"0.49267632",
"0.49179617",
"0.49162",
"0.49040836",
"0.4892166"
] | 0.6025582 | 1 |
Performs the necessary synchronization actions for the given project. Returns true if the dependencies of the given project must be synchronized, too; returns false otherwise. | def sync_project(project)
return false unless _fetch_and_patch(project)
# Does this project contains a makefile? If so, enqueue a derivative build.
has_makefile = prepare_derivative_build(project)
# Ignore libraries that may be installed inside this project
pp = @platform.local_path + @platform.dest_path(project)
@libraries_paths.each do |lp|
if lp.fnmatch?(pp.to_s + '/*')
project.ignore_path(lp.relative_path_from(pp))
@log.notice("Ignoring #{project.ignore_paths.last} inside #{project.extended_name}")
end
end
# Does the project exist in the platform? If so, compare the two.
if @platform.has_project?(project.name)
platform_project = @platform.get_project(project.name)
# Fix project location
new_path = @platform.dest_path(project)
if @platform.local_path + new_path != platform_project.local_path
log.action(MoveAction.new(@platform, platform_project, new_path))
if (@platform.local_path + new_path).exist?
if @force_changes
owarn "Overwriting existing path: #{new_path}"
else
log.error("#{new_path} already exists. Use --force to overwrite.")
end
end
end
# Compare versions and log suitable actions
_compare_versions project, platform_project
else
# If analyzing the platform does not allow us to detect the project (e.g., Fusion),
# we try to see if the directory exists where it is supposed to be.
proj_path = @platform.local_path + @platform.dest_path(project)
if proj_path.exist?
begin
platform_project = PlatformProject.new(@platform, proj_path)
_compare_versions project, platform_project
rescue => ex
log.action(UpdateProjectAction.new(@platform, project))
if @force_changes
owarn "Overwriting existing path: #{proj_path}"
else
log.error("#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}")
end
end
else # new project
log.action(InstallProjectAction.new(@platform, project))
end
end
return (not has_makefile)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_saved?\n begin \n @project.transaction do\n # validations\n ensure_unique_project_name!\n ensure_unique_tasks_names! \n # save\n save_project!\n save_tasks!\n end\n return true \n rescue Exception => e\n return false\n end \n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def sync_project_members\n unless connection_to_cluster\n cluster.log(\"No connection to cluster\",project)\n return false\n end\n if project.active?\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n if member.allowed?\n cluster.log(\"\\t Access for #{member.login} is allowed\", project)\n activate_member(member, member_state_on_cluster)\n elsif member.suspended?\n cluster.log(\"\\t Access for #{member.login} is suspended\", project)\n suspend_member(member, member_state_on_cluster)\n elsif member.denied?\n cluster.log(\"\\t Access for #{member.login} is denied\", project)\n deactivate_member(member, member_state_on_cluster)\n end\n end\n elsif project.blocked? || project.suspended?\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n suspend_member(member, member_state_on_cluster)\n end\n else\n project.members.each do |member|\n member_state_on_cluster = check_member_state_on_cluster(member)\n drop_member(member, member_state_on_cluster)\n end\n end\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def check_project\n return if project.dataset_names.empty?\n return unless project.done_preprocessing?(false)\n to_run = project.next_distances(true)\n to_run = project.next_inclade(true) if to_run.nil?\n queue_job(to_run) unless to_run.nil?\n end",
"def sync_projects(options = {})\n exclude(@core_projects) # Skip core projects\n processed = Array.new(excluded) # List of names of processed projects\n dep_queue = Array.new # Queue of Drupid::Project objects whose dependencies must be checked. This is always a subset of processed.\n\n @makefile.each_project do |makefile_project|\n dep_queue << makefile_project if sync_project(makefile_project)\n processed += makefile_project.extensions\n end\n\n unless options[:nofollow]\n # Recursively get dependent projects.\n # An invariant is that each project in the dependency queue has been processed\n # and cached locally. Hence, it has a version and its path points to the\n # cached copy.\n while not dep_queue.empty? do\n project = dep_queue.shift\n project.dependencies.each do |dependent_project_name|\n unless processed.include?(dependent_project_name)\n debug \"Queue dependency: #{dependent_project_name} <- #{project.extended_name}\"\n new_project = Project.new(dependent_project_name, project.core)\n dep_queue << new_project if sync_project(new_project)\n @makefile.add_project(new_project)\n processed += new_project.extensions\n end\n end\n end\n end\n\n # Determine projects that should be deleted\n pending_delete = @platform.project_names - processed\n pending_delete.each do |p|\n proj = platform.get_project(p)\n log.action(DeleteAction.new(platform, proj))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing deletion.\"\n else\n log.error \"#{proj.extended_name}: use --force to force deletion or install Drush >=6.0.\"\n end\n elsif proj.installed?(site)\n if @force_changes\n owarn \"Deleting an installed/enabled project.\"\n else\n log.error \"#{proj.extended_name} cannot be deleted because it is installed\"\n end\n end\n end\n end",
"def project?\n true\n end",
"def passes_consistency_check?(user)\n if private?\n if independent?\n project == user.private_files_project\n else\n project == user.private_comparisons_project\n end\n elsif public?\n project == user.public_files_project\n elsif ![STATE_CLOSED, STATE_COPYING].include?(state)\n project == space_object.project_for_user(user)\n else\n true\n end\n end",
"def perform(organization, opts)\n return unless organization.sync_enabled\n\n # Check if previous synchronization is still running\n if Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now)).exists?\n ConnectorLogger.log('info', organization, \"Synchronization skipped: Previous synchronization is still running\")\n return\n end\n\n # Check if recovery mode: last 3 synchronizations have failed\n if !opts[:forced] && organization.last_three_synchronizations_failed? \\\n && organization.synchronizations.order(created_at: :desc).limit(1).first.updated_at > 1.day.ago\n ConnectorLogger.log('info', organization, \"Synchronization skipped: Recovery mode (three previous synchronizations have failed)\")\n return\n end\n\n # Trigger synchronization\n ConnectorLogger.log('info', organization, \"Start synchronization, opts=#{opts}\")\n current_synchronization = Synchronization.create_running(organization)\n\n begin\n last_synchronization = organization.last_successful_synchronization\n connec_client = Maestrano::Connec::Client[organization.tenant].new(organization.uid)\n external_client = External.get_client(organization)\n\n if opts[:only_entities]\n ConnectorLogger.log('info', organization, \"Synchronization is partial and will synchronize only #{opts[:only_entities].join(' ')}\")\n # The synchronization is marked as partial and will not be considered as the last-synchronization for the next sync\n current_synchronization.set_partial\n opts[:only_entities].each do |entity|\n sync_entity(entity, organization, connec_client, external_client, last_synchronization, opts)\n end\n else\n organization.synchronized_entities.select{|k, v| v}.keys.each do |entity|\n sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization, opts)\n end\n end\n\n ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=success\")\n current_synchronization.set_success\n rescue => e\n ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=error, message=#{e.message} backtrace=#{e.backtrace.join(\"\\n\\t\")}\")\n current_synchronization.set_error(e.message)\n end\n end",
"def belongs_to_project?(project)\n (source_type == \"project\") &&\n (project_id == project.id)\n end",
"def updateDeps(rakeTask)\n\t\treturn true\n\tend",
"def updateDeps(rakeTask)\n\t\treturn true\n\tend",
"def insync?(is)\n is.sort! == should.sort!\n end",
"def _compare_versions(makefile_project, platform_project)\n update_action = UpdateProjectAction.new(platform, makefile_project)\n case makefile_project <=> platform_project\n when 0 # up to date\n # Check whether the content of the projects is consistent\n begin\n diff = makefile_project.file_level_compare_with platform_project\n rescue => ex\n odie \"Failed to verify the integrity of #{makefile_project.extended_name}: #{ex}\"\n end\n p = (makefile_project.drupal?) ? '' : ' (' + (platform.contrib_path + makefile_project.target_path).to_s + ')'\n if diff.empty?\n @log.notice(\"#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}\")\n elsif makefile_project.has_patches?\n log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Patched'))\n log.notice \"#{makefile_project.extended_name}#{p} will be patched\"\n log.notice(diff.join(\"\\n\"))\n else\n log.action(update_action)\n if @force_changes\n owarn \"Mismatch with cached copy: overwriting local copy.\"\n else\n log.error(\"#{platform_project.extended_name}#{p}: mismatch with cached copy:\\n\" + diff.join(\"\\n\"))\n end\n end\n when 1 # upgrade\n log.action(update_action)\n when -1 # downgrade\n log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Update'))\n if which('drush').nil?\n if @force_changes\n owarn \"Forcing downgrade.\"\n else\n log.error(\"#{platform_project.extended_name}: use --force to downgrade or install Drush >=6.0.\")\n end\n elsif platform_project.drupal?\n if @platform.bootstrapped?\n if @force_changes\n owarn \"Downgrading a bootstrapped Drupal platform.\"\n else\n log.error(\"#{platform_project.extended_name} cannot be downgraded because it is bootstrapped (use --force to override)\")\n end\n end\n elsif platform_project.installed?(site)\n if @force_changes\n owarn \"Downgrading an installed/enabled project.\"\n else\n log.error(\"#{platform_project.extended_name}#{p} must be uninstalled before downgrading (use --force to override)\")\n end\n end\n when nil # One or both projects have no version\n # Check whether the content of the projects is consistent\n begin\n diff = makefile_project.file_level_compare_with platform_project\n rescue => ex\n odie \"Failed to verify the integrity of #{component.extended_name}: #{ex}\"\n end\n if diff.empty?\n log.notice(\"#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}\")\n else\n log.action(update_action)\n log.notice(diff.join(\"\\n\"))\n if platform_project.has_version? and (not makefile_project.has_version?)\n if @force_changes\n owarn \"Upgrading #{makefile_project.name} to unknown version.\"\n else\n log.error(\"Cannot upgrade #{makefile_project.name} from known version to unknown version\")\n end\n end\n end\n end\n end",
"def developer_can_see_this_project?\n developer = Developer.where(:gamer_id => current_gamer.id).first\n projects_owned = Project.where(:owner_id => developer.id)\n projects_shared1 = developer.projects_shared\n current_project = Project.find(params[:id])\n if !projects_owned.include?(current_project) && !projects_shared1.include?(current_project)\n flash[:error] = t(:developer_cant_see_project)\n redirect_to projects_path\n end \n end",
"def depends_on?(other_task)\n depends_on.include?(other_task)\n end",
"def is_for_project?\n not self.project.nil?\n end",
"def check_own_project_and_redirect?\n unless current_user.projects.ids.include? params[:project_id].to_i\n flash[:danger] = 'Access denied. You do not own that project.'\n redirect_to projects_path\n return true\n end\n false\n end",
"def insync?(is)\n return true\n end",
"def can_be_synced_to_remote?\n if is_drupal?\n !(lapsed? or applied?) and club.billing_enable\n elsif is_spree?\n !(applied?) and club.billing_enable\n end\n end",
"def travis_sync\n res = $travis_conn.post 'user/453045/sync'\n res.travis_raise\n res.success?\nend",
"def need_sync?\n if is_ignored || err_count >= MAX_SYNC_ERR\n false\n elsif last_sync == DUMMY_TIMESTAMP\n true\n else\n case sync_type.to_sym\n when :SYNC_UP\n clab_id.nil? || ext_last_update > last_sync\n when :SYNC_DOWN\n ext_obj_id.nil? || clab_last_update > last_sync\n else\n raise SyncError, 'sync mode not supported'\n end\n end\n end",
"def insync?(is)\n @lateststamp ||= (Time.now.to_i - 1000)\n # Iterate across all of the should values, and see how they\n # turn out.\n\n @should.each { |should|\n case should\n when :present\n return true unless [:absent].include?(is)\n when :latest\n # Short-circuit packages that are not present\n return false if is == :absent\n\n # Don't run 'latest' more than about every 5 minutes\n if @latest and ((Time.now.to_i - @lateststamp) / 60) < 5\n #self.debug \"Skipping latest check\"\n else\n begin\n @latest = provider.latest\n @lateststamp = Time.now.to_i\n rescue => detail\n error = Puppet::Error.new(\"Could not get latest version: #{detail}\")\n error.set_backtrace(detail.backtrace)\n raise error\n end\n end\n\n case\n when is.is_a?(Array) && is.include?(@latest)\n return true\n when is == @latest\n return true\n when is == :present\n # This will only happen on retarded packaging systems\n # that can't query versions.\n return true\n else\n self.debug \"#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}\"\n end\n\n\n when :absent\n return true if is == :absent\n # this handles version number matches and\n # supports providers that can have multiple versions installed\n when *Array(is)\n return true\n else\n # We have version numbers, and no match. If the provider has\n # additional logic, run it here.\n return provider.insync?(is) if provider.respond_to?(:insync?)\n end\n }\n\n false\n end",
"def perform(organization_id, opts = {})\n organization = Maestrano::Connector::Rails::Organization.find(organization_id)\n return unless organization&.sync_enabled\n\n # Check if previous synchronization is still running\n if Maestrano::Connector::Rails::Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now.utc)).exists?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Previous synchronization is still running')\n return\n end\n\n # Check if recovery mode: last 3 synchronizations have failed\n if !opts[:forced] && organization.last_three_synchronizations_failed? \\\n && organization.synchronizations.order(created_at: :desc).limit(1).first.updated_at > 1.day.ago\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Recovery mode (three previous synchronizations have failed)')\n return\n end\n\n # Trigger synchronization\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Start synchronization, opts=#{opts}\")\n current_synchronization = Maestrano::Connector::Rails::Synchronization.create_running(organization)\n\n begin\n last_synchronization = organization.last_successful_synchronization\n last_synchronization_date = organization.last_synchronization_date\n connec_client = Maestrano::Connector::Rails::ConnecHelper.get_client(organization)\n external_client = Maestrano::Connector::Rails::External.get_client(organization)\n\n # First synchronization should be from external to Connec! only to let the smart merging works\n # We do a doube sync: only from external, then only from connec!\n # We also do batched sync as the first one can be quite huge\n if last_synchronization.nil?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'First synchronization ever. Doing two half syncs to allow smart merging to work its magic.')\n organization.synchronized_entities.each do |entity, settings|\n next unless settings[:can_push_to_connec] || settings[:can_push_to_external]\n\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"First synchronization ever. Doing half sync from external for #{entity}.\")\n first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, true)\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"First synchronization ever. Doing half sync from Connec! for #{entity}.\")\n first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, false)\n end\n elsif opts[:only_entities]\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Synchronization is partial and will synchronize only #{opts[:only_entities].join(' ')}\")\n # The synchronization is marked as partial and will not be considered as the last-synchronization for the next sync\n current_synchronization.mark_as_partial\n opts[:only_entities].each do |entity|\n sync_entity(entity, organization, connec_client, external_client, last_synchronization_date, opts)\n end\n else\n organization.synchronized_entities.each do |entity, settings|\n next unless settings[:can_push_to_connec] || settings[:can_push_to_external]\n\n sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts)\n end\n end\n\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=success\")\n current_synchronization.mark_as_success\n rescue => e\n Maestrano::Connector::Rails::ConnectorLogger.log('warn', organization, \"Finished synchronization, organization=#{organization.uid}, status=error, message=\\\"#{e.message}\\\" backtrace=\\\"#{e.backtrace}\\\"\")\n current_synchronization.mark_as_error(e.message)\n end\n end",
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def lock_project\n if changed_attributes.key?(\"layer_id\")\n old_layer = Layer.find(layer_id_was)\n errors.add(:layer, \"can't be from another project\") if old_layer.project_id != layer.project_id\n end\n end",
"def check_if_project_is_active(project)\n b_found_active_extraction = false\n @projects_with_extractions += 1 if project.extractions.count > 0\n project.extractions.each do |extraction|\n break if b_found_active_extraction\n if extraction.results_section_ready_for_extraction?\n b_found_active_extraction = true\n @projects_with_extractions_ready_for_extraction += 1\n end # if extraction.results_section_ready_for_extraction?\n end # project.extractions.each do |extraction|\n end",
"def need_send_status_mail?\n Project.owned_by(self).count > 0 ||\n Project.executed_by(self).count.present?\n end",
"def enqueue_dependencies(queue, enqueueables, dependencies, manifests)\n enqueueables.each do |d|\n if q = find_inconsistency(d, dependencies + queue, manifests)\n debug_conflict d, q\n return false\n end\n debug_schedule d\n queue << d\n end\n true\n end",
"def insync?(is)\n\n @lateststamp ||= (Time.now.to_i - 1000)\n # Iterate across all of the should values, and see how they\n # turn out.\n\n @should.each { |should|\n case should\n when :present\n return true unless [:absent, :held].include?(is)\n when :latest\n # Short-circuit packages that are not present\n return false if is == :absent\n\n # Don't run 'latest' more than about every 5 minutes\n if @latest and ((Time.now.to_i - @lateststamp) / 60) < 5\n #self.debug \"Skipping latest check\"\n else\n begin\n @latest = provider.latest\n @lateststamp = Time.now.to_i\n rescue => detail\n error = Puppet::Error.new(\"Could not get latest version: #{detail}\")\n error.set_backtrace(detail.backtrace)\n raise error\n end\n end\n\n case\n when is.is_a?(Array) && is.include?(@latest)\n return true\n when is == @latest\n return true\n when is == :present\n return true\n else\n self.debug \"#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}\"\n end\n\n\n when :absent\n return true if is == :absent\n # this handles version number matches and\n # supports providers that can have multiple versions installed\n when *Array(is)\n return true\n end\n }\n\n false\n end"
] | [
"0.62062305",
"0.5795183",
"0.5784787",
"0.55783385",
"0.5441141",
"0.5398129",
"0.5176099",
"0.5170818",
"0.51311874",
"0.5129792",
"0.5086733",
"0.5086733",
"0.5018834",
"0.50183266",
"0.50104463",
"0.5003509",
"0.49797264",
"0.49756303",
"0.49735576",
"0.4947927",
"0.4935815",
"0.49344853",
"0.49245048",
"0.49243703",
"0.4923477",
"0.49162692",
"0.49072468",
"0.48992372",
"0.4890075",
"0.48876056"
] | 0.6416644 | 0 |
Synchronizes libraries between the makefile and the platform. | def sync_libraries
debug 'Syncing libraries'
processed_paths = []
@makefile.each_library do |lib|
sync_library(lib)
processed_paths << lib.target_path
end
# Determine libraries that should be deleted from the 'libraries' folder.
# The above is a bit of an overstatement, as it is basically impossible
# to detect a "library" in a reliable way. What we actually do is just
# deleting "spurious" paths inside the 'libraries' folder.
# Note also that Drupid is not smart enough to find libraries installed
# inside modules or themes.
Pathname.glob(@platform.libraries_path.to_s + '/**/*').each do |p|
next unless p.directory?
q = p.relative_path_from(@platform.local_path + @platform.contrib_path)
# If q is not a prefix of any processed path, or viceversa, delete it
if processed_paths.find_all { |pp| pp.fnmatch(q.to_s + '*') or q.fnmatch(pp.to_s + '*') }.empty?
l = Library.new(p.basename)
l.local_path = p
log.action(DeleteAction.new(@platform, l))
# Do not need to delete subdirectories
processed_paths << q
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_libraries uri\n src = sources.find(uri)\n libraries.each do |lib|\n lib.merge src if lib.contain?(src.filename)\n end\n diagnoser.schedule uri\n end",
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def static_setup (so_list)\n $stderr.puts \"setup: dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n # remove leftovers from previous rake.\n rm_rf \"#{TGT_DIR}/lib\"\n rm_rf \"#{TGT_DIR}/etc\"\n rm_rf \"#{TGT_DIR}/share\"\n rm_rf \"#{TGT_DIR}/conf.d\"\n mkdir_p \"#{TGT_DIR}/fonts\"\n cp_r \"fonts\", \"#{TGT_DIR}\"\n mkdir_p \"#{TGT_DIR}/lib\"\n cp \"lib/shoes.rb\", \"#{TGT_DIR}/lib\"\n cp_r \"lib/shoes\", \"#{TGT_DIR}/lib\"\n cp_r \"lib/exerb\", \"#{TGT_DIR}/lib\"\n cp_r \"lib/package\", \"#{TGT_DIR}/lib\"\n cp_r \"samples\", \"#{TGT_DIR}/samples\"\n cp_r \"static\", \"#{TGT_DIR}/static\"\n cp \"README.md\", \"#{TGT_DIR}/README.txt\"\n cp \"CHANGELOG\", \"#{TGT_DIR}/CHANGELOG.txt\"\n cp \"COPYING\", \"#{TGT_DIR}/COPYING.txt\"\n #mkdir_p \"#{TGT_DIR}/lib\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\", remove_destination: true\n # copy include files\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n so_list.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n # the things we do for love...\n ReNames.each_pair do |k, v|\n if File.exist? \"#{TGT_DIR}/#{k}\"\n mv \"#{TGT_DIR}/#{k}\", \"#{TGT_DIR}/#{v}\"\n $stderr.puts \"renamed #{k} to #{v}\"\n end\n end \n # copy/setup etc/share\n mkdir_p \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp \"#{ShoesDeps}/share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n sh \"#{WINDRES} -I. shoes/appwin32.rc shoes/appwin32.o\"\n cp_r \"#{ShoesDeps}/etc\", TGT_DIR\n if ENABLE_MS_THEME\n ini_path = \"#{TGT_DIR}/etc/gtk-3.0\"\n mkdir_p ini_path\n File.open \"#{ini_path}/settings.ini\", mode: 'w' do |f|\n f.write \"[Settings]\\n\"\n f.write \"#gtk-theme-name=win32\\n\"\n end\n end\n mkdir_p \"#{ShoesDeps}/lib\"\n cp_r \"#{ShoesDeps}/lib/gtk-3.0\", \"#{TGT_DIR}/lib\" \n bindir = \"#{ShoesDeps}/bin\"\n if File.exist?(\"#{bindir}/gtk-update-icon-cache-3.0.exe\")\n cp \"#{bindir}/gtk-update-icon-cache-3.0.exe\",\n \"#{TGT_DIR}/gtk-update-icon-cache.exe\"\n else \n cp \"#{bindir}/gtk-update-icon-cache.exe\", TGT_DIR\n end\n cp APP['icons']['win32'], \"shoes/appwin32.ico\"\n end",
"def copy_libs\n path_to_original_lib = File.dirname(__FILE__) # File.dirname(__FILE__) is the location of this file, that give the path of the main lib folder\n libs_to_copy = ['log.rb', 'files_manager.rb', 'command.rb'] # List of Libraries copied in the project folder for standalone run\n libs_dest_dir = \"#{@project_path}/#{@libdir}\" # Dir used to store libraries, to run the rakefile\n lib_dir = File.expand_path(libs_dest_dir) # get the absolute path\n FileUtils.mkdir_p libs_dest_dir # Create the output_dir if it doesn't exist\n for lib in libs_to_copy\n lib_file = \"#{path_to_original_lib}/#{lib}\"\n (@log.fatal { \"Workflow Finalisation : cannot copy the library #{lib_file} \" }; exit ) if not File.file? lib_file\n @log.info \"Workflow Finalisation : Copy libraries for a standalone usage of the rakefiles : #{lib_file}\"\n FileUtils.cp \"#{lib_file}\", libs_dest_dir\n end\n end",
"def create_all_library_tasks(env, libraries, dependent_task)\n libraries.each do | library |\n create_library_tasks(env, library, dependent_task)\n end\n\n desc \"Remove all dependency libraries from the lib directory\"\n task :clean do\n libraries.each do | library |\n rm_rf env.dependent_library_dir(library.name)\n end\n sh \"ino clean\"\n end\n\n desc \"Build the project\"\n task :build => dependent_task do\n sh \"ino build\"\n end\n end",
"def _reload_libs\n RELOAD_LIBS.each do |lib|\n require_dependency lib\n end\n end",
"def _reload_libs\n RELOAD_LIBS.each do |lib|\n require_dependency lib\n end\n end",
"def set_platform_libs\n\n case p4osname\n when 'SOLARIS'\n osver = `uname -r`\n osver.gsub!(/5\\./, '2')\n if (osver == '25')\n $LDFLAGS += '/usr/ucblib/libucb.a '\n end\n have_library('nsl')\n have_library('socket')\n when 'NT'\n have_library('advapi32')\n have_library('wsock32')\n have_library('kernel32')\n have_library('oldnames')\n when 'CYGWIN'\n # Clear out 'bogus' libs on cygwin\n CONFIG['LIBS'] = ''\n when 'DARWIN'\n if p4osver.to_i >= 8\n # Only build for 64 bit if we have more than one arch defined in CFLAGS\n $LDFLAGS.slice!('-arch i386')\n $LDFLAGS.slice!('-arch ppc')\n $LDFLAGS += ' -framework CoreFoundation -framework Foundation'\n end\n when 'LINUX', 'MINGW32'\n $LDFLAGS += ' -Wl,--allow-multiple-definition'\n have_library('supc++')\n end\nend",
"def reconfigure_jruby_stdlib\n abort 'cannot find jruby library in libs' if Dir['libs/jruby*'].empty?\n if (gem_version = ENV['JRUBY_JARS_VERSION'])\n gem('jruby-jars', gem_version)\n end\n require 'jruby-jars'\n\n log_action(\"Copying #{JRubyJars::stdlib_jar_path} to libs\") do\n FileUtils.cp JRubyJars::stdlib_jar_path, \"libs/jruby-stdlib-#{JRubyJars::VERSION}.jar\"\n end\n StdlibDependencies.load('rakelib/ruboto.stdlib.yml')\n\n Dir.chdir 'libs' do\n jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]\n log_action(\"Reformatting #{jruby_stdlib}\") do\n FileUtils.mkdir_p 'tmp'\n Dir.chdir 'tmp' do\n FileUtils.mkdir_p 'old'\n FileUtils.mkdir_p 'new/jruby.home'\n Dir.chdir 'old' do\n `jar -xf ../../#{jruby_stdlib}`\n raise \"Unpacking jruby-stdlib jar failed: #$?\" unless $? == 0\n end\n FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'\n FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'\n\n remove_unneeded_parts_of_stdlib\n cleanup_jars\n\n Dir.chdir 'new' do\n `jar -cf ../../#{jruby_stdlib} .`\n raise \"Creating repackaged jruby-stdlib jar failed: #$?\" unless $? == 0\n end\n end\n\n FileUtils.remove_dir 'tmp', true\n end\n end\nend",
"def update_libraries(uri); end",
"def compile_libraries\n events.library_load_start(count_files_by_segment(:libraries))\n cookbook_order.each do |cookbook|\n eager_load_libraries = cookbook_collection[cookbook].metadata.eager_load_libraries\n if eager_load_libraries == true # actually true, not truthy\n load_libraries_from_cookbook(cookbook)\n else\n $LOAD_PATH.unshift File.expand_path(\"libraries\", cookbook_collection[cookbook].root_dir)\n if eager_load_libraries # we have a String or Array<String> and not false\n load_libraries_from_cookbook(cookbook, eager_load_libraries)\n end\n end\n end\n events.library_load_complete\n end",
"def common_build\n copy_gems\n end",
"def common_build\n copy_gems\n end",
"def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n # remove leftovers from previous rake.\n rm_rf \"#{TGT_DIR}/lib\"\n rm_rf \"#{TGT_DIR}/etc\"\n rm_rf \"#{TGT_DIR}/share\"\n rm_rf \"#{TGT_DIR}/conf.d\"\n mkdir_p \"#{TGT_DIR}/lib\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy include files\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n # do some windows things\n mkdir_p \"#{TGT_DIR}/share/glib-2.0/schemas\"\n if APP['GTK'] == \"gtk+-2.0\" \n cp_r\"#{TGT_SYS_DIR}/share/glib-2.0/schemas/gschema.dtd\",\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n elsif APP['GTK'] == \"gtk+-3.0\"\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n else\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n end\n sh \"#{WINDRES} -I. shoes/appwin32.rc shoes/appwin32.o\"\n cp_r \"#{ShoesDeps}/etc\", TGT_DIR\n mkdir_p \"#{ShoesDeps}/lib\"\n if APP['GTK'] == \"gtk+-3.0\"\n cp_r \"#{ShoesDeps}/lib/gtk-3.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n else\n cp_r \"#{ShoesDeps}/lib/gtk-2.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n end\n bindir = \"#{ShoesDeps}/bin\"\n #cp_r \"#{bindir}/fc-cache.exe\", TGT_DIR\n cp_r \"#{bindir}/gtk-update-icon-cache.exe\", TGT_DIR\n # below for debugging purposes\n if ENV['GDB'] \n cp \"#{bindir}/fc-cat.exe\", TGT_DIR\n cp \"#{bindir}/fc-list.exe\", TGT_DIR\n cp \"#{bindir}/fc-match.exe\", TGT_DIR\n cp \"#{bindir}/fc-pattern.exe\", TGT_DIR\n cp \"#{bindir}/fc-query.exe\", TGT_DIR\n cp \"#{bindir}/fc-scan.exe\", TGT_DIR\n cp \"#{bindir}/fc-validate.exe\", TGT_DIR\n end\n # disable MS Theme\n if !ENABLE_MS_THEME \n Dir.chdir(\"#{TGT_DIR}/share/themes/MS-Windows/gtk-2.0/\") do\n mv 'gtkrc', 'disabled-gtkrc'\n end\n else\n # add our overrides to the MS-Windows theme\n cp \"platform/msw/gtkrc\", \"#{TGT_DIR}/etc/gtk-2.0/\"\n end\n end",
"def common_build\n puts \"common_build dir=#{pwd} #{SHOES_TGT_ARCH}\"\n #mkdir_p \"#{TGT_DIR}/ruby\"\n #cp_r \"#{EXT_RUBY}/lib/ruby/#{RUBY_V}\", \"#{TGT_DIR}/ruby/lib\"\n %w[req/ftsearch/lib/* req/rake/lib/*].each do |rdir|\n FileList[rdir].each { |rlib| cp_r rlib, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}\" }\n end\n %w[req/ftsearch/ext/ftsearchrt req/chipmunk/ext/chipmunk].\n #%w[req/binject/ext/binject_c req/ftsearch/ext/ftsearchrt req/bloopsaphone/ext/bloops req/chipmunk/ext/chipmunk].\n each { |xdir| copy_ext xdir, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}/#{SHOES_TGT_ARCH}\" }\n\n gdir = \"#{TGT_DIR}/lib/ruby/gems/#{RUBY_V}\"\n {'hpricot' => 'lib', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n #{'hpricot' => 'lib', 'json' => 'lib/json/ext', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n spec = eval(File.read(\"req/#{gemn}/gemspec\"))\n mkdir_p \"#{gdir}/specifications\"\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/lib\"\n FileList[\"req/#{gemn}/lib/*\"].each { |rlib| cp_r rlib, \"#{gdir}/gems/#{spec.full_name}/lib\" }\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/#{xdir}\"\n FileList[\"req/#{gemn}/ext/*\"].each { |elib| copy_ext elib, \"#{gdir}/gems/#{spec.full_name}/#{xdir}\" }\n cp \"req/#{gemn}/gemspec\", \"#{gdir}/specifications/#{spec.full_name}.gemspec\"\n end\n end",
"def common_build\n copy_gems # in make/gems.rb\n end",
"def build_shared_library(aux_libraries, gcc_binary, ci_gcc_config)\n FileUtils.mkdir_p(BUILD_DIR)\n add_build_dirs_to_env\n suffix = OS.windows? ? \"dll\" : \"so\"\n full_lib_name = \"#{BUILD_DIR}/lib#{LIBRARY_NAME}.#{suffix}\"\n executable = Pathname.new(full_lib_name).expand_path\n File.delete(executable) if File.exist?(executable)\n arg_sets = [\"-std=c++0x\", \"-shared\", \"-fPIC\", \"-Wl,-undefined,dynamic_lookup\",\n \"-o\", executable.to_s, \"-L#{BUILD_DIR}\", \"-DARDUINO=100\"]\n if libasan?(gcc_binary)\n arg_sets << [ # Stuff to help with dynamic memory mishandling\n \"-g\", \"-O1\",\n \"-fno-omit-frame-pointer\",\n \"-fno-optimize-sibling-calls\",\n \"-fsanitize=address\"\n ]\n end\n\n # combine library.properties defs (if existing) with config file.\n # TODO: as much as I'd like to rely only on the properties file(s), I think that would prevent testing 1.0-spec libs\n # the following two take some time, so are cached when we build the shared library\n @full_dependencies = all_arduino_library_dependencies!(aux_libraries)\n @test_args = test_args(@full_dependencies, ci_gcc_config) # build full set of include directories to be cached for later\n\n arg_sets << @test_args\n arg_sets << cpp_files_arduino.map(&:to_s) # Arduino.cpp, Godmode.cpp, and stdlib.cpp\n arg_sets << cpp_files_unittest.map(&:to_s) # ArduinoUnitTests.cpp\n arg_sets << cpp_files.map(&:to_s) # CPP files for the primary application library under test\n arg_sets << cpp_files_libraries(@full_dependencies).map(&:to_s) # CPP files for all the libraries we depend on\n args = arg_sets.flatten(1)\n return nil unless run_gcc(gcc_binary, *args)\n\n artifacts << executable\n executable\n end",
"def compile\n puts \"Compilando archivos fuentes:\"\n @objs.each do |obj|\n command = \"#{@cc} -fpic -c -o #{obj} #{obj[0..-2] + \"c\"} #{@cflags}\"\n puts \"\\t\"+ command\n exit (0) if not((system(command)))\n end\n \n puts \"Convirtiendo a bibliotecas dinamicas\"\n system(\"mkdir lib\")\n @shared.each do |obj|\n library = obj.split('/').last\n compiled_libraries = `ls #{@lib_dir}`.split(\" \")\n \n libs = compiled_libraries.inject(\"\") {\n |string,lib|\n string += \"-l#{lib[3...-3]} \"\n }\n \n if (@so == \"linux\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\"\n elsif (@so == \"mac\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\" \n end\n puts \"\\t\" + command\n puts \"No compilo de forma correcta\" if not((system(command)))\n end\nend",
"def update_app\n in_root do\n run(\"echo 'a' | rake rails:update:scripts\")\n run(\"echo 'a' | rake rails:update:javascripts\")\n run(\"echo 'a' | rake rails:update:configs\")\n run(\"echo 'a' | rake rails:update:application_controller\")\n\n if @javascript_library != \"prototype\"\n run \"rm public/javascripts/controls.js\"\n run \"rm public/javascripts/dragdrop.js\"\n run \"rm public/javascripts/effects.js\"\n run \"rm public/javascripts/prototype.js\"\n end\n end\nend",
"def configure_tasks\n super\n all_object_files = []\n all_object_folders = []\n @toolchains.each do |toolchain, sources|\n toolchain.add_include_paths(@api_headers+@configuration_headers)\n object_files, object_folders = toolchain.create_compile_tasks(sources)\n all_object_files |= object_files\n all_object_folders |= object_folders\n end\n\n project_filename = @parent_project.project_name.to_s.gsub(':','-')\n library_files, library_folders = @default_toolchain.create_static_library_tasks(all_object_files, project_filename)\n dependencies = @dependencies+all_object_folders+library_folders+library_files\n\n desc \"Build library '#{@parent_project.project_name}' with configuration '#{@configuration_name}'\"\n new_task = static_library_task @configuration_name => dependencies do |t|\n @post_build.call if @post_build.respond_to? :call\n puts \"built library #{t.name}.\"\n @tests.each do |test|\n if Rake::Task.task_defined? test\n Rake::Task[test].invoke\n else\n $stderr.puts \"warning: Skipping unknown test '#{test}'\"\n end\n end\n end\n new_task.api_headers = @api_headers\n new_task.configuration_headers = @configuration_headers\n new_task.library_files = library_files\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def reshuffle_jars()\n FileUtils.mkdir_p(\"#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/\")\n FileUtils.cp(Dir[\"#{UcbDeployer::RESOURCES_DIR}/soulwing-casclient-*\"],\n \"#{self.build_dir()}/src/edit-webapp/WEB-INF/lib/\")\n # These have been placed in $CATALINA_HOME/lib\n [\"mail\", \"activation\", \"javamail\", \"commons-logging\", \"log4j\"].each do |jar|\n FileUtils.rm_rf(Dir[\"#{self.build_dir()}/src/webapp/WEB-INF/lib/#{jar}-*\"])\n end\n end",
"def libs; end",
"def load_libs; end",
"def link_libraries\n if RbConfig::CONFIG[\"THREAD_MODEL\"] == \"pthread\"\n # Link gem extension against pthread library\n have_library \"pthread\"\n have_required_function \"pthread\", \"pthread_create\"\n end\n\n # Links gem extension against the `dl` library. This is needed when Ruby is\n # not linked against `dl` itself, so link it on the gem extension.\n have_library \"dl\"\n # Check if functions are available now from the linked library\n %w[dlopen dlclose dlsym].each do |func|\n have_required_function \"dl\", func\n end\nend",
"def reconfigure_jruby_libs\n jruby_core = JRubyJars::core_jar_path.split('/')[-1]\n log_action(\"Removing unneeded classes from #{jruby_core}\") do\n Dir.mkdir \"libs/tmp\"\n Dir.chdir \"libs/tmp\"\n FileUtils.move \"../#{jruby_core}\", \".\"\n `jar -xf #{jruby_core}`\n File.delete jruby_core\n ['jni', 'org/jruby/ant', 'org/jruby/compiler/ir', 'org/jruby/demo', 'org/jruby/embed/bsf', \n 'org/jruby/embed/jsr223', 'org/jruby/ext/ffi','org/jruby/javasupport/bsf'\n ].each {|i| FileUtils.remove_dir i, true}\n `jar -cf ../#{jruby_core} .`\n Dir.chdir \"../..\"\n FileUtils.remove_dir \"libs/tmp\", true\n end\n\n jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]\n log_action(\"Reformatting #{jruby_stdlib}\") do\n Dir.mkdir \"libs/tmp\"\n Dir.chdir \"libs/tmp\"\n FileUtils.move \"../#{jruby_stdlib}\", \".\"\n `jar -xf #{jruby_stdlib}`\n File.delete jruby_stdlib\n FileUtils.move \"META-INF/jruby.home/lib/ruby/1.8\", \"..\"\n Dir.chdir \"../1.8\"\n FileUtils.remove_dir \"../tmp\", true\n `jar -cf ../#{jruby_stdlib} .`\n Dir.chdir \"../..\"\n FileUtils.remove_dir \"libs/1.8\", true\n end\nend",
"def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n mkdir_p \"#{TGT_DIR}/lib\"\n # clean out leftovers from last build\n rm_f \"#{TGT_DIR}/libruby.so\" if File.exist? \"#{TGT_DIR}/libruby.so\"\n rm_f \"#{TGT_DIR}/libruby.so.#{rbvm}\" if File.exist? \"#{TGT_DIR}/libruby.so.#{rbvm}\"\n rm_f \"#{TGT_DIR}/libruby.so.#{rbvt}\" if File.exist? \"#{TGT_DIR}/libruby.so.#{rbvt}\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy and link libruby.so - pick the right one to \n # cp \"#{EXT_RUBY}/lib/libruby.so.#{RUBY_V}\", \"#{TGT_DIR}\"\n cp \"#{EXT_RUBY}/lib/libruby.so.#{rbvm}\", \"#{TGT_DIR}\"\n # copy include files - it might help build gems\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n # can't figure out ln -s? push pwd, cd, ln, pop\n #cdir = pwd\n #cd TGT_DIR\n chdir TGT_DIR do\n ln_s \"libruby.so.#{rbvm}\", \"libruby.so\"\n #ln_s \"libruby.so.#{RUBY_V}\", \"libruby.so.#{::RUBY_V[/^\\d+\\.\\d+/]}\"\n end\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n end",
"def sync\n compile_sprockets_assets\n clean_sprockets_assets\n\n if serve_assets == \"remote\" \n storage.upload_files\n storage.clean_remote\n end\n\n end",
"def sync\n @mutex.synchronize do\n config_provider.sync\n sync_input_files\n cleanup_output_files\n end\n end",
"def define_packaging_tasks\n\n\t\t### Task: prerelease\n\t\tunless Rake::Task.task_defined?( :pre )\n\t\t\tdesc \"Append the package build number to package versions\"\n\t\t\ttask :pre do\n\t\t\t\trev = get_numeric_rev()\n\t\t\t\ttrace \"Current rev is: %p\" % [ rev ]\n\t\t\t\t$hoespec.spec.version.version << \"pre#{rev}\"\n\t\t\t\tRake::Task[:gem].clear\n\n\t\t\t\tGem::PackageTask.new( $hoespec.spec ) do |pkg|\n\t\t\t\t\tpkg.need_zip = true\n\t\t\t\t\tpkg.need_tar = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tnamespace :deps do\n\n\t\t\tif RVM_GEMSET.exist?\n\t\t\t\tdesc \"Update the project's RVM gemset\"\n\t\t\t\ttask :gemset do\n\t\t\t\t\tdeps = make_gemset_recommendations( $hoespec.spec )\n\t\t\t\t\tupdates = deps.values.compact\n\n\t\t\t\t\tif !updates.empty?\n\t\t\t\t\t\t$stderr.puts \"%d gems in the current gemset have newer matching versions:\" %\n\t\t\t\t\t\t\t [ updates.length ]\n\t\t\t\t\t\tdeps.each do |old, newer|\n\t\t\t\t\t\t\tnext unless newer\n\t\t\t\t\t\t\t$stderr.puts \" #{old} -> #{newer}\"\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif ask( \"Update? \" )\n\t\t\t\t\t\t\tupdate_rvm_gemset( deps )\n\t\t\t\t\t\t\trun 'rvm', 'gemset', 'import', RVM_GEMSET.to_s\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\n\t\t### Make the ChangeLog update if the repo has changed since it was last built\n\t\tfile '.hg/branch'\n\t\tfile 'ChangeLog' => '.hg/branch' do |task|\n\t\t\t$stderr.puts \"Updating the changelog...\"\n\t\t\tcontent = make_changelog()\n\t\t\tFile.open( task.name, 'w', 0644 ) do |fh|\n\t\t\t\tfh.print( content )\n\t\t\tend\n\t\tend\n\n\tend"
] | [
"0.7009991",
"0.6698813",
"0.63477683",
"0.6338602",
"0.60610497",
"0.5996299",
"0.5967169",
"0.58087045",
"0.5776323",
"0.5725135",
"0.5686601",
"0.563684",
"0.563684",
"0.5625365",
"0.5539826",
"0.5488299",
"0.5485501",
"0.5478093",
"0.54225814",
"0.54070246",
"0.5406288",
"0.53905135",
"0.53869843",
"0.53704035",
"0.5318383",
"0.53079474",
"0.5288705",
"0.5281042",
"0.5279022",
"0.5268561"
] | 0.75132835 | 0 |
Applies any pending changes. This is the method that actually modifies the platform. Note that applying changes may be destructive (projects may be upgraded, downgraded, deleted from the platform, moved and/or patched). Always backup your site before calling this method! If :force is set to true, changes are applied even if there are errors. See also: Drupid::Updater.sync Options: force, no_lockfile | def apply_changes(options = {})
raise "No changes can be applied because there are errors." if log.errors? and not options[:force]
log.apply_pending_actions
@derivative_builds.each { |updater| updater.apply_changes(options.merge(:no_lockfile => true)) }
@log.clear
@derivative_builds.clear
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n verify_no_uncommitted_merge\n verify_valid_update\n \n check_unknown if force\n check_collision if false # case-insensitive file-system? seriously? (uh... mac os x ring a bell?)\n \n @actions = []\n \n forget_removed\n manifest_merge\n \n stats = apply_updates\n record_updates\n stats\n end",
"def apply_changes\n\t\t@admin_manager.CommitChanges\n\tend",
"def apply\n #TODO: generate a better commit message\n @gl_admin.commit_index(\"Commit by gitolite gem\")\n @gl_admin.git.push({}, \"origin\", \"master\")\n end",
"def sync_project(project)\n return false unless _fetch_and_patch(project)\n\n # Does this project contains a makefile? If so, enqueue a derivative build.\n has_makefile = prepare_derivative_build(project)\n\n # Ignore libraries that may be installed inside this project\n pp = @platform.local_path + @platform.dest_path(project)\n @libraries_paths.each do |lp|\n if lp.fnmatch?(pp.to_s + '/*')\n project.ignore_path(lp.relative_path_from(pp))\n @log.notice(\"Ignoring #{project.ignore_paths.last} inside #{project.extended_name}\")\n end\n end\n\n # Does the project exist in the platform? If so, compare the two.\n if @platform.has_project?(project.name)\n platform_project = @platform.get_project(project.name)\n # Fix project location\n new_path = @platform.dest_path(project)\n if @platform.local_path + new_path != platform_project.local_path\n log.action(MoveAction.new(@platform, platform_project, new_path))\n if (@platform.local_path + new_path).exist?\n if @force_changes\n owarn \"Overwriting existing path: #{new_path}\"\n else\n log.error(\"#{new_path} already exists. Use --force to overwrite.\")\n end\n end\n end\n # Compare versions and log suitable actions\n _compare_versions project, platform_project\n else\n # If analyzing the platform does not allow us to detect the project (e.g., Fusion),\n # we try to see if the directory exists where it is supposed to be.\n proj_path = @platform.local_path + @platform.dest_path(project)\n if proj_path.exist?\n begin\n platform_project = PlatformProject.new(@platform, proj_path)\n _compare_versions project, platform_project\n rescue => ex\n log.action(UpdateProjectAction.new(@platform, project))\n if @force_changes\n owarn \"Overwriting existing path: #{proj_path}\"\n else\n log.error(\"#{proj_path} exists, but was not recognized as a project (use --force to overwrite it): #{ex}\")\n end\n end\n else # new project\n log.action(InstallProjectAction.new(@platform, project))\n end\n end\n return (not has_makefile)\n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def deploy!\n write_previous_revision\n update_repository\n write_revision\n end",
"def update_everything\n announcing 'Updating All Packages' do\n chroot 'update_everything'\n end\n send_to_state('build', 'update_everything')\n end",
"def update\n context.execute :rm, '-rf', \"#{deploy_path}/local_file/*\"\n context.upload! fetch(:repo_url), \"#{deploy_path}/local_file/#{fetch(:repo_url)}\"\n end",
"def forceupdate()\n rc = offline\n return rc if OpenNebula.is_error?(rc)\n\n enable\n end",
"def apply\n self.install\n\n self.say(\"Applying configuration...\", true)\n command = \"chef-solo -j #{NODE_JSON.shellescape}\"\n command << \" -o #{self.pocketknife.runlist}\" if self.pocketknife.runlist\n command << \" -l debug\" if self.pocketknife.verbosity == true\n self.execute(command, true)\n self.say(\"Finished applying!\")\n end",
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def sync!(desired)\n # Ensure that the telegraf.conf item is always mounted\n items = [\n {\n key: 'telegraf.conf',\n path: 'telegraf.conf'\n },\n desired\n ].sort_by { |item| item[:path] }\n\n cm_volume = {\n name: @volume,\n configMap: {\n name: @configmap,\n defaultMode: 420,\n items: items\n }\n }\n\n patch = {\n spec: {\n template: {\n spec: {\n volumes: [cm_volume]\n }\n }\n }\n }\n\n @api\n .api('apps/v1')\n .resource('deployments', namespace: @ns)\n .merge_patch(@deployment, patch)\n\n # Refresh the current state\n fetch!\n end",
"def apply_force\n show_info \"Creating application forcefully!\" if @options[:force]\n FileUtils.rm_rf(\"#{@path}/.\", :secure => true) if File.exists?(@path) and @options[:force]\n FileUtils.mkdir_p @path\n end",
"def update\n install\n end",
"def apply\n debug \"Applying patch at #{Dir.pwd}\"\n raise \"Patch not fetched.\" if !(@cached_location and @cached_location.exist?)\n patch_levels = ['-p1', '-p0']\n patched = false\n output = ''\n # First try with git apply\n patch_levels.each do |pl|\n begin\n runBabyRun 'git', ['apply', '--check', pl, @cached_location], :redirect_stderr_to_stdout => true\n runBabyRun 'git', ['apply', pl, @cached_location], :redirect_stderr_to_stdout => true\n patched = true\n break\n rescue => ex\n output << ex.to_s\n end\n end\n if not patched\n patch_levels.each do |pl|\n begin\n runBabyRun 'patch', ['--no-backup-if-mismatch', '-f', pl, '-d', Dir.pwd, '-i', @cached_location], :redirect_stderr_to_stdout => true\n patched = true\n break\n rescue => ex\n output << ex.to_s\n end\n end\n end\n if not patched\n if descr and descr != @cached_location.basename.to_s\n d = \" (#{descr})\"\n else\n d = ''\n end\n raise \"Patch #{@cached_location.basename}#{d} could not be applied.\\n\" + output\n end\n return true\n end",
"def SetSystemUpdate\n if FileUtils.Exists(Installation.run_update_file)\n Mode.SetMode(\"update\")\n\n Builtins.foreach(\n [\n \"language\", # language already selected\n \"disks_activate\", # disks activated before running upgrade\n \"mode\", # always doing update, is already preselected\n \"update_partition\", # no mounting\n \"prepdisk\"\n ]\n ) { |m| ProductControl.DisableModule(m) } # disks already mounted, it is dummy in update anyway\n end\n\n nil\n end",
"def update_the_framework\n if repo_is_clean?\n pull_latest_changes and run 'reload_dots'\n else\n say \"You have uncommitted changes in ~/.dots. Please resolve them before updating.\"\n end\n end",
"def update_permissions_if_vcs_changed\n return unless saved_change_to_vcs_submit?\n Repository.get_class.update_permissions\n end",
"def update\n Puppet.debug \"Attempting to upgrade #{@resource[:name]}\"\n install unless mas_app\n mas('upgrade')\n end",
"def update!(**args)\n @platform_types = args[:platform_types] if args.key?(:platform_types)\n @threat_entries = args[:threat_entries] if args.key?(:threat_entries)\n @threat_entry_types = args[:threat_entry_types] if args.key?(:threat_entry_types)\n @threat_types = args[:threat_types] if args.key?(:threat_types)\n end",
"def sync_addon_branch_to_blessed_repo(repoName, remoteBranch, localBranch, pushForce = false)\n self.log(INFO,repoName,\"Checkout #{remoteBranch} branch (it is perhaps not the default) for #{repoName}...\")\n s = system(\"git checkout #{localBranch}\")\n if !s\n print(\"[ERROR] No #{remoteBranch} branch in repository #{repoName}, Skip this repo!!!\\n\")\n self.log(INFO,repoName,\"Done.\")\n # Let's process the next one\n else\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Reset #{localBranch} to #{remoteBranch} for #{repoName} ...\")\n s = system(\"git reset --hard #{remoteBranch}\")\n if !s\n abort(\"[ERROR] Reset #{localBranch} to #{remoteBranch} for #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Push #{localBranch} branch content from exo-addons repository to blessed repository ...\")\n\n forceParam = \"\"\n if pushForce\n forceParam = \"--force\"\n end\n\n s = system(\"git push #{forceParam} blessed #{localBranch}\")\n if !s\n abort(\"[ERROR] Push of #{localBranch} branch updates to repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end\n end",
"def update!\n if path = vendorized?\n type = File.symlink?(path) ? :symlink : :copy\n FileUtils.rm_rf normalize(:lib)\n send \"vendorize_with_#{type}\"\n say \"updated #{type} #{path} -> #{program(:version)}\"\n else\n ['dom.html', 'rhino.js', 'node.js'].each do |path|\n path = normalize path\n next unless File.exists? path\n contents = File.read(path).gsub /jspec-(\\d+\\.\\d+\\.\\d+)/, \"jspec-#{program(:version)}\"\n if program(:version) == $1\n say \"skipping #{path}; already #{$1}\"\n next\n end\n File.open(path, 'r+'){ |file| file.write contents } \n say \"updated #{path}; #{$1} -> #{program(:version)}\"\n end\n end\n end",
"def deploy\n Kb8Run.update_context(@kb8context)\n @deploy_units.each do | deploy_unit |\n deploy_unit.deploy\n end\n end",
"def update_platforms\n # TODO: Check auth and policy\n if policy(@extension).manage?\n params[:supported_platforms] ||= []\n @version.supported_platforms = SupportedPlatform.where(name: params[:supported_platforms])\n @version.save\n end\n\n redirect_to({ action: :show }.merge(params.slice(:extension_id, :version)))\n end",
"def update\n ws.config.interactive = false\n Autoproj::CLI::Update.new(ws).run(\n [], reset: :force,\n packages: true,\n config: true,\n deps: true,\n osdeps_filter_uptodate: true,\n osdeps: false\n )\n @update_failed = false\n true\n rescue StandardError => e\n # if this is true, the only thing the daemon\n # should do is update the workspace on push events,\n # no PR syncing and no triggering of builds\n # on PR events\n @update_failed = Time.now\n Autoproj.error e.message\n false\n end",
"def etc_update \n announcing 'Running etc-update' do\n system(\"chroot #{$chrootdir} /scripts/run.sh update_configs\")\n end\n send_to_state('build', 'etc_update')\n end",
"def update\n @repo.reset_hard\n @repo.pull_rebase\n log << \"Database updated. Now at: #{version}\"\n end",
"def update\n super if defined? super\n @systems.each_value do |system|\n system.update\n end\n end",
"def update\n self.install\n end",
"def update\n self.install\n end"
] | [
"0.6055943",
"0.5982402",
"0.5627518",
"0.5581999",
"0.55807406",
"0.5514358",
"0.5505586",
"0.54566884",
"0.5426453",
"0.5413427",
"0.533434",
"0.53160006",
"0.531422",
"0.5291006",
"0.52754486",
"0.5270214",
"0.52656704",
"0.52529675",
"0.52236086",
"0.5191947",
"0.51876235",
"0.51482075",
"0.5147528",
"0.5140364",
"0.51396346",
"0.51376146",
"0.5122628",
"0.51188403",
"0.5106603",
"0.5106544"
] | 0.60588956 | 0 |
Updates Drupal's database using drush updatedb. If site is defined, then updates only the specified site; otherwise, iterates over all Platformsite_names and updates each one in turn. Returns true upon success, false otherwise. | def updatedb
ohai "Updating Drupal database..."
blah "Platform: #{self.platform.local_path}"
res = true
site_list = (self.site) ? [self.site] : self.platform.site_names
site_list.each do |s|
site_path = self.platform.sites_path + s
debug "Site path: #{site_path}"
unless site_path.exist?
debug "Skipping #{site_path} because it does not exist."
next
end
blah "Updating site: #{s}"
res = Drush.updatedb(site_path) && res
end
return res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n raise UnknownSite, \"Site not existent in Piwik yet, call 'save' first\" if new?\n raise ArgumentError, \"Name can not be blank\" if name.blank?\n raise ArgumentError, \"Main URL can not be blank\" if main_url.blank?\n xml = call('SitesManager.updateSite', :idSite => id, :siteName => name, :urls => main_url)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result['success'] ? true : false\n end",
"def update_site\n # ensure the site already exists\n abort \"'#{site}' does not exist\" unless test ?d, site\n\n # copy over files from the data/tasks directory\n files = site_files\n\n mkdir 'tasks'\n files['tasks'].sort.each {|file| cp file}\n\n nil\n end",
"def bulk_vhost_update(dbcheck, tenant_array)\n #tenant_status['vhost_updated'] = false\n command = \"chef-client -o prom-classfront::classflow-conf\"\n\n # list of environments that require vhost updates\n tenvs = [] \n tenant_array.each do |tenant|\n tenant_config = tenant[0]\n tenant_status = tenant[1]\n tenvs << tenant_config['env']\n end\n tenant_envlist = tenvs.uniq\n tenant_envlist.each do |tenant_env|\n front_end = dbcheck.lookup_frontend_servers(tenant_env)\n front_end.each do |instance|\n logger.info \"Updating vhost through chef-client run on #{instance}.\"\n begin\n run_ssh_command(instance, command)\n \n # Provides error details on connection failure\n rescue SocketError => e\n logger.error \"Unable to update vhost on instance #{instance}\"\n logger.error \"#{e}\"\n end\n end\n end\n \n # Mark each tenant as updated\n tenant_array.each do |tenant|\n tenant_status = tenant[1]\n tenant_status['vhost_updated'] = true\n end\n end",
"def update!(**args)\n @site = args[:site] if args.key?(:site)\n end",
"def update!(**args)\n @mysql_databases = args[:mysql_databases] if args.key?(:mysql_databases)\n end",
"def update_from_site_redirections!\n\t\t\tputs \"Invoke internal procedures to update the primary host-name table from the site store.\"\n\t\t\tbegin\n\t\t\t\tmy_tracker=Wmap::SiteTracker.instance\n my_tracker.sites_file=@data_dir + \"sites\"\n my_tracker.load_site_stores_from_file\n urls = my_tracker.get_redirection_urls\n my_tracker = nil\n\t\t\t\turls.map do |url|\n\t\t\t\t\tif is_url?(url)\n\t\t\t\t\t\thost=url_2_host(url)\n\t\t\t\t\t\tif is_fqdn?(host)\n\t\t\t\t\t\t\tip=host_2_ip(host)\n\t\t\t\t\t\t\t# Add duplication check\n\t\t\t\t\t\t\tunless @known_hosts.key?(ip)\n\t\t\t\t\t\t\t\tself.add(host)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself.save!\n\t\t\trescue Exception => ee\n\t\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\t\t\treturn nil\n\t\t\tend\n\t\tend",
"def update_from_site_store!\n\t\t\t#begin\n puts \"Invoke internal procedures to update the primary host-name table from the site store.\"\n # Step 1 - update the prime host table based on the SSL cert CN fields\n\t\t\t\tcns=Hash.new\n\t\t\t\tchecker=Wmap::UrlChecker.new(:data_dir=>@data_dir)\n my_tracker = Wmap::SiteTracker.instance\n my_tracker.sites_file = @data_dir + \"sites\"\n my_tracker.load_site_stores_from_file\n\t\t\t\tmy_tracker.get_ssl_sites.map do |site|\n\t\t\t\t\tputs \"Exam SSL enabled site entry #{site} ...\"\n\t\t\t\t\tmy_host=url_2_host(site)\n\t\t\t\t\tnext if @known_hosts.key?(my_host) # add the logic to optimize the process\n\t\t\t\t\tputs \"Pull SSL cert details on site: #{site}\"\n\t\t\t\t\tcn=checker.get_cert_cn(site)\n\t\t\t\t\tunless cn.nil? or cns.key?(cn)\n\t\t\t\t\t\tcns[cn]=true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcns.keys.map do |cn|\n\t\t\t\t\tif is_fqdn?(cn)\n\t\t\t\t\t\tnext if @known_hosts.key?(cn)\n\t\t\t\t\t\tself.add(cn)\n\t\t\t\t\t\tputs \"New entry added: #{cn}\\t#{@known_hosts[cn]}\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t# Step 2 - Save the cache into the file\n\t\t\t\tself.save!\n checker=nil\n my_tracker=nil\n\t\t\t#rescue Exception => ee\n\t\t\t#\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n # checker=nil\n # my_tracker=nil\n\t\t\t#\treturn nil\n\t\t\t#end\n\t\tend",
"def update!(**args)\n @site = args[:site] if args.key?(:site)\n @versioned_data = args[:versioned_data] if args.key?(:versioned_data)\n end",
"def update!(**args)\n @target_sites = args[:target_sites] if args.key?(:target_sites)\n end",
"def update\n logger.debug \"debug_update:params=#{params.inspect}\"\n @m_site = MSite.where(id: params[:id].to_i).first\n @m_site.name = params['app_job_offer_name']\n @m_site.password = params['app_password'].nil? ? '' : params['app_password']\n @m_site.no_scraping_flg = params['app_no_scraping_flg']\n #@m_site.recruitment_site_id = params['app_site_id'].nil? ? '' : params['app_site_id']\n @m_site.user_id = params['app_user_id'].nil? ? '' : params['app_user_id']\n @m_site.extra1 = params['extra1'].nil? ? '' : params['extra1']\n @m_site.extra2 = params['extra2'].nil? ? '' : params['extra2']\n @m_site.extra3 = params['extra3'].nil? ? '' : params['extra3'].to_i\n @m_site.enterprise_cnt = params['enterprise_cnt'].nil? ? 0 : params['enterprise_cnt']\n\n respond_to do |format|\n if @m_site.valid? && @error_msg.blank?\n @m_site.save\n format.html { redirect_to '/m_sites', notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @m_site }\n else\n format.html { render :edit }\n format.json { render json: @m_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sync_drupal_core\n if @platform.drupal_project\n _compare_versions @makefile.drupal_project, @platform.drupal_project\n else\n log.action(InstallProjectAction.new(@platform, @makefile.drupal_project))\n end\n return true\n end",
"def update!(**args)\n @site_entry = args[:site_entry] if args.key?(:site_entry)\n end",
"def update\n \n respond_to do |format|\n if @site.update(params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render json: { result: :ok, notice: 'changes saved succesfully', site: @site } }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def installed? site = nil\n site_list = (site) ? [site] : platform.site_names\n site_list.each do |s|\n site_path = platform.sites_path + s\n next unless site_path.exist?\n return true if Drush.installed?(site_path, name, relative_path)\n end\n return false\n end",
"def update\n respond_to do |format|\n if @body_site.update(body_site_params)\n format.html { redirect_to @body_site, notice: 'Body site was successfully updated.' }\n format.json { render :show, status: :ok, location: @body_site }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @body_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to xmt_press_sites_url, notice: '站点更新成功.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params.reject {|k,v|k==\"trade_items\"})\n TradeItem.where(site_id: @site.id).destroy_all\n create_trade_items(@site, site_params[:trade_items])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(id_from_params)\n\n respond_to do |format|\n current_user.account.sites.delete(@site)\n current_user.account.sites << @site\n if current_user.account.sites.exists? @site\n format.html { redirect_to root_path, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:site][:virtualhost] = nil if params[:site][:virtualhost] =~ /^\\s*$/\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n flash[:notice] = 'Site was successfully updated.'\n format.html { redirect_to(@site) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n flash[:notice] = 'Site was successfully updated.'\n Changelog.add(@current_user.login, \"Updated the #{@site.name} site\")\n format.html { redirect_to(@site) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to after_update_path, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = current_user.sites.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { flash_and_redirect(\"successfully updated!\", sites_url) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to site_path(@site), notice: 'Site was successfully updated.' }\n # format.html { redirect_to project_site_path(@site.project, @site), notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { flash.now[:error] = \"Error: See details below.\"\n render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_deployment(s_language)\n @ht_bdmroutines.each_pair do |s_bdmcomponent_name,ob_bdmroutine|\n ob_bdmroutine.send(:update_deployment,s_language)\n end # loop\n end",
"def update_site_data_catalog_variables(variables)\n variables.each do |var|\n #entry = Voeis::SiteDataCatalog.first_or_create(:site_id => self.id, :variable_id => var.id)\n #sql = \"SELECT data_value_id FROM voeis_data_value_variables WHERE variable_id = #{var.id} INTERSECT SELECT data_value_id FROM voeis_data_value_sites WHERE site_id = #{self.id}\"\n sql = \"SELECT id FROM voeis_data_values WHERE variable_id = #{var.id} AND site_id = #{self.id}\"\n results = repository.adapter.select(sql)\n if results.length > 0\n entry = Voeis::SiteDataCatalog.first_or_create(:site_id => self.id, :variable_id => var.id)\n entry.record_number = results.length\n sql = \"SELECT * FROM voeis_data_values WHERE id IN #{results.to_s.gsub('[','(').gsub(']',')')} ORDER BY local_date_time\"\n dresults = repository.adapter.select(sql)\n entry.starting_timestamp = dresults.first[:local_date_time]#(var.data_values & self.data_values).first(:order=>[:local_date_time]).local_date_time\n entry.ending_timestamp = dresults.last[:local_date_time] #(var.data_values & self.data_values).last(:order=>[:local_date_time]).local_date_time\n entry.valid?\n puts entry.errors.inspect()\n entry.save!\n end\n end #end each\n end",
"def mass_update(data)\n result = @client.api_request(\n :method => \"template.massUpdate\",\n :params => {\n :hosts => data[:hosts_id].map { |t| {:hostid => t} },\n :templates => data[:templates_id].map { |t| {:templateid => t} }\n }\n )\n result.empty? ? false : true\n end",
"def update\n @site = Site.find(params[:id])\n @site.build_key_phrases(params[:key_phrase])\n \n if params[:msa_indicator] == \"no_msa\" || params[:msa_indicator] == \"all_msas\"\n @site.online = true\n @site.metro_service_area = nil\n params[:site][:city] = nil\n params[:site][:country_code] = nil\n params[:site][:state] = nil\n @site.all_msas = (params[:msa_indicator] == \"all_msas\")\n else\n @site.online = (params[:msa_indicator] == \"online_plus_msa\" || params[:msa_indicator] == \"online_plus_all_msas\")\n @site.metro_service_area = MetroServiceArea.find_or_create_by_name(params[:metro_service_area][:name]) unless params[:metro_service_area][:name].blank?\n @site.all_msas = (params[:msa_indicator] == \"online_plus_all_msas\")\n end\n \n unless params[:comments].blank? \n comments = Comment.new(:comment => params[:comments])\n @site.comments << comments\n end\n \n respond_to do |format|\n if @site.update_attributes(params[:site])\n # if @site.ferret_enabled?\n # if @site.disabled?\n # @site.ferret_destroy\n # else\n # @site.ferret_update\n # end\n # else\n # @site.ferret_create unless @site.disabled?\n # end \n flash[:notice] = 'Site was successfully updated.'\n format.html { redirect_to(@site) }\n format.xml { head :ok }\n else\n @super_categories = Topic.roots\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n \n end",
"def update\n respond_to do |format|\n if @admin_site_structure.update(admin_site_structure_params)\n format.html { redirect_to @admin_site_structure, notice: 'Site structure was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_site_structure }\n else\n format.html { render :edit }\n format.json { render json: @admin_site_structure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n institution = @site.institution\n redirect_options = {}\n\n return unless authorize_resource(@site, UPDATE_SITE)\n\n @can_move = has_access?(institution, CREATE_INSTITUTION_SITE)\n\n respond_to do |format|\n update_or_save = false\n\n if site_params(@can_move).has_key?(:parent_id) && site_params(@can_move)[:parent_id].to_i != @site.parent_id\n new_site = institution.sites.new(site_params(true))\n begin\n Site.transaction do\n new_site.save!\n @site.devices.each do |device|\n device.site = new_site\n device.save!\n end\n @site.devices.clear\n\n @site.destroy\n update_or_save = true\n redirect_options = { context: new_site.uuid } if @navigation_context.entity.uuid == @site.uuid\n end\n rescue => e\n update_or_save = false\n # propagate errors from site to be created to original site\n new_site.errors.each do |k, m|\n @site.errors.add(k, m)\n end\n # mimic that attributes have been edited in the original site\n @site.assign_attributes(site_params)\n end\n else\n update_or_save = @site.update(site_params)\n end\n\n if update_or_save\n format.html { redirect_to sites_path(redirect_options), notice: I18n.t('sites.update.success') }\n format.json { head :no_content }\n else\n @sites = check_access(institution.sites, READ_SITE) if @can_move\n\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_site(exclude_current_locale = false)\n self.each_locale do |locale|\n next if exclude_current_locale && locale.to_s == self.default_locale.to_s\n\n self.output_locale\n\n begin\n self.output_resource_op self.site\n\n self.put(:sites, self.site._id, self.site.to_hash(false), locale)\n\n self.output_resource_op_status self.site\n rescue Exception => e\n self.output_resource_op_status self.site, :error, e.message\n end\n end\n end"
] | [
"0.66756845",
"0.56743914",
"0.5558451",
"0.54885405",
"0.5330445",
"0.5326549",
"0.52271396",
"0.52064204",
"0.5200117",
"0.51818675",
"0.5154343",
"0.51351756",
"0.510574",
"0.5096387",
"0.5085939",
"0.5059639",
"0.50403637",
"0.5034136",
"0.5017829",
"0.49873185",
"0.49864635",
"0.4977525",
"0.49445358",
"0.49350905",
"0.49274346",
"0.4909971",
"0.49083132",
"0.49018526",
"0.48918113",
"0.48733786"
] | 0.8366164 | 0 |
Returns true if the given component is successfully cached and patched; return false otherwise. | def _fetch_and_patch component
begin
component.fetch
rescue => ex
@log.error("#{component.extended_name} could not be fetched.")
debug "_fetch_and_patch: #{ex.message}"
return false
end
if component.has_patches?
begin
component.patch
rescue => ex
@log.error("#{component.extended_name}: #{ex.message}")
return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patched?\n @patched\n end",
"def patched?\n @patched\n end",
"def patched?\n @patched\n end",
"def patched?\n @patched\n end",
"def patched?\n @patched\n end",
"def cache?\n caching && true\n end",
"def check_cache(file)\n\t\t# If the module cache has been invalidated, then we return false to\n\t\t# indicate that we should go ahead and load the file now.\n\t\treturn false if (@modcache_invalidated)\n\n\t\tif (@modcache and @modcache.group?('FileModificationTimes'))\n\t\t\tno_exist = false\n\n\t\t\tbegin\n\t\t\t\tcurr_mtime = File::Stat.new(file).mtime\n\t\t\trescue Errno::ENOENT\n\t\t\t\tno_exist = true\n\t\t\tend\n\n\t\t\tif (no_exist or \n\t\t\t @modcache['FileModificationTimes'][file].nil? or\n\t\t\t @modcache['FileModificationTimes'][file].to_s != curr_mtime.to_i.to_s)\n\t\t\t\traise ModuleCacheInvalidated, \"File #{file} has a new mtime or did not exist\"\n\t\t\tend\n\t\tend\n\n\t\treturn true\n\tend",
"def cached?\n cache_path.exist?\n end",
"def cached?\n cache_path.exist?\n end",
"def cached?\n !(!@cached)\n end",
"def cache_valid?(certificate_entry)\n return false if certificate_entry.nil?\n\n (Time.now <= (certificate_entry[:timestamp] + CERTIFICATE_CACHE_TIME))\n end",
"def cached?(method, url, params = nil, body = nil)\n status = status(method, url, params, body)\n status[:status] != 'miss'\n end",
"def should_cache?\n false\n end",
"def cached_pass?(context)\n condition = context.condition(@name)\n return unless condition.cached?\n\n condition.pass?\n end",
"def using_cache\n\t\t(@modcache_invalidated != true)\n\tend",
"def content_modified?\n self.content_hash.nil? || self.content_hash != calculate_content_hash\n end",
"def patched?\n @local_path == patched_location\n end",
"def _test_component(component, context)\n true\n end",
"def patchable?\n available? && loaded? && compatible?\n end",
"def cached?(key)\n false\n end",
"def cache_valid?\n return false unless File.exist?(cache_path)\n return true if checksum.nil?\n checksum == file_digest(cache_path)\n end",
"def cache?\n false\n end",
"def update_cache?\n return @update_cache unless @update_cache.nil?\n @update_cache =\n begin\n File.stat(Gem.user_home).uid == Process.uid\n rescue Errno::ENOENT\n false\n end\n end",
"def update_resource_cache!(force = false)\n if person_resource? && (resource_cache_expired? || force)\n return true if self.update_attributes(\n :display_name => person_resource.attributes[\"DisplayName\"],\n :firstname => person_resource.attributes[\"RegisteredFirstMiddleName\"],\n :lastname => person_resource.attributes[\"RegisteredSurname\"],\n :uw_net_id => person_resource.attributes[\"UWNetID\"],\n :email => person_resource.attributes[\"UWNetID\"] + \"@uw.edu\",\n :birthdate => (Date.parse(student_person_resource.attributes[\"BirthDate\"]) rescue nil),\n :sex => student_person_resource.attribute(:gender),\n :uw_student_no => student_person_resource.attribute(:student_number).to_s.rjust(7, \"0\"),\n :resource_cache_updated_at => Time.now\n )\n end\n false\n end",
"def cached?\n Dir.exist?(cached_repo_path)\n end",
"def fresh?(thing)\n if thing.is_a?(Sprite) and not thing.save_path.file?\n # If this is a data URI sprite a non-existent file is normal.\n if ! @project || ! @project.data_uri_sprites.include?(thing)\n return false\n end\n end\n\n return false if thing.is_a?(Pathname) and not thing.cleanpath.file?\n\n @cache[section(thing)][key(thing)] == digest(thing)\n end",
"def cacheable?\n @cacheable\n end",
"def cached?(name, *args)\n return false if Rails.env == 'development'\n cache = Cacheable.cache[self][name.to_sym]\n return false unless cache.key?(args)\n params = cache[args]\n !(params[:force] && (params[:time] < (Time.new - params[:ttl])))\n end",
"def cacheable?\n true\n end",
"def use_cache?\n super && !against_head?\n end"
] | [
"0.6425704",
"0.6425704",
"0.6425704",
"0.6425704",
"0.6425704",
"0.60998744",
"0.6063766",
"0.6055901",
"0.60394156",
"0.6037532",
"0.6027015",
"0.59660506",
"0.5933369",
"0.5923776",
"0.5917685",
"0.58934426",
"0.5872757",
"0.5866805",
"0.5865231",
"0.5846616",
"0.58278835",
"0.5815211",
"0.57929516",
"0.5751991",
"0.5748086",
"0.5719533",
"0.5715597",
"0.571088",
"0.57035804",
"0.5682864"
] | 0.74526393 | 0 |
Compare project versions and log suitable actions. | def _compare_versions(makefile_project, platform_project)
update_action = UpdateProjectAction.new(platform, makefile_project)
case makefile_project <=> platform_project
when 0 # up to date
# Check whether the content of the projects is consistent
begin
diff = makefile_project.file_level_compare_with platform_project
rescue => ex
odie "Failed to verify the integrity of #{makefile_project.extended_name}: #{ex}"
end
p = (makefile_project.drupal?) ? '' : ' (' + (platform.contrib_path + makefile_project.target_path).to_s + ')'
if diff.empty?
@log.notice("#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}")
elsif makefile_project.has_patches?
log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Patched'))
log.notice "#{makefile_project.extended_name}#{p} will be patched"
log.notice(diff.join("\n"))
else
log.action(update_action)
if @force_changes
owarn "Mismatch with cached copy: overwriting local copy."
else
log.error("#{platform_project.extended_name}#{p}: mismatch with cached copy:\n" + diff.join("\n"))
end
end
when 1 # upgrade
log.action(update_action)
when -1 # downgrade
log.action(UpdateProjectAction.new(platform, makefile_project, :label => 'Update'))
if which('drush').nil?
if @force_changes
owarn "Forcing downgrade."
else
log.error("#{platform_project.extended_name}: use --force to downgrade or install Drush >=6.0.")
end
elsif platform_project.drupal?
if @platform.bootstrapped?
if @force_changes
owarn "Downgrading a bootstrapped Drupal platform."
else
log.error("#{platform_project.extended_name} cannot be downgraded because it is bootstrapped (use --force to override)")
end
end
elsif platform_project.installed?(site)
if @force_changes
owarn "Downgrading an installed/enabled project."
else
log.error("#{platform_project.extended_name}#{p} must be uninstalled before downgrading (use --force to override)")
end
end
when nil # One or both projects have no version
# Check whether the content of the projects is consistent
begin
diff = makefile_project.file_level_compare_with platform_project
rescue => ex
odie "Failed to verify the integrity of #{component.extended_name}: #{ex}"
end
if diff.empty?
log.notice("#{Tty.white}[OK]#{Tty.reset} #{platform_project.extended_name}#{p}")
else
log.action(update_action)
log.notice(diff.join("\n"))
if platform_project.has_version? and (not makefile_project.has_version?)
if @force_changes
owarn "Upgrading #{makefile_project.name} to unknown version."
else
log.error("Cannot upgrade #{makefile_project.name} from known version to unknown version")
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_versions\n if @local_version && \n (@local_version.to_machine_format >= @website_version.to_machine_format)\n display_versions\n puts \"You have the most recent version.\"\n puts \"Exiting...\"\n exit 0\n end\nend",
"def diff\n deprecation_notice!\n downstream = @cisauraus.downstreams(app, 1).first\n verify_downstream! downstream\n\n print_and_flush \"Comparing #{app} to #{downstream}...\"\n\n diff = @cisauraus.diff(app)\n print_and_flush \"done, \"\n\n if diff.size > 0\n display \"#{app} ahead by #{diff.size} #{plural('commit', diff.size)}:\"\n diff.each do |commit|\n commit_detail = `git log -n 1 --pretty=format:\" %h %ad %s (%an)\" --date=short #{commit} 2>/dev/null`\n if $?.exitstatus == 0\n display commit_detail\n else\n display \" #{commit}\"\n end\n end\n else\n display \"everything is up to date\"\n end\n end",
"def release_version!\n projects.each { |project| project.release_version!(tag_full_name) }\n print_log 'Versions released'\n slack_notifier.ping(release_message, icon_emoji: ':see_no_evil:')\n end",
"def compare_build_vers(loc_ver,rem_ver)\n if loc_ver.to_s.match(/No/)\n result = 0\n else\n if rem_ver.to_s.match(/-/) and !rem_ver.to_s.match(/beta/)\n if $verbose == 1\n puts \"Local build date: \"+loc_ver.to_s\n puts \"Remote build date: \"+rem_ver.to_s\n end\n if rem_ver.to_time > loc_ver.to_time\n result = 0\n else\n result = 1\n end\n else\n if $verbose == 1\n puts \"Local build version: \"+loc_ver\n puts \"Remote build version: \"+rem_ver\n end\n if loc_ver !~ /No/\n loc_ver = Versionomy.parse(loc_ver)\n rem_ver = Versionomy.parse(rem_ver)\n if rem_ver > loc_ver\n result = 0\n else\n result = 1\n end\n else\n result = 2\n end\n end\n end\n if result == 0\n puts \"Remote version of build is newer than local\"\n else\n if result == 1\n puts \"Local version of build is up to date\"\n else\n puts \"Local version could not be accurately determined\"\n end\n end\n return result\nend",
"def VersionALtB(a_version, b_version)\n a_version_l = Builtins.filter(Builtins.splitstring(a_version, \"-.\")) do |s|\n Builtins.regexpmatch(s, \"^[0123456789]+$\")\n end\n b_version_l = Builtins.filter(Builtins.splitstring(b_version, \"-.\")) do |s|\n Builtins.regexpmatch(s, \"^[0123456789]+$\")\n end\n\n Builtins.y2milestone(\n \"Comparing versions %1 and %2\",\n a_version_l,\n b_version_l\n )\n a_size = Builtins.size(a_version_l)\n b_size = Builtins.size(b_version_l)\n longer_size = Ops.greater_than(a_size, b_size) ? a_size : b_size\n\n b_version_is_newer = false\n compare = 0 # <0 if a<b, =0 if a==b, >0 if a>b\n i = 0\n while Ops.less_than(i, longer_size)\n # -1 will make the desirable outcome of \"2\" < \"2.0\"\n a_item = Builtins.tointeger(Ops.get(a_version_l, i, \"-1\"))\n b_item = Builtins.tointeger(Ops.get(b_version_l, i, \"-1\"))\n if Ops.less_than(a_item, b_item)\n compare = -1\n break\n end\n if Ops.greater_than(a_item, b_item)\n compare = 1\n break\n end\n i = Ops.add(i, 1)\n end\n\n Builtins.y2milestone(\"%1 <=> %2 -> %3\", a_version, b_version, compare)\n Ops.less_than(compare, 0)\n end",
"def compare_versions(version_a, version_b)\n if version_a == version_b\n return 0\n else\n version_a_d = deconstruct_version_string(version_a)\n version_b_d = deconstruct_version_string(version_b)\n\n if version_a_d[0] > version_b_d[0] ||\n (version_a_d[0] == version_b_d[0] && version_a_d[1] > version_b_d[1]) ||\n (version_a_d[0] == version_b_d[0] && version_a_d[1] == version_b_d[1] && version_a_d[2] > version_b_d[2])\n return 1\n else\n return -1\n end\n end\n end",
"def compare(project, from, to)\n get(\"/projects/#{url_encode project}/repository/compare\", query: { from: from, to: to })\n end",
"def compare_version(a, b)\n\n\t\t#split into titl.maj.min.bug.ext\n\t\ta_segments = a.split('.')\n\t\tb_segments = b.split('.')\n\n\t\t#puts a_segments\n\t\t#puts b_segments\n\n\t\t#compare major 1.x.x\n\t\tcase\n\t\twhen a_segments[1].to_i < b_segments[1].to_i\n\t\t\t-1\n\t\twhen a_segments[1].to_i > b_segments[1].to_i\n\t\t\t1\n\t\telse\n\t\t\t#compare minor 1.1.x\n\t\t\tcase\n\t\t\twhen a_segments[2].to_i < b_segments[2].to_i\n\t\t\t-1\n\t\t\twhen a_segments[2].to_i > b_segments[2].to_i\n\t\t\t\t1\n\t\t\telse\n\t\t\t\t#compare point 1.1.1\n\t\t\t\tcase\n\t\t\t\twhen a_segments[3].to_i < b_segments[3].to_i\n\t\t\t\t\t-1\n\t\t\t\twhen a_segments[3].to_i > b_segments[3].to_i\n\t\t\t\t\t1\n\t\t\t\telse\n\t\t\t\t\t0\n\t\t\t\tend\n\t\t\tend\n\t\tend #END comparator\n\tend",
"def log_changes(changes, prev_tag)\n if ( changes[:simp_core].empty? &&\n changes[:assets].empty? &&\n changes[:modules].empty? )\n puts( \"No changes found for any components since SIMP #{prev_tag}\")\n else\n require 'pager'\n include Pager\n page\n\n separator = '='*80\n puts\n puts separator\n puts \"Comparison with SIMP #{prev_tag}\"\n [:simp_core, :assets, :modules].each do |section|\n changes[section].sort_by { |key| key}.each do |component_name, info|\n puts <<~EOM\n #{separator}\n #{component_name}:\n Current version: #{info[:current_version]} Previous version: #{info[:previous_version]}\n CHANGELOG diff:\n #{info[:changelog_diff].strip.gsub(/^/,' ') + \"\\n\"}\n Git Log\n #{info[:git_log_output].strip.gsub(/^/,' ') + \"\\n\"}\n EOM\n end\n\n puts\n end\n end\n end",
"def changed_files_since_deploy\n if File.exists?(\"log/latest-REVISION-syntaxcheck\")\n revision = File.read(\"log/latest-REVISION-syntaxcheck\").chomp\n\n `git whatchanged #{revision}..HEAD`.split(\"\\n\").select{|l| l =~ /^\\:/}.collect {|l| l.split(\"\\t\")[1]}.sort.uniq\n else\n puts \"log/latest-REVISION-syntaxcheck not found. run 'cap fetch_currently_deployed_version' to get it\"\n []\n end\n end",
"def update_component_versions\n logger.info(\n 'Updating component versions',\n project: project_path,\n branch: target_branch\n )\n\n version_files = VERSION_FILES\n\n # Prior to 13.10.0, Workhorse is still a separate component from the\n # Rails application.\n #\n # This check will be removed as part of\n # https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1628.\n if @gitlab_version.major <= 13 && @gitlab_version.minor < 10\n version_files = [Project::GitlabWorkhorse.version_file, *version_files]\n end\n\n branch = ee_stable_branch\n versions = version_files.each_with_object({}) do |file, hash|\n hash[file] = read_version(ee_project_path, file, branch).to_s\n end\n\n commit_version_files(\n target_branch,\n versions,\n message: 'Update component version files'\n )\n end",
"def project_versions(project,issues)\n issues.collect(&:fixed_version).compact.uniq\n end",
"def version_compare(v1, v2)\n gem_v1 = Gem::Version.new(v1.gsub(/\\A\\s*(#{Gem::Version::VERSION_PATTERN}).*/, '\\1'))\n gem_v2 = Gem::Version.new(v2.gsub(/\\A\\s*(#{Gem::Version::VERSION_PATTERN}).*/, '\\1'))\n\n gem_v1 <=> gem_v2\n end",
"def version_from_combobox\n @versions = Project.find(params[:project_id]).shared_versions\n @sorted_versions = []\n @versions.each do |version|\n @sorted_versions.push(version.name.to_s)\n end\n @natural_sorted_versions = \\\n Naturalsorter::Sorter.sort_version(@sorted_versions, false)\n @version = params[:id].to_s\n end",
"def calculate_versions\n tags = `git for-each-ref --sort='*authordate' --format='%(refname:short)' refs/tags/`.split(\"\\n\")\n @last = tags.select {|l| l =~ /(^#{@prefix}-|\\.0$)/ }.last.gsub(/^#{@prefix}-/, '')\n @current = @last\n\n pemajor, major, minor = @last.split('.')\n minor = minor.to_i + 1\n quarter = major.to_i + 1\n @next = \"#{pemajor}.#{major}.#{minor}\"\n @quarter = \"#{pemajor}.#{quarter}.0\"\nend",
"def versions\n self.git.commits\n end",
"def update_app_version_numbers()\n \n version_string = ENV[\"FORCED_VERSION_NUMBER_STRING\"]\n xcode_project_version = nil\n \n if version_string != nil && version_string.length > 0\n\n puts \"using forced version \\\"#{version_string}\\\"\"\n\n else\n\n version_string = get_semver_from_branch\n\n if version_string == nil\n\n app_store_build_number(live: false)\n latest_app_store_version = lane_context[SharedValues::LATEST_VERSION]\n xcode_project_version = get_project_xcode_version\n\n # use largest version (note ascii comparison - not sure if accurate enough)\n version_string = latest_app_store_version > xcode_project_version ? latest_app_store_version : xcode_project_version\n puts \"using version #{version_string} (latest app store = #{latest_app_store_version}, project version = #{xcode_project_version})\"\n\n end\n\n end\n\n # increment build number\n forced_build_number = ENV[\"FORCED_BUILD_NUMBER\"]\n unless forced_build_number == nil || forced_build_number.empty?\n puts \"using forced build number \\\"#{forced_build_number}\\\"\"\n build_number = forced_build_number\n increment_build_number(build_number: build_number)\n else\n current_build_number = latest_testflight_build_number(version: version_string, initial_build_number: 0)\n\n if current_build_number == 0\n if m = version_string.match($semver_regex)\n # if no existing number was found we need to check variations of the same version\n # since Apple handles 1, 1.0, and 1.0.0 independently, but they share build number\n puts \"build number is 0 - checking version variations in case there's a match\"\n\n major = m.captures[0]\n minor = m.captures[1]\n patch = m.captures[2]\n\n puts \"major=#{major} minor=#{minor} patch=#{patch}\"\n if patch == \"0\"\n variation = \"#{major}.#{minor}\"\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n \n if current_build_number == 0 && minor == \"0\"\n variation = major\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n end\n end\n else\n UI.important \"build number is 0 and version is not semantically correct - unable to check version variations (build number may be incorrect)\"\n end\n \n end\n\n build_number = current_build_number + 1\n increment_build_number(build_number: build_number)\n end\n\n # set version number\n current_version_string = xcode_project_version || get_project_xcode_version\n increment_version_number(version_number: version_string)\n\n\n puts \"build_number #{current_build_number} => #{build_number}\"\n puts \"version_number #{current_version_string} => #{version_string}\"\n end",
"def action_version\n log @version\n\n true\n end",
"def update_app_version_numbers\n version_string = ENV['FORCED_VERSION_NUMBER_STRING']\n xcode_project_version = nil\n\n if !version_string.nil? && version_string.length > 0\n\n puts \"using forced version \\\"#{version_string}\\\"\"\n\n else\n\n version_string = get_semver_from_branch(ENV['GIT_HEAD_REF'])\n\n if version_string.nil?\n\n app_store_build_number(live: false)\n latest_app_store_version = lane_context[SharedValues::LATEST_VERSION]\n xcode_project_version = get_project_xcode_version\n\n # use largest version (note ascii comparison - not sure if accurate enough)\n version_string = latest_app_store_version > xcode_project_version ? latest_app_store_version : xcode_project_version\n puts \"using version #{version_string} (latest app store = #{latest_app_store_version}, project version = #{xcode_project_version})\"\n\n end\n\n end\n\n # increment build number\n forced_build_number = ENV['FORCED_BUILD_NUMBER']\n if forced_build_number.nil? || forced_build_number.empty?\n current_build_number = parse_latest_testflight_build_number(version_string)\n\n if current_build_number == 0\n if m = version_string.match(semver_regex)\n # if no existing number was found we need to check variations of the same version\n # since Apple handles 1, 1.0, and 1.0.0 independently, but they share build number\n puts \"build number is 0 - checking version variations in case there's a match\"\n\n major = m.captures[0]\n minor = m.captures[1]\n patch = m.captures[2]\n\n puts \"major=#{major} minor=#{minor} patch=#{patch}\"\n if patch == '0'\n variation = \"#{major}.#{minor}\"\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n\n if current_build_number == 0 && minor == '0'\n variation = major\n current_build_number = latest_testflight_build_number(version: variation, initial_build_number: 0)\n puts \"variation \\\"#{variation}\\\" = #{current_build_number}\"\n end\n end\n else\n UI.important 'build number is 0 and version is not semantically correct - unable to check version variations (build number may be incorrect)'\n end\n\n end\n\n build_number = current_build_number + 1\n increment_build_number(build_number: build_number)\n else\n puts \"using forced build number \\\"#{forced_build_number}\\\"\"\n build_number = forced_build_number\n increment_build_number(build_number: build_number)\n end\n\n # set version number\n current_version_string = xcode_project_version || get_project_xcode_version\n increment_version_number(version_number: version_string)\n update_package_version(version_string)\n\n puts \"build_number #{current_build_number} => #{build_number}\"\n puts \"version_number #{current_version_string} => #{version_string}\"\nend",
"def ver_cmp(version1,version2)\n v_int_lista=version1.split(\".\").map { |x| x.to_i() }\n v_int_listb=version2.split(\".\").map { |x| x.to_i() }\n lena=v_int_lista.length()\n lenb=v_int_listb.length()\n minab=lena<lenb ? lena:lenb\n ii=0\n while(ii<minab)\n if v_int_lista[ii]!=v_int_listb[ii]\n break\n end\n ii=ii+1\n end\n if ii<minab\n then\n return v_int_lista[ii]-v_int_listb[ii]\n elsif ii==minab\n then\n if lena>minab\n then\n return 1\n elsif (lenb > minab)\n then\n return -1\n else\n return v_int_lista[minab-1]-v_int_listb[minab-1]\n end\n end\n return 9999\nend",
"def test_version\n way = create(:way, :with_history)\n used_way = create(:way, :with_history)\n create(:relation_member, :member => used_way)\n way_with_versions = create(:way, :with_history, :version => 4)\n\n create(:way_tag, :way => way)\n create(:way_tag, :way => used_way)\n create(:way_tag, :way => way_with_versions)\n propagate_tags(way, way.old_ways.last)\n propagate_tags(used_way, used_way.old_ways.last)\n propagate_tags(way_with_versions, way_with_versions.old_ways.last)\n\n check_current_version(way.id)\n check_current_version(used_way.id)\n check_current_version(way_with_versions.id)\n end",
"def test_version_files_found\n Dir.glob( @setup_issue_show.issues_directory.join('*.show*') ).each do |file|\n version = /(\\d\\.)+/.match( file )[0][0...-1]\n @setup_issue_show.current_version = version\n\n assert_equal \"#{version}.show.html.erb\", @setup_issue_show.show_file.basename.to_s, 'Did not find the expected version file.'\n end\n end",
"def versions\n return @_versions ||= Regulate::Git::Interface.commits(id)\n end",
"def test_project\n project\n @browser.find_element(:id, 'tab-versions').click\n sleep (2)\n @browser.find_element(:xpath, \"//*[@id='tab-content-versions']/p[2]/a\").click\n version = rand(999).to_s + 'version'\n @browser.find_element(:id, 'version_name').send_keys version\n @browser.find_element(:name, 'commit').click\n #expected = 'Successful creation.'\n expected = 'Создание успешно.'\n assert_equal(expected, @browser.find_element(:id, 'flash_notice').text)\n end",
"def compare(rhs)\n\n\t\t\t\tif (@major > rhs.major) \n\t\t\t\t\treturn VERSION_LOWER\n\t\t\t\telsif (@major < rhs.major)\n\t\t\t\t\treturn VERSION_GREATER\n\t\t\t\telsif (@minor > rhs.minor) \n\t\t\t\t\treturn VERSION_LOWER\n\t\t\t\telsif (@minor < rhs.minor) \n\t\t\t\t\treturn VERSION_GREATER\n\t\t\t\telsif (@build > rhs.build) \n\t\t\t\t\treturn VERSION_LOWER\n\t\t\t\telsif (@build < rhs.build) \n\t\t\t\t\treturn VERSION_GREATER\n\t\t\t\telse\n\t\t\t\t\treturn VERSION_SAME\n\t\t\t\tend\n\n\t\t\tend",
"def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end",
"def test_version\n check_current_version(current_ways(:visible_way).id)\n check_current_version(current_ways(:used_way).id)\n check_current_version(current_ways(:way_with_versions).id)\n end",
"def test_get_version_number\n assert_equal 3, ChangeLogs.get_version_number(1,'test')\n end",
"def print_version_transition(bump_info)\n log_green \" #{bump_info.before_version} => #{bump_info.after_version}\"\n end",
"def comparePOST\n @file = encodeURIComponent(params[:file])\n @versions = params[:versions] || []\n if @versions.size < 2\n redirect_to(\"/wiki/history/#{@file}\")\n else\n redirect_to(\"/wiki/compare/%s/%s/%s\" % [\n @file,\n @versions.last,\n @versions.first]\n )\n end\n end"
] | [
"0.6104768",
"0.60805285",
"0.5968963",
"0.5905088",
"0.58202505",
"0.5816841",
"0.57681805",
"0.56585985",
"0.56272554",
"0.5576809",
"0.555087",
"0.5517455",
"0.5487077",
"0.5481953",
"0.5424551",
"0.5418769",
"0.5416611",
"0.5402685",
"0.5395409",
"0.53744745",
"0.5371622",
"0.53645337",
"0.5362463",
"0.5358047",
"0.534896",
"0.53479874",
"0.5323783",
"0.53001493",
"0.5299275",
"0.5288749"
] | 0.7295632 | 0 |
Deploys a library into the specified location. | def _install
args = Array.new
args << '-a'
args << '--delete'
component.ignore_paths.each { |p| args << "--exclude=#{p}" }
dst_path = platform.local_path + platform.contrib_path + component.target_path
dont_debug { dst_path.mkpath }
args << component.local_path.to_s + '/'
args << dst_path.to_s + '/'
begin
runBabyRun 'rsync', args
rescue => ex
odie "Installing or updating library #{component.name} failed: #{ex}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_local_library(path)\n src_path = path.realpath\n library_name = src_path.basename\n destination_path = library_path(library_name)\n\n # things get weird if the sketchbook contains the library.\n # check that first\n if destination_path.exist?\n uhoh = \"There is already a library '#{library_name}' in the library directory\"\n return destination_path if destination_path == src_path\n\n # maybe it's a symlink? that would be OK\n if destination_path.symlink?\n return destination_path if destination_path.readlink == src_path\n\n @last_msg = \"#{uhoh} and it's not symlinked to #{src_path}\"\n return nil\n end\n\n @last_msg = \"#{uhoh}. It may need to be removed manually.\"\n return nil\n end\n\n # install the library\n Host.symlink(src_path, destination_path)\n destination_path\n end",
"def publish_pod_lib()\n\t\t \t\tverbose_message(\"publishing pod repo=#{@podrepo} spec=#{@podspec}\")\n\t\t \t\tshell_command(\"bundle exec pod repo push #{@podrepo} #{@podspec} --allow-warnings\")\n\t\t \tend",
"def deploy(package_path, opts={}, &block)\n end",
"def upload_package_to_s3(sub_path)\n package = create_package(sub_path)\n raise \"Generated different package for same contents\" unless package_matches_download(package)\n upload_package(package)\n package\n end",
"def find_and_copy thelib, newplace\n tp = \"#{TGT_SYS_DIR}usr/lib/#{thelib}\"\n if File.exists? tp\n cp tp, newplace\n else\n puts \"Can't find library #{tp}\"\n end\n end",
"def install!\n\t\t\traise \"Target exists\" if target.present?\n\n\t\t\t# Directory entry - create the directory\n\t\t\ttarget.mkpath\n\t\tend",
"def install(target_dir)\n download\n verify\n unpack\n move(target_dir)\n ensure\n cleanup\n end",
"def publish!\n mkdir_p File.join(self.publish_path, self.to_s)\n self.targets.each do |tgt|\n install File.join(self.to_s, tgt), File.join(self.publish_path, self.to_s, tgt)\n end\n end",
"def install_component\n if (backend != :stdlib && command?('rsync')) || backend == :rsync\n FileUtils.mkdir_p destination_path\n cmd = [command?('rsync'), '-rtc', '--del', '--links', \"#{source_path}/\", destination_path]\n logger.debug { \"Running command: #{cmd.join ' '}\" }\n system(*cmd)\n else\n FileUtils.remove_entry_secure destination_path if Dir.exist? destination_path\n FileUtils.mkdir_p destination_path\n FileUtils.cp_r \"#{source_path}/.\", destination_path, preserve: true\n end\n end",
"def move_package\n begin\n package_file = File.join(@tmpdir, 'pkg', \"#{@plugin.vendor}-#{@package_name}-#{@plugin.metadata[:version]}.tar.gz\")\n FileUtils.cp(package_file, '.')\n rescue => e\n puts 'Could not copy package to working directory'\n raise e\n end\n end",
"def vendorize_with_copy\n FileUtils.cp_r \"#{JSPEC_ROOT}/lib\", normalize('lib')\n end",
"def install_package(target_package_path); raise NotImplementedError; end",
"def add_system_library(names)\n Array(names).each do |name|\n path = \"usr/lib/lib#{name}.dylib\"\n unless ref = project.frameworks_group.files.find { |ref| ref.path == path }\n ref = project.frameworks_group.new_file(path, :sdk_root)\n end\n frameworks_build_phase.add_file_reference(ref, true)\n ref\n end\n end",
"def vendorize_with_symlink\n FileUtils.symlink \"#{JSPEC_ROOT}/lib\", normalize('lib'), :force => true\n end",
"def push_package!\n require 'packagecloud'\n pkg = Packagecloud::Package.new(file: package_file)\n client.put_package('duo-openvpn', pkg, distro_id)\n end",
"def create_package(sub_path)\n package = Tempfile.new(@commit_hash)\n @logger.info \"Creating #{package.path}\"\n Dir.chdir(@source_location + '/' + sub_path) do\n # add a commit_hash file whose contents represent the key for this package\n IO.write('commit_hash', @commit_hash)\n RakeUtils.system \"tar -zcf #{package.path} *\"\n end\n @logger.info 'Created'\n package\n end",
"def deploy(name, path, from=\"en_US\", to)\n agency = options[:agency]\n bucket = options[:bucket]\n Log.info(\"package deploy name=#{name} path=#{path} from=#{from} \" \\\n \"to=#{to} agency=#{agency} bucket=#{bucket}\")\n unless options[:bucket]\n raise EngineFailure, '--bucket was not specified and $AWS_DEFAULT_BUCKET is not set'\n end\n\n ::Taxi::Package.deploy(\n name, path, from: from, to: to, bucket: bucket, agency: agency\n )\n end",
"def deploy_artifact(notation, file_path, url, deploy_opts = {}, lockjar_opts = {})\n Runtime.instance.resolver(lockjar_opts).naether.deploy_artifact(\n notation, file_path, url, deploy_opts)\n end",
"def install\n end",
"def install_library(library_name)\n index_libraries\n _install_library(library_name)\n end",
"def deploy_application\n deploy(selfdir + \"app\")\n end",
"def mklib(path, home_path = true)\n \n if (home_path)\n lib = path + \"/lib\"\n else\n lib = path\n end\n \n $LOAD_PATH << lib\n \nend",
"def upload(path, check_resources = true)\n unless File.exist? path\n raise CFoundry::Error, \"Invalid application path '#{path}'\"\n end\n\n zipfile = \"#{Dir.tmpdir}/#{@guid}.zip\"\n tmpdir = \"#{Dir.tmpdir}/.cf_#{@guid}_files\"\n\n FileUtils.rm_f(zipfile)\n FileUtils.rm_rf(tmpdir)\n\n prepare_package(path, tmpdir)\n\n resources = determine_resources(tmpdir) if check_resources\n\n packed = CFoundry::Zip.pack(tmpdir, zipfile)\n\n @client.base.upload_app(@guid, packed && zipfile, resources || [])\n ensure\n FileUtils.rm_f(zipfile) if zipfile\n FileUtils.rm_rf(tmpdir) if tmpdir\n end",
"def deploy(&block)\n in_directory do\n self.setup!\n self.push_with_retry!\n block.call(self, platform_api, output) if block_given?\n end\n ensure\n self.teardown!\n end",
"def inject_jar(jar_path)\n jar_dir = tmp_app_path.join('Contents/Java')\n jar_dir.rmtree\n jar_dir.mkdir\n cp Pathname.new(jar_path), jar_dir\n end",
"def copy_lib (src, loaded_from)\n return src if src.to_s.start_with?(\"lib/\")\n\n dst = LibraryDir + src.basename\n if dst.exist? # already been copied\n return dst\n end\n\n if src.dirname.to_s == \"@loader_path\"\n src = loaded_from.dirname + src.basename\n end\n fail \"bad path #{src}\" unless src.absolute?\n\n log \"\\tCopying #{src} --> #{dst}\"\n unless system(\"cp\", src.to_s, dst.to_s)\n fail \"cp failed on #{src}\"\n end\n dst.chmod(0644) # Make it writable so we can change its imports\n\n process(dst, src)\n return dst\nend",
"def install\n dest_folder = get_install_directory\n raise \"Couldn't write to or create directories #{@dirs.join(' or ')} something is up with your system!\" unless dest_folder\n string = get_remote_string @url\n verify_rules @url, string\n install_string string, dest_folder\n end",
"def update_libraries(uri); end",
"def install\n end",
"def install\n end"
] | [
"0.5888976",
"0.58690125",
"0.57633793",
"0.5740246",
"0.5650665",
"0.5595416",
"0.5500695",
"0.54927284",
"0.5443853",
"0.5400413",
"0.5385371",
"0.5382074",
"0.5320944",
"0.52846956",
"0.5275405",
"0.52716744",
"0.5267564",
"0.52641016",
"0.52589405",
"0.5245488",
"0.52311736",
"0.5231111",
"0.5206713",
"0.5204732",
"0.51991653",
"0.5197002",
"0.51940453",
"0.51899636",
"0.5181501",
"0.5181501"
] | 0.6252304 | 0 |
Creates GitHub URLs with owner and repository name | def github(repository, owner = 'siimple')
"https://github.com/#{owner}/#{repository}.git"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def github_url\n @github_url ||= \"https://github.com/#{options[:github_owner]}/#{name}\"\n end",
"def url\n \"http://github.com/#{repo.owner.login}/#{repo.name}/#{name}\"\n end",
"def name_to_url(name)\n \"https://github.com/#{name}.git\"\n end",
"def github_url\n \"https://github.com/#{self.nickname}\"\n end",
"def giturl(project_name, repo_name) ; end",
"def generate_github_url\n prefix = Environment.config['github']['default_prefix']\n self.github = \"#{prefix}/#{slug}.md\"\n end",
"def github_url\n GITHUB_ARTICLES_URL + file_name\n end",
"def url\n \"http://github.com/#{login}\"\n end",
"def user_repos_url(username,token) # :yields:String\n BASE_URL + USERS + \"#{username}/\" + \"repos?access_token=#{token}\"\n end",
"def github_url\n github_user.blank? ? nil : \"#{GITHUB_URL}#{github_user}\"\n end",
"def url\n \"http://github.com/#{@account}/#{name}/tree/master\"\n end",
"def github_buttons(repository, username)\n [\n ['', \"Follow @#{username} on GitHub\", \"Follow @#{username}\", ''],\n [\"/#{repository}\", \"Star #{username}/#{repository} on GitHub\", 'Star', 'star'],\n [\"/#{repository}/subscription\", \"Watch #{username}/#{repository} on GitHub\", 'Watch', 'eye'],\n [\"/#{repository}/fork\", \"Fork #{username}/#{repository} on GitHub\", 'Fork', 'repo-forked']\n ]\nend",
"def clone_url\n \"git://github.com/#{@account}/#{name}.git\"\n end",
"def repository_url(repositiory)\n http_uri + repositiory.path\n end",
"def github(name, ref = 'master')\n gitrepo \"github.com\", name, ref\nend",
"def github_url\n case protocol\n when :ssh\n \"git@github.com:#{repo_identifier}.git\"\n when :https\n \"https://github.com/#{repo_identifier}.git\"\n when :git\n \"git://github.com/#{repo_identifier}.git\"\n else\n raise UnknownGitHubProtocol.new(protocol)\n end\n end",
"def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end",
"def link_for_repo(repo)\n repo.url\n end",
"def build_asset_url(author, repository, options)\n Puppet.warning('Building URL myself.')\n\n tag = options[:release]\n\n if tag == 'latest'\n # Rework \"latest\" to \"master\"\n tag = 'master'\n end\n\n suffix = (options[:use_zip]) ? '.zip' : '.tar.gz'\n\n Kernel.format(\n 'https://github.com/%{author}/%{repository}/archive/%{tag}%{suffix}',\n author: author,\n repository: repository,\n tag: tag,\n suffix: suffix,\n )\nend",
"def github_link(username, link_options = nil)\n # default options\n link_options ||= {target: '_blank', rel: 'nofollow'}\n\n if username.present?\n link_to \"@#{username}\", \"https://github.com/#{username}\", link_options\n end\n end",
"def link_commits(repo_path, username, repo_name)\n\n # create a partial repo URL for GitHub repository\n partial_URL = \"https://github.com/#{username}/#{repo_name}/commit/\"\n \n # access the repository at the given repo_path\n repo = Grit::Repo.new(repo_path)\n \n all_commits = get_all_commits(repo)\n \n #all_commits.each{ |commit|\n # puts \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n #}\n\n return all_commits.map do |commit|\n \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n end\nend",
"def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end",
"def groupon_path(repo)\n github = \"github.groupondev.com\"\n ENV[\"INTERNAL_GEMS_OVER_SSH\"] ? \"git@#{github}:#{repo}.git\" : \"https://#{github}/#{repo}.git\"\nend",
"def name\n 'GitHub'\n end",
"def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end",
"def canonical_repository_url\n \"https://#{@settings.host}/scm/#{attributes[:repository_namespace]}/#{attributes[:repository_name]}.git\"\n end",
"def get_github_pages_url(book)\n if repo_exists?(book.repo_id)\n full_name = client.repository(book.repo_id).full_name\n else\n full_name = book.gh_full_name\n end\n github_pages_url = \"http://\" + full_name.split('/')[0].downcase + \".github.io/\" + full_name.split('/')[1]\n rescue Octokit::NotFound\n nil\n rescue NoMethodError\n nil\n end",
"def create_repos\n response = HTTParty.get('https://api.github.com/orgs/' + org_name + '/repos')\n data = response.parsed_response\n data.each {|repo| github_repos.create(name: repo['name'], github_id: repo['id'])}\n end",
"def github_pages_url\n link = object.path.gsub(\"::\", \"/\")\n link.tr!(\"?\", \"%3F\")\n\n \"#{GITHUB_PAGES_URL}/#{link}#{link_suffix}\"\n end",
"def repo(user_name, repo_name)\n Github::Repo.new @access_token, user_name, repo_name\n end"
] | [
"0.74512136",
"0.73287416",
"0.71374315",
"0.7082303",
"0.70542973",
"0.7044448",
"0.701122",
"0.6988843",
"0.6872043",
"0.6682912",
"0.66719663",
"0.6652131",
"0.66361123",
"0.65884995",
"0.6584942",
"0.65788907",
"0.652561",
"0.64204496",
"0.6414047",
"0.64113456",
"0.63616675",
"0.6319425",
"0.6280975",
"0.62652457",
"0.62598294",
"0.6253811",
"0.62331384",
"0.61664313",
"0.6136823",
"0.61171514"
] | 0.73397166 | 1 |
GET /vehicle_classes/new GET /vehicle_classes/new.json | def new
@vehicle_class = VehicleClass.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @vehicle_class }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @vehicle_class = VehicleClass.new(params[:vehicle_class])\n\n respond_to do |format|\n if @vehicle_class.save\n format.html { redirect_to @vehicle_class, notice: 'Vehicle class was successfully created.' }\n format.json { render json: @vehicle_class, status: :created, location: @vehicle_class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vehicle_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @class = Classe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class }\n end\n end",
"def new\n @classtable = Classtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classtable }\n end\n end",
"def new\n @vehicle = Vehicle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vehicle }\n end\n end",
"def new\n @class_taken = ClassTaken.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_taken }\n end\n end",
"def new\n @vehicle_class = VehicleClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vehicle_class }\n end\n end",
"def new\n @classroom = classroom.new\n\n render json: @classroom\n end",
"def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classified }\n end\n end",
"def new\n add_breadcrumb \"add\", nil, \"glyphicon-plus-sign\"\n\n @vehicle = Vehicle.new\n @years = VehicleYear.all\n @makes = []\n @models = []\n @trims = []\n @types = []\n @doors = []\n @sizes = []\n\n @select_years = VehicleYear.all\n @select_makes = VehicleMake.all\n @select_models = VehicleModel.all\n @select_trims = VehicleTrim.all\n @select_types = VehicleType.all\n @select_doors = VehicleDoor.all\n @select_sizes = VehicleSize.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vehicle }\n end\n end",
"def create\n @vehicle_class = VehicleClass.new(params[:vehicle_class])\n\n respond_to do |format|\n if @vehicle_class.save\n format.html { redirect_to(@vehicle_class, :notice => 'Vehicle class was successfully created.') }\n format.xml { render :xml => @vehicle_class, :status => :created, :location => @vehicle_class }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vehicle_class.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @classwork = Classwork.new\n \n drop_breadcrumb('新增')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classwork }\n end\n end",
"def new\n @classroom = Classroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classroom }\n end\n end",
"def new\n @class_mstr = ClassMstr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_mstr }\n end\n end",
"def new\n @classe = Classe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classe }\n end\n end",
"def new\n @test_class = TestClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_class }\n end\n end",
"def new\n @iclass = Iclass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @iclass }\n end\n end",
"def new\n @entity = @klass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end",
"def new\n @class_room = ClassRoom.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_room }\n end\n end",
"def create\n @clclass = Clclass.new(params[:clclass])\n\n respond_to do |format|\n if @clclass.save\n format.html { redirect_to @clclass, notice: 'Clclass was successfully created.' }\n format.json { render json: @clclass, status: :created, location: @clclass }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @contacter = Contacter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contacter }\n end\n end",
"def new\n @carpool = Carpool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carpool }\n end\n end",
"def new\n @clclass = Clclass.new\n @courses = Course.all\n @teachers = Teacher.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clclass }\n end\n end",
"def new\n @myclass = Myclass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @myclass }\n end\n end",
"def new\n @travel_type = TravelType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @travel_type }\n end\n end",
"def new\n @item_class = ItemClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_class }\n end\n end",
"def create\n @class = Classe.new(params[:class])\n\n respond_to do |format|\n if @class.save\n format.html { redirect_to @class, notice: 'Classe was successfully created.' }\n format.json { render json: @class, status: :created, location: @class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @car = Car.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car }\n\t \n end\n end",
"def new\n @vehicle = Vehicle.new\n authorize! :enabled_menu_new, @vehicle\n\n logger.info(\"Loading New Vehicle Form\")\n\n @vehicle.model = Model.new if @vehicle.model.nil?\n @vehicle.model.make = Make.new if @vehicle.model.make.nil?\n @vehicle.trim = Trim.new if @vehicle.trim.nil?\n\n # View-model for AngularJS controller\n create_edit_gon_variables(@vehicle)\n\n gon.vehicleFormIsNewRecord = true\n \n #gon.adjusters = Adjuster.includes(:contact).active.as_json(include_contact: \"yes\") # Finding all active adjuster and contacts\n gon.noEmailsFound = I18n.t(\"views.adjuster.create_edit_form.no_emails_found\") # Adjuster email search stuff\n gon.cancelLocation = request.referer || root_url\n gon.cownerfca = true\n \n respond_to do |format|\n format.html { render (params[:version]=='sds' ? \"assignments/new\" : \"new\") }\n format.json { render json: @vehicle }\n end\n end",
"def new\n @districtclass = Districtclass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @districtclass }\n end\n end",
"def new\n @clazz = Clazz.new\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @clazz }\n format.js\n end\n end"
] | [
"0.7480554",
"0.71904474",
"0.714868",
"0.7079963",
"0.7075884",
"0.70171165",
"0.68980235",
"0.68858063",
"0.68717206",
"0.6846336",
"0.6812928",
"0.6785336",
"0.6776849",
"0.6772398",
"0.67678136",
"0.67497617",
"0.67454517",
"0.6737879",
"0.6716264",
"0.66884923",
"0.6674842",
"0.6673683",
"0.666178",
"0.6658244",
"0.66371655",
"0.6635045",
"0.6629689",
"0.6608354",
"0.6594401",
"0.65871656"
] | 0.7892947 | 0 |
POST /vehicle_classes POST /vehicle_classes.json | def create
@vehicle_class = VehicleClass.new(params[:vehicle_class])
respond_to do |format|
if @vehicle_class.save
format.html { redirect_to @vehicle_class, notice: 'Vehicle class was successfully created.' }
format.json { render json: @vehicle_class, status: :created, location: @vehicle_class }
else
format.html { render action: "new" }
format.json { render json: @vehicle_class.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @vehicle_class = VehicleClass.new(params[:vehicle_class])\n\n respond_to do |format|\n if @vehicle_class.save\n format.html { redirect_to(@vehicle_class, :notice => 'Vehicle class was successfully created.') }\n format.xml { render :xml => @vehicle_class, :status => :created, :location => @vehicle_class }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vehicle_class.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle = Vehicle.new(vehicle_params)\n if @vehicle.save\n render json: { status: 'Vehicle created successfully', vehicle: @vehicle }, status: :created\n else\n render json: { errors: @vehicle.errors.full_messages }, status: :bad_request\n end\n end",
"def create\n @trainclass = Trainclass.new(trainclass_params)\n\n respond_to do |format|\n if @trainclass.save\n format.html { redirect_to @trainclass, notice: 'Trainclass was successfully created.' }\n format.json { render :show, status: :created, location: @trainclass }\n else\n format.html { render :new }\n format.json { render json: @trainclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @classs = Classs.new(classs_params)\n\n respond_to do |format|\n if @classs.save\n format.html { redirect_to @classs, notice: 'Classs was successfully created.' }\n format.json { render :show, status: :created, location: @classs }\n else\n format.html { render :new }\n format.json { render json: @classs.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.debug \"[ClassificationsController.create] params.class: #{params.class}, params: #{params}\"\n @classifaction = Classification.new transaction_data: params\n @classifaction.classifiers << StatusCodeClassifier.classify( @classifaction.transaction_data )\n @classifaction.classify\n\n if @classifaction.save\n render json: @classifaction.as_jsonapi, status: :created\n else\n render json: { error: 'oops' }, status: 500\n end\n end",
"def create\n @test_class = TestClass.new(params[:test_class])\n\n respond_to do |format|\n if @test_class.save\n format.html { redirect_to @test_class, notice: 'Test class was successfully created.' }\n format.json { render json: @test_class, status: :created, location: @test_class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @vehicle_class = VehicleClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vehicle_class }\n end\n end",
"def create\n @class = Classe.new(params[:class])\n\n respond_to do |format|\n if @class.save\n format.html { redirect_to @class, notice: 'Classe was successfully created.' }\n format.json { render json: @class, status: :created, location: @class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_vehicles vehicle\n self.create_vehicle(:four_wheeler => vehicle[:four_wheeler],:two_wheeler => vehicle[:two_wheeler],:none => vehicle[:none])\n end",
"def create\n @clclass = Clclass.new(params[:clclass])\n\n respond_to do |format|\n if @clclass.save\n format.html { redirect_to @clclass, notice: 'Clclass was successfully created.' }\n format.json { render json: @clclass, status: :created, location: @clclass }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n s_id = Allotment.where(user_id: current_user.id).pluck(:school_id).first\n standard_id = Standard.where(name: params[:class_mapping][:standard]).pluck(:id).first\n section_id = Section.where(name: params[:class_mapping][:section]).pluck(:id).first\n @classes = ClassMapping.new({:section_id => section_id, :standard_id => standard_id, :school_id => s_id})\n @saved_class = { id:@classes.id, standard: params[:class_mapping][:standard], section: params[:class_mapping][:section], school: s_id}\n if @classes.save\n render :json => @saved_class\n end\n end",
"def create\n @classname = Classname.new(classname_params)\n\n respond_to do |format|\n if @classname.save\n format.html { redirect_to @classname, notice: 'Classname was successfully created.' }\n format.json { render :show, status: :created, location: @classname }\n else\n format.html { render :new }\n format.json { render json: @classname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle = Vehicle.new(vehicle_params)\n\n respond_to do |format|\n if @vehicle.save\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle }\n else\n format.html { render :new }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle = Vehicle.new(vehicle_params)\n\n respond_to do |format|\n if @vehicle.save\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle }\n else\n format.html { render :new }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle = Vehicle.new(vehicle_params)\n\n respond_to do |format|\n if @vehicle.save\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle }\n else\n format.html { render :new }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @class_detail = ClassDetail.new(class_detail_params)\n\n respond_to do |format|\n if @class_detail.save\n format.html { redirect_to class_details_path, notice: 'Class detail was successfully created.' }\n format.json { render :show, status: :created, location: @class_detail }\n else\n format.html { render :new }\n format.json { render json: @class_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @districtclass = Districtclass.new(params[:districtclass])\n\n respond_to do |format|\n if @districtclass.save\n format.html { redirect_to @districtclass, notice: 'Districtclass was successfully created.' }\n format.json { render json: @districtclass, status: :created, location: @districtclass }\n else\n format.html { render action: \"new\" }\n format.json { render json: @districtclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle_type = VehicleType.new(vehicle_type_params)\n\n respond_to do |format|\n if @vehicle_type.save\n images\n\n format.html { redirect_to @vehicle_type, notice: 'Vehicle type was successfully created.' }\n format.json { render json: @vehicle_type, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @vehicle_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @myclass = Myclass.new(params[:myclass])\n\n respond_to do |format|\n if @myclass.save\n format.html { redirect_to @myclass, notice: 'Myclass was successfully created.' }\n format.json { render json: @myclass, status: :created, location: @myclass }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @teacher_class = TeacherClass.new(teacher_class_params)\n\n respond_to do |format|\n if @teacher_class.save\n format.html { redirect_to @teacher_class, notice: 'Teacher class was successfully created.' }\n format.json { render action: 'show', status: :created, location: @teacher_class }\n else\n format.html { render action: 'new' }\n format.json { render json: @teacher_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @vehicle_class = VehicleClass.find(params[:id])\n @vehicle_class.destroy\n\n respond_to do |format|\n format.html { redirect_to vehicle_classes_url }\n format.json { head :ok }\n end\n end",
"def create\n @subclass = Subclass.new(subclass_params)\n\n respond_to do |format|\n if @subclass.save\n format.html { redirect_to @subclass, notice: 'Subclass was successfully created.' }\n format.json { render :show, status: :created, location: @subclass }\n else\n format.html { render :new }\n format.json { render json: @subclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @data_class = DataClass.new(data_class_params)\n\n respond_to do |format|\n if @data_class.save\n format.html { redirect_to @data_class, notice: 'Data class was successfully created.' }\n format.json { render :show, status: :created, location: @data_class }\n else\n format.html { render :new }\n format.json { render json: @data_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicletype = Vehicletype.new(vehicletype_params)\n\n respond_to do |format|\n if @vehicletype.save\n format.html { redirect_to @vehicletype, notice: 'Vehicletype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vehicletype }\n else\n format.html { render action: 'new' }\n format.json { render json: @vehicletype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seatclass = Seatclass.new(seatclass_params)\n\n respond_to do |format|\n if @seatclass.save\n format.html { redirect_to @seatclass, notice: 'Seatclass was successfully created.' }\n format.json { render :show, status: :created, location: @seatclass }\n else\n format.html { render :new }\n format.json { render json: @seatclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @food_class = FoodClass.new(food_class_params)\n\n respond_to do |format|\n if @food_class.save\n format.html { redirect_to @food_class, notice: 'Food class was successfully created.' }\n format.json { render :show, status: :created, location: @food_class }\n else\n format.html { render :new }\n format.json { render json: @food_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @classification = Classification.new(classification_params)\n\n respond_to do |format|\n if @classification.save\n format.html { redirect_to @classification, notice: t('controller.successfully_created', model: t('activerecord.models.classification')) }\n format.json { render json: @classification, status: :created, location: @classification }\n else\n @classification_types = ClassificationType.all\n format.html { render action: \"new\" }\n format.json { render json: @classification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clasification = Clasification.new(clasification_params)\n\n respond_to do |format|\n if @clasification.save\n format.html { redirect_to @clasification, notice: \"Clasification was successfully created.\" }\n format.json { render :show, status: :created, location: @clasification }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @clasification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @class_taken = ClassTaken.new(params[:class_taken])\n\n respond_to do |format|\n if @class_taken.save\n format.html { redirect_to @class_taken, notice: 'Class taken was successfully created.' }\n format.json { render json: @class_taken, status: :created, location: @class_taken }\n else\n format.html { render action: \"new\" }\n format.json { render json: @class_taken.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @detail_class = DetailClass.new(detail_class_params)\n\n respond_to do |format|\n if @detail_class.save\n format.html { redirect_to @detail_class, notice: 'Detail class was successfully created.' }\n format.json { render :show, status: :created, location: @detail_class }\n else\n format.html { render :new }\n format.json { render json: @detail_class.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6542053",
"0.6026368",
"0.6023204",
"0.5992407",
"0.594664",
"0.59091014",
"0.58558065",
"0.5807038",
"0.57515264",
"0.5718768",
"0.5703635",
"0.56932074",
"0.56687945",
"0.56687945",
"0.56687945",
"0.5664808",
"0.56447494",
"0.56216687",
"0.56014836",
"0.5599138",
"0.55764544",
"0.55732876",
"0.55723375",
"0.55642277",
"0.5561214",
"0.5559138",
"0.5549397",
"0.55467135",
"0.55234325",
"0.55215216"
] | 0.72509253 | 0 |
PUT /vehicle_classes/1 PUT /vehicle_classes/1.json | def update
@vehicle_class = VehicleClass.find(params[:id])
respond_to do |format|
if @vehicle_class.update_attributes(params[:vehicle_class])
format.html { redirect_to @vehicle_class, notice: 'Vehicle class was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @vehicle_class.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @vehicle_class = VehicleClass.find(params[:id])\n\n respond_to do |format|\n if @vehicle_class.update_attributes(params[:vehicle_class])\n format.html { redirect_to(@vehicle_class, :notice => 'Vehicle class was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vehicle_class.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle_class = VehicleClass.new(params[:vehicle_class])\n\n respond_to do |format|\n if @vehicle_class.save\n format.html { redirect_to @vehicle_class, notice: 'Vehicle class was successfully created.' }\n format.json { render json: @vehicle_class, status: :created, location: @vehicle_class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vehicle_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @vehicle_class = VehicleClass.find(params[:id])\n @vehicle_class.destroy\n\n respond_to do |format|\n format.html { redirect_to vehicle_classes_url }\n format.json { head :ok }\n end\n end",
"def update\n @classroom = classroom.find(params[:id])\n\n if @classroom.update_attributes(params[:classroom])\n head :no_content\n else\n render json: @classroom.errors, status: :unprocessable_entity\n end\n end",
"def update\n @clclass = Clclass.find(params[:id])\n\n respond_to do |format|\n if @clclass.update_attributes(params[:clclass])\n format.html { redirect_to @clclass, notice: 'Clclass was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainclass.update(trainclass_params)\n format.html { redirect_to @trainclass, notice: 'Trainclass was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainclass }\n else\n format.html { render :edit }\n format.json { render json: @trainclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @classs.update(classs_params)\n format.html { redirect_to @classs, notice: 'Classs was successfully updated.' }\n format.json { render :show, status: :ok, location: @classs }\n else\n format.html { render :edit }\n format.json { render json: @classs.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n add_breadcrumb \"Classes\", classes_url\n add_breadcrumb \"Edit\"\n respond_to do |format|\n if @class.update(class_params)\n format.html { redirect_to classes_url, notice: 'Class was successfully updated.' }\n format.json { render :show, status: :ok, location: @class }\n else\n format.html { render :edit }\n flash[:alert] = @class.errors.full_messages.to_sentence\n format.json { render json: @class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @vehicle.update(vehicle_params)\n render json: { status: 'Vehicle was successfully updated', vehicle: @vehicle }, status: :ok\n else\n render json: { errors: @vehicle.errors.full_messages }, status: :bad_request\n end\n end",
"def set_vehicle(id, params)\n fleet[id] = RoutificApi::Vehicle.new(id, params)\n end",
"def update\n respond_to do |format|\n if @climb_class.update(climb_class_params)\n format.html { redirect_to @climb_class, notice: 'Climb class was successfully updated.' }\n format.json { render :show, status: :ok, location: @climb_class }\n else\n format.html { render :edit }\n format.json { render json: @climb_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @classname.update(classname_params)\n format.html { redirect_to @classname, notice: 'Classname was successfully updated.' }\n format.json { render :show, status: :ok, location: @classname }\n else\n format.html { render :edit }\n format.json { render json: @classname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @klass.update(klass_params)\n format.html { redirect_to @klass, notice: 'Class was successfully updated.' }\n format.json { render :show, status: :ok, location: @klass }\n else\n format.html { render :edit }\n format.json { render json: @klass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @class = Classe.find(params[:id])\n\n respond_to do |format|\n if @class.update_attributes(params[:class])\n format.html { redirect_to @class, notice: 'Classe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clazz = Clazz.find(params[:id])\n\n respond_to do |format|\n if @clazz.update_attributes(params[:clazz])\n format.html { redirect_to @clazz, notice: 'Clazz was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clazz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle_class = VehicleClass.new(params[:vehicle_class])\n\n respond_to do |format|\n if @vehicle_class.save\n format.html { redirect_to(@vehicle_class, :notice => 'Vehicle class was successfully created.') }\n format.xml { render :xml => @vehicle_class, :status => :created, :location => @vehicle_class }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vehicle_class.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vehicle.update(vehicle_params)\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully updated.' }\n format.json { render :show, status: :ok, location: @vehicle }\n put_request\n else\n format.html { render :edit }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @class_detail.update(class_detail_params)\n format.html { redirect_to @class_detail, notice: 'Class detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @class_detail }\n else\n format.html { render :edit }\n format.json { render json: @class_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_class = TestClass.find(params[:id])\n\n respond_to do |format|\n if @test_class.update_attributes(params[:test_class])\n format.html { redirect_to @test_class, notice: 'Test class was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @classtable = Classtable.find(params[:id])\n\n respond_to do |format|\n if @classtable.update_attributes(params[:classtable])\n format.html { redirect_to @classtable, notice: 'Classtable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @classtable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_trainclass\n @trainclass = Trainclass.find(params[:id])\n end",
"def update\n\n respond_to do |format|\n if @classroom.update(classroom_params)\n format.html { redirect_to classrooms_url, notice: t('.notice', name: @classroom.name) }\n format.json { render :show, status: :ok, location: @classroom }\n else\n format.html { render :edit }\n format.json { render json: @classroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def classs_params\n params.require(:classs).permit(:name, :major_id)\n end",
"def update\n respond_to do |format|\n if @seatclass.update(seatclass_params)\n format.html { redirect_to @seatclass, notice: 'Seatclass was successfully updated.' }\n format.json { render :show, status: :ok, location: @seatclass }\n else\n format.html { render :edit }\n format.json { render json: @seatclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @classroom.update(classroom_params)\n render :show, status: :ok, location: @classroom\n else\n render json: @classroom.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @detail_class.update(detail_class_params)\n format.html { redirect_to @detail_class, notice: 'Detail class was successfully updated.' }\n format.json { render :show, status: :ok, location: @detail_class }\n else\n format.html { render :edit }\n format.json { render json: @detail_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clasification.update(clasification_params)\n format.html { redirect_to @clasification, notice: \"Clasification was successfully updated.\" }\n format.json { render :show, status: :ok, location: @clasification }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @clasification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @vehicle_class = VehicleClass.find(params[:id])\n @vehicle_class.destroy\n\n respond_to do |format|\n format.html { redirect_to(vehicle_classes_url) }\n format.xml { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @service_class.update(service_class_params)\n format.html { redirect_to @service_class, notice: 'Service class was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @service_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @instruction_factory = InstructionFactory.find(params[:id]) \n @instruction_factory.classname = params[:instruction_factory][:classname]\n @instruction_factory.name = params[:instruction_factory][:name]\n respond_to do |format|\n \n if @instruction_factory.save\n format.html { redirect_to @instruction_factory, notice: 'instruction_factory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instruction_factory.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.671833",
"0.6302531",
"0.6031832",
"0.598615",
"0.58934313",
"0.58920443",
"0.5878864",
"0.58545864",
"0.5802909",
"0.57998174",
"0.57807755",
"0.5766228",
"0.57642245",
"0.57512605",
"0.5731569",
"0.57221085",
"0.56918097",
"0.56627613",
"0.56342727",
"0.56158066",
"0.5596487",
"0.55698943",
"0.5562553",
"0.5558727",
"0.5558077",
"0.5534126",
"0.5525206",
"0.5522822",
"0.55171937",
"0.55141586"
] | 0.72001874 | 0 |
DELETE /vehicle_classes/1 DELETE /vehicle_classes/1.json | def destroy
@vehicle_class = VehicleClass.find(params[:id])
@vehicle_class.destroy
respond_to do |format|
format.html { redirect_to vehicle_classes_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @vehicle_class = VehicleClass.find(params[:id])\n @vehicle_class.destroy\n\n respond_to do |format|\n format.html { redirect_to(vehicle_classes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @clclass = Clclass.find(params[:id])\n @clclass.destroy\n\n respond_to do |format|\n format.html { redirect_to clclasses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle = Vehicle.find(params[:id])\n @vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to vehicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle = Vehicle.find(params[:id])\n @vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to vehicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_class = TestClass.find(params[:id])\n @test_class.destroy\n\n respond_to do |format|\n format.html { redirect_to test_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle = Vehicle.find(params[:id])\n @vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle_type.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicletype.destroy\n respond_to do |format|\n format.html { redirect_to vehicletypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle_model.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_models_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n render json: { status: 'Vehicle was successfully destroyed' }, status: :ok\n end",
"def destroy\n @classtable = Classtable.find(params[:id])\n @classtable.destroy\n\n respond_to do |format|\n format.html { redirect_to classtables_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb_class.destroy\n respond_to do |format|\n format.html { redirect_to climb_classes_url, notice: 'Climb class was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sob_class.destroy\n respond_to do |format|\n format.html { redirect_to sob_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @class = Classe.find(params[:id])\n @class.destroy\n\n respond_to do |format|\n format.html { redirect_to classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @myclass = Myclass.find(params[:id])\n @myclass.destroy\n\n respond_to do |format|\n format.html { redirect_to myclasses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainclass.destroy\n respond_to do |format|\n format.html { redirect_to trainclasses_url, notice: 'Trainclass was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @districtclass = Districtclass.find(params[:id])\n @districtclass.destroy\n\n respond_to do |format|\n format.html { redirect_to districtclasses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @load_vehicle.destroy\n respond_to do |format|\n format.html { redirect_to load_vehicle_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n vehicle = Vehicle.where(uid: params[:id]).first\n # vehicle.locations.destroy_all\n vehicle.destroy\n render nothing: true, :status =>204\n end",
"def destroy\n @detail_class.destroy\n respond_to do |format|\n format.html { redirect_to detail_classes_url, notice: 'Detail class was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @klass.destroy\n respond_to do |format|\n format.html { redirect_to klasses_url, notice: 'Class was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @class_detail.destroy\n respond_to do |format|\n format.html { redirect_to class_details_url, notice: 'Class detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apex_class.destroy\n respond_to do |format|\n format.html { redirect_to apex_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @classs.destroy\n respond_to do |format|\n format.html { redirect_to classses_url, notice: 'Classs was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_class.destroy\n respond_to do |format|\n format.html { redirect_to food_classes_url, notice: 'Food class was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @service_class.destroy\n respond_to do |format|\n format.html { redirect_to service_classes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n respond_to do |format|\n format.html { redirect_to vehicles_url, notice: 'Vehicle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n respond_to do |format|\n format.html { redirect_to vehicles_url, notice: 'Vehicle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n respond_to do |format|\n format.html { redirect_to vehicles_url, notice: 'Vehicle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n respond_to do |format|\n format.html { redirect_to vehicles_url, notice: 'Vehicle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7355878",
"0.6966688",
"0.69605184",
"0.69605184",
"0.6940561",
"0.6938665",
"0.6926449",
"0.6896491",
"0.6847445",
"0.6825803",
"0.68189377",
"0.68188673",
"0.6810061",
"0.6809888",
"0.68073875",
"0.67771673",
"0.67768013",
"0.67690533",
"0.6766512",
"0.6754727",
"0.67372435",
"0.6728796",
"0.672296",
"0.67137367",
"0.66978484",
"0.6690858",
"0.6682762",
"0.6682762",
"0.6682762",
"0.6682762"
] | 0.78365064 | 0 |
Finds buildings from freebase designed by the architect. | def find_buildings(architect)
name = architect.name
url = Addressable::URI.parse('https://www.googleapis.com/freebase/v1/search')
url.query_values = {
query: name,
type: "/architecture/structure",
key: GOOGLE_CLIENT_ID
}
from_freebase = HTTParty.get(url, :format => :json)
@results = from_freebase["result"]
@buildings_designed = @results.map { |building| building["name"]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildable\n b = []\n bts_here = @buildings.map { |b| b.type }\n BuildingType.all.each do |bt|\n if not bts_here.include? bt and bts_here.include? bt.prerequisite \\\n and residents.length >= bt.min_colony\n b << bt\n end\n end\n return b\n end",
"def find_entries(building)\n @buildings_nearby = building.nearbys(3)\n end",
"def all_buildings\n @all_buildings ||= Buildings.new( ranges, fill_gaps: true )\n end",
"def index\n @buildings = Building.find_near_me(search_params)\n end",
"def extract_buildings\n raw_extracted_pages.each do |page|\n page.each do |line|\n building_info = line.split(\" \")\n if building_info.empty? == false && building_info[0] != \"ZIP\" && building_info[0].start_with?(\"Brooklyn\") == false && building_info[0].start_with?(\"Source\") == false\n raw_extracted_buildings << building_info\n end\n end\n end\n end",
"def my_buildings\n \n end",
"def list_buildings(buildings)\n \tbuildings.each do |place|\n\t\tputs \"#{buildings.index(place)}: #{place}\"\n\tend\nend",
"def build_gems; end",
"def index\n if params[:search].present?\n @buildings = Building.near(params[:search], 50, :order => :distance)\n else\n @buildings = Building.all\n end\n\n end",
"def build_room_buildings()\n buildings = {}\n $item_by_id.fetch('/buildings/')[:map].each do |building, roomlist|\n roomlist = [] if roomlist.nil?\n\n bcode = building.to_s.upcase\n list = []\n roomlist.map(&$to_room_or_nil).reject(&:nil?).each do |r|\n list << r\n end\n rooms.select { |r| r[:slug].upcase.start_with? bcode }.each do |r|\n list << r\n end\n buildings[bcode] = list.uniq { |r| r[:slug] }.sort_by { |r| [r[:rank], r[:conference_room_id]] }\n buildings[bcode].each do |r|\n r[:building] = bcode\n end\n end\n\n # make sure there are no rooms left without a :building meta attribute\n begin\n errors = rooms.select { |r| r[:building].nil? }\n raise \"there are #{errors.size} room(s) without a building assignment, please put them into content/building.yaml: #{errors.map { |r| r[:slug] }.join(\", \")}\" unless errors.empty?\n end\n\n room_to_building = {}\n buildings.each do |bcode, rooms|\n rooms.each do |r|\n room_to_building[r[:slug]] = bcode\n end\n end\n\n [buildings, room_to_building]\n end",
"def test_search\n fortunes = LinuxFortune.search('develop', ['chucknorris'])\n assert fortunes.is_a?(Array)\n assert fortunes.size > 0\n fortunes.each do |fortune|\n assert fortune.is_a?(LinuxFortune::Fortune)\n assert fortune.source.include?('chucknorris')\n end\n end",
"def buildings\n Building.where(\n user_id: users.map(&:id)\n )\n end",
"def batali_build_system\n system = Grimoire::System.new\n units = api_service.get_rest('cookbooks?num_versions=all').map do |c_name, meta|\n meta['versions'].map do |info|\n \"#{c_name}/#{info['version']}\"\n end\n end.flatten.map do |ckbk|\n Batali::Unit.new(\n Smash.new(\n :name => ckbk.split('/').first,\n :version => ckbk.split('/').last,\n :dependencies => api_service.get_rest(\"cookbooks/#{ckbk}\").metadata.dependencies.to_a\n )\n )\n end\n system.add_unit(*units)\n system\n end",
"def index\n if params[:search].nil? || params[:search].empty?\n @buildings = Building.paginate(page: params[:page])\n else\n @buildings = search_buildings(params[:search])\n end\n end",
"def builds(filters = {})\n fetch_resources_lazily(\"builds\", filters)\n end",
"def index\n @buildings = Building.find(:all, :include => :floors )\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @buildings }\n end\n end",
"def selectbuildings(arr_building_name)\n @wait = Selenium::WebDriver::Wait.new(:timeout => 2)\n arr_building_name.each do |building_name|\n @driver.find_element(:id, 'building').click\n @driver.find_element(:id, 'buildingcontainer').find_elements(:tag_name, 'li').each do |li_tag|\n if li_tag.text == building_name[\"name\"]\n li_tag.click\n break\n end\n end\n end\n @driver.find_element(:tag_name, 'body').click\n #return AvailabilityPage.new(@driver)\n end",
"def find(criteria = {})\n selected = bundles + fragments\n \n if (criteria[:name])\n selected = selected.select {|b| b.name == criteria[:name]}\n end\n if (criteria[:exports_package])\n selected = selected.select {|b| \n !(b.exported_packages.select {|package| \n package.name == criteria[:exports_package] &&\n (criteria[:version].nil? || criteria[:version].in_range(package.version))\n }.empty?)\n }\n else\n if (criteria[:version])\n if criteria[:version].is_a?(VersionRange)\n selected = selected.select {|b| criteria[:version].in_range(b.version)}\n else\n selected = selected.select {|b| b.version == criteria[:version]}\n end\n end\n end\n selected\n end",
"def find_packages\n declared_packages.collect do |package|\n guess = ::Albacore::PackageRepo.new(%w|./packages ./src/packages|).find_latest package.id\n debug \"#{name}: guess: #{guess} [albacore: project]\"\n guess\n end\n end",
"def search(gem_pattern, platform_only = T.unsafe(nil)); end",
"def find_projects\n #binding.pry\n ProjectBacker.all.select do |element|\n element.backer == self\n end\n end",
"def index\n @buildings = Building.all\n end",
"def index\n @built_withs = BuiltWith.all\n end",
"def index\n @complex_buildings = ComplexBuilding.all\n end",
"def get_target_branches\n unless @target_branches\n fetch_all\n base = @config['branches']['production']\n allowed_branches = @config['branches'].values\n allowed_branches << @config['prefixes']['release'] if @config['prefixes']['release']\n banned_branches = ['HEAD']\n target_branches = `git branch -r origin/#{base} | grep -ie '\\\\(#{allowed_branches.join(\"\\\\|\")}\\\\)' | grep -iv '\\\\(#{banned_branches.join(\"\\\\|\")}\\\\)' | sed -e 's/origin\\\\///g'`\n @target_branches = target_branches.split(\"\\n\").map{|a| a.gsub(/\\s+/, \"\")}\n end\n @target_branches\n end",
"def display_all_by_build\n\n genome = Genome.find(params[:genome_build])\n reference = Reference.where(name: params[:build_name]).first\n\n unless reference.nil? || genome.nil?\n reference_id = reference.id\n @genomeName = genome.build_version\n @experiments = genome.experiments\n @features = Array.new\n\n @experiments.each do |exp|\n @features.concat exp.features.where(reference_id: reference_id)\n end\n\n render\n\n else\n redirect_to features_path, flash: {alert: \"Selected reference could not be found in the current genome\"}\n end\n\n end",
"def searches\n Boundary.get(@url)\n end",
"def build_results\n CircleCi::Project.recent_builds_branch('salsify', 'dandelion', 'develop')\n end",
"def find_bridges(params={}, headers=default_headers)\n @logger.info(\"Find Bridges.\")\n get(\"#{@api_url}/bridges\", params, headers)\n end",
"def build_house() \n gather_team()\n @workers.each do |worker|\n worker.get_to_work()\n end\n end"
] | [
"0.6562974",
"0.59953886",
"0.5910194",
"0.5878741",
"0.575927",
"0.5737529",
"0.55921423",
"0.5330418",
"0.52442944",
"0.52077883",
"0.51805043",
"0.5166892",
"0.5140001",
"0.51317763",
"0.51228267",
"0.5102703",
"0.50916815",
"0.5072862",
"0.50587213",
"0.50572646",
"0.5045286",
"0.50263566",
"0.50192547",
"0.5017617",
"0.50112474",
"0.49979943",
"0.49913818",
"0.49905282",
"0.49864644",
"0.49857292"
] | 0.79563385 | 0 |
Gets a description of the architect from wikipedia | def get_description(architect)
search = FreebaseAPI.session.search("#{architect.name}")
resource_id = search[0]["id"]
if resource_id == nil
resource_id = search[0]["mid"]
end
resource = FreebaseAPI::Topic.get("#{resource_id}")
@description = resource.description
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description\n\t # if the description exists\n\t # return it \n\t # else \n\t # scrape to get the description\n\t # return it\n\t # end\n\tend",
"def description\n search_by_itemprop 'description'\n end",
"def description\n response_json = @client.api_get_request('', 'tree=description')\n response_json['description']\n end",
"def description\n query_root_node(\"description/text()\")\n end",
"def desc\n\t\t\"Useful for analyzing scanned web sites later.\"\n\tend",
"def description\n 'Bibita'\n end",
"def article_info(title)\n wiki_req_url = Api.path(URI.encode(title))\n call_wk_url(wiki_req_url).parse\n end",
"def description; @doc['description']; end",
"def description; @doc['description']; end",
"def get_description(n)\n @description_xpath[n].text\n end",
"def description\n @ole.Description\n end",
"def description\n @ole.Description\n end",
"def description\r\n\t\t\t`#{BITS::BITSADMIN} /getdescription {#{@id}}`\r\n\t\tend",
"def desc\n if self.namespace\n content_from 'ns:desc', :ns => self.namespace.href\n else\n content_from :desc\n end\n end",
"def description\n text_get(7, @id)\n end",
"def description\n node.at(\"description\").text\n end",
"def description\n zombie_check\n @metadata.description(@name)\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def descr\n return text_get(2, id)\n end",
"def get_animal_description(input)\n animal = EndangeredAnimals::Scraper.get_animal_information(input)\n\n puts \"\", \" ~* #{animal.name} *~\"\n puts \"-------------------------------------------------------------------\"\n puts \"Scientific Name: #{animal.scientific_name}\"\n puts \"Status: #{animal.status}\"\n puts \"Population: #{animal.population}\"\n puts \"Habitat: #{animal.habitat}\"\n puts \"Places: #{animal.place}\"\n puts \"-----------------\"\n puts \"| Description: |\"\n puts \"-----------------\", \"#{animal.description}\"\n end",
"def describe(description)\n api_desc(description)\n end",
"def description\n meta['description'] || extract_description\n end",
"def description\n info[\"Description\"]\n end",
"def description\n \"Whois lookup\"\nend",
"def description\n fetch('restaurant.description')\n end",
"def description\n metapage = ::Metapage.find_by(grade_id: nil, subject_id: o.id)\n metapage.description\n end",
"def description\n @description ||= (\n ld = LessonDescription.find_by_schoolday_and_lesson(@schoolday, @lesson)\n ld && ld.description\n )\n end",
"def description\n @description ||= begin\n readme = File.read( path( 'README.txt' ) )\n md = readme.match( /== DESCRIPTION:(.+?)\\n== /m ) or\n fail( \"can't find a description section in README.txt\" )\n md[1].strip\n end\n end",
"def search(phrase, limit=5, description=true, display=true)\n search = phrase.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=#{search}&limit=#{limit}\"\n hash = get(endpoint)\n results = hash[1]\n descriptions = hash[2]\n if display\n puts \"Displaying #{results.length} results:\"\n for i in 0...results.length\n if description\n if ! descriptions[i].empty?\n puts \"\\n'#{results[i]}' : #{descriptions[i]}\"\n else\n puts \"\\n'#{results[i]}' : No Immediate Description Available. Try `wik -d #{results[i]}`\"\n end\n else\n puts \"\\n'#{results[i]}'\"\n end\n end\n end\n return hash\n end"
] | [
"0.65950304",
"0.64274687",
"0.63954026",
"0.6331489",
"0.6326101",
"0.62938666",
"0.62824494",
"0.6216198",
"0.6216198",
"0.6149291",
"0.614699",
"0.614699",
"0.61438996",
"0.61161727",
"0.6075466",
"0.60579574",
"0.6057704",
"0.60223776",
"0.60223776",
"0.6013415",
"0.59943014",
"0.59942126",
"0.5980288",
"0.5972528",
"0.5933379",
"0.5928245",
"0.5927604",
"0.59222126",
"0.59125006",
"0.5910776"
] | 0.7135378 | 0 |
Gets buildings in the database within a 3 mile radius of the current building. | def find_entries(building)
@buildings_nearby = building.nearbys(3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @buildings = Building.find_near_me(search_params)\n end",
"def index\n if params[:search].present?\n @buildings = Building.near(params[:search], 50, :order => :distance)\n else\n @buildings = Building.all\n end\n\n end",
"def index\n @params = params.permit(:building, :floor)\n \n @buildings = Place.distinct.pluck(:building)\n @floors = Place.where(building:params[:building]).distinct.order(:floor).pluck(:floor) if @params[:building]\n @current_user_place = current_user.place\n if @params[:building] && @params[:floor]\n @cells = Place.where(building: @params[:building], floor: @params[:floor]).order(:room, :id).includes(:user).group_by{|i| i.cell}\n end\n end",
"def buildings\n Building.where(\n user_id: users.map(&:id)\n )\n end",
"def search\n @buildings = Building.search(params[:longitude], params[:latitude])\n\n if stale? last_modified: @buildings.maximum(:updated_at)\n render json: @buildings\n end\n end",
"def all_buildings\n @all_buildings ||= Buildings.new( ranges, fill_gaps: true )\n end",
"def items_near_location(long, lat)\n long = long.to_f\n lat = lat.to_f\n nearby_items = self.items.not_deleted.limit(64).with_long_lat_and_radius(long, lat, 0.000025)\n nearby_items = self.items.not_deleted.limit(64).with_long_lat_and_radius(long, lat, 0.00006) if nearby_items.empty?\n nearby_items = self.items.not_deleted.limit(64).with_long_lat_and_radius(long, lat, 0.002) if nearby_items.empty?\n nearby_items = self.items.not_deleted.limit(64).with_long_lat_and_radius(long, lat, 10.0) if nearby_items.empty?\n return nearby_items\n end",
"def index # returns all bikes within a certain radius\n ## TODO: use coordinates later, when more campuses and bikes.\n # # defaults radius to half mile, and coordinate to requesting ip address\n # radius = params[:radius] ? params[:radius] : 0.5\n # coordinates = params[:coordinates] ? params[:coordinates] : request.location\n # puts coordinates\n # @bikes = Coordinate.near(coordinates, radius).joins(:bikes)\n @bikes = Bike.available\n render json: @bikes\n end",
"def find_nearby\n locations = read_locations_from FILE\n locations.select_within_radius 100 \n locations.sort.filter_fields\n end",
"def index\n @buildings = Building.all\n end",
"def building\n return @building\n end",
"def building(building_id)\n perform_get_request(\"/building/#{building_id}\")\n end",
"def within_radius(radius: nil, limit: 100)\n # 3959 if miles; 6271 if km\n lat = self.lat\n lng = self.lng\n q = User.select(\"*,\n ( 3959 * acos (\n cos ( radians(#{lat}) )\n * cos( radians( lat ) )\n * cos( radians( lng ) - radians(#{lng}) )\n + sin ( radians(#{lat}) )\n * sin( radians( lat ) )\n )) AS distance\").to_sql\n\n result = User.from(Arel.sql(\"(#{q}) AS users\")).\n where.not(id: self.id).\n order(distance: :desc).\n limit(limit)\n\n result = result.where('distance <= ?', radius) if radius\n result\n end",
"def movies_and_theaters_near_zip(radius_in_miles)\n s_function='miles_between_lat_long(' + self.lat.to_s + ',' + self.lng.to_s + ',theaters.latitude,theaters.longitude)'\n Movie.all(:include=>[:theaters], :joins=>[:theaters], :conditions=> s_function + '<' + radius_in_miles.to_s, :order=>s_function)\n end",
"def place_conditions \n @radius = @radius.blank? ? 10 : @radius\n origin = GeoKit::Geocoders::MultiGeocoder.geocode(\"#{@place}, Deutschland\")\n distance_sql = Address.distance_sql(origin)\n @conditions.add_condition [\"#{distance_sql} < ?\", @radius]\n end",
"def search_radius\n exact_location ? 100 : 50_000\n end",
"def index\n @building = Building.find(params[:building_id])\n @listings = Listing.all\n end",
"def mapsAPI\n\t\t@buildings = Building.all\n\t\t@markers = []\n\n\t\tBuilding.find_each do |building|\n\t\t\taddress = building.address\n\t\t\tcustomer = building.customer.company_name \n\t\t\tbatteries = building.batteries.count\n\t\t\tbattery_ids = building.battery_ids\n\t\t\tcolumns = Column.where(battery_id: battery_ids).count\n\t\t\tcolumn_ids = Column.where(battery_id: building.battery_ids).ids\n\t\t\televators = Elevator.where(column_id: column_ids).count\n\t\t\tcontact = building.customer.full_name_service_person\n\n\t\t\t\tbuilding.batteries.all.each do |battery|\n\t\t\t\t\tnumber_of_floors = battery.columns.first.number_of_floors\n\n\t\t\t\tp number_of_floors\n\t\t\t\n\t\t\t\tif !address.latitude\t\t\n\n\t\t\t\n\t\t\t\t\t@full_add = address.number_street + \" \" + address.city + \" \" + address.postal_code\n\t\t\t\t\t@response = JSON.parse(Faraday.get(\"https://maps.googleapis.com/maps/api/geocode/json?address=#{@full_add}&key=#{ENV[\"GOOGLE_API\"]}\").body)\n\t\t\t\t\n\n\t\t\tpp address\n\t\t\tpp @response\n\n\t\t\t if @response[\"results\"].size != 0 \t\n\t\t\t\t\tlat = @response[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\t\t\t\tlng = @response[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\t\t\t\n\t\t\t\t\taddress.latitude = lat\n\t\t\t\t\taddress.longitude = lng\n\t\t\t\t\taddress.save!\n\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tunless address.longitude.nil?\n\t\t\t\t@markers << {address: address.display_address, lat: address.latitude, lng: address.longitude, customer: customer, batteries: batteries, columns: columns, elevators: elevators, contact: contact, number_of_floors: number_of_floors }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def places_nearby_without_photos radius=15\n Place.find_by_radius(centerLatitude,centerLongitude,radius).where(\"places.id != ?\", id).where(\"places.name_status != 'unnamed' and places.id not in (select distinct photos.place_id from photos where photos.place_id is not null) and places.id not in (select distinct place_id from place_photos)\").order(\"places.type != 'Mountain', power(places.latitude - #{centerLatitude.to_f},2)+power(places.longitude - #{centerLongitude.to_f},2)\")\n end",
"def get_nearby_food_pictures\n if params[:lat] and params[:lng]\n @restaurants = Restaurant.all\n # @buildings = Building.find( :all, :conditions => [ 'name LIKE ?', '%' + params[:q].downcase + '%'], :limit => 20)\n \n end\n\n render :json => @restaurants\n end",
"def find_nearby_quakes(cutoff_time)\n Quake\n .where(\"this.properties.time >= #{cutoff_time}\")\n .geo_near(self.geometry).spherical\n .max_distance(40233.6) #25 miles in meters\n end",
"def build_room_buildings()\n buildings = {}\n $item_by_id.fetch('/buildings/')[:map].each do |building, roomlist|\n roomlist = [] if roomlist.nil?\n\n bcode = building.to_s.upcase\n list = []\n roomlist.map(&$to_room_or_nil).reject(&:nil?).each do |r|\n list << r\n end\n rooms.select { |r| r[:slug].upcase.start_with? bcode }.each do |r|\n list << r\n end\n buildings[bcode] = list.uniq { |r| r[:slug] }.sort_by { |r| [r[:rank], r[:conference_room_id]] }\n buildings[bcode].each do |r|\n r[:building] = bcode\n end\n end\n\n # make sure there are no rooms left without a :building meta attribute\n begin\n errors = rooms.select { |r| r[:building].nil? }\n raise \"there are #{errors.size} room(s) without a building assignment, please put them into content/building.yaml: #{errors.map { |r| r[:slug] }.join(\", \")}\" unless errors.empty?\n end\n\n room_to_building = {}\n buildings.each do |bcode, rooms|\n rooms.each do |r|\n room_to_building[r[:slug]] = bcode\n end\n end\n\n [buildings, room_to_building]\n end",
"def index\n @complex_buildings = ComplexBuilding.all\n end",
"def getbuildings\n \n puts params\n custid = params[\"custormerid\"]\n puts custid\n \n buildings = Building.where(:customer_id => custid)\n puts buildings.inspect\n respond_to do |format|\n puts \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n format.json { render json: buildings }\n end\n \n\n end",
"def index\n @rooms_count = Room.all.count\n\n search = \"(r:Room)-[]->(b:Building)\"\n request = ActiveGraph::Base.new_query.match(search).order(@sort_string).skip(@skip).limit(@limit)\n\n @rooms = request.pluck('r')\n end",
"def get_building\n #check if customer is passed as parameter\n if params[:customer].present?\n #same thing than : select building_id from customer where customer.id = id \n @buildings = Customer.find(params[:customer]).buildings\n \n else\n #if non id is given select all the buildings that are refered in the customer table\n @buildings = Customer.all\n end\n \n if request.xhr?\n #if no error \n #build response \n respond_to do |format|\n #make a json format for the response \n format.json {\n #send the list of corresponding buildings \n render json: {buildings: @buildings}\n }\n end\n end\n end",
"def containing(place_id, start = 0, limit = 25)\n place_id = clean_for_search(as_id(place_id))\n results = PublicEarth::Db::Collection.search_for(\"place_id:#{place_id}\", :qt => 'standard', \n :start => start && start.to_i, :rows => limit && limit.to_i > 0 && limit.to_i || 25)\n results.models\n end",
"def available_floorplans(search=nil)\n @available_floorplans ||= begin\n if search\n search.floorplans_for(self).joins(:units).where(\"units.rent_min > 0\")\n else\n self.floorplans.joins(:units).\n where(\"units.rent_min > 0\").\n order('name','bedrooms_count, bathrooms_count').\n group(\"floorplans.id\")\n end\n end\n end",
"def data(bounding_box)\n top, left, bottom, right = bounding_box.coords\n @table.where(:lng => (left..right), :lat => (bottom..top)).all\n end",
"def nearby_metros(miles=400)\n return nil unless self.lat and self.lng\n puts \"within 30 miles of #{self.lat}/#{self.lng}\"\n Metro.find(:all, :origin => [self.lat,self.lng],:within=>miles,:order=>'distance')\n end"
] | [
"0.6500157",
"0.63188505",
"0.6158715",
"0.5812862",
"0.58100957",
"0.56593645",
"0.5573889",
"0.5507152",
"0.5484832",
"0.5345243",
"0.529608",
"0.52941185",
"0.5285553",
"0.52043456",
"0.5142721",
"0.5120539",
"0.5109875",
"0.5102623",
"0.50942796",
"0.5058412",
"0.5056639",
"0.50521076",
"0.50414485",
"0.5026347",
"0.50174433",
"0.49952978",
"0.4978594",
"0.4977205",
"0.49770617",
"0.49715686"
] | 0.6963875 | 0 |
Generates a google static map of the building and buildings nearby | def get_map(building, array_of_buildings_nearby)
each_result = array_of_buildings_nearby.map { |building| "markers=color:green%7Clabel:%7C#{building.latitude},#{building.longitude}&" }
map_from_google = "http://maps.googleapis.com/maps/api/staticmap?center=#{building.latitude},#{building.longitude}&zoom=13&size=1300x1000&maptype=roadmap&markers=color:red%7Clabel:%7C#{building.latitude},#{building.longitude}&"+each_result.join+"sensor=false&key=#{GOOGLE_CLIENT_ID}"
return map_from_google
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_static_map\n legs = @itinerary.legs\n markers = create_markers\n polylines = create_polylines\n\n params = {\n 'size' => '700x435',\n 'maptype' => 'roadmap',\n }\n\n iconUrls = {\n 'blueMiniIcon' => 'https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png',\n 'startIcon' => 'http://maps.google.com/mapfiles/dd-start.png',\n 'stopIcon' => 'http://maps.google.com/mapfiles/dd-end.png'\n }\n\n markersByIcon = markers.group_by { |m| m[\"iconClass\"] }\n\n url = \"https://maps.googleapis.com/maps/api/staticmap?\" + params.to_query\n markersByIcon.keys.each do |iconClass|\n marker = '&markers=icon:' + iconUrls[iconClass]\n markersByIcon[iconClass].each do |icon|\n marker += '|' + icon[\"lat\"].to_s + \",\" + icon[\"lng\"].to_s\n end\n url += URI::encode(marker)\n end\n\n polylines.each do |polyline|\n color = polyline['options']['color'].nil? ? \"0000ff\" : polyline['options']['color']\n url += URI::encode(\"&path=color:0x#{color}|weight:5|enc:\" + polyline['geom']['points'])\n end\n url += \"&key=#{ENV['GOOGLE_API_KEY']}\"\n return url\n end",
"def create_static_map\n path_array = coordinates_string.split(\"|\")\n\n while path_array.length > 70\n path_array = reductionPath(path_array)\n end\n coordinates_string_temp = \"\"\n path_array.each do |pos|\n # pos_array = pos.split(\",\")\n # lat = pos_array[0].to_f.round(6).to_s\n # lng = pos_array[1].to_f.round(6).to_s\n\n # coordinates_string_temp += \"|#{lat},#{lng}\"\n coordinates_string_temp += \"|#{pos}\"\n end\n \"http://maps.googleapis.com/maps/api/staticmap?path=color:0xc84446ff|weight:2#{coordinates_string_temp}&size=79x79&sensor=false\"\n end",
"def gmap_staticmap_url(options = {})\n options.symbolize_keys!\n nearby = options[:nearby] || false\n\n url = \"http://maps.googleapis.com/maps/api/staticmap?sensor=false¢er=#{self.gmap_location}\"\n url << \"&size=245x185\"\n url << \"&markers=size:mid|color:red|label:V|#{self.gmap_location}\"\n \n if nearby == true\n cnt = 1\n self.get_nearby_venues.map do |e|\n url << \"&markers=size:mid|color:blue|label:#{cnt+=1}|#{e.gmap_location}\"\n end\n end\n url << \"&sensor=false\" \n end",
"def index\n\n current_location = Image.nearby( 0.2, 121.52847610518472, 25.04476753094792).first\n @hash = Gmaps4rails.build_markers(current_location) do |location, marker|\n marker.lat 25.04476753094792\n marker.lng 121.52847610518472\n end\n\n end",
"def get_static_map(trip)\n coordinates = []\n trip.activities.each { |activity| coordinates << {lat: activity.latitude, lng: activity.longitude } }\n size = \"640x640\"\n if @trip.visits.count == 3\n marker_one = \"color:blue%7Clabel:A%7C#{coordinates[0][:lat]},#{coordinates[0][:lng]}\"\n marker_two = \"color:blue%7Clabel:B%7C#{coordinates[1][:lat]},#{coordinates[1][:lng]}\"\n marker_three = \"color:blue%7Clabel:C%7C#{coordinates[2][:lat]},#{coordinates[2][:lng]}\"\n return \"https://maps.googleapis.com/maps/api/staticmap?size=#{size}0&maptype=roadmap&markers=#{marker_one}&markers=#{marker_two}&markers=#{marker_three}&key=#{ENV['GOOGLE_API_STATIC_KEY']}\"\n end\n end",
"def index\n @locations = @organization.locations.all\n\n @map = Cartographer::Gmap.new( 'map' )\n @map.zoom = :bound\n @map.icons << Cartographer::Gicon.new\n \n @organization.locations.each do |location|\n @map.markers << \n Cartographer::Gmarker.new(\n :name => 'location_'+Digest::MD5.hexdigest(location.name),\n :marker_type => \"Building\",\n :position => [location.lat, location.lng],\n :info_window_url => \"fixme.org\"\n )\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end",
"def map_image(lat, long, width=500, height=400)\n \"http://maps.google.com/maps/api/staticmap?zoom=16&size=#{width}x#{height}&markers=#{lat},#{long}&sensor=false\"\n end",
"def map_image location, width=500, height=275, zoom=15\n image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{location.latitude},#{location.longitude}&zoom=#{zoom}&size=#{width}x#{height}&markers=color:blue%7Clabel:1%7C#{location.latitude},#{location.longitude}&sensor=false\", :class => \"map_image\")\n end",
"def google_map(center)\n \"https://maps.googleapis.com/maps/api/staticmap?center=#{center}&size=300x300&zoom=17\"\n \tend",
"def show\n @building = Building.find(params[:id].to_i)\n @reviews = @building.reviews.paginate(page: params[:page])\n @hash = Gmaps4rails.build_markers(@building) do |building, marker|\n marker.lat building.latitude\n marker.lng building.longitude\n marker.title \"#{building.building_number} #{building.street_name}\"\n end\n end",
"def index\n @map_bounds = [20, 20]\n @current_position = [0,0]\n @map = []\n @spots_around = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n create_initial_map\n generate_map\n end",
"def generate_map datecart\n image_tag \"https://maps.google.com/maps/api/staticmap?#{format_google_maps_api_call_parameters(datecart.cart_items)}\", :class => \"map\", :alt => \"Date Map\"\n end",
"def static_map(resource, options={})\n # config\n api_key = \"\"\n\n # high trafficked maps require maps to be signed by\n # Google, enable signing and add the secret to sort \n # it all out for you\n api_secret = \"\"\n signed = false\n\n # settings for this map\n location = \"#{resource.latitude},#{resource.longitude}\"\n pin_path = \"https://www.example.com.au/assets/\"\n pin = \"#{pin_path}pin.png\"\n zoom = options[:zoom] || 17\n size = options[:size] || \"470x215\"\n markers = \"\"\n markers += \"markers=icon:#{pin}%7C#{location}\"\n\n # keys and address\n url = \"https://maps.googleapis.com/maps/api/staticmap?center=#{location}&zoom=#{zoom}&size=#{size}&maptype=roadmap&#{markers}&key=#{api_key}\"\n if signed\n encoded_signature = ornament_google_signer(url, api_key, api_secret)\n url += \"&signature=#{encoded_signature}\"\n end\n\n url\n end",
"def make_map(locs, query_params={})\n gmap = GMap.new(\"map_div\")\n gmap.control_init(:large_map => true, :map_type => true)\n\n # Center on a given location?\n if respond_to?(:start_lat) && respond_to?(:start_long)\n map.center_zoom_init( [start_lat, start_long], Constants::GM_ZOOM )\n map.overlay_init(\n GMarker.new( [start_lat, start_long],\n :icon => icon_start,\n :title => name + \" start\",\n :info_window => \"start\"\n ))\n end\n\n # Center based on the points we're drawing on it.\n gmap.center_zoom_on_points_init(\n *(locs.map(&:south_west) + locs.map(&:north_east))\n )\n\n # Started playing with icons and the following got something to show up, but I decide\n # not to pursue it further right now.\n # gmap.icon_global_init(\n # GIcon.new(\n # :image => \"/images/blue-dot.png\",\n # :icon_size => GSize.new( 24,38 ),\n # :icon_anchor => GPoint.new(12,38),\n # :info_window_anchor => GPoint.new(9,2)\n # ), \"blue_dot\")\n # blue_dot = Variable.new(\"blue_dot\")\n\n # Map locations.\n for l in locs\n # map_loc(gmap, l, query_params, blue_dot)\n map_loc(gmap, l, query_params)\n end\n \n gmap\n end",
"def build_map()\n \n return_string = \"\\n\"\n # see if we have any javascript variables to set up\n\n if @js_vars.length > 0\n return_string << \"// js_vars //\\n\"\n return_string << @js_vars.values.to_s\n end\n \n # see if we have any functions to include\n\n if @include_funcs.length > 0\n return_string << build_js_funcs\n end\n\n # see if we have any createmarker code \n \n if @marker_code.length > 0\n return_string << @marker_code.values.to_s\n end\n \n # see if we have any embedded javascript code\n \n if @js_code.length > 0\n return_string << @js_code.values.to_s\n end\n \n if @onload == true\n \n return_string << \"\n \n function #{onload_func_name}(){\n if (GBrowserIsCompatible()) {\" << build_load_func << \"\n \n }\n // display a warning if the browser was not compatible\n else {\n alert(\\\"Sorry, the Google Maps API is not compatible with this browser\\\");\n }\n }\n \"\n else\n return_string << \"\n if (GBrowserIsCompatible()) {\n function #{onload_func_name}(){\n \" << build_load_func << \"\n }\n #{onload_func_name}();\n }\n // display a warning if the browser was not compatible\n else {\n alert(\\\"Sorry, the Google Maps API is not compatible with this browser\\\");\n }\n \" \n end\n return return_string\n end",
"def create_map(location, places)\n\n places = [\"#{location[\"latitude\"]},#{location[\"longitude\"]}\",\n \"color:blue|label:A|#{places[0][\"latitude\"]},#{places[0][\"longitude\"]}\",\n \"color:blue|label:B|#{places[1][\"latitude\"]},#{places[1][\"longitude\"]}\",\n \"color:blue|label:C|#{places[2][\"latitude\"]},#{places[2][\"longitude\"]}\"]\n url_params = { :key => @api_key, :size => \"800x400\", :markers => places }\n url = set_params(@base_url, url_params)\n\n return url\n end",
"def generate_map\n end",
"def map\n render :template=>'edgarj/map', :layout=>false\n end",
"def index\n @emergencia = Emergencium.all\n @hash = Gmaps4rails.build_markers(@emergencia) do |emergencia, marker|\n marker.lat emergencia.latitude\n marker.lng emergencia.longitude\n marker.infowindow emergencia.descrption\n marker.picture({\n \"url\" => 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',\n \"height\" => 32,\n \"width\" => 32\n })\n marker.json({title: emergencia.title})\nend\n\n end",
"def mapsAPI\n\t\t@buildings = Building.all\n\t\t@markers = []\n\n\t\tBuilding.find_each do |building|\n\t\t\taddress = building.address\n\t\t\tcustomer = building.customer.company_name \n\t\t\tbatteries = building.batteries.count\n\t\t\tbattery_ids = building.battery_ids\n\t\t\tcolumns = Column.where(battery_id: battery_ids).count\n\t\t\tcolumn_ids = Column.where(battery_id: building.battery_ids).ids\n\t\t\televators = Elevator.where(column_id: column_ids).count\n\t\t\tcontact = building.customer.full_name_service_person\n\n\t\t\t\tbuilding.batteries.all.each do |battery|\n\t\t\t\t\tnumber_of_floors = battery.columns.first.number_of_floors\n\n\t\t\t\tp number_of_floors\n\t\t\t\n\t\t\t\tif !address.latitude\t\t\n\n\t\t\t\n\t\t\t\t\t@full_add = address.number_street + \" \" + address.city + \" \" + address.postal_code\n\t\t\t\t\t@response = JSON.parse(Faraday.get(\"https://maps.googleapis.com/maps/api/geocode/json?address=#{@full_add}&key=#{ENV[\"GOOGLE_API\"]}\").body)\n\t\t\t\t\n\n\t\t\tpp address\n\t\t\tpp @response\n\n\t\t\t if @response[\"results\"].size != 0 \t\n\t\t\t\t\tlat = @response[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\t\t\t\tlng = @response[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\t\t\t\n\t\t\t\t\taddress.latitude = lat\n\t\t\t\t\taddress.longitude = lng\n\t\t\t\t\taddress.save!\n\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tunless address.longitude.nil?\n\t\t\t\t@markers << {address: address.display_address, lat: address.latitude, lng: address.longitude, customer: customer, batteries: batteries, columns: columns, elevators: elevators, contact: contact, number_of_floors: number_of_floors }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def generate_map\n map = make_random_map\n map = add_borders(map)\n map = ensure_adjacent_rooms(map)\nend",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def index\n \n @growshops = Growshop.near(\n current_user.address,\n 100,\n units: :km\n )\n @hash = Gmaps4rails.build_markers(@growshops) do |grow, marker|\n marker.lat grow.latitude\n marker.lng grow.longitude\n marker.infowindow grow.name\n marker.picture({\n :url => \"/trebol.png\",\n :width => 36,\n :height => 36\n })\n \n end\n\n end",
"def show\n\n gon.mapping = @map\n vals = @map.meta_data.collect{ |x| x[\"value\"] }.sort.uniq\n redirect_to \"/maps/#{@map.id}/#{map_kind}\"\n\n # gon.color_spots = [\n # vals.first,\n # color_span(vals, 1),\n # color_span(vals, 2),\n # color_span(vals, 3),\n # color_span(vals, 4),\n # vals.last\n # ]\n end",
"def maps\n @facilities = Facility.joins(:city).where(city_id: params[:search][:city_id])\n @facilities = @facilities.joins(:category).where(\"categories.id = ?\", params[:search][:category_id]) if params[:search][:category_id].present?\n @markers = []\n @facilities.each do |f|\n @markers << {\n lat: f.latitude,\n lng: f.longitude,\n image_url: helpers.asset_url('placemarker.png')\n }\n end\n # @markers = @facilities.map do |f|\n # {\n # lat: f.latitude,\n # lng: f.longitude,\n # image_url: helpers.asset_url('placemarker.png')\n # }\n authorize :facility, :map?\n # end\n end",
"def map\n add_breadcrumb :map\n @map_opt = {\n :zoom => 2,\n :auto_adjust => true,\n :auto_zoom => false,\n :center_on_user => true,\n :detect_location => true\n }\n @users = User.search do\n with :published, true\n fulltext params[:q] do\n fields(:bio, :name => 2.0)\n end\n order_by :id, :desc\n end.results\n\n @markers = @users.to_gmaps4rails do |user, marker|\n marker.infowindow render_to_string(:partial => \"/users/marker_template\", :locals => {:usr => user})\n marker.json({:id => user.id})\n end\n end",
"def build_maps\n build_image_maps\n build_flavor_maps\n end",
"def map\n @site = Site.find(params[:id])\n\n @max_lat = 0\n @max_lng = 0\n @min_lat = 0\n @min_lng = 0\n @center_lat = 0\n @center_lng = 0\n\n @markers = []\n\n render layout: \"map\"\n end"
] | [
"0.6961075",
"0.68169886",
"0.6733872",
"0.66331744",
"0.65577203",
"0.65148115",
"0.65103054",
"0.644611",
"0.6393634",
"0.6349644",
"0.6347425",
"0.63309866",
"0.6300873",
"0.62705106",
"0.6260547",
"0.62421554",
"0.62309664",
"0.6206446",
"0.61801183",
"0.6142324",
"0.6126973",
"0.61242974",
"0.61242974",
"0.61242974",
"0.6095376",
"0.60869133",
"0.6076531",
"0.60369974",
"0.6032283",
"0.601815"
] | 0.8004162 | 0 |
Pulls the instagram location that matches the name of the building and coordinates of the building | def get_instagram_location_id(building)
return_hash = HTTParty.get("https://api.instagram.com/v1/locations/search?lat=#{building.latitude}&lng=#{building.longitude}&distance=25&client_id=#{INSTAGRAM_CLIENT_ID}")
data = return_hash["data"]
location_hash = data.detect { |item| item["name"].include?(@building.name) }
unless location_hash == nil
location = location_hash["id"]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_photos(building)\n @location = get_instagram_location_id(building)\n unless @location == nil\n @photos = get_instagram_photos(@location)\n end\n end",
"def location\n fetch('how_to_train_your_dragon.locations')\n end",
"def locate_pins(location); end",
"def get_location(loc)\n geo = Geocoder.search(\"#{loc} seattle\")\n lat = geo[0].latitude\n lon = geo[0].longitude\n [lon, lat]\n end",
"def location\n fetch('hey_arnold.locations')\n end",
"def location\n fetch('rick_and_morty.locations')\n end",
"def locate(place)\n check_api_key\n @location = Hamweather::Location.parse(place)\n end",
"def locate(place)\n locations, = get :q => place\n return locations.first\n end",
"def build_location(building)\n #stom spiral algoritme ofzo\n center = player.command_centers.first\n #spiral_location(building, {:x => center.tile_position_x,\n # :y => center.tile_position_y})\n {:x => center.x.in_build_tiles, :y => center.y.in_build_tiles - 3}\n end",
"def location\n fetch('simpsons.locations')\n end",
"def location\n b = []\n b << latitude\n b << longitude\n Geocoder.coordinates(b)\n end",
"def location\n fetch('doraemon.locations')\n end",
"def location\n fetch('games.super_mario.locations')\n end",
"def get_lat_lng(search_term)\n url = \"https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=AIzaSyD1eA_mMwy_51cCkRHu06g2GeFw8rdJmgU&location=12.9923408,77.5947617&sensor=false&radius=50000&keyword=#{search_term}\"\n p URI::escape(url)\n response = JSON.parse(RestClient.get(URI::escape(url)), :symbolize_names => true )\n p response\n location_hash = response[:results][0][:geometry][:location]\n lat = location_hash[:lat]\n lng = location_hash[:lng]\n name = response[:results][0][:name]\n [name, lat, lng]\n\nend",
"def get_location(place)\n\t\tsleep(1.5)\n\t\tlocation = Geocoder.search(place)\n\t\t#puts location.inspect\n\t\tif !location.empty?\n\t\t\tlocation_geometry = location.first.geometry\n\t\t\tlocation_bounds = location_geometry['bounds']\n\t\t\tif !location_bounds.nil?\n\t\t\t\tlat_range = Range.new(location_geometry['location']['lat'], location_geometry['bounds']['northeast']['lat'])\n\t\t\t\tlong_range = Range.new(location_geometry['location']['lng'], location_geometry['bounds']['northeast']['lng'])\n\t\t\telse\n\t\t\t\tlat_range = Range.new(location_geometry['location']['lat'], location_geometry['viewport']['northeast']['lat'])\n\t\t\t\tlong_range = Range.new(location_geometry['location']['lng'], location_geometry['viewport']['northeast']['lng'])\n\t\t\tend\n\t\t\tif !location.nil?\n\t\t\t\t@user_location_lat = rand(lat_range).round(7)\n\t\t\t\t@user_location_long = rand(long_range).round(7)\n\t\t\telse\n\t\t\t\t@user_location_lat = \"here\"\n\t\t\t\t@user_location_long = \"here\"\n\t\t\tend\n\t\telse\n\t\t\t@user_location_lat = \"no data\"\n\t\t\t@user_location_long = \"no data\"\n\t\tend\n\tend",
"def get_location(photo_id)\n # begin\n rsp = @flickr.send_request('flickr.photos.geo.getLocation', {:photo_id => photo_id})\n Flickr::Photos::Location.new(:latitude => rsp.photo.location[:latitude].to_f,\n :longitude => rsp.photo.location[:longitude].to_f, :accuracy => rsp.photo.location[:accuracy].to_i)\n end",
"def location\n fetch('harry_potter.locations')\n end",
"def set_location\n location = flickr.places.findByLatLon(lat: lat, lon: lon)\n location.size >= 1 ? @location = location.first['name'] : @location = \"Unidentifiable location\"\n end",
"def maps_api_location\n \"#{self.city}+#{self.state.sub(\"International\", \"\")}\".sub(\" \", \"+\")\n end",
"def extract_coordinates(parsed)\n parsed['results'].first['geometry']['location']\nend",
"def location\n if [latitude, longitude].all?(&:present?)\n [latitude, longitude]\n end\n end",
"def get_location\n location_request = Geocoder.search(gets)\n if location_request.count != 1\n \"Whoops, we couldn't pinpoint your exact location with that address. Please try again.\"\n get_location\n else\n location_lat = location_request[0].data[\"geometry\"][\"location\"][\"lat\"]\n location_lon = location_request[0].data[\"geometry\"][\"location\"][\"lng\"]\n {lat: location_lat, lon: location_lon}\n end\nend",
"def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_start);\n \tset_to_results(shops);\n end",
"def locate(address)\n get :geo, :q => address\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
"def location\n fetch('sword_art_online.location')\n end",
"def locate(latitude,longitude)\n get escape(\"lat=#{latitude}&lon=#{longitude}\")\n end",
"def location\n ensure_full_data!\n @gapi[\"location\"]\n end",
"def get_location(location)\n client = Weatherman::Client.new\n client.lookup_by_location(location)\nend",
"def location\n fetch('books.the_kingkiller_chronicle.locations')\n end"
] | [
"0.6789773",
"0.67645496",
"0.66912407",
"0.66529256",
"0.64894986",
"0.6479431",
"0.63925785",
"0.63309735",
"0.63195944",
"0.6300483",
"0.6294831",
"0.6293119",
"0.6277442",
"0.62539244",
"0.62111926",
"0.61902106",
"0.61622113",
"0.61420965",
"0.6132925",
"0.6113445",
"0.6111327",
"0.60966116",
"0.60905725",
"0.60894614",
"0.6075838",
"0.6043413",
"0.6034065",
"0.60258234",
"0.60059845",
"0.600365"
] | 0.78662646 | 0 |
pulls a description of the building from freebase from Wikipedia | def get_building_description(building)
search = FreebaseAPI.session.search("#{building.name}")
if search != []
resource_id = search[0]["id"]
resource = FreebaseAPI::Topic.get("#{resource_id}")
@building_description = resource.description
else
@building_description = "There is no available description for this project."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info\n doc = Hpricot(open(noaa_url))\n puts noaa_url\n if !self.description\n doc.search(\"h1\").each do |elem| \n desc = elem.inner_html\n # remove imbeded links in the middle of the description\n desc.gsub!(/\\<a.href.*?\\<\\/a\\>/,' ')\n self.description = desc\n puts self.description\n self.save\n end\n end\n if !self.geo_location\n begin\n elems = doc.search(\"p/b\").to_a.map{|elm| elm.inner_html}\n if elems[1] == \"Owned and maintained by National Data Buoy Center\"\n puts elems[4]\n self.geo_location = elems[4]\n self.save\n end\n rescue\n end \n end\n end",
"def get_wiki(search)\n return Wikipedia::article(search).first\n search = search.split(/\\s+/).map {|w| w.capitalize }.join(' ')\n page = Wikipedia.find(search)\n g = JSON.parse(page.json)\n content = g[\"query\"][\"pages\"].first.last[\"revisions\"].first\n\n\n content = content[\"*\"]\n\n\n wiki = WikiCloth::Parser.new({ data: content })\n\n html = wiki.to_html\n\n doc = Nokogiri::HTML(html)\n doc = doc.xpath(\"//p\").to_s\n doc = Nokogiri::HTML(doc)\n doc = doc.xpath(\"//text()\").to_s\n\n doc = doc.split(\"\\n\")\n\n plaintext = []\n\n doc.each do |d|\n unless d.empty?\n plaintext << d\n end\n end\n\n\n return plaintext\n end",
"def description; @doc['description']; end",
"def description; @doc['description']; end",
"def description\n\t # if the description exists\n\t # return it \n\t # else \n\t # scrape to get the description\n\t # return it\n\t # end\n\tend",
"def get_info(w)\n\trequire 'open-uri'\n\tparagraph = []\n\tcontents = open('http://en.wikipedia.org/wiki/' + w) {|f| \n\t\tf.readlines.each {|x| \n\t\t\tif x =~ /<p>(.*)<\\/p>/\n\t\t\tparagraph.push($1)\n\t\t\tend\n\t}}\n\n\t# If a file name was passed in to be stored somewhere\n\t# Otherwise, Temp.doc will be created and modified\n\tif(ARGV[0] != nil)\n\t\tfile = File.open(ARGV[0], 'a')\n\telse\n\t\tfile = File.open(\"Temp.doc\", 'a')\n\tend\n\n\t# Writes to file what is being searched for\n\tfile.write(w.upcase + \":\\n\")\n\n\t# Uses regular expression to grab first two paragraph\n\tparagraph.each {|p| paragraph(p,file)}\n\t\n\tfile.write(\"\\n\")\n\tfile.close\nend",
"def search(phrase, limit=5, description=true, display=true)\n search = phrase.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=#{search}&limit=#{limit}\"\n hash = get(endpoint)\n results = hash[1]\n descriptions = hash[2]\n if display\n puts \"Displaying #{results.length} results:\"\n for i in 0...results.length\n if description\n if ! descriptions[i].empty?\n puts \"\\n'#{results[i]}' : #{descriptions[i]}\"\n else\n puts \"\\n'#{results[i]}' : No Immediate Description Available. Try `wik -d #{results[i]}`\"\n end\n else\n puts \"\\n'#{results[i]}'\"\n end\n end\n end\n return hash\n end",
"def extract_description(info_url)\n agent = Mechanize.new\n agent.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n page = agent.get(info_url)\n\n # The horrible thing about this page is they use tables for layout. Well done!\n # Also I think the \"Intended use\" bit looks like the most useful. So, we'll use that for the description\n table = page.at('div#bodypadding table')\n # For some reason occasionaly this page can be entirely blank. If it is just do our best and continue\n if table\n table.search('table')[1].search('tr').find do |row|\n # <th> tag contains the name of the field, <td> tag contains its value\n row.at('th') && row.at('th').inner_text.strip == \"Intended use\"\n end.at('td').inner_text.strip\n end\nend",
"def description\n response_json = @client.api_get_request('', 'tree=description')\n response_json['description']\n end",
"def description\n search_by_itemprop 'description'\n end",
"def wikipedia_summary(url)\n doc = Nokogiri::HTML(URI.parse(url).open)\n first_para_html = doc.search('//p').first.to_s # .gsub(/<\\/?[^>]*>/, \"\")\n Sanitize.clean(first_para_html)\n rescue Exception\n nil\n end",
"def wikipedia_summary(url)\n doc = Nokogiri::HTML(open(url))\n first_para_html = doc.search('//p').first.to_s # .gsub(/<\\/?[^>]*>/, \"\")\n return Sanitize.clean(first_para_html)\n rescue Exception\n return nil\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def get_description(n)\n description = Nokogiri::HTML(super(n)).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[0]\n description = description.split(\" \")[3..-1].join(\" \") # remove \"by 'author name'\"\n description.slice!(\"[ Subscribe to the comments on this story ] \")\n description\n else\n nil\n end\n end",
"def get_page\n @html_doc = Nokogiri::HTML(open(\"https://en.wikipedia.org/wiki/2020_NBA_playoffs\"))\n return @html_doc\n end",
"def desc\n\t\t\"Useful for analyzing scanned web sites later.\"\n\tend",
"def extract_description(document)\n node = document.css('div.well>p')\n @description = node.inner_html\n end",
"def description\n @gapi[\"description\"]\n end",
"def ask_wikipedia(search)\n # what is passed in when following a link will be encoded\n search = CGI::unescape(search)\n \n # looks like the encoding we are receiving is not the same as what wikipedia will take in some cases \n # so we decode and then re-encode this so it goes to wikipedia correctly\n search = CGI::escape(search) unless search == \"::Home\"\n\n path = \"/wiki/#{search}\"\n puts \"path = #{path}\"\n \n # temporarily we hardcode these headers which are required by m.wikipedia.org\n headers = {\n # 'User-Agent' => 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28'\n 'User-Agent' => 'Rhosync'\n }\n \n response, data = fetch(path, headers)\n data = rewrite_urls(data)\n \n [data].pack(\"m\").gsub(\"\\n\", \"\")\n end",
"def description\n ensure_full_data!\n @gapi[\"description\"]\n end",
"def crawlNameFromWiki()\n\tbase_url = \"http://en.wikipedia.org\"\n\tpage = \"/wiki/List_of_American_film_actresses\"\n\tremote_full_url = base_url + page\n\tpage = Nokogiri::HTML(open(remote_full_url))\n\tdivs = page.css(\"div#mw-content-text\")\n\tlinks = divs.css(\"div.div-col\").css(\"li\")\n\tpeople = Hash.new(0)\n\thead =\"Name ID\\n\"\n\n\t(0..links.length - 1).each do |n|\n\t\tdata = links[n].text # get the info of each celebrity\n\t\tname = links[n].css(\"a\")[0][\"title\"] # get name\n\t\t# <Optional_lines> --> using birthday to optimize crawling performance\n\t\tbirthD = \"\" \n\t\tif !data.nil?\n\t\t\tregexpression = data[/[^-]\\d{4}$/]\n\t\t\tif !regexpression.nil? and !regexpression.include?\"-\"\n\t\t\t\tbirthD = data[-4..-1]\n\t\t\tend\n\t\tend\n\t\t#</Optional_lines> \n\t\tpeople[name] = birthD # map person name to birthday\n\tend\n\tverifiedTwitter(people)\nend",
"def view(title=nil, id=nil)\n if title\n encoded = title.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=parse&format=json&prop=wikitext&page=#{encoded}&redirects\"\n elsif id\n encoded = title.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=parse&format=json&prop=wikitext&pageid=#{encoded}\"\n end\n hash = get(endpoint)\n page = hash[\"parse\"][\"wikitext\"].to_s.gsub( '\\n', \"\\n\" )\n tmp = Tempfile.new(\"wik-#{encoded}-\")\n tmp.puts page\n system \"less #{tmp.path}\"\n tmp.close\n tmp.unlink\n return hash\n end",
"def description\n 'Bibita'\n end",
"def description\n meta['description'] || extract_description\n end",
"def description\n query_root_node(\"description/text()\")\n end",
"def description(doc)\n node = doc.at('/html/head/meta[@name=\"description\"]/@content') and node.text\n end",
"def leech_story_info\n doc = Nokogiri::HTML(open(\"#{FicSourceURL}/s/#{@fic_id}\"), \"UTF-8\") \n # get author name\n author = doc.xpath(\"//table[@id='gui_table1i']/tbody/tr[1]/td[1]/a[1]\").first.inner_text\n # get story title\n title = doc.xpath(\"//table[@id='gui_table1i']/tbody/tr[1]/td[1]/b[1]\").first.inner_text\n {:title => title, :author => author}\n end",
"def wiki(project, slug)\n get(\"/projects/#{url_encode project}/wikis/#{slug}\")\n end",
"def info\n\t\treturn \"\"\n\t\tp = localized_page\n\t\treturn \"\" unless p && p.content\n\t\tlogger.debug \"parsing page #{p.title}\"\n\t\t\t\n\t\t# extract the top-most section (the one before any ToC)\n\t\tc = WikiCloth::Parser.new({ :data => WikiParser::sanitize(p.content) })\n\t\tc = c.sections.first\n\t\t\n\t\tl = I18n.locale\n\t\tret = WikiParser.new({ :data => c }).to_html\n\t\t#I18n.locale = l\n\t\treturn ret\n\tend"
] | [
"0.6826628",
"0.64196634",
"0.64164716",
"0.64164716",
"0.635525",
"0.63461125",
"0.6181845",
"0.61718607",
"0.6107073",
"0.61048776",
"0.6068321",
"0.60587573",
"0.6019766",
"0.6019766",
"0.5987795",
"0.59378594",
"0.5931605",
"0.587386",
"0.58379036",
"0.5822485",
"0.5803164",
"0.57988095",
"0.5792296",
"0.5789775",
"0.5706195",
"0.570328",
"0.5685056",
"0.56845737",
"0.5683884",
"0.5674707"
] | 0.71829194 | 0 |
Pulls photos for the splash page from instagram | def get_photos
tag = ["urbanlandscape","architecture","buildings","archidaily"].sample
return_hash = HTTParty.get("https://api.instagram.com/v1/tags/#{tag}/media/recent?client_id=#{INSTAGRAM_CLIENT_ID}")
@instagram_photos = [return_hash["data"].sample["images"]["low_resolution"]["url"], return_hash["data"].sample["images"]["low_resolution"]["url"],return_hash["data"].sample["images"]["low_resolution"]["url"],
return_hash["data"].sample["images"]["low_resolution"]["url"]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_photos(building)\n @location = get_instagram_location_id(building)\n unless @location == nil\n @photos = get_instagram_photos(@location)\n end\n end",
"def grab_the_images\n get_the_url = RestClient.get(@url)\n doc = Nokogiri::HTML(get_the_url)\n images = doc.search('img').map{ |img| img['src'] }\n images\n end",
"def scrap_the_images\n url = RestClient.get(@url)\n parsed_result = Nokogiri::HTML(url)\n images = parsed_result.search('img').map { |img| img['src'] }\n images\n end",
"def get_instagram_photos(location_id)\n return_hash = HTTParty.get(\"https://api.instagram.com/v1/locations/#{location_id}/media/recent?client_id=#{INSTAGRAM_CLIENT_ID}\")\n @instagram_photos = [return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"], return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"],return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"]]\n end",
"def fetch_content( collage )\n\n app_config = Rails.application.config_for( :customization )\n path = collage.path\n query = collage.query\n if json?( query )\n query = JSON.parse( query )\n query_type = query[ 'instagram' ][ 'type' ]\n query_string = query[ 'instagram' ][ 'query_string' ]\n end\n max_items = app_config[ 'collages_max_items_to_retrieve' ]\n index = 0\n\n # the following code goes to instagram and scrapes image data from\n # the page.\n # create a headless browser\n b = Watir::Browser.new :phantomjs\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s if query_type == 'user'\n b.goto uri\n\n # all data are stored on this page-level object.\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n\n while( has_next_page && (index < max_items) )\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\\\n + '?&max_id=' + max_id.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s + '?&max_id='\\\n + max_id.to_s if query_type === 'user'\n b.goto uri\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n end\n b.close # IMPORTANT!\n rescue\n Rails.logger.info 'collages_helper - fetch_content() - Error scraping Instagram.'\n b.close\n end",
"def get_images(min = nil, imlimit = 500)\n imcontinue = nil\n ims = Array.new\n count = 0\n loop {\n result = @site.query_prop_images(@normtitle, imlimit, imcontinue)\n proc_res = result['query']['pages']['page']\n if proc_res.key?('missing')\n raise NoPage.new(), \"Page [[#{@title}]] does not exist\"\n end\n if !proc_res.key?('images')\n return nil\n end\n if proc_res['images']['im'].is_a? Array\n ims = ims + proc_res['images']['im']\n else\n ims.push(proc_res['images']['im'])\n end\n if result.key?('query-continue') && min && count < min\n count += lllimit\n imcontinue = result['query-continue']['images']['imcontinue']\n else\n break\n end\n }\n return ims\n end",
"def search_unsplash_for query\n\n Unsplash.configure do |config|\n config.application_access_key = ENV['UNSPLASH_ACCESS']\n config.application_secret = ENV['UNSPLASH_SECRET']\n config.utm_source = \"ExampleAppForClass\"\n end\n\n search_results = Unsplash::Photo.search( query, 1, 1)\n puts search_results.to_json\n\n media = \"\"\n puts search_results.size\n search_results.each do |result|\n #puts result.to_json\n puts \"Result\"\n #message = \"GuaGua sent you photo from \"+ query.to_s + \".\" + result[\"description\"].to_s + result[\"created_at\"].to_s\n media = result[\"urls\"][\"thumb\"].to_s\n end\n return media\n\nend",
"def photos(options = {})\n client = api_client\n\n count = options.fetch(:count, 20)\n # Initial starting value for max_id, if any.\n max_id = options.fetch(:max_id, nil)\n\n api_recent_media = Hash[1.step(count,20).inject([]) do |acc, a|\n if (count > 20)\n options = {count: 20}\n count -= 20\n else\n options = {count: count}\n count = 0\n end\n options = {max_id: max_id}.merge(options) if max_id\n begin\n response = client.user_recent_media(options)\n max_id = response['data'].last['id'].to_i if response['data'].last\n acc + response['data'].map {|u| [u['id'], u]}\n rescue Instagram::Error => e\n # On error just return the accumulator and keep processing\n logger.error(\"Received error #{e.message} from Instagram; continuing.\")\n acc\n end\n end]\n end",
"def crawl(username, last_scraped_id, max_id = nil, items = [])\n # Construct url for the current page of photos\n url = \"https://instagram.com/#{ username }/media/\"\n url += \"?&max_id=#{ max_id }\" if max_id\n\n # Make network call and parse json\n uri = URI.parse(url)\n response = Net::HTTP.get_response(uri)\n json = JSON.parse(response.body) rescue nil\n\n # Raise error if there is any\n raise url if json['status'] != 'ok'\n\n # Short circuit if we have already reached the last scraped photo\n last_scraped_id_index = json['items'].map { |item| item['id'] }.index(last_scraped_id)\n if last_scraped_id_index\n items.concat(json['items'][0...last_scraped_id_index])\n puts \"crawled #{ items.size } items, reached last scraped photo, done\"\n return items\n end\n\n # Append photos from this page to the recursive collection\n items = items.concat(json['items'])\n\n # Recursively crawl the next page; otherwise, we've crawled everything\n if json['more_available']\n puts \"crawled #{ items.size } items, more available (max_id = #{ json['items'][-1]['id'] })\"\n crawl(username, last_scraped_id, json['items'][-1]['id'], items)\n else\n puts \"crawled #{ items.size } items, reached the end, done\"\n end\n\n # Return all the photos crawled\n items\nend",
"def recent_images(count = 20, page = 1)\n latest_photo = self.photos.limit(1).first\n min_id = if latest_photo\n latest_photo.uid\n else\n nil\n end\n\n params = {count: count, access_token: self.access_token}\n params[:min_id] = min_id if min_id\n\n response = Star::Requester.get \"users/#{self.uid}/media/recent\", params\n # Add new photos to DB\n response.body.data.each do |image| \n Photo.create_or_update_from_instagram(image, self)\n end\n self.photos.order('created_at DESC').limit(count)\n\n end",
"def show\n redirect_to :controller => 'sessions', :action => 'connect' if !session[:access_token] \n\n @contest = Contest.find(params[:id])\n\n client = Instagram.client(:access_token => session[:access_token])\n @user = client.user\n \n pictures = client.tag_recent_media('mazeh9art')\n \n pictures.data.each do |p|\n picture = Picture.find_or_initialize_by_instagram_id(p.id)\n picture.update_attributes(title: p.caption.text, url: p.images.standard_resolution.url )\n end\n \n gon.pics = pictures #Contest.first.getNextPictures() \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def get_images_in_page(title, limit = @query_limit_default)\n params = {\n prop: 'images',\n titles: title,\n imlimit: get_limited(limit)\n }\n\n query(params) do |return_val, query|\n pageid = query['pages'].keys.find { |id| id != '-1' }\n return unless pageid\n return_val.concat(query['pages'][pageid]['images'].collect { |img| img['title'] })\n end\n end",
"def fetch_recent_images_by_tag(tag = nil)\n configure_connection\n tag ||= Lentil::Engine::APP_CONFIG[\"default_image_search_tag\"]\n Instagram.tag_recent_media(tag, :count=>10)\n end",
"def images(page)\n document = Nokogiri.HTML(page)\n imgs = []\n document.css('img').each do |img|\n imgs << img.attributes['src']\n end\n return imgs\n end",
"def query\n # Make the request\n results = @client.posts(@url, :type => \"photo\", :limit => 5)\n i = 0\n\n # if there were no results, return 0 which will give an error in game.rb\n if results.empty?\n return 0\n elsif (results.size != 2) and (results[\"posts\"].size == 5) # results will have a size of two if there was an error with the tumblr API, also need 5 pictures\n @imageArray = Array.new(5)\n begin\n \t@imageArray[i] = results[\"posts\"][i][\"photos\"][0][\"alt_sizes\"][1][\"url\"].sub(/_[4-5]00/, '_250') # regular expression will select pictures 250px wide\n \ti += 1\n end while i < 5\n return @imageArray.size\n else\n return results.size\n end\n end",
"def show\n if !session[:access_token]\n redirect_to :controller => 'sessions', :action => 'connect'\n end\n\n pmocampo = \"30792403\"\n client = Instagram.client(:access_token => session[:access_token])\n \n @user = client.user(pmocampo)\n \n @album = Album.find(params[:id])\n @photos = client.user_recent_media(pmocampo)\n @photos = @photos.select {|p| p.tags.include?(@album.tag)}\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end",
"def get_image_from_photo_info(photos)\n photos.map do |photo|\n \"https://live.staticflickr.com/#{photo['server']}/#{photo['id']}_#{photo['secret']}.jpg\"\n end\n end",
"def photos(page = 1, per_page = 10)\n params = {\n page: page,\n per_page: per_page\n }\n\n list = JSON.parse(connection.get(\"/collections/#{id}/photos\", params).body)\n list.map { |photo| Unsplash::Photo.new photo }\n end",
"def get_images(tag)\n\tpageThumb = get_page(\"#{URL_MOTARU}/categories/view/name/#{tag}\")\n\treturn pageThumb.search(\"//div[@id='categoryWallpapersList']//img[@class='wallpaperThumb']\")\nend",
"def incremental_image_urls(url)\n log \"method begin\" if $DEBUG\n login if not logged_in?\n log \"logged in\" if $DEBUG\n\n page = agent.get(url)\n log \"got page\" if $DEBUG\n\n links = page.links.select {|l| l.href =~ /wallbase.cc\\/wallpaper/ } \n log \"selected links\" if $DEBUG\n links.each do |l|\n page = l.click\n log \"clicked link\" if $DEBUG\n url = page.image_urls().select {|e| e.match /wallbase2/ }.first\n puts url\n end\n\n end",
"def index\n @blog_posts = BlogPost.order(posted_at: :desc)\n @latlongarray = BlogPost.order(posted_at: :desc).all.collect {|blog_post| [blog_post.address, blog_post.latitude, blog_post.longitude, blog_post.blog_entry[0..50], blog_post.photo.url(:small), blog_post.friendly_id, blog_post.title]}\n response = HTTParty.get(\"https://api.instagram.com/v1/tags/oregontravelgirls/media/recent?access_token=2682.bb484d1.e90b2e38118a40fcaa13186b24649df2\")\n response2 = HTTParty.get(\"https://api.instagram.com/v1/tags/oregontravelgirls?access_token=2682.bb484d1.e90b2e38118a40fcaa13186b24649df2\")\n @count = response2[\"data\"][\"media_count\"]\n # @link = response[\"data\"][i][\"link\"]\n\n # @photos = []\n @links = []\n\n @photo_hash = {}\n\n i = 0\n if @count < 18\n @count.times do\n @photo_hash[response[\"data\"][i][\"images\"][\"standard_resolution\"][\"url\"]] = response[\"data\"][i][\"caption\"][\"text\"]\n i+=1\n end\n else\n 18.times do\n # @photos = @photos.push(response[\"data\"][i][\"images\"][\"thumbnail\"][\"url\"])\n @links = @links.push(response[\"data\"][i][\"link\"])\n @photo_hash[response[\"data\"][i][\"images\"][\"standard_resolution\"][\"url\"]] = response[\"data\"][i][\"caption\"][\"text\"]\n i+=1\n end\n end\n end",
"def photos(args = {})\r\n return Net::Flickr.instance().photos.get_public_photos(@id, args)\r\n end",
"def list_images\n if params[:page].to_s.to_i > 1000\n render(\n status: :too_many_requests,\n content_type: \"text/plain\",\n plain: \"Your queries are killing our server. \" \\\n \"There are much better ways to scrape the images \" \\\n \"from our site. \" \\\n \"Please contact the webmaster.\" \\\n \"And please stop hammering our server!\"\n )\n return\n end\n\n query = create_query(:Image, :all, by: :created_at)\n show_selected_images(query)\n end",
"def images(article_or_pageid, imlimit = 200)\n form_data = {'action' => 'query', 'prop' => 'images', 'imlimit' => imlimit, 'redirects' => true}\n case article_or_pageid\n when Fixnum\n form_data['pageids'] = article_or_pageid\n else\n form_data['titles'] = article_or_pageid\n end\n xml, dummy = make_api_request(form_data)\n page = xml.elements[\"query/pages/page\"]\n if valid_page? page\n if xml.elements[\"query/redirects/r\"]\n # We're dealing with redirect here.\n images(page.attributes[\"pageid\"].to_i, imlimit)\n else\n imgs = REXML::XPath.match(page, \"images/im\").map { |x| x.attributes[\"title\"] }\n end\n else\n nil\n end\n end",
"def extract_badgeimages()\n@badgeimages_array = []\n file = File.open('app/assets/post.html')\n doc = Nokogiri::HTML(file)\n doc.search('.mb_div a img').map do |element|\n image_url = 'http://www.boyscouttrail.com' + element['src']\n @badgeimages_array << image_url\n end\n return @badgeimages_array\nend",
"def get_place_photos(agent)\n urls_array = []\n a = agent.search(\".item.respageMenu-item.photosTab\").attr('href').value\n agent_inside = Mechanize.new\n agent_inside.user_agent_alias = 'Mac Safari'\n ## We enter the page for each link and save the data we want\n current_agent = agent_inside.get(a)\n current_agent.search(\".photobox.pos-relative.left.mb10.js-heart-container.thumbContainer\")[1..6].each do |link|\n\n a = link.search(\".res-photo-thumbnail.thumb-load\").attr('data-original').value.match(/(^.*)(?=\\?)/).to_s\n urls_array << a\n end\n return urls_array\nend",
"def paginated_hatom_imgs(uri, depth = 0)\n\tfinal_uri, page = fetch(uri)\n\tdoc = Nokogiri::parse(page.body)\n\timgs = doc.search('.entry-content a').map do |el|\n\t\tnext if el.attributes['rel'].to_s =~ /(?:^|\\s)(?:tag|bookmark)(?:\\s|$)/i\n\t\tnext if el.attributes['class'].to_s =~ /(?:^|\\s)(?:url|response|username|hashtag)(?:\\s|$)/i\n\t\trelative_to_absolute(el.attributes['href'].to_s, final_uri)\n\tend.compact.uniq.map do |uri|\n\t\tfind_photo_uri(uri) rescue nil\n\tend.compact.uniq.reject do |uri|\n\t\turi =~ /logo|avatar/\n\tend\n\n\tif imgs.length < 10 && depth < 5\n\t\tif (n = doc.at('*[rel~=\"next\"]'))\n\t\t\timgs + paginated_hatom_imgs(relative_to_absolute(\n\t\t\t\tn.attributes['href'].to_s, final_uri), depth+1)\n\t\tend\n\tend\n\n\timgs\nend",
"def get_images(hash)\n url = open(\"https://www.mariowiki.com/Super_Smash_Bros._Ultimate\")\n document = Nokogiri::HTML(url)\n\n veteran_table = document.css(\".gallery.mw-gallery-traditional\")[0]\n newcomers_table = document.css(\".gallery.mw-gallery-traditional\")[1]\n\n get_portraits_and_icons(hash, veteran_table)\n get_portraits_and_icons(hash, newcomers_table)\nend",
"def index\n @photos = get_possible_photos\n paginate json: @photos, per_page: 10\n end",
"def photos\n response = photo_search\n photos_response = response['photos']\n @photos = photos_response['photo'].each{|p| p.extend Flickr::PhotoHelper }\n @per_page = photos_response['perpage']\n @total = photos_response['total']\n @pages = photos_response['pages']\n @page = photos_response['page']\n end"
] | [
"0.7226892",
"0.6969803",
"0.6883585",
"0.6859129",
"0.6772523",
"0.65424913",
"0.6509472",
"0.64508295",
"0.6420674",
"0.64179087",
"0.6368606",
"0.6290793",
"0.6288707",
"0.61813956",
"0.6179772",
"0.6164461",
"0.6160972",
"0.6127935",
"0.6112806",
"0.6109665",
"0.6103119",
"0.6098361",
"0.608053",
"0.6076477",
"0.60685563",
"0.606134",
"0.60581845",
"0.6052278",
"0.60235435",
"0.6022843"
] | 0.74473906 | 0 |
GET /caracteristica_tipo_vehiculos GET /caracteristica_tipo_vehiculos.json | def index
@caracteristica_tipo_vehiculos = CaracteristicaTipoVehiculo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def set_caracteristica_tipo_vehiculo\n @caracteristica_tipo_vehiculo = CaracteristicaTipoVehiculo.find(params[:id])\n end",
"def index\n @tipo_veiculos = TipoVeiculo.all\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def index\n @vehiculos = Vehiculo.all\n end",
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end",
"def new\n @tipo_vehiculo = TipoVehiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def index\n @veterinarios = Veterinario.all\n end",
"def index\n @categorias = Categoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @categorias }\n end\n end",
"def index\n @veterinarios = Veterinario.all\n end",
"def index\n @terciaria_caracteristicas = TerciariaCaracteristica.all\n end",
"def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end",
"def caracteristica_tipo_vehiculo_params\n params.require(:caracteristica_tipo_vehiculo).permit(:caracteristica, :requerido, :tipo_dato_id, :tipo_vehiculo_id, :orden)\n end",
"def index\n @vehicle_types = VehicleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vehicle_types }\n end\n end",
"def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end",
"def index\n @veiculos = Veiculo.all\n end",
"def index\n @subcategorias = Subcategoria.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @subcategorias }\n end\n end",
"def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end",
"def index\n @tipo_venta = TipoVentum.all\n end",
"def new\n @uf = Uf.first\n @municipios = @uf.municipios\n @cargo_eleicao = Eleicao.find(:first, :conditions => \"status = true\").cargo_eleicaos\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cargo_eleicao }\n end\n end",
"def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end",
"def show\n @tipo_convenio = TipoConvenio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_convenio }\n end\n end",
"def index\n @tipo_de_servicios = TipoDeServicio.all\n end",
"def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end",
"def new\n @caracteristica_imovel = CaracteristicaImovel.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caracteristica_imovel }\n end\n end"
] | [
"0.67287403",
"0.6714293",
"0.6675164",
"0.6317971",
"0.6298448",
"0.6252864",
"0.6237887",
"0.62116313",
"0.6205601",
"0.6196258",
"0.6196258",
"0.6196258",
"0.61919487",
"0.6182495",
"0.6166906",
"0.61643827",
"0.6161133",
"0.6158662",
"0.614944",
"0.60912246",
"0.60810816",
"0.6080001",
"0.60665935",
"0.60636467",
"0.60636467",
"0.60402465",
"0.60398674",
"0.60382503",
"0.6035476",
"0.60254115"
] | 0.70242286 | 0 |
POST /caracteristica_tipo_vehiculos POST /caracteristica_tipo_vehiculos.json | def create
@caracteristica_tipo_vehiculo = CaracteristicaTipoVehiculo.new(caracteristica_tipo_vehiculo_params)
respond_to do |format|
if @caracteristica_tipo_vehiculo.save
format.html { redirect_to @caracteristica_tipo_vehiculo, notice: 'Caracteristica tipo Vehiculo was successfully created.' }
format.json { render :show, status: :created, location: @caracteristica_tipo_vehiculo }
else
format.html { render :new }
format.json { render json: @caracteristica_tipo_vehiculo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def caracteristica_tipo_vehiculo_params\n params.require(:caracteristica_tipo_vehiculo).permit(:caracteristica, :requerido, :tipo_dato_id, :tipo_vehiculo_id, :orden)\n end",
"def create\n @tipo_vehiculo = TipoVehiculo.new(params[:tipo_vehiculo])\n\n respond_to do |format|\n if @tipo_vehiculo.save\n format.html { redirect_to @tipo_vehiculo, notice: 'Tipo vehiculo was successfully created.' }\n format.json { render json: @tipo_vehiculo, status: :created, location: @tipo_vehiculo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_caracteristica_tipo_vehiculo\n @caracteristica_tipo_vehiculo = CaracteristicaTipoVehiculo.find(params[:id])\n end",
"def vehiculo_params\n params.require(:vehiculo).permit(:id_client, :tipo, :tamano, :descripcion)\n end",
"def create\n @admin_vehicle = City.find(session[:current_city_id]).utility.vehicles.new(admin_vehicle_params)\n @vehicle_type = params[:vehicle][:vehicle_type]\n italian_type = {parking:'Parcheggi', bike:'Bici', taxi:'Taxi'}\n respond_to do |format|\n if @admin_vehicle.save\n format.html { redirect_to session['previous_url'] || admin_vehicles_url(vehicle_type: @admin_vehicle.vehicle_type), notice: \"#{italian_type[@vehicle_type.to_sym]} è stato creato con successo.\" }\n format.json { render :show, status: :created, location: @admin_vehicle }\n else\n format.html { render :new }\n format.json { render json: @admin_vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_veiculo = TipoVeiculo.new(tipo_veiculo_params)\n\n respond_to do |format|\n if @tipo_veiculo.save\n format.html { redirect_to @tipo_veiculo, notice: 'Tipo veiculo was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_veiculo }\n else\n format.html { render :new }\n format.json { render json: @tipo_veiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def vehiculo_params\n params.require(:vehiculo).permit(:placa, :clase, :subtipo, :edad, :numero_pasajero, :cilindraje, :toneladas, :propietario, :poliza)\n end",
"def resource_params\n params.require(:tratamiento).permit(:tipo)\n end",
"def create\n @terciaria_caracteristica = TerciariaCaracteristica.new(terciaria_caracteristica_params)\n\n respond_to do |format|\n if @terciaria_caracteristica.save\n format.html { redirect_to @terciaria_caracteristica, notice: 'Terciaria caracteristica was successfully created.' }\n format.json { render :show, status: :created, location: @terciaria_caracteristica }\n else\n format.html { render :new }\n format.json { render json: @terciaria_caracteristica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objeto = Caracteristica.new(caracteristica_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Caracteristica was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehiculo = Vehiculo.new(vehiculo_params)\n\n respond_to do |format|\n if @vehiculo.save\n format.html { redirect_to @vehiculo, notice: 'Vehiculo was successfully created.' }\n format.json { render :show, status: :created, location: @vehiculo }\n else\n format.html { render :new }\n format.json { render json: @vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recursoshumanos_tipo_vinculo_params\n params.require(:recursoshumanos_tipo_vinculo).permit(:nome)\n end",
"def create\n @tipo_ventum = TipoVentum.new(tipo_ventum_params)\n\n respond_to do |format|\n if @tipo_ventum.save\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_ventum }\n else\n format.html { render :new }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def caracteristica_params\n params.require(:caracteristica).permit(:codigo, :descricao, :unidade, :created_by, :updated_by)\n end",
"def new\n @tipo_vehiculo = TipoVehiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def vehicle_params\n params.require(:vehicle).permit(:patente, :vehicle_type_id, :description, :phone)\n end",
"def create\n @tipo_de_servicio = TipoDeServicio.new(tipo_de_servicio_params)\n\n respond_to do |format|\n if @tipo_de_servicio.save\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_de_servicio }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ordem_servico = OrdemServico.new(ordem_servico_params)\n set_funcionario\n @ordem_servico.valor_total = @ordem_servico.get_valor_ordem_servico\n\n respond_to do |format|\n if @ordem_servico.save\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_salvo')}\n format.json { render :show, status: :created, location: @ordem_servico }\n else\n @ordem_servico.servico_items.build unless @ordem_servico.servico_items.size > 0\n @ordem_servico.produto_items.build unless @ordem_servico.produto_items.size > 0\n format.html { render :new }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def producto_vehiculo_params\n params.require(:producto_vehiculo).permit(:producto, :marca, :modelos, :anho, :motor, :patente, :fecha_inicio, :fecha_termino, :nombre_comprador, :apellido_comprador, :rut_comprador, :digito_verifiador_comprador, :email_comprador, :numero_comprador, :nombre_asegurado, :apellido_asegurado, :rut_asegurado, :digito_verificador_asegurado, :email_asegurado, :numero_asegurado)\n end",
"def terciaria_caracteristica_params\n params.require(:terciaria_caracteristica).permit(:nome)\n end",
"def create\n # Crear nuevo voto\n @voto = Voto.new(params[:voto])\n\n # Asociarlo con el usuario\n @voto.usuario_id = current_usuario.id\n\n # Asociarlo con la Pregunta o Respuesta\n votable_type = params[:voto][:votable_type]\n votable_id = params[:voto][:votable_id]\n if votable_type=='Pregunta'\n @voto.votable = Pregunta.find(votable_id)\n else\n @voto.votable = Respuesta.find(votable_id)\n end\n\n respond_to do |format|\n if @voto.save\n resp = {\n :votos_total => @voto.votable.votos_total,\n :votos_menos => @voto.votable.votos_menos,\n :votos_mas => @voto.votable.votos_mas\n }\n format.json { render json: resp, status: :created, location: @voto }\n else\n format.json { render json: @voto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully created.' }\n format.json { render :json => @tecnico, :status => :created, :location => @tecnico }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cliente = Cliente.new\n if params[:type] == \"PessoaFisica\"\n @cliente.pessoa = PessoaFisica.new\n else\n @cliente.pessoa = PessoaJuridica.new\n end\n @cliente.assign_attributes(cliente_params)\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to action: \"index\"}\n format.json { render json: @cliente.to_json(include: [:pessoa]) }\n else\n format.html { render :new }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def veterinario_params\n params.require(:veterinario).permit(:nome, :cpf, :sexo, :data_nascimento, :crmv, :telefone, :especialidade)\n end",
"def tipo_veiculo_params\n params.require(:tipo_veiculo).permit(:tipo)\n end",
"def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_vehiculo = TipoVehiculo.new(params[:tipo_vehiculo])\n\n respond_to do |format|\n if @tipo_vehiculo.save\n format.html { redirect_to(@tipo_vehiculo, :notice => 'TipoVehiculo was successfully created.') }\n format.xml { render :xml => @tipo_vehiculo, :status => :created, :location => @tipo_vehiculo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_vehiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @producto_vehiculo = ProductoVehiculo.new(producto_vehiculo_params)\n\n respond_to do |format|\n if @producto_vehiculo.save\n format.html { redirect_to @producto_vehiculo, notice: 'Producto vehiculo was successfully created.' }\n format.json { render :show, status: :created, location: @producto_vehiculo }\n else\n format.html { render :new }\n format.json { render json: @producto_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tarifas_servicio_params\n params.require(:tarifas_servicio).permit(:PKSERVICIO, :SER_DESCRIPCION, :SER_NOTAS)\n end",
"def create\n @veterinario = Veterinario.new(veterinario_params)\n\n respond_to do |format|\n if @veterinario.save\n format.html { redirect_to @veterinario, notice: 'Veterinario was successfully created.' }\n format.json { render :show, status: :created, location: @veterinario }\n else\n format.html { render :new }\n format.json { render json: @veterinario.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7142103",
"0.6855672",
"0.6756804",
"0.66677755",
"0.6600915",
"0.65304816",
"0.642999",
"0.62615806",
"0.62523407",
"0.62275213",
"0.6225034",
"0.62203115",
"0.61942595",
"0.61918473",
"0.6189913",
"0.6187988",
"0.61772424",
"0.61559784",
"0.6131049",
"0.6131027",
"0.6128336",
"0.6110212",
"0.61098945",
"0.6086246",
"0.6085325",
"0.6074524",
"0.6074187",
"0.6072189",
"0.60721326",
"0.6067924"
] | 0.68829685 | 1 |
PATCH/PUT /caracteristica_tipo_vehiculos/1 PATCH/PUT /caracteristica_tipo_vehiculos/1.json | def update
respond_to do |format|
if @caracteristica_tipo_vehiculo.update(caracteristica_tipo_vehiculo_params)
format.html { redirect_to @caracteristica_tipo_vehiculo, notice: 'Caracteristica tipo Vehiculo was successfully updated.' }
format.json { render :show, status: :ok, location: @caracteristica_tipo_vehiculo }
else
format.html { render :edit }
format.json { render json: @caracteristica_tipo_vehiculo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vehiculo.update_attributes(params[:tipo_vehiculo])\n format.html { redirect_to @tipo_vehiculo, notice: 'Tipo vehiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(caracteristica_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Caracteristica was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @producto_vehiculo.update(producto_vehiculo_params)\n format.html { redirect_to @producto_vehiculo, notice: 'Producto vehiculo was successfully updated.' }\n format.json { render :show, status: :ok, location: @producto_vehiculo }\n else\n format.html { render :edit }\n format.json { render json: @producto_vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n if @tipo_contrato.update_attributes(params[:tipo_contrato])\n format.html { redirect_to tipo_contratos_path, notice: 'Tipo de contrato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(carpeta_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Carpeta was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_veiculo.update(tipo_veiculo_params)\n format.html { redirect_to @tipo_veiculo, notice: 'Tipo veiculo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_veiculo }\n else\n format.html { render :edit }\n format.json { render json: @tipo_veiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vehiculo.update(vehiculo_params)\n format.html { redirect_to @vehiculo, notice: 'Vehiculo was successfully updated.' }\n format.json { render :show, status: :ok, location: @vehiculo }\n else\n format.html { render :edit }\n format.json { render json: @vehiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vehiculo.update_attributes(params[:tipo_vehiculo])\n format.html { redirect_to(@tipo_vehiculo, :notice => 'TipoVehiculo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_vehiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n respond_to do |format|\n if @terciaria_caracteristica.update(terciaria_caracteristica_params)\n format.html { redirect_to @terciaria_caracteristica, notice: 'Terciaria caracteristica was successfully updated.' }\n format.json { render :show, status: :ok, location: @terciaria_caracteristica }\n else\n format.html { render :edit }\n format.json { render json: @terciaria_caracteristica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_caracteristica_tipo_vehiculo\n @caracteristica_tipo_vehiculo = CaracteristicaTipoVehiculo.find(params[:id])\n end",
"def update\n @marcas = @truck.get_marcas() \n @modelos = @truck.get_modelos()\n @tipo_unidad = @truck.get_tipos()\n @config = @truck.get_config()\n @clase = @truck.get_clase()\n @color = @truck.get_color()\n\n\n respond_to do |format|\n if @truck.update(truck_params)\n format.html { redirect_to @truck, notice: 'Truck was successfully updated.' }\n format.json { render :show, status: :ok, location: @truck }\n else\n format.html { render :edit }\n format.json { render json: @truck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitacoes_avaliacoes_servico.update(solicitacoes_avaliacoes_servico_params)\n format.html { redirect_to @solicitacoes_avaliacoes_servico, notice: 'Solicitacoes avaliacoes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacoes_avaliacoes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @evolucao_tipo.update(evolucao_tipo_params)\n format.html { redirect_to @evolucao_tipo, notice: 'Evolucao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evolucao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_comunicacao.update(tipo_comunicacao_params)\n format.html { redirect_to @tipo_comunicacao, notice: 'Tipo comunicacao was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_comunicacao }\n else\n format.html { render :edit }\n format.json { render json: @tipo_comunicacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n obtener_datos()\n @status = params[:statusproyect]\n @cliente = params[:cliente] + \" \" +params[:cliente_apellido]\n respond_to do |format|\n if @ventum.update(cliente: @cliente, clave:@clave, fecha:@fecha, iva:@iva,subtotal:@preciofinal ,total:@totalcosto, descuentogeneral: @descglobal , distribuidor: @distribuidor, status: @status)\n @detail.each do |x|\n x.destroy\n end\n salvar()\n format.html { redirect_to @ventum, notice: 'Venta actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n if @tipo_negocio.update_attributes(params[:tipo_negocio])\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_compra.update(tipo_compra_params)\n format.html { redirect_to @tipo_compra, notice: 'Tipo compra was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_compra }\n else\n format.html { render :edit }\n format.json { render json: @tipo_compra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @registro_servicio.update(registro_servicio_params)\n format.html { redirect_to @registro_servicio, notice: 'Servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @registro_servicio }\n else\n format.html { render :edit }\n format.json { render json: @registro_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tb_servicio.update(tb_servicio_params)\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tb_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6703473",
"0.64150083",
"0.6403183",
"0.63103616",
"0.6251855",
"0.62437326",
"0.62407446",
"0.623896",
"0.6235374",
"0.6208206",
"0.61891496",
"0.617801",
"0.617799",
"0.6176649",
"0.61757034",
"0.6168954",
"0.61610365",
"0.61538714",
"0.6136334",
"0.61263084",
"0.6118688",
"0.6118309",
"0.6108322",
"0.6104115",
"0.61039615",
"0.6102761",
"0.6097784",
"0.6080753",
"0.6078636",
"0.6064738"
] | 0.66793483 | 1 |
DELETE /caracteristica_tipo_vehiculos/1 DELETE /caracteristica_tipo_vehiculos/1.json | def destroy
@caracteristica_tipo_vehiculo.destroy
respond_to do |format|
format.html { redirect_to caracteristica_tipo_vehiculos_url, notice: 'Caracteristica tipo Vehiculo was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_vehiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @terciaria_caracteristica.destroy\n respond_to do |format|\n format.html { redirect_to terciaria_caracteristicas_url, notice: 'Terciaria caracteristica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contacter = Contacter.find(params[:id])\n @contacter.destroy\n\n respond_to do |format|\n format.html { redirect_to contacters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehiculo.destroy\n respond_to do |format|\n format.html { redirect_to vehiculos_url, notice: 'Vehiculo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle_carrito.destroy\n respond_to do |format|\n format.html { redirect_to detalle_carritos_url, notice: 'Detalle carrito was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n set_redireccion\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to @redireccion, notice: 'Caracteristica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_convenio = TipoConvenio.find(params[:id])\n @tipo_convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_convenios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ordem_servico.destroy\n respond_to do |format|\n format.html { redirect_to ordem_servicos_url, notice: t('messages.cadastro_removido') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @caracteristica_patologica.destroy\n respond_to do |format|\n format.html { redirect_to caracteristica_patologicas_url, notice: 'Caracteristica patologica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @caracteristica_cartum = CaracteristicaCartum.find(params[:id])\n @caracteristica_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to caracteristica_carta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @veiculo_motorista.destroy\n respond_to do |format|\n format.html { redirect_to veiculo_motoristas_url, notice: 'Veiculo motorista was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @basico_modelo_vehiculo.destroy\n respond_to do |format|\n format.html { redirect_to basico_modelo_vehiculos_url, notice: 'Modelo vehiculo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_vehiculos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @basico_marca_vehiculo.destroy\n respond_to do |format|\n format.html { redirect_to basico_marca_vehiculos_url, notice: 'Marca vehiculo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @principal_caracteristica.destroy\n respond_to do |format|\n format.html { redirect_to principal_caracteristicas_url, notice: 'Principal caracteristica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle.destroy\n respond_to do |format|\n format.html { redirect_to vehicles_url, notice: 'El vehículo seleccionado fue eliminado' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.72620416",
"0.7072246",
"0.7028626",
"0.70176595",
"0.69568795",
"0.69474995",
"0.69376594",
"0.69361115",
"0.69206196",
"0.69167745",
"0.69157434",
"0.6912997",
"0.69037396",
"0.6896084",
"0.68951166",
"0.68947405",
"0.6893536",
"0.68873507",
"0.6882184",
"0.68803865",
"0.6857541",
"0.6851039",
"0.6847527",
"0.68425876",
"0.6842024",
"0.68403393",
"0.68371356",
"0.68365335",
"0.6835574",
"0.6833034"
] | 0.7395322 | 0 |
Nokogiri::HTML4 returns an empty Document when given a blank string GH11 | def test_empty_string_returns_empty_doc
doc = Nokogiri::HTML4("")
assert_instance_of(Nokogiri::HTML4::Document, doc)
assert_nil(doc.root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean!(html)\n @whitelist_nodes = []\n fragment = Nokogiri::HTML::DocumentFragment.parse(html)\n clean_node!(fragment)\n @whitelist_nodes = []\n\n output_method_params = {:encoding => 'utf-8', :indent => 0}\n\n if @config[:output] == :xhtml\n output_method = fragment.method(:to_xhtml)\n output_method_params[:save_with] = Nokogiri::XML::Node::SaveOptions::AS_XHTML\n elsif @config[:output] == :html\n output_method = fragment.method(:to_html)\n else\n raise Error, \"unsupported output format: #{@config[:output]}\"\n end\n\n result = output_method.call(output_method_params)\n\n # Ensure that the result is always a UTF-8 string in Ruby 1.9, no matter\n # what. Nokogiri seems to return empty strings as ASCII for some reason.\n result.force_encoding('utf-8') if RUBY_VERSION >= '1.9'\n\n return result == html ? nil : html[0, html.length] = result\n end",
"def doc\n @doc ||= ::Nokogiri::HTML(@html)\n end",
"def nokogiri\n Nokogiri::HTML(html)\n end",
"def parsed\n @parsed ||= Nokogiri::HTML(@document.to_s)\n end",
"def parsed\n @parsed ||= Nokogiri::HTML(@document.to_s)\n rescue Exception => e\n @exception_log << e\n end",
"def doc\n return @doc if @doc\n @doc = Nokogiri::HTML(@body) if @body && html? rescue nil\n end",
"def doc\n @doc ||= @body && html? && Nokogiri::HTML(@body)\n end",
"def parse_html(html)\n doc = Nokogiri::HTML(html)\n\n # Removing style and script tag content such as Javascript tags in order to get rid of JUNK text\n doc.xpath(\"//script\").remove\n doc.xpath(\"//style\").remove\n begin\n text = doc.at('body').inner_text\n rescue NoMethodError\n puts \"NoMethodError\"\n # puts file_name\n #title = nil\n end\n\n return text\nend",
"def html\n @html ||= Nokogiri::HTML html_source, nil, HTML_ENCODING if html_source\n @html\n end",
"def parsed_document\n @parsed_document ||= Nokogiri::HTML(document)\n rescue Exception => e\n add_fatal_error \"Parsing exception: #{e.message}\"\n end",
"def convert_to_document() \n Nokogiri::HTML.parse(convert())\n end",
"def make(input = nil, opts = {}, &blk)\n if input\n Nokogiri::HTML4.fragment(input).children.first\n else\n Nokogiri(&blk)\n end\n end",
"def strip_html(text)\n Nokogiri::HTML.fragment(text).content\n end",
"def parsed_document\n @parsed_document ||= Nokogiri::HTML(document)\n\n rescue Exception => e\n warn 'An exception occurred while trying to scrape the page!'\n warn e.message\n end",
"def HTML4(input, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def fix!\n fragment = Nokogiri::HTML.fragment(self.html)\n fragment.to_html\n end",
"def parse_html(html_body)\t\n #puts \"Parsing the html content: #{html_body}. Return DOM \" if @verbose\n\t\tbegin\n doc = Nokogiri::HTML(html_body)\n\t\t\t#puts \"Successfully crawling the url: #{url_object.base_uri.to_s}\" if @verbose\n\t\t\t#puts \"doc: #{doc}\" if @verbose\n\t\t\treturn doc\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return nil\n end\n\tend",
"def blanktest(doc)\n #strip out unicode character that gives us false blanks\n badspc = Nokogiri::HTML(\"​\").text\n nbsp = Nokogiri::HTML(\" \").text\n isblank = doc.gsub(badspc,\"\").gsub(nbsp,\"\").gsub(\"\\ \",\"\").gsub(/\\n/,\"\").gsub(/\\s+/,\"\")\n if isblank == \"\"\n blank = true\n else\n blank = false\n end\n end",
"def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end",
"def parse_html(html)\n cleaned = html.gsub(/\\n/, '').gsub(/>\\s*</m, '><').gsub /\\x00/, ''\n doc = Nokogiri::HTML(cleaned, nil, nil, Nokogiri::XML::ParseOptions.new.default_html.noblanks)\n # remove all 'script' and 'style' nodes from the document\n doc.css('style').each {|n| n.remove }\n doc.css('script').each {|n| n.remove }\n doc\n end",
"def parse_page\n @doc = Nokogiri::HTML(@html)\n end",
"def standardize_dom(html)\n if !html.css(\"body\")\n html.css(\":not(head)\").wrap(\"<body></body>\")\n end\n\n if !html.css(\"html\")\n html.wrap(\"<html></html>\")\n end\n nil\n end",
"def html_parser; end",
"def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::HTML(html)\n puts \"done.\"\n puts\n doc\n end",
"def test_xml_prolog_and_doctype_dont_result_in_a_leading_whitespace_in_html\n refute_match(/^\\s+/, render(\"!!! xml\\n!!!\", :format => :html4))\n end",
"def getNokogiriContent(iURL)\n rHTMLDoc = nil\n rError = nil\n\n # Get the title from the HTML header\n lHTMLContent, rError = get_url_content(iURL) do |iHTMLContent|\n next iHTMLContent, nil\n end\n if (lHTMLContent != nil)\n rHTMLDoc = Nokogiri::HTML(lHTMLContent)\n end\n\n return rHTMLDoc, rError\n end",
"def load_html(input) # :nodoc:\n thing = nil\n\n # TODO: duplicate options\n if @options[:with_html_string] or @options[:inline] or input.respond_to?(:read)\n thing = input\n elsif @is_local_file\n @base_dir = File.dirname(input)\n thing = File.open(input, 'r')\n else\n thing = open(input)\n end\n\n if thing.respond_to?(:read)\n thing = thing.read\n end\n\n return nil unless thing\n doc = nil\n\n # Handle HTML entities\n if @options[:replace_html_entities] == true and thing.is_a?(String)\n HTML_ENTITIES.map do |entity, replacement|\n thing.gsub! entity, replacement\n end\n end\n # Default encoding is ASCII-8BIT (binary) per http://groups.google.com/group/nokogiri-talk/msg/0b81ef0dc180dc74\n # However, we really don't want to hardcode this. ASCII-8BIG should be the default, but not the only option.\n if thing.is_a?(String) and RUBY_VERSION =~ /1.9/\n thing = thing.force_encoding(@options[:input_encoding]).encode!\n doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding]) {|c| c.recover }\n else\n default_encoding = RUBY_PLATFORM == 'java' ? nil : 'BINARY'\n doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding) {|c| c.recover }\n end\n\n # Fix for removing any CDATA tags from both style and script tags inserted per\n # https://github.com/sparklemotion/nokogiri/issues/311 and\n # https://github.com/premailer/premailer/issues/199\n %w(style script).each do |tag|\n doc.search(tag).children.each do |child|\n child.swap(child.text()) if child.cdata?\n end\n end\n\n doc\n end",
"def noko_for(url)\n Nokogiri::HTML(open(url).read) \nend",
"def noko_for(url)\n Nokogiri::HTML(open(url).read) \nend",
"def bend_html\n\t\t@bendable_html = Nokogiri::HTML(@unbendable_html.body)\n\tend"
] | [
"0.61461294",
"0.6067033",
"0.6050667",
"0.6016183",
"0.60105026",
"0.59127605",
"0.59118646",
"0.58931535",
"0.5870417",
"0.5856966",
"0.58140177",
"0.57919794",
"0.5760161",
"0.5754884",
"0.57185584",
"0.5705068",
"0.5703725",
"0.5668534",
"0.5663352",
"0.5653728",
"0.563945",
"0.5636219",
"0.56103176",
"0.5606364",
"0.5586047",
"0.55605876",
"0.5553774",
"0.55325544",
"0.55325544",
"0.55207443"
] | 0.81789225 | 0 |
Start a loop and work jobs indefinitely. Call this method to start the worker. This is the easiest way to start working jobs. | def start
while @running
@fork_worker ? fork_and_work : work
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start!\n until should_stop? do work end\n end",
"def start\n @worker.start\n end",
"def start\n prepare\n loop { fork_one_job }\n end",
"def start_worker\n @worker = Thread.new do\n loop do\n fill_cache\n watch_to_update_cache\n rescue StandardError => e\n # need to keep retrying since we work in the background\n @logger&.error(\"ignoring error during background work #{e}\")\n ensure\n sleep(1) # do not overwhelm the api-server if we are somehow broken\n end\n end\n sleep(0.01) until @cache\n end",
"def start\n stop\n @running = true\n @threads << broadcast_worker_loop\n @threads << read_worker_loop\n end",
"def start\n # clear work and timeout queues?\n @pool_lock.synchronize {\n @terminate = false\n launch_manager\n 0.upto(@num_threads) { |i| launch_worker }\n }\n end",
"def start_work_loop\n Hutch.connect\n @worker = Hutch::Worker.new(Hutch.broker, Hutch.consumers)\n @worker.run\n :success\n rescue ConnectionError, AuthenticationError, WorkerSetupError => ex\n logger.fatal ex.message\n :error\n end",
"def start\n boot_app && @@queue.load_jobs\n @worker_list = []\n Belated.config.workers.times do |i|\n @worker_list << Thread.new { Worker.new(number: i.next) }\n end\n return unless Belated.config.connect\n\n connect!\n banner_and_info\n trap_signals\n @@queue.enqueue_future_jobs\n end",
"def start!\n workers.each { |w| w.start! }\n\n trap(\"CHLD\") do\n debug(\"SIGCHLD Received\")\n @sigchld = true\n end\n trap(\"INT\") do\n info(\"SIGINT Received\")\n @interrupted = true\n end\n trap(\"TERM\") do\n info(\"SIGTERM Received\")\n @interrupted = true\n end\n\n if @restart_after\n loop do\n interrupted_handler\n sigchld_handler\n restart_worker_if_needed\n flush_logger\n sleep LOOP_SLEEP_SECONDS\n end\n else\n loop do\n interrupted_handler\n sigchld_handler\n flush_logger\n sleep LOOP_SLEEP_SECONDS\n end\n end\n end",
"def start\n return self unless @terminate\n @terminate = false\n 0.upto(@num_threads-1) { |i| launch_worker }\n launch_manager\n self\n end",
"def work!\n @status.start!\n \n puts \"Environment: #{Scales.env}\".green\n puts \"Application: #{@type.name}\".green\n puts \"Path: #{Dir.pwd}\".green\n puts \"Log Path: #{@status.log_path}\".green\n puts \"Threads: #{Scales.config.worker_threads}\".green\n puts \"Redis: #{Scales.config.host}:#{Scales.config.port}/#{Scales.config.database}\".green\n \n begin\n start_pool!\n rescue Interrupt => e\n @pool.map(&:exit)\n puts \"Goodbye\".green\n end\n end",
"def starting(worker)\n end",
"def start_worker_thread\n @worker_threads << ControllableThread.new(@name + \"-worker\") {yield}\n end",
"def start\n mutex.synchronize do\n return unless stopped\n @stopped = false\n end\n\n start_worker\n start_poller\n end",
"def start_loop\n return false if @loop and @loop.alive?\n if @fork_master\n fork_master_child_and_monitor\n else\n @loop = Thread.new(self) do |child|\n work_loop(child)\n end\n end\n end",
"def run\n while (get_job() ) do\n checkout_job()\n do_job()\n complete_job()\n end\n end",
"def start\n before_start if respond_to? :before_start\n\n wthreads = if threads <= 1 then [run_thread]\n elsif workers <= 1 then standard_worker\n else wthreads = Array.new(workers){ |i| spawn_worker i } end\n\n after_start if respond_to? :after_start\n\n %i[INT TERM].each{ |sig| trap(sig){ stop } }\n wthreads.each(&:join) if workers > 1\n\n rescue => error\n error(error)\n end",
"def _start_new_worker(worker)\n Thread.new do\n worker.work\n end\n end",
"def start\n loop do\n run\n end\n end",
"def run\n Disquo.logger.info \"Worker starting - queues: #{queues.inspect}, concurrency: #{@threads.max_length}\"\n\n begin\n run_cycle\n rescue => e\n handle_exception(e)\n end until @stopped\n\n Disquo.logger.info \"Worker shutting down\"\n @threads.shutdown\n end",
"def start\n validate!\n start_messages\n create_workers\n Process.wait\n end",
"def start\n validate!\n start_messages\n create_workers\n Process.wait\n end",
"def starting_work(worker, work_unit)\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def run\n Thread.current.name = format('rocketjob %03i', id)\n logger.info 'Started'\n until shutdown?\n wait = RocketJob::Config.instance.max_poll_seconds\n if process_available_jobs\n # Keeps workers staggered across the poll interval so that\n # all workers don't poll at the same time\n wait = rand(wait * 1000) / 1000\n end\n break if wait_for_shutdown?(wait)\n end\n logger.info 'Stopping'\n rescue Exception => exc\n logger.fatal('Unhandled exception in job processing thread', exc)\n ensure\n ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)\n end",
"def start_loop\n loop do\n sleep 2\n start\n end\n rescue => e\n Torkify.logger.error { e }\n end",
"def start\n start_messages\n flush_spaces\n create_workers\n Process.wait\n end",
"def start()\n @state = RUNNING\n @loop.wakeup() unless @loop.nil?\n end",
"def start\n until @done\n job = retrieve_job\n job.execute if job\n end\n end",
"def start\n workers.map { _1.start.wait! }\n end"
] | [
"0.7690687",
"0.74406934",
"0.74069166",
"0.7239609",
"0.71826047",
"0.7138462",
"0.71290505",
"0.71236503",
"0.7122355",
"0.70866305",
"0.7061016",
"0.7021328",
"0.6993364",
"0.6988627",
"0.6976624",
"0.6968612",
"0.69437313",
"0.6894958",
"0.6887947",
"0.687392",
"0.68736935",
"0.68736935",
"0.6866593",
"0.68632925",
"0.683256",
"0.68213516",
"0.6768729",
"0.67528063",
"0.672976",
"0.6724947"
] | 0.8262869 | 0 |
This method will tell the ruby process to FORK. Define setup_child to hook into the forking process. Using setup_child is good for reestablishing database connections. | def fork_and_work
cpid = fork {setup_child; work}
log(:at => :fork, :pid => cpid)
Process.wait(cpid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start!\n @stopping = false\n\n @pid = fork_child do\n __info(\"Started\")\n\n @pid = $$\n\n if respond_to?(:after_fork)\n __debug(\"Running after fork callback\")\n after_fork\n __debug(\"Finished running after fork callback\")\n end\n\n @interrupted = false\n trap(\"INT\") do\n __info(\"SIGINT Received\")\n @interrupted = true\n end\n trap(\"TERM\") do\n __info(\"SIGTERM Received\")\n @interrupted = true\n end\n\n loop do\n if @interrupted\n if respond_to?(:before_exit)\n __debug(\"Running before exit callback\")\n before_exit\n __debug(\"Finished running before exit callback\")\n end\n\n __info(\"Child process exiting gracefully\")\n exit 0\n end\n work\n end\n end\n end",
"def forking\n call_hooks :before, :fork\n end",
"def forking\n call_hooks :before, :fork\n end",
"def fork # :nodoc\n @cant_fork = true\n nil # important due #work\n end",
"def fork\n return if @cant_fork\n\n begin\n Kernel.fork\n rescue NotImplementedError\n @cant_fork = true\n nil\n end\n end",
"def fork_child(&block)\n Process.fork &block\n end",
"def setup_child\n log(:at => \"setup_child\")\n end",
"def fork_master_child_and_monitor\n @fork_master_pid = Kernel.fork do\n at_exit_to_master_child_fork\n Process.die_with_parent\n BEANPICKER_FORK[:child_master] = true\n $0 = \"Beanpicker master child #{@job_name}##{@number}\"\n work_loop(self)\n end\n @loop = Thread.new(self) do |child|\n Process.waitpid @fork_master_pid\n child.fork_master_child_and_monitor if child.running?\n end\n end",
"def after_fork\n end",
"def forked\n call_hooks :after, :fork\n end",
"def forked\n call_hooks :after, :fork\n end",
"def before_fork; end",
"def before_fork(&block); end",
"def before_fork\n end",
"def after_fork(options = {})\n return unless needs_after_fork_work?\n\n ::NewRelic::Agent.logger.debug(\"Starting the worker thread in #{Process.pid} (parent #{Process.ppid}) after forking.\")\n\n channel_id = options[:report_to_channel]\n install_pipe_service(channel_id) if channel_id\n\n # Clear out locks and stats left over from parent process\n reset_objects_with_locks\n drop_buffered_data\n\n setup_and_start_agent(options)\n end",
"def after_fork\n end",
"def before_fork\n \n end",
"def handle_fork\n LOCK.synchronize do\n if @me != Process.pid\n trace \"process forked; recovering\"\n # Update the current process ID\n @me = Process.pid\n\n # Deal w/ the inherited socket\n @sock.close rescue nil if @sock\n @sock = nil\n\n @writer = build_queue\n @writer.spawn\n end\n end\n end",
"def pause_before_fork_in_parent\n super\n end",
"def after_fork(&block)\n end",
"def after_fork\n @after_fork ||= default_after_fork\n end",
"def at_exit_to_master_child_fork\n at_exit do\n pid = BEANPICKER_FORK[:child_pid]\n if pid and pid > 0\n if Process.running?(pid)\n Process.kill \"TERM\", pid\n sleep 0.1\n if Process.running?(pid)\n sleep 2\n Process.kill \"KILL\", pid if Process.running?(pid)\n end\n end\n end\n Kernel.exit!\n end\n end",
"def before_fork\n @before_fork ||= default_before_fork\n end",
"def fork(&block)\n Kernel.fork(&block)\n end",
"def fork\n nil\n end",
"def reopen_after_fork!\n logger.debug { \"#{self.class}##{__method__} fork detected!\" } if forked?\n\n @mutex = Monitor.new\n @dispatch_shutdown_cond = @mutex.new_cond\n @event_queue = QueueWithPipe.new\n\n @dispatcher = nil if @dispatcher and not @dispatcher.alive?\n\n update_pid! # from Forked\n end",
"def daemonize! \n raise 'First fork failed' if (pid = fork) == -1\n exit unless pid.nil?\n Process.setsid\n raise 'Second fork failed' if (pid = fork) == -1\n exit unless pid.nil?\n kill\n write Process.pid\n unless safe\n Dir.chdir '/'\n File.umask 0000\n end\n redirect\n end",
"def runChild(&block)\r\n pid = fork \r\n if pid.nil?\r\n\tblock.call\r\n exit 0\r\n end\r\n Process.waitpid(pid, 0)\r\n return ($? >> 8) & 0xff\r\n end",
"def resume_after_fork_in_parent\n super\n end",
"def daemonize\n exit if fork\n Process.setsid\n exit if fork\n Dir.chdir \"/\"\n end"
] | [
"0.6555636",
"0.64870596",
"0.64870596",
"0.6371934",
"0.63652146",
"0.63288677",
"0.62412685",
"0.6237987",
"0.6191708",
"0.61820996",
"0.61820996",
"0.617719",
"0.61660683",
"0.614677",
"0.61329204",
"0.6109619",
"0.6038466",
"0.59626764",
"0.5915185",
"0.5863577",
"0.5838231",
"0.5831751",
"0.5773306",
"0.5715163",
"0.56940246",
"0.56814957",
"0.5679846",
"0.5669296",
"0.5668428",
"0.56558603"
] | 0.688024 | 0 |
This method will lock a job & process the job. | def work
if job = lock_job
QC.log_yield(:at => "work", :job => job[:id]) do
process(job)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock_job\n log(:at => \"lock_job\")\n job = nil\n while @running\n break if job = @queue.lock\n @queue.wait\n end\n job\n end",
"def work\n if job = lock_job\n QC.log_yield(:action => \"work_job\", :job => job[:id]) do\n begin\n call(job)\n log(:action => \"finished_work\", :job => job[:id])\n rescue Object => e\n log(:action => \"failed_work\", :job => job[:id], :error => e.inspect)\n handle_failure(job, e)\n ensure\n @queue.delete(job[:id])\n log(:action => \"delete_job\", :job => job[:id])\n end\n end\n end\n end",
"def perform(*arguments)\n lock_until = acquire_lock!(*arguments)\n\n # Release loner lock as job has been dequeued\n release_loner_lock!(*arguments) if loner\n\n # Abort if another job holds the lock.\n return unless lock_until\n\n begin\n super(*arguments)\n ensure\n # Release the lock on success and error. Unless a lock_timeout is\n # used, then we need to be more careful before releasing the lock.\n now = Time.now.to_i\n if lock_until != true and lock_until < now\n # Eeek! Lock expired before perform finished. Trigger callback.\n lock_expired_before_release(*arguments)\n else\n release_lock!(*arguments)\n end\n end\n end",
"def lock\n unless type\n raise InvalidLockType, \"Must pass a valid lock type (#{LOCK_TYPES})\"\n end\n\n log.info { \"Locking #{to_s}\" }\n\n if job\n job.set_status \"Locking #{to_s}\"\n job.report_running if report_job_status\n end\n\n report(attempt_lock)\n end",
"def with_lock\n self.lock = 1\n yield\n self.lock = 0\n queue_available_jobs\n end",
"def lock\n post :lock\n end",
"def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end",
"def exec(lock)\n lock.synchronize {\n @thread = Thread.current\n @time_started = Time.now\n }\n\n @handler.call *@params\n\n # ensure we do not switch to another job\n # before atomic check expiration / terminate\n # expired threads happens below\n lock.synchronize {\n @time_completed = Time.now\n @thread = nil\n }\n end",
"def do_job(job)\n job['run_at'] = Time.now\n job['status'] = 'in progress'\n job['attempt'] += 1\n storage.save(job) do |job|\n begin\n args = job['args'].merge(JR.config[:merge_job_itself_to_args] ? {:job_itself => job.dup} : {})\n job.succeed(args)\n job['args'] = args\n job_completed(job)\n rescue CancelJob\n cancel_job(job)\n rescue Exception => e\n rescue_job(e, job)\n end\n end\n end",
"def queue\n # If a Document is associated with this ProcessingJob, determine\n # whether the Document is available to be worked on, and if it's not\n # use ActiveRecord's error system to indicate it's unavailability.\n #if document and document.has_running_jobs?\n # errors.add(:document, \"This document is already being processed\") and (return false)\n #\n # # in future we'll actually lock the document\n # # Lock the document & contact CloudCrowd to start the job\n # #document.update :status => UNAVAILABLE\n #end\n \n begin\n # Note the job id once CloudCrowd has recorded the job.\n @response = RestClient.post(ProcessingJob.endpoint, {:job => CloudCrowdSerializer.new(self).to_json})\n @remote_job = JSON.parse @response.body\n self.cloud_crowd_id = @remote_job['id']\n\n # We've collected all the info we need, so\n save # it and retain the lock on the document.\n rescue Errno::ECONNREFUSED, RestClient::Exception => error\n LifecycleMailer.exception_notification(error).deliver_now\n # In the event of an error while communicating with CloudCrowd, unlock the document.\n self.update_attributes :complete => true\n #document.update :status => AVAILABLE\n raise error\n end\n end",
"def work_job\n \n # MAINTENANCE\n \n # Are we shutting down?\n if @shutdown\n Kernel.exit!(0) if @current_jobs.size == 0\n end\n \n # PROCESSING JOBS\n \n # Get a job\n job = get_new_job\n return unless job\n log.info \"Got a new job #{job.id}\"\n \n if job.job_class.fork?\n # Job that requires a fork, perfect for long-running stuff.\n log.debug \"Forking the process for job #{job.id}\"\n pid = fork do\n process_job job\n end\n @job_pids[job.id] = pid\n # TODO: We need to store which PID corresponds to this job\n elsif job.job_class.fiber?\n # A job that requires a separate fiber.\n log.debug \"Creating a new fiber for job #{job.id}\"\n Fiber.new do\n process_job job\n finish_job job\n end.resume\n else\n # Old-school, blocking job\n log.debug \"Running job #{job.id} in the blocking mode\"\n process_job job\n finish_job job\n end\n end",
"def process_job job\n begin\n log.info \"Performing job #{job.id}\"\n jo = job.job_object\n jo.log = log\n jo.perform\n log.info \"Job #{job.id} completed\"\n job.complete\n Model::Worker.increment(id, {:'stats.done' => 1})\n rescue Exception => e\n log.error \"Job #{job.id} failed\"\n log.error e\n job.fail e\n Model::Worker.increment(id, {:'stats.failed' => 1})\n p e\n end\n end",
"def lock(worker)\n return true if locked? && locked_by == worker.name\n #all this to make sure the check and the lock are simultanious:\n cnt = repository.update({properties[:lock_name]=>worker.name},self.class.all(:id=>self.id,:lock_name=>nil))\n if 0 != cnt\n @lock_name = worker.name\n true\n else\n worker.say( \"Worker #{worker.name} Failed to aquire lock on job #{id}\" )\n false\n end\n end",
"def process(_block = nil)\n EXEL::Job.run(@context[:job], @context)\n end",
"def lock\n end",
"def queue_job; end",
"def try_lock\n end",
"def lock!; end",
"def call(*, &block)\n lock_instance.execute(&block)\n end",
"def lock!\n @locked = true\n end",
"def process_job(instance, attachment_name)\n instance.send(attachment_name).job_is_processing = true\n yield\n instance.send(attachment_name).job_is_processing = false\n end",
"def lock!\n self.for_update!\n end",
"def lock!\n @locked = true\n end",
"def call(job)\n @processed_job_ids << job.job_id\n block.call(job)\n end",
"def lock\n @mutex.lock\n end",
"def work\n possible_job = pluck_queue_message(:job_requests) # FIX: pluck doesn't delete\n job = Job.build(@instance_id, possible_job)\n job.valid? ? process(job) : process_invalid(job)\n end",
"def run\n while (get_job() ) do\n checkout_job()\n do_job()\n complete_job()\n end\n end",
"def lock; end",
"def lock; end",
"def lock; end"
] | [
"0.75984836",
"0.74081296",
"0.71562034",
"0.6958986",
"0.6915542",
"0.6848545",
"0.6818486",
"0.67338485",
"0.6617119",
"0.6548684",
"0.6544134",
"0.65020645",
"0.6388422",
"0.63763344",
"0.63583463",
"0.6347701",
"0.63031745",
"0.6285066",
"0.62428504",
"0.6238647",
"0.6235661",
"0.6196417",
"0.619344",
"0.6176119",
"0.61686903",
"0.6131547",
"0.60844904",
"0.6073283",
"0.6073283",
"0.6073283"
] | 0.76929003 | 0 |
Attempt to lock a job in the queue's table. Return a hash when a job is locked. Caller responsible for deleting the job when finished. | def lock_job
log(:at => "lock_job")
job = nil
while @running
break if job = @queue.lock
@queue.wait
end
job
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end",
"def lock\n unless type\n raise InvalidLockType, \"Must pass a valid lock type (#{LOCK_TYPES})\"\n end\n\n log.info { \"Locking #{to_s}\" }\n\n if job\n job.set_status \"Locking #{to_s}\"\n job.report_running if report_job_status\n end\n\n report(attempt_lock)\n end",
"def find_and_lock_job(node)\r\n\t\t\tArmory::Job.find_job(node).each do |job|\r\n\t\t\t\treturn job if job.aquire_lock?(self.name)\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\treturn nil\r\n\t\tend",
"def lock handler, query\n\t\t\tQueueEntry.transaction do\n\t\t\t\treq = {\n\t\t\t\t\t:queue => @name,\n\t\t\t\t\t:handler => handler,\n\t\t\t\t\t:cquery => JSON.generate([query])\n\t\t\t\t}\n\t\t\t\tresp = QueueEntry.first req\n\t\t\t\tif resp then\n\t\t\t\t\tresp.locked = true\n\t\t\t\t\tresp.save\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend\n\t\tend",
"def lock(worker)\n return true if locked? && locked_by == worker.name\n #all this to make sure the check and the lock are simultanious:\n cnt = repository.update({properties[:lock_name]=>worker.name},self.class.all(:id=>self.id,:lock_name=>nil))\n if 0 != cnt\n @lock_name = worker.name\n true\n else\n worker.say( \"Worker #{worker.name} Failed to aquire lock on job #{id}\" )\n false\n end\n end",
"def lock_interaction(job_id)\n operation_lock = nil\n\n # get the lock object\n @manager_lock.synchronize do\n @job_lock_table[job_id] ||= Mutex.new\n operation_lock = @job_lock_table[job_id]\n end\n\n return operation_lock.lock\n end",
"def work\n if job = lock_job\n QC.log_yield(:action => \"work_job\", :job => job[:id]) do\n begin\n call(job)\n log(:action => \"finished_work\", :job => job[:id])\n rescue Object => e\n log(:action => \"failed_work\", :job => job[:id], :error => e.inspect)\n handle_failure(job, e)\n ensure\n @queue.delete(job[:id])\n log(:action => \"delete_job\", :job => job[:id])\n end\n end\n end\n end",
"def unlock(job_id)\n locked.del(job_id)\n end",
"def try_await_lock(table, i); end",
"def get_lock_id\n @lock_id\n end",
"def unlock\n if job\n job.report_running if report_job_status\n job.set_status(\"Unlocking #{to_s}\")\n end\n\n attempt_unlock\n\n report(true)\n end",
"def async_lock(environment)\n job = Job.new(:lock)\n async(:lock, job, environment)\n job.ticket\n end",
"def prime(job_id)\n redis do |conn|\n conn.lpush(key.primed, job_id)\n end\n end",
"def acquire_lock!(lock_name = table_name, wait_timeout = 0, &block)\n acquire_lock(lock_name, table_name, &block) or raise LockTimeout, 'Timeout waiting for lock'\n end",
"def locks\n SidekiqUniqueJobs.locks\n end",
"def try_lock\n end",
"def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end",
"def redis_lock_key(*args)\n ['lock', self.class.name, identifier(*args)].compact.join(':')\n end",
"def return_lock\n\t\t@@logger.info { \"Returning the lock to the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => true).update(:locked => false) != 0\n\tend",
"def call(&block)\n return unless (deleted_job = delete_job_by_digest)\n\n log_info(\"Deleted job: #{deleted_job}\")\n if (del_count = delete_lock)\n log_info(\"Deleted `#{del_count}` keys for #{lock_digest}\")\n end\n\n block&.call\n end",
"def pop_perform_unlocked(queue)\n item = pop(queue) or return\n\n job = Resque::Job.new(queue, item)\n if job.uniqueness.perform_locked?\n push(queue, item)\n nil\n else\n job\n end\n end",
"def acquire_lock!(*args)\n acquire_lock_impl!(:redis_lock_key, :lock_failed, *args)\n end",
"def locked?(*args)\n inspect_lock(:redis_lock_key, *args)\n end",
"def perform(*arguments)\n lock_until = acquire_lock!(*arguments)\n\n # Release loner lock as job has been dequeued\n release_loner_lock!(*arguments) if loner\n\n # Abort if another job holds the lock.\n return unless lock_until\n\n begin\n super(*arguments)\n ensure\n # Release the lock on success and error. Unless a lock_timeout is\n # used, then we need to be more careful before releasing the lock.\n now = Time.now.to_i\n if lock_until != true and lock_until < now\n # Eeek! Lock expired before perform finished. Trigger callback.\n lock_expired_before_release(*arguments)\n else\n release_lock!(*arguments)\n end\n end\n end",
"def before_enqueue_lock(*args)\n key = lock(*args)\n now = Time.now.to_i\n timeout = now + lock_timeout + 1\n\n # return true if we successfully acquired the lock\n return true if Resque.redis.setnx(key, timeout)\n\n # see if the existing timeout is still valid and return false if it is\n # (we cannot acquire the lock during the timeout period)\n return false if now <= Resque.redis.get(key).to_i\n\n # otherwise set the timeout and ensure that no other worker has\n # acquired the lock\n now > Resque.redis.getset(key, timeout).to_i\n end",
"def refresh_lock(ttl)\n check_exists\n SideJob.redis.expire \"#{redis_key}:lock\", ttl\n end",
"def lock(key)\n raise NotImplementedError\n end",
"def job_key; Thread.current[:job_key]; end",
"def lock(worker)\n NotImplementedError\n end",
"def with_lock\n self.lock = 1\n yield\n self.lock = 0\n queue_available_jobs\n end"
] | [
"0.6452512",
"0.6431981",
"0.6416419",
"0.63524985",
"0.6215029",
"0.61149627",
"0.60660475",
"0.6065861",
"0.58844405",
"0.58577037",
"0.5808292",
"0.57772124",
"0.57528585",
"0.57496834",
"0.5696457",
"0.56470734",
"0.56314474",
"0.55414003",
"0.5536355",
"0.5518415",
"0.5508652",
"0.54989463",
"0.5495695",
"0.5481857",
"0.54751754",
"0.5469552",
"0.54684925",
"0.5447891",
"0.54459345",
"0.54363245"
] | 0.70044535 | 0 |
Each job includes a method column. We will use ruby's eval to grab the ruby object from memory. We send the method to the object and pass the args. | def call(job)
args = job[:args]
klass = eval(job[:method].split(".").first)
message = job[:method].split(".").last
klass.send(message, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\r\n return unless if?\r\n job_name.constantize.send method_name, formatted_arguments\r\n end",
"def run_job(func, *args)\n if self.method(func).arity > 1\n self.send(func, *args)\n else\n self.send(func, args)\n end\n end",
"def invoke_job\n payload_object.perform\n end",
"def invoke_job\n payload_object.perform\n end",
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def call(_worker, job, _queue, _pool)\n job[\"args\"].map!(&:serialize)\n yield\n end",
"def method_missing(meth, *args, &block)\n if meth.to_s == \"to_ary\"\n raise NoMethodError\n end\n\n if args.empty? and rp = role_proxy(meth)\n rp\n elsif task = resolve_task(meth)\n task.run(self, *args, &block)\n else\n if args.last.kind_of? Hash\n opts = args.pop\n else\n opts = {}\n end\n str = ([meth] + args.map{|a| escape(a)}).join(' ')\n exec! str, opts, &block\n end\n end",
"def perform(*args); end",
"def _perform(args); end",
"def call(method, arguments)\n # Like a typical class base runtime model, we store\n # methods in the class of the object.\n @awesome_class.lookup(method).call(self, arguments)\n end",
"def execute(method)\n send(method)\n end",
"def method_missing(method, *args)\n # This is the Resque queue to which this job will be sent\n queue = @options[:to] || :default\n # Encode our Performable Method into something that can be stored in Resque\n payload = PerformableMethod.prepare(@target, method, args)\n\n if @options[:run_at]\n ::Resque.enqueue_at_with_queue(queue, @options[:run_at], PerformableMethod, payload)\n else\n ::Resque.enqueue_to(queue, PerformableMethod, payload)\n end\n end",
"def run_job\n end",
"def jobs\n raise NotImplementedError\n end",
"def eval(*args); end",
"def execute_queue(argv)\n queue = Commandable.execution_queue(argv)\n queue.collect{|meth| meth[:proc].call}\nend",
"def perform(*args, **opt)\n if is_a?(Class)\n job_warn { \"not a class method | args = #{args.inspect}\" }\n else\n set_arguments(*args, **opt)\n end\n end",
"def eval\n execute\n end",
"def jobs\r\n end",
"def execution_queue(argv)\n arguments = argv.dup\n method_hash = {}\n last_method = nil\n \n if arguments.empty?\n arguments << @@default_method.keys[0] if @@default_method and !@@default_method.values[0][:parameters].flatten.include?(:req)\n end\n arguments << \"help\" if arguments.empty?\n \n # Parse the command line into methods and their parameters\n \n arguments.each do |arg|\n if Commandable[arg]\n last_method = arg.to_sym\n method_hash.merge!(last_method=>[])\n else\n unless last_method\n default = find_by_subkey(:default)\n\n # Raise an error if there is no default method and the first item isn't a method\n raise UnknownCommandError, arguments.first if default.empty?\n \n # Raise an error if there is a default method but it doesn't take any parameters\n raise UnknownCommandError, (arguments.first) if default.values[0][:argument_list] == \"\"\n \n last_method = default.keys.first\n method_hash.merge!(last_method=>[])\n end\n method_hash[last_method] << arg\n end\n # Test for missing required switches\n @@commands.select do |key, value|\n if value[:required] and method_hash[key].nil?\n # If the required switch is also a default have the error be a missing parameter instead of a missing command\n if value[:default]\n method_hash.merge!(key=>[])\n else\n raise MissingRequiredCommandError, key \n end\n end\n end\n end\n #puts \"method_hash: #{method_hash}\" if method_hash.to_s.include?(\"required_default\")\n \n # Build an array of procs to be called for each method and its given parameters\n proc_array = []\n method_hash.each do |meth, params|\n command = @@commands[meth]\n\n if command[:parameters] && !command[:parameters].empty?\n \n #Change the method name for attr_writers\n meth = \"#{meth}=\" if command[:parameters][0][0] == :writer\n \n # Get a list of required parameters and make sure all of them were provided\n required = command[:parameters].select{|param| [:req, :writer].include?(param[0])}\n required.shift(params.count)\n raise MissingRequiredParameterError, {:method=>meth, :parameters=>required.collect!{|meth| meth[1]}.to_s[1...-1].gsub(\":\",\"\"), :default=>command[:default]} unless required.empty?\n end\n \n # Test for duplicate XORs\n proc_array.select{|x| x[:xor] and x[:xor]==command[:xor] }.each {|bad| raise ExclusiveMethodClashError, \"#{meth}, #{bad[:method]}\"}\n\n klass = Object\n command[:class].split(/::/).each { |name| klass = klass.const_get(name) }\n ## Look for class in class cache\n unless command[:class_method]\n klass = (@@class_cache[klass.name] ||= klass.new)\n end\n proc_array << {:method=>meth, :xor=>command[:xor], :parameters=>params, :priority=>command[:priority], :proc=>lambda{klass.send(meth, *params)}}\n end\n proc_array.sort{|a,b| a[:priority] <=> b[:priority]}.reverse\n \n end",
"def invoke; end",
"def job # this is a getter\n @job\n end",
"def call(method, *args)\n self.class.rpc_execute(method, *args)\n end",
"def invokeDefaultMethodWithArguments(args)\n eval(args[0])\n end",
"def execute_this(meth, *args)\n $log.debug \"app email got #{meth} \" if $log.debug?\n cc = @vim.current_component\n [cc, @lb2, @tv].each do |c|\n if c.respond_to?(meth, true)\n c.send(meth, *args)\n return true\n end\n end\n false\nend",
"def jobs\n\t\t# ...\n\tend",
"def job \n @job\n end",
"def invoking\n end",
"def batch_command__pg_gem call, *args\n @results ||= []\n call = array__from call\n call = call.first\n exec_method ||= \"exec\"\n command = args.join \" \"\n exec_rv, exception = begin\n e = !(call.respond_to? exec_method) && NoMethodError.new(\"undefined method `#{exec_method}' for #{call.class}\")\n (e && [nil, e] || [(call.send exec_method, command), nil])\n rescue => e2\n [nil, e2]\n end\n exec_rv_entries = exec_rv.entries rescue exec_rv\n exception_info = (exception_info_base [exception]) rescue []\n @results.push({\n :time => Time.now.inspect,\n :call => call,\n :args => args,\n :command => command,\n :success => exception_info[2].negate_me,\n :output => exec_rv_entries,\n :batch_command_method => \"batch_command__pg_gem\",\n :exception_info => exception_info,\n })\n @results\n end",
"def exec _obj, _args\n \"_obj exec _args;\" \n end"
] | [
"0.6800136",
"0.6119042",
"0.60659945",
"0.6003197",
"0.5835748",
"0.5820735",
"0.5820339",
"0.5695362",
"0.56889665",
"0.5594962",
"0.5581115",
"0.55651623",
"0.5553086",
"0.55027896",
"0.5485583",
"0.5466127",
"0.54465723",
"0.54454345",
"0.5445061",
"0.54314995",
"0.5403359",
"0.54024315",
"0.5397808",
"0.5382351",
"0.5376056",
"0.53677434",
"0.5366933",
"0.5362997",
"0.5358439",
"0.53443396"
] | 0.6952951 | 0 |
Saves page as HTML files. | def save_pages
path = SAVED_PAGES_DIR
# prepare dir
FileUtils.mkdir(path) unless File.directory?(path)
# prepare filename
url = @page.current_url
url = url.sub(/#{Regexp.quote(Testing.base_url)}\//, '') # remove base url
url = url.gsub(/\//, '_') # change / to _
url = 'homepage' if url.empty? # that's homepage left
filename = "#{path}/#{url}.html"
# save page
File.open(filename, 'w') { |f| f.write(@page.html) }
puts "Saved page to #{filename}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_page(file_name = nil)\r\n file_name ||= Time.now.strftime(\"%Y%m%d%H%M%S\") + \".html\"\r\n puts \"about to save page: #{File.expand_path(file_name)}\" if $DEBUG\r\n File.open(file_name, \"w\").puts page_source\r\n end",
"def XOsavePage()\n\t\tbegin\n\n\t\t\tfileName= $gcfd.logPath+@wwBrws.url.tr(\" =%?*/\\\\:\",'_')+Time.now.to_i.to_s+'.html'\n\t\t\tFile.open(fileName, 'w') do |file|\n\t\t\t\tfile.write(@wwBrws.html)\n\t\t\tend\n\t\t\t$alog.lwrite('HTML page saved in '+ fileName, 'DEBG')\n\t\t\tres= OK\n\t\trescue\n\t\t\t$alog.lwrite('Problems saving page '+ fileName, 'ERR_') \t\t\t#\n\t\t\tres= CRITICAL\n\t\tend\n\t\treturn res\n\tend",
"def savePage(fileName = \"testPage.yml\")\n\t\t#File.open(\"file.rb\") if File::exists?( \"file.rb\" )\n\t\tfile = File.new(@@pageDirectory + fileName, \"w+\")\n\t\tserializedPage = YAML::dump(@currentHTMLPage)\n\t\tfile.puts(serializedPage)\n\t\tfile.close\n\t\t#puts(\"saved page: #{fileName}\")\n\tend",
"def save_and_open\n return unless File.exist?(session.saved_page_dir)\n\n filename = \"#{session.saved_page_dir}/webrat-#{Time.now.to_i}.html\"\n \n File.open(filename, \"w\") do |f|\n f.write rewrite_css_and_image_references(session.response_body)\n end\n\n open_in_browser(filename)\n end",
"def save_page(page, name)\n f = File.new(name,'w')\n f.puts page\n f.close\n end",
"def saveScreenHTML(filepath)\n File.open(filepath, 'w') do |f|\n f.write @browser.html\n end\n end",
"def save_page page\n return unless page.text?\n\n path = page_file page.full_name\n\n FileUtils.mkdir_p File.dirname(path) unless @dry_run\n\n cache[:pages] ||= []\n cache[:pages] << page.full_name\n\n return if @dry_run\n\n File.open path, 'wb' do |io|\n Marshal.dump page, io\n end\n end",
"def save_current_page(options = {})\r\n default_options = {:replacement => true}\r\n options = default_options.merge(options)\r\n to_dir = options[:dir] || default_dump_dir\r\n\r\n if options[:filename]\r\n file_name = options[:filename]\r\n else\r\n file_name = Time.now.strftime(\"%m%d%H%M%S\") + \".html\"\r\n end\r\n\r\n Dir.mkdir(to_dir) unless File.exists?(to_dir)\r\n file = File.join(to_dir, file_name)\r\n\r\n content = page_source\r\n base_url = @web_browser.context.base_url\r\n current_url = @web_browser.url\r\n current_url =~ /(.*\\/).*$/\r\n current_url_parent = $1\r\n if options[:replacement] && base_url =~ /^http:/\r\n File.new(file, \"w\").puts absolutize_page_nokogiri(content, base_url, current_url_parent)\r\n else\r\n File.new(file, \"w\").puts content\r\n end\r\n\r\n end",
"def write_to_html filename = \"#{title}.html\", options = {}\n File.open(filename, \"w\") { |f| f.write(to_html(options)) }\n filename\n end",
"def save(filename, content)\n\t\t# FIXME - if the file exists, this should bail out\n\t\t\n\t\t# write the contents into the file\n\t\tfile = dir + '/' + filename + '.md'\n\t\tf = File.new(file, \"w\")\n\t\tf.write(content)\n\t\tf.close\n\t\t\n\t\t# return the new file\n\t\treturn page(filename)\n\tend",
"def save(filename, content)\n\t\t# FIXME - if the file exists, this should bail out\n\t\t\n\t\t# write the contents into the file\n\t\tfile = dir + '/' + filename + '.md'\n\t\tf = File.new(file, \"w\")\n\t\tf.write(content)\n\t\tf.close\n\t\t\n\t\t# return the new file\n\t\treturn page(filename)\n\tend",
"def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end",
"def save_html(directory_path, file_name, body, charset)\n # Starting directory path must public path(Rails.public_path) for security\n public_and_under_directory_path = \"#{Rails.public_path}/#{directory_path}\"\n directory_full_path = \"#{Rails.public_path}/#{directory_path}/#{file_name}\"\n\n if FileTest.exist?(public_and_under_directory_path)\n body.force_encoding(charset) if charset # For 2 byte chars.\n File.open(directory_full_path, \"w\") do |f|\n f.puts( body.gsub(/\\r\\n|\\r|\\n|\\t/, '') ) # Get response data with deleted empty lines).\n end\n end\n end",
"def files_to_page\n insert_to_page('div', html)\n insert_to_page('script', js, false)\n insert_to_page('style', style, false)\n end",
"def save_locally(dir)\n FileUtils.mkdir_p(dir) unless File.exists? dir\n \n # remove HTML BASE tag if it exists\n @contents.xpath('//base').each { |t| t.remove }\n # remove head tag\n @contents.xpath('//head').each { |t| t.remove }\n # remove link tags\n @contents.xpath('//link').each { |t| t.remove }\n # remove script tags\n @contents.xpath('//script').each { |t| t.remove }\n # remove comments\n @contents.xpath('//comment()').each { |t| t.remove }\n # remove mediawiki meta tag\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \"generator\" }\n # remove sitesub h3 tag\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \"siteSub\" }\n\n # get lastmod/viewcount values\n @contents.xpath('//li').each do |t|\n if t['id'] == \"lastmod\"\n @lastmod = t.text.strip\n end\n if t['id'] == \"viewcount\"\n @viewcount = t.text.strip\n end\n end\n\n # remove unneeded divs\n @contents.xpath('//div').each do |t|\n t.remove if t['id'] == \"column-one\"\n t.remove if t['id'] == \"footer\"\n t.remove if t['id'] == \"catlinks\"\n t.remove if t['id'] == \"contentSub\"\n t.remove if t['id'] == \"jump-to-nav\"\n t.remove if t['class'] == \"printfooter\"\n t.remove if t['class'] == \"visualClear\"\n end\n\n if @main_page == true\n save_path = File.join(dir, \"index\")\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\n else\n save_path = File.join(dir, File.basename(uri.to_s))\n title = File.basename(uri.to_s).gsub(\"_\", \" \")\n end\n save_path += '.html' if save_path !~ /\\.((html?)|(txt))$/\n File.open(save_path, 'w') { |f| f.write(\"<!DOCTYPE html>\\n<html>\\n<head>\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\">\\n<meta http-equiv=\\\"Content-Language\\\" content=\\\"en-us\\\">\\n<title>#{title}</title>\\n</head>\\n<body>\\n<p><b>This is an archived MediaWiki page.</b><br />#{@lastmod}<br />#{@viewcount}</p>\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\\n</body>\\n</html>\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def save_current_page(options = {})\n default_options = {:replacement => true}\n options = default_options.merge(options)\n if options[:dir]\n # already defined the dir\n to_dir = options[:dir]\n elsif $ITEST2_RUNNING_SPEC_ID && $ITEST2_WORKING_DIR\n\n $ITEST2_DUMP_DIR = File.join($ITEST2_WORKING_DIR, \"dump\")\n FileUtils.mkdir($ITEST2_DUMP_DIR) unless File.exists?($ITEST2_DUMP_DIR)\n\n spec_run_id = $ITEST2_RUNNING_SPEC_ID\n spec_run_dir_name = spec_run_id.to_s.rjust(4, \"0\") unless spec_run_id == \"unknown\"\n to_dir = File.join($ITEST2_DUMP_DIR, spec_run_dir_name)\n else\n to_dir = ENV['TEMP_DIR'] || \"C:\\\\temp\"\n end\n\n if options[:filename]\n file_name = options[:filename]\n else\n file_name = Time.now.strftime(\"%m%d%H%M%S\") + \".html\"\n end\n\n Dir.mkdir(to_dir) unless File.exists?(to_dir)\n file = File.join(to_dir, file_name)\n\n content = page_source\n base_url = @web_browser.context.base_url\n current_url = @web_browser.url\n current_url =~ /(.*\\/).*$/\n current_url_parent = $1\n if options[:replacement] && base_url =~ /^http:/\n File.new(file, \"w\").puts absolutize_page_hpricot(content, base_url, current_url_parent)\n else\n File.new(file, \"w\").puts content\n end\n\n end",
"def save_file\n\t\t\tfile_hash = Digest::MD5.hexdigest(File.read(@file))\n\t\t\tif file = @db.find_html_file(@filename)\n\t\t\t\t@file_changed = @db.check_or_update_if_file_changed(file, @filename, file_hash)\n\t\t\telse\n\t\t\t\t@db.create_html_file(@filename, file_hash)\n\t\t\tend\n\t\tend",
"def write_html_file(name, type, html)\n if ENV['WRITE_HTML_FILE'] != 'false'\n file_name = \"#{File.dirname(__FILE__)}/results/#{name.gsub('.xml', '')}-#{Time.now.strftime(\"%d%b\")}_#{type}.html\"\n file = File.open(file_name, 'w+')\n file.puts html\n file.close\n end\nend",
"def save_page( title )\n base_url='https://en.wikipedia.org/w/index.php?title={title}&action=raw'\n\n ## todo/check: use %20 for encoding space (or +) - why? why not?\n ## https://en.wikipedia.org/w/index.php?title=South%20Georgia%20and%20the%20South%20Sandwich%20Islands&action=raw\n ## https://en.wikipedia.org/w/index.php?title=South+Georgia+and+the+South+Sandwich+Islands&action=raw\n\n ##\n ## URI.encode_www_form_component(string, enc=nil)\n ## This method will percent-encode every reserved character,\n ## leaving only *, -, ., 0-9, A-Z, _, a-z intact.\n ## Note: It also substitues space with +.\n title_encoded = URI.encode_www_form_component( title )\n url = base_url.gsub( '{title}', title_encoded )\n\n path = \"#{title.gsub( ' ', '_' )}.txt\"\n puts \" >#{title}<, >#{title_encoded}< path=>#{path}<, try url=>#{url}<\"\n\n ## note: change path (used for disk cache)!!\n response = Webget.text( url, path: path )\n ## note: exit on get / fetch error - do NOT continue for now - why? why not?\n exit 1 if response.status.nok? ## e.g. HTTP status code != 200\nend",
"def page!\n save_and_open_page\n end",
"def page!\n save_and_open_page\n end",
"def save_as(filename)\n document.render_file(filename)\n end",
"def save_as(name)\n File.open(name, \"wb\") { |f| f.write self.render }\n end",
"def download\r\n @page = Page.find(params[:id])\r\n send_file \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\", :type=>\"html\"\r\n end",
"def save(path)\n File.open(path, \"w\") { |outfile| outfile.print self.render }\n end",
"def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend",
"def export_html(path=\"./plot.html\")\n path = File.expand_path(path, Dir::pwd)\n str = generate_html\n File.write(path, str)\n end",
"def create\r\n html=params[:page][:html]\r\n @page = Page.new(params[:page])\r\n respond_to do |format|\r\n if @page.save\r\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\r\n format.json { render json: @page, status: :created, location: @page }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n if !File.directory?(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}/images\")\r\n end\r\n File.open(target, \"w+\") do |f|\r\n f.write(html)\r\n end\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def write_page_to_fs(page, filepath, locale)\n # puts filepath.inspect\n _filepath = \"#{filepath}.liquid\"\n _filepath.gsub!(/.liquid$/, \".#{locale}.liquid\") if locale\n\n _filepath = File.join('app', 'views', 'pages', _filepath)\n\n self.replace_content_asset_urls(page.source)\n\n self.open_file(_filepath) do |file|\n file.write(page.to_yaml)\n end\n end"
] | [
"0.8056935",
"0.7496878",
"0.7451122",
"0.72687405",
"0.7257353",
"0.7221766",
"0.71642417",
"0.70610464",
"0.69691384",
"0.69001395",
"0.69001395",
"0.6792995",
"0.67413515",
"0.67035264",
"0.6671045",
"0.6603934",
"0.6600621",
"0.6598848",
"0.64960265",
"0.6471284",
"0.64679575",
"0.64679575",
"0.64574784",
"0.64483535",
"0.64386195",
"0.6432497",
"0.64187664",
"0.6415219",
"0.6410638",
"0.6403406"
] | 0.79802847 | 1 |
Returns true if file with name was found in download path. | def downloaded_file?(name)
begin
true if check_for_downloaded_file(name)
rescue Errno::ENOENT
false
ensure
FileUtils.rm_rf(DOWNLOADS_DIR)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download?\n File.exist?(path) || data.exists? ? false : true\n end",
"def has_file? name\n File.file? path / name\n end",
"def file_exists?(name)\n File.file?(File.join(path, name))\n end",
"def file?(name)\n File.file?(path(name))\n end",
"def knows?(name)\n !find_file(name).nil?\n end",
"def downloaded?( filename, buffer )\n return false unless File.exist?( filename )\n\n old = File.read( filename, encoding: buffer.encoding )\n return true if buffer == old\n\n false\n end",
"def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end",
"def has_file?(path)\n @data[:files].has_key? path.to_sym\n end",
"def file_url?(url)\n name = File.basename(url)\n name.include?('.zip') || name.include?('.tar.gz')\n end",
"def contain?(filename); end",
"def file_exist?\n return FileTest.exist?(@fileurl)\n end",
"def exist?(name)\n File.exist?(path(name))\n end",
"def attachment?(file_name)\n frm.link(:text=>file_name).exist?\n end",
"def file_exists?(path)\n end",
"def remote_file_exists?(full_path)\n remote_filetest_passes?('-e', full_path)\n end",
"def file?(path)\n ::File.file?(prefixed(path))\n end",
"def has_file?(filename)\n self.files.detect {|f| f[:name] == filename }.present?\n end",
"def valid_download?\n @download_url != \"\"\n end",
"def check_for_file(format)\n File.exists?(\"#{@work.download_basename}.#{format}\")\n end",
"def file_exists?(path)\n response = self.class.head(File.join('/', path), request_options)\n response.code >= 200 && response.code < 300\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def file_exists?\r\n File.file?(full_path)\r\n end",
"def file_exist?(path)\n exist?(path) && is_file?(path)\n end",
"def file_exists?\n File.exists?(@filename)\n end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\")\n result.exitstatus == 0 && result.stdout != ''\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def has_file?(filename)\n\t\t!self.files.detect(filename).nil?\n\tend",
"def file_exist?(filename)\n if __transport_connection\n __transport_connection.file(filename).exist?\n else\n File.exist?(filename)\n end\n end",
"def exists_file?(key)\n # sanitize the name\n key = safe_file_name(key)\n key = add_namespace(key)\n\n boolify(redis.exists?(key))\n end"
] | [
"0.768257",
"0.75007045",
"0.7192698",
"0.7155981",
"0.701944",
"0.69712734",
"0.68998456",
"0.68370384",
"0.6787563",
"0.6778114",
"0.67778194",
"0.67461026",
"0.67211103",
"0.66951305",
"0.6686307",
"0.6680138",
"0.6641023",
"0.66271234",
"0.662026",
"0.66171306",
"0.6616841",
"0.6610878",
"0.65870154",
"0.65449446",
"0.6531071",
"0.65225494",
"0.65160626",
"0.64999086",
"0.6496032",
"0.6493121"
] | 0.81684387 | 0 |
Yields opened file and ensures downloads directory is removed after. | def downloaded_file(name)
begin
file = File.open(check_for_downloaded_file(name))
yield file if block_given?
file.close
ensure
FileUtils.rm_rf(DOWNLOADS_DIR)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download!\n return download if file.nil?\n\n file.close\n file.unlink\n self.file = nil\n download\n end",
"def cleanDownloads()\n dir(\"#{DOWNLOADS_DIR}/*\").each do |path|\n if path != PREV_DOWNLOADS_DIR\n # colourFile(path)\n moveOldDownload(path)\n end\n end\n end",
"def each(&block)\n synchronized do\n return if @files.empty?\n\n file_deleteable = []\n # creates this array just once\n watched_files = @files.values\n\n # look at the closed to see if its changed\n watched_files.select {|wf| wf.closed? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the closed file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n watched_file.watch\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # look at the ignored to see if its changed\n watched_files.select {|wf| wf.ignored? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the ignored file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n # this file has not been yielded to the block yet\n # but we must have the tail to start from the end, so when the file\n # was first ignored we updated the bytes_read to the stat.size at that time.\n # by adding this to the sincedb so that the subsequent modify\n # event can detect the change\n watched_file.watch\n yield(:unignore, watched_file)\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # Send any creates.\n if (to_take = @max_active - watched_files.count{|wf| wf.active?}) > 0\n watched_files.select {|wf| wf.watched? }.take(to_take).each do |watched_file|\n watched_file.activate\n # don't do create again\n next if watched_file.state_history_any?(:closed, :ignored)\n # if the file can't be opened during the yield\n # its state is set back to watched\n if watched_file.initial?\n yield(:create_initial, watched_file)\n else\n yield(:create, watched_file)\n end\n end\n else\n now = Time.now.to_i\n if (now - @lastwarn_max_files) > MAX_FILES_WARN_INTERVAL\n waiting = @files.size - @max_active\n specific = if @close_older.nil?\n \", try setting close_older. There are #{waiting} unopened files\"\n else\n \", files yet to open: #{waiting}\"\n end\n @logger.warn(@max_warn_msg + specific)\n @lastwarn_max_files = now\n end\n end\n\n # wf.active means the actual files were opened\n # and have been read once - unless they were empty at the time\n watched_files.select {|wf| wf.active? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{$!}), deleting from @files\")\n watched_file.unwatch\n yield(:delete, watched_file)\n next\n rescue => e\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{e.inspect})\")\n next\n end\n\n if watched_file.file_closable?\n @logger.debug? && @logger.debug(\"each: active: file expired: #{path}\")\n yield(:timeout, watched_file)\n watched_file.close\n next\n end\n\n _inode = inode(path,stat)\n read_thus_far = watched_file.bytes_read\n # we don't update the size here, its updated when we actually read\n if watched_file.inode_changed?(_inode)\n @logger.debug? && @logger.debug(\"each: new inode: #{path}: old inode was #{watched_file.inode.inspect}, new is #{_inode.inspect}\")\n watched_file.update_inode(_inode)\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size < read_thus_far\n @logger.debug? && @logger.debug(\"each: file rolled: #{path}: new size is #{stat.size}, old size #{read_thus_far}\")\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size > read_thus_far\n @logger.debug? && @logger.debug(\"each: file grew: #{path}: old size #{read_thus_far}, new size #{stat.size}\")\n yield(:modify, watched_file)\n end\n end\n\n file_deleteable.each {|f| @files.delete(f)}\n end\n end",
"def each_file\n @sftp.dir.foreach(@path.to_s) do |entry|\n filename = entry.name\n yield filename unless directory? filename\n end\n end",
"def close_files\n [self.source, self.original, self.destination].each do |f|\n next unless f\n begin\n f.close\n File.unlink(f) if SystemInformation.env == 'production'\n rescue\n nil\n end\n end\n end",
"def remove_downloaded_files\n Log.log_info('In remove_downloaded_files')\n begin\n Log.log_debug('Removing downloaded files')\n # TBI\n Log.log_debug('End removing downloaded files')\n rescue StandardError => e\n Log.log_err('Exception e=' + e.to_s)\n end\n end",
"def open_safely!\n yield current_file.open\n ensure\n current_file.close\n end",
"def initialDownloadsClean()\n downloadDir = '~/Downloads'\n Dir.chdir(File.expand_path(downloadDir))\n puts \"Checking Downloads Directory for .xlsx files to clean... \"\n Dir.glob('*.xlsx').each do |file| \n if file\n puts \"file #{file} cleaned from Downloads...\"\n File.delete(file)\n else\n puts \"Nothing to clean from Downloads.\"\n end\n end\nend",
"def clean_download_dir\n dir('~/Downloads/*').each do |path|\n trash path if File.mtime(path) < TWO_WEEKS_AGO\n end\n end",
"def clear_files\n Dir.glob(Dir.pwd + \"/tmp/downloads/*.csv\").each { |file| File.delete(file) }\nend",
"def remove_files\n @batch.each_open_file_path do |path|\n 3.times do |i| \n begin \n File.unlink(path)\n break \n rescue Errno::EACCES # sometimes windows does not like this. let's wait and retry.\n sleep(1) # just in case it's open by something else..\n next unless i == 2 \n $stderr.puts \"Cannot remove #{path}...giving up.\"\n end \n end\n end\n end",
"def cleanup_download_path\n if download_path.exist?\n download_path.delete\n end\n end",
"def download_thread\n Thread.new do\n file = nil\n until @download_list.empty?\n @download_mutex.synchronize do\n file = @download_list.pop\n end\n next if file.nil?\n # AWS stores directories as their own object\n next if file.content_length == 0 && file.key =~ /\\/$/\n\n tmp = Tempfile.new(file.object_id.to_s)\n @source_container.files.get(file.key) do |data, rem, cl|\n tmp.syswrite(data)\n end\n tmp.flush\n tmp.rewind\n @upload_mutex.synchronize do\n @upload_list.push(body: tmp, key: file.key)\n end\n end\n end\n end",
"def each *args, &block\n file.each(*args, &block)\n\n if moved?\n @moved = false\n @file_io = nil\n self.each(*args, &block)\n end\n end",
"def download\n return file if file\n\n self.file = retrieve_file\n end",
"def cleanup_file(file_name)\n f = File.expand_path(file_name)\n File.unlink(f) if File.exists?(f)\n yield\nensure\n File.unlink(f) if File.exists?(f)\nend",
"def download_files\n path = Conf::directories.tmp\n manager = @current_source.file_manager\n manager.start do\n @current_source.folders.each do |folder|\n files = @files[folder]\n puts \"folder => #{folder}, Files => #{files}\" if @opts[:v]\n next if files.empty? \n # download into the TMP directory by folder\n spath = File.join(path, @current_source.name.to_s,folder)\n manager.download_files files,spath,v: true\n move_files folder\n @current_source.schema.insert_files files,folder\n SignalHandler.check { Logger.<<(__FILE__,\"WARNING\",\"SIGINT Catched. Abort.\")}\n end\n end\n end",
"def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def remove_stale_files() = stale_files.each { |file| remove_file(file) }",
"def tar_each(&block)\n # In case of extreme weirdness where this happens twice.\n close_file!\n open_file!\n @tar_reader.each(&block)\n ensure\n close_file!\n end",
"def each_file\n files.each { |filename| yield filename }\n end",
"def cleanup_open_files()\r\n if (self.active_files.length > MAX_NUM_FILES)\r\n _counter = 0\r\n \r\n self.active_files.each { |_file|\r\n _counter += 1\r\n \r\n if (_counter > MAX_NUM_FILES && _file.is_saved)\r\n _file.destroy()\r\n end\r\n }\r\n end\r\n end",
"def each(&block)\n\t\tclient.fs.sftp.dir.foreach(self.path, &block)\n\tend",
"def close_file!\n if @tar_reader\n @tar_reader.close\n @tar_reader = nil\n end\n if @file\n @file.close\n @file = nil\n end\n if @raw_file\n @raw_file.close unless @raw_file.closed?\n @raw_file = nil\n end\n end",
"def sort_files\n # Iterate thru files in @download_path\n cd(@download_path) do\n Find.find(pwd) do |path_to_file|\n @current_file_path = path_to_file\n next if @current_file_path == pwd # don't include the download folder as one of the files\n update_progress\n @file_directory, @file_name = File.split(@current_file_path)\n next if @file_name[0..0] == \".\" # skip any files/directories beginning with .\n # Stop searching this file/directory if it should be skipped, otherwise process the file\n should_skip_folder? ? Find.prune : process_download_file\n end\n end\n end",
"def wait_for_archived_file\n MAX_RETRIES.times do |retry_number|\n break if File.exist?(@archive_file)\n\n sleep(2**retry_number)\n end\n\n yield\n end",
"def each_attachment\n attachment_urls.each { |url| yield ActiveSP::File.new(self, url, true) }\n end",
"def each_file\n self.files.each_pair do |path, data|\n if not data.empty?\n yield path, StateModule::File::new(path, data)\n end\n end\n end",
"def foreach(&block)\n ::Dir.foreach(path, &block)\n end"
] | [
"0.64600426",
"0.62767065",
"0.6195767",
"0.61815876",
"0.61716676",
"0.6117953",
"0.60527706",
"0.59716886",
"0.5901977",
"0.58466125",
"0.5843151",
"0.5815639",
"0.5774412",
"0.57603896",
"0.57499844",
"0.57289475",
"0.5717408",
"0.5708387",
"0.5692621",
"0.5678006",
"0.56727445",
"0.56371975",
"0.56055504",
"0.56023437",
"0.56020254",
"0.55931664",
"0.55770683",
"0.55748284",
"0.5541627",
"0.55257857"
] | 0.71847224 | 0 |
Returns user or creates new one by given role (nondefault). | def get_user(role, *args)
# prepare role name
role = role.parameterize(?_).to_sym unless role.is_a?(Symbol)
if Testing.users[role]
# reload user
Testing.users[role].user.reload
else
# create user
Testing.users[role] = Factory(role, *args)
end
Testing.users[role]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_role(role_name)\n self.role = Role.where(name: role_name).first_or_create\n self # returns the user\n end",
"def create_login_user(role = nil)\n create(\"#{role || :admin}_user\").tap { |u| login_user(u) }\n end",
"def find_or_create_user(site=nil)\n if site.nil? and !self.users.empty?\n return self.users.first\n elsif (site and user = self.users.find_by_site_id(site.id))\n return user\n end\n\n user = ::User.create do |u|\n u.account = self\n u.site = site if site\n end\n\n if BigAuth.default_role\n role = Role.find_or_create_by(name: BigAuth.default_role)\n user.roles_users.create(:role => role)\n end\n user\n end",
"def create_user_role\n if self.role.blank?\n id = Role.select{|role| role.role_type == $roles[:user]}.map(&:id)\n self.update_attributes(:role_id => id[0])\n end\n end",
"def user_role\n Role.find_or_create_by(name: @user_group)\n end",
"def new_user\n if self.role_id.nil?\n self.role_id = 3\n end\n end",
"def new_user\n if self.role_id.nil?\n self.role_id = 3\n end\n end",
"def get_or_create_user\n @user||=use_url_session? ? get_or_create_url_session_user : current_user_with_guest\n end",
"def new\n if current_user && current_user.role == \"admin\"\n @user = User.new \n else\n redirect_to new_user_session_path\n end \n end",
"def create\n params[:user][:user_role_id] ||= UserRole.lowest.id\n\n if !current_user.can_assign_role?(params[:user][:user_role_id])\n role = UserRole.find(params[:user][:user_role_id])\n render json: { error: { detail: \"Forbidden: This operation is only available to users with role '#{ role.name }'.\", status: 403 } }, status: 403\n return\n else\n @user = User.find_by_email(params[:user][:email])\n if @user\n raise CircaExceptions::BadRequest, \"User with email #{params[:user][:email]} already exists.\"\n else\n params[:user][:password] ||= SecureRandom.hex(8)\n if params[:user][:agreement_confirmed]\n params[:user][:agreement_confirmed_at] = Time.now\n end\n @user = User.create!(user_params)\n update_notes\n render json: SerializeUser.call(@user)\n return\n end\n end\n end",
"def new_user(andrew_id)\n user = User.new\n user.andrew_id = andrew_id\n # If the app has just been created, the first user is an administrator.\n # Otherwise, everyone starts as a requester.\n user.role = User.first.nil? ? \"admin\" : \"requester\"\n user.save!\n return user\n end",
"def find_or_create_user\n @user = User.find_by(email: auth_email)\n @user ||= create_new_user\n save_omniauth_details\n\n @user\n end",
"def admin_create\n begin\n @user = User.new(user_params.merge(user_channel_id: current_user.user_channel_id))\n\n raise \"Invalid role[#{@user.role}]\" unless @user.is_available_role?\n if @user.save\n flash[:success] = t(:operation_succeeded)\n redirect_to users_path\n else\n render :new\n end\n rescue Exception => e\n flash.now[:error] = e.message\n render :new\n end\n end",
"def add_user(user,role = 'Member')\n self.users.create(id: user.id, role: role)\n end",
"def assign_default_role\n self.add_role(:newuser) if self.roles.blank?\n end",
"def assign_default_role\n self.add_role(:newuser) if self.roles.blank?\n end",
"def assign_role\n UserRole.create!(user_id: self.id, role_id: 3)\n end",
"def create\n \n # Try to find the user in the database; if not found, invite\n user = User.find_for_authentication(email: user_role_user_params[:email])\n if user.nil?\n user = User.invite!( user_role_user_params, current_user )\n end\n \n # If the user is already in the current organization, stop\n if @organization.users.include? user\n flash[:notice] = \"%s (%s) is already a member of this organization.\" % [ user.nickname, user.email ]\n redirect_to organization_users_path( @organization ) and return\n end\n \n # Abort if errors given\n unless user.save\n @user_role.errors.add( :email, 'cannot be blank.' )\n flash[:error] = \"There were some issues with inviting the user. (Is the email valid?)\"\n\n # Update the passed parameters for this role\n else\n @user_role.user = user\n flash[:success] = \"%s (%s) was invited successfully.\" % [ @user_role.user.nickname, @user_role.user.email ] if @user_role.update_attributes(user_role_params)\n end\n\n redirect_to organization_users_path( @organization )\n end",
"def new\n @role = Role.new(vendor_id: @vendor.id)\n @role.build_user\n end",
"def user\n super || create_user\n end",
"def create\n @user = User.new(user_params)\n unless @user.role\n @user.role = Role.find_by_name('Admin')\n end\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to admin_users_path, notice: 'Admin was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_role(user, role_name)\n role = Role.new(name: role_name, user: user)\n self.roles << role\n return role\n end",
"def create\n fname = \"#{self.class.name}.#{__method__}\"\n super\n user=User.find_by_email(reg_params[:email])\n pars={}\n unless user.nil?\n pars[:name]=params[:user][:name]\n pars[:role]=params[:user][:role]\n user.update(pars) \n else\n user=User.new(params[:user])\n end\n LOG.debug(fname) {\"************************ current_user=#{user.inspect}\"}\n end",
"def gen_roled_user(role, pass=\"test\")\n FactoryGirl.create(:User, role: role, password: pass, password_confirmation: pass)\n end",
"def create\n #\n # TODO confirm privledges are not compromised\n #\n user = User.find_by_email(params[:role][:user_attributes][:email])\n params[:role].delete(:user_attributes) if user.present?\n\n @role = Role.new(params[:role])\n if user.present?\n if @vendor.users.exists?(user)\n flash.now.alert = \"User already has a role at this vendor.\"\n redirect_to dashboard_vendor_vendor_roles_path(@vendor)\n return\n end\n @role.user = user\n end\n @role.vendor = @vendor\n\n if @role.save\n redirect_to dashboard_vendor_vendor_roles_path(@vendor), notice: 'User successfully added.'\n else\n render 'new'\n end\n end",
"def create\n return unless check_permission\n\n @role = Role.new(role_params)\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n else\n @users = User.all\n format.html { render :new }\n end\n end\n end",
"def new\n @user = User.new\n @role = params[:role]\n end",
"def get_or_create_user\n name = metadata['user']\n\n db = DB::Users.find(name, pool)\n u = load_user\n\n if db.nil?\n # The user does not exist, create him\n Commands::User::Create.run!(\n pool: pool.name,\n name: u.name,\n ugid: u.ugid,\n uid_map: u.uid_map.export,\n gid_map: u.gid_map.export,\n )\n\n return DB::Users.find(name, pool) || (fail 'expected user')\n end\n\n # Free the newly allocated ugid, use ugid from the existing user\n UGidRegistry.remove(u.ugid) if u.ugid != db.ugid\n\n %i(uid_map gid_map).each do |param|\n mine = db.send(param)\n other = u.send(param)\n next if mine == other\n\n fail \"user #{pool.name}:#{name} already exists: #{param} mismatch: \"+\n \"existing #{mine}, trying to import #{other}\"\n end\n\n db\n end",
"def default_user\n u = User.find_or_create_by_oauth2(default_oauth2_hash)\n create_user_shop(u)\n u\n end",
"def ensure_user(user_name:, email:, password:, roles:)\n user = User.where(user_name:).first\n if user.blank?\n user = User.new(user_name:, email:, roles:)\n user.password = password\n user.skip_confirmation!\n\n else\n user.email = email\n user.password = password unless user.valid_password?(password)\n user.roles = roles\n end\n user.skip_creation_email = true\n\n user.save!(validate: false)\n user\nend"
] | [
"0.80796206",
"0.75257456",
"0.7084824",
"0.704867",
"0.70045424",
"0.68900895",
"0.68900895",
"0.6850279",
"0.6586881",
"0.6580186",
"0.65649736",
"0.65100557",
"0.64267343",
"0.6420839",
"0.6395152",
"0.6395152",
"0.6382855",
"0.6372307",
"0.6365006",
"0.6345234",
"0.63422763",
"0.6305987",
"0.6301715",
"0.62844366",
"0.627853",
"0.62611634",
"0.6234134",
"0.6231193",
"0.62211883",
"0.62178355"
] | 0.7861061 | 1 |
Returns full name of user by his role. | def get_user_name(role)
get_user(role).full_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_name\n @role_name ||= object.meta[:role].try(:capitalize)\n end",
"def name\n \"#{role_name} #{user&.email}\"\n end",
"def role_name\r\n Role.find(object.role_id).role_name\r\n end",
"def role\r\n r = read_attribute(:role)\r\n r.capitalize unless r.nil?\r\n end",
"def get_role_name(role_type, role)\n method_symbol = ROLES[role_type]\n\n return nil if method_symbol.nil?\n\n role_object = role.send(method_symbol)\n\n return nil if role_object.name.empty?\n\n role_object.name\n end",
"def role(user)\n if user.admin\n return \"Admin\"\n else return \"User\"\n end\n end",
"def role_name\n object.role_name\n end",
"def get_full_role\n if role == \"admin\"\n return \"Administrator\"\n elsif role == \"lead\"\n return \"Organization Lead\"\n end\n end",
"def name_with_role\n \"#{self.name} (#{self.organization.name} - #{self.role.name})\"\n end",
"def user_role\n USER_ROLE[role]\n end",
"def get_role_name(key)\n key = Access::Validate.role(key)\n get_hash_value(Access::Core.roles_hash, key, :name)\n end",
"def user_name\n return User.find(user_id).name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def get_role\n return case self.role_id\n when 2\n \"User\"\n else\n \"N/A\"\n end\n end",
"def get_user_email(role)\n get_user(role).email\n end",
"def role_str\n if (role == nil)\n role_result = \"participant\"\n else\n role_result = role\n end\n role_result\n end",
"def title_for(role)\n role_titles[role]\n end",
"def role_label\n if user.is_admin?\n colored_label('Admin', :success)\n elsif user.has_role?(:manager)\n colored_label('Manager', :info)\n elsif user.has_role?(:content_manager) || user.has_role?(:event_manager) || user.has_role?(:forum_manager)\n colored_label('Submanager', :warning)\n elsif user.has_role?(:reviewer)\n colored_label('Reviewer', :default)\n elsif user.has_role?(:beta)\n colored_label('Beta', :danger)\n else\n 'User'\n end\n end",
"def getRole (user)\n case user.role\n when 0\n return 'user'\n when 1\n return 'operator'\n when 2\n return 'cto_user'\n when 3\n return 'owner'\n when 4\n return 'anonymous'\n else\n raise ('invalid user' + user.role)\n end\n end",
"def user_role\n r = Role.find_by_role(WFConsts::USER)\n r\n end",
"def user_full_name\n if user\n user.first_name + ' ' + user.last_name\n else\n 'Anonymous'\n end\n end",
"def human_name\n I18n.t(@name, :scope => [:role], :default => @name.to_s.humanize)\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end"
] | [
"0.74773586",
"0.73530936",
"0.7335994",
"0.7276779",
"0.7251935",
"0.7163674",
"0.7071336",
"0.70625144",
"0.70043963",
"0.6862761",
"0.6818438",
"0.6747765",
"0.6747765",
"0.6696236",
"0.6688714",
"0.6673189",
"0.66266805",
"0.66201437",
"0.660149",
"0.6546882",
"0.65446573",
"0.6538129",
"0.6537138",
"0.6537138",
"0.6537138",
"0.6537138",
"0.6537138",
"0.6537138",
"0.6537138",
"0.6537138"
] | 0.8967904 | 0 |
Returns email of user by his role. | def get_user_email(role)
get_user(role).email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_name(role)\n get_user(role).full_name\n end",
"def get_user_email\n user = User.find(self.user_id)\n user.email\n end",
"def admin_emails\n User.with_role(:admin, self).pluck(:email)\n end",
"def email\n return unless @user.loa3?\n\n value_for('emails')&.first\n end",
"def me_user_email\n email = Email.find_primary(me).take if auth?\n email.email || ''\n end",
"def user_role\n USER_ROLE[role]\n end",
"def get_user_email\n useremail[:value]\n end",
"def email\n (@session[:current_user_details] || {})[:email]\n end",
"def email\n mentee_user ? mentee_user.email : nil\n end",
"def email\n userid.try(:match, / <(.*@.*)>/).try(:[], 1)\n end",
"def get_email_address\n response = get_current_user_meta('email')\n email = response['query']['userinfo']['email']\n return if email == ''\n\n email\n end",
"def email\n user.emails.where( email: self.email_id ).first\n end",
"def getUserEmail(userName)\n\n if(userName == nil)\n return \"User not Found!\"\n end\n user = loadUser(userName)\n if user == nil\n return \"User not Found!\"\n end\n return user[\"email\"]\n\n end",
"def email\n\t\tif self.email_address\n\t\t\tself.email_address.email\n\t\telse\n\t\t\tself.user.email\n\t\tend\n\tend",
"def seller_email\r\n user.email rescue nil\r\n end",
"def u_email\n (self.user).email\n end",
"def user_role\n r = Role.find_by_role(WFConsts::USER)\n r\n end",
"def get_user_email\n unless auth_hash\n return nil if recaptcha_enabled? && !verify_recaptcha\n return params['email']\n end\n\n case auth_hash.provider\n when 'twitter'\n auth_hash.info.nickname\n when 'github'\n check_user_github_organizations ? auth_hash.info.email : nil\n else\n auth_hash.info.email\n end\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end",
"def email\n user.present? ? user.email : self[:email]\n end",
"def role(user)\n if user.admin\n return \"Admin\"\n else return \"User\"\n end\n end",
"def name\n \"#{role_name} #{user&.email}\"\n end",
"def user_email\n session[:user_id]\n end",
"def email_address\n response = get 'v1/market/private/user/email.json'\n response[:email]\n end",
"def email\n find_by_type('email')\n end",
"def get_role\n return case self.role_id\n when 2\n \"User\"\n else\n \"N/A\"\n end\n end",
"def email_credential\n user.credentials.where(name: email).first\n end",
"def name(user_id)\n User.find(user_id).email\n end"
] | [
"0.70791024",
"0.6951976",
"0.6823246",
"0.6756398",
"0.67435795",
"0.6634481",
"0.65817404",
"0.6566395",
"0.6548022",
"0.6535566",
"0.6454505",
"0.64337593",
"0.64110744",
"0.63814473",
"0.631941",
"0.62906945",
"0.62682307",
"0.62479496",
"0.62455654",
"0.62455654",
"0.622796",
"0.6200037",
"0.61679095",
"0.6149243",
"0.609646",
"0.6078236",
"0.6039434",
"0.60266",
"0.60202295",
"0.60100436"
] | 0.90248567 | 0 |
Saves user with role and email into Testingusers hash. | def save_user(role, email)
# prepare role name
role = role.parameterize(?_).to_sym unless role.is_a?(Symbol)
# make sure no user with same email is saved
unless get_user(role).email == email
Testing.users[role] = User.find_by_email(email)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save\n # Create the user with a unique email.\n email = @user.email_address\n at_ndx = email.index('@')\n modifier = \"_#{Jinx::UID.generate}\"\n @user.email_address = email.insert(at_ndx, modifier)\n @user.login_name = nil\n verify_save(@user)\n \n # Update the address.\n logger.debug { \"#{self} updating the #{@user} address...\" }\n @user.address.street = \"#{Jinx::UID.generate} Elm St.\"\n verify_save(@user)\n end",
"def test_add_user\r\n user = User.new\r\n user.name = \"testStudent1\"\r\n user.fullname = \"test_Student_1\"\r\n user.clear_password = \"testStudent1\"\r\n user.clear_password_confirmation = \"testStudent1\"\r\n user.email = \"testStudent1@foo.edu\"\r\n user.role_id = \"1\"\r\n user.save! # an exception is thrown if the user is invalid\r\n end",
"def create_employee_user\n email = self.work_email\n user = User.new(email: self.work_email, password: 'appsimpact@#123', role: 'employee')\n user.save\n self.user_id = user.id\n end",
"def create_user_as_admin(user_name,e_mail,password, roles = ['gardens preview', 'acquia engineering'], browser = @browser)\n Log.logger.info(\"Logging into #{browser.browser_url} as admin and creating new user #{user_name}\")\n browser.get(@sut_url)\n login_as_admin(browser)\n browser.get(\"#{@sut_url}/users/#{user_name}\")\n\n if (browser.find_element(:xpath => \"//body\").text.include?(\"404 error\"))\n browser.get(\"#{@sut_url}/admin/user/user/create\")\n temp = browser.find_element(:id => \"edit-name\")\n temp.clear\n temp.send_keys(user_name)\n temp = browser.find_element(:id => \"edit-mail\")\n temp.clear\n temp.send_keys(e_mail)\n temp = browser.find_element(:id => \"edit-pass-pass1\")\n temp.clear\n temp.send_keys(password)\n temp = browser.find_element(:id => \"edit-pass-pass2\")\n temp.clear\n temp.send_keys(password)\n # to get the role checkbox \"//div[contains(@id,'edit-roles')]//label[contains(text(), 'administrator')]//input\"\n unless roles.nil?\n roles.each do |role|\n rol_sel = \"//div[contains(@id,'edit-roles')]//label[contains(text(), '#{role}')]//input\"\n browser.find_element(:xpath => rol_sel).click if !(browser.find_elements(:xpath => rol_sel).empty?)\n end\n end\n agree_with_tos = 'edit-I-agree'\n browser.find_element(:id => agree_with_tos).click if !(browser.find_elements(:id => agree_with_tos).empty?)\n browser.find_element(:xpath => \"//input[@id='edit-submit' and @name='op' and @value='Create new account']\").click\n else\n Log.logger.debug(\"User \" + user_name + \" appears to already exist\");\n end\n end",
"def store_user\n data = load_data\n user_details = {\n 'id' => @user.uid.to_s,\n 'username' => @user.username,\n 'password' => @user.password,\n 'playlist' => @user.playlist,\n 'mylist' => @user.mylist\n }\n data << user_details\n write_user(data)\n end",
"def save\n vals = to_h\n vals.delete(:username)\n vals.delete_if { |_k, v| v.nil? || v.to_s.empty? }\n vals[:password] = vals.delete(:newpassword) if vals[:newpassword]\n payload = Gyoku.xml(user: vals)\n response = CoachClient::Request.put(url, username: @username,\n password: @password,\n payload: payload,\n content_type: :xml)\n unless response.code == 200 || response.code == 201\n fail CoachClient::NotSaved.new(self), 'Could not save user'\n end\n @password = vals[:password]\n @newpassword = nil\n self\n end",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n r = Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end",
"def set_user_attributes(user_hash)\n self.name = user_hash[:name]\n self.email = user_hash[:email]\n self.password = user_hash[:password]\n self.password_confirmation = user_hash[:password_confirmation]\n self.admin = false\n self.confirmed = false\n end",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end",
"def invite(user_params, email)\n raise StandardError, 'The account can not be activate' if email.nil?\n self.username = user_params[:username] # set the username\n self.passwd = user_params[:passwd] # set the password\n self.passwd_confirmation = user_params[:passwd_confirmation]\n\n # save user and activate\n User.save_user_and_email(self, email, true)\n end",
"def create\n\t params[:user][:login] = params[:user][:email_work] if params[:user][:login].blank?\n user = params[:user]\n @user = User.create(user)\n @user.valid? ? after_save(user) : error_responds(@user)\n end",
"def edit_user(edited_user)\n user = User.find(edited_user.email)\n user.attributes = edited_user.attributes\n user.save!\n end",
"def test_save_new_user\n # we want a login, an email and a name\n\t\tjoe = User.new({\n\t\t\t\t\t\t\t:login => \"unique_login\",\n\t\t\t\t\t\t\t:email => \"unique_login@example.com\",\n\t\t\t\t\t\t\t:firstname => \"any\",\n\t\t\t\t\t\t\t:lastname => \"user\"\n\t\t\t\t\t})\n # those are taken care of inside the controller\n joe.ipaddr = \"1.2.3.4\"\n joe.newemail = nil\n joe.confirmed = 0\n\t\tjoe.domains = { 'USERS' => 1 }\n\t\tjoe.password= \"joepass\"\n # before_create\n\t\t# joe.generate_validkey\n # before_save\n\t\t# joe.domains = User.domain2str(joe.domains)\n\t\t# joe.password = User.sha1(\"somepass\")\n # do save\n assert joe.save, \"something rotten... \" + joe.inspect\n end",
"def save\n puts \"############## aqui...\"\n # create a user\n c = Usuario.new\n c.email = \"isac.coelho@gmail.com\"\n c.password_hash = '123'\n c.password_hash.encrypted?\n c.save\n \n end",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.send(\"#{fb_email_hash_name}=\", Facebooker::User.hash_email(email))\n save(false)\n end",
"def set_entourage_user_hashes\n User.find_each do |user|\n email_hashes[hash(user.email)] = user.id\n phone_hashes[hash(user.phone)] = user.id\n end\n end",
"def registrar_usuario\n employee_user = User.new\n employee_user.email = self.email\n employee_user.password = employee_user.generar_password\n employee_user.username = asignar_username_con_opciones\n if asignar_username_con_opciones.present?\n employee_user.username = asignar_username_con_opciones\n else\n employee_user.username = self.usuario.downcase\n end\n employee_user.client_type = 'empleado'\n employee_user.save\n update(user_id: employee_user.id, user_created_id: employee_user.id) \n #luego de registrar al usuario se almacena la contraseña en la tabla Historypassword\n #donde se almacenaran las 3 ultimas usadas\n password_employee = HistoryPassword.new\n password_employee.password = employee_user.password\n password_employee.user_id = employee_user.id\n password_employee.save\n end",
"def save\n REDIS.set @user.delete(:key), @user.to_json\n @user # NOTE: SET can't fail (http://redis.io/commands/set)\n end",
"def register_user(mail, password_digest, date_joined, admin)\n return get_db_as_hash().execute(\"INSERT INTO user(mail, password_digest, date_joined, admin) VALUES (?, ?, ?, ?)\", mail, password_digest, date_joined, admin)\n end",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n end",
"def registrar_usuario\n business_user = User.new\n business_user.email = self.email\n business_user.password = business_user.generar_password\n business_user.client_type = 'empresa'\n business_user.save\n update(user_id: business_user.id, user_created_id: business_user.id)\n #luego de registrar al usuario se almacena la contraseña en la tabla Historypassword\n #donde se almacenaran las 3 ultimas usadas\n password_business = HistoryPassword.new\n password_business.password = business_user.password\n password_business.user_id = business_user.id\n password_business.save\n end",
"def user=(user)\n self.email = user.email\n self.name = user.name\n end",
"def save\n\t\t\tr = Episodey::DB::User.create(\n\t\t\t\t:name => self.name,\n\t\t\t\t:email => self.email\n\t\t\t)\n\t\t\t@id = r.id\n\t\t\treturn self\n\t\tend",
"def save!\n User.transaction do\n user.save!\n user.create_setup!\n end\n MarketingMailer.user_has_registered(user).deliver\n end",
"def create\n \n # Try to find the user in the database; if not found, invite\n user = User.find_for_authentication(email: user_role_user_params[:email])\n if user.nil?\n user = User.invite!( user_role_user_params, current_user )\n end\n \n # If the user is already in the current organization, stop\n if @organization.users.include? user\n flash[:notice] = \"%s (%s) is already a member of this organization.\" % [ user.nickname, user.email ]\n redirect_to organization_users_path( @organization ) and return\n end\n \n # Abort if errors given\n unless user.save\n @user_role.errors.add( :email, 'cannot be blank.' )\n flash[:error] = \"There were some issues with inviting the user. (Is the email valid?)\"\n\n # Update the passed parameters for this role\n else\n @user_role.user = user\n flash[:success] = \"%s (%s) was invited successfully.\" % [ @user_role.user.nickname, @user_role.user.email ] if @user_role.update_attributes(user_role_params)\n end\n\n redirect_to organization_users_path( @organization )\n end",
"def save\n\t\tbegin\n\t\t\tuser_profile = self.profile\n\t\t\tUser.create(\n\t\t\t\t:user_id => id,\n\t\t\t\t:login_name => username,\n\t\t\t\t:email => email,\n\t\t\t\t:join_tsz => created,\n\t\t\t\t:transaction_buy_count => user_profile.transaction_buy_count,\n\t\t\t\t:transaction_sold_count => user_profile.transaction_sold_count,\n\t\t\t\t:is_seller => user_profile.is_seller,\n\t\t\t\t:location => user_profile.lon ? [user_profile.lon, user_profile.lat] : nil,\n\t\t\t\t:image_url => user_profile.image,\n\t\t\t\t:country_id => user_profile.country_id,\n\t\t\t\t:gender => user_profile.gender,\n\t\t\t\t:oauth_token => nil,\n\t\t\t\t:oauth_token_secret => nil,\n\t\t\t\t:authenticated => false,\n\t\t\t\t:shop_id => @shop_id\n\t\t\t)\n\t\trescue NoMethodError\n\t\t\t# fairly rare at this point.\n\t\t\tputs \"associated_profile bug\"\n\t\tend\n\tend",
"def register_user_to_fb\n\t #users = {:email => email, :account_id => id}\n\t #Facebooker::User.register([users])\n\t #self.email_hash = Facebooker::User.hash_email(email)\n\t #save(false)\n\tend",
"def test_user( name, password, facilities=[], confirmed=true)\n user = User.create(name: name, email: name.gsub(/\\s/,'.').downcase+'@example.com')\n user.email_confirmed_at = Time.now if confirmed\n \n _facilities = facilities.is_a?(String) ? [facilities] : facilities\n _facilities.each do |f|\n user.facilities.create(name: f, access: 'rwx')\n end\n \n identity = Identity.create( name: name, password: password, password_confirmation: password)\n user.authentications << Authentication.new(provider: 'identity', uid: identity.id.to_s)\n user.save!\n user.reload\n user\n end",
"def save(user)\n if valid?\n user.update(Hash[ATTRIBUTES.map { |attribute_name| [attribute_name, send(attribute_name.to_sym)] }])\n end\n end"
] | [
"0.67035633",
"0.6299905",
"0.62603503",
"0.6214829",
"0.61662936",
"0.6138687",
"0.61385626",
"0.6133372",
"0.6131807",
"0.6131807",
"0.6128904",
"0.6040694",
"0.6033824",
"0.60336715",
"0.6021824",
"0.60114974",
"0.60092264",
"0.60001874",
"0.5986812",
"0.59661204",
"0.59326303",
"0.5927953",
"0.59278387",
"0.59270847",
"0.59235644",
"0.5918509",
"0.5907452",
"0.58983463",
"0.5883678",
"0.5868194"
] | 0.77372015 | 0 |
Calls block for email. If no options were passed, uses last email. | def open_email(opts = {}, &blk)
opts.empty? ? blk.call(emails.last) : blk.call(find_email(opts))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_inbound_email_from_mail(**kwargs, &block); end",
"def email_to(email='weare@icalialabs.com', &block)\n puts \"Hi #{email}\"\n yield if block_given?\n puts \"It was nice talking to you, see you!\"\nend",
"def email(name, &block)\n raise \"The email '#{name}' is already defined\" if self.messages[name].present?\n self.messages[name] = Proc.new { |*attrs|\n message = Mail::Message.new(self.app)\n message.defaults = self.defaults if self.defaults.any?\n message.delivery_method(*delivery_settings)\n message.instance_exec(*attrs, &block)\n message\n }\n end",
"def mailboxer_email(object)\n shouldSendEmail = true\n email if shouldSendEmail\n end",
"def mail_text(&block)\n block.call\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def receive_inbound_email_from_mail(**kwargs, &block)\n create_inbound_email_from_mail(**kwargs, &block).tap(&:route)\n end",
"def mail_to(email_address, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def safe_email(*args, **_arg1, &block); end",
"def mailboxer_email(obj=nil)\n return nil\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n email\n #if false\n #return nil\n end",
"def email; end",
"def email; end",
"def email; end",
"def email; end",
"def open_emails(opts, &blk)\n blk.call(find_emails(opts))\n end",
"def find(options = {}, &block)\n options = validate_options(options)\n \n start do |pop3|\n mails = pop3.mails\n pop3.reset # Clears all \"deleted\" marks. This prevents non-explicit/accidental deletions due to server settings.\n mails.sort! { |m1, m2| m2.number <=> m1.number } if options[:what] == :last\n mails = mails.first(options[:count]) if options[:count].is_a? Integer\n \n if options[:what].to_sym == :last && options[:order].to_sym == :desc ||\n options[:what].to_sym == :first && options[:order].to_sym == :asc ||\n mails.reverse!\n end\n \n if block_given?\n mails.each do |mail|\n new_message = Mail.new(mail.pop)\n new_message.mark_for_delete = true if options[:delete_after_find]\n yield new_message\n mail.delete if options[:delete_after_find] && new_message.is_marked_for_delete? # Delete if still marked for delete\n end\n else\n emails = []\n mails.each do |mail|\n emails << Mail.new(mail.pop)\n mail.delete if options[:delete_after_find]\n end\n emails.size == 1 && options[:count] == 1 ? emails.first : emails\n end\n \n end\n end",
"def create_inbound_email_from_mail(status: T.unsafe(nil), **mail_options, &block); end",
"def yield_email_and_respond_for_report\n csv_send_to_email = params[:email] || current_user.email\n\n yield csv_send_to_email\n\n if request.xhr?\n render plain: I18n.t(\"controllers.reports.mail_queued\", email: csv_send_to_email)\n else\n flash[:notice] = I18n.t(\"controllers.reports.mail_queued\", email: csv_send_to_email)\n redirect_back(fallback_location: url_for)\n end\n end",
"def receive(email, options={})\n @email = email\n @handler_options = options\n sender_email = email.from.to_a.first.to_s.strip\n # Ignore emails received from the application emission address to avoid hell cycles\n if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0\n if logger\n logger.info \"MailHandler: ignoring email from Redmine emission address [#{sender_email}]\"\n end\n return false\n end\n # Ignore auto generated emails\n self.class.ignored_emails_headers.each do |key, ignored_value|\n value = email.header[key]\n if value\n value = value.to_s.downcase\n if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value\n if logger\n logger.info \"MailHandler: ignoring email with #{key}:#{value} header\"\n end\n return false\n end\n end\n end\n @user = User.find_by_mail(sender_email) if sender_email.present?\n if @user && !@user.active?\n if logger\n logger.info \"MailHandler: ignoring email from non-active user [#{@user.login}]\"\n end\n return false\n end\n if @user.nil?\n # Email was submitted by an unknown user\n case handler_options[:unknown_user]\n when 'accept'\n @user = User.anonymous\n when 'create'\n @user = create_user_from_email\n if @user\n if logger\n logger.info \"MailHandler: [#{@user.login}] account created\"\n end\n add_user_to_group(handler_options[:default_group])\n unless handler_options[:no_account_notice]\n Mailer.account_information(@user, @user.password).deliver\n end\n else\n if logger\n logger.error \"MailHandler: could not create account for [#{sender_email}]\"\n end\n return false\n end\n else\n # Default behaviour, emails from unknown users are ignored\n if logger\n logger.info \"MailHandler: ignoring email from unknown user [#{sender_email}]\"\n end\n return false\n end\n end\n User.current = @user\n dispatch\n end",
"def capture_emails(&block)\n original_count = ActionMailer::Base.deliveries.size\n deliver_enqueued_emails(&block)\n new_count = ActionMailer::Base.deliveries.size\n diff = new_count - original_count\n ActionMailer::Base.deliveries.last(diff)\n end",
"def receive(email, raw_email)\n # Find which info requests the email is for\n # We deliberately don't use Envelope-to here, so ones that are BCC\n # drop into the holding pen for checking.\n reply_info_requests = [] # XXX should be set?\n for address in (email.to || []) + (email.cc || [])\n reply_info_request = InfoRequest.find_by_incoming_email(address)\n reply_info_requests.push(reply_info_request) if reply_info_request\n end\n\n # Nothing found, so save in holding pen\n if reply_info_requests.size == 0 \n InfoRequest.holding_pen_request.receive(email, raw_email)\n return\n end\n\n # Send the message to each request, to be archived with it\n for reply_info_request in reply_info_requests\n reply_info_request.receive(email, raw_email)\n end\n end",
"def test_email(from, to, &block)\n if (block_given?)\n self.class.warn_about_arguments(block, 1..2)\n end\n\n message = {\n from: from,\n to: to,\n test: true,\n callback: block\n }\n\n @messages << message\n\n # If the connection is ready to send...\n if (@interpreter and @interpreter.state == :ready)\n # ...send the message right away.\n after_ready\n end\n end",
"def send_an_email\r\n SendEmails.new(1)\r\n end",
"def send!\n raise \"job #{job.backup_id} has no email option\" unless job.options[:email]\n # define local variables for closure over Mail.new\n from_address = settings['email_from']\n to_address = job.options[:email]\n subject_text = \"Backup of RDS #{job.rds_id} (job ID #{job.backup_id})\"\n body_text = body\n mail = Mail.new do\n from from_address\n to to_address\n subject subject_text\n body \"#{body_text}\\n\"\n end\n mail.deliver!\n end",
"def find(options={}, &block)\n options = validate_options(options)\n\n start do |imap|\n options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])\n uids = imap.uid_search(options[:keys], options[:search_charset])\n uids.reverse! if options[:what].to_sym == :last\n uids = uids.first(options[:count]) if options[:count].is_a?(Integer)\n uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||\n (options[:what].to_sym != :last && options[:order].to_sym == :desc)\n\n if block_given?\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822', 'FLAGS'])[0]\n new_message = Mail.new(fetchdata.attr['RFC822'])\n new_message.mark_for_delete = true if options[:delete_after_find]\n\n if block.arity == 4\n yield new_message, imap, uid, fetchdata.attr['FLAGS']\n elsif block.arity == 3\n yield new_message, imap, uid\n else\n yield new_message\n end\n\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n else\n emails = []\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]\n emails << Mail.new(fetchdata.attr['RFC822'])\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find]\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n emails.size == 1 && options[:count] == 1 ? emails.first : emails\n end\n end\n end",
"def email(options)\n puts \"sending to #{options}\"\n Pony.mail(BASE_EMAIL.merge(options))\n end",
"def free_email(*args, **_arg1, &block); end",
"def email\n @email ||= Email::Gateway.new(client)\n end"
] | [
"0.6691691",
"0.6509347",
"0.6207139",
"0.6155163",
"0.61072505",
"0.60718304",
"0.60718304",
"0.60470617",
"0.59935564",
"0.5986473",
"0.5735649",
"0.56812257",
"0.56632024",
"0.56632024",
"0.56632024",
"0.56632024",
"0.565569",
"0.56252104",
"0.5616625",
"0.5615721",
"0.5614632",
"0.5613346",
"0.5611904",
"0.5594314",
"0.5581435",
"0.5559076",
"0.55458605",
"0.55377936",
"0.55232745",
"0.54984707"
] | 0.68484765 | 0 |
Returns email which matches options. | def find_email(opts)
find_emails(opts).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_emails(opts)\n emails.reverse.select do |email|\n email.to.include?(opts[:to]) || email.subject == opts[:subject]\n end\n end",
"def hf_email_opts\n return options_for_select(@email_enum, @agg)\n end",
"def email\n @email ||= select { |type,value| type == :email }.map do |(type,value)|\n value\n end\n end",
"def format\n options['format'] || :email\n end",
"def find_by(options)\n warn \"Using `Repository#find_by` with an email may return inexact matches\" if email_key?(options)\n where(options, true).first\n end",
"def email\n options.email || repo.email\n end",
"def email_from\n case self.type\n when 'test'\n \"milo.thurston@oerc.ox.ac.uk\"\n when 'left','sdm','lcc','cde'\n \"neil.caithness@oerc.ox.ac.uk\"\n else\n \"noreply.oboe@oerc.ox.ac.uk\"\n end\n end",
"def all_applications_emails\n apply_forms.accepted.select(:email).map(&:email).join(', ')\n end",
"def email(table, column, options)\n \"check (((#{table}.#{column})::text ~ E'^([-a-z0-9]+)@([-a-z0-9]+[.]+[a-z]{2,4})$'::text))\"\n end",
"def user_email\n msg['email'] || entry['email'] || reject['email']\n end",
"def email\n find_by_type('email')\n end",
"def setup_recipients( email )\r\n if RAILS_ENV == 'production'\r\n return email\r\n else\r\n return AppConfig.DEBUG_EMAIL_ADDRESS\r\n end\r\n end",
"def email\n preferred_email\n end",
"def email(emails = nil, use_map: true, user: nil)\n emails = user.email if emails.nil? && !user.nil?\n # Check the emails as supplied\n result = email_domain(emails)\n return result unless result.nil?\n # If no match was found, apply substitutions and check again\n emails = email_sub(emails)\n result = email_domain(emails)\n # If no match was found after substitutions, check against the email address map\n result = email_map(emails) if result.nil? && use_map\n # If there is still no match, take the first email in the list\n result = emails[0] if result.nil?\n # Return the result\n result\n end",
"def from_email\n EmailAddress.find(:all).first\n end",
"def email\n if md = RE_EMAIL.match(contact.to_s)\n md[0]\n else\n nil\n end\n end",
"def smtp_options\n {\n address: smtp_address,\n port: smtp_port,\n domain: smtp_domain,\n authentication: smtp_authentication,\n user_name: smtp_user_name,\n password: smtp_password\n }.select { |_key, value| value.presence }\n end",
"def email\n return unless @user.loa3?\n\n value_for('emails')&.first\n end",
"def email_address\n element_with_value('EMailAddress', opts[:email_address].to_s[0..50])\n end",
"def recipient_emails\n recipients.map(&:first)\n end",
"def latest_mail(options = {})\n return only_latest(mail(options))\n end",
"def email\n multi_email.primary_email_record.try(:email)\n end",
"def sender_email\n msg['from_email'] || msg['sender'] || entry['sender'] || reject['sender']\n end",
"def email\n match(/Email\\s+:\\s+([^\\s]+)/)\n end",
"def email(text_array)\n email = nil\n text_array.each do |t|\n if t.match(/.{1,}[@].{1,}[.].{1,}/)\n email = t\n end\n end\n return email\nend",
"def email\n # If product_specific_contacts is off, always return the facility's email\n return facility.email unless SettingsHelper.feature_on? :product_specific_contacts\n contact_email.presence || facility.try(:email)\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def mail(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return get_mail(default_options, options)\n end",
"def emails\n self[\"gd$email\"] ? self[\"gd$email\"].map { |e| e.address } : []\n end",
"def email?\n message_type&.to_sym == :email\n end"
] | [
"0.7402068",
"0.71108353",
"0.665396",
"0.66466504",
"0.65922785",
"0.6482124",
"0.64553875",
"0.62137663",
"0.62112653",
"0.61952025",
"0.6156319",
"0.6148581",
"0.61339813",
"0.6130241",
"0.6122711",
"0.61206514",
"0.6111462",
"0.610062",
"0.6091365",
"0.60588497",
"0.6052738",
"0.60030603",
"0.5997441",
"0.5988947",
"0.5983905",
"0.59635127",
"0.5947779",
"0.59215665",
"0.59161836",
"0.58981234"
] | 0.7285309 | 1 |
Returns an array of emails which match options. Please note that it searches from the most recent to oldest emails. | def find_emails(opts)
emails.reverse.select do |email|
email.to.include?(opts[:to]) || email.subject == opts[:subject]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getEmailsByRecipient(recipientEmail)\n searchCriteria = Hash.new\n searchCriteria['recipient']= recipientEmail\n return getEmails(searchCriteria)\n end",
"def complete_email_list\n #Email.select(:email).map{|email_record| email_record.email}\n User.all.map(&:email)\n end",
"def all_applications_emails\n apply_forms.accepted.select(:email).map(&:email).join(', ')\n end",
"def getEmails(searchCriteria = Hash.new)\n if searchCriteria.is_a? String\n search = searchCriteria\n searchCriteria = Hash.new\n searchCriteria['search'] = search\n end\n searchCriteria['key'] = @API_KEY\n searchCriteria['mailbox'] = @MAILBOX\n for i in 1..10\n response = RestClient.get(\"#{@BASE_URI}/emails\", {:params => searchCriteria})\n data = JSON.parse(response.body)\n emails = data.map { |em| Email.new(em) }\n\n if !emails.nil? && emails.length>0\n return emails\n end\n # back off and retry\n sleep(i*i)\n end\n end",
"def get_emails(search_criteria = {})\n if search_criteria.is_a? String\n search_criteria = {'search' => search_criteria}\n end\n search_criteria['key'] = @api_key\n search_criteria['mailbox'] = @mailbox\n response = send_get_emails_request(search_criteria)\n if response.length > 2\n data = JSON.parse(response.body)\n data.map { |em| Email.new(em) }\n else\n message.no_emails_found(search_criteria)\n end\n end",
"def emails\n Array(@emails)\n end",
"def get_emails_by_search(opts = {})\n data, status_code, headers = get_emails_by_search_with_http_info(opts)\n return data\n end",
"def find_by(options)\n warn \"Using `Repository#find_by` with an email may return inexact matches\" if email_key?(options)\n where(options, true).first\n end",
"def emails\n self[\"gd$email\"] ? self[\"gd$email\"].map { |e| e.address } : []\n end",
"def search_addressbook\n emails = Array.new \n flag = params[:q].to_s.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n id_search = false\n if flag\n filter = params[:q].length == 6 ? Net::LDAP::Filter.eq( \"sAMAccountName\", \"#{params[:q]}\" ) : \"\"\n id_search = true\n else\n filter = Net::LDAP::Filter.eq( \"mail\", \"*#{params[:q]}*\")\n end\n unless filter == \"\"\n ldap_connection.search( :base => AppConfig[:ldap_treebase], :filter => filter , :attributes => [\"sAMAccountName\", \"mail\"], :size => 10) do |entry|\n emails << {:name => \"#{entry[:mail].first} (#{entry[:samaccountname].first})\" , :value => entry[:mail].first}\n end\n end\n emails\n end",
"def legal_emails\n %w[stmm.confirmation@kristoffs.com\n stmm.confirmationa@aol.com\n paul@kristoffs.com\n paul.kristoff@kristoffs.com\n retail@kristoffs.com\n justfaith@kristoffs.com\n financial@kristoffs.com]\n end",
"def hf_email_opts\n return options_for_select(@email_enum, @agg)\n end",
"def get_emails(opts = {})\n data, status_code, headers = get_emails_with_http_info(opts)\n return data\n end",
"def extract_emails(emails)\n return [] if emails.blank?\n\n emails.\n split(',').\n select { |email| ::EmailValidator.valid?(email) }.\n first(100)\n end",
"def email_addresses\n emails.map(&:address)\n end",
"def get_emails(limit = 100, offset = 0, conditions = {})\n params = extract_query_params conditions\n\n params['limit'] = limit\n params['offset'] = offset\n\n request :get, \"/v3/emails.json\", params\n end",
"def find_email(opts)\n find_emails(opts).first\n end",
"def get_emails_by_recipient(recipient_email)\n search_criteria = {'recipient' => recipient_email}\n get_emails(search_criteria)\n end",
"def find_emails\n options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }\n options[:limit] = batch_size unless batch_size.nil?\n mail = ActionMailer::Base.email_class.find :all, options\n\n log \"found #{mail.length} emails to send\"\n mail\n end",
"def get_emails\n emails = [self.email1, self.email2, self.email3]\n emails.compact!\n emails.delete('')\n return emails\n end",
"def emails(text)\n scan(text, EMAIL, :email)\n end",
"def search_emails(search, subject)\n @gmail.in_mailbox(self) do\n email_results = @gmail.imap.uid_search(search).collect { |uid| messages[uid] ||= Message.new(@gmail, self, uid) }\n # If subject is not nil, filter results by subject and mark the rest of the emails as unread.\n if subject\n result = email_results.select {|email| email.subject == subject} \n email_results.reject {|email| email.subject == subject}.each do |email|\n email.mark(:unread)\n end\n return result\n end\n return email_results\n end\n end",
"def find(options={}, &block)\n options = validate_options(options)\n\n start do |imap|\n options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])\n uids = imap.uid_search(options[:keys], options[:search_charset])\n uids.reverse! if options[:what].to_sym == :last\n uids = uids.first(options[:count]) if options[:count].is_a?(Integer)\n uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||\n (options[:what].to_sym != :last && options[:order].to_sym == :desc)\n\n if block_given?\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822', 'FLAGS'])[0]\n new_message = Mail.new(fetchdata.attr['RFC822'])\n new_message.mark_for_delete = true if options[:delete_after_find]\n\n if block.arity == 4\n yield new_message, imap, uid, fetchdata.attr['FLAGS']\n elsif block.arity == 3\n yield new_message, imap, uid\n else\n yield new_message\n end\n\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n else\n emails = []\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]\n emails << Mail.new(fetchdata.attr['RFC822'])\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find]\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n emails.size == 1 && options[:count] == 1 ? emails.first : emails\n end\n end\n end",
"def getEmailList\n\t\tdata = index()\n\t\temailList = []\n\t\tdata.each do |person|\n\t\t\temailList.push(\"#{person[\"email_address\"]}\")\n\t\tend\n\t\treturn emailList\n\tend",
"def notification_email_addresses\n emails = []\n if self.billing_address.email.blank? and self.shipping_address.email.blank? and !self.user.nil?\n emails << self.user.email\n elsif self.shipping_address.nil? and !self.billing_address.email.blank?\n emails << self.billing_address.email\n else\n if (!self.user.nil? and !self.user.email.blank?)\n emails << self.user.email\n end\n emails << self.billing_address.email unless self.billing_address.email.blank?\n emails << self.shipping_address.email unless self.shipping_address.email.blank?\n end\n \n return emails.uniq\n end",
"def invitation_search(q, limit=10)\n if q.present? and q.length > 1\n already_exists_ids = []\n already_exists_emails = []\n # add owner\n already_exists_ids << self.id\n # add colaborators\n if self.members.present?\n already_exists_ids << self.members.map{|x| x.member_id}\n end\n # add invitations\n pending = Invitation.pending_from_user(self.id)\n if pending.present?\n already_exists_emails << pending.map{|x| x.to_email}\n end\n\n already_exists_ids.flatten!\n already_exists_emails.flatten!\n\n users = User.any_of({first_name: /#{q}/i}, {last_name: /#{q}/i}, {email_no_domain: /#{q}/i}).limit(limit)\n if already_exists_ids.present? && already_exists_emails.present?\n users = users.not_in({id: already_exists_ids.uniq, email: already_exists_emails.uniq})\n elsif already_exists_ids.present?\n users = users.not_in({id: already_exists_ids.uniq})\n elsif already_exists_emails.present?\n users = users.not_in({email: already_exists_emails.uniq})\n end\n\n return users\n end\n end",
"def getResultRecepientEmailList()\n return @resultRecepients\n end",
"def email_addresses\n begin\n @email_addresses ||= xmlrpc_client.call(\"list_emails\", session_id)\n rescue Timeout::Error => e\n raise \"Error during connection. Please try again later.\" \n end\n end",
"def all_emails(current_user)\n mails = []\n self.users.map{ |u| mails << u.email unless u == current_user || !u.accepting_emails }.compact.join(\", \")\n end",
"def get_email_text(search_array, timeout=600, delete=true, since_sec=3600)\n # Only look for emails that have come in since the last hour\n since = Time.now - since_sec\n imap_search_terms = search_array.dup.push(\"SINCE\", since.strftime('%d-%b-%Y'))\n @log.debug(\"Searching for email with query: #{imap_search_terms}\")\n\n super imap_search_terms, timeout, delete, since_sec\n end"
] | [
"0.63930243",
"0.62542325",
"0.62459",
"0.6218688",
"0.6195318",
"0.611811",
"0.6102273",
"0.6073789",
"0.6057075",
"0.6051387",
"0.6042426",
"0.60371006",
"0.6028046",
"0.5992832",
"0.59848726",
"0.5976612",
"0.59741294",
"0.59592247",
"0.5933756",
"0.5932831",
"0.59074754",
"0.5906787",
"0.58685744",
"0.58667046",
"0.58429426",
"0.5826007",
"0.5779555",
"0.57726634",
"0.576707",
"0.57529515"
] | 0.81047475 | 0 |
GET /valoration_users GET /valoration_users.json | def index
@valoration_users = ValorationUser.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n get('get_users')\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def list_users\n self.class.get('/users')\n end",
"def index\n render json: current_org.users\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def list\n get('users')['users']\n end",
"def users(params = {})\n response = get('users/lookup.json', params)\n response.map {|user| Croudia::Object::User.new(user) }\n end",
"def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end",
"def users(params = {})\n params.merge!(key: 'users')\n objects_from_response(Code42::User, :get, 'user', params)\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def users(params = {})\n make_get_request('/account/users', params)\n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def index\n json_response(User.all) \n end",
"def users\n\t\trespond_with User.all\n\tend",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def users\n @users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @users.map(&:as_json) }\n\t\tend\n\tend",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end",
"def index\n render ActiveModelSerializers::SerializableResource.new(@users,\n each_serializer: UserSerializer\n ).to_json, status: 200\n end",
"def list\n render json: User.all\n end",
"def get_users(request); end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t format.html # index.html.erb\n\t\t format.json { render json: @users }\n\t\tend\n\tend"
] | [
"0.6857912",
"0.67867386",
"0.6713382",
"0.6672931",
"0.66613084",
"0.6650944",
"0.66458863",
"0.6633754",
"0.6615078",
"0.66113013",
"0.65589124",
"0.65478677",
"0.65461254",
"0.65391105",
"0.653215",
"0.65111136",
"0.6507204",
"0.65040106",
"0.6503044",
"0.6501361",
"0.6499878",
"0.6499878",
"0.64933974",
"0.6481648",
"0.64587516",
"0.643912",
"0.64262795",
"0.6421409",
"0.6421235",
"0.6415143"
] | 0.7486669 | 0 |
DELETE /valoration_users/1 DELETE /valoration_users/1.json | def destroy
@valoration_user.destroy
respond_to do |format|
format.html { redirect_to valoration_users_url, notice: 'Valoracion de usuario eliminada correctamente .' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n User.cascade_delete(@user)\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = current_org.users.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n\n end",
"def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end",
"def user_management_delete_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"id\" => id,\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.delete query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 404\n raise APIException.new \"Not found\", 404, response.raw_body\n elsif response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to residencial_apartamento_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user.destroy\n format.json { head :no_content }\n end",
"def delete_users\n delete(users_path)\n end",
"def destroy\n @users = User.find(params[:id])\n @users.destroy\n\n respond_to do |format|\n format.html { redirect_to regists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @v_user_datum = VUserData.find(params[:id])\n @v_user_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to v_user_data_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n HerosUsers.destroy_all(:user_id => @user.id)\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.status = 'deleted'\n @user.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def destroy\n @api_user.destroy\n\n head :no_content\n end",
"def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user=User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user_vacancy.destroy\n respond_to do |format|\n format.html { redirect_to user_vacancies_url, notice: 'Aplicación eliminada correctamente' }\n format.json { head :no_content }\n end\n end"
] | [
"0.71498907",
"0.70878637",
"0.7073339",
"0.6991608",
"0.69904757",
"0.69669205",
"0.69529426",
"0.68953174",
"0.6893181",
"0.68703747",
"0.6869683",
"0.6856151",
"0.6822391",
"0.68212324",
"0.68212324",
"0.68152386",
"0.68060744",
"0.67937046",
"0.6785788",
"0.67701346",
"0.67622644",
"0.6752208",
"0.67492175",
"0.6746991",
"0.6745558",
"0.6743892",
"0.67382157",
"0.67378384",
"0.67359406",
"0.6718702"
] | 0.7270156 | 0 |
Index manifest range labels and OCR which is cached in Versionocr_text. | def manifest_content
versions.flat_map(&:ocr_text).compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manifestation_index_field_labels\n Blacklight.config[:manifestation_index_fields][:labels]\n end",
"def image_ids_labels_from_manifest_as_hash(manifest)\n ids_labels = []\n page_number = 0\n manifest.sequences.first.canvases.each do |canvas|\n page_number += 1\n id = canvas.images.first.resource.service['@id']\n label = if canvas['label'].nil?\n \"Page #{page_number}\"\n else\n canvas['label']\n end\n ids_labels << { 'id' => strip_iiif_server_base_from_id(id), 'label' => label }\n end\n ids_labels\n end",
"def index\n # @results = []\n # @document.bioc_doc.all_annotations.each do |a|\n # e = EntityUtil.get_annotation_entity(a)\n # a.locations.each do |l|\n # @results << {did: @document.did, offset: l.offset, text: a.text, length: l.length, infons: a.infons }\n # end\n # end\n @project = @document.project\n @version = params[:version] || @document.version\n @version = @version.to_i if @version.present?\n @is_manager = @project.manager?(current_user)\n\n if @is_manager || @project.collaborate_round\n @annotations = @document.annotations.where('`version`=?', @version)\n else\n @annotations = @assign.annotations\n end\n @annotations = @annotations.order(\"offset\")\n end",
"def index\n\t @text = SystemSetting.value_at(\"firmware_text\") || SystemSetting.new(:key => \"firmware_text\").value\n\t @files = Firmware.active.asc(:created_at)\n\t @firmware = Firmware.new\n\t @firmware_ranges = FirmwareRange.active.asc(:created_at)\n\t @firmware_range = FirmwareRange.new\n\tend",
"def _cornell_render_document_index_label doc\n\n # Rewriting because we can't get the above to work properly....\n label = doc[\"title_display\"]\n title = doc['fulltitle_display']\n vern = doc['fulltitle_vern_display']\n\n if title.present?\n label = title\n end\n\n if vern.present? && !title.nil?\n label = vern + ' / ' + label\n else\n if vern.present?\n label = vern\n end\n end\n\n label ||= doc['id']\n end",
"def lttfindex\n end",
"def legacy_indexes()\n arr = []\n\n # REFACTOR: make to_llo call this one\n hr_op = analysis(Analysis::HR_NAME, lead_pair_name())\n\n # GXX : 0 - 25\n op = analysis(Analysis::APS_NAME, primary_lead_name())\n arr << op.index(Index::APS_12_NAME) # 0\n arr << op.index(Index::APS_OMEGA_NAME)\n arr << op.index(Index::APS_U1_NAME)\n arr << op.index(Index::APS_U2_NAME)\n arr << op.index(Index::APS_U3_NAME)\n arr << op.index(Index::APS_U3xy_NAME) # 5\n arr << op.index(Index::APS_U4_NAME)\n arr << op.index(Index::APS_N1_NAME)\n arr << op.index(Index::APS_N3_NAME)\n arr << hr_op.index(Index::HR_S_NAME)\n arr << hr_op.index(Index::HR_SS_NAME) # 10\n arr << hr_op.index(Index::HR_F_NAME)\n arr << hr_op.index(Index::HR_FF_NAME)\n arr << op.index(Index::APS_A1_NAME)\n arr << op.index(Index::APS_A2_NAME)\n arr << op.index(Index::APS_A3_NAME) # 15\n arr << op.index(Index::APS_A4_NAME)\n arr << op.index(Index::APS_A5_NAME)\n arr << op.index(Index::APS_A55_NAME)\n arr << op.index(Index::APS_N2_NAME)\n arr << op.index(Index::APS_AA12_NAME) # 20\n arr << op.index(Index::APS_AA34_NAME)\n arr << op.index(Index::APS_AA123_NAME)\n arr << op.index(Index::APS_AA1_NAME)\n arr << op.index(Index::APS_AA4_NAME)\n arr << op.index(Index::APS_U5_NAME) # 25\n\n # GYY : 26 - 51\n op = analysis(Analysis::APS_NAME, secondary_lead_name())\n arr << op.index(Index::APS_12_NAME)\n arr << op.index(Index::APS_OMEGA_NAME)\n arr << op.index(Index::APS_U1_NAME)\n arr << op.index(Index::APS_U2_NAME)\n arr << op.index(Index::APS_U3_NAME) # 30\n arr << op.index(Index::APS_U3xy_NAME)\n arr << op.index(Index::APS_U4_NAME)\n arr << op.index(Index::APS_N1_NAME)\n arr << op.index(Index::APS_N3_NAME)\n arr << hr_op.index(Index::HR_S_NAME) # 35\n arr << hr_op.index(Index::HR_SS_NAME)\n arr << hr_op.index(Index::HR_F_NAME)\n arr << hr_op.index(Index::HR_FF_NAME)\n arr << op.index(Index::APS_A1_NAME)\n arr << op.index(Index::APS_A2_NAME) # 40\n arr << op.index(Index::APS_A3_NAME)\n arr << op.index(Index::APS_A4_NAME)\n arr << op.index(Index::APS_A5_NAME)\n arr << op.index(Index::APS_A55_NAME)\n arr << op.index(Index::APS_N2_NAME) # 45\n arr << op.index(Index::APS_AA12_NAME)\n arr << op.index(Index::APS_AA34_NAME)\n arr << op.index(Index::APS_AA123_NAME)\n arr << op.index(Index::APS_AA1_NAME)\n arr << op.index(Index::APS_AA4_NAME) # 50\n arr << op.index(Index::APS_U5_NAME)\n\n # QXY : 52 - 57\n psa_op = analysis(Analysis::PSA_NAME, lead_pair_name())\n arr << psa_op.index(Index::PSA_PPLUS_NAME)\n arr << psa_op.index(Index::PSA_PMINUS_NAME)\n arr << psa_op.index(Index::PSA_WW_NAME)\n arr << psa_op.index(Index::PSA_PWWPLUS_NAME) # 55\n arr << psa_op.index(Index::PSA_PWWMINUS_NAME)\n\n imr_op = analysis(Analysis::IMR_NAME, lead_pair_name())\n arr << imr_op.index(Index::IMR_L_NAME)\n\n # RH : 58 - 59\n op = analysis(Analysis::COH_NAME, lead_pair_name())\n arr << op.index(Index::COH_Q1_NAME)\n arr << op.index(Index::COH_Q2_NAME)\n\n # PIH : 60 -69\n arr << imr_op.index(Index::IMR_D1_NAME) # 60\n arr << imr_op.index(Index::IMR_D2_NAME)\n arr << imr_op.index(Index::IMR_f_NAME)\n arr << imr_op.index(Index::IMR_M1_NAME)\n arr << imr_op.index(Index::IMR_M3_NAME)\n arr << imr_op.index(Index::IMR_M2_NAME) # 65\n arr << imr_op.index(Index::IMR_M4_NAME)\n arr << imr_op.index(Index::IMR_M5_NAME)\n arr << imr_op.index(Index::IMR_M6_NAME)\n arr << imr_op.index(Index::IMR_ff_NAME)\n\n # HA : 70 - 77\n v5_op = analysis(Analysis::AMP_NAME, primary_lead_name())\n ii_op = analysis(Analysis::AMP_NAME, secondary_lead_name())\n arr << v5_op.index(Index::AMP_HYPER_NAME) # 70\n arr << ii_op.index(Index::AMP_HYPER_NAME)\n arr << v5_op.index(Index::AMP_HYPO_NAME)\n arr << ii_op.index(Index::AMP_HYPO_NAME)\n arr << v5_op.index(Index::AMP_NPLUS_NAME)\n arr << ii_op.index(Index::AMP_NPLUS_NAME) # 75\n arr << v5_op.index(Index::AMP_NMINUS_NAME)\n arr << ii_op.index(Index::AMP_NMINUS_NAME)\n\n # VXY : 78 - 102\n op = analysis(Analysis::CCR_NAME, lead_pair_name())\n arr << op.index(Index::CCR_rrr_NAME)\n arr << op.index(Index::CCR_RRR_NAME)\n arr << op.index(Index::CCR_r_NAME) # 80\n arr << op.index(Index::CCR_R_NAME)\n arr << op.index(Index::CCR_RR_NAME)\n arr << op.index(Index::CCR_rr_NAME)\n arr << op.index(Index::CCR_rR_NAME)\n arr << op.index(Index::CCR_RPLUS_NAME) # 85\n arr << op.index(Index::CCR_RMINUS_NAME)\n arr << op.index(Index::CCR_RwPLUS_NAME)\n arr << op.index(Index::CCR_RwMINUS_NAME)\n arr << op.index(Index::CCR_PT1_NAME)\n arr << op.index(Index::CCR_PT2_NAME) # 90\n arr << op.index(Index::CCR_pt1_NAME)\n arr << op.index(Index::CCR_pt2_NAME)\n arr << op.index(Index::CCR_Rn_NAME)\n arr << op.index(Index::CCR_RVVPLUS_NAME)\n arr << op.index(Index::CCR_RVVMINUS_NAME) # 95\n arr << op.index(Index::CCR_RCARET_NAME)\n arr << op.index(Index::CCR_NOTR_NAME)\n arr << op.index(Index::CCR_RNOT_NAME)\n arr << op.index(Index::CCR_r2_NAME)\n arr << op.index(Index::CCR_R2_NAME) # 100\n arr << op.index(Index::CCR_r22_NAME)\n arr << op.index(Index::CCR_RM_NAME)\n\n # Q : 103 - 131\n arr << psa_op.index(Index::PSA_TPLUS_NAME)\n arr << psa_op.index(Index::PSA_TMINUS_NAME)\n arr << psa_op.index(Index::PSA_UPLUS_NAME) # 105\n arr << psa_op.index(Index::PSA_UMINUS_NAME)\n arr << psa_op.index(Index::PSA_WPLUS_NAME)\n arr << psa_op.index(Index::PSA_WMINUS_NAME)\n arr << psa_op.index(Index::PSA_W_NAME)\n arr << psa_op.index(Index::PSA_PPLUS10_NAME) # 110\n arr << psa_op.index(Index::PSA_PPLUS15_NAME)\n arr << psa_op.index(Index::PSA_PPLUSGT15_NAME)\n arr << psa_op.index(Index::PSA_PMINUS10_NAME)\n arr << psa_op.index(Index::PSA_PMINUS15_NAME)\n arr << psa_op.index(Index::PSA_PMINUSGT15_NAME) # 115\n arr << psa_op.index(Index::PSA_VPLUS_NAME)\n arr << psa_op.index(Index::PSA_VMINUS_NAME)\n arr << psa_op.index(Index::PSA_XPLUSPLUS_NAME)\n arr << psa_op.index(Index::PSA_XPLUSMINUS_NAME)\n arr << psa_op.index(Index::PSA_XMINUSMINUS_NAME) # 120\n arr << psa_op.index(Index::PSA_XMINUSPLUS_NAME)\n arr << psa_op.index(Index::PSA_YPLUSPLUS_NAME)\n arr << psa_op.index(Index::PSA_YMINUSMINUS_NAME)\n arr << psa_op.index(Index::PSA_YPLUSMINUS_NAME)\n arr << psa_op.index(Index::PSA_YMINUSPLUS_NAME) # 125\n arr << psa_op.index(Index::PSA_ZPLUS1_NAME)\n arr << psa_op.index(Index::PSA_ZPLUS2_NAME)\n arr << psa_op.index(Index::PSA_ZPLUS3_NAME)\n arr << psa_op.index(Index::PSA_ZMINUS1_NAME)\n arr << psa_op.index(Index::PSA_ZMINUS2_NAME) # 130\n arr << psa_op.index(Index::PSA_ZMINUS3_NAME)\n\n arr\n end",
"def text_indexes\n fields = self.class.text_indexes.keys\n fields.collect{|f| text_indexes_for(f)}.flatten\n end",
"def index\n @master_texts = @project.master_texts.order(Arel.sql(\"LOWER(key)\"))\n # TODO: would be nice to have an index on lower(key), but hard to do without moving schema.sql -- think more on it\n end",
"def index\n @vocabulary_terms = VocabularyTerm.order(:label)\n end",
"def index\n set_index_data\n @text_component = @new_text_component\n end",
"def index\n set_index_data\n @text_component = @new_text_component\n end",
"def index\n authorize Manifestation\n\n @seconds = Benchmark.realtime do\n agent = get_index_agent\n @index_agent = agent\n @count = {}\n if params[:query].to_s.strip == ''\n user_query = '*'\n else\n user_query = params[:query]\n end\n if user_signed_in?\n role_ids = Role.where('id <= ?', current_user.role.id).pluck(:id)\n else\n role_ids = [1]\n end\n\n oldest_pub_date = Manifestation.order(date_of_publication: :asc).where.not(date_of_publication: nil).limit(1).pluck(:date_of_publication).first\n latest_pub_date = Manifestation.order(date_of_publication: :desc).where.not(date_of_publication: nil).limit(1).pluck(:date_of_publication).first\n pub_ranges = []\n if oldest_pub_date and latest_pub_date\n oldest_pub_year = oldest_pub_date.year / 10 * 10\n latest_pub_year = latest_pub_date.year / 10 * 10 + 10\n while(oldest_pub_year < latest_pub_year) do\n pub_ranges << {from: oldest_pub_year, to: oldest_pub_year + 10}\n oldest_pub_year += 10\n end\n end\n\n query = {\n query: {\n filtered: {\n query: {\n query_string: {\n query: user_query, fields: ['_all']\n }\n },\n #filter: {\n # term: {\n # carrier_type: 'dvd'\n # }\n #}\n }\n },\n #filter: {\n # and: [\n # term: {\n # carrier_type: 'dvd'\n # }\n # ]\n #}\n }\n\n body = {\n facets: {\n carrier_type: {\n terms: {\n field: :carrier_type\n }\n },\n library: {\n terms: {\n field: :library\n }\n },\n language: {\n terms: {\n field: :language\n }\n },\n pub_year: {\n range: {\n field: :pub_year,\n ranges: pub_ranges\n }\n }\n }\n# filter: {and: [{}]},\n }\n if params[:carrier_type]\n carrier_type = CarrierType.where(name: params[:carrier_type]).first\n body[:filter][:and] << {term: {carrier_type: carrier_type.name}} if carrier_type\n end\n if params[:library]\n library = Library.where(name: params[:library]).first\n body[:filter][:and] << {term: {library: library.name}} if library\n end\n if params[:language]\n language = Language.where(name: params[:language]).first\n body[:filter][:and] << {term: {language: language.name}} if language\n end\n if params[:pub_date_from] and params[:pub_date_to]\n body[:filter][:and] << {range: {pub_year: {gte: params[:pub_date_from].to_i, lt: params[:pub_date_to].to_i + 1}}}\n end\n search = Manifestation.search(query.merge(body), routing: role_ids)\n @manifestations = search.page(params[:page]).records\n @manifestation_ids = search.results.map(&:id).join(',')\n @count[:total] = search.results.total\n @count[:query_result] = search.results.total\n @query = params[:query]\n flash[:search_query] = Digest::SHA1.hexdigest(Marshal.dump(params[:query]))\n @search_query = flash[:search_query]\n @carrier_type_facet = search.response[\"facets\"][\"carrier_type\"][\"terms\"]\n @library_facet = search.response[\"facets\"][\"library\"][\"terms\"]\n @language_facet = search.response[\"facets\"][\"language\"][\"terms\"]\n @pub_year_facet = search.response[\"facets\"][\"pub_year\"][\"ranges\"]\n @search_engines = SearchEngine.all\n end\n end",
"def update_text_indexes(*fields)\n fields = self.class.text_indexes.keys if fields.empty?\n fields.each do |field|\n options = self.class.text_indexes[field]\n value = self.send(field).to_s\n next if value.length < options[:minlength] # too short to index\n indexes = []\n\n # If values is array, like :tags => [\"a\", \"b\"], use as-is\n # Otherwise, split words on /\\s+/ so :title => \"Hey there\" => [\"Hey\", \"there\"]\n values = value.is_a?(Array) ? value : options[:split] ? value.split(options[:split]) : value\n values.each do |val|\n val.gsub!(/[^\\w\\s]+/,'')\n val.downcase!\n next if value.length < options[:minlength]\n next if self.class.text_index_exclude_list.include? value\n if options[:exact]\n str = val.gsub(/\\s+/, '.') # can't have \" \" in Redis cmd string\n indexes << \"#{options[:key]}:#{str}\"\n else\n len = options[:minlength]\n while len <= val.length\n str = val[0,len].gsub(/\\s+/, '.') # can't have \" \" in Redis cmd string\n indexes << \"#{options[:key]}:#{str}\"\n len += 1\n end\n end\n end\n \n # Also left-anchor the cropped string if \"full\" is specified\n if options[:full]\n val = values.join('.')\n len = options[:minlength]\n while len <= val.length\n str = val[0,len].gsub(/\\s+/, '.') # can't have \" \" in Redis cmd string\n indexes << \"#{options[:key]}:#{str}\"\n len += 1\n end\n end\n\n # Determine what, if anything, needs to be done. If the indexes are unchanged,\n # don't make any trips to Redis. Saves tons of useless network calls.\n old_indexes = text_indexes_for(field)\n new_indexes = indexes - old_indexes\n del_indexes = old_indexes - indexes\n\n # No change, so skip\n # puts \"[#{field}] old=#{old_indexes.inspect} / idx=#{indexes.inspect} / new=#{new_indexes.inspect} / del=#{del_indexes.inspect}\"\n next if new_indexes.empty? and del_indexes.empty?\n\n # Add new indexes\n exec_pipelined_index_cmd(:sadd, new_indexes)\n\n # Delete indexes no longer used\n exec_pipelined_index_cmd(:srem, del_indexes)\n \n # Replace our reverse map of indexes\n redis.set reverse_index_key(field), indexes.join(';')\n end # fields.each\n end",
"def extractData()\n\n @es_client = Elasticsearch::Client.new host: 'http://192.168.59.103:9200/', log: true\n gr = RDF::Vocabulary.new(\"http://purl.org/goodrelations/v1#\")\n s = RDF::Vocabulary.new(\"http://schema.org/address\")\n v = RDF::Vocabulary.new(\"http://www.w3.org/2006/vcard/ns#\")\n l = RDF::Vocabulary.new(\"http://www.linked-usdl.org/ns/usdl-core#\")\n\n company = RDF::Node.new\n addTriple( company , RDF.type, @resume_cv.Company)\n addUSDL(company, RDF.type, gr.BusinessEntity)\n\n # content = @doc.css('div').select{|document| document['id'] == \"inhalt\"}[0]\n company_name = extractAnnotation(\"name\").first\n\n add_annotation(\"name\", company_name)\n # description = @doc.css('div').select{|description| description['id'] == \"text\"}[0]\n\n\n website = extractAnnotation(\"website\").first\n streetAddress = extractAnnotation(\"streetAddress\").first\n postal = extractAnnotation(\"postal\").first\n locality = extractAnnotation(\"locality\").first\n country = extractAnnotation(\"country\").first\n phone = extractAnnotation(\"phone\").first\n mail = extractAnnotation( \"mail\").first\n region = country\n\n extractAnnotation(\"product_categories\").each do |i|\n puts \"i: #{i}\"\n product = RDF::Node.new\n addUSDL(product, RDF.type, gr.ProductOrService)\n addUSDL(product, gr.name, i)\n addUSDL(product, gr.hasManufacturer, company)\n addTriple(company, @resume_cv.produces, i)\n end\n\n extractAnnotation(\"produces\").each do |i|\n puts \"prodcat2 : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n\n addTriple(company, @resume_cv.sells , i)\n end\n\n extractAnnotation(\"distr_category\").each do |i|\n puts \"distcat : #{i}\"\n addUSDL(company, gr.category, i)\n addTriple(company, @resume_cv.distribution_type, i)\n end\n\n extractAnnotation(\"distributes_for\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distribution_for, i)\n addTriple(company, @resume_cv.distribution_for, i)\n end\n\n extractAnnotation(\"provides\").each do |i|\n puts \"provcat : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n addTriple(company, @resume_cv.hasSpeciality , i)\n end\n\n extractAnnotation(\"distributed_by\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distributed_by, i)\n addTriple(company, @resume_cv.distributed_by, i)\n end\n\n # addTriple(company , @resume_cv.isIndustry, industry)\n # addUSDL(company, gr.category, industry)\n # addTriple(company, @resume_cv.hasSpeciality, s)\n addTriple(company , @resume_cv.hasWebsite, website)\n addUSDL(company, RDF::FOAF.page, website)\n addTriple( company , @resume_cv.name, company_name)\n addUSDL( company, gr.legalName, company_name)\n # # addTriple(company , @resume_cv.hasType, type)\n # # addTriple(company , @resume_cv.wasFounded, founded)\n # # addTriple(company , @resume_cv.hasSize, compsize)\n address = RDF::Node.new\n addUSDL(address, RDF.type , v.Address)\n addUSDL(company, l.hasCommunicationChannel, address)\n\n telephone = RDF::Node.new\n addUSDL(telephone, RDF.type, v.Voice)\n addUSDL(telephone, v.hasValue, phone)\n\n addUSDL(address, v.country_name, country)\n addUSDL(address, v.locality, locality)\n addUSDL(address, v.postal_code, postal )\n addUSDL(address, v.street_address, streetAddress)\n addUSDL(address, v.has_email ,mail)\n\n addTriple(company , @resume_cv.hasLocality, locality)\n addTriple(company , @resume_cv.hasStreetAddress, streetAddress)\n addTriple(company , @resume_cv.locatedInRegion, region)\n addTriple(company , @resume_cv.postalCode, postal)\n addTriple(company , @resume_cv.country, country)\n\n add_annotation( \"locality\", locality)\n add_annotation( \"street\" , streetAddress)\n add_annotation( \"postal\" , postal)\n add_annotation( \"country\", country)\n add_annotation( \"phone\", phone)\n add_annotation( \"mail\" , mail)\n\n company_name\n end",
"def affected(text)\n occurrences = lines.each_index.select do |i|\n lines[i].start_with?(\"+\") && text.any? { |t| lines[i].include? t }\n end\n occurrences.map do |occ|\n lines[2..occ].reverse.find { |l| l.start_with? \"Index: \" }[7..]\n end\n end",
"def formats_idx; end",
"def add_index(key)\n puts \"\\nWriting out index...\"\n start_new_page\n fix_margins\n @pdf.stop_columns\n @pdf.text \"<b>Index of Presenters, Mentors and Moderators</b>\", :font_size => 16\n @pdf.start_columns(3)\n @pdf.top_margin = @@TOP_MARGIN + 42\n current_letter = nil\n for item, pages in @indexes[key].sort_by{|k,v| k.to_s.downcase}\n if current_letter != item[0..0].downcase\n move_to_newline(nil, true)\n current_letter = item[0..0].downcase\n fix_margins\n @pdf.text \"<b>#{current_letter.upcase}</b>\", :font_size => 12\n fix_margins\n move_to_newline(18)\n end\n fix_margins\n # @pdf.add_text @x, @pdf.y, \"#{item} #{pages.uniq.join(\", \")}\", 9\n @size = 9\n parse_and_add_text(\"#{item} #{pages.uniq.join(\", \")}\", \"||\", :left, 10, 20)\n move_to_newline(10)\n end\n end",
"def visionLabels\n @labels = @json[\"responses\"][0][\"labelAnnotations\"]\n @label_descriptions = []\n @label_scores = []\n @labels.each do |label|\n @label_descriptions << label[\"description\"]\n @label_scores << label[\"score\"] * 100\n end\n end",
"def index\n @applied_labels = AppliedLabel.all\n end",
"def hash\n [range_start_index, range_end_index, fallback_font_list].hash\n end",
"def index\n @counter_words = {}\n end",
"def index_versions!\n Rails.logger.info \"Updating Solr docs with Version data at #{Time.zone.now}\"\n Version.all.each do |version|\n names = (version.imported_metadata['related_name_display'] || []) + (version.imported_metadata['author_display'] || []).uniq\n update_related_names(version.book.digital_cico_number, names) if names.present?\n end\n solr.commit\n Rails.logger.info \"Done updating Solr docs with Version data at #{Time.zone.now}\"\n end",
"def generate\n Dixi.logger.info \"Generating index for #{@project}\"\n\n @entries = {}\n\n require 'find'\n Find.find( @project.version_dir.to_s ) do |path|\n if path =~ /index\\.yaml/\n Find.prune\n elsif path =~ /\\.yaml/\n res = Dixi::Resource.from_filepath(@project, Pathname.new(path))\n self.add( res )\n end\n end\n\n save!\n @loaded = true\n\n @entries\n end",
"def locale_idx; end",
"def index\n # @results = []\n # @document.bioc_doc.all_relations.each do |a|\n # e = EntityUtil.get_relation_entity(a)\n # a.locations.each do |l|\n # @results << {did: @document.did, offset: l.offset, text: a.text, length: l.length, infons: a.infons }\n # end\n # end\n @project = @document.project\n @version = params[:version] || @document.version\n @version = @version.to_i if @version.present?\n @is_manager = @project.manager?(current_user)\n\n if @is_manager\n @relations = @document.relations.where('`version`=?', @version)\n else\n @relations = @assign.relations\n end\n @relations = @relations.order(\"offset\")\n end",
"def index_ontology_terms_from_cache( doc, term_conf, cached_data )\n [:term,:term_name].each do |term_or_name|\n cached_data[term_or_name].each do |target|\n doc[ term_conf[\"idx\"][term_or_name.to_s].to_sym ].push( target )\n end\n doc[ term_conf[\"idx\"][\"breadcrumb\"].to_sym ].push( cached_data[term_or_name].join(\" | \") )\n end\n end",
"def initialize(matching_index, pointer)\n # Matching files with other indexes than CRC\n # map< ( file_info | segment_info ), matching_pointer_info >\n # map< ( FileInfo | SegmentInfo ), MatchingIndexSinglePointer >\n @matching_files = {}\n @crc_matching_files = {}\n @score_max = compute_score_max(pointer)\n # First find CRC matching files\n if (matching_index.indexes.has_key?(:crc))\n matching_index.indexes[:crc].each do |data, lst_pointers|\n @crc_matching_files.concat(lst_pointers)\n end\n end\n # Then all other indexes\n matching_index.indexes.each do |index_name, index_data|\n if (index_name != :crc)\n index_data.each do |data, lst_pointers|\n lst_pointers.each do |matching_pointer|\n if (!@crc_matching_files.has_key?(matching_pointer))\n @matching_files[matching_pointer] = MatchingIndexSinglePointer.new if (!@matching_files.has_key?(matching_pointer))\n @matching_files[matching_pointer].score += COEFFS[index_name]\n @matching_files[matching_pointer].indexes[index_name] = [] if (!@matching_files[matching_pointer].indexes.has_key?(index_name))\n @matching_files[matching_pointer].indexes[index_name] << data\n end\n end\n end\n end\n end\n matching_index.segments_metadata.each do |segment_ext, segment_ext_data|\n segment_ext_data.each do |metadata_key, metadata_data|\n metadata_data.each do |metadata_value, lst_pointers|\n lst_pointers.each do |matching_pointer|\n if (!@crc_matching_files.has_key?(matching_pointer))\n @matching_files[matching_pointer] = MatchingIndexSinglePointer.new if (!@matching_files.has_key?(matching_pointer))\n @matching_files[matching_pointer].score += COEFF_SEGMENT_METADATA\n @matching_files[matching_pointer].segments_metadata[segment_ext] = {} if (!@matching_files[matching_pointer].segments_metadata.has_key?(segment_ext))\n @matching_files[matching_pointer].segments_metadata[segment_ext][metadata_key] = [] if (!@matching_files[matching_pointer].segments_metadata[segment_ext].has_key?(metadata_key))\n @matching_files[matching_pointer].segments_metadata[segment_ext][metadata_key] << metadata_value\n end\n end\n end\n end\n end\n # Find matching blocks' CRC sequences\n lst_crc = (pointer.is_a?(FileInfo) ? pointer.crc_list : pointer.segment.crc_list)\n @matching_files.each do |matching_pointer, matching_info|\n if (matching_info.indexes.has_key?(:block_crc))\n lst_common_crc = matching_info.indexes[:block_crc]\n # Get the list of blocks' CRC from the file\n lst_matching_crc = (matching_pointer.is_a?(FileInfo) ? matching_pointer.crc_list : matching_pointer.segment.crc_list)\n # Parse the original file and get to a matching CRC\n idx_crc = 0\n while (idx_crc < lst_crc.size)\n while ((idx_crc < lst_crc.size) and\n (!lst_common_crc.include?(lst_crc[idx_crc])))\n idx_crc += 1\n end\n if (idx_crc < lst_crc.size)\n first_crc = lst_crc[idx_crc]\n # We are at the beginning of a sequence in the original file.\n smallest_sequence_size = lst_crc.size - idx_crc\n # Find all the occurences of this sequence in the matching file.\n lst_matching_crc.each_with_index do |matching_crc, idx_matching_crc|\n if (matching_crc == first_crc)\n # We are at the beginning of a sequence in the matching file\n idx_sequence = 1\n # Get the matching sequence\n matching_sequence = [first_crc]\n while ((idx_crc+idx_sequence < lst_crc.size) and\n (idx_matching_crc+idx_sequence < lst_matching_crc.size) and\n (lst_crc[idx_crc+idx_sequence] == lst_matching_crc[idx_matching_crc+idx_sequence]))\n matching_sequence << lst_crc[idx_crc+idx_sequence]\n idx_sequence += 1\n end\n if (matching_sequence.size > 1)\n # There is a matching sequence\n offset = idx_crc*FileInfo::CRC_BLOCK_SIZE\n matching_info.block_crc_sequences[offset] = {} if (!matching_info.block_crc_sequences.has_key?(offset))\n matching_info.block_crc_sequences[offset][idx_matching_crc*FileInfo::CRC_BLOCK_SIZE] = matching_sequence\n smallest_sequence_size = matching_sequence.size if (matching_sequence.size < smallest_sequence_size)\n # For each successful sequence, increase the score\n matching_info.score += (COEFF_BLOCK_CRC_SEQUENCE * matching_sequence.size)\n end\n end\n end\n idx_crc += smallest_sequence_size\n end\n end\n end\n end\n end",
"def indexes\n keys = Ticker::INDEX.keys\n\n keys.each_with_object({}) do |index, hash|\n Ticker.send(index).full_performance.each do |key, value|\n hash[\"#{index}_#{key}\"] = value.to_s + '%'\n end\n end\n end",
"def indexes\n keys = Ticker::INDEX.keys\n\n keys.each_with_object({}) do |index, hash|\n Ticker.send(index).full_performance.each do |key, value|\n hash[\"#{index}_#{key}\"] = value.to_s + '%'\n end\n end\n end"
] | [
"0.5672804",
"0.5596004",
"0.5365592",
"0.5259642",
"0.5251661",
"0.5234646",
"0.5134985",
"0.5097468",
"0.5095543",
"0.49989572",
"0.49847534",
"0.49847534",
"0.49391136",
"0.49298456",
"0.4929787",
"0.49023813",
"0.48817268",
"0.48682404",
"0.48680332",
"0.4862281",
"0.48610207",
"0.48502004",
"0.48307616",
"0.48294932",
"0.48286217",
"0.4825518",
"0.48187506",
"0.4816376",
"0.48079064",
"0.48079064"
] | 0.6080244 | 0 |
Build an instance of PhoneNumberInstance | def get_instance(payload)
PhoneNumberInstance.new(@version, payload)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instance(payload)\n PhoneCallInstance.new(@version, payload, )\n end",
"def initialize(phone)\n @phone = phone\n end",
"def initialize(prefix = Address.new.phone_prefix, number = nil, extension = nil)\n @prefix = prefix.gsub(/\\A0/,\"\")\n\n if number\n @number = number\n elsif landline?\n @number = ([rand(2..9).to_s] + (rand(3..7).times.collect{rand(0..9).to_s})).join(\"\")\n else\n @number = ([rand(2..9).to_s] + (7.times.collect{rand(0..9).to_s})).join(\"\")\n end\n\n @extension = extension.to_s\n end",
"def register_phone_number(phone_number, options = {})\n phone = Phone.find_or_create_by_number(phone_number)\n phone.update_attribute(:last_account_id, @registration_account.id) if options[:set_last_account]\n return phone\n end",
"def get\n PhoneNumber.get self\n end",
"def phonenumber_with_extension(extension)\n Phonenumber.new(prefix, number, extension)\n end",
"def phone_number\n element_with_value('PhoneNumber', opts[:phone_number])\n end",
"def phone_number\n element_with_value('PhoneNumber', opts[:phone_number][0..14])\n end",
"def create\n @number = Number.new(number_params)\n\n if !@number.business_number.blank?\n @number.business_number = \"+1\"+Phony.normalize(@number.business_number) \n end\n\n begin \n @client = Twilio::REST::Client.new BwCallTracking::Application.config.account_sid, BwCallTracking::Application.config.auth_token \n number = @client.account.incoming_phone_numbers.create(:area_code => @number.area_code[1..3], :voice_url => BwCallTracking::Application.config.voice_url, :status_callback => BwCallTracking::Application.config.voice_url)\n @number.tracking_number = number.phone_number\n rescue StandardError => e\n puts \"ERROR: \"+e.message \n end \n\n respond_to do |format|\n if @number.save\n format.html { redirect_to numbers_url, notice: 'Number was successfully created.' }\n format.json { render :show, status: :created, location: @number }\n else\n format.html { render :new }\n format.json { render json: @number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def phone\n @phone ||= Phone::Gateway.new(client)\n end",
"def create\n @number = Number.new(number_params)\n\n if !@number.business_number.blank?\n @number.business_number = \"+1\"+Phony.normalize(@number.business_number) \n end\n\n begin \n\n numbers = Bandwidth::AvailableNumber.search_local({:area_code => @number.area_code[1..3]})\n \n if numbers.count > 0\n # buy the phone number\n number = Bandwidth::PhoneNumber.create({:number => numbers[0][:number], :applicationId => ENV[\"BANDWIDTH_APP_ID\"]})\n\n # assign the phone number to your app id\n @number.tracking_number = number.number\n @number.bw_id = number.id\n \n end\n\n rescue StandardError => e\n puts \"ERROR: \"+e.message\n raise \"There was a problem setting up your number. Try again.\" \n end \n\n respond_to do |format|\n if @number.save\n format.html { redirect_to numbers_url, notice: 'Number was successfully created.' }\n format.json { render :show, status: :created, location: @number }\n else\n format.html { render :new }\n format.json { render json: @number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end",
"def add_phone_number(type, number)\n phone_number = PhoneNumber.new\n phone_number.type = type\n phone_number.number = number\n #once we have that we need to append it to the internal @phone_numbers array with:\n phone_numbers.push(phone_number)\n end",
"def mutate_phone_number(_)\n Faker::PhoneNumber.phone_number\n end",
"def create\n @phone_number = @kontact_information.phone_numbers.build(params[:phone_number])\n respond_to do |format|\n if @phone_number.save\n flash[:notice] = 'Phone number was successfully created.'\n format.html { redirect_to(@phone_number) }\n format.mobile {redirect_to profile_kontact_kontact_information_plural_fields_path(@profile, @kontact)}\n format.xml { render :xml => @phone_number, :status => :created, :location => @phone_number }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @phone_number.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def find_or_create_phone_number(phone_text, options={})\n phone = phone_klass.find_and_create_by_number(phone_text)\n phone.assign_carrier(options[:carrier]) if options[:carrier]\n phone\n end",
"def get_instance(payload)\n NumberInstance.new(@version, payload, )\n end",
"def number_fetch(number)\n Number.new(number_request(:get, \"phone-numbers/#{number}\"))\n end",
"def shape_phone_number\n self.phone_number = twilio_format phone_number\n end",
"def initialize(user)\n @sms_client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)\n @lookup_client = Twilio::REST::LookupsClient.new(ACCOUNT_SID, AUTH_TOKEN)\n @phone_number = user.phone_number\n end",
"def set_PhoneNumber(value)\n set_input(\"PhoneNumber\", value)\n end",
"def new\n @phone = Phone.new\n end",
"def phone_number_field\n $tracer.trace(__method__)\n #unit_test_no_generate: phone_number_field, input.id(\"PhoneNumber\")\n return ToolTag.new(input.id(\"PhoneNumber\"), __method__, self)\n end",
"def set_phone_num\n @phone_num = PhoneNum.find(params[:id])\n end",
"def build_twilio_wrapper\n @twilio_wrapper = ::VoiceExtension::TwilioVoiceWrapper::Voice.new\n end",
"def new\n #@phone = Phone.new\n \n end",
"def number(twilio=false, name=nil, area_code=nil)\n if twilio\n # Check if twilio configuration exists. If not throw and errors because twilio was passed as true.\n if !@config[:configuration][:twilio].blank? and (!@config[:configuration][:twilio][:account_id].blank? and !@config[:configuration][:twilio][:api_key].blank?)\n account = @config[:configuration][:twilio][:account_id]\n key = @config[:configuration][:twilio][:api_key]\n\n # Initialize twilio client.\n twilio = Twilio::REST::Client.new account, key\n\n # If any area code is provide look for local numbers, if not get a toll free.\n if area_code.blank?\n available_numbers = twilio.account.available_phone_numbers.get('US').toll_free.list\n else\n available_numbers = twilio.account.available_phone_numbers.get('US').local.list(area_code: area_code) unless area_code.blank?\n end\n\n # Select the first number available.\n available_number = available_numbers.first\n\n # If available numbers is blank throw an error because something went wrong.\n if available_numbers.blank?\n raise StandardError, \"No Available Numbers\"\n else\n\n # Convert the phone number into something a artificial voice can say.\n phone_number = available_number.phone_number.gsub(\"+1\",\"\")\n phone_number = \"#{phone_number[0..2]}-#{phone_number[3..5]}-#{phone_number[6..10]}\"\n\n\n # Setting the transciption email\n # email = @config[:configuration][:twilio][:transcription_email].blank? ? \"developers%40level.agency\" : @config[:configuration][:twilio][:transcription_email]\n email = \"developers%40level.agency\"\n # Put together the voicemail Twimil.\n voice_message = \"http://twimlets.com/voicemail?Email=#{email}&Message=You%20reached%20the%20voicemail%20box%20of%20#{phone_number}.%20%20Please%20leave%20a%20message%20after%20the%20beep.&Transcribe=true&\"\n\n # Here we buy the number, set the voice_url to the voicemail Twimil and set the\n # sms_url to echo so Twilio will capture the message but not reply to it.\n number = twilio.account.incoming_phone_numbers.create({\n phone_number: available_number.phone_number,\n friendly_name: name,\n voice_url: voice_message,\n voice_method: \"GET\",\n sms_url: \"http://twimlets.com/echo?Twiml=%3CResponse%3E%3C%2FResponse%3E\",\n sms_method: \"GET\"\n })\n\n # If number is blank throw and error because something went wrong.\n if number.blank?\n raise StandardError, \"Unable to allocate Twilio number\"\n else\n number.phone_number\n end\n end\n else\n raise ArgumentError, \"Cannot find Twilio Account ID and API key in configuration\"\n end\n else\n Faker::PhoneNumber.phone_number\n end\n end",
"def phone_number; end",
"def phone_number; end"
] | [
"0.64506793",
"0.63382",
"0.6279368",
"0.6224359",
"0.61491865",
"0.6139333",
"0.612227",
"0.6105795",
"0.60165995",
"0.60073644",
"0.59386724",
"0.5908376",
"0.59075874",
"0.5867394",
"0.58635527",
"0.5844259",
"0.5799482",
"0.57856536",
"0.5783605",
"0.5729937",
"0.5727775",
"0.5719864",
"0.5706157",
"0.56969446",
"0.56630266",
"0.56524026",
"0.56480867",
"0.5629288",
"0.56292564",
"0.56292564"
] | 0.7626814 | 1 |
Returns an array of all users with the specified campus code. Takes the code as a string. The array is shuffled so that with_campus_code('code')[0] will be a random selection from the list of matching users. | def with_campus_code(code)
self.find_all{|user| user[1][:campus_code]==code }.shuffle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_courses_by_code(org_unit_code)\n all_courses = get_all_courses\n courses = []\n all_courses.each do |course|\n courses.push(course) if course[\"Code\"].downcase.include? org_unit_code.to_s.downcase\n end\n courses\nend",
"def show\n @users = User.where(:invite_code => @invitecode.name)\n\n end",
"def users\n signups.map do |signup|\n user_id = signup.user_id\n User.all.find {|user| user.id == user_id}\n end\n end",
"def getUserData(code)\n\t\t\t\taccessUri = URI::HTTP.build(\n\t\t\t\t\t:host => @options['api_host'],\n\t\t\t\t\t:path => @options['access_token_path'],\n\t\t\t\t\t:query => {\n\t\t\t\t\t\t:code => code,\n\t\t\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t\t\t\t:grant_type => \"authorization_code\",\n\t\t\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t\t\t:client_secret => @options['client_secret'],\n\t\t\t\t\t}.to_query\n\t\t\t\t)\n\n\t\t\t\taccessRequest = JSON.parse Net::HTTP.post_form(accessUri, []).body\n\n\t\t\t\tgetCurrentUserUri = URI::HTTP.build(\n\t\t\t\t\t:host => @options['api_host'],\n\t\t\t\t\t:path => @options[\"method_url_path\"],\n\t\t\t\t\t:query => {\n\t\t\t\t\t\t:access_token => accessRequest['access_token'],\n\t\t\t\t\t\t:application_key => @options['application_key'],\n\t\t\t\t\t\t:method => \"users.getCurrentUser\",\n\t\t\t\t\t\t:sig => self.getSig(accessRequest['access_token'])\n\t\t\t\t\t}.to_query\n\t\t\t\t)\n\n\t\t\t\tJSON.parse Net::HTTP.get_response(getCurrentUserUri).body\n\t\t\tend",
"def get_user_data(code)\n\t\taccess_uri = URI::HTTP.build(\n\t\t\t:host => @options['api_host'],\n\t\t\t:path => @options['access_token_path'],\n\t\t\t:query => {\n\t\t\t\t:code => code,\n\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t\t:grant_type => \"authorization_code\",\n\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t:client_secret => @options['client_secret'],\n\t\t\t}.to_query\n\t\t)\n\n\t\taccess_request = JSON.parse Net::HTTP.post_form(access_uri, []).body\n\n\t\tcurrent_user_uri = URI::HTTP.build(\n\t\t\t:host => @options['api_host'],\n\t\t\t:path => @options[\"method_url_path\"],\n\t\t\t:query => {\n\t\t\t\t:access_token => access_request['access_token'],\n\t\t\t\t:application_key => @options['application_key'],\n\t\t\t\t:method => \"users.getCurrentUser\",\n\t\t\t\t:sig => self.get_sig(access_request['access_token'])\n\t\t\t}.to_query\n\t\t)\n\n\t\tresponse = JSON.parse Net::HTTP.get_response(current_user_uri).body\n\n\t\tif response.nil?\n\t\t\tnil\n\t\telse \n\t\t\tresponse\n\t\tend\n\tend",
"def index\n @users = User.all.page(params[:page]).order(code: :asc)\n end",
"def getUsers( num_users = nil )\n\n #get all users\n users = (@min_user..@max_user).to_a\n \n #limit if necessary\n if num_users\n users = users.sample( num_users )\n end\n \n #return\n users\n \n end",
"def get_students\n StudentInCourse.where(:course_id => id).collect(&:user_id)\n end",
"def fremont_users\n\ttmp = Array.new\n\tres = Array.new\n\ti = 0\n\twhile (tmp = TOKEN.get('/v2/campus/7/users', params: { page: i, per_page: 100 }).parsed).length > 0\n\t\tputs 'user request page is ' + i.to_s\n\t\ttmp.each do |page|\n\t\t\tres.push(page)\n\t\tend\n\t\ti += 1\n\tend\n\treturn res\nend",
"def unique_campuses_old\n unless @unique_campuses\n res = lambda {::Campus.find(campus_ids)}\n @unique_campuses = (Rails.env.production? ? Rails.cache.fetch([self, 'unique_campuses']) {res.call} : res.call)\n end\n return @unique_campuses\n end",
"def list_users(page, filter = nil)\n return unless filter.nil? || filter.valid?\n\n user_values = User.all(self).values\n users = user_values.select { |u| filter.include?(u) } unless filter.nil?\n users_filtered, pagination_collection = Pagination.paginate_record(users, page, 10)\n [users_filtered, pagination_collection]\n end",
"def get_user_data(code)\n\t\taccess_uri = URI::HTTPS.build(:host => @options['auth_host'], :path => @options['access_token_path'])\n\t\tparams = {\n\t\t\t'client_id' => @options['client_id'],\n\t\t\t'client_secret' => @options['client_secret'],\n\t\t\t'redirect_uri' => @options['redirect_uri'],\n\t\t\t'code' => code\n\t\t}\n\n\t\taccess_request = JSON.parse Net::HTTP.post_form(access_uri, params).body\n\n\t\treturn nil if access_request['access_token'].nil? && access_request['user_id'].nil?\n\n\t\tcurrent_user_uri = URI::HTTPS.build(:host => @options['api_host'], :path => @options[\"method_url_path\"])\n\n\t\tresponse = JSON.parse Net::HTTP.post_form(current_user_uri, {'fields' => @options['user_fields'], 'uid' => access_request['user_id']}).body\n\n\t\treturn nil if response.nil?\n\t\tresponse\n\tend",
"def ids_by_tournament_code tournament_code\n perform_request api_url \"matches/by-tournament-code/#{tournament_code}/ids\"\n end",
"def get_user_data(users, username)\n user_array = []\n users.each do |user|\n if user['username'] == username\n user_array << user['name']\n user_array << user['username']\n user_array << user['password']\n user_array << user['admin']\n end\n end\n return user_array\nend",
"def show\n @user_list= []\n \n @customtable = CustomeTable.where(:identifier_id => @hackathon.id)\n @reguser = Registration.where(:hackathon_id => @hackathon.id)\n \n @reguser.each do |user| \n u = User.find(user.userId)\n @user_list.push(u.user_name)\n end\n end",
"def read_owners(config, org_guid)\n user_setup_obj = UsersSetup.new(config)\n\n users_list = []\n users = @client.organization(org_guid).managers\n\n users.each do |user|\n user_guid = user.guid\n username = user_setup_obj.get_username_from_guid(user_guid)\n users_list << Users::User.new(username, 'owner', false, user_guid)\n end\n\n users_list\n end",
"def users_lookup(user_id_array, is_use_cache: true)\n users, last_update_time = self.users_lookup_ex(user_id_array, is_use_cache: is_use_cache)\n return users\n end",
"def find_by_code(code)\n countries.find { |country| country['code'] == code }\n end",
"def list_students_by(year=Date.today.to_s[0,4])\n\t\t#pesquisar por ano e depois pedir os alunos\n\n\t\tclassroom = Classroom.find(:first, :conditions => \"year='#{year}' AND name='#{self.name}'\" )\t\t\n\t\treturn classroom.students\n\tend",
"def users\n User.in_teams(self.teams.pluck(:id))\n end",
"def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.where(\"verified = 1\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n end\n end\n end",
"def getAllApprovedUsers()\n users = [] \n docs = @usersColl.find({ \"approval_status.code\" => 1 }, { :username => 1 })\n index = 0\n docs.each do |doc|\n users[index] = doc[:username]\n index += 1\n end # End of docs iteration\n return users\n end",
"def students\n course_enrollments.where(course_role: CourseRole.student).map(&:user)\n end",
"def get_users(count=42, offset=0)\n # Build a Filter String with a corresponding array of\n # prepared filters for the sql execution\n # (prepared statements prevent sql injection)\n prepared_filters = []\n filter_string = \"\"\n\n ALLOWED_FILTERS.each do |filter_name|\n if params.has_key?(filter_name) && \"All\" != params[filter_name]\n filter_string += \" AND #{filter_name} LIKE ?\"\n prepared_filters << params[filter_name]\n end\n end\n\n # If no user filters provided we will defalt to California\n filter_string = \"AND location LIKE '%CALIFORNIA%'\" if filter_string.empty?\n\n prepared_filters << count.to_i\n prepared_filters << offset.to_i\n\n # Connect to the database\n Database.new.execute(\n \"SELECT pictures.username,\n pictures.url,\n profiles.created_at,\n profiles.location\n FROM pictures\n JOIN profiles ON profiles.username = pictures.username\n WHERE size = 'small' #{filter_string}\n ORDER BY profiles.created_at DESC\n LIMIT ? OFFSET ?\",\n prepared_filters\n )\n end",
"def get_user_list\n return User.find(:all, :order => 'last_name ASC').collect {|user| [user.full_name, user.id]}\n end",
"def users\n Section.find_roles.pluck(:name).inject(Array.new) do |result, role|\n result += User.with_role(role, self)\n end.uniq\n end",
"def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend",
"def get_users_from_api(page: 0, q: @q)\n LOGGER.info \"extractor processing page #{page} of #{@total_pages}\"\n begin\n users = @auth0.get_users(\n per_page: @total_records < PER_PAGE ? @total_records : PER_PAGE,\n page: page,\n sort: \"created_at:1\",\n include_totals: true,\n q: q\n )[\"users\"]\n\n json_to_array(users)\n rescue StandardError => ex\n @logger.warn ex\n end\n end",
"def get_students\n registrations.select{|r| !r.instructor}.map{|r| r.user}\n end",
"def staff\n [\n \"jessicacroysdale@yahoo.com\", \n \"margynewton@comcast.net\", \n \"brantallen@earthlink.net\", \n \"ksunmark@yahoo.com\", \n \"gorakr@comcast.net\", \n \"lhpilcher@frontier.com\", \n \"mmr@brantallen.com\", \n \"manbeardo@gmail.com\", \n \"jcermak53@gmail.com\"\n ]\nend"
] | [
"0.5995328",
"0.5387189",
"0.5054169",
"0.5042612",
"0.50276196",
"0.49935037",
"0.49935",
"0.49561834",
"0.49471974",
"0.49309725",
"0.49127328",
"0.49103442",
"0.4897226",
"0.48948523",
"0.4870965",
"0.48644084",
"0.48505172",
"0.48126933",
"0.4803131",
"0.4784939",
"0.4780767",
"0.47722962",
"0.47617346",
"0.4747148",
"0.47302973",
"0.47203216",
"0.46948025",
"0.4690463",
"0.46728283",
"0.46657413"
] | 0.78927916 | 0 |
Returns an array of all users with the specified affiliation type. Takes the type name as a string. The array is shuffled so that with_affiliation_type('type name')[0] will be a random selection from the list of matching users. | def with_affiliation_type(type)
self.find_all{|user| user[1][:affiliation_type]==type }.shuffle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n if params._type_filter != 'all'\n store.users.where(graduation_year: \"#{params._type_filter}\").all\n else\n store.users.all\n end\n end",
"def find_users_of_type(group_type)\n begin\n Skype.groups.find { |g| g.gtype == group_type}.users\n rescue Exception => e\n puts e.message\n end\n end",
"def populate_user_pool(user, type)\n case type\n when 'iso'\n @iso_users << user\n when 'agent'\n @agent_users << user\n end\n end",
"def affiliate_account_types\n @affiliate_account_types ||= []\n end",
"def index\n @typeofusers = Typeofuser.all\n end",
"def searchUsers\n # if current_user.rolable.class.name == \"Charity\"\n # return User.where.not(rolable_type: 'Business')\n # # list_a = User.where(rolable_type: 'Business').order(:rolable_id).pluck(:id, :rolable_id)\n # # search_list = Business.order(:id).pluck(:id, :name)\n\n # # search_list.each_with_index do |x, index|\n # # x[0] = list_a[index][0]\n # # end\n # # sea\n # # search_list = Business.where(active: true).pluck(:name)\n # # search_list.each do |b|\n # # list << b.name\n # # current_user\n # elsif current_user.rolable.class.name == \"Business\"\n # return User.where(rolable_type: 'Charity')\n # # list_a = User.where(rolable_type: 'Charity').order(:rolable_id).pluck(:id, :rolable_id)\n # # search_list = Charity.order(:id).pluck(:id, :name)\n # # search_list.each_with_index do |x, index|\n # # x[0] = list_a[index][0]\n # # end\n # # # search_list.each do |c|\n # # # list << c.name\n # # # end\n # end\n return User.where.not(rolable_type: 'Donor')\n end",
"def find_all_members type = :all\n case type\n when :all\n\n when :users\n\n when :groups\n\n else\n throw \"Invalid argument\"\n end\n end",
"def index\n @users = User.where(user_type: \"user\").all\n end",
"def index\n check_user\n if @user['u_type'] == 1\n @users = User.all\n elsif @user['u_type'] == 2\n @users = User.where.not(u_type: [1])\n end\n\n end",
"def users\n company_ids = [self.id]\n company_ids += advisor_company_ids if advised?\n\n user_ids = UserAffiliation.where(:company_id.in => company_ids).with_access.only(:user_id).map(&:user_id)\n User.where(:id.in => user_ids).order_by(created_at: :asc)\n end",
"def any_user *types\n types = types.flatten.select_labels.map(&:to_sym)\n types = types & ::CanTango.config.users.registered\n users = types.map do |type|\n meth = :\"current_#{type}\"\n send(meth) if respond_to?(meth) && (types.empty? || types.include?(type))\n end\n chosen_user = users.compact.first\n chosen_user || guest_user\n end",
"def list_users(page, filter = nil)\n return unless filter.nil? || filter.valid?\n\n user_values = User.all(self).values\n users = user_values.select { |u| filter.include?(u) } unless filter.nil?\n users_filtered, pagination_collection = Pagination.paginate_record(users, page, 10)\n [users_filtered, pagination_collection]\n end",
"def using_affiliate?(account_type)\n affiliate_account_types.include?(account_type.to_s.classify)\n end",
"def getUsers( num_users = nil )\n\n #get all users\n users = (@min_user..@max_user).to_a\n \n #limit if necessary\n if num_users\n users = users.sample( num_users )\n end\n \n #return\n users\n \n end",
"def get_affiliations\n affiliations\n end",
"def users\n Section.find_roles.pluck(:name).inject(Array.new) do |result, role|\n result += User.with_role(role, self)\n end.uniq\n end",
"def index\n @user_types_map = User.user_types.map{|k, v| [k, v.humanize.pluralize]}.to_h\n @filter = params[:filter] || 'Current'\n if @filter == 'All'\n @users = User.order(:email)\n elsif @user_types_map.values.include? @filter\n @users = User.where(locked_out: false, user_type: @user_types_map.key(@filter)).order(:email)\n else\n @users = User.where(locked_out: false).order(:email)\n end\n end",
"def all_by_name_and_type(name, type)\n where(name: name, array_type: type).order_by(&:array_index).to_a\n end",
"def get_users(count=42, offset=0)\n # Build a Filter String with a corresponding array of\n # prepared filters for the sql execution\n # (prepared statements prevent sql injection)\n prepared_filters = []\n filter_string = \"\"\n\n ALLOWED_FILTERS.each do |filter_name|\n if params.has_key?(filter_name) && \"All\" != params[filter_name]\n filter_string += \" AND #{filter_name} LIKE ?\"\n prepared_filters << params[filter_name]\n end\n end\n\n # If no user filters provided we will defalt to California\n filter_string = \"AND location LIKE '%CALIFORNIA%'\" if filter_string.empty?\n\n prepared_filters << count.to_i\n prepared_filters << offset.to_i\n\n # Connect to the database\n Database.new.execute(\n \"SELECT pictures.username,\n pictures.url,\n profiles.created_at,\n profiles.location\n FROM pictures\n JOIN profiles ON profiles.username = pictures.username\n WHERE size = 'small' #{filter_string}\n ORDER BY profiles.created_at DESC\n LIMIT ? OFFSET ?\",\n prepared_filters\n )\n end",
"def get_sample_user\n user = case params[:type]\n when \"registered\"; User.registered.sample\n when \"pending\"; User.pending.sample\n when \"active\"; Participation.active.sample.user\n when \"unregistered\"; User.initialized.sample\n else User.order(\"RAND()\").first\n end\n render :json => user.attributes_for_app\n end",
"def index\n #@users = User.all\n @users = User.paginate(page: params[:page], per_page: 10) #.where(:type => params[:type])\n end",
"def all_users\n Skype.find_users_of_type \"ALL_USERS\"\n end",
"def joined_by_type(type)\n\t\tArray(self.joined.find_all_by_joinable_type(type))\n\tend",
"def listing(type, **params)\n params[:t] = params.delete(:time) if params.key?(:time)\n @client.model(:get, \"/user/#{get_attribute(:name)}/#{type}.json\", params)\n end",
"def listing(type, **params)\n params[:t] = params.delete(:time) if params.key?(:time)\n @client.model(:get, \"/user/#{get_attribute(:name)}/#{type}.json\", params)\n end",
"def affiliation\n []\n end",
"def all_affiliations\n @all_affiliations ||= TeamAffiliation.joins(:season).where( \"seasons.season_type_id = #{season.season_type_id}\" )\n end",
"def export_users_fields\n case params[:type]\n when 'SALE'\n User.seller\n when 'CANDIDATE'\n User.hh\n end\n end",
"def all_active_directory_users\n filter = Net::LDAP::Filter.construct(\n '(&(objectCategory=organizationalPerson)(givenName=*)(sn=*)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))')\n entries = OP_CONN.search(filter: filter)\n users = []\n entries.each do |entry|\n user = User.new(convert_user_attributes(entry))\n user.status = :enabled if (!user.disabled? && user.is_app_user?)\n users << user\n end\n users\n rescue Net::LDAP::LdapError => e\n return []\n end",
"def users_receiving(type:)\n check_type!(type)\n\n User.where(\"confirmed_at IS NOT NULL\").where(:\"receives_#{type}\" => true)\n end"
] | [
"0.60695195",
"0.55628043",
"0.5533681",
"0.55197996",
"0.53264534",
"0.5293263",
"0.5292187",
"0.528896",
"0.52577406",
"0.520061",
"0.5196832",
"0.51526374",
"0.5121851",
"0.5083534",
"0.50710106",
"0.5062476",
"0.5050427",
"0.50411963",
"0.5034412",
"0.50284797",
"0.50237525",
"0.5015908",
"0.49914604",
"0.49835062",
"0.49835062",
"0.49806038",
"0.4963082",
"0.4941585",
"0.49361032",
"0.4934237"
] | 0.7788377 | 0 |
rubocop:enable Metrics/AbcSize, Metrics/MethodLength Shows a specific university's information | def show
@university = University.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def university; end",
"def set_university\n @university = University.friendly.find(params[:id])\n end",
"def set_university\n @university = University.friendly.find(params[:id])\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university }\n end\n end",
"def set_university\n @university = University.find(params[:id])\n end",
"def set_university\n @university = University.find(params[:id])\n end",
"def set_university\n @university = University.find(params[:university_id])\n end",
"def index\n @universities = University.all\n end",
"def set_university\n @university = University.find(params[:id])\n end",
"def show\n @university_profile = UniversityProfile.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @university_profile }\n end\n end",
"def set_university\n @university = University.find(params[:id])\n @university_profiles = @university.university_profiles.paginate(:page => params[:page], :per_page => 10)\n end",
"def show\n @university = University.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @university }\n end\n end",
"def edit\n @university = University.find(params[:university_id])\n end",
"def university_params\n params.require(:university).permit(:user_id, :country_id, :option, :private_or_public, :name, :description, :fundation, :rector, :email, :facebook, :twitter, :linkedin, :website, :link_admission, :address, :longitude, :latitude, :logo, :many_proffesors, :many_students, :is_wifi, :is_cafe, :is_safe, :is_libray, :is_job_help, :is_student_exchange, :is_spiritual, :gym, :pool, :residence, :location, :lunch, :football, :soccer, :volley, :tennis, :table_tennis, :baseball, :track_and_field, :golf, :swimming, :rugby, :climbing, :lacrosse, :drawing, :photography, :sculpture, :theatre, :wood, :music, :choir, :marching_band, :dance, :mun, :volunteer, :gamers, :english, :spanish, :french, :german, :chinese, :italian, :portuguese, :russian, :japanese, :latin, :greek, :signs)\n end",
"def show\n @program = Program.includes(:university, documents: [:university]).find(params[:id])\n end",
"def get_university_name(text)\n name = nil\n @universities.reverse.each do |u|\n if text.downcase.include?(u.downcase)\n name = u\n end\n end\n return name\nend",
"def university_params\n params.require(:university).permit(:universityid, :name, :f211, :f985, :area, :address, :phone, :email, :level, :membership, :nature, :schoolid, :schooltype, :website, :shoufei, :intro)\n end",
"def show\n @universitario = Universitario.find(params[:id])\n end",
"def university_title(query)\n @form['578'] = query\n end",
"def new\n @universities = University.all\n @university = University.find(:first,:conditions => [\"name = ?\",private_mw])\n @alumini = Alumini.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @alumini }\n end\n end",
"def set_university_course\n @university_course = UniversityCourse.find(params[:id])\n end",
"def university_id\n patron&.university_id || univ_id\n end",
"def set_embed_code_university\n\t\t\t@embed_code_university = EmbedCodeUniversity.find(params[:id])\n\t\tend",
"def index\n @university_courses = UniversityCourse.all\n end",
"def index\n @universities = University.find(:all,:conditions => [\"data_type = ?\",\"university\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @universities }\n end\n end",
"def index\n @university_degrees = UniversityDegree.all\n end",
"def load_university_data\n if @university\n @users = @university.users.where(\"id != 1 AND id != 2\")\n @updateable = @university\n @updates = @updateable.updates\n @events = @university.events.active.free_food.search_date(Date.today)\n @clubs = @university.clubs.sup_club.limit(5).order(:name)\n @club ||= @university.clubs.build\n @club_updates = Update.\n joins(\"inner join clubs on clubs.id = updateable_id\").\n joins(\"inner join memberships on memberships.club_id = clubs.id\").\n where(updateable_type: \"Club\").\n where(updateable_id: @clubs.map(&:id)).\n where(\"memberships.user_id = ?\", current_user.id).\n order(\"created_at DESC\")\n end\n end",
"def show\n @university = UniversityDecorator.decorate @employer_study.university\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @employer_study }\n end\n end",
"def show\n puts \"here asdasdas\"\n # begin \n # @subdiscipline.degreeprogram\n # rescue\n # else\n @degrees = @subdiscipline.discipline_university.limit(4).distinct\n # end\n end"
] | [
"0.7918296",
"0.72640204",
"0.7262395",
"0.708304",
"0.708304",
"0.70291805",
"0.70291805",
"0.69708335",
"0.69067067",
"0.68833584",
"0.6851621",
"0.6835079",
"0.67795134",
"0.65699196",
"0.6426744",
"0.6423309",
"0.64140713",
"0.64045537",
"0.6394346",
"0.6374416",
"0.6359162",
"0.62941337",
"0.62840056",
"0.6279345",
"0.6242601",
"0.62206346",
"0.6218096",
"0.61712694",
"0.6166926",
"0.615407"
] | 0.76468956 | 1 |
Displays the edit page for the university | def edit
@university = University.find(params[:university_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n\t\t# must have admin access or be in the course\n\tend",
"def update\n @university = University.find(params[:university_id])\n if @university.update(university_params)\n flash[:success] = 'Information updated!'\n redirect_to @university\n else\n render 'edit'\n end\n end",
"def edit\n # Renders the edit form\n end",
"def edit\n\n @authors = PublicationsHelper::get_faculty_members()\n @publication= Publication.find_by_id(params[:id])\n end",
"def edit\n\t\t@course = Course.find(params[:id])\n\t\t@majors = @course.major\n\t\t@distributions = @course.distribution\n\t\t@minors = @course.minor\n\t\t@concentrations = @course.concentration\n\tend",
"def edit\n\t\t#for each student, find that student using the student id\n\t\t@student = Student.find(params[:id])\n\t\t#each category is an array with 3 items - with @ so that view controller can find it, and displays those labels (on edit form)\n\t\t@cats = [\"email\", \"phone\", \"slack\"]\n\t\t#go to the new student page in order to edit\n\t\trender :new\n\t#wraps up \"edit\" action\n\tend",
"def edit\n\n end",
"def update\n @university = University.find(params[:id])\n\n respond_to do |format|\n if @university.update_attributes(params[:university])\n format.html { redirect_to @university, notice: 'University was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @university.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @university = University.find(params[:id])\n\n respond_to do |format|\n if @university.update_attributes(params[:university])\n format.html { redirect_to @university, notice: 'University was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @university.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @university = University.find(params[:id])\n end",
"def edit\n\t\t\n\tend",
"def edit\r\n end",
"def edit\n\t\t@page_name = \" - Edit Show\"\n\tend",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n\n\tend",
"def edit\n\n\tend",
"def edit\n\n\tend",
"def edit\n\n\tend"
] | [
"0.7576261",
"0.72493196",
"0.72191083",
"0.7212998",
"0.70276296",
"0.6965138",
"0.69448525",
"0.6943546",
"0.6943546",
"0.6939353",
"0.6921962",
"0.6910706",
"0.6904647",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6878052",
"0.6872",
"0.6872",
"0.6872",
"0.6872"
] | 0.8325032 | 0 |
Toggles the favorite status of this university for the current user rubocop:disable Metrics/AbcSize | def toggle_favorite
return if current_user.nil?
if current_user.favorite?(params[:university_id])
current_user.remove_favorite(params[:university_id])
else
current_user.add_favorite(params[:university_id])
end
flash[:success] = 'Favorites list updated!'
redirect_to request.referer || root_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle\n\t\tif is_favourited\n\t\t\tself.is_favourited = false\n\t\telse\n\t\t\tself.is_favourited = true\n\t\tend\n\t\tself.save\n\tend",
"def toggle_favorite\n\t toggle_favorite_for User.current_user\n\tend",
"def toggle_favorite_for user\n\t fave = user.favorites.find_by_page_id(self)\n\t if fave\n\t fave.destroy\n\t else\n\t fave = add_favorite(:created_by => user)\n\t end\n\t fave\n\tend",
"def toggle_fav\n @property = Property.find(params[:id])\n current_usertemp.favorited?(@property) ? current_usertemp.unfavorite(@property) : current_usertemp.favorite(@property)\n end",
"def toggle_favorite\n if user_signed_in?\n \t@user = current_user\n \t\n \t# toggle. so, if it's there, remove it\n \tif @user.favorite_listings.include?(params[:listing_id]) then\n \t\t\t@user.favorite_listings.delete(params[:listing_id])\n \t\t\tmessage = 'removed'\n \t\telse\n \t\t\t# else, we'll add it\n \t\t\t@user.favorite_listings << params[:listing_id] unless @user.favorite_listings.include?(params[:listing_id])\n \t\t\tmessage = 'added'\t\t\n \t\tend\n \t\t\n \t\t@user.save\n \tend\n\t\n\trender :text => message\n \n end",
"def toggle_favorite_song(song_instance)\n if song_instance.favorite \n song_instance.favorite = false\n else\n song_instance.favorite = true\n end\n end",
"def set_favourite\n if user_signed_in?\n @favourite = Favourite.where(user_id: current_user.id, product_id: set_product()).first\n end\n end",
"def favorite?\n\t is_favorite_of User.current_user\n\tend",
"def change_favorite_status\r\n\t\t\tProject.update_favorite_status params[:id], params[:is_favorite]\r\n\r\n\t\t\trender json: { status: 0 }\r\n\t\tend",
"def is_favorite_of user\n\t fave = get_favorite_for user\n\t fave ? true : false\n\tend",
"def remove_favorite\n\t remove_favorite_of User.current_user\n\tend",
"def set_favorite\n end",
"def toggle!\n self.featured = !self.featured\n save\n end",
"def toggle\n @user.toggle\n redirect_to :back\n end",
"def favorite_movie!(movie_id)\n toggle_favorite_movie(movie_id, true)\n end",
"def set_favorite\n @favorite = current_user.favorites.find(params[:id])\n end",
"def favorite?\n @favorite\n end",
"def is_favorite? (user_id)\n\t\tself.favorite_opportunities.find_by user_id: user_id\n\tend",
"def user_favorite\r\n\t\t\tif params[:is_add] == '1'\r\n\t\t\t\trender json: UsersFavoriteProject.add_favorite(params[:id])\r\n\t\t\telse\r\n\t\t\t\trender json: UsersFavoriteProject.remove_favorite(params[:id])\r\n\t\t\tend\r\n\t\tend",
"def favourite_for(user)\n favourites.find_by_user_id user\n end",
"def favorite\n authorize @shelter\n current_user.favorite_shelter(@shelter)\n\n redirect_to shelter_path(@shelter)\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end",
"def deactivate\n @listing.update(\n active: false\n )\n flash[:notice] = \"You have successfully deactivated your listing.\"\n redirect_to user_path(current_user.id)\n\n favourited_users = @listing.favourited_users\n favourited_users.each do |user|\n user.notifications.create(\n title: \"Someone deactivated your favourite\",\n body: \"#{current_user.first_name} has deactivated your favourite #{@listing.title}\",\n read: false,\n )\n end\n end",
"def favor\n favorites_count = 0\n ActiveRecord::Base.transaction do\n if params[:cancel]\n # cancel favorite\n favorites_count = Favorite.delete(params[:article_id], current_user.id)\n logger.info \"ユーザ #{current_user.id} が記事 #{params[:article_id]} に対するブックマークをキャンセルしました。\"\n else\n # commit favorite\n favorites_count = Favorite.add(params[:article_id], current_user.id)\n logger.info \"ユーザ #{current_user.id} が記事 #{params[:article_id]} に対してブックマークしました。\"\n end\n respond_to do |format|\n # toggle favorite button\n format.js { render locals: { article: Article.find(params[:article_id]) } }\n end\n end\n end",
"def is_favorite?\n\t favorite?\n\tend",
"def toggle_love\n @confession_id = love_params[:confession_id]\n @confession = Confession.find(@confession_id)\n\n toggle_love_by_user(@confession, current_user._id)\n\n respond_to do |format|\n format.js {}\n end\n end",
"def set_favorite_state\n @favorite_state = FavoriteState.find(params[:id])\n end",
"def toggle_featured\n authorize! @cookbook\n\n @cookbook.update(featured: !@cookbook.featured)\n\n redirect_to(\n cookbook_path(@cookbook),\n notice: t(\n \"cookbook.featured\",\n cookbook: @cookbook.name,\n state: @cookbook.featured? ? \"featured\" : \"unfeatured\"\n )\n )\n end",
"def favorite_for(user)\n favs.find_by(user_id: user)\n end",
"def set_favorite\n @favorite = Favorite.find(params[:id])\n end"
] | [
"0.7730504",
"0.7716409",
"0.73339504",
"0.7014469",
"0.6691316",
"0.6397005",
"0.63002366",
"0.6222146",
"0.6192686",
"0.61536056",
"0.6069941",
"0.6044374",
"0.60269773",
"0.6024551",
"0.5999595",
"0.5989017",
"0.598409",
"0.5937639",
"0.5831324",
"0.58139414",
"0.58118045",
"0.58107907",
"0.5809107",
"0.5803485",
"0.57662326",
"0.576196",
"0.5727845",
"0.57116747",
"0.569139",
"0.56770986"
] | 0.8347372 | 0 |
Checks if it has a 502, if it does it's considered a thesis | def thesis
'Thesis/Dissertation' if record.find { |a| a.tag == '502' }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_error?\n @status.between?(500, 599) if @status\n end",
"def unc_thesis_dissertation?\n rec_type_match = manuscript_lang_rec_type? || lang_rec_type?\n nature_contents_match = record.fields('008').find do |field|\n (field.value.byteslice(24..27) || '').split('').include?('m')\n end\n\n marc_006_match_results = record.fields('006').collect do |field|\n %w[a].include?(field.value.byteslice(0)) &&\n (field.value.byteslice(7..10) || '').split('').include?('m')\n end\n\n return true if (rec_type_match && nature_contents_match) ||\n marc_006_match_results.include?(true) ||\n rec_type_match && has_502?\n end",
"def is_server_error?\n code.to_i >= 500 && code.to_i <= 599\n end",
"def status_is_servererror?\n\t\treturn self.status_category == 5\n\tend",
"def server_error?\n 500 <= code && code < 600\n end",
"def is_server_error?\n @code.in? 500..599\n end",
"def server_error?\n (500...600).include?(@status_code)\n end",
"def server_error?\n (500..599).cover?(code)\n end",
"def msc2108?\n @msc ||= {}\n @msc[2108] ||= \\\n begin\n request(:get, :client_r0, '/sync/sse', skip_auth: true, headers: { accept: 'text/event-stream' })\n rescue MatrixSdk::MatrixNotAuthorizedError # Returns 401 if implemented\n true\n rescue MatrixSdk::MatrixRequestError\n false\n end\n rescue StandardError => e\n logger.debug \"Failed to check MSC2108 status;\\n#{e.inspect}\"\n false\n end",
"def has_wrong_number?\n status_code == '1'\n end",
"def undergrad?\n sdb.class_standing <= 5\n end",
"def sierra_856_perfect?\n @url == self.proper.proper_856_content\n end",
"def thesis_dissertation?\n marc_leader_06_match = record.leader.byteslice(6) == 'a'\n marc_008_24_27_match = record.fields('008').find do |field|\n (field.value.byteslice(24..27) || '').scrub(' ').split('').include?('m')\n end\n\n marc_006_match = record.fields('006').find do |field|\n %w[a s].include?(field.value.byteslice(0)) &&\n (field.value.byteslice(7..10) || '').scrub(' ').split('').include?('m')\n end\n\n return true if (marc_leader_06_match && marc_008_24_27_match) ||\n marc_006_match\n end",
"def no_500_error!\n return true if browser.all(:css, 'head title', :text => 'Internal Server Error').empty?\n sleep 30 if ENV['GIMME_CRAP']\n raise Unexpected500, browser.body\n end",
"def error?\n (500..599).include?(status)\n end",
"def error?\n !!(status.to_s =~ /[4|5]\\d\\d/)\n end",
"def nine_two?\n @connection.server_version >= 90200\n end",
"def validate\n if scrape.css(\".summarycount\").text == \"0\"\n false\n else\n true\n end\n end",
"def well(x)\ngood = 0\nbad = 0\n x.each do |i|\n if i == \"good\"\n good+=1\n else\n bad +=1\n end\nend\n\nif good>2\n 'I smell a series!'\nelsif good >=1 && good<=2\n \"Publish!\"\nelse\n \"Fail!\"\nend\nend",
"def error?\n http_status >= 400 && http_status <= 599\n end",
"def check_request\n if @req.code.to_i.between?(400, 499)\n raise Exceptions::SlicingDiceHTTPError, \"Client Error \"\\\n \"#{@req.code} (#{@req.message}).\"\n elsif @req.code.to_i.between?(500, 600)\n raise Exceptions::SlicingDiceHTTPError, \"Server Error \"\\\n \"#{@req.code} (#{@req.message}).\"\n else\n true\n end\n end",
"def ok?\n @result.code.to_i != 200\n end",
"def is_sunk? \n if @life > 0\n return false\n else\n return true\n end\n end",
"def unknown?\n !(100...600).include?(@status_code)\n end",
"def error?\n # 4xx and 5xx are errors\n return @status >= 400 && @status < 600\n end",
"def check_trip_published(arg)\n puts \"[testing]sleeping 1 sec to avoid an error on blablacar server side\"\n sleep(1)\n req = setup_http_request($publication_processed, @cookie, {:url_arg => [arg]})\n res = @http.request(req)\n if res.code != \"200\"\n if res.body.include?(\"maintenance\")\n puts \"[?] Blablacar est en maintenance\"\n end\n File.open(\"Checkpublished_error1.html\",\"w\") do |f| f.write(res.body); end\n raise CheckPublishedTripError, \"HTTP code should be 200 here [step 2 checking]\"\n end\n if res.body.force_encoding('utf-8').include?(\"Voir votre annonce\")\n puts \"voir votre annonce\"\n return true, 0\n elsif res.body.force_encoding('utf-8').include?(\"Votre annonce sera publiée dans quelques instants\")\n puts \"votre annonce sera publiée dans qq instants\"\n return true, 1\n else\n puts \"fail\"\n return false\n end\n end",
"def client_error?\n (400..499).cover?(code)\n end",
"def is_request_status_ok\n get_request_status == MA500Functions::MA500::ILV_OK.hex\n end",
"def webpage_site?\n marc_leader_06_match = record.leader.byteslice(6) == 'a'\n marc_leader_07_match = %w[b i s].include?(record.leader.byteslice(7))\n marc_008_21_match = record.fields('008').find do |field|\n field.value.byteslice(21) == 'w'\n end\n\n marc_006_match = record.fields('006').find do |field|\n field.value.byteslice(0) == 's' &&\n field.value.byteslice(4) == 'w'\n end\n\n return true if (marc_leader_06_match &&\n marc_leader_07_match &&\n marc_008_21_match) ||\n marc_006_match\n end",
"def evaluate_proquest_status(thesis)\n proquest_status = thesis.authors.map(&:proquest_allowed).uniq\n return 'conflict' if proquest_status.length > 1\n\n proquest_status.first\n end"
] | [
"0.5861513",
"0.5711736",
"0.5674996",
"0.56668204",
"0.5620021",
"0.56074923",
"0.5465322",
"0.54640204",
"0.5377562",
"0.53278047",
"0.5297188",
"0.5276339",
"0.5255286",
"0.5243283",
"0.5183556",
"0.5153264",
"0.5116197",
"0.5101628",
"0.5082114",
"0.50678253",
"0.5056442",
"0.5040275",
"0.50157255",
"0.5007125",
"0.5003671",
"0.49861616",
"0.49838725",
"0.49831036",
"0.49559474",
"0.4938612"
] | 0.5861468 | 1 |
Check leader byte 12 and 008 byte 29 for proceeding/congress | def proceeding_or_congress
if record.leader[12] == '1' || (record['008'] && record['008'].value[29] == '1') || congress?
'Proceeding/Congress'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ldr06_invalid?\n return true unless leader\n leader[6] !~ /[acdefgijkmoprt]/\n end",
"def ldr07_invalid?\n return true unless leader\n leader[7] !~ /[abcdims]/\n end",
"def game?\n marc_leader_06_o_r_match = %w[o r].include?(record.leader.byteslice(6))\n marc_008_33_g_match = record.fields('008').find do |field|\n field.value.byteslice(33) == 'g'\n end\n\n marc_leader_06_m_match = record.leader.byteslice(6) == 'm'\n marc_008_26_g_match = record.fields('008').find do |field|\n field.value.byteslice(26) == 'g'\n end\n\n marc_leader_06_e_f_match = %w[e f].include?(record.leader.byteslice(6))\n marc_008_33_34_n_match = record.fields('008').find do |field|\n (field.value.byteslice(33..34) || '').scrub(' ').split('').include?('n')\n end\n\n\n marc_006_match = record.fields('006').find do |field|\n (%w[o r].include?(field.value.byteslice(0)) && field.value.byteslice(16) == 'g') ||\n (field.value.byteslice(0) == 'm' && (field.value.byteslice(9) == 'g' ||\n (field.value.byteslice(16..17) || '').scrub(' ').split('').include?('n')))\n end\n\n return true if (marc_leader_06_o_r_match && marc_008_33_g_match) ||\n (marc_leader_06_m_match && marc_008_26_g_match) ||\n (marc_leader_06_e_f_match && marc_008_33_34_n_match) ||\n marc_006_match\n end",
"def leader\n return (@attributes & 0x08 == 0x08)\n end",
"def kit?\n marc_leader_06_match = record.leader.byteslice(6) == 'o'\n\n marc_006_match = record.fields('006').find do |field|\n field.value.byteslice(0) == 'o'\n end\n\n return true if marc_leader_06_match || marc_006_match\n end",
"def map?\n marc_leader_06_match = %w[e f].include?(record.leader.byteslice(6))\n\n marc_006_match = record.fields('006').find do |field|\n %w[e f].include?(field.value.byteslice(0))\n end\n\n marc_007_match = record.fields('007').find do |field|\n field.value.byteslice(0) == 'a'\n end\n\n return true if marc_leader_06_match || marc_006_match || marc_007_match\n end",
"def leader_available?\n error_code != :leader_not_available\n end",
"def book?\n marc_leader_06_match = %w[a t].include?(record.leader.byteslice(6))\n marc_leader_07_match = %w[a c d m].include?(record.leader.byteslice(7))\n marc_008_24_27_match = record.fields('008').find do |field|\n !(field.value.byteslice(24..27) || '').scrub(' ').split('').include?('m')\n end\n\n marc_006_match = record.fields('006').find do |field|\n %w[a t].include?(field.value.byteslice(0)) &&\n !(field.value.byteslice(7..10) || '').scrub(' ').split('').include?('m')\n end\n\n atlas_007_match = record.fields('007').find do |field|\n field.value.byteslice(0..1) == 'ad'\n end\n \n return true if (marc_leader_06_match &&\n marc_leader_07_match &&\n marc_008_24_27_match) ||\n marc_006_match ||\n atlas_007_match\n end",
"def validResponse? response\n return false unless /^[0-7]$/ =~ response.to_s \n return false if @board.isColFull? response.to_i\n true\n end",
"def archival_manuscript?\n marc_leader_06_match = %w[d f p t].include?(record.leader.byteslice(6))\n\n marc_006_00_match = record.fields('006').find do |field|\n %w[d f p t].include?(field.value.byteslice(0))\n end\n\n return true if marc_leader_06_match || marc_006_00_match\n end",
"def is_ok ( addr )\n\tindex = addr - @base\n\treturn true if @map[index] == \"X\"\n\treturn true if @map[index] == \"I\"\n\treturn false\n end",
"def counter?(x, y)\n return false unless valid?(x, y)\n return @passages[@map.data[x, y, 0]] & 0x80 == 0x80\n end",
"def bits_leader?\n @badges.key? 'bits-leader'\n end",
"def game_over(player)\n if @@tab[0][0].status == player && @@tab[0][1].status == player && @@tab[0][2].status == player # verifie si des points sont alignés au 1er lignes\n true\n elsif @@tab[1][0].status == player && @@tab[1][1].status == player && @@tab[1][2].status == player # verifie si des points sont alignés au 2é lignes\n true\n elsif @@tab[2][0].status == player && @@tab[2][1].status == player && @@tab[2][2].status == player # verifie si des points sont alignés au 3é lignes\n true\n elsif @@tab[0][0].status == player && @@tab[1][1].status == player && @@tab[2][2].status == player # verifie si des points sont alignés en oblique\n true\n elsif @@tab[0][2].status == player && @@tab[1][1].status == player && @@tab[2][0].status == player # verifie si des points sont alignés en oblique\n true\n elsif @@tab[0][0].status == player && @@tab[1][0].status == player && @@tab[2][0].status == player # verifie si des points sont alignés en vertical sur la colonne 1\n true\n elsif @@tab[0][1].status == player && @@tab[1][1].status == player && @@tab[2][1].status == player # verifie si des points sont alignés en vertical sur la colonne 2\n true\n elsif @@tab[0][2].status == player && @@tab[1][2].status == player && @@tab[2][2].status == player # verifie si des points sont alignés en vertical sur la colonne 3\n true\n else\n false\n end\n end",
"def game_over(player)\n if @@tab[0][0].status == player && @@tab[0][1].status == player && @@tab[0][2].status == player # verifie si des points sont alignés au 1er lignes\n true\n elsif @@tab[1][0].status == player && @@tab[1][1].status == player && @@tab[1][2].status == player # verifie si des points sont alignés au 2é lignes\n true\n elsif @@tab[2][0].status == player && @@tab[2][1].status == player && @@tab[2][2].status == player # verifie si des points sont alignés au 3é lignes\n true\n elsif @@tab[0][0].status == player && @@tab[1][1].status == player && @@tab[2][2].status == player # verifie si des points sont alignés en oblique\n true\n elsif @@tab[0][2].status == player && @@tab[1][1].status == player && @@tab[2][0].status == player # verifie si des points sont alignés en oblique\n true\n elsif @@tab[0][0].status == player && @@tab[1][0].status == player && @@tab[2][0].status == player # verifie si des points sont alignés en vertical sur la colonne 1\n true\n elsif @@tab[0][1].status == player && @@tab[1][1].status == player && @@tab[2][1].status == player # verifie si des points sont alignés en vertical sur la colonne 2\n true\n elsif @@tab[0][2].status == player && @@tab[1][2].status == player && @@tab[2][2].status == player # verifie si des points sont alignés en vertical sur la colonne 3\n true\n else\n false\n end\n end",
"def fix_leader!(leader)\n\n if leader.length < 24\n # pad it to 24 bytes, leader is supposed to be 24 bytes\n leader.replace( leader.ljust(24, ' ') )\n elsif leader.length > 24\n # Also a problem, slice it\n leader.replace( leader.byteslice(0, 24))\n end\n # http://www.loc.gov/marc/bibliographic/ecbdldrd.html\n leader[10..11] = '22'\n leader[20..23] = '4500'\n\n if settings['horizon.destination_encoding'] == \"UTF8\"\n leader[9] = 'a'\n end\n\n # leader should only have ascii chars in it; invalid non-ascii\n # chars can cause ruby encoding problems down the line.\n # additionally, a force_encoding may be neccesary to\n # deal with apparent weird hard to isolate jruby bug prob same one\n # as at https://github.com/jruby/jruby/issues/886\n leader.force_encoding('ascii')\n\n unless leader.valid_encoding?\n # replace any non-ascii chars with a space.\n\n # Can't access leader.chars when it's not a valid encoding\n # without a weird index out of bounds exception, think it's\n # https://github.com/jruby/jruby/issues/886\n # Grr.\n\n #leader.replace( leader.chars.collect { |c| c.valid_encoding? ? c : ' ' }.join('') )\n leader.replace(leader.split('').collect { |c| c.valid_encoding? ? c : ' ' }.join(''))\n end\n\n\n\n end",
"def early_or_late?(line_token)\n\t\tline_token[3].scan(/^Validity:(pre|post)/).any?\n\tend",
"def ecb_encrypted?(cipher)\n line_parts = cipher.scan(/.{16}/)\n line_parts.detect { |e| line_parts.count(e) > 1 } ? true : false\nend",
"def ctcp?\n #message = @params[1]\n #message[0] == ?\\01 && message[-1] == ?\\01\n /\\x01(?>[^\\x00\\x01\\r\\n]*)\\x01/ === @params[1]\n end",
"def cp2pkh?\n return false unless chunks.size == 7\n return false unless chunks[0].bytesize == 34\n return false unless Tapyrus::Color::ColorIdentifier.parse_from_payload(chunks[0].pushed_data)&.valid?\n return false unless chunks[1].ord == OP_COLOR\n [OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG] == (chunks[2..3] + chunks[5..6]).map(&:ord) &&\n chunks[4].bytesize == 21\n end",
"def ace_check\n cards[index_of_11][:points] = 1 if index_of_11 && (total > 21)\n end",
"def validity_check\n\n if strand == '+'\n\n codon = ref_seq[0..2].map(&:last).join\n return true if codon.include?('N')\n codon == 'ATG'\n\n elsif strand == '-'\n\n codon = ref_seq[-3..-1].map(&:last).join\n return true if codon.include?('N')\n codon == 'CAT'\n\n end\n\n end",
"def newspaper?\n marc_leader_06_match = record.leader.byteslice(6) == 'a'\n marc_leader_07_match = %w[b i s].include?(record.leader.byteslice(7))\n marc_008_21_match = record.fields('008').find do |field|\n field.value.byteslice(21) == 'n'\n end\n\n marc_006_match = record.fields('006').find do |field|\n field.value.byteslice(0) == 's' &&\n field.value.byteslice(4) == 'n'\n end\n\n return true if (marc_leader_06_match &&\n marc_leader_07_match &&\n marc_008_21_match) ||\n marc_006_match\n end",
"def bass?\n @cr[0xa][7] == 1\n end",
"def parseADCStatus(bytes)\n return 0 if bytes.size < 6\n (id, nodeid, adcchannel, adcvalue) = bytes.unpack('CCCn')\n @client.handleADCStatus(nodeid, adcchannel, adcvalue)\n return 6\n end",
"def is_decision\n return (@index == 89)\n end",
"def is_valid?\n ((@original.reverse.chars.first.to_i == check_digit) && (gs1_prefix == '979') && @code.count == 13) || @code.count == 12\n end",
"def check_data\n foward_data sp.getc\n end",
"def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end",
"def validate()\n cs = checksum()\n return cs == @header[LENGTH - 1]\n end"
] | [
"0.6418908",
"0.60957813",
"0.6018501",
"0.60139203",
"0.56511796",
"0.5593865",
"0.5544834",
"0.5461461",
"0.5410708",
"0.5380553",
"0.5302432",
"0.5261071",
"0.5256778",
"0.5240219",
"0.5240219",
"0.52327156",
"0.51997876",
"0.51624",
"0.5157352",
"0.5146704",
"0.5121905",
"0.51165843",
"0.5110914",
"0.50968456",
"0.5084073",
"0.5067372",
"0.5063246",
"0.5059655",
"0.5052706",
"0.5051944"
] | 0.64782 | 0 |
Checks all $6xx for a $v "congress" | def congress?
record.find do |field|
field
.tag
.slice(0) == '6' &&
field
.subfields
.find { |sf| sf.code == 'v' && PsulibTraject.regex_to_extract_data_from_a_string(sf.value, /Congress/i) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateCZ(vat_number)\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n # Only do check digit validation for standard VAT numbers\r\n return true unless vat_number.to_s.length == 8\r\n # Multiply by multipliers\r\n 0.upto(6) do |i|\r\n total = total + vat_number[i,1].to_i * multipliers[i] \r\n end\r\n # Establish Check digit\r\n total = 11 - total % 11\r\n total = 0 if total == 10\r\n total = 1 if total == 11\r\n # Compare with last character of the VAT number.\r\n return true if total == vat_number.to_s.slice(7..8).to_i\r\n return false\r\n end",
"def validateFI(vat_number)\r\n total = 0\r\n multipliers = [7,9,10,5,8,4,2]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish the check digit\r\n total = 11 - total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[7..8].to_i\r\n return false\r\n end",
"def validateHU(vat_number)\r\n total = 0\r\n multipliers = [9,7,3,1,9,7,3]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish the check digit\r\n total = 10 - total % 10\r\n total = 0 if total == 10\r\n return true if total == vat_number[7..8].to_i\r\n return false\r\n end",
"def ip_v6_cidr; end",
"def validateDK(vat_number)\r\n total = 0\r\n multipliers = [2,7,6,5,4,3,2,1]\r\n 0.upto(7) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n return true if (total % 11 == 0)\r\n return false\r\n end",
"def icmpv6_statistics\n super\n end",
"def checks\n return if @server.info[:server_version].nil? && @server.info[:app_server_version].nil? \n\n cve_data = update_cve_files(@server.info[:server_name])\n\n if cve_data.nil?\n @result.warned(\"CVE Data not available for #{@server.info[:server_name].capitalize}.\")\n return\n end\n\n server_version = @server.info[:server_version] \n\n short_name = \"#{@server.info[:server_name]}/#{@server.info[:server_version]}\"\n\n cve_data[\"cves\"].each do |cve|\n from_v = Version.new cve['from']\n to_v = cve['to'].nil? ? nil : Version.new(cve['to']) \n prior_v = cve['prior'].nil? ? nil : Version.new(cve['prior']) \n\n # If the server version is \n if server_version >= from_v \n \n # if there are no to_ / prior_v or to_v is present and we're in the range or prior is present and we're in the range, then...\n if ( to_v.nil? && prior_v.nil? ) || ( !to_v.nil? && server_version <= to_v ) || ( !prior_v.nil? && server < prior_v )\n @result.failed(\"CVE: #{short_name} CVE-#{cve['cve']}: #{cve['title']}: #{cve['url']}\")\n end\n end\n\n end\n\n end",
"def cavv_matches?\n ['','2','8'].include? cavv_response\n end",
"def validateUK(vat_number)\r\n # Only inspect check digits for 9 character numbers\r\n return true unless vat_number.length == 9\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = total % 97\r\n total -= 97 unless total == 0\r\n total = total.abs\r\n return true if total == vat_number[7..9].to_i\r\n return false\r\n end",
"def validatePL(vat_number)\r\n total = 0\r\n multipliers = [6,5,7,2,3,4,5,6,7]\r\n 0.upto(8) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[9..10].to_i\r\n return false\r\n end",
"def cavv_matches?\n ['','2','8'].include? cavv_response\n end",
"def validateES(vat_number)\r\n total = 0\r\n temp = 0\r\n multipliers = [2,1,2,1,2,1,2]\r\n esexp = [/^[A-H]\\d{8}$/,/^[N|P|Q|S]\\d{7}[A-Z]$/]\r\n 0.upto(6) do |i|\r\n temp = vat_number[i + 1].to_i * multipliers[i]\r\n if temp > 9\r\n total += (temp / 10) + (temp % 10)\r\n else\r\n total += temp\r\n end\r\n end \r\n # With profit company\r\n if not (vat_number =~ esexp[0]).nil?\r\n # Calculate the check digit\r\n total = 10 - total % 10\r\n total = 0 if total == 10\r\n return true if total == vat_number[8..9].to_i\r\n return false\r\n # Non-profit companies\r\n elsif not (vat_number =~ esexp[1]).nil?\r\n # Calculate the check digit\r\n total = 10 - total % 10\r\n total = (total + 64).chr\r\n return true if total == vat_number[8..9]\r\n return false\r\n end\r\n end",
"def validateAT(vat_number)\r\n multipliers = [1,2,1,2,1,2,1]\r\n total = 0\r\n # Extract the next digit and multiply it by the appropriate multiplier\r\n 0.upto(6) do |i|\r\n temp = vat_number[i,1].to_i * multipliers[i]\r\n if temp > 9\r\n total += (temp/10) + (temp%10)\r\n else\r\n total += temp\r\n end\r\n end\r\n # Establish Check digit\r\n total = 10 - ((total + 4) % 10)\r\n total = 0 if total == 10\r\n # Compare it with the last character of the VAT number. If it is the same, \r\n # then it's a valid check digit.\r\n return true if total == vat_number[7..1].to_i\r\n return false\r\n end",
"def validateSL(vat_number)\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = 11 - total % 10\r\n total = 0 if total > 9\r\n return true if total == vat_number[7..8].to_i\r\n return false\r\n end",
"def validateIE(vat_number)\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n # If code in the old format convert it to the new\r\n if vat_number =~ /^\\d[A-Z]/\r\n vat_number = \"0\" + vat_number[2..7] + vat_number[0..1] + vat_number[7..8]\r\n end\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish the check digit\r\n total = total % 23\r\n if total == 0\r\n total = \"W\"\r\n else\r\n total = (total + 64).chr\r\n end\r\n return true if total == vat_number[7..8]\r\n return false\r\n end",
"def validateNL(vat_number)\r\n total = 0\r\n multipliers = [9,8,7,6,5,4,3,2]\r\n 0.upto(7) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[8..9].to_i\r\n return false\r\n end",
"def validatePT(vat_number)\r\n total = 0\r\n multipliers = [9,8,7,6,5,4,3,2]\r\n 0.upto(7) do |i| \r\n total += vat_number[i,1] * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = 11 - total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[8..9].to_i\r\n return false\r\n end",
"def validateSK(vat_number)\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n 3.upto(8) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i-3] \r\n end\r\n # Establish check digit\r\n total = 11 - total % 11\r\n total -= 10 if total > 9\r\n return true if total == vat_number[9..10].to_i\r\n return false\r\n end",
"def okIP(addr)\nreturn addr != \"0.0.0.0\" &&\n addr != \"255.255.255.255\" &&\n !addr.match(/^169\\.254.*/) &&\n !addr.match(/^10.*/) &&\n !addr.match(/^172\\.[1-3].*/) && # TODO: match the block better\n !addr.match(/^192\\.168.*/)\nend",
"def _cf_cp(value)\n {\n 0x00 => :'No comparison',\n # v between v1 and v2 or strictly\n # v2 is greater than or equal to v1, and v is greater than or equal to v1 and less than or equal to v2 –Or–\n # v1 is greater than v2, and v is greater than or equal to v2 and less than or equal to v1\n 0x01 => :'((v1 <= v2) && (v1 <= v <= v2)) || ((v2 < v1) && (v1 >= v >= v2))',\n # v is not between v1 and v2 or strictly\n # v2 is greater than or equal to v1, and v is less than v1 or greater than v2 –Or–\n # v1 is greater than v2, and v is less than v2 or greater than v1\n 0x02 => :'((v1 <= v2) && (v < v1 || v > v2)) || ((v1 > v2) && (v > v1 || v < v2))',\n 0x03 => :'v == v1', # v is equal to v1\n 0x04 => :'v != v1', # v is not equal to v1\n 0x05 => :'v > v1', # v is greater than v1\n 0x06 => :'v < v1', # v is less than v1\n 0x07 => :'v >= v1', # v is greater than or equal to v1\n 0x08 => :'v <= v1' # v is less than or equal to v1\n }[value]\n end",
"def cost_between_five_and_fifty\n if cost && (cost <= 5 || cost >= 50)\n errors.add(:cost, \"has to be between 5 and 50\")\n end\n end",
"def ipv6_v; self[:ipv6_v].to_i; end",
"def ipv6_v=(i); self[:ip_v] = i.to_i; end",
"def validateEL(vat_number)\r\n total = 0\r\n multipliers = [256,128,64,32,16,8,4,2]\r\n vat_number = (\"0\" + vat_number.to_s) if vat_number.to_S.length == 8\r\n 0.upto(7) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = total % 11\r\n total = 0 if total > 9\r\n return true if total == vat_number[8..9].to_i\r\n return false\r\n end",
"def check_vip_config_with (vip_configs, vips)\n\n config_keys = ['vip','vport','rport','weight']\n vips_in_config = []\n\n vip_configs.each do |config|\n config_keys.each do |key|\n raise \"#{key} not defined in #{config}\" if config[key].nil?\n end\n vips_in_config << config['vip']\n end\n\n ## check if vips is the subset of vips_in_config\n raise \"All vips should be included in vip_confgs\" unless (vips - vips_in_config).empty?\n\n vip_configs\n end",
"def validateLV(vat_number)\r\n # Only check legal bodies\r\n return true if vat_number =~ /^[0-3]/\r\n total = 0\r\n multipliers = [9,1,4,8,3,10,2,5,7,6]\r\n 0.upto(9) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total -= 45 if total % 11 == 4 and vat_number[0,1].to_i == 9\r\n if total % 11 == 4\r\n total = 4 - total % 11\r\n elsif total % 11 > 4\r\n total = 14 - total % 11\r\n elsif total % 11 < 4\r\n total = 3 - total % 11\r\n end\r\n return true if total == vat_number[10..11].to_i\r\n return false\r\n end",
"def validateSE(vat_number)\r\n total = 0\r\n multipliers = [2,1,2,1,2,1,2,1,2]\r\n temp = 0\r\n 0.upto(8) do |i|\r\n temp = vat_number[i,1] * multipliers[i]\r\n if temp > 9\r\n total += (temp / 10) + (temp % 10)\r\n else\r\n total += temp\r\n end\r\n end\r\n # Establish check digit\r\n total = 10 - total % 10\r\n total = 0 if total == 10\r\n return true if total == vat_number[9..10].to_i\r\n return false\r\n end",
"def validateIT(vat_number)\r\n total = 0\r\n multipliers = [1,2,1,2,1,2,1,2,1,2]\r\n # Last three digits are issuing office, and cannot exceed 201\r\n temp = vat_number[0..7].to_i\r\n return false if temp == 0\r\n temp = vat_number[7..10].to_i\r\n return false if temp < 1 or temp > 201\r\n 0.upto(9) do |i|\r\n temp = vat_number[i,1].to_i * multipliers[i]\r\n if temp > 9\r\n total += temp / 10 + temp % 10\r\n else\r\n total += temp\r\n end\r\n end\r\n # Establish check digit\r\n total = 10 - total % 10\r\n total = 0 if total > 9\r\n return true if vat_number[10..11].to_i == total\r\n return false\r\n end",
"def check_budget\n checks = []\n\n # Internal consistency\n checks << check_equal(\"Transferencias internas ingresos = gastos\", \n beautify(@income[:consolidado][:transferencias]),\n beautify(@expenses[:consolidado][:transferencias]) )\n\n # Expenses\n checks.concat check_expenses('R_6_2_801_1_3', \"Estado\", :estado)\n checks.concat check_expenses('R_6_2_802_1_3', \"Organismos Autónomos\", :ooaa)\n checks.concat check_expenses('R_6_2_803_1_3', \"Agencias estatales\", :agencias)\n checks.concat check_expenses('R_6_2_804_1_3', \"Otros organismos\", :otros)\n checks.concat check_expenses('R_6_2_805_1_3', \"Seguridad Social\", :seg_social)\n\n # Income\n checks.concat check_income('R_6_1_101_1_5_1', \"Estado\", :estado)\n checks.concat check_income('R_6_1_102_1_4_1', \"Organismos Autónomos\", :ooaa)\n checks.concat check_income('R_6_1_103_1_4_1', \"Agencias estatales\", :agencias)\n checks.concat check_income('R_6_1_104_1_4_1', \"Otros organismos\", :otros)\n checks.concat check_income('R_6_1_105_1_5_1', \"Seguridad Social\", :seg_social)\n\n # Return results\n checks.join(\"\\n\")\n end",
"def validates_as_vat_number(*attr_names)\n RAILS_DEFAULT_LOGGER.debug \"Checking VAT number\"\n configuration = {\n :message => \"is not valid Vat EU number\",\n :scope => \"country_code\"\n }\n configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)\n\n validates_each(attr_names, configuration) do |record, attr_name, value|\n begin\n result = vat_check_driver.checkVat(\n :countryCode => record.send(configuration[:scope]),\n :vatNumber => value.sub(record.send(configuration[:scope]), \"\")\n )\n RAILS_DEFAULT_LOGGER.debug \"Result from VAT check: #{result.inspect}\"\n record.errors.add(attr_name, configuration[:message]) unless result && result.valid == \"true\"\n rescue => e\n unless record.send(configuration[:scope]).blank?\n if STRUCTURES[record.send(configuration[:scope]).upcase.to_sym].match(value).nil?\n record.errors.add(attr_name, configuration[:message])\n end\n else\n raise e\n end\n end\n end\n end"
] | [
"0.5797849",
"0.54535055",
"0.5433697",
"0.5311011",
"0.5214269",
"0.5204784",
"0.5195527",
"0.5188247",
"0.51843774",
"0.51213604",
"0.51066893",
"0.50621516",
"0.50555056",
"0.50261",
"0.50211585",
"0.4995403",
"0.4989062",
"0.49484044",
"0.4942425",
"0.4942111",
"0.49251565",
"0.49033934",
"0.4882854",
"0.48680645",
"0.48356062",
"0.48265043",
"0.4825576",
"0.48234186",
"0.48200682",
"0.48085308"
] | 0.5650355 | 1 |
Override for Book when leader(67) is 'am' issue172 | def book
'Book' if record.leader[6] == 'a' && record.leader[7] == 'm' && local_formats.include?('Archives/Manuscripts')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def award; end",
"def book?\n marc_leader_06_match = %w[a t].include?(record.leader.byteslice(6))\n marc_leader_07_match = %w[a c d m].include?(record.leader.byteslice(7))\n marc_008_24_27_match = record.fields('008').find do |field|\n !(field.value.byteslice(24..27) || '').scrub(' ').split('').include?('m')\n end\n\n marc_006_match = record.fields('006').find do |field|\n %w[a t].include?(field.value.byteslice(0)) &&\n !(field.value.byteslice(7..10) || '').scrub(' ').split('').include?('m')\n end\n\n atlas_007_match = record.fields('007').find do |field|\n field.value.byteslice(0..1) == 'ad'\n end\n \n return true if (marc_leader_06_match &&\n marc_leader_07_match &&\n marc_008_24_27_match) ||\n marc_006_match ||\n atlas_007_match\n end",
"def change_leader\n leader=node.xpath(\"//marc:leader\", NAMESPACE)[0]\n if leader\n leader.content=leader.content.sub(/^...../, \"00000\" )\n end\n controlfield = node.xpath(\"//marc:controlfield[@tag='001']\", NAMESPACE).first\n if Brno.collections.include?(controlfield.content.to_i)\n leader.content=leader.content.sub(\"00000ndm\", \"00000ndc\")\n end\n if Brno.prints.include?(controlfield.content.to_i)\n leader.content=leader.content.sub(\"00000ncm\", \"00000ndm\")\n end\n end",
"def leader\n @leader = SQF.leader @this\n @leader\n end",
"def author; end",
"def award\n\tend",
"def offences_by; end",
"def resolved_author; end",
"def anchored; end",
"def leader_board(scores)\r\n \r\n end",
"def leader\n return (@attributes & 0x08 == 0x08)\n end",
"def jack_handey; end",
"def aon; end",
"def leader _args\n \"leader _args;\" \n end",
"def leader\n department.leader\n end",
"def affichage_player\n\n\n end",
"def abbr; end",
"def abbr; end",
"def abbr; end",
"def abbr; end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def update\n raise 'Unimplemented award type update!'\n end",
"def soft_ace\n # softy method refactor for when an ace is played\nend",
"def fix_leader!(leader)\n\n if leader.length < 24\n # pad it to 24 bytes, leader is supposed to be 24 bytes\n leader.replace( leader.ljust(24, ' ') )\n elsif leader.length > 24\n # Also a problem, slice it\n leader.replace( leader.byteslice(0, 24))\n end\n # http://www.loc.gov/marc/bibliographic/ecbdldrd.html\n leader[10..11] = '22'\n leader[20..23] = '4500'\n\n if settings['horizon.destination_encoding'] == \"UTF8\"\n leader[9] = 'a'\n end\n\n # leader should only have ascii chars in it; invalid non-ascii\n # chars can cause ruby encoding problems down the line.\n # additionally, a force_encoding may be neccesary to\n # deal with apparent weird hard to isolate jruby bug prob same one\n # as at https://github.com/jruby/jruby/issues/886\n leader.force_encoding('ascii')\n\n unless leader.valid_encoding?\n # replace any non-ascii chars with a space.\n\n # Can't access leader.chars when it's not a valid encoding\n # without a weird index out of bounds exception, think it's\n # https://github.com/jruby/jruby/issues/886\n # Grr.\n\n #leader.replace( leader.chars.collect { |c| c.valid_encoding? ? c : ' ' }.join('') )\n leader.replace(leader.split('').collect { |c| c.valid_encoding? ? c : ' ' }.join(''))\n end\n\n\n\n end",
"def mambo_no_5; end",
"def borrower\n end",
"def is_book?()\n end",
"def leader?\n if self.role and self.role < 2 \n true\n end\n end",
"def leader_break_point=(point)\n end",
"def author_hash; end"
] | [
"0.58043206",
"0.56808156",
"0.5354745",
"0.5329781",
"0.53210366",
"0.5291353",
"0.52802956",
"0.5271217",
"0.5253043",
"0.52498794",
"0.5244782",
"0.5195514",
"0.5195438",
"0.51704353",
"0.51378924",
"0.5125665",
"0.51195174",
"0.51195174",
"0.51195174",
"0.51195174",
"0.51077443",
"0.5091706",
"0.50844556",
"0.5077042",
"0.50684917",
"0.5065532",
"0.5065071",
"0.5062099",
"0.50571156",
"0.50548345"
] | 0.5802138 | 1 |
Add more than one element at the same time. See push. The elements object must respond to to_a, or be a PQueue itself. | def concat(elements)
if empty?
if elements.kind_of?(PQueue)
initialize_copy(elements)
else
replace(elements)
end
else
if elements.kind_of?(PQueue)
@que.concat(elements.que)
sort!
else
@que.concat(elements.to_a)
sort!
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(*elements)\n @buffer.push(*elements)\n @buffer = @buffer[-@size, @size] if(@buffer.size > @size)\n end",
"def push(element)\t\t\n\t\twhile !@q1.empty? do\n\t\t\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\n\t\tend\n\t\t@q1.enq(element)\n\t\twhile !@q2.empty? do\n\t\t\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\n\t\tend\t\n\tend",
"def push (*args)\n\n args.each { |a| self << a }\n\n self\n end",
"def add(*args); elements.add(*args); end",
"def push *items\n @items.concat items\n end",
"def push(element); end",
"def push_multi(items)\n raise ArgumentError, \"push multi takes an array!, not an #{items.class}!\" unless items.is_a?(Array)\n synchronize do |buffer|\n items.each {|item| push_unsafe(item) }\n end\n end",
"def push(*objects)\n @ary.push(*objects)\n self\n end",
"def push(element)\r\n # IMPLEMENTME!\r\n end",
"def push *items\n @components ||= []\n @components.push items\n self\n end",
"def push(*items)\n items = _ensure_array_is_valid items\n super\n end",
"def enqueue(el)\n self.queue_var = [el] + self.queue_var \n end",
"def multi_push(items)\n lock.synchronize do\n items.each do |item_pair|\n item, cost = item_pair\n if(queue[item])\n raise ArgumentError,\n \"Item already exists in queue. Items must be unique! (#{item})\"\n end\n unless(cost.is_a?(Numeric) || cost.is_a?(Proc))\n raise ArgumentError,\n \"Cost must be provided as parameter or proc! (item: #{item})\"\n end\n @block_costs += 1 if cost.is_a?(Proc)\n queue[item] = cost\n end\n end\n sort!\n self\n end",
"def push(*obj)\n obj.each {|obj| self << obj }\n self\n end",
"def addToQueue(items)\n if( items.is_a? DataSet ) then\n\t@itemList.push( items )\n elsif( items.is_a? Array ) then\n\titems.each { |i| addToQueue(i) }\n end\n end",
"def push(elt)\n @elements << elt\n end",
"def unique_push!(*elements)\n elements.each do |element|\n self << element unless self.include?(element)\n end\n self\n end",
"def push(*rest) end",
"def push *parts\n @parts.concat parts\n end",
"def push(*items)\n items = items.dup\n EM.schedule { items.each { |i| @subs.values.each { |s| s.call i } } }\n end",
"def add(element)\n @push_stack.push(element)\n end",
"def push(element)\n # IMPLEMENT ME!\n end",
"def push *parts\n self.parts.concat parts\n end",
"def add_bulk(queue, items = [])\n items.each do |item|\n add(queue, item)\n end\n end",
"def push_many(items)\n # we're expecting items to have an nested array of args, lets take each one and correctly normalize them\n payloads = items[:args].map do |args|\n fail ArgumentError, \"Bulk arguments must be an Array of Arrays: [[:foo => 'bar'], [:foo => 'foo']]\" unless args.is_a?(Array)\n # clone the original items (for :queue, :class, etc..)\n item = items.clone\n # merge this item's args (eg the nested `arg` array)\n item.merge!(args: args) unless args.empty?\n # normalize this individual item\n normalize_item(item)\n end.compact\n\n # if successfully persisted to redis return the size of the jobs\n pushed = false\n pushed = raw_push(payloads) unless payloads.empty?\n pushed ? payloads.size : nil\n end",
"def add(*elems)\r\n elems.each do |e|\r\n i = @arr.find_index { |o| @ordering.call e, o }\r\n i ||= @arr.size\r\n @arr.insert i, e\r\n end\r\n self\r\n end",
"def push(element)\n # get the current length of array\n # because we will be using it several times\n current_length = @items.length\n\n # check if stack is empty\n if @count == 0\n # if so create array with size 1\n @items = Array.new(1)\n elsif @count == current_length\n # if stack is not empty then double size of array\n new_array = Array.new(current_length * 2)\n\n # copy old array onto new array\n @items.each_with_index do |item, i|\n new_array[i] = item\n end\n\n # set items to new_array\n @items = new_array\n end\n\n # set last element to element added\n @items[@count] = element\n\n # add 1 to the count\n @count += 1\n end",
"def push(x)\n @q << x \n end",
"def push(x)\n @q1.push x\n end",
"def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end"
] | [
"0.71183294",
"0.69999754",
"0.69036263",
"0.68946546",
"0.6850859",
"0.6717591",
"0.66829216",
"0.6616964",
"0.6426364",
"0.6424759",
"0.64021474",
"0.6345348",
"0.631591",
"0.6315654",
"0.62973654",
"0.6258348",
"0.6230813",
"0.62253976",
"0.6194361",
"0.61846006",
"0.6163161",
"0.6148191",
"0.6146203",
"0.60891306",
"0.60850185",
"0.6072976",
"0.6066123",
"0.604601",
"0.60453093",
"0.60399204"
] | 0.7095438 | 1 |
Replace the content of the heap by the new elements. The elements object must respond to to_a, or to be a PQueue itself. | def replace(elements)
if elements.kind_of?(PQueue)
initialize_copy(elements)
else
@que.replace(elements.to_a)
sort!
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat(elements)\n if empty?\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n replace(elements)\n end\n else\n if elements.kind_of?(PQueue)\n @que.concat(elements.que)\n sort!\n else\n @que.concat(elements.to_a)\n sort!\n end\n end\n self\n end",
"def dup\n copy = Queue.new\n copy.size = @size\n copy.elements = @elements\n copy\n end",
"def heapify(queue)\n (queue.length - 1).downto(1) do |i|\n if queue[i].value > queue[i-1].value\n queue[i], queue[i-1] = queue[i-1], queue[i]\n else\n break\n end\n end\n end",
"def push(*elements)\n @buffer.push(*elements)\n @buffer = @buffer[-@size, @size] if(@buffer.size > @size)\n end",
"def enqueue(new_element)\n if is_empty?\n @front = @rear = 0\n elsif is_full\n puts \"Queue is full or create another array and copy queue\" \n return\n else\n @rear = (@rear + 1) % @size_of_array\n end\n @queue_array[@rear] = new_element\t\n end",
"def shift\n if @elements.empty?\n return nil\n end\n\n swap(0,@elements.size-1)\n ele = @elements.pop\n heapify(0)\n ele\n end",
"def build_heap\n unless @elements.empty?\n i = (@elements.size-1)/2\n while i>=0\n heapify(i)\n i -= 1\n end\n end\n end",
"def push(v)\n @que << v\n reheap(@que.size-1)\n self\n end",
"def pop\n return nil if @elements.length == 0\n tmp = @elements.shift\n @elements.unshift @elements.pop\n heapify_down\n return tmp\n end",
"def push(element); end",
"def enqueue(el)\n self.queue_var = [el] + self.queue_var \n end",
"def enqueue(element)\n if element.class.name == \"RealQueue\"\n require 'pry'\n binding.pry\n end\n @store.unshift(element)\n self\n end",
"def push(element)\t\t\n\t\twhile !@q1.empty? do\n\t\t\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\n\t\tend\n\t\t@q1.enq(element)\n\t\twhile !@q2.empty? do\n\t\t\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\n\t\tend\t\n\tend",
"def push(value)\n @count += 1\n new_element = RubyDS::StackQueue::Element.new(value)\n if @head.nil?\n @head = new_element\n else\n new_element.next = @head\n @head = new_element\n end\n end",
"def ensure_order_and_write\n fill_queues\n unless @heap.empty?\n #extract the minimum element from the heap \n extracted_el = @heap.extract\n write_to_disk(extracted_el)\n #add the next element from the same thread to the heap\n from_queue = extracted_el[:thread]\n fill_queues\n next_el = @thread_queues[from_queue].shift\n if next_el\n @heap.push(next_el) \n end\n end\n end",
"def push(val)\n @store << val\n idx = count - 1\n @store = BinaryMinHeap.heapify_up(@store, idx, &prc)\n end",
"def insert_into_p_queue(queue, word_info)\n queue << word_info\n percolate_up_by_distance(queue, queue.length - 1)\nend",
"def heapify!\n (length / 2).downto(1) { |i| sink(i) }\n end",
"def push(node)\n new_index = (@nodeset << node).length - 1\n heapify_up new_index\n self\n end",
"def insert(data)\n @nodes << data\n heapify_up\n end",
"def pop\n @heap.pop\n end",
"def queue(a)\n p \"Before: #{a}\"\n a.push(6)\n a.shift(1)\n p \"After: #{a}\"\nend",
"def enqueue(el)\n @queue << el\n el\n end",
"def push(val)\n resize! if self.length == self.capacity\n self.length += 1 \n self[length - 1] = val \n nil \n end",
"def push(element)\r\n # IMPLEMENTME!\r\n end",
"def insert( heap_objects )\n heap_objects = [heap_objects] unless heap_objects.is_a? Array\n insert_heap_objects(heap_objects)\n insert_references(heap_objects)\n self\n end",
"def enqueue(element)\n @queue.insert(@queue.length, element)\n @head = @queue.first\n @tail = @queue.last\n end",
"def push(element)\n @data[@data.length] = element\n end",
"def heapify\n for i in (0..(@ary.size-1)).to_a.reverse\n upheap(i)\n downheap(i)\n end\n end",
"def insert(value)\n self.heap.append(value)\n self.sift_up(self.heap.length-1, self.heap)\n end"
] | [
"0.67022765",
"0.6239388",
"0.61114365",
"0.6087757",
"0.60655946",
"0.60194683",
"0.59953433",
"0.5975584",
"0.5920956",
"0.5873406",
"0.5853339",
"0.58486205",
"0.58019364",
"0.57722855",
"0.5754801",
"0.57451075",
"0.57240033",
"0.57193977",
"0.5713128",
"0.5706845",
"0.5623927",
"0.56188834",
"0.56059515",
"0.5593458",
"0.55896515",
"0.55819243",
"0.5578263",
"0.555688",
"0.5550421",
"0.5548694"
] | 0.816831 | 0 |
The element at index k will be repositioned to its proper place. This, of course, assumes the queue is already sorted. | def reheap(k)
return self if size <= 1
que = @que.dup
v = que.delete_at(k)
i = binary_index(que, v)
que.insert(i, v)
@que = que
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def insert j, k\n if k && k != 0 && greater_than?(k, j) && less_than?(k - 1, j)\n self[k] = j\n return k\n end\n \n hi = -1\n \n if k && k != 0\n hi = k\n elsif !empty?\n hi = last_key\n end\n\n # off the end?\n if hi == -1 || j > last_value\n append j\n return hi + 1\n end\n \n # binary search for insertion point:\n lo = 0\n\n while lo <= hi\n index = (hi + lo) / 2\n val = self[index]\n cmp = j <=> val\n\n if cmp == 0\n return nil\n elsif cmp > 0\n lo = index + 1\n else\n hi = index - 1\n end\n end\n\n self[lo] = j\n lo\n end",
"def kthIndex(k)\n if(@indexList[k] < 0) then\n return @base.size + 1 + @indexList[k] + k ;\n else\n return @indexList[k] + k ;\n end\n end",
"def rotate(nums, k)\n k.times do\n el = nums.pop\n nums.unshift(el)\n end\nend",
"def rotate(nums, k)\n for i in 0...k\n nums.insert(0,nums.last)\n nums.pop\n end\nend",
"def rotate(nums, k)\n k.times do\n ele = nums.pop\n nums.unshift(ele)\n end\nreturn nums\nend",
"def kth_from_last(k)\n i = 0\n l = @head\n t = @head\n\n while l\n l = l.next\n i += 1\n t = t.next if i > k\n end\n t\n end",
"def rotate(nums, k)\n result = []\n len = nums.length\n for i in (len-k)...len\n result << nums[i]\n end\n \n for i in (0...len-k)\n result << nums[i]\n end\n \n result.each_with_index do |n, j|\n nums[j] = result[j]\n end\nend",
"def kth_to_last_element(head, k)\n # First pointer (tail) will be k nodes ahead of second. When tail hits the end,\n # second will be k elements from the end \n tail = head\n second = head\n elements_apart = 0\n until tail.next.nil?\n tail = tail.next\n # Increment second if they are k elements apart, or just increment elements apart\n elements_apart == k ? second = second.next : elements_apart += 1\n end\n # Return nil if there are less than k elements\n elements_apart == k ? second : nil\nend",
"def reposition_queue\n task_queue = TaskQueue.where(user_id: user_id, task_type_id: task_type_id)\n if task_queue.pluck(:position).any? {|pos| pos > position}\n task_queue.where(\"position > ?\", position).each do |queue_item|\n queue_item.update(:position => (queue_item.position - 1))\n end\n end\n end",
"def up_heap(ary, k)\n p = (k - 1)/2\n down = ary[k]\n while (k-1)/2 >= 0 and ary[(k-1)/2] < down\n ary[k] = ary[(k-1)/2]\n k = (k-1).abs/2\n break if k == 0 \n end\n ary[k] = down\nend",
"def eliminate_by(k)\n elem = self.head\n prev = elem\n\n k = k-1\n\n while prev != elem.next \n\n k.times do\n prev = elem\n elem = elem.next\n end\n\n prev.next = elem.next\n elem = prev.next\n end\n\n return prev.data\n\n end",
"def kth_from_last_element(head, k)\n cursor = head\n list_length = 1\n while(cursor.next)\n cursor = cursor.next\n list_length += 1\n end\n\n node_index = list_length - k\n cursor = head\n count = 1\n while(count < node_index)\n cursor = cursor.next\n count += 1\n end\n return cursor\n end",
"def reposition_element(index)\n return if size <= 1\n\n element = @backing_store.delete_at(index)\n index = binary_index(@backing_store, element)\n\n @backing_store.insert(index, element)\n end",
"def rotate3(nums, k)\n k.times do\n nums.unshift(nums.pop)\n end\n nums\nend",
"def find_k(k,arr)\n\t#need to sort the array\n\t#then can do negative index to find it\n\t#we can use quicksort\n\tdriver(lt,rt)\n\t#its sorted\n\t#then find the kth element, easy\n\tk = k * -1\n\tarr[k]\nend",
"def remove_at(list, k)\n list = list.dup\n return list.delete_at(k), list\nend",
"def reverse_k_group(head, k)\n count = 0\n it = head\n while it && count < k\n count += 1\n it = it.next\n end\n \n if count == k\n it = reverse_k_group(it, k)\n \n while count > 0\n count -= 1\n tmp = head.next\n head.next = it\n it = head\n head = tmp\n end\n \n head = it\n end\n \n head\nend",
"def kth_to_last(k)\n current = @head\n scout = current\n\n k.times do\n scout = scout.next\n end\n\n until scout.next.nil?\n current = current.next\n scout = scout.next\n end\n current.value\n end",
"def solution(a, k)\n # array length is zero or one the array should remain the same\n if(a.length > 1)\n # if k > length we should k%length and get the remainder to be the new k\n if(k > a.length)\n k = k % a.length\n end\n\n b = a[0, a.length - k]\n a = a[a.length - k, a.length]\n a = a + b\n end\n a\nend",
"def kth_largest(arr, k)\n curr = 0\n h = Heap.new\n\n k.times do \n h.insert(arr[curr])\n curr += 1\n end\n\n while curr < arr.length \n if arr[curr] > h.peek\n h.remove\n h.insert(arr[curr])\n end\n\n curr += 1\n end\n\n h.remove\nend",
"def initialize(k)\n @size = k\n @queue = []\n end",
"def kth(k)\n self[k - 1]\n end",
"def kth_to_last_space_optimized(head, k)\n count = 1\n current_node = head\n while current_node\n count += 1\n current_node = current_node.next\n end\n current_node = head\n target = count - k\n count = 1\n while current_node\n return current_node.value if count == target\n count += 1\n current_node = current_node.next\n end\nend",
"def rotate(a, k)\n return a if k == 0\n b = []\n length = a.length\n\n rotate = length - k\n\n b[0..k] = a[rotate..-1]\n b[k..-1] = a[0..rotate-1]\n\n b\nend",
"def place!(val, &block)\n pos = nil\n orig_size = self.size\n block ||= lambda{|a, b| a <=> b}\n self.each_with_index do |e, i|\n if block.call(e, val) == 1\n pos = i\n break\n end\n end\n return nil unless pos\n self.insert(pos, val)\n while self.size > orig_size\n self.pop\n end\n val\n end",
"def kth_largest(arr, k)\n return nil if k > arr.length\n heaped, remaining = arr[0..k-1], arr[k..-1]\n heap = Heap.new(heaped)\n remaining.each do |n|\n if n > heap.top \n heap.pop!\n heap.push(n)\n end\n end\n heap.top\nend",
"def move_joker_b\n b_pos = $deck.find_index('B')\n $deck.delete('B')\n if b_pos == 51\n $deck << 'B'\n else\n $deck.insert (b_pos + 2) % 53, 'B'\n end\nend",
"def move_prioritized_issue_to_position_in_bucket(position, bucket)\n log(:prioritize_issue) do\n prioritized_issue.move_to_bucket(bucket, position)\n end\n\n prioritized_issue\n end",
"def quick_sort(p,k)\n unless k-p==0\n pivot_pos=p\n (p+1).upto(k) do |x|\n if @kolekcja_to_sort.get(pivot_pos) > @kolekcja_to_sort.get(x)\n x.downto(pivot_pos+1) do |y|\n @kolekcja_to_sort.swap(y,y-1)\n end\n pivot_pos+=1\n end\n end\n if(pivot_pos>p)\n quick_sort(p,pivot_pos-1)\n end\n if(pivot_pos<k)\n quick_sort(pivot_pos+1,k)\n end\n end\n end"
] | [
"0.6250075",
"0.61070997",
"0.60651135",
"0.6045751",
"0.60389817",
"0.59790665",
"0.595738",
"0.5896565",
"0.5881073",
"0.5860043",
"0.5823886",
"0.5811274",
"0.57280874",
"0.57280266",
"0.5724399",
"0.56896585",
"0.56732404",
"0.56697774",
"0.5659419",
"0.56568813",
"0.5654309",
"0.56511915",
"0.56433827",
"0.56154114",
"0.5610142",
"0.5607332",
"0.56010413",
"0.55968237",
"0.55932873",
"0.5588381"
] | 0.69713724 | 0 |
Sort the queue in accorance to the given comparison procedure. | def sort!
@que.sort! do |a,b|
case @cmp.call(a,b)
when 0, nil then 0
when 1, true then 1
when -1, false then -1
else
warn "bad comparison procedure in #{self.inspect}"
0
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort!\n lock.synchronize do\n queue.replace(\n Hash[\n queue.sort do |x,y|\n x,y = y,x if @reverse_sort\n (x.last.respond_to?(:call) ? x.last.call : x.last).to_f <=>\n (y.last.respond_to?(:call) ? y.last.call : y.last).to_f\n end\n ]\n )\n end\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a,b| a<=>b} # ||= if there are no procs given there I will create one A.K.A nill value for args given\n prc.(self)\n \n sorted = false\n while !sorted \n sorted = true\n (0...self.length - 1).each do |i| \n if prc.(self[i],self[i+1]) == 1 #giving the proc 2 values to compare\n sorted = false # change to false to make the loop run again\n self[i], self[i+1] = self[i+1], self[i] # this is swapping the elements' order\n end\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a <=> b }\n self.sort! &prc\n end",
"def collect_compare_priority\n @compare_quque = []\n @compare_quque = ComparisonTable.sort_by{|k, dar|\n DisplayOrder[StringTable[dar.first]] ? DisplayOrder[StringTable[dar.first]] : DisplayOrder[MISC_text]\n }.collect{|p| p[0]}\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new{|a,b| a <=> b }\n\n sorted = false\n while !sorted\n sorted = true\n\n (0...self.length - 1).each do |i|\n # debugger\n if prc.call(self[i], self[i + 1]) == 1 # REMEBER: spaceship operator returns a number! only 0 is falsey\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n end\n end\n\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a<=>b }\n sorted = false\n while !sorted\n sorted = true\n (0...self.size-1).each do |i|\n if prc.call(self[i], self[i+1]) == 1\n self[i], self[i+1] = self[i+1], self[i]\n sorted = false\n end\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a <=> b }\n sorted = false \n while !sorted \n sorted = true \n (0...self.length-1).each do |i|\n if prc.call(self[i], self[i+1]) == 1\n self[i], self[i+1] = self[i+1], self[i]\n sorted = false \n end \n end \n end \n self \n end",
"def bubble_sort(&prc)\n prc ||= Proc.new{ |ele1, ele2| ele1 <=> ele2 }\n\n sorted = false\n while !sorted\n sorted = true\n # check every pair in array and sort it if necessary \n (0...self.length - 1).each do |i|\n # if prc.call == 1: sort incr; prc.call == -1: sort decr \n if prc.call(self[i], self[i+1]) == 1\n self[i], self[i+1] = self[i+1], self[i]\n sorted = false\n end\n end\n end\n\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a,b| a <=> b}\n sorted = false\n while ! sorted\n sorted= true\n (0...self.length-1).each do |i|\n if prc.call(self[i], self[i+1]) == 1\n self[i], self[i+1] = self[i+1], self[i]\n sorted = false\n end\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a <=> b }\n\n sorted = false\n while !sorted\n sorted = true\n (0...self.length - 1).each do |i|\n if prc.call(self[i], self[i + 1]) == 1\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n end\n end\n \n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a <=> b}\n \n sorted = false\n while !sorted\n sorted = true\n \n\n (0...self.length - 1).each do |i|\n if prc.call(self[i], self[i + 1]) == 1\n sorted = false\n self[i], self[i + 1] = self[i + 1], self[i]\n end\n end\n end\n\n self\n end",
"def sort_operations\n operations.sort! { |a, b| sort_list(b, a) <=> sort_list(a, b) }\n end",
"def bubble_sort_rec(&prc)\n end",
"def bubble_sort(&prc)\n sorted = true\n if prc == nil #sort by increasing order probably numbers\n while sorted\n sorted = false\n self.each_with_index do |ele,idx|\n if (self[idx+1] !=nil) && (self[idx] > self[idx+1])\n self[idx] , self[idx+1] = self[idx+1] , self[idx]\n sorted = true\n end\n end\n end\n else\n while sorted\n sorted= false\n self.each_with_index do |ele,idx|\n if (self[idx+1] !=nil) && prc.call(self[idx],self[idx+1]) == 1\n self[idx] , self[idx+1] = self[idx+1] , self[idx]\n sorted = true\n end\n end\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a, b| a <=> b}\n sorted = false\n\n until sorted\n sorted = true\n i = 0\n while i < self.length - 1\n if prc.call(self[i], self[i + 1]) == 1\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n i += 1\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc = prc || Proc.new{|a,b| a <=> b}\n sorted = false\n\n until sorted\n sorted = true\n (0...self.length-1).each do |idx|\n if prc.call(self[idx], self[idx + 1]) > 0\n self[idx], self[idx + 1] = self[idx + 1], self[idx]\n sorted = false\n end\n end\n end\n self # return the sorted array\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new do |a, b| \n if self[b] && (self[b] < self[a]) \n self[a], self[b] = self[b], self[a] \n true\n else false\n end\n end\n loop do \n swapped = false \n self.each.with_index do |x, i|\n swapped = true if prc.call(i, i+1)\n end\n break if !swapped\n end\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a, b| a <=> b}\n sorted = false\n while !sorted\n sorted = true\n (0...self.length - 1).each do |i|\n if prc.call(self[i], self[i + 1]) == 1\n self[i], self[i + 1] = self[i + 1], self[i]\n sorted = false\n end\n end\n end\n self\n end",
"def apply\n jobs.sort_by.with_index { |job, ix| order(job, ix) }\n end",
"def sort_ops\n operations.running.sort_by { |op| sort_array(op) }.extend(OperationList)\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new { |a, b| a <=> b }\n sorted = false\n\n while !sorted\n sorted = true\n\n (0...self.length - 1).each do |i|\n a = self[i]\n b = self[i + 1]\n\n if prc.call(a, b) == 1\n self[i], self[i + 1] = b, a\n\n sorted = false\n end\n end\n end\n\n self\n end",
"def bubble_sort!(&prc)\n \n end",
"def bubble_sort!(&prc)\n\n end",
"def quick_sort(&prc)\n end",
"def bubble_sort!(&prc)\n end",
"def bubble_sort!(&prc)\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a, b| a <=> b}\n\n (0...self.length).each do |index1|\n (0...self.length-1-index1).each do |index2|\n self[index2], self[index2+1] = self[index2+1], self[index2] if prc.call(self[index2], self[index2+1]) === 1\n end\n end\n self\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new{|n1, n2| n1 <=> n2}\n\n (0...self.length - 1).each do |i|\n (i + 1...self.length).each do |j|\n if prc.call(self[i], self[j]) == 1\n self[i], self[j] = self[j], self[i]\n end\n end\n end\n self\n end",
"def sort_queue(attribute)\n puts \"Just about to sort the queue\"\n @queue = @queue.sort_by do |person|\n person[attribute.to_sym].downcase\n end\n queue_print\n end",
"def bubble_sort(&prc)\n prc ||= Proc.new {|a,b| a <=> b}\n sorted = false\n while !sorted\n sorted = true\n self.each_with_index do |value, idx|\n if (self[idx+1] != nil) && (prc.call(self[idx], self[idx+1]) == 1)\n self[idx], self[idx+1] = self[idx+1], self[idx]\n sorted = false\n end\n end\n end\n return self\n end"
] | [
"0.73638964",
"0.71395195",
"0.6997533",
"0.68154347",
"0.6751926",
"0.6711971",
"0.6680894",
"0.663361",
"0.66243804",
"0.6619262",
"0.66104317",
"0.66002417",
"0.6572275",
"0.654175",
"0.65317494",
"0.65134597",
"0.65091723",
"0.6505699",
"0.6491581",
"0.6463892",
"0.64542276",
"0.6450631",
"0.6449892",
"0.64348495",
"0.6430931",
"0.6430931",
"0.6429415",
"0.64215887",
"0.63760215",
"0.63745725"
] | 0.7416512 | 0 |
Parse line for authentication failures, attempts are turned in to objects | def parseLine(line)
if line.include? "Failed password" and !line.include? "invalid user"
lineArray = line.split(pattern=" ")
$attempts.push(Attempt.new(lineArray[0], lineArray[1], lineArray[2], lineArray[10]))
#noticed someone was brute forcing my ssh while I left it on overnight, noticed having
#an invalid user changed the wording in /var/log/secure and had to change to this logic
elsif line.include? "Failed password" and line.include? "invalid user"
lineArray = line.split(pattern=" ")
$attempts.push(Attempt.new(lineArray[0], lineArray[1], lineArray[2], lineArray[12]))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_shadow_line(line)\n x = line.split(':')\n {\n 'user' => x.at(0),\n 'password' => x.at(1),\n 'last_change' => x.at(2),\n 'min_days' => x.at(3),\n 'max_days' => x.at(4),\n 'warn_days' => x.at(5),\n 'inactive_days' => x.at(6),\n 'expiry_date' => x.at(7),\n 'reserved' => x.at(8),\n }\n end",
"def is_entry!(line)\n raise InvalidPasswdEntry, \"line commented out\" if line =~ /\\A#/\n parts = line.strip.split(\":\")\n raise InvalidPasswdEntry, \"line must be of the format username:password\" if parts.size != 2\n return parts\n end",
"def parse_and_validate_line(line)\n\n entry = parse_entry(line)\n return entry unless entry.parse_ok?\n\n valid_chain=is_valid_hash(entry)\n @invalid += 1 if valid_chain === false\n @num += 1\n\n entry\n end",
"def parse_errors(response_string)\n pairs = response_string.split(@field_delim)\n pairs.each do |p|\n k,v = p.split(@value_delim)\n k = generate_error_key(k,v)\n @errors[k] = v\n end\n end",
"def parse_failure_cause; end",
"def process_auth str\n if respond_to?(:authenticate)\n if @state.include?(:auth)\n reply 503, \"auth already issued\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n # There is a common misconception that the data has to be sent with the AUTH command\n @state << :auth_plain_incomplete\n reply 334, \"\"\n else\n # we got the initial response, so go ahead & process it\n process_auth_plain_line($')\n end\n elsif str =~ /\\ALOGIN\\s?/i\n if $'.length == 0\n @state << :auth_login_incomplete\n reply 334, \"VXNlcm5hbWU6\" # 'Username:' in Base64\n else\n process_auth_login_line($')\n end\n #elsif str =~ /\\ACRAM-MD5/i\n else\n reply 504, \"auth mechanism not available\"\n end\n else\n process_unknown\n end\n end",
"def parse_line\n s0 = @scanner.pos\n match_spaces\n s2 = parse_te\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s4 = @scanner.pos\n s5 = parse_fugou\n if s5 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n s6 = parse_from\n if s6 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n @reported_pos = s4\n s4 = transform_teban_fugou_from(s2, s5, s6)\n end\n end\n if s4 == :failed\n s4 = @scanner.pos\n s5 = []\n s6 = match_regexp(/[^\\r\\n ]/)\n while s6 != :failed\n s5 << s6\n s6 = match_regexp(/[^\\r\\n ]/)\n end\n @reported_pos = s4\n s4 = s5.join\n end\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s6 = parse_time\n s6 = nil if s6 == :failed\n match_str('+')\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'move' => s4, 'time' => s6 }\n end\n end\n end\n s0\n end",
"def process_auth str\n if @state.include?(:auth)\n send_data \"503 auth already issued\\r\\n\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n @state << :auth_incomplete\n send_data(\"334 \\r\\n\")\n else\n # we got the initial response, so go ahead & process it\n process_auth_line($')\n end\n #elsif str =~ /\\ALOGIN\\s+/i\n else\n send_data \"504 auth mechanism not available\\r\\n\"\n end\n end",
"def process_login_response(email, password, response)\n @email = email\n @password = password\n @token = Parser.extract_user_token response\n @id = Parser.login_object_id response\n @xp = Parser.extract_xp response\n end",
"def parse_line(line)\n results = LineRegexp.match(line)\n if results \n @elements[:line] = results[-1]\n results[-1] # remaining line \n else\n @elements[:line] = line\n line \n end\n end",
"def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n if line[0].eql?('/')\n parse_comment_line line.chomp\n throw :line_parsed\n end\n\n logger.error \"Can't understand line: #{line.chomp.inspect}\"\n end\n end",
"def process_authorization(session)\n args = session.args\n\n if (session.reply.body.status_passadd?)\n args = session.reply.body.args\n session.pass_fail[:pass] = true\n session.pass_fail[:pass_type] = :add\n elsif (session.reply.body.status_passrepl?)\n args = session.reply.body.args\n session.pass_fail[:pass] = true\n session.pass_fail[:pass_type] = :repl\n end\n\n session.pass_fail[:server_msg] = session.reply.body.server_msg\n session.pass_fail[:data] = session.reply.body.data\n session.pass_fail[:args] = args\n session.terminate = true\n return(nil)\n end",
"def parseusers(f, userentryptr)\n f.seek(userentryptr + 0x14)\n dstart = makefptr(f.read(4))\n f.seek(userentryptr + 0x1C)\n numentries = makelong(f.read(4))\n f.seek(userentryptr + 0x60)\n headerlen = makeword(f.read(2))\n f.seek(userentryptr + 40) # sorry decimal\n entrylen = makeword(f.read(2)) # sorry this is decimal\n logins = Rex::Text::Table.new(\n 'Header' => \"D20 usernames, passwords, and account levels\\n(use for TELNET authentication)\",\n 'Indent' => 1,\n 'Columns' => [\"Type\", \"User Name\", \"Password\"])\n\n 0.upto(numentries -1).each do |i|\n f.seek(dstart + headerlen + i * entrylen)\n accounttype = makeword(f.read(2))\n f.seek(dstart + headerlen + i * entrylen + 2)\n accountname = makestr(f, dstart + headerlen + i * entrylen + 2)\n f.seek(dstart + headerlen + i * entrylen + 2 + 22)\n accountpass = makestr(f, dstart + headerlen + i * entrylen + 2 + 22)\n if accountname.size + accountpass.size > 44\n print_error(\"Bad account parsing at #{dstart + headerlen + i * entrylen}\")\n break\n end\n logins << [accounttype, accountname, accountpass]\n report_cred(\n ip: datastore['RHOST'],\n port: 23,\n service_name: 'telnet',\n user: accountname,\n password: accountpass,\n proof: accounttype\n )\n end\n if not logins.rows.empty?\n loot = store_loot(\n \"d20.user.creds\",\n \"text/csv\",\n datastore['RHOST'],\n logins.to_s,\n \"d20_user_creds.txt\",\n \"General Electric TELNET User Credentials\",\n datastore['RPORT']\n )\n print_line logins.to_s\n print_status(\"Loot stored in: #{loot}\")\n else\n print_error(\"No data collected\")\n end\n end",
"def parse_response(response)\n data = response.body\n\n data.split(ROWS_SPLITTER).inject([]) do |array, row|\n suffix, occurrences = row.split(ATTRIBUTES_SPLITTER)\n\n if occurrences.to_i > 0\n array << Models::Password.new(suffix: suffix, occurrences: occurrences.to_i)\n end\n\n array\n end\n end",
"def parse_error(err)\n if err[:errors]\n err[:errors].values.flatten.map { |nested_err| parse_error(nested_err) }\n elsif err[:failed_attribute] == 'Required'\n parse_error_for_required_attr(err)\n else\n parse_error_default(err)\n end\n end",
"def parse_response_line\n if @headers.first =~ /\\AHTTP\\/1\\.[01] ([\\d]{3})/\n @status = $1.to_i\n else\n set_deferred_status :failed, {\n :status => 0 # crappy way of signifying an unrecognized response. TODO, find a better way to do this.\n }\n close_connection\n end\n end",
"def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end",
"def parse_logline(line) \n line.strip!\n split_line = line.split(/\\|/)\n addr = split_line[0].split(',').last.strip\n\n unless (addr =~ /[\\s|\\-]+/) \n @dns_map.synchronize do\n addr = @dns_map[addr] if @dns_map.include? addr\n end\n details = {}\n details[:upstream_response_time] = split_line[1].split(',').last.strip.to_f\n details[:time_local] = DateTime.strptime(split_line[2], '%d/%b/%Y:%H:%M:%S %Z')\n details[:status] = split_line[3].to_i\n details[:request_length] = split_line[4].to_i\n details[:body_bytes_sent] = split_line[5].to_i\n\n\n @log_entries.synchronize do\n @log_entries[addr] << details\n end\n end \n end",
"def extract_status_line(line)\n line =~ /RTSP\\/(\\d\\.\\d) (\\d\\d\\d) ([^\\r\\n]+)/\n @rtsp_version = $1\n @code = $2.to_i\n @message = $3\n\n if @rtsp_version.nil?\n raise RTSP::Error, \"Status line corrupted: #{line}\"\n end\n end",
"def is_entry!(line)\n raise InvalidDigestEntry, \"line commented out\" if line =~ /\\A#/\n parts = line.strip.split(\":\")\n raise InvalidDigestEntry, \"line must be of the format username:realm:md5checksum\" if parts.size != 3\n raise InvalidDigestEntry, \"md5 checksum is not 32 characters long\" if parts.last.size != 32\n raise InvalidDigestEntry, \"md5 checksum has invalid characters\" if parts.last !~ /\\A[[:xdigit:]]{32}\\Z/\n return parts\n end",
"def parse(text)\n count = 1\n lines(text).collect do |line|\n count += 1\n if val = parse_line(line)\n val\n else\n error = Puppet::Error.new(\"Could not parse line #{line.inspect}\")\n error.line = count\n raise error\n end\n end\n end",
"def parse_line(line)\n host_ip, date, method_file_protocol, http_code, _ = @line_regex.match(line).captures\n file = @mfp_regex.match(method_file_protocol).captures[0]\n ip_token = host_ip.split(':')[1]\n\n date = Time.strptime(date, '%d/%b/%Y:%H:%M:%S %z').iso8601\n query_params = CGI::parse(URI(file).query)\n\n return {\n access_date: date,\n ip_token: ip_token,\n page_number: query_params[\"seq\"] || -1,\n http_code: http_code,\n volume_id: query_params[\"id\"]\n }\n end",
"def process_response(response)\n case response\n when Net::HTTPSuccess\n JSON.parse response.body\n when Net::HTTPUnauthorized\n { 'error' => \"#{response.message}:\n username and password set and correct?\" }\n when Net::HTTPServerError\n { 'error' => \"#{response.message}: try again later?\" }\n else\n { 'error' => response.message }\n end\n end",
"def process_line(line)\n if @state.include?(:data)\n process_data_line(line)\n elsif @state.include?(:auth_plain_incomplete)\n process_auth_plain_line(line)\n elsif @state.include?(:auth_login_incomplete)\n process_auth_login_line(line)\n else\n process_command_line(line)\n end\n !@state.include?(:quit) # return true unless QUIT is given\n end",
"def parse\n out = {}\n begin \n o = @line.match(/(.*?\\d\\d:\\d\\d:\\d\\d) (.*?) (.*?) (.*$)/ )\n out[\"date\"] = o.captures[0].to_ElasticDate\n out[\"machine\"] = o.captures[1]\n out[\"service\"] = o.captures[2]\n m = out[\"service\"].match(/\\[(\\d+)\\]\\:{0,1}/)\n if m then \n out[\"servicePid\"] = m.captures[0]\n out[\"serviceName\"] = out[\"service\"].sub(/\\[\\d+\\]\\:{0,1}/,\"\")\n elsif \n out[\"servicePid\"] = -1\n out[\"serviceName\"] = out[\"service\"].sub(/\\:$/,\"\")\n end\n out[\"message\"] = o.captures[3]\n out[\"parseFails\"] = false\n rescue => ex\n STDERR.puts \"--- Exception in parsing ----\"\n STDERR.puts \"#{@line}\"\n out[\"date\"] = DateTime.now().to_ElasticDate\n out[\"machine\"] = \"\"\n out[\"service\"] = \"\"\n out[\"serviceName\"] = \"\"\n out[\"servicePid\"] = \"\"\n out[\"message\"] = @line\n out[\"parseFails\"] = true\n end\n return out\n end",
"def _parse_irc_line(state, dir, req, line)\n cmd = ''\n line[-1, 1] = '' if line[-1, 1] == \"\\r\" # strip if necessary\n\n # Throw the generic IRC line event\n @event_collector.send(:irc_line) do\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport], :line => req.buff,\n :nick => req.nick, :server => req.server, :dir => dir }\n end\n\n # First let's get the \"command\" if there is one\n cpos = line.index(' ')\n cmd = line[0, cpos] if cpos\n \n # Commands in IRC put the \"verb\" up front\n if cmd.upcase == cmd\n case cmd\n # User is initiating login. More data to come soon.\n when 'NICK'\n req.nick = line.split.last\n\n # User is providing subsequent login data. Let's take a peek\n when 'USER'\n line = line.split\n req.username = line[1] \n req.mode = line[2] # Mode is used for arbitrary data\n req.unused = line[3] # So does the \"unused\" field\n req.real_name = (line[4..-1] || []).join(' ').sub(':', '')\n\n # Send in a login event\n @event_collector.send(:irc_login) do\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport],\n :nick => req.nick, :server => req.server,\n :username => req.username, :mode => req.mode, :dir => dir,\n :real_name => req.real_name, :unused => req.unused }\n end\n\n # Better indicator of channel joining than \"join\"\n when 'MODE'\n if line[cpos+1,1] == '#' # We're joining a channel\n @event_collector.send(:irc_channel_join) do\n channel = line.split[1]\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport],\n :nick => req.nick, :server => req.server,\n :channel => channel, :dir => dir }\n end\n end # of if-channel-join\n\n # Intercept an outgoing message\n when 'PRIVMSG'\n bpos = line.index(':', cpos)\n return nil unless bpos\n recipient = line[cpos...bpos].strip\n msg = line[bpos+1..-1]\n @event_collector.send(:irc_outgoing_msg) do\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport],\n :nick => req.nick, :server => req.server,\n :recipient => recipient, :body => msg, :dir => dir }\n end\n @event_collector.send(:protos_chat_message) do\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport], :dir => dir,\n :chat_dir => :outgoing, :recipient => recipient,\n :sender => req.nick, :protocol => :irc, :content => msg }\n end\n\n # User is leaving a channel\n when 'PART' \n if line[cpos+1,1] == '#' # We're leaving a channel\n @event_collector.send(:irc_channel_part) do\n channel = line.split[1]\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport], \n :nick => req.nick, :server => req.server,\n :channel => channel, :dir => dir }\n end\n end # of if-channel-part\n\n end # of case cmd\n\n # Notice messages in IRC put the verb in the middle, start with a ':'\n elsif line[0,1] == ':'\n npos = line.index(' ', cpos+1) # Find the second space\n cmd2 = line[cpos+1...npos]\n\n # If this is a number, then we can use it to get the server string\n if cmd2 =~ /^[0-9]{3}$/\n req.server ||= cmd.sub(':', '')\n\n # If we have a recognized, all-caps word then it's probably a verb!\n elsif cmd2.upcase == cmd2\n case cmd2\n\n # Someone is sending us (our our channel) a message\n when 'PRIVMSG'\n bpos = line.index(':', npos)\n return nil unless bpos\n recipient = line[npos...bpos].strip\n msg = line[bpos+1..-1]\n return nil if (msg[0] || 0) < 9\n sender = cmd.sub(':', '').split('!')\n @event_collector.send(:irc_incoming_msg) do\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport],\n :nick => req.nick, :server => req.server,\n :recipient => recipient, :body => msg, :dir => dir,\n :sender => sender[0], :sender_location => sender[1] }\n end\n @event_collector.send(:protos_chat_message) do\n unless recipient == req.nick\n recipient = \"#{recipient} (#{req.nick})\"\n end\n { :server_ip => str_ip(state.app_state[:dst]),\n :client_ip => str_ip(state.app_state[:src]),\n :server_port => state.app_state[:dport],\n :client_port => state.app_state[:sport], :dir => dir,\n :chat_dir => :incoming, :recipient => recipient,\n :sender => sender[0], :protocol => :irc, :content => msg }\n end\n\n end # of case cmd2\n end # of type-of-server-message\n\n # We don't understand this message. What the hell is it?\n else \n\n end # of line type\n end",
"def parse_entry(line)\n\n return nil if line.nil? || line.length <= 0\n meta,msg = line.split(' : ',2)\n msg = msg.chomp unless msg.nil?\n\n parts=meta.split(' ')\n\n fields=[]\n\n unless parts.length < 3\n fields_str=parts[2][1..-2]\n fields = fields_str.split(',')\n end\n\n Entry.new(parts[0], parts[1], fields, msg, line)\n end",
"def retry_with_auth(response)\n @already_tried_with_auth = true\n logger.info(\"Authentication Required. Retrying with auth info\")\n accessor.auth_manager.associate_auth_info(response)\n add_credentials!\n @body.rewind if @body # Its a stringIO, and we already fed it to the adapter once, so rewind it when we try again\n response = fetch_response\n end",
"def parse_input(input_string)\n # \"16-20 j: vjkjjcjjrjjmtnbjjjnj\"\n unparsed_rule, password = input_string.split(': ')\n min_max, letter = unparsed_rule.split(' ')\n min, max = min_max.split('-').map(&:to_i)\n\n rule = Rule.new(letter, min, max)\n\n [password, rule]\nend",
"def authenticate( raw_vals )\n\n username = (raw_vals[:username] || raw_vals['username']).to_s.strip\n password = (raw_vals[:password] || raw_vals['password']).to_s.strip\n ip_addr = (raw_vals[:ip_address] || raw_vals['ip_address']).to_s.strip\n user_agent = (raw_vals[:user_agent] || raw_vals['user_agent']).to_s.strip\n \n ip_addr = nil if ip_addr.empty?\n user_agent = nil if user_agent.empty?\n\n if username.empty? || password.empty?\n raise Wrong_Password, \"#{raw_vals.inspect}\"\n end\n mem = Life.find.username( username ).grab(:owner).go_first!\n\n # Check for Password_Reset\n raise Password_Reset::In_Reset, mem.inspect if mem.password_in_reset?\n\n # Check for too many failed attempts.\n # Raise Account::Reset if necessary.\n fail_count = Failed_Log_In_Attempt.for_today(mem).count\n if fail_count > 2\n mem.reset_password\n raise Password_Reset::In_Reset, mem.inspect\n end\n \n # See if password matches with correct password.\n correct_password = BCrypt::Password.new(mem.data.hashed_password) === (password + mem.data.salt)\n return mem if correct_password\n\n # Update failed count.\n new_count = fail_count + 1\n \n # Insert failed password.\n Failed_Log_In_Attempt.create(\n nil,\n :owner_id => mem.data._id, \n :ip_address => ip_addr,\n :user_agent => user_agent \n )\n\n raise Wrong_Password, \"Password is invalid for: #{username.inspect}\"\n end"
] | [
"0.59757906",
"0.58948463",
"0.581665",
"0.56030965",
"0.5596017",
"0.5577017",
"0.5551559",
"0.5501202",
"0.544915",
"0.54125816",
"0.5411792",
"0.5397847",
"0.5354549",
"0.53473306",
"0.5328617",
"0.5310893",
"0.5309286",
"0.53072184",
"0.52800006",
"0.52478695",
"0.5241923",
"0.5228205",
"0.52187115",
"0.5198512",
"0.51668006",
"0.51201963",
"0.51191044",
"0.508454",
"0.50659585",
"0.5058409"
] | 0.7923529 | 0 |
GET /cookbooks GET /cookbooks.json | def index
@cookbooks = Cookbook.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cookbooks = Cookbook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cookbooks }\n end\n end",
"def index\n @cook_books = CookBook.all\n end",
"def show\n @cookbook = Cookbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cookbook }\n end\n end",
"def show\n @cook_book = CookBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cook_book }\n end\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend",
"def new\n @cook_book = CookBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cook_book }\n end\n end",
"def index\n @cookbooks = Cookbook.includes(:cookbook_versions).order(:deprecated)\n\n @current_params = cookbook_index_params\n\n if @current_params[:q].present?\n @cookbooks = @cookbooks.search(@current_params[:q]).with_pg_search_rank\n end\n\n if @current_params[:featured].present?\n @cookbooks = @cookbooks.featured\n end\n\n if @current_params[:deprecated].blank?\n @cookbooks = @cookbooks.not_deprecated\n end\n\n if @current_params[:order].present?\n @cookbooks = @cookbooks.ordered_by(@current_params[:order])\n end\n\n if @current_params[:order].blank? && @current_params[:q].blank?\n @cookbooks = @cookbooks.order(:name)\n end\n\n apply_filters @current_params\n\n @number_of_cookbooks = @cookbooks.count(:all)\n @cookbooks = @cookbooks.page(cookbook_index_params[:page]).per(20)\n\n respond_to do |format|\n format.html\n format.atom\n end\n end",
"def new\n @cookbook = Cookbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cookbook }\n end\n end",
"def scubooks\n sections = Section.all\n render json: sections\n end",
"def show\n @cookbook = Cookbook.with_name(params[:cookbook]).\n includes(:cookbook_versions).first!\n @latest_cookbook_version_url = api_v1_cookbook_version_url(\n @cookbook, @cookbook.latest_cookbook_version\n )\n\n @cookbook_versions_urls = @cookbook.sorted_cookbook_versions.map do |version|\n api_v1_cookbook_version_url(@cookbook, version)\n end\n end",
"def list_books\n books = Book.all\n \n if books.count > 0\n render json: books\n else\n render json: {e:\"No books added\"}, :status => :error\n end\n end",
"def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end",
"def index\n @cookbooks = CookbooksDecorator.decorate_collection(Cookbook.all)\n end",
"def index\n @books = Book.all\n render json: @books\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def retrieved_cookbook(name, version, opts = {})\n if platform.server_api_version >= 2\n retrieved_cookbook_v2(name, version, opts)\n else\n retrieved_cookbook_v0(name, version, opts)\n end\n end",
"def index\n books = current_user.books.all\n render json: { books: books }\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index \n @cooks = Cook.all\n\n end",
"def cookbooks_by_name\n @cookbooks_by_name ||= Mash.new\n end",
"def index\n @cooks = Cook.includes(:user)\n end",
"def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end",
"def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend",
"def cookbook_url_base\n \"cookbooks\"\n end",
"def cookbooks\n get_directories_absolute_paths cookbooks_path\n end",
"def index\n if current_user\n @books = current_user.books\n render json: @books, status: 201\n end\n end",
"def search_for_google_books(search_term)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"\n response = RestClient.get(url)\n hash = JSON.parse(response)\n hash[\"items\"]\nend"
] | [
"0.7495707",
"0.69763726",
"0.6903592",
"0.6808471",
"0.66999954",
"0.6469998",
"0.6394657",
"0.6367011",
"0.6279346",
"0.62402105",
"0.61928874",
"0.6180782",
"0.6175882",
"0.6144232",
"0.6139425",
"0.6089647",
"0.6089177",
"0.6020467",
"0.6003112",
"0.5989565",
"0.59824216",
"0.5959511",
"0.59552646",
"0.59378517",
"0.5906544",
"0.5895411",
"0.5886131",
"0.5883932",
"0.58811677",
"0.585919"
] | 0.7134527 | 1 |
GET /coupons/new GET /coupons/new.json | def new
@coupon = current_user.coupons.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @coupon }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @coupon = Coupon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coupon }\n end\n end",
"def new\n @cupon = Cupon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cupon }\n end\n end",
"def new\n @coupon_type = CouponType.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @coupon_type }\n\t format.json { render :json => @coupon_type.to_a.to_json }\n end\n end",
"def create\n @coupling = Coupling.new(coupling_params)\n\n respond_to do |format|\n if @coupling.save\n format.html { redirect_to @coupling, notice: 'Coupling was successfully created.' }\n format.json { render :show, status: :created, location: @coupling }\n else\n format.html { render :new }\n format.json { render json: @coupling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @cocktail = Cocktail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cocktail }\n end\n end",
"def new\n @checkout = Checkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checkout }\n end\n end",
"def new\n @checkout = Checkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checkout }\n end\n end",
"def new\n @coupon = Coupon.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coupon }\n end\n end",
"def create\n @coupone = Coupone.new(coupone_params)\n\n respond_to do |format|\n if @coupone.save\n format.html { redirect_to admin_coupones_path, notice: 'Coupone was successfully created.' }\n format.json { render action: 'show', status: :created, location: @coupone }\n else\n format.html { render action: 'new' }\n format.json { render json: @coupone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @coupon = Coupon.new(coupon_params)\n\n respond_to do |format|\n if @coupon.save\n format.html { redirect_to admin_coupons_path, notice: 'Coupon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @coupon }\n else\n format.html { render action: 'new' }\n format.json { render json: @coupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @pickup = Pickup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pickup }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end",
"def new\n @coupon = params[:coupon_type].constantize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coupon }\n end\n end",
"def new\n @cocktail = Cocktail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cocktail }\n end\n end",
"def new\n @comming_soon = CommingSoon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comming_soon }\n end\n end",
"def create\n @payment_coupon = Payment::Coupon.new(payment_coupon_params)\n\n respond_to do |format|\n if @payment_coupon.save\n format.html { redirect_to payment_coupons_path, notice: 'Coupon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @payment_coupon }\n else\n format.html { render action: 'new' }\n format.json { render json: @payment_coupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @breadcrumb = 'create'\n @currency = Currency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @currency }\n end\n end",
"def new\n @squishee_cup = SquisheeCup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @squishee_cup }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def create\n @coupon = Coupon.new(coupon_params)\n\n respond_to do |format|\n if @coupon.save\n format.html { redirect_to @coupon, notice: 'Coupon was successfully created.' }\n format.json { render :show, status: :created, location: @coupon }\n else\n format.html { render :new }\n format.json { render json: @coupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @clonet = Clonet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clonet }\n end\n end",
"def new\n @currency = Currency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @currency }\n end\n end",
"def new\n @our_coin = OurCoin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @our_coin }\n end\n end",
"def create\n @coupon = Coupon.new(coupon_params)\n\n respond_to do |format|\n if @coupon.save\n format.html { redirect_to @coupon, notice: \"Coupon was successfully created.\" }\n format.json { render :show, status: :created, location: @coupon }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @coupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @coupon = Coupon.new(coupon_params)\n\n respond_to do |format|\n if @coupon.save\n format.html { redirect_to @coupon, notice: \"Coupon was successfully created.\" }\n format.json { render :show, status: :created, location: @coupon }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @coupon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @correlation = Correlation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @correlation }\n end\n end",
"def new\n @credit = Credit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @credit }\n end\n end",
"def new\n @credit = Credit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @credit }\n end\n end",
"def new\n @borrow_request = BorrowRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow_request }\n end\n end"
] | [
"0.7868737",
"0.7523434",
"0.72374946",
"0.7144004",
"0.70135856",
"0.70075905",
"0.70075905",
"0.7007119",
"0.69844955",
"0.6973801",
"0.69477874",
"0.6930193",
"0.6929261",
"0.6923227",
"0.6907321",
"0.68361217",
"0.6826948",
"0.6818567",
"0.6814209",
"0.6814209",
"0.6811637",
"0.680502",
"0.67585725",
"0.6727132",
"0.6722024",
"0.6722024",
"0.6716135",
"0.67098874",
"0.67098874",
"0.6705184"
] | 0.79471594 | 0 |
DELETE /coupons/1 DELETE /coupons/1.json | def destroy
@coupon = current_user.coupons.find(params[:id])
@coupon.destroy
respond_to do |format|
format.html { redirect_to coupons_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @coupone.destroy\n respond_to do |format|\n format.html { redirect_to admin_coupones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon = Coupon.find(params[:id])\n @coupon.destroy\n\n respond_to do |format|\n format.html { redirect_to coupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon = Coupon.find(params[:id])\n @coupon.destroy\n\n respond_to do |format|\n format.html { redirect_to coupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupen.destroy\n respond_to do |format|\n format.html { redirect_to coupens_url }\n format.json { head :no_content }\n end\n end",
"def delete_coupon(id)\n url = \"#{api_resource}/#{id}/coupons\"\n request.delete(url).parse\n end",
"def destroy\n @cupon = Cupon.find(params[:id])\n @cupon.destroy\n\n respond_to do |format|\n format.html { redirect_to cupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to coupons_url, notice: 'Cupom foi excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @payment_coupon.destroy\n respond_to do |format|\n format.html { redirect_to payment_coupons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to \"/coupons\", notice: 'Coupon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to admin_conference_coupons_path(@conference) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupling.destroy\n respond_to do |format|\n format.html { redirect_to couplings_url, notice: 'Coupling was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to coupons_path, notice: \"Coupon was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon = Coupon.find(params[:id])\n @coupon.destroy\n\n respond_to do |format|\n format.html { redirect_to(coupons_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @coupon = Coupon.find(params[:id])\n @coupon.destroy\n\n respond_to do |format|\n format.html { redirect_to(coupons_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to coupons_url, notice: 'Coupon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to coupons_url, notice: 'Coupon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to coupons_url, notice: \"Coupon was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to admin_coupons_url, notice: 'Coupon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupons_user.destroy\n respond_to do |format|\n format.html { redirect_to coupons_users_url, notice: 'Coupons user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupan.destroy\n respond_to do |format|\n format.html { redirect_to coupans_url, notice: 'Coupan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @coupon\n\n @coupon.destroy\n respond_to do |format|\n format.html { redirect_to admin_coupons_path, notice: 'Cupom foi DELETADO com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupom_type.destroy\n respond_to do |format|\n format.html { redirect_to coupom_types_url, notice: 'Coupom type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @copon.destroy\n respond_to do |format|\n format.html { redirect_to copons_url, notice: 'Copon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_coupon.destroy\n respond_to do |format|\n format.html {\n flash[:delete] = 'Company Coupon was successfully destroyed.'\n redirect_to admin_company_coupons_path\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_coupon.destroy\n respond_to do |format|\n format.html { redirect_to admin_coupons_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coupen_type.destroy\n respond_to do |format|\n format.html { redirect_to coupen_types_url, notice: 'Coupen type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coconut1.destroy\n respond_to do |format|\n format.html { redirect_to coconut1s_url, notice: 'Coconut1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ele_coupon = EleCoupon.find(params[:id])\n @ele_coupon.destroy\n\n respond_to do |format|\n format.html { redirect_to(ele_coupons_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7824454",
"0.7560472",
"0.7560472",
"0.7426327",
"0.7409436",
"0.73012096",
"0.7277388",
"0.72567785",
"0.72345173",
"0.7221046",
"0.7212118",
"0.719454",
"0.718116",
"0.7180592",
"0.7178381",
"0.7178381",
"0.71775025",
"0.7155239",
"0.69896907",
"0.69573563",
"0.6936005",
"0.68612397",
"0.6816191",
"0.67587364",
"0.67587364",
"0.67343843",
"0.67218256",
"0.6718271",
"0.6707461",
"0.6682418"
] | 0.75654614 | 1 |
Renders a section of the new course form as a partial, with the locals provided. | def render_form_section(step_number)
render :partial => form_section_partial(step_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection_form(params)\n render(:partial => \"layouts/collection_form\", :locals => params)\n end",
"def create\n @section = Section.new(section_params)\n @course = Course.find(params[:course_id])\n @section.course_id = @course.id\n respond_to do |format|\n if @section.save\n format.html { redirect_to course_section_url(@section.course_id, @section), notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n format.js {}\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n # Add section to course.\n if params.has_key?('course_id')\n course_id = params['course_id']\n add_section_to_course(@section, course_id)\n end\n \n format.js { render \"\", json: @section }\n else\n format.js { render json: @section.errors, status: :unprocessable_entity }\n end\n # if add_section_to_course(@section, course_id)\n # # Use the sections helper to create the relation between the section and its course.\n # format.html { redirect_to Course.find(course_id), notice: 'Section was successfully created.' }\n # format.json { render :show, status: :created, location: @section }\n # else\n # format.html { render :new }\n # format.json { render json: @section.errors, status: :unprocessable_entity }\n # end\n end\n end",
"def new\n @course = Course.new\n render 'new'\n end",
"def new\n\t\t@course = Course.find_by_id(params[:course_id])\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend",
"def new\n @occurrence = @course.occurrences.new\n \n render :layout => !request.xhr?\n end",
"def create\n @course_section = CourseSection.new(course_section_params)\n\n respond_to do |format|\n if @course_section.save\n format.html { redirect_to @course_section, notice: 'Course section was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course_section }\n else\n format.html { render action: 'new' }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n params_hash = {institution_id: params[:institution_id],\n center_id: params[:center_id],\n academic_class_id: params[:academic_class_id]}\n @section = Section.new(params_hash)\n @section.build_profile\n @section.build_build_info\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @section }\n end\n end",
"def create\n @course = Course.new(course_params)\n\n #section_chunks = get_chunks(params)\n sections = JSON.parse(params['sections'])\n\n # The course has been created by the signed-in user.\n @course.user_id = current_user.id\n respond_to do |format|\n if @course.save\n # Save the course's subcomponents to the course.\n update_section_chunks(sections)\n\n format.html { redirect_to @course }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render new_course_path }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.js { render 'course.js'}\n format.json { render json: @course }\n end\n end",
"def create_form\n verify_ajax_request\n require_parameters :component\n render :partial => 'issue/create_form'\n end",
"def render_partial(context, options, &block); end",
"def new\n @section = Section.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @section }\n end\n end",
"def new\n @section = Section.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @section }\n end\n end",
"def new\n @section_category = SectionCategory.new\n\n respond_to do |format|\n format.html { render layout: \"editor\" }\n format.json { render json: @section_category }\n end\n end",
"def create\n @section = Section.new(section_params)\n\n if @section.save\n redirect_to sections_path, primary: 'Section was successfully created.'\n else\n render :new\n end\n end",
"def newPage\n @contribucions = getAllContribucio\n render :partial => 'index', :locals => { :contribucions => @contribucions } \n end",
"def new\n @course = Course.new\n @course.active = true\n @course_date = CourseDate.new \n \n @admin_section = true\n @page_title = \"Create New Course\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\r\n @section = Section.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @section }\r\n end\r\n end",
"def new\n render(\n :new,\n layout: false,\n locals: local_vars.merge(\n all_clinics: Renalware::Pathology::Clinic.for_algorithm,\n all_consultants: Renalware::Pathology::Consultant.ordered,\n all_templates: Renalware::Pathology::Requests::Request::TEMPLATES\n )\n )\n end",
"def new\n @grid_template ||= current_site.grid_templates.new\n render \"form\", layout: false\n end",
"def create\n @section = Section.new(params[:section])\n\n Course.find(params[:section][:add_section]).sections << @section if params[:section][:add_section]\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render json: @section, status: :created, location: @section }\n else\n format.html { render action: \"new\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n begin\n @course = Course.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def new\n @section = Section.new\n\n # If the new section is requested from an existing article page then we have to retain that article for \n # reloading that article's sortings list to include the new section.\n @article = find_article if params[:article_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.xml { render :xml => @section }\n end\n end",
"def render\n content_tag(:section, class: \"umm-preview #{form_id}\") do\n render_preview_accordion\n end\n end",
"def new\n @sections = Section.find(:all) # TODO: refactor so I don't have to repeat this all over the place\n @section = Section.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @section }\n end\n end",
"def new\n @title = t('view.buildings.modal.involved_building')\n @building = Building.new\n\n render partial: 'new', content_type: 'text/html'\n end",
"def new\n @admin_section = true\n @course_category = CourseCategory.new\n @page_title = \"New Course Category\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_category }\n end\n end",
"def show\n @course = @course_section.course\n end",
"def create\n @discipline_section = DisciplineSection.new(discipline_section_params)\n respond_to do |format|\n if @discipline_section.save\n #format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' }\n #format.json { render :show, status: :created, location: @discipline_section }\n format.js { render('discipline_sections/create')}\n else\n #raise @discipline_section.errors.inspect\n #format.html { render :new }\n #format.json { render json: @discipline_section.errors, status: :unprocessable_entity }\n format.js { render ('discipline_sections/error')}\n end\n end\n end"
] | [
"0.6517656",
"0.6438588",
"0.6257084",
"0.6197232",
"0.6195565",
"0.6128075",
"0.6099174",
"0.5989343",
"0.5924707",
"0.5899397",
"0.58902395",
"0.5866849",
"0.58593816",
"0.58593816",
"0.5828044",
"0.58233833",
"0.5815042",
"0.5814026",
"0.5811041",
"0.5804293",
"0.5801057",
"0.57995915",
"0.5773389",
"0.57688874",
"0.5755508",
"0.5752975",
"0.574132",
"0.5725913",
"0.57235205",
"0.57218"
] | 0.65311354 | 0 |
Renders a link to the new action of the current resource. | def link_new(text = t("admin.common.new_link"), url = new_resource_url)
link_to text, url, :class => 'new'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_to_new(text, path, options={})\n if path.is_a? Class\n text ||= t(\"app.actions.new\", :default => \"New\") + ' ' + path.try(:human_name).to_s.downcase\n path = options.delete(:url) || new_polymorphic_path(path) unless path.is_a? String\n end\n link_to_action(text, path, options.reverse_merge(:action => :new))\n end",
"def rezm_link_to_create_message\n link_to \"Write\", new_message_path\n end",
"def ajax_link_to_new(text, resource, options = {})\n name = (\"<i class='icon-white icon-plus'></i> \" + text).html_safe\n attributes = {\n :remote => true,\n :class => \"btn btn-primary mr-s\"\n }.merge(options)\n link_to name, resource, attributes\n end",
"def new\n # render(:new) => this whole action could also be implicit\n end",
"def link_to_new(path, message = '')\n message = icon('plus-sign') + ' ' + message\n link_to message, path, title: 'Create a new record'\n end",
"def new\n\t\t@link = Link.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @link }\n\t\tend\n\tend",
"def remote_link_to_new(text = \"新規追加\", options = {}, html_options = {})\n if registered? && (at_present? || simulation_mode?) && allow_to_add_new_entity?(options)\n options[:controller] ||= controller_name\n options[:url] = {:controller => options[:controller], :action => \"new\"}\n options[:params] = options[:params].to_h.merge( :background_params => @background_params )\n html_options[:class] ||= \"op-control\"\n link_to_remote_with_params( text, options, html_options ) \n end\n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def new\n # default: render 'new' template\n end",
"def new\n render 'new'\n end",
"def new\n render \"new\"\n end",
"def new\n render \"new\"\n end",
"def new_button(label = nil, css: '.new-button', **opt)\n label ||= 'Start a new manifest' # TODO: I18n\n prepend_css!(opt, css)\n link_to_action(label, action: :new, link_opt: opt)\n end",
"def new\n\t\t# no code needed here; all handled in the view\n\tend",
"def visit_new_page(model, **opt, &block)\n visit_action_page(model, :new, **opt, &block)\n end",
"def new_resource_path(options={})\n options.merge! :action => :new\n super_path(with_chain(resource_class), options)\n end",
"def new\n # render new.html\n end",
"def new\n render :new\n end",
"def handle_new\n obj = model.new(request.params[model.link], request)\n model.hook(:before_new, request, obj)\n new_page(obj)\n end",
"def new\n @link = Link.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end",
"def new\n @link = Link.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end",
"def new\n @post = model.new\n\n respond_to do |format|\n format.html { render :action => resource_template(\"new\") }\n end\n end",
"def new\n @asset = Asset.new\n render :action => :new, :back => url_for(:action => :index)\n end",
"def render_new_content_link(element)\n\t\t\t\tlink_to_overlay_window(\n\t\t\t\t\trender_icon('create') + t('add new content'),\n\t\t\t\t\talchemy.new_admin_element_content_path(element),\n\t\t\t\t\t{\n\t\t\t\t\t\t:size => '335x70',\n\t\t\t\t\t\t:title => t('Select an content'),\n\t\t\t\t\t\t:overflow => true\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t:id => \"add_content_for_element_#{element.id}\",\n\t\t\t\t\t\t:class => 'small button with_icon new_content_link'\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\tend",
"def new\n \n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end",
"def quest_new_page\n \"/#{user_path}/#{objective_path}/#{controller}/new\"\n end",
"def new\n @resource = Resource.new\n respond_to do |format|\n format.html {render action: :new} # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def create_link(resource, *args)\n link = ''.html_safe\n\n resource_name = normalized_resource_name(resource)\n object = determine_proper_resource(resource)\n options = args.first || {}\n\n # CSS classes for this crud link\n crud_link_css(options, 'create')\n # text to be displayed\n link_text = crud_link_text(options, 'create')\n\n # (optional) add a tooltip to the link\n if options.keys.include?(:tooltip)\n add_tooltip(options)\n end\n\n\n if defined? CanCan\n link += link_to link_text, url_for(resource), options if can?(:create, object)\n else\n link += link_to link_text, url_for(resource), options\n end\n\n link\n end"
] | [
"0.71003175",
"0.67470634",
"0.6716058",
"0.66174686",
"0.6612417",
"0.65951645",
"0.65459746",
"0.650439",
"0.650439",
"0.650439",
"0.650439",
"0.6401635",
"0.63767475",
"0.63767475",
"0.6362285",
"0.62672347",
"0.62430656",
"0.624117",
"0.6194693",
"0.61932355",
"0.61634225",
"0.6137731",
"0.6137731",
"0.6137521",
"0.6115424",
"0.61111945",
"0.6099248",
"0.6094876",
"0.60906124",
"0.6069293"
] | 0.7411677 | 0 |
Renders a table for a given ActiveRelation. Example: | def render_table(arel)
return if arel.first.nil?
partial :table, :locals => {:model => arel.first.class, :arel => arel}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table options = {} \n render_partial :table, template_locals(:table_row, options)\n end",
"def table_of(things,opts={})\n kind = things.first.table_name\n # columns = things.first.visible_columns\n add_class_to_html_options(opts, kind)\n content_tag(\n :table,\n render(:partial => \"/#{kind}/table_row\", :collection => things),\n opts\n )\n end",
"def table_for(value, options = {}, &block)\n view(value, options.merge(:as => :table), &block)\n end",
"def table(options = {}, &block)\n table_for(collection, options.merge(:class => resource_class), &block)\n end",
"def table_for(resources, *args, &block)\n self.table_id += 1\n options = args.extract_options!\n builder = TableFor::TableBuilder.new(self, resources, options, self.table_id)\n yield(builder) if block_given?\n\n self.context.render_page_for(partial: \"table\", locals: { table_builder: builder, resources: resources, page: self })\n end",
"def table_for(collection, options = {}, *attr_list)\n actions = false\n classes = options[:classes] || \"\"\n model_class_name = options[:model_name] || collection.name\n table_id = options[:id] || model_class_name.tableize\n table_klazz = model_class_name.constantize\n table_headers = []\n\n attr_list.flatten.each do |attr_name|\n if attr_name.class == Hash && !attr_name[:actions].nil?\n actions = attr_name[:actions]\n else\n header_content = table_klazz.human_attribute_name(attr_name)\n header = content_tag(:th, header_content)\n table_headers << header\n end\n end\n\n if actions\n table_headers << content_tag(:th, t('actions'), class: 'table_actions')\n end\n\n thead = content_tag :thead, content_tag(:tr, table_headers.join(\" \").html_safe)\n table_content = \"\"\n if options[:partial].present?\n table_content = render partial: options[:partial], collection: collection\n else\n table_content = render collection\n end\n tbody = content_tag :tbody, table_content\n table = content_tag(:table, \"#{thead} #{tbody}\".html_safe, id: table_id, class: \"table table-hover #{classes}\")\n table.html_safe\n end",
"def relation_table(model)\n validate_model(model)\n model.arel_table\n end",
"def table_content\n table activity_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [65, 175, 75, 85, 75, 65]\n style(column(3), align: :right)\n style(column(4), align: :right)\n style(column(5), align: :right)\n end\n end",
"def table_content\n table activity_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [110, 175, 175, 80]\n end\n end",
"def render_html_table(rde_table)\n content_tag(:table, class: 'table rde-table') do\n rde_table.rows.map { |row|\n content_tag(row.tag, class: row.css_class) do\n row.cells.map { |cell|\n if cell.ruby_formatter\n content_tag(\n cell.tag,\n instance_exec(cell.value, &cell.ruby_formatter),\n class: cell.css_class,\n title: cell.title,\n style: cell.style,\n )\n else\n content_tag(\n cell.tag,\n cell.value,\n class: cell.css_class,\n title: cell.title,\n style: cell.style,\n )\n end\n }.join.html_safe\n end\n }.join.html_safe\n end\n end",
"def table_for(*args, &block)\n tags = {\n :table => :table,\n :thead => :thead,\n :tbody => :tbody,\n :tfoot => :tfoot,\n :tr => :tr,\n :th => :th,\n :td => :td\n }\n ft_generate_html tags, *args, &block\n end",
"def table_list(objetos, show_all_actions = true, options = {})\n render :partial => '/admin/shared/table_list', :locals => { :objetos => objetos, :show_all_actions => show_all_actions, :options => options }\n end",
"def index\n @table_relations = TableRelation.all\n end",
"def terminal_table\n rows = @moods.map do |mood|\n mood.to_arr\n end\n table = Terminal::Table.new({ headings: HEADINGS, rows: rows })\n puts table\n end",
"def print_related_products_table\n srp = \"\"\n srp += \"<table><tr><th>Products</th>\"\n srp += \"<th>Description</th></tr>\"\n if(@related_products.empty?)\n srp += \"<tr><td>No Products Available</td></tr>\"\n else\n #sort alphabetically\n for prod in @related_products\n srp += \"<tr><td class=\\\"td_two_col\\\">#{link_to prod.name, prod}</td>\"\n srp += \"<td>#{prod.description}</td></tr>\"\n end\n end\n srp += \"<tr><td>#{my_button_to(\"New Product\", new_product_path, [@category])}</td></tr></table>\"\n srp\n end",
"def table\n end",
"def open\n \"<table class='table #{@custom_class}'>\"\n end",
"def render_table(rows, options = {})\n options = { :description => false }.merge options\n # Figure out the fields from the :model option\n if options[:model] && options[:fields].nil?\n options[:fields] = options[:model].default_field_order\n end\n # Figure out the fields from the first row\n if options[:fields].nil? && rows.first.class.respond_to?(:default_field_order)\n options[:fields] = rows.first.class.default_field_order\n end\n # Call to_row on all the rows\n rows = rows.map do |row|\n row.respond_to?(:to_row) ? row.to_row : row\n end\n # Call render_cell on all the cells\n rows.each do |row|\n # FIXME: default Api subclasses do not respond to #keys so specialising\n # #to_row is required to not break the following\n row.each_key do |k|\n row[k] = row[k].render_cell if row[k].respond_to? :render_cell\n end\n end\n if options[:s]\n # Simple output\n rows.each do |row|\n if options[:vertical]\n data options[:fields].map { |k| [k, row[k]].join(\"\\t\") }.join(\"\\n\")\n else\n data options[:fields].map { |k| row[k].is_a?(Array) ? row[k].join(\",\") : row[k] }.join(\"\\t\")\n end\n end\n elsif options[:vertical]\n # \"graphical\" table\n data ShowTable.render(rows, options)\n else\n data SimpleTable.render(rows, options)\n end\n end",
"def table\n model_class.arel_table\n end",
"def draw()\n @vc.content_tag(:table) do\n @left = true\n @vc.capture do\n for col in columns do\n @vc.concat col.field(@record, self)\n end\n @vc.concat('<td colspan=3></td>'.html_safe) if !@left\n end\n end\n end",
"def mount_table(*args)\n return '' if args.empty?\n array = args.delete_at(0)\n header = '<tr><th>'+args.collect{|i| i.to_s.titlecase }.join('</th><th>')+'</th></tr>'\n lines = array.collect{|i| '<tr><td>'+i.join('</td><td>')+'</td></tr>' }.join\n \n <<-TABLE\n <table>\n <thead>#{header}</thead>\n <tbody style=\"text-align:left;\">\n #{lines}\n </tbody>\n </table>\n TABLE\n end",
"def table_content\n # This makes a call to gift_rows and gets back an array of data that will \n # populate the columns and rows of a table I then included some styling to \n # include a header and make its text bold. I made the row background colors \n # alternate between grey and white Then I set the table column widths\n table gift_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [180, 180, 180]\n end\n end",
"def table(s, **options)\n html(HTML.table(s, **options))\n end",
"def results_view\n 'general_ledger_account_search_results_table'\n end",
"def crud_table(*attrs, &block)\n options = attrs.extract_options!\n attributes = (block_given? || attrs.present?) ? attrs : default_attrs\n first = attributes.shift\n table(entries, options) do |t|\n col_show(t, first) if first\n t.sortable_attrs(*attributes)\n yield t if block_given?\n add_table_actions(t)\n end\n end",
"def table_for(collection, headers, options = {})\r\n options = Defaults.get.merge options\r\n\r\n content_tag :table, options do\r\n concat (content_tag :thead do\r\n content_tag :tr do\r\n headers.map do |header|\r\n case header\r\n when String\r\n concat(content_tag :th, header)\r\n when Symbol\r\n concat(content_tag :th, collection.model.human_attribute_name(header))\r\n end\r\n end\r\n end\r\n end)\r\n\r\n concat (content_tag :tbody do\r\n collection.map do |obj|\r\n concat (content_tag :tr do\r\n capture{ yield obj }\r\n end)\r\n end\r\n end)\r\n end\r\n end",
"def table(opts = { print: true })\n require \"inspec/ui_table_helper\"\n\n the_table = TableHelper.new\n yield(the_table)\n\n colorizer = proc do |data, row, _col|\n if color? && row == 0\n ANSI_CODES[:bold] + ANSI_CODES[:color][:white] + data.to_s + ANSI_CODES[:reset]\n else\n data\n end\n end\n render_mode = color? ? :unicode : :ascii\n padding = [0, 1, 0, 1] # T R B L\n result = the_table.render(render_mode, filter: colorizer, padding: padding) + \"\\n\"\n print_or_return(result, opts[:print])\n end",
"def show_row(object, method_name)\n content_tag(:tr,\n content_tag(:th, object.class.human_attribute_name(method_name.to_s)) +\n content_tag(:td, h(object.send(method_name))),\n :class => stripe_cycle\n )\n end",
"def to_s; \"#<Veritable::Table _id='#{_id}'>\"; end",
"def table(*args, &block)\n params = args.present? && args.last.is_a?(Hash) ? args.pop : {}\n cl = params.delete(:class) || %w(table table-striped)\n cl = [cl] unless cl.is_a?(Array)\n\n options = {class: cl}.merge(params)\n content_tag :table, options do\n thead(args) +\n content_tag(:tbody, &block)\n end\n end"
] | [
"0.685716",
"0.66295767",
"0.65225935",
"0.630819",
"0.60531455",
"0.60243446",
"0.60181785",
"0.59902173",
"0.5941051",
"0.58121914",
"0.5780403",
"0.5778026",
"0.5705918",
"0.5691368",
"0.5685244",
"0.5676578",
"0.56720835",
"0.5663998",
"0.56602997",
"0.5642353",
"0.56286955",
"0.559727",
"0.5580817",
"0.5553578",
"0.5544368",
"0.55297065",
"0.5528032",
"0.55199623",
"0.5517689",
"0.54739445"
] | 0.71918875 | 0 |
p factorial(5) Write a method that accepts two arrays of numbers, and prints the sum of every combination of numbers from first and second array. For example, if the method receives [1, 5, 10] and [100, 500, 1000], the method should print a list: 101, 501, 1001, 105, 505, 1005, 110, 510, 1010]. | def sum_combinations(first_array, second_array)
new_array = []
first_array.each do |first_number|
second_array.each do |second_number|
new_array << first_number + second_number
end
end
new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_combinations(numbers1, numbers2)\n result = []\n numbers1.each do |number1|\n numbers2.each do |number2|\n result << number1 + number2\n end\n end\n result\nend",
"def sum_combinations(numbers1, numbers2)\n result = []\n numbers1.each do |number1|\n numbers2.each do |number2|\n result << number1 + number2\n end\n end\n result\nend",
"def combinations(arr_one, arr_two)\n arr_join = []\n arr_one.each do |x|\n arr_two.each do |y|\n arr_join.push(x + y)\n end\n end\n print arr_join\nend",
"def print_sums(array_1, array_2)\n array_1.each do |num_1|\n array_2.each do |num_2|\n puts num_1 + num_2\n end\n end\nend",
"def print_sums(nums1, nums2)\n nums1.each do |num1|\n nums2.each do |num2|\n p num1 + num2\n end\n end\nend",
"def combination_sum(nums, target)\n combinations = []\n combination_sum_helper(nums, target, [], combinations, 0)\n combinations\nend",
"def sum_stuff(nums1, nums2)\n nums1.each do |num1|\n nums2.each do |num2|\n puts num1 + num2\n end\n end\nend",
"def sum num1, num2, *divisor\n multiplesList = []\n n = divisor.length\n (divisor.length).times do |i|\n multiplesList += multiples num1, num2, divisor[i]\n end\n multiplesList.uniq.sum\n end",
"def multiply_all_pairs(arr1, arr2)\n p arr1.product(arr2).map { |num1, num2| num1 * num2 }.sort\nend",
"def multiply_list(arr1, arr2)\r\nresult = []\r\ncounter = 0\r\n\r\narr1.length.times do |num|\r\n result << arr1[counter] * arr2[counter]\r\n counter += 1\r\nend\r\np result\r\nend",
"def multiply_list(array1, array2)\n results = []\n n = 0\n\n array1.size.times do |num|\n results << array1[n]*array2[n]\n n += 1\n end\n\n results\nend",
"def multiply_all_pairs(arr1, arr2)\n final = []\n arr1.each do |n1|\n arr2.each do |n2|\n final << n1 * n2\n end\n end\n final.sort\nend",
"def multiply_all_pairs(num_arr1, num_arr2)\n product_arr = []\n\n num_arr1.each do |x|\n num_arr2.each do |y|\n product_arr << x * y\n end\n end\n product_arr.sort\nend",
"def multiply_all_pairs(arr1, arr2)\n result = []\n arr1.each { |num1| arr2.each { |num2| result << num1 * num2}}\n result.sort\nend",
"def multiply_all_pairs(array1, array2)\n result = []\n\n array1.each do |num|\n array2.each do |num2|\n result << num2 * num\n end\n end\n result.sort\nend",
"def multiply_all_pairs(array_1, array_2)\n results = []\n\n array_1.each do |arr_1_num|\n array_2.each {|arr_2_num| results << (arr_1_num * arr_2_num)}\n end\n results.sort\nend",
"def multiply_all_pairs(array1, array2)\n products = []\n array1.each do |num1|\n array2.each do |num2|\n products << num1 * num2\n end\n end\n products.sort\nend",
"def multiply_all_pairs(array_1, array_2)\n result = []\n\n array_1.each do |current_number_array_1|\n array_2.each do |current_number_array_2|\n result << current_number_array_1 * current_number_array_2\n end\n end\n\n result.sort\nend",
"def multiply_all_pairs(arr1, arr2)\n products = []\n arr1.each do |arr1_num|\n arr2.each do |arr2_num|\n products << arr1_num * arr2_num\n end\n end\n products.sort\nend",
"def multiply_all_pairs(arr1, arr2)\n result = []\n arr1.each do |num1|\n arr2.each { |num2| result << num1 * num2 }\n end\n result.sort\nend",
"def multiply_all_pairs(arr1, arr2)\n arr1.map do |num1| \n arr2.map { |num2| num1 * num2 }\n end.flatten.sort\nend",
"def multiply_all_pairs(arr1, arr2)\n\tproducts = []\n\n\tarr1.each do |num1|\n\t\tarr2.each do |num2|\n\t\tproducts << num1 * num2\n\t\tend\n\tend\n\tproducts.sort\nend",
"def Contained_Multiples(num1, num2)\n\tproduct_collection = []\n\tnum1_multiplier = 1\n\tnum2_multiplier = 1\n\n\t#multiply each by an increasing number until the product is larger than 1000\n\t#place each of those products into a product collection\n\twhile num1 * num1_multiplier < 1000 \n\t\tproduct_collection << num1 * num1_multiplier\n\t\tnum1_multiplier += 1\n\tend\n\n\twhile num2 * num2_multiplier < 1000\n\t\tproduct_collection << num2 * num2_multiplier\n\t\tnum2_multiplier += 1\n\tend\n\t\n\t#add each number in the product collection together to get a sum\n\tproduct_collection.inject(\"+\")\nend",
"def multiply_all_pairs(numbers1, numbers2)\n products = []\n numbers1.each do |num1|\n numbers2.each { |num2| products << num1 * num2 }\n end\n products.sort\nend",
"def numbers_sum(input_array)\n output = input_array[0] + input_array[1] # Sums the first array's input with the second array's input\n return output\nend",
"def sum_and_product(arr)\n sum = arr.inject(0, :+)\n # iterates through the array, so time complexity of n\n product = arr.reduce(1, :*)\n # also iterates through the entire array, so n.\n print \"The sum of the array is #{sum}\" + \" and\" + \" the product is #{product}.\"\nend",
"def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend",
"def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend",
"def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend",
"def multiply_all_pairs(array_1, array_2)\n array_1.product(array_2).map { |num1, num2| num1 * num2 }.sort\nend"
] | [
"0.72538614",
"0.72538614",
"0.71575385",
"0.68614876",
"0.6598263",
"0.6524028",
"0.6419899",
"0.6394974",
"0.63879704",
"0.6372417",
"0.63713336",
"0.6359029",
"0.6342019",
"0.62840295",
"0.6276934",
"0.62743974",
"0.62480026",
"0.6245428",
"0.623474",
"0.6233651",
"0.6230868",
"0.6226951",
"0.62219757",
"0.6221494",
"0.61987096",
"0.61924875",
"0.6190512",
"0.6190512",
"0.6190512",
"0.6190512"
] | 0.7435915 | 0 |
Are we past all due_dates and section due_dates for this assignment? This does not take extensions into consideration. | def past_all_due_dates?
# If no section due dates /!\ do not check empty? it could be wrong
return false if !due_date.nil? && Time.current < due_date
return false if section_due_dates.any? { |sec| !sec.due_date.nil? && Time.current < sec.due_date }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def past_due?\n self.updated_at.to_date > self.due_date\n end",
"def past?\n due_on < Date.today\n end",
"def overdue?\n return true if @past_due\n false\n end",
"def overdue?\n return false if due_at.nil?\n due_at < Time.now \n end",
"def overdue?\n due < Date.current\n end",
"def is_due?\n self.datetime.past?\n end",
"def overdue? ()\n\t\t@due_date < Time.now\n end",
"def missed_deadline?\n if self.closeDate.nil?\n self.dueDate.to_date < Date.today\n else\n self.dueDate.to_date < self.closeDate.to_date\n end\n end",
"def overdue?\n @due_date < Date.today\n end",
"def due_later?\n @due_date > Date.today\n end",
"def overdue?\n Date.today > to_date\n end",
"def overdue?\r\n @overdue = Time.now > @due_date\r\n end",
"def overdue?\n next_payment_at && next_payment_at.to_date < Date.today\n end",
"def due_to_cannot_be_in_the_past\n if dueTo.present? && dueTo < Date.today\n errors.add(:dueTo, \"can't be in the past\")\n end\n end",
"def is_past_due?(current_day)\n # compare the current day to the @due_date\n days_of_week = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\"\n ]\n # if no tasks on the list\n if @list.values.all? { |tasks| tasks.empty? } # goes through all the values and verifies that all of them meet a specific condition that we passed to the block and all the values are tasks which are arrays. Use built in method empty which will return true or false. Verifies if any of the tasks or our arrays return false that they are not empty\n # isn't past due, return false\n puts \"You have completed all the tasks on your list!\"\n false\n # elsif the current day is past the @due_date\n elsif days_of_week.index(@due_date) < days_of_week.index(current_day) # Where is due date in array of days of week? Using .index on an array will return the fixnum index of the due date\n # yes, it is past due. return true\n puts \"You still have tasks to complete and they were due on #{@due_date}!\"\n true\n # else the current day is before the @due_date\n else\n # return false\n puts \"You still have until #{@due_date} to complete these tasks.\"\n false\n end\n end",
"def past_deadline?\n self.deadline < Time.now\n end",
"def assignment_staggered_deadline?\n if @assignment_form.assignment.staggered_deadline == true\n @review_rounds = @assignment_form.assignment.num_review_rounds\n @due_date_all ||= AssignmentDueDate.where(parent_id: @assignment_form.assignment.id)\n @assignment_submission_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SUBMISSION }\n @assignment_review_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_REVIEW }\n end\n @assignment_form.assignment.staggered_deadline == true\n end",
"def time_over?\r\n return self.due_date <= Time.now\r\n end",
"def deadline_over?(risk_register)\n return date_difference(Date.today, risk_register.target_date) < 0\n end",
"def section_names_past_due_date\n if !self.section_due_dates_type && !due_date.nil? && Time.current > due_date\n return []\n end\n\n sections_past = []\n self.section_due_dates.each do |d|\n if !d.due_date.nil? && Time.current > d.due_date\n sections_past << d.section.name\n end\n end\n\n sections_past\n end",
"def upcoming?(test, days)\r\n\t\tif self.overdue.present?\r\n\t\t\tself.overdue.upcoming?(test, days)\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend",
"def due?\n super && !violations.empty?\n end",
"def due_today?\n due_date == Date.due_today\n end",
"def overdue?\n if is_appointment?\n start_date.to_date < Time.zone.now.to_date\n else\n open? && end_date.to_date < Time.zone.now.to_date\n end\n end",
"def overdue\n @date > Date.today\n end",
"def not_in_past\n return unless due_date < Time.zone.today || start_date < Time.zone.today\n errors.add(:base, \"Cannot create reservation in the past.\\n\")\n end",
"def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end",
"def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end",
"def past_due\n stripe_status == 'past_due'\n end",
"def overdue?(test)\r\n\t\tif self.overdue.present?\r\n\t\t\tself.overdue.overdue?(test)\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend"
] | [
"0.75103384",
"0.7506947",
"0.7407898",
"0.72714686",
"0.71805996",
"0.71388173",
"0.70758104",
"0.70613337",
"0.69609195",
"0.69539124",
"0.69050086",
"0.68459016",
"0.68005824",
"0.6785183",
"0.6770382",
"0.6728164",
"0.6707958",
"0.6673514",
"0.6663262",
"0.666038",
"0.6650445",
"0.65982914",
"0.6568998",
"0.65557134",
"0.65489167",
"0.65272033",
"0.64859426",
"0.64859426",
"0.6465823",
"0.64647496"
] | 0.85159796 | 0 |
Return an array with names of sections past | def section_names_past_due_date
if !self.section_due_dates_type && !due_date.nil? && Time.current > due_date
return []
end
sections_past = []
self.section_due_dates.each do |d|
if !d.due_date.nil? && Time.current > d.due_date
sections_past << d.section.name
end
end
sections_past
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sections\n @sections.values\n end",
"def sections\n @data.keys\n end",
"def sections\n @pages.collect { |p| p.sections }.flatten\n end",
"def section_contents\n used_sections = {}\n\n each_method do |method|\n next unless method.display?\n\n used_sections[method.section] = true\n end\n\n # order found sections\n sections = sort_sections.select do |section|\n used_sections[section]\n end\n\n # only the default section is used\n return [] if\n sections.length == 1 and not sections.first.title\n\n sections\n end",
"def section_names(resolve=true)\n resolve_sections if resolve\n @section_names\n end",
"def all_sections\n [ header_section ] + sections\n end",
"def find_section_names(document)\n sections = document.search(\".fc-container__header__title\")\n tidy_sections = sections.map do |section|\n tidy_section = section.text.strip.split(\"\\n\").first\n end\n @noise.each { |word| tidy_sections.delete(word) if tidy_sections.include? word }\n tidy_sections\n end",
"def sections\n return @sections\n end",
"def list_sections\n \n end",
"def course_sections\n ['1', '2']\n end",
"def sections\n @ini.keys\n end",
"def sections\n @ini.keys\n end",
"def slice_names\n self.paths.keys.sort\n end",
"def sections\n (1..section_size).inject([]) do |array, row_offset|\n (1..section_size).inject(array) do |array, column_offset|\n array << section_coordinates(row_offset - 1, column_offset - 1)\n end\n end\n end",
"def sections\n @blocks.inject([]) {|collector, block|\n collector << block if block.is_a?(Section)\n collector\n }\n end",
"def sections\n @sections ||= context\n .public_methods\n .grep(/\\A(?!wait_)\\w+_section$\\z/)\n .map { |el| Meta::Section.new(el.to_s.gsub('_section', ''), context) }\n end",
"def sections_section_index\n return @sections_current_index\n end",
"def sections_info(plan)\n return [] if plan.nil?\n\n info = []\n plan.sections.each do |section|\n info.push(section_info(plan, section))\n end\n info\n end",
"def sections\n @sections || [:backtrace, :request, :session, :environment]\n end",
"def section_ids\n sections.map { |co| co.id }\n end",
"def sections\n temp_sections = []\n if @section_ids.count > 0\n @section_ids.each do |section_id|\n temp_sections.push @client.section(@org_id, section_id)\n end\n end\n return temp_sections\n end",
"def sections\n parsed {\n @sections\n }\n end",
"def section_metadata\n [section_metadata_one, section_metadata_two, section_metadata_three]\n end",
"def section_locations(section)\n schedules = recurring_schedules(section)\n schedules.size > 0 ? schedules.map {|schedule| \"#{schedule[:roomNumber]} #{schedule[:buildingName]}\"} : []\n end",
"def section_names_and_ids(article)\n # Grab section names and ids from the article.\n filename = File.join('epub', 'OEBPS', xhtml(article.fragment_name))\n doc = Nokogiri::HTML(File.read(filename))\n names = doc.css('div.section>h2').map do |s|\n s.children.children.last.content\n end\n ids = doc.css('div.section').map { |s| s.attributes['id'].value }\n names.zip(ids)\n end",
"def tab_items\n LessonOutline.outline.sections.collect do |section|\n\n end.join(\"\\n\")\n end",
"def sections\n self.entries.select { |e| e.is_a?(ListSection) }\n end",
"def list_names(section)\n BASE_CONFIG[section].map { |key, val| [val[:group], key] }.sort\n end",
"def inspect\n \"#<#{self.class.name} sections=#{sections.inspect}>\"\n end",
"def section_names\n # Exclude the global \"core\" section\n config.sections.reject { |s| %w[core alias].include?(s) }\n end"
] | [
"0.65460247",
"0.6378971",
"0.63661057",
"0.6332716",
"0.6199342",
"0.61626226",
"0.6130235",
"0.61289954",
"0.6107049",
"0.60453933",
"0.6034676",
"0.6034676",
"0.6029097",
"0.5967057",
"0.5951521",
"0.5927236",
"0.5893753",
"0.5860448",
"0.58439827",
"0.5843596",
"0.5814976",
"0.57961816",
"0.5767449",
"0.574116",
"0.5645995",
"0.5641025",
"0.5629351",
"0.561377",
"0.5611756",
"0.5608643"
] | 0.71234185 | 0 |
Return the start_time for +section+ if it is not nil, otherwise return this assignments start_time instead. | def section_start_time(section)
return start_time unless section_due_dates_type
section&.section_due_dates&.find_by(assignment: self)&.start_time || start_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_time\n dtstart_property ? dtstart.to_datetime : nil\n end",
"def start_t\n self.start_time.strftime(\"%I:%M\") if self.start_time\n end",
"def start_time\n @parts.first.start_time\n end",
"def start_time\n eval(start) if start.present?\n end",
"def get_collection_time(section = nil)\n if section.nil?\n return @get_global_collection_time unless @get_global_collection_time.nil?\n @get_global_collection_time = calculate_collection_time\n else\n reset_collection_time if @get_collection_time.nil?\n unless @get_collection_time[section.id].nil?\n return @get_collection_time[section.id]\n end\n @get_collection_time[section.id] = calculate_collection_time(section)\n end\n end",
"def start_date\n\t \tTime.at(self.start_time) rescue nil\n\t end",
"def start_time\n\t\t\treturn @start_time.strftime('%H:%M')\n\t\tend",
"def start(value = nil)\n return @start unless value\n @start = _parse_time(value)\n end",
"def start_time\n return @start_time\n end",
"def add_section_time\n orderDate = self.orderDate\n sectionTime = self.section.startTime\n self.orderDate = DateTime.new(orderDate.year, orderDate.month, orderDate.day, sectionTime.hour, sectionTime.min)\n end",
"def start_time\n @start_time\n end",
"def start_time=(value)\n @start_time = value\n end",
"def started_at\n Time.parse @gapi.start_time\n rescue StandardError\n nil\n end",
"def start_time=(val)\n if val.kind_of?(Time) || val.kind_of?(DateTime)\n self.start_minute_of_a_day = val.minute_of_a_day\n elsif val.kind_of?(String)\n self.start_minute_of_a_day = Time.zone.parse(val).minute_of_a_day\n end\n end",
"def start_time\n dtstart.to_datetime\n end",
"def start_time(person_or_type = nil)\n attribute_for_audience_with_generic(:start_time, person_or_type)\n end",
"def start_time\n start_at.strftime(\"%F\") if start_at\n end",
"def start_time_to_s\n\t \tself.start_date.try(:strftime, '%H:%M:%S')\n\t end",
"def start_time(*args)\n raw = starts_at || shift.starts_at\n raw = Time.local date.year, date.month, date.day, raw.hour, raw.min\n return raw if args.include? :raw\n raw.to_s(:meridian_time).strip\n end",
"def get_start_time()\n return process_stamp(@start_time)\n end",
"def start_time\n self.day\n end",
"def start_time\n data.start_time\n end",
"def start_time\n data.start_time\n end",
"def start_date\n Time.parse(@start_date) if @start_date\n end",
"def start_formatted\n display_time read_attribute(:start)\n end",
"def retrieve_start_timestamp(experiment)\n if timestamp = get(experiment.handle.to_s, 'started_at')\n Time.parse(timestamp)\n end\n end",
"def set_section_time\n @section_time = SectionTime.find(params[:id])\n end",
"def start_time=(_start_time)\n Time.use_zone(screen.time_zone) do\n if _start_time.kind_of?(Hash)\n # convert to time, strip off the timezone offset so it reflects local time\n t = DateTime.strptime(\"#{_start_time[:date]} #{_start_time[:time]}\".gsub(I18n.t('time.am'), \"am\").gsub(I18n.t('time.pm'), \"pm\"), \"#{I18n.t('time.formats.date_long_year')} %I:%M %P\")\n write_attribute(:start_time, Time.zone.parse(Time.iso8601(t.to_s).to_s(:db)))\n else\n write_attribute(:start_time, _start_time)\n end\n end\n end",
"def time\n start.try(:to_time).try(:strftime, '%-l:%M %P')\n end",
"def get_started_at_smart_str\n return nil if self.started_at.nil?\n if Time.current.to_date == self.started_at.to_date\n get_formatted_time(self.started_at)\n else\n get_formatted_datetime(self.started_at)\n end\n end"
] | [
"0.6611356",
"0.63496816",
"0.63237846",
"0.6315924",
"0.61634696",
"0.5929832",
"0.59176123",
"0.5888484",
"0.58759874",
"0.5828085",
"0.5786118",
"0.5782122",
"0.5776625",
"0.57565486",
"0.57317555",
"0.57188463",
"0.5703946",
"0.5685448",
"0.5680661",
"0.5667713",
"0.5663121",
"0.5658057",
"0.5658057",
"0.5619327",
"0.5613114",
"0.5581057",
"0.5567544",
"0.5564189",
"0.5559082",
"0.5555506"
] | 0.83767444 | 0 |
Calculate the latest due date among all sections for the assignment. | def latest_due_date
return due_date unless section_due_dates_type
due_dates = section_due_dates.map(&:due_date) << due_date
due_dates.compact.max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def due_date\n if assignment.section_due_dates_type\n a_due_date = assignment.assessment_section_properties\n .find_by(section_id: inviter&.section)&.due_date || assignment.due_date\n else\n a_due_date = assignment.due_date\n end\n extension_time = (extension&.time_delta || 0)\n return a_due_date + extension_time if !assignment.is_timed || start_time.nil?\n\n start_time + extension_time + assignment.duration\n end",
"def final_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[-1] \n end",
"def edit\n @assignment = Assignment.find_by_id(params[:id])\n @past_date = @assignment.section_names_past_due_date\n @assignments = Assignment.all\n @sections = Section.all\n\n unless @past_date.nil? || @past_date.empty?\n flash_now(:notice, t('past_due_date_notice') + @past_date.join(', '))\n end\n\n # build section_due_dates for each section that doesn't already have a due date\n Section.all.each do |s|\n unless SectionDueDate.find_by_assignment_id_and_section_id(@assignment.id, s.id)\n @assignment.section_due_dates.build(section: s)\n end\n end\n @section_due_dates = @assignment.section_due_dates\n .sort_by { |s| [SectionDueDate.due_date_for(s.section, @assignment), s.section.name] }\n end",
"def due_date\n students = self.accessible_students \n return nil if students.length == 0\n\n date = students.first.due_date\n students.find_each do |student|\n if student.due_date \n if !date || student.due_date > date\n date = student.due_date\n end\n end\n end\n\n date\n end",
"def section_names_past_due_date\n if !self.section_due_dates_type && !due_date.nil? && Time.current > due_date\n return []\n end\n\n sections_past = []\n self.section_due_dates.each do |d|\n if !d.due_date.nil? && Time.current > d.due_date\n sections_past << d.section.name\n end\n end\n\n sections_past\n end",
"def calculate_replies_due\n date = Course.joins(:course_selections)\n .where('course_selections.application_id' => self.id)\n .order(:start_date).first.start_date\n Application.calculate_replies_due date.year\n end",
"def due\n\t\t\t\tif read_attribute(:due) && read_attribute(:due) > 0\n\t\t\t\tTime.at(read_attribute(:due)).to_date\n\t\t\t\telse\n\t\t\t\tnil\n\t\t\t\tend\n\t\t\tend",
"def due_by\n #occurring_days = ae_definition.occurring_days\n dob = profile.kids_type.birthdate.to_date\n dob + (ae_definition.occurring_days + ae_definition.due_by_days )\n end",
"def due_date\n if @lease.grace_period.present? && @lease.grace_period >= 0\n @date + @lease.grace_period.day\n else\n @date\n end\n end",
"def due_date\n return @due_date\n end",
"def due\n if read_attribute(:due) && read_attribute(:due) > 0\n Time.at(read_attribute(:due)).to_date\n else\n nil\n end\n end",
"def get_due_date()\n return @due_date\n end",
"def next_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[0]\n end",
"def last_story_date\n self.stories.select {|story| story.completion_date}.sort_by(&:completion_date).last.completion_date.to_s rescue nil\n end",
"def due_date_task_list\n @due_date_task_list\n end",
"def book_due_dates\n borrowed_books.each { |book| puts \"#{book.title} checked out by #{book.borrower.first.name}. Due date: #{book.due_date.strftime(\"%B %d, %Y\")}.\"}\n end",
"def past_all_due_dates?\n # If no section due dates /!\\ do not check empty? it could be wrong\n return false if !due_date.nil? && Time.current < due_date\n return false if section_due_dates.any? { |sec| !sec.due_date.nil? && Time.current < sec.due_date }\n\n true\n end",
"def get_due_date #returns date book due integer\n loan_days = 7\n takeout_day = nil\n lines = File.readlines('libraryday.txt')\n lines.each{| line | takeout_day = line}\n takeout_day.chomp\n due_date = takeout_day.to_i + loan_days\n return due_date\n end",
"def get_due_date()\n @due_date\n end",
"def update_due_date\n @due_date_all.each do |dd|\n update_due_date_nameurl(dd)\n adjust_due_date_for_timezone(dd)\n break if validate_due_date\n end\n end",
"def\n get_due_date()\n @due_date\n end",
"def due_date\n @due_date\n end",
"def last_payment_due_on\n entry = workshop_price.specific_payment_schedule(initial_payments_should_start_on, Date.today)\n entry ? entry[:due_on] : initial_payments_should_start_on.to_date\n end",
"def update_due_dates(attributes, user)\n return false unless attributes\n\n attributes.each do |due_date|\n next if due_date[:due_at].blank?\n\n # parse the dd and convert it to utc before saving it to db\n # eg. 2015-06-22 12:05:00 -0400\n current_local_time = Time.parse(due_date[:due_at][0..15])\n tz = ActiveSupport::TimeZone[user.timezonepref].tzinfo\n utc_time = tz.local_to_utc(Time.local(current_local_time.year,\n current_local_time.month,\n current_local_time.day,\n current_local_time.strftime('%H').to_i,\n current_local_time.strftime('%M').to_i,\n current_local_time.strftime('%S').to_i))\n due_date[:due_at] = utc_time\n if due_date[:id].nil? || due_date[:id].blank?\n dd = AssignmentDueDate.new(due_date)\n @has_errors = true unless dd.save\n else\n dd = AssignmentDueDate.find(due_date[:id])\n # get deadline for review\n @has_errors = true unless dd.update_attributes(due_date)\n end\n @errors += @assignment.errors.to_s if @has_errors\n end\n end",
"def pledge_deadline\n @pledge_deadline ||= begin\n date = node.css('.project-stats li').last.inner_html.to_s\n if date =~ /Funded/\n Date.parse date.split('<strong>Funded</strong>').last.strip\n elsif date =~ /hours left/\n future = Time.now + date.match(/\\d+/)[0].to_i * 60*60\n Date.parse(future.to_s)\n elsif date =~ /days left/\n Date.parse(Time.now.to_s) + date.match(/\\d+/)[0].to_i\n end\n end\n end",
"def due\n DateTime.parse(value_for('due'))\n end",
"def list_not_completed_this_month_date_only\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month\n end",
"def assignment_staggered_deadline?\n if @assignment_form.assignment.staggered_deadline == true\n @review_rounds = @assignment_form.assignment.num_review_rounds\n @due_date_all ||= AssignmentDueDate.where(parent_id: @assignment_form.assignment.id)\n @assignment_submission_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SUBMISSION }\n @assignment_review_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_REVIEW }\n end\n @assignment_form.assignment.staggered_deadline == true\n end",
"def current_assignment\n assignments.all.map{|a| a unless a.end_date != nil}.compact.first \n end",
"def days_remaining\n enrollment.days_to_due_date - 1\n end"
] | [
"0.66624385",
"0.64978683",
"0.63785654",
"0.6357543",
"0.62413526",
"0.6073185",
"0.60312366",
"0.5918119",
"0.5880308",
"0.58605635",
"0.5858714",
"0.58551776",
"0.5819644",
"0.5787709",
"0.5778905",
"0.57377017",
"0.57364464",
"0.57348734",
"0.5726459",
"0.5724474",
"0.57143986",
"0.5703903",
"0.56960464",
"0.56786495",
"0.5655922",
"0.5654713",
"0.5628512",
"0.5585147",
"0.55845404",
"0.55761856"
] | 0.7644729 | 0 |
Return collection date for all groupings as a hash mapping grouping_id to collection date. | def all_grouping_collection_dates
submission_rule_hours = submission_rule.periods.pluck('periods.hours').sum.hours
no_penalty = Set.new(groupings.joins(:extension).where('extensions.apply_penalty': false).pluck(:id))
collection_dates = Hash.new { |h, k| h[k] = due_date + submission_rule_hours }
all_grouping_due_dates.each do |grouping_id, grouping_due_date|
if no_penalty.include? grouping_id
collection_dates[grouping_id] = grouping_due_date
else
collection_dates[grouping_id] = grouping_due_date + submission_rule_hours
end
end
collection_dates
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_grouping_due_dates\n section_due_dates = groupings.joins(inviter: [section: :section_due_dates])\n .where('section_due_dates.assessment_id': id)\n .pluck('groupings.id', 'section_due_dates.due_date')\n\n grouping_extensions = groupings.joins(:extension)\n .pluck(:id, :time_delta)\n\n due_dates = Hash.new { |h, k| h[k] = due_date }\n section_due_dates.each do |grouping_id, sec_due_date|\n due_dates[grouping_id] = sec_due_date unless sec_due_date.nil?\n end\n grouping_extensions.each do |grouping_id, ext|\n due_dates[grouping_id] += ext\n end\n due_dates\n end",
"def group\n records.group_by{|r| r[:date]}\n end",
"def group_by_day\n\n\tend",
"def calculate_grouping_collection_time(grouping)\n return grouping.due_date if assignment.is_timed && grouping.start_time.nil?\n\n add = grouping.extension.nil? || grouping.extension.apply_penalty ? hours_sum.hours : 0\n grouping.due_date + add\n end",
"def date_group_items\n @date_group_items ||= []\n end",
"def group_by_day\n created_at.to_date\n end",
"def group_by_day\n group_by { |e| e.timestamp.strftime '%Y-%m-%d' }\n end",
"def groupby_fields\n ids = {}\n ids.merge!(make_grp_prj_periods[0])\n ids.merge!(make_grp_prj_nodes[0])\n { '_id' => ids }\n end",
"def group_all\n grp = {}\n grp.merge!(groupby_fields)\n grp.merge!(groupby_values)\n { '$group' => grp }\n end",
"def taggable_document_collection_groups_container\n Rails.cache.fetch(taggable_document_collection_groups_cache_digest, expires_in: 1.day) do\n DocumentCollection.latest_edition.alphabetical.includes(:groups).flat_map do |collection|\n collection.groups.map { |group| [\"#{collection.title} (#{group.heading})\", group.id] }\n end\n end\n end",
"def group_entries entries\n @time_cache ||= {}\n entries.group_by do |title, _|\n begin\n time = @time_cache[title]\n (time || parse_date(title)).strftime '%Y-%m-%d'\n rescue NoMethodError, ArgumentError\n time, = title.split ' ', 2\n parse_date(time).strftime '%Y-%m-%d'\n end\n end\n end",
"def groupByDate(bridges)\n datehash = Hash.new\n\n bridges.each do |ips|\n ips.values.each do |measurements|\n measurements.each do |m|\n time = Date.strptime(m[\"start_time\"].to_s, '%s')\n \n datehash[time] ? datehash[time].push(m) : datehash[time] = [m]\n end\n end\n end\n\n return datehash\n end",
"def all_group_hash\n hash = {}\n for group in @all_groups\n hash[group] = {}\n end\n return hash\n end",
"def collection_hash\n collection_field_pairs = collection_fields.map do |field|\n [ normalize_header(field.header), field.value ]\n end\n Hash[ collection_field_pairs ]\n end",
"def products_to_be_added_grouped_by_date\n group_by_date(products_to_be_added)\n end",
"def index\n @events = Event.where('event_start >= ?', Date.today).order(:event_start, :time_begin)\n @date_events_hash = @events.group_by(&:event_start)\n end",
"def key_by_date\n self.strftime('%Y-%m-%d')\n end",
"def taggable_document_collection_groups_cache_digest\n @taggable_document_collection_groups_cache_digest ||= calculate_digest(Document.where(document_type: \"DocumentCollection\").order(:id), \"document-collection-groups\")\n end",
"def group_by(collection, grouping_value)\n collection.reduce({}) do |acc, item| #we build a dictionary (or hashmap)\n acc.tap do |acc| #because I love old fashioned functional style\n acc[item[grouping_value]] ||= [] #because a new value\n acc[item[grouping_value]] << item\n end\n end.map do |key, value| #transform the hash to an array\n value\n end\nend",
"def event_groups(dates, pennkey = nil)\n output = {}\n dateline = {}\n\n KEY_HASH.each do |category, category_hash|\n category_output = {}\n events = Consultation::Interaction.where(consultation_or_instruction: category)\n # Safe handling for null pennkey\n events = events.where(staff_pennkey: pennkey) unless pennkey.nil?\n # Filter on date range\n events = events\n .where('event_date >= ?', dates.first)\n .where('event_date <= ?', dates.last)\n\n # Loop through the columns for calculations\n category_hash.each do |column, method|\n # Treat columns differently by method\n category_output[column.to_s] = if method == 'average'\n [\n column_average(events, column),\n column_nils(events, column)\n ]\n elsif method == 'median'\n [\n column_median(events, column),\n column_nils(events, column)\n ]\n elsif method == 'sum'\n [\n column_sum(events, column),\n column_nils(events, column)\n ]\n else\n key_groups(events, column)\n end\n end # End of category hash loop\n\n # Group the event date by month.\n # Keep separate for further handling\n dateline[category.to_s] = events.group_by_month(:event_date).count\n dateline[category.to_s].transform_keys!(&:to_date)\n\n output[category.to_s] = category_output\n end # end of KEY_HASH loop\n\n # Manipulate timelines to create uniformity\n # Flatten the list of timestamps\n datestamps = dateline.map { |_k, v| v.keys }.flatten\n # Find the full range of months\n months = find_months_between(datestamps.minmax)\n # Fill in zeros for missing months\n dateline.map { |k, v| [k, months_fill_zero(v, months)] }.to_h\n\n [output, dateline]\n end",
"def to_hash\n\t\t\t\th = {}\n\t\t\t\tself.days.each do |name, day|\n\t\t\t\t\th.merge!(name => day.to_hash)\n\t\t\t\tend\n\t\t\t\th\n\t\t\tend",
"def checkin_organize_bookings_by_dates(bookings)\n by_dates = OrderedHash.new\n sorted_by_date_start = bookings.sort_by {|b| b.date_start}\n sorted_by_date_start.each do |booking|\n key = booking.date_start\n if by_dates.has_key?(key)\n by_dates[key] << booking\n else\n arr = Array.new\n arr << booking\n by_dates[key] = arr\n end\n end\n by_dates\n end",
"def dates\n entries = Entry.all\n $dates_array = Array.new\n entries.each do |entry|\n $dates_array << entry.created_at.strftime(\"%Y-%m-%d\")\n end\n $dates_array.uniq\n end",
"def to_json_table(event, collection, date)\n dates_hash = Hash.new\n (event.created_at.to_date..Date.today).map{ |date| date.strftime(\"%m/%d/%Y\") }.each do |d|\n dates_hash[d]=0\n end\n\n collection.select(\"count(*) as n, #{variable_date_truncate(date)} as day\").\n group(variable_date_truncate(date)).reorder(\"day\").each{|c| dates_hash[c.day]=c.n}\n\n data_table = [['Date', 'N'].to_s]\n data_table << dates_hash.to_a.collect{|c| c.to_s}\n\n return data_table.collect{|v| v}.join(\",\").html_safe\n end",
"def set_dates(results)\n date_dimension = []\n for result in results\n stored_element = date_dimension.detect { |element| element[:date].to_s == result.send(:date).to_s }\n if stored_element\n stored_element[:value][:pageviews] += result.send(:pageviews).to_i\n stored_element[:value][:unique_pageviews] += result.send(:unique_pageviews).to_i\n else\n date_dimension << {:date => result.send(:date).to_s, :value => {:pageviews => result.send(:pageviews).to_i, :unique_pageviews => result.send(:unique_pageviews).to_i} }\n end\n result.date_dimension = date_dimension\n end\n end",
"def entry_dates()\r\n return @entries_by_date.keys.sort.reverse()\r\n end",
"def group_by\n end",
"def get_recent_days_summary\n summary = {}\n # process datasets\n @dataset.keys.each do |station|\n @dataset[station].keys.each do |date|\n key = date.strftime(\"%d/%m/%Y\")\n raise \"date conflict in datasets for #{date}\" if !summary[key].nil?\n summary[key] = make_summary_row(@dataset[station][date])\n end\n end \n return summary\n end",
"def users_by_day\n\t\thash = Hash.new\n\t\t# SORTING USER_COMMITMENTS BY CREATION DATE TO AN ARRAY\n\t\tsorted_array = self.user_themes.all.sort { |a, b| a.created_at <=> b.created_at }\n\t\t# CREATING A HASH WHERE EACH DATE FROM FIRST UC CONTAINS VALUE OF UCs CREATED\n\t\tsorted_array.each do |each_ut|\n\t\t\tif hash[each_ut.created_at.to_date] == nil\n\t\t\t\thash[each_ut.created_at.to_date] = 0\n\t\t\tend\n\t\t\thash[each_ut.created_at.to_date] += 1\n\t\tend\n\t\tday_count = sorted_array[0].created_at.to_date\n\t\thash[day_count - 1.days] = 0\n\t\t# INCREMENTING WITH PREVIOUS DAY\n\t\twhile (day_count <= Date.today)\n\t\t\tif hash[day_count] != nil\n\t\t\t\thash[day_count] = hash[day_count - 1.days] + hash[day_count]\n\t\t\telse\n\t\t\t\thash[day_count] = hash[day_count - 1.days]\n\t\t\tend\n\t\t\tday_count += 1.days\n\t\tend\n\t\treturn hash\n\tend",
"def group_by\n\n end"
] | [
"0.68985265",
"0.6179693",
"0.6074221",
"0.5908538",
"0.5896297",
"0.58740526",
"0.5835777",
"0.5834629",
"0.57039577",
"0.5646266",
"0.5592449",
"0.55805844",
"0.5535527",
"0.5521801",
"0.5419339",
"0.5414376",
"0.5407178",
"0.53307223",
"0.52696747",
"0.5269064",
"0.52617943",
"0.5253675",
"0.52385336",
"0.5223995",
"0.51711106",
"0.517014",
"0.51699513",
"0.5167791",
"0.51356524",
"0.5132285"
] | 0.80465966 | 0 |
Return due date for all groupings as a hash mapping grouping_id to due date. | def all_grouping_due_dates
section_due_dates = groupings.joins(inviter: [section: :section_due_dates])
.where('section_due_dates.assessment_id': id)
.pluck('groupings.id', 'section_due_dates.due_date')
grouping_extensions = groupings.joins(:extension)
.pluck(:id, :time_delta)
due_dates = Hash.new { |h, k| h[k] = due_date }
section_due_dates.each do |grouping_id, sec_due_date|
due_dates[grouping_id] = sec_due_date unless sec_due_date.nil?
end
grouping_extensions.each do |grouping_id, ext|
due_dates[grouping_id] += ext
end
due_dates
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_grouping_collection_dates\n submission_rule_hours = submission_rule.periods.pluck('periods.hours').sum.hours\n no_penalty = Set.new(groupings.joins(:extension).where('extensions.apply_penalty': false).pluck(:id))\n collection_dates = Hash.new { |h, k| h[k] = due_date + submission_rule_hours }\n all_grouping_due_dates.each do |grouping_id, grouping_due_date|\n if no_penalty.include? grouping_id\n collection_dates[grouping_id] = grouping_due_date\n else\n collection_dates[grouping_id] = grouping_due_date + submission_rule_hours\n end\n end\n collection_dates\n end",
"def calculate_grouping_collection_time(grouping)\n return grouping.due_date if assignment.is_timed && grouping.start_time.nil?\n\n add = grouping.extension.nil? || grouping.extension.apply_penalty ? hours_sum.hours : 0\n grouping.due_date + add\n end",
"def due_by\n #occurring_days = ae_definition.occurring_days\n dob = profile.kids_type.birthdate.to_date\n dob + (ae_definition.occurring_days + ae_definition.due_by_days )\n end",
"def days_assigned\r\n days_assigned = []\r\n self.groups.each {|g| days_assigned.push(g.day)}\r\n return days_assigned\r\n end",
"def date_group_items\n @date_group_items ||= []\n end",
"def due_date(due)\n return DateLabelHelper::DueDateView.new(due, prefs).due_date_html\n end",
"def group_by_day\n\n\tend",
"def details\n date_hash = {due_date: @due}\n detail_hash = {}\n detail_hash[:description] = format_description(@description)\n detail_hash[:date] = \"due: #{format_date(@type, date_hash)}\"\n detail_hash[:priority] = format_priority(@priority)\n detail_hash[:type] = @type\n detail_hash\n end",
"def due_date_task_list\n @due_date_task_list\n end",
"def due_date_string\n ::Util.date_to_string(self.due_date)\n end",
"def due_date_string\n ::Util.date_to_string(self.due_date)\n end",
"def issues_due_in_days\n due_date = options.days.day.from_now.to_date\n s = ARCondition.new [\"#{Issue.table_name}.due_date <= ?\", due_date]\n s << issue_statuses\n s << projects\n s << trackers\n Issue.find(:all, :include => [:status, :assigned_to, :author, :project, :watchers, :tracker],\n :conditions => s.conditions,\n :order => \"#{Issue.table_name}.due_date, #{Project.table_name}.name\")\n end",
"def book_due_dates\n borrowed_books.each { |book| puts \"#{book.title} checked out by #{book.borrower.first.name}. Due date: #{book.due_date.strftime(\"%B %d, %Y\")}.\"}\n end",
"def due_date_formatted\n object.due_date.strftime('%a %d %b %Y') if object.due_date\n end",
"def due_date\n created_at + Spree::BilletConfig.due_date.days\n end",
"def get_due_date()\n return @due_date\n end",
"def due_tasks\n tasks = []\n\n all_tasks.each do |task|\n due = task.due_date.get\n\n if due.is_a?(Time) && due > Time.new\n tasks << Task.new(task.name.get, due)\n end\n end\n\n # Sorts the array of tasks by due_date\n tasks.sort! { |a,b| a.due_date <=> b.due_date }\n end",
"def latest_due_date\n return due_date unless section_due_dates_type\n due_dates = section_due_dates.map(&:due_date) << due_date\n due_dates.compact.max\n end",
"def title\n zone = Timezone::Zone.new :zone => group.due_timezone\n due = date_due.to_time.localtime(zone.utc_offset)\n due.strftime('%A, %B %-d, %Y')\n end",
"def format_date(number)\n if number == 1\n dates = @start_date.strftime(\"%D\") if @start_date\n dates << \" -- \" + @end_date.strftime(\"%D\") if @end_date\n dates = \"N/A\" if !dates\n return dates\n else\n @due ? @due.strftime(\"%D\") : \"No due date\"\n end\n end",
"def final_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[-1] \n end",
"def get_due_date()\n @due_date\n end",
"def update_due_date\n @due_date_all.each do |dd|\n update_due_date_nameurl(dd)\n adjust_due_date_for_timezone(dd)\n break if validate_due_date\n end\n end",
"def group_by_day\n created_at.to_date\n end",
"def due_date\n return @due_date\n end",
"def groupby_fields\n ids = {}\n ids.merge!(make_grp_prj_periods[0])\n ids.merge!(make_grp_prj_nodes[0])\n { '_id' => ids }\n end",
"def\n get_due_date()\n @due_date\n end",
"def group_entries entries\n @time_cache ||= {}\n entries.group_by do |title, _|\n begin\n time = @time_cache[title]\n (time || parse_date(title)).strftime '%Y-%m-%d'\n rescue NoMethodError, ArgumentError\n time, = title.split ' ', 2\n parse_date(time).strftime '%Y-%m-%d'\n end\n end\n end",
"def by_days(rations)\n rations\n .group_by { |e| e[4] }\n .map do |k, v|\n { number: k,\n rations: squash_rations(v).each { |e| e.delete_at(4) } \n }\n end\n end",
"def due_date\n if assignment.section_due_dates_type\n a_due_date = assignment.assessment_section_properties\n .find_by(section_id: inviter&.section)&.due_date || assignment.due_date\n else\n a_due_date = assignment.due_date\n end\n extension_time = (extension&.time_delta || 0)\n return a_due_date + extension_time if !assignment.is_timed || start_time.nil?\n\n start_time + extension_time + assignment.duration\n end"
] | [
"0.7547602",
"0.5708773",
"0.5608013",
"0.5571348",
"0.5565333",
"0.5494454",
"0.5491765",
"0.5466965",
"0.5460922",
"0.54379493",
"0.54379493",
"0.5391702",
"0.53843033",
"0.5348482",
"0.52871644",
"0.52607083",
"0.5225119",
"0.52177906",
"0.51892334",
"0.51842934",
"0.51721805",
"0.5166525",
"0.5163798",
"0.5162243",
"0.51501405",
"0.5141518",
"0.5140566",
"0.51244813",
"0.5117625",
"0.5050579"
] | 0.82948434 | 0 |
checks if the due date for +section+ has passed for this assignment or if the main due date has passed if +section+ is nil. | def past_collection_date?(section = nil)
Time.current > submission_rule.calculate_collection_time(section)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def past_all_due_dates?\n # If no section due dates /!\\ do not check empty? it could be wrong\n return false if !due_date.nil? && Time.current < due_date\n return false if section_due_dates.any? { |sec| !sec.due_date.nil? && Time.current < sec.due_date }\n\n true\n end",
"def section_start_time(section)\n return start_time unless section_due_dates_type\n\n section&.section_due_dates&.find_by(assignment: self)&.start_time || start_time\n end",
"def edit\n @assignment = Assignment.find_by_id(params[:id])\n @past_date = @assignment.section_names_past_due_date\n @assignments = Assignment.all\n @sections = Section.all\n\n unless @past_date.nil? || @past_date.empty?\n flash_now(:notice, t('past_due_date_notice') + @past_date.join(', '))\n end\n\n # build section_due_dates for each section that doesn't already have a due date\n Section.all.each do |s|\n unless SectionDueDate.find_by_assignment_id_and_section_id(@assignment.id, s.id)\n @assignment.section_due_dates.build(section: s)\n end\n end\n @section_due_dates = @assignment.section_due_dates\n .sort_by { |s| [SectionDueDate.due_date_for(s.section, @assignment), s.section.name] }\n end",
"def validate_due_date\n @due_date_nameurl_not_empty && @due_date_nameurl_not_empty_checkbox &&\n (@metareview_allowed || @drop_topic_allowed || @signup_allowed || @team_formation_allowed)\n end",
"def overdue?\n return false if due_at.nil?\n due_at < Time.now \n end",
"def dates_are_correct\n errors.add(:begins, _(\"%{fn} can't be blank\")) if begins.nil?\n errors.add(:finishes, _(\"%{fn} can't be blank\")) if finishes.nil?\n\n dates_in_order?(begins, finishes) or\n errors.add(:begins, _('Conference must end after its start date'))\n\n dates_in_order?(cfp_open_date, cfp_close_date) or\n errors.add(:cfp_open_date, _('Call for papers must end after its ' +\n 'start date'))\n dates_in_order?(cfp_close_date, begins) or\n errors.add(:cfp_close_date, _('Call for papers must finish before ' +\n 'the conference begins'))\n\n dates_in_order?(reg_open_date, reg_close_date) or\n errors.add(:reg_open_date, _('Registration must end after its ' +\n 'start date'))\n dates_in_order?(reg_close_date, finishes) or\n errors.add(:reg_close_date, _('Registration must finish before the ' +\n 'conference ends'))\n end",
"def check_completed_at\n self.errors.add('Completion Date', 'can\\'t be blank') if (self.completed && self.completed_at.blank?)\n end",
"def due?\n super && !violations.empty?\n end",
"def section_names_past_due_date\n if !self.section_due_dates_type && !due_date.nil? && Time.current > due_date\n return []\n end\n\n sections_past = []\n self.section_due_dates.each do |d|\n if !d.due_date.nil? && Time.current > d.due_date\n sections_past << d.section.name\n end\n end\n\n sections_past\n end",
"def due_date_nameurl_not_empty?(dd)\n dd.deadline_name.present? || dd.description_url.present?\n end",
"def overdue? ()\n\t\t@due_date < Time.now\n end",
"def is_overdue\n if @due_date\n if ( (Time.now - @due_date) > 0 )\n @status = \"overdue\"\n puts \"#{@title} is overdue! Please return!\"\n else\n days_left = @due_date.yday - Time.now.yday\n puts \"You have #{days_left} days before you need to return #{@title}.\"\n end\n\n else\n puts \"#{@title} has not been checked out.\"\n end \n end",
"def assignment_staggered_deadline?\n if @assignment_form.assignment.staggered_deadline == true\n @review_rounds = @assignment_form.assignment.num_review_rounds\n @due_date_all ||= AssignmentDueDate.where(parent_id: @assignment_form.assignment.id)\n @assignment_submission_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SUBMISSION }\n @assignment_review_due_dates = @due_date_all.select { |due_date| due_date.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_REVIEW }\n end\n @assignment_form.assignment.staggered_deadline == true\n end",
"def empty_due_on?(month:, day:)\n day.zero? && month.zero? || day.zero? && month == -1\n end",
"def missed_deadline?\n if self.closeDate.nil?\n self.dueDate.to_date < Date.today\n else\n self.dueDate.to_date < self.closeDate.to_date\n end\n end",
"def overdue?\n due < Date.current\n end",
"def date_check\n if due_date.present? && due_date < Date.today\n errors.add(:due_date, \"can't be before today\")\n end\n end",
"def verify_date_completed(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::DATE_COMPLETED.name], element_value(date_completed_input))\n end",
"def verify_date_completed(test_data)\n verify_values_match(test_data[UseOfCollections::DATE_COMPLETED.name], element_value(date_completed_input))\n end",
"def overdue?\r\n @overdue = Time.now > @due_date\r\n end",
"def check_fixed_date_requirements(date)\n return true unless release_fixed_date? && release_date.present?\n date == release_date\n end",
"def overdue?(test)\r\n\t\tif self.overdue.present?\r\n\t\t\tself.overdue.overdue?(test)\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend",
"def correct_completion_status_date\n if self.is_complete? && self.completed_at.blank?\n # if task is marked complete without a completion time, update completion time to now & allow confirmation\n self.completed_at = DateTime.now\n return true\n elsif !self.is_complete? && !self.completed_at.blank?\n # if task is marked incomplete, but there is a completion time entered, update completion time to blank & allow confirmation\n self.completed_at = nil\n return true\n else\n return false\n end\n end",
"def overdue?\n @due_date < Date.today\n end",
"def due_date\n if assignment.section_due_dates_type\n a_due_date = assignment.assessment_section_properties\n .find_by(section_id: inviter&.section)&.due_date || assignment.due_date\n else\n a_due_date = assignment.due_date\n end\n extension_time = (extension&.time_delta || 0)\n return a_due_date + extension_time if !assignment.is_timed || start_time.nil?\n\n start_time + extension_time + assignment.duration\n end",
"def in_force?\n if self.effective_date.nil?\n false\n elsif self.termination_date.nil?\n Date.today >= effective_date\n else\n Date.today >= effective_date and Date.today < termination_date\n end\n end",
"def has_date?\n !fields.select { |f| f.responsible_for?('Date') }.empty?\n end",
"def temporarly_assignment_date\n\t\terrors.add(:expected_return_date, \" can't be blank on Temporarly Assignment\") if assignment_type == \"false\" && expected_return_date.blank?\n\tend",
"def due?\n return true if @payment_due.to_f > 0\n false\n end",
"def editable_by_with_date_check?(usr)\n if TimeEntry.diary_threshold_enabled?\n return false if self.spent_on && (self.spent_on < TimeEntry.min_date_for_modifications)\n end\n editable_by_without_date_check?(usr)\n end"
] | [
"0.68316144",
"0.6027668",
"0.58691174",
"0.5817499",
"0.5736533",
"0.57332796",
"0.5676839",
"0.562399",
"0.55553293",
"0.5540483",
"0.55387837",
"0.553669",
"0.5522066",
"0.5494772",
"0.5493549",
"0.54701877",
"0.5455643",
"0.54438186",
"0.5436364",
"0.5411823",
"0.53773504",
"0.53612983",
"0.5335421",
"0.5321802",
"0.5313614",
"0.53043765",
"0.5273205",
"0.52671456",
"0.52645075",
"0.52522415"
] | 0.6037223 | 1 |
Return true if this is a group assignment; false otherwise | def group_assignment?
invalid_override || group_max > 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_group(grp)\n true\n end",
"def has_group?\n\t\t@group == ''\n\tend",
"def has_group?\n @group == ''\n end",
"def group?(group)\n\t\t\tend",
"def group?\n true\n end",
"def belongs_to_group?\n self.group ? true : false\n end",
"def group?\n type == :group_id\n end",
"def group?\n type == :group_id\n end",
"def group?\n proprieties[:group]\n end",
"def in_group?(group)\n @groups.include? group\n end",
"def group_member?\n kind == 'group_member'\n end",
"def permanent?\n return BlizzABS::Alignments::PERMANENT_GROUPS.include?(@group)\n end",
"def group_choosen?\n !current_group.nil?\n end",
"def group_choosen?\n !current_group.nil?\n end",
"def group?(name)\n name = name.to_s\n @groups.find{ |g| g.name == name } || false\n end",
"def defined?(group_name)\n true\n end",
"def group?\n members.count > 2 or self[:name].present?\n end",
"def member_of?(group)\n cn_groups.include?(group)\n end",
"def is_assessment_group?\n @reportable.class.table_name == 'assessment_groups'\n end",
"def group_owner_entry?\n group_entry? && principle == \"GROUP\"\n end",
"def defined?(group_name)\n @groups.key?(group_name)\n end",
"def valid_group?\n unless self.target_group.nil?\n if self.target_group.is_a? String\n !!(self.target_group == self.group)\n else\n !!(self.target_group == self.group(:id))\n end\n else\n # The group is OK if it wasn't specified\n return true\n end\n rescue ArgumentError => ex\n # The group is NOT OK if the group doesn't exist\n WarningShot::PermissionResolver.logger.error(\"Group [#{self.target_group}] does not exist: #{ex.message}\")\n return false\n end",
"def restricted?\n self.groups.any?\n end",
"def in_group_belonging_to?(org_id)\n return true if !guidance_group.nil? && (guidance_group.org.id == org_id)\n\n false\n end",
"def groupable?\n return false if multiple?\n\n human_readable?\n end",
"def assignment?\n selector.to_s[-1] == ASSIGN_SUFFIX\n end",
"def group?\n @opts[:group] != DEFAULT_GROUP\n end",
"def group? group\n group_name = group.respond_to?(:name) ? group.name : group\n self.groups.map(&:name).include?(group_name.to_s)\n end",
"def targets_any_group?\n self.muscle_groups.each_char do |c|\n return true if c == \"1\"\n end\n return false\n end",
"def group?\n self['source'] == 'QSGroupObjectSource'\n end"
] | [
"0.73700017",
"0.7085128",
"0.7085075",
"0.7007405",
"0.69147724",
"0.6789472",
"0.67761934",
"0.67761934",
"0.67606944",
"0.6724919",
"0.6724355",
"0.66221046",
"0.6609396",
"0.6609396",
"0.6580318",
"0.65559894",
"0.6530837",
"0.6528801",
"0.64976317",
"0.64862597",
"0.6454262",
"0.6436885",
"0.64245355",
"0.6416802",
"0.6402131",
"0.638092",
"0.6375072",
"0.63359565",
"0.632529",
"0.63213706"
] | 0.7879265 | 0 |
Returns the group by the user for this assignment. If pending=true, it will return the group that the user has a pending invitation to. Returns nil if user does not have a group for this assignment, or if it is not a group assignment | def group_by(uid, pending=false)
return unless group_assignment?
# condition = "memberships.user_id = ?"
# condition += " and memberships.status != 'rejected'"
# add non-pending status clause to condition
# condition += " and memberships.status != 'pending'" unless pending
# groupings.first(include: :memberships, conditions: [condition, uid]) #FIXME: needs schema update
#FIXME: needs to be rewritten using a proper query...
User.find(uid.id).accepted_grouping_for(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group group_uuid\n group_uuid = @everyone_group if group_uuid.blank?\n \n return group_uuid if group_uuid.is_a?(Group)\n\n tmp = @groups.find{|grp|grp.uuid == group_uuid}\n \n raise \"unknown group or user with id #{group_uuid}\" unless tmp\n \n tmp\n end",
"def get_group( name )\n if ( !@groups.has_key?( name ) )\n @groups[name] = Group.new( name )\n end\n return @groups[name]\n end",
"def user_groups\n return @user_groups if @user_groups\n\n @user_groups = default_user_groups\n @user_groups |= current_user.groups if current_user and current_user.respond_to? :groups\n @user_groups |= ['registered'] if !current_user.new_record? && current_user.is_osu\n @user_groups\n end",
"def get_current_group\n sd = get_security_descriptor\n\n sd&.group\n end",
"def group(user_id, group_id)\n is_initialized_and_enabled do\n group = Itly::Group.new(\n\n )\n validate_schema(group)\n @adapters.each { |adapter| adapter.group(user_id, group_id, group.properties) }\n end\n end",
"def user_group(user)\n Etc.getpwnam(user).gid\n rescue ArgumentError\n Chef::Log.warn(\n \"ssh_authorize_key: User #{user} not found at compile time, perhaps \"\\\n \"you should specify a default group. I will use #{user} for now.\"\n )\n user\n end",
"def group\n @group ||= group_id && course.groups.find_by(id: group_id)\n end",
"def get_group(gid)\n\t\t\t\tgroups().each do |group|\n\t\t\t\t\treturn group[1].groupname if group[1].gid == gid\n\t\t\t\tend\n\t\t\t\tnil\n\t\t\tend",
"def group\n strong_memoize(:group) do\n if params[:group_id].present? && valid_request?\n the_group = Group.find_by(id: params[:group_id])\n can?(current_user, :read_group, the_group) ? the_group : nil\n end\n end\n end",
"def get_group_by_name(groupname)\n return @grouphash[groupname]\n end",
"def groups\n Group.groups(user_name)\n end",
"def group_owner\n User.find_by(id: self.user_id)\n end",
"def group\n Group.get!(gidnumber)\n end",
"def find_group(name)\n login unless authenticated?\n group = JSON.parse RestClient.get(resource_url(\"groups/#{URI.escape(name)}\"), :cookies => @cookies).body\n return group['name'] == name ? group : nil\n rescue RestClient::ResourceNotFound\n return nil\n end",
"def get_a_user_group(opts = {})\n data, _status_code, _headers = get_a_user_group_with_http_info(opts)\n data\n end",
"def get_default_group(user)\n case node['platform_family']\n when 'suse'\n 'users'\n when 'mac_os_x'\n 'staff'\n else\n user[:username] || user[:id]\n end\n end",
"def get_assigned_group_for_application(app_id, group_id, options = {})\n get(\"/apps/#{app_id}/groups/#{group_id}\", options)\n end",
"def group_for_course(course)\n student = self\n group_memberships = GroupMembership.where{ \n (group_id.in( course.groups.select{id} )) & \n (user_id.eq student.id)\n }\n\n if group_memberships.length == 0 \n return nil\n else\n group_memberships.first.group\n end\n end",
"def group(id)\n result = connection.get(\"groups/#{id}\")\n result.is_a?(Array) ? result[0] : result\n end",
"def group(name)\n groups.detect { |group| group.name == name } ||\n raise(\"No such Fever group: #{name.inspect}\")\n end",
"def user_groups\n return @user_groups if @user_groups\n\n @user_groups = default_user_groups\n # TODO: necessary to include #hyrax_group_names?\n @user_groups |= current_user.hyrax_group_names if current_user.respond_to? :hyrax_group_names\n @user_groups |= ['registered'] if !current_user.new_record? && current_user.roles.count.positive?\n # OVERRIDE: add the names of all user's roles to the array of user_groups\n @user_groups |= all_user_and_group_roles\n\n @user_groups\n end",
"def get_group_by_group_id(group_id)\n id = $r.get(\"group_id.to.id:#{group_id}\")\n return nil if !id\n get_group_by_id(id)\n end",
"def user_groups_assignable_for_user(usr)\n return [] if usr.nil?\n \n if administrator?(usr)\n UserGroup.find_by_sql <<-SQL\n select user_groups.* from user_groups order by user_groups.name\n SQL\n else\n UserGroup.find_by_sql <<-SQL\n select user_groups.* from user_groups, user_groups_users\n where user_groups.id = user_groups_users.user_group_id\n and user_groups_users.user_id = #{usr.id}\t \n order by user_groups.name\n SQL\n end\n end",
"def user_group_invitation(user_id, invitation_id)\n get(\"/v1/users/#{user_id}/group_invitations/#{invitation_id}\")\n end",
"def get_group_by_name(name)\n @groups.each do |group|\n if group[0][\"name\"].downcase == name.downcase\n return group\n end\n end\n end",
"def get_or_create_group\n name = metadata['group']\n\n db = DB::Groups.find(name, pool)\n grp = load_group\n\n if db.nil?\n # The group does not exist, create it\n Commands::Group::Create.run!(\n pool: pool.name,\n name: grp.name\n )\n\n return DB::Groups.find(name, pool) || (fail 'expected group')\n end\n\n db\n end",
"def group\n return @group\n end",
"def group\n return @group\n end",
"def group(name = nil)\n if name\n @groups << name\n self.class.groups[name] ||= []\n self.class.groups[name] << self\n else\n @groups\n end\n end",
"def get_user_group(opts = {})\n get_user_group_with_http_info(opts)\n nil\n end"
] | [
"0.64377785",
"0.62712103",
"0.6109005",
"0.60526294",
"0.59797424",
"0.5970683",
"0.59606713",
"0.5936941",
"0.58517164",
"0.58206666",
"0.5807047",
"0.5767545",
"0.5765994",
"0.57379544",
"0.57206124",
"0.57015955",
"0.5680632",
"0.5659439",
"0.563401",
"0.5631924",
"0.5548329",
"0.55462885",
"0.55369353",
"0.5533413",
"0.551528",
"0.5508427",
"0.5467498",
"0.5467498",
"0.54513025",
"0.5444206"
] | 0.6889387 | 0 |
Returns a boolean indicating whether marking has started for at least one submission for this assignment. Only the most recently collected submissions are considered. | def marking_started?
Result.joins(:marks, submission: :grouping)
.where(groupings: { assessment_id: id },
submissions: { submission_version_used: true })
.where.not(marks: { mark: nil })
.any?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at_submission_limit?\n if assessment.max_submissions == -1\n false\n else\n count = assessment.submissions.where(course_user_datum: course_user_datum).count\n count >= assessment.max_submissions\n end\n end",
"def has_ta_for_marking?\n ta_memberships.count > 0\n end",
"def has_submissions?\n participants.each do |participant|\n return true if participant.has_submissions?\n end\n return false\n end",
"def has_submissions?\n participants.each do |participant|\n return true if participant.has_submissions?\n end\n return false\n end",
"def has_submissions?\n participants.each do |participant|\n return true if participant.has_submissions?\n end\n return false\n end",
"def ready_for_submission?\n self.all_reviewers_assigned? && \n self.all_manager_reviewers_assigned? &&\n self.design_data_filled_in?\n end",
"def marked?\n !@attributes.nil? && @attributes.include?(:Marked)\n end",
"def only_last_submission?\n @options[:only_last_submission].present?\n end",
"def marked?\n\t\t\t\t@marked\n\t\t\tend",
"def marks?(more_than_one = true)\n if (m = marks(selected_sound(), selected_channel())).nil?\n false\n else\n if more_than_one\n m.length > 1\n else\n true\n end\n end\n end",
"def any_requested_booking_completed?\n count = 0\n index\n @requested_bookings.each { |booking| count += 1 if booking.completed }\n true if count.positive?\n end",
"def has_submissions?\n submitted_files.any? || submitted_hyperlinks.present?\n end",
"def submitted_fafsa?\n !fafsa_submitted_at.nil?\n end",
"def submission_output?\n parent_type == \"Job\" && parent.submission.present?\n end",
"def submitted_wasfa?\n !wasfa_submitted_at.nil?\n end",
"def marked?(mark)\n @marks.include?(mark)\n end",
"def over?\n self.assignments.remaining.count == 0 && !sets_available?\n end",
"def submitted?\n self.status.to_i > status_enum['unsubmitted']\n end",
"def reviewers_full?\n return false if offering.min_number_of_reviews_per_applicant.blank?\n reviewers.without_committee_scores.size >= offering.min_number_of_reviews_per_applicant\n end",
"def being_submitted?(item)\n state_group(item) == :submission\n end",
"def submitted?\n !self.submitted_at.nil?\n end",
"def marked_ready_for_review\n @marked_ready_for_review ||= (ready_for_review? ? 1 : 0)\n end",
"def start_list_present?\n if uses_lane_assignments?\n lane_assignments.any?\n elsif compete_in_order?\n order_finalized?\n elsif start_data_type == \"Mass Start\"\n wave_numbers.any?\n else\n false\n end\n end",
"def required?\n min_repeats.positive?\n end",
"def has_assignments?\n return (self.finance_category_receipt_templates.last.present? or self.finance_category_receipt_templates.first.present?)\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def marked?\n @location != nil\n end",
"def has_work?\n how_much_more_work > 0\n end",
"def processings?\n @processings.any?\n end",
"def submitted?(item = nil)\n item ||= default_to_self\n item[:submission_id].present? &&\n (last_submit = item[:last_submit]).present? &&\n (last_indexed = item[:last_indexed]).present? &&\n (last_submit > last_indexed)\n end"
] | [
"0.65497744",
"0.6442843",
"0.6427484",
"0.6427484",
"0.6427484",
"0.6415172",
"0.6296651",
"0.6267579",
"0.62600434",
"0.6258977",
"0.62069887",
"0.6139671",
"0.6119147",
"0.60979986",
"0.6074502",
"0.6005708",
"0.59459144",
"0.59257805",
"0.58691365",
"0.5851322",
"0.5843812",
"0.5825899",
"0.58149564",
"0.57825637",
"0.5765416",
"0.5762199",
"0.5741612",
"0.5738141",
"0.57346034",
"0.57299304"
] | 0.7670785 | 0 |
Returns a list of total marks for each complete result for this assignment. There is one mark per grouping (not per student). Does NOT include: groupings with no submission incomplete results original results when a grouping has submitted a remark request that is not complete | def completed_result_marks
return @completed_result_marks if defined? @completed_result_marks
@completed_result_marks = self.current_results
.where(marking_state: Result::MARKING_STATES[:complete])
.order(:total_mark)
.pluck(:total_mark)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage_grades_array(assignment)\n groupings = assignment.groupings\n .joins(:tas)\n .where(memberships: { user_id: id })\n grades = []\n\n if assignment.assign_graders_to_criteria\n criteria_ids = self.criterion_ta_associations.where(assessment_id: assignment.id).pluck(:criterion_id)\n out_of = criteria_ids.sum do |criterion_id|\n Criterion.find(criterion_id).max_mark\n end\n return [] if out_of.zero?\n\n mark_data = groupings.joins(current_result: :marks)\n .where('marks.criterion_id': criteria_ids)\n .where.not('marks.mark': nil)\n .pluck('results.id', 'marks.mark')\n .group_by { |x| x[0] }\n mark_data.values.each do |marks|\n next if marks.empty?\n\n subtotal = 0\n has_mark = false\n marks.each do |_, mark|\n subtotal += mark\n has_mark = true\n end\n grades << subtotal / out_of * 100 if has_mark\n end\n else\n out_of = assignment.max_mark\n groupings.includes(:current_result).find_each do |grouping|\n result = grouping.current_result\n unless result.nil? || result.total_mark.nil? || result.marking_state != Result::MARKING_STATES[:complete]\n percent = calculate_total_percent(result, out_of)\n unless percent == BLANK_MARK\n grades << percent\n end\n end\n end\n end\n grades\n end",
"def percentage_grades_array(assignment)\n grades = Array.new()\n out_of = assignment.max_mark\n assignment.groupings.includes(:current_result).joins(:tas)\n .where(memberships: { user_id: id }).find_each do |grouping|\n result = grouping.current_result\n unless result.nil? || result.total_mark.nil? || result.marking_state != Result::MARKING_STATES[:complete]\n percent = calculate_total_percent(result, out_of)\n unless percent == BLANK_MARK\n grades.push(percent)\n end\n end\n end\n\n return grades\n end",
"def next_grouping_ordered_total_mark(results, ascending)\n # if the current result isn't present in results, add it for future processing\n results = results.or(Result.where('results.id': self.current_result.id))\n result_data = results.pluck('results.id', 'groups.group_name').uniq { |id, _| id }\n total_marks = Result.get_total_marks(result_data.map { |id, _| id })\n result_data.each do |el|\n el.append(total_marks[el[0]])\n end\n result_data = result_data.sort_by { |_, group_name, total_mark| [total_mark, group_name] }\n curr_res_index = result_data.bsearch_index do |_, group_name, total_mark|\n [total_marks[self.current_result.id], self.group.group_name] <=> [total_mark, group_name]\n end\n if ascending\n next_res_index = curr_res_index + 1\n else\n next_res_index = curr_res_index - 1\n end\n if next_res_index >= 0 && next_res_index < result_data.length\n return Result.find(result_data[next_res_index][0]).grouping\n end\n nil\n end",
"def get_marks_list(submission)\n criteria.map do |criterion|\n mark = submission.get_latest_result.marks.find_by(criterion: criterion)\n [(mark.nil? || mark.mark.nil?) ? '' : mark.mark,\n criterion.max_mark]\n end\n end",
"def update_marks\n result = self.grouping&.current_submission_used&.get_latest_result\n return page_not_found('No submission exists for that group') if result.nil?\n\n # We shouldn't be able to update marks if marking is already complete.\n if result.marking_state == Result::MARKING_STATES[:complete]\n render 'shared/http_status', locals: { code: '404', message:\n 'Marking for that submission is already completed' }, status: :not_found\n return\n end\n matched_criteria = assignment.criteria.where(name: params.keys)\n if matched_criteria.empty?\n render 'shared/http_status', locals: { code: '404', message:\n 'No criteria were found that match that request.' }, status: :not_found\n return\n end\n\n matched_criteria.each do |crit|\n mark_to_change = result.marks.find_or_initialize_by(criterion_id: crit.id)\n mark_to_change.mark = params[crit.name] == 'nil' ? nil : params[crit.name].to_f\n unless mark_to_change.save\n # Some error occurred (including invalid mark)\n render 'shared/http_status', locals: { code: '500', message:\n mark_to_change.errors.full_messages.first }, status: :internal_server_error\n return\n end\n end\n result.save\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok\n end",
"def group_by_marks(marks, pass_marks)\n marks.group_by do |k,v| \n v > pass_marks ? \"Passed\" : \"Failed\"\n end\n end",
"def get_total_mark\n user_visibility = is_a_review? ? :peer_visible : :ta_visible\n Result.get_total_marks([self.id], user_visibility: user_visibility)[self.id]\n end",
"def calculate_marks\n stream = Stream.find(stream_id)\n sub_maps = stream.sub_str_maps.all\n xuser = self.user\n xcategory = xuser.personal.category\n xacademic = xuser.academic\n tenth_mark = xacademic.tenth_marks\n user_subs = xacademic.subject_entries.all\n total_special_sub = sub_maps.count\n total = 0\n user_subs.each do |us|\n total += us.marks\n sub_maps.each do |sm|\n if us.subject_id == sm.subject_id\n total += us.marks\n end\n end\n end\n self.calculated_marks = total*10000 + tenth_mark\n end",
"def get_marks_in_subject(subject)\n self.subject_mark_mapping.each { |subjectMarkMap|\n if subjectMarkMap.subject && subjectMarkMap.subject.name == subject\n return subjectMarkMap.marks\n end\n }\n return 0;\n end",
"def scale_marks\n max_mark_was = previous_changes[:max_mark].first\n # results with specific assignment\n results = Result.includes(submission: :grouping)\n .where(groupings: { assessment_id: assessment_id })\n all_marks = marks.where.not(mark: nil).where(result_id: results.ids)\n # all associated marks should have their mark value scaled to the change.\n updated_marks = {}\n all_marks.each do |mark|\n updated_marks[mark.id] = mark.scale_mark(max_mark, max_mark_was, update: false)\n end\n unless updated_marks.empty?\n Mark.upsert_all(all_marks.pluck_to_hash.map { |h| { **h.symbolize_keys, mark: updated_marks[h['id'].to_i] } })\n end\n updated_results = results.map do |result|\n [result.id, result.get_total_mark]\n end.to_h\n unless updated_results.empty?\n Result.upsert_all(\n results.pluck_to_hash.map { |h| { **h.symbolize_keys, total_mark: updated_results[h['id'].to_i] } }\n )\n end\n end",
"def show\n @exam_result = Xmt::Test::ExamResult.find(params[:id])\n @total_marks = @exam_result.question_scores.sum(:marks)\n end",
"def set_autotest_marks\n test_run = test_runs.first\n return if test_run.nil? || test_run.test_group_results.empty?\n\n result = get_latest_result\n complete_marks = true\n result.create_marks # creates marks for any new criteria that may have just been added\n result.marks.each do |mark|\n test_groups = mark.criterion.test_groups\n if test_groups.empty? # there's at least one manually-assigned mark\n complete_marks = false\n next\n end\n # don't update mark if there is an error\n next if test_run.test_group_results\n .exists?(error_type: TestGroupResult::ERROR_TYPE.slice(:no_results, :test_error).values)\n\n all_marks_earned = 0.0\n all_marks_total = 0.0\n test_groups.each do |test_group|\n res = test_run.test_group_results.find_by(test_group: test_group)\n all_marks_earned += res&.marks_earned || 0.0\n all_marks_total += res&.marks_total || 0.0\n end\n if all_marks_earned == 0 || all_marks_total == 0\n final_mark = 0.0\n elsif all_marks_earned >= all_marks_total\n final_mark = mark.criterion.max_mark\n elsif mark.criterion.is_a? CheckboxCriterion\n final_mark = 0\n else\n final_mark = (all_marks_earned / all_marks_total * mark.criterion.max_mark).round(2)\n if mark.criterion.instance_of? RubricCriterion\n # find the nearest mark associated to a level\n nearest_mark = mark.criterion.level_with_mark_closest_to(final_mark).mark\n final_mark = nearest_mark\n end\n end\n mark.mark = final_mark\n mark.save\n end\n\n # all marks are set by tests, can set the marking state to complete\n if complete_marks\n result.marking_state = Result::MARKING_STATES[:complete]\n result.save\n end\n end",
"def results(marks)\n # your code here\n avg = (marks.reduce(:+) / (marks.length).to_f).round(3)\n\n scores = {\n \"h\"=> 0,\n \"a\"=> 0,\n \"l\"=> 0\n }\n\n marks.each do |i|\n if i > 8\n scores[\"h\"] += 1\n elsif i == 7 || i == 8\n scores[\"a\"] += 1\n else \n scores[\"l\"] += 1\n end\n end\n if scores[\"a\"] == 0 && scores[\"l\"] == 0\n result = [avg, scores, 'They did well']\n else\n result = [avg, scores]\n end\n result\nend",
"def process_scores\n applicable_subjects = []\n subjects.group_by(&:batch_subject_group).each_pair do |batch_group, batch_subjects|\n (batch_subjects << batch_group).compact.each do |sub|\n applicable_subjects << sub\n end\n end\n applicable_subjects.sort_by{|as| as.priority.to_i}.each do|sub|\n mark = student.converted_assessment_marks.detect{|cam| cam.markable_id == sub.id and \n cam.markable_type == sub.class.name and cam.assessment_group_batch_id == agb.id}\n next unless mark\n build_score(sub, mark)\n process_skills(sub,mark) if consider_skills_of_subjects(sub)\n process_attributes(sub, mark, agb.subject_attribute_assessments) if agb.subject_attribute_assessments.present? and sub.is_a?(Subject)\n end\n\n add_to_exam_totals_hash(@total_score)\n end",
"def calculate_marks(academic_record)\n marks = Hash.new\n marks[:sub1] = academic_record.sub1_marks.to_i if academic_record.sub1_marks\n marks[:sub2] = academic_record.sub2_marks.to_i if academic_record.sub2_marks\n marks[:sub3] = academic_record.sub3_marks.to_i if academic_record.sub3_marks\n marks[:sub4] = academic_record.sub4_marks.to_i if academic_record.sub4_marks\n marks[:sub5] = academic_record.sub5_marks.to_i if academic_record.sub5_marks\n marks[:sub6] = academic_record.sub6_marks.to_i if academic_record.sub6_marks\n marks[:sub7] = academic_record.sub7_marks.to_i if academic_record.sub7_marks\n marks[:sub8] = academic_record.sub8_marks.to_i if academic_record.sub8_marks\n marks[:sub9] = academic_record.sub9_marks.to_i if academic_record.sub9_marks\n marks[:sub10] = academic_record.sub10_marks.to_i if academic_record.sub10_marks\n\n marks = marks.sort {|x,y| y[1] <=> x[1]}.to_h\n array_marks = marks.values\n best4_marks = array_marks[0].to_i + array_marks[1].to_i + array_marks[2].to_i + array_marks[3].to_i\n\n calculated_marks = 1000000*best4_marks + 10000*academic_record.hs_marks_percent + 100*academic_record.tenth_marks_percent + academic_record.hs_year_pass-2000\n if academic_record.hs_board.downcase.eql?priority_board\n calculated_marks += priority_marks\n end\n calculated_marks\n end",
"def marking_started?\n Result.joins(:marks, submission: :grouping)\n .where(groupings: { assessment_id: id },\n submissions: { submission_version_used: true })\n .where.not(marks: { mark: nil })\n .any?\n end",
"def results(marks)\n dict = {'h' => 0, 'a'=> 0, 'l'=> 0}\n\n list = [(marks.sum.to_f / marks.count).round(3)]\n dict['h'] = marks.select { |m| m == 9 || m == 10 }.count\n dict['a'] = marks.select { |m| m == 7 || m == 8 }.count\n dict['l'] = marks.select { |m| m.between?(1,6) }.count\n list << dict\n dict['a'] == 0 && dict['l'] == 0 ? list << \"They did well\" : list\nend",
"def exam_marks(subject, student)\n exam = exam_data(subject)\n exam_score = exam.scores(student)\n unless exam_score.nil?\n if exam.nil?\n result = 'NA'\n else\n exam_score.nil? ? result = '-' : result = type_result(exam, exam_score)\n end\n result\n end \n end",
"def exam_mar(subject, student, marks)\n exam = exam_data(subject)\n exam_score = exam.scores(student)\n return if exam.nil?\n marks.to_f + exam_score.marks.to_f\n end",
"def group_percent_from_result(result)\n result.groups.each do |name, files|\n covered = files.covered_percent.round(0)\n yield name, name, covered, covered\n end\n end",
"def group_by_marks(marks, n)\n marks.group_by {|name, mark| mark < n ? \"Failed\" : \"Passed\"}\nend",
"def exam_total(subject, total)\n exam = exam_data(subject)\n return if exam.nil?\n total.to_f + exam.maximum_marks.to_f\n end",
"def build_exam_set\n @scores = new_collection\n @total_max = 0\n @total_score = 0\n @overrided_subjects = assessment_group.override_assessment_marks.find_all_by_course_id(batch.course_id).collect(&:subject_code)\n process_scores\n \n Models::ExamSet.new(\n :obj_id => assessment_group.id,\n :name => assessment_group.display_name,\n :scores => @scores,\n :aggregates => process_aggregates,\n :term_name => term_name(assessment_group),\n :term_exam => assessment_group.is_final_term,\n :group_exam => is_assessment_group?,\n :planner_exam => (assessment_group.is_final_term and (assessment_group.parent_type == 'AssessmentPlan')),\n :attendance_report => process_attendance,\n :planner_name => assessment_plan.name,\n :scoring_type => AssessmentGroup::SCORE[assessment_group.scoring_type],\n :show_percentage => (assessment_group.is_final_term && assessment_group.show_percentage?),\n :maximum_mark => assessment_group.maximum_marks,\n :hide_marks => assessment_group.hide_marks,\n :consider_skills => assessment_group.consider_skills\n )\n end",
"def generate_marks\n exams.attending.each do |e|\n e.update_attribute :result, Course::VALID_MARKS.sample\n end\n end",
"def released_marks\n submissions.joins(:results).where(results: { released_to_students: true })\n end",
"def mark_total an_date\n the_count = marks.select{|m| m.mark_date == an_date}.count\n the_count == 0 ? \"\" : the_count \n end",
"def reset_marking_states(assessment_id)\n Result.joins(submission: :grouping)\n .where('submissions.submission_version_used': true, 'groupings.assessment_id': assessment_id)\n .each do |result|\n result.update(marking_state: Result::MARKING_STATES[:incomplete])\n end\n end",
"def calculate_total_percent(result, out_of)\n total = result.total_mark\n\n percent = BLANK_MARK\n\n # Check for NA mark or division by 0\n unless total.nil? || out_of == 0\n percent = (total / out_of) * 100\n end\n percent\n end",
"def calculate_total_percent(result, out_of)\n total = result.total_mark\n\n percent = BLANK_MARK\n\n # Check for NA mark or division by 0\n unless total.nil? || out_of == 0\n percent = (total / out_of) * 100\n end\n percent\n end",
"def marks; end"
] | [
"0.66736305",
"0.6563935",
"0.60964465",
"0.6092609",
"0.59290284",
"0.58807623",
"0.58621305",
"0.58563954",
"0.563786",
"0.56040406",
"0.5603901",
"0.5529249",
"0.5495633",
"0.5478703",
"0.5440172",
"0.5396839",
"0.53787684",
"0.5327259",
"0.53193814",
"0.52937317",
"0.52880245",
"0.5260294",
"0.52594686",
"0.52000576",
"0.51649016",
"0.51384807",
"0.5051833",
"0.5044848",
"0.5044848",
"0.5029118"
] | 0.68614364 | 0 |
Clones the Groupings from the assignment with id assessment_id into self. Destroys any previously existing Groupings associated with this Assignment | def clone_groupings_from(assessment_id)
warnings = []
original_assignment = Assignment.find(assessment_id)
self.transaction do
self.group_min = original_assignment.group_min
self.group_max = original_assignment.group_max
self.student_form_groups = original_assignment.student_form_groups
self.group_name_autogenerated = original_assignment.group_name_autogenerated
self.group_name_displayed = original_assignment.group_name_displayed
self.groupings.destroy_all
self.assignment_properties.save
self.save
self.reload
original_assignment.groupings.each do |g|
active_student_memberships = g.accepted_student_memberships.select { |m| !m.user.hidden }
if active_student_memberships.empty?
warnings << I18n.t('groups.clone_warning.no_active_students', group: g.group.group_name)
next
end
active_ta_memberships = g.ta_memberships.select { |m| !m.user.hidden }
grouping = Grouping.new
grouping.group_id = g.group_id
grouping.assessment_id = self.id
grouping.admin_approved = g.admin_approved
unless grouping.save
warnings << I18n.t('groups.clone_warning.other',
group: g.group.group_name, error: grouping.errors.messages)
next
end
all_memberships = active_student_memberships + active_ta_memberships
Repository.get_class.update_permissions_after(only_on_request: true) do
all_memberships.each do |m|
membership = Membership.new
membership.user_id = m.user_id
membership.type = m.type
membership.membership_status = m.membership_status
unless grouping.memberships << membership # this saves the membership as a side effect, i.e. can return false
grouping.memberships.delete(membership)
warnings << I18n.t('groups.clone_warning.no_member',
member: m.user.user_name, group: g.group.group_name, error: membership.errors.messages)
end
end
end
end
end
warnings
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_assignment_group(course_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :name,\n :position,\n :group_weight,\n :rules,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/assignment_groups\",\n :course_id => course_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n AssignmentGroup.new(response)\n end",
"def set_group_assignment\n @group_assignment = GroupAssignment.find(params[:id])\n end",
"def set_group_assignment\n @group_assignment = GroupAssignment.find(params[:id])\n end",
"def assigned_groups=(array_hash)\n # Find new groups (but no duplicates)\n self.added_groups = []\n array_hash.each do |h|\n unless groups.detect { |c| c.id.to_s == h[:id] } || self.added_groups.detect { |f| f.id.to_s == h[:id] }\n c = !h[:id].blank? ? Group.find(h[:id]) : Group.new({:page_object => self})\n c.attributes = h.reject { |k,v| k == :id } # input values, but don't try to overwrite the id\n self.added_groups << c unless c.nil?\n end\n end\n # Delete removed groups\n groups.each do |c|\n if h = array_hash.detect { |h| h[:id] == c.id.to_s }\n c.attributes = h.reject { |k,v| k == :id }\n else\n c.destroy_association = 1\n end\n end\n end",
"def groups\n\t\t\t@groups.clone\n\t\tend",
"def empty_group\n self.group_memberships.each {|m| m.destroy}\n end",
"def clone_group_id\n data[:clone_group_id]\n end",
"def new\n @assignments = Assignment.all\n @assignment = Assignment.new\n @assignment.build_submission_rule\n #@assignment.assignment_files.build\n unless request.post?\n render :new\n return\n end\n # Is the instructor forming groups?\n if params[:is_group_assignment] == 'true' && params[:assignment][:student_form_groups] == '0'\n params[:assignment][:invalid_override] = true\n else\n params[:assignment][:invalid_override] = false\n end\n\n @assignment = Assignment.new(params[:assignment])\n\n # A little hack to get around Rails' protection of the \"type\"\n # attribute\n @assignment.submission_rule.type = params[:assignment][:submission_rule_attributes][:type]\n\n\n @assignment.transaction do\n\n unless @assignment.save\n render :new\n return\n end\n if params[:assignment_files]\n params[:assignment_files].each do |assignment_file_name|\n unless assignment_file_name.empty?\n assignment_file = AssignmentFile.new(filename: assignment_file_name, assignment: @assignment)\n assignment_file.save\n end\n end\n end\n if params[:persist_groups_assignment]\n @assignment.clone_groupings_from(params[:persist_groups_assignment])\n end\n @assignment.save\n end\n redirect_to action: 'edit', id: @assignment.id\n end",
"def get_assignment_group(course_id,assignment_group_id,include,opts={})\n query_param_keys = [\n :include,\n :override_assignment_dates\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"assignment_group_id is required\" if assignment_group_id.nil?\n raise \"include is required\" if include.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :assignment_group_id => assignment_group_id,\n :include => include\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/assignment_groups/{assignment_group_id}\",\n :course_id => course_id,\n :assignment_group_id => assignment_group_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n AssignmentGroup.new(response)\n end",
"def reset_alignment_group(id)\n # create new alignment data\n $game_system.alignments[id] = BlizzABS::AlignmentData.new(id)\n # for all battlers of this group on the map\n $game_map.battlers_group(id).each {|b|\n # reset the alignment setup\n b.ai.setup_group(id)\n # delete moving commands\n b.force_move = []\n # reset the alignment setup\n b.reset_action}\n end",
"def grouping_sets\n raise Error, \"GROUP BY GROUPING SETS not supported on #{db.database_type}\" unless supports_grouping_sets?\n clone(:group_options=>:\"grouping sets\")\n end",
"def set_content_group\n @content_group = ContentGroup.find(params[:content_group_id])\n @content_group_clone = @content_group.dup\n end",
"def all_assessment_groups\n extract_assessment_groups(assessment_groups.all(:include => :assessment_group_batches))\n end",
"def copy(assignment_id)\n new_team = AssignmentTeam.create_team_and_node(assignment_id)\n new_team.name = name\n new_team.save\n copy_members(new_team)\n end",
"def reset_group_membership\n shell_out!(\"group\", \"mod\", \"-n\", \"#{new_resource.group_name}_bak\", new_resource.group_name)\n\n shell_out!(\"group\", \"add\", set_options(overwrite_gid: true))\n\n shell_out!(\"group\", \"del\", \"#{new_resource.group_name}_bak\")\n end",
"def clone(with_name, with_email, keep_owner = true)\n Ecircle.client.\n clone_group(:templateGroupId => @id, :newGroupEmail => with_email,\n :newGroupName => with_name, :keepOwner => keep_owner)\n end",
"def destroy\n Group.delete_groups_and_acls([id])\n end",
"def group\n @group ||= Group.new @instance, group_id\n end",
"def create\n @group_assignment = GroupAssignment.new(group_assignment_params)\n\n respond_to do |format|\n if @group_assignment.save\n format.html { redirect_to @group_assignment, notice: 'Group assignment was successfully created.' }\n format.json { render :show, status: :created, location: @group_assignment }\n else\n format.html { render :new }\n format.json { render json: @group_assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group_assignment = GroupAssignment.new(group_assignment_params)\n\n respond_to do |format|\n if @group_assignment.save\n format.html { redirect_to @group_assignment, notice: \"Group assignment was successfully created.\" }\n format.json { render :show, status: :created, location: @group_assignment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @group_assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign_all\n @batch = Batch.shod(params[:id])\n @exam_groups = @batch.exam_groups.all\n end",
"def create\n @group = Group.find(params[:group_id])\n @assignment = @group.assignments.build(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to [:teacher, @group], notice: 'Assignment was successfully created.' }\n format.json { render json: @assignment, status: :created, location: @assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @content_group_clone = ContentGroup.new(content_group_clone_params)\n respond_to do |format|\n if @content_group_clone.save\n @content_group.content_group_items.each do |item|\n clone_item = item.dup\n clone_item.content_id = @content_group_clone.id\n clone_item.save\n end\n flash[:success] = 'Content group was successfully cloned.'\n format.html { redirect_to admin_content_group_url(@content_group_clone) }\n format.json { render :show, status: :created, location: @content_group_clone }\n else\n format.html { render :new }\n format.json { render json: @content_group_clone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def v1_category_groupings_id_put(id, opts = {})\n v1_category_groupings_id_put_with_http_info(id, opts)\n return nil\n end",
"def instructor_create_grp(course, group)\n load_course_grps course\n\n # Create new group set\n logger.info \"Creating new group set called '#{group.group_set}'\"\n (button = button_element(xpath: '//button[@id=\"add-group-set\"]')).when_present Utils.short_wait\n js_click button\n wait_for_element_and_type(text_area_element(id: 'new_category_name'), group.group_set)\n checkbox_element(id: 'enable_self_signup').check\n button_element(id: 'newGroupSubmitButton').click\n link_element(xpath: \"//a[@title='#{group.group_set}']\").when_present Utils.short_wait\n\n # Create new group within the group set\n logger.info \"Creating new group called '#{group.title}'\"\n js_click button_element(class: 'add-group')\n wait_for_element_and_type(edit_group_name_input_element, group.title)\n button_element(id: 'groupEditSaveButton').click\n link_element(xpath: \"//a[contains(.,'#{group.title}')]\").when_present Utils.short_wait\n (link = link_element(xpath: \"//a[contains(.,'#{group.title}')]/../following-sibling::div[contains(@class,'group-actions')]//a\")).when_present Utils.short_wait\n logger.info \"Group ID is '#{group.site_id = link.attribute('id').split('-')[1]}'\"\n end",
"def clear\n 1.upto(@gsize) do |j|\n 1.upto(@gsize) do |i|\n stone = @ban[j][i]\n stone.group.clear if stone.group\n end\n end\n # Collect all the groups and put them into @garbage_groups\n @killed_groups.shift # removes @@sentinel\n @merged_groups.shift # removes @@sentinel\n @garbage_groups.concat(@killed_groups)\n @garbage_groups.concat(@merged_groups)\n @killed_groups.clear\n @killed_groups.push(@@sentinel)\n @merged_groups.clear\n @merged_groups.push(@@sentinel)\n @num_groups = 0\n @history.clear\n end",
"def destroy_assignment_group(course_id,assignment_group_id,move_assignment_to,opts={})\n query_param_keys = [\n :move_assignment_to\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"assignment_group_id is required\" if assignment_group_id.nil?\n raise \"move_assignment_to is required\" if move_assignment_to.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :assignment_group_id => assignment_group_id,\n :move_assignment_to => move_assignment_to\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/assignment_groups/{assignment_group_id}\",\n :course_id => course_id,\n :assignment_group_id => assignment_group_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n AssignmentGroup.new(response)\n end",
"def set_group\n @group = Enrollment.find(params[:id])\n end",
"def add_assessment(assessment)\n\n #TODO: Sanity check all attempts?\n\n #Merge the new assessment's attempts into the list of attempts.\n @attempts.push(*assessment.attempts)\n\n #And merge its associations.\n assessment.by_copy.each do |id, attempts|\n @by_copy[id] ||= []\n @by_copy[id].push(*attempts)\n end\n\n #TODO: Remove duplication.\n assessment.by_question.each do |id, attempts|\n @by_question[id] ||= []\n @by_question[id].push(*attempts)\n end\n\n end",
"def destroy\n @assignment.destroy\n end"
] | [
"0.5652616",
"0.54184777",
"0.54184777",
"0.5326901",
"0.5303908",
"0.5192986",
"0.5096948",
"0.49637893",
"0.49484473",
"0.49453995",
"0.49220583",
"0.48253575",
"0.48099196",
"0.48020983",
"0.47992045",
"0.4795924",
"0.4756138",
"0.47462055",
"0.47451362",
"0.47436652",
"0.47416463",
"0.47296816",
"0.47103512",
"0.47027892",
"0.47004578",
"0.4677366",
"0.46523046",
"0.462377",
"0.4608603",
"0.46012864"
] | 0.77257097 | 0 |
Get a list of repo checkout client commands to be used for scripting | def get_repo_checkout_commands(ssh_url: false)
self.groupings.includes(:group, :current_submission_used).map do |grouping|
submission = grouping.current_submission_used
next if submission&.revision_identifier.nil?
url = ssh_url ? grouping.group.repository_ssh_access_url : grouping.group.repository_external_access_url
Repository.get_class.get_checkout_command(url,
submission.revision_identifier,
grouping.group.group_name, repository_folder)
end.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands\n @commands ||= source.checkout(revision, configuration[:deploy_release])\n end",
"def client_commands\n @client_commands ||= []\n end",
"def available_commands(options)\n commands = %w[/start /checkin /checkout]\n response_to_user(options, commands.to_s)\n end",
"def cmds\n pry(Git::Multi::Commands)\nend",
"def clients\n command('.clients').split(\"\\n\")\n end",
"def all_commands\n [client_commands, server_commands].flatten\n end",
"def list_checkout_keys\n CircleCi.request(@conf, \"/project/#{username}/#{project}/checkout-key\").get\n end",
"def list_checkout_keys\n CircleCi.request(conf, \"#{base_path}/checkout-key\").get\n end",
"def commands\n unless defined? @commands\n @commands = []\n end\n return @commands\n end",
"def commands\n @commands ||= [].tap do |c|\n commands_list.each do |command|\n if command.instance_of? String\n c << standard_commands[command].new\n else\n ret_command = send(command)\n c << (ret_command.instance_of?(Hash) ? ret_command.values : ret_command)\n end\n end\n end.flatten\n end",
"def commands\n COMMANDS\n end",
"def command_list\n collect_do - subcommand_list\n end",
"def commands\n @commands ||= []\n end",
"def list\n Dir.chdir @root do\n cmd = \"git branch\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.split.map { |s|\n # Remove trailing/leading whitespace and astericks\n s.sub('*', '').strip\n }.reject { |s|\n # Drop elements created due to trailing newline\n s.size == 0\n }\n end\n end",
"def cli_checkout_code\n ssh.run(\"sudo git clone --recursive --quiet #{CLI_GIT} #{CLI_PATH}\")\n\n if config.wordpress.cli.nil?\n tags = ssh.capture(\"cd #{CLI_PATH} && git tag\").split(\"\\n\").map(&:strip).reverse\n tag = tags.first\n rev = ssh.capture(\"cd #{CLI_PATH} && git rev-parse #{tag}\").strip\n else\n tag = config.wordpress.cli\n\n if tag =~ /^[\\d\\.]+$/ # version def\n tag = \"v#{tag}\" unless tag =~ /v[\\d]+/\n end\n \n rev = tag\n end\n\n res = ssh.run(\"cd #{CLI_PATH} && sudo git checkout #{rev}\")\n\n if res.failure?\n error \"Unable to checkout revision #{rev}: #{res.output}\"\n end\n\n #rev, tag\n end",
"def cmds(pool)\n cmds = \"\"\n pool.keys.each do |cmd|\n unless cmds == \"\"\n cmds += ', ' + cmd.to_s \n else\n cmds += cmd.to_s \n end\n end\n cmds += \" and quit!\" if pool == @cli_cmds\n result = \" > Available commands: \" + cmds\n end",
"def commands\n ensure_cache_up_to_date\n commands = self.redis.keys(\"bluster:objects:command:*\")\n commands.map! { |r| r.split(\":\")[3] }\n commands.uniq\n end",
"def commands_list\n out = \"\"\n # If there are no commands set\n if COMMANDS.empty?\n out << \" ooops! commands are not here!\"\n else\n # Get the longest command's name, so we can output it nice 'n' clean\n # This '+ int' at the end is a distance (in spaces) from the longest\n # command to descriptions\n longest = COMMANDS.max_by(&:size).size + 8\n COMMANDS.each do |cmd|\n # Calc, calc.\n spaces = longest - cmd.size\n # Check if there is a 'desc' method\n desc = if eval \"Command::#{cmd}.new.respond_to? 'desc'\"\n # If there is - execute it\n eval \"Command::#{cmd}.new.desc\"\n else\n # If there is not\n \"---\"\n end\n out << \" \" << cmd.downcase.to_s << \" \" * spaces << desc\n # If this command is the last one, don't make a new line\n unless cmd == COMMANDS.last\n out << \"\\n\"\n end\n end\n end\n out\n end",
"def get_commands\n return nil\n end",
"def dirty_repos\n dirty = []\n service_names = Services::SERVICES.keys\n service_names.each do |service_name|\n service = Services::SERVICES[service_name]\n repo = service[:name]\n\n # Build command to checkout from master or the specified dev branch\n cmd = \"pushd #{user_workspace}/#{repo} 2>&1; \"\n branch = @prod ? 'master' : service[:dev_branch]\n cmd += \"git checkout #{branch} 2>&1; echo $?; popd > /dev/null 2>&1\"\n output = `#{cmd}`\n dirty << service_name unless output.split(' ').last.to_i.zero?\n end\n dirty\n end",
"def commands\n return [] unless options[\"commands\"]\n options[\"commands\"].map do |options|\n options['parents'] = parents + [name]\n Command.new options\n end\n end",
"def get_repo_status\n args = {:clone => CONFIG[\"local\"][\"clone\"]}\n st = `#{Templates.status(args)}`\n current_branch = st.split(\"\\n\")[0][3..-1].split(\"...\")[0]\n modified_files = st.split(\"\\n\")[1..-1].join(\"\\n\")\n [current_branch, modified_files]\n end",
"def command_names\n commands.map &:name\n end",
"def commands\n args.commands.map do |cmd|\n if cmd.respond_to?(:join)\n cmd.map { |c| c.index(' ') ? \"'#{c}'\" : c }.join(' ')\n else\n cmd.to_s\n end\n end\n end",
"def list_commands\n puts template(:all, {\n app: File.basename(@app),\n\n cmds: ::WeatherSage::CLI::Help::COMMANDS.values.map { |cmd|\n template(:cmd, cmd)\n }.join(\"\\n\"),\n\n envs: ::WeatherSage::CLI::Env::VARS.map { |row|\n template(:env, row)\n }.join(\"\\n\\n\"),\n })\n end",
"def commands\n\t\tall = {\n\t\t\t\"webcam_list\" => \"List webcams\",\n\t\t\t\"webcam_snap\" => \"Take a snapshot from the specified webcam\",\n\t\t\t\"record_mic\" => \"Record audio from the default microphone for X seconds\"\n\t\t}\n\t\treqs = {\n\t\t\t\"webcam_list\" => [ \"webcam_list\" ],\n\t\t\t\"webcam_snap\" => [ \"webcam_start\", \"webcam_get_frame\", \"webcam_stop\" ],\n\t\t\t\"record_mic\" => [ \"webcam_record_audio\" ],\n\t\t}\n\n\t\tall.delete_if do |cmd, desc|\n\t\t\tdel = false\n\t\t\treqs[cmd].each do |req|\n\t\t\t\tnext if client.commands.include? req\n\t\t\t\tdel = true\n\t\t\t\tbreak\n\t\t\tend\n\n\t\t\tdel\n\t\tend\n\n\t\tall\n\tend",
"def list\n @repos\n end",
"def supported_commands\n commands.keys\n end",
"def commands\n @commands.keys.sort\n end",
"def get_commands\n %w{ testchoosedir testchoosefile testnumberedmenu testdisplay_list testdisplay_text testdir }\n end"
] | [
"0.6906992",
"0.66299105",
"0.64811516",
"0.6417524",
"0.63387716",
"0.62840855",
"0.6183623",
"0.61274904",
"0.60522085",
"0.6041457",
"0.6018772",
"0.60027796",
"0.5930975",
"0.59106493",
"0.58975005",
"0.5853557",
"0.58476704",
"0.5822731",
"0.5821721",
"0.5796154",
"0.5795255",
"0.5768986",
"0.57317543",
"0.5723489",
"0.5716537",
"0.56972325",
"0.56944436",
"0.5677183",
"0.5670626",
"0.56617457"
] | 0.669381 | 1 |
Generate JSON summary of grades for this assignment for the current user. The user should be an admin or TA. | def summary_json(user)
return {} unless user.admin? || user.ta?
if user.admin?
groupings = self.groupings
graders = groupings.joins(:tas)
.pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')
.group_by { |x| x[:id] }
assigned_criteria = nil
else
groupings = self.groupings
.joins(:memberships)
.where('memberships.user_id': user.id)
graders = {}
if self.assign_graders_to_criteria
assigned_criteria = user.criterion_ta_associations
.where(assessment_id: self.id)
.pluck(:criterion_id)
else
assigned_criteria = nil
end
end
grouping_data = groupings.joins(:group)
.left_outer_joins(inviter: :section)
.pluck_to_hash(:id, 'groups.group_name', 'sections.name')
.group_by { |x| x[:id] }
members = groupings.joins(:accepted_students)
.pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')
.group_by { |x| x[:id] }
tag_data = groupings
.joins(:tags)
.pluck_to_hash(:id, 'tags.name')
.group_by { |h| h[:id] }
groupings_with_results = groupings.includes(current_result: :marks).includes(:submitted_remark, :extension)
result_ids = groupings_with_results.pluck('results.id').uniq.compact
extra_marks_hash = Result.get_total_extra_marks(result_ids, max_mark: max_mark)
hide_unassigned = user.ta? && hide_unassigned_criteria
criteria_shown = Set.new
max_mark = 0
selected_criteria = user.admin? ? self.criteria : self.ta_criteria
criteria_columns = selected_criteria.map do |crit|
unassigned = !assigned_criteria.nil? && !assigned_criteria.include?(crit.id)
next if hide_unassigned && unassigned
max_mark += crit.max_mark unless crit.bonus?
accessor = crit.id
criteria_shown << accessor
{
Header: crit.bonus? ? "#{crit.name} (#{Criterion.human_attribute_name(:bonus)})" : crit.name,
accessor: "criteria.#{accessor}",
className: 'number ' + (unassigned ? 'unassigned' : ''),
headerClassName: unassigned ? 'unassigned' : ''
}
end.compact
final_data = groupings_with_results.map do |g|
result = g.current_result
has_remark = g.current_submission_used&.submitted_remark.present?
if user.ta? && anonymize_groups
group_name = "#{Group.model_name.human} #{g.id}"
section = ''
group_members = []
else
group_name = grouping_data[g.id][0]['groups.group_name']
section = grouping_data[g.id][0]['sections.name']
group_members = members.fetch(g.id, [])
.map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] }
end
tag_info = tag_data.fetch(g.id, [])
.map { |a| a['tags.name'] }
criteria = result.nil? ? {} : result.mark_hash.select { |key, _| criteria_shown.include?(key) }
extra_mark = extra_marks_hash[result&.id]
{
group_name: group_name,
section: section,
members: group_members,
tags: tag_info,
graders: graders.fetch(g.id, [])
.map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] },
marking_state: marking_state(has_remark,
result&.marking_state,
result&.released_to_students,
g.collection_date),
final_grade: [criteria.values.compact.sum + (extra_mark || 0), 0].max,
criteria: criteria,
max_mark: max_mark,
result_id: result&.id,
submission_id: result&.submission_id,
total_extra_marks: extra_mark
}
end
{ data: final_data,
criteriaColumns: criteria_columns,
numAssigned: self.get_num_assigned(user.admin? ? nil : user.id),
numMarked: self.get_num_marked(user.admin? ? nil : user.id) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grades\r\n grade_nodes = BankNodestructure.grade_gather(params[:subject])\r\n render json: grade_nodes.to_json\r\n end",
"def show_grades(grades, format)\n puts 'Assessment\\'s grades'\n puts AssessmentSerializer::serialize_grades(grades, format)\n puts\n end",
"def grade_for(user)\n subject = assignment.grade_subject_for user\n grade = grades.find_by subject: subject\n return grade unless grade.nil?\n Grade.new metric: self, course: course, subject: subject\n end",
"def grades\n object.grades.collect do |grade|\n { :grade => grade, :student => grade.student }\n end\n end",
"def students_with_low_grades_json(time_now, time_threshold, grade_threshold)\n all_assignments = assignments(time_now, time_threshold, grade_threshold)\n by_student = all_assignments.group_by(&:student)\n json = by_student.map do |student, assignments|\n {\n student: student.as_json(:only => [:id, :email, :first_name, :last_name, :grade, :house]),\n assignments: assignments.map {|assignment| serialize_assignment(assignment) }\n }\n end\n json.as_json\n end",
"def grades\n @learn_grades\n end",
"def average_grade_overall\n return self.data[\"average_grade\"]\n end",
"def user_grade(user)\n\t\t\n\t\tgrade = Grade.where(:assignment_id => self.id, :user_id => user.id).first\n\t\t\n\t\tif grade\n\t\t\treturn grade.grade\n\t\tend\n\tend",
"def summary\n comment = @policy.describe(@grades)\n if (comment)\n comment = \" (#{comment})\"\n else\n comment = \"\"\n end\n mygrade = grade\n if mygrade\n mygrade = \"#{mygrade.round(1)}\"\n else\n mygrade = \"[No grades available]\"\n end\n if ((0 == @percent) || (100 == @percent) || (-100 == @percent)) \n dots = @@dots[@type.length + 1 .. -1]\n puts \"#{@type} #{dots}: #{mygrade}#{comment}\"\n else\n dots = @@dots[@type.length + 9 .. -1]\n percentText = \"#{@percent.round(1)}\"\n if (@percent < 10) \n percentText = \" #{percentText}\"\n end\n puts \"#{@type} #{dots} (#{percentText}%): #{mygrade}#{comment}\"\n end\n end",
"def show\n\t\t@grade = Grade.find_by_assignment_id_and_user_id(@assignment.id, @current_user.id)\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @assignment }\n\t\tend\n\tend",
"def index\n if params[:assignment_id] && current_user.teacher?\n @assignment = Assignment.find(params[:assignment_id])\n @grades = @assignment.grades\n elsif params[:id] && current_user.teacher?\n @user = User.find(params[:id])\n elsif current_user.teacher?\n @assignments = current_user.assignments\n else\n @user = current_user\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @assignment.to_json(:include => :grades ) } \n end\n end",
"def grades(options = {})\n should_include_inactive = options.fetch(:include_inactive_students, false)\n relevant_students = should_include_inactive ? self.students : self.students.active\n GradeLevels.sort relevant_students.flat_map(&:grade).compact.uniq\n end",
"def get_grade_params_for_javascript\n weight_hash = []\n self.course.assignments.each do |assignment|\n score = assignment.maximum_score\n if self.grade_type == \"weights\"\n score *= 0.01\n end\n weight_hash << score\n end\n \"'#{GradingRule.get_grade_type self.course_id}', #{mapping_rule.to_json}, #{weight_hash.to_json}\"\n end",
"def grade\n @grade\n end",
"def show\n render json: @grade\n end",
"def show\n @grade = Grade.find(params[:id])\n respond_to do |format|\n format.html \n format.json { render :json => @grade.as_json(:include => :assignment) }\n end\n end",
"def get_grade(user)\n chain_grade = 1\n for link in get_chain_as_links()\n chain_grade *= link.get_grade(user)\n end\n\n chain_grade\n end",
"def user_grade(user)\n\t\ttotalGrade = 0\n\t\ttotalWorth = 0\n\t\n\t\tgrades = Grade.joins(:assignment).where('assignments.assignment_type_id' => self.id, :user_id => user)\n\n\t\tif drop_lowest\n\t\t\t# If we are dropping the lowest score, we have to calculate the grades individually\n\t\t\tscores = []\n\t\n\t\t\t# Calculate each score\n\t\t\tgrades.each do |g|\n\t\t\t\tif g.assignment.worth != 0\n\t\t\t\t\tscores.push(g.grade / g.assignment.worth)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t# Sort and remove lowest score\n\t\t\tscores = scores.sort\n\t\t\tscores.delete_at(0)\n\t\t\n\t\t\t# Calculate grade using remainder\n\t\t\tif scores.length != 0\n\t\t\t\treturn scores.sum / scores.length * 100\n\t\t\tend\n\n\t\telse\n\t\t\t# Calculate the grades in bulk\n\t\t\tgrade = grades.sum(:grade).to_f\n\t\t\tworth = grades.sum(:worth).to_f\n\n\t\t\tif worth != 0\n\t\t\t\treturn (grade / worth) * 100\n\t\t\tend\n\n\t\tend\n\tend",
"def description_hint_grades\n grades = Evaluation::Grade.all\n \"School grades (#{grades.join(', ')}) are assigned and \" \\\n 'displayed with each object.'\n end",
"def new\n\t\t@grade = Grade.new\n\t\t\n\t\trespond_to do |format|\n\t\t\t# Prevent the user from creating grades for disabled assignments\n\t\t\tif @assignment.isDisabled(@current_user)\n\t\t\t\tformat.html {redirect_to root_path, notice: \"Cannot create a grade for a disabled assignment.\"}\n\t\t\t\t\n\t\t\t# Users must be in the course to add a grade\n\t\t\telsif @current_user.courses.include?(@course)\n\t\t\t\tformat.html # new.html.erb\n\t\t\t\tformat.json { render json: @grade }\n\t\t\telse\n\t\t\t\tformat.html {redirect_to root_path, notice: \"Access Denied\"}\n\t\t\tend\n\t\tend\n\tend",
"def print_grades\n @learn_grades.each do |grade|\n puts grade.which_course?.foreground(:yellow) + \": \".foreground(:yellow)\n puts grade.summary\n end\n end",
"def index\n @default_fields = DEFAULT_FIELDS\n if current_user.student?\n @grade_entry_forms = GradeEntryForm.where(is_hidden: false).order(:id)\n @assignments = Assignment.where(is_hidden: false).order(:id)\n @marking_schemes = MarkingScheme.none\n #get the section of current user\n @section = current_user.section\n # get results for assignments for the current user\n @a_id_results = Hash.new()\n @assignments.each do |a|\n if current_user.has_accepted_grouping_for?(a)\n grouping = current_user.accepted_grouping_for(a)\n if grouping.has_submission?\n submission = grouping.current_submission_used\n if submission.has_remark? && submission.remark_result.released_to_students\n @a_id_results[a.id] = submission.remark_result\n elsif submission.has_result? && submission.get_original_result.released_to_students\n @a_id_results[a.id] = submission.get_original_result\n end\n end\n end\n end\n\n # Get the grades for grade entry forms for the current user\n @g_id_entries = Hash.new()\n @grade_entry_forms.each do |g|\n grade_entry_student = g.grade_entry_students.find_by_user_id(\n current_user.id )\n if !grade_entry_student.nil? &&\n grade_entry_student.released_to_student\n @g_id_entries[g.id] = grade_entry_student\n end\n end\n\n render :student_assignment_list, layout: 'assignment_content'\n elsif current_user.ta?\n @grade_entry_forms = GradeEntryForm.order(:id)\n @assignments = Assignment.includes(:submission_rule).order(:id)\n render :grader_index, layout: 'assignment_content'\n @marking_schemes = MarkingScheme.all\n else\n @grade_entry_forms = GradeEntryForm.order(:id)\n @assignments = Assignment.includes(:submission_rule).order(:id)\n render :index, layout: 'assignment_content'\n @marking_schemes = MarkingScheme.all\n end\n end",
"def show\n @course = Course.includes(:teachers, :students).find(params[:id])\n current_user_enrollment = @course.enrollments.where(:user_id => current_user.id).first\n @grade = Grade.new(current_user_enrollment.grade) if current_user_enrollment\n @average_grade = Grade.new(@course.average_gradepoint) if can? :manage, @course\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n @grades = Grade.all\n render json: {data: @grades, status: \"SUCCESS\"}, :status => 200\n end",
"def grades\n @grade_entry_form = record\n end",
"def index\n @assignments = Assignment.all(order: :id)\n if current_user.student?\n # get results for assignments for the current user\n @a_id_results = Hash.new()\n @assignments.each do |a|\n if current_user.has_accepted_grouping_for?(a)\n grouping = current_user.accepted_grouping_for(a)\n if grouping.has_submission?\n submission = grouping.get_submission_used\n if submission.has_result? && submission.get_latest_result.released_to_students\n @a_id_results[a.id] = submission.get_latest_result\n end\n end\n end\n end\n render :student_assignment_list\n elsif current_user.ta?\n render :grader_index\n else\n render :index\n end\n end",
"def get_grades(user_id, course_id, use_source_domain = nil)\r\n relative_url = Path::USERS_COURSES_GRADEBOOK_USERGRADEBOOKITEMS \r\n\t if !use_source_domain.nil?\r\n\t\trelative_url = get_grades_url(use_source_domain)\r\n\t end\r\n\t relative_url = relative_url % [user_id, course_id]\t \r\n\t get(relative_url)\r\n end",
"def available_grade_levels_json\n params.require(:workspace_id)\n\n # schools\n school_ids = queries.supported_schools.map(&:id).select do |school_id|\n queries.is_authorized_for_school_id?(school_id)\n end\n schools_json = School.find(school_ids).as_json(only: [:id, :name])\n\n # grade levels (include if any of their schools would allow it)\n grade_levels_next_year = queries.supported_grade_levels_next_year.select do |grade_level_next_year|\n grade_level_now = GradeLevels.new.previous(grade_level_next_year)\n school_ids.any? {|school_id| queries.is_authorized_for_grade_level_now?(school_id, grade_level_now) }\n end\n\n render json: {\n schools: schools_json,\n grade_levels_next_year: grade_levels_next_year\n }\n end",
"def report_card\n puts self.get_gpa\n grades = self.registrations.includes(:course)\n # puts \"Your grades for each class are as follows:\\n\"\n tp grades, {\"Subject\" => {:display_method => lambda{|x| x.course.subject}}}, {\"Grades\" => {:display_method => lambda{|x| numeric(x.grade)}}}\n end",
"def create\n\t\t@grade = Grade.new(params[:grade])\n\t\t@grade.assignment_id = params[:assignment_id]\n\t\t@grade.user_id = @current_user.id\n\t\t\n\t\tLogsController.createGrade(@current_user, @grade)\n\n\t\trespond_to do |format|\n\t\t\t# For fast grades (:commit == \"Save\") redirect to the course page\n\t\t\tif params[:commit] == \"Save\" && @grade.save\n\t\t\t\tformat.html { redirect_to course_path(@assignment.course), notice: 'Grade was successfully created.' }\n\t\t\telsif @grade.save\n\t\t\t\tformat.html { redirect_to assignment_path(@assignment), notice: 'Grade was successfully created.' }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\tend\n\t\tend\n\tend"
] | [
"0.65349764",
"0.6458462",
"0.63696796",
"0.63133717",
"0.62026393",
"0.61628884",
"0.612055",
"0.61048",
"0.60763615",
"0.6075817",
"0.60441387",
"0.6010963",
"0.5997677",
"0.593085",
"0.5891875",
"0.5885968",
"0.587215",
"0.5867793",
"0.58181137",
"0.57529193",
"0.57428896",
"0.5720642",
"0.5711298",
"0.5707751",
"0.5613072",
"0.56085795",
"0.56009156",
"0.55793107",
"0.557324",
"0.55642223"
] | 0.6518727 | 1 |
Generate CSV summary of grades for this assignment for the current user. The user should be an admin or TA. | def summary_csv(user)
return '' unless user.admin?
if user.admin?
groupings = self.groupings
.includes(:group,
:accepted_students,
current_result: :marks)
else
groupings = self.groupings
.includes(:group,
:accepted_students,
current_result: :marks)
.joins(:memberships)
.where('memberships.user_id': user.id)
end
headers = [['User name', 'Group', 'Final grade'], ['', 'Out of', self.max_mark]]
self.ta_criteria.each do |crit|
headers[0] << (crit.bonus? ? "#{crit.name} (#{Criterion.human_attribute_name(:bonus)})" : crit.name)
headers[1] << crit.max_mark
end
headers[0] << 'Bonus/Deductions'
headers[1] << ''
result_ids = groupings.pluck('results.id').uniq.compact
extra_marks_hash = Result.get_total_extra_marks(result_ids, max_mark: max_mark)
CSV.generate do |csv|
csv << headers[0]
csv << headers[1]
groupings.each do |g|
result = g.current_result
marks = result.nil? ? {} : result.mark_hash
g.accepted_students.each do |s|
row = [s.user_name, g.group.group_name]
if result.nil?
row += Array.new(2 + self.ta_criteria.count, nil)
else
row << result.total_mark
row += self.ta_criteria.map { |crit| marks[crit.id] }
row << extra_marks_hash[result&.id]
end
csv << row
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_all_report\n @user = User.find(params[:id])\n report = StringIO.new\n CSV::Writer.generate(report, ',') do |csv|\n #Get Words\n @words = @user.word_answers.find(:all, :order => \"question_id ASC\")\n csv << %w(question answer date)\n @words.each do |answer|\n csv << [answer.word.value, answer.value, answer.created_at]\n end\n #Get Situations\n @situation_answers = @user.completion_answers.find(:all, :order => \"question_id ASC\")\n @situation_answers.each do |answer|\n csv << [answer.completion.value, answer.value, answer.created_at]\n end\n #Get Scenarios\n @scenario_answers = @user.scenario_answers.find(:all, :order => \"question_id ASC\")\n @scenario_answers.each do |answer|\n csv << [answer.scenario.value, answer.value, answer.created_at]\n end\n \n #Get posts\n @posts = @user.posts.find(:all, :order => \"created_at DESC\")\n @posts.each do |post|\n csv << [post.topic.title, post.body, post.created_at]\n end\n end\n export_as_csv(report,@user.whole_name+\"-all\")\n end",
"def students_for_accreditation_committee(dean_user)\n indices = Index.find_for(dean_user)\n @@mylog.info(\"There is %i students\" % indices.size)\n File.open(\"students.csv\", 'wb') do |outfile|\n CSV::Writer.generate(outfile, ';') do |csv|\n indices.each do |index|\n row = []\n row << index.student.display_name\n row << index.status\n if index.status == 'absolvoval'\n row << index.disert_theme.defense_passed_on\n else\n row << ''\n end\n row << index.year\n row << index.study_name\n row << index.department.short_name\n row << index.specialization.code\n row << index.enrolled_on\n row << index.final_exam_passed_on || index.study_plan.try(:status) || \"nemá\"\n row << index.disert_theme.try(:title)\n row << index.tutor.try(:display_name)\n csv << row\n end\n end\n end\n\n end",
"def grader_mapping\n grade_entry_form = GradeEntryForm.find(params[:grade_entry_form_id])\n\n students = Student.left_outer_joins(:user, grade_entry_students: [tas: :user])\n .where('grade_entry_students.assessment_id': grade_entry_form.id)\n .order('users.user_name', 'users_roles.user_name')\n .pluck('users.user_name', 'users_roles.user_name')\n .group_by { |x| x[0] }\n .to_a\n\n file_out = MarkusCsv.generate(students) do |student, graders|\n [student] + graders.pluck(1)\n end\n\n send_data file_out,\n type: 'text/csv',\n disposition: 'attachment',\n filename: \"#{grade_entry_form.short_identifier}_grader_mapping.csv\"\n end",
"def create_finals_file\n file = File.open('final.csv', 'w')\n $students.each do |student|\n name = student[:name]\n avg = get_avggrades(student)\n file.puts \"#{name} #{avg}\"\n end\n file.close\nend",
"def export_grade(user, course)\n @user = user\n @course = course\n I18n.locale = @user.locale\n mail(to: @user.email)\n end",
"def summary\n comment = @policy.describe(@grades)\n if (comment)\n comment = \" (#{comment})\"\n else\n comment = \"\"\n end\n mygrade = grade\n if mygrade\n mygrade = \"#{mygrade.round(1)}\"\n else\n mygrade = \"[No grades available]\"\n end\n if ((0 == @percent) || (100 == @percent) || (-100 == @percent)) \n dots = @@dots[@type.length + 1 .. -1]\n puts \"#{@type} #{dots}: #{mygrade}#{comment}\"\n else\n dots = @@dots[@type.length + 9 .. -1]\n percentText = \"#{@percent.round(1)}\"\n if (@percent < 10) \n percentText = \" #{percentText}\"\n end\n puts \"#{@type} #{dots} (#{percentText}%): #{mygrade}#{comment}\"\n end\n end",
"def print_grades\n @learn_grades.each do |grade|\n puts grade.which_course?.foreground(:yellow) + \": \".foreground(:yellow)\n puts grade.summary\n end\n end",
"def export_students_to_csv\n CSV.generate(headers: true) do |csv|\n csv << %w[perm email first_name last_name github_username]\n\n roster_students.each do |user|\n csv << [\n user.perm,\n user.email,\n user.first_name,\n user.last_name,\n user.username\n ]\n end\n end\n end",
"def grade_for(user)\n subject = assignment.grade_subject_for user\n grade = grades.find_by subject: subject\n return grade unless grade.nil?\n Grade.new metric: self, course: course, subject: subject\n end",
"def students_for_dean(dean_user)\n indices = Index.find_for(dean_user)\n @@mylog.info(\"There is %i students\" % indices.size)\n File.open(\"students.csv\", 'wb') do |outfile|\n CSV::Writer.generate(outfile, ';') do |csv|\n csv << ['uic', 'name', 'enrolled', 'finished/absolved', 'form', 'status',\n 'department', 'specialization', 'program', 'faculty', 'tutor',\n 'title', 'title_en', 'nominal_length']\n indices.each do |index|\n row = []\n @@mylog.info(\"Adding %s\" % index.student.display_name)\n row << index.student.uic\n row << index.student.display_name\n row << index.enrolled_on.strftime('%d. %m. %Y')\n if index.finished?\n row << index.finished_on.strftime('%d. %m. %Y')\n elsif index.absolved?\n row << index.disert_theme.defense_passed_on.strftime('%d. %m. %Y')\n else\n row << ''\n end\n row << index.study.name\n row << index.status\n row << index.department.name\n row << index.specialization.name\n row << index.specialization.program.name\n row << index.faculty.name\n row << index.tutor.try(:display_name)\n row << index.disert_theme.try(:title)\n row << index.disert_theme.try(:title_en)\n row << index.nominal_length\n csv << row\n end\n end\n end\n end",
"def student_usages_per_day\n results = []\n AnalyticsUsage.where(\"user_id is NOT NULL\").each do |usage|\n results << [usage.user.try(:name),(usage.user.edutorid rescue \"\"),(usage.user.center.try(:name) if usage.user.center rescue \"\"),(usage.user.academic_class.try(:name) if usage.user.academic_class rescue \"\"),(usage.user.section.try(:name) rescue \"\"),(usage.today_usage/60 rescue 0),Time.at(usage.usage_date).to_datetime.strftime(\"%d-%b-%Y\")]\n end\n filename = \"Total_usage\"\n csv_data = FasterCSV.generate do |csv|\n csv << \"Name,Edutorid,Center,Class,Section,total-usage-in-minutes,date\".split(\",\")\n results.each do |c|\n csv << c\n end\n end\n #path = Rails.root.to_s+\"/tmp/cache\"\n #file = File.new(path+\"/\"+\"#{Time.now.to_i}\"+\"_usage.csv\", \"w+\")\n #File.open(file,'w') do |f|\n # f.write(csv_data)\n #end\n\n #Usermailer.send_csv(csv)\n #attachment =\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end",
"def download_grader_students_mapping\n grade_entry_form = GradeEntryForm.find(params[:grade_entry_form_id])\n students = Student.all\n\n file_out = CsvHelper::Csv.generate do |csv|\n students.each do |student|\n # csv format is student_name, ta1_name, ta2_name, ... etc\n student_array = [student.user_name]\n grade_entry_student = grade_entry_form.grade_entry_students.find_by_user_id(student.id)\n unless grade_entry_student.nil?\n grade_entry_student.tas.each { |ta| student_array.push(ta.user_name) }\n end\n\n csv << student_array\n end\n end\n\n send_data(file_out, :type => 'text/csv', :disposition => 'inline')\n end",
"def download\n grade_entry_form = record\n send_data grade_entry_form.export_as_csv(current_role),\n disposition: 'attachment',\n type: 'text/csv',\n filename: \"#{grade_entry_form.short_identifier}_grades_report.csv\"\n end",
"def download_csv\n case current_user.role.name\n when 'Edutor Admin'\n usages = Usage\n when 'Institute Admin'\n usages = current_user.usages\n when 'Center Representative'\n usages = current_user.usages\n when 'Teacher'\n class_contents = current_user.class_contents\n section_students = current_user.sections.map{|section| section.students.select('id')}.flatten\n student_group_students = current_user.sections.map{|section| section.student_groups.select('id')}.flatten\n total_students = (section_students + student_group_students).uniq\n usages_ids = class_contents.map(&:uri).map{|uri|\n Usage.where('uri like ?',\"%#{uri}%\").where(:user_id=>total_students).map(&:id)\n }\n usages = Usage.where(:id=>usages_ids)\n end\n filename =\"usages_#{Date.today.strftime('%d%b%y')}\"\n csv_data = FasterCSV.generate do |csv|\n csv << Usage.csv_header\n usages.each do |c|\n csv << c.to_csv\n end\n end\n send_data csv_data, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => \"attachment; filename=#{filename}.csv\"\n end",
"def show\n grade_entry_form = record\n send_data grade_entry_form.export_as_csv(current_role),\n type: 'text/csv',\n filename: \"#{grade_entry_form.short_identifier}_grades_report.csv\",\n disposition: 'inline'\n rescue ActiveRecord::RecordNotFound => e\n # could not find grade entry form\n render 'shared/http_status', locals: { code: '404', message: e }, status: :not_found\n end",
"def get_csv\n CSV.generate do |csv|\n csv << ['Name','Student ID','User ID','Role','Email Address','Sections']\n get_feed[:students].each do |student|\n name = student[:last_name] + ', ' + student[:first_name]\n user_id = student[:login_id]\n student_id = student[:student_id]\n email_address = student[:email]\n role = ENROLL_STATUS_TO_CSV_ROLE[student[:enroll_status]]\n sections = sections_to_name_string(student[:sections])\n csv << [name, student_id, user_id, role, email_address, sections]\n end\n end\n end",
"def grades\n @learn_grades\n end",
"def report_card\n puts self.get_gpa\n grades = self.registrations.includes(:course)\n # puts \"Your grades for each class are as follows:\\n\"\n tp grades, {\"Subject\" => {:display_method => lambda{|x| x.course.subject}}}, {\"Grades\" => {:display_method => lambda{|x| numeric(x.grade)}}}\n end",
"def user_grade(user)\n\t\t\n\t\tgrade = Grade.where(:assignment_id => self.id, :user_id => user.id).first\n\t\t\n\t\tif grade\n\t\t\treturn grade.grade\n\t\tend\n\tend",
"def write_csv\n\t\tCSV.open(\"csv_exports/edits_per_user_#{@dataset}.csv\", 'w') do |csv|\n\t\t\tcsv << ['user', 'edits']\n\t\t\t@users.each do |user, edits|\n\t\t\t\tcsv << [user,edits]\n\t\t\tend\n\t\tend\n\tend",
"def grades(options = {})\n should_include_inactive = options.fetch(:include_inactive_students, false)\n relevant_students = should_include_inactive ? self.students : self.students.active\n GradeLevels.sort relevant_students.flat_map(&:grade).compact.uniq\n end",
"def save_students\n file = CSV.open(@user_file, \"w\") do |csv|\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data.join(\",\")\n csv << csv_line\n end\n end\nend",
"def refresh_grade_distribution\n self.grade_distribution_percentage =\n self.assignment.grade_distribution_array.to_csv\n self.save\n end",
"def user_grade(user)\n\t\ttotalGrade = 0\n\t\ttotalWorth = 0\n\t\n\t\tgrades = Grade.joins(:assignment).where('assignments.assignment_type_id' => self.id, :user_id => user)\n\n\t\tif drop_lowest\n\t\t\t# If we are dropping the lowest score, we have to calculate the grades individually\n\t\t\tscores = []\n\t\n\t\t\t# Calculate each score\n\t\t\tgrades.each do |g|\n\t\t\t\tif g.assignment.worth != 0\n\t\t\t\t\tscores.push(g.grade / g.assignment.worth)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t# Sort and remove lowest score\n\t\t\tscores = scores.sort\n\t\t\tscores.delete_at(0)\n\t\t\n\t\t\t# Calculate grade using remainder\n\t\t\tif scores.length != 0\n\t\t\t\treturn scores.sum / scores.length * 100\n\t\t\tend\n\n\t\telse\n\t\t\t# Calculate the grades in bulk\n\t\t\tgrade = grades.sum(:grade).to_f\n\t\t\tworth = grades.sum(:worth).to_f\n\n\t\t\tif worth != 0\n\t\t\t\treturn (grade / worth) * 100\n\t\t\tend\n\n\t\tend\n\tend",
"def description_hint_grades\n grades = Evaluation::Grade.all\n \"School grades (#{grades.join(', ')}) are assigned and \" \\\n 'displayed with each object.'\n end",
"def show_grades(grades, format)\n puts 'Assessment\\'s grades'\n puts AssessmentSerializer::serialize_grades(grades, format)\n puts\n end",
"def admin_report\n @current_teacher = current_teacher\n @school = School.find(@current_teacher.school_id)\n @students = Student.where(school_id: current_teacher.school_id).order('full_name ASC')\n @teachers = Teacher.where(school_id: current_teacher.school_id).order('full_name ASC')\n @squares = Square.where(school_id: current_teacher.school_id).order('full_name ASC')\n end",
"def export_summary(user_data)\n header = []\n row = []\n\n # chose to remove the 'total' key in the hash, figured end user will want to use own calculation on the CSV file when downloaded\n user_data[\"points\"].delete(\"total\")\n\n # put the hash keys into an array to form the header line\n user_data[\"points\"].each_key do |key|\n header << key\n end\n\n # put the values in an array to form the first line\n user_data[\"points\"].each_value do |value|\n row << value\n end\n\n # create the CSV file\n CSV.open(\"summary_#{user_data[\"name\"].downcase.split.join(\"_\")}.csv\", \"wb\") do |csv|\n\n # add the arrays into the file to create the header and first row\n csv << header\n csv << row\n end\n\n # unless something went wrong, show that the data exported correctly\n if File.exist?(\"summary_#{user_data[\"name\"].downcase.split.join(\"_\")}.csv\")\n puts \"\\nFile successfully save!\"\n else\n puts \"\\nThe files did not save, try again.\"\n end\nend",
"def download\n grade_entry_form = GradeEntryForm.find(params[:id])\n send_data grade_entry_form.export_as_csv,\n disposition: 'attachment',\n type: 'text/csv',\n filename: \"#{grade_entry_form.short_identifier}_grades_report.csv\"\n end",
"def save_students\n File.open(user_filename, \"w\") do |file|\n @students.each do |student|\n student_data = [student[:name], student[:cohort], student[:hobbies]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n end\nend"
] | [
"0.64762557",
"0.6321437",
"0.61371285",
"0.6104188",
"0.60931075",
"0.6081165",
"0.6062825",
"0.600055",
"0.5902005",
"0.5894944",
"0.58642745",
"0.5826113",
"0.5805274",
"0.5775729",
"0.57514143",
"0.5672579",
"0.56558406",
"0.56496567",
"0.5637919",
"0.56340665",
"0.5607692",
"0.55987054",
"0.55960923",
"0.55482656",
"0.55335873",
"0.5493176",
"0.54899025",
"0.54758793",
"0.54708403",
"0.54437715"
] | 0.7496393 | 0 |
Returns an array of [mark, max_mark]. | def get_marks_list(submission)
criteria.map do |criterion|
mark = submission.get_latest_result.marks.find_by(criterion: criterion)
[(mark.nil? || mark.mark.nil?) ? '' : mark.mark,
criterion.max_mark]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_markers\n @max_markers ||= arg ? arg.to_i : MAX_MARKERS\n end",
"def marks\n marks = []\n if input =~ / *mark:(\\d\\S*)/i\n marks = $1.gsub /(\\d+)-(\\d+)/ do\n ($1.to_i..$2.to_i).to_a.join(',')\n end\n marks = marks.split(',').collect {|s| s.to_i}.sort\n end\n marks\n end",
"def max_value_and_index\n [max, max_index]\n end",
"def max_mark(user_visibility = :ta_visible)\n criteria.where(user_visibility => true, bonus: false).sum(:max_mark).round(2)\n end",
"def valid_mark\n unless mark.nil?\n if mark > markable.max_mark\n errors.add(:mark, I18n.t('mark.error.validate_criteria'))\n end\n end\n end",
"def marks; end",
"def max_min\n tab_x = Array.new\n tab_y = Array.new \n @tab_point.each do |point|\n tab_x.push(point.x)\n tab_y.push(point.y)\n end\n\n [tab_x.min, tab_y.min, tab_x.max, tab_y.max]\n end",
"def maxpos\n v, opts = max x: true, y: true\n x = opts[\"x\"]\n y = opts[\"y\"]\n [v, x, y]\n end",
"def min_max(nums)\n\treturn [nums.min, nums.max,]\nend",
"def find_minmax\n loc1, loc2 = self.find_minmax_locator\n [loc1 && loc1.value, loc2 && loc2.value]\n end",
"def max\n maxes = []\n\n maxes << @in.max unless @in.empty?\n maxes << @out.max unless @out.empty?\n\n maxes.max\n end",
"def max_ion_coordinates()\n\t\t(max_bion_i, max_bion_j, max_bion_value) = max_value_in_ions_array(assigned_bions_intensities_array)\n\t\t(max_yion_i, max_yion_j, max_yion_value) = max_value_in_ions_array(assigned_yions_intensities_array)\n\n\t\tif (max_bion_value > max_yion_value)\n\t\t\treturn \"bion\", max_bion_i, max_bion_j\n\t\telse\n\t\t\treturn \"yion\", max_yion_i, max_yion_j\n\t\tend\n\tend",
"def max_marks_should_not_be_less_than_any_individual_marks\n #This will get hsh[subject_id] = 'corresponding_mark_column' in the marks table\n hsh = mark_columns_with_subject_ids(self.section) \n marks = Mark.for_section(self.section_id).for_exam(self.exam_id).all\n col_name = hsh[self.subject_id]\n marks.each do |mark|\n if mark.send(col_name) && max_marks && (mark.send(col_name) > max_marks)\n errors.add(:max_marks, \"should not be less than individual marks\")\n end\n end\n end",
"def getMinMax(array,pos)\n minimum = 1000000\n maximum = -1000000\n for player in array\n if player[4] == pos\n minimum = [player[player.length-1],minimum].min\n maximum = [player[player.length-1],maximum].max\n end\n end\n return [minimum,maximum]\nend",
"def calculate_max_seqs\n file_summaries.map(&:seqs).max\n end",
"def max\n @data[0]\n end",
"def calculate_auto_bounds\n return [ 0, 0, 0, 0 ] if @markers.length == 0\n \n max_lat, max_lng = @markers.first.point\n min_lat, min_lng = @markers.first.point\n \n @markers.slice(1, @markers.length).each do |marker|\n if marker.point[0] < min_lat then min_lat = marker.point[0] end\n if marker.point[0] > max_lat then max_lat = marker.point[0] end\n if marker.point[1] < min_lng then min_lng = marker.point[1] end\n if marker.point[1] > max_lng then max_lng = marker.point[1] end\n end\n \n return [ min_lat, min_lng, max_lat, max_lng ]\n end",
"def get_max\n @max\n end",
"def max_value_in_ions_array(ions_array)\n\t\tmax_value = nil\n\t\tmax_i = 0\n\t\tmax_j = 0\n\t\tions_array.each_with_index do |row, i|\n\t\t\trow.each_with_index do |value, j|\n\t\t\t\tif j > 0 && j < 3 && (max_value.nil? || value.to_f > max_value.to_f)\n\t\t\t\t\tmax_value = value\n\t\t\t\t\tmax_i = i\n\t\t\t\t\tmax_j = j\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn max_i, max_j, max_value\n\tend",
"def max; end",
"def max; end",
"def get_max()\n end",
"def get_max()\n return @maxs_stack.peek()\n end",
"def maxima\n return Features.maxima(@data)\n end",
"def mark_sort array\n array_max = array.max\n array_min = array.min\n markings = [0] * (array_max - array_min + 1)\n array.each do |a|\n markings[a - array_min] += 1\n end\n\n res = []\n markings.length.times do |i|\n markings[i].times do\n res << i + array_min;\n end\n end\n\n res\nend",
"def max_y\n vertical_code_list&.codes&.count.to_i + roster_rows.to_i\n end",
"def gmax()\n resp = cmd(\"GMAX\").chars.to_a\n volts = resp[0..2].join.to_f * 0.1\n current = resp[3..5].join.to_f * 0.1\n return [volts, current]\n end",
"def max\n [self.begin, self.end].max\n end",
"def find_max\n\t# Use method: stu_max = @students_list.max_by{|x| x.avg}\n\t max =0\n\t for i in 0..(@students_list.length-1) \n\t\tif @students_list[i].avg > max\n\t\t max = @students_list[i].avg\n\t\t stu_max = @students_list[i]\n\t\tend\n\t end\n\t puts \"Student who has max avg\".center(30)\n\t puts \"Name: #{stu_max.name}\".rjust(20)\n\t puts \"Birthday: #{stu_max.birthday}\".rjust(20)\n\t puts \"Math: #{stu_max.math}\".rjust(20)\n\t puts \"Literature: #{stu_max.liter}\".rjust(20)\n\t puts \"English: #{stu_max.eng}\".rjust(20)\n\t puts \"AVG: #{stu_max.avg}\".rjust(20)\n\tend",
"def max\n end"
] | [
"0.65130913",
"0.6288525",
"0.62065625",
"0.5847636",
"0.5839843",
"0.5831783",
"0.58300966",
"0.58051425",
"0.5730118",
"0.5723641",
"0.57102364",
"0.5706892",
"0.5682888",
"0.56750625",
"0.5651811",
"0.5651421",
"0.5602612",
"0.55788976",
"0.5578301",
"0.5548771",
"0.5548771",
"0.5538782",
"0.5529718",
"0.5515602",
"0.55145985",
"0.5509536",
"0.5508245",
"0.5499478",
"0.5481763",
"0.5478858"
] | 0.6789641 | 0 |
Returns all the TAs associated with the assignment | def tas
Ta.find(ta_memberships.map(&:user_id))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n @assignments\n end",
"def all\n @assignments = TaskAssignment.all\n\n end",
"def get_assigned_transactions\n # find tag assignments relating to this pattern\n TagAssignment.find_all_by_source_and_source_info(2, self.id).map do |ta|\n # get the transaction to which the assignment refers\n ta.transaction\n end\n end",
"def task_assignments\n harvest_client.task_assignments(project_id: self.id)\n end",
"def index\n @type_of_assignments = TypeOfAssignment.all\n end",
"def assignments\n return @assignments\n end",
"def assignments\n return @assignments\n end",
"def assignments\n return @assignments\n end",
"def assignments\n return @assignments\n end",
"def assignments\n return @assignments\n end",
"def titems\n @titems ||= begin\n list.collect { |idx| Runner.iextrait.extrait_titems[idx] }\n end\n end",
"def index\n @qualification_ts = QualificationT.all\n end",
"def get_schedules\n ret=[]\n #puts \"==============teachings=#{self.teachings.to_a}\"\n self.teachings.to_a.each do |teaching|\n teaching.schedules.each do |schedule|\n ret << schedule\n end\n end\n ret\n end",
"def get_teachers\n ret=[]\n self.teachings.each do |teaching|\n ret<< teaching.teaching_teacher\n end\n ret.uniq\n end",
"def unassigned_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).unassigned\n end\n output\n end",
"def active_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).active\n end\n output\n end",
"def index\n @task_assignments = TaskAssignment.all\n end",
"def assignment_roles\n AssignmentRole.all\n end",
"def all_assessments\n teacher_class_rooms = case self.type\n when 'Teacher'\n self.teacher_class_rooms\n when 'CenterAdmin'\n self.center.class_rooms\n when 'InstituteAdmin'\n self.institution.class_rooms\n else\n []\n end\n content_ids = teacher_class_rooms.map(&:content_id)\n Content.where('board_id IN (?) or content_year_id IN (?) or subject_id IN (?)',content_ids,content_ids,content_ids).assessment_types\n end",
"def index\n @tintas = Tinta.all\n end",
"def task_assignments\n @task_assignments ||= Harvest::API::TaskAssignments.new(credentials)\n end",
"def get_apartments_with_tenants apts, tenants\n return apts.map { |apt|\n names = get_tenant_names_in_apt tenants, apt.id\n names\n }\n end",
"def get_tas\n TaForCourse.find_all_by_course_id(id).collect(&:user_id)\n end",
"def get_assignments(type, id)\n\t\tassignments = Array.new\n\t\t\n # Gather all assignments with this 'id' in the 'type' column\n\t\tlist = Relationship.where({ type.to_s => id })\n\n # In each assignment\n\t\tlist.each do |relationship|\n # Gather human readable parts\n assignment = assign_parts(relationship)\n\t\t\tassignments.push(assignment)\n\t\tend\n\n\t\treturn assignments\n\tend",
"def index\n @assignments = Assignment.eager_load(assignment_schedules: :corrections).order(number: :asc).all\n end",
"def index\n @tasks = @assignment.tasks.all \n end",
"def txactions\n load! unless loaded?\n return @txactions\n end",
"def placement_tpo\n @placement_exams = PlacementExam.all\n end",
"def attestation_subjects\n beg_sem = semester - 3\n end_sem = semester - 1\n return @attestation_subjects ||= plan_subjects.select do |ps|\n (beg_sem..end_sem).include? ps.finishing_on\n end\n end",
"def assignments; end"
] | [
"0.6106364",
"0.60140854",
"0.59386253",
"0.5815721",
"0.577215",
"0.57510734",
"0.57510734",
"0.57510734",
"0.57510734",
"0.57510734",
"0.5709013",
"0.5437892",
"0.5429713",
"0.5394504",
"0.53821075",
"0.5365384",
"0.5359678",
"0.5342053",
"0.53200847",
"0.52771217",
"0.5270091",
"0.52193093",
"0.5191943",
"0.51709276",
"0.51698226",
"0.5162868",
"0.5162199",
"0.5137411",
"0.5135072",
"0.5059162"
] | 0.6438123 | 0 |
Returns all the submissions that have not been graded (completed). Note: This assumes that every submission has at least one result. | def ungraded_submission_results
current_submissions_used.joins(:current_result)
.where('results.marking_state': Result::MARKING_STATES[:incomplete])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uncompleted_quests()\n Quest.all.select do |quest|\n quest.characters.include?(self) == false\n end\n\n end",
"def uncompleted_students(assessment)\n course_users = assessment.course.course_users\n # Eager load :user as it's needed for the recipient email.\n students = course_users.student.includes(:user)\n submitted =\n assessment.submissions.confirmed.includes(experience_points_record: { course_user: :user }).\n map(&:course_user)\n Set.new(students) - Set.new(submitted)\n end",
"def bad_results\n select {|r| !r.success }\n end",
"def pending_submissions\n if pending_submission_params[:my_students] == 'true'\n my_student_ids = current_course_user ? current_course_user.my_students.select(:user_id) : []\n @submissions.by_users(my_student_ids).pending_for_grading\n else\n @submissions.pending_for_grading\n end\n end",
"def unanswered_questions\n answered_ids = self.responses.map(&:beta_question_id)\n BetaQuestion.where.not(id: answered_ids)\n end",
"def index\n @runs = Run.all.where.not(:status => \"completed\")\n end",
"def ungraded_answers(submission)\n submission.reload.current_answers.select { |a| a.attempting? || a.submitted? }\n end",
"def incomplete_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :pending\n end\n end",
"def unanswered_check_in_questions\n action_items.where(component_type:Check::COMPONENT_TYPE, day:1..day.to_i).select{|i| !i.complete?}\n end",
"def incomplete_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif !evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\n\t\trender json: @evaluations\n\tend",
"def missing_list\n list = []\n active_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def submissions options = {}\n options = options.is_a?(Hash) ? options : { options => true }\n\n submission_ids = self.meetings.collect(&:packlets).flatten.collect(&:submission_id).uniq\n if self.published? && options[:all] != true\n Submission.where :id + submission_ids, :state => Submission.state(:published)\n else\n Submission.where :id + submission_ids\n end\n end",
"def all_not_done\n self.select { |todo| !todo.done? }\n end",
"def incomplete_tasks\n\t\ttasks.select{ |t| !t.completed? }\n\tend",
"def ungraded_attempts\n @attempts.select { |x| x.ungraded? }\n end",
"def missing_list\n list = []\n regular_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def unprocessed_results\n unprocessed_results = []\n self.design_review_results.each do |drr|\n unprocessed_results << drr unless drr.complete?\n end\n unprocessed_results.sort_by { |result| result.reviewer.last_name }\n end",
"def incomplete_products\n return self.products.select do |product|\n !product.passing? && !product.failing?\n end\n end",
"def get_others_submissions\n evaluated_submissions = {}\n milestones = Milestone.all\n milestones.each do |milestone|\n evaluated_submissions[milestone.id] = {}\n self.evaluateds.each do |evaluated|\n evaluated_submissions[milestone.id][evaluated.id] = Submission.find_by(team_id: evaluated.evaluated_id,\n milestone_id: milestone.id)\n end\n end\n return evaluated_submissions\n end",
"def course_incomplete_eval\n\t\t@student_evals = Student.find(params[:student_id]).evaluations.where('course_id = ?', params[:course_id])\n\t\t@evaluations = []\n\t\tif @student_evals != nil\n\t\t\tfor e in @student_evals\n\t\t\t\tif !e.isCompleted\n\t\t\t\t\t@evaluations << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend",
"def unreplied_surveys\n unreplied_survey_ids = Survey.surveys_for(self).collect{|s| s.id if s.try(:id)}.compact - completed_surveys.ids\n unreplied_survey_ids.empty? ? nil : unreplied_survey_ids\n end",
"def unanswered_questions\n Question.all.reject do |question|\n responsers_id = question.responses.pluck(:user_id)\n responsers_id.include?(self.id)\n end\n end",
"def sessions_submissions\n\t\t@submissions = Submission.non_allotted(@conference)\n\tend",
"def load_valid_submissions\n @submissions = []\n begin\n user_client = user_fire_cloud_client(current_user)\n workspace = user_client.get_workspace(@user_workspace.namespace, @user_workspace.name)\n @submissions = user_client.get_workspace_submissions(@user_workspace.namespace, @user_workspace.name)\n # remove deleted submissions from list of runs\n if !workspace['workspace']['attributes']['deleted_submissions'].blank?\n deleted_submissions = workspace['workspace']['attributes']['deleted_submissions']['items']\n @submissions.delete_if {|submission| deleted_submissions.include?(submission['submissionId'])}\n end\n rescue => e\n logger.info \"Cannot retrieve submissions for user_workspace '#{@user_workspace.full_name}': #{e.message}\"\n end\n end",
"def create_missing_submission_questions\n questions_with_submission_questions = @submission.submission_questions.includes(:question).map(&:question)\n questions_without_submission_questions = questions_to_attempt - questions_with_submission_questions\n new_submission_questions = []\n questions_without_submission_questions.each do |question|\n new_submission_questions <<\n Course::Assessment::SubmissionQuestion.new(submission: @submission, question: question)\n end\n\n ActiveRecord::Base.transaction do\n Course::Assessment::SubmissionQuestion.import! new_submission_questions, recursive: true\n end\n\n new_submission_questions.any?\n end",
"def index\n @submissions_unmatched = Submission.order('created_at DESC').where('person_id is ?', nil)\n @submissions = Submission.paginate(page: params[:page]).order('created_at DESC').includes(:person)\n end",
"def no_solutions\n\t\t#~ @no_solutions = []\n\t\t#~ Problem.all.each do |pr|\n\t\t\t#~ if pr.solutions.empty? && pr.checked\n\t\t\t\t#~ @no_solutions.push(pr)\n\t\t\t#~ end\n\t\t#~ end\n\t\t\n\t\t@no_solutions = Problem.where(checked: true).select { |p| p.solutions.empty?}.paginate(page: params[:page], per_page: 10)\n\n\tend",
"def index\n if params.key? :assignment_id\n @submissions = Submission.where(assignment_id: params[:assignment_id])\n else\n @submissions = Submission.where(user_id: current_user.id)\n end\n if @submissions.is_a?(FalseClass)\n @submissions = []\n end\n\n end",
"def index\n @restaurant_evaluations = RestaurantEvaluation.all\n @restaurants_not_evald = Restaurant.where.not(id: @restaurant_evaluations.map(&:restaurant_id))\n end",
"def missing_answers\n return @missing_answers if @missing_answers\n answer_for_qing(:rebuild => true)\n @missing_answers = visible_questionings.collect do |qing|\n (answer_for(qing).nil? && qing.required?) ? qing : nil\n end.compact\n end"
] | [
"0.6562504",
"0.6243815",
"0.6091786",
"0.60580516",
"0.60443515",
"0.59850144",
"0.59800386",
"0.59739655",
"0.59259164",
"0.5905791",
"0.5903663",
"0.5900361",
"0.5891795",
"0.5876577",
"0.58748436",
"0.58684295",
"0.5788737",
"0.5778207",
"0.57766414",
"0.5775974",
"0.5764136",
"0.5730562",
"0.57285845",
"0.5714941",
"0.5640655",
"0.5623387",
"0.55925643",
"0.55866885",
"0.55784535",
"0.55604386"
] | 0.77749896 | 0 |
Returns the groupings of this assignment associated with the given section | def section_groupings(section)
groupings.select do |grouping|
grouping.inviter.present? &&
grouping.inviter.has_section? &&
grouping.inviter.section.id == section.id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def section_groups\n return @section_groups\n end",
"def grouped_names(section)\n BASE_CONFIG[section].group_by { |_, v| v[:group] }.transform_values { |v| v.map(&:first) }\n end",
"def groupbysection()\n merge(notgroupbysection: 'true')\n end",
"def section_groups=(value)\n @section_groups = value\n end",
"def sectionless_groupings\n groupings.select do |grouping|\n grouping.inviter.present? &&\n !grouping.inviter.has_section?\n end\n end",
"def groups\n groups = []\n relations = self.group_relations\n relations.each do |r|\n groups.push r.group\n end\n groups\n end",
"def groups\n return @groups\n end",
"def groups\n find(:group).map { |g| g.content }\n end",
"def get_groupings_table_info(target_assignment=nil)\n if target_assignment.nil?\n target_assignment = @assignment\n end\n\n groupings = target_assignment.groupings\n .includes(:group,\n :student_memberships,\n :non_rejected_student_memberships,\n :students,\n :inviter)\n groupings.map do |grouping|\n g = grouping.attributes\n g[:name] = grouping.group.group_name\n g[:members] = grouping.student_memberships.map {|membership| [membership.user.id, membership.user.user_name, membership.membership_status]}#grouping.students\n g[:section] = grouping.section\n g[:valid] = grouping.is_valid?\n g\n end\n end",
"def list_names(section)\n BASE_CONFIG[section].map { |key, val| [val[:group], key] }.sort\n end",
"def groups\n @groups ||= {}\n end",
"def sections\n temp_sections = []\n if @section_ids.count > 0\n @section_ids.each do |section_id|\n temp_sections.push @client.section(@org_id, section_id)\n end\n end\n return temp_sections\n end",
"def groups\n quads\n end",
"def groups\n\t\t\t@groups ||= Group.find(:all, :distinguishedname => @entry.memberOf)\n\t\tend",
"def groups\n @@groups = Group.groups if @@groups.nil? or @@groups.empty?\n @@groups\n end",
"def get_groups()\n return self.groups\n end",
"def groups\n unless @groups\n @groups = convert_to_objects(cn_groups)\n end\n @groups\n end",
"def section_selection\n sections.map { |s| [s.to_label, s.id] }\n end",
"def groups\n find_groups if @groups.nil?\n @groups\n end",
"def grouping\n @ole.Grouping\n end",
"def groups\n @groups ||= @csv.group_by { |row| row[:id] }\n end",
"def groups\n match(/Groups\\s+:\\s+(.+)$/).split rescue []\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def groups\n return [] if memberOf.nil?\n @groups ||= Group.find(:all, distinguishedname: @entry.memberOf).delete_if(&:nil?)\n end",
"def section_locations(section)\n schedules = recurring_schedules(section)\n schedules.size > 0 ? schedules.map {|schedule| \"#{schedule[:roomNumber]} #{schedule[:buildingName]}\"} : []\n end",
"def groups\n @parent.groups(@filter)\n end",
"def groups\n return [] if self.group_list.nil?\n self.group_list\n end",
"def groups_in(node_name)\n @groups.data_for(node_name)['groups'] || {}\n end",
"def section_groups_url\n return @section_groups_url\n end",
"def sections\n return @sections\n end"
] | [
"0.7498284",
"0.700692",
"0.6822014",
"0.6727",
"0.6499582",
"0.6297976",
"0.6255746",
"0.6225984",
"0.62206864",
"0.61077076",
"0.6011966",
"0.5975515",
"0.59560347",
"0.59146875",
"0.59062314",
"0.5886351",
"0.585062",
"0.5840111",
"0.58187306",
"0.5804865",
"0.57734555",
"0.57664645",
"0.57634836",
"0.5742665",
"0.5742316",
"0.5740006",
"0.57337284",
"0.5733468",
"0.5714528",
"0.571402"
] | 0.83134943 | 0 |
Returns the groupings of this assignment that have no associated section | def sectionless_groupings
groupings.select do |grouping|
grouping.inviter.present? &&
!grouping.inviter.has_section?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def section_groupings(section)\n groupings.select do |grouping|\n grouping.inviter.present? &&\n grouping.inviter.has_section? &&\n grouping.inviter.section.id == section.id\n end\n end",
"def groupbysection()\n merge(notgroupbysection: 'true')\n end",
"def possible_groups groups\r\n possible_grps = groups.select {|g| !self.days_assigned.include?(g.day)}\r\n\r\n if possible_grps.count == 0 && self.duplicate_days < self.schedule_dataset.duplicate_days_allowed\r\n return groups\r\n\r\n # Return the groups with days that the seminarian has not been assigned to\r\n else\r\n return possible_grps\r\n end\r\n end",
"def section_groups\n return @section_groups\n end",
"def no_associated_field_groups\n FieldGroup.where(tag_id: id).none?\n end",
"def effective_groups\n ret = [ self ]\n memberships.each do |m|\n unless ret.include?(m) # prevent infinite recursion\n tmp = m.effective_groups\n tmp.each do |g|\n ret << g unless ret.include?(g)\n end\n end\n end\n ret\n end",
"def ungrouped\n cached_dataset(:_ungrouped_ds){clone(:group => nil, :having => nil)}\n end",
"def prune_empty_groups\n @channels.each_value do |channel|\n channel.leave_group if channel.group? && channel.recipients.empty?\n end\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def populated_groups\n @counts.keys\n end",
"def without_empty_sets\n collection = clone\n collection.sets.reject!(&:empty?)\n collection\n end",
"def layout_tags_not_in_subfield_grouping\n unless @layout_tags_not_in_subfield_grouping\n @layout_tags_not_in_subfield_grouping = Array.new\n layout_config[\"groups\"].each do |group, gdata|\n next if gdata[\"subfield_grouping\"]\n gdata[\"all_tags\"].each do |tag, tdata|\n @layout_tags_not_in_subfield_grouping.push tag\n end\n end\n @layout_tags_not_in_subfield_grouping.uniq!\n @layout_tags_not_in_subfield_grouping.sort!\n end\n @layout_tags_not_in_subfield_grouping \n end",
"def contact_groups_represented\n @contact_groups_represented ||= contacts.map(&:contact_groups).flatten.uniq\n end",
"def group\n nil\n end",
"def empty_group\n self.group_memberships.each {|m| m.destroy}\n end",
"def non_member_groups\n Group.joins(\"LEFT OUTER JOIN ( SELECT * FROM group_memberships WHERE person_id = #{self.id} ) AS gm ON groups.id = gm.group_id\").where('gm.person_id IS NULL').where('groups.active')\n end",
"def groups\n return [] if self.group_list.nil?\n self.group_list\n end",
"def group_fines\n []\n end",
"def get_all_groups\n grps = []\n grps += self.groups\n grps.each { |g| grps += g.get_all_groups }\n return grps.compact.uniq\n end",
"def base_groups\n [self.institution_id,self.center_id,self.academic_class_id,self.section_id].compact rescue []\n end",
"def opt_groups\n return unless departments.empty?\n end",
"def remove_onl_sections( sections )\n\n onl_sections = []\n sections.each do |section|\n section.meetings.each do |meeting|\n onl_sections << section if meeting.start_time.nil? # MIGHT ADD DUPLICATES\n end\n end\n\n onl_sections.each do |onl_section|\n sections.delete(onl_section)\n end\n\n return onl_sections\n end",
"def groups\n @groups ||= {}\n end",
"def empty?\n group.empty?\n end",
"def assessment_divisions(assessment)\n if assessment.quiz_sections.empty?\n [assessment]\n else\n assessment_division_set = []\n assessment.quiz_sections.each do |quiz_section|\n if quiz_section.children_sections.empty? and quiz_section.parent_id.nil?\n assessment_division_set << quiz_section\n else\n quiz_section.children_sections.each do |child_section|\n assessment_division_set << child_section\n end\n end\n end\n assessment_division_set\n end\n\n end",
"def groups\n @@groups = Group.groups if @@groups.nil? or @@groups.empty?\n @@groups\n end",
"def zero\n self.group = []\n end",
"def all_groups\r\n result = []\r\n self.groups.each { |group| result << group.descendants_and_self }\r\n result.flatten!\r\n result.uniq!\r\n return result\r\n end"
] | [
"0.65282017",
"0.62313753",
"0.6221667",
"0.61291695",
"0.59813946",
"0.58380204",
"0.57698745",
"0.57679343",
"0.57531184",
"0.57531184",
"0.57531184",
"0.57382804",
"0.57162774",
"0.57115316",
"0.56997824",
"0.5666407",
"0.56526107",
"0.5646992",
"0.5642918",
"0.56289417",
"0.5628782",
"0.5626925",
"0.562127",
"0.5613177",
"0.5610915",
"0.5597104",
"0.5574231",
"0.5563493",
"0.5534213",
"0.5533764"
] | 0.760112 | 0 |
Returns true if this is a peer review, meaning it has a parent assignment, false otherwise. | def is_peer_review?
!parent_assessment_id.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_peer_review_assignment?\n not pr_assignment.nil?\n end",
"def parent?\n !parent.nil?\n end",
"def parent?\n not parent.nil?\n end",
"def parent?\n true\n end",
"def parent?\n ! parent.nil?\n end",
"def requires_parent_approval?\n requires_parent_approval.nil? ? REQUIRES_PARENT_APPROVAL : requires_parent_approval\n end",
"def parent?\n false\n end",
"def parent?\n !parent_type.nil?\n end",
"def parent?\n !parent_type.nil?\n end",
"def has_parent?\n !parent.nil?\n end",
"def has_parent?\n !parent_context.nil?\n end",
"def has_parents?\n \n return @parent ? true : false\n \n end",
"def owns_parent?(parent)\n parent.student.teacher == current_user\n end",
"def parent?\n !parents.empty?\n end",
"def is_parent?\n parent_id.blank? && !self.sub_groups.blank?\n end",
"def has_parent?\n parent_id != nil\n end",
"def has_parent?\n if !self.parent.nil?\n return self.parent\n else\n return false\n end\n end",
"def parentable?\n false\n end",
"def parent?\n !@child_pid.nil?\n end",
"def parent?\n false\n end",
"def requested_through_parents?\n (@parents.blank?) ? false : true\n end",
"def parent?(id)\n self.parent_id == id\n end",
"def main?\n @parent_id.nil?\n end",
"def parent?\n true \n end",
"def parent?\n !root?\n end",
"def has_parent?\n ! embedded['parent'].nil?\n end",
"def is_a_parent?\r\n count_of_sub_jobs = Job.where(\"parent_job_id = #{id}\").count\r\n if count_of_sub_jobs == 0\r\n false\r\n else\r\n true\r\n end\r\n end",
"def parent_missing?\n has_field?(:crossref) && !has_parent?\n end",
"def has_parent?\n !root?\n end",
"def has_parents?\n \n return ! @parents.empty?\n \n end"
] | [
"0.7613671",
"0.71404904",
"0.7124823",
"0.7092197",
"0.70604664",
"0.70581985",
"0.7031308",
"0.70253164",
"0.7008059",
"0.69065076",
"0.68752193",
"0.6844034",
"0.6798208",
"0.67847764",
"0.6759756",
"0.67313075",
"0.66988647",
"0.6680572",
"0.6639289",
"0.6610706",
"0.6586034",
"0.6578659",
"0.6557632",
"0.6557524",
"0.6534154",
"0.6495123",
"0.6489285",
"0.6430024",
"0.6413642",
"0.63928187"
] | 0.8202432 | 0 |
Yield an open repo for each grouping of this assignment, then yield again for each repo that raised an exception, to try to mitigate concurrent accesses to those repos. | def each_group_repo
failed_groupings = []
self.groupings.each do |grouping|
begin
grouping.access_repo do |repo|
yield(repo)
end
rescue StandardError
# in the event of a concurrent repo modification, retry later
failed_groupings << grouping
end
end
failed_groupings.each do |grouping|
begin
grouping.access_repo do |repo|
yield(repo)
end
rescue StandardError
# give up
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_repository(&block)\n repositories.values.each(&block)\n end",
"def all_repos_as_generator\n Enumerator.new do |enum|\n each do |repo|\n enum.yield repo\n end\n end\n end",
"def all_repos_as_generator\n Enumerator.new do |enum|\n each do |repo|\n enum.yield repo\n end\n end\n end",
"def for_each_bitbucket_repo\n @bitbucket_repos.each do |bitbucket_repo_info|\n HybridPlatformsConductor::Bitbucket.with_bitbucket(bitbucket_repo_info[:url], @logger, @logger_stderr) do |bitbucket|\n (bitbucket_repo_info[:repos] == :all ? bitbucket.repos(bitbucket_repo_info[:project])['values'].map { |repo_info| repo_info['slug'] } : bitbucket_repo_info[:repos]).each do |name|\n yield bitbucket, {\n name: name,\n project: bitbucket_repo_info[:project],\n url: \"#{bitbucket_repo_info[:url]}/scm/#{bitbucket_repo_info[:project].downcase}/#{name}.git\",\n jenkins_ci_url: bitbucket_repo_info[:jenkins_ci_url].nil? ? nil : \"#{bitbucket_repo_info[:jenkins_ci_url]}/job/#{name}\",\n checks: bitbucket_repo_info[:checks]\n }\n end\n end\n end\n end",
"def find_invalid_repos\n repos_with_issues = RepositorySet.new(\n Repositext::PARENT_DIR\n ).git_ensure_repos_are_ready(\n :all_content_repos\n ) { |repo_path| puts \" - #{ repo_path.split('/').last }\" }\n # TODO: Use #all_synced_foreign_repos instead of the RepositorySet method. Requires a refactoring.\n repos_with_issues += ensure_st_ops_filenames_are_valid\n if repos_with_issues.any?\n puts\n puts \"Could not proceed because the following git repositories are not ready:\".color(:red)\n puts\n repos_with_issues.each { |repo_path, issues|\n puts repo_path\n puts '-' * 40\n issues.each { |e| puts \" - #{ e }\".color(:red) }\n }\n puts\n raise ReposNotReadyError.new(\n \"\\n\\nCannot proceed with synching subtitles until all content repos are clean!\".color(:red)\n )\n end\n true\n end",
"def each_module(&block)\n (@modules || {}).each do |type, repos|\n (repos || {}).values.each do |repo|\n yield repo\n end\n end\n end",
"def each\n @lock.synchronize do\n @db.clear_marks\n # Start with the object 0 and the indexes of the root objects. Push them\n # onto the work stack.\n stack = [ 0 ] + @root_objects.values\n while !stack.empty?\n # Get an object index from the stack.\n id = stack.pop\n next if @db.is_marked?(id)\n\n unless (obj = object_by_id_internal(id))\n PEROBS.log.fatal \"Database is corrupted. Object with ID #{id} \" +\n \"not found.\"\n end\n # Mark the object so it will never be pushed to the stack again.\n @db.mark(id)\n yield(obj.myself) if block_given?\n # Push the IDs of all unmarked referenced objects onto the stack\n obj._referenced_object_ids.each do |r_id|\n stack << r_id unless @db.is_marked?(r_id)\n end\n end\n end\n end",
"def ensure_forks(owner, repo)\n currepo = ensure_repo(owner, repo)\n\n if currepo.nil?\n warn \"Could not find repo #{owner}/#{repo} for retrieving forks\"\n return\n end\n\n existing_forks = db.from(:projects, :users).\\\n where(Sequel.qualify('users', 'id') => Sequel.qualify('projects', 'owner_id')). \\\n where(Sequel.qualify('projects', 'forked_from') => currepo[:id]).\\\n select(Sequel.qualify('projects', 'name'), :login).all\n\n retrieve_forks(owner, repo).reduce([]) do |acc, x|\n if existing_forks.find do |y|\n forked_repo_owner = x['url'].split(/\\//)[4]\n forked_repo_name = x['url'].split(/\\//)[5]\n y[:login] == forked_repo_owner && y[:name] == forked_repo_name\n end.nil?\n acc << x\n else\n acc\n end\n end.map { |x| save{ensure_fork(owner, repo, x['id']) }}.select{|x| !x.nil?}\n end",
"def chunked_repo_sets \n all_repositories = Dir.entries(OBSERVATIONS_DIR).select{|x| x != '.' && x != '..' && x != '.DS_Store'}.map{|x| \"#{OBSERVATIONS_DIR}/\" + x}\n stride = 500\n start_i = 0\n end_i = stride - 1\n repo_count = all_repositories.size\n repo_sets = Array.new\n while start_i < repo_count do\n end_i = repo_count - 1 if end_i >= repo_count\n next_set = all_repositories[start_i..end_i]\n repo_sets << next_set\n start_i = end_i + 1\n end_i += stride\n end\n repo_sets\nend",
"def ensure_issues(owner, repo)\n currepo = ensure_repo(owner, repo)\n if currepo.nil?\n warn \"Could not find repo #{owner}/#{repo} for retrieving issues\"\n return\n end\n\n issues = db[:issues].filter(:repo_id => currepo[:id]).all\n raw_issues = retrieve_issues(owner, repo).reduce([]) do |acc, x|\n if issues.find { |y| y[:issue_id] == x['number'] }.nil?\n acc << x\n else\n acc\n end\n end\n\n raw_issues.map { |x| save { ensure_issue(owner, repo, x['number']) } }.select { |x| !x.nil? }\n end",
"def each\n git.tree.each_pair(true) do |ab, xyz_tree|\n next unless ab.length == 2\n \n xyz_tree.each_pair(true) do |xyz, target_tree|\n source = \"#{ab}#{xyz}\"\n \n target_tree.keys.each do |target|\n doc_sha = assoc_sha(source, target)\n yield(doc_sha) if doc_sha\n end\n end\n end\n end",
"def each(&block)\n @issues.each(&block)\n end",
"def each_for_write\n \t \tbegin\n\t \t \thelper = TransHelper.new\n\t \t \thelper.trans([:Layer]) do |tr,db,tables|\n\t \t \t \tself.each do |sel_object|\n\t \t \t \t\tent = helper.get_obj(sel_object.ObjectId, :Read)\n\t \t \t \t\tlayer = helper.get_obj(ent.LayerId)\n\t \t \t \t\tif !layer.IsLocked\n\t \t \t \t\t\tent.UpgradeOpen\n\t \t \t \t \tyield ent \n\t \t \t \t end\t\n\t \t \t \tend\n\t \t \tend\n \t rescue Exception => e\n\t\t puts_ex e\n\t \t end\t\n \t end",
"def load_issues\n load_repository_data()\n\n gh_client.list_issues(repo_name, { state: \"all\" }).each do |data|\n issue = IssueGraph::Issue.new\n issue.load_from_gh_data(data)\n issue[:repo_id] = repo[:id]\n issue[:repo_name] = repo_name\n self.add(issue)\n end\n end",
"def each(&block)\n @control_file.distributions.each do |dist|\n dist.package_rules.each do |rule|\n yield PackageState.new(dist: dist, rule: rule, apt_site: @apt_site,\n build_archive: @build_archive)\n end\n end\n end",
"def ensure_all_content_repos_are_ready\n find_invalid_repos\n find_invalid_primary_st_ops_filenames\n end",
"def get_github_issues\n @github_issues = octokit_client.issues(repo_name).each_with_object({}) { |issue, issues|\n issues[issue[\"number\"]] = issue\n }\n end",
"def excess_repositories_for(multi_repo = nil)\n repository_full_names = repositories_for(multi_repo).map(&:full_name)\n local_repositories_for(multi_repo).reject { |repo|\n repository_full_names.include? repo.full_name\n }\n end",
"def get_github_repos_already_cloned\n repos = Array.new\n\n configatron.dir.children.each do |repo_name|\n if repo_name.directory?\n begin\n repo = Github.repos.get(\n user: ENV['GITHUB_ACCOUNT'],\n oauth_token: ENV['GITHUB_API_TOKEN'],\n repo: repo_name.basename.to_s\n )\n rescue Exception => e\n puts \"\\n#{e}\"\n next\n end\n repos << repo if repo.fork\n end\n end # configatron.dir.children.each do |repo_name|\n\n return repos\nend",
"def each(&block)\n synchronized do\n return if @files.empty?\n\n file_deleteable = []\n # creates this array just once\n watched_files = @files.values\n\n # look at the closed to see if its changed\n watched_files.select {|wf| wf.closed? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the closed file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n watched_file.watch\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # look at the ignored to see if its changed\n watched_files.select {|wf| wf.ignored? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the ignored file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n # this file has not been yielded to the block yet\n # but we must have the tail to start from the end, so when the file\n # was first ignored we updated the bytes_read to the stat.size at that time.\n # by adding this to the sincedb so that the subsequent modify\n # event can detect the change\n watched_file.watch\n yield(:unignore, watched_file)\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # Send any creates.\n if (to_take = @max_active - watched_files.count{|wf| wf.active?}) > 0\n watched_files.select {|wf| wf.watched? }.take(to_take).each do |watched_file|\n watched_file.activate\n # don't do create again\n next if watched_file.state_history_any?(:closed, :ignored)\n # if the file can't be opened during the yield\n # its state is set back to watched\n if watched_file.initial?\n yield(:create_initial, watched_file)\n else\n yield(:create, watched_file)\n end\n end\n else\n now = Time.now.to_i\n if (now - @lastwarn_max_files) > MAX_FILES_WARN_INTERVAL\n waiting = @files.size - @max_active\n specific = if @close_older.nil?\n \", try setting close_older. There are #{waiting} unopened files\"\n else\n \", files yet to open: #{waiting}\"\n end\n @logger.warn(@max_warn_msg + specific)\n @lastwarn_max_files = now\n end\n end\n\n # wf.active means the actual files were opened\n # and have been read once - unless they were empty at the time\n watched_files.select {|wf| wf.active? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{$!}), deleting from @files\")\n watched_file.unwatch\n yield(:delete, watched_file)\n next\n rescue => e\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{e.inspect})\")\n next\n end\n\n if watched_file.file_closable?\n @logger.debug? && @logger.debug(\"each: active: file expired: #{path}\")\n yield(:timeout, watched_file)\n watched_file.close\n next\n end\n\n _inode = inode(path,stat)\n read_thus_far = watched_file.bytes_read\n # we don't update the size here, its updated when we actually read\n if watched_file.inode_changed?(_inode)\n @logger.debug? && @logger.debug(\"each: new inode: #{path}: old inode was #{watched_file.inode.inspect}, new is #{_inode.inspect}\")\n watched_file.update_inode(_inode)\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size < read_thus_far\n @logger.debug? && @logger.debug(\"each: file rolled: #{path}: new size is #{stat.size}, old size #{read_thus_far}\")\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size > read_thus_far\n @logger.debug? && @logger.debug(\"each: file grew: #{path}: old size #{read_thus_far}, new size #{stat.size}\")\n yield(:modify, watched_file)\n end\n end\n\n file_deleteable.each {|f| @files.delete(f)}\n end\n end",
"def gather_errors\n if @propagation_exceptions\n raise InternalError, \"recursive call to #gather_errors\"\n end\n\n # The ensure clause must NOT apply to the recursive check above.\n # Otherwise, we end up resetting @propagation_exceptions to nil,\n # which wreaks havoc\n begin\n @propagation_exceptions = []\n yield\n @propagation_exceptions\n\n ensure\n @propagation_exceptions = nil\n end\n\tend",
"def batch_by_oid(repo, oids)\n wrapped_gitaly_errors do\n repo.gitaly_commit_client.list_commits_by_oid(oids)\n end\n end",
"def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end",
"def each_group\n @groups.each_value do | group |\n yield( group )\n end\n end",
"def clone_repos repos\n $logger.info \"Detecting if clones repos #{repos}\"\n failed_repos = []\n repos.each do |repo|\n repo_path = \"#{GIT_DIR}/#{repo}\"\n # TODO: Use ssh instead of http\n clone_url = \"http://#{GIT_USER}:#{GIT_PASSWORD}@#{BASE_GIT_URL}:#{BASE_GIT_PORT}/scm/#{PROJECT_ID}/#{repo}.git\"\n unless `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' config --get remote.origin.url`.to_s.strip == clone_url\n $logger.info \"No git repo found or invalid git repo detected at #{repo_path}. Deleting and recloning project #{repo}\"\n # If for some reason we didn't detect that it's a git repo, just clear the whole directory\n # And reclone (note that we only need to clone the latest commit on the master branch)\n successfully_cloned = system \"git clone #{clone_url} --branch master --single-branch --depth 1 #{repo_path}\"\n unless successfully_cloned\n $logger.warn \"Could not git clone repo #{clone_url} to #{repo_path}\"\n failed_repos.push repo\n FileUtils.rm_rf repo_path\n end\n end\n # Make sure the git repos are unmodified before we do anything\n `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' reset --hard HEAD`\n end\n $logger.info \"Removing failed repos #{failed_repos}\"\n repos -= failed_repos\n return repos\nend",
"def list_repositories\n return static_list_repositories if false\n super.select do |repo|\n sleep 1\n begin\n github[\"repos/#{repo['full_name']}/contents/.dockstore.yml\"].head\n sleep 1\n rescue RestClient::NotFound\n output.puts \"No .dockstore.yml found in #{repo['full_name']}, skipping\"\n end\n end\n end",
"def commits_all(num_commits)\n # Check for 'master' branch and switch to that if it exists\n # main_branch = nil\n # @repo.heads().each do |head|\n # main_branch = \"master\" if head.name == \"master\"\n # end\n main_branch = @repo.head().name\n # Get commits on that branch\n if num_commits > 50\n i = num_commits / 25\n (0..i).each do |i|\n yield @repo.commits(main_branch, 25, i*25)\n end\n else\n yield @repo.commits(main_branch, num_commits)\n end\n end",
"def scope\n Repo.with_env(REPO => self) { yield }\n end",
"def each_dir\n self.exit_list.each do |e|\n yield e if e\n end\n end",
"def exclusive(timeout: 10.minutes)\n counter = 0\n log_wait = proc do |owner|\n if (counter += 1) % 10 == 1\n executor.output.write(\"Waiting for repository lock for #{owner}\\n\")\n end\n end\n MultiLock.lock(repo_cache_dir, outside_caller, timeout: timeout, failed_to_lock: log_wait) { return yield }\n end"
] | [
"0.5769062",
"0.54741853",
"0.54741853",
"0.5373891",
"0.5342644",
"0.5220153",
"0.51537997",
"0.5115386",
"0.5093881",
"0.5078732",
"0.49326602",
"0.4898599",
"0.48803905",
"0.48647445",
"0.48645085",
"0.48617437",
"0.48591366",
"0.48534536",
"0.48212472",
"0.4780582",
"0.47706047",
"0.47286358",
"0.47279158",
"0.4718397",
"0.47031784",
"0.47026297",
"0.46869028",
"0.46818116",
"0.46802253",
"0.46736878"
] | 0.80896103 | 0 |
zip all files in the folder at +self.autotest_files_dir+ and return the path to the zip file | def zip_automated_test_files(user)
zip_name = "#{self.short_identifier}-testfiles-#{user.user_name}"
zip_path = File.join('tmp', zip_name + '.zip')
FileUtils.rm_rf zip_path
files_dir = Pathname.new self.autotest_files_dir
Zip::File.open(zip_path, Zip::File::CREATE) do |zip_file|
self.autotest_files.map do |file|
path = File.join zip_name, file
abs_path = files_dir.join(file)
if abs_path.directory?
zip_file.mkdir(path)
else
zip_file.get_output_stream(path) { |f| f.print File.read(abs_path.to_s, mode: 'rb') }
end
end
end
zip_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zipfiles\n @zipfile_name = \"#{$zip_folder}#{$testcase}.zip\"\n Zip::File.open(\"#{@zipfile_name}\", Zip::File::CREATE) do |zipfile|\n Dir.glob(\"#{$image_folder}#{$testcase}*\").each do |filename|\n file = File.basename(\"#{filename}\")\n zipfile.add(file, \"#{$image_folder}\" + file)\n end\n end\n end",
"def zip_result_directory\n end",
"def zipped!\n return if File.exist?(zip_path)\n FileUtils.mkdir_p \"/tmp/play-zips\"\n system \"zip #{zip_path} #{path}/*\"\n end",
"def zip_files\n time = Time.now.strftime('%Y-%d-%m_%H-%M-%S')\n Archive::Zip.archive(File.join(ARCHIVE[0], ARCHIVE[1], time, ARCHIVE[2]), File.join(LOCAL_DIR, '.'))\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each { |file| File.delete(file) }\n end",
"def output_zipfile_path\n Pathname.new(output_final_directory_path).dirname.to_s + '/' + zip_filename\n end",
"def zip_path\n \"/tmp/play-zips/#{zip_name}\"\n end",
"def zip_file_directory\n \"#{File.dirname(filename)}/#{File.basename(filename, '.zip')}\"\n end",
"def zip_file\n path = Dir.mktmpdir\n File.join(path, 'deploy.zip').tap do |path|\n Zip::File.open(path, Zip::File::CREATE) do |zip|\n Dir[\"#{@path}/**/**\"].each do |file|\n zip.add(file.sub(\"#{File.dirname(@path)}/\", ''), file)\n end\n end\n end\n end",
"def zip_download\n require 'zip'\n require 'tempfile'\n\n tmp_dir = ENV['TMPDIR'] || \"/tmp\"\n tmp_dir = Pathname.new tmp_dir\n # Deepblue::LoggingHelper.debug \"Download Zip begin tmp_dir #{tmp_dir}\"\n Deepblue::LoggingHelper.bold_debug [ \"zip_download begin\", \"tmp_dir=#{tmp_dir}\" ]\n target_dir = target_dir_name_id( tmp_dir, curation_concern.id )\n # Deepblue::LoggingHelper.debug \"Download Zip begin copy to folder #{target_dir}\"\n Deepblue::LoggingHelper.bold_debug [ \"zip_download\", \"target_dir=#{target_dir}\" ]\n Dir.mkdir( target_dir ) unless Dir.exist?( target_dir )\n target_zipfile = target_dir_name_id( target_dir, curation_concern.id, \".zip\" )\n # Deepblue::LoggingHelper.debug \"Download Zip begin copy to target_zipfile #{target_zipfile}\"\n Deepblue::LoggingHelper.bold_debug [ \"zip_download\", \"target_zipfile=#{target_zipfile}\" ]\n File.delete target_zipfile if File.exist? target_zipfile\n # clean the zip directory if necessary, since the zip structure is currently flat, only\n # have to clean files in the target folder\n files = Dir.glob( (target_dir.join '*').to_s)\n Deepblue::LoggingHelper.bold_debug files, label: \"zip_download files to delete:\"\n files.each do |file|\n File.delete file if File.exist? file\n end\n Deepblue::LoggingHelper.debug \"Download Zip begin copy to folder #{target_dir}\"\n Deepblue::LoggingHelper.bold_debug [ \"zip_download\", \"begin copy target_dir=#{target_dir}\" ]\n Zip::File.open(target_zipfile.to_s, Zip::File::CREATE ) do |zipfile|\n metadata_filename = curation_concern.metadata_report( dir: target_dir )\n zipfile.add( metadata_filename.basename, metadata_filename )\n export_file_sets_to( target_dir: target_dir, log_prefix: \"Zip: \" ) do |target_file_name, target_file|\n zipfile.add( target_file_name, target_file )\n end\n end\n # Deepblue::LoggingHelper.debug \"Download Zip copy complete to folder #{target_dir}\"\n Deepblue::LoggingHelper.bold_debug [ \"zip_download\", \"download complete target_dir=#{target_dir}\" ]\n send_file target_zipfile.to_s\n end",
"def zip_xml_files\n logger.debug('ZIPPING ALL FILES.')\n # time = Time.now.strftime('%Y-%d-%m_%H-%M-%S')\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each do |file|\n list_files.push(file)\n end\n puts list_files.length\n list_files.each do |file|\n Archive::Zip.archive((file + ARCHIVE_EXTN), file) if File.extname(file).eql?('.xml')\n end\n list_files.each do |file|\n File.delete(file)\n end\n logger.debug('ALL FILES ZIPPED.')\n end",
"def extract_zip\n # FileUtils.rmtree(@extract_folder)\n zip_files = Dir[\"#{@download_folder}/*.zip\"]\n\n zip_files.each do |zip|\n Zip::File.open(zip) do |zip_file|\n zip_file.each do |f|\n file_name = f.name\n FileUtils.mkdir_p(\"#{@extract_folder}/#{File.dirname(file_name)}\")\n\n # doesn't extract empty files or files with fake locale\n if f.size && f.size != 0\n # if true overwrite existing files with same name\n zip_file.extract(f, \"#{@extract_folder}/#{f.name}\") { true }\n end\n end\n end\n delete_zip(zip)\n end\n end",
"def zipXMLFiles\n logger.debug(\"ZIPPING ALL FILES.\")\n #time = Time.now.strftime(\"%Y-%d-%m_%H-%M-%S\")\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each {\n |file|\n listFiles.push(file)\n }\n puts listFiles.length\n listFiles.each {\n |file|\n if File.extname(file).eql?(\".xml\")\n Archive::Zip.archive((file + ARCHIVE_EXTN), file)\n end\n }\n listFiles.each {\n |file|\n File.delete(file)\n }\n logger.debug(\"ALL FILES ZIPPED.\")\n end",
"def generate_zip folder, zip_path\n FileUtils.rm zip_path if File.file? zip_path\n\n scan_path = File.join(folder, '*')\n puts \"Zipping up: #{scan_path}\"\n input_files = Dir.glob(scan_path)\n\n Zip::File.open(zip_path, Zip::File::CREATE) do |zipfile|\n input_files.each do |file|\n # Two arguments:\n # - The name of the file as it will appear in the archive\n # - The original file, including the path to find it\n zipfile.add(File.basename(file), file)\n end\n end\n end",
"def zip(folder, file=nil, options={})\n raise ArgumentError if folder == '.*'\n file ||= File.basename(File.expand_path(folder)) + '.zip'\n cmd = \"zip -rqu #{file} #{folder}\"\n puts cmd if options[:dryrun] or options[:verbose]\n system cmd unless options[:dryrun] or options[:noop]\n return File.expand_path(file)\n end",
"def zip_file\n \"#{package_name}.zip\"\n end",
"def zip_file_directory\n # Get the base file name and remove problematic parens\n basename = File.basename(filename, \".zip\").delete(\"(\").delete(\")\")\n \"#{File.dirname(filename)}/#{basename}\"\n end",
"def zip\n raise \"No tracks in album #{name}\" if songs.empty? \n bundle_filename = \"#{RmedialSetting.default.static_file_path}/zip/#{artist.name} - #{name}.zip\"\n raise \"Unable to create zip file\" if !Medium.path_is_writeable?(bundle_filename)\n \n # check to see if the file exists already, and if it does, delete it.\n File.delete(bundle_filename) if File.file?(bundle_filename) \n\n # open or create the zip file\n Zip::ZipFile.open(bundle_filename, Zip::ZipFile::CREATE) { |zipfile|\n # collect the album's tracks\n self.songs.collect { |song|\n # add each track to the archive, names using the track's attributes\n zipfile.add(song.ideal_file_name, song.file_name)\n }\n }\n\n # set read permissions on the file\n File.chmod(0644, bundle_filename)\n\n return bundle_filename\n end",
"def archive\n files.each do |path|\n path_obj = Pathname.new(path)\n path_name = path_obj.dirname.to_s\n compress = Kellerkind::Compress.new(:target_path => out,\n :source_path => path,\n :tarball_prefix => path_obj.basename.to_s)\n compress.find_at_source_path = true\n if File.exists?(path)\n Kellerkind::Process.verbose(:start_compressing)\n compress.gzip\n if File.exists?(\"#{path_name}/#{compress.tarball_name}\")\n Kellerkind::Process.verbose(:finished_compressing)\n FileUtils.mv(\"#{path_name}/#{compress.tarball_name}\",\n \"#{out}/#{compress.tarball_name}\")\n FileUtils.rm_rf(path)\n FileUtils.touch(path) if self.recreate\n end\n end\n end\n end",
"def add_files(zip)\n ZipFileGenerator.new(@manifest.base_dir, zip).write\n end",
"def zipSequenceFiles()\n puts \"Zipping sequence files\"\n zipCmd = \"bzip2 *sequence.txt\"\n `#{zipCmd}`\n end",
"def zipSequenceFiles()\n puts \"Zipping sequence files\"\n zipCmd = \"bzip2 *sequence.txt\"\n `#{zipCmd}`\n end",
"def zip(path)\n FileUtils.mkdir_p(path)\n zip_file_path = File.join(path, \"#{self.to_param}.zip\")\n if File.exists?(zip_file_path)\n File.delete(zip_file_path)\n end\n \n # open or create the zip file\n Zip::ZipFile.open(zip_file_path, Zip::ZipFile::CREATE) do |zip_file|\n \n # Add data files\n project_for_zip(zip_file, 'project.js')\n tags_for_zip(zip_file, 'category.js')\n\n app_maps.each do |map|\n map.facts_for_zip(zip_file, \"map_#{map.id}_project.js\")\n map.tags_for_zip(zip_file, \"map_#{map.id}_category.js\")\n end\n \n # Add images\n images_dir = 'images'\n zip_file.mkdir(images_dir) unless zip_file.find_entry(images_dir)\n self.facts.collect do |fact|\n# begin\n zip_file.add(fact.image, fact.photo.path(:thumb)) unless fact.photo_file_name.nil? || zip_file.find_entry(fact.image)\n # rescue => ex\n # # Need a way to output these errors\n # end\n end\n \n end\n File.chmod(0644, zip_file_path)\n zip_file_path\n end",
"def zip(dir, filename)\n Dir.chdir( File.join(options.logdir) ) do\n unless File.exists?(\"#{filename}.zip\")\n Zip::Archive.open(\"#{filename}.zip\", Zip::CREATE) do |ar|\n Dir.glob(\"#{dir}/**/*\").each do |path|\n if File.directory?(path)\n ar.add_dir(path)\n else\n ar.add_file(path, path)\n end\n end\n end\n end\n end\n end",
"def create_zip\n require 'zip'\n zip_files = [self.ground_truth, self.image_sequence, self.config_file]\n if self.acceptable_segmentation_region.present?\n zip_files.push(self.acceptable_segmentation_region)\n end\n zip_filename = Rails.root.join(dir_path, \"#{self.name}.zip\")\n Zip::File.open(zip_filename, Zip::File::CREATE) do |zipfile|\n zip_files.each do |file|\n zipfile.add(file, \"#{dir_path}/#{file}\")\n end\n end\n end",
"def zip_app_export_migrations\n temp_file = Tempfile.new([ZipTempFilePrefix, '.zip'])\n # This is the tricky part\n # Initialize the temp file as a zip file\n Zip::OutputStream.open(temp_file) { |zos| }\n\n # Add files to the zip file as usual\n Zip::File.open(temp_file.path, Zip::File::CREATE) do |zip|\n Dir.glob(\"#{app_export_dir}/*.rb\").each do |path|\n filename = path.split('/').last\n zip.add(filename, path)\n end\n end\n temp_file\n end",
"def compress_done_files(task)\n task_dir = student_work_dir(:done, task, false)\n zip_file = zip_file_path_for_done_task(task)\n return if (zip_file.nil?) || (not Dir.exists? task_dir)\n\n FileUtils.rm(zip_file) if File.exists? zip_file\n\n input_files = Dir.entries(task_dir).select { | f | (f =~ /^\\d{3}\\.(cover|document|code|image)/) == 0 }\n\n Zip::File.open(zip_file, Zip::File::CREATE) do | zip |\n zip.mkdir \"#{task.id}\"\n input_files.each do |in_file|\n zip.add \"#{task.id}/#{in_file}\", \"#{task_dir}#{in_file}\"\n end\n end\n\n FileUtils.rm_rf(task_dir)\n end",
"def zip\n if !FileTest::directory?(\"/mnt/filebox/assets/zipfile_repository\")\n Dir::mkdir(\"/mnt/filebox/assets/zipfile_repository\")\n end\n if self.zipped_file.nil? or !File.file?(self.zipped_file)\n logger.info(\"[ZIP] Creating zipfile for #{self.name}\")\n self.zipped_file = \"/mnt/filebox/assets/zipfile_repository/#{SecureRandom.hex(32)}.zip\"\n self.zipped_at = Time.now\n self.save!\n self._zip\n else\n # Check for modifications and rebuild if newer\n unless self.updated_at >= self.zipped_at\n logger.info(\"[ZIP] Rebuilding zipfile for #{self.name}\")\n self._zip\n end\n end\n \n return self.zipped_file\n end",
"def create_zip( ctx, file:, upload_dir:, archive_dir:, ** ) #File::Twin\n source_files = file.records\n\n zip_file = File.join( archive_dir, \"#{file.identifier}.zip\" )\n\n return false if File.exists?(zip_file)\n\n Zip::File.open(zip_file, Zip::File::CREATE) do |zip|\n source_files.each do |record|\n raise \"error with #{record.inspect}\" unless record.file_path # TODO: remove me\n\n name_in_zip = \"#{record.index}-#{File.basename(record.file_path)}\"\n\n zip.add( name_in_zip, File.join(upload_dir, record.file_path) ) # FIXME: this could break\n end\n end\n\n\n\n ctx[:zip] = zip_file\n end",
"def genDataZip(dir='generated', file_name='OdinSampleDataSet.zip', zip_dir='generated')\n # make sure the target file does not already exist\n # if it does, rename it to a tmp file\n runShellCommand(\"zip -j #{dir}/#{file_name} #{zip_dir}/*.xml #{zip_dir}/*.ctl\")\nend",
"def zip_qrda_files\n file_name = name.gsub(/[^0-9A-Za-z]/, '_')\n FileUtils.mkdir_p(\"public/data/#{user_id}\")\n update_attribute(:file_path, \"data/#{user_id}/#{file_name}.zip\")\n Zip::ZipOutputStream.open('public/' + file_path) do |zip|\n i = 0\n document_ids.shuffle.each do |document_id|\n doc = Document.find(document_id)\n doc.update_attribute(:test_index, i)\n doc.update_attribute(:name, i.to_s.rjust(4, '0') + ' - ' + doc.name)\n zip.put_next_entry(\"#{doc.name}.xml\")\n zip << doc.qrda\n i += 1\n end\n end\n end"
] | [
"0.7580474",
"0.7249701",
"0.69867814",
"0.6880902",
"0.6818721",
"0.66885334",
"0.6682488",
"0.6645554",
"0.6627621",
"0.65886855",
"0.6527539",
"0.65157723",
"0.65040874",
"0.6441311",
"0.6413885",
"0.6413867",
"0.6406123",
"0.6397341",
"0.6334762",
"0.62782717",
"0.62782717",
"0.62457794",
"0.6241073",
"0.6232563",
"0.62305033",
"0.61992747",
"0.61855334",
"0.617238",
"0.6146123",
"0.612683"
] | 0.77902246 | 0 |
Returns the marking state used in the submission and course summary tables for the result(s) for single submission. +has_remark+ is a boolean indicating whether a remark request exists for this submission +result_marking_state+ is one of Result::MARKING_STATES or nil if there are no results for this submission +released_to_students+ is a boolean indicating whether a result has been released to students +collection_date+ is a Time object indicating when the submission was collected | def marking_state(has_remark, result_marking_state, released_to_students, collection_date)
if result_marking_state.present?
return 'remark' if result_marking_state == Result::MARKING_STATES[:incomplete] && has_remark
return 'released' if released_to_students
return result_marking_state
end
return 'not_collected' if collection_date < Time.current
'before_due_date'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marking_started?\n Result.joins(:marks, submission: :grouping)\n .where(groupings: { assessment_id: id },\n submissions: { submission_version_used: true })\n .where.not(marks: { mark: nil })\n .any?\n end",
"def completed_result_marks\n return @completed_result_marks if defined? @completed_result_marks\n\n @completed_result_marks = self.current_results\n .where(marking_state: Result::MARKING_STATES[:complete])\n .order(:total_mark)\n .pluck(:total_mark)\n end",
"def update_marks\n result = self.grouping&.current_submission_used&.get_latest_result\n return page_not_found('No submission exists for that group') if result.nil?\n\n # We shouldn't be able to update marks if marking is already complete.\n if result.marking_state == Result::MARKING_STATES[:complete]\n render 'shared/http_status', locals: { code: '404', message:\n 'Marking for that submission is already completed' }, status: :not_found\n return\n end\n matched_criteria = assignment.criteria.where(name: params.keys)\n if matched_criteria.empty?\n render 'shared/http_status', locals: { code: '404', message:\n 'No criteria were found that match that request.' }, status: :not_found\n return\n end\n\n matched_criteria.each do |crit|\n mark_to_change = result.marks.find_or_initialize_by(criterion_id: crit.id)\n mark_to_change.mark = params[crit.name] == 'nil' ? nil : params[crit.name].to_f\n unless mark_to_change.save\n # Some error occurred (including invalid mark)\n render 'shared/http_status', locals: { code: '500', message:\n mark_to_change.errors.full_messages.first }, status: :internal_server_error\n return\n end\n end\n result.save\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok\n end",
"def get_marks_list(submission)\n criteria.map do |criterion|\n mark = submission.get_latest_result.marks.find_by(criterion: criterion)\n [(mark.nil? || mark.mark.nil?) ? '' : mark.mark,\n criterion.max_mark]\n end\n end",
"def remark_result\n if remark_request_timestamp.nil? || non_pr_results.length < 2\n nil\n else\n non_pr_results.last\n end\n end",
"def released_marks\n submissions.joins(:results).where(results: { released_to_students: true })\n end",
"def update_marking_state\n if has_missing_params?([:marking_state])\n # incomplete/invalid HTTP params\n render 'shared/http_status', locals: { code: '422', message:\n HttpStatusHelper::ERROR_CODE['message']['422'] }, status: :unprocessable_entity\n return\n end\n result = self.grouping&.current_submission_used&.get_latest_result\n return page_not_found('No submission exists for that group') if result.nil?\n result.marking_state = params[:marking_state]\n if result.save\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok\n else\n render 'shared/http_status', locals: { code: '500', message:\n result.errors.full_messages.first }, status: :internal_server_error\n end\n end",
"def get_total_mark\n user_visibility = is_a_review? ? :peer_visible : :ta_visible\n Result.get_total_marks([self.id], user_visibility: user_visibility)[self.id]\n end",
"def marked?(mark)\n @marks.include?(mark)\n end",
"def marked_ready_for_review\n @marked_ready_for_review ||= (ready_for_review? ? 1 : 0)\n end",
"def reset_marking_states(assessment_id)\n Result.joins(submission: :grouping)\n .where('submissions.submission_version_used': true, 'groupings.assessment_id': assessment_id)\n .each do |result|\n result.update(marking_state: Result::MARKING_STATES[:incomplete])\n end\n end",
"def has_remark?\n !remark_result.nil?\n end",
"def markedup\n markedup? ? (@markedup ||= {}) : @markedup_attributes.dup\n end",
"def exam_marks(subject, student)\n exam = exam_data(subject)\n exam_score = exam.scores(student)\n unless exam_score.nil?\n if exam.nil?\n result = 'NA'\n else\n exam_score.nil? ? result = '-' : result = type_result(exam, exam_score)\n end\n result\n end \n end",
"def get_latest_result\n if !submitted_remark.nil?\n remark_result\n else\n get_original_result\n end\n end",
"def marked?\n\t\t\t\t@marked\n\t\t\tend",
"def calculate_marks(academic_record)\n marks = Hash.new\n marks[:sub1] = academic_record.sub1_marks.to_i if academic_record.sub1_marks\n marks[:sub2] = academic_record.sub2_marks.to_i if academic_record.sub2_marks\n marks[:sub3] = academic_record.sub3_marks.to_i if academic_record.sub3_marks\n marks[:sub4] = academic_record.sub4_marks.to_i if academic_record.sub4_marks\n marks[:sub5] = academic_record.sub5_marks.to_i if academic_record.sub5_marks\n marks[:sub6] = academic_record.sub6_marks.to_i if academic_record.sub6_marks\n marks[:sub7] = academic_record.sub7_marks.to_i if academic_record.sub7_marks\n marks[:sub8] = academic_record.sub8_marks.to_i if academic_record.sub8_marks\n marks[:sub9] = academic_record.sub9_marks.to_i if academic_record.sub9_marks\n marks[:sub10] = academic_record.sub10_marks.to_i if academic_record.sub10_marks\n\n marks = marks.sort {|x,y| y[1] <=> x[1]}.to_h\n array_marks = marks.values\n best4_marks = array_marks[0].to_i + array_marks[1].to_i + array_marks[2].to_i + array_marks[3].to_i\n\n calculated_marks = 1000000*best4_marks + 10000*academic_record.hs_marks_percent + 100*academic_record.tenth_marks_percent + academic_record.hs_year_pass-2000\n if academic_record.hs_board.downcase.eql?priority_board\n calculated_marks += priority_marks\n end\n calculated_marks\n end",
"def set_autotest_marks\n test_run = test_runs.first\n return if test_run.nil? || test_run.test_group_results.empty?\n\n result = get_latest_result\n complete_marks = true\n result.create_marks # creates marks for any new criteria that may have just been added\n result.marks.each do |mark|\n test_groups = mark.criterion.test_groups\n if test_groups.empty? # there's at least one manually-assigned mark\n complete_marks = false\n next\n end\n # don't update mark if there is an error\n next if test_run.test_group_results\n .exists?(error_type: TestGroupResult::ERROR_TYPE.slice(:no_results, :test_error).values)\n\n all_marks_earned = 0.0\n all_marks_total = 0.0\n test_groups.each do |test_group|\n res = test_run.test_group_results.find_by(test_group: test_group)\n all_marks_earned += res&.marks_earned || 0.0\n all_marks_total += res&.marks_total || 0.0\n end\n if all_marks_earned == 0 || all_marks_total == 0\n final_mark = 0.0\n elsif all_marks_earned >= all_marks_total\n final_mark = mark.criterion.max_mark\n elsif mark.criterion.is_a? CheckboxCriterion\n final_mark = 0\n else\n final_mark = (all_marks_earned / all_marks_total * mark.criterion.max_mark).round(2)\n if mark.criterion.instance_of? RubricCriterion\n # find the nearest mark associated to a level\n nearest_mark = mark.criterion.level_with_mark_closest_to(final_mark).mark\n final_mark = nearest_mark\n end\n end\n mark.mark = final_mark\n mark.save\n end\n\n # all marks are set by tests, can set the marking state to complete\n if complete_marks\n result.marking_state = Result::MARKING_STATES[:complete]\n result.save\n end\n end",
"def results(marks)\n dict = {'h' => 0, 'a'=> 0, 'l'=> 0}\n\n list = [(marks.sum.to_f / marks.count).round(3)]\n dict['h'] = marks.select { |m| m == 9 || m == 10 }.count\n dict['a'] = marks.select { |m| m == 7 || m == 8 }.count\n dict['l'] = marks.select { |m| m.between?(1,6) }.count\n list << dict\n dict['a'] == 0 && dict['l'] == 0 ? list << \"They did well\" : list\nend",
"def remark_submitted?\n !submitted_remark.nil?\n end",
"def check_marks\n stream = Stream.find(stream_id)\n sub_maps = stream.sub_str_maps.all\n xuser = self.user\n cat = xuser.personal.category\n academic = xuser.academic\n sub_mark = sub_maps.pluck(cat)\n\n user_subs = academic.subject_entries.all\n ok = false\n i = 0\n sub_maps.each do |su|\n ok = false\n user_subs.each do |as|\n if su.subject_id === as.subject_id\n if sub_mark[i] <= as.marks\n ok = true\n end\n end\n end\n unless ok\n errors.add(:stream_id, \"This stream cannot be choosen since you dont have required marks/subject\")\n break\n end\n i += 1\n end\n ok\n end",
"def ungraded_submission_results\n current_submissions_used.joins(:current_result)\n .where('results.marking_state': Result::MARKING_STATES[:incomplete])\n end",
"def github_check\n base_url = \"repos/#{@project.repository_path}/commits/#{@reference}\"\n preview_header = {Accept: 'application/vnd.github.antiope-preview+json'}\n\n check_suites = GITHUB.get(\"#{base_url}/check-suites\", headers: preview_header)[:check_suites]\n checks = GITHUB.get(\"#{base_url}/check-runs\", headers: preview_header)\n\n overall_state = check_suites.\n map { |suite| check_state_equivalent(suite[:conclusion]) }.\n max_by { |state| STATE_PRIORITY.index(state.to_sym) }\n\n statuses = checks[:check_runs].map do |check_run|\n {\n state: check_state_equivalent(check_run[:conclusion]),\n description: ApplicationController.helpers.markdown(check_run[:output][:summary]),\n context: check_run[:name],\n target_url: check_run[:html_url],\n updated_at: check_run[:started_at]\n }\n end\n\n {state: overall_state || 'pending', statuses: statuses}\n end",
"def build_remark(markable)\n if subject_remarks_enabled? and markable.is_a? Subject\n RemarkFactory.build(:reportable => reportable, :student => student, :subject => markable)\n end\n end",
"def remark\n I18n.t(\n \"bets.remarks.#{status}\", match: match.title, market: market_title,\n amount: @amount\n )\n end",
"def status!(as_seen_by)\n if grade_type == NORMAL\n if submission_status == :submitted\n latest_submission.final_score as_seen_by\n else # :not_yet_submitted, :not_submitted\n submission_status\n end\n else # ZEROED, EXCUSED\n AssessmentUserDatum.grade_type_to_sym grade_type\n end\n end",
"def get_marks_in_subject(subject)\n self.subject_mark_mapping.each { |subjectMarkMap|\n if subjectMarkMap.subject && subjectMarkMap.subject.name == subject\n return subjectMarkMap.marks\n end\n }\n return 0;\n end",
"def calculate_marks\n stream = Stream.find(stream_id)\n sub_maps = stream.sub_str_maps.all\n xuser = self.user\n xcategory = xuser.personal.category\n xacademic = xuser.academic\n tenth_mark = xacademic.tenth_marks\n user_subs = xacademic.subject_entries.all\n total_special_sub = sub_maps.count\n total = 0\n user_subs.each do |us|\n total += us.marks\n sub_maps.each do |sm|\n if us.subject_id == sm.subject_id\n total += us.marks\n end\n end\n end\n self.calculated_marks = total*10000 + tenth_mark\n end",
"def scale_marks\n max_mark_was = previous_changes[:max_mark].first\n # results with specific assignment\n results = Result.includes(submission: :grouping)\n .where(groupings: { assessment_id: assessment_id })\n all_marks = marks.where.not(mark: nil).where(result_id: results.ids)\n # all associated marks should have their mark value scaled to the change.\n updated_marks = {}\n all_marks.each do |mark|\n updated_marks[mark.id] = mark.scale_mark(max_mark, max_mark_was, update: false)\n end\n unless updated_marks.empty?\n Mark.upsert_all(all_marks.pluck_to_hash.map { |h| { **h.symbolize_keys, mark: updated_marks[h['id'].to_i] } })\n end\n updated_results = results.map do |result|\n [result.id, result.get_total_mark]\n end.to_h\n unless updated_results.empty?\n Result.upsert_all(\n results.pluck_to_hash.map { |h| { **h.symbolize_keys, total_mark: updated_results[h['id'].to_i] } }\n )\n end\n end",
"def group_by_marks(marks, pass_marks)\n marks.group_by do |k,v| \n v > pass_marks ? \"Passed\" : \"Failed\"\n end\n end"
] | [
"0.6196458",
"0.57900906",
"0.55054015",
"0.5472209",
"0.5287388",
"0.5229246",
"0.5186584",
"0.51033205",
"0.49532717",
"0.48759097",
"0.4866761",
"0.48430914",
"0.47840425",
"0.4767782",
"0.47308603",
"0.47213885",
"0.46793315",
"0.46694344",
"0.4660344",
"0.46467748",
"0.4568441",
"0.45627668",
"0.4556267",
"0.45306715",
"0.44684908",
"0.44260606",
"0.4421194",
"0.44155663",
"0.4407683",
"0.43514803"
] | 0.736618 | 0 |
output_image displays the original image array on the console | def output_image
puts "Original Image"
array.each do |row|
puts row.join
end
puts "\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_image\n @image_array.each do |e|\n puts e.join\n end\n end",
"def output_image\n @image.each do |image|\n puts image.join(' ')\n end\n end",
"def output_image\r\n # loop continues through each Row and outputs content\r\n puts \"Original Image\"\r\n @array.each do |row|\r\n puts row.join\r\n end\r\n end",
"def output_image\n @image_blur_array.each do |row|\n puts row.join\n end\n end",
"def output_image\n @transformed_matrix.each do |element|\n puts element.join\n end\n end",
"def output_image\r\n @image.each do |cell|\r\n puts cell.join\r\n end\r\n end",
"def output_image\r\n # loop continues through each Row and outputs content\r\n @array.each do |row|\r\n puts row.join\r\n end\r\n end",
"def output\r\n\t\t@image.each do |row|\r\n\t\t\trow.each do |pixel|\r\n\t\t\t\tprint pixel\r\n\t\t\tend\r\n\t\t\tputs\r\n\t\tend\r\n\tend",
"def output_image\r\n @icon.each do |data|\r\n puts data.join\r\n end\r\n end",
"def output_image\n @grid.each do |i|\n i.each do |x|\n print \"#{x} \"\n end\n puts\n end\n end",
"def output_image\n @grid.each do |i|\n i.each do |x|\n print \"#{x} \"\n end\n puts\n end\n end",
"def output_image\r\n\t\tif !(@data.empty?)\r\n\t\t\t@data.each do |row| \r\n\t\t\t\tputs row.join(' ')\r\n\t\t\tend\r\n \r\n\t\telse\r\n\t\t\tputs \"No values supplied.\"\r\n\t\tend\r\n\tend",
"def inspect\n img = []\n @images.each { |image| img << image.inspect }\n img = '[' + img.join(\",\\n\") + \"]\\nscene=#{@scene}\"\n end",
"def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pixel\n page.x = j * pixel.columns\n page.y = i * pixel.rows\n pixel.page = page\n progress()\n end\n end\n\n puts 'Writing image, this could take a while...'\n convert.mosaic.write($output)\nend",
"def putImage(theWidth, theHeight, theImage)\n\n\tputs \"Raw Image:\";\n\tputs theImage.join();\n\t\n\t\n\tputs \"\"\n\tputs \"Bitmap Image:\"\n\tn = 0;\n\n\t0.upto(theHeight - 1) do |y|\n\t\t0.upto(theWidth - 1) do |x|\n\t\t\tprint (theImage[n] == 1) ? '#' : ' ';\n\t\t\tn += 1;\n\t\tend\n\t\tputs \"\";\n\tend\n\nend",
"def output_pixel_array(pixel_array)\n pixel_array.each do |line|\n STDOUT.write \"row #{line.map { |chr| '%02X' % chr}.join('')}\\n\"\n end\nend",
"def show\n @pixels.map(&:join).join(\"\\n\")\n end",
"def output\n { images: images, stemcells: [], repository_bases: repository_bases }\n end",
"def show_image(buffer)\n # We need to squish 8 pixels (3 bytes each) into 2 images of 1 byte.\n # (i.e. a black-and-white image of 8 pixels needs to turn from \n # [[0xFF, 0xFF, 0xFF], [0x00, 0x00, 0x00], [0xFF, 0xFF, 0xFF], [0x00, 0x00, 0x00], [0xFF, 0xFF, 0xFF], [0x00, 0x00, 0x00], [0xFF, 0xFF, 0xFF], [0x00, 0x00, 0x00]]\n # to 0b10101010 (one bit per pixel, instead of 3 bytes). \n # Red pixels will be saved off as a separate image.\n black_image, red_image = [], []\n buffer.each_byte.each_slice(3).each_slice(8) do |chunk|\n black_image_chunk = 0\n red_image_chunk = 0\n # for each chunk of 8 pixels, construct a 8-bit number from each of the pixels.\n chunk.each_with_index do |pixel, i|\n # Write from left to right.\n index_to_write = 7 - i\n # if the pixel is white, write a 1 on the black image, and a 0 on the red image\n if pixel.all?(0xff)\n black_image_chunk |= 1 << index_to_write\n red_image_chunk |= 0 << index_to_write\n # if the pixel is black, write a 0 on the black image and the red image\n elsif pixel.all?(0x00)\n black_image_chunk |= 0 << index_to_write\n red_image_chunk |= 0 << index_to_write\n # any other color will be interpreted as red; write a 1 on the black image and the red image\n else\n black_image_chunk |= 1 << index_to_write\n red_image_chunk |= 1 << index_to_write\n end\n end\n black_image << black_image_chunk\n red_image << red_image_chunk\n end\n p \"Shoving #{black_image.length} bytes down the pipe\"\n show_image_buffer(black_image, red_image)\n end",
"def to_image\n @to_image ||= begin\n draw\n renderer.finish\n renderer.image\n end\n end",
"def show\n raise ArgumentError.new(\"There is no image\") if self.data == []\n (0...self.data.row_count).each do |i|\n puts self.data.row(i).to_a.join\n end\n end",
"def to_s\n image.map { |row| \"#{row.join}\\n\" }.join\n end",
"def print\n Catpix::print_image self.img_url,\n :limit_x => 1.0,\n :limit_y => 0,\n :center_x => true,\n :center_y => true,\n :bg => \"white\",\n :bg_fill => true,\n :resolution => \"low\"\n end",
"def write(output_filename)\n Trace::get_logger.info('Image.write') { \"Writing output file...\" }\n \n output_file = ChunkyPNG::Image.new(@width, @height, ChunkyPNG::Color::TRANSPARENT)\n \n @width.times do |x|\n @height.times do |y|\n output_file[x,y] = @pixels[[x,y]].get_color\n end\n end\n \n output_file.save(\"#{output_filename}.png\", :interlace => false)\n end",
"def to_s\n @image.map(&:join).join(\"\\n\")\n end",
"def print_image(image)\n image.each do |row|\n row.each do |cell|\n print cell\n end\n puts\n end\n puts \"-------\"\nend",
"def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end",
"def print_picture(image)\n system \"clear\"\n Catpix::print_image image,\n :limit_x => 0.5,\n :limit_y => 0,\n :center_x => true,\n :center_y => false,\n :bg => \"black\",\n :bg_fill => false,\n :resolution => \"high\"\n end",
"def to_s\n @image.map { |row| row.join }.join(\"\\n\")\n end",
"def convert_to_images(arr,rows,cols)\n canvas = ChunkyPNG::Canvas.new(28, 28, ChunkyPNG::Color::TRANSPARENT)\n canvas.grayscale!\n \n for i in 0..arr.length-1 do\n for j in 0..rows-1 do\n for k in 0..cols-1 do\n canvas[j,k] = arr[i][((cols+1)*j)+k]\n end\n end\n canvas.save(\"F:\\\\Projects\\\\YetAnotherAnn\\\\filename#{i}.png\", :interlace => true)\n end\nend"
] | [
"0.8743838",
"0.8411666",
"0.83464825",
"0.8229349",
"0.8193728",
"0.8159136",
"0.7911556",
"0.7807944",
"0.7544636",
"0.74437386",
"0.74437386",
"0.7297534",
"0.6746136",
"0.6692161",
"0.647412",
"0.6412234",
"0.63871527",
"0.6357325",
"0.6318918",
"0.63045055",
"0.62975824",
"0.6286761",
"0.6285845",
"0.6256469",
"0.62456673",
"0.6243513",
"0.6207688",
"0.61730295",
"0.6170962",
"0.6137329"
] | 0.8688341 | 1 |
return short url append by host | def short_url
"#{HOST_URL}/#{short_code}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short(host,port)\n Rails.application.routes.url_helpers.short_url(slug: self.slug,host: host, port: port)\n end",
"def build_url(host)\n host.protocol + host.url\n end",
"def small_url(host=Smurl.host)\n custom_url = CustomUrl.last(smurl_id: id)\n link = custom_url.link if custom_url\n path = link || SmallUrl.encode62(id)\n\n relative = '/' + path\n if host\n host + relative\n else \n relative\n end\n end",
"def short_url\n @short_url ||= client.shorten(long_url: url).link\n rescue => e\n Rails.logger.warn(\"Could not shorten bit.ly url #{e.message}\")\n url\n end",
"def full_shortened_url(base)\n base + '/' + short_url\n end",
"def short_url\n return nil if url.nil?\n url.gsub(\"http://\",\"\").gsub(\"www.\", \"\")\n end",
"def short\n Rails.application.routes.url_helpers.short_url(short_url: self.short_url)\n end",
"def host\n \"#{@url.scheme}://#{@url.host}\"\n end",
"def full_url\n if website.match(/[A-Za-z]:\\/\\//)\n website\n else\n \"http://#{website}\"\n end\n end",
"def generate_short_url\n url = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond).to_s(36)\n old_url = Link.where(short_url: url).last\n if old_url.present? \n self.generate_short_url\n else\n self.short_url = url\n end\n end",
"def full_url\n full_domain(:with_protocol => true)\n end",
"def full_url\n full_domain(:with_protocol => true)\n end",
"def nice_url\n if homepage\n if Addressable::URI.parse(homepage)\n Addressable::URI.parse(homepage).host\n else\n homepage.first(15)\n end\n else\n \"\"\n end\n end",
"def nice_url\n if homepage\n if Addressable::URI.parse(homepage)\n Addressable::URI.parse(homepage).host\n else\n homepage.first(15)\n end\n else\n \"\"\n end\n end",
"def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end",
"def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end",
"def friendly_url\n uri = URI(url)\n uri.scheme + \"://\" + uri.host\n end",
"def to_param\n short_url\n end",
"def to_param\n short_url\n end",
"def full_url display_url\n if display_url.blank?\n return nil\n end\n return (display_url[0..6] == \"http://\" or display_url[0..7] == \"https://\") ? display_url : \"http://#{display_url}\"\n end",
"def fullurl\n if Rails.env == 'development'\n 'http://localhost:3000' + object.url.to_s\n else\n 'http://signlab-rails.herokuapp.com' + object.url.to_s\n end\n end",
"def get_short_url(link)\n client = Bitly.client\n shortened_url = client.shorten(link)\n return shortened_url.short_url \n end",
"def create_short_url(url_params) \n url = Url.new(url_params)\n url.suffix= url.create_suffix(url_params[:longurl],0)\n while url.unique(url.suffix) == false\n url.suffix = url.create_suffix(url_params[:longurl],1)\n end\n domain = Domainatrix.parse(url_params[:longurl]).domain + '.' + Domainatrix.parse(url_params[:longurl]).public_suffix\n short_domain = ShortDomain.where(domain: domain).first[:prefix]\n url.shorturl = \"http://\" + short_domain +'/'+ url.suffix\n if url.save\n return url\n else\n return nil\n end\n end",
"def full_url(path, params={})\n url = \"#{host[:protocol]}://\"\n url += \"#{host[:user]}:#{host[:password]}@\" if host[:user]\n url += \"#{host[:host]}:#{host[:port]}\"\n url += \"#{host[:path]}\" if host[:path]\n url += \"/#{full_path(path, params)}\"\n end",
"def short_link\n UrlShort::IsGd.shorten @link\n end",
"def url_shortener(full_uri)\n mapper = UrlMapper.find_by_original_url(full_uri)\n \n if mapper\n string = mapper.short_url\n else\n string = \"/\"\n 5.times { string << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }\n begin\n UrlMapper.create!({:short_url => string, :original_url => full_uri})\n rescue\n end\n end\n \"#{APP_CONFIG['url_shortener']}#{string}\"\n end",
"def full_url(input)\n expand_url(input, site_url)\n end",
"def short\n alexa_rank = alexa_rank params[:url]\n host = get_domain params[:url]\n host = host.split \".\"\n domain = host.count >= 3 ? host[host.count - 3] : host[host.count - 2]\n @url = @user.url.create url: params[:url], alexa_rank: alexa_rank, domain: domain\n @url.save!\n render json: {url_short: @url.url_short}\n end",
"def scheme_with_host(domain=nil)\n ['http://', domain || self.name, '/'].join(\"\")\n end",
"def host_url\n proto = request.env['SERVER_PROTOCOL'].downcase.index(\"https\").nil? ? \"http\" : \"https\"\n return \"#{proto}://#{request.env['HTTP_HOST']}\"\n end"
] | [
"0.80925566",
"0.7928922",
"0.76821166",
"0.7560309",
"0.7550189",
"0.75313836",
"0.7279538",
"0.71979976",
"0.7113133",
"0.70219237",
"0.69709235",
"0.69709235",
"0.6969316",
"0.6969316",
"0.6963016",
"0.6963016",
"0.69367605",
"0.69334364",
"0.69334364",
"0.6926783",
"0.6918369",
"0.6906842",
"0.6903463",
"0.6889874",
"0.6878069",
"0.68697304",
"0.68626434",
"0.6841645",
"0.6816349",
"0.6802883"
] | 0.8159383 | 0 |