query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
This test when found 9 rubies | def test_mood4
assert_equal @p.mood?([9, 0]), 'sad.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_rubies\n @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.3 ]\n end",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def sample_mri_rubies\n @sample_mri_rubies ||= %w[ ruby-3.2 ruby-2.7 ]\n end",
"def test_rubies_found_positive\n prospector = Rubyist.new(1)\n prospector.rubies_found(2, 2)\n assert prospector.real_ruby_count == 2 && prospector.fake_ruby_count == 2\n end",
"def supported_rubies\n @supported_rubies ||= supported_mri_rubies + jrubies\n end",
"def test_rubies_found_negative\n prospector = Rubyist.new(1)\n prospector.rubies_found(-2, -2)\n assert prospector.real_ruby_count.zero? && prospector.fake_ruby_count.zero?\n end",
"def jrubies\n @jrubies ||= %w[ jruby-9.3 jruby-9.2 ]\n end",
"def supported_mri_rubies\n @supported_mri_rubies ||= %w[\n ruby-3.2 ruby-3.1 ruby-3.0\n ruby-2.7 ruby-2.6 ruby-2.5\n ]\n end",
"def older_rubies\n @older_rubies ||= %w[ ruby-3.0 ruby-2.7 ruby-2.6 ruby-2.5 ]\n end",
"def recent_rubies\n @recent_rubies ||= %w[ ruby-3.2 ruby-3.1 jruby-9.3 ]\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def test_harness_dependencies(*)\n return unless platform[/n(5|6)k/]\n skip_if_nv_overlay_rejected(agent)\n\n # Vxlan has a hard requirement to disable feature fabricpath on n5/6k\n cmd = 'no feature-set fabricpath'\n command_config(agent, cmd, cmd)\nend",
"def test_three_rubies_test\r\n rubyArr = [3,3]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2 || numReturn == 3\r\n assert true\r\n end\r\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def testBasicBinaryWithRubyInTerminal\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/windows\\/bin$/,\n :Cmd => /^allinoneruby\\.bat ruby-#{RUBY_VERSION}\\.exe$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> ruby -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_real_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.real_rubies_found(7)\n\t\tassert test_main.num_real_rubies, 14\n\tend",
"def test_two_rubies_test\r\n rubyArr = [2,2]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2\r\n assert true\r\n end\r\n end",
"def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> ruby -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_Browser_001_is_browser_installed()\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_001_is_browser_installed\")\n puts2(\"#######################\")\n\n puts2(\"\\n\\nTest - is_chrome64_installed?()\")\n puts2(\"is_chrome64_installed? = \" + is_chrome64_installed?().to_s)\n\n puts2(\"\\n\\nTest - is_firefox64_installed?()\")\n puts2(\"is_firefox64_installed? = \" + is_firefox64_installed?().to_s)\n\n end",
"def test_version\n assert_match(/^Ocra \\d+(\\.\\d)+$/, `ruby #{ocra} --version`)\n end",
"def testCommandLineVersion\n executeSlave( [ '--version' ] )\n end",
"def testNominalWithSeveralRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithSeveralRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.txt\"), 'txt', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_Enviroment_002_isPlatform\r\n\r\n puts2(\"\")\r\n puts2(\"#######################\")\r\n puts2(\"Testcase: test_Enviroment_002_isPlatform\")\r\n puts2(\"#######################\")\r\n\r\n puts2(\"Running Ruby for Windows: \" + is_win?.to_s)\r\n puts2(\"Running Ruby for Windows 32-bit: \" + is_win32?.to_s)\r\n puts2(\"Running Ruby for Windows 64 bit: \" + is_win64?.to_s)\r\n puts2(\"Running Ruby for Linux: \" + is_linux?.to_s)\r\n puts2(\"Running Ruby for OS/X: \" + is_osx?.to_s)\r\n puts2(\"Running on JRuby: \" + is_java?.to_s)\r\n\r\n end",
"def test_find_rubies_nonzero\r\n\t\tassert_includes [email protected]_rubies, @t.find_rubies\r\n\tend",
"def testNominalWithSeveralPlatforms\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndWindows ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/Windows/Inst/Install.exe\"), 'Windows', 'Inst', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_platforms\n {\n 'suse' => %w( 12.2 )\n }.each do |platform, versions|\n versions.each do |version|\n yield(platform, version)\n end\n end\nend",
"def testBasicBinaryWithRubyInTerminal\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/linux\\/bin$/,\n :Cmd => /^allinoneruby ruby\\-#{RUBY_VERSION}\\.bin$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def test_ruby_string_big\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(2).eql? '2 rubies'\n end",
"def test_find_fake_rubies_zero\r\n\t\tassert_equal 0, @t2.find_fake_rubies\r\n\tend",
"def test_platform_uses_unknown_if_uname_fails\n NewRelic::Helper.stubs('run_command').with('uname -s').raises(NewRelic::CommandRunFailedError)\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal 'unknown', platform\n end\n end",
"def test_add_to_rubies\n pros = Prospector.new(0,0,0)\n pros.add_to_rubies([1,1])\n assert pros.real == 1 && pros.fake == 1\n end",
"def find_fake_rubies\r\n # Add 1 to max_fake_rubies to make maximum inclusive\r\n @random.rand(@max_fake_rubies + 1)\r\n end",
"def test_find_fake_rubies_nonzero\r\n\t\tassert_includes [email protected]_fake_rubies, @t.find_fake_rubies\r\n\tend",
"def testBasicBinaryWithRuby\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/windows\\/bin$/,\n :Cmd => /^allinoneruby\\.bat --rubyw rubyw-#{RUBY_VERSION}\\.exe$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> start rubyw -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_find_rubies_zero\r\n\t\tassert_equal 0, @t2.find_rubies\r\n\tend",
"def testNominalWithRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def detect_cpu_cores_nix\n # On Unix platforms trying to use etc module to determine accessible\n # number of cores\n require 'etc'\n Etc.nprocessors\n end",
"def testBasicBinary\n execTest('Applications/Basic', [], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> start rubyw -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_bad_jruby_deps\n check_deps_fail BadJRubyBall unless `/usr/bin/which jruby`.chomp.empty?\n end",
"def test_platform_uses_uname_for_jruby\n stubbed = 'MCP'\n NewRelic::Helper.stubs('run_command').with('uname -s').returns(stubbed)\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal platform, stubbed.downcase\n end\n end",
"def find_rubies\r\n # Add 1 to max_rubies to make maximum inclusive\r\n @random.rand(@max_rubies + 1)\r\n end",
"def testCommandLineVersionShort\n executeSlave( [ '-v' ] )\n end",
"def platform(name)\n case ENV['PLATFORM']\n when 'windows_10_edge'\n {selenium_version: '3.141.59',\n platform_name: 'Windows 10',\n browser_name: 'edge',\n browser_version: '18.17763'}.merge(sauce_w3c(name))\n when 'windows_8_ie'\n # Note: w3c is not working for Windows 8 & IE 11\n {platform: 'Windows 8.1',\n browser_name: 'ie',\n selenium_version: '3.141.59',\n version: '11.0'}.merge(sauce_oss(name))\n when 'mac_sierra_chrome'\n # This is for running with w3c which is not yet the default\n # {platform_name: 'macOS 10.12',\n # browser_name: 'chrome',\n # \"goog:chromeOptions\": {w3c: true},\n # browser_version: '65.0'}.merge(sauce_w3c name)\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n when 'mac_mojave_safari'\n {platform_name: 'macOS 10.14',\n browser_name: 'safari',\n browser_version: '12.0'}.merge(sauce_w3c(name))\n when 'windows_7_ff'\n {platform_name: 'Windows 7',\n browser_name: 'firefox',\n browser_version: '60.0'}.merge(sauce_w3c(name))\n else\n # Always specify a default\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n end\n end",
"def test_hardware_cpu_type\n assert [:intel, :ppc].include?(Hardware.cpu_type)\n end",
"def test_json_max_rubies\n load_location_setup\n assert_equal 5, @json_location.max_rubies\n end",
"def test_ruby_count_zeros\n pros = Prospector.new(0,0,0)\n assert pros.ruby_count.eql? \"After 0 days, Rubyist #0 found:\\n\\t0 rubies.\\n\\t0 fake rubies.\\n\"\n end",
"def test_display_two\r\n assert_output(\"After 2 days, Rubyist #2 found:\\n\\t2 rubies.\\n\\t2 fake rubies.\\n\") { @g.display_rubies(2, 2, 2, 2) }\r\n end",
"def testBasicBinaryWithRuby\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/linux\\/bin$/,\n :Cmd => /^allinoneruby ruby\\-#{RUBY_VERSION}\\.bin$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def custom_runner?\n Gem::Version.new(MiniTest::Unit::VERSION) >= Gem::Version.new('2.1.0')\n end",
"def test_vers_class_run_variant\n assert_equal 0, run_with_args(%w(-v))\n assert_match(/Ruby BlackBag version #{Rbkb::VERSION}/, @stdout_io.string)\n end",
"def test_json_max_fake_rubies\n load_location_setup\n assert_equal 10, @json_location.max_fake_rubies\n end",
"def test_display_one\r\n assert_output(\"After 2 days, Rubyist #1 found:\\n\\t1 ruby.\\n\\t1 fake ruby.\\n\") { @g.display_rubies(1, 1, 1, 2) }\r\n end",
"def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb') do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def testMissingSlave\n executeProcess(\n [\n '--masterticket', '123'\n ],\n :Error => WEACE::MissingVariableError\n )\n end",
"def test_found_no_rubies\n\t\tp = Print.new\n\t\tassert_output(\"\\tFound no rubies or fake rubies in Town.\\n\") {p.print_day([0,0],'Town')}\n\tend",
"def fails_on_jruby\n before do\n unless SpecConfig.instance.mri?\n skip \"Fails on jruby\"\n end\n end\n end",
"def fails_on_jruby\n before do\n unless SpecConfig.instance.mri?\n skip \"Fails on jruby\"\n end\n end\n end",
"def test_platform_uses_ruby_platform\n stubbed = 'ENCOM OS-12'\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, stubbed) do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal platform, stubbed.downcase\n end\n end",
"def test_provided_example\n assert_equal \"tknk\", @system.base.name\n end",
"def test_random_rubies\n loc1 = Location.new(\"location 1\", 10, 1000)\n res = loc1.random_rubies\n assert res >= 0 && res <= 10\n end",
"def rvm_installed?\n cmd_test %{-s \"/usr/local/lib/rvm\"}\nend",
"def rackspace_cloudbackup_test_platforms\n return {\n ubuntu: %w(12.04),\n debian: %w(7.2), # Requires Fauxhai chicanery as https://github.com/customink/fauxhai/pull/60\n # hasn't made its way to RubyGems yet.\n centos: %w(6.4 6.5)\n }\nend",
"def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end",
"def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end",
"def test_binary_rpaths\n # Find all the binaries.\n bins = Dir.glob(File.join($config[\"_embedded_root_dir\"], \"bin/**/*\"))\n bins += Dir.glob(File.join($config[\"_embedded_root_dir\"], \"sbin/**/*\"))\n bins += Dir.glob(File.join($config[\"_embedded_root_dir\"], \"lib/**/*.so\"))\n bins += Dir.glob(File.join($config[\"_embedded_root_dir\"], \"libexec/**/*.so\"))\n bins += Dir.glob(File.join($config[\"_embedded_root_dir\"], \"/apps/core/shared/vendor/**/*.so\"))\n bins.map! { |path| File.realpath(path) }\n bins.select! { |path| File.file?(path) }\n bins.reject! { |path| `file #{path}` =~ /(text executable|ASCII)/ }\n\n # Spot check to ensure our list of binaries actually includes things we\n # expect.\n assert_operator(bins.length, :>, 0)\n [\n \"/embedded/bin/ruby\",\n \"/embedded/sbin/rsyslogd\",\n \"/embedded/openresty/nginx/sbin/nginx\",\n \"/embedded/libexec/trafficserver/header_rewrite.so\",\n # LuaRock\n \"/embedded/apps/core/shared/vendor/lua/lib/lua/5.1/yaml.so\",\n # Rubygem\n \"/oj/oj.so\",\n ].each do |expected_path_end|\n assert(bins.find { |path| path.end_with?(expected_path_end) }, \"Expected #{bins.inspect} to include #{expected_path_end.inspect}\")\n end\n\n # Ensure each binary file has no rpath or runpath setting.\n bins.each do |path|\n output, _status = run_shell(\"chrpath\", \"-l\", path)\n assert_match(\"no rpath or runpath tag found\", output)\n end\n end",
"def install_ruby_dependencies(rubie)\n pkgs = []\n case rubie\n when /^ruby-/, /^ree-/, /^rbx-/, /^kiji/\n case node['platform']\n when \"debian\",\"ubuntu\"\n pkgs = %w{ build-essential openssl libreadline6 libreadline6-dev\n zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev\n sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev\n ncurses-dev automake libtool bison ssl-cert }\n pkgs += %w{ subversion } if rubie =~ /^ruby-head$/\n when \"suse\"\n pkgs = %w{ gcc-c++ patch zlib zlib-devel libffi-devel\n sqlite3-devel libxml2-devel libxslt-devel }\n if node['platform_version'].to_f >= 11.0\n pkgs += %w{ libreadline5 readline-devel libopenssl-devel }\n else\n pkgs += %w{ readline readline-devel openssl-devel }\n end\n pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/\n when \"centos\",\"redhat\",\"fedora\",\"scientific\",\"amazon\"\n pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel\n libyaml-devel libffi-devel openssl-devel }\n pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/\n end\n when /^jruby-/\n # TODO: need to figure out how to pull in java recipe only when needed. For\n # now, users of jruby will have to add the \"java\" recipe to their run_list.\n #include_recipe \"java\"\n case node['platform']\n when \"debian\",\"ubuntu\"\n pkgs += %w{ g++ ant }\n end\n end\n\n pkgs.each do |pkg|\n package pkg do\n action :nothing\n end.run_action(:install)\n end\nend",
"def validate_release \n if !system(\"origen examples\") #|| !system(\"origen specs\") \n puts \"Sorry but you can't release with failing tests, please fix them and try again.\" \n exit 1 \n else \n puts \"All tests passing, proceeding with release process!\" \n end \n end",
"def test_display_negative_rubyist\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 0, 2) }\r\n end",
"def test_version\n assert Snarl.version >= '1.1'\n end",
"def rubinius?(platform = T.unsafe(nil)); end",
"def yosemite_or_newer?\n Gem::Version.new(`sw_vers -productVersion`) >= Gem::Version.new('10.10')\nend",
"def running_jruby_1_7_or_later\n RUBY_PLATFORM == 'java' && !JRUBY_VERSION.match(/[0-1]\\.[0-6]/)\nend",
"def test_standard_to_rubygems_inequality_comparison\n assert_operator(::Versionomy.parse('1.2.4'), :>, ::Versionomy.parse('1.2.3', :rubygems))\n assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2.beta.3', :rubygems))\n assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2', :rubygems))\n end",
"def testMissingMaster\n executeProcess(\n [\n '--slaveticket', '456'\n ],\n :Error => WEACE::MissingVariableError\n )\n end",
"def testSlaveProductWithoutAs\n executeInstall(['--install', 'SlaveProduct', '--product', 'DummyProduct'],\n :Repository => 'Dummy/SlaveClientInstalled',\n :AddRegressionSlaveAdapters => true,\n :Error => WEACEInstall::CommandLineError\n ) do |iError|\n assert_equal(nil, $Variables[:ComponentInstall])\n end\n end",
"def test_bad_chicken_deps\n check_deps_fail BadChickenBall unless `/usr/bin/which csc`.chomp.empty?\n end",
"def test_bad_node_deps\n check_deps_fail BadNodeBall unless `/usr/bin/which node`.chomp.empty?\n end",
"def ensure_r10k_didnt_run(up_result, workdir)\n expect(up_result.stdout).to_not include(\"vagrant-r10k: Beginning r10k deploy of puppet modules\")\n expect(up_result.stdout).to_not include('vagrant-r10k: Deploy finished')\n\n # file tests\n expect(File).to_not exist(\"#{workdir}/puppet/modules/reviewboard/Modulefile\")\n expect(File).to_not exist(\"#{workdir}/puppet/modules/nodemeister/Modulefile\")\n expect(File).to_not exist(\"#{workdir}/puppet/modules/nodemeister/manifests/init.pp\")\n end",
"def supported_pkgs\n {\"rpm\"=>1, \"deb\"=>1}\nend",
"def chef_installed?\n cmd_if %{rvm use #{ruby} >/dev/null && gem list --no-versions | grep -q \"^chef$\" >/dev/null}, true\nend",
"def test_versions\n tidy = TidyExe.new\n assert_not_nil(tidy.version, 'version returned nil.')\n assert_not_nil(tidy.version_major, 'version_major returned nil.')\n assert_not_nil(tidy.version_minor, 'version_minor returned nil.')\n assert_not_nil(tidy.version_patch, 'version_patch returned nil.')\n assert_not_nil(tidy.version_plain, 'version_plain returned nil.')\n end",
"def testNominalWithRegression\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '--regressioncmd', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def distro_ruby_versions\n case distribution_class\n when :ubuntu\n if is_distribution?(\"<= artful\")\n [\"2.3\"]\n elsif is_distribution?(\"<= eoan\")\n [\"2.5\"]\n elsif is_distribution?(\"<= impish\")\n [\"2.7\"]\n elsif is_distribution?(\"<= kinetic\")\n [\"3.0\"]\n else\n [\"3.1\"]\n end\n when :debian\n if is_distribution?(\"<= jessie\")\n [\"2.1\"]\n elsif is_distribution?(\"<= stretch\")\n [\"2.3\"]\n elsif is_distribution?(\"<= buster\")\n [\"2.5\"]\n elsif is_distribution?(\"<= bullseye\")\n [\"2.7\"]\n else\n [\"3.1\"]\n end\n else\n raise \"Unknown distribution class\"\n end\nend",
"def check_compatibility\n linux = '0'\n windows = '0'\n mac = '0'\n\n versions.each do |v|\n compat = v.check_compat\n linux = v.check_linux(compat)\n windows = v.check_windows(compat)\n mac = v.check_mac(compat)\n end\n\n compatibility = linux + windows + mac\n update compatibility: compatibility\n end",
"def is_yum_platform\n node[:platform_family] == \"rhel\"\nend",
"def testNominalWithSeveralTypes\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndOther ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Other/DummyOtherFile\"), 'All', 'Other', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_display_negative_iterations\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 1, 0) }\r\n end",
"def required_ruby_version\n spec.required_ruby_version\n end",
"def test_random_fake_rubies\n loc1 = Location.new(\"location 1\", 1000, 10)\n res = loc1.random_fake_rubies\n assert res >= 0 && res <= 10\n end",
"def testBasicBinary\n execTest('Applications/Basic', [], 'ReleaseInfo_Exe.rb') do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def test_current_browsers_detected\n for browser in CURRENT_BROWSERS\n @request.user_agent = browser\n assert ! @page.legacy_browser?\n end\n end",
"def test_rubygems_to_standard_inequality_comparison\n assert_operator(::Versionomy.parse('1.2.3', :rubygems), :<, ::Versionomy.parse('1.2.4'))\n assert_operator(::Versionomy.parse('1.2.b.3', :rubygems), :>, ::Versionomy.parse('1.2b2'))\n assert_operator(::Versionomy.parse('1.2', :rubygems), :>, ::Versionomy.parse('1.2b1'))\n end",
"def testSlaveProductWithoutAsArg\n executeInstall(['--install', 'SlaveProduct', '--product', 'DummyProduct', '--as'],\n :Repository => 'Dummy/SlaveClientInstalled',\n :AddRegressionSlaveAdapters => true,\n :Error => OptionParser::MissingArgument\n ) do |iError|\n assert_equal(nil, $Variables[:ComponentInstall])\n end\n end",
"def version_specified_gem?(node); end",
"def rhel6x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version >= 6 && major_version < 7\n end",
"def ruby_1_9?\n @ruby_1_9 ||= RUBY_VERSION < '2.0.0'\n end",
"def rhel8?(node = __getnode)\n node[\"platform_family\"] == \"rhel\" && node[\"platform_version\"].to_f >= 8.0 && node[\"platform_version\"].to_f < 9.0\n end",
"def maglev_using_rvm\n ENV['rvm_path'] != \"\" && (/^maglev/ =~ ENV['rvm_ruby_string']) == 0\nend",
"def maglev_using_rvm\n ENV['rvm_path'] != \"\" && (/^maglev/ =~ ENV['rvm_ruby_string']) == 0\nend",
"def testNominalWithRegressionFailed\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => failure\n [ 1, '' ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '--regressioncmd', 'test/runReg'\n ],\n :Error => WEACE::Master::Server::Processes::Dev_Release::RegressionError\n )\n end\n end"
] | [
"0.6857168",
"0.67097574",
"0.66240954",
"0.65992486",
"0.65953755",
"0.64571726",
"0.63883245",
"0.6254133",
"0.62039113",
"0.6201605",
"0.6195706",
"0.6161385",
"0.6081036",
"0.60472536",
"0.60472536",
"0.6003172",
"0.5975586",
"0.5961504",
"0.5864507",
"0.5860492",
"0.58475554",
"0.5841598",
"0.5838164",
"0.58373445",
"0.5820626",
"0.58121675",
"0.57970935",
"0.5788197",
"0.5787244",
"0.5785935",
"0.5776124",
"0.5767133",
"0.57527906",
"0.574545",
"0.5727663",
"0.571752",
"0.5709532",
"0.56940496",
"0.56896013",
"0.5683835",
"0.5670304",
"0.5654719",
"0.5643874",
"0.55900544",
"0.55831015",
"0.5574352",
"0.5571697",
"0.5564944",
"0.5542798",
"0.5539121",
"0.55268586",
"0.5509588",
"0.5499014",
"0.5496381",
"0.54914975",
"0.5478063",
"0.5471045",
"0.5471045",
"0.5450982",
"0.5437798",
"0.5429292",
"0.541365",
"0.5413638",
"0.5409935",
"0.5409935",
"0.54098666",
"0.5406616",
"0.54019576",
"0.54008394",
"0.53770083",
"0.53649664",
"0.53520244",
"0.5350883",
"0.53487194",
"0.5346425",
"0.5346217",
"0.5345412",
"0.53385514",
"0.5331107",
"0.5329462",
"0.53220356",
"0.531277",
"0.5311843",
"0.53082657",
"0.5300609",
"0.5298549",
"0.5298491",
"0.52948666",
"0.5288248",
"0.5287587",
"0.5285504",
"0.5283789",
"0.52723503",
"0.5271503",
"0.52687025",
"0.5260825",
"0.52586377",
"0.525764",
"0.5254148",
"0.5254148",
"0.5241155"
] | 0.0 | -1 |
This test when found 10 rubies | def test_mood5
assert_equal @p.mood?([10, 0]), 'victorious!'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_rubies\n @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.3 ]\n end",
"def test_rubies_found_positive\n prospector = Rubyist.new(1)\n prospector.rubies_found(2, 2)\n assert prospector.real_ruby_count == 2 && prospector.fake_ruby_count == 2\n end",
"def sample_mri_rubies\n @sample_mri_rubies ||= %w[ ruby-3.2 ruby-2.7 ]\n end",
"def test_rubies_found_negative\n prospector = Rubyist.new(1)\n prospector.rubies_found(-2, -2)\n assert prospector.real_ruby_count.zero? && prospector.fake_ruby_count.zero?\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def supported_rubies\n @supported_rubies ||= supported_mri_rubies + jrubies\n end",
"def test_real_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.real_rubies_found(7)\n\t\tassert test_main.num_real_rubies, 14\n\tend",
"def test_find_rubies_nonzero\r\n\t\tassert_includes [email protected]_rubies, @t.find_rubies\r\n\tend",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def older_rubies\n @older_rubies ||= %w[ ruby-3.0 ruby-2.7 ruby-2.6 ruby-2.5 ]\n end",
"def recent_rubies\n @recent_rubies ||= %w[ ruby-3.2 ruby-3.1 jruby-9.3 ]\n end",
"def find_rubies\r\n # Add 1 to max_rubies to make maximum inclusive\r\n @random.rand(@max_rubies + 1)\r\n end",
"def test_three_rubies_test\r\n rubyArr = [3,3]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2 || numReturn == 3\r\n assert true\r\n end\r\n end",
"def test_find_fake_rubies_nonzero\r\n\t\tassert_includes [email protected]_fake_rubies, @t.find_fake_rubies\r\n\tend",
"def jrubies\n @jrubies ||= %w[ jruby-9.3 jruby-9.2 ]\n end",
"def find_fake_rubies\r\n # Add 1 to max_fake_rubies to make maximum inclusive\r\n @random.rand(@max_fake_rubies + 1)\r\n end",
"def supported_mri_rubies\n @supported_mri_rubies ||= %w[\n ruby-3.2 ruby-3.1 ruby-3.0\n ruby-2.7 ruby-2.6 ruby-2.5\n ]\n end",
"def test_two_rubies_test\r\n rubyArr = [2,2]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2\r\n assert true\r\n end\r\n end",
"def test_json_max_rubies\n load_location_setup\n assert_equal 5, @json_location.max_rubies\n end",
"def test_display_two\r\n assert_output(\"After 2 days, Rubyist #2 found:\\n\\t2 rubies.\\n\\t2 fake rubies.\\n\") { @g.display_rubies(2, 2, 2, 2) }\r\n end",
"def detect_cpu_cores_nix\n # On Unix platforms trying to use etc module to determine accessible\n # number of cores\n require 'etc'\n Etc.nprocessors\n end",
"def test_add_to_rubies\n pros = Prospector.new(0,0,0)\n pros.add_to_rubies([1,1])\n assert pros.real == 1 && pros.fake == 1\n end",
"def test_harness_dependencies(*)\n return unless platform[/n(5|6)k/]\n skip_if_nv_overlay_rejected(agent)\n\n # Vxlan has a hard requirement to disable feature fabricpath on n5/6k\n cmd = 'no feature-set fabricpath'\n command_config(agent, cmd, cmd)\nend",
"def test_find_rubies_zero\r\n\t\tassert_equal 0, @t2.find_rubies\r\n\tend",
"def test_ruby_string_big\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(2).eql? '2 rubies'\n end",
"def test_random_rubies\n loc1 = Location.new(\"location 1\", 10, 1000)\n res = loc1.random_rubies\n assert res >= 0 && res <= 10\n end",
"def test_find_fake_rubies_zero\r\n\t\tassert_equal 0, @t2.find_fake_rubies\r\n\tend",
"def test_ruby_count_zeros\n pros = Prospector.new(0,0,0)\n assert pros.ruby_count.eql? \"After 0 days, Rubyist #0 found:\\n\\t0 rubies.\\n\\t0 fake rubies.\\n\"\n end",
"def test_json_max_fake_rubies\n load_location_setup\n assert_equal 10, @json_location.max_fake_rubies\n end",
"def testBasicBinaryWithRubyInTerminal\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/windows\\/bin$/,\n :Cmd => /^allinoneruby\\.bat ruby-#{RUBY_VERSION}\\.exe$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> ruby -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_new_location_rubies\n assert_equal 5, @loc1.max_rubies\n end",
"def testNominalWithSeveralRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithSeveralRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.txt\"), 'txt', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_display_one\r\n assert_output(\"After 2 days, Rubyist #1 found:\\n\\t1 ruby.\\n\\t1 fake ruby.\\n\") { @g.display_rubies(1, 1, 1, 2) }\r\n end",
"def test_found_no_rubies\n\t\tp = Print.new\n\t\tassert_output(\"\\tFound no rubies or fake rubies in Town.\\n\") {p.print_day([0,0],'Town')}\n\tend",
"def testCommandLineVersion\n executeSlave( [ '--version' ] )\n end",
"def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> ruby -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_random_fake_rubies\n loc1 = Location.new(\"location 1\", 1000, 10)\n res = loc1.random_fake_rubies\n assert res >= 0 && res <= 10\n end",
"def os_cpu_cores\n case RbConfig::CONFIG['host_os']\n when /darwin/\n Integer(`sysctl -n hw.ncpu`)\n when /linux/\n Integer(`cat /proc/cpuinfo | grep processor | wc -l`)\n else\n raise StandardError, \"Unsupported platform\"\n end\nend",
"def testBasicBinaryWithRubyInTerminal\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/linux\\/bin$/,\n :Cmd => /^allinoneruby ruby\\-#{RUBY_VERSION}\\.bin$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def testNominalWithSeveralPlatforms\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndWindows ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/Windows/Inst/Install.exe\"), 'Windows', 'Inst', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_new_location_fake_rubies\n assert_equal 10, @loc1.max_fake_rubies\n end",
"def testNominalWithRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_platforms\n {\n 'suse' => %w( 12.2 )\n }.each do |platform, versions|\n versions.each do |version|\n yield(platform, version)\n end\n end\nend",
"def test_version\n assert_match(/^Ocra \\d+(\\.\\d)+$/, `ruby #{ocra} --version`)\n end",
"def test_Browser_001_is_browser_installed()\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_001_is_browser_installed\")\n puts2(\"#######################\")\n\n puts2(\"\\n\\nTest - is_chrome64_installed?()\")\n puts2(\"is_chrome64_installed? = \" + is_chrome64_installed?().to_s)\n\n puts2(\"\\n\\nTest - is_firefox64_installed?()\")\n puts2(\"is_firefox64_installed? = \" + is_firefox64_installed?().to_s)\n\n end",
"def test_vers_class_run_variant\n assert_equal 0, run_with_args(%w(-v))\n assert_match(/Ruby BlackBag version #{Rbkb::VERSION}/, @stdout_io.string)\n end",
"def test_display_negative_iterations\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 1, 0) }\r\n end",
"def test_display_negative_rubyist\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 0, 2) }\r\n end",
"def test_hardware_cpu_type\n assert [:intel, :ppc].include?(Hardware.cpu_type)\n end",
"def testBasicBinaryWithRuby\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/windows\\/bin$/,\n :Cmd => /^allinoneruby\\.bat --rubyw rubyw-#{RUBY_VERSION}\\.exe$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> start rubyw -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def testCommandLineVersionShort\n executeSlave( [ '-v' ] )\n end",
"def test_platform_uses_unknown_if_uname_fails\n NewRelic::Helper.stubs('run_command').with('uname -s').raises(NewRelic::CommandRunFailedError)\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal 'unknown', platform\n end\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def testBasicBinary\n execTest('Applications/Basic', [], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> start rubyw -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end",
"def test_different_increase\n\t\tm = Miner.new(1)\n\t\tfr = m.fake_rubies\n\t\tr = m.rubies\n\t\tm.increase_rubies(1,2)\n\t\tassert_equal(fr+2,m.fake_rubies)\n\t\tassert_equal(r+1,m.rubies)\n\tend",
"def test_no_increase\n\t\tm = Miner.new(1)\n\t\tfr = m.fake_rubies\n\t\tr = m.rubies\n\t\tm.increase_rubies(0,0)\n\t\tassert_equal(fr,m.fake_rubies)\n\t\tassert_equal(r,m.rubies)\n\tend",
"def numvcpus\n begin\n os_cpu_cores\n rescue\n 4\n end\nend",
"def test_fake_string_big\n pros = Prospector.new(0,0,0)\n assert pros.fake_string(2).eql? '2 fake rubies'\n end",
"def print_rubies_found(rubies_found, fake_rubies_found, town)\n raise 'Ruby and/or Fake Ruby counts can not be < 0!' if rubies_found < 0 || fake_rubies_found < 0\n\n name = town.name\n if rubies_found.zero? && fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{name}.\"\n elsif rubies_found == 1 && fake_rubies_found.zero?\n puts \"\\tFound 1 ruby in #{name}.\"\n elsif rubies_found.zero? && fake_rubies_found == 1\n puts \"\\tFound 1 fake ruby in #{name}.\"\n elsif rubies_found == 1 && fake_rubies_found == 1\n puts \"\\tFound 1 ruby and 1 fake ruby in #{name}.\"\n elsif rubies_found > 1 && fake_rubies_found.zero?\n puts \"\\tFound #{rubies_found} rubies in #{name}.\"\n elsif rubies_found.zero? && fake_rubies_found > 1\n puts \"\\tFound #{fake_rubies_found} fake rubies in #{name}.\"\n else\n puts \"\\tFound #{rubies_found} rubies and\n #{fake_rubies_found} fake rubies in #{name}.\"\n end\n end",
"def platform(name)\n case ENV['PLATFORM']\n when 'windows_10_edge'\n {selenium_version: '3.141.59',\n platform_name: 'Windows 10',\n browser_name: 'edge',\n browser_version: '18.17763'}.merge(sauce_w3c(name))\n when 'windows_8_ie'\n # Note: w3c is not working for Windows 8 & IE 11\n {platform: 'Windows 8.1',\n browser_name: 'ie',\n selenium_version: '3.141.59',\n version: '11.0'}.merge(sauce_oss(name))\n when 'mac_sierra_chrome'\n # This is for running with w3c which is not yet the default\n # {platform_name: 'macOS 10.12',\n # browser_name: 'chrome',\n # \"goog:chromeOptions\": {w3c: true},\n # browser_version: '65.0'}.merge(sauce_w3c name)\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n when 'mac_mojave_safari'\n {platform_name: 'macOS 10.14',\n browser_name: 'safari',\n browser_version: '12.0'}.merge(sauce_w3c(name))\n when 'windows_7_ff'\n {platform_name: 'Windows 7',\n browser_name: 'firefox',\n browser_version: '60.0'}.merge(sauce_w3c(name))\n else\n # Always specify a default\n {selenium_version: '3.141.59',\n platform: 'macOS 10.12',\n browser_name: 'chrome',\n version: '65.0'}.merge(sauce_oss(name))\n end\n end",
"def ensure_r10k_didnt_run(up_result, workdir)\n expect(up_result.stdout).to_not include(\"vagrant-r10k: Beginning r10k deploy of puppet modules\")\n expect(up_result.stdout).to_not include('vagrant-r10k: Deploy finished')\n\n # file tests\n expect(File).to_not exist(\"#{workdir}/puppet/modules/reviewboard/Modulefile\")\n expect(File).to_not exist(\"#{workdir}/puppet/modules/nodemeister/Modulefile\")\n expect(File).to_not exist(\"#{workdir}/puppet/modules/nodemeister/manifests/init.pp\")\n end",
"def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb') do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def rvm_installed?\n cmd_test %{-s \"/usr/local/lib/rvm\"}\nend",
"def pods_test\n pod 'Quick'\n pod 'Nimble'\nend",
"def test_Enviroment_002_isPlatform\r\n\r\n puts2(\"\")\r\n puts2(\"#######################\")\r\n puts2(\"Testcase: test_Enviroment_002_isPlatform\")\r\n puts2(\"#######################\")\r\n\r\n puts2(\"Running Ruby for Windows: \" + is_win?.to_s)\r\n puts2(\"Running Ruby for Windows 32-bit: \" + is_win32?.to_s)\r\n puts2(\"Running Ruby for Windows 64 bit: \" + is_win64?.to_s)\r\n puts2(\"Running Ruby for Linux: \" + is_linux?.to_s)\r\n puts2(\"Running Ruby for OS/X: \" + is_osx?.to_s)\r\n puts2(\"Running on JRuby: \" + is_java?.to_s)\r\n\r\n end",
"def test_display_one_day\r\n assert_output(\"After 1 day, Rubyist #1 found:\\n\\t1 ruby.\\n\\t1 fake ruby.\\n\") { @g.display_rubies(1, 1, 1, 1) }\r\n end",
"def custom_runner?\n Gem::Version.new(MiniTest::Unit::VERSION) >= Gem::Version.new('2.1.0')\n end",
"def test_current_browsers_detected\n for browser in CURRENT_BROWSERS\n @request.user_agent = browser\n assert ! @page.legacy_browser?\n end\n end",
"def test_random_rubies_zero\n loc1 = Location.new(\"location 1\", 0, 100)\n assert_equal 0, loc1.random_rubies\n end",
"def testBasicBinaryWithRuby\n execTest('Applications/Basic', [ '-r' ], 'ReleaseInfo_Exe.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/IncludeRuby\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/Launch\\/linux\\/bin$/,\n :Cmd => /^allinoneruby ruby\\-#{RUBY_VERSION}\\.bin$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end",
"def test_platform_uses_uname_for_jruby\n stubbed = 'MCP'\n NewRelic::Helper.stubs('run_command').with('uname -s').returns(stubbed)\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, 'java') do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal platform, stubbed.downcase\n end\n end",
"def test_location_max_ruby\n assert_equal @l1.max_ruby, [10, 10] # pass\n end",
"def testNominalWithRegression\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '--regressioncmd', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def rackspace_cloudbackup_test_platforms\n return {\n ubuntu: %w(12.04),\n debian: %w(7.2), # Requires Fauxhai chicanery as https://github.com/customink/fauxhai/pull/60\n # hasn't made its way to RubyGems yet.\n centos: %w(6.4 6.5)\n }\nend",
"def testNominalWithSeveralTypes\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndOther ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Other/DummyOtherFile\"), 'All', 'Other', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def testMissingSlave\n executeProcess(\n [\n '--masterticket', '123'\n ],\n :Error => WEACE::MissingVariableError\n )\n end",
"def test_bad_jruby_deps\n check_deps_fail BadJRubyBall unless `/usr/bin/which jruby`.chomp.empty?\n end",
"def common_pods_for_test\n pod 'Quick', '2.1.0'\n pod 'Nimble', '8.0.1'\nend",
"def upgrade_cores!(num_cores)\n upgrade_item_price = _item_price_in_category(\"guest_core\", num_cores)\n _order_upgrade_item!(upgrade_item_price) if upgrade_item_price\n nil != upgrade_item_price\n end",
"def test_framework_runtimes\n find_duplicates :frameworks\n end",
"def test_platform_uses_ruby_platform\n stubbed = 'ENCOM OS-12'\n NewRelic::Agent::Samplers::MemorySampler.stub_const(:RUBY_PLATFORM, stubbed) do\n platform = NewRelic::Agent::Samplers::MemorySampler.platform\n\n assert_equal platform, stubbed.downcase\n end\n end",
"def test_version\n assert Snarl.version >= '1.1'\n end",
"def create_rubies\n @rubies = [[1, 1], [2, 2], [1, 1], [0, 3], [3, 0], [2, 2], [2, 2]]\n end",
"def testNominalWithRegressionShort\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '-r', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_display_invalid_ruby\r\n assert_raises('rubyist_num must be an integer!') { @g.display_rubies(1, 1, 'a', 2) }\r\n end",
"def guest_cpus\n begin\n host_cpus / 2\n rescue\n 4\n end\nend",
"def testMissingMaster\n executeProcess(\n [\n '--slaveticket', '456'\n ],\n :Error => WEACE::MissingVariableError\n )\n end",
"def test_provided_example\n assert_equal \"tknk\", @system.base.name\n end",
"def test_on_current_browsers\n for current_browser in CURRENT_BROWSERS\n @request.user_agent = current_browser\n get :index\n assert_response :success\n assert_select 'img[src*=painless_test.png]'\n end\n end",
"def test_random_fake_rubies_zero\n loc1 = Location.new(\"location 1\", 100, 0)\n assert_equal 0, loc1.random_fake_rubies\n end",
"def fails_on_jruby\n before do\n unless SpecConfig.instance.mri?\n skip \"Fails on jruby\"\n end\n end\n end",
"def fails_on_jruby\n before do\n unless SpecConfig.instance.mri?\n skip \"Fails on jruby\"\n end\n end\n end",
"def testNominalWithRegressionFailed\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => failure\n [ 1, '' ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '--regressioncmd', 'test/runReg'\n ],\n :Error => WEACE::Master::Server::Processes::Dev_Release::RegressionError\n )\n end\n end",
"def test_show_rush_result\n assert_output(\"After 2 days, Rubyist 1 found:\n 10 rubies.\n 10 fake rubies.\nGoing home victorious!\\n\"){ @p.show_rush_result(2, 1, [10, 10]) }\n end",
"def verify_proper_clustering\n # only perform the tests using a parent node.\n if ( parent_id.nil? && factor.positive? )\n if factor > 0\n version = build[\"version\"]\n major, minor, patch = version.split( \".\" ).map( &:to_i )\n result = ( major >= 10 && minor >= 1 ) ? true : false\n errors.add( 'Build version is too low' ) unless result\n end\n\n if factor.positive?\n result = nodes % factor\n errors.add( 'nodes is not equally divisible by factor' ) unless result == 0\n end\n end\n end",
"def number_of_cpu_cores\n case RbConfig::CONFIG['host_os']\n when /linux/\n Dir.glob('/sys/devices/system/cpu/cpu[0-9]*').count\n when /darwin|bsd/\n Integer(`sysctl -n hw.ncpu`)\n when /solaris/\n Integer(`kstat -m cpu_info | grep -w core_id | uniq | wc -l`)\n else\n 5\n end\n end",
"def test_legacy_browser_detected\n for browser in LEGACY_BROWSERS\n @request.user_agent = browser\n assert @page.legacy_browser?\n end\n end",
"def results\n if @rubies_found > 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found > 1\n puts \"\\tFound #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found == 1\n puts \"\\tFound #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{@current_city}\"\n end\n end",
"def testNominal\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_Browser_003_BrowserTypes\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_003_BrowserTypes\")\n puts2(\"#######################\")\n\n #$VERBOSE = true\n #$DEBUG = true\n\n #sAskURL = \"http://ask.com\"\n sBingURL = \"http://www.bing.com\"\n sGoogleURL = \"http://google.com\"\n #sBlankURL = \"about:blank\"\n\n # Define an empty array\n aSupportedBrowsers = []\n\n # Determine the current OS\n sCurrentOS = \"\"\n if(is_win?)\n #sCurrentOS = \"windows\"\n puts2(\"OS = Windows\")\n if(is_win?(10))\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\", \"Edge\"]\n else\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\"]\n end\n elsif(is_osx?)\n #sCurrentOS = \"osx\"\n puts2(\"OS = OSX\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Safari\"]\n elsif(is_linux?)\n #sCurrentOS = \"linux\"\n puts2(\"OS = Linux\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\"]\n end\n\n puts2(\"Supported browsers = \" + aSupportedBrowsers.to_s)\n\n # Loop thru each browser\n aSupportedBrowsers.each { |sBrowserName|\n\n # Start a browser\n oBrowser = start_browser(sBrowserName)\n\n #puts2(\"\\nIs a Global browser running: \" + is_global_browser_running?.to_s + \"\\n\\n\")\n\n sCurrentURL = oBrowser.url\n puts2(\"Current URL: \" + sCurrentURL)\n\n puts2(\"\\nBrowser type...\")\n puts2(\"\\tis_chrome? = \" + oBrowser.is_chrome?.to_s)\n puts2(\"\\tis_edge? = \" + oBrowser.is_edge?.to_s)\n puts2(\"\\tis_firefox? = \" + oBrowser.is_firefox?.to_s)\n puts2(\"\\tis_ie? = \" + oBrowser.is_ie?.to_s)\n puts2(\"\\tis_opera? = \" + oBrowser.is_opera?.to_s)\n puts2(\"\\tis_safari? = \" + oBrowser.is_safari?.to_s)\n\n oBrowser.display_info()\n\n # The #browser.version method is not supported for Edge\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - #browser.version method is not supported for Edge\")\n else\n sBrowserVersion = oBrowser.version.to_s\n puts2(\"Browser's full version = \" + sBrowserVersion)\n sBrowserMajorVersion = sBrowserVersion.prefix(\".\")\n puts2(\"Browser's major version = \" + sBrowserMajorVersion)\n end\n\n if(oBrowser.is_chrome?)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Chrome \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_chrome?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - For Edge\")\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i - 1)).to_s)\n #puts2(\"Edge \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_edge?(sBrowserMajorVersion.to_i).to_s)\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_firefox?)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Firefox \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_firefox?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_ie?)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"IE \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_ie?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_opera?)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Opera \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_opera?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_safari?)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Safari \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_safari?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n\n # Access a URL\n puts2(\"\\nBrowser - Set URL = \" + sBingURL)\n oBrowser.goto(sBingURL)\n sleep(10) # Placeholder delay to figure out why a new IE fails at this point, and what can be waited on.\n puts2(\"\\tURL = \" + oBrowser.url)\n puts2(\"\\tBrowser name = \" + oBrowser.name.to_s)\n\n puts2(\"Misc. browser methods...\")\n puts2(\"\\tBrowser status = '\" + oBrowser.status.to_s + \"'\")\n puts2(\"\\tBrowser ready_state = \" + oBrowser.ready_state.to_s)\n puts2(\"\\tWindow current = \" + oBrowser.window.current?.to_s)\n puts2(\"\\tBrowse refresh...\")\n oBrowser.refresh\n\n # Start with browser in it's current size\n puts2(\"\\tBrowser is at it's initial size & position\")\n oBrowser.display_info()\n\n puts2(\"\\nMaximize browser\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Resize the window to 640x480\")\n oBrowser.window.resize_to(640,480)\n oBrowser.display_info()\n\n puts2(\"Move the window to 100x100\")\n oBrowser.window.move_to(100,100)\n oBrowser.display_info()\n\n iWindowWidth = 1024\n puts2(\"Resize the window to its max height but specified width (\" + iWindowWidth.to_s + \")\")\n oBrowser.window.move_to(100,10) # w,h\n oBrowser.display_info()\n\n puts2(\"Maximize window...\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Max height & specified width...\")\n iHeight = oBrowser.window.size.height\n oBrowser.window.resize_to(iWindowWidth,iHeight)\n oBrowser.display_info()\n\n puts2(\"\\nLoad a different URL \" + sGoogleURL)\n oBrowser.goto(sGoogleURL)\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n\n puts2(\"Use the browser's 'back' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's back operation not supported.\")\n oBrowser.goto(sBingURL)\n sleep(1)\n else\n oBrowser.back\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Use the browser's 'forward' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's forward operation not supported.\")\n oBrowser.goto(sGoogleURL)\n sleep(1)\n else\n oBrowser.forward\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Focus the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").focus\n sleep(1)\n\n puts2(\"Hover the cursor on 1st div...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser does not appear to support hover\")\n else\n oBrowser.div(:id, \"searchform\").hover\n sleep(1)\n end\n\n puts2(\"Click the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").click\n sleep(1)\n\n puts2(\"\\nAbout to close the current browser\")\n puts2(\"\\tDoes browser exist? = \" + oBrowser.exists?.to_s)\n puts2(\"\\tDoes window exist? = \" + oBrowser.window.exists?.to_s)\n puts2(\"Close the browser...\")\n oBrowser.close\n puts2(\" Does browser exist? = \" + oBrowser.exists?.to_s)\n #puts2(\" Does window exist? = \" + oBrowser.window.exists?.to_s) # Can't check on window if its closed.\n\n puts2(\"\\n##### Next browser...\")\n\n } # END - Loop thru each browser\n\n rescue => e\n\n puts2(\"*** ERROR and Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\n\n if(oBrowser.exists? == true)\n oBrowser.display_info()\n else\n puts(\"No existing browser found\")\n end\n\n # Force any open browsers to exit\n kill_browsers()\n\n # Raise the error with a custom message after the rest of the rescue actions\n raise(\"*** TESTCASE - test_Browser_003_LocalBrowsers\")\n\n ensure\n\n #end # Start browser types\n\n end"
] | [
"0.6731414",
"0.6711774",
"0.65207714",
"0.6389709",
"0.63414603",
"0.6326461",
"0.61986166",
"0.6160062",
"0.614903",
"0.6110676",
"0.61095417",
"0.60324895",
"0.6005822",
"0.59746015",
"0.59568477",
"0.59517497",
"0.5933567",
"0.5928484",
"0.58905494",
"0.5882204",
"0.58745027",
"0.58487654",
"0.58487034",
"0.58289236",
"0.5804462",
"0.5802886",
"0.5776432",
"0.57680774",
"0.5738618",
"0.57306087",
"0.56694275",
"0.566386",
"0.5660211",
"0.56204194",
"0.5564659",
"0.5555699",
"0.5529052",
"0.5475934",
"0.5473208",
"0.5466072",
"0.5451461",
"0.5446288",
"0.5438607",
"0.5421363",
"0.5413146",
"0.540266",
"0.5393132",
"0.5389947",
"0.53533834",
"0.53523415",
"0.5348309",
"0.53180796",
"0.53113735",
"0.53113735",
"0.5308631",
"0.5306617",
"0.5304149",
"0.5274721",
"0.5222465",
"0.5210618",
"0.5209112",
"0.5204877",
"0.5204185",
"0.5203931",
"0.520276",
"0.52009267",
"0.5180784",
"0.5178602",
"0.51667196",
"0.51653534",
"0.514863",
"0.5147776",
"0.5147326",
"0.51348287",
"0.5120882",
"0.51045424",
"0.50933766",
"0.5090985",
"0.50878537",
"0.5086155",
"0.50856215",
"0.50830287",
"0.5082016",
"0.5078381",
"0.50780135",
"0.50754243",
"0.50695395",
"0.5044935",
"0.5044612",
"0.50424874",
"0.50345963",
"0.502641",
"0.502641",
"0.50236595",
"0.50235736",
"0.50222385",
"0.501895",
"0.50161743",
"0.5012318",
"0.49968258",
"0.49844205"
] | 0.0 | -1 |
This test when found 100 rubies | def test_mood6
assert_equal @p.mood?([100, 0]), 'victorious!'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_rubies\r\n # Add 1 to max_rubies to make maximum inclusive\r\n @random.rand(@max_rubies + 1)\r\n end",
"def test_find_rubies_nonzero\r\n\t\tassert_includes [email protected]_rubies, @t.find_rubies\r\n\tend",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def test_rubies_found_positive\n prospector = Rubyist.new(1)\n prospector.rubies_found(2, 2)\n assert prospector.real_ruby_count == 2 && prospector.fake_ruby_count == 2\n end",
"def find_fake_rubies\r\n # Add 1 to max_fake_rubies to make maximum inclusive\r\n @random.rand(@max_fake_rubies + 1)\r\n end",
"def test_real_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.real_rubies_found(7)\n\t\tassert test_main.num_real_rubies, 14\n\tend",
"def test_find_fake_rubies_nonzero\r\n\t\tassert_includes [email protected]_fake_rubies, @t.find_fake_rubies\r\n\tend",
"def test_three_rubies_test\r\n rubyArr = [3,3]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2 || numReturn == 3\r\n assert true\r\n end\r\n end",
"def test_rubies_found_negative\n prospector = Rubyist.new(1)\n prospector.rubies_found(-2, -2)\n assert prospector.real_ruby_count.zero? && prospector.fake_ruby_count.zero?\n end",
"def test_random_rubies\n loc1 = Location.new(\"location 1\", 10, 1000)\n res = loc1.random_rubies\n assert res >= 0 && res <= 10\n end",
"def test_json_max_rubies\n load_location_setup\n assert_equal 5, @json_location.max_rubies\n end",
"def sample_rubies\n @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.3 ]\n end",
"def test_new_location_rubies\n assert_equal 5, @loc1.max_rubies\n end",
"def test_two_rubies_test\r\n rubyArr = [2,2]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2\r\n assert true\r\n end\r\n end",
"def test_find_rubies_zero\r\n\t\tassert_equal 0, @t2.find_rubies\r\n\tend",
"def test_display_two\r\n assert_output(\"After 2 days, Rubyist #2 found:\\n\\t2 rubies.\\n\\t2 fake rubies.\\n\") { @g.display_rubies(2, 2, 2, 2) }\r\n end",
"def test_add_to_rubies\n pros = Prospector.new(0,0,0)\n pros.add_to_rubies([1,1])\n assert pros.real == 1 && pros.fake == 1\n end",
"def sample_mri_rubies\n @sample_mri_rubies ||= %w[ ruby-3.2 ruby-2.7 ]\n end",
"def test_ruby_count_zeros\n pros = Prospector.new(0,0,0)\n assert pros.ruby_count.eql? \"After 0 days, Rubyist #0 found:\\n\\t0 rubies.\\n\\t0 fake rubies.\\n\"\n end",
"def test_find_fake_rubies_zero\r\n\t\tassert_equal 0, @t2.find_fake_rubies\r\n\tend",
"def test_json_max_fake_rubies\n load_location_setup\n assert_equal 10, @json_location.max_fake_rubies\n end",
"def test_random_fake_rubies\n loc1 = Location.new(\"location 1\", 1000, 10)\n res = loc1.random_fake_rubies\n assert res >= 0 && res <= 10\n end",
"def test_no_increase\n\t\tm = Miner.new(1)\n\t\tfr = m.fake_rubies\n\t\tr = m.rubies\n\t\tm.increase_rubies(0,0)\n\t\tassert_equal(fr,m.fake_rubies)\n\t\tassert_equal(r,m.rubies)\n\tend",
"def test_different_increase\n\t\tm = Miner.new(1)\n\t\tfr = m.fake_rubies\n\t\tr = m.rubies\n\t\tm.increase_rubies(1,2)\n\t\tassert_equal(fr+2,m.fake_rubies)\n\t\tassert_equal(r+1,m.rubies)\n\tend",
"def test_new_location_fake_rubies\n assert_equal 10, @loc1.max_fake_rubies\n end",
"def test_display_one\r\n assert_output(\"After 2 days, Rubyist #1 found:\\n\\t1 ruby.\\n\\t1 fake ruby.\\n\") { @g.display_rubies(1, 1, 1, 2) }\r\n end",
"def test_found_no_rubies\n\t\tp = Print.new\n\t\tassert_output(\"\\tFound no rubies or fake rubies in Town.\\n\") {p.print_day([0,0],'Town')}\n\tend",
"def test_display_negative_iterations\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 1, 0) }\r\n end",
"def testNominalWithSeveralRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithSeveralRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.txt\"), 'txt', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_ruby_string_big\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(2).eql? '2 rubies'\n end",
"def test_random_rubies_zero\n loc1 = Location.new(\"location 1\", 0, 100)\n assert_equal 0, loc1.random_rubies\n end",
"def results\n if @rubies_found > 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found > 1\n puts \"\\tFound #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found == 1\n puts \"\\tFound #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{@current_city}\"\n end\n end",
"def hunt_rubies\n i = 0\n while i < @num_turns\n @rubies_found = 0\n @fake_rubies_found = 0\n\n # Search the current city for any rubies.\n search_city\n # Once you don't find any rubies, display your results.\n results\n # Verify that you didn't find any rubies this time.\n check_next_city\n\n # Head to the next city.\n if @next_city\n @next_city = false\n # Decide where you want to go\n travel\n puts \"Heading from #{@prev_city} to #{@current_city}\"\n i += 1\n end\n end\n end",
"def there_are_twelve_enabled_puppies\n expect(Puppy.enabled.size).to eql 12\nend",
"def create_rubies\n @rubies = [[1, 1], [2, 2], [1, 1], [0, 3], [3, 0], [2, 2], [2, 2]]\n end",
"def search_for_rubies(loc)\n curr_city = loc.to_i\n loop do\n @total_days += 1\n real_ruby = 0\n fake_ruby = 0\n real_ruby = @rng.rand(@table[curr_city][0]) if @table[curr_city][0] > 0\n fake_ruby = @rng.rand(@table[curr_city][1]) if @table[curr_city][1] > 0\n puts \" Found #{real_ruby} real ruby and #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby == 1\n puts \" Found #{real_ruby} real rubies and #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby == 1\n puts \" Found #{real_ruby} real ruby and #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby > 1\n puts \" Found #{real_ruby} real rubies and #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby > 1\n puts \" Found #{real_ruby} real ruby in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby == 0\n puts \" Found #{real_ruby} real rubies in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby == 0\n puts \" Found #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby == 1\n puts \" Found #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby > 1\n @total_real_rubies += real_ruby\n @total_fake_rubies += fake_ruby\n puts \" Found no rubies or fake rubies in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby == 0\n break if real_ruby == 0 && fake_ruby == 0\n end\n end",
"def test_trip_plural_rubies_singular_fakes\n p = Print.new\n assert_output(\"After 1 days, Rubyist 2 found:\\n\\t10 rubies.\\n\\t1 fake ruby.\\nGoing home victorious!\\n\") {p.print_trip([10,1],1,2)}\n end",
"def print_rubies_found(rubies_found, fake_rubies_found, town)\n raise 'Ruby and/or Fake Ruby counts can not be < 0!' if rubies_found < 0 || fake_rubies_found < 0\n\n name = town.name\n if rubies_found.zero? && fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{name}.\"\n elsif rubies_found == 1 && fake_rubies_found.zero?\n puts \"\\tFound 1 ruby in #{name}.\"\n elsif rubies_found.zero? && fake_rubies_found == 1\n puts \"\\tFound 1 fake ruby in #{name}.\"\n elsif rubies_found == 1 && fake_rubies_found == 1\n puts \"\\tFound 1 ruby and 1 fake ruby in #{name}.\"\n elsif rubies_found > 1 && fake_rubies_found.zero?\n puts \"\\tFound #{rubies_found} rubies in #{name}.\"\n elsif rubies_found.zero? && fake_rubies_found > 1\n puts \"\\tFound #{fake_rubies_found} fake rubies in #{name}.\"\n else\n puts \"\\tFound #{rubies_found} rubies and\n #{fake_rubies_found} fake rubies in #{name}.\"\n end\n end",
"def test_check_plural_total\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_rb=0\n ruby_rush.fake_rb=1\n assert_equal \"rubies,ruby\", ruby_rush.check_plural_total\n ruby_rush.total_real_sp='ruby'\n ruby_rush.total_fake_sp='ruby'\n ruby_rush.real_rb=1\n ruby_rush.fake_rb=0\n assert_equal \"ruby,rubies\", ruby_rush.check_plural_total\n ruby_rush.total_real_sp='ruby'\n ruby_rush.total_fake_sp='ruby'\n ruby_rush.real_rb=2\n ruby_rush.fake_rb=2\n assert_equal \"rubies,rubies\", ruby_rush.check_plural_total\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n end",
"def test_fake_string_big\n pros = Prospector.new(0,0,0)\n assert pros.fake_string(2).eql? '2 fake rubies'\n end",
"def test_it_can_find_golden_items_from_threshold\n threshold = 605_1\n assert_equal 5, @sa.find_golden_items(@se.items.all, threshold).count\n end",
"def init_rubies\n @table = [\n [1, 1], # Enumerable Canyon ==> 0\n [1, 1], # Monkey Patch City ==> 1\n [2, 2], # Duck Type Beach ==> 2\n [3, 0], # Matzburg ==> 3\n [0, 3], # Nil Town ==> 4\n [2, 2], # Hash Crossing ==> 5\n [2, 2] # Dynamic Palisades ==> 6\n ]\n end",
"def recent_rubies\n @recent_rubies ||= %w[ ruby-3.2 ruby-3.1 jruby-9.3 ]\n end",
"def test_display_negative_rubyist\r\n assert_raises('rubyist_num must be greater than 0!\\n') { @g.display_rubies(1, 1, 0, 2) }\r\n end",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def test_random_fake_rubies_zero\n loc1 = Location.new(\"location 1\", 100, 0)\n assert_equal 0, loc1.random_fake_rubies\n end",
"def test_pre_season_ranks\n season = seasons :_2007\n master = season.pool_users.master\n pool_users = season.pool_users\n pool_users.each do |pool_user|\n pool_user.pics.each do |pic|\n pic.update_attribute(:bid_id, nil)\n end\n end\n pool_users.map(&:reload).each do |pool_user|\n assert_not pool_user.bracket_complete?\n end\n season.pool_users.by_rank(master.pics).each { |pool_user, rank| assert_equal 1, rank }\n end",
"def test_show_rush_result\n assert_output(\"After 2 days, Rubyist 1 found:\n 10 rubies.\n 10 fake rubies.\nGoing home victorious!\\n\"){ @p.show_rush_result(2, 1, [10, 10]) }\n end",
"def test_total_turns_1\n \tpro = Prospector.new(1)\n \tpro.prospect_move(1)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n end",
"def test_select\n\n @dashboard.register { catchall }\n\n @dashboard.launch(Ruote.define do\n concurrence { alpha; bravo; charly }\n end)\n\n while @dashboard.storage_participant.size < 3; end\n\n assert_equal(\n 1,\n @dashboard.storage_participant.select { |wi|\n wi.participant_name == 'bravo'\n }.size)\n end",
"def testNominalWithRN\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGemWithRN ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ],\n Actions::File_UploadReleaseNote => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/ReleaseNotes/DummyGemReleaseNote.html\"), 'html', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def supported_rubies\n @supported_rubies ||= supported_mri_rubies + jrubies\n end",
"def test_all\n query = \"iphone5s\"\n\n products = ProductHelper.crawl(query)\n products.each do |product|\n #STDERR.puts product\n end\n pgroups = ProductHelper.clustering(products)\n pgroups.each do |pgroup|\n info = \"\"\n unless pgroup.spu.nil?\n info = pgroup.spu['Title']\n end\n STDERR.puts \"#{pgroup.size},#{info}\"\n end\n end",
"def homepage_load(count=1)\n \tfor i in 0..count\n\t puts \"#Trial #{i}\"\t\n\t homepage_test\n end\n end",
"def older_rubies\n @older_rubies ||= %w[ ruby-3.0 ruby-2.7 ruby-2.6 ruby-2.5 ]\n end",
"def _test_pages_available\n #execute this code x number of times\n @custom_number_of_users.times do |i|\n puts 'Running tests for user #'+i.to_s\n # assert_section nil\n end\n end",
"def test_tile_rack_with_several_tiles_should_need_some_tiles\n [:A,:B,:C].each{|x| @newTileRack.append(x)}\n assert_equal(4,@newTileRack.number_of_tiles_needed)\n end",
"def test_print_items_books\r\n\t\tmock_argv = [87]\r\n\t\tARGV.replace(mock_argv)\r\n\t\trequire_relative 'city_sim_9006'\r\n\t\tprng = Random.new((ARGV[0]))\r\n\t\toakland = City::new\r\n\t\tgame = CitySim::new\r\n\t\tall_drivers = [d1 = Driver.new(1)]\r\n\t\tnum_starting_locs = oakland.all_locations.length\r\n\t\tnum_options = 2\r\n\t\tall_items = stfu do game.run_sim(all_drivers, oakland, prng, num_starting_locs, num_options) end\r\n\t\tassert_equal all_items[0].num_books, 3\r\n\tend",
"def test_spawn_prospectors\r\n \ttest_group = ProspectorGroup.new\r\n \tassert_equal 12 , test_group.spawn_prospectors(12).size\r\n end",
"def test_rub_per_round\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.rub_per_round(mocked_Graph)\n\t\tassert mocked_Graph\n\tend",
"def test_end_search_0_turns\n \tpro = Prospector.new(1)\n \tpro.loop_prospector(0)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n \tassert pro.days == 0\n \tassert pro.turns == 0\n end",
"def test_display_one_day\r\n assert_output(\"After 1 day, Rubyist #1 found:\\n\\t1 ruby.\\n\\t1 fake ruby.\\n\") { @g.display_rubies(1, 1, 1, 1) }\r\n end",
"def test_turn_putter_none\n pros = Prospector.new(0,0,0)\n assert pros.turn_putter(0,0).eql? \"\\tFound no rubies or fake rubies in Enumerable Canyon\"\n end",
"def jrubies\n @jrubies ||= %w[ jruby-9.3 jruby-9.2 ]\n end",
"def test_prospect_search_no_rubies\n \tlocation_stub = Minitest::Mock.new('Mock Location')\n \tpro = Prospector.new(1)\n \tdef location_stub.loc\n \"Laboon Lake\"\n end\n def location_stub.max_rubies\n 0\n end\n def location_stub.max_fake_rubies\n 1\n end\n def location_stub.neighbor_list\n [\"Sean's Bowser Castle\", \"Kitty's Cozy Condo\"]\n end\n pro.change_curr_location(location_stub)\n pro.prospect_search(1)\n assert pro.total_rubies == 0\n end",
"def test_harness_dependencies(*)\n return unless platform[/n(5|6)k/]\n skip_if_nv_overlay_rejected(agent)\n\n # Vxlan has a hard requirement to disable feature fabricpath on n5/6k\n cmd = 'no feature-set fabricpath'\n command_config(agent, cmd, cmd)\nend",
"def test_number_of_winners\n Range.new(1, @unique_advertises_count).each do |i|\n winners = Auctioneer.auction(\n creatives: @creatives,\n number_of_winners: i\n )\n\n assert { winners.count == i }\n end\n end",
"def test_location_max_ruby\n assert_equal @l1.max_ruby, [10, 10] # pass\n end",
"def test_initialize_prospectors\n assert_equal initialize_prospectors(5).count, 5\n end",
"def there_are_five_disabled_puppies\n expect(Puppy.disabled.size).to eql 5\nend",
"def test_ruby_rush_no_rubyist\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(0, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #0 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 0 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def testNominalWithSeveralPlatforms\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndWindows ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/Windows/Inst/Install.exe\"), 'Windows', 'Inst', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_results_negative\r\n assert_raises('Cannot have a negative number of rubies found!') { @g.results(-1) }\r\n end",
"def test_empty_tile_rack_should_need_max_tiles\n assert_equal(7,@newTileRack.number_of_tiles_needed)\n end",
"def test_fun_five_prospectors\n\t@city = GoldRush::new\n\tcity.initiliaze(1,5)\n\tassert_equal 5, @city.prospectors.length\n end",
"def test_print_fake\r\n test = Prospect.new(0)\r\n test.totalfakes = 1\r\n assert_output(/\\tFound 1 fake ruby in Enumerable Canyon. /) { test.print_all_rubies(test.totalruby, test.totalfakes)}\r\n end",
"def test_print_items_classes_when_driver_starts_at_cathedral\r\n\t\tmock_argv = [16526]\r\n\t\tARGV.replace(mock_argv)\r\n\t\trequire_relative 'city_sim_9006'\r\n\t\tprng = Random.new((ARGV[0]))\r\n\t\toakland = City::new\r\n\t\tgame = CitySim::new\r\n\t\tall_drivers = [d1 = Driver.new(1)]\r\n\t\tnum_starting_locs = oakland.all_locations.length\r\n\t\tnum_options = 2\r\n\t\tall_items = stfu do game.run_sim(all_drivers, oakland, prng, num_starting_locs, num_options) end\r\n\t\tassert_equal all_items[0].num_classes, 2\r\n\tend",
"def test_coded_chrs\n assert_equal 5, @mk.coded_chrs.count\n end",
"def pods_test\n pod 'Quick'\n pod 'Nimble'\nend",
"def prospect(town, prng)\n raise 'Valid Pseudo-Random Number Generator must be passed in!' unless prng.is_a?(Random)\n\n # Existence of at least 1 of either type is implicit\n rubies_possible = town.rubies # Will throw NoMethodError if not Town\n fake_rubies_possible = town.fake_rubies\n\n # Mine for rubies\n rubies_found = prng.rand(rubies_possible + 1)\n fake_rubies_found = prng.rand(fake_rubies_possible + 1)\n\n # Return found rubies in an array\n rubies = Array[rubies_found, fake_rubies_found]\n rubies\n end",
"def testNominalWithSeveralTypes\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_DummyGemAndOther ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Other/DummyOtherFile\"), 'All', 'Other', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def testNominal\n executeProcess(\n [\n '--masterticket', '123',\n '--slaveticket', '456'\n ]\n ) do |iError, iSlaveActions|\n assert_equal(\n {\n Tools::TicketTracker => {\n Actions::Ticket_RejectDuplicate => [\n [ '123', '456' ]\n ]\n }\n },\n iSlaveActions\n )\n end\n end",
"def testNominal\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def ntest_number_of_pages\n assert_equal(3,@transformer.number_of_pages(jobs(:job_56)))\n end",
"def verify_proper_clustering\n # only perform the tests using a parent node.\n if ( parent_id.nil? && factor.positive? )\n if factor > 0\n version = build[\"version\"]\n major, minor, patch = version.split( \".\" ).map( &:to_i )\n result = ( major >= 10 && minor >= 1 ) ? true : false\n errors.add( 'Build version is too low' ) unless result\n end\n\n if factor.positive?\n result = nodes % factor\n errors.add( 'nodes is not equally divisible by factor' ) unless result == 0\n end\n end\n end",
"def test_vcs_search_minor_than_60\n TeamcityRuby::Core.new(['vcsroot_find', '.\\config.rb', 'dev', '60', 'minor_than', '.\\result_vcs_search_minor_than_60.yml']) \n result = YAML::load_file('.\\result_vcs_search_minor_than_60.yml')\n #Datagod Gauge\n if result.size() > 0 \n statsd = Statsd.new\n statsd.gauge('dev VCS roots minor than 60', result.count)\n puts \"result.count : #{result.count}\"\n end\n \n bed = YAML::load_file(File.join(File.dirname(__FILE__), 'bed_vcs_search_minor_than_60.yml')) \n assert_equal result, bed \n end",
"def test_display_invalid_fake\r\n assert_raises('total_fake rubies must be an integer!') { @g.display_rubies(1, 'a', 1, 2) }\r\n end",
"def run_test(tests, ints_to_test, current_test_name)\n require \"./primality_tests/\" + current_test_name + \".rb\"\n tests[current_test_name.to_sym][:result] = []\n ints_to_test.each {|int|\n tests[current_test_name.to_sym][:result] << send(current_test_name, int)\n }\nend",
"def test_print_out_found_long\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=2\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n end",
"def test_ut_da10b_t1_16\n p \"Test 16\"\n pu =Pu.new( :name => \"SamplePU3\" )\n # gets a list of pjs belong to selected pu\n pjs = pu.get_pjs_belong_to_pu\n assert_equal [], pjs\n end",
"def test_controller_computed_primes\n\n assert_equal(Sieve::Primes.new.take(104)[4,-1],Prime.each.take(104)[4,-1])\n end",
"def testNominalWithRegression\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '--regressioncmd', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def show_rush_result(day, number, total_ruby_found)\n puts \"After #{day} days, Rubyist #{number} found:\n #{total_ruby_found[0]} rubies.\n #{total_ruby_found[1]} fake rubies.\nGoing home #{mood?(total_ruby_found)}\"\n end",
"def test_print_books_plural\n\t\tassert_output(\"Driver 1 obtained 3 books!\\n\") { print_books(3,1) }\n\tend",
"def testSingleResourceImportanceChain\n executeSimpleTest(\n [ [ 'T1', 'R1', 100, 2, ['T2'], ' =='],\n [ 'T2', 'R1', 900, 2, [], ' =='],\n [ 'T3', 'R1', 300, 6, ['T2'], ' ======'],\n [ 'T4', 'R1', 200, 2, [], ' =='],\n [ 'T5', 'R1', 800, 2, [], ' =='],\n [ 'T6', 'R1', 950, 2, [], ' =='],\n [ 'T7', 'R1', 1500, 2, [], '=='] ] )\n end",
"def test_check_plural\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.cur_real_rb=0\n ruby_rush.cur_fake_rb=1\n assert_equal \"rubies,ruby\", ruby_rush.check_plural\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=0\n assert_equal \"ruby,rubies\", ruby_rush.check_plural\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n assert_equal \"rubies,rubies\", ruby_rush.check_plural\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n \n end",
"def testNominalWithRegressionShort\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '-r', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end",
"def upgrade_cores!(num_cores)\n upgrade_item_price = _item_price_in_category(\"guest_core\", num_cores)\n _order_upgrade_item!(upgrade_item_price) if upgrade_item_price\n nil != upgrade_item_price\n end",
"def rubies\n @parent.list_strings\n end",
"def test_display_negative_real\r\n assert_raises(\"total_rubies must be a number greater than or equal to 0.\\n\") { @g.display_rubies(-1, 1, 1, 2) }\r\n end"
] | [
"0.6955006",
"0.6875608",
"0.6873788",
"0.6765082",
"0.6738218",
"0.6694599",
"0.6629453",
"0.64132553",
"0.638477",
"0.6319529",
"0.6239585",
"0.62267745",
"0.61831784",
"0.6135034",
"0.61318135",
"0.6086829",
"0.6078069",
"0.6061363",
"0.6035586",
"0.59994864",
"0.59683067",
"0.59472257",
"0.5920269",
"0.58732253",
"0.5833336",
"0.58270174",
"0.5820323",
"0.5767217",
"0.5749547",
"0.57040036",
"0.5701221",
"0.568978",
"0.5639374",
"0.55735695",
"0.55628717",
"0.5532243",
"0.551964",
"0.55194616",
"0.55179596",
"0.5516073",
"0.5504105",
"0.54985356",
"0.54980826",
"0.54824615",
"0.54362875",
"0.5428226",
"0.5423736",
"0.54116774",
"0.5393622",
"0.53828603",
"0.53821164",
"0.53734785",
"0.53494936",
"0.53401226",
"0.5334732",
"0.532912",
"0.5327107",
"0.53241915",
"0.5320711",
"0.532039",
"0.5300404",
"0.5285389",
"0.52796483",
"0.5274385",
"0.5263365",
"0.52625287",
"0.52622527",
"0.52620965",
"0.524951",
"0.5246977",
"0.5229003",
"0.5226817",
"0.52264124",
"0.5226392",
"0.52228767",
"0.5214665",
"0.51963615",
"0.5193375",
"0.5178142",
"0.5166855",
"0.5160101",
"0.5150059",
"0.5140955",
"0.51398844",
"0.5139035",
"0.51383185",
"0.5131157",
"0.51222247",
"0.5111376",
"0.5104489",
"0.51038766",
"0.50908905",
"0.50867164",
"0.50842583",
"0.5083742",
"0.5080801",
"0.5080781",
"0.50763494",
"0.5049499",
"0.50471383",
"0.50463766"
] | 0.0 | -1 |
UNIT TESTS FOR show_rush_result(x, y, []) | def test_show_rush_result
assert_output("After 2 days, Rubyist 1 found:
10 rubies.
10 fake rubies.
Going home victorious!\n"){ @p.show_rush_result(2, 1, [10, 10]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_concatonation_6\n find = Finder.new\n arr = []\n arr3 = find.concatonation(arr)\n assert_equal arr3, []\n end",
"def big_result_array\n @my_big_result_array.push(@result)\n #puts \" \"\n #puts \"#{@my_big_result_array}\"\n #puts \" \"\n end",
"def test_print_out_found_long\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=2\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n end",
"def test_full_stack_push_and_pop\n puts \"test_full_stack_push_and_pop\"\n (rand(10) + 2).times do\n expects = []\n 100.times do\n expects << random_string\n pr = push(expects[-1])\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n end\n\n 100.times do\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n end\n end",
"def test_concat_arrays\n array = []\n array_one = [1,2,3,4,5]\n array_two = [6,7,8,9,10]\n array = array_one.concat(array_two)\n assert_equal [1,2,3,4,5,6,7,8,9,10], array\n end",
"def test_ruby_rush_no_turn\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nHeading from a to a\n Found no rubies or fake rubies in a.\n Found no rubies or fake rubies in a.\nAfter 3 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end",
"def show_rush_result(day, number, total_ruby_found)\n puts \"After #{day} days, Rubyist #{number} found:\n #{total_ruby_found[0]} rubies.\n #{total_ruby_found[1]} fake rubies.\nGoing home #{mood?(total_ruby_found)}\"\n end",
"def test_addition\n @eval.load_stacks([5, 5, '+'])\n assert_equal 10, @eval.quick_maffs_a('+')\n end",
"def test_ruby_rush_no_rubyist\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(0, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #0 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 0 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_print_out_found_nothing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output (\"\\tFound no #{ruby_rush.real_sp} or fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_nothing}\n end",
"def test_combine_arrays\n array = []\n array_one = [1,2,3,4,5]\n array_two = [2,5,9]\n array = array_one & array_two\n assert_equal [2,5], array\n end",
"def combine(a, b)\n\tresults = Array.new\n#check to see if there is only one element left\n\n#should this be a case statement?\n\tif a.first >= b.first\n\t\tresults.push(b.first)\n\t\tb.drop(first)\n\telsif b.first >= a.first\n\t\tresults.push(a.first)\n\t\ta.drop(first)\n\telsif b == []\t&& a != []\n\t\tresults.push(a)\n\telsif a == []\t&& b != []\n\t\tresults.push(b)\n\tend\n\n=======\n\t# create a results array\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n\t\t# push the smaller element onto the result array\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\nend",
"def combine(a, b)\n\t# create a results array\n\t\n\t# counters pointing to the index of the smallest elements in each array\n\n\t# check that we have elements to compare\n\t\t# push the smaller element onto the result array\n\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\n\nend",
"def merge(left, right, &prc)\n start = Time.now\n merged_array = []\n prc = Proc.new { |num1, num2| num1 <=> num2 } unless block_given?\n until left.empty? || right.empty?\n case prc.call(left.first, right.first)\n when -1\n merged_array << left.shift\n when 0\n merged_array << left.shift\n when 1\n merged_array << right.shift\n end\n end\n finish = Time.now\n diff = (finish - start)\n puts diff\n\n \n merged_array + left + right\n end",
"def compare_arrays(basic, result)\n if basic == result\n puts \"Congratulation arrays are the same\"\n else\n puts basic\n puts result\n raise \"Ooo-nooooooo\"\n end\nend",
"def merge(array1, array2)\n results = []\n\n results = array1 + array2\n\n 10.times do\n n = -1\n\n 10.times do\n if results[n].to_i < results[n - 1].to_i\n results[n], results[n - 1] = results[n - 1], results[n]\n end\n\n n -= 1\n end\n end\n\n results\nend",
"def test_draw_included_in_stack\n assert_equal (draw - stack), []\n end",
"def merge_arr(left, right)\n # puts \"left: #{left}, right: #{right}\"\n left ||= []\n right ||= []\n res = []\n \n loop do\n res += right and break if left.empty?\n res += left and break if right.empty?\n \n if left.first <= right.first\n res << left.shift\n else\n res << right.shift\n end\n end\n \n res\nend",
"def test_concatonation_2\n find = Finder.new\n node1 = Minitest::Mock.new\n node2 = Minitest::Mock.new\n node3 = Minitest::Mock.new\n node4 = Minitest::Mock.new\n def node1.ch; 'C'; end\n def node1.id; '1'; end\n def node2.ch; 'A'; end\n def node2.id; '2'; end\n def node3.ch; 'K'; end\n def node3.id; '3'; end\n def node4.ch; 'E'; end\n def node4.id; '4'; end\n arr = [[node1], [node2], [node3], [node4]]\n arr3 = find.concatonation(arr)\n assert_equal arr3, [[node1], [node2], [node3], [node4]]\n end",
"def push_in_the_results(test_line)\n if end_of_line?(test_line)\n @results.push((ree? or mri?) ? @line.pack('c*') : @line.join)\n @line.clear\n end\n end",
"def test_concatonation_5\n find = Finder.new\n node1 = Minitest::Mock.new\n node2 = Minitest::Mock.new\n node3 = Minitest::Mock.new\n node4 = Minitest::Mock.new\n def node1.ch; 'C'; end\n def node1.id; '1'; end\n def node2.ch; 'A'; end\n def node2.id; '2'; end\n def node3.ch; 'K'; end\n def node3.id; '3'; end\n def node4.ch; 'E'; end\n def node4.id; '4'; end\n arr = [[node1, node2], [node2]]\n arr3 = find.concatonation(arr)\n assert_equal arr3, [[node1, node2], [node2]]\n end",
"def test_concatonation_1\n find = Finder.new\n node1 = Minitest::Mock.new\n node2 = Minitest::Mock.new\n node3 = Minitest::Mock.new\n node4 = Minitest::Mock.new\n def node1.ch; 'C'; end\n def node1.id; '1'; end\n def node2.ch; 'A'; end\n def node2.id; '2'; end\n def node3.ch; 'K'; end\n def node3.id; '3'; end\n def node4.ch; 'E'; end\n def node4.id; '4'; end\n arr = [[node1, node2], [node2, node3, node4]]\n arr3 = find.concatonation(arr)\n assert_equal arr3, [[node1, node2, node3, node4]]\n end",
"def test_merge_abutting_1\n x = IntegerRange.new(1, 4)\n y = IntegerRange.new(5, 10)\n\n assert_equal(x.mergeable?(y), true)\n x.merge(y)\n\n assert_equal(x.bottom, 1)\n assert_equal(x.top, 10)\n assert_equal(x.to_a, (1..10).to_a)\n\n a = []\n x.each { |i| a << i }\n\n assert_equal(a, (1..10).to_a)\n end",
"def test_concatonation_4\n find = Finder.new\n node1 = Minitest::Mock.new\n node2 = Minitest::Mock.new\n node3 = Minitest::Mock.new\n node4 = Minitest::Mock.new\n def node1.ch; 'C'; end\n def node1.id; '1'; end\n def node2.ch; 'A'; end\n def node2.id; '2'; end\n def node3.ch; 'K'; end\n def node3.id; '3'; end\n def node4.ch; 'E'; end\n def node4.id; '4'; end\n arr = [[node1, node2], [node2, node3], [node3, node4]]\n arr3 = find.concatonation(arr)\n assert_equal arr3, [[node1, node2, node3], [node2, node3, node4]]\n end",
"def test_0910_collect_concat\n @@log.debug \"test_0910_collect_concat starts\" if @@log.debug?\n assert_respond_to(@list, :collect_concat, \"test_0910_collect_concat_respond\")\n # Need some arrays for this test .....\n part_one = [@aen, @bsb]\n part_two = [@cab, @dad]\n ary_all = [ part_one, part_two ]\n # This should be the orignal list\n cc_res = ary_all.collect_concat {|pers| pers }\n 0.upto(cc_res.size-1) do |n|\n # Each element should be the same\n assert(cc_res[n] == @list[n], \"test_0910_collect_concat_eltck_#{n}\")\n end\n #\n assert(cc_res == @list.to_a, \"test_0910_collect_concat_eltck_all\")\n #\n @@log.debug \"test_0910_collect_concat ends\" if @@log.debug?\n end",
"def combine(left, right)\n\t# create a results array\n results = []\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n while right.length > 0 && left.length > 0\n\t\t# push the smaller element onto the result array\n if right[0] <= left[0]\n results.push(right[0])\n right.delete_at(0)\n elsif left[0] < right[0]\n results.push(left[0])\n left.delete_at(0)\n end\n end\n # if there are elements left over in a, move them to result\n if !right.empty?\n results.push(right)\n # if there are elements left over in b, move them to result\n elsif !left.empty?\n results.push(left)\n end\n return results.flatten\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\nend",
"def report_test_results(test_name, results)\n status = true\n message = \"\"\n for result in results\n # print (\"Status: \"+result[0].to_s+\"\\n\")\n status = (status && result[0])\n if (result[1].is_a?(Array))\n for m in result[1]\n message += m.to_s + \"\\n\\t\"\n end\n else\n message += result[1] + \"; \"\n end\n end\n\n report_test_result(test_name, status, message)\nend",
"def test_concatonation_3\n find = Finder.new\n node1 = Minitest::Mock.new\n node2 = Minitest::Mock.new\n node3 = Minitest::Mock.new\n node4 = Minitest::Mock.new\n def node1.ch; 'C'; end\n def node1.id; '1'; end\n def node2.ch; 'A'; end\n def node2.id; '2'; end\n def node3.ch; 'K'; end\n def node3.id; '3'; end\n def node4.ch; 'E'; end\n def node4.id; '4'; end\n arr = [[node1, node2], [node2, node3], [node4]]\n arr3 = find.concatonation(arr)\n assert_equal arr3, [[node1, node2, node3], [node4]]\n end",
"def merge(left, right)\n results = []\n\n while (left.length > 0 && right.length > 0)\n if (left[0] < right[0])\n results.push( left.shift() )\n else\n results.push( right.shift() )\n end\n end\n # return a new array. Take everything in results and add it to the array.\n # Take everything in left and add them in.\n # Take everything in right and add them as well.\n # One array will be empty after while loop finishes\n return [*results, *left, *right]\nend",
"def beer(arr, x, y)\n build = Array.new \n arr << x << y \nend",
"def beer(arr, x, y)\n\tbuild = Array.new\n\tarr << x << y \nend",
"def test_resta\n assert_equal 7,@a.resta(@b).num\n assert_equal 2,@a.resta(@b).denom\n end",
"def merge(list1,list2)\n x1 = list1.length\n x2 = list2.length\n out = []\n if x1 == 0 || x2 == 0 ; return out = list1 + list2 else\n x = x1 + x2 # add both lengths for # of steps\n x1 -= 1 # -1 to equal index.last\n x2 -= 1 # ^\n while x > 0 \n if list1[x1] > list2[x2] \n if x1 > -1; out.unshift(list1[x1])\n else out.unshift(list2[x2]); x2 -= 1 end\n x1 -= 1 \n elsif list1[x1] < list2[x2]\n if x2 > -1; out.unshift(list2[x2])\n else out.unshift(list1[x1]); x1 -= 1 end\n x2 -= 1\n else \n out.unshift(list2[x2],list1[x1])\n x1 -= 1\n x2 -= 1\n x -= 1 # extra count down cuz pushing 2 equal elements\n end\n x -= 1\n end\n out\n end\nend",
"def method2(x, y, z)\n z = []\n x > y ? x == 0 : x == x\n\n until x>=y\n puts \"At the top x is #{x}\"\n z.push(x)\n\n x = x +1\n puts \"Numbers now: #{z}\"\n puts \"At the bottom x is #{x}\"\n end\nend",
"def ruby_rush(current_locaiton)\n print_start(@number)\n if @num_of_turns > 1\n loop do\n dig(current_locaiton, @rng) # return whether finished with the current location\n @num_of_turns -= 1 # update the count\n break if @num_of_turns.zero?\n\n previous_location = current_locaiton.name\n current_locaiton = current_locaiton.go_to_next(@rng) # go to next location\n print_heading(previous_location, current_locaiton.name) # print heading from and to\n end\n end\n dig(current_locaiton, @rng) # return whether finished with the current location\n show_rush_result(@day, @number, @total_ruby_found) # print the result of rubyist rush\n end",
"def add_to_array(x, y)\n combined_array = x\n combined_array.push(y)\nend",
"def find_outer(x, y, array, result)\n start_x = x\n start_y = y\n\n until array[x].empty?\n result << array[x].shift\n end\n\n x += 1\n \n until array[x].nil? || array[x].empty?\n result << array[x].pop\n x += 1\n end\n \n x -= 1\n \n until array[x].empty?\n result << array[x].pop\n end\n\n x -= 1\n \n until array[x].empty?\n result << array[x].shift\n x -= 1\n end\n \n x, y = start_x, start_y\n return if array.flatten.empty?\n \n find_outer(x + 1, y + 1, array, result)\nend",
"def test(arr_a,arr_b)\n arr = []\n arr_a.each do |num|\n arr_b.each do |num_two|\n if num == num_two\n arr << num\n end \n end\n end\n arr\nend",
"def test_difference_two_from_one\n array = []\n array_one = [1,2,3,4,5]\n array_two = [2,5,9]\n array = array_one &! array_two\n assert_equal [9], array\n end",
"def test_merge\n # Arrange\n cases = [{input: [0, 3, 2, 1, 4], expected: [0, 1, 3, 2, 4]}]\n cases.each { |test_case|\n input = test_case[:input]\n mid = input[input.length/2]\n lo = 0\n hi = input.length - 1\n expected_output = test_case[:expected]\n @aux = Array.new(input.length)\n\n # Act\n output = standard_merge(input, lo, mid, hi)\n\n # Assert\n assert_equal(expected_output, output)\n }\n end",
"def test_crosshatch_success\n result = @sudoku_1.crosshatch(@sudoku_1.squares[1], 1)\n assert_equal([2, 4, 1], result)\n end",
"def test_merge_abutting_2\n x = IntegerRange.new(1, 4)\n y = IntegerRange.new(5, 10)\n\n assert_equal(y.mergeable?(x), true)\n y.merge(x)\n\n assert_equal(y.bottom, 1)\n assert_equal(y.top, 10)\n assert_equal(y.to_a, (1..10).to_a)\n\n a = each_to_a(y)\n\n assert_equal(a, (1..10).to_a)\n end",
"def union(a,b)\n len1=a.length\n len2=b.length\n ctr1=0\n ctr2=0\n puts \"Union of the gives arrays:\"\n while (ctr1<len1 && ctr2<len2)\n if a[ctr1]==b[ctr2]\n print \"#{a[ctr1]} \"\n ctr1+=1\n ctr2+=1\n elsif a[ctr1]<b[ctr2]\n print \"#{a[ctr1]} \"\n ctr1+=1\n else\n print \"#{b[ctr2]} \"\n ctr2+=1\n end\n end\n \n #Printing remaining elements(if any)\n while ctr1<len1\n print \"#{a[ctr1]} \"\n ctr1+=1\n end\n while ctr2<len2\n print \"#{b[ctr2]} \"\n ctr2+=1\n end\n \nend",
"def testHelper arr, description, expected\n\tresult = leastOccuringValueInArray(arr)\n\tString resultType = result.class\n\t \n\tString testStatus = \"Failed\"\n\tif (leastOccuringValueInArray(arr).class == expected.class)\n\t\t(leastOccuringValueInArray(arr) == expected)? testStatus = \"Passed\" : testStatus = \"Failed\"\n\tend\n\t\n\t# Print test results\n\tputs \"| \" + testStatus + \" | \" + description + \", expected: \" + expected.to_s + \"(\" + expected.class.to_s + \")\" + \", actual: \" + result.to_s + \"(\" + resultType.to_s + \")\"\nend",
"def combine(left, right) ## will not call combine within combine\n\t# create a results array\n<<<<<<< HEAD\n\tresults = []\n\t# check that we have elements to compare\n\t# until there is nothing left in the right or left arrays:\n\tuntil left.length == 0 || right.length == 0\n\t# push the smaller element into the results array and then get rid of it (slice!).\n\t\tif left[0] <= right[0]\n\t\t\tresults.push(left.slice!(0))\n\t\telse\n\t\t\tresults.push(right.slice!(0))\n\t\tend\n\tend\n\t# Add the arrays to each other if they're not nil.\n\tresults += left if !left.nil?\n\tresults += right if !right.nil?\n\treturn results\n=======\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n\t\t# push the smaller element onto the result array\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\n>>>>>>> dab67fda06d0a272bd575d9f294d4c234c05b701\nend",
"def /\n a = pop\n b = pop\n push b / a\n end",
"def display_merge_sort(array, expected_array, test_msg)\n puts \"===========================================\"\n puts \"\\nInput array: \" + test_msg\n p array\n result = merge_sort(array)\n puts \"\\nSorted array:\"\n p result\n puts \"\\nExpected output is:\"\n p expected_array\n puts \"\\n===========================================\"\nend",
"def array_diff(a,b)\n box = []\n i = 0\n while i < a.length\n if a[i] == b [i]\n puts true\n else\n puts false\n box << a[i]\n end\n i += 1\n end\n i += 1\n return p box\nend",
"def test_calculate_negative\n \tassert_equal '0', @gold_rush.calculate(-1, 0)\n end",
"def push_remainder\n # push all remaining negatives, none correct, score of 0.\n push n.last, n.first - tn.first, 0.0\n end",
"def test_false_empty\n @eval.load_stacks([5, 5, '+'])\n assert_equal false, @eval.empty_stack\n end",
"def test_calculate\n \tassert_equal '508.16', @gold_rush.calculate(23, 25)\n end",
"def array_concat(array_1, array_2)\n array_2.each do |x|\n \tarray_1 << x\n \t\n end\n p array_1\nend",
"def bigger_two(list_1,list_2)\n puts \"running code\"\n sum_one = list_1[0] + list_1[1]\n sum_two = list_2[0] + list_2[1]\n #changed variable name to sum because thats more clear than x and y\n if sum_one > sum_two\n return list_1\n else #used else to condense code\n return list_2\n end\n if sum_two = sum_one\n return list_1\n end\nend",
"def get_test_cases()\n test_cases = []\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|X|O|X|O|*\n X|O|O|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|X\n O|O|X|X|O|X|X\n \"\"\"\n )\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|X|*|*|*|*\n *|O|X|*|*|*|X\n O|O|O|O|*|*|X\n O|O|X|X|X|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n O|X|*|*|*|*|*\n X|X|*|O|*|*|O\n O|X|*|O|*|*|X\n X|O|X|X|*|O|O\n X|O|O|X|*|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|O|O|O|O|*\n \"\"\")\n\n return test_cases\n\n end",
"def verify_operation_result(expected, actual)\n if expected.is_a?(Array)\n if expected.empty?\n expect(actual).to be_empty\n else\n expected.each_with_index do |expected_elt, i|\n # If the YAML spec test does not define a result,\n # do not assert the operation's result - the operation may\n # have produced a result, the test just does not care what it is\n if expected_elt\n verify_result(expected_elt, actual[i])\n end\n end\n end\n else\n verify_result(expected, actual)\n end\n end",
"def test_merge_sort_helper\n # Arrange\n hundred_elements = (0..100).to_a\n cases = [{input: [0], expected: [0]},\n {input: [0, 1], expected: [0, 1]},\n {input: [0, 1, 2, 5, 7], expected: [0, 1, 2, 5, 7]},\n {input: [1, 5, 2, 0], expected: [0, 1, 2, 5]},\n {input: hundred_elements.shuffle, expected: hundred_elements}]\n\n\n cases.each { |test_case|\n # Act\n @aux = Array.new(test_case[:input].length)\n actual = standard_merge_sort test_case[:input], 0, test_case[:input].length - 1\n\n # Assert\n assert_equal test_case[:expected], actual\n }\n end",
"def array_concat(array_1, array_2)\n\n while array_2.length > 1\n array_1.push {array_2.each do |array_2.length| }\n\n return array_1\n end\n\nend",
"def test_print_out_gains\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.days=10\n ruby_rush.real_rb=10\n ruby_rush.fake_rb=10\n ruby_rush.prospector=1\n assert_output(\"After 10 days, Rubyist 1 found:\\n\\t10 rubies.\\n\\t10 fake rubies.\\n\") {ruby_rush.print_out_gains}\n end",
"def test_packing_array\n array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 32000]\n assert_equal array, RubyVolt::DataType::Array.testpacking(array)[1..-1]\n end",
"def array_concat(array_1, array_2)\n array_concat = array_1 + array_2\n puts array_concat\nend",
"def test_orderOfElements\n @stack.push( 42 )\n assert_equal(@stack.top, 42)\n @stack.push( 84 )\n assert_equal(@stack.top, 84)\n @stack.pop\n assert_equal(@stack.top, 42)\n @stack.pop\n assert_nil(@stack.top)\n end",
"def simple_quicksort(array)\n left = []\n right = []\n pivot = [array.first]\n\n return [] if array.empty?\n\n quick_sort_partition(array, left, right)\n return pivot if (left + right).empty?\n\n result = simple_quicksort(left) + pivot + simple_quicksort(right)\n puts result.join(' ') unless result.empty?\n result\nend",
"def test_difference_one_from_two\n array = []\n array_one = [1,2,3,4,5]\n array_two = [2,5,9]\n array = array_one &! array_two\n assert_equal [1,3,4], array\n end",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def mergeHelper(l,r)\r\n #puts 'inside mergeHelper'\r\n sortedStorage = []\r\n # while the arrays still have elements in them, execute this loop\r\n while !l.empty? && !r.empty?\r\n if(l[0] < r[0])\r\n sortedStorage.push(l.shift)\r\n else\r\n sortedStorage.push(r.shift)\r\n end\r\n end\r\n # now that we merged the arrays, concat and return\r\n sortedStorage.concat(l,r)\r\n return sortedStorage\r\n end",
"def test_display_two\r\n assert_output(\"After 2 days, Rubyist #2 found:\\n\\t2 rubies.\\n\\t2 fake rubies.\\n\") { @g.display_rubies(2, 2, 2, 2) }\r\n end",
"def test_true_empty\n @eval.load_stacks([5, '+'])\n assert_equal true, @eval.empty_stack\n end",
"def test_example\n print_label(\"./data/aart_ruby_recursion.txt\")\n this_type = nil\n assert_equal(-1, KarateChop.chop(3, [], this_type))\n assert_equal(-1, KarateChop.chop(3, [1], this_type))\n assert_equal(0, KarateChop.chop(1, [1], this_type))\n #\n assert_equal(0, KarateChop.chop(1, [1, 3, 5], this_type))\n assert_equal(1, KarateChop.chop(3, [1, 3, 5], this_type))\n assert_equal(2, KarateChop.chop(5, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(0, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(2, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(4, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(6, [1, 3, 5], this_type))\n #\n assert_equal(0, KarateChop.chop(1, [1, 3, 5, 7], this_type))\n assert_equal(1, KarateChop.chop(3, [1, 3, 5, 7], this_type))\n assert_equal(2, KarateChop.chop(5, [1, 3, 5, 7], this_type))\n assert_equal(3, KarateChop.chop(7, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(0, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(2, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(4, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(6, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(8, [1, 3, 5, 7], this_type))\n end",
"def combine(a, b)\n\t# create a results array\n\tresults = Array.new(a.length + b.length)\n\n\t# counters pointing to the index of the smallest elements in each array\n\tindex_a = 0\n\tindex_b = 0\n\tresults_index = 0\n\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n\twhile results_index < results.length\n\t\t# if there are elements left over in b, move them to result\n\t\tif index_a == a.length\n\t\t\tresults[results_index] = b[index_b]\n\t\t\tindex_b += 1\n\t\t# if there are elements left over in a, move them to result\n\t\telsif index_b == b.length\n\t\t\tresults[results_index] = a[index_a]\n\t\t\tindex_a += 1\n\t\t# push the smaller element onto the result array\n\t\telsif a[index_a] <= b[index_b]\n\t\t\tresults[results_index] = a[index_a]\n\t\t\tindex_a += 1\n\t\telse\n\t\t\tresults[results_index] = b[index_b]\n\t\t\tindex_b += 1\n\t\tend\n\t\tresults_index += 1\n\tend\n\treturn results\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\nend",
"def iterate_arrays(id1_campaign, id2_campaign, am_reach, fb_reach)\n n = id1_campaign.length\n if ( n != id2_campaign.length )\n\traise \"The compare lists must have equal lengths\"\n end\n print_results = []*n\n\n for i in 0..(n-1)\n\tprint_results[i] = calculate_and_print( id1_campaign[i], id2_campaign[i], am_reach[i], fb_reach[i] )\n end\n\n for i in 0..(n-1)\n\tputs \" --------- Result of Comparison ----------- \\n \\n\"\n\tputs \" Run : id=\" + id1_campaign[i].to_s() + \" vs. id=\" + id2_campaign[i].to_s()+\"\\n\\n\"\n\tputs print_results[i]\n end\n\n true\nend",
"def test_results_victory\r\n assert_output(\"Going home victorious!\\n\") { @g.results(10) }\r\n end",
"def multi(x,y)\n (1..y).each do |i|\n a = []\n a << i if i % x == 0\n puts a\n end \nend",
"def merge_resultsets(result1, result2); end",
"def merge_resultsets(result1, result2); end",
"def merge(left, right, &prc)\nmerged_array = []\nprc ||= Proc.new { |num1, num2| num1 <=> num2 }\nuntil left.empty? || right.empty?\n case prc.call(left.first, right.first)\n when -1\n merged_array << left.shift\n when 0\n merged_array << left.shift\n when 1\n merged_array << right.shift\n end\nend\n\nmerged_array + left + right\nend",
"def combine(a, b)\n\t# create a results array\n\tresults = []\n\t# counters pointing to the index of the smallest elements in each array\n\tl = 0\n\tr = 0\n\t# check that we have elements to compare\n\t\t# push the smaller element onto the result array\n\tuntil results.length == a.length + b.length\n\t\tif !a[l].nil? && !b[r].nil?\n\t\t\tif a[l] <= b[r]\n\t\t\t\tresults.push(a[l])\n\t\t\t\tl += 1\n\t\t\telse\n\t\t\t\tresults.push(b[r])\n\t\t\t\tr += 1\n\t\t\tend\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\n\t\telsif !a[l].nil?\n\t\t\tresults.push(a[l])\n\t\t\tl += 1\n\t\telse\n\t\t\tresults.push(b[r])\n\t\t\tr += 1\n\t\tend\n\tend\n\treturn results\nend",
"def test_divide\n @eval.load_stacks([25, 5, '/'])\n assert_equal 5, @eval.quick_maffs_a('/')\n end",
"def test_print_results\n @d.add_book\n @d.add_book\n @d.add_book\n @d.add_book\n @d.add_dino\n @d.add_dino\n @d.add_dino\n @d.add_class\n @d.add_class\n assert_output(\"Driver 1 obtained 4 books!\\nDriver 1 obtained 3 dinosaur toys!\\nDriver 1 attended 4 classes!\\n\") { @d.print_results }\n end",
"def show_stack\n counter = 0\n new_string = ''\n if !@array_list.empty?\n # Loop for the size of the array\n while counter != @array_list.length.to_i\n # Adds the elements to the array\n new_string = if counter != @array_list.length.to_i - 1\n \"#{new_string}#{@array_list[counter]}, \"\n else\n new_string + @array_list[counter].to_s\n end\n counter += 1\n end\n else\n new_string = 'null'\n end\n # Returns the new string\n new_string\n end",
"def merge_arrays(arr_one, arr_two)\n ret = []\n while arr_one.length > 0 || arr_two.length > 0\n if arr_one[0] < arr_two[0]\n ret << arr_one.shift\n elsif arr_two[0] < arr_one[0]\n ret << arr_two.shift\n elsif arr_two.empty?\n ret += arr_one\n elsif arr_one.empty?\n ret += arr_two\n else\n ret\n end\n end\n ret\nend",
"def seventh_puzzle\n ret = []\n 10.times { ret.push(sixth_puzzle) }\n return ret\nend",
"def concat_list_take_one(list_one, list_two)\n # brute force attempt\n concatenated_array = list_one + list_two\n concatenated_array.sort!\nend",
"def end_push\n ## empty\n return [[], []]\n end",
"def result(value = [])\n @@result ||= []\n @@result << value\n value.join(\", \")\nend",
"def test_6_function_input_3_return_mined\r\n results = create_array()\r\n assert_equal(\"Mined\", results[3-1])\r\n end",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def test_2\n\t\ta = 1, 2, 3, 4\n\t\tb = [1, 2, 3, 4]\n\t\tassert_equal(a, b)\n\tend",
"def test_with_bignum; show([[10**40]]) end",
"def test_two\n\t\tmy_number = \"1234\"\n\t\tbash_numbers = [\"1233\",\"1244\",\"1255\",\"1234\"]\n\t\tassert_equal([\"1234\"],grand_bash(my_number,bash_numbers))\n\tend",
"def display_result(obj)\n\t\tnode = obj\n\t\tarr = []\n\t\tn = node.count + 1\n\t\tputs \"From #{@start} to #{@final}\"\n\t\tputs \"Total movements: #{node.count}\"\n\t\tn.times do \n\t\t\tarr << node\n\t\t\tnode = node.parent\n\t\tend\n\n\t\tarr.reverse.each do |item|\n\t\t\tp item.value\n\t\tend\n\t\texit\n\n\tend",
"def array_concat(array_1, array_2)\n array_2.each do |x|\n array_1.push x\n end\n return array_1\nend",
"def off_test_stack32_014\n rsp = exec(\": test 2 4 6 depth ;\")\n stk = stack(rsp)\n assert_equal([2, 4, 6, 3], stk)\n end",
"def array_concat(array_1, array_2)\n p array_1.concat array_2\nend",
"def merge_sort(array)\n return [] if array.empty?\n return array if array.count == 1\n retu_arr = []\n left = array[0...(array.length/2)]\n right = array[(array.length/2)..-1]\n left_sort = merge_sort(left)\n right_sort = merge_sort(right)\n \n puts \"left sort is #{left_sort}\"\n puts \"right sort is #{right_sort}\"\n \n while left_sort.empty? == false && right_sort.empty? == false\n if left_sort.first < right_sort.first\n retu_arr << left_sort.shift\n else\n retu_arr << right_sort.shift\n end\n end\n if left_sort.empty? == false\n retu_arr.concat(left_sort)\n elsif right_sort.empty? == false\n retu_arr.concat(right_sort)\n end\n puts \"retu arr is : #{retu_arr}\"\n retu_arr\n\nend",
"def match_result\n [match_x, match_y]\n end",
"def array_concat(array_1, array_2)\n if array_1.length == 0 && array_2.length == 0\n return []\n else\n x = 1\n while x <= array_2.length\n array_2.each do |new_item|\n array_1.push(new_item)\n x += 1\n end\n end\n return array_1 \n end\nend",
"def array_concat(array_1, array_2)\n array_2.each do |x|\n array_1.push(x)\n end\n return array_1\nend"
] | [
"0.5895557",
"0.5867255",
"0.583838",
"0.57620066",
"0.56787837",
"0.5641524",
"0.5628743",
"0.55312467",
"0.5474883",
"0.5435381",
"0.54129934",
"0.53561556",
"0.5318023",
"0.531553",
"0.53137696",
"0.5312709",
"0.52847123",
"0.5272771",
"0.5241636",
"0.5240005",
"0.5223984",
"0.5213298",
"0.52073014",
"0.5203012",
"0.52017653",
"0.51990867",
"0.51660734",
"0.51555055",
"0.5133722",
"0.5132155",
"0.5119389",
"0.5115209",
"0.511028",
"0.5082048",
"0.5075062",
"0.50642675",
"0.5046249",
"0.5039047",
"0.5026713",
"0.50226325",
"0.5020666",
"0.5006455",
"0.5005592",
"0.4999752",
"0.49989462",
"0.49947408",
"0.49508882",
"0.49500647",
"0.49448976",
"0.49364087",
"0.49337",
"0.49313363",
"0.49250147",
"0.49242616",
"0.4921918",
"0.49201906",
"0.49122402",
"0.49116254",
"0.490689",
"0.49063474",
"0.49047634",
"0.49041077",
"0.48972535",
"0.48953483",
"0.4892589",
"0.4887368",
"0.4885813",
"0.48851424",
"0.48842517",
"0.48840487",
"0.48779842",
"0.4876982",
"0.48721224",
"0.48717585",
"0.4864036",
"0.48625478",
"0.48621884",
"0.48546445",
"0.4854615",
"0.48509055",
"0.4850309",
"0.4849548",
"0.48415497",
"0.48411864",
"0.4838449",
"0.48363718",
"0.48330966",
"0.48304707",
"0.48265716",
"0.4821665",
"0.48214048",
"0.48198634",
"0.48176455",
"0.48163122",
"0.48112896",
"0.48106885",
"0.48078576",
"0.48066208",
"0.4806182",
"0.4803891"
] | 0.7192215 | 0 |
UNIT TEST FOR dig(location, rng) Equvalent classes: since mock_rng only return the same array that predefined, passing something other than [0,0] will loop infinitely, to see if this is true, please change the [0,0] to any other nonzero pair This test the output when only loop once | def test_dig_once
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output(" Found no rubies or fake rubies in a.\n"){@p.dig(mock_location, mock_rng)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dig(current_locaiton, rng)\n current_found = []\n while current_found != [0, 0]\n current_found = current_locaiton.random_total_ruby(rng) # digging\n @day += 1\n @total_ruby_found[0] += current_found[0] # add up the real ruby\n @total_ruby_found[1] += current_found[1] # add up the fake ruby\n print_ruby_found_in_this_location(current_locaiton, current_found)\n end\n end",
"def get_rng \n end",
"def test_go_to_next\n @l1.add_neighbors([@l2, @l3])\n mock_rng = Minitest::Mock.new('rng')\n def mock_rng.rand(x); 1; end\n assert_equal @l1.go_to_next(mock_rng), @l3 # pass\n end",
"def test_new_location_mock_zero\r\n random = Minitest::Mock.new(\"test_random\")\r\n def random.rand(num); 5; end\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.neighbor_count(index); 0; end\r\n def location.find_neighbor(index, new_index); 2; end\r\n assert_equal 2, @g.new_location(0, random, location)\r\n end",
"def test_day_output_several_real\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_output(\"\\tFound 2 rubies in Hash Crossing.\\n\") { @g.day_output([2, 0], 3, location) }\r\n end",
"def test_new_location_mock_high_bound\r\n random = Minitest::Mock.new(\"test_random\")\r\n def random.rand(num); 0; end\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.neighbor_count(index); 2; end\r\n def location.find_neighbor(index, new_index); 4; end\r\n assert_equal 4, @g.new_location(6, random, location)\r\n end",
"def test_that_getting_chars_is_accurate\n # set seed, make rng\n # set png\n # set px [0,0] of png to 'a' value and add rng val\n # call get_char_at_px with new rng and that png for [0,0]\n end",
"def test_day_output_zero\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Enumerable Canyon\"; end\r\n assert_output(\"\\tFound no rubies or no fake rubies in Enumerable Canyon.\\n\") { @g.day_output([0, 0], 3, location) }\r\n end",
"def test_random_neighbor_is_valid\n @test_neighbor_list.each do |neighbor|\n @test_loc.connect neighbor\n end\n \t5.times { assert_includes @test_neighbor_list, @test_loc.random_neighbor? }\n end",
"def test_possible_location_from_hospital_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Fourth Ave.\"\r\n\tend",
"def test_possible_location_from_hillman_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tdowntown = oakland.generate_hillman_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal downtown[0], \"Downtown\"\r\n\t\tassert_equal downtown[1][0], \"Fifth Ave.\"\r\n\tend",
"def test_link_neighbors_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tArray cities = [city1, city2]\n\t\tcity.link_neighbors cities\n\t\tassert_equal cities, city.cities\n\tend",
"def test_possible_location_from_hospital_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Foo St.\"\r\n\tend",
"def rand_location\n {lat: rand_in(40, 50), lon: rand_in(40, 80) * -1, ele: rand_in(200, 400)}\nend",
"def test_day_output_high_location\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Invalid index!') { @g.day_output([1, 1], 7, location) }\r\n end",
"def test_day_output_one\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Nil Town\"; end\r\n assert_output(\"\\tFound 1 ruby and 1 fake ruby in Nil Town.\\n\") { @g.day_output([1, 1], 3, location) }\r\n end",
"def test_cathedral_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 2; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Hillman\"\r\n\tend",
"def test_prospect\n\tmock_rng = Minitest::Mock.new(\"mock_rng\")\n\tdef mock_rng.rand;1;end\n\tmock_loc = Minitest::Mock.new(\"mock_loc\")\n\tdef mock_loc.max_gold;0;end\n\tdef mock_loc.max_silver;0;end\n p = Prospector.new(0,mock_loc,0)\n\tp.prospect(mock_rng)\n\tassert 1, p.num_days\n end",
"def check_range(rng)\n new(rng).results\n end",
"def test_day_output_one_real\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Monkey Patch City\"; end\r\n assert_output(\"\\tFound 1 ruby in Monkey Patch City.\\n\") { @g.day_output([1, 0], 3, location) }\r\n end",
"def test_that_grid_generation_is_accurate\n end",
"def test_random_neighbor_no_connections\n assert_nil @loc1.random_neighbor\n end",
"def test_next_location_valid_location\n mock_map = Minitest::Mock.new('Mock Map')\n mock_map_finder = Minitest::Mock.new('Mock Map Finder')\n joe = Prospector.new(mock_map, mock_map_finder)\n def mock_map_finder.get_location_index(_param)\n 3\n end\n assert_includes [0, 1, 2, 3, 4, 5, 6], joe.next_location(0, 1, 1)\n end",
"def test_location_0\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 0, locations)\r\n\t\tassert_equal hillman, driver.location\r\n\tend",
"def rand_point()\n \n end",
"def grab_x_loc\n rand 100\n end",
"def test_day_output_several_both\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Matzburg\"; end\r\n assert_output(\"\\tFound 2 rubies and 2 fake rubies in Matzburg.\\n\") { @g.day_output([2, 2], 3, location) }\r\n end",
"def test_doe_latin_hypercube_method_should_return_evenly_distributed_points_across_parameter_space_5_param_case\n @experiment_with_multiple_params.doe_info = [[\"latinHypercube\", [\"param-0\", \"param-1\", \"param-2\", \"param-3\", \"param-4\"]]]\n\n\n doe_method_result = @experiment_with_multiple_params.apply_doe_methods.first\n\n\n\n assert_equal \"latinHypercube\", doe_method_result[0]\n assert_equal [\"param-0\", \"param-1\", \"param-2\", \"param-3\", \"param-4\"], doe_method_result[1]\n assert_equal 6, doe_method_result[2].size\n\n level_counters = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n\n doe_method_result[2].each do |input_parameter_space_point|\n input_parameter_space_point.each_with_index do |value, index|\n level_counters[index][value / 20] += 1\n end\n end\n\n level_counters.each { |counter| assert_equal [1, 1, 1, 1, 1, 1], counter }\n end",
"def test_random_neighbor_with_no_neighbors\n \tloc = Location.new('Lonely City')\n \tassert_nil loc.random_neighbor?\n end",
"def test_next_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tcity.link_neighbors [city1, city2]\n\t\tcity = city.next\n\t\tassert_includes [city1, city2], city\n\tend",
"def test_nil_town_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_fake_rb=3\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.nil_town_search}\n end",
"def go_to_next(rng)\n choice = rng.rand([email protected])\n @neighbors[choice]\n end",
"def test_day_output_several_fakes\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Duck Type Beach\"; end\r\n assert_output(\"\\tFound 2 fake rubies in Duck Type Beach.\\n\") { @g.day_output([0, 2], 3, location) }\r\n end",
"def test_possible_location_from_cathedral_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\tmuseum = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal museum[0], \"Museum\"\r\n\t\tassert_equal museum[1][0], \"Bar St.\"\r\n\tend",
"def test_possible_location_from_museum_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Fifth Ave.\"\r\n\tend",
"def test_link_neighbors_invalid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity.link_neighbors 'here'\n\t\tassert_nil city.cities\n\tend",
"def test_day_output_negative_location\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Invalid index!') { @g.day_output([1, 1], -1, location) }\r\n end",
"def test_possible_location_from_museum_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Bar St.\"\r\n\tend",
"def test_print_location_starting\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.print_location(mocked_Graph, 0)\n\t\tassert mocked_Graph\n\tend",
"def test_all\n coords = all_combos\n coords.each do |c|\n find_route(c[0], c[1])\n end\nend",
"def test_new_location_high\r\n random = Minitest::Mock.new(\"test_random\")\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Invalid index!') { @g.new_location(7, random, location) }\r\n end",
"def test_get_gold_zero_max\n mock_loc = Minitest::Mock.new(\"mock_loc\")\n\tdef mock_loc.max_gold; 0;end\n p = Prospector.new(0, mock_loc, 0)\n\tmock_rng = Minitest::Mock.new(\"mock_rng\")\n\tdef mock_rng.rand(a);2;end\n\tassert_equal p.get_gold(mock_rng), 0\n end",
"def test_day_output_string_location\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Index must be a integer!') { @g.day_output([1, 1], 'matt', location) }\r\n end",
"def test_link_neighbors_nil\n\t\tprng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tassert_nil city.cities\n\tend",
"def test_other_start_location_false\r\n\t\tmock_driver = Minitest::Mock::new\r\n\t\tdef mock_driver.get_start_location; 3; end\r\n\t\toakland = City::new\r\n\t\tstart_loc = oakland.all_locations[mock_driver.get_start_location]\r\n\t\trefute_includes start_loc, oakland.downtown[0]\r\n\t\trefute_includes start_loc, oakland.monro[0]\r\n\tend",
"def test_computer_generates_a_number\n computer = Computer.new\n numbers = [1, 2, 3, 4]\n assert_equal \"D4\", computer.generate_coordinates\n end",
"def test_location_1\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 1, locations)\r\n\t\tassert_equal hospital, driver.location\r\n\tend",
"def test_new_location_low\r\n random = Minitest::Mock.new(\"test_random\")\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n assert_raises('Invalid Index!') { @g.new_location(-1, random, location) }\r\n end",
"def test_doe_latin_hypercube_method_should_return_evenly_distributed_points_across_parameter_space_2_param_case\n @experiment_with_multiple_params.doe_info = [[\"latinHypercube\", [\"param-0\", \"param-1\"]]]\n\n\n doe_method_result = @experiment_with_multiple_params.apply_doe_methods.first\n\n\n assert_equal \"latinHypercube\", doe_method_result[0]\n assert_equal [\"param-0\", \"param-1\"], doe_method_result[1]\n assert_equal 6, doe_method_result[2].size\n\n level_counters = [ [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0] ]\n\n doe_method_result[2].each do |input_parameter_space_point|\n input_parameter_space_point.each_with_index do |value, index|\n level_counters[index][value / 20] += 1\n end\n end\n\n level_counters.each{|counter| assert_equal [1, 1, 1, 1, 1, 1], counter}\n end",
"def test_coordinate\n result = @sudoku_1.coordinate(2, 4)\n assert_equal(0, result)\n end",
"def test_random_neighbor_one_connection\n @loc1.add_neighbor @loc2\n assert_equal @loc2, @loc1.random_neighbor\n end",
"def where_trent\n\n addresses = [\n '7 Kelly Street, Ultimo, NSW, Australia',\n '120 Spencer Street, Melbourne, VIC, Australia',\n '77 Castle Street, Castle Hill, NSW, 2154, Australia',\n '7114 Kundiman Street Sampaloc 1008 Manila Philippines'\n ]\n address = addresses.sample(1)\n\n return address\n\nend",
"def test_monroeville_from_cathedral_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tmonro = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal monro[0], \"Monroeville\"\r\n\t\tassert_equal monro[1][0], \"Fourth Ave.\"\r\n\tend",
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nHeading from a to a\n Found no rubies or fake rubies in a.\n Found no rubies or fake rubies in a.\nAfter 3 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_location_2\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 2, locations)\r\n\t\tassert_equal cathedral, driver.location\r\n\tend",
"def find_diggs\n assert_not_nil @rdigg.stories.find_diggs(\"7987660\")\n end",
"def next_loc(curr_loc)\n curr_loc = curr_loc.to_i\n return nil if curr_loc < 0 || curr_loc > 6\n range = @map[curr_loc].length - 2\n next_loc = rand_num(range).to_i\n\n next_loc += 1 if next_loc == 0\n return nil if next_loc.nil?\n\n puts \"Heading from #{@map[curr_loc][0]} to #{@map[curr_loc][next_loc]}.\"\n get_city_index(@map[curr_loc][next_loc])\n end",
"def test_hospital_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 0; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Hospital\"\r\n\tend",
"def test_random_neighbor_many_connections\n neighbor_list = [@loc2, @loc3, @loc4]\n\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.add_neighbor @loc4\n\n assert_includes neighbor_list, @loc1.random_neighbor\n end",
"def next_location(current_city, seed)\n current_city = current_city.to_i\n return nil if current_city < 0 || current_city >= 7\n range = 1\n range = @map[current_city].length - 1 unless @map[current_city].length <= 1\n next_city = random_number(seed, range).to_i\n\n next_city += 1 if next_city.zero?\n return nil if next_city.nil?\n if @visited_locations < 5\n print \"Heading from #{@map[current_city][0]} to #{@map[current_city][next_city]}\"\n print \", holding #{@silver_total} ounces of silver and #{@gold_total} ounces of gold.\"\n puts\n end\n\n # Gets next_city location on map to return\n @visited_locations += 1\n city = @map_finder.get_city_index(@map[current_city][next_city])\n city\n end",
"def test_hillman_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 3; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Museum\"\r\n\tend",
"def get_rng\n return @lower + (@upper - @lower) * Kernel.rand\n end",
"def randomLatLng()\n max_north=18.8\n min_north=14\n max_east=122\n min_east=121.5\n puts \"#{rand(min_north..max_north)},#{rand(min_east..max_east)}\"\nend",
"def test_generate_offset_return_value\n offset_generator = OffsetGenerator.new(260317)\n assert_equal String, offset_generator.generate_offset(\"a\").class\n assert_equal 1, offset_generator.generate_offset(\"a\").length\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"a\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"b\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"c\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"d\")\n end",
"def test_location_change\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_output(\"Heading from Hash Crossing to Hash Crossing.\\n\") { @g.location_change(location, 0, 0)}\r\n end",
"def test_day_output_one_fake\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Dynamic Palisades\"; end\r\n assert_output(\"\\tFound 1 fake ruby in Dynamic Palisades.\\n\") { @g.day_output([0, 1], 3, location) }\r\n end",
"def lat_range (min, max)\n lat = rand(0..(max - min)) + min\n lat\nend",
"def test_coordinate_from_array\n result = @sudoku_1.coordinate_from_array(@sudoku_1.rows[2], @sudoku_1.columns[4])\n assert_equal(0, result)\n end",
"def test_random_rubies\n loc1 = Location.new(\"location 1\", 10, 1000)\n res = loc1.random_rubies\n assert res >= 0 && res <= 10\n end",
"def test_street_used_to_go_to_downtown\r\n\t\toakland = City::new\r\n\t\tfifth = Minitest::Mock::new\r\n\t\tdef fifth.street; \"Fifth Ave.\"; end\r\n\t\tassert_includes oakland.generate_hillman_locs(oakland, 0)[1][0], fifth.street\r\n\tend",
"def test_double_create\n generator = nil\n assert_nothing_raised do\n generator = Markov::Generator.new [[1.0, \"bob\"], [0.8, \"sam\", :sam]]\n results = (0..50).map {|n| generator.one}\n assert results.include?(\"bob\")\n assert results.include?(\"sam\")\n end\n end",
"def getRandomPoint()\n while(true)\n pos = @bbox.randomPoint() ;\n return pos if(isInside(pos)) ;\n end\n end",
"def generate_coords\n coords = [0,0]\n coords[0] = rand(9)\n coords[1] = rand(9)\n coords\n end",
"def generate_seed(size, pat, zeros = nil)\n @seeded ||= nil\n y = size - pat.length \n x = size - pat[0].length\n if zeros.nil?\n @seeded = [(rand * x).floor, (rand * y).floor] if @seeded.nil?\n else\n @seeded = [0,0] if @seeded.nil?\n end\n end",
"def test_move\n mock_loc = Minitest::Mock.new \"mock_loc\"\n\tdef mock_loc.name;\"previous location\";end\n\tmock_loc2 = Minitest::Mock.new \"mock_loc2\"\n\tdef mock_loc2.name;\"next location\";end\n\tmap = Map.new\n\tmap.nodes = [mock_loc, mock_loc2]\n\tdummy_rng = Minitest::Mock.new(\"dummy_rng\")\n\tdef mock_loc.choose_neighbor(a);1;end\n p = Prospector.new(0, mock_loc, 0)\n\tp.move(dummy_rng, map)\n\tassert_equal mock_loc2, p.current_loc\n\tassert_equal 1, p.current_loc_id\n end",
"def test_next_location_negative_location\n mock_map = Minitest::Mock.new('Mock Map')\n mock_map_finder = Minitest::Mock.new('Mock Map Finder')\n joe = Prospector.new(mock_map, mock_map_finder)\n def mock_map_finder.get_location_index(_param)\n nil\n end\n assert_nil joe.next_location(-1, 1, 1)\n end",
"def test_find\n @search.adjacent_points_function = ->(current) {[-0.1, 0.1].map {|x| current + x}}\n @search.cost_function = ->(x){x - 0.1}\n assert_in_delta 0.1, @search.find\n end",
"def test_enumerable_canyon_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 1; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. enumerable_canyon_search}\n end",
"def rng(m, low, high)\n\n # cf. the parameter info at http://www.brighton-webs.co.uk/distributions/triangular.asp\n return nil unless high > low && m > low && m < high\n\n u = rand\n\n if u <= (m-low)/(high-low)\n r = low+ Math.sqrt(u*(high-low)*(m-low))\n else\n r = high - Math.sqrt((1.0-u)*(high-low)*(high-m))\n end\n\nend",
"def valid_nums(randnums)\n# exclusions = [1, 4, 6, 7, 8, 14, 16, 18, 19, 20, 24, 25, 26, 30]\nship_arr = [2, 3, 5, 9, 10, 11, 12, 13, 15, 17, 21, 22,\n 23, 27, 28, 29, 31, 32]\n\nx = ship_arr.sample\nship_arr.delete(x)\ny = ship_arr.sample\n\nrandnums = randnums.fill(x.to_i, 3..3)\nrandnums = randnums.fill(y.to_i, 8..8)\nend",
"def test_get_gold_has_max\n mock_loc = Minitest::Mock.new(\"mock_loc\")\n\tdef mock_loc.max_gold;1;end\n p = Prospector.new(0, mock_loc, 0)\n\tmock_rng = Minitest::Mock.new(\"mock_rng\")\n\tdef mock_rng.rand(a);1;end\n\tassert_equal p.get_gold(mock_rng), 1\n end",
"def search_for_rubies(loc)\n curr_city = loc.to_i\n loop do\n @total_days += 1\n real_ruby = 0\n fake_ruby = 0\n real_ruby = @rng.rand(@table[curr_city][0]) if @table[curr_city][0] > 0\n fake_ruby = @rng.rand(@table[curr_city][1]) if @table[curr_city][1] > 0\n puts \" Found #{real_ruby} real ruby and #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby == 1\n puts \" Found #{real_ruby} real rubies and #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby == 1\n puts \" Found #{real_ruby} real ruby and #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby > 1\n puts \" Found #{real_ruby} real rubies and #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby > 1\n puts \" Found #{real_ruby} real ruby in #{@map[curr_city][0]}\" if real_ruby == 1 && fake_ruby == 0\n puts \" Found #{real_ruby} real rubies in #{@map[curr_city][0]}\" if real_ruby > 1 && fake_ruby == 0\n puts \" Found #{fake_ruby} fake ruby in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby == 1\n puts \" Found #{fake_ruby} fake rubies in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby > 1\n @total_real_rubies += real_ruby\n @total_fake_rubies += fake_ruby\n puts \" Found no rubies or fake rubies in #{@map[curr_city][0]}\" if real_ruby == 0 && fake_ruby == 0\n break if real_ruby == 0 && fake_ruby == 0\n end\n end",
"def fortress_random_point\n FortressCell.where(\"mini_map_id=? and symbol=?\", mini_map.id, :concrete.to_s).sample\n end",
"def test_location_connections_empty\n assert @loc1.neighbors.empty?\n end",
"def setup_castle\r\n randomnums = Random.new\r\n zero_out\r\n treasures_allot\r\n terrors_allot\r\n set_at_room(4,6, 100 + randomnums.rand(1...100))\r\n set_at_room(16,6, 100 + randomnums.rand(1...100))\r\nend",
"def test_random_fake_rubies\n loc1 = Location.new(\"location 1\", 1000, 10)\n res = loc1.random_fake_rubies\n assert res >= 0 && res <= 10\n end",
"def test_next_location_invalid_location\n mock_map = Minitest::Mock.new('Mock Map')\n mock_map_finder = Minitest::Mock.new('Mock Map Finder')\n joe = Prospector.new(mock_map, mock_map_finder)\n def mock_map_finder.get_location_index(_param)\n nil\n end\n assert_nil joe.next_location(10, 1, 1)\n end",
"def test_confirm_point_values\n[:A,:E,:I,:O,:N,:R,:T,:L,:S,:U].each{|num| assert_equal 1, TileBag.points_for(num.to_sym)}\n\n[:D,:G].each{|num| assert_equal 2, TileBag.points_for(num.to_sym)}\n[:B,:C,:M,:P].each{|num| assert_equal 3, TileBag.points_for(num.to_sym)}\n[:F,:H,:V,:W,:Y].each{|num| assert_equal 4, TileBag.points_for(num.to_sym)}\n[:K].each{|num| assert_equal 5, TileBag.points_for(num.to_sym)} \n[:J,:X].each{|num| assert_equal 8, TileBag.points_for(num.to_sym)} \n[:Q,:Z].each{|num| assert_equal 10, TileBag.points_for(num.to_sym)} \n end",
"def test_neighbors_returns_an_array\n assert @cell.neighbors.is_a?(Array)\n end",
"def random_coord(min, max)\n rand * (max-min) + min\nend",
"def test_next_location_invalid_location_seven\n mock_map = Minitest::Mock.new('Mock Map')\n mock_map_finder = Minitest::Mock.new('Mock Map Finder')\n joe = Prospector.new(mock_map, mock_map_finder)\n def mock_map_finder.get_location_index(_param)\n nil\n end\n assert_nil joe.next_location(7, 1, 1)\n end",
"def next_location(rando)\n random = Random.new(rando.seed)\n @neighbors[random.rand([email protected])]\n end",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end",
"def random(tg,faulty,replacements,n)\n get_mappings(faulty,replacements).sample\nend",
"def test_random_total_ruby\n mock_rng = Minitest::Mock.new('rng')\n def mock_rng.rand(x); 1; end\n def random_fake_ruby(mock_rng); 1; end\n def random_real_ruby(mock_rng); 1; end\n assert_equal @l1.random_total_ruby(mock_rng), [1, 1]\n end",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def test_finding_paths_4\n find = Finder.new\n arr = []\n arr3 = find.finding_paths(arr)\n assert_equal arr3, []\n end",
"def test_get_location_index_zero\n finder = MapLocationFinder.new\n assert_nil finder.get_location_index(0)\n end",
"def test_location_get_neighbors\n\t\tneighbors_1 = [\"Hogwarts\"]\n\t\tloc = Location::new(\"Location\", neighbors_1)\n\t\tassert_equal neighbors_1, loc.get_neighbors\n\tend",
"def test_prospect_gold_positive\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcheck = city.prospect_gold\n\t\tassert_includes (0..7), check\n\tend"
] | [
"0.65181816",
"0.61968327",
"0.58114105",
"0.58022386",
"0.5738806",
"0.57243747",
"0.5701427",
"0.55380976",
"0.5530091",
"0.550793",
"0.55027753",
"0.54968274",
"0.54933864",
"0.5485736",
"0.5479253",
"0.5443515",
"0.5435742",
"0.5435286",
"0.54314697",
"0.53941715",
"0.5392196",
"0.5378573",
"0.53560627",
"0.5355676",
"0.5346979",
"0.534686",
"0.53375214",
"0.5325241",
"0.5321011",
"0.5298839",
"0.5297487",
"0.52905405",
"0.5259641",
"0.5257418",
"0.5251508",
"0.5243209",
"0.5228959",
"0.522098",
"0.52077955",
"0.5186107",
"0.51822835",
"0.5170513",
"0.51683795",
"0.5161024",
"0.51480985",
"0.51406205",
"0.51384",
"0.51360273",
"0.51322377",
"0.5122786",
"0.51218647",
"0.5115888",
"0.51124394",
"0.5108071",
"0.51032937",
"0.5102616",
"0.50974",
"0.50933117",
"0.50870055",
"0.5081861",
"0.5070502",
"0.50689036",
"0.5062365",
"0.50539",
"0.50457513",
"0.5019504",
"0.50113803",
"0.5011012",
"0.50053847",
"0.5001126",
"0.49961874",
"0.49905887",
"0.49879706",
"0.49804243",
"0.49747786",
"0.497374",
"0.49727207",
"0.4961501",
"0.4959349",
"0.49512184",
"0.49430895",
"0.49430272",
"0.4927029",
"0.49218553",
"0.49075955",
"0.49049872",
"0.49034733",
"0.4901888",
"0.48790562",
"0.48732504",
"0.48687205",
"0.4866599",
"0.48658225",
"0.48635",
"0.4862147",
"0.48587683",
"0.4855166",
"0.4852331",
"0.4849155",
"0.4848646"
] | 0.7199725 | 0 |
UNIT TEST FOR ruby_rush(location) Equvalent classes: no turns to make more than 1 turn This test when no turn is needed EDGE CASE | def test_ruby_rush_no_turn
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(1, 0, mock_rng)
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #1 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
After 1 days, Rubyist 1 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_turns_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_duck_type_beach\n assert_includes ['Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def test_move_turns_enumerable_canyon_to_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_enumerable_canyon\n assert_includes ['Duck Type Beach', 'Monkey Patch City'], ruby_rush.city\n \n end",
"def test_move_turns_hash_crossing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_hash_crossing\n assert_includes ['Matzburg', 'Nil Town', 'Dynamic Palisades'], ruby_rush.city\n end",
"def test_move_turns_matzburgh\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_matzburgh\n assert_includes ['Monkey Patch City', 'Duck Type Beach', 'Hash Crossing', 'Dynamic Palisades'], ruby_rush.city\n end",
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nHeading from a to a\n Found no rubies or fake rubies in a.\n Found no rubies or fake rubies in a.\nAfter 3 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_move_turns_dynamic_palisades\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_dynamic_palisades\n assert_includes ['Matzburg', 'Hash Crossing'], ruby_rush.city\n end",
"def test_move_turns_nil_town\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_nil_town\n assert_includes ['Monkey Patch City', 'Hash Crossing'], ruby_rush.city\n end",
"def test_move_turns_monkey_patch_city\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_monkey_patch_city\n assert_includes ['Nil Town', 'Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def ruby_rush(current_locaiton)\n print_start(@number)\n if @num_of_turns > 1\n loop do\n dig(current_locaiton, @rng) # return whether finished with the current location\n @num_of_turns -= 1 # update the count\n break if @num_of_turns.zero?\n\n previous_location = current_locaiton.name\n current_locaiton = current_locaiton.go_to_next(@rng) # go to next location\n print_heading(previous_location, current_locaiton.name) # print heading from and to\n end\n end\n dig(current_locaiton, @rng) # return whether finished with the current location\n show_rush_result(@day, @number, @total_ruby_found) # print the result of rubyist rush\n end",
"def play_turn(board, search_depth); raise 'not implemented'; end",
"def test_ruby_rush_no_rubyist\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(0, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #0 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 0 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_for_not_cathedral\n testLocation = LocationNode.new(\"Hillman\",nil,nil,nil,nil)\n assert_equal false, incrementClass(testLocation)\n end",
"def test_knight_moves(knight, initial, final, msg_condition)\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n \"\n puts \"Testing knight_moves method...\"\n puts \"\\nCondition: #{msg_condition}\"\n puts \"\\nInitial knight location = [#{knight.cur_location[0]}, #{knight.cur_location[1]}]\"\n puts \"\\nInitial: [#{initial[0]}, #{initial[1]}], Final: [#{final[0]}, #{final[1]}]\\n \"\n knight.knight_moves(initial, final)\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n \"\nend",
"def test_single_capture\n\t\tmygame=CheckersGame.new\n\t\tmygame.move('c3','d4').move('f6','e5')\n\t\t# +---+---+---+---+---+---+---+---+\n\t\t#\th | | r | | r | | r | | r | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\tg | r | | r | | r | | r | | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\tf | | r | | r | | . | | r | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\te | . | | . | | r | | . | | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\td | | . | | b | | . | | . | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\tc | b | | . | | b | | b | | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\tb | | b | | b | | b | | b | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\ta | b | | b | | b | | b | | \n\t\t#\t +---+---+---+---+---+---+---+---+\n\t\t#\t\t1 2 3 4 5 6 7 8 \n\t\tmygame.move('d4','f6')\n\t\t#assert_equal(CheckersGame.new.remove('c','3').place('f','6',CheckersGame::Square::BLACK,false).toggle_turn,mygame)\n\t\t\n\tend",
"def determine_moves(loc)\n\n piece = @spaces[loc]\n\n moveset = []\n attackset = []\n new_moves = []\n\n x = loc[0]\n y = loc[1]\n\n enemy_king_checked = false\n\n\n case piece.type\n\n when \"pawn\"\n\n if piece.color == \"white\"\n\n new_moves << [x, y+1]\n new_moves << [x,y+2] if y == 1\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if y == 1\n\n end\n\n atk_moves = [[x+1, y+1], [x-1, y+1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"black\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"black\" and @spaces[move].type == \"king\"\n end\n end\n \n\n elsif piece.color == \"black\"\n\n new_moves = [[x, y-1]]\n new_moves << [x,y-2] if y == 6\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if loc[1] == 6\n\n end\n\n atk_moves = [[x+1, y-1], [x-1, y-1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"white\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"white\" and @spaces[move].type == \"king\"\n end\n end\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n \n\n when \"rook\"\n\n runner(loc, :north)\n runner(loc, :east)\n runner(loc, :south)\n runner(loc, :west)\n\n when \"knight\"\n\n possible_directions =\n [ [x+1, y+2],\n [x+1, y-2],\n [x-1, y+2],\n [x-1, y-2],\n [x+2, y+1],\n [x+2, y-1],\n [x-2, y+1],\n [x-2, y-1] ]\n\n moveset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and @spaces[d].nil?\n end\n\n attackset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and (@spaces[d].nil?.! and @spaces[d].color != @spaces[loc].color)\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n\n\n when \"bishop\"\n\n runner(loc, :northeast)\n runner(loc, :southeast)\n runner(loc, :northwest)\n runner(loc, :southwest)\n\n\n when \"queen\"\n\n runner(loc, :north)\n runner(loc, :northeast)\n runner(loc, :east)\n runner(loc, :southeast)\n runner(loc, :south)\n runner(loc, :southwest)\n runner(loc, :west)\n runner(loc, :northwest)\n\n\n when \"king\"\n\n runner(loc, :north, 1)\n runner(loc, :northeast, 1)\n runner(loc, :east, 1)\n runner(loc, :southeast, 1)\n runner(loc, :south, 1)\n runner(loc, :southwest, 1)\n runner(loc, :west, 1)\n runner(loc, :northwest, 1)\n\n end\n\n\n end",
"def test_leaving_first_3_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\tassert p.leaving?\n end",
"def test_leaving_first_3_false_gold_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def get_move\n #puts \"get_move for #{self}\"\n return [] if goal == nil or goal == []\n while(1)\n rv = []\n g = goal.shift\n return [] if g == nil\n puts g.join('---')\n case g[0]\n when KILL\n e = g[1] # get the ennemy\n if(not $map.exists?(e) or e.life<=0)\n puts 'this ant does not exists anymore or is dead, next goal'\n next \n end\n \n dist = distance(self,e)\n #puts \"I am #{self}\"\n #puts \"goal: kill this enneny: #{e}\"\n i = 0\n if dist > 1 # move\n # by doing this we are finding subgoals\n # TODO: add_sub_goal ?\n\n path = find_best_way(e.x,e.y)# we have to move next to it\n #puts ppath(path)\n if path==nil\n # TODO: no path, find something else to do\n puts 'no path ! , next goal'\n next\n end\n \n # we have a path to it\n # so now we have to move smartly\n # if we are at 3 cases, we can move and attack\n # more than that we have to move at 4 cases and wait the next turn\n # TODO: do not wait at a position where we can be attacked\n if(path.size-2 <= 3) # minus two because the path include our case\n i = path.size-2 # 0 based minus one, so -2 \n #puts 's1'\n elsif(path.size-2 >= 6) # we are far away\n i = 6\n #puts 's2'\n else\n i = (path.size-2)\n #puts 's3'\n end\n #puts i\n #sleep(1)\n if i <= 0\n puts \"i <= 0 (#{i}), #{ppath(path)}\"\n sleep(5)\n else\n a,b = path[i][0]\n #puts \"I am moving to (#{[a,b].join(',')})\"\n self.x,self.y = a,b\n rv << \"Cb#{object_id}~\"+[a,b].pack('cc')\n #puts x\n end\n end\n return rv if i > 3 # return if we can not attack at the same round\n #puts i\n dist = distance(self,e)\n if dist == 1\n puts 'Attack'\n rv << \"Cc#{object_id}~#{e.object_id}\"\n e.life -= 5\n end\n return rv\n else\n puts 'unknown goal, next goal'\n end # case\n end #while\n puts \"no goal ? find something else to do !\"\n rv\n end",
"def test_way_generator\n \tassert_equal 1, @gold_rush.way_generator(1)\n end",
"def test_taking_turns\r\n pl1 = ConnectNGame::Player.new(\"A\", \"OK\", :silicon)\r\n pl2 = ConnectNGame::Player.new(\"B\", \"GOOD\", :carbon)\r\n\r\n game = ConnectNGame::Game.new(pl1, pl2).game_initialize\r\n\r\n assert_equal(4, game.rack.order)\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(1, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(2, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(3, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(4, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(5, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(6, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:victory, game.next_move)\r\n assert_equal(7, game.turn)\r\n end",
"def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end",
"def test_nil_town_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_fake_rb=3\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.nil_town_search}\n end",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end",
"def test_leaving_first_3_false_both_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 3\n\tp.silver_found = 4\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def test_travel_iteration_six\n fake_state = Minitest::Mock.new\n assert_equal([8, 7], @game.travel(6, fake_state, 8, 7))\n end",
"def test_leaving_first_3_false_silver_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 1\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end",
"def test_scenario2\n r = robot\n r.turn_left\n assert_equal('0,0,WEST', r.report)\n end",
"def test_should_kill_with_more_than_3_neighbours\n @game.state = [[1,1,1],[1,1,1],[1,1,1]]\n after = @game.evolve\n assert_equal [[0,0,0],[0,0,0],[0,0,0]],after\n end",
"def knight_moves\n\t\tnode = Square.new(@start)\n\t\t@queue << node\n\t\twhile @queue.empty? == false\n\t\t\tcurrent = @queue[0]\n\t\t\tif current.value == @final\n\t\t\t\tdisplay_result(current)\t\t\t\n\t\t\telse\n\n\t\t\t\t8.times do |num|\n\t\t\t\t\tx = current.value[0] + @row[num]\n\t\t\t\t\ty = current.value[1] + @col[num]\n\t\t\t\t\tif (x.between?(1,8) && y.between?(1,8)) && @revised.include?([x, y]) == false\n\t\t\t\t\t\tnode = Square.new([x, y])\n\t\t\t\t\t\tnode.parent = current\n\t\t\t\t\t\tnode.count = current.count + 1\n\t\t\t\t\t\t@queue << node\n\t\t\t\t\telse\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@revised << current.value\n\t\t\t\[email protected]\n\t\t\tend\n\t\tend\n\t\tputs \"NOT FOUND !!!\"\n\t\tputs \"This program presumes a 8x8 Chess Board\"\n\t\tputs \"Therefore your coordinates must be between (1, 1) and (8, 8).\"\n\tend",
"def gen_rook_moves(color, piece=:rook)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north\n if (dirs & 0x1) != 0x1\n to = from+k*8\n if i+k>7 || comrades.set?(to)\n # no further north moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south\n if (dirs & 0x2) != 0x2\n to = from-k*8\n if i<k || comrades.set?(to)\n # no further south moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving east\n if (dirs & 0x4) != 0x4\n to = from+k\n if j+k>7 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further east moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end\n \n # try moving west\n if (dirs & 0x8) != 0x8\n to = from-k\n if j-k<0 || comrades.set?(to)\n # no further east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further west moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end \n end\n end \n moves\n end",
"def move_r6(wins, player, opponent)\n taken = player + opponent # all occupied board positions\n open_corners = (@corners - (taken & @corners)) # all open corners\n open_edges = (@edges - (taken & @edges)) # all open edges\n if adj_cor_op_edg?(player, opponent) # if opponent has adjacent corners and opposing edge\n position = open_edges.sample # take a random open edge\n elsif adj_edg_op_cor?(player, opponent) # if opponent has adjacent edges and opposing corner\n position = open_corners.sample # take a random open corner, or use win/block/edge logic\n else\n position = win_check(wins, player, opponent) # otherwise use win/block/edge logic\n end\n end",
"def test_knights_repeat_moving_should_stalemate\n e = RulesEngine.new\n place_pieces(e, \"\n K - - N - - - -\n - - - - - - - -\n - - - - - - - -\n - - - - - - - -\n - - - - - - - -\n - - - - - - - -\n - - - - - - - -\n k - - n - - - -\n \")\n\n e.move!(D1, B2);\n e.move!(D8, B7);\n e.move!(B2, D1);\n e.move!(B7, D8);\n\n e.move!(D1, B2);\n e.move!(D8, B7);\n e.move!(B2, D1);\n e.move!(B7, D8);\n\n e.move!(D1, B2);\n e.move!(D8, B7);\n e.move!(B2, D1);\n e.move!(B7, D8);\n\n assert(e.draw?(Colour::WHITE))\n assert(e.draw?(Colour::BLACK))\n end",
"def obstructed?(current_pos,other_pos,board)\n # debugger\n tester = other_pos\n # puts tester\n # sleep 2\n\n #\n # (-1..1).each do |i|\n # (-1..1).each do |j|\n\n\n if other_pos[0] > current_pos[0] #New position is below us\n if other_pos[1] > current_pos[1] #new position is on our right--bishop move\n tester[0] -= 1\n tester[1] -= 1\n until tester == current_pos\n # puts board.grid[tester[0]][tester[1]]\n # puts !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n # sleep 2\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n # return false if the piece at tester is not a nul piece\n tester[0] -= 1\n tester[1] -= 1\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[0] -= 1\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n elsif other_pos[1] == current_pos[1] #new position is on our level horizontally\n until tester == current_pos\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n end\n\n elsif other_pos[0] < current_pos[0] #New position is above us\n if other_pos[1] > current_pos[1] #new position is on our right\n until tester == current_pos\n tester[0] += 1\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[0] += 1\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n else #new position is on our level horizontally\n until tester == current_pos\n tester[0] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n end\n\n else #new position is at our level vertically\n if other_pos[1] > current_pos[1] #new position is on our right\n until tester == current_pos\n tester[1] -= 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n elsif other_pos[1] < current_pos[1] #new position on our left\n until tester == current_pos\n tester[1] += 1\n return false if !board.grid[tester[0]][tester[1]].is_a?(Nul_piece)\n end\n\n end\n end\n\n return false if board.grid[other_pos[0]][other_pos[1]].color == self.color\n # puts \"hello\"\n # sleep(2)\n true\n\n end",
"def test_exposed_check_by_move\n board = ChessBoard.new\n piece = Knight.new(:white)\n board.add(piece, 'd4')\n\n board.add(King.new(:white), 'd1')\n board.add(Rook.new(:black), 'd8')\n\n refute(piece.valid_move?('d4', 'e6', board), 'Knight cannot expose king to check')\n end",
"def test_scenario3\n r = Robot.new(1, 2, 'EAST')\n r.move(table)\n r.move(table)\n r.turn_left\n r.move(table)\n assert_equal('3,3,NORTH', r.report)\n end",
"def test_move_less_3_succ\r\n \t@test_prospector.current_silver = 0\r\n \t@test_prospector.current_gold = 0\r\n \t@test_prospector.move_count = 1 \r\n \tassert_equal true, @test_prospector.move?\r\n end",
"def test_print_change_turn\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.last_city=\"Enumerable Canyon\"\n ruby_rush.city=\"Duck Type Beach\"\n assert_output(\"Heading from Enumerable Canyon to Duck Type Beach.\\n\") {ruby_rush.print_change_turn}\n end",
"def walkthrough()\r\n choose_winner =false \r\n choose_winner= walkthrough_test( @turn[2])\r\n \r\n\t if choose_winner ==true\r\n\t return true\r\n\t else\r\n\t return false\r\n\t end \r\n \tend",
"def test_chk_mv_pawn\n e = RulesEngine.new\n\n # cannot move a \"pawn\" from an empty square\n assert_equal(e.chk_mv(Coord.from_alg('e3'), Coord.from_alg('e4')), false)\n\n # can move one square forward\n assert_equal(e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('e3')), true)\n\n # cannot move one square forward if blocked\n e.place_piece(Coord.from_alg('e3'), Chess::Piece.new(Colour::WHITE, Chess::Piece::BISHOP))\n assert_equal(e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('e3')), false)\n\n # cannot move two squares forward if blocked\n assert(!e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('e4')))\n\n # cannot move diagonally if not a capture\n assert_equal(e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('d3')), false)\n\n # can move diagonally if a capture\n e.place_piece(Coord.from_alg('d3'), Chess::Piece.new(Colour::BLACK, Chess::Piece::BISHOP))\n assert_equal(e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('d3')), true)\n\n # cannot capture the same colored piece\n e.place_piece(Coord.from_alg('d3'), Chess::Piece.new(Colour::WHITE, Chess::Piece::BISHOP))\n assert_equal(e.chk_mv(Coord.from_alg('e2'), Coord.from_alg('d3')), false)\n\n # make sure it works both ways\n e.place_piece(Coord.from_alg('d6'), Chess::Piece.new(Colour::BLACK, Chess::Piece::BISHOP))\n assert_equal(e.chk_mv(Coord.from_alg('e7'), Coord.from_alg('f6')), false)\n end",
"def test_print_out_found_long\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=2\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n end",
"def test_rub_per_round\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.rub_per_round(mocked_Graph)\n\t\tassert mocked_Graph\n\tend",
"def test_prospect_move_no_neighbors\n \tlocation_stub = Minitest::Mock.new('Mock Location')\n \tpro = Prospector.new(1)\n \tdef location_stub.loc\n \"Laboon Lake\"\n end\n def location_stub.max_rubies\n 1\n end\n def location_stub.max_fake_rubies\n 1\n end\n def location_stub.neighbor_list\n []\n end\n pro.change_curr_location(location_stub)\n assert pro.curr_location.loc == \"Laboon Lake\"\n end",
"def possible_rook_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\t# Checks how many spaces rook can move up\n\t\tmove_up = true\n\t\ti = 1\t\t\n\t\twhile move_up && i < 8\n\t\t\tpos = [y+i, x]\n\t\t\tif pos[0] >= 8\t\n\t\t\t\tmove_up = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down\n\t\tmove_down = true\t\t\n\t\ti = 1\t\n\t\twhile move_down && i < 8\n\t\t\tpos = [y-i, x]\n\t\t\tif pos[0] < 0\t\n\t\t\t\tmove_down = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move right\n\t\tmove_right = true\t\t\n\t\ti = 1\t\n\t\twhile move_right && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move left\n\t\tmove_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_left && i < 8\n\t\t\tpos = [y, x+1]\n\t\t\tif pos[1] > 7\t\n\t\t\t\tmove_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\t\t\n\t\tcandidates\n\tend",
"def test_fun_forward_path\n\t@city = GoldRush::new\n\tassert_equal nil, @city.angels.forward_path4\n\tassert_equal nil, @city.sutter.forward_path3\n\tassert_equal nil, @city.nevada.forward_path2\n end",
"def test_should_give_birth_if_3_neighbours\n @game.state = [[1,0,0],[1,1,0],[0,0,0]]\n after = @game.evolve\n assert_equal [[1,1,1],[1,1,1],[1,1,1]],after\n end",
"def test_check_calculate_white_pawn_move\n e = RulesEngine.new\n place_pieces(e, \"\n - - - - - - - - \n - - - - - K - -\n - - - - - - - - \n k - - - - - - - \n - - - - - - - - \n - - - p - - - - \n - - - - - - - - \n - - - - - - - -\n \")\n expected = \"\n - - - - - - - - \n - - - - - - - - \n - - - - - - - - \n - - - - - - - -\n - - - @ - - - - \n - - - - - - - - \n - - - - - - - - \n - - - - - - - - \n \"\n assert_move_state(e, expected, D3);\n end",
"def test_should_kill_with_no_neighbours\n @game.state = [[1,0,0],[0,0,0],[0,0,0]]\n after = @game.evolve\n assert_equal 0,after[0][0]\n end",
"def test_total_turns_1\n \tpro = Prospector.new(1)\n \tpro.prospect_move(1)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n end",
"def move_knight\n #there is no more than eight moves\nend",
"def test_chess\r\n assert_nil(game.setup, \"This is not nil.\")\r\n assert_match(/king|queen|bishop|knight|rook|pawn/, game.promote(nil, nil), \"This is not a piece of chess.\")\r\n assert_match(/black|white/, game.take_turn, \"This is not black or white.\")\r\n assert_match(/black|white/, game.switch_players, \"This is not black or white.\")\r\n assert_match(/true|false/, game.checkmate?.to_s, \"No pass test\")\r\n assert_match(/true|false/, game.check?.to_s, \"No pass test\")\r\n\r\n assert_match(\"[\\\"+ \\\", \\\"BP \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\"]\",\r\n board.move(\"B1\", \"C1\").to_s, \"No pass test\")\r\n assert_match(/true|false/, board.king_threatened?(nil, nil).to_s, \"No pass test\")\r\n\r\n end",
"def generate_possible_moves(state)\n end",
"def test_manipulation()\n t = Turn.new([1,2,3,4])\n\n t.black_hits = 1\n t.white_hits = 1\n\n # Testen des ueberschreiben\n assert_raise(RuleViolationError) do\n t.black_hits = 2\n end\n assert_raise(RuleViolationError) do\n t.white_hits = 2\n end\n assert_equal(1, t.black_hits)\n assert_equal(1, t.white_hits)\n\n # Testen ob der Code geandert werden darf\n t.code.push(1)\n assert_equal([1,2,3,4], t.code)\n\n end",
"def test_red_move(st_x, st_y, type, moves)\n moves.each do |move|\n mv_x, mv_y = move\n if legal_red_move(st_x, st_y, mv_x, mv_y, @game.board)\n @game.board[st_y][st_x] = 0\n @game.board[mv_y][mv_x] = 2\n if king_me(mv_x, mv_y, type)\n @game.turn_count = 1\n @game.save\n return {:board => @game.board, :turn_count => @game.turn_count, :message_type => 1, :message => \"Move successful, you now have a king!\"}\n end\n else\n return {:board => @game.board, :message_type => 0, :message => \"Move unsuccessful\"}\n end\n end\n @game.turn_count = 1\n @game.save\n {:board => @game.board, :turn_count => @game.turn_count, :message_type => 1, :message => \"Move successful\"}\n end",
"def test_should_kill_with_just_one_neighbour\n @game.state = [[0,0,0],[1,0,0],[1,0,0]]\n after = @game.evolve\n assert_equal 0,after[1][0]\n assert_equal 0,after[2][0]\n end",
"def test_trivial\n @game.state=[]\n assert_equal [],@game.evolve\n @game.state=[[0]]\n assert_equal [[0]],@game.evolve\n end",
"def possible_knight_moves(start_arr)\n\t\tx = start_arr[0]\n\t\ty = start_arr[1]\n\t\tcandidates = []\n\t\tcandidates << [x+1,y+2]\n\t\tcandidates << [x+1,y-2]\n\t\tcandidates << [x-1,y+2]\n\t\tcandidates << [x-1,y-2]\n\t\tcandidates << [x+2,y+1]\n\t\tcandidates << [x+2,y-1]\n\t\tcandidates << [x-2,y+1]\n\t\tcandidates << [x-2,y+1]\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\t\tchildren.delete_if do |child|\n\t\t\tif !(@board[child] == \"*\")\n\t\t\t\tif @board[child].color == @board[start_arr].color\n\t\t\t\t\ttrue\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tchildren\n\tend",
"def possible_bishop_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\t# Checks how many spaces rook can move up & right\n\t\tmove_up_right = true\n\t\ti = 1\t\t\n\t\twhile move_up_right && i < 8\n\t\t\tpos = [y+i, x+i]\n\t\t\tif pos[0] >= 8 || pos[1] >= 8\n\t\t\t\tmove_up_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down & right\n\t\tmove_down_right = true\t\t\n\t\ti = 1\t\n\t\twhile move_down_right && i < 8\n\t\t\tpos = [y-i, x+i]\n\t\t\tif pos[0] < 0 || pos[1] >= 8\n\t\t\t\tmove_down_right = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down_right = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down_right = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move up & left\n\t\tmove_up_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_up_left && i < 8\n\t\t\tpos = [y+i, x-i]\n\t\t\tif pos[0] >= 8 || pos[1] < 0\t\n\t\t\t\tmove_up_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_up_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_up_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\n\t\t# Checks how many spaces rook can move down & left\n\t\tmove_down_left = true\t\t\n\t\ti = 1\t\n\t\twhile move_down_left && i < 8\n\t\t\tpos = [y-i, x-i]\n\t\t\tif pos[0] < 0 || pos[1] < 0\t\n\t\t\t\tmove_down_left = false\n\t\t\telse\t\n\t\t\t\tif !(@board[pos] == \"*\")\n\t\t\t\t\tif @board[pos].color == @board[start_arr].color\n\t\t\t\t\t\tmove_down_left = false\n\t\t\t\t\telsif !( @board[pos].color == @board[start_arr].color )\n\t\t\t\t\t\tcandidates << pos\n\t\t\t\t\t\tmove_down_left = false\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tcandidates << pos\n\t\t\t\tend\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\t\t\n\t\tcandidates\n\tend",
"def surge; end",
"def knight_moves(initial, final)\n @board.check_impossible_move(initial, final)\n\n search_queue = [Vertex.new(initial)]\n\n until search_queue.empty?\n test_vertex = search_queue.shift\n\n return show_path(make_path(test_vertex)) if test_vertex.value == final\n \n @board.possible_moves(test_vertex.value).each do |move|\n new_vertex = Vertex.new(move)\n new_vertex.parent = test_vertex\n test_vertex.children << move\n search_queue << new_vertex\n end \n\n end\n \"No path was found :(\"\n end",
"def test_leaving_last_2_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\tassert p.leaving?\n end",
"def play_move!( m )\n self.delete_if { |pos, piece| pos == m.to_coord || pos == m.captured_piece_coord }\n\n piece_moved = self.delete(m.from_coord)\n self[m.to_coord] = piece_moved\n\n if m.castled==1\n castling_rank = m.to_coord.rank.to_s\n [['g', 'f', 'h'], ['c', 'd', 'a']].each do |king_file, new_rook_file, orig_rook_file|\n #update the position of the rook corresponding to the square the king landed on\n\tif m.to_coord.file == king_file \n\t rook = self.delete(\"#{orig_rook_file}#{castling_rank}\")\n\t self[\"#{new_rook_file}#{castling_rank}\"] = rook\n\tend\n end\n end\n \n #TODO investigate why this method is getting called multiply per moves << Move.new\n return unless piece_moved\n ep_from_rank, ep_to_rank, ep_rank = EN_PASSANT_CONFIG[ piece_moved.side ]\n @en_passant_square = ( piece_moved.function == :pawn &&\n m.from_coord.rank == ep_from_rank && \n m.to_coord.rank == ep_to_rank ) ? m.from_coord.file + ep_rank.to_s : nil\n\n #reflect promotion\n if piece_moved && piece_moved.function == :pawn && m.to_coord.to_s.rank == piece_moved.promotion_rank\n self.delete(m.to_coord)\n self[m.to_coord] = Queen.new(piece_moved.side, :promoted)\n #puts self.to_s if m.to_coord == 'a8'\n #debugger if m.to_coord == 'a8'\n end\n \n self\n end",
"def valid_moves\n\n end",
"def prospector_journey(num_turns)\r\n i = 0\r\n while i < @prospectors.count\r\n @prospectors[i].print_start\r\n\r\n while @prospectors[i].visits < num_turns\r\n found_anything = @prospectors[i].look_for_rubies\r\n @prospectors[i].print_findings\r\n # Has more visits they can make\r\n if @prospectors[i].visits < num_turns - 1 && !found_anything\r\n @prospectors[i].move\r\n # No more visits to make, don't move again before returning\r\n elsif @prospectors[i].visits == num_turns - 1 && !found_anything\r\n break\r\n end\r\n end\r\n\r\n @prospectors[i].print_total_findings\r\n @prospectors[i].going_home\r\n\r\n i += 1\r\n end\r\nend",
"def test_move\n mock_loc = Minitest::Mock.new \"mock_loc\"\n\tdef mock_loc.name;\"previous location\";end\n\tmock_loc2 = Minitest::Mock.new \"mock_loc2\"\n\tdef mock_loc2.name;\"next location\";end\n\tmap = Map.new\n\tmap.nodes = [mock_loc, mock_loc2]\n\tdummy_rng = Minitest::Mock.new(\"dummy_rng\")\n\tdef mock_loc.choose_neighbor(a);1;end\n p = Prospector.new(0, mock_loc, 0)\n\tp.move(dummy_rng, map)\n\tassert_equal mock_loc2, p.current_loc\n\tassert_equal 1, p.current_loc_id\n end",
"def internship_passed; end",
"def walkthrough_test( object)\r\n\t counter=4\r\n\t i,j =0\r\n\t \r\n\t # This Two Loops run the intire nested hash Array along\r\n\t # Ignores all fields which are empty\r\n\t # The loop goes for each position there an object through four Methods\r\n\t # The Methods returns a number of found objects in a same line\r\n\t while i < 8\r\n\t j=0\r\n\t while j < 8\r\n\t \r\n\t if @nha2[i][j] != nil\r\n\t if @nha2[i][j] == object\r\n\t\r\n\t ru1= walkhigh(i,j,object) \r\n\t if ru1==0\r\n\t # puts \"WINNER1\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru2 = walkright(i,j,object)\r\n\t if ru2==0\r\n\t # puts \"WINNER2\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru3 = walkleft_down(i,j,object)\r\n\t if ru3==0\r\n\t # puts \"WINNER3\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru4 = walkright_down(i,j,object)\r\n\t if ru4==0\r\n\t # puts \"WINNER4\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t end\r\n\t end \r\n\t j+=1\r\n\t end \r\n\t i+=1 \r\n\t end\r\n end",
"def test_dead_cell_with_three_neighbors_lives\n assert @life.will_live?(false, 3)\n end",
"def test_live_cell_with_four_neighbors_dies\n refute @life.will_live?(true, 4)\n end",
"def bishop_moves(x, y, game)\n own_spaces = game[game[:turn]].keys\n opponent_spaces = game[@opp_turn[game[:turn]]].keys\n moves = []\n # up right\n temp_x = x + 1\n temp_y = y + 1\n while temp_x < 5 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y])\n moves.push([temp_x, temp_y])\n break if opponent_spaces.include?([temp_x, temp_y])\n temp_x += 1\n temp_y += 1\n end\n # up left\n temp_x = x - 1\n temp_y = y + 1\n while temp_x > 0 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y])\n moves.push([temp_x, temp_y])\n break if opponent_spaces.include?([temp_x, temp_y])\n temp_x -= 1\n temp_y += 1\n end\n # down right\n temp_x = x + 1\n temp_y = y - 1\n while temp_x < 5 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y])\n moves.push([temp_x, temp_y])\n break if opponent_spaces.include?([temp_x, temp_y])\n temp_x += 1\n temp_y -= 1\n end\n # down left\n temp_x = x - 1\n temp_y = y - 1\n while temp_x > 0 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y])\n moves.push([temp_x, temp_y])\n break if opponent_spaces.include?([temp_x, temp_y])\n temp_x -= 1\n temp_y -= 1\n end\n moves\nend",
"def test_location_no_neighbors\n assert_equal @l1.neighbors, [] # pass\n end",
"def test_bot_left_one_unit_per_floor_single_corridor\n num_finished_spaces = 1\n args_hash = {}\n args_hash['num_floors'] = 3\n args_hash['num_units'] = 3\n args_hash['level'] = 'Bottom'\n args_hash['corridor_position'] = 'Single Exterior (Front)'\n args_hash['horz_location'] = 'Left'\n expected_num_del_objects = {}\n expected_num_new_objects = { 'BuildingUnit' => 1, 'Surface' => 6, 'ThermalZone' => 1, 'Space' => 1, 'SpaceType' => 1, 'PeopleDefinition' => num_finished_spaces, 'People' => num_finished_spaces, 'ScheduleConstant' => 1, 'ShadingSurfaceGroup' => 2, 'ShadingSurface' => 3, 'ExternalFile' => 1, 'ScheduleFile' => 1 }\n expected_values = { 'FinishedFloorArea' => 900 * 1, 'BuildingHeight' => 8, 'Beds' => 3.0, 'Baths' => 2.0, 'NumOccupants' => 3.39, 'EavesDepth' => 2, 'NumAdiabaticSurfaces' => 1 }\n _test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, __method__)\n end",
"def movement(row1, col1, board)\n\n possible_moves=Array.new\n if @color==\"white\"\n # checking square in front\n if row1+1<8 && board.get_square(row1+1,col1).occupied==false\n possible_moves <<[row1+1,col1]\n\n #checking 2 squares forward\n if @position==\"initial\" && !board.get_square(row1+2,col1).occupied\n possible_moves <<[row1+2,col1]\n end\n end\n\n # checking attacking squares\n if row1+1<8 && col1-1>=0\n atk_sq1 = board.get_square(row1+1,col1-1)\n\n if atk_sq1.occupied && atk_sq1.piece.color != @color || !atk_sq1.occupied && atk_sq1.en_passanted\n possible_moves <<[row1+1,col1-1]\n end\n end\n if row1+1<8 && col1+1<8\n atk_sq2 = board.get_square(row1+1,col1+1)\n if atk_sq2.occupied && atk_sq2.piece.color != @color || !atk_sq2.occupied && atk_sq2.en_passanted\n possible_moves <<[row1+1,col1+1]\n end\n end\n\n elsif @color==\"black\"\n # checking square in front\n if row1-1>=0 && board.get_square(row1-1,col1).occupied==false\n possible_moves <<[row1-1,col1]\n\n # checking for 2 squares forward\n if @position==\"initial\" && board.get_square(row1-2,col1).occupied==false\n possible_moves <<[row1-2,col1]\n end\n end\n\n # checking attacking squares\n if row1-1>=0 && col1-1>=0\n atk_sq1 = board.get_square(row1-1,col1-1)\n if (atk_sq1.occupied && atk_sq1.piece.color != @color) || (!atk_sq1.occupied && atk_sq1.en_passanted)\n possible_moves <<[row1-1,col1-1]\n end\n end\n if row1-1>=0 && col1+1<8\n atk_sq2 = board.get_square(row1-1,col1+1)\n if (atk_sq2.occupied && atk_sq2.piece.color != @color) || (!atk_sq2.occupied && atk_sq2.en_passanted)\n possible_moves <<[row1-1,col1+1]\n end\n end\n end\n\n #removing moves that go off the board\n possible_moves = possible_moves.select do |a|\n a[0]>=0 && a[0]<8 && a[1]>=0 && a[1]<8\n end\n\n return possible_moves\n\n end",
"def generate_cup_bracket(teams)\n @participants = teams\n @participant_number = @participants.length\n @levels = @participant_number.log2\n @levels = (1<<(@levels) == @participant_number) ? @levels -1 : @levels\n @total_matchups = 1<<(@levels)\n (@participant_number..(2*@total_matchups - 1)).each do |x| \n @participants << nil \n end\n \n # puts @levels\n\n left_index, right_index = 1, 2\n\n @tree = [[left_index, right_index]] \n @the_nodes = [] \n @match = 0\n\n (0..@levels).each do |level|\n game = (1<<level) - 1 \n nodes = @tree[-(game+1)/2,(game+1)/2].inject([]) {|s,e| s+e} \n @the_nodes << nodes\n i = 0\n nodes.each do |index| \n opponent = ((2*(game+1)-index+1) > @participant_number) ? nil : (2*(game+1) - index+1)\n if i < game\n @tree << [index, opponent]\n # puts \"[z]: #{index} vs #{opponent}\"\n else \n @tree << [opponent, index]\n # puts \"[M]: #{index} vs #{opponent}\"\n end \n i += 1\n end \n end\n \n @tree << [left_index, right_index]\n # puts \"[Final]: #{left_index} vs #{right_index}\"\n \n # @jornada = 0\n level = @levels\n counter = @levels + 1\n while counter > 0\n game = (1<<(level)) - 1 \n i = 0\n @the_nodes[counter-1].each do |index| \n next_game= \"\"\n\n player_1 = @participants[index-1].name \n home_id = @participants[index-1].id\n\n opponent = 'Bye' \n player_2 = 'Bye' \n away_id = nil\n\n unless (2*(game+1)-index+1) > @participant_number\n opponent = (2*(game+1) - index+1) \n player_2 = @participants[opponent-1].name \n away_id = @participants[opponent-1].id\n end\n\n\n last_game = get_the_last_game\n \n if level == @levels \n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FirstGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n puts \"[#{level_in_words(level)}]: #{home_id} #{ away_id}\"\n \n else\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n\n puts \"[#{level_in_words(level)}]: #{@previous_1.id} #{ @previous_2.id}\"\n\n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'SubsequentGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end \n end\n\n level -= 1\n counter -=1\n end\n\n last_game = get_the_last_game\n \n # third place\n jornada = Game.last_cup_game(self).jornada.to_i + 1 \n @game = Game.create!(:name => level_in_words(99), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'ThirdPlaceGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n # final\n home_id = @participants[left_index-1].id\n away_id = @participants[right_index-1].id\n player_1 = @participants[left_index-1].name\n player_2 = @participants[right_index-1].name \n \n jornada = Game.last_cup_game(self).jornada.to_i + 1\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n \n puts \"[#{level_in_words(0)}]: #{@previous_1.id} #{ @previous_2.id}\"\n \n last_game = get_the_last_game\n @game = Game.create!(:name => level_in_words(0), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FinalGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end",
"def test_first_order_black_57\n # If Mr. X was last seen at node 57 and has used one black ticket, he could be at 43 or 58.\n # (This is identical to test_first_order_yellow_57, and is used as a sanity check)\n expected = [43, 58].sort\n actual = @game.possible_locations(57, [:black])\n assert_equal(expected, actual)\n end",
"def run_sim\n @continue_running = @started = true\n processed = []\n\n (0...@num_rounds).each do |round|\n puts \"Round #{round}\"\n (0...Board::BOARD_ROWS).each do |i|\n (0...Board::BOARD_COLUMNS).each do |j|\n\n Thread.stop unless continue_running? \n\n grid_object = @board.matrix[i][j]\n next if grid_object.nil? or grid_object == :Grass\n\n # do not process the same agent twice; this happens when an agent\n # moves down (to the next row) and maybe other cases\n processed.include?(grid_object) ? next : processed << grid_object\n\n options = @board.get_move_options(i,j)\n\n if grid_object.respond_to?(:evaluate_moves) then\n result = grid_object.evaluate_moves(options)\n\n # Check if we should move or delete the object\n result == :delete ? @board.delete(i,j) : move(@board.matrix,i,j,result)\n\n # Check if the agent is ready to reproduce and handle accordingly\n # NOTE: It is important to understand that the base spawn address is where\n # the agent started NOT where it was moved. That doesn't really make sense,\n # but I didn't bother to address it.\n # TODO: Fix that...\n if grid_object.ready_to_reproduce?\n grid_object.reset_food_consumption\n @board.spawn_agents(grid_object.class,i,j) \n end\n\n grid_object.decrement_life\n else\n next\n end\n\n options = nil\n sleep(@speed)\n end\n end\n\n @board.grow_grass()\n processed = []\n end\n end",
"def test_gold_rush_is_gold_rush\n assert @gold_rush.is_a?(GoldRush)\n end",
"def legal_moves\n # Fill this in\n end",
"def test_duck_type_beach_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. duck_type_beach_search}\n end",
"def test_connect_mines\n @g.connect_mines\n\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[0]], ['Duck Type Beach']\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[1]], ['Monkey Patch City']\n end",
"def main\n # Make each run\n RUNS.each do |name, data|\n # skip run?\n if data[:skip]\n puts \"Skipped '#{name}'\"\n next\n end\n\n # Process data\n target = data[:input]\n board = Board.new\n side_length = 1\n x = y = 0\n current_value = 1\n board[x, y] = current_value\n\n while current_value <= target\n # side of new ring is 2 more than previous\n side_length += 2\n # move cursor to first corner of new ring\n x += 1\n y -= 1\n # add elements for each side of the whole ring\n [[0, 1], [-1, 0], [0, -1], [1, 0]].each do |mod|\n (side_length - 1).times do\n x += mod[0]\n y += mod[1]\n current_value = board.neighbors(x, y).sum\n board[x, y] = current_value\n break if current_value > target\n end\n break if current_value > target\n end\n end\n\n # Print result\n res = board.cell_count\n success_msg = res == data[:target] ? 'succeeded' : 'failed'\n puts \"AOC17-#{PUZZLE}/#{name} #{success_msg}: #{res}, #{current_value} (Target: #{data[:target]})\"\n end\nend",
"def test_leaving_last_2_false_gold_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 2\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\trefute p.leaving?\n end",
"def next_state(state, move)\n # Deep copy position (is this the easiest way?)\n position = Marshal.load(Marshal.dump(state[:position]))\n player = state[:player]\n opp = opponent(player)\n pieces = Marshal.load(Marshal.dump(state[:pieces]))\n from = move[0]\n to = move[1]\n force_analysis = false\n check = false\n moving_piece = pieces[player].find { |piece| piece.location == from }\n if !moving_piece\n puts \"ERROR--no piece to move!\"\n end\n # Check for capture\n if position[to[0]][to[1]] != \".\"\n # Remove enemy piece\n pieces[opp].delete_if { |piece| piece.location == to }\n # Force AI to continue analysis\n force_analysis = true\n end\n # Check for promotion\n if moving_piece.class == Pawn && to[0] == end_row(player)\n # Replace pawn with queen\n # (Underpromotion not yet implemented)\n pieces[player].delete(moving_piece)\n moving_piece = Queen.new(self, to, player)\n pieces[player] << moving_piece\n end\n # Move piece\n position[from[0]][from[1]] = \".\"\n position[to[0]][to[1]] = moving_piece.icon\n moving_piece.location = to\n # Complete castling by moving rook\n if moving_piece.class == ChessKing && (from[1] - to[1]).abs == 2\n rook_column = to[1] == 6 ? 7 : 0\n castling_rook = pieces[player].find { |piece| piece.location == [from[0], rook_column] }\n if castling_rook\n rook_dest = to[1] == 6 ? 5 : 3\n position[from[0]][rook_column] = \".\"\n position[to[0]][rook_dest] = castling_rook.icon\n castling_rook.location = [to[0], rook_dest]\n else\n puts \"Castling error -- can't find rook!\"\n end\n end\n # Switch active player\n next_player = opp\n # # Create new state for testing whether king is in check\n # new_position_state = {\n # :position => position,\n # :player => player,\n # :pieces => pieces,\n # :check => false,\n # :force_analysis => false\n # }\n # # Test whether opponent's king is now in check\n # check = check?(new_position_state)\n # force_analysis = true if check\n # Return new state\n {\n :position => position,\n :player => next_player,\n :pieces => pieces,\n :check => check,\n :force_analysis => force_analysis\n }\n end",
"def test_bot_left_two_unit_per_floor_single_corridor\n num_finished_spaces = 1\n args_hash = {}\n args_hash['num_floors'] = 3\n args_hash['num_units'] = 6\n args_hash['level'] = 'Bottom'\n args_hash['corridor_position'] = 'Single Exterior (Front)'\n args_hash['horz_location'] = 'Left'\n expected_num_del_objects = {}\n expected_num_new_objects = { 'BuildingUnit' => 1, 'Surface' => 6, 'ThermalZone' => 1, 'Space' => 1, 'SpaceType' => 1, 'PeopleDefinition' => num_finished_spaces, 'People' => num_finished_spaces, 'ScheduleConstant' => 1, 'ShadingSurfaceGroup' => 2, 'ShadingSurface' => 3, 'ExternalFile' => 1, 'ScheduleFile' => 1 }\n expected_values = { 'FinishedFloorArea' => 900 * 1, 'BuildingHeight' => 8, 'Beds' => 3.0, 'Baths' => 2.0, 'NumOccupants' => 3.39, 'EavesDepth' => 2, 'NumAdiabaticSurfaces' => 2 }\n _test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, __method__)\n end",
"def test_robot_multi_obstacle\n # Build a 3 unit high wall at x=1\n obstacles = [\n {:x => 1, :y => 0},\n {:x => 1, :y => 1},\n {:x => 1, :y => 2}\n ]\n world = World.new(5, 5, obstacles)\n rover = MarsRover.new(0,0,'E', world)\n message = rover.command('F')\n assert_equal(\"Obstacle found at x:1 y:0\", message)\n message = rover.command('LFRF')\n assert_equal(\"Obstacle found at x:1 y:1\", message)\n message = rover.command('LFRF')\n assert_equal(\"Obstacle found at x:1 y:2\", message)\n message = rover.command('LFRF')\n assert_equal([1,3,'E'], rover.position)\n end",
"def test_bot_left_one_unit_per_floor_no_corridor\n num_finished_spaces = 1\n args_hash = {}\n args_hash['num_floors'] = 3\n args_hash['num_units'] = 3\n args_hash['level'] = 'Bottom'\n args_hash['corridor_position'] = 'None'\n args_hash['horz_location'] = 'Left'\n expected_num_del_objects = {}\n expected_num_new_objects = { 'BuildingUnit' => 1, 'Surface' => 6, 'ThermalZone' => 1, 'Space' => 1, 'SpaceType' => 1, 'PeopleDefinition' => num_finished_spaces, 'People' => num_finished_spaces, 'ScheduleConstant' => 1, 'ShadingSurfaceGroup' => 1, 'ShadingSurface' => 2, 'ExternalFile' => 1, 'ScheduleFile' => 1 }\n expected_values = { 'FinishedFloorArea' => 900 * 1, 'BuildingHeight' => 8, 'Beds' => 3.0, 'Baths' => 2.0, 'NumOccupants' => 3.39, 'EavesDepth' => 2, 'NumAdiabaticSurfaces' => 1 }\n _test_measure(nil, args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, __method__)\n end",
"def knight_moves(start, finish)\n tree = MoveTree.new(start)\n queue = [tree]\n result = nil\n visited_points = Set.new()\n while queue.length > 0\n current_node = queue.shift\n visited_points.add(current_node.point)\n if current_node.point == finish\n result = get_path(current_node)\n break\n else\n propagate_tree(current_node)\n queue += current_node.children.reject { |n| visited_points.include?(n.point) }\n end\n end\n result\nend",
"def test_travel_iteration_five\n fake_state = Minitest::Mock.new\n def fake_state.max_silver\n 0\n end\n\n def fake_state.max_gold\n 0\n end\n\n def fake_state.city_name\n 'test1'\n end\n\n def fake_state.edge_cities\n [Location.new('test1', 0, 0)]\n end\n\n assert_equal([6, 2], @game.travel(5, fake_state, 6, 2))\n end",
"def valid_black_rook(start,dest)\n x = start[0]; y = start[1]\n x1 = dest[0]; y1 = dest[1]\n\n xtrans = x\n ytrans = y\n\n return false if black_owned(x1,y1)\n\n #Getting the one space moves for the square around the rook\n if x1 == x+1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x-1 && y1 == y\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y+1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 == y-1\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n\n #The spaces that are +1 further away\n if x1 > x+1 && y1 == y\n while xtrans < x1-1 do\n xtrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 < x-1 && y1 == y\n while xtrans > x1+1 do\n xtrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 > y+1\n while ytrans < y1-1 do\n ytrans += 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n elsif x1 == x && y1 < y-1\n while ytrans > y1+1 do\n ytrans -= 1\n if @b[xtrans][ytrans] != \" \"\n return false #blockaded!\n end\n end\n @white_piece.push(@b[x1][y1]) if white_owned(x1,y1)\n @b[x][y] = \" \"\n @blk_rook_left_move = true if x == 0 && y == 7\n @blk_rook_right_move = true if x == 7 && y == 7\n @b[x1][y1] = @BR\n return true\n end\n return false\n end",
"def test_zeroth_order_possibilities\n # If Mr. X was last seen at node 1 and hasn't moved, he could only be at node 1.\n expected = [1]\n actual = @game.possible_locations(1, [])\n assert_equal(expected, actual)\n end",
"def test_008_phase\n assert_equal 'edge', @me.phase\n end",
"def gen_bishop_moves(color, piece=:bishop)\n moves = []\n if color == :white\n position = @position.white \n comrades = @position.white_pieces\n enemy = @position.black_pieces\n else\n position = @position.black\n comrades = @position.black_pieces\n enemy = @position.white_pieces\n end\n\n # no work to do when there are no pieces\n return moves if position[piece].nil?\n \n # for each piece\n position[piece].set_bits.each do |from| \n # [i,j] = current position\n i = from / 8\n j = from % 8\n\n #dirs flags which directions the piece is blocked\n dirs = 0\n for k in 1..7\n break if dirs == 0xf\n \n # try moving north-east\n if (dirs & 0x1) != 0x1\n to = from+k*9\n if i+k>7 || j+k>7 || comrades.set?(to)\n # no further north-east moves possible\n dirs = dirs | 0x1\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north moves possible\n dirs = dirs | 0x1 if enemy.set?(to) \n end\n end\n \n # try moving south-west\n if (dirs & 0x2) != 0x2\n to = from-k*9\n if i<k || j<k || comrades.set?(to)\n # no further south-west moves possible\n dirs = dirs | 0x2\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-west moves possible\n dirs = dirs | 0x2 if enemy.set?(to) \n end\n end\n \n # try moving north-west\n if (dirs & 0x4) != 0x4\n to = from+k*7\n if i+k>7 || j<k || comrades.set?(to)\n # no further north-west moves possible\n dirs = dirs | 0x4\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further north-west moves possible\n dirs = dirs | 0x4 if enemy.set?(to) \n end\n end \n \n # try moving south-east\n if (dirs & 0x8) != 0x8\n to = from-k*7\n if i<k || j+k>7 || comrades.set?(to)\n # no further south-east moves possible\n dirs = dirs | 0x8\n else\n moves.push [Square.index(from), Square.index(to)]\n # if it's occupied by the enemy, no further south-east moves possible\n dirs = dirs | 0x8 if enemy.set?(to) \n end\n end\n \n end\n end \n moves\n end",
"def possible_king_moves(start_arr)\n\t\tx = start_arr[0]\n\t\ty = start_arr[1]\n\t\tcandidates = []\n\t\tcandidates << [x+1,y]\n\t\tcandidates << [x-1,y]\t\t\n\t\tcandidates << [x,y+1]\t\t\t\t\n\t\tcandidates << [x,y-1]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tcandidates << [x+1,y+1]\n\t\tcandidates << [x-1,y-1]\t\n\t\tcandidates << [x-1,y+1]\t\t\t\t\n\t\tcandidates << [x+1,y-1]\t\t\t\t\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\t\tchildren.delete_if do |child|\n\t\t\tif !(@board[child] == \"*\")\n\t\t\t\t# If pieces not same color\n\t\t\t\tif @board[child].color == @board[start_arr].color\n\t\t\t\t\tif occupied(child)\n\t\t\t\t\t\tcan_do = true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tchildren\n\tend",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def test_matzburgh_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=3\n ruby_rush.real_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.matzburgh_search}\n end",
"def initialize_strategy\n main_position = player.command_centers.first.position\n _, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|\n main_position.getDistance(b) <=> main_position.getDistance(a)\n end.reverse\n overlord_target = nil\n\n #Basic Strategy:\n strategy_step \"Every idle worker should mine\" do\n precondition { player.workers.any? &:idle? }\n\n postcondition { false } #this step should be repeated\n\n order do\n center = player.command_centers.first\n\n minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|\n b.distance(center) <=> a.distance(center)\n end\n\n player.workers.select(&:idle?).each do |worker|\n worker.mine(minerals.pop)\n end\n end\n end\n\n #When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned\n strategy_step \"Spawn a drone\" do\n precondition { player.minerals >= 50 && player.supply_used < 10 }\n\n postcondition { false } #this step should be repeated\n\n order { spawn UnitType.Zerg_Drone }\n end\n\n #When there is not enough supply an overlord should be spawned\n strategy_step \"Spawn an overlord\" do\n precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart\n\n progresscondition { player.units.values.any? {|unit| unit.has_order? \"Spawn Overlord\" } }\n\n postcondition { false }#this step should be repeated\n\n order { spawn UnitType.Zerg_Overlord }\n end\n\n strategy_step \"Early overlord scout\" do\n overlord = nil\n target = nil\n\n precondition do\n overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)\n if overlords.count == 1\n overlord = overlords.first\n target = unscouted_bases.shift\n overlord_target = target\n true\n end\n end\n\n progresscondition { overlord && target }\n\n postcondition { overlord.position == target if overlord }\n\n order { overlord.move(target) if overlord }\n end\n\n strategy_step \"Drone scout\" do\n drone_scout = nil\n target = nil\n\n precondition do\n if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift\n drone_scout = player.workers.first\n true\n end\n end\n\n order do\n # TODO why is if drone_scout necessary?\n drone_scout.move(target) if drone_scout\n end\n end\n\n #At 5 supply, 200 minerals a spawning pool should be made\n strategy_step \"Make a spawning pool at 5 supply\" do\n precondition { player.minerals > 200 && player.supply_total >= 10 }\n\n postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }\n\n progresscondition { player.units.values.any? {|u| u.has_order? \"Build SpawningPool\" } }\n\n order do\n player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))\n end\n end\n\n #When there is a spawning pool and enough minerals and supply, a zergling should be made\n strategy_step \"Make zerglings\" do\n precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }\n\n precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }\n\n postcondition { false } #this step should be repeated\n\n order do\n while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do\n spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame\n end\n end\n end\n\n strategy_step \"Move in!\" do\n precondition { zerglings.count >= 1 && enemy.units.count == 0 }\n\n postcondition { false }\n\n order do\n target = unscouted_bases.shift || overlord_target\n\n zerglings.each do |z|\n puts \"Ordering zerglings to move\"\n z.move(target)\n end\n end\n end\n\n #When there are 5 zerglings, they should attack\n strategy_step \"Attack!\" do\n precondition { zerglings.count >= 5 && enemy.units.count > 0 }\n\n postcondition { false } #just keep on doin' it\n\n order do \n puts \"Ordering zerglings to attack\"\n zerglings.each { |z| attack_nearest_enemy(z) }\n end\n end\n end",
"def enum_moves\n @scratch = dup_maze(@maze)\n @locs.each_with_index do |loc, robot|\n @cost = 1\n leading_edge = [loc]\n loop do\n next_edge = []\n leading_edge.each do |x, y|\n next_edge.concat search_from(x, y, robot)\n end\n break if next_edge.empty?\n leading_edge = next_edge\n @cost += 1\n end\n end\n\n @moves\n end",
"def prospect_move(total_turns)\n @turns += 1\n if @turns == total_turns\n end_search\n else\n neighbor_index = rand(@curr_location.neighbor_list.length)\n puts \"Heading from #{@curr_location.loc} to #{@curr_location.neighbor_list[neighbor_index]}.\"\n change_curr_location(@map.get_by_name(@curr_location.neighbor_list[neighbor_index]))\n end\n end",
"def runner\nwelcome\nn = initial_round\nhit?(n)\nend"
] | [
"0.7230817",
"0.7083209",
"0.7044638",
"0.6998747",
"0.6992644",
"0.69415236",
"0.668375",
"0.6547405",
"0.63591486",
"0.6337923",
"0.63192415",
"0.62576455",
"0.61337245",
"0.6104942",
"0.6095351",
"0.6086338",
"0.6002079",
"0.6000081",
"0.59954333",
"0.59413654",
"0.5937977",
"0.59321755",
"0.59305835",
"0.5928613",
"0.58855283",
"0.5882829",
"0.58718526",
"0.58585644",
"0.5848893",
"0.5846834",
"0.5825797",
"0.58239007",
"0.58155626",
"0.58151823",
"0.58057487",
"0.5801584",
"0.5800756",
"0.57927936",
"0.5789132",
"0.5778656",
"0.5766796",
"0.5763809",
"0.57606816",
"0.5760239",
"0.5756337",
"0.57527876",
"0.57473195",
"0.57445806",
"0.5718367",
"0.57150704",
"0.5705975",
"0.5695368",
"0.56894606",
"0.5651262",
"0.5639764",
"0.5639005",
"0.5636733",
"0.5635885",
"0.562758",
"0.5625594",
"0.561678",
"0.5607018",
"0.56002235",
"0.5596804",
"0.559528",
"0.55899364",
"0.5589335",
"0.558811",
"0.55821913",
"0.55816364",
"0.5575445",
"0.5567186",
"0.55657166",
"0.5561817",
"0.55576164",
"0.554401",
"0.55435383",
"0.55409074",
"0.5531874",
"0.5531807",
"0.5527936",
"0.5527748",
"0.55242735",
"0.55172235",
"0.5514466",
"0.5505538",
"0.55041003",
"0.5503025",
"0.5500745",
"0.5500556",
"0.5491501",
"0.5488225",
"0.548076",
"0.5479218",
"0.54771155",
"0.54762673",
"0.54703695",
"0.5470078",
"0.5469111",
"0.54673946"
] | 0.680165 | 6 |
UNIT TEST FOR ruby_rush(location) Equvalent classes: no turns to make more than 1 turn This test when 0 prospector is passed, if run "ruby ruby_rush.rb", it should output nothing, however, in this case it should print Rubyist 0 EDGE CASE | def test_ruby_rush_no_rubyist
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(0, 0, mock_rng)
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #0 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
After 1 days, Rubyist 0 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nHeading from a to a\n Found no rubies or fake rubies in a.\n Found no rubies or fake rubies in a.\nAfter 3 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_ruby_rush_no_turn\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 0, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.random_total_ruby(mock_rng); [0, 0]; end\n assert_output(\"Rubyist #1 starting in Enumerable Canyon.\n Found no rubies or fake rubies in a.\nAfter 1 days, Rubyist 1 found:\n 0 rubies.\n 0 fake rubies.\nGoing home empty-handed.\\n\"){@p2.ruby_rush(mock_location)}\n end",
"def test_print_out_found_long\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=2\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n end",
"def test_print_out_mood\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_rb=10\n assert_output(\"Going home victorious!\\n\") {ruby_rush.print_out_mood}\n ruby_rush.real_rb=9\n assert_output(\"Going home sad.\\n\") {ruby_rush.print_out_mood}\n ruby_rush.real_rb=0\n assert_output(\"Going home empty-handed.\\n\") {ruby_rush.print_out_mood}\n end",
"def test_print_out_gains\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.days=10\n ruby_rush.real_rb=10\n ruby_rush.fake_rb=10\n ruby_rush.prospector=1\n assert_output(\"After 10 days, Rubyist 1 found:\\n\\t10 rubies.\\n\\t10 fake rubies.\\n\") {ruby_rush.print_out_gains}\n end",
"def test_move_turns_enumerable_canyon_to_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_enumerable_canyon\n assert_includes ['Duck Type Beach', 'Monkey Patch City'], ruby_rush.city\n \n end",
"def test_print_change_turn\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.last_city=\"Enumerable Canyon\"\n ruby_rush.city=\"Duck Type Beach\"\n assert_output(\"Heading from Enumerable Canyon to Duck Type Beach.\\n\") {ruby_rush.print_change_turn}\n end",
"def test_move_turns_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_duck_type_beach\n assert_includes ['Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def test_print_out_found_nothing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output (\"\\tFound no #{ruby_rush.real_sp} or fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_nothing}\n end",
"def test_show_rush_result\n assert_output(\"After 2 days, Rubyist 1 found:\n 10 rubies.\n 10 fake rubies.\nGoing home victorious!\\n\"){ @p.show_rush_result(2, 1, [10, 10]) }\n end",
"def test_move_turns_matzburgh\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_matzburgh\n assert_includes ['Monkey Patch City', 'Duck Type Beach', 'Hash Crossing', 'Dynamic Palisades'], ruby_rush.city\n end",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end",
"def test_nil_town_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_fake_rb=3\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.nil_town_search}\n end",
"def test_print_usage\n assert_output(\"Usage:\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns*\n*seed* should be an integer\n*num_prospectors* should be a non-negative integer\n*num_turns* should be a non-negative integer\\n\") { print_usage }\n end",
"def test_move_turns_hash_crossing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_hash_crossing\n assert_includes ['Matzburg', 'Nil Town', 'Dynamic Palisades'], ruby_rush.city\n end",
"def test_duck_type_beach_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. duck_type_beach_search}\n end",
"def test_total_turns_1\n \tpro = Prospector.new(1)\n \tpro.prospect_move(1)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n end",
"def test_move_turns_dynamic_palisades\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_dynamic_palisades\n assert_includes ['Matzburg', 'Hash Crossing'], ruby_rush.city\n end",
"def test_turn_putter_real\n pros = Prospector.new(0,0,0)\n assert pros.turn_putter(1,0).eql? \"\\tFound 1 ruby in Enumerable Canyon\"\n end",
"def ruby_rush(current_locaiton)\n print_start(@number)\n if @num_of_turns > 1\n loop do\n dig(current_locaiton, @rng) # return whether finished with the current location\n @num_of_turns -= 1 # update the count\n break if @num_of_turns.zero?\n\n previous_location = current_locaiton.name\n current_locaiton = current_locaiton.go_to_next(@rng) # go to next location\n print_heading(previous_location, current_locaiton.name) # print heading from and to\n end\n end\n dig(current_locaiton, @rng) # return whether finished with the current location\n show_rush_result(@day, @number, @total_ruby_found) # print the result of rubyist rush\n end",
"def test_rub_per_round\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.rub_per_round(mocked_Graph)\n\t\tassert mocked_Graph\n\tend",
"def test_move_turns_nil_town\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_nil_town\n assert_includes ['Monkey Patch City', 'Hash Crossing'], ruby_rush.city\n end",
"def test_move_turns_monkey_patch_city\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_monkey_patch_city\n assert_includes ['Nil Town', 'Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def test_matzburgh_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 3; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=3\n ruby_rush.real_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.matzburgh_search}\n end",
"def test_example\n print_label(\"./data/aart_ruby_recursion.txt\")\n this_type = nil\n assert_equal(-1, KarateChop.chop(3, [], this_type))\n assert_equal(-1, KarateChop.chop(3, [1], this_type))\n assert_equal(0, KarateChop.chop(1, [1], this_type))\n #\n assert_equal(0, KarateChop.chop(1, [1, 3, 5], this_type))\n assert_equal(1, KarateChop.chop(3, [1, 3, 5], this_type))\n assert_equal(2, KarateChop.chop(5, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(0, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(2, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(4, [1, 3, 5], this_type))\n assert_equal(-1, KarateChop.chop(6, [1, 3, 5], this_type))\n #\n assert_equal(0, KarateChop.chop(1, [1, 3, 5, 7], this_type))\n assert_equal(1, KarateChop.chop(3, [1, 3, 5, 7], this_type))\n assert_equal(2, KarateChop.chop(5, [1, 3, 5, 7], this_type))\n assert_equal(3, KarateChop.chop(7, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(0, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(2, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(4, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(6, [1, 3, 5, 7], this_type))\n assert_equal(-1, KarateChop.chop(8, [1, 3, 5, 7], this_type))\n end",
"def test_leaving_first_3_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\tassert p.leaving?\n end",
"def test_ruby_count_zeros\n pros = Prospector.new(0,0,0)\n assert pros.ruby_count.eql? \"After 0 days, Rubyist #0 found:\\n\\t0 rubies.\\n\\t0 fake rubies.\\n\"\n end",
"def test_turn_putter_both\n pros = Prospector.new(0,0,0)\n assert pros.turn_putter(1,1).eql? \"\\tFound 1 ruby and 1 fake ruby in Enumerable Canyon\"\n end",
"def test_turn_putter_none\n pros = Prospector.new(0,0,0)\n assert pros.turn_putter(0,0).eql? \"\\tFound no rubies or fake rubies in Enumerable Canyon\"\n end",
"def test_way_generator\n \tassert_equal 1, @gold_rush.way_generator(1)\n end",
"def test_print_location\n \t@gold_rush.initialize(2, 2)\n \tassert_equal \"Heading from Sutter Creek to Angels Camp, holding 1 ounce of gold and 0 ounces of silver.\", @gold_rush.print_location(@prospectors[0], 0)\n end",
"def test_end_search_0_turns\n \tpro = Prospector.new(1)\n \tpro.loop_prospector(0)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n \tassert pro.days == 0\n \tassert pro.turns == 0\n end",
"def test_knight_moves(knight, initial, final, msg_condition)\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n \"\n puts \"Testing knight_moves method...\"\n puts \"\\nCondition: #{msg_condition}\"\n puts \"\\nInitial knight location = [#{knight.cur_location[0]}, #{knight.cur_location[1]}]\"\n puts \"\\nInitial: [#{initial[0]}, #{initial[1]}], Final: [#{final[0]}, #{final[1]}]\\n \"\n knight.knight_moves(initial, final)\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n \"\nend",
"def test_pros_sim\r\n sim = GoldRushSim.new(1, 1)\r\n fakePros = Minitest::Mock.new(\"fake prospector\")\r\n def fakePros.location; 'Sutter Creek'; end\r\n \tdef fakePros.mine_iteration(param); 1; end\r\n \tdef fakePros.mine_last_two(param); 1; end\r\n \tdef fakePros.convert_resources(); 1; end\r\n \tdef fakePros.days; 1; end\r\n \tdef fakePros.gold; 1; end\r\n \tdef fakePros.silver; 1; end\r\n \tdef fakePros.end_messages(a, b, c, d, e); nil; end\r\n assert_equal true, sim.pros_sim(fakePros, 0)\r\n end",
"def test_real_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.real_rubies_found(7)\n\t\ttest_main.real_rubies_found(7)\n\t\tassert test_main.num_real_rubies, 14\n\tend",
"def test_for_not_cathedral\n testLocation = LocationNode.new(\"Hillman\",nil,nil,nil,nil)\n assert_equal false, incrementClass(testLocation)\n end",
"def test_monkey_patch_city_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 1; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.monkey_patch_city_search}\n end",
"def test_leaving_first_3_false_gold_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 0\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def test_dynamic_palisades_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. dynamic_palisades_search}\n end",
"def test_rubies_found_positive\n prospector = Rubyist.new(1)\n prospector.rubies_found(2, 2)\n assert prospector.real_ruby_count == 2 && prospector.fake_ruby_count == 2\n end",
"def test_leaving_first_3_false_silver_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 0\n\tp.silver_found = 1\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def test_enumerable_canyon_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 1; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush. enumerable_canyon_search}\n end",
"def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end",
"def test_leaving_first_3_false_both_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 3\n\tp.silver_found = 4\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end",
"def main\n # Make each run\n RUNS.each do |name, data|\n # skip run?\n if data[:skip]\n puts \"Skipped '#{name}'\"\n next\n end\n\n # Process data\n target = data[:input]\n board = Board.new\n side_length = 1\n x = y = 0\n current_value = 1\n board[x, y] = current_value\n\n while current_value <= target\n # side of new ring is 2 more than previous\n side_length += 2\n # move cursor to first corner of new ring\n x += 1\n y -= 1\n # add elements for each side of the whole ring\n [[0, 1], [-1, 0], [0, -1], [1, 0]].each do |mod|\n (side_length - 1).times do\n x += mod[0]\n y += mod[1]\n current_value = board.neighbors(x, y).sum\n board[x, y] = current_value\n break if current_value > target\n end\n break if current_value > target\n end\n end\n\n # Print result\n res = board.cell_count\n success_msg = res == data[:target] ? 'succeeded' : 'failed'\n puts \"AOC17-#{PUZZLE}/#{name} #{success_msg}: #{res}, #{current_value} (Target: #{data[:target]})\"\n end\nend",
"def test_chess\r\n assert_nil(game.setup, \"This is not nil.\")\r\n assert_match(/king|queen|bishop|knight|rook|pawn/, game.promote(nil, nil), \"This is not a piece of chess.\")\r\n assert_match(/black|white/, game.take_turn, \"This is not black or white.\")\r\n assert_match(/black|white/, game.switch_players, \"This is not black or white.\")\r\n assert_match(/true|false/, game.checkmate?.to_s, \"No pass test\")\r\n assert_match(/true|false/, game.check?.to_s, \"No pass test\")\r\n\r\n assert_match(\"[\\\"+ \\\", \\\"BP \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\", \\\"+ \\\"]\",\r\n board.move(\"B1\", \"C1\").to_s, \"No pass test\")\r\n assert_match(/true|false/, board.king_threatened?(nil, nil).to_s, \"No pass test\")\r\n\r\n end",
"def test_one_ruby_test\r\n rubyArr = [1,1]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1\r\n assert true\r\n end\r\n end",
"def coverage; end",
"def coverage; end",
"def test_turn_putter_fake\n pros = Prospector.new(0,0,0)\n assert pros.turn_putter(0,1).eql? \"\\tFound 1 fake ruby in Enumerable Canyon\"\n end",
"def test_ruby_string_1\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(1).eql? '1 ruby'\n end",
"def test_008_phase\n assert_equal 'edge', @me.phase\n end",
"def test_leaving_last_2_true\n p = Prospector.new(0,0,0)\n\tp.gold_found = 1\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\tassert p.leaving?\n end",
"def test_move_less_3_succ\r\n \t@test_prospector.current_silver = 0\r\n \t@test_prospector.current_gold = 0\r\n \t@test_prospector.move_count = 1 \r\n \tassert_equal true, @test_prospector.move?\r\n end",
"def test_raises_incorrect_turns_input\n assert_raises \"Should raise error when turns input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(0)\n end\n \n assert_raises \"Should raise error when turns input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(1.1)\n end\n \n assert_raises \"Should raise error when turns input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(-1.1)\n end\n \n assert_raises \"Should raise error when turns input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turns_check(\"\")\n end\n end",
"def test_print_results\n\t\ttest_main = Main.new(3, 1, 6)\n\t\tmocked_Graph = MiniTest::Mock.new(\"mocked graph\")\n\t\tmocked_Graph.expect(:get_curr_loc, Node.new(\"Enumerable Canyon\", 4, 5, 10))\n\t\ttest_main.print_results\n\t\tassert mocked_Graph\n\tend",
"def walkthrough_test( object)\r\n\t counter=4\r\n\t i,j =0\r\n\t \r\n\t # This Two Loops run the intire nested hash Array along\r\n\t # Ignores all fields which are empty\r\n\t # The loop goes for each position there an object through four Methods\r\n\t # The Methods returns a number of found objects in a same line\r\n\t while i < 8\r\n\t j=0\r\n\t while j < 8\r\n\t \r\n\t if @nha2[i][j] != nil\r\n\t if @nha2[i][j] == object\r\n\t\r\n\t ru1= walkhigh(i,j,object) \r\n\t if ru1==0\r\n\t # puts \"WINNER1\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru2 = walkright(i,j,object)\r\n\t if ru2==0\r\n\t # puts \"WINNER2\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru3 = walkleft_down(i,j,object)\r\n\t if ru3==0\r\n\t # puts \"WINNER3\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t \r\n\t ru4 = walkright_down(i,j,object)\r\n\t if ru4==0\r\n\t # puts \"WINNER4\"\r\n\t return true\r\n\t break\r\n\t end\r\n\t end\r\n\t end \r\n\t j+=1\r\n\t end \r\n\t i+=1 \r\n\t end\r\n end",
"def test_gold_rush_is_gold_rush\n assert @gold_rush.is_a?(GoldRush)\n end",
"def test_check_days\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.days=1\n assert_equal \"day\", ruby_rush.check_days\n ruby_rush.dayys=\"day\"\n ruby_rush.days=2\n assert_equal \"days\", ruby_rush.check_days\n ruby_rush.dayys=\"day\"\n end",
"def runner\nwelcome\nn = initial_round\nhit?(n)\nend",
"def test_print_ruby_found_nothing\n mock_location = Minitest::Mock.new('location')\n def mock_location.name; 'a'; end\n assert_output(\" Found no rubies or fake rubies in a.\\n\"){\n @p.print_ruby_found_in_this_location(mock_location, [0, 0])}\n end",
"def show_rush_result(day, number, total_ruby_found)\n puts \"After #{day} days, Rubyist #{number} found:\n #{total_ruby_found[0]} rubies.\n #{total_ruby_found[1]} fake rubies.\nGoing home #{mood?(total_ruby_found)}\"\n end",
"def test_manipulation()\n t = Turn.new([1,2,3,4])\n\n t.black_hits = 1\n t.white_hits = 1\n\n # Testen des ueberschreiben\n assert_raise(RuleViolationError) do\n t.black_hits = 2\n end\n assert_raise(RuleViolationError) do\n t.white_hits = 2\n end\n assert_equal(1, t.black_hits)\n assert_equal(1, t.white_hits)\n\n # Testen ob der Code geandert werden darf\n t.code.push(1)\n assert_equal([1,2,3,4], t.code)\n\n end",
"def test_amount_gold_silver\n\tassert_equal 0, @gold_rush.prospector.num_gold\n\tassert_equal 0, @gold_rush.prospector.num_silver\n end",
"def run_simulation(num_prospector, joe)\n num_prospector = num_prospector.to_i\n return nil if num_prospector < 0\n\n # Iterate through each turn\n success = 1\n count = 0\n y = 0\n puts \"\\nRubyist #{num_prospector} starting in #{@map[y][0]}\"\n while count < @num_turns\n joe.mine(count, y)\n count += 1\n y = joe.next_location(y, @seed, num_prospector) unless count >= @num_turns\n end\n success\n end",
"def test_print_items_classes\r\n\t\tmock_argv = [666]\r\n\t\tARGV.replace(mock_argv)\r\n\t\trequire_relative 'city_sim_9006'\r\n\t\tprng = Random.new((ARGV[0]))\r\n\t\toakland = City::new\r\n\t\tgame = CitySim::new\r\n\t\tall_drivers = [d1 = Driver.new(1), d2 = Driver.new(2), d3 = Driver.new(3)]\r\n\t\tnum_starting_locs = oakland.all_locations.length\r\n\t\tnum_options = 2\r\n\t\tall_items = stfu do game.run_sim(all_drivers, oakland, prng, num_starting_locs, num_options) end\r\n\t\tassert_equal all_items[2].num_classes, 16\r\n\tend",
"def test_increment_visit\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n pros.increment_visit\n assert_equal 1, pros.visited_num\n end",
"def show_usage_message\n puts('Usage: ')\n puts('ruby ruby_rush.rb *seed* *num_prospectors* *num_turns*')\n puts('*seed* should be an integer')\n puts('*num_prospectors* should be a non-negative integer')\n puts('*num_turns* should be a non-negative integer')\n exit(1)\nend",
"def test_print_mine_results_4\n map = create_towns\n p1 = Prospector::new map[0]\n ret = [0, 0]\n test_i = p1.print_mine_results ret\n assert_equal test_i, 4\n end",
"def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end",
"def test_fish_in_river()\n assert_equal(0, @river.fish_in_river())\n end",
"def play_turn(board, search_depth); raise 'not implemented'; end",
"def arg_error\r\n puts \"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns*\\n*seed* should be an integer\\n*num_prospectors*\"\\\r\n \" should be a non-negative integer\\n*num_turns* should be a non-negative integer\"\r\n exit 1\r\nend",
"def test_print_classes_negative\n\t\tassert_raises(\"Cannot have fewer than 0 classes\") { print_classes(-1,-1) }\n\tend",
"def test_run\n prospector = Rubyist.new(1)\n turns = 1\n random_generator = Minitest::Mock.new('rndm')\n def random_generator.rand(*_num)\n 0\n end\n simulator = Sim.new(prospector, turns, random_generator)\n assert_equal simulator.run, 'Going home empty-handed.'\n end",
"def test_calculate_negative\n \tassert_equal '0', @gold_rush.calculate(-1, 0)\n end",
"def test_print_items_classes_when_driver_starts_at_cathedral\r\n\t\tmock_argv = [16526]\r\n\t\tARGV.replace(mock_argv)\r\n\t\trequire_relative 'city_sim_9006'\r\n\t\tprng = Random.new((ARGV[0]))\r\n\t\toakland = City::new\r\n\t\tgame = CitySim::new\r\n\t\tall_drivers = [d1 = Driver.new(1)]\r\n\t\tnum_starting_locs = oakland.all_locations.length\r\n\t\tnum_options = 2\r\n\t\tall_items = stfu do game.run_sim(all_drivers, oakland, prng, num_starting_locs, num_options) end\r\n\t\tassert_equal all_items[0].num_classes, 2\r\n\tend",
"def test_dsl_6\n #--------------------------------------------\n show Rock + Paper + Scissors + Lizard + Spock\n #--------------------------------------------\n assert_equal \\\n \"Paper covers Rock (winner Paper)\\n\" \\\n \"Scissors cut Paper (winner Scissors)\\n\" \\\n \"Scissors decapitate Lizard (winner Scissors)\\n\" \\\n \"Spock smashes Scissors (winner Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end",
"def test_rubies_found_negative\n prospector = Rubyist.new(1)\n prospector.rubies_found(-2, -2)\n assert prospector.real_ruby_count.zero? && prospector.fake_ruby_count.zero?\n end",
"def generate_cup_bracket(teams)\n @participants = teams\n @participant_number = @participants.length\n @levels = @participant_number.log2\n @levels = (1<<(@levels) == @participant_number) ? @levels -1 : @levels\n @total_matchups = 1<<(@levels)\n (@participant_number..(2*@total_matchups - 1)).each do |x| \n @participants << nil \n end\n \n # puts @levels\n\n left_index, right_index = 1, 2\n\n @tree = [[left_index, right_index]] \n @the_nodes = [] \n @match = 0\n\n (0..@levels).each do |level|\n game = (1<<level) - 1 \n nodes = @tree[-(game+1)/2,(game+1)/2].inject([]) {|s,e| s+e} \n @the_nodes << nodes\n i = 0\n nodes.each do |index| \n opponent = ((2*(game+1)-index+1) > @participant_number) ? nil : (2*(game+1) - index+1)\n if i < game\n @tree << [index, opponent]\n # puts \"[z]: #{index} vs #{opponent}\"\n else \n @tree << [opponent, index]\n # puts \"[M]: #{index} vs #{opponent}\"\n end \n i += 1\n end \n end\n \n @tree << [left_index, right_index]\n # puts \"[Final]: #{left_index} vs #{right_index}\"\n \n # @jornada = 0\n level = @levels\n counter = @levels + 1\n while counter > 0\n game = (1<<(level)) - 1 \n i = 0\n @the_nodes[counter-1].each do |index| \n next_game= \"\"\n\n player_1 = @participants[index-1].name \n home_id = @participants[index-1].id\n\n opponent = 'Bye' \n player_2 = 'Bye' \n away_id = nil\n\n unless (2*(game+1)-index+1) > @participant_number\n opponent = (2*(game+1) - index+1) \n player_2 = @participants[opponent-1].name \n away_id = @participants[opponent-1].id\n end\n\n\n last_game = get_the_last_game\n \n if level == @levels \n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FirstGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n puts \"[#{level_in_words(level)}]: #{home_id} #{ away_id}\"\n \n else\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n\n puts \"[#{level_in_words(level)}]: #{@previous_1.id} #{ @previous_2.id}\"\n\n @game = Game.create!(:name => level_in_words(level), \n :cup_id => self.id, :home_id => home_id ,:away_id => away_id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'SubsequentGame', :jornada => last_game['jornada'], \n\t\t\t :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n\t\t\t :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n\t\t\t :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n\t\t\t :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end \n end\n\n level -= 1\n counter -=1\n end\n\n last_game = get_the_last_game\n \n # third place\n jornada = Game.last_cup_game(self).jornada.to_i + 1 \n @game = Game.create!(:name => level_in_words(99), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'ThirdPlaceGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n # final\n home_id = @participants[left_index-1].id\n away_id = @participants[right_index-1].id\n player_1 = @participants[left_index-1].name\n player_2 = @participants[right_index-1].name \n \n jornada = Game.last_cup_game(self).jornada.to_i + 1\n @previous_1 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, home_id], \n :order => \"id\") \n @previous_2 = Game.find(:first, \n :conditions => [\"cup_id = ? and home_id = ? and type_name != 'GroupStage' and next_game_id is null\", self.id, away_id], \n :order => \"id\")\n \n puts \"[#{level_in_words(0)}]: #{@previous_1.id} #{ @previous_2.id}\"\n \n last_game = get_the_last_game\n @game = Game.create!(:name => level_in_words(0), :cup_id => self.id, \n :starts_at => last_game['starts_at'], :ends_at => last_game['ends_at'], \n :reminder_at => last_game['reminder_at'], :deadline_at => last_game['deadline_at'], \n :type_name => 'FinalGame', :jornada => last_game['jornada'], \n :points_for_single => POINTS_FOR_SINGLE, :points_for_double => POINTS_FOR_DOUBLE, \n :points_for_winner => POINTS_FOR_WINNER, :points_for_draw => POINTS_FOR_DRAW, \n :points_for_goal_difference => POINTS_FOR_GOAL_DIFFERENCE,\n :points_for_goal_total => POINTS_FOR_GOAL_TOTAL)\n \n @previous_1.next_game_id = @game.id\n @previous_1.save!\n @previous_2.next_game_id = @game.id\n @previous_2.save!\n end",
"def test_run_passes\n sim = Simulator.new(1, 2, 5)\n sim.setup_map\n mock_prospector = Minitest::Mock.new('Mock Prospector')\n def mock_prospector.mine(_param)\n 1\n end\n\n def mock_prospector.next_location(_param, _param2)\n 1\n end\n\n def mock_prospector.location_count\n 1\n end\n assert_equal 5, sim.run(4, mock_prospector)\n end",
"def off_test_stack32_014\n rsp = exec(\": test 2 4 6 depth ;\")\n stk = stack(rsp)\n assert_equal([2, 4, 6, 3], stk)\n end",
"def test_fun_five_prospectors\n\t@city = GoldRush::new\n\tcity.initiliaze(1,5)\n\tassert_equal 5, @city.prospectors.length\n end",
"def test_right_forward\n rover = MarsRover.new\n rover.command('RF')\n assert_equal([1,0,'E'], rover.position)\n end",
"def test_check_plural_total\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_rb=0\n ruby_rush.fake_rb=1\n assert_equal \"rubies,ruby\", ruby_rush.check_plural_total\n ruby_rush.total_real_sp='ruby'\n ruby_rush.total_fake_sp='ruby'\n ruby_rush.real_rb=1\n ruby_rush.fake_rb=0\n assert_equal \"ruby,rubies\", ruby_rush.check_plural_total\n ruby_rush.total_real_sp='ruby'\n ruby_rush.total_fake_sp='ruby'\n ruby_rush.real_rb=2\n ruby_rush.fake_rb=2\n assert_equal \"rubies,rubies\", ruby_rush.check_plural_total\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n end",
"def running_test_case; end",
"def test_scenario2\n r = robot\n r.turn_left\n assert_equal('0,0,WEST', r.report)\n end",
"def test_initialize\n rm = [@g.ruby_mines['Enumerable Canyon'].name, @g.ruby_mines['Monkey Patch City'].name, @g.ruby_mines['Nil Town'].name, @g.ruby_mines['Matzburg'].name, @g.ruby_mines['Hash Crossing'].name, @g.ruby_mines['Dynamic Palisades'].name]\n assert_equal [1, 1, ['Enumerable Canyon', 'Monkey Patch City', 'Nil Town', 'Matzburg', 'Hash Crossing', 'Dynamic Palisades'], 1, 0], [@g.seed, @g.num_prospectors, rm, @g.num_turns, @g.done]\n end",
"def test_raises_incorrect_prospectors_input\n assert_raises \"Should raise error when prospectors input is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(0)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n rb_rush.prospectors_check(1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not an integer and is less than or equal to 0!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(-1.1)\n end\n \n assert_raises \"Should raise error when prospectors input is not a number!\\n\\n\" do\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.prospectors_check(\"\")\n end\n \n end",
"def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end",
"def test_print_mine_results_2\n map = create_towns\n p1 = Prospector::new map[0]\n ret = [1, 0]\n test_i = p1.print_mine_results ret\n assert_equal test_i, 2\n end",
"def test_three_rubies_test\r\n rubyArr = [3,3]\r\n seed = 10\r\n r = Random.new(seed)\r\n numReturn = mine(rubyArr, r)\r\n if numReturn == 0 || numReturn == 1 || numReturn == 2 || numReturn == 3\r\n assert true\r\n end\r\n end",
"def test_step; end",
"def test_leaving_last_2_false_gold_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 2\n\tp.silver_found = 2\n\tp.num_loc_visited = 4\n\trefute p.leaving?\n end",
"def test_evaluate\n assert_equal(8, @LiarHand.evaluate, 'Evaluate not working for <LiarHand>, check parameters/hashmap values')\n assert_equal(7.5, @IdiotHand.evaluate, 'Evaluate not working for <IdiotHand>, check parameters/hashmap values')\n\n assert_equal(6.5, @LightHand.evaluate, 'Evaluate not working for <LightHand>, check parameters/hashmap values')\n assert_equal(0, @SpiderHand.evaluate, 'Evaluate not working for <SpiderHand>, check parameters/hashmap values')\n end",
"def test_check_end_of_rubyist_not_end\n pros = Prospector.new(3,0,0)\n def pros.moving_string(a,b); \"moving\"; end\n assert pros.check_end_of_rubyist(0,0).eql? 'moving'\n end",
"def test_stack_050\n\n @vc.parse <<EOF\n\n: test\n\n 0. 2dup 1+\n 2dup 1+\n 2dup 1+\n\n;\n\nEOF\n @vc.compile\n @vc.run\n assert_equal(:halt, @vc.vm.state)\n assert_equal(8, @vc.vm.depth)\n assert_equal(3, @vc.vm.tos)\n assert_equal(0, @vc.vm.nos)\n assert_equal(2, @vc.vm.pick(2))\n assert_equal(0, @vc.vm.pick(3))\n assert_equal(1, @vc.vm.pick(4))\n assert_equal(0, @vc.vm.pick(5))\n assert_equal(0, @vc.vm.pick(6))\n assert_equal(0, @vc.vm.pick(7))\n end",
"def test_print_mine_results_3\n map = create_towns\n p1 = Prospector::new map[0]\n ret = [0, 1]\n test_i = p1.print_mine_results ret\n assert_equal test_i, 3\n end",
"def test_top_wrap\n rover = MarsRover.new(0,4,'S', world=World.new(5,5))\n rover.command('B')\n assert_equal([0,0,'S'], rover.position)\n end"
] | [
"0.76328766",
"0.7544048",
"0.7075955",
"0.69788057",
"0.68797725",
"0.6820669",
"0.67566013",
"0.6733562",
"0.66909605",
"0.6612063",
"0.6569835",
"0.64888614",
"0.6456789",
"0.64035106",
"0.63809",
"0.63476205",
"0.63425696",
"0.6342358",
"0.6258989",
"0.62483585",
"0.6137327",
"0.6132827",
"0.60654974",
"0.6050824",
"0.60219",
"0.6019063",
"0.60137594",
"0.60069674",
"0.60037357",
"0.5934385",
"0.5891555",
"0.5883475",
"0.5846809",
"0.58156353",
"0.5813044",
"0.57847536",
"0.5782539",
"0.5779479",
"0.5763664",
"0.5753825",
"0.57374483",
"0.5715862",
"0.5707025",
"0.57017976",
"0.56919765",
"0.5643803",
"0.56343395",
"0.5627393",
"0.5623795",
"0.5623795",
"0.5606472",
"0.55988294",
"0.5567108",
"0.5551204",
"0.55445665",
"0.5539945",
"0.55244714",
"0.55237025",
"0.5522435",
"0.5521933",
"0.552139",
"0.5514542",
"0.5514351",
"0.5513237",
"0.55051774",
"0.5504252",
"0.5500831",
"0.55006987",
"0.5488148",
"0.548191",
"0.5478672",
"0.54763937",
"0.5467236",
"0.54665786",
"0.5455758",
"0.54443353",
"0.5439018",
"0.5424379",
"0.54133886",
"0.5398976",
"0.5398611",
"0.5395096",
"0.538988",
"0.5379782",
"0.5360394",
"0.53560406",
"0.5354608",
"0.5354219",
"0.5353817",
"0.5353612",
"0.5349932",
"0.53498054",
"0.53495884",
"0.53457093",
"0.53419024",
"0.5337402",
"0.5326998",
"0.53224057",
"0.5318925",
"0.5305559"
] | 0.73236626 | 2 |
This test when at least one turn is needed | def test_ruby_rush_turns
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(1, 2, mock_rng)
def mock_location.name; 'a'; end
def mock_location.go_to_next(mock_rng); [self, self][0];end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #1 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
Heading from a to a
Found no rubies or fake rubies in a.
Found no rubies or fake rubies in a.
After 3 days, Rubyist 1 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n @turns_allowed < 0\n end",
"def initial_turn?(turn)\n max_turn = @players_count\n turn <= max_turn\n end",
"def regular_turn?(turn)\n min_turn = @players_count * 2 + 1\n turn >= min_turn\n end",
"def test_take_one_turn\n turn = Turn.new(@player1, @player2)\n assert_equal :mutually_assured_destruction, turn.type\n\n @game.take_a_turn(1)\n\n assert_equal 23, @player1.deck.cards.count\n assert_equal 23, @player2.deck.cards.count\n end",
"def first_turn?\n \tturns_in_round = self.turns.where(round: self.round).count\n \tturns_in_round -= 1 if self.round == 1\n \tturns_in_round == 0\n end",
"def full?\n turn_count == 9\n end",
"def walkthrough()\r\n choose_winner =false \r\n choose_winner= walkthrough_test( @turn[2])\r\n \r\n\t if choose_winner ==true\r\n\t return true\r\n\t else\r\n\t return false\r\n\t end \r\n \tend",
"def check_for_win_condition(turn)\n # binding.pry\n @board[turn - 1][0].all?('black')\n # binding.pry\n end",
"def game_tied?\n if @number_of_turns == 9\n true\n else\n false\n end\n end",
"def take_turn\n valid_cells(@opponent_board).sample\n end",
"def toss_again?(cubes, turn_points)\n true\n end",
"def out_of_turns?\n result = !@data[@data.length-1][:key].nil?\n puts \"Out of turns!\" if result\n @out_of_turns = result\n result\n end",
"def do_turn\n return if @pw.my_planets.length == 0\n return if @pw.enemy_planets.length == 0\n return if @pw.not_my_planets.length == 0\n end",
"def check_turn\n if @turn == Turn_Enemy\n next_enemy\n elsif @turn == Turn_Player\n next_actor\n end\n end",
"def check_phase\n if @turn == Turn_Player\n if $game_system.acted.size >= (friends_of(Battler_Actor).select {|mem| !mem.death_state?}).size\n @phase_count += 1\n if @active_battler == nil\n $game_system.acted.clear\n set_turn( Turn_Enemy)\n next_enemy\n end\n end\n elsif @turn == Turn_Enemy\n if $game_system.acted.size >= (friends_of(Battler_Enemy).select {|mem| !mem.death_state?}).size\n @phase_count += 1\n if @active_battler == nil\n $game_system.acted.clear\n set_turn( Turn_Player)\n @cursor.moveto( tactics_actors.first)\n end\n end\n end\n end",
"def turn(tictactoe)\n moves_avail = @tictactoe.open_squares(p1_moves(@tictactoe),p2_moves(@tictactoe))\n\n return \"Player 1\" if moves_avail.length.odd? && tictactoe.players[0].first_to_act == \"true\"\n return \"Player 2\" if moves_avail.length.even? && tictactoe.players[0].first_to_act == \"true\"\n return \"Player 2\" if moves_avail.length.odd? && tictactoe.players[0].first_to_act == \"false\"\n return \"Player 1\" if moves_avail.length.even? && tictactoe.players[0].first_to_act == \"false\"\n end",
"def turn?\n @turn\n end",
"def who_win?\n count_turn = 0\n\n while count_turn <= 0 \n \n if @A1.content == \"O\" && @A2.content == \"O\" && @A3.content == \"O\" && @A1.content == \"X\" && @A2.content == \"X\" && @A3.content == \"X\"\n @winning_game = true \n end\n\n if @B1.content == \"O\" && @B2.content == \"O\" && @B3.content == \"O\" && @B1.content == \"X\" && @B2.content == \"X\" && @B3.content == \"X\"\n @winning_game = true \n end\n\n if @C1.content == \"O\" && @C2.content == \"O\" && @C3.content == \"O\" && @C1.content == \"X\" && @C2.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A1.content == \"O\" && @B1.content == \"O\" && @C1.content == \"O\" && @A1.content == \"X\" && @B1.content == \"X\" && @C1.content == \"X\"\n @winning_game = true \n end\n\n if @A2.content == \"O\" && @B2.content == \"O\" && @C2.content == \"O\" && @A2.content == \"X\" && @B2.content == \"X\" && @C2.content == \"X\"\n @winning_game = true \n end\n\n if @A3.content == \"O\" && @B3.content == \"O\" && @C3.content == \"O\" && @A3.content == \"X\" && @B3.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A1.content == \"O\" && @B2.content == \"O\" && @C3.content == \"O\" && @A1.content == \"X\" && @B2.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A3.content == \"O\" && @B2.content == \"O\" && @C1.content == \"O\" && @A3.content == \"X\" && @B2.content == \"X\" && @C1.content == \"X\"\n @winning_game = true \n end\n\n count_turn += 1\n end\n\n if count_turn == 9 \n equality_game = true\n end\n end",
"def test_taking_turns\r\n pl1 = ConnectNGame::Player.new(\"A\", \"OK\", :silicon)\r\n pl2 = ConnectNGame::Player.new(\"B\", \"GOOD\", :carbon)\r\n\r\n game = ConnectNGame::Game.new(pl1, pl2).game_initialize\r\n\r\n assert_equal(4, game.rack.order)\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(1, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(2, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(3, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(4, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(5, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(6, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:victory, game.next_move)\r\n assert_equal(7, game.turn)\r\n end",
"def next_turn?\n @status != :end\n end",
"def player1_next? #le joueur 1 aura toujours des nombres de tours impairs\n return false if ( turn_count % 2 == 0 )\n return true\n end",
"def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end",
"def valid_move?(index)\n puts \"Turn #{turn_count}\"\n index.between?(0,8) && !position_taken?(index)\n end",
"def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end",
"def check_only_play_once?(player, turn, done)\n played_cards = all_discards(done)\n\n valid_discards = played_cards.uniq\n\n if played_cards != valid_discards\n raise Cheating, \"Player is using cards more than once!\"\n else\n true\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |triple|\n if(winning?(board, triple))\n return triple\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |triple|\n if(winning?(board, triple))\n return triple\n end\n end\n return false\nend",
"def won?()\n WIN_COMBINATIONS.detect do |e|\n @board[e[0]] == @board[e[1]] && @board[e[1]] == @board[e[2]] && position_taken?( e[0])\n end\nend",
"def test_take_turn\n new_turn = @round.take_turn(\"Juneau\")\n # stores and returns new Turn from the take_turn method\n assert_equal [@round.take_turn(\"Juneau\")], @round.turns\n # Round moves to the next card in the deck when take_turn method is called\n assert_equal @card_2, @round.current_card\n end",
"def player_turn(player, board)\n check_the_case = false\n while check_the_case == false\n my_choice = 0\n while my_choice < 1 || my_choice > 9\n my_choice = player.call_player\n if my_choice < 1 || my_choice > 9\n p \"Ce n'est pas une commande valide!\"\n end\n end\n check_the_case = board.check_case_value(my_choice, player.number)\n end\n board.display_board\n if board.check_victory(my_choice) == true\n p \"#{player.name} a gagné!\"\n return true\n end\nend",
"def game_over?\n if $board.has_value?(\"none\") == false then\n puts \"No more turns available\"\n return true\n else\n return false\n end\n end",
"def won?\n WIN_COMBINATIONS.any? do |win_combo|\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if position_taken?(win_index_1) && position_1 == position_2 && position_2 == position_3\n #binding.pry\n return win_combo\n end\n end\n end",
"def test_any_chance_of_working \n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_no_statuses_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?)\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?(true))\n \n end",
"def won?\n WIN_COMBINATIONS.detect{|win| @board[win[0]] == @board[win[1]] && @board[win[1]] == @board[win[2]] && position_taken?(win[2])}\nend",
"def won?(board)\n WIN_COMBINATIONS.any? do |combo|\n if combo.all? do |i|\n position_taken_x?(board, i)\n end\n return combo\n puts \"Congratulations, X wins!\"\n break\n elsif combo.all? do |i|\n position_taken_o?(board, i)\n end\n return combo\n puts \"Congratulations, O wins!\"\n break\n else\n false\n end\n end\n end",
"def check_win\n\t\t\tif win\n\t\t\t\tputs \"\\n You win!\" \n\t\t\telse\n\t\t\t\t# shows how many turns remain\n\t\t\t\tputs \"\\n You have #{TURNS - @turns} turns left\"\n\t\t\tend\n\t\tend",
"def is_spare?\n sum == 10 && turn[0] != 10\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\nend",
"def nextTurnAllowed\n return (@currentPlayer.nil? or @currentPlayer.validState)\n end",
"def won?\n WIN_COMBINATIONS.detect do |win_combination|\n @board[win_combination[0]] == @board[win_combination[1]] &&\n @board[win_combination[1]] == @board[win_combination[2]] &&\n position_taken?(win_combination[0])\n end\nend",
"def get_next_present\n if last_turn?\n @game.detect {|f| !f[:final] }\n else\n @game.detect {|f| !f[:finished] }\n end\n end",
"def turn_end?\n players.all?(&:cant_take_cards?) || players.any?(&:wants_open_cards?)\n end",
"def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end",
"def test_both_players_exceed_defcon\n scenario us: 4, ussr: 5, defcon: 3\n assert_no_award\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[1]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0]+1)\n end\n end",
"def won?\n\n WIN_COMBINATIONS.find do |win_combination|\n # puts \"This is win combination #{win_combination}\"\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def won_match?\n @sets_won == 3\n end",
"def passed?\n !failed?\n end",
"def passed?\n !failed?\n end",
"def full?\n full = false\n full = true if turn_count == 9\n full\nend",
"def check(board, solution)\n available_indications = board.next_boards.map do |board_with_move|\n solution.call(board_with_move)\n end\n required_indications = (0..(@board_length - 1)).to_a\n impossible_indications = (required_indications - available_indications)\n unless impossible_indications.empty?\n puts \"no move available to indicate #{impossible_indications} for #{board}\"\n puts \"boards_with_moves #{boards_with_moves}\"\n puts \"available #{available_indications}\"\n end\n impossible_indications.empty?\n end",
"def over?(board)\n if won?(board) || draw?(board) #BE CAREFUL! If you flipped this, the test wouldn't have passed because it wouldn't stopped after the fail\n true\n end\nend",
"def test_player1_should_win\n\t\tresult = Rule.new.determine_outcome_from_tosses(\"r\", \"s\")\n\t\tassert_equal(0, result)\n\tend",
"def check_win(player)\n winning_combos.each do |winning_combo|\n if three_in_a_row(winning_combo, player)\n @winner = player\n return true\n end\n end\n \n false\n \n end",
"def won?(board)\n # cycle through WIN_COMBINATIONS\n WIN_COMBINATIONS.detect { |winning_combo|\n # print win_index\n # print '\\n'\n position_taken?(board,winning_combo[0]) &&\n position_taken?(board,winning_combo[1]) &&\n position_taken?(board,winning_combo[2]) &&\n board[winning_combo[0]] == board[winning_combo[1]] &&\n board[winning_combo[1]] == board[winning_combo[2]]\n }\nend",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def stop_game?\n finished? || user_turn?\n end",
"def test_if_it_takes_a_turn\n new_turn = @round.take_turn(\"Juneau\")\n assert_equal Turn, new_turn.class\n end",
"def won?\n WIN_COMBINATIONS.each do |triple|\n if(winning?(triple))\n return triple\n end\n end\n return false\n end",
"def won?(board)\n # !won?(board)\n WIN_COMBINATIONS.detect do |combo| # [0,1,2]\n if position_taken?(board, combo[0]) && board[combo[0]] == board[combo[1]] && board[combo[1]] == board[combo[2]]\n combo\n end\n end\nend",
"def game_turn(game, player1, player2, board)\n 1.upto(5) do |game_turn|\n # Joueur 1\n break if player_turn(player1, board) == true\n # On check la fin du game\n if game.check_end_game(game_turn) == true\n p 'Egalité !'\n break\n end\n # Joueur2\n break if player_turn(player2, board) == true\n end\n p 'Le jeu est fini!'\nend",
"def has_run?\n @passed != nil\n end",
"def won?\n ::WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == @board.cells[combo[1]] &&\n board.cells[combo[1]] == @board.cells[combo[2]] &&\n board.taken?(combo[0]+1)\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combination| #ex: [0,1,2]\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board, combination[0])\n end\nend",
"def test_both_players_level_and_exceed_defcon\n scenario us: 4, ussr: 4, defcon: 3\n assert_no_award\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | combination |\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board,combination[0])\n end\nend",
"def turn\n puts \"#{@player_1.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_1)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n puts \"#{@player_2.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_2)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] && board[combo[2]] == board[combo[1]] && position_taken?(board,combo[0])\n end\nend",
"def process_turn\n Board.each_r_c do |r, c|\n win = @board.check_win(r, c)\n unless win == :none\n @winner = true\n @winner_direction = win\n @winner_r = r\n @winner_c = c\n break\n end\n end\n # Done processing, reset flag\n @done_turn = false\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n combo.all? { |c| position_taken?( c ) && @board[c] == @board[ combo[0] ] }\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |wc|\n @board[wc[0]] == @board[wc[1]] && @board[wc[1]] == @board[wc[2]] && position_taken?(wc[0])\n end \n end",
"def take_turn(turn_value)\n turn = turn_value\n \n if turn.even? \n @player_human.move(@board)\n puts drawgrid \n is_a_human_win(@board) \n else\n @player_computer.move(@board)\n puts drawgrid \n is_a_computer_win(@board) \n end \n end",
"def won?\n the_win_combination = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n the_win_combination = win_combination\n break\n end\n end\n the_win_combination\n end",
"def won?\n [email protected]? do |card|\n !card.face_up\n end\n end",
"def finished?\n if winner \n return true\n end\n end",
"def player_turn\n # if the board has more x's then it is the computer's turn\n if @board.count(@symbol) > @board.count(@computer_symbol)\n computer_turn\n else\n users_turn\n end\n end",
"def test_guess_is_incorrect\n card = Card.new(\"Which planet is closest to the sun?\", \"Mercury\", :STEM)\n turn = Turn.new(\"Saturn\", card)\n\n refute turn.correct?\n end",
"def final?\n self.winner || self.moves.empty?\n end",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def won?(board)\n # binding.pry\n check = false\n WIN_COMBINATIONS.each do |win_combination|\n first_index = win_combination[0]\n second_index = win_combination[1]\n third_index = win_combination[2]\n\n position_1 = board[first_index]\n position_2 = board[second_index]\n position_3 = board[third_index]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n check = true\n end\n end\n check\nend",
"def won?(board)\n # binding.pry\n check = false\n WIN_COMBINATIONS.each do |win_combination|\n first_index = win_combination[0]\n second_index = win_combination[1]\n third_index = win_combination[2]\n\n position_1 = board[first_index]\n position_2 = board[second_index]\n position_3 = board[third_index]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n check = true\n end\n end\n check\nend",
"def number_correct\n @turns.count do |turn|\n turn.correct?\n end\n end",
"def done_or_not(board)\n\tif chk_horizontal(board) == true && chk_vertical(board) == true && chk_region(board) == true\n\t\t'Finished!'\n\telse \n\t\t'Try again!'\n\tend \nend",
"def won?\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n return win_combination\n end\n end\n return false\n end",
"def slot_outcomes\n ones = [1, 1, 1, 1]\n twos = [2, 2, 2, 2]\n threes = [3, 3, 3, 3]\n fours = [4, 4, 4, 4]\n if @wheel_spin == ones\n puts \"Congratulations! You won!\"\n @wallet = @wallet * 3\n elsif @wheel_spin == twos\n puts \"Congratulations! You won!\"\n @wallet = @wallet * 3\n elsif @wheel_spin == threes\n puts \"Congratulations! You won!\"\n @wallet = @wallet * 3\n elsif @wheel_spin == fours\n puts \"Congratulations! You won!\"\n @wallet = @wallet * 3\n else\n puts \"Sorry, try again!\"\n @wallet = @wallet - 1\n end\n end",
"def test_complete?\n assert(@LiarHand.complete? == true, 'Hand for <LiarHand> expected to be full but wasnt.')\n assert(@IdiotHand.complete? == true, 'Hand for <IdiotHand> expected to be full but wasnt.')\n\n assert(@LightHand.complete? == true, 'Hand for <LightHand> expected to be full but wasnt')\n assert(@SpiderHand.complete? == true, 'Hand for <SpiderHand> expected to be full but wasnt')\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |item|\n board[item[0]] == board[item[1]] && board[item[1]] == board[item[2]] && position_taken?(board, item[0])\n end\nend",
"def won?(board)\n tanda=0\n WIN_COMBINATIONS.each do |ok|\n if board[ok[0]]== \"X\" && board[ok[1]]== \"X\" && board[ok[2]]==\"X\"\n tanda=2\n return ok\n elsif board[ok[0]]== \"O\" && board[ok[1]]== \"O\" && board[ok[2]]==\"O\"\n tanda=2\n return ok\n end\n end\n if tanda==0\n return false\n end\nend",
"def valid_init_turn(accumulated_score)\n # if intial turn accumulated_score < 300, scores are not stored\n if @allowed == false && accumulated_score >= 300\n @allowed = true\n puts 'Turn score >= 300. Now your scores will be stored'\n elsif @allowed == false\n accumulated_score = 0\n puts \"Initial turn score < 300. Your scores won't be counted yet\"\n end\n accumulated_score\n end",
"def check_win\n return @this_players_turn if @table.check_table == true\n nil\n end",
"def done?(state)\n legal_moves(state).empty?\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?(board)\n\nif\n WIN_COMBINATIONS.detect do |winner|\n winner.all? {|token| board[token] == \"X\"} || winner.all? {|token| board[token] == \"O\"}\n end\nelse\n x = false\nend\nend",
"def draw?(board)\n redundant = won?(board)\n if redundant\n return false\n end\n return true\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combination|\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board, combination[0])\n end\nend",
"def draw?(board)\n #must be true for a draw, false for in progress,<<so use full? then && so that both sides must evauluate true and since it must be false for a won game >> !won?\n full?(board) && !won?(board)\nend"
] | [
"0.7382166",
"0.7101779",
"0.7051302",
"0.7045431",
"0.7043881",
"0.70234454",
"0.6897063",
"0.6800436",
"0.6782517",
"0.6708824",
"0.67020375",
"0.6700645",
"0.6686612",
"0.66621333",
"0.66278386",
"0.6560461",
"0.65486294",
"0.65314674",
"0.65277857",
"0.64799243",
"0.646396",
"0.64631623",
"0.639464",
"0.6384494",
"0.63682216",
"0.63632965",
"0.63632965",
"0.63586754",
"0.6345024",
"0.63381225",
"0.6335343",
"0.6333464",
"0.6323009",
"0.63149154",
"0.6312307",
"0.6311607",
"0.63104224",
"0.63009566",
"0.62992907",
"0.6295862",
"0.62871414",
"0.62864274",
"0.62706834",
"0.62694496",
"0.6267306",
"0.6264604",
"0.625882",
"0.62584686",
"0.6257876",
"0.6246235",
"0.6243887",
"0.6243512",
"0.6235859",
"0.6232851",
"0.62253827",
"0.62252873",
"0.62252873",
"0.62159175",
"0.6203041",
"0.6202794",
"0.6200796",
"0.6199145",
"0.61989963",
"0.6198354",
"0.61922216",
"0.6190665",
"0.61889535",
"0.61856455",
"0.6177349",
"0.61763924",
"0.61760575",
"0.6172896",
"0.6167097",
"0.6153686",
"0.6145735",
"0.6135264",
"0.61344194",
"0.61247057",
"0.6123997",
"0.6122789",
"0.6117414",
"0.61126536",
"0.61126536",
"0.6109005",
"0.61067396",
"0.6103233",
"0.6100804",
"0.6100342",
"0.6099598",
"0.60988384",
"0.60978055",
"0.60950446",
"0.60930485",
"0.609268",
"0.609268",
"0.60914475",
"0.60914475",
"0.6090833",
"0.60906464",
"0.609003",
"0.6087305"
] | 0.0 | -1 |
This method is used because, for nil values, savon will respond with an hash containing all other attributes. If we check that the expected type is matched, we can prevent to retrieve wrong values | def get_if_kind value, kind
value.kind_of?(kind) && value || nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duck_type_hash_values(hash)\n hash.inject(HashWithIndifferentAccess.new) do |corrected_hash, hash_entry|\n key = hash_entry.first\n value = hash_entry.last\n model_attribute = model_attributes[key.to_sym] || {}\n value = ActiveModel::Attributes.convert_to(model_attribute[:type], value) unless value.nil? && model_attribute[:allow_nil]\n corrected_hash[key] = value\n corrected_hash\n end\n end",
"def skip_conversion?(obj, attr, value)\n value.nil? || !obj.class.attributes.key?(attr)\n end",
"def typecast_attributes\n @attributes.each_pair do |name,value|\n # skip primary key columns\n # ajay Singh --> skip the loop if attribute is null (!name.present?)\n next if (name == \"id\") or (!name.present?)\n attr_type = attr_type_for(name)\n \n # empty attributes should stay empty (e.g. an empty int field shouldn't be typecast as 0)\n if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')\n @attributes[name] = nil\n next\n end\n \n case attr_type\n when :bool\n @attributes[name] = (value == \"1\")\n when :datetime, :datetimecombo\n begin\n @attributes[name] = DateTime.parse(value)\n rescue\n @attributes[name] = value\n end\n when :int\n @attributes[name] = value.to_i\n end\n end\n @attributes\n end",
"def value_type\n 'UNKNOWN'\n end",
"def cast_value(value)\n case value\n when String then decode_and_initialize(value)\n when Hash then extract_model_klass(value).new(value)\n when nil then value\n else\n raise_cast_error(value) unless value.class.ancestors.include?(StoreModel::Model)\n\n value\n end\n rescue ActiveModel::UnknownAttributeError => e\n handle_unknown_attribute(value, e)\n end",
"def attributes_before_type_cast\n @attributes_before_type_cast ||= {}.with_indifferent_access\n end",
"def attributes_before_type_cast\n json_attributes_before_type_cast\n end",
"def attributes_before_type_cast\n @attributes\n end",
"def valid_attributes\n { :val_1 => 1.1,\n :val_2 => 2.2,\n :val_3 => 3.3,\n :val_4 => 4.4,\n :notes => \"hi\"\n }\n end",
"def set_validated_values\n # Check if the key is valid\n unless key && KEY_TO_TYPE.key?(key.to_sym)\n errors.add(:key, \"#{key} is not a supported metadatum\")\n end\n\n if data_type == \"number\"\n # Set number types. ActiveRecord validated.\n self.number_validated_value = number_raw_value\n elsif data_type == \"string\"\n check_and_set_string_type\n end\n end",
"def _save_set_values(values)\n ret = super\n load_typecast\n ret\n end",
"def check_value_empty(data)\n case @type\n when 'str', 'text', 'password', 'img', 'url'\n data.empty?\n when 'int', 'float', 'enum'\n # These values are always non-empty\n false\n when 'set'\n data == 0\n else\n raise \"Invalid type #{@type.inspect} encountered on attribute #{@name.inspect}\"\n end\n end",
"def enforce_value_types(hash = attributes)\n keys_to_manage = %i[valueDate valueDateTime valueDecimal valueInteger]\n\n keys = hash.keys\n keys.each do |k|\n v = hash[k]\n\n if v.is_a? Hash\n enforce_value_types(v)\n next\n elsif v.is_a? Array\n v.each { |item| enforce_value_types(item) if item.is_a? Hash }\n next\n end\n\n next unless keys_to_manage.include?(k.to_sym)\n\n case v\n when /^\\d{4}-\\d{2}-\\d{2}$/ # date\n next if k == 'valueDate'\n hash.delete(k)\n hash['valueDate'] = v\n when /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|((\\+|-)\\d{2}:\\d{2}))$/ # dateTime\n next if k == 'valueDateTime'\n hash.delete(k)\n hash['valueDateTime'] = v\n else\n fix_formatting(hash, k)\n end\n end\n end",
"def read_present\n @attrs.select { |k,v| !v.nil? }\n end",
"def jsonapi_received_attributes\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams.require(\n\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t:attributes\n\t\t\t\t\t\t).permit(\n\t\t\t\t\t\t\t*jsonapi_model_class.attribute_names\n\t\t\t\t\t\t).reject do |key, value|\n\t\t\t\t\t\t\t# ignore automatically generated attributes\n\t\t\t\t\t\t\t%w(\n\t\t\t\t\t\t\t\tid \n\t\t\t\t\t\t\t\tcreated_at created_on \n\t\t\t\t\t\t\t\tupdated_at updated_on\n\t\t\t\t\t\t\t).include?(\n\t\t\t\t\t\t\t\tkey.to_s\n\t\t\t\t\t\t\t) or \n\n\t\t\t\t\t\t\t# ignore reference attributes\n\t\t\t\t\t\t\tkey.to_s =~ /_id$/\n\t\t\t\t\t\tend\n\t\t\t\t\trescue ActionController::ParameterMissing => e\n\t\t\t\t\t\tnil\n\t\t\t\t\tend\n\t\t\t\tend",
"def value\n typecast.present? ? typecasted_value : super\n end",
"def aggregate_treat_undefined_attributes_as_default_value?; end",
"def lenient_value_coercions; end",
"def untypecasted_value\n read_attribute(:value)\n end",
"def ensure_default_attribute_value(attributes, attribute, value)\n if attribute.format.present?\n value = case entity_class.columns_hash[attribute.entity_attribute].sql_type\n when /time/i\n Time.strptime(value, attribute.format)\n when /date/i\n Date.strptime(value, attribute.format)\n else\n raise ArgumentError, \"For #{klass} there is no crystal ball. Please contact Lukas with bribe\"\n end\n end\n attributes.store(attribute.entity_attribute, value)\n\n attributes\n end",
"def value_required?\n if (@data_type == :none) || (@data_type == :global_class)\n return false\n else\n return true\n end\n end",
"def normalize_blank_values\n attributes.each do |column, value|\n self[column].present? || self[column] = nil\n end\n end",
"def original_attributes_before_type_cast\n ensure_original_attributes_stored\n clone_attributes :read_original_attribute_before_type_cast\n end",
"def empty_to_null\n attributes_before_type_cast.each do | key, value |\n write_attribute(key, nil) if value.kind_of?( String ) && value.empty?\n end\n end",
"def check_attributes\n if (@values == nil)\n puts \"Specify necessary informations: \"\n get_input_values\n @additions = Array.new()\n end\n #check_time_string\n end",
"def validate_must_attributes\n\t\tself.must_attribute_types.each do |attrtype|\n\t\t\toid = attrtype.name\n\t\t\tif attrtype.single?\n\t\t\t\tself.errors.add( oid, \"MUST have a value\" ) if self[ oid ].nil?\n\t\t\telse\n\t\t\t\tself.errors.add( oid, \"MUST have at least one value\" ) if self[ oid ].empty?\n\t\t\tend\n\t\tend\n\tend",
"def not_nil_value\n if @attributes['value'].nil?\n errors.add(:value, ' cannot be nil')\n end\n end",
"def expected_type\n @data[\"expected_type\"]\n end",
"def check!\n super()\n \n if @params.kind_of? Array and (not @params.all? { |v| v.type != JsonRpcObjects::V11::GenericTypes::Nil })\n raise Exception::new(\"Nil return type isn't allowed for parameters.\")\n end\n end",
"def value_types; end",
"def process_attributes(data, keep_xsi_type = false)\n if data.kind_of?(Hash)\n if keep_xsi_type\n xsi_type = data.delete(:\"@xsi:type\")\n data[:xsi_type] = xsi_type if xsi_type\n end\n data.reject! {|key, value| key.to_s.start_with?('@')}\n end\n end",
"def test_attribute_defaults\n m = define_serializer do |cls|\n attribute :name\n attribute :station, default: 'ATTRIBUTE_NONE'\n attribute :rank\n\n cls.send(:define_method, :default_value) do |object, attr_name|\n 'SERIALIZER_NONE'\n end\n end\n\n valid = [\n %w(Data NCC-1701-D ltc),\n %w(Q ATTRIBUTE_NONE SERIALIZER_NONE),\n %w(Quark DS9 SERIALIZER_NONE)\n ]\n\n m.render(small_user_table).zip(valid).each do |got, expected|\n assert_equal expected, got\n end\n end",
"def attributes_for_json\n self.class.attributes.each_with_object({}) do |name, attributes|\n value = read_attribute(name)\n if value != self.class.attribute_defaults[name.to_sym]\n value = (value.to_f * 1000).to_i if value.is_a? Time\n attributes[name.to_s] = value\n end\n end\n end",
"def method_missing(name, *args)\n return @values[name] if @values.key? name\n return nil if optional_attributes.include? name\n super\n end",
"def cast\n defined_attributes.each do |name, attr|\n value = public_send(name)\n next if value.nil?\n\n begin\n casted = attr.cast!(value)\n public_send(\"#{name}=\", casted)\n rescue ActiveEntity::CastError\n end\n end\n nil\n end",
"def assert_valid_value(object, action:)\n unless object.nil? || object_class === object\n raise SerializationTypeMismatch,\n \"can't #{action} `#{@attr_name}`: was supposed to be a #{object_class}, but was a #{object.class}. -- #{object.inspect}\"\n end\n end",
"def matterful_attributes(options={})\n options = options.dup\n default = options[:default].nil? ? true : options[:default]\n foreign_key = options[:foreign_key].nil? ? true : options[:foreign_key]\n sti = options[:sti].nil? ? true : options[:sti]\n polymorphic = options[:polymorphic].nil? ? true : options[:polymorphic]\n # Set compare_blank_values to false only if you, DO NOT want to update existing information with nil information from the new object\n # For example, sometimes your table has historical data, while source, may only have current. You may want to keep historical data\n # for reference, or if some process relies on it. It's generally not a good idea to delete good data, unless you have to.\n compare_blank_values = options[:compare_blank_values].nil? ? true : options[:compare_blank_values]\n\n # extra keys supplied as array of strings to ignore in comparison\n attributes_to_ignore = options[:extra].nil? ? [] : options[:extra]\n\n # Let's check for and add typical attributes that sti & polymorphic models have, override\n # this by sti: false, polymorphic: false, foreign_key: false\n # by default when looking to compare two objects\n # Customer.find(1).shipping_address.same_as? Address.new(city: 'Chicago')\n # we really only want to see if any of the 'matterfule information changed', like address_line_1 or city.\n # TODO: I guess I could do some smart checking on the model to see what kind of attributes it has.\n # For now we'll just check for all that we want to remove\n if default\n attributes_to_ignore += ['id', 'created_at', 'updated_at']\n end\n # By default we want foreign keys like caegory_id as they provide useful information about current record.\n # Let's say you import a bunch of addresses\n # and they ony matterful change was from shipping to billing category.\n unless foreign_key\n # This will skip polymorphic style foreign keys and only deal with belongs_to style keys\n attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/_id\\z/) && !k.match(/able_id\\z/) }\n end\n if sti\n attributes_to_ignore += ['type']\n end\n # If you are looking at a model that is polymorphic than most like you want to update something\n # like city for an Address , not addressable_id or addresable_type\n # That is more likely type of information to be updated on external import.\n if polymorphic\n attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/able_id\\z/) }\n attributes_to_ignore += attributes.keys.keep_if{|k| k.match(/able_type\\z/) }\n end\n\n # This will only be invoked on blank values\n # Since this gem is used only in the context of ActiveRecord, safe to use blank?, from ActionPack\n # KEEP IN MIND THIS THI WILL NOT CHECK for blanks in sti, foreign, and default attributes\n # it will only check for blank values in keys not in attributes_to_ignore already!!!!\n unless compare_blank_values\n attributes.except(*attributes_to_ignore).keys.each do |key|\n if self.send(key).blank?\n attributes_to_ignore += [key]\n end\n end\n end\n attributes.except(*attributes_to_ignore)\n end",
"def model_attributes(params)\n clean_params = super #hydra-editor/app/forms/hydra_editor/form.rb:54\n # model expects these as multi-value; cast them back\n clean_params[:rights] = Array(params[:rights]) if params[:rights]\n clean_params[:title] = Array(params[:title]) if params[:title]\n if params[:description]\n clean_params[:description] = Array(params[:description])\n clean_params[:description].map! do |description|\n ::DescriptionSanitizer.new.sanitize(description)\n end\n end\n # Model expects provenance as single-value.\n if params[:provenance]\n clean_params[:provenance] = ::DescriptionSanitizer.\n new.sanitize(params[:provenance])\n end\n\n # Oops; we're blanking out these values when changing permissions and probably versions, too\n # -- they don't have these fields in the form at all so they don't get repopulated.\n clean_params = encode_physical_container(params, clean_params)\n clean_params = encode_external_id(params, clean_params)\n\n clean_params.keys.each do |key|\n # strip ALL the things!\n if clean_params[key].is_a?(Array)\n clean_params[key].map!(&:strip)\n elsif clean_params[key].is_a?(String)\n clean_params[key] = clean_params[key].strip\n end\n end\n\n clean_params\n end",
"def valid_attributes\n { \"name\" => \"MyString\" }\n end",
"def valid_attributes\n { \"name\" => \"MyString\" }\n end",
"def ensure_params_have_values\n @attributes[:lat] = 33.1243208 unless @attributes[:lat].present? \n @attributes[:lon] = -117.32582479999996 unless @attributes[:lon].present? \n @attributes[:radius].present? ? @_search_radius = @attributes[:radius] : self.set_radius\n end",
"def check_value!(value)\n # Allow nil and Strings to fall back on the validations for typecasting\n case value\n when nil, String, expected_type\n value\n else\n raise TypeError, \"#{@name} expected #{expected_type.inspect} but got #{value.inspect}\"\n end\n end",
"def validate_attributes_schema\n @attributes.keys.each do |key|\n value = read_attribute(key)\n next unless value\n # type validation\n if (column = column_for_attribute(key)) and !key.ends_with?(\":\")\n if column.collection?\n unless value.is_a?(Array)\n raise WrongAttributeDataType, \"#{human_attribute_name(column.name)} has the wrong type. Expected collection of #{column.klass}. Record is #{value.class}\"\n end\n value.each do |v|\n validate_attribute_type(v, column)\n end\n else\n validate_attribute_type(value, column)\n end\n else\n # Don't save attributes set in a previous schema version\n @attributes.delete(key)\n end\n end\n end",
"def test_reflection_value\n serializer_class = Class.new(ActiveModel::Serializer) do\n has_one :blog\n end\n serializer_instance = serializer_class.new(@model, @instance_options)\n\n # Get Reflection\n reflection = serializer_class._reflections.fetch(:blog)\n\n # Assert\n assert_nil reflection.block\n assert_equal Serializer.config.include_data_default, reflection.options.fetch(:include_data_setting)\n assert_equal true, reflection.options.fetch(:include_data_setting)\n\n include_slice = :does_not_matter\n assert_equal @model.blog, reflection.send(:value, serializer_instance, include_slice)\n end",
"def parse_value(type, key, value) #:nodoc:\n if type == :boolean\n TRUE_VALUES.include?(value)\n elsif value && ALLOWED_TYPES[type].none?{ |klass| value.is_a?(klass) }\n raise \"Expected type :#{type} in params[:#{key}], got #{value.class}\"\n else\n value\n end\n end",
"def valid_attributes\n { \n \"name\" => \"Dummy Sale\",\n \"description\"=>\"Dummy event description data\", \n \"start_date\"=> Time.zone.now.strftime(\"%Y/%m/%d %H:%M:%S %z\"), \n \"end_date\"=> (Time.zone.now+2.months).strftime(\"%Y/%m/%d %H:%M:%S %z\"), \n \"permalink\" => taxon.permalink,\n \"eventable_type\"=> taxon.class.to_s,\n \"eventable_id\" => taxon.id.to_s,\n \"is_active\"=>\"1\", \n \"is_hidden\"=>\"0\", \n \"is_permanent\"=>\"0\"\n }\n end",
"def serialize_allowed_value(v)\n { String => \"string\",\n Fixnum => \"integer\" }[v] || v\n end",
"def raw_model_values(model)\n values = {}\n prohibited = [:id, :created_at, :updated_at]\n model.class.attributes.each do |attr|\n v = model.send(\"#{attr}\") unless prohibited.include?(attr)\n values[attr] = v if v\n end\n values\n end",
"def serialize_record_data?; collect_keys.present? || collect_only_keys.present?; end",
"def before_save\n deserialized_values.each{|k,v| @values[k] = serialize_value(k, v)}\n super\n end",
"def casted_value\n case qtype.name\n when 'date' then date_value\n when 'time' then time_value\n when 'datetime' then datetime_value\n when 'integer' then value.blank? ? nil : value.to_i\n when 'decimal' then value.blank? ? nil : value.to_f\n else value.blank? ? nil : value\n end\n end",
"def read_original_attribute_before_type_cast(attr_name)\n ensure_original_attributes_stored\n attr_name = attr_name.to_s\n \n if excluded_attribute?(attr_name)\n read_attribute_before_type_cast(attr_name)\n else\n @original_attributes[attr_name]\n end\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def valid_attributes\n {}\n end",
"def allow_unknown_attributes!\n define_method :handle_unknown_attribute do |*|\n end\n end",
"def restore_attributes(options = {})\n original_attributes_before_type_cast = self.original_attributes_before_type_cast.dup\n \n if options[:only]\n only = Array(options[:only]).map(&:to_s)\n original_attributes_before_type_cast.delete_if { |key, value| !only.include?(key) }\n elsif options[:except]\n except = Array(options[:except]).map(&:to_s)\n original_attributes_before_type_cast.delete_if { |key, value| except.include?(key) }\n end\n \n @attributes.update(original_attributes_before_type_cast)\n end",
"def check_attributes(variant)\n variant.views.must_be_kind_of Fixnum\n variant.totalReward.must_be_kind_of Float\n variant.upperConfidenceBound.must_be_kind_of Float\n variant.lowerConfidenceBound.must_be_kind_of Float\n end",
"def valid_attributes\n hash = @time_record.attributes.reject {|k,v| %w{id user_id pay_period_id created_at updated_at}.include?(k)}\n end",
"def cast_eav_value value, attribute # :nodoc:\n attributes = self.class_eav_attributes.stringify_keys\n return value unless attributes.keys.include?(attribute)\n return value if attributes[attribute] == String # no need for casting\n\n\n begin\n # for core types [eg: Integer '12']\n eval(\"#{attributes[attribute]} '#{value}'\")\n\n rescue\n begin\n # for BigDecimal [eg: BigDecimal.new(\"123.45\")]\n eval(\"#{attributes[attribute]}.new('#{value}')\")\n\n rescue\n begin\n # for date/time classes [eg: Date.parse(\"2011-03-20\")]\n eval(\"#{attributes[attribute]}.parse('#{value}')\")\n rescue\n value\n end\n\n end\n end\n end",
"def valid_attributes\n {\"name\"=>'Magasin', \"organism_id\"=>@o.id.to_s}\n end",
"def data_with_nils\n to_a\n end",
"def load_attributes!\n fetch_data unless data_fetched?\n # master & value attributes\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_master\"])\n raw_attributes.merge!(Ken::Util.convert_hash(@data[\"/type/reflect/any_value\"])) \n @attributes = {}\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.id == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n # reverse properties\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_reverse\"])\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.master_property == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n @attributes_loaded = true\n end",
"def attributes_before_type_cast\n attributes.keys.inject({}) do |result, key|\n result[key] = attributes.before_type_cast(key)\n result\n end\n end",
"def parse_value(type, key, value)\n if type == :boolean\n TRUE_VALUES.include?(value)\n elsif value && ALLOWED_TYPES[type].none?{ |klass| value.is_a?(klass) }\n raise \"Expected type :#{type} in params[:#{key}], got #{value.class}\"\n else\n value\n end\n end",
"def optional_type\n @only_power = false\n @only_light = false\n if params.has_key? 'power' and not params.has_key? 'light' then\n @only_power = true\n elsif params.has_key? 'light' and not params.has_key? 'power' then\n @only_light = true\n end\n end",
"def convert_blank_to_nil\n all_fields = self.get_array_of_symbolic_keys\n # updating record's field with nil for blank values\n all_fields.each do |field|\n if self[field].blank?\n self[field] = nil;\n end\n end\n end",
"def ignore_if_not_exists\n attributes.fetch(:ignoreIfNotExists)\n end",
"def enforce_type(key, value)\n ensure_apply_object_class\n # Enforce attribute value formatting\n normalize_attribute(key, value)[1]\n end",
"def value(klass = 'number_value')\n v = @attributes[klass] \n if self.new_record? && \n (!v || (v.respond_to?(:empty?) && v.empty?))\n eval default_code\n else\n v\n end\n end",
"def _before_validation\n serialize_deserialized_values\n super\n end",
"def valid_attributes\n { \"name\" => \"Band\", \"creation_year\" => 2008 }\n end",
"def valid_attributes\n { \"details\" => \"100pts\", \"points\" => \"1\", \"bib_number\" => \"123\", }\n end",
"def values_for_database!(all_attribute_keys, attributes)\n # TODO(lsmola) we'll need to fill default value from the DB to the NOT_NULL columns here, since sending NULL\n # to column with NOT_NULL constraint always fails, even if there is a default value\n all_attribute_keys.each do |key|\n next unless attributes.key?(key)\n\n if (type = serializable_keys[key])\n attributes[key] = type.serialize(attributes[key])\n end\n end\n attributes\n end",
"def validate_required_values\n # Make sure all MUST attributes have a value\n @object_classes.each do |object_class|\n object_class.must.each do |required_attribute|\n # Normalize to ensure we catch schema problems\n # needed?\n real_name = to_real_attribute_name(required_attribute.name, true)\n raise UnknownAttribute.new(required_attribute) if real_name.nil?\n # # Set default if it wasn't yet set.\n # @data[real_name] ||= [] # need?\n value = @data[real_name] || []\n # Check for missing requirements.\n if value.empty?\n _schema = schema\n aliases = required_attribute.aliases.collect do |name|\n self.class.human_attribute_name(name)\n end\n args = [self.class.human_object_class_name(object_class)]\n if ActiveLdap.const_defined?(:GetTextFallback)\n if aliases.empty?\n format = \"is required attribute by objectClass '%s'\"\n else\n format = \"is required attribute by objectClass '%s'\" \\\n \": aliases: %s\"\n args << aliases.join(', ')\n end\n else\n if aliases.empty?\n format = _(\"%{fn} is required attribute by objectClass '%s'\")\n else\n format = _(\"%{fn} is required attribute by objectClass \" \\\n \"'%s': aliases: %s\")\n args << aliases.join(', ')\n end\n end\n errors.add(real_name, format % args)\n end\n end\n end\n end",
"def expect_record name, value\n expect_type name, value, \"Record\", lambda{ value.is_a?(Record) }\n end",
"def expected= patient_identifier\n self.test_type_data = patient_identifier.attributes\n end",
"def value\n if self[:value_type].present?\n case self[:value_type].to_sym\n when :string, :text\n self[:value].to_s\n when :password\n self[:value].to_s\n when :decimal\n BigDecimal.new(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP)\n when :integer\n self[:value].to_i\n when :boolean\n (self[:value].to_s =~ /^[t|1]/i) != nil\n else\n self[:value].is_a?(String) ? YAML.load(self[:value]) : self[:value]\n end\n else\n self[:value]\n end\n end",
"def values(opts)\n opts = check_params(opts,[:class_instance_keys,:field_instance_names])\n super(opts)\n end",
"def get_field_deserializers()\n return super.merge({\n \"unit\" => lambda {|n| @unit = n.get_string_value() },\n \"value\" => lambda {|n| @value = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end",
"def safe_attributes=(attrs, user=User.current)\n if attrs.respond_to?(:to_unsafe_hash)\n attrs = attrs.to_unsafe_hash\n end\n\n return unless attrs.is_a?(Hash)\n\n if attrs['custom_field_values'].present?\n editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}\n attrs['custom_field_values'].select! {|k, v| editable_custom_field_ids.include?(k.to_s)}\n end\n\n if attrs['custom_fields'].present?\n editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}\n attrs['custom_fields'].select! {|c| editable_custom_field_ids.include?(c['id'].to_s)}\n end\n\n super(attrs, user)\n end",
"def attribute_type\n (float? || integer? || text? || boolean? ? field_type : 'string').to_sym\n end",
"def attributes_for_saving_with_person attributes\n attributes = attributes_for_saving_without_person(attributes)\n\n attributes.delete(:company)\n attributes.delete(:deals)\n attributes.delete(:won_deals_total)\n attributes.delete(:lead_status)\n attributes.delete(:viewed_at)\n attributes.delete(:deal_ids)\n attributes.delete(:predefined_contacts_tag_ids)\n attributes.delete(:user_id)\n attributes.delete(:user)\n\n attributes.delete(:image_thumb_url) if attributes[:image_thumb_url] == \"/images/thumb/missing.png\"\n\n attributes\n end",
"def assign_value\n if assigned_attr = AttrName.find_by_id(self.attr_name_id)\n case assigned_attr.value_type\n when \"STRING\"\n self.string_val = self.raw_value\n when \"FLOAT\" #has a special case to remove the dollar symbol in front of it\n #remove_dollar_sign\n self.float_val = self.raw_value.to_f\n when \"DATETIME\"\n self.datetime_val = self.raw_value.to_datetime\n when \"BOOLEAN\"\n if self.raw_value == 'true'\n self.bool_val = true\n else\n self.bool_val = false\n end\n when \"INTEGER\"\n if assigned_attr.treat_as_price\n logger.debug \"Treating this as a price\"\n self.price_val_cents = Money.parse(self.raw_value).cents\n else\n self.int_val = self.raw_value.to_i\n end\n else\n self.string_val = self.raw_value\n end\n end\n end",
"def value_required?\n false\nend",
"def find_original_attribute\n assoc_attr_names_with_types.detect do |attr_name, attr_type|\n original_attribute = send(attr_name)&.send(attr_type)\n break original_attribute if original_attribute.present?\n\n false\n end\n end",
"def nonregular_type; end",
"def value_with_typecast\n if values == \"boolean\"\n value == \"true\" ? true : false\n elsif values.is_a?(Hash) && values[\"ids\"] == \"id\"\n value.to_i\n else\n value\n end\n end",
"def value_type\n value_type_card&.first_name || default_value_type_code.cardname\nend",
"def type\n if validator_hash[:numericality] == true ||\n validator_hash[:numericality] == { allow_nil: true }\n 'Decimal'\n elsif validator_hash.dig(:numericality, :only_integer)\n 'Integer'\n elsif validator_hash[:ingested_date]\n 'Date'\n elsif validator_hash.dig(:case_insensitive_inclusion, :in) == %w[Y N]\n 'YesNo'\n elsif inclusion_list_with_lookup_values?(validator_hash.dig(:case_insensitive_inclusion, :in))\n attr.name.tr(' ', '')\n else\n 'String'\n end\n end",
"def valid_attributes\n {name: \"db-01\", type: \"postgres\"}\n end",
"def factorygirl_attributes\n symbolize_attributes!\n @attributes.each do |key, value|\n next unless respond_to?(method = method_name(key))\n if (result = send method, value) || value.nil?\n @attributes[key] = result if @attributes.key? key\n else\n @attributes.delete key\n end\n end\n end",
"def unknown_attributes\n @unknown_attributes ||= {}\n end",
"def unknown_attributes\n @unknown_attributes ||= {}\n end",
"def unknown_attributes\n @unknown_attributes ||= {}\n end",
"def assert_model_valid(instance)\n instance.value_attributes_for_avro\n expect(instance).to be_valid\n end"
] | [
"0.6222344",
"0.6185397",
"0.6137916",
"0.5797852",
"0.5711898",
"0.5684088",
"0.5650208",
"0.5619862",
"0.5615035",
"0.559395",
"0.5582619",
"0.55615693",
"0.55510503",
"0.55469906",
"0.5544507",
"0.55360687",
"0.5529707",
"0.5524967",
"0.55000794",
"0.5471463",
"0.54710865",
"0.543084",
"0.5428531",
"0.54271924",
"0.54088473",
"0.54049796",
"0.5404749",
"0.5366836",
"0.53650504",
"0.53624773",
"0.5357018",
"0.5351246",
"0.5334374",
"0.5321898",
"0.5319493",
"0.5308657",
"0.5307919",
"0.5304158",
"0.53022957",
"0.53022957",
"0.5290513",
"0.5289292",
"0.52860945",
"0.52812946",
"0.52797294",
"0.5275783",
"0.5266971",
"0.52620095",
"0.52516526",
"0.524791",
"0.52465594",
"0.52399856",
"0.52231216",
"0.52231216",
"0.52231216",
"0.52231216",
"0.52231216",
"0.52231216",
"0.52231216",
"0.52231216",
"0.5223085",
"0.521768",
"0.5215859",
"0.5206409",
"0.5196595",
"0.51806957",
"0.51770526",
"0.51733476",
"0.5161804",
"0.51607656",
"0.5160367",
"0.5160306",
"0.51552504",
"0.5154328",
"0.5141325",
"0.5139282",
"0.5135984",
"0.5135584",
"0.5135176",
"0.5128584",
"0.51240164",
"0.51236814",
"0.5121881",
"0.51148003",
"0.5111534",
"0.51103175",
"0.51087314",
"0.51051456",
"0.5095387",
"0.50952667",
"0.50949466",
"0.50939673",
"0.50923",
"0.5084164",
"0.5075176",
"0.5072604",
"0.507172",
"0.5067057",
"0.5067057",
"0.5067057",
"0.50578815"
] | 0.0 | -1 |
filter_params = ["col=docketNumberColumn&val=legacy|evidence_submission", "col=taskColumn&val=TranslationTask"] [ "cached_appeals_attributes.docket_type IN (?) AND tasks.type in (?)", ["legacy", "evidence_submission"], ["TranslationTask"] ] | def where_clause
return [] if filter_params.empty?
filters = filter_params.map(&QueueFilterParameter.method(:from_string))
where_string = TaskFilter.where_string_from_filters(filters)
where_arguments = filters.map(&:values).reject(&:empty?)
[where_string] + where_arguments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering_params(params)\n params.slice(:shortlist, :client, :category, :updated_at, :costmodel, :state, :prio)\n end",
"def tasks_by_filters\n to_include = [ :users, :tags, :sheets, :todos, :dependencies, :milestone ]\n to_include << { :company => :properties}\n to_include << { :project => :customer }\n to_include << { :task_property_values => { :property_value => :property } }\n to_include << { :dependants => [:users, :tags, :sheets, :todos, \n { :project => :customer }, :milestone ] }\n\n conditions = \"tasks.project_id IN (#{@project_ids}) AND \" + filter\n conditions += \" AND #{ @extra_conditions }\" if !@extra_conditions.blank?\n\n Task.find(:all, \n :conditions => [ conditions ],\n :include => to_include)\n end",
"def filter\n filter = \"\"\n\n if session[:filter_user].to_i > 0\n task_ids = User.find(session[:filter_user].to_i).tasks.collect { |t| t.id }.join(',')\n if task_ids == ''\n filter = \"tasks.id IN (0) AND \"\n else\n filter = \"tasks.id IN (#{task_ids}) AND \"\n end\n elsif session[:filter_user].to_i < 0\n not_task_ids = Task.find(:all, :select => \"tasks.*\", :joins => \"LEFT OUTER JOIN task_owners t_o ON tasks.id = t_o.task_id\", :readonly => false, :conditions => [\"tasks.company_id = ? AND t_o.id IS NULL\", current_user.company_id]).collect { |t| t.id }.join(',')\n if not_task_ids == ''\n filter = \"tasks.id = 0 AND \"\n else\n filter = \"tasks.id IN (#{not_task_ids}) AND \" if not_task_ids != \"\"\n end\n end\n\n if session[:filter_milestone].to_i > 0\n filter << \"tasks.milestone_id = #{session[:filter_milestone]} AND \"\n elsif session[:filter_milestone].to_i < 0\n filter << \"(tasks.milestone_id IS NULL OR tasks.milestone_id = 0) AND \"\n end\n\n unless session[:filter_status].to_i == -1 || session[:filter_status].to_i == -2\n if session[:filter_status].to_i == 0\n filter << \"(tasks.status = 0 OR tasks.status = 1) AND \"\n elsif session[:filter_status].to_i == 2\n filter << \"(tasks.status > 1) AND \"\n else\n filter << \"tasks.status = #{session[:filter_status].to_i} AND \"\n end\n end\n\n if session[:filter_status].to_i == -2\n filter << \"tasks.hidden = 1 AND \"\n else\n filter << \"(tasks.hidden = 0 OR tasks.hidden IS NULL) AND \"\n end\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n\n unless session[:filter_customer].to_i == 0\n filter << \"tasks.project_id IN (#{current_user.projects.find(:all, :conditions => [\"customer_id = ?\", session[:filter_customer]]).collect(&:id).compact.join(',') }) AND \"\n end\n\n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) \"\n\n return filter\n end",
"def filters_sql\n if filters.blank?\n ''\n else\n conditions = JSON.parse filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map { |x| \"'#{x}'\" }.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def parse_filters(params)\n if params['filters'].blank?\n Utilities::Geo::REGEXP_COORD.keys\n else\n params.permit(filters: [])[:filters].map(&:to_sym)\n end\n end",
"def filtering_params(params)\n\t\t params.slice(:name, :category_id, :trademark)\n\t\tend",
"def tasks_by_filters\n to_include = [ :users, :tags, :sheets, :todos, :dependencies, \n :milestone, :notifications, :watchers, \n :customers ]\n to_include << { :work_logs => :user }\n to_include << { :company => :properties }\n to_include << { :project => :customer }\n to_include << { :task_property_values => { :property_value => :property } }\n to_include << { :dependants => [:users, :tags, :sheets, :todos, \n { :project => :customer }, :milestone ] }\n\n conditions = filter\n conditions += \" AND tasks.project_id in (#{ @select_project_ids })\"\n conditions += \" AND #{ @extra_conditions }\" if !@extra_conditions.blank?\n\n Task.find(:all, \n :conditions => [ conditions ],\n :include => to_include, \n :limit => 250,\n :order => \"tasks.id desc\")\n end",
"def filterHotDogStandsByCondimentPreferences(httpRequestParameters)\n # Only apply the filters if the user has selected what drinks they prefer.\n if httpRequestParameters[\"selectedCondiments\"][\"length\"].to_i > 0\n httpRequestParameters[\"selectedCondiments\"][\"values\"].each do |condimentIndex|\n # On every preferred condiment selected, append the query with the exists call that checks if that condiment\n # is in the available condiments set.\n @searchQuery = @searchQuery.where(\"exists (select * from available_condiments where \" + \\\n \" condiment_id = ? and available_condiments.hot_dog_stands_id = hot_dog_stands.id)\", condimentIndex)\n end\n end\n end",
"def filtering_params(params)\n params.slice(:desired_location, :max_price_dollars, :tour_name, :earliest_start, :latest_end, :min_seats)\n end",
"def filtering_params(params)\n params.slice(:business_id, :location, :starts_with)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def get_filters_sql\n if self.filters.blank?\n return ''\n else\n conditions = JSON.parse self.filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map{|x| \"'#{x}'\"}.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def query_builder_with_filter_from_hash(params)\n types = get_types_parameters\n\n validate_parameters(types, params)\n\n pattern = params[:q]\n\n only_liked = params[:only_liked] == 'true'\n only_shared = params[:only_shared] == 'true'\n only_subscriptions = params[:subscribed] == 'true'\n only_samples = params[:sample] == 'true'\n exclude_shared = params[:exclude_shared] == 'true'\n exclude_raster = params[:exclude_raster] == 'true'\n locked = params[:locked]\n shared = compose_shared(params[:shared], only_shared, exclude_shared)\n tags = params.fetch(:tags, '').split(',')\n tags = nil if tags.empty?\n bbox_parameter = params.fetch(:bbox,nil)\n privacy = params.fetch(:privacy,nil)\n only_with_display_name = params[:only_with_display_name] == 'true'\n with_dependent_visualizations = params[:with_dependent_visualizations].to_i\n only_published = params[:only_published] == 'true'\n\n vqb = VisualizationQueryBuilder.new\n .with_prefetch_user\n .with_prefetch_table\n .with_prefetch_permission\n .with_prefetch_synchronization\n .with_prefetch_external_source\n .with_types(types)\n .with_tags(tags)\n\n if !bbox_parameter.blank?\n vqb.with_bounding_box(Carto::BoundingBoxUtils.parse_bbox_parameters(bbox_parameter))\n end\n\n # FIXME Patch to exclude legacy visualization from data-library #5097\n if only_with_display_name\n vqb.with_display_name\n end\n\n vqb.with_published if only_published\n\n if current_user\n vqb.with_current_user_id(current_user.id)\n vqb.with_liked_by_user_id(current_user.id) if only_liked\n vqb.with_subscription if only_subscriptions\n vqb.with_sample if only_samples\n case shared\n when FILTER_SHARED_YES\n vqb.with_owned_by_or_shared_with_user_id(current_user.id)\n when FILTER_SHARED_NO\n vqb.with_user_id(current_user.id) if !only_liked\n when FILTER_SHARED_ONLY\n vqb.with_shared_with_user_id(current_user.id)\n .with_user_id_not(current_user.id)\n end\n\n vqb.without_raster if exclude_raster\n\n if locked == 'true'\n vqb.with_locked(true)\n elsif locked == 'false'\n vqb.with_locked(false)\n end\n\n if types.include? Carto::Visualization::TYPE_REMOTE\n vqb.without_synced_external_sources\n vqb.without_imported_remote_visualizations\n end\n\n vqb.with_privacy(privacy) unless privacy.nil?\n\n if with_dependent_visualizations.positive? && !current_user.has_feature_flag?('faster-dependencies')\n vqb.with_prefetch_dependent_visualizations\n end\n else\n user = Carto::User.where(username: CartoDB.extract_subdomain(request)).first\n raise Carto::ParamInvalidError.new(:username) unless user.present?\n vqb.with_user_id(user.id)\n .with_privacy(Carto::Visualization::PRIVACY_PUBLIC)\n end\n\n if pattern.present?\n vqb.with_partial_match(pattern)\n end\n\n vqb\n end",
"def filter_parameters=(_arg0); end",
"def filter_parameters=(_arg0); end",
"def process_filters(records,filter_params)\n return records unless filter_params\n filter_params.each do |field,filter_param|\n if filter_param.has_key?(\"value\")\n value = filter_param[\"value\"]\n next unless value.present?\n condition = filter_param[\"condition\"] || 'eq'\n case condition\n when \"eq\"\n value = true if value == 'true'\n value = [false, nil] if value == 'false'\n records = records.where(field.to_sym => value)\n when \"cont\"\n records = records.where(\"#{field} LIKE '%#{value}%'\")\n when \"ncont\"\n records = records.where(\"#{field} NOT LIKE '%#{value}%'\")\n when \"gt\"\n records = records.where(\"#{field} > ?\", value)\n when \"lt\"\n records = records.where(\"#{field} < ?\", value)\n end\n end\n end\n return records\n end",
"def list_filters\n {\n track_end_date: 'TrkEndDate gt VALUE',\n track_first_submitted: 'TrkFirstSubmitted gt VALUE',\n app_no: 'AppNo eq VALUE',\n first_name: 'AppFirstName eq VALUE',\n last_name: 'AppLastName eq VALUE',\n email: 'AppEmailAddress eq VALUE'\n }\n end",
"def filterHotDogStandsByFoodPreferences(httpRequestParameters)\n # Only apply the filters if the user has selected what foods they prefer.\n if httpRequestParameters[\"selectedFoods\"][\"length\"].to_i > 0\n httpRequestParameters[\"selectedFoods\"][\"values\"].each do |foodIndex|\n # Upon every preferred food selected, if the user has specified a price range, apply a filter that not only\n # checks to see if the food exists in the set of food prices, but also to see if the food price is within\n # the price range the user has specified. Otherwise, only apply the filter to see if the food exists in\n # the set of food prices.\n if httpRequestParameters[\"isAPriceRangeSpecified\"] === \"true\"\n @searchQuery = @searchQuery.where(\"exists (select * from food_prices where food_id = ? and \" + \\\n \"food_prices.hot_dog_stands_id = hot_dog_stands.id and food_prices.price >= ? and food_prices.price <= ?)\", \\\n foodIndex, httpRequestParameters[\"minimumItemPrice\"].to_f, httpRequestParameters[\"maximumItemPrice\"].to_f)\n else\n @searchQuery = @searchQuery.where(\"exists (select * from food_prices where food_id = ? and \" + \\\n \"food_prices.hot_dog_stands_id = hot_dog_stands.id)\", foodIndex)\n end\n end\n end\n end",
"def query_params(params)\n p = params.to_hash.symbolize_keys\n unless p[:apply_project_rules_for].blank?\n if proj = Project.find_by_id(p[:apply_project_rules_for])\n p.merge!(proj.observations_url_params(extended: true))\n end\n p.delete(:apply_project_rules_for)\n end\n unless p[:list_id].blank?\n list = List.find_by_id(p[:list_id])\n p.delete(:list_id)\n p[:taxon_ids] ||= [ ]\n if list && list.taxon_ids.any?\n p[:taxon_ids] += list.taxon_ids\n else\n # the list has no taxa, so no results. Set this\n # params so the query returns nothing\n p[:empty_set] = true\n end\n end\n if p[:swlat].blank? && p[:swlng].blank? && p[:nelat].blank? && p[:nelng].blank? && p[:BBOX]\n p[:swlng], p[:swlat], p[:nelng], p[:nelat] = p[:BBOX].split(',')\n end\n unless p[:place_id].blank?\n p[:place] = begin\n Place.find(p[:place_id])\n rescue ActiveRecord::RecordNotFound\n nil\n end\n p[:place_id] = p[:place].id if p[:place] && p[:place].is_a?( Place )\n end\n unless p[:not_in_place].blank?\n not_in_place_record = begin\n Place.find( p[:not_in_place] )\n rescue ActiveRecord::RecordNotFound\n nil\n end\n p[:not_in_place] = not_in_place_record&.id if not_in_place_record.is_a?( Place )\n p[:not_in_place_record] = not_in_place_record\n end\n p[:search_on] = nil unless Observation::FIELDS_TO_SEARCH_ON.include?(p[:search_on])\n # iconic_taxa\n if p[:iconic_taxa]\n p[:iconic_taxa_instances] = iconic_taxa_param_to_instances(p[:iconic_taxa])\n end\n if !p[:taxon_id].blank?\n p[:observations_taxon] = Taxon.find_by_id(p[:taxon_id].to_i)\n elsif !p[:taxon_name].blank?\n begin\n p[:observations_taxon] = Taxon.single_taxon_for_name(p[:taxon_name], iconic_taxa: p[:iconic_taxa_instances])\n rescue ActiveRecord::StatementInvalid => e\n raise e unless e.message =~ /invalid byte sequence/\n taxon_name_conditions[1] = p[:taxon_name].encode('UTF-8')\n p[:observations_taxon] = TaxonName.where(taxon_name_conditions).joins(includes).first.try(:taxon)\n end\n if !p[:observations_taxon]\n p.delete(:taxon_name)\n end\n end\n if p[:taxon_ids] == [\"\"]\n p[:taxon_ids] = nil\n end\n if !p[:observations_taxon] && !p[:taxon_ids].blank?\n p[:observations_taxon_ids] = [p[:taxon_ids]].flatten.join(',').split(',').map(&:to_i)\n p[:observations_taxa] = Taxon.where(id: p[:observations_taxon_ids]).limit(100)\n end\n\n unless p[:without_taxon_id].blank?\n p[:without_observations_taxon] = Taxon.find_by_id( p[:without_taxon_id].to_i )\n end\n\n if p[:has]\n p[:has] = p[:has].split(',') if p[:has].is_a?(String)\n p[:id_please] = true if p[:has].include?('id_please')\n p[:with_photos] = true if p[:has].include?('photos')\n p[:with_sounds] = true if p[:has].include?('sounds')\n p[:with_geo] = true if p[:has].include?('geo')\n end\n\n p[:captive] = p[:captive].yesish? unless p[:captive].blank?\n\n if p[:skip_order]\n p.delete(:order)\n p.delete(:order_by)\n else\n p[:order_by] = \"created_at\" if p[:order_by] == \"observations.id\"\n if ObservationsController::ORDER_BY_FIELDS.include?(p[:order_by].to_s)\n p[:order] = if %w(asc desc).include?(p[:order].to_s.downcase)\n p[:order]\n else\n 'desc'\n end\n else\n p[:order_by] = \"observations.id\"\n p[:order] = \"desc\"\n end\n end\n\n # date\n date_pieces = [p[:year], p[:month], p[:day]]\n unless date_pieces.map{|d| (d.blank? || d.is_a?(Array)) ? nil : d}.compact.blank?\n p[:on] = date_pieces.join('-')\n end\n if p[:on].to_s =~ /^\\d{4}/\n p[:observed_on] = p[:on]\n if d = Observation.split_date(p[:observed_on])\n p[:observed_on_year], p[:observed_on_month], p[:observed_on_day] = [ d[:year], d[:month], d[:day] ]\n end\n end\n p[:observed_on_year] ||= p[:year].to_i unless p[:year].blank?\n p[:observed_on_month] ||= p[:month].to_i unless p[:month].blank? || p[:month].is_a?(Array)\n p[:observed_on_day] ||= p[:day].to_i unless p[:day].blank?\n\n # observation fields\n ofv_params = p.select{|k,v| k =~ /^field\\:/}\n unless ofv_params.blank?\n p[:ofv_params] = {}\n ofv_params.each do |k,v|\n p[:ofv_params][k] = {\n :normalized_name => ObservationField.normalize_name(k.to_s),\n :value => v\n }\n end\n observation_fields = ObservationField.where(\"lower(name) IN (?)\", p[:ofv_params].map{|k,v| v[:normalized_name]})\n p[:ofv_params].each do |k,v|\n v[:observation_field] = observation_fields.detect do |of|\n v[:normalized_name] == ObservationField.normalize_name(of.name)\n end\n end\n p[:ofv_params].delete_if{|k,v| v[:observation_field].blank?}\n end\n\n p[:user_id] = p[:user_id] || p[:user]\n\n # Handle multiple users in user_id\n users = [p[:user_id].to_s.split( \",\" )].flatten.map do | user_id |\n candidate = user_id.to_s.strip\n User.find_by_id( candidate ) || User.find_by_login( candidate )\n end.compact\n p[:user_id] = users.blank? ? nil : users.map(&:id)\n p[:user_id] = p[:user_id].first if p[:user_id].is_a?( Array ) && p[:user_id].size == 1\n\n unless p[:user_id].blank? || p[:user_id].is_a?(Array)\n p[:user] = User.find_by_id(p[:user_id])\n p[:user] ||= User.find_by_login(p[:user_id])\n end\n if p[:user].blank? && !p[:login].blank?\n p[:user] ||= User.find_by_login(p[:login])\n end\n\n unless p[:ident_user_id].blank?\n ident_users = p[:ident_user_id].is_a?( Array ) ?\n p[:ident_user_id] : [p[:ident_user_id].to_s.split( \",\" )].flatten\n ident_user_ids = []\n ident_users.each do | id_or_login |\n id_or_login = id_or_login.strip\n ident_user = User.find_by_id( id_or_login )\n ident_user ||= User.find_by_login( id_or_login )\n ident_user_ids << ident_user.id if ident_user\n end\n p[:ident_user_id] = ident_user_ids.join( \",\" )\n end\n\n unless p[:projects].blank?\n project_ids = [p[:projects]].flatten\n p[:projects] = Project.find(Project.slugs_to_ids(project_ids))\n p[:projects] = p[:projects].compact\n if p[:projects].blank?\n project_ids.each do |project_id|\n p[:projects] += Project.find(Project.slugs_to_ids(project_id))\n end\n p[:projects] = p[:projects].flatten.compact\n end\n end\n\n if p[:pcid] && p[:pcid] != 'any'\n p[:pcid] = p[:pcid].yesish?\n end\n\n unless p[:not_in_project].blank?\n p[:not_in_project] = Project.find(p[:not_in_project]) rescue nil\n end\n\n p[:rank] = p[:rank] if Taxon::VISIBLE_RANKS.include?(p[:rank])\n p[:hrank] = p[:hrank] if Taxon::VISIBLE_RANKS.include?(p[:hrank])\n p[:lrank] = p[:lrank] if Taxon::VISIBLE_RANKS.include?(p[:lrank])\n\n p.each do |k,v|\n p[k] = nil if v.is_a?(String) && v.blank?\n end\n\n p[:_query_params_set] = true\n p\n end",
"def filter_params\n params.permit(\n :state,\n :start,\n :end,\n :course,\n :subject,\n :organizer_id,\n :teacher_email,\n :only_attended,\n :order_by\n )\n end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def filter_data(params_list)\n filter_params = {}\n\n if params['data']\n params['data'].keys.each do |key|\n if params_list.map{|x| x.to_s}.include? key\n filter_params[key] = params['data'][key]\n end\n end\n end\n\n filter_params\n end",
"def filter\n @filter_params.each do |key, val|\n # Strip empty values from the array if the given value is an array.\n val.select!{ |val| !val.to_s.empty? } if val.is_a?(Array)\n\n # Convert key if it starts with a column name.\n key = key.slice(@model_method_name.length + 1, key.length) if key.start_with?(\"#{@model_method_name}_\")\n\n if @force_filter_for && @force_filter_for.include?(key)\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n elsif @model.column_names.include?(key)\n if val.is_a?(Array) && val.empty?\n # Ignore.\n else\n @query = @query.where(key => val)\n end\n elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])\n next if val.blank?\n table = @model.arel_table\n \n val.to_s.strip.split(/\\s+/).each do |str|\n @query = @query.where(table[match[1].to_sym].matches(\"%#{escape(str)}%\"))\n end\n elsif @args[:filter]\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n else\n raise \"Dont know what to do regarding filter with key: '#{key}'.\"\n end\n end\n end",
"def filtering_params(params)\n \tparams.slice(:make, :color, :drive, :has_keys, :year, :state, :lot_number, :buy_now_price, :auction)\n\tend",
"def filter\n filter = \"\"\n\n filter = filter_by_user\n filter += filter_by_status\n filter += filter_by_milestones_projects_and_customers\n filter += filter_by_properties\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) AND \"\n\n filter = filter.gsub(/( AND )$/, \"\")\n return filter\n end",
"def filter_params\n params.permit(\n type: [],\n id: []\n ).to_h.symbolize_keys.merge!(project_id: sessions_current_project_id)\n end",
"def parse_params(params)\n all_filters.each {|f| f.reset; f.active = false}\n data = params.symbolize_keys\n Array(data[:fields]).each do |name|\n filter = all_filters.find {|f| f.name == name}\n if filter\n filter.active = true\n operator = data[:operators][name].to_sym\n filter.operator = operator if filter.operators.include?(operator)\n filter.value = data[:values][name] unless operator == :blank\n end\n end\n validate\n end",
"def filter_group query_params, *types\n types = [:select, :scope, :date_range, :search] if types.empty?\n query_params.filters.each do |field, config|\n type = config[:type]\n concat render_filter(query_params, field, type) if types.include?(type || :search)\n end\n end",
"def filter(params)\n\n\t self.log << \"Started filtering cases\"\n\n\t\[email protected] do |adrc_case|\n\n\t\t self.log << {:message => \"packing #{adrc_case[:subject_id]}\"}\n\t\t vgroup = Vgroup.joins(\"LEFT JOIN enrollment_vgroup_memberships ON vgroups.id = enrollment_vgroup_memberships.vgroup_id\")\n\t\t \t\t\t\t.joins(\"LEFT JOIN scan_procedures_vgroups ON scan_procedures_vgroups.vgroup_id = vgroups.id\")\n\t\t \t\t\t\t.where(\"enrollment_vgroup_memberships.enrollment_id = ?\",Enrollment.where(:enumber => adrc_case[:enumber]).first.id)\n\t\t \t\t\t\t.where(\"scan_procedures_vgroups.scan_procedure_id = ?\",adrc_case[:scan_procedure].id)\n\t\t \t\t\t\t.first\n\n\n\t\t #does this vgroup have the right image datasets?\n\t\t visits = Visit.where(:appointment_id => vgroup.appointments.select{|item| item.appointment_type == 'mri'}.map(&:id))\n\t\t images = Jobs::NaccUpload::ImageDataset.where(:visit_id => visits.map(&:id)).select{|item| (@sdm_filter.map{|x| x.series_description.downcase}.include? item.series_description.downcase) and (item.series_description != 'DTI whole brain 2mm FATSAT ASSET')}\n\t\t ppt = vgroup.enrollments.first.participant\n\n\t # if we only have 2 different scan types, or the status flag for this case is 'R', fail the case\n\t series_description_counts = images.each_with_object(Hash.new(0)){|item,hash| hash[@sdm_filter.select{|sdm| sdm.series_description.downcase == item.series_description.downcase}.first.series_description_type_id] += 1}\n\t if series_description_counts.keys.count < 2\n\t \tself.exclusions << {:protocol => adrc_case[:scan_procedure].codename, :subject => adrc_case[:enumber], :message => \"too few scan types\"}\n\t \tnext\n\t end\n\n\t if adrc_case[:status_flag] == 'R'\n\t \tself.exclusions << {:protocol => adrc_case[:scan_procedure].codename, :subject => adrc_case[:enumber], :message => \"status is 'R' for this case\"}\n\t \tnext\n\t end\n\n\t #this case passes, so let's set it up for prep\n\n\t\t adrc_case[:case_dir] = \"#{adrc_case[:subject_id]}_#{vgroup.vgroup_date.strftime(\"%Y%m%d\")}_wisc\"\n\t\t adrc_case[:subject_dir] = \"#{params[:target_dir]}/#{adrc_case[:case_dir]}\"\n\t\t adrc_case[:participant] = ppt\n\n\t\t if !File.directory?(adrc_case[:subject_dir])\n\t\t Dir.mkdir(adrc_case[:subject_dir])\n\t\t end\n\n\t\t subject_subdirs = []\n\t adrc_case[:images] = []\n\n\t\t images.each do |image|\n\n\t\t \t#check that there's nothing rated \"severe\" or \"incomplete\" on the IQC checks for this image\n\t\t \tif image.passed_iqc?\n\n\t\t\t \tpath_parts = image.path.split(\"/\")\n\t\t\t \timage_target_dir = \"#{adrc_case[:subject_dir]}/#{path_parts.last}\"\n\n\t\t\t \tif subject_subdirs.include? image_target_dir\n\t\t\t \t\t#tack something on the end so that we don't overwrite\n\t\t\t \t\timage_target_dir = \"#{image_target_dir}_#{subject_subdirs.count}}\"\n\t\t\t \tend\n\n\t\t\t \tsubject_subdirs << image_target_dir\n\t\t \t\tadrc_case[:images] << {:path => File.realpath(image.path), :target_dir => image_target_dir}\n\t\t \tend\n\t\t end\n\n\t\t @driver << adrc_case\n\n\t\tend\n\n\t\tself.log << \"Filtering cases complete (#{@driver.count} new cases, #{self.exclusions.count} exclusions from processing)\"\n\tend",
"def process_filters(search_opts = {})\n filter_str = ''\n if search_opts['filter']\n search_opts['filter'].each do |f|\n filter_str = \"#{filter_str} AND #{f}\"\n end\n search_opts.delete('filter')\n end\n filter_str\n end",
"def filter_params\n params.require(:filter).permit(:title, :department, :user, :commit)\n end",
"def query_parameters\n params = {}\n params['filter'] = @optional['filter'] if @optional['filter']\n params\n end",
"def filtering_params(params)\n params.slice(:id, :tipo)\n end",
"def filtering_params\n params.slice(:country, :data_source, :vaccine,\n :date_updated_start_date, :date_updated_end_date,\n :first_vaccine_date_start, :first_vaccine_date_end)\n end",
"def filterHotDogStandsByDrinkPreferences(httpRequestParameters)\n # Only apply the filters if the user has selected what drinks they prefer.\n if httpRequestParameters[\"selectedDrinks\"][\"length\"].to_i > 0\n httpRequestParameters[\"selectedDrinks\"][\"values\"].each do |drinkIndex|\n # Upon every preferred drink selected, if the user has specified a price range, apply a filter that not only\n # checks to see if the drink exists in the set of drink prices, but also to see if the drink price is within\n # the price range the user has specified. Otherwise, only apply the filter to see if the drink exists in\n # the set of drink prices.\n if httpRequestParameters[\"isAPriceRangeSpecified\"] === \"true\"\n @searchQuery = @searchQuery.where(\"exists (select * from drink_prices where drink_id = ? and \" +\n \"drink_prices.hot_dog_stands_id = hot_dog_stands.id and drink_prices.price >= ? and drink_prices.price <= ?)\", \\\n drinkIndex, httpRequestParameters[\"minimumItemPrice\"].to_f, httpRequestParameters[\"maximumItemPrice\"].to_f)\n else\n @searchQuery = @searchQuery.where(\"exists (select * from drink_prices where drink_id = ? and \" +\n \"drink_prices.hot_dog_stands_id = hot_dog_stands.id)\", drinkIndex)\n end\n end\n end\n end",
"def apply_filters(results:)\n return results unless filter_params.present?\n\n if filter_params[:organization_id].present? && !filter_params[:funder_id].present?\n return DataManagementPlan.find_by_organization(\n organization_id: filter_params[:organization_id]\n )\n end\n\n if filter_params[:funder_id].present? && !filter_params[:organization_id].present?\n return DataManagementPlan.find_by_funder(\n organization_id: filter_params[:funder_id]\n )\n end\n\n DataManagementPlan.find_by_organization(organization_id: filter_params[:organization_id])\n .find_by_funder(organization_id: filter_params[:funder_id])\n end",
"def filter_proc(filters = {})\n lambda do |p|\n (filters[:name].nil? || p.name =~ filters[:name]) &&\n (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&\n (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&\n (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&\n (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&\n (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&\n (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&\n (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&\n (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&\n true\n end\n end",
"def set_filters\n @filters = []\n section_ids = Section.pluck(:id)\n\n [:ministers, :departments].each do |filter_type|\n if params[filter_type].present?\n id_list = params[filter_type].map(&:to_i)\n\n id_list.reject! do |item|\n !section_ids.include? item\n end\n\n @filters += Section.where(id: id_list)\n end\n end\n end",
"def extra_search_actions(items, extra_filters = [], kind = nil)\n (extra_filters || []).each do |filter|\n case filter\n when 'my_country'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.where(country: current_user.country)\n when 'churches', 'groups'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'contents'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'events'\n items = items.joins('inner join user_groups on user_groups.id = events.eventable_id and events.eventable_type = \\'UserGroup\\' inner join users on users.id = user_groups.user_id').where('users.country = ?', current_user.country)\n \n # TODO\n end\n when 'my_groups'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.joins(:user_groups).where(user_groups: {id: current_user.user_groups.pluck(:id)})\n when 'churches', 'groups'\n items = items.where(id: current_user.user_groups.select(:id))\n when 'contents'\n items = items.where(user_id: current_user.user_groups_members.select(:id))\n when 'events'\n items = items.where(id: current_user.user_groups_events.select(:id))\n end\n end\n end\n items\n end",
"def filter_params\n params.require(:filter).permit(:name, :brand, :description, :notes)\n end",
"def filters= options = {}\n prominent = [ :eid, :url ]\n narrowing = options.keys & Ydl::Videos.columns - prominent\n @filters = { prominent: prominent, narrowing: narrowing }\n end",
"def filter *filters\n spawn :@filters, @filters + parse_filter_input(filters)\n end",
"def filter_data(data, action)\n params_combinator = ParamsOperators::Retriever.new(data, action)\n params_combinator.run\n end",
"def filter_params\n params.require(:filter).permit(:source, :max_dist, :max_time)\n end",
"def filtering_params(params)\n params.slice(:omnisearch)\n end",
"def filter(filtering_params)\n\t\t\tresults = self.where(nil)\n\t\t\tfiltering_params.each do |key, value|\n\t\t\t\tresults = results.public_send(key, value) if value.present?\n\t\t\tend\n\t\t\tresults\n\t\tend",
"def prepare_filters(input, setup = @valid_filters)\n input = input.keys_to_symbols\n (setup.keys & input.keys).inject({}) do |prepared, filter|\n # TODO if we ever do more complex filters (eg multiple ids, where logically they're stored as a list but go\n # back to a csv string for display), this is where we do it\n prepared.merge(filter => input[filter])\n end\n end",
"def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end",
"def filter_bets(bets)\n %w[country continent tournament_id].each do |parameter|\n bets = bets.where(\"#{parameter} = ?\", params[parameter.to_sym].downcase) if params[parameter.to_sym].present?\n end\n bets\n end",
"def filter_data\n case params[:filter][:info]\n when 'Public'\n @tag = Tag.find_by(tag: 'Public')\n when 'Basketball Courts'\n @tag = Tag.find_by(tag: 'Basketball Courts')\n when 'Book Store'\n @tag = Tag.find_by(tag: 'Book Store')\n end\n\n @joins = Tagtoilet.where('tag_id = ?', @tag.id)\n @toilets = @joins.map{|join| Toilet.find(join.toilet_id)}\n @toilets.to_json\n end",
"def filter_params\n params.require(:filter).permit(:name, :description, :opt_in)\n end",
"def cell_filtering_params\n params.fetch(:cell_filtering, {})\n end",
"def filter_params\n params.permit(:date_lte, :date_gte, :time_lte, :time_gte, :month_details)\n end",
"def filter_params\n params[:f] || {}\n end",
"def do_params_filter scope\n filter_params.each do |k,value|\n if value.present?\n if self.class.custom_filter_fields[k].present?\n scope = self.class.custom_filter_fields[k].call scope, value\n elsif resource_class.column_names.include? k\n if resource_class.columns_hash[k].type == :boolean\n if value == '0'\n puts \"Should filter\"\n scope = scope.where(k => [false,nil])\n else\n scope = scope.where(k => true)\n end\n else\n scope = scope.where(k => value)\n end\n elsif resource_class.reflect_on_association(k.to_sym).present?\n klass = resource_class.reflect_on_association(k.to_sym).klass\n scope = do_inner_params_filter klass, value, scope\n else\n Rails.logger.warn(\"No filter is available for field #{k}\")\n end\n end\n end\n scope\n end",
"def filtering_params(params)\n unless params[:search]\n return []\n end\n # {\"price_from\"=>\"50.000\",\n # \"price_till\"=>\"\",\n # \"property_type\"=>\"propertyTypes.bungalow\",\n # \"locality\"=>\"#<OpenStruct value=\\\"provincias.cadiz\\\", label=\\\"Cádiz\\\">\",\n # \"zone\"=>\"#<OpenStruct value=\\\"provincias.ciudadReal\\\", label=\\\"Ciudad Real\\\">\",\n # \"count_bedrooms\"=>\"6\",\n # \"count_bathrooms\"=>\"\",\n # \"property_state\"=>\"propertyStates.brandNew\"}\n params[:search].slice(:in_locality, :in_zone, :for_sale_price_from, :for_sale_price_till, :for_rent_price_from,\n :for_rent_price_till, :property_type, :property_state, :count_bathrooms, :count_bedrooms)\n end",
"def filter_params\n params.fetch(:filter, {}).permit(:text, :type)\n end",
"def add_filters(filters); end",
"def content_filter_params\n params.require(:content_filter).permit(:filter_list)\n end",
"def jsonapi_filter params, joins_clause = 'joins'\n query = all\n\n params.each do |key, value|\n filter_condition = Jsonapi::Fster::FilterCondition.new(self, key, value)\n query = query.where(filter_condition.where_query)\n\n joins_hash = filter_condition.joins_hash\n query = query.public_send(joins_clause, joins_hash) if joins_hash.present?\n end\n\n query\n end",
"def parse_filter(definition, primary, secondary = nil, extra = nil)\n\n if primary.is_a?(Hash)\n fail ClearlyQuery::FilterArgumentError.new(\"filter hash must have at least 1 entry, got '#{primary.size}'\", {hash: primary}) if primary.blank? || primary.size < 1\n fail ClearlyQuery::FilterArgumentError.new(\"extra must be null when processing a hash, got '#{extra}'\", {hash: primary}) unless extra.blank?\n\n conditions = []\n\n primary.each do |key, value|\n result = parse_filter(definition, key, value, secondary)\n if result.is_a?(Array)\n conditions.push(*result)\n else\n conditions.push(result)\n end\n end\n\n conditions\n\n elsif primary.is_a?(Symbol)\n\n case primary\n when :and, :or\n combiner = primary\n filter_hash = secondary\n result = parse_filter(definition, filter_hash)\n combine_all(combiner, result)\n when :not\n #combiner = primary\n filter_hash = secondary\n\n #fail CustomErrors::FilterArgumentError.new(\"'Not' must have a single combiner or field name, got #{filter_hash.size}\", {hash: filter_hash}) if filter_hash.size != 1\n\n result = parse_filter(definition, filter_hash)\n\n #fail CustomErrors::FilterArgumentError.new(\"'Not' must have a single filter, got #{hash.size}.\", {hash: filter_hash}) if result.size != 1\n\n if result.respond_to?(:map)\n negated_conditions = result.map { |c| compose_not(c) }\n else\n negated_conditions = [compose_not(result)]\n end\n negated_conditions\n\n when *definition.all_fields.dup.push(/\\./)\n field = primary\n field_conditions = secondary\n info = definition.parse_table_field(field)\n result = parse_filter(definition, field_conditions, info)\n\n build_subquery(definition, info, result)\n\n when *OPERATORS\n filter_name = primary\n filter_value = secondary\n info = extra\n\n table = info[:arel_table]\n column_name = info[:field_name]\n valid_fields = info[:filter_settings][:fields][:valid]\n\n custom_field = definition.build_custom_field(column_name)\n\n if custom_field.blank?\n condition(filter_name, table, column_name, valid_fields, filter_value)\n else\n condition_node(filter_name, custom_field, filter_value)\n end\n\n else\n fail ClearlyQuery::FilterArgumentError.new(\"unrecognised combiner or field name '#{primary}'\")\n end\n else\n fail ClearlyQuery::FilterArgumentError.new(\"unrecognised filter component '#{primary}'\")\n end\n end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end",
"def filter_params\n params.require(:filter).permit(family: [], number: [], sub_fam: [], sub_num: [], enhancement: [], enh_sub_fam: [], enh_sub_num: [])\n end",
"def parameters_to_filter\n @parameters_to_filter ||= []\n end",
"def make_conditions(params, model)\n search_string = params[SEARCH_KEY]\n filter_string = params[FILTER_KEY]\n if search_string && filter_string\n error 400, convert(body_for(:invalid_params, [FILTER_KEY]))\n elsif search_string\n words = search_string.downcase.split(\" \")\n { :_keywords => { '$all' => words } }\n elsif filter_string\n begin\n unsafe = QS_FILTER.parse(filter_string)\n sanitize(unsafe, model)\n rescue QueryStringFilter::ParseError\n error 400, convert(body_for(:invalid_filter, filter_string))\n end\n else\n {}\n end\n end",
"def filter!(collection)\n # Limit by type\n collection = collection.where(type: params[:type]) if params.has_key?(:type)\n\n # Limit by Tracker ID\n if params.has_key? :tracker_id\n tracker_ids = (params[:tracker_id] || '').to_s.split(\",\")\n collection = collection.where(tracker_id: tracker_ids)\n\n # not a perfect place, but should be okay for now...\n Tracker.where(id: tracker_ids).each { |tracker| tracker.delay.remote_sync_if_necessary(state: \"open\", person: current_user) }\n end\n\n # Limit by Tracker Type\n if params.has_key?(:tracker_type)\n constant_names = tracker_constant_names_for_type(params[:tracker_type])\n collection = collection.joins(:tracker).where('trackers.type IN (?)', constant_names) unless constant_names.blank?\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:tracker_team_id)\n collection = filter_by_tracker_team_id(collection, params[:tracker_team_id])\n end\n\n # Filter by issue open/closed\n collection = collection.where(can_add_bounty: params[:can_add_bounty].to_bool) if params.has_key?(:can_add_bounty)\n\n #Filter by issue paid_out\n collection = collection.where(paid_out: params[:paid_out].to_bool) if params.has_key?(:paid_out)\n\n # Filter by Featured\n collection = collection.where(featured: params[:featured].to_bool) if params.has_key?(:featured)\n\n # Filter by issue accepting request_for_proposals\n if params[:accepting_proposals].to_bool\n collection = filter_by_accepting_proposals(collection.joins(:request_for_proposal))\n end\n\n if params.has_key?(:bounty_min) || params.has_key?(:bounty_max)\n collection = filter_by_bounty_total(collection)\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:thumbed_by_person_id)\n if params[:thumbed_by_person_id] == 'me' && current_user\n person_id = current_user.id\n else\n person_id = params[:thumbed_by_person_id]\n end\n collection = collection.joins(:thumbs).where(\"thumbs.person_id\" => person_id, \"thumbs.downvote\" => false)\n end\n\n collection\n end",
"def conditions_for_keywords\n sql = []\n params = []\n\n keywords.each do |kw|\n str = \"lower(tasks.name) like ?\"\n str += \" or lower(tasks.description) like ?\"\n sql << str\n 2.times { params << \"%#{ kw.word.downcase }%\" }\n end\n\n sql = sql.join(\" or \")\n res = TaskFilter.send(:sanitize_sql_array, [ sql ] + params)\n return \"(#{ res })\" if !res.blank?\n end",
"def construct_filter_query(queries)\n query_string = '?'\n query_list = Array[]\n\n # Format the include_* queries similarly to other queries for easier\n # processing\n if queries.key?('include_deleted')\n queries['include_deleted'] = if queries['include_deleted']\n ['true']\n else\n ['false']\n end\n end\n\n if queries.key?('include_revisions')\n queries['include_revisions'] = if queries['include_revisions']\n ['true']\n else\n ['false']\n end\n end\n\n # If uuid is included, the only other accepted queries are the\n # include_*s\n if queries.key?('uuid')\n query_string = format('/%s?', queries['uuid'])\n if queries.key?('include_deleted')\n query_string += format('include_deleted=%s&',\n queries['include_deleted'][0])\n end\n\n if queries.key?('include_revisions')\n query_string += format('include_revisions=%s&',\n queries['include_revisions'][0])\n end\n\n # Everthing is a list now, so iterate through and push\n else\n # Sort them into an alphabetized list for easier testing\n # sorted_qs = sorted(queries.to_a, key = operator.itemgetter(0))\n sorted_qs = queries.to_a.sort\n sorted_qs.each do |query, param|\n param.each do |slug|\n # Format each query in the list\n # query_list.push('%s=%s' % Array[query, slug])\n query_list.push(format('%s=%s', query, slug))\n end\n end\n\n # Construct the query_string using the list.\n # Last character will be an & so we can push the token\n query_list.each do |string|\n query_string += format('%s&', string)\n end\n end\n query_string\n end",
"def agg_where\n agg_filters = params.fetch(:agg_filters, {})\n if agg_filters.is_a?(String)\n agg_filters = JSON.parse(agg_filters)\n end\n where = Hash[agg_filters.map{|key, val|\n [key, val]\n }.reject{|x| x[1].empty? }.map{|x| [x[0], x[1].keys]}]\n\n [\"start_date\", \"completion_date\"].each do |key|\n if where.has_key?(key)\n unix_milliseconds_string = where[key].first # only doing one!\n year = Time.at(unix_milliseconds_string.to_i / 1000).year\n where[key] = {\n gte: \"#{year}||/y\",\n lte: \"#{year}||/y\",\n }\n end\n end\n where\n end",
"def index \n\n @components = Component\n\n @filters \n\n @component_type\n\n @component_subtype_id\n\n if component_params[:component_type_id]\n\n @component_type = ComponentType.find params[:component_type_id]\n\n @components = @components.includes(:component_types).where( :component_types => {:id => params[:component_type_id]}).order(:title)\n\n if @component_type.component_category_types.size > 0\n\n @filters = ComponentCategoryType.where(public: true)\n\n @filters = @filters.where(component_type_id: params[:component_type_id])\n\n @filters = @filters.order(:number) \n\n elsif @component_type.component_subtypes.size > 0\n\n @filters = @component_type\n\n # @filters = @filters.where(component_type_id: params[:component_type_id]) \n\n end\n\n add_breadcrumb \"#{@component_type.title}\", components_path(component_type_id: component_params[:component_type_id])\n\n else\n\n add_breadcrumb \"Товары\", :components_path\n\n end\n\n if component_params[:categories]\n\n # @shoes = shoes.where(\"categories ->> '12' = '23' AND categories ->> '13' = '19'\")\n\n # Component.where(\"categories #>> '{\\\"3\\\",0}' = '1' OR categories #>> '{\\\"3\\\",1}' = '1' \")\n \n categories_st = \"(\"\n\n component_params[:categories].each_pair do |key, value|\n\n filter_size = ComponentCategoryValue.where(component_category_type_id: key).size\n\n# http://www.tutorialspoint.com/ruby/ruby_loops.htm\n for i in 0...value.size\n\n for j in 0...filter_size\n\n categories_st << \"categories #>> '{\\\"#{key}\\\",#{j}}' = '#{value[i]}'#{(j==filter_size-1 ? \") AND (\" : \" OR \")}\"\n\n end\n\n end\n\n end\n\n # categories_st = categories_st.slice(0, categories_st.length - 5)\n categories_st = categories_st.slice(0, categories_st.length - 7)\n\n categories_st << \")\" if categories_st\n\n @components = @components.where(categories_st)\n\n end\n\n if component_params[:component_subtype_id]\n\n @component_subtype_id = component_params[\"component_subtype_id\"]\n\n# http://stackoverflow.com/questions/4687004/rails-habtm-relationship-how-can-i-find-a-record-based-on-an-attribute-of-t\n @components = @components.includes(:component_subtypes).where(component_subtypes: {id: @component_subtype_id})\n\n end\n\n if component_params[:size]\n\n @size = component_params[:size]\n\n categories_st = \"\"\n\n @size.each do |el|\n\n # categories_st << \"sizerange @> #{el} AND \"\n categories_st << \"sizerange @> #{el} OR \" \n\n end\n\n # categories_st = categories_st.slice(0, categories_st.length - 5)\n categories_st = categories_st.slice(0, categories_st.length - 4) \n\n @components = @components.where(categories_st)\n\n end\n\n @components = @components.order(:title)\n\n @categories = component_params[:categories].to_h\n\n respond_to do |format|\n format.html {}\n format.js {}\n end\n\n end",
"def csv_filter_params\n params.require(:csv_filter).permit(:name, :csv_attribute_id, :before_value, :after_value, :compare_value, :csv_operator_id)\n end",
"def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end",
"def filter_story_params\n allowed = [\n :title, :description, :estimate, :story_type, :state, :requested_by_id,\n :owned_by_id, :position, :labels\n ]\n filtered = {}\n params[:story].each do |key, value|\n filtered[key.to_sym] = value if allowed.include?(key.to_sym)\n end\n filtered\n end",
"def prepare_filters(filters, page, per_page, filter_group_start_index = 0)\n filter_array = []\n if filters.present?\n filters[:filter_groups].each_with_index do |filter_group, group_index|\n filter_group[:filters].each_with_index do |filter, filter_index|\n filter_string = \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][field]=#{filter[:field]}&\"\n filter_string += \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][value]=#{filter[:value]}&\"\n filter_string += \"searchCriteria[filter_groups][#{group_index + filter_group_start_index}][filters][#{filter_index}][conditionType]=#{filter[:condition]}\"\n filter_array.push(filter_string)\n end\n end\n\n filters[:order].each_with_index do |order, index|\n order_string = \"searchCriteria[sortOrders][#{index}][field]=#{order[:field]}&\"\n order_string += \"searchCriteria[sortOrders][#{index}][direction]=#{order[:direction]}\"\n filter_array.push(order_string)\n end\n end\n\n filter_array.push(\"searchCriteria[pageSize]=#{per_page}\") if per_page.present?\n filter_array.push(\"searchCriteria[currentPage]=#{page}\") if page.present?\n filter_array.join '&'\n end",
"def parse_filter_params(permitted:)\n # Symbolize the keys so the values can be used with keyword arguments in the filter scopes.\n filter_params = params[:filter].try(:permit, permitted).try(:to_h)\n end",
"def filter_params( *allowed )\n\n # grab params\n filtered = params.permit( allowed ).to_h.symbolize_keys.select{ |k,v| v.match( FILTERS[ BASE_PARAMS[ k ]]) }\n\n # do any necessary parsing\n filtered.update( filtered ) do |k,v|\n\n v = Date.parse( v ).at_midnight.utc if BASE_PARAMS[ k ] == :date\n\n v\n\n end\n\n end",
"def paradigms_for_dump\n# puts \"(paradigms_for_dump): #{params.inspect}\"\n\n attrs = params.permit(:status, :dumped)\n\n if attrs[\"status\"] == 'all'\n # if URL is paradigms/peek/all\n # no filtering should be applied:\n # all 'review' and 'ready' paradigms, regardless of 'dumped' are needed\n attrs.delete(\"status\")\n\n elsif ! attrs.key?(\"dumped\")\n # otherwise add filtering condition that picks not dumped paradigms\n # but respect the value of :dumped if given (peek?dumped=true)\n attrs[\"dumped\"] = \"false\"\n end\n\n if attrs.key?(\"dumped\")\n attrs[\"dumped\"] = attrs[\"dumped\"].to_bool \n end\n\n# puts \"filtering: #{attrs.inspect}\"\n\n paradigms = Paradigm.all\n paradigms = paradigms.where(attrs) if attrs\n end",
"def assign_filters\n if self.location_id && self.location.filter_list\n\t\t\tvalues = self.location.filter_list.split(',').map { |f| \"(#{f},#{self.id})\" }.join(',')\n self.connection.execute(\"INSERT DELAYED INTO report_filters (filter_id,report_id) VALUES #{values}\") if !values.blank?\n\t\tend\n\t\ttrue\n end",
"def assign_filters\n if self.location_id && self.location.filter_list\n\t\t\tvalues = self.location.filter_list.split(',').map { |f| \"(#{f},#{self.id})\" }.join(',')\n self.connection.execute(\"INSERT DELAYED INTO report_filters (filter_id,report_id) VALUES #{values}\") if !values.blank?\n\t\tend\n\t\ttrue\n end",
"def build_query(params)\n query = UserInteraction.includes(:user, :interaction, :answer)\n fields = get_fields()\n params.each do |filter|\n field_id = filter['field'].to_sym\n operator = filter['operand']\n operand = filter['value']\n if operator == FILTER_OPERATOR_CONTAINS\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), \"%\"+operand.to_s+\"%\" )\n else\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), operand )\n end\n end\n return query \n end",
"def filter_params\n params.require(:filter).permit(:template, :name, :code)\n end",
"def conditions\n sqlwhere = \"1 = 1 \"\n sqlwhere = sqlwhere + \"and orders.namel like ? \" if is_string_here?(namel)\n sqlwhere = sqlwhere + \"and orders.email like ? \" if is_string_here?(email)\n sqlwhere = sqlwhere + \"and addresses.street_address1 like ? \" if is_string_here?(street_address1)\n sqlwhere = sqlwhere + \"and addresses.street_address2 like ? \" if is_string_here?(street_address2)\n sqlwhere = sqlwhere + \"and orders.user_id = ? \" if is_object_here?(user_id)\n sqlwhere = sqlwhere + \"and orders.order_state_id = ? \" if is_object_here?(order_state_id)\n sqlwhere = sqlwhere + \"and orders.checkout_state_id = ? \" if is_object_here?(checkout_state_id)\n sqlwhere = sqlwhere + \"and orders.created_at > ? \" if is_object_here?(created_at_since)\n sqlwhere = sqlwhere + \"and orders.created_at < ? \" if is_object_here?(created_at_till)\n\n result = [sqlwhere]\n result << UnicodeUtils.downcase(namel) if is_string_here?(namel)\n result << UnicodeUtils.downcase(email) if is_string_here?(email)\n result << UnicodeUtils.downcase(street_address1) if is_string_here?(street_address1)\n result << UnicodeUtils.downcase(street_address2) if is_string_here?(street_address2)\n result << user_id if is_object_here?(user_id)\n result << order_state_id if is_object_here?(order_state_id)\n result << checkout_state_id if is_object_here?(checkout_state_id)\n result << created_at_since if is_object_here?(created_at_since)\n result << created_at_till if is_object_here?(created_at_till)\n result\n end",
"def filtering_params(params)\n\t params.slice(:search, :title, :content)\n\tend",
"def get_filter\n if params[:jobfilter] && filters.any? { |f| f.filter_id == params[:jobfilter] }\n params[:jobfilter]\n end\n end",
"def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end",
"def get_buy_requests_query\n s1='\"properties\".\"order_type\" = '+\"'#{params[:property][:order_type]}'\"\n if params[:property][:property_type] != 0 && params[:property][:property_type] != \"NILL\" && params[:property][:property_type].present?\n s1=s1+\" AND \"+'\"properties\".\"property_type\" = '+\"'#{params[:property][:property_type]}'\"\n end\n if params[:property][:property_location] != 0 && params[:property][:property_location] != \"NILL\" && params[:property][:property_location].present? \n s1=s1+\" AND \"+'\"properties\".\"property_location\" = '+\"'#{params[:property][:property_location]}'\"\n end\n if params[:property][:property_locality] != 0 && params[:property][:property_locality] != \"NILL\" && params[:property][:property_locality].present? \n s1=s1+\" AND \"+'\"properties\".\"property_locality\" = '+\"'#{params[:property][:property_locality]}'\" \n end \n return s1\n end",
"def normalize_params(params)\n # filters\n conditions = params[:filter] && convert_filters(params[:filter])\n \n normalized_conditions = {}\n conditions && conditions.each_pair do |k, v|\n normalized_conditions.merge!(k.gsub(\"__\", \"_\") => v)\n end\n \n {:conditions => normalized_conditions}\n end",
"def selected_filter_conditions(filter_class)\n\n @conditions = \"\"\n @included = []\n\n #pass in existing filters\n if params[:selected_filters]\n @selected_filters = params[:selected_filters] \n else \n @selected_filters = {} \n end\n\n #intialise hashes to store filters\n filter_class.filters.each do |j_f|\n @selected_filters[j_f] = {} if !defined?(@selected_filters[j_f]) || @selected_filters[j_f] == nil \n end\n\n @filtered = params[:filter]\n\n #new filter passed in - add or remove from existing as needed\n if @filtered\n\n if params[:remove]\n @selected_filters[@filtered].delete(params[:id])\n else\n @filter_id = params[:id]\n @filter_name = params[:name]\n @selected_filters[@filtered] = {params[:id] => params[:name]}\n end\n\n end\n\n #build up list of conditions to filter results\n if @selected_filters != {}\n @selected_filters.each do |filter, values|\n\n if values != {}\n\t @included << filter.to_sym\n @conditions += \" AND \" if @conditions != \"\"\n @ids = []\n \n values.each do | v | \n @ids << v[0]\n end\n \n @conditions += \"#{filter}.id IN (#{@ids})\"\n\t end \n end\n end\n\n end",
"def set_filters\n filter_param_keys = [\n 'brand', 'color',\n 'size', 'department', 'keywords'\n ]\n @filters = []\n filter_param_keys.each do |key|\n if !params[key].blank?\n params[key].split(',').each do |val|\n @filters << {:key => key, :val => val}\n end\n end\n end\n \n \n if params[:price]\n params[:price].split(',').each_slice(2).to_a.each do |range|\n @filters << {:key => 'price', :val => range.join(',')}\n end\n end\n\n if @products\n @brands = @products.facet('brand_facet').rows.sort_by{ |brand| brand.value.capitalize}\n @departments = @products.facet('department_facet').rows\n end\n \n @colors = ['green', 'blue', 'purple', 'red', 'pink', 'beige', 'brown', 'yellow', 'orange', 'black', 'white', 'gray', 'teal', 'glowing', 'gold', 'silver']\n \n if [email protected]? && @taxon.has_size?\n sizes = (Spree::Product.sizes.sort_by{|size| size.position}.map(&:presentation) & @products.facet(\"size_facet\").rows.map(&:value))\n end\n end",
"def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def filtro_particular(conscaso, params_filtro)\n return conscaso\n end",
"def get_sell_requests_query\n s1='\"properties\".\"order_type\" = '+\"'#{params[:property][:order_type]}'\"\n if params[:property][:property_type] != 0 && params[:property][:property_type] != \"NILL\" && params[:property][:property_type].present?\n s1=s1+\" AND \"+'\"properties\".\"property_type\" = '+\"'#{params[:property][:property_type]}'\"\n end\n if params[:property][:property_location] != 0 && params[:property][:property_location] != \"NILL\" && params[:property][:property_location].present? \n s1=s1+\" AND \"+'\"properties\".\"property_location\" = '+\"'#{params[:property][:property_location]}'\"\n end\n if params[:property][:property_locality] != 0 && params[:property][:property_locality] != \"NILL\" && params[:property][:property_locality].present? \n s1=s1+\" AND \"+'\"properties\".\"property_locality\" = '+\"'#{params[:property][:property_locality]}'\" \n end \n return s1\n end",
"def query_params\n return if params.blank?\n\n rq_params = params[:rq]\n rq_params&.delete_if { |key, value| key == 'enabled_eq' && value == '0' }\n end",
"def asset_params\n params.select{|key,value| key.in?(Asset.column_names())}\n end",
"def column_filter_conditions_for(table, type)\n values = column_filters[type].join(', ')\n foreign_key = type.singularize.foreign_key\n\n if table == type\n \"\\\\`id\\\\` in (#{ values })\"\n elsif columns_for(table).include?(foreign_key)\n \"\\\\`#{ foreign_key }\\\\` in (#{ values })\"\n end\n end",
"def item_params\n filtered = params.fetch(:item, {}).permit(:done, :task, tag_ids: [])\n if filtered[:tag_ids].blank?\n filtered[:tag_ids] = nil\n end \n return filtered\n end",
"def apply_filters(query, options)\n if @model_ids && options[:mview]\n query = query.where(model_id: @model_ids)\n elsif @model_ids\n query = query.where('scenarios.model_id' => @model_ids)\n end\n query = query.where(scenario_id: @scenario_ids) if @scenario_ids\n query = query.where(indicator_id: @indicator_ids) if @indicator_ids\n query = query.where(location_id: @location_ids) if @location_ids\n query = query.joins(:indicator).where(indicators: {subcategory_id: apply_category_filter}) if @category_ids\n puts query.to_sql.inspect\n query\n end",
"def build_from_params(params)\n if params[:fields] || params[:f]\n self.filters = {}\n add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])\n else\n available_filters.keys.each do |field|\n add_short_filter(field, params[field]) if params[field]\n end\n end\n self.group_by = params[:group_by] || (params[:query] && params[:query][:group_by])\n self.column_names = params[:c] || (params[:query] && params[:query][:column_names])\n self\n end"
] | [
"0.6277281",
"0.6103675",
"0.60293704",
"0.60208803",
"0.6006719",
"0.60038644",
"0.5992396",
"0.5947627",
"0.59263736",
"0.5913383",
"0.59046406",
"0.59046406",
"0.5891756",
"0.5884239",
"0.5862696",
"0.5862696",
"0.58618766",
"0.5858242",
"0.5830111",
"0.58234847",
"0.58136994",
"0.5808589",
"0.5808589",
"0.5754956",
"0.57492",
"0.57486975",
"0.5748166",
"0.5727087",
"0.5694908",
"0.56644374",
"0.5656984",
"0.56549186",
"0.5650813",
"0.5649268",
"0.5645969",
"0.5616295",
"0.5612396",
"0.5593679",
"0.558202",
"0.5564666",
"0.55581284",
"0.5556413",
"0.5536873",
"0.5533766",
"0.553136",
"0.552375",
"0.55115646",
"0.550491",
"0.5503036",
"0.55007935",
"0.5499735",
"0.54994273",
"0.5499385",
"0.5499058",
"0.54953754",
"0.54814816",
"0.5481146",
"0.54804397",
"0.54802686",
"0.54754716",
"0.54646784",
"0.5457072",
"0.54477113",
"0.54458284",
"0.5436183",
"0.5436058",
"0.54262644",
"0.5426024",
"0.54257745",
"0.5424852",
"0.5421085",
"0.54205364",
"0.54196453",
"0.54159087",
"0.5413661",
"0.54122007",
"0.5407846",
"0.5405531",
"0.54019",
"0.5401259",
"0.5401259",
"0.53932524",
"0.53863484",
"0.53854424",
"0.5378099",
"0.5376822",
"0.5373778",
"0.53663355",
"0.53651977",
"0.5362889",
"0.5339131",
"0.5338203",
"0.53346276",
"0.5332098",
"0.53305596",
"0.5325957",
"0.5317543",
"0.5313625",
"0.5302552",
"0.52989376"
] | 0.5817226 | 20 |
GET /stock_disposals GET /stock_disposals.xml | def index
@search = StockDisposal.search(params[:search])
@stock_disposals = @search.order('stock_disposal_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @stock_disposals }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_disposal }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def index\n session[:product] = params[:product] if params[:product]\n @stocks = Stock.product session[:product]\n default_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stocks }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n default_data\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def index_old\n @stocks = Stock.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stocks }\n end\n end",
"def cyberstock\n @classifieds = Cyberstock.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def show\n @net_investment = 0\n @stock = Stock.find(params[:id])\n @investments = Investment.where(stock_id: @stock.id).limit(10)\n @my_investments = Investment.where(stock_id: @stock.id, member_id: current_member.id)\n @my_investments.each do |investment|\n @net_investment += investment.share_change\n end \n @stock.price = StockQuote::Stock.quote(@stock.ticker).last_trade_price_only\n @stock.save\n require 'net/http'\n\n begin\n @url = 'http://chart.finance.yahoo.com/z?s=%{ticker}' % {ticker: @stock.ticker}\n @resp = Net::HTTP.get_response(URI.parse(@url)) # get_response takes an URI object\n rescue\n print \"Connection error.\"\n end \n end",
"def show\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.xml { render :xml => @stockist }\n end\n end",
"def show\n @producto_stock = ProductoStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def show\n @warehouse = Warehouse.find(params[:id])\n @stocks = Stock.where(:company_id => @company.id, :warehouse_id => params[:id]).page(params[:page]).per(20)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse }\n end\n end",
"def index\r\n @stock_transfers = StockTransfer.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @stock_transfers }\r\n end\r\n end",
"def show\n @stock_item = StockItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def show\n @stock_adjustment = StockAdjustment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_adjustment }\n end\n end",
"def show\n @sp500_stock = Sp500Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sp500_stock }\n end\n end",
"def list\n\t@storecunsumptions = Storecunsumption.paginate :page => params[:page], :per_page => 10\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def index\n @stockists = Stockist.all.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @stockists }\n end\n end",
"def show\n @quant = Quant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quant }\n end\n end",
"def show\n @stock_cargo = StockCargo.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_cargo }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def index\n @semi_product_exchanges = SemiProductExchange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @semi_product_exchanges }\n end\n end",
"def show\n\t@storecunsumption = Storecunsumption.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def index\n @spending_rates = SpendingRate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spending_rates }\n end\n end",
"def show\r\n @stock_cargo = StockCargo.find(params[:id])\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @stock_cargo }\r\n end\r\n end",
"def show\n @total_stock = TotalStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @total_stock }\n end\n end",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def show\n @stock_gabarra = StockGabarra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_gabarra }\n end\n end",
"def index\n @savings = @advance.savings\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n render json: @stock\n end",
"def call_api\n url = \"#{@base_uri}/stock\"\n params = {symbol: @symbol, api_token: @api_key}\n\n if @exchange\n params[:stock_exchange] = @exchange\n end\n\n Lita.logger.debug \"call_api: #{url} #{params.inspect}\"\n\n @response = RestClient.get url, {params: params}\n\n Lita.logger.debug \"response: #{@response}\"\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def index\n @product = Product.find(params[:product_id])\n @product_stocks = @product.product_stocks\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_stocks }\n end\n end",
"def show\n @stock_resource = StockResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_resource }\n end\n end",
"def show\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_stock }\n end\n end",
"def show\n @savings = Savings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n @quote = YahooFinance::get_standard_quotes(@stock.ticker)[@stock.ticker]\n @tweets = Twitter.search('$' + @stock.ticker).results\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_stock }\n end\n end",
"def show\r\n @stock_transfer = StockTransfer.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @stock_transfer }\r\n end\r\n end",
"def index\n @quantity_discounts = QuantityDiscount.find(:all).paginate :per_page => 10, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quantity_discounts }\n end\n end",
"def index\n @quants = Quant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quants }\n end\n end",
"def index\n @discounts = Discount.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @discounts }\n end\n end",
"def index\n @search = StockAdjustment.search(params[:search])\n @stock_adjustments = @search.order('stock_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stock_adjustments }\n end\n end",
"def index\n @uniform_stock_receiveds = UniformStockReceived.all\n @search = UniformStockReceived.search(params[:q])\n @uniform_stock_receiveds = @search.result\n end",
"def show\n if Stock.check_valid(params[:symbol])\n if Stock.not_exists?(params[:symbol])\n create\n end\n $stock = Stock.find(params[:symbol])\n # Gather and check chart data\n @input = Stock.get_overview(params)\n if @input === 404\n not_found\n else\n @data = YahooFinance.quotes([params[:symbol]], [:name, :last_trade_price, :ask, :bid, :open, :close, :volume, :market_capitalization, :dividend_yield, :dividend_per_share, :change, :change_in_percent, :last_trade_date, :stock_exchange])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: $stock }\n end\n end\n else\n not_found\n end\n end",
"def show\n @stocklist = Stocklist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stocklist }\n end\n end",
"def index\n @stock_prices = StockPrice.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stock_prices }\n end\n end",
"def index\n @expenses = Expense.limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def show\n @feedstock = Feedstock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedstock }\n end\n end",
"def show\n @openingstockentrymaster = Openingstockentrymaster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @openingstockentrymaster }\n end\n end",
"def index\n @stock_results = StockResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stock_results }\n end\n end",
"def index\n @dispenses = Dispense.all\n end",
"def show\n @portfolio = Portfolio.find(params[:id])\n\n \n # @stocks = YahooFinance.quotes([@portfolio.stocks.group_by(&:stock_symbol)], [:ask, :bid], { raw: false } )\n # additional resources :\n # https://github.com/herval/yahoo-finance\n # https://github.com/rlazoti/yahoofinance-example/blob/master/view_stocks.rb\n\n @stocks = YahooFinance.quotes(@portfolio.stocks.group_by(&:stock_symbol), [:ask, :bid, :symbol, :last_trade_price], { raw: false } )\n \n\n @stock = Stock.new\n @stock.portfolio_id = @portfolio.id\n end",
"def index\n @product_exchanges = ProductExchange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_exchanges }\n end\n end",
"def show\n @stock_price = StockPrice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_price }\n end\n end",
"def uri\n @uri_parameters = {:s => @stock_symbol, :annual => true}\n super\n end",
"def show\n @round_expense = RoundExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @round_expense }\n end\n end",
"def index\n @expense_items = ExpenseItem.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expense_items }\n end\n end",
"def show\n @semi_product_exchange = SemiProductExchange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @semi_product_exchange }\n end\n end",
"def stockview\n @items = Item.all.paginate(:page => params[:page], per_page: 10)\n render action: :stock\n end",
"def stocks\n\n end",
"def index\n render :layout => \"user\"\n #Stock.test 'SK6U.SI'\n #Stock.searchSymbol 'starhub'\n #Stock.historicalData 'CC3.SI','2013-07-21','2013-07-25'\n end",
"def index\n @sale_representatives = SaleRepresentative.find_all_by_company_id(current_user.company_id) \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sale_representatives }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n @items = @stock.item\n @stock_audits = @stock.stock_audit\n end",
"def show\n @catalogs_supply = Catalogs::Supply.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @catalogs_supply }\n end\n end",
"def index\n @fixed_deposits = FixedDeposit.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_deposits }\n end\n end",
"def index\n @priced_items = PricedItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @priced_items }\n end\n end",
"def xhr_list\n @entities = Entity.where(id: AccessResource.get_ids({user: current_user, resource_klass: 'Entity'})).where.not(name: [nil, '']).order(created_at: :desc)\n @stockholder = params[:stockholder].to_b\n render layout: false\n end",
"def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end",
"def index\n @neuropsyches = Neuropsych.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @neuropsyches }\n end\n end",
"def show\n @clenum = Clenum.find(params[:ids])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @clenum }\n end\n end",
"def uri\n @uri_parameters = {:s => @stock_symbol}\n @uri_parameters[:annual] = @annual if @annual\n super\n end",
"def index\n @dispositifs = Dispositif.all\n end",
"def index\n @facturas = Factura.facturatotal(session[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @facturas }\n end\n end",
"def show\n @stock_entry = StockEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_entry }\n end\n end",
"def stoxx\n puts \"\\n******* stoxx *******\"\n\n # == data format: yyyymmdd[hhmm[ss]]\n startDate = \"20170121\" + \"000000\"\n endDate = \"20170317\" + \"000000\"\n symbol = \"IBM\"\n remote_key = Rails.application.config.bar_chart_key\n\n remote_url = \"https://marketdata.websol.barchart.com\"\n remote_url += \"/getHistory.json?key=\" + remote_key + \"&symbol=\" + symbol\n remote_url += \"&type=daily&startDate=\" + startDate + \"&endDate=\" + endDate\n\n json_data = HTTParty.get(remote_url)\n puts \" ** json_data['results'].length: #{json_data['results'].length.inspect}\"\n @stock_data = json_data['results']\n\n end",
"def index\n @company_inventory_stocks = CompanyInventoryStock.all\n end",
"def show\n @stock_transaction = StockTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_transaction }\n end\n end",
"def index\n @inventory_details = InventoryDetail.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @inventory_details }\n end\n end",
"def show\n @ticker = Ticker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticker }\n end\n end",
"def index\n @title=\"Listing Discharges\"\n @discharges = Discharge.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @discharges }\n end\n end",
"def index\r\n @purchase_requisition_categories = PurchaseRequisitionCategory.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @purchase_requisition_categories }\r\n end\r\n end",
"def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end",
"def index\n @labor_cost_lines = LaborCostLine.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @labor_cost_lines }\n end\n end",
"def index\n @lsrs_cmp = LsrsCmp.order('WarehouseName')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lsrs_cmp }\n end\n end",
"def show\n @counselling = Counselling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @counselling }\n end\n end",
"def show\n @incomestock = Incomestock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incomestock }\n end\n end",
"def stocks(refresh = false)\n @stocks = nil if refresh\n @stocks ||= begin\n @client.get(\"venues/#{@venue_symbol}/stocks\")['symbols'] rescue nil\n end\n end",
"def index\n @stock_products = StockProduct.all\n end",
"def index\n @stock_collections = StockCollection.all\n end",
"def index\n @quantity_units = QuantityUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quantity_units }\n end\n end",
"def show\n @quantity_discount = QuantityDiscount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quantity_discount }\n end\n end",
"def new\n @producto_stock = ProductoStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def new\n @stock_item = StockItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end"
] | [
"0.73839664",
"0.69784445",
"0.684364",
"0.68045205",
"0.66675204",
"0.6667231",
"0.6651202",
"0.66298026",
"0.66160965",
"0.66003895",
"0.657",
"0.6551531",
"0.65320325",
"0.6529588",
"0.64958584",
"0.6486223",
"0.64720434",
"0.64450586",
"0.6437113",
"0.6437113",
"0.6437113",
"0.6437113",
"0.6406989",
"0.6394638",
"0.6386343",
"0.635993",
"0.63529205",
"0.63453573",
"0.6314733",
"0.6300163",
"0.62918425",
"0.62796813",
"0.6273164",
"0.62686825",
"0.6256111",
"0.6239286",
"0.62341297",
"0.62264633",
"0.6225429",
"0.6209654",
"0.62063026",
"0.6206065",
"0.6195681",
"0.61789936",
"0.6178498",
"0.61782545",
"0.6171302",
"0.6155357",
"0.61536825",
"0.6121579",
"0.6121579",
"0.6121579",
"0.6121579",
"0.61200535",
"0.6119001",
"0.6107711",
"0.6107524",
"0.61024535",
"0.6095939",
"0.6093582",
"0.60927075",
"0.6088277",
"0.6075805",
"0.60748875",
"0.6066039",
"0.60638714",
"0.6060854",
"0.60547334",
"0.60545415",
"0.60519475",
"0.6043603",
"0.60434127",
"0.6038939",
"0.60298055",
"0.6023448",
"0.60226476",
"0.60209894",
"0.6015597",
"0.60084254",
"0.59976876",
"0.5992303",
"0.59862775",
"0.59856117",
"0.59847885",
"0.59839684",
"0.59785706",
"0.59739566",
"0.59728736",
"0.5962692",
"0.5955112",
"0.5942318",
"0.59371173",
"0.59321904",
"0.5929949",
"0.59294575",
"0.59241915",
"0.5921306",
"0.5917669",
"0.5911217",
"0.59107035"
] | 0.6864505 | 2 |
GET /stock_disposals/1 GET /stock_disposals/1.xml | def show
@stock_disposal = StockDisposal.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @stock_disposal }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n default_data\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def index\n @search = StockDisposal.search(params[:search])\n @stock_disposals = @search.order('stock_disposal_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stock_disposals }\n end\n end",
"def index\n session[:product] = params[:product] if params[:product]\n @stocks = Stock.product session[:product]\n default_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stocks }\n end\n end",
"def show\n @producto_stock = ProductoStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def show\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n format.html # show.haml\n format.xml { render :xml => @stockist }\n end\n end",
"def index_old\n @stocks = Stock.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stocks }\n end\n end",
"def show\n @stock_item = StockItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def show\n @stock_adjustment = StockAdjustment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_adjustment }\n end\n end",
"def show\n @warehouse = Warehouse.find(params[:id])\n @stocks = Stock.where(:company_id => @company.id, :warehouse_id => params[:id]).page(params[:page]).per(20)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @warehouse }\n end\n end",
"def cyberstock\n @classifieds = Cyberstock.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def show\n @quant = Quant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quant }\n end\n end",
"def show\n @net_investment = 0\n @stock = Stock.find(params[:id])\n @investments = Investment.where(stock_id: @stock.id).limit(10)\n @my_investments = Investment.where(stock_id: @stock.id, member_id: current_member.id)\n @my_investments.each do |investment|\n @net_investment += investment.share_change\n end \n @stock.price = StockQuote::Stock.quote(@stock.ticker).last_trade_price_only\n @stock.save\n require 'net/http'\n\n begin\n @url = 'http://chart.finance.yahoo.com/z?s=%{ticker}' % {ticker: @stock.ticker}\n @resp = Net::HTTP.get_response(URI.parse(@url)) # get_response takes an URI object\n rescue\n print \"Connection error.\"\n end \n end",
"def index\r\n @stock_transfers = StockTransfer.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @stock_transfers }\r\n end\r\n end",
"def show\n\t@storecunsumption = Storecunsumption.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def show\n @stock_cargo = StockCargo.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_cargo }\n end\n end",
"def show\n @sp500_stock = Sp500Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sp500_stock }\n end\n end",
"def index\n @stockists = Stockist.all.paginate :page => params[:page], :per_page => 30\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @stockists }\n end\n end",
"def list\n\t@storecunsumptions = Storecunsumption.paginate :page => params[:page], :per_page => 10\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def show\n @stock_gabarra = StockGabarra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_gabarra }\n end\n end",
"def show\r\n @stock_cargo = StockCargo.find(params[:id])\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @stock_cargo }\r\n end\r\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def show\r\n @stock_transfer = StockTransfer.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @stock_transfer }\r\n end\r\n end",
"def index\n @semi_product_exchanges = SemiProductExchange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @semi_product_exchanges }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def show\n @savings = Savings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def call_api\n url = \"#{@base_uri}/stock\"\n params = {symbol: @symbol, api_token: @api_key}\n\n if @exchange\n params[:stock_exchange] = @exchange\n end\n\n Lita.logger.debug \"call_api: #{url} #{params.inspect}\"\n\n @response = RestClient.get url, {params: params}\n\n Lita.logger.debug \"response: #{@response}\"\n end",
"def index\n @spending_rates = SpendingRate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @spending_rates }\n end\n end",
"def show\n @openingstockentrymaster = Openingstockentrymaster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @openingstockentrymaster }\n end\n end",
"def index\n @savings = @advance.savings\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def index\n @search = StockAdjustment.search(params[:search])\n @stock_adjustments = @search.order('stock_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stock_adjustments }\n end\n end",
"def show\n @stock_resource = StockResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_resource }\n end\n end",
"def show\n @catalogs_supply = Catalogs::Supply.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @catalogs_supply }\n end\n end",
"def show\n @semi_product_exchange = SemiProductExchange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @semi_product_exchange }\n end\n end",
"def show\n @total_stock = TotalStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @total_stock }\n end\n end",
"def show\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n render json: @stock\n end",
"def show\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_stock }\n end\n end",
"def index\n @quantity_discounts = QuantityDiscount.find(:all).paginate :per_page => 10, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quantity_discounts }\n end\n end",
"def show\n if Stock.check_valid(params[:symbol])\n if Stock.not_exists?(params[:symbol])\n create\n end\n $stock = Stock.find(params[:symbol])\n # Gather and check chart data\n @input = Stock.get_overview(params)\n if @input === 404\n not_found\n else\n @data = YahooFinance.quotes([params[:symbol]], [:name, :last_trade_price, :ask, :bid, :open, :close, :volume, :market_capitalization, :dividend_yield, :dividend_per_share, :change, :change_in_percent, :last_trade_date, :stock_exchange])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: $stock }\n end\n end\n else\n not_found\n end\n end",
"def uri\n @uri_parameters = {:s => @stock_symbol, :annual => true}\n super\n end",
"def index\n @product = Product.find(params[:product_id])\n @product_stocks = @product.product_stocks\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_stocks }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def index\n @quants = Quant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quants }\n end\n end",
"def index\n @product_exchanges = ProductExchange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_exchanges }\n end\n end",
"def new\n @producto_stock = ProductoStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n @quote = YahooFinance::get_standard_quotes(@stock.ticker)[@stock.ticker]\n @tweets = Twitter.search('$' + @stock.ticker).results\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock }\n end\n end",
"def index\n @discounts = Discount.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @discounts }\n end\n end",
"def stoxx\n puts \"\\n******* stoxx *******\"\n\n # == data format: yyyymmdd[hhmm[ss]]\n startDate = \"20170121\" + \"000000\"\n endDate = \"20170317\" + \"000000\"\n symbol = \"IBM\"\n remote_key = Rails.application.config.bar_chart_key\n\n remote_url = \"https://marketdata.websol.barchart.com\"\n remote_url += \"/getHistory.json?key=\" + remote_key + \"&symbol=\" + symbol\n remote_url += \"&type=daily&startDate=\" + startDate + \"&endDate=\" + endDate\n\n json_data = HTTParty.get(remote_url)\n puts \" ** json_data['results'].length: #{json_data['results'].length.inspect}\"\n @stock_data = json_data['results']\n\n end",
"def show\n @feedstock = Feedstock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedstock }\n end\n end",
"def show\n @ticker = Ticker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticker }\n end\n end",
"def show\n @round_expense = RoundExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @round_expense }\n end\n end",
"def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end",
"def show\n @clenum = Clenum.find(params[:ids])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @clenum }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n @items = @stock.item\n @stock_audits = @stock.stock_audit\n end",
"def new\n @stock_item = StockItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def show\n @stocklist = Stocklist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stocklist }\n end\n end",
"def index\n @expenses = Expense.limit(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expenses }\n end\n end",
"def uri\n @uri_parameters = {:s => @stock_symbol}\n @uri_parameters[:annual] = @annual if @annual\n super\n end",
"def show\n @se_use_consumption_consumable_data = SeUseConsumptionConsumableData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @se_use_consumption_consumable_data }\n end\n end",
"def show\n @portfolio = Portfolio.find(params[:id])\n\n \n # @stocks = YahooFinance.quotes([@portfolio.stocks.group_by(&:stock_symbol)], [:ask, :bid], { raw: false } )\n # additional resources :\n # https://github.com/herval/yahoo-finance\n # https://github.com/rlazoti/yahoofinance-example/blob/master/view_stocks.rb\n\n @stocks = YahooFinance.quotes(@portfolio.stocks.group_by(&:stock_symbol), [:ask, :bid, :symbol, :last_trade_price], { raw: false } )\n \n\n @stock = Stock.new\n @stock.portfolio_id = @portfolio.id\n end",
"def show\n @stock_price = StockPrice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_price }\n end\n end",
"def index\n @expense_items = ExpenseItem.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expense_items }\n end\n end",
"def show\n @quantity_discount = QuantityDiscount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quantity_discount }\n end\n end",
"def show\n @sellerring = Sellerring.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sellerring }\n end\n end",
"def index\n @inventory_details = InventoryDetail.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @inventory_details }\n end\n end",
"def index\n @uniform_stock_receiveds = UniformStockReceived.all\n @search = UniformStockReceived.search(params[:q])\n @uniform_stock_receiveds = @search.result\n end",
"def index\n render :layout => \"user\"\n #Stock.test 'SK6U.SI'\n #Stock.searchSymbol 'starhub'\n #Stock.historicalData 'CC3.SI','2013-07-21','2013-07-25'\n end",
"def show\n @asset_disposal = AssetDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_disposal }\n end\n end",
"def index\n @lsrs_cmp = LsrsCmp.order('WarehouseName')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lsrs_cmp }\n end\n end",
"def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end",
"def show\n @stock_transaction = StockTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_transaction }\n end\n end",
"def index\n @sale_representatives = SaleRepresentative.find_all_by_company_id(current_user.company_id) \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sale_representatives }\n end\n end",
"def show\n @product_exchange = ProductExchange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_exchange }\n end\n end",
"def show\n @discount = Discount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discount }\n end\n end",
"def show\n @spending_rate = SpendingRate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @spending_rate }\n end\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def index\n @stocks = Stock.all\n end",
"def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end",
"def show\n @stock_entry = StockEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_entry }\n end\n end",
"def show\n @lsrs_soildata = LsrsSoil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lsrs_soildata }\n end\n end",
"def index\n @stock_prices = StockPrice.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stock_prices }\n end\n end",
"def stockview\n @items = Item.all.paginate(:page => params[:page], per_page: 10)\n render action: :stock\n end",
"def show\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shelf.to_xml(:include => :books) }\n end\n end",
"def index\n @fixed_deposits = FixedDeposit.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_deposits }\n end\n end",
"def show\n @market_order = MarketOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @market_order }\n end\n end",
"def show\n @movimiento_stock = MovimientoStock.find(params[:id])\n @detalles_movimientos_stocks=DetalleMovimientoStock.find(:all,:conditions=>['id_movimiento_stock = ? ',@movimiento_stock.id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movimiento_stock }\n end\n end",
"def index\n @marketplaces = Marketplace.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @marketplaces }\n end\n end",
"def index\n @neuropsyches = Neuropsych.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @neuropsyches }\n end\n end",
"def stocks\n\n end",
"def show\n @series = Series.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @series }\n end\n end",
"def show\n @price_list = PriceList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @price_list }\n end\n end",
"def show\n @price_list = PriceList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @price_list }\n end\n end",
"def show\n @rate_change_history = RateChangeHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end"
] | [
"0.70859355",
"0.69048846",
"0.6814533",
"0.67747676",
"0.6750608",
"0.67310715",
"0.6709758",
"0.6687208",
"0.66353226",
"0.6603198",
"0.6600585",
"0.6586406",
"0.65736115",
"0.65573055",
"0.65422374",
"0.6491666",
"0.64363325",
"0.6431845",
"0.6419068",
"0.63996696",
"0.63941467",
"0.63940793",
"0.638557",
"0.6367664",
"0.635327",
"0.635327",
"0.635327",
"0.635327",
"0.63422257",
"0.6340388",
"0.62823886",
"0.62725407",
"0.6262864",
"0.62350637",
"0.62309915",
"0.6222",
"0.6215488",
"0.6199565",
"0.6183107",
"0.61763185",
"0.61688995",
"0.6159127",
"0.61476535",
"0.6139713",
"0.6138021",
"0.6121444",
"0.61122555",
"0.60881245",
"0.6086354",
"0.6084131",
"0.6082546",
"0.60820997",
"0.60764164",
"0.60756093",
"0.60712326",
"0.60592645",
"0.60563284",
"0.60555476",
"0.6053349",
"0.6052184",
"0.60505223",
"0.60303587",
"0.6022075",
"0.60216546",
"0.6017432",
"0.6016313",
"0.6011737",
"0.6008205",
"0.5995772",
"0.5991456",
"0.59911555",
"0.5986357",
"0.5969001",
"0.5965049",
"0.5958708",
"0.5940368",
"0.5936589",
"0.59324044",
"0.5930733",
"0.59253967",
"0.5921502",
"0.5921502",
"0.5921502",
"0.5921502",
"0.59072715",
"0.59028155",
"0.5902799",
"0.5902205",
"0.59016836",
"0.59004945",
"0.58971673",
"0.58953047",
"0.5894729",
"0.588953",
"0.58885854",
"0.5886633",
"0.5883494",
"0.5882326",
"0.5882326",
"0.5879551"
] | 0.73961794 | 0 |
GET /stock_disposals/new GET /stock_disposals/new.xml | def new
@stock_disposal = StockDisposal.new
@stock_disposal.stock_disposal_date = Date.today
@stock_disposal.user_id = current_user.id
@stock_disposal.save!
redirect_to edit_stock_disposal_path(@stock_disposal)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @stockist = Stockist.new\n assign_lovs\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @stockist }\n end\n end",
"def new\n @stock_item = StockItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def new\r\n @stock_transfer = StockTransfer.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @stock_transfer }\r\n end\r\n end",
"def new\n @quant = Quant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quant }\n end\n end",
"def new\n @producto_stock = ProductoStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def new\n @savings = Savings.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def new\n @sp500_stock = Sp500Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sp500_stock }\n end\n end",
"def new\n @openingstockentrymaster = Openingstockentrymaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @openingstockentrymaster }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @stock = Stock.new\n default_data\n @main_unit = MeasureUnit.find_main(session[:product]).first\n @last = Stock.last_movimentation(session[:product]).first\n @measure_units = MeasureUnit.by_product session[:product]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @sprint = Sprint.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n # @stock_resource = StockResource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_resource }\n end\n end",
"def new\n @stock_gabarra = StockGabarra.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_gabarra }\n end\n end",
"def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end",
"def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end",
"def new\n @total_stock = TotalStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @total_stock }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new\n @stocklist = Stocklist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stocklist }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def new\n @feedstock = Feedstock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedstock }\n end\n end",
"def new\n @stock_transaction = StockTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_transaction }\n end\n end",
"def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end",
"def new\n @round_expense = RoundExpense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @round_expense }\n end\n end",
"def new\n @catalogs_supply = Catalogs::Supply.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalogs_supply }\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n flash[:notice] = 'Stock was successfully created.'\n format.html { redirect_to(@stock) }\n format.xml { render :xml => @stock, :status => :created, :location => @stock }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @stock_entry = StockEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_entry }\n end\n end",
"def new\n @stock_type = StockType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_type }\n end\n end",
"def new\n @scrape_order = ScrapeOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scrape_order }\n end\n end",
"def new\n @stock_price = StockPrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_price }\n end\n end",
"def new\n @product_stock = ProductStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_stock }\n end\n end",
"def new\n @stock_transfer = StockTransfer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_transfer }\n end\n end",
"def new\n @sellerring = Sellerring.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sellerring }\n end\n end",
"def new\n @title = \"New Operations\"\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @series }\n end\n end",
"def new\n @sticker = Sticker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sticker }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @financial_position = FinancialPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @financial_position }\n end\n end",
"def new\n @fixed_expense = FixedExpense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fixed_expense }\n end\n end",
"def new\n @semi_product_exchange = SemiProductExchange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @semi_product_exchange }\n end\n end",
"def new\n @spending_rate = SpendingRate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spending_rate }\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n @slittingproduction = Slittingproduction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slittingproduction }\n end\n end",
"def new\n @seance = Seance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @seance }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @contract = Contract.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contract }\n end\n end",
"def new\n @contract = Contract.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contract }\n end\n end",
"def new\n @price = Price.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price }\n end\n end",
"def new\n @st_pi = StPi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_pi }\n end\n end",
"def new\n @spit = Spit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spit }\n end\n end",
"def new\n @clenum = Clenum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @clenum }\n end\n end",
"def new\n @discount = Discount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discount }\n end\n end",
"def new\n @shipment = Shipment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shipment }\n end\n end",
"def new\n @requisition = Requisition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisition }\n end\n end",
"def new\n @production = Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @production }\n end\n end",
"def new\n @print = Print.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @print }\n end\n end",
"def show\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_disposal }\n end\n end",
"def new\n @operating_expense = OperatingExpense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end",
"def new\n @centricsteel = Centricsteel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @centricsteel }\n end\n end",
"def new\n @cash_position = CashPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cash_position }\n end\n end",
"def new\n @round = Round.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @round }\n end\n end",
"def new\n @round = Round.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @round }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @purchase_bill }\n end\n end",
"def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expense }\n end\n end",
"def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expense }\n end\n end",
"def new\n @renewal = Renewal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @renewal }\n end\n end",
"def new\n @portfolio = Portfolio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portfolio }\n end\n end",
"def new\n @supplier = Supplier.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @supplier }\n end\n end",
"def new\n @product_exchange = ProductExchange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @product_exchange }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @artist_product }\n end\n end",
"def new\n @convenio = Convenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @convenio }\n end\n end",
"def new\n @quantity_discount = QuantityDiscount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quantity_discount }\n end\n end",
"def new\n @price_list = PriceList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price_list }\n end\n end",
"def new\n @payment_history = PaymentHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payment_history }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def new\n @catalogs_priority = Catalogs::Priority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalogs_priority }\n end\n end",
"def new\n @lsrs_soildata = LsrsSoil.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lsrs_soildata }\n end\n end",
"def new\n @finance = Finance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finance }\n end\n end",
"def new\n @polling_station = PollingStation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @polling_station }\n end\n end",
"def new\n @rate_change_history = RateChangeHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end",
"def new\n @fixed_deposit = FixedDeposit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fixed_deposit }\n end\n end",
"def new\n @variable_charge = VariableCharge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @variable_charge }\n end\n end",
"def new\n @currency = Currency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @currency }\n end\n end",
"def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end",
"def new\n @holding_company = HoldingCompany.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @holding_company }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @catalog_product = CatalogProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog_product }\n end\n end",
"def new\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def new\n @statusproject = Statusproject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @statusproject }\n end\n end"
] | [
"0.7741212",
"0.7340712",
"0.7331441",
"0.7201202",
"0.71404",
"0.71376634",
"0.7123625",
"0.7110244",
"0.7090372",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.6971428",
"0.6971428",
"0.6951421",
"0.6936358",
"0.69197434",
"0.68991786",
"0.6886591",
"0.6872423",
"0.6872423",
"0.6850417",
"0.68290734",
"0.68187547",
"0.6807276",
"0.68040264",
"0.68040264",
"0.6803548",
"0.67589545",
"0.67522836",
"0.6741885",
"0.67404675",
"0.67249197",
"0.6723501",
"0.6719321",
"0.67164",
"0.67090935",
"0.66991806",
"0.6697959",
"0.669703",
"0.66930866",
"0.66758823",
"0.66700774",
"0.666674",
"0.66594505",
"0.66593707",
"0.66569287",
"0.6654942",
"0.6647538",
"0.66297036",
"0.6626854",
"0.6622538",
"0.66077816",
"0.66077816",
"0.66004246",
"0.6599194",
"0.6586493",
"0.6573272",
"0.6554335",
"0.6550068",
"0.65457296",
"0.65424144",
"0.6540957",
"0.6538686",
"0.653472",
"0.6531427",
"0.6520773",
"0.6518219",
"0.6518219",
"0.6516896",
"0.65151733",
"0.65151733",
"0.6511509",
"0.6504768",
"0.65014726",
"0.6501291",
"0.65007037",
"0.6500456",
"0.6500383",
"0.649941",
"0.6497922",
"0.6497665",
"0.64973134",
"0.6494355",
"0.6485447",
"0.64782435",
"0.6477953",
"0.6475576",
"0.64698637",
"0.64689875",
"0.6466655",
"0.6464311",
"0.64625835",
"0.64625835",
"0.646226",
"0.6457621",
"0.64540946",
"0.64532566"
] | 0.0 | -1 |
POST /stock_disposals POST /stock_disposals.xml | def create
@stock_disposal = StockDisposal.new(params[:stock_disposal])
if @stock_disposal.save
redirect_to(edit_stock_disposal_path(@stock_disposal), :notice => 'Stock disposal was successfully created.')
else
render :action => "new"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @repuesto_servicio = RepuestoServicio.new(repuesto_servicio_params)\n @repuesto_servicio.stock=params[:repuesto_servicio][:stock] = 0.0\n respond_to do |format|\n if @repuesto_servicio.save\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue creado con éxito.' }\n format.json { render :show, status: :created, location: @repuesto_servicio }\n else\n format.html { render :new }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n flash[:notice] = 'Stock was successfully created.'\n format.html { redirect_to(@stock) }\n format.xml { render :xml => @stock, :status => :created, :location => @stock }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sp500_stock = Sp500Stock.new(params[:sp500_stock])\n\n respond_to do |format|\n if @sp500_stock.save\n format.html { redirect_to @sp500_stock, notice: 'Sp500 stock was successfully created.' }\n format.json { render json: @sp500_stock, status: :created, location: @sp500_stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sp500_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n @stock.product_id = session[:product]\n\n respond_to do |format|\n if @stock.save\n flash[:notice] = 'Movimentação criada.'\n format.html { redirect_to(@stock) }\n format.xml { render :xml => @stock, :status => :created, :location => @stock }\n else\n default_data\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @sp500_stock = Sp500Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sp500_stock }\n end\n end",
"def create\n stock_values = Ystock.get_stock(params[:stock_resource][:stock])\n @stock_resource = StockResource.new(:symbol => (stock_values[:symbol]), :price => (stock_values[:price]), :change => (stock_values[:change]), :volume => (stock_values[:volume]))\n\n respond_to do |format|\n if @stock_resource.save\n format.html { redirect_to @stock_resource, notice: 'Stock resource was successfully created.' }\n format.json { render json: @stock_resource, status: :created, location: @stock_resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_disposal }\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to stocks_url, notice: 'Stock was successfully created.' }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quant = Quant.new(params[:quant])\n\n respond_to do |format|\n if @quant.save\n flash[:notice] = 'Quant was successfully created.'\n format.html { redirect_to(@quant) }\n format.xml { render :xml => @quant, :status => :created, :location => @quant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n session[:product] = params[:product] if params[:product]\n @stocks = Stock.product session[:product]\n default_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stocks }\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render action: 'show', status: :created, location: @stock }\n else\n format.html { render action: 'new' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n respond_to do |format|\n if @stock.save\n record = Record.new\n record.price = @stock[:price]\n record.stock_id = @stock[:id]\n record.note = @stock[:notes]\n record.date = @stock[:retrieved]\n record.save\n format.html { redirect_to stocks_path, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: stocks_path }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cancellation = Cancellation.new_from_xml(request.body.read)\n respond_to do |format|\n if @cancellation.save! \n format.xml { render :action => 'show', :status => :created, :location => @cancellation }\n else\n format.xml { render :xml => @cancellation.errors, :status => :unprocessable_entity }\n end\n end \n \n #@orders.each do |order|\n end",
"def index\n @search = StockDisposal.search(params[:search])\n @stock_disposals = @search.order('stock_disposal_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stock_disposals }\n end\n end",
"def create\n @purchased_stock = PurchasedStock.new(params[:purchased_stock])\n\n respond_to do |format|\n if @purchased_stock.save\n format.html { redirect_to @purchased_stock, notice: 'Purchased stock was successfully created.' }\n format.json { render json: @purchased_stock, status: :created, location: @purchased_stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchased_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @purchased_stock = PurchasedStock.new(params[:purchased_stock])\n\n respond_to do |format|\n if @purchased_stock.save\n format.html { redirect_to @purchased_stock, notice: 'Purchased stock was successfully created.' }\n format.json { render json: @purchased_stock, status: :created, location: @purchased_stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchased_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @stockist = Stockist.new\n assign_lovs\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @stockist }\n end\n end",
"def new\n @stock = Stock.new\n default_data\n @main_unit = MeasureUnit.find_main(session[:product]).first\n @last = Stock.last_movimentation(session[:product]).first\n @measure_units = MeasureUnit.by_product session[:product]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @producto_stock = ProductoStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @producto_stock }\n end\n end",
"def show\n @net_investment = 0\n @stock = Stock.find(params[:id])\n @investments = Investment.where(stock_id: @stock.id).limit(10)\n @my_investments = Investment.where(stock_id: @stock.id, member_id: current_member.id)\n @my_investments.each do |investment|\n @net_investment += investment.share_change\n end \n @stock.price = StockQuote::Stock.quote(@stock.ticker).last_trade_price_only\n @stock.save\n require 'net/http'\n\n begin\n @url = 'http://chart.finance.yahoo.com/z?s=%{ticker}' % {ticker: @stock.ticker}\n @resp = Net::HTTP.get_response(URI.parse(@url)) # get_response takes an URI object\n rescue\n print \"Connection error.\"\n end \n end",
"def new\n @stock_item = StockItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_item }\n end\n end",
"def create\n @total_stock = TotalStock.new(params[:total_stock])\n\n respond_to do |format|\n if @total_stock.save\n format.html { redirect_to @total_stock, notice: 'Total stock was successfully created.' }\n format.json { render json: @total_stock, status: :created, location: @total_stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @total_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def new\r\n @stock_transfer = StockTransfer.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @stock_transfer }\r\n end\r\n end",
"def create\n \n @producto_stock = ProductoStock.new(params[:producto_stock])\n \n respond_to do |format|\n if @producto_stock.save\n format.html { redirect_to(@producto_stock, :notice => 'ProductoStock was successfully created.') }\n format.xml { render :xml => @producto_stock, :status => :created, :location => @producto_stock }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @producto_stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @stock_item = StockItem.new(params[:stock_item])\n\n respond_to do |format|\n if @stock_item.save\n flash[:notice] = 'StockItem was successfully created.'\n format.html { redirect_to(@stock_item) }\n format.xml { render :xml => @stock_item, :status => :created, :location => @stock_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stock_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @product_stock = ProductStock.new(params[:product_stock])\n\n respond_to do |format|\n if @product_stock.save\n format.html { redirect_to @product_stock, notice: 'Estoque de Produto atualizado' }\n format.json { render json: @product_stock, status: :created, location: @product_stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stock_collection = StockCollection.new(stock_collection_params)\n\n respond_to do |format|\n if @stock_collection.save\n format.html { redirect_to stocks_path, notice: 'Stock collection was successfully loaded.' }\n format.json { render :show, status: :created, location: @stock_collection }\n else\n format.html { render :new }\n format.json { render json: @stock_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params[:stock]\n end",
"def create\n @model_stock = ModelStock.new(model_stock_params)\n\n respond_to do |format|\n if @model_stock.save\n format.html { redirect_to @model_stock, notice: t('common.message.created_success')}\n format.json { render :show, status: :created, location: @model_stock }\n else\n format.html { render :new }\n format.json { render json: @model_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company_inventory_stock = CompanyInventoryStock.new(company_inventory_stock_params)\n\n respond_to do |format|\n if @company_inventory_stock.save\n format.html { redirect_to @company_inventory_stock, notice: 'Company inventory stock was successfully created.' }\n format.json { render :show, status: :created, location: @company_inventory_stock }\n else\n format.html { render :new }\n format.json { render json: @company_inventory_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n params.each do |key,value|\n if key.include? 'quantity'\n c = Commodity.find(key.split('_')[0].to_i)\n quan = value.to_i.abs\n if StockType.find(@document.stock_type_id).s_type == StockingType::SHIPPING\n quan = -quan\n end\n s = @document.stocks.create(commodity_id: c.id, quantity: quan, warehouse_id: @document.warehouse_id)\n CommodityWarehouseRelationship.update_stock(@document.warehouse_id, c.id, quan)\n end\n end\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @total_stock = TotalStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @total_stock }\n end\n end",
"def create\n @uniform_stock_received = UniformStockReceived.new(uniform_stock_received_params)\n\n respond_to do |format|\n if @uniform_stock_received.save\n format.html { redirect_to @uniform_stock_received, notice: (t 'uniform_stock_receiveds.title')+(t 'actions.created') }\n format.json { render action: 'show', status: :created, location: @uniform_stock_received }\n else\n format.html { render action: 'new' }\n format.json { render json: @uniform_stock_received.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stocks\n\n end",
"def new\n @quant = Quant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quant }\n end\n end",
"def create\n @feedstock = Feedstock.new(params[:feedstock])\n\n respond_to do |format|\n if @feedstock.save\n format.html { redirect_to @feedstock, notice: 'Estoque criado.' }\n format.json { render json: @feedstock, status: :created, location: @feedstock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feedstock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n if @stock_disposal.update_attributes(params[:stock_disposal])\n format.html { redirect_to(@stock_disposal, :notice => 'Stock disposal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock_disposal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params.require(:stock).permit(:serial_number, :job_number, :engine_id, :alternator_id, :detail, :status, :status_detail, :gesan_number, :ppsr, :needs_ppsr, :supplier_name, :vin, :shipping_date, :accounts_signoff, :projects_signoff, :location, :ppsr_expiry)\n end",
"def set_dispense_posting_params\n params.require(:dispense).permit(:company_id, :pharmacy_id, :customer_id, :prescription_id, :item_id, :rx_signature_id, :rx_number, :fill_number, :legacy_customer_id_number, :fill_time, :legacy_item_id_number, :refill_type, :status, :split_bill_rx, :billing_complete, :pharmacist_initials, :technician_initials, :quantity, :days_supply, :delivery_route, :lot_number, :serial_number, :discard_date, :price, :usual_customary_price, :base_cost, :acquisition_cost, :fee, :discount, :tax, :ancillary_fee, :professional_service_fee, :cost_basis, :other_coverage_code, :other_amount, :other_amount_type, :reason_for_delay, :denial_override_code, :partial_fill_status, :reported_to_pmp)\n end",
"def uri\n @uri_parameters = {:s => @stock_symbol, :annual => true}\n super\n end",
"def stock_params\n params.require(:stock).permit(:name, :identifier, :type, :base_price, :ltp, :high, :low, :open, :close, :delisted)\n end",
"def create\n @addstock = Addstock.new(addstock_params)\n\n respond_to do |format|\n if @addstock.save\n format.html { redirect_to @addstock, notice: 'Addstock was successfully created.' }\n format.json { render :show, status: :created, location: @addstock }\n else\n format.html { render :new }\n format.json { render json: @addstock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params.require(:stock).permit(:code, :commodity_id, :stock_type_id, :warehouse_id, :price, :quantity, :sum, :summary, :s_date)\n end",
"def cyberstock\n @classifieds = Cyberstock.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end",
"def create\n\n @stock = Stock.new(stock_params)\n @stock.ticker = params[:stock][:ticker].upcase\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to @stock, notice: 'Stock was successfully added to watchlist.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @openingstockentrymaster = Openingstockentrymaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @openingstockentrymaster }\n end\n end",
"def create\n @product_stock = ProductStock.new(params[:product_stock])\n\n respond_to do |format|\n if @product_stock.triggered_save\n format.html { redirect_to product_product_stocks_path(@product_stock.product), :notice => 'Product stock was successfully created.' }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @store = Stock.new(stock_params)\n\n respond_to do |format|\n if @store.save\n format.html { redirect_to @store, notice: 'Stock was successfully created.' }\n format.json { render action: 'show', status: :created, location: @store }\n else\n format.html { render action: 'new' }\n format.json { render json: @store.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params.require(:stock).permit(:symbol, :user_id, :price, :retrieved, :notes, :stock_list_id, :stockList)\n end",
"def new\n @product_stock = ProductStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_stock }\n end\n end",
"def new\n # @stock_resource = StockResource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_resource }\n end\n end",
"def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n temp_params = stock_params\n temp_params[\"type\"] = stock_params[\"type\"] == \"NSE\" ? \"BSE\" : \"NSE\"\n Stock.create(temp_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paperstock = Paperstock.new(paperstock_params)\n\n respond_to do |format|\n if @paperstock.save\n format.html { redirect_to @paperstock, notice: 'Paperstock was successfully created.' }\n format.json { render :show, status: :created, location: @paperstock }\n else\n format.html { render :new }\n format.json { render json: @paperstock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @disponible = Disponible.new(disponible_params)\n\n if @disponible.save\n render json: @disponible, status: :created, location: @disponible\n else\n render json: @disponible.errors, status: :unprocessable_entity\n end\n end",
"def stock_params\n params.require(:stock).permit(:name, :description_1, :description_2, :amount, :assign_amount)\n end",
"def create\n \n ticker = params[:stock][:ticker].upcase\n @stock = Stock.find_or_create_by_ticker(ticker)\n \n respond_to do |format|\n if @stock.valid?\n format.html { redirect_to @stock }\n format.json { render json: @stock, status: :created, location: @stock }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @stock_disposal = StockDisposal.find(params[:id])\n @stock_disposal.voided = true\n @stock_disposal.save!\n flash[:notice] = \"Voided Successfully\"\n\n respond_to do |format|\n format.html { redirect_to(stock_disposals_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @stockist = Stockist.new(params[:stockist])\n\n respond_to do |format|\n if @stockist.save\n flash[:notice] = 'Stockist was successfully created.'\n format.html { redirect_to(admin_stockist_path(@stockist)) }\n format.xml { render :xml => @stockist, :status => :created, :location => @stockist }\n else\n assign_lovs\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stockist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @stock_transaction = StockTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_transaction }\n end\n end",
"def create\n @stock_entry = StockEntry.new(params[:stock_entry])\n\n respond_to do |format|\n if @stock_entry.save\n format.html { redirect_to @stock_entry, notice: 'Stock entry was successfully created.' }\n format.json { render json: @stock_entry, status: :created, location: @stock_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params.require(:stock).permit(:provider, :name, :email, :description, :price, :amount)\n end",
"def index\r\n @stock_transfers = StockTransfer.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @stock_transfers }\r\n end\r\n end",
"def create\n @contract = Contract.new(contract_params)\n @contract.daily_premium_prices.push(params[:daily_premium_prices])\n\n respond_to do |format|\n if @contract.save\n # format.html { redirect_to @contract, notice: 'Contract was successfully created.' }\n format.json { render :show, status: :created, location: @contract }\n else\n format.html { render :new }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @stock_entry = StockEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_entry }\n end\n end",
"def new\n @stocklist = Stocklist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stocklist }\n end\n end",
"def create\n @total_closing = TotalClosing.new(total_closing_params)\n\n respond_to do |format|\n if @total_closing.save\n format.html { redirect_to @total_closing, notice: 'Total closing was successfully created.' }\n format.json { render action: 'show', status: :created, location: @total_closing }\n else\n format.html { render action: 'new' }\n format.json { render json: @total_closing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @round_expense = RoundExpense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @round_expense }\n end\n end",
"def create\n @stock_ticker = StockTicker.new(stock_ticker_params)\n\n respond_to do |format|\n if @stock_ticker.save\n format.html { redirect_to @stock_ticker, notice: 'Stock ticker was successfully created.' }\n format.json { render :show, status: :created, location: @stock_ticker }\n else\n format.html { render :new }\n format.json { render json: @stock_ticker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stock_params\n params.require(:stock).permit(:symbol, :name, :industry_id, :sector_id, :ccc_seq, :price, :yield_years, :div_yield, :old_rate, :new_rate, :mr_inc, :ex_div, :div_record, :div_pay, :qtly_sched, :annual_div, :payout, :i_graham, :p_e, :fye_month, :ttm_eps, :peg_ratio, :ttm_p_sales, :mrq_p_book, :ttm_roe, :ty_growth, :ny_growth, :last_5_growth, :est_5_growth, :na, :mktcap, :inside_own, :debt_equity, :chowder_rule)\n end",
"def new\n @savings = Savings.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @savings }\n end\n end",
"def stock_params\n params.require(:stock).permit(:symbol)\n end",
"def stoxx\n puts \"\\n******* stoxx *******\"\n\n # == data format: yyyymmdd[hhmm[ss]]\n startDate = \"20170121\" + \"000000\"\n endDate = \"20170317\" + \"000000\"\n symbol = \"IBM\"\n remote_key = Rails.application.config.bar_chart_key\n\n remote_url = \"https://marketdata.websol.barchart.com\"\n remote_url += \"/getHistory.json?key=\" + remote_key + \"&symbol=\" + symbol\n remote_url += \"&type=daily&startDate=\" + startDate + \"&endDate=\" + endDate\n\n json_data = HTTParty.get(remote_url)\n puts \" ** json_data['results'].length: #{json_data['results'].length.inspect}\"\n @stock_data = json_data['results']\n\n end",
"def new\n @stock_transfer_voucher = StockTransferVoucher.new_stock_transfer(@company)\n\n @products = Product.where(:company_id => @company.id, :inventory => true)\n @destination_warehouses = @company.warehouses\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stock_transfer_voucher }\n end\n end",
"def stock_params\n params.fetch(:stock, {})\n end",
"def xhr_list\n @entities = Entity.where(id: AccessResource.get_ids({user: current_user, resource_klass: 'Entity'})).where.not(name: [nil, '']).order(created_at: :desc)\n @stockholder = params[:stockholder].to_b\n render layout: false\n end",
"def new\n @stock_price = StockPrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_price }\n end\n end",
"def new\n @stock_transfer = StockTransfer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_transfer }\n end\n end",
"def create\n @stock_price = StockPrice.new(params[:stock_price])\n\n respond_to do |format|\n if @stock_price.save\n format.html { redirect_to @stock_price, notice: 'Stock price was successfully created.' }\n format.json { render json: @stock_price, status: :created, location: @stock_price }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stock_price.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6200757",
"0.6067822",
"0.59701884",
"0.5920933",
"0.5904213",
"0.5868793",
"0.58488536",
"0.57551795",
"0.57526445",
"0.57396585",
"0.57396585",
"0.57396585",
"0.57396585",
"0.5730848",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5712397",
"0.5703639",
"0.56894964",
"0.5688815",
"0.5686687",
"0.5679166",
"0.56765985",
"0.56627774",
"0.56627774",
"0.56626153",
"0.5657525",
"0.56317395",
"0.562568",
"0.5618757",
"0.56139374",
"0.5584579",
"0.5584579",
"0.55772805",
"0.5573225",
"0.55583525",
"0.5557016",
"0.55488634",
"0.55432314",
"0.55314255",
"0.55307496",
"0.5515074",
"0.5515074",
"0.5515074",
"0.5515074",
"0.5515074",
"0.5515074",
"0.55117965",
"0.5505597",
"0.5501156",
"0.54991716",
"0.5497323",
"0.547269",
"0.5468695",
"0.5460699",
"0.5455886",
"0.54467285",
"0.5430812",
"0.54271793",
"0.5422229",
"0.54165006",
"0.5415515",
"0.54104155",
"0.54102427",
"0.5409896",
"0.5402079",
"0.5394951",
"0.5390305",
"0.5379292",
"0.5372893",
"0.5372498",
"0.53692114",
"0.5366767",
"0.5364374",
"0.5364083",
"0.53520066",
"0.5342243",
"0.5340328",
"0.5336308",
"0.53302747",
"0.53285766",
"0.5324116",
"0.5323907",
"0.5306808",
"0.5304534",
"0.5298446",
"0.52978224",
"0.52928275",
"0.5291015",
"0.5286484",
"0.52844775",
"0.5282974",
"0.52822906",
"0.52721035",
"0.5266383",
"0.5254992"
] | 0.63193685 | 0 |
PUT /stock_disposals/1 PUT /stock_disposals/1.xml | def update
@stock_disposal = StockDisposal.find(params[:id])
respond_to do |format|
if @stock_disposal.update_attributes(params[:stock_disposal])
format.html { redirect_to(@stock_disposal, :notice => 'Stock disposal was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @stock_disposal.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n flash[:notice] = 'Stock was successfully updated.'\n format.html { redirect_to(@stock) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_stock\n \tproduct = FileOperations.search_by_name(self)\n \tproduct = product[0].split(';')\n \tself.id = product[0]\n \tself.name = product[1]\n \tself.price = product[2]\n \tself.company = product[3]\n \tself.stock = product[4].to_i - 1\n \tFileOperations.update(self)\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n flash[:notice] = 'Movimentação atualizada.'\n format.html { redirect_to(@stock) }\n format.xml { head :ok }\n else\n default_data\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sp500_stock = Sp500Stock.find(params[:id])\n\n respond_to do |format|\n if @sp500_stock.update_attributes(params[:sp500_stock])\n format.html { redirect_to @sp500_stock, notice: 'Sp500 stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sp500_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n format.html { redirect_to stocks_url, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @producto_stock = ProductoStock.find(params[:id])\n\n respond_to do |format|\n if @producto_stock.update_attributes(params[:producto_stock])\n format.html { redirect_to(@producto_stock, :notice => 'ProductoStock was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @producto_stock.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:symbol])\n binding.pry\n respond_to do |format|\n if @stock.update_attributes(params[:currentPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n if @stock.update_attributes(params[:openingPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n if @stock.update_attributes(params[:closingPrice])\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock.update(stock_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company_inventory_stock.update(company_inventory_stock_params)\n format.html { redirect_to @company_inventory_stock, notice: 'Company inventory stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_inventory_stock }\n else\n format.html { render :edit }\n format.json { render json: @company_inventory_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_resource = StockResource.find(params[:id])\n\n respond_to do |format|\n if @stock_resource.update_attributes(params[:stock_resource])\n format.html { redirect_to @stock_resource, notice: 'Stock resource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n if @product_stock.update_attributes(params[:product_stock])\n format.html { redirect_to @product_stock, notice: 'Estoque atualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @total_stock = TotalStock.find(params[:id])\n\n respond_to do |format|\n if @total_stock.update_attributes(params[:total_stock])\n format.html { redirect_to @total_stock, notice: 'Total stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @total_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @model_stock.update(model_stock_params)\n format.html { redirect_to @model_stock, notice: t('common.message.updated_success')}\n format.json { render :show, status: :ok, location: @model_stock }\n else\n format.html { render :edit }\n format.json { render json: @model_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n PostLogger.info(\"Change position - Now: #{@stock.quantity} shares of #{@stock.symbol} in #{@stock.portfolio.user.name}'s - #{@stock.portfolio.name} Portfolio\")\n\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quant = Quant.find(params[:id])\n\n respond_to do |format|\n if @quant.update_attributes(params[:quant])\n flash[:notice] = 'Quant was successfully updated.'\n format.html { redirect_to(@quant) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock_collection.update(stock_collection_params)\n format.html { redirect_to @stock_collection, notice: 'Stock collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock_collection }\n else\n format.html { render :edit }\n format.json { render json: @stock_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @movimiento_stock = MovimientoStock.find(params[:id])\n respond_to do |format|\n if @movimiento_stock.update_attributes(params[:movimiento_stock])\n format.html { redirect_to @movimiento_stock, notice: 'Movimiento stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movimiento_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n @stock_cargo = StockCargo.find(params[:id])\n respond_to do |format|\n if @stock_cargo.update_attributes(params[:stock_cargo])\n flash[:notice] = '货物更新成功.'\n format.html { redirect_to(@stock_cargo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock_cargo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @purchased_stock = PurchasedStock.find(params[:id])\n\n respond_to do |format|\n if @purchased_stock.update_attributes(params[:purchased_stock])\n format.html { redirect_to @purchased_stock, notice: 'Purchased stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @purchased_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @purchased_stock = PurchasedStock.find(params[:id])\n\n respond_to do |format|\n if @purchased_stock.update_attributes(params[:purchased_stock])\n format.html { redirect_to @purchased_stock, notice: 'Purchased stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @purchased_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feedstock = Feedstock.find(params[:id])\n\n respond_to do |format|\n if @feedstock.update_attributes(params[:feedstock])\n format.html { redirect_to @feedstock, notice: 'Estoque atualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feedstock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_item = StockItem.find(params[:id])\n\n respond_to do |format|\n if @stock_item.update_attributes(params[:stock_item])\n flash[:notice] = 'StockItem was successfully updated.'\n format.html { redirect_to(@stock_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @repuesto_servicio = RepuestoServicio.new(repuesto_servicio_params)\n @repuesto_servicio.stock=params[:repuesto_servicio][:stock] = 0.0\n respond_to do |format|\n if @repuesto_servicio.save\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue creado con éxito.' }\n format.json { render :show, status: :created, location: @repuesto_servicio }\n else\n format.html { render :new }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_disposal }\n end\n end",
"def update\n @stockist = Stockist.find(params[:id])\n\n respond_to do |format|\n if @stockist.update_attributes(params[:stockist])\n flash[:notice] = 'Stockist was successfully updated.'\n format.html { redirect_to(admin_stockist_path(@stockist)) }\n format.xml { head :ok }\n else\n assign_lovs\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stockist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @asset_disposal = AssetDisposal.find(params[:id])\n\n respond_to do |format|\n if @asset_disposal.update_attributes(params[:asset_disposal])\n format.html { redirect_to(@asset_disposal, :notice => t('disposal.title2')+\" \"+t('updated')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset_disposal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stockstatus.update(stockstatus_params)\n format.html { redirect_to @stockstatus, notice: 'Stockstatus was successfully updated.' }\n format.json { render :show, status: :ok, location: @stockstatus }\n else\n format.html { render :edit }\n format.json { render json: @stockstatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @store.update(stock_params)\n format.html { redirect_to @store, notice: 'Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @store.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n nueva_cantidad = compra_params[:cantidad].to_i\n\n respond_to do |format|\n if @compra.edit_stock(nueva_cantidad) && @compra.update(compra_params)\n format.html { redirect_to @compra, notice: 'Compra was successfully updated.' }\n format.json { render :show, status: :ok, location: @compra }\n else\n format.html { render :edit }\n format.json { render json: @compra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @mateStock = MateStock.find(params[:id])\n\n respond_to do |format|\n if @mateStock.update_attributes(params[:mate_stock])\n format.html { redirect_to action: 'index', notice: 'Mate Stock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mateStock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_adjustment = StockAdjustment.find(params[:id])\n\n respond_to do |format|\n if @stock_adjustment.update_attributes(params[:stock_adjustment])\n format.html { redirect_to(@stock_adjustment, :notice => 'Stock adjustment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stock_adjustment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cash_dispense = CashDispense.find(params[:id])\n\n respond_to do |format|\n if @cash_dispense.update_attributes(params[:cash_dispense])\n format.html { redirect_to @cash_dispense, notice: 'Cash dispense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cash_dispense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @addstock.update(addstock_params)\n format.html { redirect_to @addstock, notice: 'Addstock was successfully updated.' }\n format.json { render :show, status: :ok, location: @addstock }\n else\n format.html { render :edit }\n format.json { render json: @addstock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asset_stock.update(asset_stock_params)\n format.html { redirect_to @asset_stock, notice: 'Asset stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_stock }\n else\n format.html { render :edit }\n format.json { render json: @asset_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_type = StockType.find(params[:id])\n\n respond_to do |format|\n if @stock_type.update_attributes(params[:stock_type])\n format.html { redirect_to @stock_type, notice: 'Stock type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to:1つのアクションから複数のフォーマットで返す\n respond_to do |format|\n if @stock.update(stock_params)\n \n # 写真のアップロードと保存\n if params[:stock].has_key? :picture\n @stock.picture = params[:stock][\"picture\"].read\n @stock.filename = params[:stock][\"picture\"].original_filename\n @stock.save\n end\n\n format.html { redirect_to @stock, notice: 'Stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock }\n else\n format.html { render :edit }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def push\n API::SOAP::CatalogInventory::StockItem.update(self.product);\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def set_stock\n @stock = Stock.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @stock_ticker.update(stock_ticker_params)\n format.html { redirect_to @stock_ticker, notice: 'Stock ticker was successfully updated.' }\n format.json { render :show, status: :ok, location: @stock_ticker }\n else\n format.html { render :edit }\n format.json { render json: @stock_ticker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @uniform_stock_received.update(uniform_stock_received_params)\n format.html { redirect_to @uniform_stock_received, notice: (t 'uniform_stock_receiveds.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @uniform_stock_received.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @disponible = Disponible.find(params[:id])\n\n if @disponible.update(disponible_params)\n head :no_content\n else\n render json: @disponible.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @distributor_stock_book.update(distributor_stock_book_params)\n format.html { redirect_to @distributor_stock_book, notice: 'Distributor stock book was successfully updated.' }\n format.json { render :show, status: :ok, location: @distributor_stock_book }\n else\n format.html { render :edit }\n format.json { render json: @distributor_stock_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product_stock = ProductStock.find(params[:id])\n\n respond_to do |format|\n ProductStock.transaction do\n if @product_stock.update_stock_history(params[:product_stock], params[:description]) &&\n @product_stock.triggered_update_attributes(params[:product_stock])\n format.html { redirect_to product_product_stocks_path(@product_stock.product), :notice => 'Product stock was successfully updated.' }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end\n end",
"def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end",
"def destroy\n @stock_disposal = StockDisposal.find(params[:id])\n @stock_disposal.voided = true\n @stock_disposal.save!\n flash[:notice] = \"Voided Successfully\"\n\n respond_to do |format|\n format.html { redirect_to(stock_disposals_url) }\n format.xml { head :ok }\n end\n end",
"def update \r\n\r\n @stock_cargo = current_user.stock_cargos.find(params[:id])\r\nputs @stock_cargo.cargoname\r\n respond_to do |format|\r\n if @stock_cargo.update_attributes!(params[:stock_cargo])\r\n flash[:notice] = '货物更新成功.'\r\n format.html { redirect_to(@stock_cargo) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @stock_cargo.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n respond_to do |format|\n if @asset_stock_status.update(asset_stock_status_params)\n format.html { redirect_to @asset_stock_status, notice: 'Asset stock status was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_stock_status }\n else\n format.html { render :edit }\n format.json { render json: @asset_stock_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock_product.update_attributes(stock_product_params)\n format.html { redirect_to @stock_product, notice: 'Stock product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incomestock = Incomestock.find(params[:id])\n\n respond_to do |format|\n if @incomestock.update_attributes(params[:incomestock])\n format.html { redirect_to @incomestock, notice: 'Incomestock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incomestock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_transaction = StockTransaction.find(params[:id])\n\n respond_to do |format|\n if @stock_transaction.update_attributes(params[:stock_transaction])\n format.html { redirect_to stock_transactions_path, notice: 'Stock transaction was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_stock_book.update(product_stock_book_params)\n format.html { redirect_to @product_stock_book, notice: 'Product stock book was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_stock_book }\n else\n format.html { render :edit }\n format.json { render json: @product_stock_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @stock_transfer = StockTransfer.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @stock_transfer.update_attributes(params[:stock_transfer])\r\n flash[:notice] = 'StockTransfer was successfully updated.'\r\n format.html { redirect_to(@stock_transfer) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @stock_transfer.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @stock_entry = StockEntry.find(params[:id])\n\n respond_to do |format|\n if @stock_entry.update_attributes(params[:stock_entry])\n format.html { redirect_to @stock_entry, notice: 'Stock entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stock_price = StockPrice.find(params[:id])\n\n respond_to do |format|\n if @stock_price.update_attributes(params[:stock_price])\n format.html { redirect_to @stock_price, notice: 'Stock price was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_price.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @idea = Idea.find(params[:id])\n stock = Stock.find(params[:stock_id])\n @idea.stock = stock\n \n respond_to do |format|\n if @idea.update_attributes(params[:idea])\n format.html { redirect_to(@idea, :notice => 'Idea was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @idea.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @atp_stock.update(atp_stock_params)\n format.html { redirect_to @atp_stock, notice: 'Atp stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @atp_stock }\n else\n format.html { render :edit }\n format.json { render json: @atp_stock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stock_interval.update(stock_interval_params)\n format.html { redirect_to @stock_interval, notice: 'Stock interval was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock_interval.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_sample_stock.update(product_sample_stock_params)\n format.html { redirect_to @product_sample_stock, notice: 'Product sample stock was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_sample_stock }\n else\n format.html { render :edit }\n format.json { render json: @product_sample_stock.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6463435",
"0.63264483",
"0.6311057",
"0.6310576",
"0.62480193",
"0.6191191",
"0.6191191",
"0.6191191",
"0.61430705",
"0.6135126",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.60818243",
"0.6046155",
"0.60362464",
"0.60362464",
"0.6034732",
"0.6026568",
"0.6021538",
"0.60166156",
"0.60028505",
"0.59825",
"0.5966776",
"0.5961692",
"0.5960555",
"0.5956925",
"0.594219",
"0.5918573",
"0.5918573",
"0.5916346",
"0.59146035",
"0.58882415",
"0.5843434",
"0.58432454",
"0.58287287",
"0.58168566",
"0.58148617",
"0.57925814",
"0.5791098",
"0.5788502",
"0.5784599",
"0.57817566",
"0.5777529",
"0.5769057",
"0.5767563",
"0.5760646",
"0.57301867",
"0.57280904",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57203597",
"0.57085156",
"0.5701741",
"0.5695104",
"0.56778514",
"0.5677156",
"0.5657645",
"0.5656496",
"0.56555915",
"0.56498957",
"0.5646437",
"0.56450695",
"0.5643882",
"0.5617004",
"0.5607728",
"0.5606777",
"0.55986744",
"0.5597918",
"0.55945987",
"0.55853486",
"0.55734223",
"0.557199",
"0.55696625"
] | 0.6835427 | 0 |
DELETE /stock_disposals/1 DELETE /stock_disposals/1.xml | def destroy
@stock_disposal = StockDisposal.find(params[:id])
@stock_disposal.voided = true
@stock_disposal.save!
flash[:notice] = "Voided Successfully"
respond_to do |format|
format.html { redirect_to(stock_disposals_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to(stocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to(stocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @producto_stock = ProductoStock.find(params[:id])\n @producto_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to(producto_stocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stockist = Stockist.find(params[:id])\n @stockist.destroy\n\n respond_to do |format|\n format.html { redirect_to(stockists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_item = StockItem.find(params[:id])\n @stock_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(stock_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock = Stock.find( params[:id] )\n @stock.delete_status = 1\n @stock.save\n #@stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_edit_all_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sp500_stock = Sp500Stock.find(params[:id])\n @sp500_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to sp500_stocks_url }\n format.json { head :no_content }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def deleteStock\n p params[:ticker]\n Stock.where(:ticker => params[:ticker]).destroy_all \n end",
"def destroy\n @stock_gabarra = StockGabarra.find(params[:id])\n @stock_gabarra.destroy\n\n respond_to do |format|\n format.html { redirect_to(stock_gabarras_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @openingstockentrymaster = Openingstockentrymaster.find(params[:id])\n @openingstockentrymaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(openingstockentrymasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @total_stock = TotalStock.find(params[:id])\n @total_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to total_stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock_cargo = StockCargo.find(params[:id])\n @stock_cargo.destroy\n\n respond_to do |format|\n format.html { redirect_to(stock_cargos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shelf = Shelf.find(params[:id])\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to(shelves_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n redirect_to delete_stock_investments_path(@stock.id)\n @stock.destroy \n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @gstr_advance_receipts = GstrAdvanceReceipt.find_by_id_and_company_id(params[:id], @company.id)\n @gstr_advance_receipts.delete_gstr_one_entry \n @gstr_advance_receipts.delete\n respond_to do |format|\n @gstr_advance_receipts.register_delete_action(request.remote_ip, @current_user, 'deleted')\n format.html { redirect_to(gstr_advance_receipts_url, :notice =>\"Gstr Advance Receipt has been succesfully deleted\") }\n format.xml {head :ok}\n \n end\n end",
"def destroy\r\n @stock_cargo = StockCargo.find(params[:id])\r\n @stock_cargo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(stock_cargos_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @purchased_stock = PurchasedStock.find(params[:id])\n @purchased_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to purchased_stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchased_stock = PurchasedStock.find(params[:id])\n @purchased_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to purchased_stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @round_expense = RoundExpense.find(params[:id])\n @round_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(round_expenses_url) }\n format.xml { head :ok }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n # @core_stock_product.destroy\n # respond_to do |format|\n # format.html { redirect_to core_stock_products_url }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @savings = Savings.find(params[:id])\n @savings.destroy\n\n respond_to do |format|\n format.html { redirect_to(savings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_audit = StockAudit.new\n @stock_audit.user = current_user\n @stock_audit.stock = @stock\n @stock_audit.comment = \"destroyed stock unit with an ID of #{@stock.id}\"\n @stock_audit.save\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uniform_stock_received.destroy\n respond_to do |format|\n format.html { redirect_to uniform_stock_receiveds_url, notice: (t 'uniform_stock_receiveds.title')+(t 'actions.removed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @economic = Economic.find(params[:id])\n @economic.destroy\n\n respond_to do |format|\n format.html { redirect_to(economics_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @operating_expense = OperatingExpense.find(params[:id])\n @operating_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(operating_expenses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @semi_product_exchange = SemiProductExchange.find(params[:id])\n @semi_product_exchange.destroy\n\n respond_to do |format|\n format.html { redirect_to(semi_product_exchanges_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n sql = \"DELETE FROM stock_items WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n end",
"def destroy\n @feedstock = Feedstock.find(params[:id])\n @feedstock.destroy\n\n respond_to do |format|\n format.html { redirect_to feedstocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @qx = Qx.find(params[:id])\n @qx.destroy\n\n respond_to do |format|\n format.html { redirect_to(qxes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quantity_discount = QuantityDiscount.find(params[:id])\n @quantity_discount.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_quantity_discounts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_resource = StockResource.find(params[:id])\n @stock_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_resources_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @catalogs_supply = Catalogs::Supply.find(params[:id])\n @catalogs_supply.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalogs_supplies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_entry = StockEntry.find(params[:id])\n @stock_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale_on_sale_import = SaleOnSaleImport.find(params[:id])\n @sale_on_sale_import.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_on_sale_imports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product_stock = ProductStock.find(params[:id])\n @product_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to product_stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock_price = StockPrice.find(params[:id])\n @stock_price.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_prices_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @product_stock = ProductStock.find(params[:id])\n @product_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to product_stocks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully deleted from watchlist.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_stock.destroy\n respond_to do |format|\n format.html { redirect_to model_stocks_url, notice: t('common.message.destroyed_success')}\n format.json { head :no_content }\n end\n end",
"def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_transaction = StockTransaction.find(params[:id])\n @stock_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_transactions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cash_dispense = CashDispense.find(params[:id])\n @cash_dispense.destroy\n\n respond_to do |format|\n format.html { redirect_to cash_dispenses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @stock_transfer = StockTransfer.find(params[:id])\r\n @stock_transfer.destroy\r\n \r\n flash[:notice] = \"Stock Transfer successfully destroyed\"\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(stock_transfers_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @catalog = Catalog.find(params[:id])\n @catalog.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalogs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock_interval.destroy\n respond_to do |format|\n format.html { redirect_to stock_intervals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scrape_order = ScrapeOrder.find(params[:id])\n @scrape_order.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrape_orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sellerring = Sellerring.find(params[:id])\n @sellerring.destroy\n\n respond_to do |format|\n format.html { redirect_to(sellerrings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url, notice: 'Stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @discharge = Discharge.find(params[:id])\n @discharge.destroy\n\n respond_to do |format|\n format.html { redirect_to(discharges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @discount = Discount.find(params[:id])\n @discount.destroy\n\n respond_to do |format|\n format.html { redirect_to(discounts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @company_inventory_stock.destroy\n respond_to do |format|\n format.html { redirect_to company_inventory_stocks_url, notice: 'Company inventory stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock_product.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stoc.destroy\n respond_to do |format|\n format.html { redirect_to stock_url, notice: 'Stoc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def handle_del( m, params )\n name = params[:name].downcase.sub(/[ ]/, '_')\n unless @stock.has_key?( name )\n m.reply( \"Not in registry.\" ); return\n end\n @stock.delete(name)\n @registry[:stock] = @stock\n m.reply( \"done\" )\n end",
"def destroy\n @stock_collection.destroy\n respond_to do |format|\n format.html { redirect_to stock_collections_url, notice: 'Stock collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typical_deliverable = TypicalDeliverable.find(params[:id])\n @typical_deliverable.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => 'catalogs') }\n #format.xml { head :ok }\n end\n end",
"def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n File.delete(get_file_path(@stocked_file))\n @stocked_file.destroy\n respond_to do |format|\n format.html { redirect_to stocked_files_url, notice: 'Stocked file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @expenditure_category = ExpenditureCategory.find(params[:id])\n @expenditure_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenditure_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dailyreport = Dailyreport.find(params[:id])\n @dailyreport.destroy\n\n respond_to do |format|\n format.html { redirect_to(dailyreports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n stock= @sales_order_detail.stock\n stock.update(:quantity=> (stock.quantity+@sales_order_detail.quantity))\n @sales_order_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+@sales_order_detail.sales_order.id.to_s, notice: 'Sales order detail was successfully deleted.' }\n end\n end",
"def destroy\n @store.destroy\n respond_to do |format|\n format.html { redirect_to stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @paperstock.paperstock_items.each do |paperstock_item|\n paperstock_item.destroy\n end\n @paperstock.destroy\n respond_to do |format|\n format.html { redirect_to paperstocks_url, notice: 'Paperstock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @total_closing.destroy\n respond_to do |format|\n format.html { redirect_to total_closings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asset_disposal = AssetDisposal.find(params[:id])\n @asset_disposal.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_disposals_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\tStorecunsumption.find(params[:id]).destroy\n\tredirect_to :action => 'list'\n\tend",
"def destroy\n audit(@finance_document, current_user)\n @finance_document.destroy\n\n head :no_content\n end",
"def destroy\n @stock_transfer = StockTransfer.find(params[:id])\n @stock_transfer.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_transfers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @warehouse_supplier = WarehouseSupplier.find(params[:id])\n @warehouse_supplier.destroy\n\n respond_to do |format|\n format.html { redirect_to(warehouse_suppliers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @atp_stock.destroy\n respond_to do |format|\n format.html { redirect_to atp_stocks_url, notice: 'Atp stock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end",
"def destroy\n @rr_sale = RrSale.find(params[:id])\n @rr_sale.destroy\n\n respond_to do |format|\n format.html { redirect_to(rr_sales_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.6983932",
"0.6983932",
"0.6754126",
"0.66912115",
"0.6672646",
"0.665523",
"0.66400844",
"0.65826917",
"0.65727395",
"0.65109795",
"0.650712",
"0.6475347",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64137226",
"0.64111155",
"0.63989794",
"0.6397535",
"0.6397535",
"0.6393141",
"0.637626",
"0.637552",
"0.6366184",
"0.63583815",
"0.63583815",
"0.6355684",
"0.6340545",
"0.63339573",
"0.63336927",
"0.6315305",
"0.6298776",
"0.62887996",
"0.62827116",
"0.6276794",
"0.6271403",
"0.6270091",
"0.62622976",
"0.62490344",
"0.6248827",
"0.6247153",
"0.6246284",
"0.62182134",
"0.6217779",
"0.6212721",
"0.6209368",
"0.6187938",
"0.6187698",
"0.6187286",
"0.6183253",
"0.6175869",
"0.61689025",
"0.61673194",
"0.6166886",
"0.61617666",
"0.61565137",
"0.61533153",
"0.615099",
"0.6149009",
"0.6148485",
"0.6136357",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.61345994",
"0.6130741",
"0.6129264",
"0.61269814",
"0.61264956",
"0.6125388",
"0.612177",
"0.61217654",
"0.6120537",
"0.6113193",
"0.61073035",
"0.61066407",
"0.6094057",
"0.6094057",
"0.60895944",
"0.6086963",
"0.60836625",
"0.6078846",
"0.60755897",
"0.60725343",
"0.6071862",
"0.6070868",
"0.6070654",
"0.60694325",
"0.6062445",
"0.606096",
"0.60599566"
] | 0.6327988 | 33 |
This is landing page when lawfirm admin logs in | def index
update_session
@company_id = current_user.company_id
@company = Company.find(@company_id, :include => :product_licences)
@users = User.find(:all,:include=>[:company,:employee,:role,{:product_licence_details=>{:product_licence=>:product}}],:conditions=>['company_id=?',@company.id]) if @company.users_not_client
@employees = @company.employees.size
@totalusers = @users.size
@activeusers = SubproductAssignment.all(:select => ["distinct user_id"], :conditions => ["company_id = ? AND employee_user_id IS NULL", @company_id]).size
@activepermlicence = 0
@activetemplicence = 0
@remainpermlicence = 0
@remaintemplicence = 0
@duration_setting = @company.duration_setting
@company.product_licences.each do |pl|
@activepermlicence += 1 if (pl.licence_type == 0 and pl.status == 1)
@activetemplicence += 1 if (pl.licence_type == 1 and pl.status == 1)
@remainpermlicence += 1 if (pl.licence_type == 0 and pl.status == 0)
@remaintemplicence += 1 if (pl.licence_type == 1 and pl.status == 0)
end
params[:company_id]=current_user.company_id
if params[:company_id].present?
@company ||= Company.find(params[:company_id])
@tne_setting = @company.tne_invoice_setting.id if @company.tne_invoice_setting.present?
end
respond_to do |format|
format.html #index.html.erb
format.xml { render :xml => @users }
authorize!(:index,current_user) unless current_user.role?:lawfirm_admin
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def landing_page\n if current_user\n redirect_to actions_path(current_user[:id])\n end\n end",
"def landing\n redirect_to dashboard_path if current_user\n end",
"def home\n if user_signed_in?\n current_user.update_attribute(:login_status, true) if current_user # update login status for logged in user\n if !current_user.is_super_admin? && current_user.sign_in_count == 1 && current_user.created_by != 0 #User records which are created by super admin or dept admin has to change the password while they are logged in first time\n redirect_to :controller => \"registrations\", :action => \"privacy_setting\"\n else\n redirect_to :controller => \"dashboard\", :action => \"index\"\n end\n else\n redirect_to new_user_session_path\n end\n end",
"def landing\n render text: '<h3>You logged in!</h3>', layout: true\n end",
"def logged_in_admin\n unless admin?\n # show a flash message on the page\n flash[:danger] = \"Non sei autorizzato a visitare questa pagina\"\n # redirect user to home page\n redirect_to root_path\n end\n end",
"def index\n if !user_signed_in?\n redirect_to home_path\n elsif current_user.admin?\n redirect_to admin_portal_path\n else\n redirect_to portal_path\n end\n end",
"def home_check\n if logged_in? && @current_user.admin?\n puts @current_user\n redirect_to account_url(@current_user.id)\n return\n elsif logged_in?\n redirect_to cases_path\n else\n redirect_to page_path(\"home\")\n return\n end\n end",
"def home\n if user_signed_in?\n\n if current_user.connection_valid?\n @favorites = current_user.favorites\n @queries = current_user.queries\n @keytech_username = current_user.keytech_username\n # Load Dashboard async in javascript\n render 'home'\n else\n render 'invalid_login'\n end\n else\n\n # User is not signed in in platform\n render 'landing_page'\n end\n end",
"def landing\n redirect_to(root_url) && return unless ADMIN_OPTIONS['report_mode']\n end",
"def landing\n redirect_to(root_url) && return unless ADMIN_OPTIONS['report_mode']\n end",
"def admin_logged_in\n unless admin_logged_in?\n redirect_to root_url, flash: {danger: '请登陆'}\n end\n end",
"def admin\n if user_signed_in?\n \t redirect_to members_url\n \telse\n \t redirect_to new_user_session_path\n \t end\n \n end",
"def show\n if cookies[:admin_id]\n \n else\n redirect_to \"/\"\n end\n end",
"def admin_signin_status\n unless user_signed_in? && is_admin?\n redirect_to root_url\n end\n end",
"def show\n if !session[:is_admin]\n redirect_to root_url\n end\n end",
"def app_landing\n end",
"def loginpage\n end",
"def landing\n \n end",
"def landing\n \n end",
"def landing\n end",
"def landing\n end",
"def show\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n end",
"def landing\n if student_signed_in?\n redirect_to shops_path\n elsif shop_signed_in?\n redirect_to current_shop\n end\n end",
"def index\n if user_signed_in?\n redirect_to dashboard_path\n else\n render :index\n #redirect_to new_user_session_url(subdomain: ENV[\"SUBDOMAIN\"])\n end\n end",
"def user_dashboard\n if @current_user.superadmin_role\n path = auth_hub.index_superadmin_url\n elsif @current_user.admin_role\n path = auth_hub.index_admin_url\n elsif @current_user.admin_servizi\n path = auth_hub.index_admin_url\n end\n redirect_to path unless path.blank?\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Admin Access Only.\"\n redirect_to login_url\n \n end\n end",
"def login_page\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Зайдите как администратор\"\n redirect_to login_url\n end\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Зайдите как администратор\"\n redirect_to login_url\n end\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Зайдите как администратор\"\n redirect_to login_url\n end\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Зайдите как администратор\"\n redirect_to login_url\n end\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Зайдите как администратор\"\n redirect_to login_url\n end\n end",
"def home\n if current_user\n redirect_to '/dashboard'\n else\n render 'home'\n end\n end",
"def home\n if !view_context.signed_in?\n redirect_to '/'\n end\n end",
"def admin_user\n if logged_in?\n redirect_to root_url unless current_user.admin?\n elsif\n #flash[:failure] = \"Invalid Request\"\n redirect_to(root_url)\n end\n end",
"def admin_user\n if logged_in?\n redirect_to root_url unless current_user.admin?\n elsif\n #flash[:failure] = \"Invalid Request\"\n redirect_to(root_url)\n end\n end",
"def home\n if logged_in?\n redirect_to user_path(current_user) # Redirect to user show page if logged in\n else\n render layout: 'welcome' # Render home view with welcome layout\n end\n end",
"def show\n\t\tif !isLogin\n\t\t\tredirect_to controller: 'login', action: 'login'\n\t\t\treturn\n\t\tend\n\n\tend",
"def show\n\t\tif !isLogin\n\t\t\tredirect_to controller: 'login', action: 'login'\n\t\t\treturn\n\t\tend\n\n\tend",
"def admin_logged_in\n unless (logged_in? && current_employee.admin)\n flash[:danger] = \"Please log in to access this page.\"\n redirect_to adminlogin_path\n end\n end",
"def admin_user\n if logged_in?\n redirect_to(root_url) unless current_user.admin?\n else\n flash[:danger] = \"You reached an invalid url and have been redirected to the home page.\"\n redirect_to(root_url)\n end\n end",
"def logged_in_admin\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to admin_login_path\n end\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def logged_in_admin\n unless logged_admin_in?\n flash[:danger] = \"Access denied.\"\n redirect_to root_path\n end\n end",
"def admin_required\n if not admin?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end",
"def welcome\n if user_logged_in?\n redirect_to root_path\n else\n redirect_to new_user_registration_path\n end\n end",
"def logged_in_admin\n unless current_user && current_user.admin\n flash[:danger] = \"Please log in as admin.\"\n redirect_to '/home'\n end\n end",
"def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end",
"def index\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n else \n redirect_to '/'\n end\n end",
"def require_admin\n unless env['warden'].user.advisor? || env['warden'].user.resident?\n flash.error = \"You are not authorized to access that page.\"\n redirect '/'\n end\n end",
"def index\n if user_signed_in?\n redirect_to home_path\n end\n end",
"def index\n if user_signed_in?\n redirect_to home_path\n end\n end",
"def home\n # if user_signed_in?\n # redirect_to studios_path=end\n # end\n end",
"def login_required\n if !logged_in?\n flash[:notice] = \"Log in to edit or delete your post\"\n redirect_to welcome_index_path\n else\n flash[:notice] = \"Alerting you to the monkey on your car!\"\n end\n end",
"def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&¤t_user.admin?\n end",
"def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&¤t_user.admin?\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def requires_login\n unless user_logged_in?\n return redirect_to login_index_path, notice: \"You must login to view that page.\"\n end\n end",
"def logged_in_band\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to band_login_url\n end\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin? # se current_user.admin for falso redireciona para pagina principal\n end",
"def login\n redirect_to lato_core.root_path if core_controlSession\n end",
"def admin_user\n redirect_to(root_url) unless logged_in?&¤t_user.user_role\n end",
"def index\n render ('index') #render the admin_helpers view. The main page controller calls this action after the admin_helpers logs in\n end",
"def index\n redirect_to(:action => 'login') unless logged_in? \n end",
"def home\n # check if signed_in and then display (you are currently signed in, view your profile)\n # automatically renders page 'users/home'\n if signed_in?\n redirect_to current_user\n else\n @event = Event.find(ENV['demopage'].to_i)\n @event_code = @event.event_code\n @url = demo_record_vg_url(:event_code => @event.event_code)\n\n\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\n render :unsigned_home, :layout => nil\n end\n\n end",
"def admin_user\n\t unless current_user.admin?\n flash[:danger] = \"Log in as Admin.\"\n redirect_to(root_url)\n\t end \n\t end",
"def start\n redirect_to member_dashboard_path if member_signed_in?\n end",
"def new\n redirect_to dashboard_path, notice: \"Logged in!\" if logged_in?\n end",
"def admin_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" \n return\n end\n\n unless current_user.admin?\n redirect_to boards_path, notice: \"You do not have permission for that.\" \n return\n end\n end",
"def login\n if admin_is_signed_in?\n redirect_to admin_index_path\n return\n end\n if user_is_signed_in?\n redirect_to root_path\n return\n end\n @admin=Admin.new\n end",
"def autenticathe_admin!\n unless someone_is_logged_in? && is_admin_user?(current_user)\n redirect_to root_path\n end\n end",
"def admin_required!\n if current_user.blank?\n redirect_to new_user_session_path, :flash => {:notice => \"Please login to access that page.\"}\n elsif !current_user.is_superadmin? && !current_user.is_admin?\n redirect_to root_path, :flash => {:notice => \"You are not authorized user to access that page.\"}\n end\n end",
"def admin_logged_in!\n return if current_admin.present?\n \n flash[:alert] = \"You must be signed in as an administrator\"\n redirect_to login_url\n end",
"def show\n if user_signed_in?\n else\n redirect_to root_path\n end\n end",
"def authorized\n if logged_in?\n return View(\"sessions/page_requires_login\"); \n end\n return View(\"Index\")\n end",
"def show\n @user = current_user\n @admin = @user.admin\n unless @admin\n redirect_to :root, :alert => t(\"notice.access\")\n end\n end",
"def login_required\n \t\t redirect_to(root_url, notice: 'You have to be signed in to do that! Top right ~') unless current_user\n \tend",
"def index\n # The hook below can access controller's instance variables.\n if current_user\n if current_user.role?:livia_admin\n redirect_to companies_url\n elsif is_secretary_or_team_manager?\n redirect_to \"/wfm/notes\"\n elsif current_user.end_user\n redirect_to physical_clientservices_home_index_path\n elsif is_client\n redirect_to matter_clients_url\n elsif current_user.role?:lawfirm_admin\n redirect_to lawfirm_admins_url\n return\n end\n else\n flash[:error] = t(:flash_DB_error)\n redirect_to login_url\n end\n end",
"def index\n if is_logged_in\n redirect_to(:action=>'list')\n end\n #all logic in login_redirect_logic\n end",
"def logged_in\n unless customer_logged_in? || employee_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to customer_login_url\n end\n end",
"def home\n authenticate!\n end",
"def adm_login_form\n render 'adm_login'\n end",
"def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end",
"def admin_user\n unless logged_in? && current_user.admin?\n redirect_to root_url\n end\n end",
"def authorize_page\n if (params[:id] == 'dashboard' or params[:id] == 'welcome') and current_user.nil?\n session[:next] = request.fullpath\n puts session[:next]\n redirect_to new_user_session_path, alert: _(\"You have to log in to continue.\")\n end\n end",
"def require_login\n if !current_user\n flash[:error] = \"You must be logged in to access this section\"\n redirect_to main_app.root_path # halts request cycle\n end\n \n end",
"def new\n if logged_in?\n redirect_to admin_url\n end\n end",
"def index\n # Insert ruby code...\n redirect_to home_path if current_user\n end",
"def index\n\t\t# Logs user in if session cookie is present\n\t\tif @user = User.find_by_id(session[:user]) \n\t\t\tredirect_to user_dash_path(@user) \n\t\tend\n\tend",
"def not_authenticated\n redirect_to root_landing_url\n end",
"def landing() end",
"def index\n redirect_to disabled_path\n # unless logged_in?\n # redirect_to tour_path\n # else\n # @current_item = \"my_hsa\"\n # end\n end",
"def admin_user\n redirect_to(root_url) unless current_doctor.admin?\n end",
"def admin_user\n \n unless current_user.admin?\n \tflash[:danger] = \"Please log in with the correct user name.\"\n \tredirect_to(root_url)\n end\n end",
"def home\n redirect_to signin_path() and return if ( @current_user.nil? )\n end",
"def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless user_signed_in? && current_user.admin?\n end",
"def logged_in\n unless logged_in?\n redirect_to root_url, flash: {danger: '请登陆'}\n end\n end",
"def authorized\n redirect_to '/welcome' unless logged_in?\n end",
"def show\n if current_user && current_user.admin?\n else\n #flash[:notice] = \"No such page exists\"\n redirect_to new_sponsorship_path\n end \n end",
"def admin_user\n\t\tunless admin? \n\t\t\tflash[:danger] = \"Only administrators have access to this page\"\n\t\t\tredirect_back_or(root_url) \n\t\tend\n\tend"
] | [
"0.7578353",
"0.75149035",
"0.74154544",
"0.7392141",
"0.7380116",
"0.7125782",
"0.7101803",
"0.7048784",
"0.7013973",
"0.70138943",
"0.7004813",
"0.6988301",
"0.69840455",
"0.69813025",
"0.69743896",
"0.6942855",
"0.6911446",
"0.69081086",
"0.69081086",
"0.68998235",
"0.68998235",
"0.6855731",
"0.6824682",
"0.6791787",
"0.6776018",
"0.675067",
"0.67496943",
"0.6740663",
"0.6740663",
"0.6740663",
"0.6740663",
"0.6740663",
"0.67356575",
"0.6735626",
"0.6732869",
"0.6732869",
"0.6727666",
"0.6726784",
"0.6726784",
"0.6724391",
"0.67077297",
"0.6699706",
"0.6696109",
"0.66879475",
"0.6680265",
"0.66784775",
"0.667371",
"0.666863",
"0.6668602",
"0.66442627",
"0.66410166",
"0.66410166",
"0.66362464",
"0.663423",
"0.66335386",
"0.66335386",
"0.66242933",
"0.6623944",
"0.6605186",
"0.66002005",
"0.6598173",
"0.6597185",
"0.65955776",
"0.659511",
"0.65889186",
"0.65858215",
"0.6584847",
"0.6583277",
"0.6576731",
"0.6575098",
"0.6573266",
"0.6570611",
"0.6570159",
"0.65660983",
"0.65650815",
"0.6563383",
"0.6563149",
"0.65560967",
"0.6553323",
"0.6551282",
"0.6543949",
"0.6542196",
"0.65402937",
"0.6536975",
"0.6533757",
"0.65326005",
"0.6530097",
"0.65292746",
"0.6529053",
"0.65279824",
"0.65273637",
"0.6523533",
"0.65108943",
"0.6510745",
"0.6510248",
"0.65047383",
"0.65047383",
"0.64978075",
"0.6495792",
"0.64953035",
"0.64945555"
] | 0.0 | -1 |
GET /lawfirm_admins/new GET /lawfirm_admins/new.xml | def new
@employee = Employee.new
@lawfirm_admin = User.new
@roles = Role.scoped_by_company_id(current_user.company_id)
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @lawfirm_admin }
authorize!(:new,current_user) unless current_user.role?:lawfirm_admin
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def newAdmin\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @admin = Admin.new\n build_permissions\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end",
"def new\n @adminnistrador = Adminnistrador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adminnistrador }\n end\n end",
"def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end",
"def new\n @administrator = Administrator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrator }\n end\n end",
"def new\n @administrativo = Administrativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrativo }\n end\n end",
"def new\n @admin = AdminAccount.find_by_id(session[:admin_id])\n @admin_account = AdminAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_account }\n end\n end",
"def new\n respond_to do |format|\n format.json { render :json => @admin } \n format.xml { render :xml => @admin }\n format.html\n end\n end",
"def new\n\t\t@user = User.new\n\t\t@addresses = Address.all\n\t\t@address = Address.new\n\t\t\n\t\twidok = 'new'\n\t\twidok = 'user_new' if !(admin_logged_in?)\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html { render widok } # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @user }\n\t\tend\n\tend",
"def new\n @admin_test = Admin::Test.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_test }\n end\n end",
"def new\n @admin_town = Admin::Town.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_town }\n end\n end",
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def create\n @admin = Admin.new(params[:admin])\n\n respond_to do |format|\n if @admin.save\n format.html { redirect_to([:admin, @admin], :notice => 'Admin was successfully created.') }\n format.xml { render :xml => @admin, :status => :created, :location => @admin }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @new = true\n @administrativo = Administrativo.new\n @administrativo.build_user\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @administrativo }\n end\n end",
"def new\n @whitelist = Whitelist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @whitelist }\n end\n end",
"def new\n @user_addon = UserAddon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_addon }\n end\n end",
"def new\n @user = User.new\n get_list\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @user }\n end\n end",
"def new\n @usr = Usr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usr }\n end\n end",
"def new\n @user = Admin.new\n\n respond_to do |format|\n format.html { render :template => \"admin/session/new\"}\n format.xml { render :xml => @user }\n end\n end",
"def new\n @admin = AdminAccount.find_by_id(session[:admin_id])\n @user_account = UserAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_account }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @account = Admin::Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @admin_information = Admin::Information.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_information }\n end\n end",
"def new\n @user = User.new\n render :xml => @user\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end",
"def new\n\tputs \"\\n\\t\\t in new\\n\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @admin_language = Language.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_language }\n end\n end",
"def new\n @norma = Norma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norma }\n end\n end",
"def new\n @plantilla = Plantilla.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plantilla }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @online_retailer_user }\n end\n end",
"def new\n @admin_production = Admin::Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_production }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html { render :template => \"admin_sites/new\" }\n format.xml { render :xml => @site }\n end\n end",
"def new\n @alfabe = Alfabe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @alfabe }\n end\n end",
"def new\n @add_users_to_film = AddUsersToFilm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_users_to_film }\n end\n end",
"def new\n @accountadmin_language = AccountadminLanguage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @accountadmin_language }\n end\n end",
"def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end",
"def new\n # TODO: refactor models so that externaluserdomain is in portal namespace?\n # @external_user_domain = Portal::ExternalUserDomain.new\n @external_user_domain = ExternalUserDomain.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @external_user_domain }\n end\n end",
"def new\n logger.debug(\"Create a new user\")\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n \tif is_admin_logged\n \t\t@admin_panel = true\n\t @news = News.new\t\n\t respond_to do |format|\n\t format.html # new.html.erb\n\t format.xml { render :xml => @news }\n\t end\n\t \n\t else\n\t \tflash.now[:error] = \"Zaloguj sie jako administrator\"\n\t \tredirect_to root_url\t \t\n\t end\n end",
"def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end",
"def new\n @rol = Rol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rol }\n end\n end",
"def new\n respond_to do |format|\n format.html { head :forbidden }\n format.xml { head :forbidden }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.xml { render xml: @user}\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @permiso = Permiso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @permiso }\n end\n end",
"def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end",
"def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end",
"def new\n @docent = Docent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @docent }\n end\n end",
"def new\r\n @administrateur = Administrateur.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @administrateur }\r\n end\r\n end",
"def new\n @leilao = Leilao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @leilao }\n end\n end",
"def new\n @apparel = Apparel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @apparel }\n end\n end",
"def new\n @portal = Portal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal }\n end\n end",
"def new\n @loantypemaster = Loantypemaster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loantypemaster }\n end\n end",
"def new\n @login = Login.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @login }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin }\n end\n end",
"def new\n @admin_coleccion = Admin::Coleccion.new\n @page_title = 'Nueva Colección'\n @action = 'Crear Colección'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin_coleccion }\n end\n end",
"def new\n @tipo_lista = TipoLista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_lista }\n end\n end",
"def new\n @applicant_status = ApplicantStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @applicant_status }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def new\n @lb202556 = Lb202556.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def new\n @senhas = Senha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @senhas }\n end\n end",
"def new\n @primary_role = PrimaryRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @primary_role }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end",
"def new\n @zorg_voor_jeugd_alias = ZorgVoorJeugdAlias.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @zorg_voor_jeugd_alias }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end",
"def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end",
"def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def new\n @user = User.new\n logger.info 'huyen anh'\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def create\n @lien = Lien.new(params[:lien])\n\n respond_to do |format|\n if @lien.save\n flash[:notice] = 'Lien was successfully created.'\n format.html { redirect_to(@lien) }\n format.xml { render :xml => @lien, :status => :created, :location => @lien }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @allergen = Allergen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @allergen }\n end\n end",
"def new\n @role = Role.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @lablocational = Lablocational.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lablocational }\n end\n end",
"def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end",
"def new\n @ministerio = Ministerio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ministerio }\n end\n end",
"def new\n @program_language = ProgramLanguage.new\n\n @admin_log = AdminLog.new(:aid=> session[:user_id], :controller => \"program_language\", :action => \"new\")\n @admin_log.save\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @program_language }\n end\n end",
"def new\n @uitgelicht = Uitgelicht.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end",
"def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lieu }\n end\n end",
"def new\n @firm = Firm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @firm }\n end\n end",
"def new\n @user = User.new\n @roles = Role.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def new\n @database = Database.new\n @users = User.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @database }\n end\n end",
"def new\n @userapp = Userapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @userapp }\n end\n end",
"def new\n @olark = Olark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @olark }\n end\n end",
"def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @user }\n end\n end",
"def new\n @staffclassification = Staffclassification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @staffclassification }\n end\n end",
"def new\n @role_user = RolesUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_user }\n end\n end"
] | [
"0.7479434",
"0.7479434",
"0.7479434",
"0.73625475",
"0.7280876",
"0.7228282",
"0.7226389",
"0.71882176",
"0.71882176",
"0.7166781",
"0.6993046",
"0.6900532",
"0.6839136",
"0.6838397",
"0.6787496",
"0.67837363",
"0.6780029",
"0.67764145",
"0.6773507",
"0.6769669",
"0.675304",
"0.6738025",
"0.669716",
"0.6682591",
"0.6680606",
"0.66757196",
"0.6666129",
"0.6635011",
"0.6632503",
"0.66238904",
"0.661672",
"0.66129553",
"0.66122377",
"0.6609348",
"0.66069216",
"0.66067886",
"0.6606616",
"0.6604767",
"0.6601039",
"0.6596855",
"0.6593951",
"0.6592407",
"0.65838903",
"0.65781665",
"0.65781665",
"0.6576523",
"0.65764856",
"0.65713924",
"0.6566531",
"0.6566531",
"0.6553945",
"0.65459895",
"0.65422195",
"0.6541681",
"0.6539921",
"0.65378505",
"0.6530412",
"0.6526973",
"0.6521442",
"0.65211594",
"0.6520734",
"0.6520111",
"0.65148354",
"0.6510341",
"0.6502147",
"0.6501714",
"0.64959836",
"0.6491779",
"0.64881325",
"0.6481384",
"0.648085",
"0.6479789",
"0.6475546",
"0.64742744",
"0.64726657",
"0.64726657",
"0.64726657",
"0.64726657",
"0.64712894",
"0.6469832",
"0.64691097",
"0.64627033",
"0.64611435",
"0.6458813",
"0.6458169",
"0.6457362",
"0.6455953",
"0.6453257",
"0.6452923",
"0.6452587",
"0.6451497",
"0.6449387",
"0.6449262",
"0.64482963",
"0.6446389",
"0.6440249",
"0.64370716",
"0.64349866",
"0.64346594",
"0.64333916",
"0.6429667"
] | 0.0 | -1 |
Creating a new user for lawfirm POST /lawfirm_admins POST /lawfirm_admins.xml | def create
@employee = Employee.new(params[:employee])
@employee.company_id=current_user.company_id
respond_to do |format|
if @employee.save_with_user(params)
flash[:notice] = "#{t(:text_new_user)} " "#{t(:flash_was_successful)} " "#{t(:text_created)}"
format.html { redirect_to lawfirm_admins_url}
format.xml { render :xml => @lawfirm_admin, :status => :created, :location => @lawfirm_admin }
else
format.html { render :action => "new" }
format.xml { render :xml => @lawfirm_admin.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admin_user = User.new(admin_user_params)\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Default attributes: role = TA or role = STUDENT\n # params[:user] is a hash of values passed to the controller\n # by the HTML form with the help of ActiveView::Helper::\n @user = Admin.new(user_params)\n # Return unless the save is successful; save inherted from\n # active records--creates a new record if the model is new, otherwise\n # updates the existing record\n if @user.save\n flash[:success] = I18n.t('admins.create.success',\n user_name: @user.user_name)\n\n redirect_to action: 'index'\n else\n flash[:error] = I18n.t('admins.create.error')\n render 'new'\n end\n end",
"def create\n @user = User.new(admin_user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to admin_users_path, notice: 'El administrador ha sido creado con éxito.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @admin_user = Admin::User.new(admin_user_params)\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n result = @api_user = ApiUser.create(api_user_params)\n if result.persisted?\n # aanmaken gelukt, schrijft logentry en toon beheeraccounts overzicht\n log self.class.name, LogEntry::INFORMATIONAL, \"App gebruiker #{@api_user.username}, klant-id #{@api_user.customer_id}, is aangemaakt door #{current_admin_user.username}\"\n redirect_to admin_api_users_path\n else\n # aanmaken niet gelukt, toon formulier opniew (met foutmelding)\n render :new\n end\n end",
"def create\n @user = User.new(params[:user], :as => :admin)\n respond_to do |format|\n if @user.save\n flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages\n format.html { redirect_to admin_users_path, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages\n format.html { render :action => \"new\"}\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to admin_users_path, :notice => t('flash.admin.users.create')\n else\n render :action => \"new\"\n end\n end",
"def create\n @user = User.new(params[:admin_user])\n\n if @user.save\n redirect_to(@user, :notice => 'User was successfully created.')\n else\n render :action => \"new\"\n end\n end",
"def create\n @user = User.new(user_params)\n @user.admin = false\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to(root_url, notice: 'User was successfully created.') }\n format.xml { render xml: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_admin_user = Admin::AdminUser.new(params[:admin_admin_user])\n\n respond_to do |format|\n if @admin_admin_user.save\n format.html { redirect_to @admin_admin_user, notice: 'Admin user was successfully created.' }\n format.json { render json: @admin_admin_user, status: :created, location: @admin_admin_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if current_user.admin?\n @user.admin = params[:user][:admin].to_i rescue 0\n end\n\n respond_to do |format|\n if @user.save\n flash[:notice] = 'Account created'\n format.html { redirect_to user_url(@user) }\n format.xml { head :created, location: user_url(@user) }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @user.errors.to_xml }\n end\n end\n end",
"def create\n @user = User.new(user_name: params[:user_name], email: params[:email], password: params[:password])\n @user.admin = User.all.empty?\n respond_to do |format|\n if @user.save\n format.html { redirect_to root_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_user = AdminUser.new(params[:admin_user])\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: 'Admin user was successfully created.' }\n format.json { render json: @admin_user, status: :created, location: @admin_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n update_protected_attrs_from_params(:user, :login, :active) do |p|\n @user = User.new(p)\n end\n\n respond_to do |format|\n if @user.save\n flash[:notice] = 'User was successfully created.'\n format.html { redirect_to([:admin, @user]) }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n params[\"user\"].each {|key, value| value.strip!}\n params[\"user\"][\"email\"].downcase!\n \n new_user = User.new(params[\"user\"])\n new_user.password = params[\"user\"][\"password_hash\"]\n\n if new_user.save\n flash[:message] = \"New administrator successfully created:<br>\n <ul><li><strong>Name:</strong> #{new_user.user_name}</li>\n <li><strong>Email:</strong> #{new_user.email}</li>\n <li><strong>ID:</strong> #{new_user.id}</li>\n <li><strong>Privilege Level:</strong> #{new_user.privilege}</li></ul>\"\n redirect_to \"/admin/update_library\"\n \n else \n @error_messages = new_user.errors.to_a\n @user = User.new\n @users_array = User.select(\"email\")\n render \"new\"\n end\n end",
"def create\n @admin_user = AdminUser.new(params[:admin_user])\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to action: :index, notice: 'Admin user was successfully created.' }\n format.json { render json: @admin_user, status: :created, location: @admin_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n @user.save\n respond_with( [ :admin, @user] )\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to admin_users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @adminuser = Adminuser.new(params[:adminuser])\n\n respond_to do |format|\n if @adminuser.save\n format.html { redirect_to @adminuser, notice: 'Adminuser was successfully created.' }\n format.json { render json: @adminuser, status: :created, location: @adminuser }\n else\n format.html { render action: \"new\" }\n format.json { render json: @adminuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createAdmin\n success = false\n @user = User.new(params[:user])\n if (!session[:user] || session[:user].admin == 0)\n flash[:notice] = \"Only administrators can create administrators\"\n else\n success = @user.save\n end\n\n respond_to do |format|\n if success\n flash[:notice] = \"Administratyor #{@user.name} was successfully created.\"\n format.html { redirect_to(:action => 'index') }\n else\n format.html { render :action => \"newAdmin\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n UserMailer.registration_confirmation(@user).deliver\n sign_in @user\n @administrator = Administrator.new\n @administrator.user_id = @user.id\n @administrator.admin = false\n @administrator.status = true\n @administrator.save\n flash[:success] = 'Welcome to BestBay!'\n redirect_to root_path\n else\n render 'new'\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to [:admin, @user], notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to new_admin_user_path, alert: @user.errors.full_messages().join(', ') }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(body)\n post 'create_user', body\n end",
"def create\n #@user.skip_confirmation!\n respond_to do |format|\n if @user.save\n #@user.confirm\n format.html { redirect_to([:admin, @user], notice: 'User was successfully created.') }\n format.xml { render xml: @user, status: :created, location: @user }\n website.add_log(user: current_user, action: \"Created user: #{@user.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n \n @user.admin = :user if @user.admin.blank?\n\n respond_to do |format|\n if @user.save\n flash[:notice] = \"新規登録完了\"\n format.html { redirect_to \"/login\" }\n format.json { redirect_to \"/login\", status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.admin = params[:user].delete(:admin)\n respond_to do |format|\n if (@user.confirmed_at = Time.now) && @user.save\n flash[:notice] = 'User was successfully created.'\n format.html { redirect_to admin_users_path(:anchor => dom_id(@user)) }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :new }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end",
"def create\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n @user.is_admin = params[:user][:is_admin] if admin?\n @user.is_staff = params[:user][:is_staff]\n @user.save\n flash[:notice] = t('users.created')\n format.html { redirect_to(admin_user_url(@user)) }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(\n email: params[:user][:email],\n password: params[:user][:password],\n password_confirmation: params[:user][:password_confirmation],\n admin: params[:user][:admin],\n master: params[:user][:master]\n )\n\n e = -> (ex) {\n flash[:alert] = ex.message\n session[:form] = {\n email: params[:user][:email],\n admin: params[:user][:admin],\n master: params[:user][:master],\n }\n redirect_to(action: :new)\n }\n\n begin\n @user.save!\n rescue => ex\n e.(ex) and return\n end\n\n begin\n #TODO カレントユーザーでZabbixとコネクションを張れるようにする\n s = AppSetting.get\n z = Zabbix.new(s.zabbix_user, s.zabbix_pass)\n z.create_user(@user)\n rescue => ex\n @user.destroy\n e.(ex) and return\n end\n\n flash[:notice] = I18n.t('users.msg.created')\n redirect_to(action: :index) and return\n end",
"def newAdmin\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def create\n @user = ::User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to admincp_user(@user), notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to admin_url}\n format.json { render action: 'show', status: :created, location: @user }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n flash[:notice] = 'Firm was successfully created.'\n format.html { redirect_to(@user) }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n # Senha padrao = matricula\n @user.password = @user.matricula\n @user.password_confirmation = @user.matricula\n @user.admin = false\n\n # Usuario comum so pode criar usuarios em sua propria unidade\n unless current_user.admin?\n @user.unidade_id = current_user.unidade_id\n end\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'Usuário criado com sucesso.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user\n if current_user.manager? || current_user.admin?\n @user = User.new(user_params)\n @user.password = 'test@123'\n @user.password_confirmation = 'test@123'\n redirect_to @user if @user.save\n else\n flash[:notice] = NOT_AUTHORIZED\n redirect_to home_index_path\n end\n end",
"def create\n if !current_user || is_admin?\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to(:root, :notice => 'Registration successfull.') }\n #format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n #format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to :root\n end\n end",
"def create\n if current_user && current_user.admin? \n @user = User.new(params[:user])\n if @user.save\n flash[:notice] = 'User was successfully created.'\n redirect_to user_path(@user)\n else\n respond_with(@user.errors, :status => :unprocessable_entity) do |format|\n format.html { render :action => :new }\n end\n end\n else\n flash[:notice] = 'You do not have Admin rights to create a user'\n redirect_to :back\n end\n end",
"def create\n @user_admin = UserAdmin.new(user_admin_params)\n\n respond_to do |format|\n if @user_admin.save\n format.html { redirect_to @user_admin, notice: 'User admin was successfully created.' }\n format.json { render :show, status: :created, location: @user_admin }\n else\n format.html { render :new }\n format.json { render json: @user_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n \n # generate pw\n pw = random_pw\n @user.password = pw\n @user.password_confirmation = pw\n \n respond_to do |format|\n if @user.save\n \n if @user.admin?\n # Send mail that contains password\n UserMailer.notify_new_admin(@user, pw).deliver\n # Notify owner about new admin\n DebugMailer.send_email(@user.inspect, t('notification.new_admin_created')).deliver\n end\n \n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:id])\n user = @user.attributes\n user[\"role\"] = 2\n @user.update!(user)\n admin_params = Administrator.new.attributes\n admin_params[\"superadmin\"] = 0\n admin_params[\"user\"] = @user\n admin_params[\"geofence\"] = Geofence.first\n @administrator = Administrator.new(admin_params)\n respond_to do |format|\n if @administrator.save\n format.html { redirect_to administrators_path, notice: 'Administrator was successfully created.' }\n format.json { render :show, status: :created, location: @administrator }\n else\n format.html { render :new }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user\n \t@user = User.new(user_params)\n @user.username = @user.name.split.sum\n \[email protected]_id = current_user.facility_id\n \[email protected] = 'medinternational.dev'[email protected]_s + \"@gmail.com\"\n \[email protected] = \"english\"\n \[email protected] = \"password\"\n @user.role = Role.find_by_name(\"bmet_tech\")\n \trespond_to do |format|\n \t\tif @user.save\n \t\t\tformat.html { redirect_to settings_path, notice: 'User successfully created'}\n \t\t\tformat.json { redirect_to settings_path, notice: 'User successfully created'}\n \t\telse\n \t\t\tformat.html {redirect_to settings_path, notice: 'Failed to create user'}\n \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity}\n \t\tend\n \tend\n end",
"def create\n @user = Spree.user_class.new(user_params)\n\n @user.skip_confirmation!\n @user.spree_roles << Spree::Role.designer_role\n\n if @user.save\n set_roles\n\n flash.now[:success] = flash_message_for(@user, :successfully_created)\n redirect_to spree.edit_admin_user_path(@user)\n else\n render :new\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to [:admin, @user], notice: 'Action was successfully created.' }\n format.json { render json: @user, status: :created }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @users = User.new(user_params)\n if params[:approved]\n render json: { error: 'You must be logged in as administrator to approve user'} , status: 401\n else\n if @users.save\n # Tell the UserMailer to send a welcome email after save\n UserMailer.welcome_email(@users).deliver_now\n response = { message: 'User created successfully'}\n render json: response, status: :created \n else\n raise ExceptionHandler::RecordNotUnique\n end\n end\n end",
"def create\n @user = User.new(user_params)\n @user.is_administrator = false\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to login_url, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: login_url }\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_user(name, is_admin, building_id, notify_new_request= false, notify_new_listing=false)\n user_id = User.create(\n first_name: name,\n last_name: 'LNU',\n email: 'jack+' + name + '@jackmgill.com',\n password: 'foo',\n is_admin: is_admin,\n building_id: building_id,\n notify_new_request: notify_new_request,\n notify_new_listing: notify_new_listing\n ).id\n return user_id\nend",
"def create\n begin\n adminUser=AdminUser.create!(\n :pays => params[:pays],\n :nom => params[:nom],\n :prenom => params[:prenom],\n :date_naiss => params[:date_naiss],\n :profil => params[:profil],\n :etat => \"actif\",\n :email => params[:email],\n :telephone => params[:telephone],\n :password => params[:password]\n )\n\n result = {\n :success => true,\n :code => 200,\n :id => adminUser.id\n }\n rescue Exception => e \n result = {\n :success => false,\n :code => 500,\n :message => e.to_s\n }\n end\n respond_to do |format|\n format.html\n format.json { render :json => result.to_json } \n \n end\n end",
"def create\n @user = User.new(SiteConfig.default_user_attributes.merge( user_params || {} ) )\n # Наличие пароля не обязательно при создании, необходимо так же сделать кнопочки чтобы администратор мог инициировать смену пароля пользователем через email, sms\n\n unless @user.persisted?\n @user.creation_reason = :manager\n @user.build_account\n end\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to edit_admin_user_path(@user, :tab => params[:tab]), :notice => 'Пользователь был успешно создан.' }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def create\n @admin_user = Admin::User.new(admin_user_params)\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: \"用户<#{@admin_user.username}>创建成功!\" }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user\n\t \to = [('a'..'z'), ('1'..'9')].map { |i| i.to_a }.flatten\n\t \tstring = (0...9).map { o[rand(o.length)] }.join\n\t \t@user = User.create( username: params[:user][:username],password: string ,rol: params[:user][:rol], name: params[:user][:name], carrier: params[:user][:carrier], email: params[:user][:email], landline: params[:user][:landline], cell_phone: params[:user][:cell_phone], container: params[:user][:cell_phone], liquid_charge: params[:user][:liquid_charge], dry_charge: params[:user][:dry_charge] )\n\t \trespond_to do |format|\n\t \t\tif @user.save\n\t \t\t\tflash[:notice] = 'Se ha creado un nuevo usuario'\n\t \t\t\tformat.html { redirect_to users_path }\n\t \t\t\tformat.js {}\n\t \t\t\tformat.json { render :show, status: :created, location: @user }\n\t \t\telse\n\t \t\t\twarden.custom_failure!\n\t \t\t\tformat.html { render :new }\n\t \t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t \t\tend\n\t \tend\n\t end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n if @user == current_user\n if current_user.admin\n format.html { redirect_to users_url,\n notice: \"User #{@user.login_name} was successfully created.\" }\n end\n else\n format.html { redirect_to login_url,\n notice: \"User #{@user.login_name} was successfully created, please log in.\" }\n end\n format.json { render json: @user,\n status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.password = Password.create(@user.password)\n\n respond_to do |format|\n if !session[:user].isadmin? && params[:user].isadmin?\n flash[:error] = 'Only admins can create admins.'\n format.html { redirect_to @user }\n elsif @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { redirect_to action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Note this is different to the usual situation where anybody can create\n # an account. Here, only administrators can create accounts for others;\n # and doing so does not log them out.\n unless current_user.admin?\n flash[:error] = \"Users can only be created by administrators.\"\n redirect_to (request.env[\"HTTP_REFERER\"] || root_path) and return\n end\n \n @user = User.new(params[:user])\n success = @user && @user.save\n if success && @user.errors.empty?\n # Protects against session fixation attacks, causes request forgery\n # protection if visitor resubmits an earlier form using back\n # button. Uncomment if you understand the tradeoffs.\n # reset session\n redirect_to users_path\n flash[:notice] = \"The account #{ERB::Util.h @user.login} has been setup for #{ERB::Util.h @user.name}.\"\n else\n flash.now[:error] = \"We couldn't set up that account, sorry.\"\n render :action => 'new'\n end\n end",
"def create\n @useradmin = Useradmin.new(params[:useradmin])\n\n respond_to do |format|\n if @useradmin.save\n format.html { redirect_to @useradmin, notice: 'Useradmin was successfully created.' }\n format.json { render json: @useradmin, status: :created, location: @useradmin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @useradmin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\n if current_user.local_access?\n @user.uo_id = current_user.uo_id\n end\n\n respond_to do |format|\n @user.password_string = @user.password\n if verify_super_admin(@user) && @user.save\n format.html { redirect_to admin_users_path, notice: 'Usuário foi criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n if current_user.local_access?\n @uos = {current_user.uo.nome => current_user.uo.id}\n else\n @uos = Uo.order(\"nome ASC\").all.collect {|uo| [uo.nome, uo.id]}\n end\n @roles = Role.order(\"nome ASC\").all.collect { |role| [role.nome, role.id] }\n if !verify_super_admin(@user)\n flash.now[:error] = \"Apenas um usuário com papel de SuperAdmin pode criar outro usuário SuperAdmin\"\n end\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.admin = 'f'\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'Bienvenido' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(\n email: params[:user][:email],\n password: params[:user][:password],\n password_confirmation: params[:user][:password_confirmation],\n admin: params[:user][:admin],\n master: params[:user][:master],\n )\n\n e = lambda { |ex|\n flash[:alert] = ex.message\n session[:form] = {\n email: params[:user][:email],\n admin: params[:user][:admin],\n master: params[:user][:master],\n }\n redirect_to(action: :new)\n }\n\n begin\n @user.save!\n rescue StandardError => ex\n e.call(ex) and return\n end\n\n begin\n # TODO カレントユーザーでZabbixとコネクションを張れるようにする\n z_params = params[:user][:zabbix_servers]\n z_params.shift\n @user.zabbix_server_ids = z_params\n zab = ZabbixServer.find(z_params)\n zab.each do |s|\n z = Zabbix.new(s.fqdn, s.username, s.password)\n z.create_user(@user)\n end\n rescue StandardError => ex\n @user.destroy\n e.call(ex) and return\n end\n\n flash[:notice] = I18n.t('users.msg.created')\n redirect_to(action: :index) and return\n end",
"def create\n @user = User.new(user_params)\n @user.is_admin = true if User.count == 0\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to :root, notice: 'Thank you for creating your MindImp Account! Please check your email for more details.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user.admin\n @user = User.new(params[:user])\n @user.assign_attributes(params[:user], :without_protection => true)\n end\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n Mailer.deliver_registration_confirmation(@user)\n format.html { redirect_to( admin_users_path, :notice => 'User was successfully created.') }\n format.xml { render :xml => @user, :status => :created, :location => admin_users_path }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => admin_users_path.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_user = Admin::User.new(admin_user_params)\n \n if @admin_user.password.blank?\n secure_password = @admin_user.generate_password \n @admin_user.password = secure_password\n @admin_user.password_confirmation = secure_password\n end\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to admin_users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.html { render :new }\n format.json { render @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize Admin\n @admin = current_admin.own_users.new(admin_params)\n respond_to do |format|\n if @admin.save\n format.html { redirect_to admins_url, notice: 'Admin was successfully created.' }\n format.json { render :show, status: :created, location: @admin }\n else\n format.html { render :new }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n flash[:notice] = \"#{@user.full_name} invited successfully\"\n redirect_to admin_users_path\n else\n msg = []\n flash[:error] = @user.errors.full_messages.each{|e| msg << \"#{e}\" unless msg.include?(e)}\n render 'new'\n end\n end",
"def create\n logger.debug(\"AAA \" + params[:user][:password])\n\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n format.html { redirect_to(users_path, :notice => 'User was successfully created.') }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(register_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to admin_users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_user(username, password, full_name, email)\n representation = form_encoded({ \"user[name]\" => username,\n \"user[password]\" => password,\n \"user[full_name]\" => full_name,\n \"user[email]\" => email }) \n puts representation\n begin\n response = open(@service_root + '/users', :method => :post, \n :body => representation)\n puts \"User #{username} created at #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == \"409\" # Conflict\n puts \"Sorry, there's already a user called #{username}.\"\n else\n raise e\n end\n end\n end",
"def new_user_create\n @user = User.create_user(user_params, current_user.account_id) # New User\n begin\n @user.save!\n @users = User.get_all(current_user.account_id)\n flash[:success] = \"User was created successfully!\"\n rescue => e\n flash[:alert] = \"User creation failed!\"\n end \n end",
"def create\n @corporate_user, password = User.create_corp_user(corporate_user_params)\n respond_to do |format|\n if @corporate_user.save\n admin_email = User.where(id: @corporate_user.parent_id).first.email\n InviteUser.corporate_user_confirmation(@corporate_user,admin_email,password).deliver\n format.html { redirect_to corporate_users_path, notice: \"#{APP_MSG['corporate_user']['create']}\" }\n format.json { render :show, status: :created, location: corporate_user_path }\n else\n format.html { render :new }\n format.json { render json: @corporate_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tredirect_to :controller => 'welcome', :action => 'index'\n\t\t\tflash[:info] = 'Wait until admin enables your account'\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n\t\tparams.permit!\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to(users_url,\n :notice => \"User #{@user.name} was successfully created.\") }\n format.xml { render :xml => @user,\n :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def create(attributes)\n put(\"admin/user\", body: attributes)\n response\n end",
"def create\n\t\t@user = User.new(user_new_params)\n\t\trespond_to do |format|\n\t\t\tif @user.save_dependent params[:setting_id], user_params[:admin]\n\t\t\t\tformat.html { redirect_to users_manage_users_url, notice: 'User was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @user }\n\t\t\telse\n\t\t\t\tformat.html { redirect_to users_manage_users_url, warn: 'An error prevented user creation.' }\n\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @usernew = Usernew.new(params[:usernew])\n usernew.admin = false;\n respond_to do |format|\n if @usernew.save\n format.html { redirect_to @usernew, notice: 'User was successfully created.' }\n format.json { render json: @usernew, status: :created, location: @usernew }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usernew.errors, status: :unprocessable_entity }\n end\n end\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 new_admin_user\n user = User.take\n\n NotifierMailer.new_admin_user user.organizations.first.id, user.email\n end",
"def create_patron_user\n\t branch = Nimbos::Branch.where(patron_id: self.id).first\n\t role = Nimbos::Role.find_or_create_by(name: \"admin\")\n\t user = self.users.new\n\t user.name = self.contact_name\n\t user.surname = self.contact_surname\n\t user.email = self.email\n\t user.language = self.language\n\t user.locale = self.locale\n\t user.mail_encoding = self.mail_encoding\n\t user.time_zone = self.time_zone\n\t user.branch_id = branch.id\n\t user.password = self.password\n\t user.password_confirmation = self.password\n\t user.firstuser = true\n\t user.role_ids = [role.id]\n\t user.save!\n\t #user.add_role :admin\n\t end",
"def create\n\t\t@user = User.new(user_params)\n\n\t\[email protected] = nil unless admin?\n\n\t\trespond_to do |format|\n\t\t\tif @user.save\n\t\t\t\tformat.html { redirect_to log_in_path, notice: \"User was successfully created.\" }\n\t\t\t\tformat.json { render action: \"show\", status: :created, location: @user }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @user.attributes = params[:user]\n @user.role_ids = params[:user][:role_ids] if params[:user]\n @user = User.new(params[:user])\n respond_to do |format|\n if @user.save\n flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages\n format.html { redirect_to admin_users_path, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages\n format.html { render :action => \"new\"}\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n log_in @user\n @user.update_attributes(admin: true) if params[:user][:admin] == '1'\n flash[:success] = \"Sign up success!\"\n redirect_to @user\n else\n render 'new'\n end\n\n end",
"def create\n @user = User.new(user_to_be_created)\n\n error = @user.validate_user?\n\n if error.nil? && @user.save\n handler_notice('Usuário cadastrado com sucesso!', login_path)\n else\n handler_notice_error(error, new_user_path)\n end\n end",
"def create\n @user = User.new(user_params)\n user.skip_confirmation!\n\n respond_to do |format|\n if user.save && update_roles\n format.html { redirect_to admin_user_path(user), notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: user }\n else\n format.html { render :new }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(email, pass, login = nil, id = nil, cui = nil)\n send_req({\n act: :user_create,\n cloudflare_email: email,\n cloudflare_pass: pass,\n cloudflare_username: login,\n unique_id: id,\n clobber_unique_id: cui\n })\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n auto_login(@user)\n format.html { redirect_to notify_path, notice: \"Your account has been created. However, you must verify your account with an administrator to complete activation. You may do so by connecting to <span class='highlight'>petyard.net</span> in Minecraft.<br /><br /><a href='#{user_path(@user)}'>Continue to your profile</a>\" }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createUser(admin=false) \n usr = User.new \n usr.Admin = admin \n @Users.add usr \n end",
"def create\n @user = User.new()\n authorize @user\n\n respond_to do |format|\n if @user.update(permitted_attributes(@user))\n format.html { redirect_to admin_users_path, notice: 'Usuário foi CRIADO com sucesso.' }\n format.json { render :show, status: :created, location: [:admin, @user] }\n else\n format.html { render :new }\n format.json { render json: [:admin, @user].errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n @roles = [Role.find_by_name(params[:user]['role'])]\n @user.person.attributes = (params[:person])\n @user.roles = @roles\n respond_to do |format|\n if @user.save\n flash[:notice] = 'User was successfully created.'\n format.html { redirect_to admin_users_url }\n format.xml { render :xml => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_user\n @user = User.new(params[:user])\n @user.save\n \n redirect_to :action => :users\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 create\n login = user_params[:login]\n first = user_params[:first_name]\n last = user_params[:last_name]\n key = user_params[:key]\n\n raise \"not authorized\" unless is_admin\n\n if login.blank? || first.blank? || last.blank? || key.blank?\n raise \"all fields are required\"\n elsif LDAP::User.create(login, first, last, key)\n render_success(\"user #{login} created.\")\n else\n render_failure(\"failed to create user\")\n end\n rescue => e\n render_failure(e.message)\n end",
"def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end",
"def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end",
"def create\n @user = User.new(user_params)\n if User.count == 0\n @user.role = 'admin'\n else\n @user.role = \"user\"\n end\n\n respond_to do |format|\n if @user.save\n UserMailer.welcome_email(@user).deliver\n format.html { redirect_to :users, notice: 'User was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_admin_path(@user), notice: new_user_message }\n format.json { render :show, status: :created }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin = Admin.new(params[:admin])\n mass_assign_protected_attributes\n @admin.created_by = current_admin.email\n respond_to do |format|\n if @admin.save\n format.html { redirect_to(admin_admins_url, :notice => 'Admin was successfully created.') }\n format.xml { render :xml => @admin, :status => :created, :location => @admin }\n else\n build_permissions\n format.html { render :action => \"new\" }\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_user\n\t\t@resource = User.new\n\t\t@resource_name = 'user'\n\tend",
"def create\n @user = User.new(user_params)\n\n return render action: 'new' unless @user.save\n\n client = Dwolla.new\n\n first_name = @user.first_name\n last_name = @user.last_name\n email = @user.email\n type = \"personal\"\n address = @user.address\n city = @user.city\n state = @user.state\n postal_code = @user.postal_code\n date_of_birth = @user.date_of_birth\n last_four_of_ssn = @user.last_four_of_ssn\n\n client.create_customer(first_name, last_name, email, type, address, city, state, postal_code, date_of_birth, last_four_of_ssn)\n redirect_to user_path(@user), notice: 'Created user'\n end",
"def create\n params[:user][:admin] = 0\n @user = User.new(params[:user])\n @user.meals_remaining = 0\n if @user.save\n UserMailer.welcome_email(@user).deliver\n respond_to do |format|\n format.html { render :controller => \"users\", :action => \"show\" }\n format.js { render :action => \"user_create_success\" }\n end\n else\n @errors = @user.errors.full_messages\n @errors.uniq!\n flash[:error_header] = \"Something went wrong.\"\n flash[:error_subheader] = \"The email address or password you entered was incorrect.\"\n respond_to do |format|\n format.html { redirect_to account_url }\n format.js { render :action => \"user_create_failure\" }\n end\n end\n end",
"def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end",
"def do_create\n begin\n raise 'Passwords do not match' unless request[:password] == request[:checkpass]\n user = Models::User.new\n user.username = request[:username]\n user.email = request[:email]\n user.name = request[:name]\n user.password = request[:password]\n user.save\n flash[:success] = 'New user has been added.'\n redirect('/admin')\n rescue Object => boom\n flash[:error] = \"Error encountered while saving: #{boom}\"\n redirect_referer\n end\n end",
"def create\n @firm = Firm.new(params[:firm])\n\[email protected] = @firm.subdomain.downcase\n respond_to do |format|\n if @firm.save\n flash[:notice] = 'Firm was successfully created! Now create the first user.'\n format.html { redirect_to(register_user_path(@firm)) }\n \n else\n \tflash[:error] = 'Firm could not be created'\n format.html { render \"public/register\", :layout => \"registration\"}\n format.xml { render :xml => @firm.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.71763515",
"0.71489644",
"0.71198547",
"0.7116344",
"0.7099577",
"0.7099321",
"0.7081512",
"0.70758986",
"0.7055621",
"0.7053395",
"0.70374274",
"0.70353943",
"0.69993305",
"0.6981225",
"0.6969473",
"0.69678545",
"0.69398874",
"0.69397867",
"0.6918515",
"0.691331",
"0.6912357",
"0.6894449",
"0.6885493",
"0.6882014",
"0.6879063",
"0.68647265",
"0.68579704",
"0.6847353",
"0.68265027",
"0.68223345",
"0.6814703",
"0.68053985",
"0.6799377",
"0.679881",
"0.6795851",
"0.6794609",
"0.6782989",
"0.6782206",
"0.6780833",
"0.6774545",
"0.6766624",
"0.67558134",
"0.6753659",
"0.67496824",
"0.6744431",
"0.67270315",
"0.6722499",
"0.6715841",
"0.6711186",
"0.67108154",
"0.67049146",
"0.67016107",
"0.6696037",
"0.66915303",
"0.66880256",
"0.6680777",
"0.66643876",
"0.66602886",
"0.6659929",
"0.66538167",
"0.66480154",
"0.66443473",
"0.66442007",
"0.6639318",
"0.663718",
"0.6635282",
"0.6635148",
"0.66336375",
"0.6626703",
"0.6615212",
"0.6614931",
"0.6614668",
"0.6614072",
"0.661077",
"0.6602759",
"0.6593584",
"0.6593138",
"0.65865123",
"0.65759385",
"0.6572929",
"0.6568272",
"0.65672517",
"0.6557844",
"0.6555127",
"0.6552948",
"0.65522265",
"0.65479857",
"0.6543199",
"0.6542302",
"0.6541806",
"0.65406275",
"0.65312415",
"0.65309453",
"0.6522187",
"0.6509236",
"0.6508622",
"0.6499017",
"0.6498153",
"0.6494029",
"0.64920115"
] | 0.68165004 | 30 |
PUT /lawfirm_admins/1 PUT /lawfirm_admins/1.xml This function is used to update the lawfirm admin details | def update
@lawfirm_admin = User.find(params[:id])
respond_to do |format|
if @lawfirm_admin.update_attributes(params[:lawfirm_admin])
flash[:notice] = "#{t(:text_lawfirmadmin)} " "#{t(:flash_was_successful)} " "#{t(:text_updated)}"
format.html { redirect_to(@lawfirm_admin) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @lawfirm_admin.errors, :status => :unprocessable_entity }
authorize!(:update,current_user) unless current_user.role?:lawfirm_admin
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @admin = Admin.find(params[:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to([:admin, @admin], :notice => 'Admin was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:admin][:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to(:controller => \"admins\", :action => \"index\") }\n format.xml { head :ok }\n else \n format.html { render :action => \"index\" }\n flash.now[:alert] = \"Problem saving admin\"\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n mass_assign_protected_attributes\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to(admin_admins_url, :notice => 'Admin was successfully updated.') }\n format.xml { head :ok }\n else\n build_permissions\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n pam = admin_params\n if @admin.blank?\n @admin = Admin.new(pam)\n # @admin.skip_reconfirmation!\n else\n @admin.attributes = pam\n end\n\n unless current_admin&.editable?(@admin)\n @admin.errors.add(:role, :invalid_permission)\n raise ApiUserErrors::AdminUpdateError, @admin.error_messages\n end\n\n isOk = @admin.save\n\n raise ApiUserErrors::AdminUpdateError, @admin.error_messages unless isOk\n\n respond_to do |format|\n format.html {redirect_to backend_admins_url, notice: '保存成功!' }\n format.json { render :update }\n end\n end",
"def update\n @admin_admin_user = Admin::AdminUser.find(params[:id])\n\n respond_to do |format|\n if @admin_admin_user.update_attributes(params[:admin_admin_user])\n format.html { redirect_to @admin_admin_user, notice: 'Admin user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n\n if @admin.update(admin_params)\n head :no_content\n else\n render json: @admin.errors, status: :unprocessable_entity\n end\n end",
"def update\n authorize @admin\n respond_to do |format|\n attr = admin_params\n if attr[:password].blank? && attr[:password_confirmation].blank?\n attr = attr.except(:password, :password_confirmation)\n end\n if @admin.update(attr)\n format.html { redirect_to admins_url, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @adminnistrador = Adminnistrador.find(params[:id])\n\n respond_to do |format|\n if @adminnistrador.update_attributes(params[:adminnistrador])\n flash[:notice] = 'Adminnistrador was successfully updated.'\n format.html { redirect_to(@adminnistrador) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adminnistrador.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_admin.update(admin_admin_params)\n format.html { redirect_to @admin_admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_admin }\n else\n format.html { render :edit }\n format.json { render json: @admin_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @admin.update(admin_params)\n render :show, status: :ok, location: @admin\n else\n render json: @admin.errors, status: :unprocessable_entity\n end\n end",
"def update\n @administrator = Administrator.find(params[:id])\n\n respond_to do |format|\n if @administrator.update_attributes(params[:administrator])\n flash[:notice] = 'Administrator was successfully updated.'\n format.html { redirect_to(@administrator) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @administrator.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n if @admin.update_attributes(params[:admin])\n flash[:notice] = 'Admin was successfully updated.'\n redirect_to :action => 'show', :id => @admin\n else\n render :action => 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @admin_admin.update(admin_admin_params)\n format.html { redirect_to '/admin/admins', notice: 'Admin was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(update_admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize Admin\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n base = 'Failed to save the system administrator. '\n respond_to do |format|\n if @admin.update_attributes(sys_admin_params)\n flash[:success] = 'The system administrator was successfully updated.'\n format.html { redirect_to edit_admins_system administrator_url(@admin) }\n format.json { render json: { rows: [@admin.marshall], status: 200, total: 1 } }\n else\n flash[:error] = 'An error occured while updating the system administrator.'\n format.html { render action: \"edit\", alert: base + @admin.errors.full_messages.to_sentence + \".\" }\n format.json { render json: { errors: @admin.errors, status: :unprocessable_entity } }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to admins_url, notice: 'Admin was successfully updated.' }\n # format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @useradmin = Useradmin.find(params[:id])\n\n respond_to do |format|\n if @useradmin.update_attributes(params[:useradmin])\n format.html { redirect_to @useradmin, notice: 'Useradmin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @useradmin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_user = AdminUser.find(params[:id])\n\n respond_to do |format|\n if @admin_user.update_attributes(params[:admin_user])\n format.html { redirect_to @admin_user, notice: 'Admin user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @adminuser = Adminuser.find(params[:id])\n\n respond_to do |format|\n if @adminuser.update_attributes(params[:adminuser])\n format.html { redirect_to @adminuser, notice: 'Adminuser was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @adminuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_user = AdminUser.find(params[:id])\n\n respond_to do |format|\n if @admin_user.update_attributes(params[:admin_user])\n format.html { redirect_to controller: :admin_users, action: :index, :id => @admin_user.id, notice: 'Admin user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update!(**args)\n @admins = args[:admins] if args.key?(:admins)\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to @admin, notice: 'Admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n flash[:success]='更改已被成功保存!'\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_account = AdminAccount.find(params[:id])\n\n respond_to do |format|\n if @admin_account.update_attributes(params[:admin_account])\n format.html { redirect_to(@admin_account, :notice => 'Admin account was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @admin_account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n\n @admin.email=params[:admin][:email]\n @admin.password=params[:admin][:password]\n @admin.receive_emails=params[:admin][:receive_emails]\n respond_to do |format|\n if @admin.save\n format.html { redirect_to(admins_url, :notice => 'Admin was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update_admin\n update admin_client\n end",
"def update\n @administrator = Administrator.find(params[:id])\n\n if @administrator.update_attributes(params[:administrator])\n flash[:notice] = 'Administrator was successfully updated.'\n redirect_to admin_administrators_path\n else\n render :action => \"edit\"\n end\n end",
"def update\n authorize @admin\n\n respond_to do |format|\n if @admin.update(admin_params)\n flash[:success] = \"Admin #{@admin.email} was successfully updated.\"\n format.html { redirect_to admins_url,\n notice: \"Admin #{@admin.email} was successfully updated.\" }\n format.json { render json: {role: admin_params[:role]} }\n else\n format.html { render action: 'index' }\n format.json { render json: @admin.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def update\n @administrador = Administrador.find(params[:id])\n\n respond_to do |format|\n if @administrador.update_attributes(params[:administrador])\n format.html { redirect_to \"/dados_admin\", notice: 'Seus dados foram atualizados com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @administrador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin = Admin.find(params[:id])\n if @admin.update(admin_params)\n redirect_to(admin_path(@admin))\n else\n render('edit')\n end\n end",
"def update\n\t\tif !administrator_signed_in? || current_administrator.id != 1\n\t\t\tredirect_to root_path\n\t\t\treturn\n\t\tend\n\n\t\t@admin_administrator = Admin::Administrator.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @admin_administrator.update_attributes(administrator_params)\n\t\t\t\tformat.html { redirect_to admin_administrators_url }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @data.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @admin_administrator.update(admin_administrator_params)\n format.html { redirect_to @admin_administrator, notice: t('crud.updated_successfully!', name: Admin::Administrator.model_name.human) }\n format.json { render action: 'show', status: :ok, location: @admin_administrator }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @adminstrator.update(adminstrator_params)\n format.html { redirect_to adminstrators_url, notice: 'Administrator #{adminstrator.name} was successfully updated.' }\n format.json { render :show, status: :ok, location: @adminstrator }\n else\n format.html { render :edit }\n format.json { render json: @adminstrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_admin_params\n params.require(:admin).permit(:name, :user_name, :password, :password_confirmation, :phone_number, :email, :confirm_token, :email_confirmed, :institution_id, :admin_level)\n end",
"def update\n respond_to do |format|\n begin\n @admin_obj.update!(admin_params)\n flash[:success] = 'Admin was successfully updated.'\n format.html { redirect_to admin_admin_url(@admin_obj) }\n format.json { render :show, status: :ok, location: @admin_obj }\n rescue Exception => e \n flash[:danger] = \"Error: #{e.message}\"\n format.html { render :edit }\n end\n end\n end",
"def update\n @admin_staff = Admin::Staff.find(params[:id])\n\n respond_to do |format|\n if @admin_staff.update_attributes(params[:admin_staff])\n format.html { redirect_to @admin_staff, notice: 'Staff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_staff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @administrateur = Administrateur.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @administrateur.update_attributes(params[:administrateur])\r\n format.html { redirect_to @administrateur, notice: 'Administrateur was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @administrateur.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @administrativo = Administrativo.find(params[:id])\n\n respond_to do |format|\n if @administrativo.update_attributes(params[:administrativo])\n format.html { redirect_to(@administrativo, :notice => 'Administrativo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @administrativo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user.update(admin_params)\n format.html { redirect_to admin_users_path, notice: \"Administrador (#{@user.name}), foi alterado com sucesso!\" }\n format.json { render :show, status: :ok, location: [:admin, @user] }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @admin_system_admin\n respond_to do |format|\n if @admin_system_admin.update(admin_system_admin_params)\n format.html { redirect_to @admin_system_admin, notice: 'System admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_system_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Admin.find(params[:id])\n if @resource.update(required_admin_params)\n flash[:notice] = t('messages.flash.notice.common.updated')\n redirect_to edit_admin_path(@resource)\n else\n flash[:alert] = I18n.t('messages.flash.alert.admin.not_updated')\n render :edit, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @administration = Administration.find(params[:id])\n\n respond_to do |format|\n if @administration.update_attributes(params[:administration])\n format.html { redirect_to(@administration, :notice => 'Administration was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @administration.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_admin.update(user_admin_params)\n format.html { redirect_to @user_admin, notice: 'User admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_admin }\n else\n format.html { render :edit }\n format.json { render json: @user_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_n_admin.update(admin_n_admin_params)\n format.html { redirect_to @admin_n_admin, notice: 'N admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_n_admin }\n else\n format.html { render :edit }\n format.json { render json: @admin_n_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_super_admin_info\n @admin=current_admin\n if @admin\n old_password=admin_params[:password]\n @admin=Admin.authenticate(@admin.username, old_password)\n if @admin\n @admin.privilages=\"empty\"\n mobile=String(admin_params[:mobile]).strip.to_i\n admin_params[:mobile]=mobile\n @admin.update_attributes(admin_params)\n if @admin.valid?\n flash[:success]=\"Updated succesfuly \"\n redirect_to admin_index_path\n else\n @admin_=current_admin\n render 'update_super_admin'\n end\n else\n flash.now[:error]=\"Invalid password\"\n @admin=current_admin\n @admin_=current_admin\n render 'update_super_admin'\n end\n else\n redirect_to admin_index_path\n end\n end",
"def update\n respond_to do |format|\n if @administrador.update(administrador_params)\n format.html { redirect_to @administrador, notice: 'Administrador was successfully updated.' }\n format.json { render :show, status: :ok, location: @administrador }\n else\n format.html { render :edit }\n format.json { render json: @administrador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # permite apos editar, salvar sem a necessidade de alterar senha\n passwd = params[:admin][:password]\n passwd_confirmation = params[:admin][:password_confirmation]\n\n if passwd.blank? && passwd_confirmation.blank?\n params[:admin].delete(:password)\n params[:admin].delete(:password_confirmation)\n end\n ###\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to admin_index_path, notice: I18n.t('messages.updated') }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @adminuser.update(adminuser_params)\n format.html { redirect_to @adminuser, notice: 'Adminuser was successfully updated.' }\n format.json { render :show, status: :ok, location: @adminuser }\n else\n format.html { render :edit }\n format.json { render json: @adminuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_role = Role.find(params[:id])\n\n respond_to do |format|\n if @admin_role.update_attributes(params[:admin_role])\n format.html { redirect_to @admin_role, notice: 'Role was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_role.errors, status: :unprocessable_entity }\n end\n end\n end",
"def admin_update\n @user = User.find_by_id(params[:user_id])\n if @user.update(email: params[:user][:email], display_name: params[:user][:display_name], admin: params[:user][:admin])\n if params[:user][:admin] == \"1\"\n add_user_to_admin_role(@user)\n else\n delete_user_from_admin_role(@user)\n end\n flash.keep[:notice] = 'The \"' + params[:user][:email] + '\" account was successfully updated.'\n redirect_to '/users'\n else\n render :admin_edit\n end\n end",
"def set_admin\n @admins = Admin.find(params[:id])\n end",
"def update\n @readonly_administrator = ReadonlyAdministrator.find(params[:id])\n if @readonly_administrator.update_attributes(params[:readonly_administrator])\n head :no_content\n else\n respond_with @readonly_administrator, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @admin_attribute.update(admin_attribute_params)\n format.html { redirect_to admin_attributes_path, notice: 'Attribute was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_attribute }\n else\n format.html { render :edit }\n format.json { render json: @admin_attribute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #authenticate admin\n @employee = Employee.find(params[:id])\n\n if @employee.update_attributes(update_params)\n flash[:success] = \"successful update of employee\"\n redirect_to admin_employee_path(@employee)\n else\n flash.now[:danger] = \"employee update failed\"\n render \"edit\"\n end\n end",
"def update\n @dbadmin = Dbadmin.find(params[:id])\n\n respond_to do |format|\n if @dbadmin.update_attributes(params[:dbadmin])\n format.html { redirect_to @dbadmin, notice: 'Dbadmin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dbadmin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n # use attributes instead of update_attributes because the latter will not update the protected\n # admin attribute. Since we are in the admin portal, this level of security is not needed. But we\n # still need to manually set the admin property if needed\n @user.attributes = params[:user]\n @user.admin = params[:user][:admin]\n\n if @user.save\n redirect_to(admin_user_path(@user), :notice => 'User was successfully updated.')\n else\n render :action => \"edit\"\n end\n end",
"def update\n @appellation = Appellation.find(params[:id])\n\n respond_to do |format|\n if @appellation.update_attributes(params[:admin_appellation])\n format.html { redirect_to(admin_appellation_path(@appellation), :notice => 'Appellation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appellation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to management_path(@admin), notice: 'Management was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @management.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n\t\trespond_to do |format|\n\t\t if @admin_user.update(admin_user_params)\n\t\t format.html { redirect_to edit_admin_admin_user_path(@admin_user), notice: 'Dados alterados com sucesso' }\n\t\t format.json { render :show, status: :ok, location: @admin_user }\n\t\t else\n\t\t format.html { render :edit }\n\t\t format.json { render json: @admin_user.errors, status: :unprocessable_entity }\n\t\t end\n\t\tend\n\tend",
"def update\n @team_admin = TeamAdmin.find(params[:id])\n\n respond_to do |format|\n if @team_admin.update_attributes(params[:team_admin])\n format.html { redirect_to @team_admin, notice: 'Team admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_admin\n @admin_admin = Admin.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @administrator.update(administrator_params)\n format.html { redirect_to %i[admin settings root], notice: t('.success') }\n format.json { render :show, status: :ok, location: @administrator }\n else\n format.html { render :edit }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @area_of_law = AreaOfLaw.find(params[:id])\n\n respond_to do |format|\n if @area_of_law.update_attributes(params[:area_of_law])\n purge_all_pages\n format.html { redirect_to admin_areas_of_law_path, notice: 'Area of law was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { \n flash[:error] = 'Could not update the Area of Law'\n render action: \"edit\" \n }\n format.json { render json: @area_of_law.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin\n # authorize Admin\n @admin = Admin.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @admin_staff.update(admin_staff_params)\n format.html { redirect_to @admin_staff, notice: 'Staff was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_staff }\n else\n format.html { render :edit }\n format.json { render json: @admin_staff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @all_users = User.all\n if @company.check_for_atleast_one_admin(params[:company]['company_admins_attributes'].collect{|i| i[1]}.flatten)\n respond_to do |format|\n if @company.update_attributes(company_params)\n format.html { redirect_to @company, flash: {:success => 'Company was successfully updated.'} }\n format.json { render :show, status: :ok, location: @company }\n else\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { render :edit }\n format.json { render json: @company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def admin!\n metadata['admin'] = true\n save\n end",
"def update\n @admin_agency = Admin::Agency.find(params[:id])\n\n respond_to do |format|\n if @admin_agency.update_attributes(params[:admin_agency])\n format.html { redirect_to @admin_agency, notice: 'Agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @administrator_local.update(administrator_local_params)\n format.html { redirect_to @administrator_local, notice: 'Administrator local was successfully updated.' }\n format.json { render :show, status: :ok, location: @administrator_local }\n else\n format.html { render :edit }\n format.json { render json: @administrator_local.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n passwd = params[:admin][:password]\n passwd_confirmation = params[:admin][:password_confirmation]\n\n if passwd.blank? && passwd_confirmation.blank?\n params[:admin].delete(:password)\n params[:admin].delete(:password_confirmation)\n end\n\n respond_to do |format|\n if @admin.update(admin_params)\n format.html { redirect_to admin_admins_path, notice: \"Administrador (#{@admin.name}), foi alterado com sucesso!\" }\n format.json { render :show, status: :ok, location: [:admin, @admin] }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin\n\n @admin = Admin.find(params[:id])\n\n end",
"def update\n @user.update(user_params)\n respond_with( [ :admin, @user] )\n end",
"def update\n respond_to do |format|\n if @administrator.update(administrator_params)\n format.html { redirect_to [:admin, :account], notice: t('.success') }\n format.json { render :show, status: :ok, location: @administrator }\n else\n format.html { render :show }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_whitelist = Admin::Whitelist.find(params[:id])\n\n respond_to do |format|\n if @admin_whitelist.update_attributes(params[:admin_whitelist])\n format.html { redirect_to @admin_whitelist, notice: 'Whitelist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_whitelist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_admin\n @delete_admin_obj.status = GlobalConstant::Admin.deleted_status\n @delete_admin_obj.last_otp_at = nil\n @delete_admin_obj.admin_secret_id = nil\n @delete_admin_obj.password = nil\n @delete_admin_obj.save!\n end",
"def update\n respond_to do |format|\n if @administrator.update(administrator_params)\n format.html { redirect_to @administrator, notice: 'Administrator was successfully updated.' }\n format.json { render :show, status: :ok, location: @administrator }\n else\n format.html { render :edit }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin.update(admin_params)\n format.html do \n sign_in @admin.user\n redirect_to @admin, notice: 'Admin was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @admin }\n else\n format.html { render :edit }\n format.json { render json: @admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_admin\n @admin_admin = Admin.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @admin_jewelry.update(admin_jewelry_params)\n format.html { redirect_to @admin_jewelry, notice: 'Jewelry was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_jewelry }\n else\n format.html { render :edit }\n format.json { render json: @admin_jewelry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.admin = params[:user].delete(:admin)\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n else\n format.html { render :edit }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @useradmin = Useradmin.find(params[:id])\n #\n respond_to do |format|\n if @useradmin.update_attributes(params[:useradmin])\n format.html { redirect_to @useradmin, notice: 'Useradmin was successfully updated.' }\n format.js\n else\n format.html { render action: \"edit\" }\n format.js { render action: \"edit\" }\n end\n end\n end",
"def b_admin\n @user = User.find(params[:id])\n @user.admin = true\n @user.save\n render json: { message: 'User is now an admin you can test the houses endpoint now.' }\n end",
"def admin_update\n @user = User.get(params[:id])\n if @user.update(params[:user])\n flash[:success] = \"User updated\"\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @employee_detail.update(employee_detail_params)\n @user = User.find_by_email(@employee_detail.user.email)\n \n @user.update_attributes(admin: params[:employee_detail][:admin])\n\n format.html { redirect_to @employee_detail, notice: 'Employee detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_detail }\n else\n format.html { render :edit }\n format.json { render json: @employee_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_admin\n @admin_admin = Admin::Admin.find(params[:id])\n end",
"def update\n @vendor = Vendor.find(params[:id])\n\n respond_to do |format|\n if @vendor.update_attributes(params[:vendor])\n format.html { redirect_to([:admin,@vendor] ,:notice => 'Vendor was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vendor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n params = administrator_params\n geofence = Geofence.find(params[:geofence])\n params[:geofence] = geofence\n\n respond_to do |format|\n if @administrator.update(params)\n\n format.html { redirect_to administrators_path, notice: 'Administrator was successfully updated.' }\n format.json { render :show, status: :ok, location: @administrator }\n else\n format.html { render :edit }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @administration = Administration.find(params[:id])\n\n respond_to do |format|\n if @administration.update_attributes(params[:administration])\n format.html { redirect_to @administration, notice: 'Administration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @administration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @administration = Administration.find(params[:id])\n\n respond_to do |format|\n if @administration.update_attributes(params[:administration])\n format.html { redirect_to @administration, notice: 'Administration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @administration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin\n\n @admin = Admin.find(params[:id])\n end"
] | [
"0.70015043",
"0.6937324",
"0.68194336",
"0.6771369",
"0.6688973",
"0.6649208",
"0.6625246",
"0.661637",
"0.65906847",
"0.65853345",
"0.6581446",
"0.65613234",
"0.65500945",
"0.6543245",
"0.65211725",
"0.6518823",
"0.6518823",
"0.65128094",
"0.6503596",
"0.6498323",
"0.64921886",
"0.6478022",
"0.6465917",
"0.6424954",
"0.6422395",
"0.6414231",
"0.6414231",
"0.6414231",
"0.6414231",
"0.6414231",
"0.6414231",
"0.6395079",
"0.63459915",
"0.634402",
"0.6332496",
"0.63282573",
"0.62887484",
"0.62859553",
"0.62558424",
"0.6249011",
"0.624811",
"0.6238127",
"0.6236132",
"0.62168896",
"0.6203148",
"0.61932415",
"0.6192986",
"0.61841273",
"0.6182246",
"0.61780226",
"0.6176146",
"0.6166",
"0.616378",
"0.6153199",
"0.61481565",
"0.614348",
"0.6119237",
"0.6112795",
"0.6097694",
"0.60854167",
"0.60841364",
"0.6083026",
"0.6082212",
"0.6078862",
"0.6078668",
"0.60703325",
"0.60643244",
"0.60572064",
"0.60466886",
"0.60360163",
"0.6035125",
"0.6034154",
"0.6031792",
"0.6030177",
"0.60276437",
"0.60225874",
"0.6011478",
"0.60094833",
"0.60054654",
"0.6005182",
"0.59982646",
"0.59966975",
"0.59954906",
"0.59851134",
"0.59843606",
"0.59767413",
"0.59765476",
"0.5975445",
"0.5962624",
"0.5959599",
"0.5943343",
"0.5939629",
"0.5930329",
"0.59282374",
"0.5925842",
"0.59244233",
"0.59228647",
"0.5922594",
"0.5922594",
"0.5922485"
] | 0.74389315 | 0 |
DELETE /lawfirm_admins/1 DELETE /lawfirm_admins/1.xml This function is used to delete the lawfirm admin having provided id | def destroy
@lawfirm_admin = User.find(params[:id])
@lawfirm_employee=Employee.find(:first,:conditions=>["user_id=?",@lawfirm_admin.id])
@product_licence_detail=ProductLicenceDetail.find(:all,:conditions=>["user_id=?",params[:id]])
@subproduct=SubproductAssignment.find(:all,:conditions=>["user_id=? OR employee_user_id=?",params[:id],params[:id]])
respond_to do |format|
if @lawfirm_employee.destroy
for product_licence_detail in @product_licence_detail
product_licence_detail.product_licence.update_attributes(:status=>0)
product_licence_detail.destroy
end
@subproduct.each do |subproduct|
subproduct.destroy
end
@lawfirm_admin.destroy
flash[:notice] = "#{t(:text_new_user)} " "#{t(:flash_was_successful)} " "#{t(:text_deactivated)}"
format.html { redirect_to(:controller=>"lawfirm_admins",:action=>"index") }
format.xml { head :ok }
else
format.html { render :action => "index" }
authorize!(:destroy,current_user) unless current_user.role?:lawfirm_admin
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rem_admin oid\n self.admins.delete oid\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_admins_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_admins_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admins_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admins_url) }\n format.xml { head :ok }\n end\n end",
"def delete_admin(id)\n @m = Member.find_by_society_id_and_user_id(self.id, id)\n if @m == nil then return end\n \n if @m.admin \n @m.admin = false\n @m.save\n\t\t\tadd_post(id, \"Administrator status revoked\")\n end\n end",
"def delete\n @admin = Admin.find(params[:id])\n end",
"def destroy\n restrict 'allow only admins' or begin\n @admin = Admin.find_by_id(params[:id])\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n restrict 'allow only admins' or begin\n @admin = Admin.find_by_id(params[:id])\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n redirect_to(admin_index_path)\n end",
"def delete\n admin = Admin.where(id: params[:id]).first\n admin.deleted_at = Time.now\n admin.deleted_time = Time.now.to_i\n admin.deleted_user = 1\n if admin.save\n flash[:notice] = 'ユーザー情報を削除しました'\n render json: { success: true }\n else\n flash[:error] = 'ユーザー情報の削除に失敗しました'\n render json: { success: false }\n end\n end",
"def destroy\n @administrator = Administrator.find(params[:id])\n @administrator.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrators_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @administrator = Administrator.find(params[:id])\n @administrator.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrators_url) }\n format.xml { head :ok }\n end\n end",
"def delete_admin\n service_response = AdminManagement::AdminUser::DeleteAdmin.new(params).perform\n render_api_response(service_response)\n end",
"def destroy\n @admin_account = AdminAccount.find(params[:id])\n begin\n flash[:notice] = \"Admin #{@admin_account.name} deleted\"\n @admin_account.destroy\n rescue Exception => e\n flash[:notice] = e.message\n end\n\n respond_to do |format|\n format.html { redirect_to(admin_accounts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @adminnistrador = Adminnistrador.find(params[:id])\n @adminnistrador.destroy\n\n respond_to do |format|\n format.html { redirect_to(adminnistradors_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n render json: {:ok => true}\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_sys_admins_url }\n format.json { render json: { status: 200 } }\n end\n end",
"def destroy\n @admin.destroy\n\n head :no_content\n end",
"def destroy\n @admin_admin_user = Admin::AdminUser.find(params[:id])\n @admin_admin_user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n get_master_context\n authenticate_muni_admin!\n @muni_admin = MuniAdmin.find(params[:id])\n\n if (current_muni_admin == @muni_admin)\n flash[:error] = \"You cannot delete yourself.\"\n @error = true\n return\n end\n\n authorize_muni_admin!(:delete, @muni_admin)\n\n if @muni_admin\n if !@muni_admin.deployments.empty?\n @redirect = destroy_confirm_master_muni_admin_path(@master, @muni_admin)\n else\n flash[:notice] = \"Administrator #{@muni_admin.email} has been removed.\"\n @muni_admin.destroy\n end\n end\n end",
"def destroy\n UserService.deleteUser(params[:id],current_admin[:id])\n redirect_to users_path\n end",
"def destroy\n @readonly_administrator = ReadonlyAdministrator.find(params[:id])\n @readonly_administrator.destroy\n head :no_content\n end",
"def destroy\n @dbadmin = Dbadmin.find(params[:id])\n @dbadmin.destroy\n\n respond_to do |format|\n format.html { redirect_to dbadmins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @administrateur = Administrateur.find(params[:id])\r\n @administrateur.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to administrateurs_url }\r\n format.json { head :ok }\r\n end\r\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administrativo = Administrativo.find(params[:id])\n @administrativo.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrativos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to backend_admins_url, notice: '删除成功!' }\n format.json { render :destroy }\n end\n end",
"def destroy\n @useradmin = Useradmin.find(params[:id])\n @useradmin.destroy\n\n respond_to do |format|\n format.html { redirect_to useradmins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administrador = Administrador.find(params[:id])\n @administrador.destroy\n\n respond_to do |format|\n format.html { redirect_to administradors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tif !administrator_signed_in? || current_administrator.id != 1\n\t\t\tredirect_to root_path\n\t\t\treturn\n\t\tend\n\n\t\t@admin_administrator = Admin::Administrator.find(params[:id])\n\t\t@admin_administrator.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to admin_administrators_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @administration = Administration.find(params[:id])\n @administration.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrations_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @admin_user = AdminUser.find(params[:id])\n @admin_user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :ok }\n end\n end",
"def delete_user(id)\n elektron_identity.delete(\"users/#{id}\")\n end",
"def destroy\n session[:admin_id] = nil\n redirect_to '/adminlogin'\n end",
"def destroy\n @adminuser = Adminuser.find(params[:id])\n @adminuser.destroy\n\n respond_to do |format|\n format.html { redirect_to adminusers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_user = AdminUser.find(params[:id])\n @admin_user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @admins.id != current_admin.id \n @admins.destroy\n respond_to do |format|\n format.html { redirect_to admins_path, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @law = Law.find(params[:id])\n @law.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_laws_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_administrator.destroy\n respond_to do |format|\n format.html { redirect_to admin_administrators_url }\n format.json { head :no_content }\n end\n end",
"def delete_admin\n service_response = ManagerManagement::Team::DeleteAdmin.new(params).perform\n return render_api_response(service_response)\n end",
"def delete_id(id)\n ids_in_doc = root.fetch(full_path, :single => true)\n raise TypeError, \"Expecting array\" unless ids_in_doc.kind_of? Array\n ids_in_doc.delete id\n root.save!\n ids.delete id\n save!\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @admin_admin.destroy\n respond_to do |format|\n format.html { redirect_to admin_admins_url, notice: 'Admin was successfully destroyed.' }\n end\n end",
"def destroy\n result = HTTParty.delete(\"http://jeapi.herokuapp.com/junior_enterprises/#{params[:id]}\",\n :headers => { 'token' => JEAPI_KEY } )\n\n if is_admin? \n redirect_to \"/admin/junior_enterprises\", notice: \"Deletado com sucesso\"\n else\n redirect_to \"/log_out\", notice: \"Deletado com sucesso\"\n end\n end",
"def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end",
"def del(id, which=:groups)\n resp = self.class.delete(\"/#{which}/#{id}\")\n check_errors resp\n end",
"def destroy\n empty_searched_admin_id\n empty_user_id\n session[:admin_id] = nil\n sign_out_admin\n redirect_to admin_login_path\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n \n end\n end",
"def destroy\n @retaileradmin = Retaileradmin.find(params[:id])\n @retaileradmin.destroy\n flash[:notice] = 'Retailer deleted successfully.'\n @retaileradmins = Retaileradmin.all\n render :action => 'index'\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @guarantor = Guarantor.find(params[:id])\n @guarantor.destroy\n applicant=Applicant.find(@guarantor.applicant_id)\n respond_to do |format|\n format.html { redirect_to(applicant, :notice => 'Guarantor deleted.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_staff = Admin::Staff.find(params[:id])\n @admin_staff.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_staffs_url }\n format.json { head :no_content }\n end\n end",
"def admin_delete_app\n\n # Get Current App\n app = MailfunnelsUtil.get_app\n\n # If the User is not an admin redirect to error page\n if !app.is_admin or app.is_admin === 0\n response = {\n success: false\n }\n\n render json: response and return\n end\n\n # Get App to be deleted\n del_app = App.find(params[:app_id])\n\n unless del_app\n response = {\n success: false\n }\n\n render json: response and return\n end\n\n\n # Delete App\n del_app.destroy\n\n\n response = {\n success: true\n }\n\n render json: response and return\n\n\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end",
"def destroy\n @admin_admin.destroy\n respond_to do |format|\n format.html { redirect_to admin_admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n supprimer = AdministrateurService.instance.supprimerAdmin(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end",
"def destroy\n @user = User.find(params[:id])\n @user.delete!\n\n redirect_to admin_users_path\n end",
"def destroy\n @user = User.find(params[:id])\n @user.delete!\n\n redirect_to admin_users_path\n end",
"def destroy\n @staffd = Staffd.find(params[:id])\n @staffd.destroy\n\n respond_to do |format|\n format.html { redirect_to(staffds_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n else\n redirect_to new_admin_session_path and return\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 authorize @admin\n\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admin_admins_url, notice: \"Administrador (#{@admin.name}), foi excluido com sucesso!\" }\n format.json { head :no_content }\n end\n end",
"def DeleteRole id\n \n APICall(path: \"custom_roles/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n authorize(@administrator, :update?)\n\n @administrator.destroy\n\n redirect_to admin_administrators_path, notice: t('administrator.deleted')\n end",
"def delete!(id:)\n client.delete_list(id: id)\n end",
"def destroy\n\t\t@adminfilm = Film.find(params[:id])\n \t\[email protected]\n \t\tredirect_to '/adminCool'\n\tend",
"def delete(id)\n FileUtils.rm_r File.join(DOTDIR, id)\n end",
"def destroy\n restrict('allow only admins') or begin\n @user = User.find_by_id(params[:id])\n if @user.destroy\n respond_to do |format|\n format.html { redirect_to manage_users_url }\n format.xml { head :ok }\n end\n else\n \n end\n end\n end",
"def destroy\n @admin_bid = Bid.find(params[:id])\n @admin_bid.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_bids_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n @conn.execute(*@builder.delete(id))\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n respond_to do |format|\n format.html { redirect_to(admin_users_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n if administrador?\n @emergencium = Emergencium.find(params[:id])\n @emergencium.destroy\n respond_to do |format|\n format.html { redirect_to(emergencia_url) }\n format.xml { head :ok }\n end\n else\n @entidade = Entidade.where(\" user_id = ?\", current_user.id)\n @emergencium = Emergencium.find(params[:id], :conditions => [\" entidade_id = ?\", @entidade[0].id]) rescue nil\n unless @emergencium.nil?\n @emergencium.destroy\n respond_to do |format|\n format.html { redirect_to(emergencia_url) }\n format.xml { head :ok }\n end\n else\n render :action => \"index\"\n end\n end\n end",
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete(id)\n path(id).delete\n clean(id) if clean?\n end",
"def deleteDataId(data_of, id)\n url_data = stringGetUrlPath(data_of)\n url_request = \"#{url_data}/#{id}\"\n puts \">>>>>> delete #{data_of} with id:#{id}\"\n deleteData(url_request)\n end",
"def destroy\n if current_user.is_an_admin?\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n else\n flash[:error] = \"That action is not permitted.\"\n redirect_back_or_default('/')\n end \n end",
"def destroy\n @admin_bait = Bait.find(params[:id])\n @admin_bait.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_baits_url }\n format.json { head :ok }\n end\n end",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def destroy\n if current_user.has_role?(:admin)\n \n @asunto = Asunto.find(params[:id])\n @asunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(asuntos_url) }\n format.xml { head :ok }\n end\n else\n redirect_to(root_path,:notice => 'No se tienen permisos.')\n end\n end",
"def destroy\n @admin_coleccion = Admin::Coleccion.find(params[:id])\n @admin_coleccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_coleccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admin_index_path, notice: I18n.t('messages.destroyed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admins_url, notice: 'Admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def delete\n\n @cook = User.find(params[:id])\n @cook.remove_role :waiter\n \n @cookaccounts = AdminCookAccount.where(id_cook: @cook.id)\n @cookaccounts.delete_all\n\n redirect_to admin_cooks_url\n\n end",
"def remove_admin(admin, user_id)\n return get_db_as_hash().execute(\"UPDATE user SET admin = 0 WHERE user_id = ?\", user_id).first \n end",
"def destroy\n staff = Staff.find(params[:id])\n staff.destroy\n end"
] | [
"0.7001102",
"0.69888604",
"0.69888604",
"0.6978432",
"0.6978432",
"0.69739366",
"0.6951878",
"0.6825269",
"0.6825269",
"0.661862",
"0.66075414",
"0.6600806",
"0.6600806",
"0.66003877",
"0.6563595",
"0.65455747",
"0.64972305",
"0.64598364",
"0.6443755",
"0.6438352",
"0.6397254",
"0.63669443",
"0.63380736",
"0.63370985",
"0.6323666",
"0.6321163",
"0.62880605",
"0.62699705",
"0.6260865",
"0.6260129",
"0.6246864",
"0.62419933",
"0.6240509",
"0.62331903",
"0.6215247",
"0.6202971",
"0.6183657",
"0.6172797",
"0.6172153",
"0.6165525",
"0.6161566",
"0.61568075",
"0.61501914",
"0.61459327",
"0.61457556",
"0.6145637",
"0.61147565",
"0.61127824",
"0.6110208",
"0.60844487",
"0.60818964",
"0.60566294",
"0.6046576",
"0.60462546",
"0.60329473",
"0.6025743",
"0.6015156",
"0.59996504",
"0.59975374",
"0.5995767",
"0.5995172",
"0.5991131",
"0.59842134",
"0.5974367",
"0.5974367",
"0.5966495",
"0.59626347",
"0.59569323",
"0.59528",
"0.59501016",
"0.5949193",
"0.59490144",
"0.5938166",
"0.59365886",
"0.59328747",
"0.5930947",
"0.5927534",
"0.5919627",
"0.59142905",
"0.59123",
"0.5911016",
"0.59098786",
"0.59086716",
"0.59050083",
"0.5903636",
"0.58935046",
"0.5893236",
"0.5887733",
"0.58849984",
"0.5883979",
"0.5883796",
"0.5882502",
"0.5882502",
"0.5882502",
"0.5882502",
"0.5882502",
"0.5882502",
"0.58817667",
"0.5879845",
"0.5877122",
"0.58679885"
] | 0.0 | -1 |
This function is used to update the selected employee details | def update_employee
@user = User.find(params[:id])
@user.update_attributes(:first_name=>params[:lawfirm_admin][:first_name],:last_name=>params[:lawfirm_admin][:last_name])
@employees=Employee.scoped_by_user_id_and_company_id(@user.id,current_user.company_id).first
respond_to do |format|
if @employees.update_attributes(:birthdate => params[:lawfirm_admin][:employee][:birthdate],
:security_question => params[:lawfirm_admin][:employee][:security_question],
:security_answer => params[:lawfirm_admin][:employee][:security_answer],
:billing_rate => params[:lawfirm_admin][:employee][:billing_rate]
)
flash[:notice] = "#{t(:text_user)} " "#{t(:flash_was_successful)} " "#{t(:text_updated)}"
format.html { redirect_to:controller=>"lawfirm_admins",:action=>"index" }
format.xml { head :ok }
else
format.html { render :action => "edit" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_employee\n @employee = current_user.employees.find(params[:id])\n end",
"def set_employee\n @employee = current_user.employees.find(params[:id])\n end",
"def set_employee_detail\n @employee_detail = EmployeeDetail.find(params[:id])\n end",
"def set_employeedetail\n @employeedetail = Employeedetail.find(params[:id])\n end",
"def update\n @employee.attributes = user_params\n @employee.build_option if @employee.option.nil?\n @employee.option.attributes = option_params[:option_attributes]\n \n respond_to do |format|\n if @employee.save\n format.html { redirect_to employee_path(@employee), notice: 'Employee was successfully changed.' }\n else\n flash[:errors] = @employee.errors.full_messages\n format.all { render \"edit\" }\n end\n end\n end",
"def set_employee\n #@employee = Employee.find(params[:id])\n @employee = Employee.find(params[:id] || current_user.employee_id)\n end",
"def update\n\n @company = Company.find(1)\n @employee[:company_id] = 1\n\n @categorias =Categorium.all \n @afps = Afp.all\n @employee.fecha_nacimiento = Date.today\n @employee.fecha_ingreso = Date.today\n @employee.fecha_cese = Date.today\n @locations =Location.all\n @divisions =Division.all \n @ocupacions = Ocupacion.all \n @ccostos = Ccosto.all\n\n @dptos = Dpto.all \n @provins = Provin.all \n @distritos = Distrito.all \n\n\n \n \n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employee\n @employee = Employee.find(params[:employee_id]) if params[:employee_id].present?\n end",
"def update\n @employee = Employee.find(params[:id])\n\n respond_to do |format|\n if @employee.update_attributes(params[:employee])\n Cutofftotalsalary.find_by_employee_name(@employee.name).update_attributes(cutoff_id: Cutoff.last.id, employee_name: @employee.name, sss: @employee.sss, philhealth: @employee.philhealth, pagibig: @employee.pagibig, withholding_tax: @employee.withholding_tax)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_staff(edit_employee)\n employee = Employee.find(edit_employee.id)\n employee.attributes = edit_employee.attributes\n employee.save!\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def employee_updates\n if params[\"employee_id\"] == \"new\"\n @employee = Employee.new\n @employee.florist_id = session[\"found_florist_id\"]\n @employee.view_pref = \"all\"\n else\n @employee = Employee.where(id: params[\"employee_id\"]).first\n end\n @employee.name = params[\"name\"]\n @employee.email = params[\"email\"]\n @employee.w_phone = params[\"phone_w\"]\n @employee.c_phone = params[\"phone_c\"]\n @employee.username = params[\"username\"]\n @employee.password = params[\"password\"] \n @employee.password_confirmation = params[\"password_confirmation\"]\n # This step is done to keep the POC from inadvertantly changing their rights... the POC should always have \"All Admin Rights\"\n if @employee.primary_poc == \"yes\"\n @employee.admin_rights = \"All Admin Rights\"\n @employee.status = \"Active\"\n else\n @employee.status = params[\"status\"]\n # if they are changing the \"status\" to Inactive, then go ahead and change the employees admin privielegs to \"none\".\n if params[\"status\"] == \"Inactive\"\n @employee.admin_rights = \"None\"\n else\n # if they have room for more active users (per their plan) or they are past the number but the change is to change someone's privileges to \"None, then let them set the userprivielegs. Otherwise default to \"None\". This will allow them to show up in the list but not access the system.\n if Florist.find(session[\"found_florist_id\"]).employees.where(status: \"Active\").where(\"admin_rights not like 'None'\").size < Florist.find(session[\"found_florist_id\"]).plan.number_of_users || (Florist.find(session[\"found_florist_id\"]).employees.where(status: \"Active\").where(\"admin_rights not like 'None'\").size >= Florist.find(session[\"found_florist_id\"]).plan.number_of_users && params[\"admin_rights\"] == \"None\")\n @employee.admin_rights = params[\"admin_rights\"]\n else\n @employee.admin_rights = \"None\"\n end\n end\n \n end\n if @employee.save\n if EMPLOYEES_VIEW_MUST_HAVE.include?(Employee.where(id: session[\"found_user_id\"]).first.admin_rights)\n redirect_to \"/employees\" and return\n else\n redirect_to home_path and return\n end\n else\n @ADMIN_RIGHTS = ADMIN_RIGHTS\n @EMPLOYEES_VIEW_MUST_HAVE = EMPLOYEES_VIEW_MUST_HAVE \n render(:employee_edit) and return\n end\n end",
"def set_employee\n @employee = Employee.find_by_id(params[:id])\n end",
"def set_employee\n if params[:id] != nil\n @employee = Employee.find(params[:id])\n end\n end",
"def update\n @company = Company.find(params[:company_id])\n @employee = @company.employees.find(params[:id]) \n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to company_employees_url(@company), notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n end",
"def set_employee\n @employee = Employee.employee_by_id(params[:id])\n end",
"def update\n @employee = current_owner.employees.find(params[:id])\n puts \"#{params}\"\n respond_to do |format|\n if @employee.update_attributes(params[:employee])\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee_detail.update(employee_detail_params)\n @user = User.find_by_email(@employee_detail.user.email)\n \n @user.update_attributes(admin: params[:employee_detail][:admin])\n\n format.html { redirect_to @employee_detail, notice: 'Employee detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_detail }\n else\n format.html { render :edit }\n format.json { render json: @employee_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employee\n @employee = Employee.find(params[:id])\n #@categories = EmployeeCategory.find(:all)\n end",
"def edit\n @employee = Employee.find(params[:id])\n @employee_contact = @employee.employee_contact.blank? ? EmployeeContact.new : @employee.employee_contact\n @employee_ec_contact = @employee.employee_ec_contact.blank? ? EmployeeEcContact.new : @employee.employee_ec_contact\n @employee_job = @employee.employee_job.blank? ? EmployeeJob.new : @employee.employee_job\n @employee_salary = @employee.employee_salary.blank? ? EmployeeSalary.new : @employee.employee_salary\n @employee_qualification = @employee.employee_qualification.blank? ? EmployeeQualification.new : @employee.employee_qualification\n @employee_membership = @employee.employee_membership.blank? ? EmployeeMembership.new : @employee.employee_membership\n @employee_spouse = @employee.employee_spouse.blank? ? EmployeeSpouse.new : @employee.employee_spouse\n @form_id = 'edit-form'\n @users = User.order(:username).all\n @supervisors = Employee.all\n @designations = Designation.order(:title).all\n @employment_statuses = EmploymentStatus.order(:name).all\n @job_categories = JobCategory.order(:name).all\n @departments = Department.order(:name).all\n \n respond_to do |fmt|\n fmt.html { render :partial => 'form' }\n fmt.json { render :json => @employee }\n end\n end",
"def update\n if isAdmin\n @part_time_employee = PartTimeEmployee.find(params[:id])\n @employee = @part_time_employee.employee\n\n @part_time_employee.assign_attributes(part_time_employee_params)\n @employee.assign_attributes(employee_params)\n respond_to do |format|\n @part_time_employee.valid?\n if @employee.valid? && @part_time_employee.valid?\n @employee.editor_id = current_user.id\n if @part_time_employee.part_time_employees_id != nil\n @realFulltime = PartTimeEmployee.find(@part_time_employee.part_time_employees_id)\n @realEmployee = Employee.find(@realFulltime.employee_id)\n\n @realFulltime.dateOfHire = @part_time_employee.dateOfHire\n @realFulltime.dateofTermination = @part_time_employee.dateofTermination\n @realFulltime.hourlyRate = @part_time_employee.hourlyRate\n @realFulltime.verified = 1\n\n @realEmployee.lastName = @employee.lastName\n @realEmployee.firstName = @employee.firstName\n @realEmployee.sin = @employee.sin\n @realEmployee.dateOfBirth = @employee.dateOfBirth\n @realEmployee.reasonForLeaving = @employee.reasonForLeaving\n @realEmployee.company_id = @employee.company_id\n @realEmployee.editor_id = current_user.id\n\n @realEmployee.save\n @realFulltime.save\n\n @part_time_employee.destroy\n @employee.destroy\n else\n @logs = Log.new\n @logs.employeeInfo = @employee.to_json\n @logs.additionalInfo = @part_time_employee.to_json\n @logs.CRUD = \"Update\"\n @logs.table = \"Full Time Employee\"\n @logs.who = current_user.name\n @logs.save\n @employee.save\n @part_time_employee.save\n end\n format.html { redirect_to @part_time_employee, notice: 'Full time employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @part_time_employee }\n else\n format.html { render :new }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n\n #format.html { render :new }\n format.json { render json: @part_time_employee.errors, status: :unprocessable_entity }\n end\n end\n else\n @employee = Employee.new(employee_params)\n\n @employee.editor_id = current_user.id\n @part_time_employee = PartTimeEmployee.new(part_time_employee_params)\n @oldFullTime = PartTimeEmployee.find(params[:id])\n @oldFullTimeId = @oldFullTime.part_time_employees_id\n if @oldFullTimeId == nil\n @oldFullTimeId = @oldFullTime.id\n end\n @part_time_employee.part_time_employees_id = @oldFullTimeId\n @part_time_employee.hourlyRate = PartTimeEmployee.find(params[:id]).hourlyRate\n\n respond_to do |format|\n @part_time_employee.valid?\n if @employee.valid? && @part_time_employee.valid?\n if @employee.save\n @part_time_employee.employee = Employee.find(@employee.id)\n format.json { render :show, status: :created, location: @employee }\n @logs = Log.new\n @logs.employeeInfo = @employee.to_json\n @logs.additionalInfo = @part_time_employee.to_json\n @logs.CRUD = \"Update\"\n @logs.table = \"Full Time Employee\"\n @logs.who = current_user.name\n @logs.save\n if @part_time_employee.save\n format.html { redirect_to @part_time_employee, notice: 'Full time employee was successfully created.' }\n format.json { render :show, status: :created, location: @part_time_employee }\n end\n end\n else\n format.html { render :new }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n\n #format.html { render :new }\n format.json { render json: @part_time_employee.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n\n @employees = Employee.all\n @employee = Employee.find(params[:id])\n\n @employee.update_attributes(employee_params)\n\n @nationalities = Nationality.all.order(:nationality_title)\n @marital_statuses = MaritalStatus.all\n\n=begin\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def update\n respond_to do |format|\n if @employeedetail.update(employeedetail_params)\n format.html { redirect_to @employeedetail, notice: \"Employeedetail was successfully updated.\" }\n format.json { render :show, status: :ok, location: @employeedetail }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @employeedetail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employe\n @employe = Employe.find(params[:id])\n end",
"def set_employee_benefit_selection\n @employee_benefit_selection = EmployeeBenefitSelection.find(params[:id])\n end",
"def set_admin_employee\n @admin_employee = Employee.find(params[:id])\n end",
"def set_employee\n if params[:id].nil? # if there is no user id in params, show current one\n @employee = current_user\n else\n @employee = User.find(params[:id])\n end\n end",
"def set_employee\n @employee = User.find(params[:id])\n end",
"def set_employee\n @employee = User.find(params[:id])\n end",
"def update\n @employee = Employee.find(params[:id])\n \n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employee_record\n @employee_record = EmployeeRecord.find(params[:id])\n end",
"def set_employed\n @employed = Employed.find(params[:id])\n end",
"def update\n @employee = Employee.find_by_id(params[:id])\n @employee.update_attributes({:id => params[:id],\n :name => params[:name],\n :title => params[:title],\n :status => params[:status],\n :employment_type => params[:employment_type],\n :attendance_type_id => params[:attendance_type_id],\n :hourly_rate => params[:hourly_rate],\n :location => params[:location],\n :capitalizable_group_id => params[:capitalizable_group_id],\n :leave_days => params[:leave_days],\n :commencement_date => params[:commencement_date],\n :termination_date => params[:termination_date]})\n if request.xhr?\n render :json => @employee\n end\n end",
"def update\n respond_to do |format|\n if @aga_employee.update(aga_employee_params)\n format.html { redirect_to @aga_employee, notice: 'Aga employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @aga_employee }\n else\n format.html { render :edit }\n format.json { render json: @aga_employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_employee_event\n @employee_event = EmployeeEvent.find(params[:id])\n end",
"def update\n authorize! :manage, Employee\n if responsibility_changes?\n new_employee = Employee.new_from_old(employee_params['responsibility'], @employee)\n @employee.destroy\n new_employee.save\n @employee = new_employee\n end\n\n respond_to do |format|\n if @employee.update(employee_attrs)\n format.html { redirect_to (@employee.try(:employee) || @employee), notice: t('action.update.succeed', entity: Employee.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @qualification=Qualification.find(:all)\n if request.get?\n session['employer_id']=params[:id];\n @emp = Emp.find(:first, :conditions=>[\"id=#{params[:id]}\"])\n end\n if request.post?\n\n @emp = Emp.find(:first, :conditions=>[\"id=#{session['employer_id']}\"])\n\n @emp.qualifications.destroy_all\n params[:people_ids] ||= []\n @emp.qualifications << Qualification.find(params[:people_ids])\n unless @emp.blank?\n if @emp.update_attributes(params[:emp])\n\n redirect_to :controller=>'emp', :action=>'index'\n end\n end\n end\n end",
"def set_employe\n if(params.has_key?(:id))\n @employe = Employe.find(params[:id])\n end\n end",
"def set_employee\n begin\n @company = Company.find(params[:company_id])\n @employee = Employee.find(params[:id]) unless params[:id].nil?\n rescue\n end\n end",
"def update\n respond_to do |format|\n if @assignment_employee.update(assignment_employee_params)\n format.html { redirect_to @assignment_employee, notice: 'Assignment employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @assignment_employee }\n else\n format.html { render :edit }\n format.json { render json: @assignment_employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #respond_to do |format|\n if @employee.update(employee_params)\n # format.html { redirect_to employee_path(@employee), notice: 'User was successfully updated.' }\n # format.json { render :show, status: :ok, location: @employee }\n redirect_to employee_path(@employee), notice: 'User was successfully updated.'\n else\n #format.html { render :edit }\n #format.json { render json: @employee.errors, status: :unprocessable_entity }\n redirect_to employee_path(@employee), notice: 'User was not updated.'\n\n end\n #end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def set_employee\n @employee = User.find(params[:id])\n end",
"def set_employee_personal\n @employee_personal = EmployeePersonal.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee.update(employee_params)\n format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee }\n else\n format.html { render :edit }\n format.json { render json: @employee.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7010766",
"0.69439214",
"0.6918158",
"0.6909097",
"0.68602324",
"0.68302035",
"0.6824709",
"0.6805335",
"0.6800489",
"0.6784139",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.66731614",
"0.66731524",
"0.6636146",
"0.66320354",
"0.6626513",
"0.6626513",
"0.6626513",
"0.6626513",
"0.6626513",
"0.6626513",
"0.6607997",
"0.66038173",
"0.65676415",
"0.6556599",
"0.65437114",
"0.65225583",
"0.65018386",
"0.6488093",
"0.64769685",
"0.64730304",
"0.6447354",
"0.6444998",
"0.6443004",
"0.6443004",
"0.6422022",
"0.6418112",
"0.6407986",
"0.6394996",
"0.6391347",
"0.6367398",
"0.6366244",
"0.636514",
"0.63553005",
"0.6348568",
"0.63412726",
"0.63382256",
"0.6334927",
"0.6331693",
"0.63249457",
"0.63244903",
"0.63244903",
"0.63244903",
"0.63244903",
"0.63244903",
"0.63244903"
] | 0.640846 | 81 |
This function is used to provide the list of deactivated users of the selected company | def deactivated_users
@users=User.find_with_deleted(:all,:conditions=>['company_id=? AND deleted_at IS NOT NULL',current_user.company_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_eligible_for_cc_list\n User.find(:all, :conditions => 'active=1',:order => 'last_name') -\n Role.find_by_name('HCL Manager').active_users -\n Role.find_by_name('Manager').active_users -\n Role.find_by_name('ECO Admin').active_users -\n Role.lcr_designers -\n self.users\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 acct_list usr, aFlg\n if usr.is_admin? && aFlg \n User.joins(:bank_accounts).include_list.where('bank_accounts.status = ?', 'active').uniq.reorder('first_name ASC') \n else\n BankAccount.inc_list.where(user_id: usr, status: 'active')\n end\n end",
"def index\n @users = User.where(company_id: current_user.company_id)\n end",
"def curator_list\n users.map(&:email)\n end",
"def index\n \n @company = Company.find(params[:company_id])\n if !can?(:manage, @company)\n raise CanCan::AccessDenied.new(\"Usted no puede administrar otra compañia\", :manage, @company)\n end\n \n if current_user.super_admin == true\n @users = User.where(:company_id => params[:company_id])\n else\n @users = User.where(:company_id => current_user.company_id)\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def active_users\n joins = DepartmentsUser.where(department_id: self, active: true)\n joins.map{|j| User.find(j.user_id)}\n end",
"def list\n @users = User.where(organization: false)\n\n render \"list\"\n end",
"def index\n @company_users = CompanyUser.all\n end",
"def unassigned_approvers_for_contract(contract)\n\n # todo: shouldnt have to use select here... theres a better way\n user_ids = contract.approver_users.map {|user| user.id}\n self.approver_users.select {|user| !user_ids.include?(user.id)}\n\n end",
"def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend",
"def managed_users\n @manager = scoped_company.users.find(params[:id])\n @managed_users = @manager.employees.not_disabled.includes(:teams)\n @list_truncate_limit = 30\n @datatable = UserDirectoryDatatable.new(view_context, @company)\n render layout: false\n end",
"def index\n @companions = current_user.companions.uniq\n end",
"def user_id_company_users(start, stop, users)\n removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n removed.\n where.not(user_id: @test).\n where('started_at < ?', stop).\n where('removed_at > ?', start)\n not_removed_users = UserCompany.\n where(user_id: users).\n not_deleted.\n not_removed.\n where.not(user_id: @test).\n where('started_at < ?', stop)\n (removed_users + not_removed_users).pluck(:user_id).uniq\nend",
"def complete_email_list\n #Email.select(:email).map{|email_record| email_record.email}\n User.all.map(&:email)\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def unapproved_credited_users_report\n \n User.find :all, \n :joins => %Q{\n INNER JOIN enrollments e ON e.participant_id = users.id \n INNER JOIN credit_assignments ca ON ca.enrollment_id = e.id\n INNER JOIN users co ON co.id = users.coordinator_id\n },\n :conditions => %Q{\n (ca.enrollment_finalized_on IS NOT NULL) AND\n (ca.user_id IS NOT NULL) AND\n (ca.district_finalize_approved_on IS NULL) AND\n (ca.credit_id = #{self.id}) AND\n (ca.parent_credit_assignment_id IS NULL)\n },\n :select => \"users.*, co.last_name AS coordinator_last_name, ca.credit_hours as credit_hours, ca.enrollment_finalized_on as enrollment_finalized_on\",\n :order => 'co.last_name ASC, users.last_name ASC',\n :group => 'users.id'\n \n end",
"def active_users\n return User.find_by_sql(\"SELECT users.* from users inner join roles_users ru on users.id=ru.user_id\n INNER JOIN roles r on ru.role_id=r.id\n WHERE users.activo=true AND r.name='#{self.name}'\")\n end",
"def index\n @company = Company.find(params[:company_id])\n @users = @company.users.where(\"role > 0\").paginate(:page => params[:page], :per_page => 15)\n end",
"def active_users\n PullRequest.active_users(current_year)\n end",
"def available_collaborators\n Set[*self.account.users].difference(self.users).to_a\n end",
"def index\n index! {\n @users = current_company.users\n }\n end",
"def inactive\n @inactive_users = User.where(isActive:false).paginate(:page => params[:inactive_users_page], :per_page => 10)\n end",
"def pending_users\n @pending_users = User.find(:all, :conditions => {:enabled => false, :activation_code => !nil})\n render :partial => 'pending_users'\n end",
"def cumulative_company_users(stop, company)\n users = UserCompany.\n where(company: company).\n where.not(user_id: @test).\n where('started_at < ?', stop).\n pluck(:user_id).\n uniq\nend",
"def company_recipients(company)\n company.current_members\n end",
"def list\n response = Tiptaplab.api.make_call(\"users/authorizations\")\n response.keys\n end",
"def invited_users\n user_state.select { |user, state| state == :invited }.keys\n end",
"def list_all_users\n\n end",
"def users\n # TODO use SQL\n results = self.approvers + self.observers + [self.requester]\n results.compact\n end",
"def users\n @users_by_href.values\n end",
"def users\n users = []\n if current_user.lead?\n users = object.users.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n elsif current_user.dev?\n vms_v = object.vms.select { |vm| vm.is_jenkins }\n users = vms_v.flat_map(&:user).uniq.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n else\n users <<= current_user\n end\n users.map { |u| u.id }\n end",
"def data_after_licence_unassignment_deactivation\n @company_id = @product_licence.company_id\n @totalusers = User.find_user_not_admin_not_client(@company_id)\n @activeusers = SubproductAssignment.scoped_by_company_id_and_employee_user_id(@company_id,nil).all(:select => 'user_id').collect{|sa| sa.user_id}.uniq.compact\n @employees = User.find_user_not_admin_not_client(@company_id)\n @productlicence = ProductLicence.scoped_by_company_id(@company_id)\n @activepermlicence = @productlicence.select {|o| o.licence_type == 0}.size\n @activetemplicence = @productlicence.select {|o| o.licence_type == 1}.size\n @usedpermlicence = @productlicence.select {|o| o.status == 1 && o.licence_type == 0}.size\n @usedtemplicence = @productlicence.select {|o| o.status == 1 && o.licence_type == 1}.size\n @remainlicence = @productlicence.select {|o| o.status == 0 && o.licence_type == 0}.size\n @remaintemplicence = @productlicence.select {|o| o.status == 0 && o.licence_type == 1}.size\n end",
"def people(convo)\n @recipients = convo.conversation.users.where('user_id <> ?', current_user)\n end",
"def enabled_account_names\n @enabled_account_names ||= @user.enabled_accounts.map(&:name)\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 deactivate\r\n items = Marketplace::Database.instance.items_by_user(self)\r\n items.each{ |item| item.deactivate }\r\n\r\n buy_orders = Marketplace::Database.instance.buy_orders_by_user(self)\r\n buy_orders.each{ |buy_order| buy_order.delete }\r\n\r\n Marketplace::Database.instance.add_deactivated_user(self)\r\n Marketplace::Database.instance.delete_user(self)\r\n Marketplace::Activity.create(Activity.USER_DEACTIVATE, self, \"#{self.name} has been deactivated\")\r\n end",
"def index\n @accounts = current_user.accounts.not_canceled\n end",
"def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end",
"def free_developer_accounts\n @attributes[:free_developer_accounts]\n end",
"def company_employee_list(company_id)\n roles = Role.where(company_id: company_id)\n workers = []\n User.where(id: roles.pluck(:user_id).uniq).each do |w|\n workers.push(\n id: w.id,\n email: w.email,\n roles: roles.where(user_id: w.id).select(:id, :name)\n )\n end\n workers\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 user_blocked\n @company = Company.find(params[:company_id])\n end",
"def get_users_on_flight_reject_requester\n\n\t\t# Then query saved journeys using the 'purchased_flight' identifier\n\t\t# for a list of the the other user id's who are on the flight\n\t\t# \n\t\t# Remove the queryer from the list and remove sensetive information\n\t\t# \n\t\t# Done. Return our model list\n\n\t\tjourney_id = params[\"journeyId\"]\n\t\tuser_id = params[\"userId\"]\n\n\t\tuser_list = User.on_journey(journey_id).reject{ |s| s.id == user_id }\n\n\t\trender json: user_list.as_json(only: [:id, :first_name, :last_name, :email]), status: 200\n\n\tend",
"def non_registered_ad_users\n all_active_directory_users.select{|user| user.non_registered?}\n end",
"def filtered_list\n if !(current_user.belongs_to_common_pool || current_user.belongs_to_back_office)\n @lawfirms = []\n @assigned_lawfirm_users.each do |lawyer|\n @lawfirms << lawyer.company if lawyer.company\n end\n @lawfirms.uniq!\n @logged_by_users = [[\"----livians----\",\"\"]]\n @logged_by_users += @cluster_livian_users.collect{|livian|[livian.full_name,livian.id]}\n @logged_by_users << [\"----lawyers----\",\"\"]\n @logged_by_users += @assigned_lawfirm_users.collect{|lowyer|[lowyer.full_name,lowyer.id]}\n @lawyers = (params[:search].present? && params[:search][:company_id].present?) ? get_company_lawyers(current_user,params[:search][:company_id],\"communications\") : @assigned_lawfirm_users\n else\n filtere_list_for_cp_or_bo\n end\n end",
"def index\n\t#display only activated users\n\t@users=User.where(activated: true).paginate(page: params[:page])\n\tend",
"def recipient_users\n User.active.where(id: recipient_user_ids).all\n end",
"def list_current_users *args\r\n puts \"not implemented yet\"\r\n end",
"def unowned_purchasable_companies(_entity)\n []\n end",
"def recipients\n Array.wrap(::User.find_by_user_key(@work.depositor))\n end",
"def getUserList\n @userList\n end",
"def users_list\r\n @users_list = User.order_by_asc('name').find(:all, :conditions => [\"group_id <> ?\", Group.get_guest.id])\r\n if params[:users]\r\n @users_list = User.get_user_list params\r\n end\r\n end",
"def index\n @companies = NewCompany.where(user: current_user)\n end",
"def users(except_for = nil)\n return @users if except_for.nil?\n @users - [except_for]\n end",
"def current_organization_users\n endpoint = '/api/org/users'\n @logger.debug(\"Getting organization users (GET #{endpoint})\") if @debug\n get(endpoint)\n end",
"def disable_expired_users()\n confluence_user_names.each do |name|\n next if name == \"conflusa\" \n ldap_person = find_in_ldap(name)\n \n if ldap_person.nil? || !eligible_for_confluence?(ldap_person)\n user = find_in_confluence(name)\n user.disable()\n @disabled_users << user \n end\n end\n end",
"def index\n @corporate_users = User.get_all_users(current_user).where.not(id: current_user.id)\n @corporate_users = @corporate_users.paginate(:page => params[:page],:per_page => 10).order('id DESC')\n end",
"def available_users\n\t\tfree_users = []\n\t\tfor user in User.all\n\t\t\tunless user.assignments.nil? || user.assignments.empty?\n\t\t\t\tfor assignment in user.assignments\n\t\t\t\t\tif assignment.active\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tfree_users << user\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tfree_users << user\n\t\t\tend\n\t\tend\n\t\treturn free_users\n\tend",
"def list_users_by_account(accountId, options={}) path = \"/api/v2/accounts/#{accountId}/users\"\n get(path, options, AvaTax::VERSION) end",
"def index\n if current_user.admin?\n @companies = Company.all.order(:name).page(params[:page]).per(10)\n else\n @companies = current_user.company\n end\n end",
"def off_org_users\n \n end",
"def index\n @user = current_user\n if @user.is_admin\n @users = User.all\n # @licenses = @user.license\n elsif @user.licensed\n @users = User.where(id: current_user.id)\n else\n redirect_to licenses_stub_path\n end\n end",
"def get_employees\n @employees = User.find_user_not_admin_not_client(get_company_id)\n end",
"def user_email_list\n @email_list = []\n\n EmailList.all.each do |email|\n if email.creator_id == current_user.id\n @email_list << email \n end\n end\n @email_list\n end",
"def list\n logger.debug \"Processing the list...\"\n @users = User.all.order('updated_at desc') #where(:status=>1)\n end",
"def eligible_collaborators\n ineligible_users = [@cookbook.collaborators, @cookbook.owner].flatten\n User.where('users.id NOT IN (?)', ineligible_users)\n end",
"def get_unissued_invites()\n User.find(session[:user_id]).unissued_invites\n end",
"def current_company\n if user_signed_in?\n @company = current_user.company\n @folders = @company.folders\n if current_user.admin?\n # excluding self\n @users = @company.users\n end\n end\n end",
"def pay_users\n ::User.where(\"upper(account_type) != 'FREE'\").count\n end",
"def index\r\n @deposits = []\r\n if current_user.admin?\r\n @deposits = Deposit.all\r\n else\r\n @deposits = Deposit.where(user_id: current_accounts.collect{|x| x.acct_number})\r\n end\r\n end",
"def approvable_users\n @approvable_users ||= (controllable_users + editable_request_applicants + controllable_users.map{|uu|uu.editable_request_applicants}).flatten.uniq\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 all_activated(user, email_alert_definition)\n true\n end",
"def viewable_users\n @viewable_users ||= (controllable_users + request_applicants + controllable_users.map{|uu|uu.request_applicants}).flatten.uniq\n end",
"def show \n available_users\n end",
"def index\n @supported_users = current_user.inverse_accountability_partners\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 @companies = current_user.companies\n @company_tab = 'active'\n end",
"def collaborators\n self.users.where(\"project_memberships.active = ?\", true)\n end",
"def index\n # current_user.companies.\n @incidents = Incident.all\n end",
"def returning_users\n []\n end",
"def choose\n @users = User.all.reject{ |user| user == current_user }\n end",
"def expired_users_with_email\n @expired_users_with_email ||= User.expired.where.not(email: nil)\n end",
"def deactivate\n verify_post_request\n require_parameters :login\n\n Api.users.deactivate(params[:login])\n\n hash={}\n respond_to do |format|\n format.json { render :json => jsonp(hash) }\n format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'users') }\n end\n end",
"def compras_compartilhadas\n\t\tlista = current_user.compras.order(\"created_at DESC\")\n\t\tresu = []\n\t\tlista.each do |compra|\n\t\t\tif(compra.users.first != current_user)\n\t\t\t\tresu << compra\n\t\t\tend\n\t\tend\n\t\tresu\n\tend",
"def account_list\n return [] unless company\n [company] + company.sibling_accounts\n end",
"def filtered_list\n if !(current_user.belongs_to_common_pool || current_user.belongs_to_back_office)\n @lawfirms = []\n company_ids = @assigned_lawfirm_users.map(&:company_id).uniq\n @lawfirms = Company.find(company_ids)\n @lawyers = (params[:search].present? && params[:search][:company_id].present?) ? get_company_lawyers(current_user,params[:search][:company_id],\"user_tasks\") : @assigned_lawfirm_users\n else\n filtered_list_for_cp_or_bo\n end\n end",
"def expired_users_with_accounts\n @expired_users_with_accounts ||= User.expired\n .joins(:accounts)\n .having('count(accounts) > 0')\n .group('users.id')\n end",
"def get_assigned_employee_users(assigned_lawfirm_users)\n lawfirm_employees = self.employees.uniq.delete_if{|e| e.blank? || e.user.blank?}\n lawfirm_users = lawfirm_employees.map(&:user) if lawfirm_employees\n lawfirm_users.to_a & assigned_lawfirm_users.to_a\n end",
"def all_users\n result = []\n api.search(accounts_dn, ::LDAP::LDAP_SCOPE_SUBTREE, accounts_filter) do |user|\n result << user.to_hash\n end\n result\n end",
"def index\n if current_company.users.include?(current_user)\n @employees = current_company.employees\n else\n redirect_to root_path\n end\n end",
"def visible_users\n User.where.not(type: :AutotestUser)\n end",
"def show\n @users = current_user.employer.recruiters.sort! {|a,b| a.first_name + a.last_name <=> b.first_name + b.last_name} # if current_user.has_role?(\"account_owner\")\n end",
"def collaborators\n collab_roles = accepted_roles.for_name(\"collaborator\")\n User.find_by_sql(\"SELECT * FROM users INNER JOIN roles_users ON roles_users.user_id = users.id WHERE roles_users.role_id IN (12)\")\n end",
"def members(show_staged=false)\n invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active\n [self.users, invites.to_a].flatten\n end",
"def get_accounts_by_user\n return User.find(params[:user_id]).accounts\n end",
"def invitable_users\n @title = \"Invitar usuario\"\n @invitable_users = GetInvitableUsers.call(@previa_group)\n end"
] | [
"0.6757092",
"0.6395814",
"0.6158302",
"0.6103465",
"0.60084844",
"0.5934883",
"0.5920795",
"0.588568",
"0.5873272",
"0.583159",
"0.5816811",
"0.58001757",
"0.5790376",
"0.577243",
"0.5767259",
"0.5761732",
"0.5761732",
"0.5726059",
"0.572201",
"0.5719444",
"0.5711827",
"0.57105863",
"0.56966305",
"0.56930286",
"0.56909955",
"0.56775033",
"0.5669196",
"0.5668921",
"0.56454027",
"0.5625703",
"0.5619142",
"0.5619007",
"0.5616792",
"0.56061774",
"0.5605006",
"0.55852956",
"0.5584365",
"0.5579977",
"0.5573979",
"0.556898",
"0.55683994",
"0.5565554",
"0.555815",
"0.5548915",
"0.5541349",
"0.55383694",
"0.552392",
"0.5512105",
"0.55006266",
"0.5495245",
"0.54926175",
"0.54854715",
"0.54821354",
"0.5476738",
"0.5469162",
"0.546407",
"0.54568386",
"0.5449159",
"0.5446483",
"0.54441154",
"0.5439536",
"0.5419706",
"0.54062647",
"0.5402779",
"0.53944767",
"0.53940445",
"0.53926474",
"0.5389862",
"0.5389413",
"0.53893244",
"0.53878826",
"0.53830343",
"0.5378812",
"0.53783464",
"0.5377919",
"0.53777283",
"0.5377206",
"0.5372931",
"0.53706735",
"0.53706735",
"0.5365765",
"0.53600115",
"0.5359924",
"0.53591675",
"0.5357602",
"0.5357303",
"0.53557295",
"0.5354478",
"0.53507286",
"0.53475165",
"0.5347138",
"0.5338782",
"0.53373355",
"0.5332787",
"0.5331876",
"0.53292626",
"0.53276044",
"0.532027",
"0.5315772",
"0.5307117"
] | 0.7541923 | 0 |
This function is used to reactivate the selected deactivated user | def activate
@users=User.find_with_deleted(params[:id])
@lawfirm_employee=Employee.find_with_deleted(:first,:conditions => {:user_id => @users.id})
respond_to do |format|
if @users.update_attribute('deleted_at','')
@lawfirm_employee.update_attribute('deleted_at','')
flash[:notice] = "#{t(:text_user)} " "#{t(:flash_was_successful)} " "#{t(:text_activated)}"
format.html {redirect_to :controller=>"lawfirm_admins",:action=>"index"}
format.xml { head :ok }
else
format.html { render :action => "deactivated_users" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reactivate(user)\n if !user.account_active?\n user.reactivate!\n end\n end",
"def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, self, \"#{self.name} has been reactivated\")\r\n end",
"def admin_reactivate\n user = User.find(params[:id])\n authorize! :edit, @user #prevent other users from disabling OTP on another user.\n user.deactivated = false\n user.save!\n flash[:notice] = \"Successfully Reactivated user.\"\n redirect_back(fallback_location: '/')\n end",
"def activate_user(user)\n user.status_id=0\n user.save\n end",
"def activate\n @user = User.find(params[:id])\n @user.activate\n redirect_to :back\n end",
"def user_onoff_flag\n @requested_user = User.find_by_account_number(params[:id])\n if @requested_user.is_active?\n @requested_user.update_columns(:is_active => false)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully de-activated.\"}\n else\n @requested_user.update_columns(:is_active => true)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully activated.\"}\n end\n end",
"def deactivate\n @this_user.update_attributes(:active => false)\n redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]\n end",
"def reactivate\n @user = User.find(params[:id])\n @user.create_activation_digest\n @user.update_attribute(:activation_digest, @user.activation_digest)\n @user.send_activation_email\n flash[:info] = \"Click the activation link we just emailed you, \n and we'll log you in.\"\n redirect_to root_url\n end",
"def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end",
"def activate\n @activated = true\n self.active = true\n save(false)\n end",
"def deactive\n user = User.find(params[:id])\n user.toggle!(:active)\n user.save\n if user.active == true \n redirect_to users_path, :notice => \"Activate User #{user.userName}\"\n else \n flash[:error] = \"Deactivate User #{user.userName}\"\n redirect_to users_path \n end\n end",
"def activate\n @this_user.update_attributes(:active => true)\n redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]\n end",
"def deactivate\r\n items = Marketplace::Database.instance.items_by_user(self)\r\n items.each{ |item| item.deactivate }\r\n\r\n buy_orders = Marketplace::Database.instance.buy_orders_by_user(self)\r\n buy_orders.each{ |buy_order| buy_order.delete }\r\n\r\n Marketplace::Database.instance.add_deactivated_user(self)\r\n Marketplace::Database.instance.delete_user(self)\r\n Marketplace::Activity.create(Activity.USER_DEACTIVATE, self, \"#{self.name} has been deactivated\")\r\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.make_admin_if_first_user\n save(false)\n end",
"def deactivate\n @user = User.find(params[:id])\n @user.deactivate\n redirect_to :back\n end",
"def inactivate\n self.update_attribute(:active, false)\n end",
"def activate_if_invited\n invited_user = Invite.find_by_invited_user_email(self.email)\n if ! invited_user.nil?\n invited_user.update_attribute(:invited_user_id, self.id)\n self.account_active = 1\n self.save!\n end\n end",
"def activate\n @user = User.find(params[:id])\n\n \tif @user.user_state == \"confirmed\"\n flash[:notice] = \"\" + @user.first_name + \", your account is already confirmed.\"\n redirect_to(:action => 'confirmed', :id => params[:id])\n else\n\t\t\trespond_to do |format|\n\t\t\t\tif @user.update_attributes(params[:user])\n\t\t \t\[email protected]_state = \"confirmed\"\n\t\t\t\t\[email protected]_at = Time.now\n\n\t\t\t\t\tif @user.update_attributes(params[:user])\t\t\t\t\t\t\n\t\t\t\t\t\tNotifier.user_confirmed(@user).deliver\n\t\t\t\t\t\tflash[:notice] = \"You're all set, \" + @user.first_name + \"!\"\n\t\t\t\t\t\tformat.html { redirect_to(:action => 'completed', :id => params[:id]) }\n\t\t\t\t\telse\n\t\t\t\t\t\tflash[:error] = 'Failed to set user state to confirmed. Please try again.'\n\t\t\t\t\t\tformat.html { render :action => \"invitation\", :layout => \"activate\" }\n\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tflash[:error] = 'User was not updated.'\n\t\t\t\t\tformat.html { render :action => \"invitation\", :layout => \"activate\" }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end",
"def activate\n @user = User.find(params[:format])\n @user.update(:active_flag => true)\n flash[:info] = \"User Activated\"\n ## email user and line management to indicate the profile has been activated\n UserMailer.activated_user_email(@user).deliver\n redirect_to users_path\n end",
"def activate\n self.active = true\n save\n end",
"def active_user\n user = pending_user\n user.activate! if user.valid?\n user\n end",
"def activate\n @user.activation_code = nil\n @user.activation_expires_at = nil\n @user.activated_at = Time.zone.now\n @user.save\n end",
"def activate\n user = User.find_by_username params[:username]\n if user && user.activation == params[:activation]\n user.activation = \"ACTIVATION_ACTIVE\"\n user.save()\n render status: 200, json: {error: false}\n else\n render status: 403, json: {error: true}\n end\n end",
"def activate!\n self.active = true\n save\n end",
"def activate!(user)\n return false if self.active?\n\n @user = user\n\n create_hook!\n\n self.active = true\n self.save!\n end",
"def activate!\n self.active = true\n self.save!\n end",
"def deactivate!(user)\n return false unless self.active?\n\n @user = user\n\n remove_hook!\n\n self.active = false\n self.save!\n end",
"def deactivate\n admin = Administrator.find_by_user_id(params[:id])\n admin.status = false\n admin.save\n @users = User.all\n render 'index'\n end",
"def activate\n @user = User.find(params[:id])\n @user.activate!\n\n UserMailer.delay({ run_at: 1.minutes.from_now }).user_activated(@user) \n\n respond_to do |format|\n format.html { redirect_to :users, notice: 'Пользователь успешно активирован.' }\n end\n end",
"def deactivate\n\t @user.update(:active => false)\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def inactivate! record\n record.update_column(:active, false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.activate!\n save!\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save!\n end",
"def activate\r\n @activated = true\r\n self.activated_at = Time.now.utc\r\n self.activation_code = nil\r\n save(false)\r\n end",
"def set_to_activate\n if REQUIRES_ACCOUNT_CONFIRMATION_TO_ACTIVATE && owner.parent && !owner.parent.account_confirmed\n self.status = Status::PENDING_ACCOUNT_CONFIRMATION\n elsif owner.requires_parental_guidance? && owner.parent.nil?\n self.status = Status::PENDING\n else\n self.status = Status::OPEN\n owner.update_friends_new_item\n end\n self.activated_at = Time.now\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.save(false)\n end",
"def change_state!(_ctx, user:, **)\n role(user).activate!\n end",
"def activate!\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(false)\n end",
"def activate\n user = User.find_by_token(params[:token])\n unless user.nil?\n unless user.activated?\n user.activate\n user.save\n #notify admins\n UserMailer.deliver_notify_admins_signup(User.admins, user)\n #login\n self.current_user = user\n flash[:notice] = 'Account successfuly activated.'\n redirect_to profile_path(user.login)\n else\n render :partial => '/sessions/already_activated', :layout => true\n end\n else\n render :text => '<strong>Invalid Request!</strong>', :layout => true\n end\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save(:validate => false)\n end",
"def activate\n update_attribute(:activated, true)\n end",
"def activate\n @user = User.find(:first, :conditions => [ 'id = ? AND token = ? AND token_expiry >= ?',\n @params[:id], @params[:token], 0.minutes.from_now ])\n if @user\n reset_session # Reset old sessions if exists\n @user.update_attributes({ :userstatus_id => 2,\n :token => nil, :token_expiry => nil })\n url = url_for(:controller => 'user', :action => 'login')\n UserNotifier.deliver_activation(@user, url) \n render :action => 'activated'\n else\n render :action => 'invalid'\n end\n end",
"def activate\n admin = Administrator.find_by_user_id(params[:id])\n admin.status = true\n admin.save\n @users = User.all\n render 'index'\n end",
"def activate_deactivate(file_data, path_to_users_file)\n clear\n puts \"1. Activate User\\n2. Deactivate User\\n3. Go back\\n\"\n choice = gets.strip.chomp.to_i\n case choice\n when 1\n activate_user(file_data, path_to_users_file)\n when 2\n deactivate_user(file_data, path_to_users_file)\n when 3\n clear\n return\n end\nend",
"def deactivate\n @user = User.find(params[:id])\n @user.deactivate!\n\n UserMailer.delay({ run_at: 1.minutes.from_now }).user_deactivated(@user) \n\n respond_to do |format|\n format.html { redirect_to :users, notice: 'Пользователь успешно деактивирован.' }\n end\n end",
"def activate\n self.activated_at = Time.now.utc\n self.perishable_token = nil\n save(false)\n end",
"def reactivate\n unless @active\n apply(ItemReactivated.new(id))\n end\n end",
"def activate\r\n # puts 'activate'\r\n @@activated = true\r\n @suspended = false\r\n @user_esc = false\r\n @cancel_reason = nil\r\n @enable_redraw = true\r\n end",
"def activate\n unless self.recently_activated?\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.status = \"active\" if has_role?(:employer_admin) || has_role?(:applicant)\n \n save(:validate => false)\n end\n end",
"def activate\n self.current_user = params[:activation_code].blank? ? :false : User.find_by_activation_code(params[:activation_code])\n if logged_in? && !current_user.active?\n current_user.activate\n redirect_to(user_path(self.current_user) + '?welcome')\n else\n redirect_to '/'\n end\n end",
"def activated\n @user = User.find(params[:id])\n end",
"def activate\n @user = User.find(params[:id])\n\n if @user.activated?\n flash[:fail] = \"Account already activated\"\n redirect_to root_url\n\n elsif @user.activation_token && params[:activation_token] == @user.activation_token\n @user.activated = true\n @user.activation_token = nil\n\n if @user.save\n flash[:success] = \"Activated account\"\n sign_in!(@user)\n redirect_to user_url(@user)\n else\n flash[:errors] = [\"Unable to activate account\"] + @user.errors.full_messages\n redirect_to root_url\n end\n\n else\n flash[:fail] = \"Invalid activation token\"\n redirect_to root_url\n end\n\n end",
"def activate\n deactivate_ids = @decline_items.to_a.collect(&:id)\n user_ids = Set.new\n @items.each do |item|\n next if deactivate_ids.include?(item.id)\n item_params = params[\"item_#{item.id}\"]\n item.attributes = item_params if item_params\n logger.info \" [ + ] #{item.id} - #{item_params}\"\n item.activate! if !@testing\n user_ids << item.user_id\n end\n @decline_items.to_a.each { |item|\n logger.info \" [ x ] #{item.id}\"\n item.decline! if !@testing\n user_ids << item.user_id\n }\n if auth_user.is_a?(Parent) and auth_user.account_confirmed\n clean_pending_item_notifications!( user_ids )\n end\n update_user_data!( user_ids )\n\n if !auth_user.account_confirmed\n if ::Users::Notifications::NeedsAccountConfirm.where(recipient_user_id: auth_user.id).empty?\n ::Users::Notifications::NeedsAccountConfirm.create(sender_user_id: Admin.cubbyshop_admin.id, recipient_user_id: auth_user.id)\n if request.headers['X-App-Name'].eql? 'kidstrade-ios'\n ::NotificationMail.create_from_mail(Admin.cubbyshop_admin.id, auth_user.id, UserMailer.account_confirmation_available(auth_user))\n end\n ::Jobs::VerifyAccountReminder.new(auth_user.id).enqueue!\n end\n end\n\n flash[:notice] = 'Items activated successfully'\n respond_to do |format|\n format.html {\n if !auth_user.account_confirmed\n redirect_to :account_confirmation\n else\n render 'approve_confirmed', layout: 'markup'\n end\n }\n format.js\n format.json { render json: {success: true, item_count: @items.size} }\n end\n end",
"def activate!\n @activated = true\n\n self.active = true\n \n # Authlogic resets the perishable token by default on save, but I'm leaving the call\n # to reset_perishable_token! here directly to help reveal intent (which's is kinda a\n # dead purpose after this long comment, but who cares).\n #\n # This also saves the record.\n #\n reset_perishable_token!\n end",
"def activate\n @activated = true\n # self.activated_at = Time.now.utc #此行变更为下一行\n self.activated_at = Time.now\n self.activation_code = nil\n save(false)\n # save\n end",
"def activate\n authorize current_user\n\n user = User.find(params[:id])\n return if user.blank?\n\n begin\n user.active = !user.active\n user.save!\n render json: {\n code: 1,\n msg: format(_(\"Successfully %{action} %{username}'s account.\"),\n action: user.active ? _('activated') : _('deactivated'),\n username: user.name(false))\n }\n rescue StandardError\n render json: {\n code: 0,\n msg: format(_('Unable to %{action} %{username}'),\n action: user.active ? _('activate') : _('deactivate'),\n username: user.name(false))\n }\n end\n end",
"def deactivate\n self.active = false\n save\n end",
"def deactivate\n return false if deactivated?\n self.status = 'deactivated'\n save\n end",
"def activate\n\t\t#puts \"sessions_controller.activate\"+params.inspect\n\t\tuser = User.find(params[:id]) if User.exists?(params[:id])\n\t\tunless user.nil?\n\t\t\tif user.may_connect?\n\t\t\t\ttype=Typesobject.find_by_forobject_and_name(\"user\", PlmServices.get_property(:TYPE_USER_PERSON))\n\t\t\t\tuser.typesobject=type\n\t\t\t\tif user.save\n\t\t\t\t\t@current_user = user\n\t\t\t\t\tsession[:user_id] = user.id\n\t\t\t\t\tflash[:notice] = t(:ctrl_role_needed)\n\t\t\t\t\trespond_to do |format|\n\t\t\t\t\t\tformat.html { render :action => :edit }\n\t\t\t\t\t\tformat.xml { head :ok }\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tflash[:notice] = t(:ctrl_new_account_not_validated, :user=>user.login)\n\t\t\t\t\t#puts \"sessions_controller.activate new_account_not_validated :\"+user.to_s\n\t\t\t\t\trespond_to do |format|\n\t\t\t\t\t#format.html { render :action => :new }\n\t\t\t\t\t\tformat.html { redirect_to user}\n\t\t\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_user_not_valid,:user=>user )\n\t\t\t\t@current_user=nil\n\t\t\t\t#puts \"sessions_controller.activate user_not_valid :\"+user.to_s\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.html { redirect_to user }\n\t\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tflash[:notice] = t(:ctrl_new_account_not_existing, :user=>nil)\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { render :action => :new }\n\t\t\t\tformat.xml {render :xml => errs, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\n\tend",
"def deactivate_user(users, path_to_users_file)\n puts \"Enter username to make inactive:\\n\"\n username = gets.strip.chomp\n if username == \"admin\"\n clear\n puts \"Sorry! You cannot deactivate this admin user.\"\n return\n end\n users.each do |user|\n if user['username'] == username and username != \"admin\" # cant delete admin user\n # confirm you want to deactivate the user\n puts \"You are about to deactivate #{user['username']}. Sure? (y/n)\"\n choice = gets.strip.chomp.downcase\n if choice.match(/^y/) \n # deactivate the user\n user['active']=false\n write_json_file(users, path_to_users_file)\n clear\n puts \"#{username} user has been deactivated\"\n return\n else\n clear\n puts \"User remains active\"\n return\n end\n end\n end\n clear\n puts \"User does not exist\"\nend",
"def do_activate\n self.activated_at = Time.now.utc\n self.deleted_at = nil\n end",
"def set_activation\n @salary_history = SalaryHistory.find(params[:id])\n @salary_history.update_attributes(:activate => true)\n SalaryHistory.update_all(\"activate = false\", \"id <> #{ params[:id] } AND user_id = #{@salary_history.user_id}\" )\n redirect_to salary_histories_user_path(@salary_history.user_id)\n end",
"def reactivate\n @administrator.reactivate\n respond_to do |format|\n format.html { redirect_to %i[admin settings root], notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def activate\n @activated = true\n update_attributes(:activated_at => Time.now.utc, :activation_code => nil)\n end",
"def activate\n @activated = true\n update_attributes(:activated_at => Time.now.utc, :activation_code => nil)\n end",
"def activate\n @activated = true\n update_attributes(:activated_at => Time.now.utc, :activation_code => nil)\n end"
] | [
"0.7758062",
"0.756553",
"0.74289834",
"0.7199117",
"0.7058953",
"0.7014198",
"0.6988723",
"0.6914783",
"0.6855231",
"0.68459487",
"0.68384975",
"0.6821023",
"0.67126447",
"0.6705593",
"0.66877896",
"0.6679637",
"0.66748154",
"0.6554469",
"0.6513467",
"0.6510232",
"0.6509916",
"0.65054905",
"0.649028",
"0.64859873",
"0.64838994",
"0.6481438",
"0.64797205",
"0.64753336",
"0.6475117",
"0.6473408",
"0.6455878",
"0.6441832",
"0.6436454",
"0.64354306",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64312255",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64257634",
"0.64142907",
"0.6392987",
"0.6384894",
"0.63837016",
"0.6381695",
"0.6378873",
"0.6376051",
"0.6362651",
"0.6345358",
"0.6343416",
"0.6341749",
"0.63398045",
"0.63333",
"0.63199264",
"0.63053805",
"0.6281786",
"0.6270702",
"0.6258748",
"0.62550575",
"0.6249423",
"0.6242031",
"0.6234701",
"0.6231526",
"0.6224863",
"0.6220125",
"0.6218685",
"0.6199369",
"0.61847466",
"0.6181882",
"0.617253",
"0.6171779",
"0.6169878",
"0.6169878",
"0.6169878"
] | 0.0 | -1 |
Gets the Domain Name | def get_domain(session)
domain = ""
ipv4_info = nil
ipv6_info = nil
begin
subkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History"
v_name = "DCName"
domain_dc = registry_getvaldata(subkey, v_name)
rescue
print_error("Could not determine if the host is part of a domain.")
end
if (!domain_dc.nil?)
# leys parse the information
dom_info = domain_dc.split('.')
domain = dom_info[1].upcase
dc = domain_dc.gsub('\\\\','')
print_good("Domain: #{domain}")
print_good("Domain Controller: #{dc}")
# Resolve IPv4 address
begin
ipv4_info = session.net.resolve.resolve_host(dc, AF_INET)
print_good("IPv4: #{ipv4_info[:ip]}")
rescue
print_status("Could not resolve IPv4 for #{dc}")
end
# Resolve IPv6 address
begin
ipv6_info = session.net.resolve.resolve_host(dc, AF_INET6)
print_good("IPv6: #{ipv6_info[:ip]}")
rescue
print_status("Could not resolve IPv6 for #{dc}")
end
else
print_status "Host is not part of a domain."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domain_name\n return @domain_name\n end",
"def domain_name\n return @domain_name\n end",
"def domain_name\n @domain_name ||= default_name\n end",
"def domain\n unless @domain\n if defined? ActiveSupport::CoreExtensions::String::Inflections\n @domain = name.tableize\n else\n @domain = name.downcase\n end\n end\n @domain\n end",
"def get_domain()\n\t\tdomain = \"\"\n\t\tbegin\n\t\t\tsubkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n\t\t\tv_name = \"DCName\"\n\t\t\tdomain_dc = registry_getvaldata(subkey, v_name)\n\t\t\tdom_info = domain_dc.split('.')\n\t\t\tdomain = dom_info[1].upcase\n\t\trescue\n\t\t\tprint_error(\"This host is not part of a domain.\")\n\t\tend\n\t\treturn domain\n\tend",
"def get_domain()\n\t\tdomain = \"\"\n\t\tbegin\n\t\t\tsubkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n\t\t\tv_name = \"DCName\"\n\t\t\tdomain_dc = registry_getvaldata(subkey, v_name)\n\t\t\tdom_info = domain_dc.split('.')\n\t\t\tdomain = dom_info[1].upcase\n\t\trescue\n\t\t\tprint_error(\"This host is not part of a domain.\")\n\t\tend\n\t\treturn domain\n\tend",
"def domain\n @domain ||= PublicSuffix.parse(@fqdn).domain\n end",
"def fqdn domain_name\n Service.fqdn domain_name, dns\n end",
"def domain\n components = rdns.map {|rdn| rdn[:dc]}.compact\n components.join('.') unless components.empty?\n end",
"def getDomain\n @domain\n end",
"def domain\n return nil if @domain.empty?\n @domain\n end",
"def get_server_domain\n @hostname ||= Socket.gethostname\n end",
"def default_domain_name\n return @default_domain_name\n end",
"def default_domain_name\n return @default_domain_name\n end",
"def get_domain\n @domain\n end",
"def getdomain()\n domain = \"\"\n begin\n subkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n v_name = \"DCName\"\n domain_dc = registry_getvaldata(subkey, v_name)\n dom_info = domain_dc.split('.')\n domain = dom_info[1].upcase\n rescue\n print_error(\"This host is not part of a domain.\")\n end\n return domain\n end",
"def domain(tld_length = 1)\n host.split('.').last(1 + tld_length).join('.')\n end",
"def get_url_domain\n uri = URI.parse(url)\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def get_domain url\n uri = URI.parse url\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def get_domain\n domain = nil\n begin\n subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History'\n v_name = 'DCName'\n domain_dc = registry_getvaldata(subkey, v_name)\n rescue\n print_error 'Could not determine if the host is part of a domain.'\n return nil\n end\n if !domain_dc.nil?\n # lets parse the information\n dom_info = domain_dc.split('.').drop(1)\n domain = dom_info.join('.')\n else\n print_status 'Host is not part of a domain.'\n end\n domain\n end",
"def domain(tld_length = 1)\n host.split(\":\").first.split(\".\").last(1 + tld_length).join(\".\")\n end",
"def domain\n @uri[:domain]\n end",
"def domain\n server_name || http_host\n end",
"def domain\n @domain\n end",
"def domain\n @domain\n end",
"def get_domain_name(host)\n domain = nil\n search = nil\n resolv_conf = if host['platform'].include?('windows')\n if host.is_cygwin?\n host.exec(Command.new(\"cat /cygdrive/c/Windows/System32/drivers/etc/hosts\")).stdout\n else\n host.exec(Command.new('type C:\\Windows\\System32\\drivers\\etc\\hosts')).stdout\n end\n else\n host.exec(Command.new(\"cat /etc/resolv.conf\")).stdout\n end\n resolv_conf.each_line do |line|\n if (match = /^\\s*domain\\s+(\\S+)/.match(line))\n domain = match[1]\n elsif (match = /^\\s*search\\s+(\\S+)/.match(line))\n search = match[1]\n end\n end\n return_value ||= domain\n return_value ||= search\n\n return unless return_value\n\n return_value.gsub(/\\.$/, '')\n end",
"def dns_name instance\n instance.dns_name\n end",
"def domain_info\n @domain = normalized_email.split('@').last\n domain\n end",
"def domain_name=(value)\n @domain_name = value\n end",
"def domain_name=(value)\n @domain_name = value\n end",
"def domain\n try_opt(:domain)\n end",
"def domain_name\n Faker::Internet.domain_name\n end",
"def domain_name\n Faker::Internet.domain_name\n end",
"def domain\n @attributes[:domain]\n end",
"def domain\n @attributes[:domain]\n end",
"def subdomain\n host.split(\".\").first\n end",
"def domain\n return @domain if defined? @domain\n\n @domain = begin\n PublicSuffix.parse(normalized_domain, default_rule: nil)\n rescue PublicSuffix::DomainInvalid, PublicSuffix::DomainNotAllowed\n nil\n end\n end",
"def getDomain(payload)\n\tdomainName = \"\"\n\t\n\twhile true\n\n\t\t# Get length of domain name section\n\t\tlength = payload[0].unpack('c*')[0]\n\t\t#length = payload[0].to_i\n\n\t\tif(length != 0)\n\n\t\t\t# Add domain section to overall domain name string\n\t\t\tdomainName += payload[1, length] + \".\"\n\t\t\tpayload = payload[length + 1..-1]\n\t\telse\n\t\t\t# Return overall domain name string\n\t\t\treturn domainName = domainName[0, domainName.length - 1]\n\t\tend\n\tend\n\tputs \"Domain Info: \" + domainName\nend",
"def parse_domain_name\n mdata = /ip domain-name ([\\w.]+)/.match(config)\n { domain_name: mdata.nil? ? '' : mdata[1] }\n end",
"def get_domain(payload)\n domain_name = \"\"\n while(true)\n # Get length fields\n len = payload[0].unpack('H*')[0].to_i\n \n if len != 0 then\n domain_name += payload[1, len] + \".\"\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1]\n return domain_name\n end # if len != 0 then\n end # while(true)\n end",
"def dns_name\n [\"public\", fqdn].join(\".\")\n end",
"def domain\n URI(base_url).host.downcase\n end",
"def domain\n Domain.new((address.split('@')[1] || '').strip)\n end",
"def subdomain\n self.name.gsub('_', '.')\n end",
"def domain\n domain = request.host\n domain << \":#{request.port}\" unless [80, 443].include?(request.port)\n domain\n end",
"def domain(domain)\n get(\"/dns/domain/#{domain}\")\n end",
"def domain\n settings.service.domain \n end",
"def subdomain\n ([self.short_name] + self.class.dalianshops.domain.split('.')[1..-1]).join('.')\n end",
"def extract_domain_name(payload)\n\t\tif(payload) then\n\t\t domain_name = \"\"\n while(true)\n \t\n \t len = payload[0].unpack('H*')[0].to_i\n \t # to understand below you might need to read up on dns packets. they take the form of [length][string][length][string][...]0\n \t if len != 0 then \n \n domain_name += payload[1, len] + \".\" #grab the first chunk from the begining, until the length specified by the packet\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1] # -1 to truncate the 0 at the end of the payload\n \t\n \n return domain_name\n \t\n end # if len != 0 then\n end\n end\n\tend",
"def domain\n @options['domain']\n end",
"def email_domain\n if !self[:email].blank?\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.last}\" if 2 == split_host.size\n else\n self.organization.site_domain if self.organization\n end\n rescue URI::InvalidURIError\n nil\n end",
"def dns\n @gapi.dns_name\n end",
"def return_email_domain \n return \"@\" + self.email.split('@')[1]\n end",
"def domain_name=(d)\n @domain_name = d\n end",
"def domain_name(url)\n return nil unless url\n if m=url.match(/([^.\\/ ]+)\\.(com|net|info|org|name|biz|gov|\\w\\w)(\\.\\w+)?(\\/.*)*(\\?.*)*$/)\n \"#{m[1]}.#{m[2]}\"\n else\n url\n end\n end",
"def ldap_domain\n @attributes[:ldap_domain]\n end",
"def domain\n URI.parse(@config.split('<')[0].split('->')[0])\n end",
"def domain\n email.split(\"@\")[1]\n end",
"def new_domain\n domain || tag('Domain') || local_domain_name\n end",
"def host_or_domain\n return @host_or_domain\n end",
"def domain\n\t\treturn @dmn\n\tend",
"def smtp_domain\n @smtp_username.split('@').last\n end",
"def domain_name(url)\n url.gsub(\"www.\",\"\").split(\"//\")[1].split(\"/\")[0].split('.')[0]\nend",
"def domain_name(url)\n if url.match(/^www/)\n p url.split(\".\")[1]\n elsif url.match(/^http/)\n x = url.split(\"/\")[2]\n if x.match(/^www/)\n p x.split(\".\")[1]\n else\n p x.split(\".\")[0]\n end\n else\n p url.split(\".\")[0]\n end\nend",
"def canonical\n dns_host_name\n end",
"def build_domain_name(env)\n config = env[:machine].provider_config\n domain_name =\n if config.default_prefix.nil?\n env[:root_path].basename.to_s.dup.concat('_')\n elsif config.default_prefix.empty?\n # don't have any prefix, not even \"_\"\n String.new\n else\n config.default_prefix.to_s.dup\n end\n domain_name << env[:machine].name.to_s\n domain_name.gsub!(/[^-a-z0-9_\\.]/i, '')\n domain_name << \"_#{Time.now.utc.to_i}_#{SecureRandom.hex(10)}\" if config.random_hostname\n domain_name\n end",
"def public_dns_name\n data[:public_dns_name]\n end",
"def dns_host_name\n @dns_host_name ||= ::SimpleIDN.to_ascii(@host_name)\n end",
"def fqdn\n [ hostname, domain ].join('.') unless hostname.nil? and domain.nil?\n end",
"def domain \n @node[\"domain\"]\n end",
"def domain_name(url)\n #url.gsub(/http:|https:|www.|\\/\\/|.com.*/,'')\n url.gsub(/http:|https:|www.|\\/\\//,'').split('.').first\nend",
"def domain_name(subdomain: T.unsafe(nil), domain: T.unsafe(nil)); end",
"def request_subdomain\n request.host.split(/\\./).first\n end",
"def username_domain(username = nil)\n username ||= options[:username] if options\n return unless username\n username.to_s.split('@').last\n end",
"def get_domain_name_from_email_address(email)\nend",
"def host\n domain\n end",
"def cname\n self[:cname] || domain_names&.first&.canonicalize_cname\n end",
"def cname\n self[:cname] || domain_names&.first&.canonicalize_cname\n end",
"def name\n FFI::Libvirt.virDomainGetName(self)\n end",
"def name\n FFI::Libvirt.virDomainGetName(self)\n end",
"def subdomain\n #for debug at localhost\n return self.class.system_top_domain if self.class.system_top_domain == 'localhost'\n short_name + '.' + self.class.system_top_domain\n end",
"def domain\n children[1]\n end",
"def domain\n children[1]\n end",
"def base_domain(response)\n if response.respond_to? :request\n host = response.request.host.sub /:\\d+$/, ''\n return if host =~ /^([\\d.]+|localhost)$/\n\n host =~ /([^.]*)\\.([^.]*|..\\...|...\\...|..\\....)$/\n \".#{$1}.#{$2}\"\n end\n end",
"def normalized_domain\n if @text.empty?\n nil\n elsif parsed_domain\n parsed_domain.host\n end\n end",
"def hostname\n Socket.gethostname.split('.').first.strip\n end",
"def domain\n @domain ||= 'https://api.sirportly.com'\n end",
"def get_domain\n UserNotifierMailer.get_domain(\"http://localhost:3000\")\n end",
"def domain\n Domain.find_by_id(domain_id)\n end",
"def get_domain(opts = {})\n data, _status_code, _headers = get_domain_with_http_info(opts)\n data\n end",
"def domain\n @domain ||= self.domain_id ? Domain.find_by_id(self.domain_id) : nil\n end",
"def domain\n @domain ||= self.domain_id ? Domain.find_by_id(self.domain_id) : nil\n end",
"def domain(dom)\n domain = URI.extract(dom)\n raise ArgumentError, 'The domain must be a URL.' if domain.blank?\n @domain = URI.parse(domain[0]).normalize.to_s\n end",
"def lexical_domain\n\t\treturn self.class.lexdomain_table[ self.lexdomainid ][ :lexdomainname ]\n\tend",
"def subdomain\n ([self.short_name] + self.class.admin_site.domain.split('.')[1..-1]).join('.')\n end",
"def domain_name(str)\n str = str.split('//')\n str = str[str.size - 1].split('.')\n str.delete('www')\n str[0]\nend",
"def fqdn\n [name, tag, domain].compact.join('.')\n end",
"def www\n \"www.#{domain}\"\n end",
"def domain_name(url)\n url.match(%r{(http(s)?://)?(www.)?([a-zA-Z0-9-]*)}).to_a.last\nend",
"def get_fqdn\n return @resource[:name]\n end",
"def getDomainName(payload)\n domainName = \"\"\n while(true)\n len = payload[0].to_i\n if (len != 0)\n domainName += payload[1,len] + \".\"\n payload = payload[len+1..-1]\n else\n return domainName = domainName[0,domainName.length-1]\n end\n end\nend"
] | [
"0.8669912",
"0.8669912",
"0.8288713",
"0.7990533",
"0.77144927",
"0.77144927",
"0.7672004",
"0.75785726",
"0.75526994",
"0.7537022",
"0.7514205",
"0.74978065",
"0.74932903",
"0.74932903",
"0.7477797",
"0.7467327",
"0.7402699",
"0.7373754",
"0.73704624",
"0.7328876",
"0.73192734",
"0.72918594",
"0.7271831",
"0.7260368",
"0.7260368",
"0.71957505",
"0.71908945",
"0.7170941",
"0.7160638",
"0.7160638",
"0.715054",
"0.71453124",
"0.71453124",
"0.70917475",
"0.70917475",
"0.7063087",
"0.7059855",
"0.7042028",
"0.7037982",
"0.7036901",
"0.69930756",
"0.6988043",
"0.69847965",
"0.6957769",
"0.69513816",
"0.6941644",
"0.6940865",
"0.69157857",
"0.69097775",
"0.69007915",
"0.68932164",
"0.688357",
"0.6850106",
"0.68111265",
"0.6801622",
"0.67961955",
"0.6792783",
"0.6790683",
"0.67860854",
"0.6772897",
"0.6768755",
"0.6755875",
"0.67549694",
"0.6740023",
"0.6737902",
"0.6708055",
"0.67032564",
"0.66866",
"0.66695595",
"0.66688657",
"0.66687936",
"0.66559094",
"0.6653261",
"0.66308904",
"0.6614179",
"0.6606495",
"0.6605834",
"0.6605834",
"0.6604319",
"0.6604319",
"0.6602318",
"0.66001725",
"0.66001725",
"0.65961635",
"0.6590842",
"0.6581684",
"0.6581032",
"0.65771013",
"0.65770763",
"0.656936",
"0.6563937",
"0.6563937",
"0.6563328",
"0.6536674",
"0.65322214",
"0.6526431",
"0.65256697",
"0.65145046",
"0.6513917",
"0.6513078",
"0.6511226"
] | 0.0 | -1 |
Get the query parameters necessary to get the next page of data from Pandora. | def get_next_data_indices(html)
# .js-more-link is found on mobile pages.
show_more = Nokogiri::HTML(html).css('.show_more, .js-more-link')[0]
if show_more
next_indices = {}
data_attributes = ['nextStartIndex', 'nextLikeStartIndex', 'nextThumbStartIndex']
data_attributes.each do |attr_name|
attr = show_more.attributes['data-' + attr_name.downcase]
next_indices[attr_name.to_sym] = attr.value.to_i if attr
end
next_indices
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params\n @pagination.request.query_parameters\n end",
"def next_page\n url = @entity[:next]\n return unless url\n\n query = URI.decode_www_form(URI(url).query).to_h\n query = query.to_h { |k, v| [k.to_sym, v] }\n self.class.list(**query)\n end",
"def next_url_str\n \"#{@url_base_str}?#{QUERY_STRING_PART1}&#{@query_str_next_page}\"\n end",
"def next_page(extra_params = {})\n base, args = next_page_params\n base ? @api.get_page([base, args.merge(extra_params)]) : nil\n end",
"def page_params\n end",
"def params_for_page page\n page_string = page > 1 ? \"/page/#{page}\" : ''\n params = @additional_params.join('&')\n if params.empty?\n page_string\n else\n page_string + \"?#{params}\"\n end\n end",
"def page_params \n params.has_key?(:pagination) ? get_page_params( params.require(:pagination) ) : {}\n end",
"def previous_and_next_document_params(index, window = 1)\n solr_params = blacklight_config.document_pagination_params.dup\n\n if solr_params.empty?\n solr_params[:fl] = blacklight_config.document_model.unique_key\n end\n\n if index > 0\n solr_params[:start] = index - window # get one before\n solr_params[:rows] = (2 * window) + 1 # and one after\n else\n solr_params[:start] = 0 # there is no previous doc\n solr_params[:rows] = 2 * window # but there should be one after\n end\n\n solr_params[:facet] = false\n solr_params\n end",
"def next_search_result_page(params = {}, opts = {})\n return self.class.empty_search_result(opts) unless has_more\n\n params = filters.merge(page: next_page).merge(params)\n\n _search(url, params, opts)\n end",
"def next_page_link\n paging['next'] if paging\n end",
"def next_page_path(list: nil, **url_params)\n items = list&.try(:records) || list || page_items\n return if (items.size < page_size) || (last = items.last).blank?\n\n # General pagination parameters.\n prm = url_parameters(url_params)\n page = positive(prm.delete(:page))\n offset = positive(prm.delete(:offset))\n limit = positive(prm.delete(:limit))\n size = limit || page_size\n if offset && page\n offset = nil if offset == ((page - 1) * size)\n elsif offset\n page = (offset / size) + 1\n offset = nil\n else\n page ||= 1\n end\n prm[:page] = page + 1 if page\n prm[:offset] = offset + size if offset\n prm[:limit] = limit if limit && (limit != default_page_size)\n\n # Parameters specific to the EMMA Unified Search API.\n title = date = nil\n case prm[:sort]&.to_sym\n when :title then title = last.dc_title\n when :sortDate then date = last.emma_sortDate\n when :publicationDate then date = last.emma_publicationDate\n when :lastRemediationDate then date = last.rem_remediationDate\n else prm.except!(:prev_id, :prev_value)\n end\n if title || date\n prm[:prev_id] = url_escape(last.emma_recordId)\n prm[:prev_value] = url_escape(title || IsoDay.cast(date).to_s)\n end\n\n make_path(request.path, **prm)\n end",
"def pagination\n [ :next_page ]\n end",
"def next_page(params = nil)\n perform_request(@next_page_link)\n end",
"def page_params\n []\n end",
"def query_params\n {\n affiliate:,\n access_key:,\n query:,\n offset:,\n limit:\n }\n end",
"def query_args\n {\n page: params[:start] ? (params[:start].to_i / params[:length].to_i).floor + 1 : 1,\n per_page: params[:length],\n load: false,\n order: ordering,\n aggs: enabled_aggs,\n where: agg_where,\n smart_aggs: false\n }\n end",
"def pagination_params\n page = params[:page].to_i\n page = 1 unless page > 0\n per = params[:per].to_i\n per = 25 unless per > 0\n {page: page, per: per}\n end",
"def rel_next_href_params(records, original_params = original_request_params.clone)\n @rel_next_href_params ||= records.is_a?(WillPaginate::Collection) && records.next_page ?\n original_params.merge({ :page => records.next_page }) : nil\n end",
"def next_query\n @start += 1000\n\n {\n start: @start - 1000,\n rows: 1000,\n q: @q,\n fq: @fq,\n def_type: @def_type,\n fl: 'uid,fulltext_url',\n facet: false\n }\n end",
"def jsonapi_pagination_params\n pagination = params[:page].try(:slice, :number, :size) || {}\n per_page = jsonapi_page_size(pagination)\n num = [1, pagination[:number].to_f.to_i].max\n\n [(num - 1) * per_page, per_page, num]\n end",
"def query_param\n {\n query: ::Kahn::JSON.decode(params.fetch('query', '{}')),\n fields: ::Kahn::JSON.decode(params.fetch('fields', '{}')),\n limit: params.fetch(:limit, 10),\n skip: params.fetch(:skip, 0)\n }\n end",
"def previous_and_next_document_params(index, window = 1)\n solr_params = {}\n\n if index > 0\n solr_params[:start] = index - window # get one before\n solr_params[:rows] = 2*window + 1 # and one after\n else\n solr_params[:start] = 0 # there is no previous doc\n solr_params[:rows] = 2*window # but there should be one after\n end\n\n solr_params[:fl] = '*'\n solr_params[:facet] = false\n solr_params\n end",
"def set_params_page\n params[:page] = params.fetch(\"page\"){1}.to_i\n params[:per_page] = params.fetch(\"per_page\"){20}.to_i\n end",
"def next_page\n @rally_rest.query(@query.next_page(:start => self.start_index + self.page_size,\n\t\t\t\t :pagesize => self.page_size))\n end",
"def next_page_number\n Hash(next_page_params).fetch('page', {}).fetch('number', nil)\n end",
"def pagination!\n parameter :page, :integer, :required => false, :default => 1, :paramType => \"query\"\n parameter :per_page, :integer, :required => false, :default => 30, :paramType => \"query\", \n :allowed => 1..1000\n end",
"def params_for_page(page_number)\n { controller: controller, action: action, params: query_params.merge(\n Foliate.config.page_param => (page_number if page_number > 1)\n ) }\n end",
"def params\n { :params => { 'max-results' => '1000' }}\n end",
"def next_page_url\n \"#{request.path}?page=#{@page + 1}\"\n end",
"def make_pagination_params(options)\n params = {}\n params['Marker'] = options[:marker] if options[:marker]\n params['MaxItems'] = options[:max_items] if options[:max_items]\n params\n end",
"def set_params_page\n params[:page] = params.fetch(\"page\"){1}.to_i\n params[:per_page] = params.fetch(\"per_page\"){20}.to_i\n end",
"def get_page_number\n if page_parameters_defined?\n @query_params[:page] = params[:document_counter].to_i==1 ? 1 : ((params[:document_counter].to_f-1)/current_per_page).ceil\n end\n end",
"def query_parameters\n end",
"def page_from_params\n page_num = params[:page].to_i\n\n page_num.zero? ? DEFAULT_PAGE : page_num\n end",
"def solr_retrieve_previous_next(options = {})\n\n rid = options['previous-next-index']\n\n # set defaults if missing\n if options['page'].nil?\n options['page'] = '1'\n end\n if options['per_page'].nil?\n options['per_page'] = '20'\n end\n\n rpp = options['per_page'].to_i\n\n # determine result page and update options\n goto_page = rid / rpp\n if (rid % rpp) > 0\n goto_page += 1\n end\n options['page'] = goto_page.to_s\n pnum = options['page'].to_i\n\n max = rpp * pnum\n min = max - rpp + 1\n result_index = rid - min\n cached_results = search(options, false, false)\n cached_results_found = cached_results.stat_total_hits\n\n # last result in set, get next result\n if rid == max\n options_next = options\n options_next['page'] = cached_results.page_number+1\n next_result_set = search(options_next, false, false)\n result_next = next_result_set.records.first\n else\n unless rid == cached_results_found\n result_next = cached_results.records[result_index+1]\n end\n end\n\n if result_index == 0\n # first result in set that's not the very first result, get previous result\n if rid != 1\n options_previous = options\n options_previous['page'] = cached_results.page_number-1\n previous_result_set = search(options_previous, false, false)\n result_prev = previous_result_set.records.last\n end\n else\n result_prev = cached_results.records[result_index-1]\n end\n\n # return json result set with just the previous and next records in it\n r = empty_results(cached_results.stat_total_hits)\n results = EBSCO::EDS::Results.new(r, @config)\n next_previous_records = []\n unless result_prev.nil?\n next_previous_records << result_prev\n end\n unless result_next.nil?\n next_previous_records << result_next\n end\n results.records = next_previous_records\n results.to_solr\n\n end",
"def next_page\n pagination_adapter.next_page\n end",
"def query_parameters\n request.GET\n end",
"def page_number\n query_params&.dig(:page)\n end",
"def page_number\n query_params&.dig(:page)\n end",
"def next_page; end",
"def params\n @params||=Addressable::URI.parse(\"?#{@http_query_string}\").query_values\n end",
"def query_params\n get_query_params\n end",
"def parameters\n url_params = \"\"\n\n if @resource == :catalog\n url_params += \"&\" + \"offset=#{URI.escape(@offset.to_s)}\" if @offset\n url_params += \"&\" + \"size=#{URI.escape(@size.to_s)}\" if @size\n url_params += \"&\" + \"search=#{URI.escape(@search)}\" if @search\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n url_params += \"&\" + \"state=#{URI.escape(@state)}\" if @state\n url_params += \"&\" + \"sort=#{URI.escape(@sort)}\" if @sort\n url_params += \"&\" + \"instock=#{@instock}\" if @instock\n elsif @resource == :categorymap\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n url_params += \"&\" + \"search=#{URI.escape(@search)}\" if @search\n elsif @resource == :reference\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n end\n\n return url_params\n end",
"def next_page\n @client.get(@raw_page['nextRecordsUrl']).body if has_next_page?\n end",
"def query_parameters; end",
"def build_scroll_params(response = nil)\n @page += 1 if response\n @opts[:query_params][:filter] = { skip: @page * @limit, limit: @limit }\n @opts\n end",
"def page_parameters_defined?\n if params[:document_counter].nil? || current_per_page==0\n @query_params[:page]=1\n logger.warn \"document_counter or current_per_page parameters are not defined, return to the first search page\"\n false\n else\n true\n end\n end",
"def next_page(params = {})\n @items = load_page(params)\n end",
"def query_params_cache_keys\n [params[:page]]\n end",
"def next_page\n if next_page?\n @query[:startPage] += 1\n fetch\n end\n end",
"def query_params; end",
"def paginator\n per_page = @ruhoh.db.config(\"paginator\")[\"per_page\"]\n current_page = master.context[\"page\"]['current_page'].to_i rescue 0\n current_page = current_page.zero? ? 1 : current_page\n offset = (current_page-1)*per_page\n\n page_batch = all[offset, per_page]\n raise \"Page does not exist\" unless page_batch\n page_batch\n end",
"def extract_next_page(pagination)\n return nil if pagination[:next].nil?\n\n CGI.parse(URI.parse(pagination[:next]).query)[\"page\"].first\n rescue\n nil\n end",
"def previous_and_next_documents_for_search(\n index,\n req_params,\n other_params = nil\n )\n pagination_params = previous_and_next_document_params(index)\n start = pagination_params.delete(:start)\n rows = pagination_params.delete(:rows)\n query =\n search_builder\n .with(req_params)\n .start(start)\n .rows(rows)\n .merge(other_params || {})\n .merge(pagination_params)\n .except(:add_facetting_to_solr, :add_facet_paging_to_solr)\n\n # Get the previous, current and next documents.\n response = repository.search(query)\n\n # Previous or next document will be *nil* at the ends of results.\n docs = response.documents\n prev_doc = (docs.first if index > 0)\n next_doc = (docs.last if index < (response.total - 1))\n return response, [prev_doc, next_doc]\n end",
"def get_paging_order_info\n {\n :page => params[:page],\n :limit => params[:limit].nil? ? 20 : params[:limit]\n }\n end",
"def next_page\n end",
"def next_page\n @links['next']\n end",
"def set_page_vars\n @page = params[:page] ? params[:page].to_i : START_PAGE\n @per_page = PER_PAGE\n end",
"def long_page_params\n params.fetch(:long_page, {})\n end",
"def next_page\n @page = info(@page[:next_page])\n end",
"def pagination_param\n Kaminari.config.param_name\n end",
"def pagination_param\n Kaminari.config.param_name\n end",
"def query_params\n @query_params ||= QueryParamsController.new config\n end",
"def get_offset_and_limit\n if @request_params[:offset].present?\n offset = @request_params[:offset].to_i\n offset = 0 if offset < 0\n end\n\n limit = @request_params[:limit].to_i\n if limit < 1\n limit = 25\n elsif limit > 100\n limit = 100\n end\n\n if offset.nil? && @request_params[:page].present?\n offset = (@request_params[:page].to_i - 1) * limit\n offset = 0 if offset < 0\n end\n\n offset ||= 0\n\n @params = {offset: offset, limit: limit}\n end",
"def next\n if (r = @lastresult[\"queries\"][\"nextPage\"])\n @previous = @lastresult.clone\n\n return search_by_query_hash(r.first)\n else\n return nil\n end\n end",
"def paging_find(start=nil, limit=nil)\n start = start.is_a?(Integer) ? start : (params[:start] || 0).to_i\n limit = limit.is_a?(Integer) ? limit : (params[:limit] || 100).to_i\n {:offset=>start,:limit=>limit}\n end",
"def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend",
"def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend",
"def pagination_params()\n normalize_param_value(:_pg).permit(:_s, :_p, :_c)\n end",
"def get_query_params_from_session\n begin\n unless searches_from_history.find(session[:search]['id'].to_i).nil?\n @query_params = searches_from_history.find(session[:search]['id'].to_i).query_params\n get_page_number\n end\n rescue => e\n logger.error \"Unable to restore search from session due to the following error: #{e}\"\n end\n end",
"def next; pager.page(page + 1); end",
"def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend",
"def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend",
"def show\n realtime_page_next_by_time Integer(params[:post_id]), Integer(params[:after]), Integer(params[:limit])\n end",
"def generate_next_url\n if eds_session.has_key? :query_string\n url = HTMLEntities.new.decode eds_session[:query_string]\n\n #blacklight expects the search term to be in the parameter 'q'.\n #q is moved back to 'query-1' in 'generate_api_query'\n #should probably pull from Info method to determine replacement strings\n #i could turn the query into a Hash, but available functions to do so delete duplicated params (Addressable)\n url.gsub!(\"query-1=AND,TI:\", \"q=\")\n url.gsub!(\"query-1=AND,AU:\", \"q=\")\n url.gsub!(\"query-1=AND,SU:\", \"q=\")\n url.gsub!(\"query-1=AND,\", \"q=\")\n\n #Rails framework doesn't allow repeated params. turning these into arrays fixes it.\n url.gsub!(\"facetfilter=\", \"facetfilter[]=\")\n url.gsub!(\"limiter=\", \"limiter[]=\")\n\n #i should probably pull this from the query, not the URL\n if (params[:search_field]).present?\n url << \"&search_field=\" << params[:search_field].to_s\n end\n return url\n else\n return ''\n end\n end",
"def get_paged_editions(params = {})\n Enumerator.new do |yielder|\n next_link = get_editions_url(params)\n while next_link\n yielder.yield begin\n response = get_json(next_link)\n end\n next_link_info = response[\"links\"].select { |link| link[\"rel\"] == \"next\" }.first\n next_link = next_link_info && next_link_info[\"href\"]\n end\n end\n end",
"def do_pagination\n @page_number = 1\n if params[:page] && params[:page].to_i > 0\n @page_number = params[:page].to_i\n end\n @pagination = true\n @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page }\n @pagination_options = {} if params[:all]\n end",
"def query_params\n params[:query]\n end",
"def get_more\n @options = {\n :includeFirst => false, :limit => 10, :fetch_mode => 'normal', :fetch_focus_id => 0,\n :handle => \".endless_scroll_inner_wrap\" \n }\n\n if params.has_key? :includeFirst then\n @options[:includeFirst] = params[:includeFirst] == 'true' ? true : false \n end\n\n if params.has_key? :fetch_mode then\n if params[:fetch_mode] == 'following' then\n @options[:fetch_mode] = 'following'\n elsif params[:fetch_mode] == 'followers' then\n @options[:fetch_mode] = 'followers'\n end\n end\n\n if params.has_key? :fetch_focus_id then\n @options[:fetch_focus_id] = params[:fetch_focus_id].to_i\n end\n\n if params.has_key? :handle then\n @options[:handle] = params[:handle]\n end\n\n upper = @options[:includeFirst] ? 0..params[:last_id].to_i : 0..(params[:last_id].to_i - 1)\n\n if @options[:fetch_mode] == 'normal' then\n @next_personas = Persona.where( :id => upper).order('id desc').limit(@options[:limit])\n elsif @options[:fetch_mode] == 'following' then\n persona = Persona.find(@options[:fetch_focus_id])\n @next_personas = Persona.where(\n :id => persona.followers.where(:tracked_object_type => 'persona', \n :tracked_object_id => upper ).pluck(:tracked_object_id) \n ).order('id desc').limit(@options[:limit])\n elsif @options[:fetch_mode] == 'followers' then\n persona = Persona.find(@options[:fetch_focus_id])\n @next_personas = Persona.where(:id => Follower.where(\n :tracked_object_id => persona.id, :tracked_object_type => 'persona').pluck(:persona_id)\n ).order('id desc').group(:id).having(:id => upper)\n end\n end",
"def set_pagination_buttons(data, options = {})\n return if data.nil? || data.empty?\n\n if data.next_page\n params = {\n :page => data.next_page,\n :per_page => data.per_page\n }.merge(options)\n\n @next_page = \"?#{Rack::Utils.build_query params}\"\n end\n\n if data.previous_page\n params = {\n :page => data.previous_page,\n :per_page => data.per_page\n }.merge(options)\n\n @prev_page = \"?#{Rack::Utils.build_query params}\"\n end\n end",
"def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n end",
"def index_meta_data\n {\n q: params[:q],\n order: params[:order],\n order_by: params[:order_by],\n page: @borrowerships.current_page,\n per_page: @borrowerships.limit_value,\n total_pages: @borrowerships.total_pages\n }\n end",
"def next_page(options = nil)\n next_page_async(options).get\n end",
"def page_params\n params.fetch(:page, {})\n end",
"def page_params\n params.fetch(:page, {})\n end",
"def first_two_result_pages(options = {})\n get_result_pages([1, 2], options)\n end",
"def page_params\n params[:title, :page]\n end",
"def paginate opts = {}\n @paginator = true\n page = (opts[:page] || 1).to_i\n per_page = (opts[:per_page] || 20).to_i\n page = 1 if page < 1\n limit( per_page, ( page - 1 ) * per_page )\n end",
"def pagination_params(opts = {})\n { :page => params[:page] || 1, :per_page => params[:per_page] || 10 }.merge(opts)\n end",
"def next_url_for_path(path, pagy)\n return unless pagy.next\n\n url = URI.parse(path); url_query = Rack::Utils.parse_query url.query\n url.query = Rack::Utils.build_query url_query.merge(pagy.vars[:page_param].to_s => pagy.next)\n url.to_s\n end",
"def pager(method,filter_param,per_page=500)\n session[:ooc_deviation_search][:row_from]=0\n session[:ooc_deviation_search][:row_to]=per_page\n deviations = OocDeviationSearch.search(session[:ooc_deviation_search])\n count = deviations.size == 0 ? 0 : deviations.first.count\n if count > 0\n pages = (count / per_page.to_f).ceil\n if count < per_page\n per_page=count\n end\n pages.times do |page|\n page +=1\n session[:ooc_deviation_search][:row_from]=0\n session[:ooc_deviation_search][:row_to]=per_page\n if filter_param.downcase=='all'\n row_to=per_page*page\n row_from=(row_to-per_page)+1\n session[:ooc_deviation_search][:row_from]=row_from\n session[:ooc_deviation_search][:row_to]=row_to\n end\n #$stderr.puts \"pager: #{page} | #{pages} | #{session[:ooc_deviation_search][:row_from]} |\\\n ##{session[:ooc_deviation_search][:row_to]} | #{count}\"\n unless page==1\n SwareBase.uncached do\n deviations = OocDeviationSearch.search(session[:ooc_deviation_search])\n count = deviations.size == 0 ? 0 : deviations.first.count\n end\n end\n send(method, deviations)\n end\n end\n end",
"def get_query_params(url)\n url_partitioned_at_question_mark = url.partition(\"?\")\n url_partitioned_at_question_mark[2]\nend",
"def set_params\n params[:page] ||= 1\n params[:per_page] ||= 15\n params[:order_by] ||= \"id\"\n params[:order_direction] ||= \"ASC\"\n end",
"def params\n options = @options.dup\n options.empty? ? '' : '?' + options.to_param\n end",
"def offset_params\r\n if params[:offset]\r\n @offset = params[:offset].to_i\r\n end\r\n if params[:limit]\r\n @limit = params[:limit].to_i\r\n end\r\n @offset ||= OFFSET\r\n @limit ||= LIMIT\r\n end",
"def paginate(type, request, ds, opts={})\n return ds.all if opts[:all_results]\n limit = limit_for(type, request)\n %r{\\/(\\d+)\\z} =~ request.env['PATH_INFO']\n offset = (($1||1).to_i - 1) * limit\n objs = ds.limit(limit+1, (offset if offset > 0)).all\n next_page = false\n if objs.length > limit\n next_page = true\n objs.pop\n end\n [next_page, objs]\n end",
"def get_more\n @reserve = get_chain\n last_link = @reserve\n count = @page_size / 100\n count = 15 if count < 15\n while(count > 0)\n last_link = get_next_for(last_link)\n count -= 1\n end\n @next_object = get_next_for(last_link)\n set_next_for( last_link , nil )\n self\n end",
"def previous_and_next_documents_for_search(index, request_params, extra_controller_params = {})\n p = previous_and_next_document_params(index)\n new_state = request_params.is_a?(Blacklight::SearchState) ? request_params : Blacklight::SearchState.new(request_params, blacklight_config)\n query = search_builder.with(new_state).start(p.delete(:start)).rows(p.delete(:rows)).merge(extra_controller_params).merge(p)\n response = repository.search(query)\n document_list = response.documents\n\n # only get the previous doc if there is one\n prev_doc = document_list.first if index > 0\n next_doc = document_list.last if (index + 1) < response.total\n [response, [prev_doc, next_doc]]\n end",
"def page\n @page ||= params[:page] || 1\n end",
"def search_params_pre_1986(d)\n # http://proquest.umi.com.libproxy.mit.edu/pqdweb?SQ=&DBId=9866&date=ON&onDate=03%2F05%2F1979&beforeDate=&fromDate=&toDate=&FT=1&AT=article&author=&sortby=CHRON&RQT=305&querySyntax=PQ&searchInterface=1&moreOptState=OPEN&TS=1326313179&h_pubtitle=&h_pmid=&clientId=5482&JSEnabled=1\n add_default_params( d, {\n :DBId=>'9866',\n })\n end",
"def pager(method,filter_param,per_page=500)\n \n deviations = DeviationSearch.search(session[:deviation_search],0,per_page)\n count = deviations.first[:count]\n if count > 0\n pages = (count / per_page.to_f).ceil\n if count < per_page\n per_page=count\n end\n pages.times do |page|\n page +=1\n end_row=per_page\n start_row=0\n if filter_param.downcase=='all'\n end_row=per_page*page\n start_row=(end_row-per_page)+1\n end\n# $stderr.puts \"pager: #{page} | #{pages} | #{start_row} | #{end_row} | #{count}\"\n unless page==1\n SwareBase.uncached do\n deviations = DeviationSearch.search(session[:deviation_search],start_row,end_row)\n end\n end\n send(method, deviations)\n end\n end\n end"
] | [
"0.6929868",
"0.66783047",
"0.6589785",
"0.64171207",
"0.64108557",
"0.63823503",
"0.6332605",
"0.63242555",
"0.63110876",
"0.6306954",
"0.6299668",
"0.6277547",
"0.6274955",
"0.6257447",
"0.62573224",
"0.6252217",
"0.62498194",
"0.6217454",
"0.620299",
"0.61821204",
"0.6136657",
"0.6105155",
"0.60962826",
"0.6094296",
"0.60854226",
"0.60838616",
"0.60783774",
"0.6069805",
"0.6042546",
"0.6029643",
"0.60234946",
"0.60121524",
"0.59931797",
"0.5976693",
"0.5976427",
"0.59577936",
"0.595631",
"0.59525335",
"0.59525335",
"0.594116",
"0.59379184",
"0.5929908",
"0.59113795",
"0.5902269",
"0.59013647",
"0.5896963",
"0.58857054",
"0.58696085",
"0.5842809",
"0.5826882",
"0.58142644",
"0.5812473",
"0.58121496",
"0.5809541",
"0.58094376",
"0.58009523",
"0.5791751",
"0.5787906",
"0.57723624",
"0.5762532",
"0.5756328",
"0.5756328",
"0.5741802",
"0.5741249",
"0.5735916",
"0.5693847",
"0.5682242",
"0.5682242",
"0.56719875",
"0.5665323",
"0.56622046",
"0.5652516",
"0.5652516",
"0.56493795",
"0.56420124",
"0.56388545",
"0.5633291",
"0.5629259",
"0.5621763",
"0.5616835",
"0.56143767",
"0.56143636",
"0.56128144",
"0.56113535",
"0.56113535",
"0.5606478",
"0.56032616",
"0.55930084",
"0.558759",
"0.5580149",
"0.5574419",
"0.5573297",
"0.5568843",
"0.5558398",
"0.5553417",
"0.5553234",
"0.55423105",
"0.5539256",
"0.5537866",
"0.55330354",
"0.5530966"
] | 0.0 | -1 |
Loops over each .infobox container and yields the title and subtitle. | def infobox_each_link(html)
Nokogiri::HTML(html).css('.infobox').each do |infobox|
infobox_body = infobox.css('.infobox-body')
title_link = infobox_body.css('h3 a').text.strip
subtitle_link = infobox_body.css('p a').first
subtitle_link = subtitle_link.text.strip if subtitle_link
yield(title_link, subtitle_link)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infobox\n infoboxes.first\n end",
"def print_info(info)\n bio = []\n committees = []\n info.each do |li|\n if li.include?(\"ommittee\")\n committees << li\n else\n bio << li\n end\n end\n puts \"---------------------- Personal Bio ----------------------\"\n bio.each do |li|\n puts li\n end\n puts \"\"\n puts \"------------------------ Committees ------------------------\"\n committees.each do |li|\n puts li\n end\n puts \"\"\n end",
"def printall\n $page.css('.oneRes').each do |play|\n puts \"#{play.css('.eventTitle').text}---#{play.css('.detail li a')[0].text}\"\n end\nend",
"def gallery_details(gallery)\n Scraper.scrape_idv_gallery(gallery) \n \n puts \"\"\n puts \"Here is more details about #{gallery.name.bold}.\".black.on_white\n puts \"\"\n puts \"Presenting Artist(s): #{gallery.artist_name.join(\" | \")} \"\n puts \"\"\n puts \"About the Gallery: #{gallery.info} \"\n puts \"\"\n \n end",
"def artist_details(artist)\n Scraper.scrape_individual_artist(artist) \n\n puts \"\"\n puts \"Here are more details about #{artist.name.bold}.\".black.on_light_white\n puts \"\"\n puts \"Representing Gallery: #{artist.gallery.name} \"\n puts \"\"\n puts \"Artist Bio: #{artist.bio}\"\n puts \"\"\n puts \"About the Artist : #{artist.about_art}\"\n puts \"\"\n\n end",
"def show_info\n @planets.each do |planet|\n planet.show_details\n end\n end",
"def print_out(print_info)\n line_width = 40\n \n puts print_info[0][0].center(line_width) #we print the title first\n \n print_info[1].each_with_index do |v,i| #we use each_with_index so that we can loop through each element in the sub-arrays\n print \"Chapter #{i + 1}: #{print_info[1][i].ljust(line_width/2)}\" #prints out the prefix \"Chapter#:\" and the names\n print \"Page #{print_info[2][i]}\".rjust(line_width/2) #prints out the \n print \"\\n\"\n end\n \n\nend",
"def infobox(text, height=0, width=0)\n command = %(--infobox \"#{text}\" #{height.to_i} #{width.to_i})\n call_and_capture command\n end",
"def print_albums_info albums\n\tsystem \"clear\" or system \"cls\"\n\tputs add_space(' Albums').colorize(:color => :white, :background => :blue)\n\ti = 0\n\twhile i < albums.length\n\t\talbum = albums[i]\n\t\tid = ' Album ID: ' + album.id.to_s\n\t\tgenre = ' -= ' + album.genre + ' =-'\n\t\ttitle = ' > ' + album.title + ' by ' + album.artist\n\t\tputs add_space(' ').colorize(:color => :black, :background => :white)\n\t\tputs add_space(id).colorize(:color => :black, :background => :white)\n\t\tputs add_space(genre).colorize(:color => :red, :background => :white)\n\t\tputs add_space(title).colorize(:color => :red, :background => :white)\n\t\ti+=1\n\tend\n\tread_string(\"Press ENTER to continue.... \")\n\tsystem \"clear\" or system \"cls\"\nend",
"def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend",
"def display_songs\n puts \"Your Discography\"\n songs.each do |song|\n puts \"* Artist: #{song.artist} - Song Name: #{song.title}\"\n end\n end",
"def display_info\n\t\tputs \"Total track number: #{@track_list.length}\"\n\t\tputs \"Total artist number: #{@artist_list.length}\"\n\t\tputs \"Last three played track:\"\n\t\t@last_played.each do |last_played_track|\n puts \"------------ Track Info -------------\"\n\t\t\tputs \"#{last_played_track.to_s}\"\n\t\tend\n\tend",
"def box_info\n @subclasses = Registry.all(:puppet_class).find_all do |c|\n c.statement.parent_class == object.name.to_s\n end\n erb(:box_info)\nend",
"def infobox(msg, title, height = 5, width = 40)\n @dialog.title = \"\\\"#{title}\\\"\"\n @dialog.infobox(\"\\n\" + msg, height, width)\nend",
"def top_containers\n container_information.select do |container|\n container[\"label\"].to_s.downcase.include?(\"box\") || container[\"profile\"].include?(\"OS folder\")\n end\n end",
"def info\n title + \" (\" + genotype_info + ' / ' + phenotype_info + ')'\n end",
"def info(index)\n return @boxes[@current_box][index]\n end",
"def list_all_titles\n Anime.all.sort{|a,b| a.name <=> b.name}.each_with_index do |anime,i|\n puts \"#{i+1}. #{anime.name}\"\n end\n self.more_info\n end",
"def infobox(msg, title, height = 5, width = 40)\n @dialog.title = \"\\\"#{title}\\\"\"\n @dialog.infobox(\"\\n\" + msg, height, width)\n end",
"def build_info_box\n issue_date_present = [email protected]_date.empty?\n\n if issue_date_present\n @pdf.text_box(\n @labels[:issue_date],\n size: 11,\n at: [x(284), y(498) - @push_down],\n width: x(240)\n )\n @pdf.text_box(\n @document.issue_date,\n size: 13,\n at: [x(384), y(498) - @push_down],\n width: x(146),\n align: :right\n )\n\n if used? @labels[:sublabels][:issue_date]\n position = issue_date_present ? 483 : 498\n\n @pdf.text_box(\n @labels[:sublabels][:issue_date],\n size: 10,\n at: [x(284), y(position) - @push_down],\n width: x(240)\n )\n end\n end\n\n due_date_present = [email protected]_date.empty?\n\n if due_date_present\n position = issue_date_present ? 478 : 493\n position -= 10 if used? @labels[:sublabels][:issue_date]\n\n @pdf.text_box(\n @labels[:due_date],\n size: 11,\n at: [x(284), y(position) - @push_down],\n width: x(240)\n )\n @pdf.text_box(\n @document.due_date,\n size: 13,\n at: [x(384), y(position) - @push_down],\n width: x(146),\n align: :right\n )\n\n if used? @labels[:sublabels][:due_date]\n position = issue_date_present ? 463 : 478\n position -= 10 if used? @labels[:sublabels][:issue_date]\n\n @pdf.text_box(\n @labels[:sublabels][:due_date],\n size: 10,\n at: [x(284), y(position) - @push_down],\n width: x(240)\n )\n end\n end\n\n variable_symbol_present = [email protected]_symbol.empty?\n\n if variable_symbol_present\n position = (issue_date_present || due_date_present) ? 483 : 498\n position = issue_date_present && due_date_present ? 458 : 463\n position -= 10 if used? @labels[:sublabels][:issue_date]\n position -= 10 if used? @labels[:sublabels][:due_date]\n\n @pdf.text_box(\n @labels[:variable_symbol],\n size: 11,\n at: [x(284), y(position) - @push_down],\n width: x(240)\n )\n @pdf.text_box(\n @document.variable_symbol,\n size: 13,\n at: [x(384), y(position) - @push_down],\n width: x(146),\n align: :right\n )\n\n if used? @labels[:sublabels][:variable_symbol]\n position = issue_date_present ? 443 : 458\n position -= 10 if used? @labels[:sublabels][:issue_date]\n position -= 10 if used? @labels[:sublabels][:due_date]\n\n @pdf.text_box(\n @labels[:sublabels][:variable_symbol],\n size: 10,\n at: [x(284), y(position) - @push_down],\n width: x(240)\n )\n end\n end\n\n if issue_date_present || due_date_present || variable_symbol_present\n big_box = (issue_date_present && due_date_present && variable_symbol_present && info_box_sublabels_used?)\n height = (issue_date_present && due_date_present) ? 75 : 60\n height = big_box ? 110 : height\n height = @payment_box_height if @payment_box_height > height\n\n @pdf.stroke_rounded_rectangle([x(274), y(508) - @push_down], x(266), height, 6)\n @push_items_table += 23 if @push_items_table <= 18\n @push_items_table += 24 if big_box\n\n #@push_items_table += 30\n end\n end",
"def print_info_array(super_array)\n super_array.each do |sub_array|\n sub_array.each {|item| puts item}\n puts\n end\n end",
"def get_info\n puts \"#{@title} by #{@author} is #{@status}.\"\n if @description\n puts \"#{@title} description: #{@description}.\"\n end\n end",
"def info\n puts \"All stations:\"\n @stations.each.with_index(1) do |station|\n puts \"#{station.name}: \"\n station.show_trains(\"Cargo\")\n station.show_trains(\"Passenger\")\n end\n\n puts \"All routes:\"\n show_routes\n puts \"All trains:\"\n show_trains\n puts \"All wagons:\"\n show_wagons\n end",
"def display_book_info(book)\n puts \"*\" * 20\n puts \"\"\n puts \"Title: \" + book[\"volumeInfo\"][\"title\"]\n puts \"Snippet: \" + book[\"searchInfo\"][\"textSnippet\"]\n puts \"\"\nend",
"def print_info_do(members)\n members.each do |member|\n puts \"Name: #{member.name}\"\n puts \"Age: #{member.age}\"\n puts \"Sex: #{member.sex}\"\n puts \"Status: #{member.status}\"\n puts \"Children: #{member.children}\"\n puts \"-------------------------------------\"\n end\nend",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def process_info(dir)\n\t\t# info should be a subdir of the root course dir and contain markdown files\n\t\tinfo_dir = File.join(dir, 'info')\n\t\tif File.exist?(info_dir)\n\t\t\tinfo_page = Page.create(:title => \"Syllabus\", :position => 0, :path => 'info')\n\t\t\tprocess_subpages(info_dir, info_page)\n\t\tend\n\tend",
"def listinfo\n puts \"排名:#{@no}\"\n puts \"月份:#{@month}\" if @month\n puts \"标签: #{@subtag}\" if @subtag\n puts \"标题:#{@title}\"\n puts \"集数:#{@episode}\" if @episode\n puts \"链接:#{@link}\"\n puts \"<bilibili独家哟!>\" if @bilibilionly_flag\n puts \"--------------------\"\n end",
"def info_content\n\n info = []\n info << \"<b>\" + @place[:title].escape_html + \"</b>\"\n unless $params.election_description.empty?\n info << \"<i>\" + $params.election_description.escape_html + \"</i>\"\n info << \"\"\n end\n\n a = \"#{@place[:name]}, #{@place[:street]}, #{@place[:city]}, #{@place[:state]} #{@place[:zip]}\"\n info << \"<a href=\\\"http://maps.google.com/?daddr=#{a.escape_uri}\\\" target=\\\"_blank\\\">#{@place[:name].escape_html}</a>\"\n info << @place[:street].escape_html\n info << \"#{@place[:city]}, #{@place[:state]} #{@place[:zip]}\".escape_html\n info << \"\"\n info << \"Hours of operation:\"\n info += @place[:schedule_formatted].escape_html.split(\"\\n\").map {|s| \"\\u2022 \" + s}\n unless @place[:notes].empty?\n info << \"\"\n info << @place[:notes].escape_html\n end\n unless $params.election_info.empty?\n info << \"\"\n info << $params.election_info\n end\n info.join(\"\\n\")\n end",
"def show_divs\r\n divs = Document.new(self).get_divs\r\n puts \"There are #{divs.length} divs\"\r\n index = 1\r\n divs.each do |l|\r\n puts \"div: name: #{l.name}\"\r\n puts \" id: #{l.id}\"\r\n puts \" class: #{l.className}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end",
"def display_all_book_info(books)\n books.each { |book| display_book_info(book) }\nend",
"def get_detailed_info(html)\n result = {}\n page = Nokogiri::HTML(html)\n result[:img] = extract_image(page)\n # No easy identifiers, so get where the section starts, where the next section starts, and look at all tables in between\n # TODO: Use XPath to use less code\n start_elem = page.css('span.mw-headline[id^=\"Persona_3\"]').last\n elem = start_elem.parent.next\n until elem.name == 'h3' || elem.name == 'h2' || elem.nil? # Reached next game, next section or EOF\n if elem.name == 'table'\n result.merge!(extract_table_info elem)\n elsif elem.name == 'div' && elem[:class] =~ /tabber/\n elem.css('.tabbertab > table').each do |table|\n result.merge!(extract_table_info table)\n end\n end\n\n elem = elem.next\n end\n\n result\n end",
"def print_hike_info(hike_array)\n hike_array.each do |hike_instance|\n hike_instance.print_info\n 15.times {print \"*\"}\n print \"\\n\"\n end\n end",
"def print_details()\n\t$details.each {|k, v| puts \"#{k}: #{v}\"}\nend",
"def basic_info_data\n hash = {}\n target_div = self.div(:class=>\"s3d-contentpage-title\", :text=>\"Basic Information\").parent.parent.div(:id=>\"displayprofilesection_body\")\n target_div.divs(:class=>\"displayprofilesection_field\").each { |div| hash.store(div.span(:class=>\"s3d-input-label\").text, div.span(:class=>\"field_value\").text) }\n return hash\n end",
"def print_info\n puts \"#{ @name } is the #{ @position } planet from the sun.\\nIt is a #{ @type } planet that is #{ @diameter } miles wide.\\n#{ @name } has #{ @moons } moons.\"\n end",
"def metadata_each\n rhGet(ForjDefault.dump(), :sections).each { | section, hValue |\n next if section == :default\n hValue.each { | key, value |\n yield section, key, value\n }\n }\n end",
"def homes_info(homes)\n homes.each do |hm|\n puts \"#{hm.name} is in #{hm.city}\"\n puts \"Price: $#{hm.price} a night.\"\n end\nend",
"def get_book_content\n\n get_book_name\n\n @bookRootObj.xpath(\"//paras\").children.each do |child|\n\n if child.name == \"p\" then\n get_p_info child\n elsif child.name == \"mp\" then\n get_mp_info child\n else\n #raise StandardError, \"Can't get this tag <#{child.name}>.\"\n end\n end\n end",
"def print_info\n\n puts \"\\e[H\\e[2J\" # clear terminal screen\n\n # print the listing title\n print \"#{@@white}Job Title: #{@@green}#{self.title}\\n\"\n\n\n # print the time left to bid\n print \"\\t#{@@white}Time Left: #{@@green}#{self.time_left}\\n\"\n\n # print the budget for the job if valid\n if self.budget\n print \"\\t#{@@white}Budget: #{@@green}#{self.budget}\\n\"\n end\n\n # print the tags associated with the listing\n print \"\\t#{@@white}Tags: #{@@green}#{self.tags.join(',')}\\n\"\n\n # print the number of bids if valid\n if self.bids\n print \"\\n\\t#{@@white}Bids: #{@@green}#{self.bids}\\n\"\n end\n\n # print the average bid if valid\n if self.avg_bid\n print \"\\t#{@@white}Average Bid: #{@@green}#{self.avg_bid}\\n\"\n end\n\n # display the summary of bids at the momment\n print \"\\t#{@@white}Bid Summary: #{@@green}#{self.bid_summary}\\n\" if self.bid_summary\n\n # if we don't have the main description then print the short_description otherwise print the main description\n print \"\\t#{@@white}Description: \\n#{@@green}\"\n if self.description == nil\n # print \"#{self.short_description}\\n\\n\".green # put a .each_line block here and add \\t\\t to space it out properly\n desc = self.short_description\n else\n # print \"#{self.description}\\n\\n\".green\n desc = self.description\n end\n\n # fix the formating issues by indenting each line with tabs twice\n desc.each_line {|line| print \"\\t\\t#{@@green}#{line}\\n\"}\n\n print \"#{@@reset}\"\n end",
"def popup_info(title, text)\n dialog = Gtk::MessageDialog.new(\n @window,\n Gtk::Dialog::MODAL,\n Gtk::MessageDialog::INFO,\n Gtk::MessageDialog::BUTTONS_OK,\n text\n )\n dialog.title = title\n dialog.run\n dialog.destroy\n end",
"def boxify(page, _site)\n return if page.content.nil?\n\n lang = page['lang'] || 'en'\n\n # Interim solution, fancier box titles\n # rubocop:disable Layout/LineLength\n page.content = page.content.gsub(%r{<(?<boxclass>#{Gtn::Boxify.box_classes})-title( ?(?<noprefix>noprefix))>(?<title>.*?)</\\s*\\k<boxclass>-title\\s*>}) do\n # rubocop:enable Layout/LineLength\n m = ::Regexp.last_match\n box_type = m[:boxclass]\n title = m[:title]\n noprefix = m[:noprefix]\n if page.data['citation_target'] == 'jupyter'\n title = Gtn::Boxify.safe_title(title)\n title = Gtn::Boxify.format_box_title(title, box_type, lang, noprefix: noprefix)\n icon = Gtn::Boxify.get_icon(box_type, emoji: true)\n box = \"<div class=\\\"box-title\\\" aria-description=\\\"#{box_type} box: \" \\\n \"#{title}\\\" style=\\\"font-size: 150%\\\">#{icon} #{title}</div>\"\n box.gsub!(/\\\\"/, '"')\n box.gsub!(/([^\\\\])\"/, '\\1\\\\\"')\n else\n _, box = Gtn::Boxify.generate_title(box_type, title, lang, page.path, noprefix: noprefix)\n end\n\n box\n end\n\n # Long term solution, proper new boxes\n # BUT: does not work with <details></details> that are actual HTML elements, so we'll need to rename those.\n # page.content = page.content.gsub(/<(#{Gtn::Boxify.box_classes})>/) {\n # box_type = $1\n # box = Gtn::Boxify.generate_box(box_type, nil, lang, page.path)\n # box\n # }\n\n # page.content = page.content.gsub(/<(#{Gtn::Boxify.box_classes}) title=\"([^\"]*)\">/) {\n # box_type = $1\n # title = $2\n # box = Gtn::Boxify.generate_box(box_type, title, lang, page.path)\n # box\n # }\n\n # page.content = page.content.gsub(/<\\/\\s*(#{Gtn::Boxify::box_classes})\\s*>/) {\n # box_type = $1\n # \"\\n</div></div><!--#{box_type}-->\"\n # }\n end",
"def info_window; @info_window; end",
"def page_metadata(page)\n data = []\n add_data = Proc.new do |content|\n data.push(content_tag(:div, content))\n end\n \n filing = page.filing\n doc = page.filing_doc\n\n [[\"Filing: #{filing.fcc_num}\", fcc_filing_url(filing)],\n [\"Document: #{doc.fcc_num}\", doc.url]].each do |args|\n add_data[link_to(*args)]\n end\n\n add_data[\"Pages: #{doc.pagecount}\"] \n\n %w(author lawfirm applicant).each do |name|\n if (value = filing.send(name)).present?\n add_data[\"#{name.titleize}: #{value}\"]\n end\n end\n\n data.join(\"\\n\").html_safe\n end",
"def get_all_info\n\t\tpage = fetch\n\t\tscrape(page)\n\tend",
"def all_info(the_planet_i_care_about)\n return @planets.each do |each_planet_in_my_solar_system|\n if each_planet_in_my_solar_system.name == the_planet_i_care_about\n puts each_planet_in_my_solar_system.info\n end\n end\n end",
"def print_tips\n tips.each { |key, value| print \"Tip #{key}: #{value}\" }\nend",
"def print_songs\n self.songs.each.do |song|\n puts song.name\n end",
"def print_titles(books)\n books.each do |book|\n puts get_title(book)\n end\nend",
"def info\n container.info\n end",
"def show_pasta\n @nameP.each do |pastaType|\n puts \"- #{pastaType}\"\n end\n end",
"def title\n @info[:Title]\n end",
"def print_stats(title_array)\n # some iteration magic and puts out the movies in a nice list\n title_array.each do |title|\n puts \"#{title}\\n\"\n puts\"*****************\\n\"\n end\nend",
"def display_planet_list\n puts \"Here are the current planets in our solar system:\"\n @all_planets.each do |planet_info|\n puts planet_info.name\n end\n end",
"def add_info\n UpcomingReleases::Album.all.each do |album|\n info = UpcomingReleases::Scraper.scrape_info_page(ALBUM_URL + album.info_url)\n album.add_album_info(info)\n end\n end",
"def printcat(cat)\n list = $page.css('.oneRes').select{|play| play.css('.detail li a')[1].text == cat}\n list.each do |play|\n puts \"#{play.css('.eventTitle').text}---#{play.css('.detail li a')[0].text}\"\n end\nend",
"def output_details(files) \n @stdout.puts\n @stdout.puts \"Details\".bold\n files.each do |t|\n fname = t.path\n @stdout.puts \"File: %s\" % [((t.status == FileData::STATUS_OK) ? fname : fname.red)]\n @stdout.puts \"Includes: %s\" % [format_fds(t.includes)] unless t.includes.empty?\n @stdout.puts \"Included by: %s\" % [format_fds(t.included_by)] unless t.included_by.empty?\n @stdout.puts \"References: %s\" % [format_fds(t.references)] unless t.references.empty?\n @stdout.puts \"Referenced by: %s\" % [format_fds(t.referenced_by)] unless t.referenced_by.empty?\n unless t.status == FileData::STATUS_NOT_FOUND\n # show that part only if file exists\n @stdout.puts \"Size: %s (%d)\" % [format_size(t.size),t.size]\n if (t.docbook)\n @stdout.puts \"Type: DocBook, Version #{t.version}, Tag: #{t.tag}\"\n else\n @stdout.puts \"MIME: #{val_s(t.mime)}\"\n end\n @stdout.puts \"Timestamp: %s\" % [t.ts]\n @stdout.puts \"SHA1: %s\" % [t.checksum]\n end\n @stdout.puts \"Error: %s\" % [t.error_string.to_s.red] unless (t.error_string.nil?) \n @stdout.puts\n end\n end",
"def children\n TkWinfo.children(content)\n end",
"def display_each\n puts \" * #{self.experience} experience at #{self.company_name}\"\n end",
"def print_movies(films)\n # some iteration magic and puts out the movies in a nice list\n counter = 1\n puts\n puts\n puts \"List of Film Titles\"\n puts \"===================\"\n\n title_array = films.map do |film_hash|\n film_hash[\"title\"]\n end\n title_array.each do |title_string|\n puts \"#{counter}. #{title_string}\"\n counter += 1\n end\nend",
"def pilot_info\n @pilot_list.each do |pilot|\n puts pilot.info\n end\n end",
"def message_detail\n @archive.series.each do |series|\n titles = series.webpage.parser.xpath(\"//div[@id='series_title']/ul/li\")\n .map {|e| e.children.text }\n\n speakers = series.webpage.parser.xpath(\"//div[@id='series_speaker']/ul/li\")\n .map {|e| e.children.text}\n\n campuses = series.webpage.parser.xpath(\"//div[@id='series_campus']/ul/li\")\n .map {|e| e.children.text}\n\n videos = series.webpage.parser.xpath(\"//div[@id='series_video']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n audios = series.webpage.parser.xpath(\"//div[@id='series_audio']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n notes = series.webpage.parser.xpath(\"//div[@id='series_notes']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n #array indexen\n t = s = c = v = a = n = 1;\n lt = ls = lc = 1;\n\n series.sermons.each do |sermon|\n sermon.messages.each do |message|\n lt = t if titles[t] != ''\n ls = s if speakers[s] != ''\n lc = c if campuses[c] != ''\n\n message.title = titles[lt]\n message.speaker = speakers[ls]\n message.video = videos[v]\n message.audio = audios[a]\n message.notes = notes[n]\n message.campus = campuses[c]\n\n t += 1; s += 1; c += 1; v += 1; a += 1; n+=1;\n end\n end\n\n end\n end",
"def opening_reminder()\n @list_reminder = YAML.load(File.read(\"@list_reminder.yml\"))\n @list_reminder.each do |element|\n box = TTY::Box.frame(width: 30, height: 10, align: :center, padding: 3, title: {top_left: \"NOTES\",\n bottom_right: 'wilson® v1.0'}, style: {fg: :bright_yellow, bg: :blue, border: {fg: :bright_yellow,\n bg: :blue}}) do \"#{element}\"\n end \n print box \n \n end\n end",
"def get_item_general_info(page, da_container)\n #get td item that contains detail general info\n tds = da_container.search('td')\n \n item_general_info = {}\n \n item_general_info[:info_url] = get_info_url(page, tds)\n item_general_info[:council_reference] = get_council_reference(tds)\n item_general_info[:comment_url] = get_comment_url(tds)\n item_general_info[:address] = get_address(tds)\n item_general_info[:description] = get_description(tds)\n item_general_info[:date_received] = get_date_received(tds)\n item_general_info[:date_scraped] = get_date_scraped\n \n return item_general_info\nend",
"def get_item_general_info(page, da_container)\n #get td item that contains detail general info\n tds = da_container.search('td')\n \n item_general_info = {}\n \n item_general_info[:info_url] = get_info_url(page, tds)\n item_general_info[:council_reference] = get_council_reference(tds)\n item_general_info[:comment_url] = get_comment_url(tds)\n item_general_info[:address] = get_address(tds)\n item_general_info[:description] = get_description(tds)\n item_general_info[:date_received] = get_date_received(tds)\n item_general_info[:date_scraped] = get_date_scraped\n \n return item_general_info\nend",
"def metadata (root, info)\n info = decode_strings(info)\n\n # may be useful to some people\n callback(:pdf_version, @xref.pdf_version)\n\n # ye olde metadata\n callback(:metadata, [info]) if info\n\n # new style xml metadata\n if root[:Metadata]\n stream = @xref.object(root[:Metadata])\n callback(:xml_metadata,stream.unfiltered_data)\n end\n\n # page count\n if (pages = @xref.object(root[:Pages]))\n if (count = @xref.object(pages[:Count]))\n callback(:page_count, count.to_i)\n end\n end\n end",
"def print_student_job_listings jobs\n puts \"Available student jobs: #{jobs.count}\"\n jobs.each_with_index do |info, i|\n puts \"Job listing #{i + 1}\"\n puts 'Title: ' + info[:title]\n puts 'Employer: ' + info[:employer]\n puts 'Pay: ' + info[:pay]\n puts 'Job Duration: ' + info[:duration]\n puts 'Hours: ' + info[:hours]\n puts 'Description: ' + info[:desc]\n puts 'Additional information: ' + info[:link] + \"\\n\\n\"\n end\nend",
"def catdet; $ie.frame(:name, 'infoArea').frame(:name, 'detailArea').frame(:name, 'categDetail'); end",
"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 each_detail(&block)\n return if defined?(invoice_details).nil?\n\n invoice_details.each do |detail|\n block.call(detail[0], detail[1])\n end\n end",
"def display_titles\n Anime.all.each do |movie|\n puts \"#{movie.rank} - #{movie.title}\"\n puts \"--------------------------------\"\n end\n end",
"def display_collection_tag_info(tags_info:, num_tags:, tags_error:, tag_keys:)\n if num_tags == 0\n # there are no tags, or there was an issue retrieving the collection tag\n # information from cmr search (.json format) in which case we are displaying\n # a flash message\n content_tag(:p, 'There are no tags associated with this collection')\n elsif tags_error\n # we retrieved the collection's tag keys, but ran into an issue retrieving\n # further tag information, so we can display the tag keys but no more\n content_tag(:div) do\n concat(content_tag(:div, \"There was an error retrieving Tag information: #{tags_error}\", class: 'eui-banner--danger'))\n\n concat(content_tag(:ul) do\n tag_keys.each do |tag_key|\n concat(content_tag(:p) do\n concat(content_tag(:li) do\n concat(content_tag(:strong, 'Tag Key: '))\n concat(content_tag(:span, tag_key))\n end)\n concat(content_tag(:li) do\n concat(content_tag(:strong, 'Description: '))\n concat(content_tag(:span, 'Not retrieved'))\n end)\n end)\n end\n end)\n end\n else\n content_tag(:ul) do\n tags_info.each do |tag|\n concat(content_tag(:p) do\n concat(content_tag(:li) do\n concat(content_tag(:strong, 'Tag Key: '))\n concat(content_tag(:span, tag.fetch('tag_key', 'Not found')))\n end)\n concat(content_tag(:li) do\n concat(content_tag(:strong, 'Description: '))\n # If there is no description, the response can hold '' so fetch is\n # not sufficient\n description = tag.fetch('description', '')\n description = 'Not provided' if description.blank?\n concat(content_tag(:span, description))\n end)\n end)\n end\n end\n end\n end",
"def infobox(text, height=0, width=0)\n\t\tcommand = option_string() + \"--infobox \\\"\" + text.to_s +\n \"\\\" \" + height.to_i.to_s + \" \" + width.to_i.to_s + \" \"\n\t\tsuccess = system(command)\n\t\treturn success\n\tend",
"def print_songs\n songs.each do |song|\n puts song.name\n end\n end",
"def print_songs\n songs.each do |song|\n puts song.name\n end\n end",
"def print_songs\n @songs.each do |song|\n puts song.name\n end \n end",
"def pagy_info(pagy, vars=nil)\n name = vars && vars[:item_name] || pagy_t(pagy.opts[:i18n_key] || 'pagy.info.item'.freeze, count: pagy.count)\n name = pagy_t('pagy.info.item'.freeze, count: pagy.count) if name.start_with?('translation missing:'.freeze)\n key = pagy.pages == 1 ? 'single_page'.freeze : 'multiple_pages'.freeze\n pagy_t \"pagy.info.#{key}\", item_name: name, count: pagy.count, from: pagy.from, to: pagy.to\n end",
"def show_info\n \"\n Title: #{title}\n URL: #{url}\n points: #{points}\n item ID: #{item_id}\n \"\n end",
"def salon_info\n puts HEADER_LINE\n puts \"#{@name.upcase}\".center(HEADER_LENGTH)\n puts HEADER_LINE\n contact_info\n puts\n puts \" #{@about}\"\n puts HEADER_LINE\n end",
"def displayInfo(text)\n puts \"( - ) #{text}\"\n end",
"def info\n o = \"You find yourself #{@name.bold}.\"\n o << \" #{@description}\" if @description.unblank?\n o << \"\\n\" << items_here if @items.unblank?\n o << \"\\nExits are #{exits.to_sentence(:bold => true)}.\" if exits.unblank?\n o\n end",
"def info(*objects)\n tag_log(:info, :to_s, *objects)\n end",
"def scrobble_info(scrobble)\n artist = scrobble.at_css(@options['artist_selector'])\n track = scrobble.at_css(@options['track_selector'])\n scrobbled_at = scrobble.at_css(@options['scrobbled_at_selector'])\n {\n artist: artist.content.strip,\n track: track.content.strip,\n scrobbled_at: scrobbled_at.content.strip\n }\n end",
"def disp_animals\n @animals.each do |animal|\n puts \"Name: #{animal.name}\"\n puts \"Species: #{animal.species}\"\n end\n end",
"def get_more_info\n div_css = '#productDetails'\n str = page.evaluate_script(\"$(\\\"#{div_css}\\\").parent().html();\")\n html_doc = Nokogiri::HTML(str.gsub('<br>', ' '))\n\n # Get more info label\n moreinfo_lb = html_doc.css('.credits-link>.text').text\n\n # Get more info text\n moreinfo_txt = html_doc.css('#credits').text\n\n { moreinfo_lb: moreinfo_lb, moreinfo_txt: moreinfo_txt }\n end",
"def print_songs\n @songs.each do |song|\n puts song.name\n end\n end",
"def print_songs \n songs.each {|song| puts song.name}\n end",
"def display_albums(margin, box_height, bar_width)\n spacing = 0\n spacing_add = box_height + margin\n i = @page\n while i < @viewable_albums + @page\n display_album(@data_array[i].title, spacing, box_height, margin, bar_width, PRIMARY, \"album_button_#{i}\",i) rescue nil\n spacing += spacing_add\n i += 1\n end\nend",
"def print_info_each_student\n list_cohorts\n @cohorts.each do |cohort|\n puts \"\\nStudents in the #{cohort} cohort\\n\".center(50)\n @students.each_with_index do |student_info, index|\n if cohort == student_info[:cohort]\n puts \"#{index+1}. #{student_info[:name]}\".center(50)\n plural = \"s\" if student_info[:pronoun] != \"they\"\n puts \"#{student_info[:name]} is #{student_info[:height]} tall, was born in #{student_info[:country]} and #{student_info[:pronoun]} like#{plural} #{student_info[:hobbies]}.\"\n end\n end\n end\nend",
"def print_streaminfo\n # No test: METADATA_BLOCK_STREAMINFO must be present in valid Flac file\n @streaminfo.each_pair { |key,val| puts \"#{key}: #{val}\" }\n nil\n end",
"def print_songs\n songs.each do |song|\n print song.name + \"\\n\"\nend \nend",
"def process_output\n\tcounter = 1\n\t\t@parsed[\"businesses\"].each do |x|\n\t\t\tputs \"#{counter} Name: \" + x[\"name\"] + \" Rating:\" + x[\"rating\"].to_s\n\t\t\tcounter +=1 \n\t\tend\n\tend",
"def hotel_info\n puts HEADER_LINE\n puts \"#{@name.upcase}\".center(HEADER_LENGTH)\n puts HEADER_LINE\n puts\n contact_info\n puts\n puts HEADER_LINE\n puts\n puts \" #{@about}\"\n puts\n puts HEADER_LINE\n end",
"def summary(info)\n\treturn info[\"currently\"][\"summary\"]\nend",
"def print_songs\n songs.each {|song| puts song.name}\n end",
"def icebox\n get_stories_by_iteration(\"icebox\")\n end",
"def section(title)\n puts \"===== #{title} =====\" if @display_headers\n yield\n puts if @display_headers\nend",
"def print_songs\n self.songs.each{|song|\n puts song.name\n }\n end",
"def print_employee_data\n\n # Define positions.\n box_offsets = [[0, 0], [4.25, 0], [0, -5.5], [4.25, -5.5]]\n starting_x = 0.25\n starting_y = 10.75\n\n # Draw text for each position.\n box_offsets.each do |o|\n box_x = starting_x + o[0]\n box_y = starting_y + o[1]\n print_employee_data_box(box_x, box_y)\n end\n\n end",
"def each_pokemon\n @boxes.each do |box|\n box.each do |pokemon|\n yield(pokemon) if pokemon\n end\n end\n end"
] | [
"0.56834084",
"0.5539195",
"0.540508",
"0.53586096",
"0.5356067",
"0.5336224",
"0.5262764",
"0.5255277",
"0.5218763",
"0.52040935",
"0.5201281",
"0.5191843",
"0.51775026",
"0.5132716",
"0.5117383",
"0.510193",
"0.5070635",
"0.5040298",
"0.50319785",
"0.50212955",
"0.50076014",
"0.5005043",
"0.500273",
"0.49753818",
"0.49691427",
"0.49633822",
"0.49630216",
"0.4949983",
"0.49308077",
"0.4924162",
"0.49209926",
"0.49093708",
"0.48467803",
"0.48450577",
"0.484443",
"0.48245257",
"0.482097",
"0.48186457",
"0.48088357",
"0.48077816",
"0.4801019",
"0.4792309",
"0.4775577",
"0.47582403",
"0.47572666",
"0.47547346",
"0.4750003",
"0.4747598",
"0.47449902",
"0.4743001",
"0.47388",
"0.47322837",
"0.47314045",
"0.47183117",
"0.47076777",
"0.47072563",
"0.470485",
"0.4673422",
"0.46706685",
"0.4661924",
"0.46560705",
"0.46543786",
"0.46536383",
"0.4649129",
"0.4649129",
"0.4637573",
"0.46374634",
"0.46346688",
"0.4634307",
"0.4633754",
"0.46304414",
"0.46282205",
"0.46210676",
"0.46182874",
"0.46182874",
"0.46125695",
"0.46087846",
"0.46028003",
"0.46017748",
"0.45989743",
"0.45906812",
"0.45890322",
"0.45857325",
"0.45855445",
"0.45794928",
"0.45784158",
"0.45720437",
"0.45686975",
"0.45673898",
"0.45664674",
"0.45616192",
"0.4553539",
"0.45528236",
"0.4550697",
"0.45491385",
"0.45470566",
"0.45461613",
"0.4545662",
"0.45433477",
"0.45394635"
] | 0.7267246 | 0 |
Loops over each .doublelink container and yields the title and subtitle. Encountered on mobile pages. | def doublelink_each_link(html)
Nokogiri::HTML(html).css('.double-link').each do |doublelink|
title_link = doublelink.css('.media__bd__header').text.strip
subtitle_link = doublelink.css('.media__bd__subheader').text.strip
yield(title_link, subtitle_link)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_video_page_urls(webpage,options)\r\n puts \"Extracting data from html5 data\"\r\n webpage.css('li.regularitem').each do |post|\r\n link = post.css('h4.itemtitle').css('a').first\r\n description = post.css('div.itemcontent').first.text\r\n download_episode(link.child.text,link['href'],description, options)\r\n end\r\nend",
"def infobox_each_link(html)\n Nokogiri::HTML(html).css('.infobox').each do |infobox|\n infobox_body = infobox.css('.infobox-body')\n\n title_link = infobox_body.css('h3 a').text.strip\n subtitle_link = infobox_body.css('p a').first\n subtitle_link = subtitle_link.text.strip if subtitle_link\n\n yield(title_link, subtitle_link)\n end\n end",
"def printall\n $page.css('.oneRes').each do |play|\n puts \"#{play.css('.eventTitle').text}---#{play.css('.detail li a')[0].text}\"\n end\nend",
"def extract_links(reddit_page)\n @music = {}\n reddit_page['data']['children'].each do |item|\n data = item['data'] if !item['data'].nil?\n media = data['media'] if !data['media'].nil?\n oembed = media['oembed'] if !media.nil? and !media['oembed'].nil?\n\n # CAUTION -- CONTINUE HERE IF OEMBED IS NULL\n # otherwise have to catch in every statement\n if oembed.nil?\n next\n end\n\n oembed['title'] = HTMLEntities.new().decode(oembed['title'])\n\n # Youtube\n if data['domain'] == 'youtube.com' and !oembed['url'].nil?\n # @music[oembed['title']] = {url:oembed['url'], reddit:data['permalink']}\n yt_url = oembed['url']\n yt_id = yt_url.match(/v=.{11}/)[0][2, yt_url.length]\n @music[oembed['title']] = {ytid:yt_id, url:yt_url, reddit:data['permalink']}\n\n # Soundcloud\n elsif data['domain'] == 'soundcloud.com'\n @music[oembed['title']] = {url:data['url'], reddit:data['permalink']}\n end\n end\n\n last_id = reddit_page['data']['after']\n # puts last_id\n return @music, last_id\nend",
"def message_detail\n @archive.series.each do |series|\n titles = series.webpage.parser.xpath(\"//div[@id='series_title']/ul/li\")\n .map {|e| e.children.text }\n\n speakers = series.webpage.parser.xpath(\"//div[@id='series_speaker']/ul/li\")\n .map {|e| e.children.text}\n\n campuses = series.webpage.parser.xpath(\"//div[@id='series_campus']/ul/li\")\n .map {|e| e.children.text}\n\n videos = series.webpage.parser.xpath(\"//div[@id='series_video']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n audios = series.webpage.parser.xpath(\"//div[@id='series_audio']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n notes = series.webpage.parser.xpath(\"//div[@id='series_notes']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n #array indexen\n t = s = c = v = a = n = 1;\n lt = ls = lc = 1;\n\n series.sermons.each do |sermon|\n sermon.messages.each do |message|\n lt = t if titles[t] != ''\n ls = s if speakers[s] != ''\n lc = c if campuses[c] != ''\n\n message.title = titles[lt]\n message.speaker = speakers[ls]\n message.video = videos[v]\n message.audio = audios[a]\n message.notes = notes[n]\n message.campus = campuses[c]\n\n t += 1; s += 1; c += 1; v += 1; a += 1; n+=1;\n end\n end\n\n end\n end",
"def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('.zone_B_with_ads')\n allUrl = links.css('div.tile__content a.tile__read_more').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n #puts i\n end\nend",
"def related_content\n list = []\n self.div(:class=>\"relatedcontent_list\").links.each do |link|\n list << link.title\n end\n return list\n end",
"def links\n return unless success? and body\n\n doc = Nokogiri::HTML(@body)\n \n links = []\n\n doc.css('div.list-lbc a').each do |a|\n link = {\n :url => a['href'],\n :title => a.css('div.title').first.content.strip\n }\n\n link[:ad_id] = link[:url][/^http:\\/\\/www.leboncoin.fr\\/locations\\/(\\d+).*/,1]\n links << link\n yield link if block_given?\n end\n\n links\n end",
"def scrape_detail\n self.doc = Scrapable::Helpers.parse detail_url\n self.class.attributes.each do |attribute,id|\n if id['anchor'] # substring\n self[attribute] = doc.at_css('#' + id).andand[:href]\n else\n self[attribute] = doc.at_css('#' + id).andand.text.andand.sub(/\\A[[:space:]]+\\z/, '')\n end\n end\n end",
"def get_titles()\n $result = ''\n while $i < 3 do\n result+= @driver.find_element(:xpath => '//*[@id=\"layout\"]/div[2]/div[2]/div/div/div/section['+ $i +']/job-tile-responsive/div[1]/div[1]/h4/a').text\n end\n return result\n end",
"def link_titles(title_link_arr)\n result=[]\n titles_and_links = title_link_arr\n titles_and_links.each do |x|\n result << link_title(x)\n end\n result\n end",
"def scrape_appended_links\n File.open('Vanguard News.txt', 'w') do |f|\n f.write Time.now.to_s + \"\\n\"\n @vanguard_links.each do |single_page|\n new_link = HTTParty.get(single_page)\n document = Nokogiri::HTML(new_link.body)\n stop_value_index = document.css('p').find_index { |p| p.text.include?(@stop_sign) }\n # pry.bindings\n f.write '*************************' + \"\\n\"\n f.write document.css('.entry-title').first.text.upcase + \"\\n\"\n f.write document.css('p')[1..(stop_value_index - 1)].text + \"\\n\"\n f.write '*************************' + \"\\n\"\n end\n end\n end",
"def get_position_links\n # Get all links that have the text: \"View Details\"\n links = @page.links_with(:text => /View Details/)\n href_links = []\n # convert all links into an appropriate html link\n links.each { |link| href_links << 'https://www.jobsatosu.com' + link.href }\n href_links\n end",
"def scrape_and_look_for_next_link(url)\n i = 0;\n page = Nokogiri::HTML(open(url))\n counties = scrape_timesbycounty(page)\n counties.collect do |county| \n if county \n county_url = BASE_URL + URI.escape(county['href'])\n areapage = Nokogiri::HTML(open(county_url))\n churches = scrape_area(areapage)\n churches.collect do |church| \n if church \n church_url = BASE_URL + URI.escape(church['href'])\n masstimes = Nokogiri::HTML(open(church_url))\n times = scrape_masstimes(masstimes)\n puts \"------------------------------------------\"\n puts \"county = \" +county.inner_text.strip\n puts \"church = \" +church.inner_text.strip\n puts \"times = \" +times.map { |str| \"'\" + str.to_s + \"'\" }.join(\",\")\n puts \"------------------------------------------\" \n i+=1\n record = {}\n record['ID'] = i \n record['County'] = county.inner_text.strip \n record['Church'] = church.inner_text.strip \n record['Times'] = times.map { |str| \"'\" + str.to_s + \"'\" }.join(\",\") \n ScraperWiki.save([\"ID\"], record)\n end\n end\n end\n end\nend",
"def scrape_and_look_for_next_link(url)\n i = 0;\n page = Nokogiri::HTML(open(url))\n counties = scrape_timesbycounty(page)\n counties.collect do |county| \n if county \n county_url = BASE_URL + URI.escape(county['href'])\n areapage = Nokogiri::HTML(open(county_url))\n churches = scrape_area(areapage)\n churches.collect do |church| \n if church \n church_url = BASE_URL + URI.escape(church['href'])\n masstimes = Nokogiri::HTML(open(church_url))\n times = scrape_masstimes(masstimes)\n puts \"------------------------------------------\"\n puts \"county = \" +county.inner_text.strip\n puts \"church = \" +church.inner_text.strip\n puts \"times = \" +times.map { |str| \"'\" + str.to_s + \"'\" }.join(\",\")\n puts \"------------------------------------------\" \n i+=1\n record = {}\n record['ID'] = i \n record['County'] = county.inner_text.strip \n record['Church'] = church.inner_text.strip \n record['Times'] = times.map { |str| \"'\" + str.to_s + \"'\" }.join(\",\") \n ScraperWiki.save([\"ID\"], record)\n end\n end\n end\n end\nend",
"def maybe_item_thumb_links\n maybe_column.links(:class => \"img\", :href => /.*/) # ---------------------------------- EVERYTHING USING THIS NEEDS REPLACING!!!!!!!!\n end",
"def featured_content_list\n list = []\n self.div(:id=>\"featuredcontent_content_container\").links(:class=>/featuredcontent_content_title/).each do |link|\n list << link.text\n end\n return list\n end",
"def retrieve_links(query, page = 1)\n\t\tyoutube = Nokogiri::HTML(open(URI.encode(\"#{self.query_url}#{query}&page=#{page}\")))\n\t\tself.stats = retrieve_youtube_result_stats(youtube, query)\n\t\t(youtube/\"h3[@id^='video-long-title-']/a\").each do |res|\t\t\t\t\t\t\t# 'a' tag has id which starts with \"video-long-title-\"\n\t\t\turl = res['href']\n\t\t\tdescription = res.inner_text\n\t\t\tvideo_id = url.split('=').last\t\t\t\t\t\t\t\t\t\t\t\t# /watch?v=WwojCsQ3Fa8 => WwojCsQ3Fa8 => video_id\n\t\t\tthumb_url = \"http://i4.ytimg.com/vi/#{video_id}/default.jpg\"\n\t\t\tself.links << ThumbnailedLink.new(\"#{self.base_url}#{url}\", description, thumb_url, self.name)\n\t\tend\n\t\tself.links\n\tend",
"def get_embed_link_meta(work)\n chapters_text = ts(\"Chapters: \") + work.chapter_total_display + tag(\"br\")\n fandom_text = add_label_for_embed(ts(\"Fandom: \"), work.fandoms.map {|fandom| link_to fandom.name, tag_url(fandom)}.join(', ').html_safe, tag(\"br\"))\n rating_text = add_label_for_embed(ts(\"Rating: \"), work.ratings.map {|rating| rating.name}.join(', '), tag(\"br\"))\n warning_text = add_label_for_embed(ts(\"Warnings: \"), work.warnings.map {|warning| warning_display_name(warning.name)}.join(', '), tag(\"br\"))\n relationship_text = add_label_for_embed(ts(\"Relationships: \"), work.relationships.map {|rel| rel.name}.join(', '), tag(\"br\"))\n char_text = add_label_for_embed(ts(\"Characters: \"), work.characters.map {|char| char.name}.join(', '), tag(\"br\"))\n tags_text = add_label_for_embed(ts(\"Additional Tags: \"), work.freeforms.map {|freeform| freeform.name}.join(', '), tag(\"br\"))\n if work.series.count != 0\n series_text = add_label_for_embed(ts(\"Series: \"), series_list_for_feeds(work), tag(\"br\"))\n end\n summary_text = add_label_for_embed(ts(\"Summary: \"), sanitize_field(work, :summary))\n \n if work.series.count != 0\n [chapters_text, fandom_text, rating_text, warning_text, relationship_text, char_text, tags_text, series_text, summary_text].compact.join\n else\n [chapters_text, fandom_text, rating_text, warning_text, relationship_text, char_text, tags_text, summary_text].compact.join\n end \n end",
"def scrape_details\n unscraped.each do |item|\n item.scrape_detail\n item.save!\n end\n end",
"def non_fulltext_links\n links = []\n other_customlinks = @record.fetch('CustomLinks',{})\n if other_customlinks.count > 0\n other_customlinks.each do |other_customlink|\n link_url = other_customlink['Url']\n link_label = other_customlink['Text']\n link_icon = other_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-other'})\n end\n end\n\n links\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def scrape_table(page)\n data_table = page.css('div.boxListResult').each do |x|\n record = {}\n record[:Link] = DOMAIN + x.css(\"div.contInfo h3 a\").at_css(\"a\")[\"href\"]\n # Print out the data we've gathered\n puts record\n # Finally, save the record to the datastore - 'Artist' is our unique key\n ScraperWiki.save_sqlite(unique_keys=[:Link], data=record)\n end\nend",
"def show_title\n h2 { h @title.titles }\n text gs_title(@title)\n sources = []\n sources << a('Anime News Network Encyclopdia', :href => \"http://www.animenewsnetwork.com/encyclopedia/anime.php?id=#{@title.ann_id}\") unless @title.ann_id.nil?\n sources << a('AniDB', :href => \"http://anidb.net/perl-bin/animedb.pl?show=anime&aid=#{@title.anidb_id}\") unless @title.anidb_id.nil?\n \n unless sources.empty?\n p { \"View #{h @title.title} in #{sources.join(\", \")}.\" }\n end\n end",
"def each\n @links.each { |title, url| yield title, url }\n end",
"def imdb_top_movie_urls\n url = \"https://www.imdb.com/chart/top\"\n html_string = open(url).read\n doc = Nokogiri::HTML(html_string)\n movie_link_elements = doc.search('.lister-list .titleColumn a').first(5)\n movie_link_elements.map do |element|\n \"http://www.imdb.com#{element.attr(\"href\")}\"\n end\nend",
"def fulltext_links\n\n links = []\n\n ebscolinks = @record.fetch('FullText',{}).fetch('Links',{})\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'pdflink'\n link_label = 'PDF Full Text'\n link_icon = 'PDF Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'pdf'})\n end\n end\n end\n\n htmlfulltextcheck = @record.fetch('FullText',{}).fetch('Text',{}).fetch('Availability',{})\n if htmlfulltextcheck == '1'\n link_url = 'detail'\n link_label = 'Full Text in Browser'\n link_icon = 'Full Text in Browser Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'html'})\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-pdf'\n link_label = 'PDF eBook Full Text'\n link_icon = 'PDF eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-pdf'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-epub'\n link_label = 'ePub eBook Full Text'\n link_icon = 'ePub eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-epub'})\n end\n end\n end\n\n items = @record.fetch('Items',{})\n if items.count > 0\n items.each do |item|\n if item['Group'] == 'Url'\n if item['Data'].include? 'linkTerm="'\n link_start = item['Data'].index('linkTerm="')+15\n link_url = item['Data'][link_start..-1]\n link_end = link_url.index('"')-1\n link_url = link_url[0..link_end]\n link_label_start = item['Data'].index('link>')+8\n link_label = item['Data'][link_label_start..-1]\n link_label = link_label.strip\n else\n link_url = item['Data']\n link_label = item['Label']\n end\n link_icon = 'Catalog Link Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'cataloglink'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'other'\n link_label = 'Linked Full Text'\n link_icon = 'Linked Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'smartlinks+'})\n end\n end\n end\n\n ft_customlinks = @record.fetch('FullText',{}).fetch('CustomLinks',{})\n if ft_customlinks.count > 0\n ft_customlinks.each do |ft_customlink|\n link_url = ft_customlink['Url']\n link_label = ft_customlink['Text']\n link_icon = ft_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-fulltext'})\n end\n end\n\n links\n end",
"def get_links\n links = @doc.search(\"//a[@class='title ']\")\n links.map! { |link| \"#{link['href']}\" } \n save_files(links)\n end",
"def get_crafted_items(index)\n page = get_additional_info(index)\n elements = page.css('.content-body-title a')\n items = []\n\n elements.each do |el|\n href = /item\\/(\\d+)/.match(el['href'])\n id = nil\n\n if (href && href.length > 1)\n items.push(href[1])\n end\n end\n\n items\nend",
"def thumb_links\n @doc.xpath(\"//tbody//img[@class='list_thumb']/@src\").map {|link| link.to_s.gsub(/\\/s\\//, \"/m/\")}\n end",
"def unwrap_links(elements); end",
"def scrap_trip_pages\n \n mp_trip_pages.each do |mp, trip_page|\n printf \"mp - #{mp}\\n\"\n doc = utf_page(trip_page)\n t = Time.now\n komandiruotes = (doc/\"//a[text()='Komandiruotės']\").first\n mp_business_trip(mp, denormalize( komandiruotes.attributes['href'] ) ) if komandiruotes\n printf \"Laikas: #{Time.now - t}\\n\"\n #sleep 3\n end\n \n end",
"def scrape\n google_url = create_google_url\n google_data = Scrubyt::Extractor.define do\n fetch google_url\n\n link_title \"//a[@class='l']\", :write_text => true do\n link_url\n end\n end\n google_data.to_hash.map {|r| r[:link_url]}\n end",
"def original_poster(doc)\n doc.search('.subtext > a:nth-child(2)').map { |link| link.inner_text }[0]\n end",
"def find_links\n @links = {}\n @contents.xpath('//a[@href]').each do |tag|\n if tag[:href].include? \"http://wiki.dublincore.org/index.php\"\n tag[:href] = tag[:href].sub(\"http://wiki.dublincore.org/index.php\", \"\")\n tag[:href] = @base_url + tag[:href] unless tag[:href].include? \"File:\"\n elsif tag[:href].include? \"/index.php\"\n tag[:href] = tag[:href].sub(\"/index.php\", \"\")\n tag[:href] = @base_url + tag[:href] unless tag[:href].include? \"File:\" \n end\n if tag[:href].include? \"File:\"\n if tag.children[0][:src].nil?\n file_name = tag[:href].sub(\"/File:\", \"\")\n source = html_get(URI.parse(URI.escape(File.join('http://wiki.dublincore.org/index.php', tag[:href]))))\n contents = Nokogiri::HTML(source)\n file_path = contents.xpath(\"//a[@class='internal']/@href\")\n # download_resource(File.join('http://wiki.dublincore.org/index.php', file_path.to_s), File.join(@file_dir, file_name))\n tag[:href] = File.join(@base_url, \"files/#{file_name}\")\n else\n tag[:href] = File.join(@base_url, \"images/#{File.basename(tag.children[0][:src])}\")\n tag.children[0][:src] = File.join(@base_url, \"images/#{File.basename(tag.children[0][:src])}\")\n end\n end\n @links[tag[:href]] = (tag[:title] || '') if (! @links.include? tag[:href])\n end\n end",
"def fetch_movie_urls\n url = \"https://www.imdb.com/chart/top\"\n doc = Nokogiri::HTML(open(url).read)\n movies = doc.search(\".titleColumn a\")[0...5]\n movies.map do |movie_link|\n end_url = movie_link.attribute(\"href\").value\n \"http://www.imdb.com#{end_url}\"\n\n end\n\nend",
"def scrape_links(parsed_page, core_path)\n links = []\n \n parsed_page.css('#class-index').css('.entries').css('a').each do |link|\n link_data = Hash.new\n \n link_data[:title] = link.text\n link_data[:path] = core_path + link.attributes['href'].value\n \n links << link_data\n end\n \n links\nend",
"def parse_result_page(page)\n page.search(\"div.listing div.title a\").map do |result_row|\n result_row.attribute(\"href\").value\n end\nend",
"def parse_result_page(page)\n page.search(\"div.listing div.title a\").map do |result_row|\n result_row.attribute(\"href\").value\n end\nend",
"def no_item_thumb_links\n no_column.links(:class => \"img\", :href => /.*/) # ---------------------------------- EVERYTHING USING THIS NEEDS REPLACING!!!!!!!!\n end",
"def scrape(para)\n # need SECTION & PLACENAME from para\n # need to follow embedded href to get DESCRIPTION\n links = para.css(\"a\")\n # puts links.length\n # puts links.text\n\n # grabs href from anchor elements\n links.each{|links| puts links['href']}\n #grabs title from anchor elements\n links.each{|links| puts links['title']}\nend",
"def scrape(para)\n # need SECTION & PLACENAME from para\n # need to follow embedded href to get DESCRIPTION\n links = para.css(\"a\")\n # puts links.length\n # puts links.text\n\n # grabs href from anchor elements\n links.each{|links| puts links['href']}\n #grabs title from anchor elements\n links.each{|links| puts links['title']}\nend",
"def news_links\n visit \"http://hk.apple.nextmedia.com/\"\n\n links = doc.css(\"#article_ddl option\").collect do |option|\n link = Link.new\n link.title = option.text\n link.url = option[\"value\"]\n link\n end.reject { |l| l.url.nil? }\n links\n end",
"def scrape_table(page)\n page.css('.listing_content').collect do |x|\n record = {}\n record['Business'] = x.css('.business-name a').text\n record['Address'] = x.css('.street-address').text.sub(/,[\\s]*/, '') || \"not listed\"\n record['City'] = x.css('.locality').text || \"not listed\"\n record['State'] = x.css('.region').text || \"not listed\"\n record['Zipcode'] = x.css('.postal-code').text || \"not listed\"\n record['Phone'] = x.css('.business-phone').text || \"not listed\"\n\n ## collect secondary info\n url = x.at_css('.business-name a').attribute(\"href\")\n page2 = Nokogiri::HTML(open(url))\n ext_record = scrape_page2(page2)\n \n record.merge!(ext_record)\n ScraperWiki.save([\"Business\"], record)\n end\nend",
"def scrape_table(page)\n page.css('.listing_content').collect do |x|\n record = {}\n record['Business'] = x.css('.business-name a').text\n record['Address'] = x.css('.street-address').text.sub(/,[\\s]*/, '') || \"not listed\"\n record['City'] = x.css('.locality').text || \"not listed\"\n record['State'] = x.css('.region').text || \"not listed\"\n record['Zipcode'] = x.css('.postal-code').text || \"not listed\"\n record['Phone'] = x.css('.business-phone').text || \"not listed\"\n\n ## collect secondary info\n url = x.at_css('.business-name a').attribute(\"href\")\n page2 = Nokogiri::HTML(open(url))\n ext_record = scrape_page2(page2)\n \n record.merge!(ext_record)\n ScraperWiki.save([\"Business\"], record)\n end\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def search_description_scrape\n @doc.search('.muted a').first(10).each do |description|\n @descriptions << description.text\n end\n check_for_results\n end",
"def get_items_links(uri_arr)\n\t\tlinks = []\n\t\t(1..get_max_page(uri_arr) ).each do |x|\n\t\t links.concat P.get_css_list P.build_uri(uri_arr), '.isolux-thumbnail-name a' \n\t\tend\n\t\t\n\t\tlinks\n\tend",
"def search3(doc)\n doc.search('.title > a:first-child').map { |link| link.inner_text}\n end",
"def list\n extract_names_and_urls = lambda do |doc|\n [extact_url(@url, document), extract_titles(document)]\n end\n \n html.css('a').map(&extract_names_and_urls)\n end",
"def printcat(cat)\n list = $page.css('.oneRes').select{|play| play.css('.detail li a')[1].text == cat}\n list.each do |play|\n puts \"#{play.css('.eventTitle').text}---#{play.css('.detail li a')[0].text}\"\n end\nend",
"def return_links_array(doc)\n links = doc.css(\".search-content .teaser-item__title a\")\n recipe_links = []\n links.each do |element|\n recipe_links << \"https://www.bbcgoodfood.com\" + element.attribute('href').value\n end\n return recipe_links\n end",
"def getHalfMinuteArticle(showURL,theYear,defaultDate)\n\tpage = Nokogiri::HTML(open(showURL))\n\tshowTitle = page.css('td#contentTd table td h3 strong.title').text.strip\n\tshowDescription = page.css('td#contentTd p').text.strip\n\tepisodeTable = page.css('td#contentTd table td a.hmenu')\n\tepisodeTitle = []\n\tepisodeURL = []\n\tepisodeDate = []\n\tepisodeMaster = []\n\tepisodeDesc = []\n\t\t\n\tepisodeTable.each do |t|\n\t\tepisodeURL.push('http://www.moneyradio.org/'+t['href'])\n\t\ttitleText = t.text.strip\n\t\t#episodeDate.push(titleText.index(theYear))\t\t\n\t\tif(titleText.index(theYear).nil?)\n\t\t\tepisodeDate.push(Date.strptime(defaultDate, '%m/%d/%Y'))\n\t\t\tepisodeTitle.push(t.text.strip)\n\t\t\t#use this print out to debug\n\t\t\t#puts t.text.strip\n\t\telse\n\t\t\tif titleText.index('1011/2007') # this is special case in 2007\n\t\t\t\tepisodeDate.push(Date.strptime(defaultDate, '%m/%d/%Y'))\n\t\t\t\tepisodeTitle.push(t.text.strip)\t\t\t\t\n\t\t\telse\n\t\t\t\tepisodeDate.push(Date.strptime(titleText[0..(titleText.index(theYear)+theYear.length-1)], '%m/%d/%Y'))\n\t\t\t\tepisodeTitle.push(titleText[(titleText.index(theYear)+theYear.length)..titleText.length].to_s.strip)\n\t\t\tend\n\t\t\t#use this print out to debug\n\t\t\t#puts t.text.strip\n\t\tend\n\tend\n\tf = 0\n\t#episodeURL = episodeURL[0..4]\n\tepisodeURL.each do |c|\n\t\tarticlePage = Nokogiri::HTML(open(c))\n\t\tcontent = articlePage.css('td#contentTd p').text.strip\n\t\t#puts content\n\t\tepisodeDesc.push(content)\n\t\tputs f.to_s\n\t\tputs episodeDate[f]\n\t\tputs episodeTitle[f]\n\t\tsleep(3)\n\t\tf = f+1\n\tend\n\t#puts \"title: \"+episodeTitle.length.to_s + \"content: \"+episodeDesc.length.to_s\n\tk = 0\n\tepisodeURL.each do |j|\n\t\tepisode = EpisodePage.new\n\t\tepisode.name = episodeTitle[k]\n\t\tepisode.date = episodeDate[k]\n\t\t#episode.url = j\n\t\tepisode.desc = episodeDesc[k]\n\t\tk = k + 1\n\t\tepisodeMaster.push(episode)\n\tend\n\treturn episodeMaster\nend",
"def linkPages\n @all_pages.each_value do |one_page|\n one_page.addPageLinks\n end\n @all_pages.each_value do |one_page|\n one_page.addMissingLinkNames\n end\n end",
"def links\n construct_html(self.items)\n end",
"def get_bardahl_product_data\n agent = Mechanize.new\n page = agent.get('https://allbardahl.ru/catalog/additives/')\n review_links = page.links_with(text: /[a-zA-Z]/, href: %r{/\\w+})[1, 76]\n\n array_links = []\n review_links.map.with_index do |elem, i|\n i % 2 == 0 ? array_links << elem : next\n end\n array_links\nend",
"def show_links\r\n links = Document.new(self).get_links\r\n puts \"There are #{links.length} links\"\r\n index = 1\r\n links.each do |l|\r\n puts \"link: name: #{l.name}\"\r\n puts \" id: #{l.id}\"\r\n puts \" href: #{l.href}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end",
"def titles\n urls.each do |url|\n @titles << Nokogiri::HTML(open(url)).css('title')[0].text\n end\n @titles\n end",
"def readPage \n @doc = Nokogiri::HTML.parse(@@BROWSER.html)\n\n # related TAGS\n @tags = []\n @doc.css('.tags.tags--postTags li a').each do |related_tag|\n @tags.push({\n :tag_name => related_tag.children.text,\n :tag_link => related_tag.attribute('href').value\n })\n end\n\n # BLOGS\n @blogs = []\n @doc.css('.streamItem').each do |blog|\n # author details: name, link to medium\n author_details = blog.css('.postMetaInline-authorLockup a').css('[data-action=\"show-user-card\"]')\n author_name = author_details.text.strip\n author_link = author_details.map { |link| link['href'] }\n\n # blog_archieve details\n blog_archieve_details = blog.css('.postMetaInline-authorLockup a').css('[data-action=\"show-collection-card\"]')\n blog_archieve_name = blog_archieve_details.text\n blog_archieve_link = blog_archieve_details.map { |link| link['href'] }\n\n # blog title image\n img_link = \"\"\n if blog.css('.progressiveMedia-image.js-progressiveMedia-image').empty?\n else\n img_link = blog.css('.progressiveMedia-image.js-progressiveMedia-image').attribute('data-src').value\n end\n\n # blog_link\n blog_link = blog.css('.postArticle-readMore .button--smaller').attribute('href').value\n\n @blogs.push({\n :title => blog.css('.graf--title').text, \n :sub_title => blog.css('.graf--subtitle').text,\n :trailing => blog.css('.graf--trailing').text,\n :author_name => author_name,\n :author_link => author_link[0],\n :blog_archieve_name => blog_archieve_name,\n :blog_archieve_link => blog_archieve_link[0],\n :blog_link => blog_link,\n :reading_time => blog.css('.readingTime').attr('title').value,\n :upvotes => blog.css('.js-actionMultirecommendCount').text,\n :img_link => img_link\n })\n end\n \n respond_to do |format|\n format.json{\n render json: {\n \"tags\": @tags,\n \"blogs\": @blogs\n }.to_json\n }\n end\n end",
"def output_jobs(links)\n links.length\n links.each { |link| puts link.text + \"\\n\\t\" + \"https://www.jobsatosu.com\" + link['href']}\nend",
"def link_stories! \n story_ids = find_all_story_ids\n return if story_ids.empty?\n\n message = \"### Clubhouse Stories\\n\\n\"\n story_ids.each do |id|\n message << \"* [#{story_link(id)}](#{story_link(id)}) \\n\"\n end \n markdown message\n end",
"def get_child_links(url)\n\n $log.info \"START #{__FILE__}.#{__method__}\"\n\t\n doc = Nokogiri::HTML(open(url))\n\t\n # append hostname to url\n if url == $url_root_shopping\n doc.xpath($deal_config[$site_name][\"child_links\"][\"a\"]).each do |link|\n $child_links << \"#{URI.parse(url).host}#{link['href']}\"\n #puts $child_links[-1]\n end\n\n else\n doc.xpath($deal_config[$site_name][\"child_links\"][\"b\"]).each do |link|\n $child_links << \"#{URI.parse(url).host}#{link['href']}\"\n #puts $child_links[-1]\n end\n end\n \n #puts doc.xpath($deal_config[$site_name][\"child_links\"][\"1\"])\n\t\n $log.info \"END #{__FILE__}.#{__method__}\"\n\t\n end",
"def get_da_detail_page(page, da_container)\n\n tds = da_container.search('td')\n\n href = tds[0].at('a')['href']\n\n detail_page = page.link_with(:href => \"#{href}\").click\n\n \n\n return detail_page\n\nend",
"def get_da_detail_page(page, da_container)\n\n tds = da_container.search('td')\n\n href = tds[0].at('a')['href']\n\n detail_page = page.link_with(:href => \"#{href}\").click\n\n \n\n return detail_page\n\nend",
"def title_links(options = {})\n generate_links(:title, options)\n end",
"def scrape_1_page(page)\n p \"scraping a page\" #{link.href}\" \n blog_date_1 = nil #the first part of the pubDate field goes into here\n blog_body = nil #the body text goes here\n blog_date_2 = nil #the second part of the pubDate field goes into here\n comments_arr = nil #temporary storage for comments before they get added to main document\n \n #select on td id=maincontent\n page.search('#maincontent')[0].each_child{ |child|\n \n if @max_blog_entries != nil and @curr_blog_entries >= @max_blog_entries\n @completed = true\n p \"reached max_blog_entries=#{@max_blog_entries}\"\n return\n end\n \n if child.search('.blogheader').length != 0\n blog_date_1 = convert_xanga_header_to_wordpress_date(child.inner_html)\n p \"blog head #{blog_date_1}\" \n #this is first part of date-time\n\n elsif child.search('.blogbody').length != 0\n #TODO: extract comments, number of views for blog\n \n #this is body of the blog\n blog_body = sanitize_blog_body(child.search(\"td\")[1].inner_html)\n \n p \"blog body=#{blog_body}\"\n \n #extract the date of blog for archiving purposes\n #inside class blogbody, lives a class smalltext, and we want the inner_html of the second <a href> tag\n blog_date_2 = convert_to_usable_time(child.search('.blogbody')[0].search('.smalltext')[0].search(\"a\")[1].inner_html)\n \n #create teh new document out of blogheader and blogfooter\n doc = create_new_xml_blog( blog_body, blog_date_1 + blog_date_2 )\n \n #catch comments here\n #inside class blogbody, lives a class smalltext, and we want the inner_html of the fifth <a href> tag\n if child.search('.blogbody')[0].search('.smalltext')[0].search(\"a\")[4].inner_html != \"add comments\"\n comments_arr =scrape_comments( Hpricot::Elements[ child.search('.blogbody')[0].search('.smalltext')[0].search(\"a\")[4] ].attr(\"href\") )\n comments_arr.each { |comment| \n doc.search(\"item\").append(comment.inner_html.to_s)\n #p \"adding comment here #{comment.inner_html.to_s}\"\n }\n #dump_page(doc)\n end\n\n #add resulting document to the @doc object already created\n @doc.search(\"channel\").append(doc.inner_html.to_s) \n\n @curr_blog_entries += 1\n end\n \n }\n end",
"def process_results(agent)\n links = ScraperWiki.select(\"link FROM links\")\n links.collect{ |x| x['link'] }.each do | link |\n load_details(agent, link)\n delete_link(link)\n sleep 10\n end\n ScraperWiki.save_var(INDEX, 0)\nend",
"def process_results(agent)\n links = ScraperWiki.select(\"link FROM links\")\n links.collect{ |x| x['link'] }.each do | link |\n load_details(agent, link)\n delete_link(link)\n sleep 10\n end\n ScraperWiki.save_var(INDEX, 0)\nend",
"def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('div.case')\n allUrl = links.css('h3 a').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n puts i\n end\nend",
"def scrape\n doc = capture\n puts \"scraping...\"\n symbols = doc.css(\"tr.snippet td.symbol\").map &:text\n tickers = doc.css(\"tr.snippet td.rgt.nwp\").map &:text\n puts \"data scraped\"\n return [symbols, tickers]\n end",
"def show_subjects\n @kw_by_code_keys.each{|key|\t# Iterate thru tags in the same order we read them\n # For this instance (parent ID) of this tag...\n pid, tag = key\n\n h_tag = @kw_by_code[key]\n next unless h_tag['a']\n\n h_tag['a'].each{|s|\n subject = s.sub(/ *thesis *$/i, '')\t# Remove \"thesis\" from end of 695.a\n puts \" <meta tagcode=\\\"subjects.fixed1\\\">#{subject}</meta>\"\n }\n }\n end",
"def get_da_detail_page(page, da_container)\n tds = da_container.search('td')\n href = tds[0].at('a')['href']\n detail_page = page.link_with(:href => \"#{href}\").click\n \n return detail_page\nend",
"def get_da_detail_page(page, da_container)\n tds = da_container.search('td')\n href = tds[0].at('a')['href']\n detail_page = page.link_with(:href => \"#{href}\").click\n \n return detail_page\nend",
"def pages\n @descriptive_detail.pages\n end",
"def get_info_page_links(page)\n info_links = page.links_with(href: %r{info.html})\n if not info_links\n info_links = page.links_with(href: %r{aboutus.html})\n end\n if not info_links\n info_links = page.links_with(text: '会社概要')\n end\n return info_links\nend",
"def custom_hook_all(items)\n grouped_by_page = items.group_by do |i|\n \"#{i[:category]}-#{i[:subcategory]}\"\n end\n grouped_by_page.each do |_, pages|\n page_record = {\n category: pages[0][:category],\n hierarchy: pages[0][:hierarchy],\n subcategory: pages[0][:subcategory],\n tagname: 'h1',\n text: nil,\n display_title: \"Go to #{pages[0][:subcategory]}\",\n title: pages[0][:category],\n url: pages[0][:url],\n weight_tag_name: 90,\n weight_order: -1\n }\n items << page_record\n end\n items\n end",
"def sitemap_links\n each_sitemap_link.to_a\n end",
"def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end",
"def get_atags(docs)\n # # Get doc\n # docs = get_docs(5)\n # \n # #meta_tags\n # meta_tags = nil\n # \n # # New docs\n # docs_new = []\n \n # href a tags\n a_tags_href = []\n \n vendor_list = []\n \n # #debug\n # get_next_sibling = true\n \n # Modify\n docs.each do |doc|\n #--------------------\n # Modify 'a' tags\n #--------------------\n \n # Get 'a' tags\n a_tags = doc.css(\"div ul li a\")\n \n # href value\n a_tags.each do |a_tag|\n if a_tag['href'].start_with?(\"/hl?\")\n # Modify url\n a_tag['href'] = \"http://headlines.yahoo.co.jp\" + a_tag['href']\n \n # Add\n a_tags_href.push(a_tag)\n \n # #debug =================================\n # #debug\n \n # # REF http://nokogiri.rubyforge.org/nokogiri/Nokogiri/XML/Node.html\n # ns = a_tag.next_sibling\n# # \n # if get_next_sibling\n# # \n # # while (ns) do\n# # \n # # if ns.next_sibling != \"写真\"\n # write_log(\n # \"a_tag.next_sibling=\" + a_tag.next_sibling, \n # # \"a_tag.content=\" + a_tag.content, \n # # __FILE__,\n # __FILE__.split(\"/\")[-1],\n # __LINE__.to_s)\n # # break\n# # \n # # end\n# # \n # # ns = ns.next_sibling\n # # end\n# \n # get_next_sibling = false\n# \n # end#if get_next_sibling\n # while (ns) do\n# \n # if(ns['href'] && ns['href'].start_with?(\"http::\"))\n# \n # write_log(\n # \"ns.content=\" + ns.content, \n # # __FILE__,\n # __FILE__.split(\"/\")[-1],\n # __LINE__.to_s)\n# \n # break\n# \n # end\n# \n # ns = ns.next_sibling\n# \n # end\n# \n # get_next_sibling = false\n# \n # end\n# \n # # vendor = a_tag.next_sibling.next_sibling.next_sibling\n# \n # # if a_tag.next_sibling != nil\n # # vendor_list << vendor.text\n # # end\n# \n# \n # #/========================================\n \n end#if a_tag['href'].start_with?(\"/hl?\")\n end#a_tags.each do |a_tag|\n \n \n # # New doc\n # docs_new.push(a_tags_href)\n \n #----------------------\n # Vendor list\n # \n \n \n # a_tags.each do |a_tag|\n# \n # if a_tag['href'].start_with?(\"http://headlines.yahoo.co.jp/list\")\n# \n # vendor_list << a_tag.text\n# \n # # # Modify url\n # # a_tag['href'] = \"http://headlines.yahoo.co.jp\" + a_tag['href']\n # # \n # # # Add\n # # a_tags_href.push(a_tag)\n# \n # end#if a_tag['href'].start_with?(\"/hl?\")\n# \n # end#a_tags.each do |a_tag|\n #--------------------\n # Modify 'charset' value\n #--------------------\n \n end#docs.each do |doc|\n \n #debug\n write_log(\n \"vendor_list.size=\" + vendor_list.size.to_s +\n \"/\" + \"a_tags_href.size=\" + a_tags_href.size.to_s,\n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n \n \n # Return\n return a_tags_href\n \n end",
"def render_meta_links(records)\n render PaginatorComponent.new(records: records, params: params).with_variant(:meta_links)\n end",
"def sanger_phenotyping_details_links( colony_prefix, result_data=nil )\n sanger_phenotyping_setup\n links = JSON.parse( @@ms.cache.fetch(\"sanger-phenotyping-pheno_links\") )[colony_prefix]\n return links\nend",
"def search_title_scrape\n @doc.search('b')[2..6].each do |name|\n @names << name.text\n end\n search_description_scrape\n end",
"def list_html(medias)\n list = \"\"\n log \"list_html: #{medias.size}\"\n medias.each do |media|\n log \"media: #{media.title}\"\n list << \"<li><img src='\" << media.url << \"'><br>\" << media.title << \"</li>\"\n end\n \"<ul class='gallery_detail'>#{list}</ul>\"\n end",
"def scrape(site)\n base_url = \"#{site}/page/\"\n\n url_list = Array.new\n post_links = Array.new\n\n # Grabbing all the pages\n (1..14).each do |i|\n url_list << base_url + i.to_s\n puts \"Getting page \" + i.to_s\n end\n\n # Going through individual pages\n url_list.each do |page|\n doc = Nokogiri::HTML(open(page))\n\n # Getting post links, make sure to check the HTML <==================== CHANGE THIS ===========================\n doc2 = doc.css('h2.entry-title a')\n\n doc2.each do |link|\n puts 'Collecting link ' + post_links.count.to_s\n post_links << link['href']\n end\n end\n\n puts \"Finished with getting all the links\"\n\n CSV.open(\"derek-halpern-wp.csv\", \"wb\") do |csv|\n csv << [\"Title\", \"Link\", \"Date\", \"Comments\", \"Likes\", \"Tweets\", \"LinkedIn\", \"Pins\", \"+ 1's\"]\n \n post_links.each_with_index do |post, index|\n\n share_counts = \"http://api.sharedcount.com/?url=#{post}\"\n resp = (Net::HTTP.get_response(URI.parse(share_counts))).body\n result = JSON.parse(resp, :symbolize_names => true)\n\n fb = result[:Facebook][:total_count]\n tw = result[:Twitter]\n ln = result[:LinkedIn]\n pin = result[:Pinterest]\n gp = result[:GooglePlusOne]\n\n post_page = Nokogiri::HTML(open(post))\n\n # Make sure the post headline follows this structure <==================== CHANGE THIS ===========================\n post_title = post_page.css('h1.entry-title').text\n \n # Make sure the comments follow this structure <==================== CHANGE THIS ===========================\n post_comments = post_page.css('#comments_intro').text.to_i\n\n #post_date = post_page.css('.meta .signature').text\n #find_comments = post_page.xpath('//*[@id=\"comments\"]/comment()').text\n #convert_to_ng = Nokogiri::HTML.parse(find_comments)\n #post_comments = convert_to_ng.css('h2').text.to_i\n\n puts \"Scraping post \" + index.to_s + \"/\" + post_links.length.to_s\n\n csv << [\"#{post_title}\", \"#{post}\", \"#{post_date}\",\"#{post_comments}\", \"#{fb}\", \"#{tw}\", \"#{ln}\", \"#{pin}\", \"#{gp}\"]\n end\n end\nend",
"def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def process_contents\n @img_tags = @contents.xpath( '//img[@src]' )\n @img_tags.each do |tag|\n download_resource(File.join('http://wiki.dublincore.org', tag[:src]), File.join(@image_dir, File.basename(tag[:src])))\n end\n find_links\n end",
"def get_all_infos page, category\n list_items = page.search('.post')\n\n link = page.uri.to_s\n list_items.each_with_index{|item,index|\n # get all items in page -------------------\n content = item.at('.entry-content a').text\n author = item.at('.entry-author a').text\n record = {\n :category => category,\n :author => author,\n :conent => content\n }\n ScraperWiki.save_sqlite([], record)\n }\nend",
"def get_all_infos page, category\n list_items = page.search('.post')\n\n link = page.uri.to_s\n list_items.each_with_index{|item,index|\n # get all items in page -------------------\n content = item.at('.entry-content a').text\n author = item.at('.entry-author a').text\n record = {\n :category => category,\n :author => author,\n :conent => content\n }\n ScraperWiki.save_sqlite([], record)\n }\nend",
"def get_all_infos page, category\n list_items = page.search('.post')\n\n link = page.uri.to_s\n list_items.each_with_index{|item,index|\n # get all items in page -------------------\n content = item.at('.entry-content a').text\n author = item.at('.entry-author a').text\n record = {\n :category => category,\n :author => author,\n :conent => content\n }\n ScraperWiki.save_sqlite([], record)\n }\nend",
"def get_all_infos page, category\n list_items = page.search('.post')\n\n link = page.uri.to_s\n list_items.each_with_index{|item,index|\n # get all items in page -------------------\n content = item.at('.entry-content a').text\n author = item.at('.entry-author a').text\n record = {\n :category => category,\n :author => author,\n :conent => content\n }\n ScraperWiki.save_sqlite([], record)\n }\nend",
"def scrape_link_data(link)\n { title: link.text, link: link[:href] }\n end",
"def each_hyperlink # :yields: text\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def job_links\n links = []\n loop do\n links << listing_page.links_with(class: 'ovalbuttondetails')\n break unless next_link\n @listing_page = next_link.click\n end\n links.flatten\n end",
"def display_songs\n puts \"Your Discography\"\n songs.each do |song|\n puts \"* Artist: #{song.artist} - Song Name: #{song.title}\"\n end\n end"
] | [
"0.5757896",
"0.56283975",
"0.5623225",
"0.5478858",
"0.5420071",
"0.53946555",
"0.5342132",
"0.53353864",
"0.5314344",
"0.5277145",
"0.5217491",
"0.52047503",
"0.5177311",
"0.5176968",
"0.5176968",
"0.5172046",
"0.5168489",
"0.51254624",
"0.5104758",
"0.510346",
"0.50438666",
"0.50355655",
"0.5031987",
"0.5031987",
"0.5031987",
"0.5031987",
"0.5021394",
"0.5006321",
"0.50012857",
"0.49986917",
"0.4996051",
"0.49846974",
"0.49768448",
"0.49704516",
"0.4963771",
"0.49515852",
"0.49428135",
"0.4934298",
"0.4928814",
"0.49252176",
"0.4924541",
"0.4924541",
"0.4922118",
"0.49155584",
"0.49155584",
"0.4897996",
"0.48949313",
"0.48949313",
"0.48752025",
"0.48752025",
"0.48752025",
"0.48752025",
"0.48598602",
"0.48580188",
"0.4856806",
"0.48563954",
"0.48563778",
"0.484643",
"0.48349845",
"0.48285994",
"0.4809373",
"0.48016888",
"0.47959313",
"0.47950983",
"0.47950652",
"0.4791666",
"0.4787108",
"0.4786222",
"0.47772908",
"0.47772908",
"0.47730497",
"0.47726697",
"0.4769831",
"0.4769831",
"0.4764019",
"0.47348624",
"0.47326967",
"0.47297475",
"0.47297475",
"0.4723286",
"0.47212255",
"0.47191277",
"0.4698646",
"0.46969384",
"0.46963608",
"0.4687327",
"0.46829414",
"0.46810645",
"0.4677996",
"0.4673066",
"0.46721604",
"0.46630275",
"0.46566573",
"0.46566573",
"0.46566573",
"0.46566573",
"0.46553725",
"0.46548074",
"0.46535134",
"0.46485052"
] | 0.76147765 | 0 |
Loops over each .follow_section container. | def get_followx_users(html)
users = []
Nokogiri::HTML(html).css('.follow_section').each do |section|
listener_name = section.css('.listener_name').first
webname = listener_name['webname']
# Remove any 'spans with a space' that sometimes appear with special characters.
listener_name.css('span').each(&:remove)
name = listener_name.text.strip
href = section.css('a').first['href']
users << { name: name, webname: webname, href: href }
end
users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_section\n @sections.each_value do | section |\n yield( section )\n end\n end",
"def section_looper(email_body)\n section = [:first_section, :second_section, :third_section]\n\n section.each do |section|\n type_looper(email_body, section)\n end\nend",
"def each_section(&block)\n @files.each do |file, list|\n list.each do |entry|\n yield(entry) if entry.is_a?(Section)\n end\n end\n end",
"def follow_many(targets, scrollback: 30)\n targets.map { |target| follow(target, scrollback: scrollback) }\n end",
"def next_follow\n end",
"def each_section(&block)\n while (section = next_section)\n block.call(section) if block\n end\n\n return self\n end",
"def followings\n @hot_topics = Topic.hot_topics(5)\n @interviewee = User.where(:nickname => params[:id]).first\n @is_same_user = @interviewee.is_same_user?(@current_user)\n \n @followings = @interviewee.followings\n end",
"def my_followers_mottos\n my_followers.each {|follower_instance| puts follower_instance.life_motto }\n end",
"def get_potential_follows_from_mimic(user)\n # iterate over the mimics in the table\n follow_lists = []\n user.mimics.each do |mimic|\n follow_lists << get_followers(user, mimic.twitter_id)\n end\n\n# Rails.logger.debug follow_lists.to_yaml\n follow_lists\n\n end",
"def follow_links(p)\n\t\tif p.links\n\t\t\tp.links.each do |l|\n\t\t\t\tnext if @visited_pages.include? l\n\t\t\t\t\n\t\t\t\tlp = Wikipedia.find(l)\n\t\t\t\tif lp.is_a? Array\n\t\t\t\t\tlp.each do |lp_i|\n\t\t\t\t\t\tlogger.debug \"following to: #{lp_i.title}\"\n\t\t\t\t\t\tif is_artist_page? lp_i\n\t\t\t\t\t\t\tp = lp_i\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telsif not is_artist_page? p\n\t\t\t\t\tif is_artist_page? lp\n\t\t\t\t\t\tp = lp\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tp\n\tend",
"def each_section(&block)\n return unless block\n\n @ini.each_key(&block)\n self\n end",
"def process_objects_section(parent_section, layout, objects)\n return if objects.nil?\n\n section_list = []\n objects.each_with_index do |object, i|\n section_list += object.sections(layout, parent_section, first_object: i.zero?, object_index: i)\n end\n section_list\n end",
"def show_collection_profile_navigation(collection, section)\n [\"intro\", \"faq\", \"rules\"].each do |s|\n if show_collection_section(collection, s) && s != section\n return true # if at least one other section than the current one is not blank, we need the navigation; break out of the each...do\n end\n end\n return false # if it passed through all tests above and not found a match, then we don't need the navigation\n end",
"def follow\n\t\t@most_active_users.each do |user|\n\t\t\tpath = \"https://github.com/%s/followers\" % [user]\n\t\t\tnavigate(path)\n\n\t\t\tDEFAULT_NUMBER_PAGES.times do |page|\n\t\t\t\tfollow_button = find_many_elements_by_xpath(@follow_xpath)\n\t\t\t\tfollow_button.each { |follow_element| follow_element.submit; sleep 1 }\n\n\t\t\t\tnext_button = find_by_link_text('Next')\n\t\t\t\tnext_button.nil? ? break : next_button.click\n\t\t\tend\n\t\tend\n\tend",
"def follows\n @follows ||= refresh_follows\n end",
"def list_sections\n \n end",
"def following\n if response[\"following\"] and response[\"following\"][\"groups\"]\n @following = response[\"following\"]\n @following[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n return @following\n end\n end",
"def get_social_reach(person)\n person\n\n .loop do |p|\n p.in_e(:FOLLOWS).out_v(type: 'person').uniq\n end\n\n .while do |p, depth|\n if depth == 0\n :loop\n else depth <= 6\n :loop_and_emit\n else\n false\n end\n end",
"def show\n @followup = Followup.new(preceding_move_id:@move.id)\n \n # ON BLOCK\n hit_mv_array = []\n @move.character.moves.each do |move|\n if move.eldest_move.startup.to_i - @move.on_block.to_i < 10 and move.jails_on_hit?\n hit_mv_array << move\n elsif move.parent == nil\n if move.eldest_move.startup.to_i - @move.on_block.to_i < 10\n hit_mv_array << move\n end\n end\n end\n @on_block_moves = hit_mv_array\n \n # ON HIT\n hit_mv_array = []\n @move.character.moves.each do |move|\n if move.eldest_move.startup.to_i - @move.on_hit.to_i < 10 and move.jails_on_hit?\n hit_mv_array << move\n elsif move.parent == nil\n if move.eldest_move.startup.to_i - @move.on_hit.to_i < 10\n hit_mv_array << move\n end\n end\n end\n @on_hit_moves = hit_mv_array\n \n # ON COUNTER HIT\n hit_mv_array = []\n @move.character.moves.each do |move|\n if move.eldest_move.startup.to_i - @move.on_counter_hit.to_i < 10 and move.jails_on_hit?\n hit_mv_array << move\n elsif move.parent == nil\n if move.eldest_move.startup.to_i - @move.on_counter_hit.to_i < 10\n hit_mv_array << move\n end\n end\n end\n @on_counter_hit_moves = hit_mv_array\n\n end",
"def parse_yields(section)\n @yields = section.strip\n end",
"def follow\r\n \r\n @followu = FollowUser.where(user_id: @u_id)\r\n @followt = FollowThread.where(user_id: @u_id)\r\n end",
"def each_section(&block)\n each do |entry|\n if entry.is_a?(List)\n # Iterate the list's sections\n entry.each_section(&block)\n elsif entry.is_a?(ListSection)\n # Pass the list section to the block\n yield(entry) if block_given?\n end\n end\n nil\n end",
"def autofollow\n find_current_blog\n @browser.goto $root+'/blog/'+ @blogname +'/followers'\n if @browser.button(:class => \"chrome blue big follow_button\").exists?\n follow_links = @browser.buttons(:class => \"follow_button\")\n end\n follow_links.each { |follow_button| follow_button.click } if follow_links\n sleep 2\n end",
"def followers\n scrape_for(:followers, :get_followers)\n end",
"def each_mid(&block)\n \n end",
"def i_love_each_of( albums )\n i = 0\n until i == albums.count \n puts \"I <3 #{albums[ i ]}!\" \n i += 1\n end\nend",
"def me_and_followings\n self.followings+[self]\n end",
"def follow\n\n end",
"def sections\n @body.xpath('.//a:section', a: NS)\n end",
"def show\n @user_profile = UserProfile.find(params[:id])\n\n #refactor this code out also we can probably just\n #get the avatar url and put it into a hash to pass to the view will be faster\n #also need to load up the posts better\n @followed_users_profile_list = Array.new\n @followed_users_post_list = Array.new\n followed_users = @user_profile.user.all_follows\n followed_users.each do |followed|\n @followed_users_profile_list << User.find(followed.followable_id).user_profile\n posts = User.find(followed.followable_id).posts\n posts.each do |post|\n @followed_users_post_list << post\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_profile }\n end\n end",
"def follow(listing)\n followed_listings << listing\n end",
"def interaction_scrape\n total_interactions = 0\n Drug.all.each do |drug|\n puts drug.name.upcase\n next if drug.interaction_url == nil\n rows = Nokogiri::HTML(open(drug.interaction_url)).css('.interaction.scroll-target.row')\n row_count, count = rows.count, 0\n rows.each do |row|\n drug_1 = drug.name\n drug_2 = row.css('.interactant.h5').text\n next if DrugInteraction.find_by(drug_1: drug_2, drug_2: drug_1)\n interaction_text = row.css('.span9.interaction-messages').text\n DrugInteraction.create(\n drug_1: drug_1,\n drug_2: drug_2,\n info: interaction_text\n )\n count += 1 ; total_interactions += 1\n puts count.to_s + \" rows out of \" + row_count.to_s\n end\n puts \"DONE. (\" + total_interactions.to_s + \" interactions logged.)\"\n puts \" \"\n \n end\n\nend",
"def following\n\t\tauthenticate_current_user\n\t\t# grab all the current user's following\n\t\tfollowing = UserFollower.where(user_follower_id: current_user.id)\n\t\t# create an empty array\n\t\tfollowing_group = []\n\t\t# rotate through each following returned, and grab the user object\n\t\tfollowing.each do |x|\n\t\t\t# push each following user object into array\n\t\t\tfollowing_group.push(User.find(x.user_id))\n\t\tend\n\t\t# respond with the array of following user objects\n\t\trespond_with following_group\n\n\tend",
"def followed_objects\n get_followed_objects_of_kind\n end",
"def parse_sections\n AIPP::Downloader.new(storage: AIPP.options.storage, source: sources_file) do |downloader|\n @dependencies.tsort(AIPP.options.section).each do |section|\n info(\"parsing #{section.sectionize}\")\n class_for(section).new(\n downloader: downloader,\n aixm: aixm\n ).attach_patches.tap(&:parse).detach_patches\n end\n end\n end",
"def following\n scrape_for(:following, :get_following)\n end",
"def followings\n @followings = @other_user.followings.paginate(:page => params[:page], :per_page => 20)\n end",
"def scrollProfileIntoView(items, itemNumber)\n if itemNumber >= 1\n element = items[(itemNumber-1)].find_element(TITLEOFTHEFREELANCER)\n @utills.scrollElementIntoView(element)\n end # End of IF\n end",
"def index\n @meeting_follow_ups = MeetingFollowUp.all\n end",
"def followers\n follows = {}\n @followors = Array.new\n @user_categoriess = Array.new\n @user_category = UserCategory.where(:master_category_id => params[:master_category_id])#,:user_id => params[:user_id])\n @user_category.each do |us_cate|\n\n @user_categoriess << us_cate.id\n end\n @cate_reletion_user = UserCategoryRelation.in(:user_category_id => @user_categoriess).where(:friend_user_id => params[:user_id], :is_active => \"true\")\n @cate_reletion_user.each do |cate_rele|\n @use_entity = UserEntity.where(:user_id => cate_rele.user_id)\n @user = User.where(:id => cate_rele.user_id)\n @user.each do |users|\n fl = follows.merge(:user_name => users.first_name,:user_id => users.id, :profile_picture => users.profile_picture_url, :entity_count => @use_entity.count, :status => \"NO\")\n @followors << fl\n end\n end\n\n @follo = @followors.sort{|a,b| [a[:user_id]] <=> [b[:user_id]]}\n respond_to do |format|\n if [email protected]?\n format.json {render :json => @follo.uniq.count}\n else\n format.json {render :json => {:message => \"There is no Followers\"}}\n end\n end\n end",
"def followers\n @brand = Brand.find(params[:id])\n if @brand\n @followers = @brand.get_followers - @brand.friends\n render :update do |page|\n page << \"$j('.text_followers').addClass('selected_tab');$j('.text_following,.text_friends').removeClass('selected_tab')\"\n page.replace_html \"stream_content\", :partial => \"followers\"\n end\n end\n end",
"def set_sections\n @sections = Section.find_ordered_parents\n end",
"def follow(user)\n client.search(\"#bonjour_monde\", result_type: \"recent\").take(20).collect.each {|name| client.follow(name.user.screen_name)}\nend",
"def scrape_cont(noko_page)\n noko_page.css('br').each{ |br| br.replace(\", \") }\n\n #### ORIGINAL BELOW ####\n staffs = noko_page.css('.staff-bio h3')\n\n cs_hsh_arr = []\n for i in 0...staffs.count\n staff_hash = {}\n # staff_hash[:full_name] = noko_page.xpath(\"//a[starts-with(@href, 'mailto:')]/@data-staff-name\")[i].value\n # staff_hash[:job] = noko_page.xpath(\"//a[starts-with(@href, 'mailto:')]/@data-staff-title\") ? noko_page.xpath(\"//a[starts-with(@href, 'mailto:')]/@data-staff-title\")[i].value : \"\"\n staff_hash[:full_name] = noko_page.css('.staff-bio h3')[i] ? noko_page.css('.staff-bio h3')[i].text.strip : \"\"\n staff_hash[:job_desc] = noko_page.css('.staff-bio h4')[i] ? noko_page.css('.staff-bio h4')[i].text.strip : \"\"\n\n staff_hash[:email] = noko_page.css('.staff-email-button')[i] ? noko_page.css('.staff-email-button')[i].attributes[\"href\"].text.gsub(/^mailto:/, '') : \"\"\n # staff_hash[:email] = noko_page.css('.staff-email-button')[i].attributes[\"href\"] ? noko_page.css('.staff-email-button')[i].attributes[\"href\"].text : \"\"\n staff_hash[:phone] = noko_page.css('.staffphone')[i] ? noko_page.css('.staffphone')[i].text.strip : \"\"\n\n cs_hsh_arr << staff_hash\n end\n\n cs_hsh_arr = @cs_helper.prep_create_staffer(cs_hsh_arr) if cs_hsh_arr.any?\n\n if !cs_hsh_arr.any?\n raw_staffs_arr = []\n ez_staffs = []\n\n raw_staffs_arr << noko_page.css('.staff .staff-item')\n raw_staffs_arr << noko_page.css('.staff-bio h3')\n raw_staffs_arr << noko_page.css('.ict_content_cl .team-member')\n\n raw_staffs_arr.map do |raw_staffs|\n ez_staffs += @cs_helper.extract_noko(raw_staffs) if raw_staffs.any?\n end\n\n cs_hsh_arr = @cs_helper.consolidate_cs_hsh_arr(ez_staffs)\n\n return cs_hsh_arr\n end\n\n return cs_hsh_arr\n end",
"def show\n @user = User.find_by_username(params[:id])\n \n #Array to save all of the follow information\n @following_users = Array.new\n \n #Extracting the follow_ids out of this array\n @user.follows.each do |i|\n @following_users.push i.follow_id\n end\n \n #getting the users whose follow id is the same as the follow_id\n @followed_users = User.find_all_by_id(@following_users)\n\n #Array of Followers\n @followers = Array.new\n \n #Extracting the follow_ids out of the reverse_followers array\n @user.reverse_follows.each do |i|\n @followers.push i.follow_id\n end\n \n @shouts = Shout.order('created_at desc').paginate(:page => params[:page], :per_page => 4)\n\n if current_user\n \t@already_following = false\n \tcurrent_user.follows.each do |follow|\n \t\tif follow.follow == @user\n \t\t\t@already_following = true\n \t\t\tbreak\n \t\tend\n \tend\n \t\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def follows\n @follower ||= FollowConfig.new\n @follower\n end",
"def followees\n @user = User.find params[:id]\n @users = @user.followees.page params[:page]\n @title = 'Following'\n render 'followship'\n end",
"def followees\n @user = User.find(session[:user_id])\n @followees = @user.followees \n render 'followees'\n end",
"def slide\n node = self\n until node.context == :section && node.level == 1\n node = node.parent\n end\n node\n end",
"def my_followers_mottos\n Bloodoath.all.each do |bloodoath|\n if bloodoath.cult == self\n puts bloodoath.follower.life_motto\n end\n end\n end",
"def each\n collection.each do |profile|\n yield(profile)\n end\n end",
"def follow_meta_refresh_self=(follow); end",
"def following\n @title = \"Following\"\n @professional = professional.find(params[:id])\n @professionals = @professional.followed_professionals.paginate(page: params[:page])\n render 'show_follow'\n end",
"def follow\n # if params[:followage] && (['User','Cube', 'Post'].include?(params[:followage][:followed_type]))\n # @parent = Object.const_get(params[:followage][:followed_type]).find(params[:followage][:followed_id])\n # current_user.follow!(@parent, :record => true)\n # end\n\n current_user.follow!(@parent, :record => true)\n\n ## IMPORTANT! Km analytics are on 'record_follow' method of the User class, as we need to prevent recording multiple-follows\n Analytics.km_follow(current_user, @parent)\n \n respond_to do |format|\n format.html { redirect_to @parent }\n format.js { render :layout => false }\n end \n end",
"def followers\n @title = 'Followers'\n @users = @user.followers.page(params[:page])\n render 'show_follow'\n end",
"def find_cycle\n first = @people_prefs.index{|i| i.size > 1}\n cycle_crawl(first)\n end",
"def fetch_user_and_followings\n @user = User.find(params[:followee_id])\n @follow = Follow.find_by(follower_id: current_user.id, followee_id: params[:followee_id])\n end",
"def index\n @album_follows = AlbumFollow.all\n end",
"def next\n if self.last?\n first_in_section\n else lower_item\n end\n end",
"def following\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @users = @user.follow_users.fields_for_list.order(\"actions.id asc\").offset(params[:offset]).limit(params[:limit])\n end",
"def loop_print(students, center_by)\n #commenting\n i = 0\n while i<students.length\n student = students[i]\n puts \"#{i+1}. #{student[:name]} (#{student[:cohort]} cohort)\".center(center_by)\n i+=1\n end\nend",
"def display_albums(margin, box_height, bar_width)\n spacing = 0\n spacing_add = box_height + margin\n i = @page\n while i < @viewable_albums + @page\n display_album(@data_array[i].title, spacing, box_height, margin, bar_width, PRIMARY, \"album_button_#{i}\",i) rescue nil\n spacing += spacing_add\n i += 1\n end\nend",
"def following\n @title = 'Following'\n @users = @user.following.page(params[:page])\n render 'show_follow'\n end",
"def each_child\n \n end",
"def complete_tour\n # Complete tour only if it is visible\n if page.has_css? 'div.hopscotch-bubble'\n while page.has_css? 'div.hopscotch-bubble .hopscotch-next'\n find('div.hopscotch-bubble .hopscotch-next').click\n end\n end\nend",
"def message_detail\n @archive.series.each do |series|\n titles = series.webpage.parser.xpath(\"//div[@id='series_title']/ul/li\")\n .map {|e| e.children.text }\n\n speakers = series.webpage.parser.xpath(\"//div[@id='series_speaker']/ul/li\")\n .map {|e| e.children.text}\n\n campuses = series.webpage.parser.xpath(\"//div[@id='series_campus']/ul/li\")\n .map {|e| e.children.text}\n\n videos = series.webpage.parser.xpath(\"//div[@id='series_video']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n audios = series.webpage.parser.xpath(\"//div[@id='series_audio']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n notes = series.webpage.parser.xpath(\"//div[@id='series_notes']/ul/li\")\n .map do |e|\n link = nil\n e.children.each do |c|\n if c.name == 'a'\n link = c\n break\n end\n end\n\n if !link.nil?\n link.attributes['href'].value.strip\n else\n link\n end\n end\n\n #array indexen\n t = s = c = v = a = n = 1;\n lt = ls = lc = 1;\n\n series.sermons.each do |sermon|\n sermon.messages.each do |message|\n lt = t if titles[t] != ''\n ls = s if speakers[s] != ''\n lc = c if campuses[c] != ''\n\n message.title = titles[lt]\n message.speaker = speakers[ls]\n message.video = videos[v]\n message.audio = audios[a]\n message.notes = notes[n]\n message.campus = campuses[c]\n\n t += 1; s += 1; c += 1; v += 1; a += 1; n+=1;\n end\n end\n\n end\n end",
"def following_info\n following = []\n self.following.each do |follower|\n following << follower.attributes.merge(avatar: follower.avatar.url)\n end\n response = {\n message: \"Successfully fetch #{ self.username } following\",\n relations: following\n }\n end",
"def show\n @extends = Extend.includes( :user ).limit(10).where( story: @story ).paginate( page: params[:page], per_page: 10 ) \n @following = Follower.find_by( user: current_user, story: @story )\n puts @following\n end",
"def followers\n @pagy, @accounts = pagy_countless @account.followers, link_extra: 'data-remote=\"true\"'\n respond_to do |format|\n format.json.ujs { render 'index', layout: false }\n format.html { render 'followers' }\n end\n end",
"def all_following( options={} )\n\t\t\t\tall_follows( options ).collect{ |f| f.followed }\n\t\t\tend",
"def follow_list(options)\n session.options = adapt_to_dev_env(options)\n session.get('/follows')\n end",
"def sections_for( page )\n titles_for( page ).zip( tables_for( page ) )\n end",
"def each_category(&block)\n visit_category_list\n\n links = []\n\n within \".columnas-fp\" do\n links = all('a')\n end\n\n links.each do |link|\n block.call link.text, link[:href]\n end\n end",
"def claim_loop\n segments = []\n @eobs.each_with_index do |eob, index|\n @check_grouper.last_eob = eob\n @check = eob.check_information\n @job = @check.job\n if @check.micr_line_information && @check.micr_line_information.payer && @facility.details[:micr_line_info]\n @payer = @check.micr_line_information.payer\n else\n @payer = @check.payer\n end\n @facility_output_config = @facility.output_config(@payer.payer_type)\n @reason_codes = nil #this variable is used in child class for configurable section\n @eob = eob\n @claim = eob.claim_information\n @eob_index = index\n @services = eob.service_payment_eobs\n @is_claim_eob = (eob.category.upcase == \"CLAIM\")\n @count = count\n segments << transaction_set_line_number(index + 1)\n segments << transaction_statistics([eob])\n segments += generate_eobs\n end\n segments.flatten.compact\n end",
"def work_examples!\n @html.css('pre').each do |pre|\n lines = pre.content.split(\"\\n\")\n first_line = lines.first.to_s.strip\n next unless first_line.match(/^# ([A-Za-z]+)$/i)\n\n sections = split_lines(lines)\n example = Example.new sections\n @examples.push example\n template = Tilt.new(Ifdoc.root('data', 'templates', 'example.haml'))\n\n pre.after(template.render(example))\n pre.remove\n end\n end",
"def send_following_emails\n self.question.follow_questions.each do | follow |\n if follow.user_id != self.user_id && follow.user.email_follows?\n FollowQuestionMailer.new_answer(follow.user, self.question, self).deliver\n end\n end\n end",
"def followerss\n followers = relationships.find_by_followed_id(self.id)\n return followers\n end",
"def each(&block)\n scenes_collection.each(&block)\n end",
"def follows; [] end",
"def each_article\n begin\n yield article\n end while self.next\n end",
"def following\n json[\"entry_data\"][\"ProfilePage\"].first[\"graphql\"][\"user\"][\"edge_follow\"][\"count\"]\n end",
"def links_to_follow(page)\n links = @focus_crawl_block ? @focus_crawl_block.call(page) : page.links\n links.select { |link| visit_link?(link, page) }\n end",
"def all_follows( options={} )\n\t\t\t\tself.follows.active.includes( :followed) .all( options )\n\t\t\tend",
"def all_follows(options={})\n self.follows.unblocked.approved.includes(:followable).apply_finder_options(options, true)\n end",
"def friends_management\n\t\tfriends = @client.friend_ids.to_a\n\t\tfollowers = @client.follower_ids.to_a\n\n\t\tto_follow = followers - friends\n\t\t# to_unfollow = friends - followers\n\n\t\tto_follow.each do |id|\n\t\t\tfollow(id)\n\t\tend\n\n\t\t# 一旦停止 \n\t\t# to_unfollow.each do |id|\n\t\t# \tunfollow(id)\n\t\t# end\n\tend",
"def club_cache_img(page)\n information = Hash.new\n next_page = \"____\"\n current_page = page\n fields = [:name,:mission,:link,:location,:affiliations,:img]\n #fields = [:img]\n count = 1\n #club_id = 1\n\n loop do\n table = current_page.css('div[id=\"ctl00_ContentBody_pageFormControl_panel_listing\"]')[0].children[5].children\n table.each do |club|\n #club_img = ''\n name = ''\n club_info = fields.each_with_object(nil).to_h\n if !club.text.strip.empty?\n club.children.each do |inside|\n if !inside.text.strip.empty?\n club_info[:link] = \"https://activities.osu.edu\" + inside.css('a').attribute('href')\n inside.children.each do |field|\n if !field.text.strip.empty?\n club_img = \"https://activities.osu.edu\" + field.children[0].css('img').attribute('src') #image link\n club_info[:img] = \"https://activities.osu.edu\" + field.children[0].css('img').attribute('src') #image link\n field.children.each do |next_layer| \n if !next_layer.text.strip.empty?\n inside = 0\n next_layer.children.each do |card_values|\n if !card_values.text.strip.empty?\n if inside == 0\n club_info[:location] = card_values.children[5].text.strip\n elsif inside == 1\n name = card_values.children[0].text.strip\n club_info[:name] = name\n elsif inside == 2\n affiliations = card_values.children[0].text.strip.gsub '|', ' '\n club_info[:affiliations] = affiliations\n elsif inside == 3\n club_info[:mission] = card_values.children[0].text.strip\n end\n inside += 1\n end\n end\n end\n end\n end\n end\n end\n end\n end\n \n # if !club_img.empty?\n # information[club_id] = club_img\n # club_id+=1\n # end\n\n # if club_info[:img] != nil\n # information[club_id] = club_img\n # club_id+=1\n # end\n \n if !name.empty?\n information[name] = club_info\n end\n end\n \n #puts \"pre-link-get string\"\n next_page = current_page.css('a[title=\"Go to Next Page\"]')\n break if next_page.empty?\n next_page_link = next_page[0].attribute('href')\n #puts \"post-link-get string\"\n link_check = current_page.link_with(:href => next_page_link.to_s)\n #puts \"post-link-get\"\n if !link_check.nil?\n #puts \"pre-hit\"\n current_page = link_check.click\n #puts \"hit\"\n puts count\n count += 1\n \n else\n puts current_page.link_with(:href => next_page_link.to_s).nil?\n break\n end\n\n end\n\n File.write 'clubsimg.txt', information.to_s\n hashit = JSON.pretty_generate(information)\n open('data-scrape/clubs_with_img.json','w+') {|file|\n file.puts hashit\n }\n\nend",
"def infobox_each_link(html)\n Nokogiri::HTML(html).css('.infobox').each do |infobox|\n infobox_body = infobox.css('.infobox-body')\n\n title_link = infobox_body.css('h3 a').text.strip\n subtitle_link = infobox_body.css('p a').first\n subtitle_link = subtitle_link.text.strip if subtitle_link\n\n yield(title_link, subtitle_link)\n end\n end",
"def fellow_cult_members\n my_cults_oaths = self.cults.map do |cult|\n cult.oaths\n end\n flat_oaths = my_cults_oaths.flatten\n fellow_followers = flat_oaths.map do |oath|\n oath.follower\n end\n fellow_followers\n end",
"def followers\n\t Friendship.findFriends(self,\"follow\",\"from\")\n end",
"def preprocess_section (cfg, image_hash, header_hash, link_hash, menu_list) \n Dir.chdir(cfg[\"doc_home\"]) {\n cfg['sections'].keys.each { |section|\n #puts \"using #{section}\"\n #puts \" #{cfg['sections'][section]}\"\n #puts \" #{cfg['sections'][section][:files]}\"\n @image_hash = {}\n @header_hash = {}\n cfg['sections'][section][:files].each { |fname|\n relpath = \"#{cfg['sections'][section][:dir]}/#{fname}\"\n #puts \"In dir #{relpath}\"\n d = File.dirname(relpath)\n f = File.basename(relpath)\n if cfg['nested'] \n Dir.chdir(d) {\n # pre_doc is an array \n pre_doc = Kramdown::Document.new(File.read(f, encoding: \"UTF-8\"),\n {img_hash: @image_hash, hdr_hash: @header_hash, lnk_hash: @link_hash,\n menu_list: @menu_list, input: cfg['input_format']\n }).to_preprocess\n }\n else \n pre_doc = Kramdown::Document.new(File.read(f, encoding: \"UTF-8\"),\n {img_hash: @image_hash, hdr_hash: @header_hash, lnk_hash: @link_hash,\n menu_list: @menu_list, input: cfg['input_format']\n }).to_preprocess\n end\n download_images(cfg, @image_hash)\n }\n #cfg['sections'][section]['images'] = @image_hash\n foo = cfg['sections'][section]['headers'] = @header_hash\n }\n }\n end",
"def scrape_people\n people = []\n lis = @browser.lis(css: \".mod.result.people\")\n lis.each do |li|\n user_id = li.attribute_value(\"data-li-entity-id\")\n\n bd = li.div(class: \"bd\")\n name = bd.h3.a.text\n if name =~ /linkedin member/i\n next\n end\n\n if bd.dl(class: \"snippet\").present?\n title = bd.dl(class: \"snippet\").dd.p.text\n else\n title = bd.div.text\n end\n\n full_url = bd.h3.a.href\n person = {\n user_id: user_id,\n name: name,\n full_url: full_url,\n title: title\n }\n people << person\n end\n people\nend",
"def mutual_follows\n self.followees.to_a.select { |followee| followee.is_following?(self) }\n end",
"def follow(target, scrollback: 100)\n target = target.write_target if target.respond_to?(:write_target)\n StreamLog.follow(read_target, target)\n read_feed.follow(*target, scrollback)\n end",
"def followers\n config = create_or_find_config\n \n puts\n Twitter::Base.new(config['email'], config['password']).followers.each do |u|\n puts \"#{u.name} (#{u.screen_name})\"\n puts \"#{u.status.text} at #{u.status.created_at}\" unless u.status.nil?\n end\n end",
"def followed_events\n @followed = Follower.all.where(:customer_id => params[:customer_id])\n @followed_events=Array.new\n @eventos_nous=Array.new\n @followed.each do |f|\n @followed_events = Evento.all.where(:id_creator => f.company_id)\n @followed_events.each do |e|\n @eventos_nous << e.formatted_data.as_json()\n end\n end\n render json: @eventos_nous\n end",
"def build_user_following_tips\n group_ids = instance_user.follows.where(followable_type: 'Group').pluck(:followable_id)\n\n following_tip_ids = instance_user.follows.where(id: instance_available_ids).pluck(:followable_id)\n\n group_tip_ids = Follow.where(\n id: instance_available_ids,\n blocked: false,\n follower_type: 'Group',\n follower_id: group_ids\n ).pluck(:followable_id)\n\n following_tip_ids + group_tip_ids\n end",
"def follow\n current_profile.follow_profile(@profile)\n respond_to do |format|\n format.html { redirect_to profile_home_path(@profile.site_identifier) }\n format.json { head :no_content }\n end\n end",
"def followers\n # First, get all of this cult's blood oaths and then for each one, return the follower that blood oath belongs to\n self.blood_oaths.map { |blood_oath| blood_oath.follower }\n end",
"def each\n @links.each { |_, actor| yield(actor) }\n end",
"def links_to_follow(page)\n @page = page # need below, sorry\n links = @focus_crawl_block ? instance_eval(@focus_crawl_block).call(page) : page.links\n links.select { |link| visit_link?(link, page) }.map { |link| link.dup }\n end"
] | [
"0.5388726",
"0.5186861",
"0.51480687",
"0.5068497",
"0.50241494",
"0.4946938",
"0.48971945",
"0.48966563",
"0.48904923",
"0.4889079",
"0.4866163",
"0.4848056",
"0.48419654",
"0.48185638",
"0.47735327",
"0.47356346",
"0.4717704",
"0.46736893",
"0.4658205",
"0.46570393",
"0.46366337",
"0.46310169",
"0.46308407",
"0.46287334",
"0.4614433",
"0.45955262",
"0.45921174",
"0.45889923",
"0.45722824",
"0.4568795",
"0.45529714",
"0.45513567",
"0.45475987",
"0.45432216",
"0.45337743",
"0.4531524",
"0.4524818",
"0.45187998",
"0.45094913",
"0.45037362",
"0.44967324",
"0.44943094",
"0.44854486",
"0.4485134",
"0.4479255",
"0.44554314",
"0.4432601",
"0.44312042",
"0.44300342",
"0.44208962",
"0.4415748",
"0.44154757",
"0.4404506",
"0.44038457",
"0.43956873",
"0.43934768",
"0.43918657",
"0.43883058",
"0.4385913",
"0.43843684",
"0.43742993",
"0.4374292",
"0.43679217",
"0.4367412",
"0.4364104",
"0.436018",
"0.43559796",
"0.4353696",
"0.43500447",
"0.4348522",
"0.43452328",
"0.43432865",
"0.4343152",
"0.43327546",
"0.43320978",
"0.4331536",
"0.43301696",
"0.43253163",
"0.43231958",
"0.43231022",
"0.4316187",
"0.4313553",
"0.43122986",
"0.43112564",
"0.43094394",
"0.43077585",
"0.43037146",
"0.4303472",
"0.43025294",
"0.42994404",
"0.4296901",
"0.4294611",
"0.42928168",
"0.42916426",
"0.42883235",
"0.4287957",
"0.42823827",
"0.4280896",
"0.42781895",
"0.4274942"
] | 0.45544216 | 30 |
Creates and initializes a new instance of the ExternalSubscription class. | def initialize(client)
@client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscription\n Zapi::Models::Subscription.new\n end",
"def new\n @subscription = Subscription.new\n end",
"def new\n @subscriber = Subscriber.new\n end",
"def initialize(subscription_purchase)\n @subscription_purchase = subscription_purchase\n end",
"def initialize\n @subscribers = []\n end",
"def after_initialize\n self.build_subscription if subscription.nil?\n end",
"def initialize(configuration, options = {})\n super(configuration, 'subscriptions', 'Microsoft.Resources', options)\n end",
"def initialize(options = {})\n expect! options => { :adapter => String }\n\n adapter_url = options[:adapter]\n\n EM.next_tick do\n @adapter = RubPubSub::Adapter.create(adapter_url)\n end\n end",
"def create_new_subscription\n @subscription_offers = Subscription.get_subscription_list\n end",
"def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end",
"def initialize( publish_key, subscribe_key, secret_key, cipher_key, ssl_on )\n @publish_key = publish_key\n @subscribe_key = subscribe_key\n @secret_key = secret_key\n @cipher_key = cipher_key\n @ssl = ssl_on\n @origin = 'pubsub.pubnub.com'\n\n if @ssl\n @origin = 'https://' + @origin\n else\n @origin = 'http://' + @origin\n end\n end",
"def subscribe(options, &block)\n subscriptions.create(options, &block)\n end",
"def create\n @subscription = Subscription.create(params[:subscription])\n gb = Gibbon::API.new(\"6f8672a5c2393d1441c54d3be3fb79a1-us1\")\n gb.lists.subscribe({:id => \"c0ca5b3d41\", :email => {:email => params[:subscription][:email]}, :merge_vars => {:FNAME => '', :LNAME => ''}, :double_optin => false})\n end",
"def create\n addon = lookup_external_id_in_addons(params)\n if addon[:result] == 'success'\n render json: { subscriber: update_subscriber(addon[:external_id].merge(params)) || {} }\n else\n render json: { subscriber: addon.to_json }\n end\n end",
"def initialize(subscription_id:, environment: \"Azure\")\n @subscription_id = subscription_id\n @environment = environment\n end",
"def initialize(subscription_id:, environment: \"Azure\")\n @subscription_id = subscription_id\n @environment = environment\n end",
"def initialize(config, &block)\n @logger = DXLClient::Logger.logger(self.class.name)\n\n @reply_to_topic = \"#{REPLY_TO_PREFIX}#{config.client_id}\"\n\n @subscriptions = Set.new\n @subscription_lock = Mutex.new\n\n @mqtt_client = MQTTClientAdapter.new(config)\n @connection_manager = ConnectionManager.new(config,\n @mqtt_client,\n object_id)\n @callback_manager = create_callback_manager(config)\n @request_manager = RequestManager.new(self, @reply_to_topic)\n @service_manager = ServiceManager.new(self)\n\n initialize_mqtt_client\n handle_initialization_block(block)\n end",
"def subscription(name = nil, &block)\n Subscription.new(name, &block)\n end",
"def initialize(integration)\n @integration = integration\n @references = [ ]\n end",
"def subscribe!\n # TODO: Implement\n end",
"def create_stripe_subscription!\n Stripe::Subscription.create(\n customer: create_stripe_customer!,\n tax_percent: Price::DEFAULT_TAX_RATE,\n trial_from_plan: store.eligible_for_trial_subscription?,\n items: [\n {plan: stripe_plan_id},\n ],\n metadata: {store: store.name}\n )\n end",
"def initialize\n @provider = AmqpSource\n end",
"def create(params)\n params.merge!(\n :order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this\n :amount => 0\n )\n \n post = Api.default_post_for_params(params).merge({\n :subscription => 1,\n :subscriptionname => params[:description]\n })\n \n query = Api.authorize(post)\n \n if query['accept']\n # Return the new subscriber\n subscription = new(query[\"subscriptionid\"].to_i).reload\n \n # Set (obfuscated) card number:\n subscription.card_no = query[\"tcardno\"]\n \n subscription\n else\n new(nil, 'error' => query[\"error\"])\n end\n end",
"def new\n @subscriber = MailchimpSubscriber.new\n end",
"def build_create_subscription_request(xml, options)\n # Subscription\n add_subscription(xml, options)\n\n xml.target!\n end",
"def subscription_node\n unless subscription = pubsub.find_first('ns:subscription', :ns => self.class.registered_ns)\n self.pubsub << (subscription = XMPPNode.new('subscription', self.document))\n subscription.namespace = self.pubsub.namespace\n end\n subscription\n end",
"def initialize(subscription_line_item)\n @subscription_line_item = subscription_line_item\n end",
"def create_initial_subscription\n return unless self.subscription_plan_id.to_i > 0\n\n @subscription_plan = SubscriptionPlan.find(self.subscription_plan_id)\n if @subscription_plan.user?\n self.subscribe_to_plan(@subscription_plan)\n else\n create_organization_and_subscription_plan\n end\n end",
"def subscription(id)\n Sensit::Api::Subscription.new id, @http_client\n end",
"def initialize (receiver, xref)\n @receiver = receiver\n @xref = xref\n end",
"def initialize_pubsub_client\n @client = Google::Cloud::Pubsub.new\n end",
"def create_subscription(sender)\n PsegRecurring::Subscription.new(@credentials).send_subscription(sender)\n end",
"def initialize(subscription_key)\n fail ArgumentError, 'Subscription key cannot be nil' if subscription_key.nil?\n fail ArgumentError, 'Subscription key must be of type string' if subscription_key.class.to_s != 'String'\n @subscription_key = subscription_key\n end",
"def auto_initialize!\n client\n topic\n end",
"def initialize(api_key)\n @api_key = api_key\n @data_api_url = 'https://www.altadata.io/data/api/'\n @subscription_api_url = \"https://www.altadata.io/subscription/api/subscriptions?api_key=#{@api_key}\"\n end",
"def get_instance(payload)\n UserDefinedMessageSubscriptionInstance.new(@version, payload, account_sid: @solution[:account_sid], call_sid: @solution[:call_sid])\n end",
"def initialize(aRoot)\n raise StandardError if aRoot.nil?\n\n @root = aRoot\n @subscribers = []\n end",
"def initialize\n get_enterprise_token\n initialize_client\n end",
"def pubsub_adapter; end",
"def initialize(channel, &callback)\n @channel = channel\n @redis = Connection.new\n subscribe &callback\n end",
"def create_subscription(options)\n # This call automatically creates an invoice, always.\n Stripe::Subscription.create({\n customer: customer.id,\n tax_percent: calculate_vat_rate\n }.merge(options))\n end",
"def initialize\r\n @time = :forever\r\n @timed_out = false\r\n @subscribers = Array.new\r\n @scheduler = Rufus::Scheduler.start_new\r\n end",
"def subscribe( publication )\n subscriptions.create(publication: publication) unless has_subscribed?(publication)\n rescue ActiveRecord::RecordNotUnique\n end",
"def initialize(opts = {})\n @storage = opts[:storage]\n # Conn must respond to #send\n @conn = opts[:conn]\n @subscriptions = []\n end",
"def set_api_subscription\n @api_subscription = Api::Subscription.find(params[:id])\n end",
"def pubsub\n @pubsub || @mutex.synchronize { @pubsub ||= config.pubsub_adapter.new(self) }\n end",
"def create_subscriptions\n Subscription.create_subscriptions(self.id, self.hashtag)\n end",
"def initialize(config)\n @config = config\n setup_delivery\n end",
"def subscription(options = {})\n Subscription.new(options.merge(:url => url)).to_hash\n end",
"def subscribe(magazine, price)\n Subscription.create(price: price, magazine_id: magazine.id, reader_id: self.id)\n end",
"def create_if_necessary!\n if topic.blank?\n @topic = pubsub.create_topic(topic_name).tap do |topic|\n raise error, \"Unable to create topic #{topic_name}\" if topic.nil?\n end\n end\n\n @subscription = @topic.find_subscription(subscription_name) || @topic.create_subscription(subscription_name)\n @subscription.tap do |subscription|\n raise Error, \"Unable to create subscription #{subscription_name}\" if subscription.nil?\n\n # Default subscription expiry is 31 days. We want none of that.\n subscription.expires_in = nil unless pubsub.project_id == EMULATOR.fetch(:project_id)\n end\n end",
"def create_subscription(options)\n # Get the plan.\n plan = Stripe::Plan.retrieve(options[:plan])\n\n # Charge VAT in advance because subscription call will create and pay an invoice.\n # TK actually we need to apply VAT for invoiceitems that are pending and scheduled\n # for the next invoice.\n # Do not charge VAT if the plan or the subscription is still in trial (invoice will come later).\n vat, invoice_item = charge_vat_of_plan(plan) unless \\\n plan.trial_period_days || (options[:trial_end] && options[:trial_end] != 'now')\n\n # Start subscription.\n # This call automatically creates an invoice, always.\n subscription = customer.subscriptions.create(options)\n\n [subscription, last_invoice]\n rescue Stripe::StripeError, Stripe::CardError => e\n # Something failed in Stripe, if we already charged for VAT,\n # we need to rollback this. As we may charge twice later otherwise.\n invoice_item.delete if invoice_item\n raise e\n end",
"def initialize(options={})\n @next_url = options[:callback_url] \n @sess = true\n @secure = SECURE_AUTHSUB_ENABLED # set secure = true for signed AuthSub requests\n if options[:auth_token]\n @client.authsub_token = options[:auth_token] \n # Set private key when upgrading token to session\n @client.authsub_private_key = private_key if @secure\n end\n end",
"def set_email_subscription\n @email_subscription = EmailSubscription.find(params[:id])\n end",
"def initialize email, api_key\n @email = email\n @api_key = api_key\n end",
"def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end",
"def subscribe(recipient)\n subscription = subscriptions.find_or_initialize_by(recipient: recipient)\n return unless subscription.new_record?\n subscription.save\n subscription\n end",
"def create\n @subscription = @target.create_subscription(subscription_params)\n return_back_or_ajax\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/pubsub/v1/pubsub_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|\n config.credentials = credentials\n config.quota_project = @quota_project_id\n config.endpoint = @config.endpoint\n end\n\n @publisher_stub = ::Gapic::ServiceStub.new(\n ::Google::Cloud::PubSub::V1::Publisher::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def initialize address, lifetime\n #@identity = identity\n @address = address\n #@service = nil\n @expiry = Time.now + 0.001 * lifetime\n end",
"def initialize(options = {})\n # Mandatory params\n @client_id = @@client_id || options.fetch(:client_id)\n @client_key = @@client_key || options.fetch(:client_key)\n @tenant_id = @@tenant_id || options.fetch(:tenant_id)\n\n # Optional params\n @subscription_id = @@subscription_id || options[:subscription_id]\n @resource_group = @@resource_group || options[:resource_group]\n @api_version = @@api_version || options[:api_version] || '2015-01-01'\n @grant_type = @@grant_type || options[:grant_type] || 'client_credentials'\n\n # The content-type used for all internal http requests\n @content_type = @@content_type || 'application/json'\n\n # Call the get_token method to set this.\n @token = @@token || options[:token]\n\n # Base URL used for REST calls. Modify within method calls as needed.\n @base_url = Azure::Armrest::RESOURCE\n end",
"def create\n\t\t@subscription = Subscription.new(params[:subscription])\n\t\trespond_to do |format|\n\t\t\tif fonct_new_dup?\n\t\t\t\tobject_orig=Subscription.find(params[:object_orig_id])\n\t\t\tst = @subscription.create_duplicate(object_orig)\n\t\t\telse\n\t\t\tst = @subscription.save\n\t\t\tend\n\t\t\tif st\n\t\t\t\t#format.html { redirect_to(@subscription, :notice => 'Subscription was successfully created.') }\n\t\t\t\tflash[:notice] = 'Subscription was successfully created.'\n\t\t\t\tparams[:id]= @subscription.id\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n\t\t\telse\n\t\t\t\t@ingroups = Group.all\n\t\t\t\t@inprojects = Project.all\n\t\t\t\t@fortypesobjects=Typesobject.get_from_observer\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def initialize(stream, jid, nodename = nil, create_if_not_exist = true)\n super(stream,jid)\n @nodename = nodename\n @jid = jid\n @stream = stream\n\n if create_if_not_exist and not node_exist?\n # if no nodename is given a instant node will created\n # (if the service supports instant nodes)\n @nodename = create_node\n else\n get_subscriptions\n end\n end",
"def subscribe_to_newsletter\n SubscribeToNewsletterService.new(self).call\n end",
"def initialize(*args)\n super\n self[:notify] = [\n \"Service[splunk]\",\n \"Service[splunkd]\",\n ].select { |ref| catalog.resource(ref) } unless catalog.nil?\n\n end",
"def create_inbound_subscription(destination_address, options)\n query = options.merge({ :destination_address => destination_address })\n \n Response.new self.class.post(\"/smsmessaging/inbound/subscriptions\", \n :basic_auth => @auth,\n :body => camelcase_keys(query),\n :headers => SMSIFIED_HTTP_HEADERS\n )\n\n end",
"def initialize\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @g_suite_add_ons_stub = ::Google::Cloud::GSuiteAddOns::V1::GSuiteAddOns::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials\n end",
"def initialize(resource, embed_config={}, options={})\n raise NotImplementedError\n end",
"def initialize\n @client = Savon.client(wsdl: Twinfield::WSDLS[:session])\n end",
"def set_vendor_subscription\n @vendor_subscription = VendorSubscription.find(params[:id])\n end",
"def initialize(topic)\n @topic = topic\n Consumers::Includer.call(self)\n end",
"def initialize\n @wsdl = Reuters::Wsdls.const_get client_name\n @namespace = Reuters::Namespaces.const_get client_name\n @token = Reuters::Client::Token.new\n end",
"def initialize(*args)\n super\n self[:notify] = [\n \"Service[splunk]\",\n \"Service[splunkd]\",\n ].select { |ref| catalog.resource(ref) }\n end",
"def initialize(config) # trackers, domain\n @@config = config\n check_config\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def create_subscription(options)\n stripe_service.create_subscription(options)\n end",
"def initialize(sub_addr = \"tcp://localhost:14532\",\n dealer_addr = \"tcp://localhost:14533\",\n filters = [\":PRIVMSG\",\n \":INVITE\",\n \":JOIN\",\n \":BOOT\",\n \":PART\"])\n \n @sub_addr, @dealer_addr, @filters = sub_addr, dealer_addr, filters\n @sub_sock = Clubot.ctx.socket ZMQ::SUB\n @dealer_sock = Clubot.ctx.socket ZMQ::DEALER\n end",
"def build_twilio_wrapper\n @twilio_wrapper = ::VoiceExtension::TwilioVoiceWrapper::Voice.new\n end",
"def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end",
"def subscription(options = {})\n\t\t\t# provide the client with another (i.e. the external address) if given\n\t\t\tsub = {server: config[:server_external] || config[:server], timestamp: (Time.now.to_f * 1000).round}.merge(options)\n\t\t\tsub[:signature] = Digest::SHA1.hexdigest([config[:secret_token], sub[:channel], sub[:timestamp]].join)\n\t\t\tsub\n\t\tend",
"def initialize(subscription, coupons)\n @subscription = subscription\n @collection = coupons.map{|coupon| Coupon.new(coupon) }\n end",
"def set_subscription\n @subscription = ::Pushar::Core::Subscription.unscoped.find(params[:id])\n end",
"def subscribe\n self.subscribed = true\n end",
"def subscribe(params = {})\n @connection ||= stub_connection\n @subscription = self.class.channel_class.new(connection, CHANNEL_IDENTIFIER, params.with_indifferent_access)\n @subscription.singleton_class.include(ChannelStub)\n @subscription.subscribe_to_channel\n @subscription\n end",
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/cloud/pubsublite/v1/admin_services_pb\"\n\n # Create the configuration object\n @config = Configuration.new Client.configure\n\n # Yield the configuration if needed\n yield @config if block_given?\n\n # Create credentials\n credentials = @config.credentials\n # Use self-signed JWT if the endpoint is unchanged from default,\n # but only if the default endpoint does not have a region prefix.\n enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&\n [email protected](\".\").first.include?(\"-\")\n credentials ||= Credentials.default scope: @config.scope,\n enable_self_signed_jwt: enable_self_signed_jwt\n if credentials.is_a?(::String) || credentials.is_a?(::Hash)\n credentials = Credentials.new credentials, scope: @config.scope\n end\n @quota_project_id = @config.quota_project\n @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id\n\n @operations_client = Operations.new do |config|\n config.credentials = credentials\n config.endpoint = @config.endpoint\n end\n\n @admin_service_stub = ::Gapic::ServiceStub.new(\n ::Google::Cloud::PubSubLite::V1::AdminService::Stub,\n credentials: credentials,\n endpoint: @config.endpoint,\n channel_args: @config.channel_args,\n interceptors: @config.interceptors\n )\n end",
"def initialize\n @params_class = Spree::Adyen::HPP::Params\n @invoice_class = Spree::Adyen::Invoice\n end",
"def create \n @subscription = Subscription.new(params[:subscription])\n \n uri = URI.parse(request.env[\"HTTP_REFERER\"])\n unless %w{ app.atra.obra.org localhost app.americantrackracing.com raceatra.com www.raceatra.com}.include?(uri.host)\n flash[:notice] = \"Cannot send request from '#{uri.host}'\"\n return render(:action => \"new\")\n end\n\n if @subscription.valid?\n email = SubscriptionMailer.create_subscription_request(@subscription)\n SubscriptionMailer.deliver(email)\n redirect_to(:action => \"subscribed\")\n else\n render(:action => \"new\")\n end\n end"
] | [
"0.6230527",
"0.61710626",
"0.6051603",
"0.6007223",
"0.60044414",
"0.5992861",
"0.5931622",
"0.59278744",
"0.59158975",
"0.5833374",
"0.5807633",
"0.5788254",
"0.57842785",
"0.57239157",
"0.57192904",
"0.57192904",
"0.5705709",
"0.5704582",
"0.57011056",
"0.5672389",
"0.5665421",
"0.5649535",
"0.5632948",
"0.5623515",
"0.5623477",
"0.5597462",
"0.5596576",
"0.5595015",
"0.55934685",
"0.5575647",
"0.5534326",
"0.5510218",
"0.5509688",
"0.5502169",
"0.54986346",
"0.54977775",
"0.546125",
"0.5443371",
"0.5432023",
"0.5423513",
"0.5406433",
"0.5406047",
"0.5383971",
"0.5383387",
"0.53832847",
"0.53654766",
"0.53605616",
"0.535844",
"0.5354256",
"0.53496903",
"0.53441185",
"0.53316474",
"0.53285193",
"0.53236884",
"0.53213865",
"0.53149295",
"0.5311528",
"0.5280844",
"0.5278501",
"0.52746874",
"0.5265948",
"0.52634627",
"0.52606606",
"0.5252978",
"0.52439004",
"0.52345425",
"0.5232828",
"0.52290654",
"0.52222",
"0.5220313",
"0.5218208",
"0.5217084",
"0.5206561",
"0.5205319",
"0.5202323",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.5198799",
"0.51963735",
"0.51939195",
"0.51935893",
"0.5193186",
"0.5189606",
"0.51844233",
"0.51842093",
"0.51822233",
"0.5179708",
"0.5178481",
"0.51771563",
"0.5176894"
] | 0.0 | -1 |
route for verifying cas service tickets | def devise_cas_server(mapping, controllers)
# Add specific cas server routes
# "Default" routes are create in the "normal" devise session configuration
resource :session, :only => [], :controller =>
controllers[:cas_server_sessions], :path => '' do
#get :new, :path => mapping.path_names[:sign_in], :as => "new"
#post :create, :path => mapping.path_names[:sign_in], :as => "create"
#match :destroy, :path => mapping.path_names[:sign_out], :as => "destroy"
get "serviceValidate",
:to => "#{controllers[:sessions]}#service_validate"
get "validate",
:to => "#{controllers[:sessions]}#validate"
get "proxyValidate",
:to => "#{controllers[:sessions]}#service_validate"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_ticket(options = {})\n query = create_ticket_query(options)\n make_request(Briareus::Torii::VALIDATE_TICKET, query)\n end",
"def authenticate!\n last_ticket = session[:cas_last_valid_ticket]\n ticket = read_ticket(params)\n\n if ticket\n if resource = mapping.to.authenticate_with_cas_ticket(ticket)\n session[:cas_devise_resouce_name] = mapping.class_name\n session[:cas_last_valid_ticket] = ticket\n success!(resource)\n else\n fail(:invalid)\n end\n elsif returning_from_cas?\n fail(:invalid)\n else\n redirect!(login_url)\n end\n end",
"def ticket\n end",
"def issue_service_ticket\n if tgt = has_valid_tgt and has_service_info?\n st = ServiceTicket.create(\n :service => cookies[:service],\n :username => current_user.id,\n :granted_by_tgt_id => tgt.id\n )\n\n service_back_url = cookies[:service_back_url]\n cookies.delete :service\n cookies.delete :service_back_url\n\n return service_back_url + \"?ticket=#{st.ticket}\"\n end\n end",
"def request_login_ticket\n uri = URI.parse(login_url+'Ticket')\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = (uri.scheme == 'https')\n https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)\n res = https.post(uri.path, ';')\n \n raise CASException, res.body unless res.kind_of? Net::HTTPSuccess\n \n res.body.strip\n end",
"def process(params = nil)\n params ||= {}\n ticket = CASino::ServiceTicket.where(ticket: params[:ticket]).first\n if !params[:service].nil? && ticket_valid_for_service?(ticket, params[:service], !!params[:renew])\n @listener.validation_succeeded(\"yes\\n#{ticket.ticket_granting_ticket.user.username}\\n\")\n else\n @listener.validation_failed(\"no\\n\\n\")\n end\n end",
"def check\n salt = params[:salt]\n address = params[:address]\n ticket = Ticket.find_by_address(address)\n verified = ticket.verify(salt)\n paid = TicketAddresses.ticket_address_paid(address)\n status = ticket.status\n\n render json: {\n verified: verified,\n paid: paid,\n status: status,\n }\n end",
"def cas_authenticate(username,password,request)\n cas_base_url = SETTINGS.cas[:host]\n client = CASClient::Client.new(\n :cas_base_url => cas_base_url\n )\n\n service_url = read_service_url(request) \n\n # get login ticket for cas\n session[\"cas_lt\"] = client.request_login_ticket\n\n credentials = { \n :username => username,\n :password => password,\n :service => service_url,\n :lt => session[\"cas_lt\"]\n }\n\n # send login data to cas server\n uri = URI.parse(\"#{cas_base_url}/login\") unless uri.kind_of? URI\n req = Net::HTTP::Post.new(uri.path)\n req.use_ssl = (uri.scheme == 'https')\n if req.use_ssl?\n req.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n req.set_form_data(credentials)\n cas_login = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n\n response = CASClient::LoginResponse.new(cas_login)\n session[:cas_ticket] = response.ticket\n\n # we create a ServiceTicket object out of this\n st = read_ticket(response.ticket, service_url)\n\n # at this point we get a service ticket and we validate it\n validation = client.validate_service_ticket(st) unless st.nil?\n\n if validation.success\n session[:access_token] = st.user\n end unless validation.nil?\n\n return session[:access_token]\n end",
"def new\n redirect_to('/auth/cas')\n end",
"def ticket\r\n TicketController.instance\r\n end",
"def authenticate\n mandatory_keys = [:app_id, :ticket, :sign]\n if params.slice(*mandatory_keys).values.any?(&:nil?)\n render json: to_response('Some params are lost') and return\n elsif @service_provider.nil?\n render json: to_response('ServiceProvider error') and return\n elsif not CommonUtils.valid_sign?(@service_provider.app_id, params[:ticket], @service_provider.credential, params[:sign])\n render json: to_response(\"Bad request: Invalid parameter(s)\") and return\n end\n\n ticket = Ticket.recover(@service_provider, params[:ticket])\n if ticket.blank? || ticket.expired?\n render json: to_response(\"Invalid ticket\")\n else\n ticket.used = true\n ticket.save!\n render json: to_response(\"success\", ticket.user)\n end\n end",
"def index\n @tickets = Ticket.all\n authorize @tickets\n end",
"def show_ticket\n end",
"def get_service_ticket\n tgt = get_ticket_granting_ticket\n return nil if tgt.blank?\n\n puts tgt\n puts Rails.configuration.x.umls.umls_service\n response = RestClient.post(tgt, { service: Rails.configuration.x.umls.umls_service })\n if response.code != 200 # expect a 200/OK response\n return nil\n end\n\n response.body\n end",
"def return_to_path_with_cas_token\n unless master_domain? params[:_return_to]\n token = SecureToken.new\n token.expires_at = 5.minutes.from_now\n token[:type] = 'cas'\n token[:user_id] = User.current.id.to_s\n token.save!\n \n return return_to_path(:cas_token => token.token)\n end\n \n return_to_path\n end",
"def sign_agreement_verify\n @is_verify = true\n @candidate = Candidate.find(params[:id])\n end",
"def test_checkin\n req = c.checkin(\"abc123\", 123, &blk)\n\n assert_sent(req.tag, :verb => V::CHECKIN, :path => \"abc123\", :cas => 123)\n assert_recv(reply(req.tag, :cas => 123))\n end",
"def service_validate_url(service, ticket)\n service = service.sub(/[?&]ticket=[^?&]+/, '')\n url = append_service(@service_validate_url, service)\n url << '&ticket=' << Rack::Utils.escape(ticket)\n end",
"def verify\n head :ok\n end",
"def test_createticket\n\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n\n end",
"def verification_letter(user)\n @user = user\n authorization = @user.authorizations.where(confirmed: false).first\n @url = \"http://localhost:3000/verifications/#{@user.id}/#{authorization.id}/#{authorization.checksum}/verify\"\n\n mail to: @user.email\n end",
"def show\r\n # @ticket = Contact::Ticket.find_by_uuid(params[:id])\r\n raise UnknowsAction\r\n end",
"def sign_agreement\n @is_verify = false\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end",
"def call_authorization_issue_api(ticket, subject, authTime)\n return call_api(\"/api/auth/authorization/issue\", {\n \"ticket\" => ticket,\n \"subject\" => subject,\n \"authTime\" => authTime\n })\nend",
"def test_new_ticket_bannerite()\n get :new, {}, {:cas_user => users(:banner_user).username}\n assert_response :redirect\n assert_redirected_to :controller => 'login', :action => 'index'\n assert_equal @no_permission_msg, flash[:notice]\n end",
"def verify_action\n if current_user.customer?\n redirect_to root_url\n end\n end",
"def request_cas_response(uri, type)\n log.debug \"Requesting CAS response for URI #{uri}\"\n \n uri = URI.parse(uri) unless uri.kind_of? URI\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = (uri.scheme == 'https')\n https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)\n \n begin\n raw_res = https.start do |conn|\n conn.get(\"#{uri.path}?#{uri.query}\")\n end\n rescue Errno::ECONNREFUSED => e\n log.error \"CAS server did not respond! (#{e.inspect})\"\n raise \"The CAS authentication server at #{uri} is not responding!\"\n end\n \n # We accept responses of type 422 since RubyCAS-Server generates these\n # in response to requests from the client that are processable but contain\n # invalid CAS data (for example an invalid service ticket).\n if raw_res.kind_of?(Net::HTTPSuccess) || raw_res.code.to_i == 422\n log.debug \"CAS server responded with #{raw_res.inspect}:\\n#{raw_res.body}\"\n else\n log.error \"CAS server responded with an error! (#{raw_res.inspect})\"\n raise \"The CAS authentication server at #{uri} responded with an error (#{raw_res.inspect})!\"\n end\n \n type.new(raw_res.body)\n end",
"def check_services(claim)\n if claim.services.count < 1 \n flash[:error] = \"Kindly add a service to this claim to continue\"\n redirect_to addService_insurer_claim_path(claim)\n end\n\n end",
"def cas_client_sign_in\n render nothing: true, status: :unauthorized\n end",
"def session_ticket(options = {})\n xml = signon_app_cert_rq\n response = commit('session_ticket', xml)\n end",
"def login_ticket\n LoginTicket\n end",
"def get_payment_ticket\n end",
"def test_solveticket\n\n # create ticket\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n end",
"def index\n respond_with(@tickets)\n end",
"def service_validate_url\n URI.join(cas_url, 'serviceValidate').to_s\n end",
"def service_validate_url\n URI.join(cas_url, 'serviceValidate').to_s\n end",
"def verify\n\n end",
"def verify\n end",
"def confirm_url\n if @tenant_alias.properly_configured?\n @tenant_alias.update(verified: true)\n ApartmentAcmeClient::RenewalService.run!\n flash[:notice] = \"Alias verified\"\n else\n flash[:alert] = \"Alias failed to be verified\"\n end\n redirect_to tenant_aliases_path\n end",
"def test_workflow\n\n #create a random agent\n randomagent = UUIDTools::UUID.timestamp_create.to_s\n @zendeskclient.createuser(randomagent+='@gmail.com', 'Harish', \"4\", \"0\", [134692])\n assert_equal(201, @zendeskclient.responsecode)\n #lets make sure the /user/#{id}.xml exists\n\n usercreationresponse = @zendeskclient.response\n begin\n resource = RestClient::Resource.new usercreationresponse, @username, @pswd\n rescue\n assert(false) # if we hit this assertion for any reason means, we cannot access the user file\n # which means we have failed\n end\n\n # create ticket with the same user as created above as requester\n # this is implemented by using the same email id as before\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', randomagent)\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match(@host))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n\n end",
"def verified_request?; end",
"def verify\n if !params[:token] || !params[:company_id]\n flash[:alert] = t(:invalid_verification)\n redirect_to root_path\n else\n @company = Company.find(params[:company_id])\n @user = @company.users.find_by_remember_token(params[:token])\n\n if @user.nil? || @user.state != STATE[:unchecked]\n flash[:alert] = t(:invalid_verification)\n redirect_to root_path\n end\n end\n end",
"def verify()\n # TODO\n end",
"def authenticate\n unless FfcrmVend.config.token == params[:token]\n render :text => \"\", :status => :unauthorized\n end\n end",
"def index\n res = create_request2(root_url + '/login/auth', 'tequila.epfl.ch')\n redirect_to ('https://tequila.epfl.ch/cgi-bin/tequila/requestauth?request' + res)\n end",
"def request_authorization\n create_ticket\n verify_resource_owner or return\n render_authorize_form\n end",
"def show\n @ticket = Ticket.find_by_reference(params[:id])\n end",
"def received(ticket)\n @ticket = ticket\n @greeting = \"Hi \" + @ticket.name + ' !'\n\n mail to: @ticket.email, subject: 'Confirming your request with unique reference.'\n end",
"def verify\n end",
"def show\n if (! granted_for?('tickets')) && (! params[:reservation_code] )\n render :text => _('Sorry, Access denied'), :layout => get_application_layout\n return true\n end\n @ticket = Ticket.find(params[:id])\n if params[:reservation_code] == @ticket.reservation_code\n respond_to do |format|\n format.html\n format.xml { render :xml => @ticket }\n end\n else\n render :text => _('Sorry, Access denied'), :layout => get_application_layout\n end\n end",
"def process(cookies = nil, user_agent = nil)\n cookies ||= {}\n tgt = find_valid_ticket_granting_ticket(cookies[:tgt], user_agent)\n if tgt.nil?\n @listener.user_not_logged_in\n else\n @listener.two_factor_authenticators_found(tgt.user.two_factor_authenticators.where(active: true))\n end\n end",
"def verify_email\n service_response = UserManagement::DoubleOptIn.new(params).perform\n render_api_response(service_response)\n end",
"def index\n @tickets = current_user.tickets\n end",
"def index\n @tickets = current_user.tickets\n end",
"def ticket_dashboard\n @user = User.first \n @ticket = Ticket.find_by(id: params[:id])\n end",
"def validate_ticket!(value)\n ticket = value && find_by_value(value)\n raise CasServer::InvalidTicket.new(self.new) if ticket.nil?\n raise CasServer::ExpiredTicket.new(ticket) if ticket.expired?\n raise CasServer::ConsumedTicket.new(ticket) if ticket.consumed?\n ticket.consume!\n end",
"def create\n @ticket = OTRS::Ticket.new(params[:ticket])\n\n respond_to do |wants|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n wants.html { redirect_to(@ticket) }\n wants.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n wants.json { render :json => @ticket, :status => :created, :location => @ticket }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n @ticket = Ticket.new(params[:ticket])\n @ticket.ticket_status_id = 1\n @ticket.requestor_id = current_user.id\n @ticket.account_id = current_user.company.account_id\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(@ticket, :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def verify_credentials\n get('/account/verify_credentials.json')\n end",
"def checkout\n @appointment = current_user.appointments.find(params[:appointment_id])\n\n # TO DO: Process the credit card of the user here\n end",
"def verification_link\n\n service_response = SimpleTokenApi::Request::User.new(\n host_url_with_protocol,\n request.cookies,\n {\"User-Agent\" => http_user_agent}).basic_detail(GlobalConstant::TemplateType.verification_template_type)\n\n # Check if error present or not?\n unless service_response.success?\n render_error_response(service_response)\n return\n end\n\n @presenter_obj = ::Web::Client::Setup.new(service_response, params)\n redirect_to '/token-sale-blocked-region', status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.is_blacklisted_ip?(get_ip_to_aml_countries)\n redirect_to \"/login\", status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.has_sale_ended?\n\n @user = service_response.data[\"user\"]\n redirect_if_step_not_reachable(@user[\"user_token_sale_state\"], GlobalConstant::TokenSaleUserState.verification_page_allowed_states)\n return if has_performed?\n\n set_page_meta_info(@presenter_obj.custom_meta_tags)\n end",
"def index\n \n @tickets = Ticket.all\n @tickets = @tickets.order(:updated_at)\n @tickets = @tickets.joins(:payment).where(\"payments.id = ?\",params[:clave]) unless params[:clave]==\"\" or params[:clave].nil?\n \n @payment = Payment.find(params[:clave])\n end",
"def check(uri, username=nil, password=nil, service_doc = nil,\n requested_e_coll = nil, requested_m_coll = nil)\n \n @authent = Authent.new(username, password)\n @reporter.header = uri\n ::Ape.conf[:REQUESTED_ENTRY_COLLECTION] = requested_e_coll if requested_e_coll\n ::Ape.conf[:REQUESTED_MEDIA_COLLECTION] = requested_m_coll if requested_m_coll\n begin\n might_fail(uri, service_doc)\n rescue Exception\n @reporter.error(self, \"Ouch! Ape fall down go boom; details: \" +\n \"#{$!}\\n#{$!.class}\\n#{$!.backtrace}\")\n end\n end",
"def verify_charge(id)\n\n response = get_request(\"#{base_url}/transactions/#{id}/verify\")\n return response\nend",
"def send_verify_email_link\n service_response = UserManagement::SendDoubleOptInLink.new(params).perform\n render_api_response(service_response)\n end",
"def buyticket\n @ticket = Ticket.new(ticket_params)\n @event = Event.find(@ticket.event_id)\n if @ticket.valid?\n @ticket.save\n # this will have to change to credit card functionality later\n redirect_to events_url, notice: 'You successfully purchased your ticket to this event.'\n # redirect to my groups url (when logged in!)\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end",
"def zendesk_agent_url\n \"https://getchef.zendesk.com/agent/tickets/#{zendesk_id}\"\n end",
"def call_authorization_fail_api(ticket, reason)\n return call_api(\"/api/auth/authorization/fail\", {\n \"ticket\" => ticket,\n \"reason\" => reason\n })\nend",
"def submit_ticket(ticket)\n @ticket = ticket\n\n mail :to => \"[email protected]\", \n :subject => \"Ticket: \" + ticket.id.to_s,\n :reply_to => \"[email protected]\"\n end",
"def send_recipt(ticket)\n @ticket = ticket\n\n mail to: ticket.email\n end",
"def verify\n if verify_donor\n json = { success: true, location: subscriber_url(current_subscriber) }\n else\n json = { success: false, message: \"We couldn't verify this account. Please check your info.\" }\n end\n\n respond_to do |format|\n format.json do\n render json: json\n end\n end\n end",
"def verify\n create_order\n start_challenge\n wait_verify_status\n check_verify_status\n rescue Acme::Client::Error => e\n retry_on_verify_error(e)\n end",
"def destroy\n ticket.destroy!\n render status: :ok, nothing: true\n end",
"def delete_ticket\n @ticket = Ticket.find(params[:id])\n @ticket.delete\n \n render :nothing => true\n end",
"def show\n @ticket = Ticket.find(params[:id])\n \n end",
"def verify_primary_account_holder\n redirect_to dashboard_path and return\n end",
"def ticket\n @ticket ||= @api.get_ticket['ticket']\n end",
"def show\n if @ticket\n if ProjectUser.verify_role(current_user.id, @ticket.project_id, 'client')\n render json: Ticket.build_ticket_object(@ticket, current_user.id), status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no ticket found with id of #{params[:project_id]}\" }, status: 404\n end\n end",
"def authenticate!\n @client = Octokit::Client.new\n url = @client.authorize_url(CLIENT_ID)\n redirect url\nend",
"def verify_delete(id)\n request(:delete, \"verify/#{id}\")\n end",
"def overall_tickets\n\n end",
"def check_enrollment transaction, token, postback_url\n redirect_params = ActiveSupport::OrderedHash.new\n redirect_params['pageGenerationMode'] = 'CUSTOMIZED'\n redirect_params['responseUrl'] = postback_url\n order_params = ActiveSupport::OrderedHash.new\n order_params['amount'] = transaction.amount.to_s\n order_params['currency'] = transaction.currency\n params = ActiveSupport::OrderedHash.new\n params['apiOperation'] = 'CHECK_3DS_ENROLLMENT'\n params['3DSecure'] = {'authenticationRedirect' => redirect_params}\n params['session'] = {'id' => token}\n params['order'] = order_params\n\n ThreeDomainSecureResponse.new(request(:put, \"/merchant/#{merchant_id}/3DSecureId/#{transaction.three_domain_id}\", params))\n end",
"def authenticate!\n Authenticator.verify!(params['token'])\n end",
"def route\n #TODO\n end",
"def check_agreement\n if ([email protected]?)\n redirect_to(:action => :agreement)\n return false\n end\n end",
"def send_logout_notification_for_service_ticket(st)\n uri = URI.parse(st.service)\n http = Net::HTTP.new(uri.host, uri.port)\n #http.use_ssl = true if uri.scheme = 'https'\n\n time = Time.now\n rand = CASServer::Utils.random_string\n\n path = uri.path\n path = '/' if path.empty?\n\n req = Net::HTTP::Post.new(path)\n req.set_form_data(\n 'logoutRequest' => %{<samlp:LogoutRequest ID=\"#{rand}\" Version=\"2.0\" IssueInstant=\"#{time.rfc2822}\">\n<saml:NameID></saml:NameID>\n<samlp:SessionIndex>#{st.ticket}</samlp:SessionIndex>\n</samlp:LogoutRequest>}\n )\n\n begin\n http.start do |conn|\n response = conn.request(req)\n\n if response.kind_of? Net::HTTPSuccess\n $LOG.info \"Logout notification successfully posted to #{st.service.inspect}.\"\n return true\n else\n $LOG.error \"Service #{st.service.inspect} responed to logout notification with code '#{response.code}'!\"\n return false\n end\n end\n rescue Exception => e\n $LOG.error \"Failed to send logout notification to service #{st.service.inspect} due to #{e}\"\n return false\n end\n end",
"def index\n @tickets = get_current_user_ticket_list(@user)\n end",
"def show\n @tickets_count = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.count\n @ticket = Helpdesk::Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ticket }\n end\n end",
"def verify\n @educator = Educator.find(params[:id])\n respond_to do |format|\n if @educator.update(verified: true)\n format.html { redirect_to current_admin, notice: 'Educator successfully verified.' }\n format.json { render current_admin, status: :ok, location: @educator }\n else\n format.html { redirect_to current_admin }\n format.json { render json: @educator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_authentication\n load_token\n return false if !@token || @token.empty?\n res = get '/'\n !res.key?('error')\n end",
"def orphan_cas\n @greeting = \"Hi\"\n\n tag :incidents, :orphan_cas\n mail to: \"[email protected]\"\n end",
"def show\n @ticket = Ticket.find(params[:id])\n end",
"def verify_team\n set_team_from_team_id\n unless ( @team )\n flash[:error] = I18n.t(:invalid_action_request) + ' - ' + I18n.t('meeting.errors.missing_team_id')\n redirect_to( meetings_current_path() ) and return\n end\n end",
"def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def verify(id)\n Verify.new(request(:get, \"verify/#{id}\"))\n end",
"def process(params = nil, user_agent = nil)\n cookies ||= {}\n tgt = find_valid_ticket_granting_ticket(params[:tgt], user_agent, true)\n if tgt.nil?\n @listener.user_not_logged_in\n else\n validation_result = validate_one_time_password(params[:otp], tgt.user.active_two_factor_authenticator)\n if validation_result.success?\n tgt.awaiting_two_factor_authentication = false\n tgt.save!\n begin\n url = unless params[:service].blank?\n acquire_service_ticket(tgt, params[:service], true).service_with_ticket_url\n end\n if tgt.long_term?\n @listener.user_logged_in(url, tgt.ticket, CASino.config.ticket_granting_ticket[:lifetime_long_term].seconds.from_now)\n else\n @listener.user_logged_in(url, tgt.ticket)\n end\n rescue ServiceNotAllowedError => e\n @listener.service_not_allowed(clean_service_url params[:service])\n end\n else\n @listener.invalid_one_time_password\n end\n end\n end",
"def index\n @contracts = Contract.all\n authorize @contracts\n end",
"def verify(email, options = {})\n body = options.fetch(\"query\", {})\n\t\n email = CGI::escape(email)\n\n @client.get(\"/verify?email=#{email}\", body, options)\n end",
"def test\n notify_credit_problem\n redirect_to(:action => 'show')\n end",
"def check!()\n # Check to see if the ticket is expired\n if self.expired?\n return { :success => false, :message => \"Ticket Expired\", :resultcode => 0, :date => Time.now.strftime(\"%Y-%m-%d\"), :eventid => self.event_id }\n # Check to see if the available entries have been exhausted\n elsif self.used?\n return { :success => false, :message => \"No Entries Available\", :resultcode => 0, :date => Time.now.strftime(\"%Y-%m-%d\"), :eventid => self.event_id }\n # Otherwise, grant access\n else\n # Decrement available entries\n self.update_attributes({:entries_used => self.entries_used + 1, :entries_available => self.entries_available - 1})\n # Log an entry under the ticket\n Entry.log(self)\n # Return success!\n return { :success => true, :message => \"Access Granted\", :resultcode => 1, :date => Time.now.strftime(\"%Y-%m-%d\"), :eventid => self.event_id }\n end\n end"
] | [
"0.6015382",
"0.59969294",
"0.5995943",
"0.5924438",
"0.5924347",
"0.58806807",
"0.57586455",
"0.5751043",
"0.574028",
"0.5724429",
"0.5716088",
"0.56804955",
"0.5601082",
"0.5588801",
"0.5572531",
"0.55346036",
"0.54623085",
"0.5427396",
"0.538374",
"0.5369777",
"0.53545094",
"0.53491455",
"0.5340148",
"0.53394246",
"0.52841765",
"0.52753836",
"0.52500474",
"0.5216343",
"0.5210422",
"0.5186745",
"0.51854056",
"0.5184109",
"0.5151855",
"0.5150427",
"0.51490754",
"0.51490754",
"0.5135851",
"0.51342356",
"0.5130971",
"0.51149964",
"0.511395",
"0.5099842",
"0.5089513",
"0.5077833",
"0.5061796",
"0.5054827",
"0.5051771",
"0.5047823",
"0.5047818",
"0.50341713",
"0.5024138",
"0.502206",
"0.5010057",
"0.5010057",
"0.49951217",
"0.49912247",
"0.49910894",
"0.49866742",
"0.49735993",
"0.49543986",
"0.49522606",
"0.4949711",
"0.49482325",
"0.4946492",
"0.49405706",
"0.49387282",
"0.4919565",
"0.49178088",
"0.49050707",
"0.49019054",
"0.48985612",
"0.48976934",
"0.48958212",
"0.4895182",
"0.48712498",
"0.4870755",
"0.48654547",
"0.48640013",
"0.48593786",
"0.48589057",
"0.48520795",
"0.48487598",
"0.48459917",
"0.48456278",
"0.48420218",
"0.4841549",
"0.4836819",
"0.48281193",
"0.4827545",
"0.482418",
"0.48208183",
"0.48189506",
"0.48176876",
"0.48174456",
"0.48160586",
"0.48142964",
"0.48132524",
"0.4812169",
"0.48112214",
"0.48075742"
] | 0.56996137 | 11 |
can modify an address if it's not been used in an completed order | def editable?
new_record? || (Spree::Order.complete.where("bill_address_id = ? OR
ship_address_id = ? AND
state != 'complete' AND
shipment_state != 'shipped'", id, id).count == 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_address(user, address)\n logger.debug { \"Work around caTissue prohibition of #{user} address #{address} update by creating a new address record for a dummy user...\" }\n address.identifier = nil\n perform(:create, address) { create_object(address) }\n logger.debug { \"Worked around caTissue address update bug by swizzling the #{user} address #{address} identifier.\" }\n perform(:update, user) { update_object(user) }\n user\n end",
"def set_address\n end",
"def fix(address)\n @address = address\n end",
"def fix(address)\n @address = address\n end",
"def update_order_addresses\n order = current_order\n if order.bill_address.blank? || order.shipping_address.blank?\n order.bill_address ||= build_bill_address(payment_details_response)\n order.shipping_address ||= build_shipping_address(payment_details_response)\n\n complete_order_step(order, 'address')\n end\n end",
"def change_address(new_address)\n @address_change_verification ||= verifications.create(type: 'AddressChangeVerification')\n address_change_verification.recipient = new_address\n end",
"def delivery_address_update\n # stores the current delivery address\n delivery_address = @current_user.addresses.find_by(delivery_address: true)\n delivery_address.delivery_address = nil\n delivery_address.save!\n # changes the current delivery address to the given address id as a parameter\n address = @current_user.addresses.find(params[:id])\n address.delivery_address = true\n address.save!\n redirect_to cart_items_path\n end",
"def edit_address(edited_address)\n address = Address.find(edited_address.uid)\n address.attributes = edited_address.attributes\n address.save!\n end",
"def add_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def check_address_owner(id, type)\n if a = Spree::Address.find_by_id(id)\n if a.user_id.present? && a.user_id != self.user_id\n raise \"Attempt to assign address #{a.id.inspect} from user #{a.user_id.inspect} to order #{self.number} from user #{self.user_id.inspect}\"\n end\n end\n\n id = a.try(:id)\n if type == :bill\n self['bill_address_id'] = id\n self.bill_address.try(:reload) if id\n else\n self['ship_address_id'] = id\n self.ship_address.try(:reload) if id\n end\n end",
"def remove_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n end",
"def ship_address=(address)\n be_default = Spree::Config.automatic_default_address\n save_in_address_book(address.attributes, be_default) if address\n end",
"def can_update_addresses?\n !complete?\n end",
"def edit_address(order_or_user, address_id, expect_success, values, type=nil)\n visit_edit_address(order_or_user, address_id)\n fill_in_address(values, type)\n click_button Spree.t('actions.update')\n\n if expect_success\n expect_address_collection_path(order_or_user)\n expect(page).to have_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n expect(path_with_query).to eq(spree.admin_address_path(address_id, user_id: @user_id, order_id: @order_id))\n end\n end",
"def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end",
"def update_address_id\n if params[:order]\n\n # [:order][:ship_address_id] was inserted by the address book\n # it will be blank if no address from the book was selected\n # it will have the id if an address from the book was selected\n \n if params[:order][:ship_address_id]\n ship_address_id = params[:order][:ship_address_id]\n params[:order].delete :ship_address_id\n\n if !ship_address_id.blank?\n address = Address.find_by_id( ship_address_id )\n if address\n @order.ship_address = address\n params[:order].delete :ship_address_attributes\n end\n return true\n end\n end\n if params[:order][:bill_address_id]\n\n bill_address_id = params[:order][:bill_address_id]\n params[:order].delete :bill_address_id\n\n if !bill_address_id.blank?\n bill_address = Address.find_by_id( bill_address_id )\n if bill_address\n @order.bill_address = bill_address\n params[:order].delete :bill_address_attributes\n end\n return true\n end\n end\n true\n end\n end",
"def chkout_modify_existing_address\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_modify_existing_address, a.id(\"change_address\")\n return ToolTag.new(a.id(\"change_address\"), __method__, self)\n end",
"def update_or_create_address(attributes)\n if attributes[:id]\n # TODO: Delete this part of the IF? It never gets called during tests.\n address = Spree::Address.find(attributes[:id])\n if address.editable?\n address.update_attributes(attributes)\n else\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n end\n else\n address = Spree::Address.new(attributes)\n end\n address\n end",
"def set_completed_address\n if self.street && self.number\n address = \"#{ self.street }, #{ self.number }\"\n\n unless self.complement.blank?\n address += \", #{ self.complement }\"\n end\n\n if self.neighborhood\n address += \", #{ self.neighborhood }\"\n end\n\n if self.city && self.city.state\n address += \", #{ self.city.name } - #{ self.city.state.name }\"\n end\n\n address += \" - Brasil\"\n\n self.completed = address\n end\n end",
"def update_and_merge(address, addresses)\n if !address.editable? # Should not happen via UI unless order has detached address not on user\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n return address\n end\n\n user = address.user\n new_address = address.clone\n new_address.attributes = address_params\n new_match = addresses.find(new_address)\n old_match = addresses.find(address)\n\n attrs = address_params\n\n if new_match && new_match != old_match\n # The new address data matches a group, the existing data potentially\n # matches a different group. Need to destroy the old group, deduplicate\n # and modify the new group, and reassign default addresses as needed.\n address = new_match.primary_address\n\n # Destroy any old matching addresses, if possible.\n old_match.destroy if old_match\n new_match.destroy_duplicates\n\n # Update any remaining editable addresses.\n old_match.update_all_attributes(attrs) if old_match\n new_match.update_all_attributes(attrs)\n elsif old_match\n # The old address data matches a group, the new data is identical or does\n # not match a group. Need to update the existing addresses with the new\n # data and deduplicate.\n address = old_match.primary_address\n\n # Deduplicate and update the existing addresses.\n old_match.destroy_duplicates\n old_match.update_all_attributes(attrs)\n else\n # No matching group; just update the address and rely on order and user\n # callbacks to synchronize addresses.\n address.update_attributes(attrs)\n end\n\n # Update default address assignments in case they were destroyed\n if address.user_id && user && address.user_id == user.id\n user.bill_address_id = address.id if new_match.try(:user_bill) || old_match.try(:user_bill)\n user.ship_address_id = address.id if new_match.try(:user_ship) || old_match.try(:user_ship)\n\n if user.changed? && !user.save\n address.errors.add(:user, user.errors.full_messages.to_sentence)\n end\n end\n\n return address, new_match, old_match\n end",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def original_address\n super\n end",
"def assign_from_address!(address)\n self.address_line1 = address.address_line1\n self.address_line2 = address.address_line2\n self.locality = address.town\n self.county = address.county\n self.country = address.country || 'GB'\n self.postcode = address.postcode\n end",
"def add_or_replace_address(address, existing_addresses)\n # Update the registration's nested addresses, replacing any existing address of the same type\n updated_addresses = existing_addresses\n matched_address = updated_addresses.find(existing_address.id) if existing_address\n\n if matched_address\n updated_addresses.delete(matched_address)\n matched_address.delete\n end\n\n updated_addresses << address if address\n\n updated_addresses\n end",
"def before_address\n @order.bill_address ||= current_user.try(:bill_address).try(:clone) || Address.new(:country => default_country)\n @order.ship_address ||= current_user.try(:ship_address).try(:clone) || Address.new(:country => default_country)\n end",
"def billing_address=( address ) \n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.billing_address_id = duplicate_address.id\n else\n address.save\n self.billing_address_id = address.id\n end\n end",
"def edit_address\n traveller = Traveller.find(params[:pk])\n address = params[:value]\n\n coordinates = GoogleAPIGeocoder.do_geocode(address)\n\n if coordinates.nil?\n render json: {success: false, msg: 'Unable to find the location of the given address. Please check that it is correct.'}\n else\n traveller.update(address: address, latitude: coordinates[0], longitude: coordinates[1])\n\n if current_user.nil?\n if session[:trip] != nil\n travellers = session[:trip].travellers\n travellers[travellers.index(traveller)].address = params[:value]\n end\n\n if session[:travellers] != nil\n session[:travellers][session[:travellers].index(traveller)].address = params[:value]\n end\n end\n\n render json: {success: true}\n end\n end",
"def address=(value)\n @address = value\n end",
"def address=(value)\n @address = value\n end",
"def change_address\n @change_address || @inputs.keys.first\n end",
"def cleanse_address(address)\n cleansed_address = SOAAddressCleanser.cleanse_address(address)\n cleansed_address.save!\n end",
"def address_change\n @update_cart_invoice = zip_code_changed?\n true\n end",
"def delink_addresses_validation\n if bill_address.try(:user_id)\n bill_copy = bill_address.clone_without_user\n bill_copy.save\n self.bill_address = bill_copy\n end\n\n if ship_address && (\n ship_address.user_id ||\n (ship_address.id && ship_address.id == bill_address.try(:id)) ||\n (ship_address.changed? && ship_address == bill_address))\n ship_copy = ship_address.clone_without_user\n ship_copy.save\n self.ship_address = ship_copy\n shipments.update_all address_id: ship_address_id\n end\n end",
"def add_place_id_to_address(place_id, address_id)\n if where(:id => address_id).first.place_id == -1\n update(address_id, :place_id => place_id)\n end\n end",
"def address=(address)\n set_if_changed(:address, address.to_s) do\n invalidate_cache!\n end\n end",
"def make_addresses_editable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_editable?, :editable?\n def editable?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #editable? method\n Spree::Address.class_eval do\n alias_method :editable?, :orig_editable?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_can_update_addresses?\n end\n end\n end\n end",
"def update_fetch_address( atts = {} )\n self.fetch_address = (self.fetch_address || {}).merge( atts )\n end",
"def set_street_address_1_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def strip_order_address_users(order)\n order.bill_address.try(:update_attributes!, user_id: nil)\n order.ship_address.try(:update_attributes!, user_id: nil)\n order\n end",
"def associate_address\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.present?\n @user.update_attributes(bill_address_id: order.billing_address.id, ship_address_id: order.shipping_address.id)\n end\n end",
"def autosave_associated_records_for_address\n if new_address = Address.find_by_streetAddress_and_locality(address.streetAddress, address.locality) then\n self.address = new_address\n else\n self.address.save!\n self.address_id = address.id\n end\n if (self.latitude == 0 && self.longitude == 0)\n geocode_address\n end\n self.valid?\n end",
"def set_reserved_address\n @reserved_address = ReservedAddress.find(params[:id])\n end",
"def add_state_to_addresses_activerecord\n\t\taddresses = StreetAddress.find(:all, :select => \"id\", \n\t\t :conditions => [\"source_id = ? AND state_id IS NULL\", @source.id])\n\t\taddresses.each do |address|\n\t\t\taddr = StreetAddress.find(address.id)\n\t\t\taddr.state = addr.street_segments.first.precinct.locality.state\n\t\t\taddr.save\n\t\tend\n\tend",
"def touch_addresses\n if changes.include?(:bill_address_id) && self.bill_address.present?\n self.bill_address.touch\n end\n\n if changes.include?(:ship_address_id) && self.ship_address.present?\n self.ship_address.touch\n end\n end",
"def add_or_update_address\n if @property.address !=nil\n @address = @property.address\n #client id added in query\n @address.update_attributes(params[:real_estate_property][:address_attributes])\n else\n #client id added in query\n @address = Address.store_address_details(params[:real_estate_property][:address_attributes][:txt],params[:real_estate_property][:address_attributes][:city], params[:real_estate_property][:address_attributes][:zip],params[:real_estate_property][:address_attributes][:province])\n @property.address_id = @address.id\n end\n end",
"def shipping_address=( address )\n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.shipping_address_id = duplicate_address.id\n else\n address.save\n self.shipping_address_id = address.id\n end\n end",
"def preselect_existing_address\n return unless can_preselect_address?\n\n selected_address = temp_addresses.detect { |address| address[\"uprn\"].to_s == existing_address.uprn }\n self.temp_address = selected_address[\"uprn\"] if selected_address.present?\n end",
"def set_address_type\n\n end",
"def address2_set(address)\n self.address2.set address\n end",
"def save_address\n end",
"def address=(val)\n old = @address\n @address = val\n [@got, @plt, @symbols].compact.each do |tbl|\n tbl.each_pair { |k, _| tbl[k] += val - old }\n end\n @one_gadgets&.map! { |off| off + val - old }\n end",
"def set_street_address_2_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_2, @customer.street_address_2)\n end",
"def address1_set(address)\n self.address1.set address\n end",
"def translate_address_state\n super\n end",
"def clone_billing_address\n self.ship_address = self.bill_address if self.bill_address\n end",
"def edit_frontend_address(user, address, expect_success, values, default_bill=nil, default_ship=nil)\n address = address.id if address.is_a?(Spree::Address)\n\n visit spree.account_path\n if address\n click_link \"edit_address_#{address}\"\n expect(current_path).to eq(spree.edit_address_path(address))\n else\n within('#addresses > tbody > tr:first-child') do\n click_link Spree.t(:edit)\n end\n end\n\n fill_in_address(values)\n check_frontend_defaults(default_bill, default_ship)\n\n click_button Spree.t(:update)\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n expect(current_path).to eq(spree.account_path)\n expect_frontend_addresses(user)\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n end\n end",
"def needs_address?\n !flagged? && !sent?\n end",
"def update_address\n address_zip = ZipCodes.identify(zip_code) || {}\n self.city = address_zip[:city]\n self.state = address_zip[:state_name]\n self.state_code = address_zip[:state_code]\n end",
"def add_address # rubocop:disable Metrics/AbcSize\n return unless @bib.place.any?\n\n reg = @bib.place[0].region[0].name if @bib.place[0].region.any?\n addr = [@bib.place[0].name, @bib.place[0].city, reg]\n @item.address = addr.compact.join(\", \")\n end",
"def visit_edit_address(order_or_user, address, direct=false)\n address = address.id if address.is_a?(Spree::Address)\n\n if direct\n order_id = order_or_user.is_a?(Spree::Order) ? order_or_user.id : nil\n user_id = order_or_user.is_a?(Spree::User) ? order_or_user.id : order_or_user.user_id\n visit spree.edit_admin_address_path(address, order_id: order_id, user_id: user_id)\n else\n visit_addresses(order_or_user)\n click_link \"edit-address-#{address}\"\n end\n\n expect(current_path).to eq(spree.edit_admin_address_path(address))\n end",
"def set_address\n @address = Addresslanlng.new\n end",
"def set_prober_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def change_address\n\t\twait_for_elements_exist([\"* id:'changeAddress'\"], timeout: 30)\n\t\ttouch(\"* id:'changeAddress'\")\n\t\twait_for_animation\n\tend",
"def regeocode\n self.geocode_address if self.address_changed? || self.city_changed? || self.state_changed?\n end",
"def set_local_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def add_address(request, address)\r\n return if address.nil?\r\n request.Set(RocketGate::GatewayRequest::BILLING_ADDRESS, address[:address1])\r\n request.Set(RocketGate::GatewayRequest::BILLING_CITY, address[:city])\r\n request.Set(RocketGate::GatewayRequest::BILLING_ZIPCODE, address[:zip])\r\n request.Set(RocketGate::GatewayRequest::BILLING_COUNTRY, address[:country])\r\n\r\n#\r\n#\tOnly add the state if the country is the US or Canada.\r\n#\t \r\n if address[:state] =~ /[A-Za-z]{2}/ && address[:country] =~ /^(us|ca)$/i\r\n request.Set(RocketGate::GatewayRequest::BILLING_STATE, address[:state].upcase)\r\n end\r\n end",
"def check_order_address(user, order, type)\n addr = order.send(type)\n user ||= order.user\n\n if addr && addr.user_id && addr.user_id != user.try(:id)\n raise \"Order #{order.id} has address that belongs to user #{addr.user_id.inspect} instead of #{user.try(:id).inspect}\"\n end\n\n addr\n end",
"def set_address(address)\n @fields.merge!(address.to_hash)\n end",
"def payment_address!\n return unless currency.coin?\n record = payment_address\n\n # The address generation process is in progress.\n if record.address.blank?\n record\n else\n # allows user to have multiple addresses.\n payment_addresses.create!(currency: currency)\n end\n end",
"def clone_shipping_address\n if Spree::AddressBook::Config[:show_bill_address_on_cc_form] == false\n if self.ship_address\n self.bill_address = self.ship_address\n end\n else\n if self.bill_address_id == nil\n self.bill_address = self.ship_address\n end\n end\n true\n end",
"def valid_address?(address)\n all_addresses = get_all_addresses\n all_addresses.include? address\nend",
"def set_address\n @address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_id)\n end",
"def address() @address; end",
"def lower_address=(value)\n @lower_address = value\n end",
"def full_order_to_address\n ship_address.address1 + ' ' + ship_address.address2\n end",
"def delete_address(address)\n address.delete!\n end",
"def expect_order_addresses(order)\n order.reload\n expect_selected(order.bill_address, :order, :bill)\n expect_selected(order.ship_address, :order, :ship)\n\n expect(page).to have_content(content_regex(order.bill_address)) if order.bill_address\n expect(page).to have_content(content_regex(order.ship_address)) if order.ship_address\n end",
"def org_address=(address)\n company.from_address!(address)\n end",
"def set_street_address_1_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def payment_address\n return unless currency.coin?\n payment_addresses.last&.enqueue_address_generation || payment_addresses.create!(currency: currency)\n end",
"def set_address\n\t\t@address = Contact.find(params[:contact_id]).address\n\tend",
"def try_to_fix address\n parts = address.split(\",\")\n if parts.shift\n parts.join(',')\n else\n address\n end\n end",
"def update_address(id, params)\n put(\"addresses/#{id}\", address: params, change_case: false)\n end",
"def make_addresses_deletable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_can_be_deleted?, :can_be_deleted?\n def can_be_deleted?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_del_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #can_be_deleted? method\n Spree::Address.class_eval do\n alias_method :can_be_deleted?, :orig_can_be_deleted?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_del_can_update_addresses?\n end\n end\n end\n end",
"def use_another_address_for_shipping=(val)\n value = val.is_a?(String) ? (val.to_i > 0) : val\n @use_another_address_for_shipping = value\n end",
"def persist_order_address(order)\n if order.ship_address\n address = save_in_address_book(\n order.ship_address.attributes,\n Spree::Config.automatic_default_address\n )\n self.ship_address_id = address.id if address && address.persisted?\n end\n\n if order.bill_address\n address = save_in_address_book(\n order.bill_address.attributes,\n order.ship_address.nil? && Spree::Config.automatic_default_address\n )\n self.bill_address_id = address.id if address && address.persisted?\n end\n\n save! # In case the ship_address_id or bill_address_id was set\n end",
"def update_address(address, profile_id)\n @type = Type::CIM_UPDATE_ADDRESS\n @fields.merge!(address.to_hash)\n handle_profile_id(profile_id)\n make_request\n end",
"def address?\n if self.address\n return false\n else\n return true\n end\n end",
"def address=(addr)\n @address = check_address addr\n build_pack\n end",
"def update\n if current_user\n @address = Address.find(params[:id])\n if current_user == @address.user\n address = Address.new(params[:address])\n address.user = current_user\n if address.save\n @address.update_attributes(:status => 'deleted')\n flash[:notice] = I18n.t(\"stizun.address.address_changed\")\n redirect_to user_addresses_path(current_user)\n else\n flash[:error] = I18n.t(\"stizun.address.address_couldnt_be_saved\")\n render :action => 'edit'\n end\n else\n flash[:error] = I18n.t(\"stizun.address.you_have_no_permission_to_edit\")\n redirect_to root_path\n end\n end\n end",
"def check_address(_)\n raise NotImplementedError\n end",
"def address=(address)\n @address = ensure_type(Address, address)\n end",
"def secondary_address; end",
"def address3_set(address)\n self.address3.set address\n end",
"def address_changed?\n \tstreet_changed? || city_changed? || state_changed?\n end",
"def visit_order_addresses(order)\n visit spree.admin_order_customer_path(order)\n expect_address_list\n\n expect_order_addresses(order)\n expect_user_addresses(order.user) if order.user\n end",
"def ship_address_tax_update\n if ship_address and (ship_address_id_changed? or ship_address.changed?)\n create_avalara_tax_adjustment\n end\n end",
"def set_shipping_address(address)\n @fields.merge!(address.to_hash)\n end",
"def create\n user_id = @current_user.id\n input_address = params[:address].delete(\" \").delete(\",\").capitalize # removes all spaces and comma's from the newly entered address.\n address = @current_user.addresses\n address_arr = []\n address.each do |a|\n address_arr.push(a.address.delete(\" \").delete(\",\").capitalize)\n end\n # checks whether the address entered already exists for the current user\n unless (address_arr.include?(input_address))\n if (address.empty?) # if user have no address, address created first should be the delivery address.\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n :delivery_address => true,\n )\n else\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n )\n end\n else\n flash[:error] = \"Already Existing Address!!!\"\n end\n redirect_to cart_items_path\n end"
] | [
"0.6788056",
"0.67573225",
"0.673295",
"0.673295",
"0.66663474",
"0.66016954",
"0.65904987",
"0.65477854",
"0.6543206",
"0.64874625",
"0.64228237",
"0.6421653",
"0.64139307",
"0.64091563",
"0.6393491",
"0.6385536",
"0.6381176",
"0.63621795",
"0.6309696",
"0.6298268",
"0.6288718",
"0.6263421",
"0.6263421",
"0.6253257",
"0.62465024",
"0.62375814",
"0.6237182",
"0.6213165",
"0.6203518",
"0.61858165",
"0.61858165",
"0.61855733",
"0.61695176",
"0.61617374",
"0.6128098",
"0.6122346",
"0.6115358",
"0.611442",
"0.6113292",
"0.6108035",
"0.6086088",
"0.60830176",
"0.60813344",
"0.60769415",
"0.60762167",
"0.60625947",
"0.6057763",
"0.60413486",
"0.604114",
"0.60327905",
"0.6011437",
"0.6001988",
"0.59970516",
"0.5994909",
"0.59886223",
"0.5987903",
"0.5986241",
"0.5982237",
"0.5979749",
"0.59715986",
"0.5944815",
"0.5936229",
"0.5925963",
"0.5922896",
"0.5922071",
"0.5920192",
"0.59191984",
"0.591842",
"0.5905452",
"0.5903081",
"0.5901011",
"0.58558136",
"0.5855497",
"0.58483285",
"0.58390766",
"0.58256394",
"0.582191",
"0.5814367",
"0.58133173",
"0.58073264",
"0.5801345",
"0.5796275",
"0.5791464",
"0.57911927",
"0.578803",
"0.5780785",
"0.5777424",
"0.5777368",
"0.5774025",
"0.5773034",
"0.5772383",
"0.57709557",
"0.57674015",
"0.57671905",
"0.5764147",
"0.5763194",
"0.5762261",
"0.57579166",
"0.57575476",
"0.5754092",
"0.5741919"
] | 0.0 | -1 |
Remove readonly validation to be able to modify addresses over the flow | def readonly?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def delink_addresses\n delink_addresses_validation\n save\n end",
"def delink_addresses_validation\n if bill_address.try(:user_id)\n bill_copy = bill_address.clone_without_user\n bill_copy.save\n self.bill_address = bill_copy\n end\n\n if ship_address && (\n ship_address.user_id ||\n (ship_address.id && ship_address.id == bill_address.try(:id)) ||\n (ship_address.changed? && ship_address == bill_address))\n ship_copy = ship_address.clone_without_user\n ship_copy.save\n self.ship_address = ship_copy\n shipments.update_all address_id: ship_address_id\n end\n end",
"def original_address\n super\n end",
"def remove_all_original_addresses\n super\n end",
"def without_validations\n with_validations(false)\n end",
"def make_addresses_editable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_editable?, :editable?\n def editable?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #editable? method\n Spree::Address.class_eval do\n alias_method :editable?, :orig_editable?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_can_update_addresses?\n end\n end\n end\n end",
"def discard_blank_addresses\n return unless self.state == 'address' || self.state == 'cart'\n\n if bill_address && bill_address.invalid? && bill_address.blank?\n self.bill_address = nil\n end\n if ship_address && ship_address.invalid? && ship_address.blank?\n self.ship_address = nil\n end\n end",
"def clear_validations_on_phone\n _validators.reject!{ |key, value| key == :phone }\n\n _validate_callbacks.each do |callback|\n callback.raw_filter.attributes.reject! { |key| key == :phone } if callback.raw_filter.respond_to?(:attributes)\n end\n\nend",
"def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end",
"def invalid_address\n render_error(:unprocessable_entity, {recipient: ['invalid address']})\n end",
"def cleanse_address(address)\n cleansed_address = SOAAddressCleanser.cleanse_address(address)\n cleansed_address.save!\n end",
"def add_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def make_addresses_deletable\n before(:each) do\n # Allow editing of completed order addresses\n Spree::Address.class_eval do\n alias_method :orig_can_be_deleted?, :can_be_deleted?\n def can_be_deleted?\n true\n end\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :orig_del_can_update_addresses?, :can_update_addresses?\n def can_update_addresses?\n true\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #can_be_deleted? method\n Spree::Address.class_eval do\n alias_method :can_be_deleted?, :orig_can_be_deleted?\n end\n\n [Spree::Order, Spree::User].each do |c|\n c.class_eval do\n alias_method :can_update_addresses?, :orig_del_can_update_addresses?\n end\n end\n end\n end",
"def address_params\n #funky strong params block taken from https://github.com/rails/rails/issues/9454#issuecomment-14167664\n params.require(:address).permit(:id, :name, :address, :telephone, :agent).tap do |whitelisted|\n whitelisted[:address] = params[:address][:address]\n end\n end",
"def skip_validations\n true\n end",
"def sanitize_draft_errors(draft)\n if draft.errors.any?\n errors = draft.errors.dup\n draft.errors.clear\n errors.each{|attr, message|\n if attr == 'outbounds_phone_number_phone_number_digits'\n draft.errors.add(:outbounds_phone_number, message)\n elsif !(attr =~ /^outbounds_phone_number/) && !(attr == 'outbounds' && message == 'is invalid')\n draft.errors.add(attr, message)\n end\n }\n end\n end",
"def translate_address_state\n super\n end",
"def remove_proxy_exclusion(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def _format_input(type)\n @attr[:readonly] = :readonly\n super\n end",
"def strip_order_address_users(order)\n order.bill_address.try(:update_attributes!, user_id: nil)\n order.ship_address.try(:update_attributes!, user_id: nil)\n order\n end",
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n yield\n ensure\n @disable_auto_validations = previous\n self\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n @ethereum_address = @ethereum_address.to_s\n\n @ethereum_address = Util::CommonValidator.sanitize_ethereum_address(@ethereum_address)\n\n return error_with_identifier('invalid_api_params',\n 'um_cea_1',\n ['invalid_ethereum_address']\n ) unless Util::CommonValidator.is_ethereum_address?(@ethereum_address)\n\n success\n end",
"def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend",
"def fix(address)\n @address = address\n end",
"def fix(address)\n @address = address\n end",
"def nil_address\n self.address_line1 = nil\n self.address_line2 = nil\n self.locality = nil\n self.county = nil\n self.country = nil\n self.postcode = nil\n end",
"def chkout_modify_existing_address\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_modify_existing_address, a.id(\"change_address\")\n return ToolTag.new(a.id(\"change_address\"), __method__, self)\n end",
"def readonly!\n @readonly = true\n end",
"def add_proxy_exclusion(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def validate\n unless address =~ /^(\\d{1,3}\\.){3}\\d{1,3}$/\n raise ValidationError, \"Invalid address\"\n end\n end",
"def edit\n super\n\n if resource.try(:is_email_fake)\n resource.email = ''\n end\n end",
"def clear_validations_on_country\n _validators.reject!{ |key, value| key == :country }\n\n _validate_callbacks.each do |callback|\n callback.raw_filter.attributes.reject! { |key| key == :country } if callback.raw_filter.respond_to?(:attributes)\n end\n\n end",
"def bypass_site_allowed_ips\n @attributes[:bypass_site_allowed_ips]\n end",
"def address_attributes\n attributes.delete_if {|key, value| [\"id\", 'updated_at', 'created_at'].any?{|k| k == key }}\n end",
"def address_attributes\n attributes.delete_if {|key, value| [\"id\", 'updated_at', 'created_at'].any?{|k| k == key }}\n end",
"def remove_global_proxy_exclusion(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def force_address_zipcode_numeric\n before(:each) do\n Spree::Address.class_eval do\n validates_numericality_of :zipcode\n end\n end\n\n after(:each) do\n # http://stackoverflow.com/a/11268726/737303 was useful\n Spree::Address._validators[:zipcode].reject!{|z| z.is_a?(ActiveModel::Validations::NumericalityValidator) }\n cb = Spree::Address._validate_callbacks.find{|z|\n z.raw_filter.is_a?(ActiveModel::Validations::NumericalityValidator) && z.raw_filter.attributes.include?(:zipcode)\n }\n Spree::Address._validate_callbacks.delete(cb)\n end\n end",
"def chkout_email_address_field\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_email_address_field, input.className(create_ats_regex_string(\"ats-emailfield\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-emailfield\")), __method__, self)\n end",
"def check_address(_)\n raise NotImplementedError\n end",
"def update_or_create_address(attributes)\n if attributes[:id]\n # TODO: Delete this part of the IF? It never gets called during tests.\n address = Spree::Address.find(attributes[:id])\n if address.editable?\n address.update_attributes(attributes)\n else\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n end\n else\n address = Spree::Address.new(attributes)\n end\n address\n end",
"def setInvalid()\n\t\t@isValid = false\n\tend",
"def ensure_editable; return false unless editable? end",
"def chkout_address_1_field\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_address_1_field, input.className(create_ats_regex_string(\"ats-line1field\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-line1field\")), __method__, self)\n end",
"def accounting_validation_state\n super\n end",
"def address_validation_contexts\n default_page_statuses\n\n # Checking if address_read_only is true or EMPTY\n if @address_read_only\n %i[address_selected]\n else\n %i[save]\n end\n end",
"def process_addresses(params)\n assign_attributes(params)\n save(validate: false)\n add_email!\n add_addresses!\n save\n end",
"def sanitized_allowed_attributes=(attributes); end",
"def sanitized_allowed_attributes=(attributes); end",
"def validate_only=(value)\n @credential_handler.validate_only = value\n end",
"def validateaddress(coinaddress)\n coind.validateaddress\n end",
"def set_prober_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def set_address\n authorize @address = Address.find(params[:id])\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n unless Util::CommonValidator.is_ethereum_address?(@address)\n return validation_error(\n 'e_fb_1',\n 'invalid_api_params',\n ['invalid_eth_address'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n end",
"def read_only?; end",
"def read_only?; end",
"def force_user_address_updates(enabled)\n before(:each) do\n # Allow or disallow user address assignment\n Spree::User.class_eval do\n alias_method :orig_can_update_addresses?, :can_update_addresses?\n\n if enabled\n def can_update_addresses?\n true\n end\n else\n def can_update_addresses?\n false\n end\n end\n end\n end\n\n after(:each) do\n # Restore original #can_update_addresses? method\n Spree::User.class_eval do\n alias_method :can_update_addresses?, :orig_can_update_addresses?\n end\n end\n end",
"def validator=(_); end",
"def partially_valid_clear\n @partially_valid_attributes = []\n end",
"def add_global_proxy_exclusion(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def readonly?; true; end",
"def readonly?; true; end",
"def readonly?; true; end",
"def edit_address(edited_address)\n address = Address.find(edited_address.uid)\n address.attributes = edited_address.attributes\n address.save!\n end",
"def clone_billing_address\n self.ship_address = self.bill_address if self.bill_address\n end",
"def address_params\n params.require(:address).permit(Address.attribute_list) unless params[:address].nil?\n end",
"def prober_address\n super\n end",
"def validate_to_address\n raise StanzaErrors::FeatureNotImplemented.new(self, 'cancel') unless pubsub\n end",
"def readonly! #:nodoc:\n @readonly = true\n end",
"def update!(**args)\n @disable_street_address_resolution = args[:disable_street_address_resolution] if args.key?(:disable_street_address_resolution)\n @html_sanitization = args[:html_sanitization] if args.key?(:html_sanitization)\n end",
"def update!(**args)\n @disable_street_address_resolution = args[:disable_street_address_resolution] if args.key?(:disable_street_address_resolution)\n @html_sanitization = args[:html_sanitization] if args.key?(:html_sanitization)\n end",
"def update!(**args)\n @disable_street_address_resolution = args[:disable_street_address_resolution] if args.key?(:disable_street_address_resolution)\n @html_sanitization = args[:html_sanitization] if args.key?(:html_sanitization)\n end",
"def validate_address(address, options={})\n options = @options.update(options)\n address_validation_request = build_address_validation_street_request(address, options)\n #UPS sandbox is not knowing about all states\n log(:address_validation, address_validation_request)\n response = commit(:address_validation_street, save_request(address_validation_request), (false))\n response = response.gsub(/\\sxmlns(:|=)[^>]*/, '').gsub(/<(\\/)?[^<]*?\\:(.*?)>/, '<\\1\\2>')\n log(:address_validation, response)\n parse_address_street_validation_response(response, options)\n end",
"def state_is_not_anonymised\n errors.add(:state, :forbidden) if record.anonymised?\n end",
"def call_to(name)\n @validators.delete(name.to_s)\n end",
"def readonly=(value)\n if value\n self[:readonly] = ''\n else\n remove_attribute :readonly\n end\n end",
"def mask_with_a_care!(mask)\n original_addr = @addr\n mask_without_a_care!(mask)\n @addr = original_addr unless self.class.mask_by_default\n return self\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def clear_address_finder_error\n self.address_finder_error = transient_registration.address_finder_error\n transient_registration.update(address_finder_error: nil)\n end",
"def before_address\n @order.bill_address ||= current_user.try(:bill_address).try(:clone) || Address.new(:country => default_country)\n @order.ship_address ||= current_user.try(:ship_address).try(:clone) || Address.new(:country => default_country)\n end",
"def validateaddress(namecoin_address)\n request :validateaddress, namecoin_address\n end",
"def delete_virtual_address\n super\n end",
"def validate_to\n @to = validate_address(TO)\n end",
"def make_private!\n reinitialize_rules!\n allow_if do\n false\n end\n return self\n end",
"def validate_travel_private\n return unless travel.publicx?\n\n errors.add(:travel_id, :public)\n end",
"def set_address\n end",
"def email_address=(val)\n super(val.strip)\n end",
"def is_not_editable!\n update_attribute :is_editable, false\n end",
"def set_local_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def change_address\n @change_address || @inputs.keys.first\n end",
"def replace_administrative_ip(opts)\n opts = check_params(opts,[:old_ips,:new_ips,:netmasks])\n super(opts)\n end",
"def chkout_address_2_field\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_address_2_field, input.className(create_ats_regex_string(\"ats-line2field\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-line2field\")), __method__, self)\n end",
"def excluded_addresses=(new_addresses)\n @excluded_scan_targets[:addresses] = new_addresses\n end",
"def invalid; end",
"def allow_invalid_person?\n allow_invalid_person\n end",
"def destroy\n authorize @address\n end",
"def normalize_address(address)\n wallet.blockchain_api&.supports_cash_addr_format? ? CashAddr::Converter.to_legacy_address(super) : super\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end"
] | [
"0.6529041",
"0.6417117",
"0.6414065",
"0.6406976",
"0.63714033",
"0.62140036",
"0.5917872",
"0.5861237",
"0.58362716",
"0.583402",
"0.5806216",
"0.57939327",
"0.57844913",
"0.57755953",
"0.57173073",
"0.56794775",
"0.56619424",
"0.56577146",
"0.5621468",
"0.56036043",
"0.5595804",
"0.55673766",
"0.55528784",
"0.5526547",
"0.54915196",
"0.5484224",
"0.54830265",
"0.54830265",
"0.54747957",
"0.5473735",
"0.54701585",
"0.54417753",
"0.54332596",
"0.54104143",
"0.53986233",
"0.5393733",
"0.5390223",
"0.5390223",
"0.5384029",
"0.53816134",
"0.53771317",
"0.5374749",
"0.5363083",
"0.53621095",
"0.5360316",
"0.53388405",
"0.5334088",
"0.5319347",
"0.53131557",
"0.53067607",
"0.53067607",
"0.5306715",
"0.5299936",
"0.52978814",
"0.5296241",
"0.5284797",
"0.52841806",
"0.52841806",
"0.5281004",
"0.5279607",
"0.526895",
"0.52661246",
"0.52606624",
"0.52606624",
"0.52606624",
"0.52599406",
"0.52466863",
"0.52370507",
"0.52247643",
"0.5223955",
"0.5221861",
"0.5217984",
"0.5216705",
"0.5216705",
"0.52159613",
"0.5205359",
"0.51993364",
"0.5197355",
"0.51960474",
"0.51954424",
"0.51954424",
"0.5191175",
"0.51861686",
"0.5183805",
"0.51814663",
"0.5179731",
"0.5174201",
"0.51607084",
"0.51590675",
"0.51587605",
"0.5156922",
"0.5153274",
"0.51506525",
"0.51439446",
"0.514167",
"0.514113",
"0.51366955",
"0.5134108",
"0.5133423",
"0.5129069",
"0.5127849"
] | 0.0 | -1 |
Use discard ability to not affect order created previously | def destroy
can_be_deleted? ? delete : discard
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_order(order)\n @queue.remove(order)\n end",
"def discard; end",
"def discard; end",
"def discard!\n update!(adjustment: 0)\n end",
"def original_order\n end",
"def discard!\n # This should be overridden by concrete adapters.\n end",
"def parts_with_order_remove part\n self.parts_with_order = self.parts_with_order.reject{|master_file| master_file.pid == part.pid }\n end",
"def discard( visit_queue )\n if reserve? && visit_queue.order_count > 0\n orders = visit_queue.hosts.inject( [] ) do |a, hq|\n a.concat( hq.orders.to_a )\n end\n if orders.length > 0\n n = reader.unreserve( orders )\n @log.info { \"Unreserved #{n} orders on discard\" }\n end\n end\n rescue SQLException => x\n @log.error( \"On discard: \", x )\n end",
"def discard=(_arg0); end",
"def set_initial_discards!\n @finisher = @temp_finisher\n @discard2 = @temp_discard2\n @discard1 = @temp_discard1\n (@temp_discard1 + @temp_discard2).each do |c|\n @hand.delete(c)\n end\n @special_action_available = true\n @temp_discard1 = nil\n @temp_discard2 = nil\n @temp_finisher = nil\n log_me!(\"discards #{@discard2.map(&:name).join(' ')} to discard 2.\")\n log_me!(\"discards #{@discard1.map(&:name).join(' ')} to discard 1.\")\n log_me!(\"selects #{@finisher.name} for their finisher.\")\n end",
"def discardable\n []\n end",
"def delete_complement\n raise(\":delete_complement method is supported only for :saver_strategy => [:batch, :concurrent_safe_batch]\")\n end",
"def discard\n @args = nil\n @block = nil\n end",
"def dummy_order\n order = spree_line_item ? spree_line_item.order.dup : ::Spree::Order.create\n order.ship_address = subscription.shipping_address || subscription.user.ship_address if subscription\n order.bill_address = subscription.billing_address || subscription.user.bill_address if subscription\n\n order.freeze\n end",
"def exclude; end",
"def discard_saved_state\n end",
"def ignore; end",
"def processOrder\n \n end",
"def order(*order)\n clone(:order => (order.compact.empty?) ? nil : order)\n end",
"def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end",
"def unordered\n order(nil)\n end",
"def purge!\n unless self.ordered?\n self.line_items.each do |line_item|\n remove_line_item(line_item) if line_item.invalid?\n end\n end\n end",
"def ignores; end",
"def discard_transaction\n\t clear_vertex\n\t super if defined? super\n\tend",
"def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end",
"def toggle_order(order)\n (@current_order = order;@list = 1;@message = nil;return true) if order.match('ascending')\n (@current_order = order;@list = uids;@message = nil;return true) if order.match('descending')\n end",
"def ignore\n @ignore = true\n end",
"def discard_results; end",
"def discard\n fmap { Unit }\n end",
"def complete_order\n @queue.dequeue\n end",
"def order; end",
"def order; end",
"def skips; end",
"def exclude_from_shuffle\n @ole.ExcludeFromShuffle\n end",
"def omit(reason=true, &block)\n @_omits << [reason, block]\n end",
"def discard_a(event)\n output_changed event.old_element\n end",
"def discard! *keys\n keys.each {|k| delete k }\n self\n end",
"def ignore\n @ignore = true\n end",
"def item_without(exclude)\n item = @item\n exclude.each do |e|\n item[e] = nil\n end\n \n item\n end",
"def drop_orders\n return Order.where(:status => 'washed', :dropper_id => nil).where.not(:picker_id => nil) if self.pickup_boy?\n end",
"def discard(key = (no_arg = true))\n if no_arg\n @next.clear\n else\n @next.delete(key)\n end\n end",
"def unapply\n return return_with(:error, I18n.t('coupon.cannot_remove')) unless unappliable_order?\n return return_with(:error, I18n.t('coupon.error_occurred_applying')) unless reset_order! && reset_coupon!\n return_with(:success)\n end",
"def normalize_order(order); end",
"def remove_from(order)\n Spree::Deprecation.warn(\"#{self.class.name.inspect} does not define #remove_from. The default behavior may be incorrect and will be removed in a future version of Solidus.\", caller)\n [order, *order.line_items, *order.shipments].each do |item|\n item.adjustments.each do |adjustment|\n if adjustment.source == self\n item.adjustments.destroy(adjustment)\n end\n end\n end\n end",
"def discard_b(event)\n output_changed event.new_element\n end",
"def order_minus\n order_op(true, @question)\n end",
"def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end",
"def skip_deletion\n @mark_for_delete = false\n end",
"def shift_up_orders()\n Feature.update_all('\"order\" = \"order\" - 1', '\"order\" > '+order.to_s)\n end",
"def unmark_two_candidate_elements_as_backtrackable(without_el)\n @foo = backtrackable_elements + select do |el| el.dirty? end\n @foo.delete(without_el)\n @foo.each &:reset_before_backtracking\n end",
"def discard_effect\n @game.discard_pile_cards << \"lock_down\"\n end",
"def discard(card)\n discard_pile << card\n end",
"def discard_a(event)\n event\n end",
"def undiscard\n unless @multi_year_chart.kept?\n @multi_year_chart.discarded_at = nil\n @multi_year_chart.save(touch: false)\n\n flash.notice = t('scenario.trash.undiscarded_flash')\n flash[:undo_params] = [discard_multi_year_chart_path(@multi_year_chart), { method: :put }]\n end\n\n redirect_back(fallback_location: discarded_saved_scenarios_path)\n end",
"def clear_ignores!\n @ignored = Array.new\n end",
"def excluded; end",
"def destroy\n @transferred_event_order.destroy\n end",
"def unappliable_order?\n order.bought? == false\n end",
"def -(other)\n other.inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end",
"def get_undelivered_order_ids\n\n #enable this one for previous restricted conditioned(pause/resume)\n #orders =self.orders.select('id, delivery_date').where('spree_orders.delivery_date > ?', Time.now).limit(3)\n orders = self.orders.select('id, delivery_date').where('spree_orders.state in (?) ', ['confirm', 'placed']).limit(3)\n\n order_ids = {}\n\n orders.each_with_index do |order, index|\n order_ids.merge!(index => order.id)\n end\n\n order_ids\n end",
"def ignore(*ids); end",
"def ignore!\n self.ignored = true\n end",
"def before_delivery\r\n return if params[:order].present?\r\n \r\n if @order.bill_address.address1 == 'dummy_address1' or @order.bill_address.city == 'dummy_city' or @order.bill_address.address2.include? \"CityBox\"\r\n @disable_all_except_citybox = true\r\n end\r\n\r\n packages = @order.shipments.map { |s| s.to_package }\r\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\r\n end",
"def invert_order(order)\n return nil unless order\n new_order = []\n order.map do |f|\n case f\n when SQL::OrderedExpression\n SQL::OrderedExpression.new(f.expression, !f.descending)\n else\n SQL::OrderedExpression.new(f)\n end\n end\n end",
"def omit(reason=true)\n if block_given?\n @_omit = reason\n yield\n @_omit = nil\n else\n @_omit = reason\n end\n end",
"def revert\n self.class.revert [self]\n end",
"def reverse!\n\t\t@order *= -1\n\t\tresort\n\tend",
"def exclude=(_arg0); end",
"def order=(_arg0); end",
"def ignore\n @ignored = true\n self\n end",
"def ignore!\n @should_ignore = true\n end",
"def eject!\n oldest_object = @store.first\n @map.delete(oldest_object.key)\n @store.remove(oldest_object.key)\n end",
"def discard(k = nil)\n k = k.to_s if k\n @discard.merge Array(k || keys)\n k ? self[k] : self\n end",
"def discard_b(event)\n event\n end",
"def return\n @cards += @discard\n @discard.clear\n @cards.shuffle\n end",
"def pop\n _exchange\n end",
"def delete_front()\n \n end",
"def default; return DefaultOrder; end",
"def ignore\n @ignore ||= []\n end",
"def discard(indexes)\n [indexes].flatten.sort.reverse.each do |card_index|\n @cards.delete_at(card_index)\n end\n end",
"def revert\n end",
"def undolist\n @rank_participants = RankParticipant.only_deleted.reverse\n end",
"def ignore(*args); end",
"def skipped; end",
"def reverse_order(order)\n if not valid_order?(order)\n raise ArgumentError\n end\n create_order(order, (0...order.size).to_a)\nend",
"def complement\n self.class.all.difference(self)\n end",
"def remove!; end",
"def without(what)\n God.knows \"without #{what}\"\n what = What.is(what)\n what.reject = true\n what\nend",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def skip_actions; end",
"def down_item\n order_op2(false, @item)\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def order_cancellation\n\t\torder = Order.first\n\t\tOrderMailer.order_cancellation(order)\n end",
"def reverse_order!\n self.reverse_order_value = !reverse_order_value\n self\n end",
"def invert_order(order)\n return unless order\n order.map do |f|\n case f\n when SQL::OrderedExpression\n f.invert\n else\n SQL::OrderedExpression.new(f)\n end\n end\n end",
"def prune_ignored!\n ignored = []\n\n results.each do |result|\n if Config.ignore?(result.name) && !prompt(\"#{result.name} is ignored. Process anyway\")\n warn(\"skipping #{result.name}...\")\n ignored << result\n end\n end\n\n ignored.each { |i| results.delete(i) }\n end",
"def discard\n unless @multi_year_chart.discarded?\n @multi_year_chart.discarded_at = Time.zone.now\n @multi_year_chart.save(touch: false)\n\n flash.notice = t('scenario.trash.discarded_flash')\n flash[:undo_params] = [undiscard_multi_year_chart_path(@multi_year_chart), { method: :put }]\n end\n\n redirect_back(fallback_location: list_multi_year_charts_path)\n end",
"def undo\n if !(isAtBeginning)\n @actions[@index].applyOpposite\n @index -= 1\n end\n end"
] | [
"0.7194839",
"0.66748106",
"0.66748106",
"0.6154552",
"0.6128351",
"0.60287637",
"0.6027542",
"0.5975205",
"0.59112036",
"0.58811426",
"0.58564126",
"0.5744626",
"0.57152545",
"0.5609577",
"0.56091636",
"0.55947673",
"0.5539908",
"0.5507179",
"0.5493804",
"0.54894567",
"0.54735136",
"0.5466931",
"0.54642856",
"0.54609257",
"0.5459428",
"0.54315984",
"0.5423328",
"0.5422498",
"0.5415953",
"0.5414126",
"0.5407536",
"0.5407536",
"0.54038537",
"0.5363235",
"0.53498614",
"0.53470576",
"0.5341776",
"0.5341197",
"0.5328271",
"0.5319967",
"0.53187895",
"0.5294725",
"0.5293257",
"0.5289419",
"0.5282502",
"0.5280637",
"0.5274307",
"0.5259827",
"0.52545893",
"0.52320695",
"0.5225185",
"0.5224331",
"0.5215755",
"0.5213138",
"0.5201226",
"0.51999176",
"0.51996773",
"0.51913315",
"0.5191095",
"0.51902443",
"0.5183752",
"0.5181825",
"0.51817465",
"0.51740557",
"0.5161775",
"0.5160983",
"0.51606935",
"0.51592773",
"0.5158279",
"0.51574653",
"0.51564175",
"0.51315826",
"0.5123644",
"0.5122336",
"0.51069933",
"0.5105387",
"0.5093632",
"0.50912714",
"0.5090222",
"0.50827086",
"0.5080838",
"0.506836",
"0.50680596",
"0.5059997",
"0.50592875",
"0.5058333",
"0.5057966",
"0.50545925",
"0.5053724",
"0.5052374",
"0.5047217",
"0.50456184",
"0.50456184",
"0.50456184",
"0.50456184",
"0.50435036",
"0.5040208",
"0.50360245",
"0.5032491",
"0.50298697",
"0.5023218"
] | 0.0 | -1 |
Applies a block as a mapping on all keys, returning a new hash. | def with_keys
keys.each_with_object self.class.new do |hash_key, hsh|
hsh[ yield hash_key ] = self[ hash_key ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_mapped(hash, prc, &block)\n new_hash = {}\n hash.each do |k, v|\n new_hash[block.call[k]] = prc.call(v)\n end \n new_hash\nend",
"def map_values &block\n keys.inject({}) {|acc,k|\n acc[k] = yield(k, self[k])\n acc\n }\n end",
"def map_into_hash(&block)\n Hash[*map {|x| [x[0], block.call(x)]}.inject([], &:concat)]\n end",
"def remap\n # This is Ruby magic for turning a hash into an array into a hash again\n Hash[*self.map do |key, value|\n yield key, value\n end.compact.flatten]\n end",
"def each(&block)\n @hash.each {|k,v| block.call k,v }\n end",
"def map_keys(hash)\n hash.map { |k, v| { yield(k) => v } }.reduce(:merge)\n end",
"def transform_keys(&block); end",
"def transform_keys!(&block); end",
"def map_keys\n inject(self.class.new) do |memo, (key, value)|\n memo[yield(key)] = value\n memo\n end\n end",
"def transform_hash(original, &block)\n original.inject({}) do |result, (key, value)|\n value = if value.is_a?(Hash)\n transform_hash(value, &block)\n else\n value\n end\n yield(result, key, value)\n result\n end\n end",
"def modify_keys\n each_with_object self.class.new do |hash_pair, hsh|\n hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]\n end\n end",
"def each(&block)\n hash.each(&block)\n end",
"def each(&block)\n @hash.each(&block)\n end",
"def hmap\n return map unless block_given?\n map { |k, v| yield(k, v) }.compact.to_h\n end",
"def each(&block)\n self.keys.each{|k| block.call([k, self[k]])}\n self\n end",
"def hash_mapped(hash, proc_a, &prc)\n new_hash = Hash.new(0)\n\n hash.each do |k, v|\n new_k = prc.call(k)\n new_hash[new_k] = proc_a.call(v)\n end\n new_hash\nend",
"def hash(hash, &block)\n hash.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = _recurse_(value, &block)\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def transform_keys!(hash)\n return enum_for(:transform_keys!, hash) unless block_given?\n hash.keys.each do |key|\n hash[yield(key)] = hash.delete(key)\n end\n hash\n end",
"def resolve_all(key, &block)\n map do |hash|\n hash = hash.dup\n hash[key] = hash[key].resolve(&block)\n hash\n end\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys(&block)\n result = {}\n each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value\n end\n result\n end",
"def hash_mapped(hash, prc1, &prc2)\n return_hash = Hash.new(0)\n\n hash.each do |k,v|\n return_hash[prc2.call(k)] = prc1.call(v)\n end\n return_hash\nend",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def each(&block)\n keys.each(&block)\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def vmap\n return map unless block_given?\n map { |k, v| [k, yield(v)] }.to_h\n end",
"def hash_mapped(hsh, prc, &bloc)\n mapped = Hash.new \n\n hsh.each { |k, v| mapped[bloc.call(k)] = prc.call(v) }\n\n mapped\nend",
"def kmap\n return map unless block_given?\n map { |k, v| [yield(k), v] }.to_h\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def hash_mapped(hash, prc1, &prc2)\n new_hash = Hash.new\n hash.each do |key, value|\n new_hash[prc2.call(key)] = prc1.call(value)\n end\n new_hash\nend",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def map! &block\n mapped = enumerable_map(&block)\n clear\n merge mapped\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def apply_mappings(body)\n {}.tap do |hash|\n mapping_data = $config.dig(:mapping, 'data')\n body.each do |key, value|\n hash[mapping_data.fetch(key, key)] = map_value(value)\n end\n end\n end",
"def rehash\n out = {}\n each_pair { |k, v| out[k] = v }\n replace out\n end",
"def transform_keys(&block)\n @key_transformer = block\n end",
"def deep_transform_keys!(&block); end",
"def deep_transform_keys(&block); end",
"def block_to_hash(default = {}, &block)\n default.merge((yield HashWithAccessors.new(default)).to_hash) if block_given?\n end",
"def remap\n each_with_object({}) { |a, hash| hash[yield a[0]] = a[1] }\n end",
"def in_mappa(&block)\n if block_given?\n self.map(&block).to_h\n else\n self.to_h\n end\n end",
"def transform_keys(&block)\n return to_enum(:transform_keys) unless block_given?\n new_instance_with_inherited_permitted_status(\n @parameters.transform_keys(&block)\n )\n end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def each\n @internal_hash.each { |k,_| yield k }\n end",
"def each_key(&block)\n self.keys.each{|k| block.call(k)}\n self\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def map(&block)\n mapper.instance_eval(&block)\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def each_key(&block)\n keys.each(&block)\n end",
"def my_map\n\t\tmapped = []\n\t\tif block_given?\n\t\t\tself.my_each { |elt| mapped << (yield elt) }\n\t\tend\n\t\tmapped\n\tend",
"def map(hash); end",
"def each(*args, &block)\n @hash.each(*args, &block)\n end",
"def map!(&block)\n self.replace(self.map &block)\n end",
"def map_keys!(hash, fn)\n hash.keys.each { |key| hash[fn[key]] = hash.delete(key) }\n hash\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def transform_values\n map_to_hash { |key, value| [key, yield(value)] }\n end",
"def each_hash(with_table=nil, &block)\n return enum_for(:each_hash, with_table) unless block\n while rec = fetch_hash(with_table)\n block.call rec\n end\n self\n end",
"def each_hash(with_table=nil, &block)\n return enum_for(:each_hash, with_table) unless block\n while rec = fetch_hash(with_table)\n block.call rec\n end\n self\n end",
"def change_keys!(options = {}, &block)\n Hash::KeyChanger.new(self).change_keys(options, &block)\n end",
"def new_hash(*args, &block)\n if block\n r = hash_class.new\n r.default = block\n r\n elsif args.size == 1\n value = args.first\n if value.is_a?(Hash) or value.is_a?(hash_class)\n r = hash_class.new\n r.putAll(value)\n r\n else\n r = hash_class.new\n r.default = value\n r\n end\n else\n r = hash_class.new\n args.each_slice(2) {|key,val| r.put(key,val)}\n r\n end\n end",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def build_hash items\n result = {}\n items.each do |v|\n k = yield v\n if result.has_key? k\n raise \"Duplicate hash key: #{k} with values #{v} and #{result[k]}\"\n end\n result[k] = v\n end\n result\n end",
"def rehash\n buckets.compact.each do |key, value|\n insert(key, value)\n end\n end",
"def hash_map(h)\n Hash[\n h.map { |k, v| [k, yield(k, v)] }\n ]\nend",
"def to_hash_with_key\r\n result = {}\r\n each do |elt|\r\n result[yield(elt)] = elt\r\n end\r\n result\r\n end",
"def transform_keys!(&block)\n return to_enum(:transform_keys!) unless block_given?\n @parameters.transform_keys!(&block)\n self\n end",
"def deep_transform &block\n\n\t\tDeepTransform.do_deep_transform_on_hashlike_(self, &block)\n\tend",
"def each(&block)\n return super(&block) unless @lazy_loading && @processors.any?\n self.keys.each { |k| block.(k, self[k]) }\n end",
"def each(&block)\n to_h.each(&block)\n end",
"def to_hash\r\n result = {}\r\n each do |elt|\r\n result[elt] = yield(elt)\r\n end\r\n result\r\n end",
"def deep_transform_keys(&block)\n new_instance_with_inherited_permitted_status(\n @parameters.deep_transform_keys(&block)\n )\n end",
"def transform_keys\n { a: 1, b: 2 }.transform_keys { |key| key_map[key] || key }\n end",
"def map_keywords(block)\n block\n .parameters\n .select { |arg,| arg.equal?(:keyreq) }\n .to_h { [_2, BLOCK_OPTIONS_MAPPINGS[_2]] }\n end",
"def each\n\n return unless block_given?\n self.to_h.each { |k, v| yield(k, v) }\n end",
"def mapping\n @mapping ||= {}\n if block_given?\n @store_mapping = true and yield and @store_mapping = false\n create_elasticsearch_index\n else\n @mapping\n end\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def each_pair(&block)\n @hash.each_pair(&block)\n end",
"def blocks_to_hash(blocks)\n blocks.each_with_object({}) do |block, hash|\n hash.merge!(block.to_hash)\n end\n end",
"def merge(other_hash, &block)\n to_h.merge(other_hash, &block).reduce(self.class.new) do |map, pair|\n map[pair.first] = pair.last\n map\n end\n end",
"def merge(other_hash, &block)\n to_h.merge(other_hash, &block).reduce(self.class.new) do |map, pair|\n map[pair.first] = pair.last\n map\n end\n end",
"def each\n @hash.each_key { |o| yield(o) }\n self\n end",
"def each(&block)\n @items.each_key(&block)\n self\n end",
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def hmap_val(&block)\n self.hmap { |k, v| [k, block.call(v)] }\n end",
"def ingest_configuration_block!(hash, &block)\n hash.each do |k, v|\n value = if v.is_a?(Hash)\n ingest_configuration_block!(v, &block)\n else\n zip_to_hash(block, *Array(v))\n end\n\n hash.merge! k => value\n end\n end",
"def group_by(&block)\n result = {}\n each {|value|\n new_key = block.call(value)\n (result[new_key] ||= []) << value\n }\n result\n end",
"def group_by(&block)\n result = {}\n each {|value|\n new_key = block.call(value)\n (result[new_key] ||= []) << value\n }\n result\n end",
"def each(&block)\n @index.each do |key, start_length|\n block.call([key, self[key]])\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def each_key(&block)\n config.resolver.each_key(_container, &block)\n self\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end"
] | [
"0.7017899",
"0.6760221",
"0.6752278",
"0.6417896",
"0.63462883",
"0.6295345",
"0.6265601",
"0.62649757",
"0.6250273",
"0.6204803",
"0.6175375",
"0.617129",
"0.6165666",
"0.61600757",
"0.611611",
"0.61144835",
"0.60972804",
"0.6071984",
"0.60192746",
"0.601169",
"0.601169",
"0.5960607",
"0.59512895",
"0.59362084",
"0.59362084",
"0.59268993",
"0.58680254",
"0.5862977",
"0.58469856",
"0.58292025",
"0.58217734",
"0.5812136",
"0.57965106",
"0.57954293",
"0.5790823",
"0.57669765",
"0.57541525",
"0.5737749",
"0.570543",
"0.56936675",
"0.5689287",
"0.5685528",
"0.5677649",
"0.5661308",
"0.56604755",
"0.5658924",
"0.56471854",
"0.5639337",
"0.5639337",
"0.5639337",
"0.5639337",
"0.5631846",
"0.56308997",
"0.5621094",
"0.5621094",
"0.5614808",
"0.5586001",
"0.5580693",
"0.5564132",
"0.55490613",
"0.55425143",
"0.5531881",
"0.5531881",
"0.55256647",
"0.54888934",
"0.54888934",
"0.5482883",
"0.547909",
"0.54720193",
"0.546747",
"0.54614764",
"0.5457943",
"0.54554",
"0.5447741",
"0.5435121",
"0.54256445",
"0.5424049",
"0.540807",
"0.5407781",
"0.53919005",
"0.5379944",
"0.53790873",
"0.5365346",
"0.53466964",
"0.5340418",
"0.53396803",
"0.53382236",
"0.53382236",
"0.5338085",
"0.5336374",
"0.53340656",
"0.5324088",
"0.5321886",
"0.5315513",
"0.5315513",
"0.5289935",
"0.5284149",
"0.5280233",
"0.5275518",
"0.5270061"
] | 0.59291345 | 25 |
The difference from with_keys is that modify_keys expects block that takes 2 arguments (key: value pair) and returns the new key. | def modify_keys
each_with_object self.class.new do |hash_pair, hsh|
hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_keys!(options = {}, &block)\n Hash::KeyChanger.new(self).change_keys(options, &block)\n end",
"def transform_keys(&block)\n @key_transformer = block\n end",
"def transform_keys!(&block); end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def transform_keys(&block); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def transform_keys!(&block)\n return to_enum(:transform_keys!) unless block_given?\n @parameters.transform_keys!(&block)\n self\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def new_key(old_key)\n key_store[old_key] || old_key\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def rename_keys!(keys_hash)\n keys_hash.each do |old, new|\n self[new] = self.delete(old) if self[old]\n end\n self\n end",
"def each_key(&block)\n self.keys.each{|k| block.call(k)}\n self\n end",
"def transform_keys!(hash)\n return enum_for(:transform_keys!, hash) unless block_given?\n hash.keys.each do |key|\n hash[yield(key)] = hash.delete(key)\n end\n hash\n end",
"def transform_keys!\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def each_key(&block)\n keys.each(&block)\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_transform_keys!(&block); end",
"def modify\n authorized_keys_file = @filename\n keys = Hash.new\n\n @@mutex.synchronize do\n PathUtils.flock(@lockfile) do\n File.open(authorized_keys_file, File::RDWR|File::CREAT, @mode) do |file|\n file.each_line do |line|\n begin\n keys[line.split[-1].chomp] = line.chomp\n rescue\n end\n end\n\n if block_given?\n old_keys = keys.clone\n\n yield keys\n\n if old_keys != keys\n file.seek(0, IO::SEEK_SET)\n file.write(keys.values.join(\"\\n\")+\"\\n\")\n file.truncate(file.tell)\n end\n end\n file.close\n end\n PathUtils.oo_chown(0, @container.gid, authorized_keys_file)\n @container.chcon(authorized_keys_file,\n ::OpenShift::Runtime::Utils::SelinuxContext.instance.get_mcs_label(@container.uid))\n end\n end\n keys\n end",
"def deep_transform_keys(&block)\n result = {}\n each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value\n end\n result\n end",
"def transform_keys(&block)\n return to_enum(:transform_keys) unless block_given?\n new_instance_with_inherited_permitted_status(\n @parameters.transform_keys(&block)\n )\n end",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def transform_keys(*matchers, **options, &block)\n transform Reporting::Transforms::TransformKeys, matchers: matchers, **options, &block\n end",
"def deep_transform_keys(&block); end",
"def my_hash_modification_method(source, thing_to_modify)\n source.each do |key, value|\n source[key]+= thing_to_modify\n end\nend",
"def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend",
"def rekey(o, &block)\n\n case o\n when Hash; o.remap { |(k, v), h| h[block.call(k)] = rekey(v, &block) }\n when Array; o.collect { |e| rekey(e, &block) }\n when Symbol; o.to_s\n else o\n end\n end",
"def with_keys\n keys.each_with_object self.class.new do |hash_key, hsh|\n hsh[ yield hash_key ] = self[ hash_key ]\n end\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\nreturn source.each_with_object(source) { |(key, value), hash| hash[key] = value + thing_to_modify}\nend",
"def my_hash_modification_method(source, things_to_modify)\n source.each {|k, v| source[k] = v + things_to_modify}\nend",
"def chain_change_keys!(*calls)\n options = calls.extract_options!\n\n calls.inject(self) do |h, m|\n h.change_keys!(options, &m)\n end\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n source.map do |k, v|\n source[k] = v += thing_to_modify\n end\n return source\nend",
"def my_hash_modification_method!(source, thing_to_modify)\n# source = Hash[source.map {|k,v| [k, thing_to_modify + v ]}]\nsource.each do |key, value|\n source[key] = value + thing_to_modify\nend\nend",
"def swapkey!( newkey, oldkey )\n self[newkey] = self.delete(oldkey) if self.has_key?(oldkey)\n self\n end",
"def swapkey!( newkey, oldkey )\n self[newkey] = self.delete(oldkey) if self.has_key?(oldkey)\n self\n end",
"def transform_keys\n { a: 1, b: 2 }.transform_keys { |key| key_map[key] || key }\n end",
"def set_key(key, &block)\n @callbacks[key.ord] = block\n end",
"def rename_keys!(request, new_client_or_user_name)\n orig_keys_path = keys_path_base(request)\n new_keys_path = orig_keys_path.dup\n .tap { |path| path[-2] = new_client_or_user_name }\n\n key_names = list_data_or_else(request, orig_keys_path, nil)\n return unless key_names # No keys to move\n\n key_names.each do |key_name|\n # Get old data\n orig_path = [ *orig_keys_path, key_name ]\n data = get_data(request, orig_path, :data_store_exceptions)\n\n # Copy data to new path\n create_data(\n request,\n new_keys_path, key_name,\n data,\n :create_dir\n )\n end\n\n # Delete original data\n delete_data_dir(request, orig_keys_path, :recursive, :data_store_exceptions)\n end",
"def deep_transform_keys(&block)\n new_instance_with_inherited_permitted_status(\n @parameters.deep_transform_keys(&block)\n )\n end",
"def new_key(list, key, value)\n\tlist[key] = value\nend",
"def my_hash_modification_method!(my_family_pets_ages, thing_to_modify)\n my_family_pets_ages.each do |key, value|\n my_family_pets_ages[key] = value + thing_to_modify\n end\nend",
"def increment(key, amount=1, &block)\n if block.nil?\n key_to_use = key\n else\n key_to_use = self.keys.detect { |k| block.call(key, k) } \n end\n \n if self[key_to_use].nil?\n self[key_to_use] = amount\n else\n self[key_to_use] += amount\n end\n end",
"def set_composite_key(&block)\n if persisted? && key_field_changed?\n swap_composite_keys(&block)\n else\n identify and block.call\n end\n end",
"def change_key=(value)\n @change_key = value\n end",
"def updateKey; @key = getKey; self end",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n modded_hash = source.update(source){|k, v| v + thing_to_modify}\n p modded_hash\nend",
"def key=(new_key)\n @key = new_key\n end",
"def each_key(container, &block)\n container.each_key(&block)\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def with_keys_disabled\n disable_keys\n yield\n enable_keys\n end",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def internal_replace(key, expected_old_value = T.unsafe(nil), &block); end",
"def with_keys_disabled\n disable_keys\n yield\n enable_keys\n end",
"def new_key(school,key,value)\n school[key.to_sym] = value\nend",
"def each_key\n @keys.values.each do |k|\n yield k\n end\n end",
"def each(&block)\n self.keys.each{|k| block.call([k, self[k]])}\n self\n end",
"def forward_as_key!(receiver, *keys)\n keys.each {|key| forward_as_key(receiver, key)}\n end",
"def each_key(&block); end",
"def rename_keys!(hash, mapping)\n mapping.each { |k, v| hash[v] = hash.delete(k) }\n hash\n end",
"def swap_composite_keys(&block)\n @identifier, new_id = id.dup, identify\n block.call\n @identifier = nil\n end",
"def each(&block)\n keys.each(&block)\n end",
"def my_hash_modification_method!(source, years_to_add)\n source.each do |name, old_age|\n source[name] = old_age + years_to_add\n end\n return source\nend",
"def update!(new_key_vals)\n check_keys(new_key_vals.keys)\n @key_vals.merge!(new_key_vals)\n rebuild_array\n self\n end",
"def rename(newkey)\n redis.rename @key, sanitize_key(newkey)\n\n @key = newkey\n ensure\n notify_changed\n end",
"def rekey_as_needed; end",
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def with(new_key_vals)\n check_keys(new_key_vals.keys)\n self.class.new(@key_vals.merge(new_key_vals))\n end",
"def with_key_transform(proc = nil, &block)\n fn = proc || block\n\n raise ArgumentError, \"a block or callable argument is required\" if fn.nil?\n\n handle = Dry::Types::FnContainer.register(fn)\n with(key_transform_fn: handle)\n end",
"def change_key(key, new_key, delete=false)\n return if @stored[key].nil? || @stored[key].empty? || (key == new_key)\n \n # Must maintain heap property\n raise \"Changing this key would not maintain heap property!\" unless (delete || @compare_fn[new_key, key])\n node = @stored[key].shift\n if node\n node.key = new_key\n @stored[new_key] ||= []\n @stored[new_key] << node\n parent = node.parent\n if parent\n # if heap property is violated\n if delete || @compare_fn[new_key, parent.key]\n cut(node, parent)\n cascading_cut(parent)\n end\n end\n if delete || @compare_fn[node.key, @next.key]\n @next = node\n end\n return [node.key, node.value]\n end\n nil\n end",
"def delete(key, &block); end",
"def update!(**args)\n @keys = args[:keys] if args.key?(:keys)\n end",
"def update!(**args)\n @keys = args[:keys] if args.key?(:keys)\n end",
"def exchange_keys; end",
"def exchange_keys; end",
"def my_hash_modification_method(source, thing_to_modify)\n newsource=Hash[source.map{|key, value| [key, value.is_a?(Integer)? value + thing_to_modify : value]}]\nend",
"def test_mod_with_lambda\n @hash_builder.values_mod = lambda {|element| return (element.to_i * 2).to_s}\n expected = {'one' => '2', 'two' => '4', 'three' => '6'}\n map = @hash_builder.hash\n assert_equal(expected, map)\n end",
"def watch(*keys, &block)\n ensure_same_node(:watch, keys) do |node|\n @watch_key = key_tag(keys.first) || keys.first.to_s\n\n begin\n node.watch(*keys, &block)\n rescue StandardError\n @watch_key = nil\n raise\n end\n end\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def nested_keys(&block)\n Enumerator.new do |y|\n to_a.each do |k,v|\n y.yield k\n v.nested_keys { |nk| y.yield(nk) } if v.is_a?(Hash)\n end\n end.each(&block)\n end",
"def each(&block)\n @items.each_key(&block)\n self\n end",
"def my_hash_modification_method!(hash, age_diff)\n hash.each { |name, age| hash[name] = (age + age_diff) }\nend",
"def kms_key= new_kms_key_name\n frozen_check!\n @gapi.kms_key_name = new_kms_key_name\n end",
"def each_key(&block)\n config.resolver.each_key(_container, &block)\n self\n end",
"def []= k, v \n split_fields if not @h\n kupper = k.upcase\n @h[kupper] = v\n @original_key[kupper] = k\n end",
"def map_keys!(hash, fn)\n hash.keys.each { |key| hash[fn[key]] = hash.delete(key) }\n hash\n end",
"def incr(key); end",
"def incr(key); end"
] | [
"0.7046134",
"0.6701812",
"0.6563892",
"0.6489941",
"0.6489941",
"0.64120585",
"0.63497555",
"0.6327554",
"0.62617",
"0.6221917",
"0.6221917",
"0.6221917",
"0.6221917",
"0.61262983",
"0.6104013",
"0.6077979",
"0.6073564",
"0.60711193",
"0.6051081",
"0.6031146",
"0.6031146",
"0.6027657",
"0.60005826",
"0.60005826",
"0.60005826",
"0.5988066",
"0.595527",
"0.59388745",
"0.59275395",
"0.59073377",
"0.58844095",
"0.5866249",
"0.5860439",
"0.5838692",
"0.5827354",
"0.57944906",
"0.5768682",
"0.57052237",
"0.5693873",
"0.56743604",
"0.5624641",
"0.5623668",
"0.56130826",
"0.5610325",
"0.5604572",
"0.55772024",
"0.55772024",
"0.55698067",
"0.5566651",
"0.5490197",
"0.54822874",
"0.54536635",
"0.53907055",
"0.53615063",
"0.5357313",
"0.5349044",
"0.5347198",
"0.5334938",
"0.5330176",
"0.53293693",
"0.5309648",
"0.5285363",
"0.52641517",
"0.52490383",
"0.52175295",
"0.52105254",
"0.5208087",
"0.51983875",
"0.51701343",
"0.5146178",
"0.51381755",
"0.5132169",
"0.5118546",
"0.5115585",
"0.5101696",
"0.50997216",
"0.50820416",
"0.50549686",
"0.50451094",
"0.50377876",
"0.50141966",
"0.5011133",
"0.5001295",
"0.49851176",
"0.49851176",
"0.49832696",
"0.49832696",
"0.4977509",
"0.4948249",
"0.49256054",
"0.4924728",
"0.49090984",
"0.49046856",
"0.48976976",
"0.48875135",
"0.48832357",
"0.48828262",
"0.48814118",
"0.4878834",
"0.4878834"
] | 0.70331115 | 1 |
Applies a block as a mapping on all values, returning a new hash. | def with_values
each_with_object self.class.new do |(k, v), hsh| hsh[ k ] = yield v end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_into_hash(&block)\n Hash[*map {|x| [x[0], block.call(x)]}.inject([], &:concat)]\n end",
"def map_values &block\n keys.inject({}) {|acc,k|\n acc[k] = yield(k, self[k])\n acc\n }\n end",
"def hash_mapped(hash, prc, &block)\n new_hash = {}\n hash.each do |k, v|\n new_hash[block.call[k]] = prc.call(v)\n end \n new_hash\nend",
"def remap\n # This is Ruby magic for turning a hash into an array into a hash again\n Hash[*self.map do |key, value|\n yield key, value\n end.compact.flatten]\n end",
"def map! &block\n mapped = enumerable_map(&block)\n clear\n merge mapped\n end",
"def hmap_val(&block)\n self.hmap { |k, v| [k, block.call(v)] }\n end",
"def apply_mappings(body)\n {}.tap do |hash|\n mapping_data = $config.dig(:mapping, 'data')\n body.each do |key, value|\n hash[mapping_data.fetch(key, key)] = map_value(value)\n end\n end\n end",
"def each(&block)\n hash.each(&block)\n end",
"def each(&block)\n @hash.each(&block)\n end",
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def map(&blk)\n _values.map(&blk)\n end",
"def map(&block)\n mapper.instance_eval(&block)\n end",
"def map!(&block)\n self.replace(self.map &block)\n end",
"def remap\n each_with_object({}) { |a, hash| hash[yield a[0]] = a[1] }\n end",
"def transform_values &_block # :yields: value\n return enum_for(:transform_values) unless block_given?\n hsh = {}\n each do |k, v|\n hsh[k] = yield v\n end\n hsh\n end",
"def transform_values\n map_to_hash { |key, value| [key, yield(value)] }\n end",
"def map(hash); end",
"def vmap\n return map unless block_given?\n map { |k, v| [k, yield(v)] }.to_h\n end",
"def each(&block)\n @hash.each {|k,v| block.call k,v }\n end",
"def my_map\n\t\tmapped = []\n\t\tif block_given?\n\t\t\tself.my_each { |elt| mapped << (yield elt) }\n\t\tend\n\t\tmapped\n\tend",
"def hmap\n return map unless block_given?\n map { |k, v| yield(k, v) }.compact.to_h\n end",
"def resolve_all(key, &block)\n map do |hash|\n hash = hash.dup\n hash[key] = hash[key].resolve(&block)\n hash\n end\n end",
"def transform_hash(original, &block)\n original.inject({}) do |result, (key, value)|\n value = if value.is_a?(Hash)\n transform_hash(value, &block)\n else\n value\n end\n yield(result, key, value)\n result\n end\n end",
"def in_mappa(&block)\n if block_given?\n self.map(&block).to_h\n else\n self.to_h\n end\n end",
"def map(*args, &blk) values.map(*args, &blk) ; end",
"def hash_mapped(hash, prc1, &prc2)\n return_hash = Hash.new(0)\n\n hash.each do |k,v|\n return_hash[prc2.call(k)] = prc1.call(v)\n end\n return_hash\nend",
"def hash_mapped(hsh, prc, &bloc)\n mapped = Hash.new \n\n hsh.each { |k, v| mapped[bloc.call(k)] = prc.call(v) }\n\n mapped\nend",
"def hash_mapped(hash, proc_a, &prc)\n new_hash = Hash.new(0)\n\n hash.each do |k, v|\n new_k = prc.call(k)\n new_hash[new_k] = proc_a.call(v)\n end\n new_hash\nend",
"def hash_mapped(hash, prc1, &prc2)\n new_hash = Hash.new\n hash.each do |key, value|\n new_hash[prc2.call(key)] = prc1.call(value)\n end\n new_hash\nend",
"def map_values!(hash, fn)\n hash.each { |key, value| hash[key] = fn[value] }\n hash\n end",
"def each(&block)\n to_h.each(&block)\n end",
"def each( &block ) # :yield: member, value\n\t\t\[email protected]( &block )\n\t\tend",
"def map(&block)\n dup.map!(&block)\n end",
"def my_map\n\t\tresult = []\n\t\tif block_given?\n\t\t\tself.my_each do |element|\n\t\t\t\tresult << user_block.call(element)\n\t\t\tend\n\t\t\tresult\n\t\telse\n\t\t\tself \n\t\tend\n\tend",
"def map_attributes(&block)\n if !block_given? || block.arity != 1\n raise InvalidBlockSpecification, \"after proc should have an arity of 1 (Hash|Array: values)\"\n end \n @options[:map_attributes] = block\n end",
"def my_map(block = nil)\n output = []\n my_each do |item|\n if block.nil?\n output.push(yield(item))\n else\n output.push(block.call(item))\n end\n end\n return output\n end",
"def create_hash(&block); end",
"def create_hash(&block); end",
"def ingest_configuration_block!(hash, &block)\n hash.each do |k, v|\n value = if v.is_a?(Hash)\n ingest_configuration_block!(v, &block)\n else\n zip_to_hash(block, *Array(v))\n end\n\n hash.merge! k => value\n end\n end",
"def deep_transform &block\n\n\t\tDeepTransform.do_deep_transform_on_hashlike_(self, &block)\n\tend",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def my_map block\n output = []\n for i in self\n output << block.call(i)\n end\n output\n end",
"def map!(&block_)\n raise TableLockedError if @parent\n @vals.map!(&block_)\n self\n end",
"def my_map(&block)\n result = []\n my_each do |elem|\n result << block.call(elem)\n end\n result\n end",
"def each(&block)\n return to_enum unless block_given?\n @map.each(&block)\n self\n end",
"def transform_values! &block # :yields: value\n return enum_for(:transform_values!) unless block_given?\n each do |k, v|\n store k, (yield v)\n end\n self\n end",
"def block_to_hash(default = {}, &block)\n default.merge((yield HashWithAccessors.new(default)).to_hash) if block_given?\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def map\n r = self.dup\n begin\n r[0] = yield r[0]\n r[1] = yield r[1]\n rescue TypeError => e\n warn \"the block associated with #map returned nil; aborting map function\"\n puts e.backtrace\n end\n r\n end",
"def merge(other_hash, &block)\n to_h.merge(other_hash, &block).reduce(self.class.new) do |map, pair|\n map[pair.first] = pair.last\n map\n end\n end",
"def merge(other_hash, &block)\n to_h.merge(other_hash, &block).reduce(self.class.new) do |map, pair|\n map[pair.first] = pair.last\n map\n end\n end",
"def map &block\n self.class.from_a enumerable_map(&block)\n end",
"def each(*args, &block)\n @hash.each(*args, &block)\n end",
"def each(&block)\n self.keys.each{|k| block.call([k, self[k]])}\n self\n end",
"def each_pair(&block)\n @hash.each_pair(&block)\n end",
"def my_map\n\t\treturn to_enum(:my_map) unless block_given?\n\t\tmapped_array = []\n\t\tfor elements in self\n\t\t\tmapped_array.push(yield(elements))\n\t\tend\n\t\tmapped_array\n\n\tend",
"def my_map(&block)\n array = Array.new\n self.my_each do |x|\n array << block.call(x)\n end\n array\n end",
"def each(&block)\n @values.each(&block)\n self\n end",
"def map_keys\n inject(self.class.new) do |memo, (key, value)|\n memo[yield(key)] = value\n memo\n end\n end",
"def mapping\n @mapping ||= {}\n if block_given?\n @store_mapping = true and yield and @store_mapping = false\n create_elasticsearch_index\n else\n @mapping\n end\n end",
"def map_to_h(&block)\n [self, map(&block)].transpose.to_h\n end",
"def update(*other_hashes, &blk); end",
"def each_value_for_hash(params, &block)\n case params\n when Hash then params.each { |_k, v| each_value_for_hash(v, &block) }\n when Array then params.each { |v| each_value_for_hash(v, &block) }\n else\n yield params\n end\n end",
"def each(&blk)\n to_h.each(&blk)\n end",
"def hash(hash, &block)\n hash.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = _recurse_(value, &block)\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def map\n yield(@value)\n end",
"def transform_values(context, hash)\n hash.transform_values do |blocks|\n accumulator = []\n Array(blocks).each do |block|\n block.call(context.source_record, accumulator, context)\n end\n accumulator\n end\n end",
"def map(&block_)\n if @parent\n vec_ = ::Array.new(@structure.dim, 0)\n nvals_ = ([email protected]).map do |i_|\n val_ = yield(@vals[@offset + @structure._compute_offset_for_vector(vec_)])\n @structure._inc_vector(vec_)\n val_\n end\n Table.new(@structure.unlocked_copy, :acquire => nvals_)\n else\n Table.new(@structure, :acquire => @vals.map(&block_))\n end\n end",
"def to_hash\r\n result = {}\r\n each do |elt|\r\n result[elt] = yield(elt)\r\n end\r\n result\r\n end",
"def each_hash(with_table=nil, &block)\n return enum_for(:each_hash, with_table) unless block\n while rec = fetch_hash(with_table)\n block.call rec\n end\n self\n end",
"def each_hash(with_table=nil, &block)\n return enum_for(:each_hash, with_table) unless block\n while rec = fetch_hash(with_table)\n block.call rec\n end\n self\n end",
"def each_value(&block)\n self.keys.each{|k| block.call(self[k])}\n self\n end",
"def blocks_to_hash(blocks)\n blocks.each_with_object({}) do |block, hash|\n hash.merge!(block.to_hash)\n end\n end",
"def with_values!\n each_with_object self do |(k, v), hsh| hsh[ k ] = yield v end\n end",
"def each_value(&block)\n return to_enum(:each_value) unless block_given?\n @parameters.each_pair do |key, value|\n yield convert_hashes_to_parameters(key, value)\n end\n\n self\n end",
"def my_map\n return self unless block_given?\n mapped = []\n for m in self\n mapped << yield(m)\n end\n return mapped\n end",
"def applyhash\n result = {}\n result[:sample] = :apply_samples\n result[:split] = :apply_splits\n return result\n end",
"def mapper &mapper_block\n @mapper_block = mapper_block.to_proc\n self.instance_eval do\n def process *args, &block\n instance_exec(*args, &@mapper_block)\n end\n end\n self\n end",
"def my_map_with_block_and_proc(proc = nil)\n\t\tcontainer = []\n\t\tself.my_each do |x|\n\t\t\tif block_given? && proc\n\t\t\t\tfirst = proc.call(x)\n\t\t\t\tcontainer << yield(first)\n\t\t\telsif !proc\n\t\t\t\tcontainer << yield(x)\n\t\t\telsif !block_given?\n\t\t\t\tcontainer << proc.call(x)\n\t\t\tend\n\t\tend\n\t\tcontainer\n\tend",
"def map_by(&blk)\n clone.map_by &blk\n end",
"def my_map_mod(p = nil)\n return to_enum(:my_map) unless block_given? || p\n\n result = []\n if block_given?\n if self.is_a? Hash\n my_each { |k,v| result << yield(k, v) }\n else # self is array\n my_each { |elem| result << yield(elem) }\n end\n elsif proc\n if self.is_a? Hash\n my_each { |k,v| result << p.call(k, v) }\n else # self is array\n my_each { |elem| result << p.call(elem) }\n end\n end\n result\n end",
"def initialize_mapping\n @mapping = primitives.map(&:mapping).reduce(:merge) || {}\n end",
"def each\n @values_map.each do |key, value|\n yield key, value\n end\n end",
"def each(&blk)\n _values.each(&blk)\n end",
"def each_hash\n if block_given?\n while row = next_hash\n yield row\n end\n else\n self.enum_for(:each_hash)\n end\n end",
"def group_by(&block)\n result = {}\n each {|value|\n new_key = block.call(value)\n (result[new_key] ||= []) << value\n }\n result\n end",
"def group_by(&block)\n result = {}\n each {|value|\n new_key = block.call(value)\n (result[new_key] ||= []) << value\n }\n result\n end",
"def hash_map(h)\n Hash[\n h.map { |k, v| [k, yield(k, v)] }\n ]\nend",
"def each\n original.each do |key, value|\n yield key, value\n end\n end",
"def map!\n return to_enum( :map! ) unless block_given?\n expand( address ).flatten.each { |addr| data[ addr ] = yield data[ addr ] }\n end",
"def map(&blk)\n raise ArgumentError, \"Another mapper is already defined\" if @_mapper\n @_mapper = blk\n end",
"def rehash\n out = {}\n each_pair { |k, v| out[k] = v }\n replace out\n end",
"def each(&block)\n @values.each(&block)\n end",
"def map(&block)\n to_a.map(&block)\n end",
"def map(&block)\n to_a.map(&block)\n end",
"def recalculate_values_hashes\n vh = {}\n @values.each do |k,v|\n vh[k] = v.hash\n end\n @values_hashes = vh.freeze\n end",
"def each_pair(&block)\n return to_enum(__callee__) unless block_given?\n @parameters.each_pair do |key, value|\n yield [key, convert_hashes_to_parameters(key, value)]\n end\n\n self\n end",
"def map_bucket\n @buckets.map do |bucket_name, bucket|\n yield bucket_name, bucket\n end if block_given?\n end"
] | [
"0.7244583",
"0.71429604",
"0.7062576",
"0.6548765",
"0.64875376",
"0.64793706",
"0.6475992",
"0.64561754",
"0.64016134",
"0.63935715",
"0.63692224",
"0.63340443",
"0.6298385",
"0.6263541",
"0.6254937",
"0.62542176",
"0.6247096",
"0.6219773",
"0.62044334",
"0.6203134",
"0.61769265",
"0.61707383",
"0.6084295",
"0.6058211",
"0.6051764",
"0.603198",
"0.6022856",
"0.5993141",
"0.5978657",
"0.59608924",
"0.5959414",
"0.59557015",
"0.59504396",
"0.59417796",
"0.5934858",
"0.5919599",
"0.58968353",
"0.5886149",
"0.5886149",
"0.58408105",
"0.58351207",
"0.58350587",
"0.58256614",
"0.5816375",
"0.5800177",
"0.5784457",
"0.57584876",
"0.5742964",
"0.5737039",
"0.5737039",
"0.57289016",
"0.57285863",
"0.57285863",
"0.5712442",
"0.5710915",
"0.570585",
"0.57031345",
"0.5696588",
"0.56708527",
"0.56453794",
"0.5628222",
"0.5616736",
"0.56098706",
"0.56073916",
"0.5598331",
"0.5591283",
"0.5589522",
"0.5572173",
"0.5568469",
"0.55629516",
"0.55617297",
"0.55607486",
"0.55607486",
"0.55604",
"0.55569094",
"0.5553084",
"0.5538709",
"0.5526084",
"0.5507351",
"0.55019164",
"0.549945",
"0.5493949",
"0.5480936",
"0.54807925",
"0.5479287",
"0.5475309",
"0.5456249",
"0.5454359",
"0.5454359",
"0.5451414",
"0.5431593",
"0.5423629",
"0.5423539",
"0.54233456",
"0.54232115",
"0.54145384",
"0.54145384",
"0.541321",
"0.53979844",
"0.53938156"
] | 0.54932284 | 82 |
Like do_with_values, but modifies the receiver. | def with_values!
each_with_object self do |(k, v), hsh| hsh[ k ] = yield v end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def with_values\n @values = true\n self\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def transform_values!; end",
"def transform_values! &block # :yields: value\n return enum_for(:transform_values!) unless block_given?\n each do |k, v|\n store k, (yield v)\n end\n self\n end",
"def inject(*args)\n args = wrap_values(args)\n super(*args)\n end",
"def update!(**args)\n @value = args[:value] if args.key?(:value)\n @values = args[:values] if args.key?(:values)\n end",
"def with_values\n each_with_object self.class.new do |(k, v), hsh| hsh[ k ] = yield v end\n end",
"def prepared_modify_values\n @opts[:prepared_modify_values]\n end",
"def transform_values!\n return to_enum(:transform_values!) unless block_given?\n @parameters.transform_values! { |v| yield convert_value_to_parameters(v) }\n self\n end",
"def inject(*args)\n args = wrap_values(args)\n super(*args)\n end",
"def inject(*args)\n args = wrap_values(args)\n super(*args)\n end",
"def with_values\n Fetcher.new(self).with_values\n end",
"def update(values, opts = nil)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def deep_transform_values!(&block)\n _deep_transform_values_in_object!(self, &block)\n end",
"def update_values(values)\n before_update_values\n this.update(set_values(values))\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend",
"def old_value=(_arg0); end",
"def my_hash_modification_method!(source, thing_to_modify)\n source.map do |k, v|\n source[k] = v += thing_to_modify\n end\n return source\nend",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def reducx(*values)\n @assign = values.compact.reduce({ }, :merge!).keep_if &value_present\n self\n end",
"def reducx(*values)\n @assign = values.compact.reduce({ }, :merge).keep_if &value_present\n self\n end",
"def _reduce_196(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n\n result\nend",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def _reduce_194(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n\n result\nend",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update_values(*args)\n cache_delete\n super\n end",
"def update_values\n end",
"def update_values\n end",
"def _reduce_194(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_194(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @denied_values = args[:denied_values] if args.key?(:denied_values)\n @inherit_from_parent = args[:inherit_from_parent] if args.key?(:inherit_from_parent)\n @suggested_value = args[:suggested_value] if args.key?(:suggested_value)\n end",
"def copy_changed(**values)\n self.class.new(**self.to_hash.merge!(values))\n end",
"def _reduce_196(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_196(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_196(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_197(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_204(val, _values, result)\n result = new_assign val[0], val[2]\n\n result\nend",
"def _reduce_204(val, _values, result)\n result = new_assign val[0], val[2]\n\n result\nend",
"def _reduce_204(val, _values, result)\n result = new_assign val[0], val[2]\n\n result\nend",
"def _reduce_385(val, _values, result)\n @context.in_argdef = false\n\n result\nend",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @range = args[:range] if args.key?(:range)\n @value = args[:value] if args.key?(:value)\n end",
"def *(val)\n data * Reg.clean_value(val)\n end",
"def _reduce_201(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n\n result\nend",
"def update!(**args)\n @return_value = args[:return_value] if args.key?(:return_value)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend",
"def with(value)\n yield value\n end",
"def update(value_or_values)\n buffer.update(value_or_values)\n end",
"def user(*values)\n values.inject(self) { |res, val| res._user(val) }\n end",
"def _reduce_207(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_207(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_171(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n\n result\nend",
"def _reduce_199(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_201(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_201(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_171(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend",
"def _reduce_200(val, _values, result)\n result = @builder.assign(val[0], val[1], val[2])\n \n result\nend"
] | [
"0.6264453",
"0.6167606",
"0.6115198",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.60684884",
"0.5932668",
"0.5826649",
"0.57475924",
"0.57391495",
"0.5710634",
"0.56982976",
"0.5682476",
"0.566554",
"0.566554",
"0.56484115",
"0.56224966",
"0.56073344",
"0.5594445",
"0.5520426",
"0.5517926",
"0.548969",
"0.5483574",
"0.54484427",
"0.54326016",
"0.53705376",
"0.53690344",
"0.53684264",
"0.53679556",
"0.53679556",
"0.53520674",
"0.53508234",
"0.53508234",
"0.5337568",
"0.5337568",
"0.5330121",
"0.5328631",
"0.53190225",
"0.53190225",
"0.53190225",
"0.5310449",
"0.5309354",
"0.5309354",
"0.5309354",
"0.5299049",
"0.5295841",
"0.52876884",
"0.52811795",
"0.52719235",
"0.52697724",
"0.52668405",
"0.5257807",
"0.52552325",
"0.5234328",
"0.5234328",
"0.5233203",
"0.52318764",
"0.52316386",
"0.52316386",
"0.52132654",
"0.5210841"
] | 0.6076297 | 3 |
The difference from do_with_values is that modify_values expects block that takes 2 arguments (key: value pair) and returns the new value. | def modify_values
each_with_object self.class.new do |hash_pair, ꜧ|
ꜧ[ hash_pair[0] ] = yield( hash_pair )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def transform_values! &block # :yields: value\n return enum_for(:transform_values!) unless block_given?\n each do |k, v|\n store k, (yield v)\n end\n self\n end",
"def transform_values &_block # :yields: value\n return enum_for(:transform_values) unless block_given?\n hsh = {}\n each do |k, v|\n hsh[k] = yield v\n end\n hsh\n end",
"def each_value(&block)\n values.each(&block)\n end",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def with_values!\n each_with_object self do |(k, v), hsh| hsh[ k ] = yield v end\n end",
"def modify!\n raise ArgumentError.new('no block given') unless block_given?\n\n @mutex.synchronize do\n value = @value\n @value = yield value\n if unlocked_empty?\n @empty_condition.signal\n else\n @full_condition.signal\n end\n apply_deref_options(value)\n end\n end",
"def with_values\n each_with_object self.class.new do |(k, v), hsh| hsh[ k ] = yield v end\n end",
"def each(&block)\n @values.each(&block)\n end",
"def with_block(&block)\n yield self if block_given? && @value\n end",
"def process_value(value)\n block_given? ? yield(value) : value\n end",
"def each(&blk)\n values.each(&blk)\n end",
"def with(value, &block)\n block.call(value)\n end",
"def map(&blk)\n _values.map(&blk)\n end",
"def each(&blk)\n @values.each(&blk)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n source.map do |k, v|\n source[k] = v += thing_to_modify\n end\n return source\nend",
"def modify_prices(prices, &block)\n p block.inspect\nend",
"def each_value\n @vals.each {|v| yield v}\n end",
"def each(&block)\n @values.each(&block)\n self\n end",
"def each(&blk)\n _values.each(&blk)\n end",
"def swap(object, new_values)\n old_values = {}\n new_values.each do |key, value|\n old_values[key] = object.send key\n object.send :\"#{key}=\", value\n end\n yield\n ensure\n old_values.each do |key, value|\n object.send :\"#{key}=\", value\n end\n end",
"def modify_prices(prices, &block)\n prices.each do |p|\n block[p] if block_given?\n end\nend",
"def with(value)\n yield value\n end",
"def internal_replace(key, expected_old_value = T.unsafe(nil), &block); end",
"def transform_values!\n return to_enum(:transform_values!) unless block_given?\n @parameters.transform_values! { |v| yield convert_value_to_parameters(v) }\n self\n end",
"def test_mod_with_lambda\n @hash_builder.values_mod = lambda {|element| return (element.to_i * 2).to_s}\n expected = {'one' => '2', 'two' => '4', 'three' => '6'}\n map = @hash_builder.hash\n assert_equal(expected, map)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\nreturn source.each_with_object(source) { |(key, value), hash| hash[key] = value + thing_to_modify}\nend",
"def modify_prices(prices, &block)\n block.inspect\nend",
"def deep_transform_values!(&block)\n _deep_transform_values_in_object!(self, &block)\n end",
"def modify(timeout = nil)\n raise ArgumentError.new('no block given') unless block_given?\n\n @mutex.synchronize do\n wait_for_full(timeout)\n\n # If we timed out we'll still be empty\n if unlocked_full?\n value = @value\n @value = yield value\n @full_condition.signal\n apply_deref_options(value)\n else\n TIMEOUT\n end\n end\n end",
"def each(&block)\n\n\n\n values.each &block\n\n\n\n end",
"def each(&block)\n value.each(&block)\n end",
"def map(*args, &blk) values.map(*args, &blk) ; end",
"def swap(object, new_values)\n old_values = {}\n new_values.each do |key, value|\n old_values[key] = object.send key\n object.send :\"#{key}=\", value\n end\n clear_cached_variables(new_values)\n yield\n ensure\n clear_cached_variables(new_values)\n old_values.each do |key, value|\n object.send :\"#{key}=\", value\n end\n end",
"def swap(object, new_values)\n old_values = {}\n new_values.each do |key, value|\n old_values[key] = object.send key\n object.send :\"#{key}=\", value\n end\n clear_cached_variables(new_values)\n yield\n ensure\n clear_cached_variables(new_values)\n old_values.each do |key, value|\n object.send :\"#{key}=\", value\n end\n end",
"def change(values_={}, unparse_params_={})\n unparse_params_ = @_unparse_params.merge(unparse_params_) if @_unparse_params\n values_ = _canonicalize_values_hash(values_)\n Value.new(@_values.merge(values_), @_format, unparse_params_)\n end",
"def each_value(&block)\n return to_enum(:each_value) unless block_given?\n @parameters.each_pair do |key, value|\n yield convert_hashes_to_parameters(key, value)\n end\n\n self\n end",
"def update(&block)\n self.each_with_index do |e,i|\n self[i] = block.call(e)\n end\nend",
"def test_blocks_legacy\n hash_ = ::Hash.new\n block_ = ::Proc.new do\n set_value(:a){ 1 }\n end\n ::Blockenspiel.invoke(block_) do\n add_method(:set_value, :receive_block => true) do |key_, bl_|\n hash_[key_] = bl_.call\n end\n end\n assert_equal(1, hash_[:a])\n end",
"def map(&blk)\n return self unless valid?\n if @multiple\n @value.map!(&blk)\n else\n @value = yield(@value)\n end\n self\n end",
"def my_hash_modification_method(source, thing_to_modify)\n source.each do |key, value|\n source[key]+= thing_to_modify\n end\nend",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def each\n @values.each do |value|\n yield value\n end\n end",
"def test_mod_with_proc\n @hash_builder.values_mod = Proc.new {|element| return (element.to_i * 2).to_s}\n map = @hash_builder.hash\n flunk \"Never gets here\"\n # because return in Proc stops process and returns value to test_mod_with_proc caller\n end",
"def each_value(&block)\n self.keys.each{|k| block.call(self[k])}\n self\n end",
"def hmap_val(&block)\n self.hmap { |k, v| [k, block.call(v)] }\n end",
"def test_mod_with_proc_and_no_return\n @hash_builder.values_mod = Proc.new {|element| (element.to_i * 2).to_s}\n expected = {'one' => '2', 'two' => '4', 'three' => '6'}\n map = @hash_builder.hash\n assert_equal(expected, map)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend",
"def transform_values\n map_to_hash { |key, value| [key, yield(value)] }\n end",
"def apply(value)\n return value unless value # DISCUSS: is that ok here?\n \n if array?\n value = value.collect do |item|\n yield item\n end\n else\n value = yield value\n end\n \n value\n end",
"def update_values(values)\n before_update_values\n this.update(set_values(values))\n end",
"def each_value\n each { |k, v| yield v }\n end",
"def each_value\n each { |k, v| yield v }\n end",
"def update!(**args)\n @value = args[:value] if args.key?(:value)\n @values = args[:values] if args.key?(:values)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n# source = Hash[source.map {|k,v| [k, thing_to_modify + v ]}]\nsource.each do |key, value|\n source[key] = value + thing_to_modify\nend\nend",
"def my_hash_modification_method(source, things_to_modify)\n source.each {|k, v| source[k] = v + things_to_modify}\nend",
"def swap(object, new_values)\n old_values = {}\n\n new_values.each do |key, value|\n old_values[key] = object.send key\n object.send(:\"#{key}=\", value)\n end\n\n clear_cached_variables(new_values)\n\n yield\nensure\n clear_cached_variables(new_values)\n\n old_values.each do |key, value|\n object.send(:\"#{key}=\", value)\n end\nend",
"def transform_value(value, &block)\n if value.respond_to?(:each_index)\n value.map do |elem|\n elem.transform_keys(&block) rescue elem\n end\n else\n value.transform_keys(&block) rescue value\n end\n end",
"def each_value(&block); end"
] | [
"0.70878273",
"0.6709955",
"0.6445185",
"0.6364775",
"0.6345696",
"0.61099946",
"0.6093925",
"0.59731215",
"0.59385407",
"0.5900864",
"0.587235",
"0.5830395",
"0.58281344",
"0.57860756",
"0.57767963",
"0.57549393",
"0.5705455",
"0.570011",
"0.56847584",
"0.56792855",
"0.5676091",
"0.56706405",
"0.5662677",
"0.56604743",
"0.56513923",
"0.56486595",
"0.56196153",
"0.55851716",
"0.55704904",
"0.55104625",
"0.5498933",
"0.54706085",
"0.5465162",
"0.5457745",
"0.5457745",
"0.54535675",
"0.5439023",
"0.54261863",
"0.5404011",
"0.53973866",
"0.5393532",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5393158",
"0.5392341",
"0.5376171",
"0.5374847",
"0.53610164",
"0.5359894",
"0.5357852",
"0.5353868",
"0.5351141",
"0.5347114",
"0.5341339",
"0.5338094",
"0.5338094",
"0.5319659",
"0.5309027",
"0.5292489",
"0.5276351",
"0.5274662",
"0.5265774"
] | 0.69693863 | 1 |
Like modify_values, but modifies the receiver. | def modify_values!
each_with_object self do |hash_pair, ꜧ|
ꜧ[ hash_pair[0] ] = yield( hash_pair )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_values(values)\n before_update_values\n this.update(set_values(values))\n end",
"def prepared_modify_values\n @opts[:prepared_modify_values]\n end",
"def update_values\n end",
"def update_values\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def update_values(*args)\n cache_delete\n super\n end",
"def with_values\n @values = true\n self\n end",
"def revalue\n @value = nil\n @ops.each do |v|\n v[1].revalue\n end\n end",
"def transform_values!; end",
"def my_array_modification_method!(source, thing_to_modify)\n source.each_index do |x|\n if (source[x].is_a?(Integer))\n source[x]+=thing_to_modify\n end\n end\n source\nend",
"def update(values, opts = nil)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def update!(**args)\n @values = args[:values] if args.key?(:values)\n @pivot_value_regions = args[:pivot_value_regions] if args.key?(:pivot_value_regions)\n end",
"def update(orig_val, val)\r\n @m.load(@operand_addr, orig_val)\r\n @m.load(@operand_addr, val)\r\n end",
"def modify\n super\n end",
"def update!(**args)\n @value = args[:value] if args.key?(:value)\n @values = args[:values] if args.key?(:values)\n end",
"def _refresh_set_values(values)\n ret = super\n load_typecast\n ret\n end",
"def copy_changed(**values)\n self.class.new(**self.to_hash.merge!(values))\n end",
"def old_value=(_arg0); end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n @denied_values = args[:denied_values] if args.key?(:denied_values)\n @inherit_from_parent = args[:inherit_from_parent] if args.key?(:inherit_from_parent)\n @suggested_value = args[:suggested_value] if args.key?(:suggested_value)\n end",
"def new_value(old_value)\n raise 'to be implemented in subclass'\n end",
"def change(values_={}, unparse_params_={})\n unparse_params_ = @_unparse_params.merge(unparse_params_) if @_unparse_params\n values_ = _canonicalize_values_hash(values_)\n Value.new(@_values.merge(values_), @_format, unparse_params_)\n end",
"def transform_values!\n return to_enum(:transform_values!) unless block_given?\n @parameters.transform_values! { |v| yield convert_value_to_parameters(v) }\n self\n end",
"def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @range = args[:range] if args.key?(:range)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def update!(**args)\n @set_values = args[:set_values] if args.key?(:set_values)\n @unset_values = args[:unset_values] if args.key?(:unset_values)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend",
"def deep_transform_values!(&block)\n _deep_transform_values_in_object!(self, &block)\n end",
"def my_array_modification_method(source, thing_to_modify)\n source.map! do |x|\n \t\tif x.is_a?(Integer) \n \t\t\tx + thing_to_modify\n \t\telse\n \t\t\tx\n \t\tend\n \tend\nend",
"def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each { |a|\n if a.is_a? Integer\n new_array << a + thing_to_modify\n else\n new_array << a\n end\n }\n source.replace(new_array)\nend",
"def modify\n each_with_object self.class.new do |hash_pair, ꜧ|\n key, val = yield hash_pair\n ꜧ[key] = val\n end\n end",
"def updateVal!(newVal)\n update_attributes(amount: newVal)\n end",
"def _refresh_set_values(h)\n @values = h\n end",
"def _refresh_set_values(h)\n @values = h\n end",
"def transform_values! &block # :yields: value\n return enum_for(:transform_values!) unless block_given?\n each do |k, v|\n store k, (yield v)\n end\n self\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! do |element|\n if element.class == Fixnum\n element += thing_to_modify\n else\n element = element\n end\n end\nend",
"def affect_relation_values!\n Relations.new(@klass).affect_relation_values!\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n source.map do |k, v|\n source[k] = v += thing_to_modify\n end\n return source\nend",
"def update!(other_value)\n replace!([value, normalize(other_value)].compact.last)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.map!{ |item|\n item += thing_to_modify if item.is_a?(Integer)\n item\n }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |element, i|\n source[i] += thing_to_modify if element.is_a?(Numeric)\n end\n source\n end",
"def replace!(new_value)\n @value = normalize(new_value)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend",
"def mutate(arr)\n arr.pop # (no bang! here) mutates\nend",
"def *(val)\n data * Reg.clean_value(val)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n\nreturn source.collect! { |item| item.is_a?(Fixnum) ? item + thing_to_modify : item}\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! {|elem|\n if elem.is_a?(Integer)\n elem += thing_to_modify\n else\n elem\n end\n }\nend",
"def update!(**args)\n @normalized_value = args[:normalized_value] if args.key?(:normalized_value)\n @remodelings = args[:remodelings] if args.key?(:remodelings)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! { |x|\n if x.is_a?(Integer)\n x + thing_to_modify\n else\n x\n end\n }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! do |n|\n if n.is_a? Integer\n n += thing_to_modify\n else\n n\n end\n end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.dup\n i_want_pets.map!{|number| number.is_a?(Integer) ? number + 1 : number}\nend",
"def update!(**args)\n @allowed_values = args[:allowed_values] if args.key?(:allowed_values)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n\n source.map! do |x|\n\n if x.class == Fixnum\n\n x + thing_to_modify\n else\n x\n end\n\n end\n\nend"
] | [
"0.6396381",
"0.62501186",
"0.61811745",
"0.61811745",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.60446376",
"0.602978",
"0.5907186",
"0.5901745",
"0.5797278",
"0.57886356",
"0.5761954",
"0.575565",
"0.5734918",
"0.5728805",
"0.5722105",
"0.57094646",
"0.57057655",
"0.5693517",
"0.5681799",
"0.56702495",
"0.5652859",
"0.5641796",
"0.5590187",
"0.55735904",
"0.557017",
"0.5569378",
"0.5569378",
"0.5553752",
"0.55519116",
"0.5550384",
"0.5529725",
"0.55232173",
"0.5518251",
"0.55123836",
"0.55123836",
"0.55025125",
"0.54994255",
"0.54867566",
"0.5461432",
"0.54597276",
"0.54540026",
"0.5439098",
"0.5439098",
"0.54321116",
"0.54210067",
"0.5384784",
"0.5379822",
"0.5377172",
"0.53714883",
"0.537028",
"0.53349215",
"0.531916",
"0.53142",
"0.53142",
"0.53083",
"0.5307808",
"0.5307692",
"0.52914375",
"0.52883303"
] | 0.6025924 | 47 |
Like map that returns a hash. | def modify
each_with_object self.class.new do |hash_pair, ꜧ|
key, val = yield hash_pair
ꜧ[key] = val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(*) end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash(key); end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def map(hash); end",
"def to_hash() end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def hash_code; end",
"def hash\n @hash || calculate_hash!\n end",
"def hash=(_arg0); end",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end",
"def hash()\n #This is a stub, used for indexing\nend",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def to_hash(*)\n mapper.new(self).to_hash\n end",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def hash\n @hash ||= self.to_a.hash\n end",
"def hash\n [self[0], self[1]].hash\n end",
"def hash\n [value].hash\n end",
"def hash\n [value].hash\n end",
"def hash\n to_h.hash ^ self.class.hash\n end",
"def geohash(key, member); end",
"def hash\n num = @high << 64\n num |= @low\n num.hash\n end",
"def hash\n [].hash\n end",
"def hash\n return @hash_code if defined? @hash_code\n @hash_code = usual_equal_object.hash\n end",
"def hash(*args, **_arg1, &block); end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def to_hash(*_arg0); end",
"def hash\n to_a.hash\n end",
"def hash\n @hash.hash\n end",
"def hash\n value.hash\n end",
"def hash\n size.hash ^ rank.hash\n end",
"def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end",
"def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end",
"def hash\n\t\t[@id].hash\n\tend",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n self.begin.hash ^ self.end.hash\n end",
"def hash\n self.class.name.hash ^ @key.hash\n end",
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def hasher\n Hashids.new(@hash_id_state[:salt], @hash_id_state[:length])\n end",
"def hash\n return to_s.hash\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n @__set.to_a.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\n @orig.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def hash\n excl = @excl ? 1 : 0\n hash = excl\n hash ^= @begin.hash << 1\n hash ^= @end.hash << 9\n hash ^= excl << 24;\n # Are we throwing away too much here for a good hash value distribution?\n return hash & Fixnum::MAX\n end",
"def hash\n 0\n end",
"def hash\n simplified.hash\n end",
"def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def hash\n value = 0\n my_rows = @rows\n r_size = my_rows.size\n for i in 0..r_size-1 do\n a_row = my_rows[i]\n a_size = a_row.size\n for j in 0..a_size-1 do\n value ^= a_row[j].hash\n end\n end\n return value\n end",
"def hash\n @hash\n end",
"def hash\n @hash ||= Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }\n end",
"def rehash() end",
"def hash\n h = @e.nil? ? 0 : @e\n h = (h << 1) ^ @r.hash\n h = (h << 1) ^ @v.hash\n end",
"def hash\n @symbols.hash + 37*positive?.hash\n end",
"def hash\n\t\t[@a, @b, self.class::D].hash\n\tend",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def hash\n [@bit, @type].hash\n end",
"def hash\n [ data, type ].hash\n end",
"def hash_hash(h)\n require 'digest/md5'\n\n ordered = h.sort.map { |i| i.class==Hash ? i.sort : i }\n return ordered.to_s\n Digest::MD5.hexdigest(Marshal::dump(ordered))\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def gnu_hash(s)\n s.bytes.reduce(5381) { |acc, elem| (acc * 33 + elem) & 0xffffffff }\n end",
"def hash\r\n id.hash\r\n end",
"def hash\n values.hash ^ known_data.hash\n end",
"def hash\n self.to_f.hash\n end",
"def deep_hash\n UniMap.deep_hash( self )\n end",
"def hash\n\t\t\"#{@x}#{@y}\".hash\n\tend",
"def to_hash\n @hash.dup\n end",
"def hash\r\n @_hash ||= _hash\r\n end",
"def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end",
"def hash\n [rel, href].hash\n end",
"def hash\n @vector\n end"
] | [
"0.8170091",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7883063",
"0.77076054",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.7431091",
"0.74183583",
"0.7400428",
"0.7323604",
"0.7271566",
"0.7256129",
"0.72284836",
"0.7188674",
"0.7101835",
"0.7101835",
"0.7101835",
"0.71007663",
"0.71007663",
"0.70492476",
"0.70447797",
"0.7041317",
"0.6990058",
"0.69866425",
"0.69866425",
"0.6986451",
"0.6951161",
"0.69481933",
"0.6927746",
"0.69252783",
"0.69204056",
"0.69169754",
"0.6905487",
"0.6856946",
"0.6831936",
"0.68311614",
"0.6816893",
"0.6782492",
"0.6768901",
"0.6765142",
"0.6764593",
"0.6764593",
"0.6764593",
"0.67546535",
"0.6727089",
"0.67137355",
"0.67112166",
"0.6694008",
"0.6688474",
"0.6668925",
"0.66580504",
"0.66580504",
"0.66580504",
"0.6657621",
"0.6648273",
"0.6648015",
"0.66479474",
"0.66421705",
"0.6638601",
"0.66199297",
"0.66050035",
"0.66033095",
"0.6601871",
"0.6601567",
"0.65686977",
"0.6566116",
"0.65629095",
"0.65629095",
"0.65629095",
"0.65629095",
"0.65629095",
"0.65629095",
"0.65599656",
"0.65558463",
"0.65546227",
"0.6554501",
"0.65442485",
"0.6543341",
"0.65388376",
"0.6535602",
"0.653544",
"0.6520865",
"0.651642",
"0.65006495",
"0.64996004",
"0.64971113",
"0.64930034"
] | 0.0 | -1 |
A bit like Arrayslice, but only takes 1 argument, which is either a Range, or an Array, and returns the selection of the hash for the keys that match the range or are present in the array. | def slice matcher
self.class[ case matcher
when Array then
select { |key, _| matcher.include? key }
else
select { |key, _| matcher === key }
end ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice(*keys)\n self.select { |k,v| keys.include?(k) }\n end",
"def slice_hash\n items = @selector.scan(/['|\"](\\w+)['|\"]/).flatten\n return {} if items.empty?\n if items.size == 1\n items[0] = items[0].to_s if items[0].is_a?(Symbol)\n @value.select {|key| key.to_s.match(items.first) }\n else\n Hash[@value.select {|key, value| items.include?(key)}]\n end\n end",
"def slice!(*keys); end",
"def find_multiple_key_values(array)\n return [self[array]] unless array.is_a? Array\n array.collect { |k| self[k] }\n end",
"def find_hash_with_key(array:, key:)\n array.find { |element| element.is_a?(Hash) && element.has_key?(key) }\n end",
"def slice *keys\r\n keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)\r\n keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) }\r\n end",
"def slice(start, length = nil)\n case start\n when Integer\n if length\n range(start, start + length - 1)\n else\n conn.lindex(key, start) rescue nil\n end\n when Range, Array\n range *range_pair(start)\n else\n []\n end\n end",
"def slice *keys\n dup.slice!(*keys)\n end",
"def slice(some_hash, *keys)\n allowed = Set.new(keys)\n hash = {}\n allowed.each { |k| hash[k] = some_hash[k] if some_hash.has_key?(k) }\n hash\n end",
"def slice! *keys\n keys.inject({}) {|acc,key|\n acc[key] = self.delete(key) if self.has_key?(key)\n acc\n }\n end",
"def shared_slice(hash_)\n offset_ = @offset\n select_set_ = {}\n hash_.each do |k_, v_|\n if (ainfo_ = @structure.axis(k_))\n aindex_ = ainfo_.axis_index\n unless select_set_.include?(aindex_)\n lindex_ = ainfo_.index(v_)\n if lindex_\n offset_ += ainfo_.step * lindex_\n select_set_[aindex_] = true\n end\n end\n end\n end\n Table.new(@structure.substructure_omitting(select_set_.keys),\n :acquire => @vals, :offset => offset_, :parent => self)\n end",
"def slice(*keys)\n required = self.class.required_attributes\n common = keys & required\n\n if keys.size == common.size && common.size == required.size\n self.class.new(@hash.slice(*keys))\n else\n to_hash.slice(*keys)\n end\n end",
"def slice(*keys)\n keys.map! { |key| @hash.convert_key(key) } if @hash.respond_to?(:convert_key, true)\n keys.each_with_object(@hash.class.new) { |k, hash| hash[k] = @hash[k] if @hash.has_key?(k) && if_string_not_empty(@hash[k]) }\n end",
"def final(arr,key)\n\tright = arr.length-1\n\tleft = 0\n\n\tresult = Array.new(2)\n\tresult[0] = -1\n\tresult[1] = -1\n\n\tsearch_range(arr,key,right,left,result)\n\tp result\nend",
"def keys\n [Array(hash_keys) + Array(range_keys)].flatten.uniq\n end",
"def keys\n [Array(hash_keys) + Array(range_keys)].flatten.uniq\n end",
"def FilterHashArray array, filter = {}, include = true, &proc\n out = []\n array.each do |item|\n #puts \"item #{item.inspect}\"\n ok = true\n filter.each_pair do |k, v|\n #puts \"#{k} = #{v.inspect}\"\n if !item.has_key?(k) || \n v.is_a?(Array) && !v.map(&:to_s).include?(item[k].to_s) || \n !v.is_a?(Array) && v.to_s != item[k].to_s\n ok = false\n #puts \"False\"\n break\n end\n end\n if ok && include || !ok && !include\n #puts \"Ok\"\n out << item\n proc.call(item) unless proc.nil?\n end\n end\n out\n end",
"def slice(hash_)\n shared_slice(hash_).dup\n end",
"def get_range_keys(column_family, options = {})\n get_range(column_family,options.merge!(:count => 1)).keys\n end",
"def search_range(array, range=nil, &block)\n lower = search_lower_boundary(array, range, &block)\n upper = search_upper_boundary(array, range, &block)\n return lower ... upper\n end",
"def _get_array(sp, key)\n return self[key] if sp.length == 0\n\n if key.is_a?(Range)\n res = []\n self[key].each do |k|\n next unless k.structured?\n res << k.rh_get(sp) if k.rh_exist?(sp)\n end\n res\n else\n self[key].rh_get(sp) if self[key].structured?\n end\n end",
"def my_hash_finding_method(source, thing_to_find)\n new_array = []\n source.map do |k, v|\n if v == thing_to_find\n new_array << k\n end\n end\n return new_array\nend",
"def get_range(range)\n r = []\n enum = range.to_enum\n begin\n while (x = enum.next) < @size\n r << get_single_key(x)\n end\n rescue StopIteration\n end\n r.empty? ? nil : r\n end",
"def slice *keys\n missing = {}\n values = fetch_values(*keys) {|key| missing[key] = nil }\n\n result = {}\n values.each_with_index do |val, i|\n key = keys[i]\n next if missing.key? key\n next if result.key? key\n result[key] = val\n end\n result\n end",
"def my_hash_finding_method(source, thing_to_find)\n source.select! do|key, value|\n value == thing_to_find\n end\n return source.keys\nend",
"def slice(range, options = {})\n start, finish = range_pair(range)\n fetch_range :zrange, start, finish, options\n end",
"def slice(*keys)\n FlexHash[keys.map { |key| [key, fetch(key)] }]\n end",
"def slice(*keep)\n inject(Characterizable::BetterHash.new) do |memo, ary|\n if keep.include?(ary[0])\n memo[ary[0]] = ary[1]\n end\n memo\n end\n end",
"def getrange(key, start, stop); end",
"def getrange(key, start, stop); end",
"def hash_array_intersection(k, merged)\n merged_str = merged[k].map(&:to_s)\n _self_str = self[k].map(&:to_s)\n intersection_str_arr = merged_str & _self_str\n return intersection_str_arr.map { |a| eval(a) }\n end",
"def to_array_of_partial_hashes(array)\n array = if array.kind_of?(Array) then array else [ array ] end\n array.each { |h| assert_partial_key!(h) }\n array\n end",
"def setrange(key, offset, value); end",
"def setrange(key, offset, value); end",
"def slice!(*keys)\r\n replace(slice(*keys))\r\n end",
"def slice!(*keys)\r\n replace(slice(*keys))\r\n end",
"def [](slice)\n slice.respond_to?(:each) ? slice.map{|i| recover_at(i) } : recover_at(slice)\n end",
"def quickselect!(kth_lowest_value, left_index, right_index)\r\n # If we reach a base case - that is, that the subarray has one cell,\r\n # we know we've found the value we're looking for:\r\n if right_index - left_index <= 0\r\n return @array[left_index]\r\n end\r\n\r\n # Partition the array and grab the index of the pivot:\r\n pivot_index = partition!(left_index, right_index)\r\n\r\n \r\n # If what we're looking for is to the left of the pivot:\r\n if kth_lowest_value < pivot_index\r\n # Recursively perform quickselect on the subarray to \r\n # the left of the pivot:\r\n quickselect!(kth_lowest_value, left_index, pivot_index - 1)\r\n # If what we're looking for is to the right of the pivot:\r\n elsif kth_lowest_value > pivot_index\r\n # Recursively perform quickselect on the subarray to \r\n # the right of the pivot:\r\n quickselect!(kth_lowest_value, pivot_index + 1, right_index)\r\n else # if kth_lowest_value == pivot_index\r\n # if after the partition, the pivot position is in the same spot\r\n # as the kth lowest value, we've found the value we're looking for\r\n return @array[pivot_index]\r\n end\r\nend",
"def slice!(*keys)\n replace(slice(*keys))\n end",
"def slice!(*keys)\n replace(slice(*keys))\n end",
"def slice!(*keys)\n replace(slice(*keys))\n end",
"def hash_select(hash, &prc)\n results = Hash.new(0)\n hash.each_pair {|k, v| results[k] = v if prc.call(k,v)}\n results\nend",
"def slice!(*keys)\n replace(slice(*keys))\n end",
"def my_hash_finding_method(source, thing_to_find)\n output_array = []\n i = 0\n source.each_pair { |key,value|\n if value == thing_to_find\n output_array[i] = key\n i += 1\n end\n }\n return output_array\nend",
"def hash_offset(array, offset)\r\n hash = {}\r\n \r\n i = 0\r\n while i < array.length \r\n if i >= (array.length - offset) #if i >= 22, in this case. So this condition applies for the last 4 elements of the array\r\n hash[array[i-array.length + offset]] = array[i] # hash[array[22-26+4]] --> hash[array[0]] --> hash[\"a\"]=array[22] --> hash[\"a\"]=\"w\"\r\n else\r\n hash[(array[i].ord + offset).chr] = array[i] #otherwise do the normal offset by 4\r\n end\r\n i += 1\r\n end\r\n return hash\r\nend",
"def rh_get(*p)\n p = p.flatten\n return self if p.length == 0\n\n key = p[0]\n sp = p.drop(1)\n\n re, res, opts = _regexp(key)\n return _keys_match(re, res, sp, opts) unless re.nil?\n\n return _get_array(sp, key) if [Fixnum, Range].include?(key.class)\n\n _loop_get_array(key, p)\n end",
"def slice arg\n\t\t\tif arg.is_a? Regexp\n\t\t\t\tfind_all{ |key| key.to_s.match(arg) }.to_h\n\t\t\telse\n\t\t\t\t super arg.to_sym\n\t\t\tend\n\t\tend",
"def select(hash, keys)\n hash.select { |k, v| keys.include?(k) }\n end",
"def range_keys_for_indexes\n all_keys = options[:local_indexes].map(&:range_key) +\n options[:global_indexes].map(&:range_key)\n\n all_keys.reject do |range_key|\n range_key == options[:range_key]\n end.uniq\n end",
"def my_hash_finding_method(source, thing_to_find)\n final_answer = source.select{|key, value| value == thing_to_find}\n p final_answer.keys\nend",
"def my_hash_finding_method(source, thing_to_find)\n final_answer = source.select{|key, value| value == thing_to_find}\n p final_answer.keys\nend",
"def my_hash_finding_method(source, thing_to_find)\n source.select {|k, v| v == thing_to_find}.keys\nend",
"def test_slicing_arrays\n array = [:peanut, :butter, :and, :jelly]\n\n assert_equal [:peanut], array[0,1]\n assert_equal [:peanut, :butter], array[0,2]\n assert_equal [:and, :jelly], array[2,2]\n assert_equal [:and, :jelly], array[2,20]\n assert_equal [], array[4,0]\n assert_equal [], array[4,100]\n assert_equal nil, array[5,0]\n end",
"def keys_from_hash\n if @keys.find_index(@option.value)\n return @keys.find_index(@option.value)\n else\n return @keys.first\n end\n end",
"def my_hash_finding_method(hash, number)\n hash.select {|key, value| value == number}.keys\nend",
"def query(left, right, threshold)\n i = @array.bsearch_index { |num, count| count >= threshold }\n return -1 if i.nil?\n @array[i..-1].find { |num, _|\n l = @hash[num].bsearch_index { |i| i >= left } || @hash[num].size-1\n r = @hash[num].bsearch_index { |i| i >= right } || @hash[num].size-1\n r -= 1 if @hash[num][r] > right\n r - l + 1 >= threshold\n }&.first || -1\n end",
"def hash_query(search_str, arr, search_key, return_key)\n\tif arr != nil\n\t\tarr.find {|hash| hash[search_key] == search_str}[return_key]\n\tend\nend",
"def slice(array, m, n)\n # Returns ALL the elements of an array from index m to index n, as a new array.\n # Returns nil if the indexes are invalid. \n\n if array.class != Array or m<0 or n<0 or m > array.size-1 or m > n or n > array.size-1\n return nil\n end\n \n return array[m..n]\nend",
"def my_hash_finding_method(source, thing_to_find)\n solution = source.select { |key, value| value == thing_to_find }\n solution.keys\nend",
"def OverlappingRanges(arr)\n\n # code goes here\n return arr \n \nend",
"def my_hash_finding_method(my_hash, number)\n\t\n\tif !number.is_a?(Fixnum)\nraise ArgumentError.new('The Second Argument Should be a Fixnum')\n\tend\n\n\treturn my_hash.select {|key, value| value == number}.keys\nend",
"def get_range(key1, key2)\n @store_.get_range(key1, key2)\n end",
"def [](index_or_range, length=nil)\n case index_or_range\n when Range\n start = index_or_range.begin\n length = index_or_range.end - start\n length += 1 unless index_or_range.exclude_end?\n slice_from_start_and_length(start, length)\n when Integer\n if length\n slice_from_start_and_length(index_or_range, length)\n else\n slice = slice_from_start_and_length(index_or_range, 1) and slice.first\n end\n else\n raise ArgumentError\n end\n end",
"def subhash(*extract)\n\t\th2 = self.select{|key, value| extract.include?(key) }\n\t\th2\n\tend",
"def subset(*keys)\n keys = keys.flatten\n map {|h| h.subset(keys) }\n end",
"def my_select\n if is_a? Hash\n arr = {}\n my_each do |k, v|\n a = yield(k, v)\n arr[k] = v if a\n end\n else\n arr = []\n my_each do |k|\n a = yield(k)\n arr << k if a\n end\n end\n arr\n end",
"def search_first(array, range=nil, &block)\n boundary = search_lower_boundary(array, range, &block)\n if boundary >= array.length || yield(array[boundary]) != 0\n return nil\n else \n return boundary\n end\n end",
"def binary_search(array, key, low=0, high=array.size-1) \n return -1 if low > high \n mid = (low + high) / 2 \n return mid if array[mid]==key \n if array[mid] > key \n high = mid - 1 \n else \n low = mid + 1 \n end \n binary_search(array, key, low, high) \nend",
"def values_at(*selectors)\n res = []\n selectors.each do |s|\n if s.is_a? Range\n subary = self[s]\n unless subary.nil?\n self[s].each do |el|\n res << el\n end\n end\n if has_size? && !s.exclude_end? && s.include?(size)\n res << nil\n end\n else\n res << self[s.to_int]\n end\n end\n return res\n end",
"def dupe_indices(array)\n #ht = Hash.new {|h,k| h[k]=[]}\n #ht[\"cats\"] << \"Jellicle\"\n #ht[\"cats\"] << \"Mr. Mistoffelees\"\n hash = Hash.new { |h,k| h[k]=[] }\n array.each_with_index do |char, i|\n hash[char] << i\n end\n \n # puts \"Hash b select form : #{b.select{|key, value| value < 200}}\\n\\n\n hash.select{ |k,v| v.length > 1}\n\n\nend",
"def partition_hash(hash, *keys)\n keys = gather_keys(*keys)\n hash = normalize_hash(hash)\n return (matched = hash.slice(*keys)), hash.except(*matched.keys)\n end",
"def array_to_indices_hash(array)\n array.inject({}) {|hash,e| hash[hash.size] = e; hash }\n end",
"def all_elements_except_first_3(array)\n\tn = [1, 2, 3, 4, 5, 6, 7]\n\tn.slice(3..6)\nend",
"def ari_slice(arr)\n start_diff=nil\n start_idx=nil\n rtn=[]\n idx=0\n until idx>arr.length-1\n if arr[idx+1] && arr[idx+2]\n if arr[idx]-arr[idx+1]==arr[idx+1]-arr[idx+2] &&start_diff.nil?\n start_diff=arr[idx]-arr[idx+1]\n start_idx=idx\n idx+=2\n elsif start_diff.nil?\n idx+=1\n elsif start_diff && start_diff==arr[idx]-arr[idx+1]\n idx+=1\n elsif start_diff\n rtn<< arr[start_idx..idx]\n start_idx=nil\n start_diff=nil\n idx+=1\n end\n elsif arr[idx+1]\n if start_diff && start_diff==arr[idx]-arr[idx+1]\n idx+=1\n elsif start_diff\n rtn<< arr[start_idx..idx]\n start_idx=nil\n start_diff=nil\n idx+=1\n else\n idx+=1\n end\n else\n if start_diff\n rtn<< arr[start_idx..idx]\n start_idx=nil\n start_diff=nil\n idx+=1\n else\n idx+=1\n end\n end\n end\n rtn\nend",
"def k_select(a, start, fin, k)\n # fin is last index in array range\n # partition, if ind swapped is == k, then kth element\n if start == fin\n return a[start]\n end\n \n a, idx = random_partition(a, start)\n part_kth_largest = fin - idx + 1\n if part_kth_largest == k\n return a[idx]\n elsif k > part_kth_largest\n return k_select(a, start, idx - 1, k - part_kth_largest)\n else\n return k_select(a, idx + 1, fin, k)\n end\nend",
"def slice(p0, *rest) end",
"def sub_hash(hash, key); end",
"def slice(*rest) end",
"def [] key\n if @table[hash_index(key)]\n detected_item = @table[hash_index(key)].detect do |item|\n item.first == key\n end\n detected_item.last\n end\n end",
"def only_changes(array, hash)\n tmp_hash = Hash.new\n array.each do |a|\n hash.each do |k, v|\n tmp_hash[k] = v if a == k\n end\n end\n tmp_hash\n end",
"def binary_search(array, key)\n low, high = 0, array.length - 1\n while low <= high\n mid = (low + high) >> 1\n case key <=> array[mid] # if key < array[mid] then return -1 if key = array[mid] then 0 else return 1\n\t when 1\n low = mid + 1\n when -1\n high = mid - 1\n else\n return mid\n end\n end\nend",
"def binary_search(key,array)\n\tlow = 0\n\thigh = array.sort.length - 1\n\treturn -1 if low>high\n\tmid = (low+high)/2\n\treturn mid if array[mid]==key\n\t\tif array[mid]>key\n\t\t\thigh=mid-1\n\t\t\tmid=(low+high)/2\n\t\telse\n\t\t\tlow=mid+1\n\t\t\tmid=(low+high)/2\n\t\tend\nend",
"def value_array(hash, *keys)\n return unless hash.is_a?(Hash)\n keys.flatten!\n keys.map { |v| [v, nil] }.to_h.merge(hash).slice(*keys).values\n end",
"def points_of_subset_fast subset, options={}\n points_of_subset = []\n lower_range_bound = options[:omit_first] ? 2 : 1\n power = 1; while (2**power <= subset) do power +=1 end\n\n (lower_range_bound .. power).each do |i|\n points_of_subset << i if (subset & 2**(i-1) == 2**(i-1))\n end\n points_of_subset\n end",
"def subarray(array)\n sum_to_index = {}\n i = 0\n sum = 0\n while i < array.length do\n sum += array[i]\n if sum_to_index[0]\n return [0, sum_to_index[0]]\n elsif sum_to_index[sum]\n return [sum_to_index[sum] + 1, i]\n else\n sum_to_index[sum] = i\n end\n i += 1\n end\nend",
"def slice *ks, k:'to_sym', v:'itself'\n nh = { }\n for i in ks.flatten\n at = \"@#{i}\"\n if instance_variable_defined? at\n value = instance_variable_get at\n unless value.nil?\n nh[B.fcall(k, i)] = B.fcall(v, value)\n end\n else\n raise KeyError, \"Unknown element #{i}\"\n end\n end\n return nh\n end",
"def slice( range)\n ::Vector.elements( self.to_a.slice(range) )\n end",
"def intersection(array1, array2)\n hash_table = {}\n result = []\n if array1 && array2\n i = 0\n while i < array1.length\n hash_table[array1[i]] = 1\n i += 1\n end\n i = 0\n while i < array2.length\n if hash_table[array2[i]]\n result << array2[i]\n end\n i += 1\n end\n end\n return result\nend",
"def slice!(start, length = nil)\n result = case start\n when Range, Array\n trim *range_pair(start)\n else\n trim(start, start + length - 1)\n end\n Redis::Future === result ? result : to_a\n end",
"def hash_select(hash, &prc)\n new_hash = Hash.new { |h, k| h[k] = 0 }\n\n hash.each do |k, v| \n if prc.call(k, v)\n new_hash[k] = v\n end \n end \n\n new_hash\nend",
"def subset_in_array?(array, value)\n result = 1.upto(array.length).flat_map do |n|\n array.combination(n).to_a\n end\n result.include?(value)\nend",
"def [](*key)\n key = key[0] if key.length == 1\n case key\n when Integer\n if key > shape[0] - 1\n raise IndexError, \"index #{key} is out of bounds for axis 0 with size #{shape[0]}\"\n end\n _at(key)\n when Range, Enumerator\n start, stop, step = MXNet::Utils.decompose_slice(key)\n if step && step != 1\n raise ArgumentError, 'slice step cannot be zero' if step == 0\n Ops.slice(self, begin: [start], end: [stop], step: [step])\n elsif start || stop\n _slice(start, stop)\n else\n self\n end\n when Array\n keys = key\n raise ArgumentError, \"index cannot be an empty array\" if keys.empty?\n shape = self.shape\n unless shape.length >= keys.length\n raise IndexError, \"Slicing dimensions exceeds array dimensions, #{keys.length} vs #{shape.length}\"\n end\n begins, ends, steps, kept_axes = [], [], [], []\n keys.each_with_index do |slice_i, idx|\n case slice_i\n when Integer\n begins << slice_i\n ends << slice_i + 1\n steps << 1\n when Range, Enumerator\n start, stop, step = MXNet::Utils.decompose_slice(slice_i)\n raise ArgumentError, \"index=#{keys} cannot have slice=#{slice_i} with step=0\" if step == 0\n begins << (start || MXNet::None)\n ends << (stop || MXNet::None)\n steps << (step || MXNet::None)\n kept_axes << idx\n else\n raise IndexError, \"NDArray does not support slicing with index=#{slice_i} of type #{slice_i.class}\"\n end\n end\n kept_axes.concat([*(keys.length) ... shape.length])\n sliced_nd = Ops.slice(self, begin: begins, end: ends, step: steps)\n return sliced_nd if kept_axes.length == shape.length\n\n # squeeze sliced_shape to remove the axes indexed by integers\n out_shape = []\n sliced_shape = sliced_nd.shape\n kept_axes.each do |axis|\n out_shape << sliced_shape[axis]\n end\n # if key is an array of integers, still need to keep 1 dim\n # while in Numpy, the output will become an value instead of an ndarray\n out_shape << 1 if out_shape.length == 0\n if out_shape.inject(:*) != sliced_shape.inject(:*)\n raise \"out_shape=#{out_shape} has different size than sliced_shape=#{sliced_shape}\"\n end\n sliced_nd.reshape(out_shape)\n else\n raise IndexError, \"NDArray does not support slicing with key #{key} of type #{key.class}\"\n end\n end",
"def to_a\n @keys.select{ |k| key_true?(k) }\n end",
"def do_something(my_hash)\n my_hash.select_keys('a', 'b')\n end",
"def bin_search(arr, key)\n low = 0\n high = arr.length - 1\n while high >= low do\n mid = low + (high - low) / 2\n if arr[mid] > key\n high = mid - 1\n elsif arr[mid] < key\n low = mid + 1\n else\n return mid\n end\n end\n return 0\nend",
"def keys_from_hash\n if @keys.include?(@option.value)\n @keys.find_index(@option.value)\n else\n 0\n end\n end",
"def intersection_hash(array1, array2)\n hash = Hash.new()\n intersection = []\n\n array1.each do |el|\n hash[el] = true\n end\n\n array2.uniq.each do |el|\n if hash[el]\n intersection << el\n end\n end\n\n intersection\nend",
"def find_range(arr,low,high)\n arr.find_all{|item| item >=low && item <= high}.length\nend",
"def doggy(array, search_letter)\n\tsearch_letter_array= array.each_index.select{|i| array[i] == search_letter}\n\treturn search_letter_array \nend",
"def select(&b)\n h = {}\n self.each_key{|k|\n v = self[k]\n if b.call(k, v)\n h[k] = v\n end\n }\n h\n end"
] | [
"0.633876",
"0.5887167",
"0.587299",
"0.5757401",
"0.5737074",
"0.5715574",
"0.5698993",
"0.56831104",
"0.5671356",
"0.56427866",
"0.55725247",
"0.55609095",
"0.5527846",
"0.5519133",
"0.5504924",
"0.5504924",
"0.54737115",
"0.5471463",
"0.54487014",
"0.5444409",
"0.5407212",
"0.5404766",
"0.5383544",
"0.53742313",
"0.5351548",
"0.5311958",
"0.5273305",
"0.5253455",
"0.5250851",
"0.5250851",
"0.523236",
"0.5210781",
"0.51918447",
"0.51918447",
"0.5167417",
"0.5167417",
"0.5148825",
"0.5133677",
"0.5133666",
"0.5133666",
"0.5133666",
"0.5120942",
"0.51209164",
"0.5106803",
"0.5077568",
"0.5074448",
"0.50646776",
"0.50639546",
"0.5061667",
"0.50608677",
"0.50608677",
"0.50490487",
"0.5045813",
"0.50423527",
"0.5020618",
"0.50084424",
"0.49974617",
"0.49957898",
"0.49865943",
"0.49518412",
"0.49417263",
"0.49361455",
"0.49297428",
"0.49176565",
"0.4914717",
"0.4909588",
"0.49080193",
"0.4891066",
"0.48865104",
"0.48859876",
"0.48728487",
"0.48722973",
"0.48698947",
"0.48681822",
"0.4857834",
"0.4833422",
"0.48107627",
"0.48004228",
"0.4796456",
"0.47921962",
"0.4784564",
"0.47816455",
"0.47801426",
"0.47748256",
"0.47716755",
"0.47628394",
"0.47616792",
"0.4759878",
"0.4751399",
"0.47513872",
"0.4747737",
"0.4718437",
"0.4718105",
"0.4714755",
"0.4702883",
"0.46947783",
"0.46941522",
"0.4689567",
"0.4684148",
"0.4678156"
] | 0.7008151 | 0 |
Prettyprints the hash consisting of names as keys, and numeric values. Takes 2 named arguments: +:gap+ and +:precision+. | def pretty_print_numeric_values gap: 0, precision: 2
key_strings = keys.map &:to_s
value_strings = values.map { |n| "%.#{precision}f" % n rescue "%s" % n }
lmax, rmax = key_strings.map( &:size ).max, value_strings.map( &:size ).max
lgap = gap / 2
rgap = gap - lgap
key_strings.zip( value_strings ).map do |kς, vς|
"%- #{lmax+lgap+1}s%#{rmax+rgap+1}.#{precision}f" % [ kς, vς ]
end.each { |line| puts line }
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_format\n pretty = \"\"\n sorted = @hash.sort_by { |name, arrays| name }\n\n sorted.each { |name, array|\n pretty.concat(name)\n pretty.concat(\": \")\n pretty.concat(\"#{@hash[name].join(\",\")}\\n\")\n\n }\n pretty\n\n ### FILL IN YOUR CODE HERE\n end",
"def pretty_value(value)\n hash_to_grid(Hash[value.map { |s, v| [s, format('%+.3f', v)] }])\n .map { |row| row.map { |cell| cell || ' ' }.join(' ') }\n end",
"def pretty_output #two columns\n alphabetical_keys = @concordance_hash.keys.sort\n half = (alphabetical_keys.length - 1) / 2\n alphabetical_keys[0..half].each_with_index do |key, idx|\n value = \"{\" + @concordance_hash[key][0].to_s + \":\" +\n @concordance_hash[key][1..-1].to_s.delete(\"[] \") + \"}\"\n\n key2 = alphabetical_keys[1 + idx + half]\n value2 = \"{\" + @concordance_hash[key2][0].to_s + \":\" +\n @concordance_hash[key2][1..-1].to_s.delete(\"[] \") + \"} \\n\"\n if 1 + idx + half >= alphabetical_keys.length\n value2 = \"\\n\"\n end\n\n printf \"%-15s %-20s %-15s %s\", key, value, key2, value2\n end\n end",
"def print_hash_pair(entry)\n print \"%#{@entry_size}s |\" % [entry[0].to_s[0...@entry_size]]\n ratio = entry[1] * 1.0 / @count\n\n # print dynamic bar for value\n (ratio * @width).round.times {\n print \"=\"\n }\n puts \" (#{(ratio * 100).round(2)}%)\"\n end",
"def print_scores(delta,ongoing=false)\n round_name = @name\n round_name += \"*\" if ongoing\n printf \"%-#{COL_SPACING}s\", round_name\n @scores.each do |key,val|\n if delta\n d = delta[key]\n d = 0.0 if not d\n if d == 0 # not sure why one-liner doesn't work here...\n d = \"=\"\n elsif d < 0\n d = d.to_s + \"k\"\n else\n d = \"+\" + d.to_s + \"k\"\n end\n val = val.to_s + \"(\" + d + \")\"\n else\n val = val.to_s\n end\n printf \"%-#{COL_SPACING}s\", val\n end\n puts nil\n end",
"def pretty(hash)\n hash.each do |key,value|\n puts \"#{key}: #{value}\"\n end\nend",
"def pretty(hash)\n hash.each do |key,value|\n puts \"#{key}: #{value}\"\n end\nend",
"def format(precision) # :nodoc:\r\n (precision == nil || precision == 0) ? \"%s\" : \"%.#{precision}f\"\r\n end",
"def precision\n self['precision']\n end",
"def precision=(val)\n self['precision'] = val\n end",
"def field_precision(key)\n IBM_DB.field_precision(@stmt, key)\n end",
"def precision; end",
"def pretty_print(pp)\n pp.pp_hash to_hash\n end",
"def look_pretty(grocery_hash)\n grocery_hash.each do |grocery, quantity|\n puts \"We need #{grocery}: #{quantity}\"\nend\n \nend",
"def prettyfie_list(hash)\r\n puts \"This is your current grocery list:\"\r\n puts \"\\n\"\r\n hash.each {|key, value| puts \"#{key} quantity = #{value}\" }\r\n puts \"\\n\"\r\nend",
"def pretty_list(hash)\r\n puts \"Grocery List:\"\r\n puts \" \"\r\n hash.each do |item_name, quantity|\r\n puts \"#{item_name}: #{quantity}\"\r\n end\r\nend",
"def dump_hash( map )\r\n keys = map.keys.sort\r\n keys.each do |k|\r\n puts k\r\n map[k].each do |attr_k, attr_v|\r\n puts \" #{attr_k} -> #{attr_v}\"\r\n end\r\n end\r\n end",
"def format(key, value)\n \"#{key}#{key_value_separator}#{format_value(value)}\"\n end",
"def pretty\n cpf_numbers = numeric\n \"%s.%s.%s-%s\" % [cpf_numbers[0..2], cpf_numbers[3..5], cpf_numbers[6..8], cpf_numbers[9..10]]\n end",
"def grocery_printed_pretty(groceryhash)\n $groceryhash.map do |food_item, food_quantity|\n puts \"#{food_item.to_s} : #{food_quantity}\"\n end\nend",
"def pretty_inspect(element)\n return element.inspect unless element.is_a?(Hash)\n\n pairs_string = element.keys.map do |key|\n [pretty_inspect(key), pretty_inspect(element.fetch(key))].join(\" => \")\n end.join(\", \")\n\n \"{ #{pairs_string} }\"\n end",
"def pprint\n start_col = 17\n width = 80 - start_col\n\n @methods.sort.each do |k,v|\n printf \"%-15s\", k\n cur_col = start_col\n\n v.keys.sort.each do |k|\n needed = k.length + 1\n if cur_col + needed > width\n printf \"\\n%s\", \" \" * 15\n cur_col = start_col\n end\n printf \"%s \", k\n cur_col += needed\n end\n printf \"\\n\\n\"\n end\n end",
"def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end",
"def printable\n result = \"\"\n\n @d.keys.sort.each do|key|\n result += \"[#{key}] \\\"#{@d[key]}\\\"\\n\"\n end\n result = result[0..-2]\n end",
"def dist_pp(dist)\n keys = dist.keys.sort\n max = dist.values.max + 2\n keys.each { |l| \n print \"#{l}: \"; dist[l].times do print \"#\" end\n (max - dist[l]).times { print \" \" }\n print \"(#{dist[l]})\\n\"\n }\n puts dist_csv(dist)\n end",
"def pretty_hash(hash, level: 0, indent: 2)\n unique_values_count = 0\n hash.each do |k, v|\n (level * indent).times { print ' ' }\n print \"#{k}:\"\n if v.is_a?(Hash)\n puts\n unique_values_count += pretty_hash(v, level: level + 1, indent: indent)\n else\n puts \" #{v}\"\n unique_values_count += 1\n end\n end\n unique_values_count\nend",
"def prettify(obj)\n # Most look best with pretty_inspect\n str = obj.pretty_inspect\n # Mashes need to be first converted to Hashes then pretty_inspect\n if obj.kind_of? Mash\n str = obj.to_hash.pretty_inspect\n end\n # For Arrays, pretty_inspect displays one value per line which\n # uses up too much real estate\n if obj.kind_of? Array\n str = obj.inspect\n end\n # Manually format Hashes so keys and values each display in columns\n if obj.kind_of? Hash\n key_length = 0\n obj.keys.each do |key|\n key_length = key.length if key.length > key_length\n end\n buf = []\n obj.each do |key,value|\n buf << sprintf(\"%-#{key_length}.#{key_length}s => %s\", key, value)\n end\n str = buf.join(\"\\n\")\n end\n str\n end",
"def beautify_hash(hash)\n hash.each do |item, quantity|\n puts \"#{item.capitalize}: #{quantity}\"\n end\nend",
"def printable\n\t\[email protected] do |key, value|\n\t\t\t\"[#{key}] \\\"#{value}\\\"\"\n\t\tend.join(\"\\n\")\n\tend",
"def conversion_precision; end",
"def set_precision(precision)\n @precision = precision\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n \n pp nds\n puts nds \nend",
"def export(data, indent=0)\n str = \"{\\n\"\n \n data.keys.sort{|k1,k2| k1.to_s <=> k2.to_s}.each_with_index do |k, i|\n str << (\" \" * (indent+1))\n str << \"#{k.inspect} => \"\n if data[k].kind_of?(Hash)\n str << export(data[k], indent+1)\n else\n str << data[k].inspect\n end\n str << \",\" if i < (data.keys.size - 1)\n str << \"\\n\"\n end\n \n str << (\" \" * (indent))\n str << \"}\"\n \n str\n end",
"def output\n alphabetical_keys = @concordance_hash.keys.sort\n alphabetical_keys.each do |key|\n value = \"{\" + @concordance_hash[key][0].to_s + \":\" +\n @concordance_hash[key][1..-1].to_s.delete(\"[] \") + \"}\"\n\n printf \"%-25s %s \\n\", key, value\n end\n end",
"def print_hash a_hash, preamble=''\n puts preamble unless preamble.empty?\n a_hash.each_pair do |k,v|\n puts \"#{k}: #{v.to_s}\"\n end\nend",
"def pretty_print_list(hash)\n\thash.each do |key, value|\n\t\tputs \"You need #{value}, #{key}\"\n\tend\nend",
"def pp_hash(obj, anno)\n s = \"#{anno}{\"\n group(1, s, '}') {\n seplist(obj, nil, :each_pair) {|k, v|\n group {\n pp k\n text ':'\n group(1) {\n breakable ' '\n pp v\n }\n }\n }\n }\n end",
"def pretty_print(pp)\n pp.object_address_group(self) do\n ivs = sorted_instance_variables.map(&:to_s)\n pp.seplist(ivs, proc { pp.text ',' }) do |iv|\n pp.breakable ' '\n pp.group(1) do\n pp.text iv\n pp.text ':'\n pp.breakable\n pp.pp instance_variable_get(iv)\n end\n end\n end\n end",
"def approx_1(precision)\n if precision < 1 && precision.positive?\n k = 2\n values_r = []\n values_f = []\n loop do\n curr_value = Rational(k - 1, faculty(k))\n values_r << curr_value\n values_f << curr_value.to_f\n break if (1 - sum(values_r)) <= precision\n\n k += 1\n end\n return { 'values_f' => values_f,\n 'values_r' => values_r,\n 'sum_f' => sum(values_f).to_f,\n 'sum_r' => sum(values_r),\n 'index' => k - 2 }\n end\n nil\n end",
"def ar_precision\n precision || 6\n end",
"def ar_precision\n precision || 6\n end",
"def pretty_up(list)\n puts \"\\nHere is your grocery list: \"\n list.each do |key, value|\n puts value.to_s + ' ' + key.to_s\n end\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n nil\nend",
"def render_options\n hsh = {}\n if minval = @minimalize\n @units = ABBREVIATED_DECIMAL_UNITS\n @format = \"%n%u\"\n @precision = minval\n @strip_insignificant_zeros = true\n @delimiter = ''\n @significant = true\n end\n\n\n hsh[:number_to_human] = HUMAN_ACCESSORS.inject({}) do |h, att|\n if val = self.instance_variable_get(\"@#{att}\")\n h[att] = val\n end\n\n h\n end\n\n return hsh\n end",
"def print_hash(hash)\n hash.inject(\"\") { |s, (k, v)| \"#{s} #{k}: #{v}.\" }\nend",
"def print_hash(hash)\n hash.inject(\"\") { |s, (k, v)| \"#{s} #{k}: #{v}.\" }\nend",
"def pretty_print(list)\n list.each {|item, quantity| puts \"#{item} : #{quantity}\"}\nend",
"def display_products(products)\n puts \" ID Description Price\"\n puts \"-\" * 50\n products.each do |key, value|\n #puts key.class\n #puts value[1] + 1\n puts \"#{key} #{value[0].rjust(25)} $#{sprintf(\"%.2f\", value[1]).to_s.rjust(6)}\"\n end\nend",
"def pretty_list(list)\n puts \"Grocery List:\"\n list.each do |key, value|\n puts \"#{value} #{key}(s)\"\n end\n \nend",
"def inspect spacing=20, threshold=15\n longest = [@name.to_s.size,\n @index.to_a.map(&:to_s).map(&:size).max, \n @data .map(&:to_s).map(&:size).max,\n 'nil'.size].max\n\n content = \"\"\n longest = spacing if longest > spacing\n name = @name || 'nil'\n formatter = \"\\n%#{longest}.#{longest}s %#{longest}.#{longest}s\"\n content += \"\\n#<\" + self.class.to_s + \":\" + self.object_id.to_s + \" @name = \" + name.to_s + \" @size = \" + size.to_s + \" >\"\n\n content += sprintf formatter, \"\", name\n @index.each_with_index do |index, num|\n content += sprintf formatter, index.to_s, (self[*index] || 'nil').to_s\n if num > threshold\n content += sprintf formatter, '...', '...'\n break\n end\n end\n content += \"\\n\"\n\n content\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def to_s\n pairs = inject([]) do |strs, (k, v)|\n strs << \"#{k.to_s} => #{v.to_s}\"\n end\n \"{\\n\" + pairs.join(\",\\n\") + \"\\n}\"\n end",
"def formatted_props\n props.map do |name, flags|\n formatted_flags = flags\n .inspect\n .gsub(\"=>\", \" => \")\n .gsub(\"{\", \"{ \")\n .gsub(\"}\", \" }\")\n \"#{name.inspect} => #{formatted_flags}\"\n end.join(\",\\n \")\n end",
"def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n nil\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\n return nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp\nend",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp(nds)\nend",
"def format(number, digits: nil, display_sign: nil, min_integers: nil, min_precision: nil, max_precision: nil, **)\n number = number * @factor\n negative = number < 0\n number = -number if negative\n prefix, suffix = affixes(display_sign, negative, number == 0)\n \n number = number.round(max_precision || @max_precision)\n integer = number.to_i\n\n %{#{ prefix }#{\n integer(integer, min_integers || @min_integers) }#{\n fraction(number, min_precision || @min_precision, max_precision || @max_precision) }#{\n suffix }}\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend",
"def format_hash(header, hash)\n # Staring with the \"header\" parameter string, concatenate each of the\n # parameter name/value pairs with a prefix intended to better display the\n # results within the Kinetic Task log.\n hash.inject(header) do |result, (key, value)|\n result << \"\\n #{key}: #{value}\"\n end\n end",
"def hformat(hash = {})\n hash.map { |k, v| [k.to_sym, vformat(v)] }.to_h\nend",
"def format\n Hash[params.map {|k, v| [k.to_s.dasherize, v]}]\n end",
"def format_key_val_string(key, vals, longest_length)\n format_key_string(key, longest_length) + ' ' + format_tuple_string(vals)\n end",
"def pretty_print_nds(nds)\n pp nds\n # Change the code below to pretty print the nds with pp\nend",
"def printable\n asPrintable = \"\"\n doCount = 0 # way to keep track of the entries loop so a new line can be added to the end of the concat string\n @entries.sort.each do |keyWord, value|\n asPrintable += \"[#{keyWord}] \\\"#{value}\\\"\"\n if doCount < @entries.length - 1 # in order for test to pass, it cant have a extra line at the end\n asPrintable += \"\\n\" # only add one if not the last element of the hash\n end\n doCount += 1 # each loop adds one\n end\n asPrintable # return concat string\n end",
"def pp_hash(obj)\n group(1, '{', '}') {\n seplist(obj, nil, :each_pair) {|k, v|\n group {\n pp k\n text '=>'\n group(1) {\n breakable ''\n pp v\n }\n }\n }\n }\n end",
"def format_print(print_values)\n widths = Array.new(print_values[0].size, 0)\n print_values.each do |print_value|\n widths = widths.zip(print_value).map! {|width, value| value.length > width ? value.length : width }\n end\n\n print_values.each do |print_value|\n widths.zip(print_value) do |width, value|\n printf(\"%-#{width + 5}s\", value)\n end\n puts \"\"\n end\n end",
"def pretty_print_nds(nds)\n pp nds\nend",
"def pretty_print_nds(nds)\n pp nds\nend"
] | [
"0.6146382",
"0.6140371",
"0.594296",
"0.58612174",
"0.5827848",
"0.57910174",
"0.57910174",
"0.55943",
"0.556954",
"0.5556113",
"0.5476537",
"0.54356927",
"0.5401115",
"0.5388913",
"0.5348654",
"0.53310674",
"0.52935606",
"0.5293029",
"0.52821684",
"0.5275408",
"0.5253943",
"0.52520955",
"0.5224545",
"0.5213914",
"0.5201506",
"0.52006555",
"0.5176851",
"0.51489514",
"0.5133671",
"0.512658",
"0.51214176",
"0.5089245",
"0.5089166",
"0.5084132",
"0.50562924",
"0.5050364",
"0.503422",
"0.50310403",
"0.5026586",
"0.5020032",
"0.5020032",
"0.5010119",
"0.49985144",
"0.49961597",
"0.4995557",
"0.4995557",
"0.49939743",
"0.4985536",
"0.4948843",
"0.49462497",
"0.49436933",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.4942864",
"0.49358267",
"0.49288064",
"0.49206626",
"0.49206626",
"0.49196205",
"0.4918316",
"0.49104616",
"0.49104616",
"0.49104616",
"0.49089608",
"0.49086598",
"0.49058807",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49048117",
"0.49023247",
"0.48982367",
"0.48963013",
"0.48878324",
"0.48828498",
"0.4879772",
"0.4877816",
"0.48760468",
"0.48740557",
"0.48740557"
] | 0.7695462 | 0 |
GET /page_modules/1 GET /page_modules/1.xml | def show
@page_module = PageModule.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @page_module }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_module = PageModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def index\n @learning_modules = LearningModule.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @learning_modules }\n end\n end",
"def index\n @course_modules = CourseModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @course_modules }\n end\n end",
"def show\n @appmodule = Appmodule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @appmodule }\n end\n end",
"def index\n @text_modules = TextModule.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_modules }\n end\n end",
"def show\n @learning_module = LearningModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @learning_module }\n end\n end",
"def client_modules\n get 'client/modules'\n end",
"def show\n @svn_module = SvnModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def get_module(org_unit_id, module_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _get(query_string)\nend",
"def show\n @course_module = CourseModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @course_module }\n end\n end",
"def rest__list\n diff = ret_request_params(:diff)\n project = get_default_project()\n datatype = :module\n remote_repo_base = ret_remote_repo_base()\n\n opts = Opts.new(project_idh: project.id_handle())\n if detail = ret_request_params(:detail_to_include)\n opts.merge!(detail_to_include: detail.map(&:to_sym))\n end\n\n opts.merge!(remote_repo_base: remote_repo_base, diff: diff)\n datatype = :module_diff if diff\n\n rest_ok_response NodeModule.list(opts), datatype: datatype\n end",
"def show\n @text_module = TextModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @text_module }\n end\n end",
"def index\n @modulos = Modulo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @modulos }\n end\n end",
"def modules\n @modules= GmaModule.all :order=>\"seq\"\n render :layout => false\n end",
"def index\n @pages = current_cms.pages.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def show\n @academic_module = AcademicModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @academic_module }\n end\n end",
"def index\n @pages = @comic.pages\n \n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def get_root_modules(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/root/\"\n _get(query_string)\nend",
"def show\n @coursemod = Coursemod.find(params[:id])\n @lessons = @coursemod.lessons.paginate(:page => params[:page])\n @title = @coursemod.module_name\n end",
"def show\n @module_template = ModuleTemplate.find( params[:id] )\n\t@module_instances = @module_template.module_instances\n\t@module_instances_page = @module_template.module_instances.paginate( :page => params[:page], :per_page => 20 )\n\t@module_parameters = @module_template.module_parameters\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @module_template }\n end\n end",
"def admin_xml_each_page(path)\n first_page=admin_xml(path)\n pages=REXML::XPath.first(first_page,'//LastPage/text()').value.to_i\n (1..pages).each do |page|\n result=admin_xml(\"#{path}?page=#{page}\")\n yield result\n end\n end",
"def index\n @pm_elements = PmElement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pm_elements }\n end\n end",
"def index\n @process_modules = ProcessModule.all\n end",
"def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @software_training_modules }\n end\n end",
"def get_module_resource\n \"#{get_resource.to_s.chomp(\"/\")}/#{@exploit_receiver_page}/\"\n end",
"def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def show\n @modulo = Modulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @modulo }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @pages = @offering.pages.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @modrequests = Modrequest.all\n end",
"def index\n @pages = @club.all_pages\n \n @page_title = \"Page Listing\"\n @site_section = \"clubs\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end \n end",
"def index\n @modulos = Modulo.find(:all)\n @tab = :recursos\n @nav = :modulos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @modulos }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def get_module_structure(org_unit_id, module_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}/structure/\"\n _get(query_string)\nend",
"def fetchModules\n puts \"Fetching Modules\"\n #direct url to gradeTable\n url = @baseUrl + 'state=htmlbesch&moduleParameter=Student&menuid=notenspiegel&breadcrumb=notenspiegel&breadCrumbSource=menu&asi='\n # pp @sessionId\n gradePage = @agent.get(url + @sessionId)\n\n #fetch curriculum for creditpoints\n #curriculum = agent.get('http://web-1k.rz.fh-wiesbaden.de/bachelorcurriculum.cfm?fb=22&sprachid=1&sid=103&poid=93&detail=ja').body\n\n doc = Hpricot(gradePage.body)\n table = doc.at(\"//table[2]\")\n rows = (table/\"tr\")\n \n modules = []\n \n (1...rows.length).to_a.each do |i|\n size = (rows[i]/\"td\").size\n cells = (rows[i]/\"td\")\n \n #TODO insert debug/log code\n mod = Modul.new(cells[0],cells[1],cells[2],cells[3],cells[4],cells[5],cells[6],cells[7])\n modules.push mod\n end \n puts \"Fetched \" + modules.length.to_s + \" modules\"\n return modules\n end",
"def index\n @pages = Page.find(:all, :order => \"position DESC\")\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @pages }\n end\n end",
"def index\n @system_modules = SystemModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @system_modules }\n end\n end",
"def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def module_intems\n # /api/v1/courses/:course_id/modules/:module_id/items\n api_module_intems_url = \"#{@@api_root_url}/courses/#{self.course_id}/modules/#{self.id}/items\" \n @module_items = []\n begin\n module_intems_json = self.get_json(api_module_intems_url)\n rescue RestClient::Unauthorized => e\n else\n module_intems_json.each do |module_intem|\n @module_items << ModuleItem.new(self.course_id, self.id, module_intem)\n end\n @module_items\n end \n end",
"def show\n @advert_module = AdvertModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @advert_module }\n end\n end",
"def xml_type\n \"MODS\"\n end",
"def show\n @system_module = SystemModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_module }\n end\n end",
"def get_module_uri\n \"#{get_uri.chomp(\"/\")}/#{@exploit_receiver_page}\"\n end",
"def update\n @page_module = PageModule.find(params[:id])\n\n respond_to do |format|\n if @page_module.update_attributes(params[:page_module])\n format.html { redirect_to(@page_module) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\", message: \"成功更新页面模块!\"}'}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }\n format.json { render :text => \"{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}\"}\n end\n end\n end",
"def index\n @pages = Page.order(\"name ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pm_nodes = Pm::Node.all\n end",
"def index\n @pages = Page.all\n\n respond_to do |format| \n format.json {render json: @pages}\n format.xml {render xml: @pages}\n end\n\n end",
"def index\n @page_title = \"Power Units\"\n @power_units = PowerUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @power_units }\n end\n end",
"def index\n#\t\t@pages = Page.find(:all)\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml\t{ render :xml => @pages }\n\t\tend\n\tend",
"def index\n @pages = @user.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def extract_modules\n i = 0\n path = \"//foxml:datastream[@ID='DC']/foxml:datastreamVersion\"\\\n \"[@ID='#{@current_dc_version}']/foxml:xmlContent/oai_dc:dc\"\\\n \"/dc:identifier/text()[not(starts-with(.,'york')) ]\"\n @doc.xpath(path, @ns).each do |s|\n keyname = 'module'\n i += 1\n keyname += i.to_s\n @key_metadata[keyname.to_sym] = s.to_s\n end\n end",
"def new\n @appmodule = Appmodule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @appmodule }\n end\n end",
"def index\n @module5s = Module5.all\n end",
"def list_modules module_type\n if module_type.empty?\n @colour.help \"ForGen module types: #{MODULE_TYPES}\"\n return\n end\n\n if MODULE_TYPES.include? module_type\n @colour.help \"Listing modules of type #{module_type}:\"\n Dir[\"#{DIR_MODULES}/#{module_type}/**/forgen_metadata.xml\"].select{ |file| !File.directory? file }.each_with_index do |case_name, case_number|\n @colour.help \"#{case_number}) #{case_name}\"\n end\n else\n @colour.error \"Module type [#{module_type}] does not exist\"\n end\nend",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def destroy\n @page_module = PageModule.find(params[:id])\n @page_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_modules_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def index\n @progres = Progre.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @progres }\n end\n end",
"def index\n @nodes = Node.all\n @title = \"List of taxonomy nodes - Browse organisms\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.json { render json: @pages }\n format.xml { render xml: @pages }\n end\n end",
"def create\n @page_module = PageModule.new(params[:page_module])\n\n respond_to do |format|\n if @page_module.save\n format.html { redirect_to(@page_module) }\n format.xml { render :xml => @page_module, :status => :created, :location => @page_module }\n format.json { render :text => '{status: \"success\", message: \"成功创建页面模块!\"}'}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }\n format.json { render :text => \"{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}\"}\n end\n end\n end",
"def index\n unless params[:type]\n @page = Page.find_by_permalink(\"production\", :order => \"position ASC\")\n #@page_ids = []\n else\n @page = Page.find_by_permalink(\"accessories\", :order => \"position ASC\")\n #@items = Item.find_by_page_id(params[:page_id])\n end\n\n #respond_to do |wants|\n # wants.html # index.html.erb\n # # wants.xml { render :xml => @items }\n # end\n end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def index\n @links = @panel.links\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @links }\n end\n end",
"def index\n @ects_modules = EctsModule.all\n end",
"def pages\n end",
"def index\n @admin_pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def rest__list\n diff = ret_request_params(:diff)\n project = get_default_project()\n datatype = :module\n remote_repo_base = ret_remote_repo_base()\n\n opts = Opts.new(project_idh: project.id_handle())\n if detail = ret_request_params(:detail_to_include)\n opts.merge!(detail_to_include: detail.map(&:to_sym))\n end\n\n opts.merge!(remote_repo_base: remote_repo_base, diff: diff)\n datatype = :module_diff if diff\n\n rest_ok_response filter_by_namespace(TestModule.list(opts)), datatype: datatype\n end",
"def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @software_training_module }\n end\n end",
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def new\n @learning_module = LearningModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @learning_module }\n end\n end",
"def maven_module_list(path, recurse = false)\n\n module_list = Array.new\n\n XPath.each(Document.new(File.new(\"#{path}/pom.xml\")), '/project/modules/module/text()').each do |name|\n\n module_list.push(name.to_s)\n\n if recurse\n maven_module_list(\"#{path}/#{name}\", true).each do |name2|\n module_list.push(\"#{name}/#{name2}\")\n end\n end\n end\n\n module_list\nend",
"def index\n @pages = []\n website.available_locales.each do |l|\n @pages << {\n url: locale_sitemap_url(locale: l.locale.to_s, format: 'xml'),\n updated_at: 1.day.ago}\n end\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def admin_xml(path,method=:get,options={})\n xml_message(amee_admin,\"/admin#{path}\",method,options)\n end",
"def index\n @active_page = :versions\n\n respond_to do |format|\n format.html\n format.xml do\n find_versions\n @versions_count = @versions.size\n @versions = @versions[ @page_limit * (@current_page - 1), @page_limit ].to_a\n render :action => :index, :layout => false\n end\n end\n end",
"def show\n @lesson = current_user.organization.lessons.find(params[:id], :include => :pages)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lesson }\n end\n end",
"def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end",
"def index #This is the ACTION 'index', accessed via /manage/pages, as opposed to the STUB 'index', accessed via /pages\n restrict('allow only admins') or begin\n @pages = Page.find(:all)\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @pages.to_xml }\n end\n end\n end",
"def index\n @content_pages = ContentPage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @content_pages }\n end\n end",
"def index\n @pages = Page.all\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = @store.pages.active\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @mod_packs = ModPack.all\n end",
"def show\n @module_pack = ModulePack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @module_pack }\n end\n end",
"def index\n @permisos = Permiso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @permisos }\n end\n end",
"def test_get_ModuleList\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/test001.xml\")\n golden = [\"D78F1070_EVA\",\n \"QLK0RCPUEVA0V3\",\n \"QLK0RCPUEVA0V3_ADR\",\n \"QLK0RCPUEVA0V3_ALU\",\n \"QLK0RCPUEVA0V3_EXE\",\n \"QLK0RCPUEVA0V3_EXE2\",\n \"QLK0RCPUEVA0V3_CLK\",\n \"QLK0RCPUEVA0V3_DEC\"]\n # Normalrror\n assert_equal(golden,XMLParse::get_ModuleList(@root))\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def show\n @page = @site.pages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def rest__export\n node_module = create_obj(:node_module_id)\n rest_ok_response publish_to_dtkn_helper(node_module)\n end",
"def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @sfmodules = Sfmodule.all\n end",
"def index\n @pppams_indicator_base_refs = PppamsIndicatorBaseRef.paginate(:all, :per_page => 20, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pppams_indicator_base_refs }\n>>>>>>> 7436653363ecf064fdcfcd2b30df919b5144a2b8\n end\n end",
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def getPtbModule( entity_id, __module, destructive)\n params = Hash.new\n params['entity_id'] = entity_id\n params['module'] = __module\n params['destructive'] = destructive\n return doCurl(\"get\",\"/ptb/module\",params)\n end",
"def index\n @current_item = \"my_account\"\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @accounts.to_xml }\n end\n end",
"def index\n @machine_modules = MachineModule.all\n end",
"def index\n @independents = @member.independents\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @independents }\n end\n end"
] | [
"0.64441085",
"0.63864636",
"0.6316744",
"0.62338394",
"0.6195307",
"0.6128555",
"0.61051494",
"0.6068587",
"0.6030302",
"0.5996949",
"0.59323084",
"0.5863857",
"0.5822671",
"0.5817481",
"0.58161277",
"0.5808764",
"0.57973474",
"0.57889366",
"0.57724065",
"0.57589155",
"0.57496256",
"0.5744937",
"0.57360786",
"0.57297444",
"0.56942254",
"0.56828654",
"0.5646376",
"0.56356955",
"0.56317645",
"0.5628526",
"0.5624202",
"0.5606527",
"0.56029147",
"0.5575849",
"0.5572284",
"0.5567239",
"0.55647033",
"0.55586135",
"0.55533093",
"0.55533093",
"0.55443436",
"0.55443436",
"0.5539924",
"0.5522713",
"0.5517533",
"0.5512303",
"0.54877883",
"0.54847777",
"0.5482148",
"0.5466669",
"0.54650015",
"0.5456856",
"0.54502946",
"0.5443913",
"0.5436588",
"0.5422946",
"0.5404571",
"0.5403968",
"0.5393441",
"0.5393441",
"0.5386129",
"0.5383683",
"0.538053",
"0.537984",
"0.53720236",
"0.53453803",
"0.5342204",
"0.53381306",
"0.5329111",
"0.5309811",
"0.5306604",
"0.5306264",
"0.5305701",
"0.5305697",
"0.5295985",
"0.529569",
"0.52907366",
"0.5290413",
"0.5287993",
"0.52877676",
"0.5285995",
"0.5285433",
"0.5273098",
"0.526939",
"0.52649873",
"0.525289",
"0.52527624",
"0.5251907",
"0.5244879",
"0.5235545",
"0.52347445",
"0.52335393",
"0.5223149",
"0.5223143",
"0.522106",
"0.521347",
"0.5210017",
"0.52062124",
"0.5200546",
"0.5189551"
] | 0.7119129 | 0 |
GET /page_modules/new GET /page_modules/new.xml | def new
@page_module = PageModule.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @page_module }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def new\n @appmodule = Appmodule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @appmodule }\n end\n end",
"def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = current_cms.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @learning_module = LearningModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @learning_module }\n end\n end",
"def new\n @page = @offering.pages.new\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = @site.pages.new\n @page.parts << PagePart.new(:name => \"body\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @modulo = Modulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @modulo }\n end\n end",
"def new\n @text_module = TextModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_module }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software_training_module }\n end\n end",
"def new\n @course_module = CourseModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_module }\n end\n end",
"def create\n @page_module = PageModule.new(params[:page_module])\n\n respond_to do |format|\n if @page_module.save\n format.html { redirect_to(@page_module) }\n format.xml { render :xml => @page_module, :status => :created, :location => @page_module }\n format.json { render :text => '{status: \"success\", message: \"成功创建页面模块!\"}'}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }\n format.json { render :text => \"{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}\"}\n end\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end",
"def new\n @page = Page.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end",
"def new\n @academic_module = AcademicModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @academic_module }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @page }\n end\n end",
"def new\n @pages_dynamic_page = Pages::DynamicPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pages_dynamic_page }\n end\n end",
"def new\n @page = Page.new\n\t\t@types = Type.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @cms_page = CmsPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cms_page }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.json {render json: @page}\n format.xml {render xml: @page}\n end\n end",
"def new\n @pagecontent = Pagecontent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pagecontent }\n end\n end",
"def new\n @page = current_site.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.json { render json: @page }\n format.xml { render xml: @page }\n end\n end",
"def new\n @module_template = ModuleTemplate.new\n\t@module_template.module_parameters.build\n\t@module_template.module_instances.build\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @module_template }\n end\n end",
"def new\n new_object Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :layout => \"default\" }\n end\n end",
"def new\n @page = Page.new\n @user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @advert_module = AdvertModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @advert_module }\n end\n end",
"def new\n @menu_page = MenuPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu_page }\n end\n end",
"def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @admin_page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n\t\t@page = Page.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @page }\n\t\tend\n\tend",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @module_pack = ModulePack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @module_pack }\n end\n end",
"def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @static_page = StaticPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @static_page }\n end\n end",
"def new\n @static_page = StaticPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @static_page }\n end\n end",
"def new\n @system_module = SystemModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system_module }\n end\n end",
"def new\n @prime = Prime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prime }\n end\n end",
"def new\n @title = 'New Page'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @get_started_page }\n end\n end",
"def new\n @node = Node.new(:displayed => true)\n @node.template = Template.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @page_role = PageRole.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_role }\n end\n end",
"def new\n @mainpage = Mainpage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mainpage }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n @page = ContentPage.new\n @blocks = nil\n #@newBlock = PageBlock.new\n @form_action = \"create_page\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @page = Page.find(params[:page_id])\n @site_section = @page.site_section\n @article_list = ArticleList.new\n @page_section = @article_list.build_page_section\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article_list }\n end\n end",
"def new\n @page = @user.pages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @menutree = Menutree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menutree }\n end\n end",
"def new\n @webpage = Webpage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @webpage }\n end\n end",
"def new\n @page_layout = PageLayout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_layout }\n end\n end",
"def new\n @content_page = ContentPage.new :page_layout => \"default\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_page }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @oasis_page = OasisPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @oasis_page }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @_template = @site.templates.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @_template }\n end\n end",
"def new\r\n @page = Page.new\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @page }\r\n end\r\n end",
"def new\n @pages = Page.new\n #renders new.html.erb\n end",
"def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end",
"def new_rest\n @page_usage_event = PageUsageEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_usage_event }\n end\n end",
"def new\n new_prc\n\n setup_campuses_and_semesters\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prc }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n # render :new app/views/pages/new.html.erb\n end",
"def new\n @sub_page = SubPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sub_page }\n end\n end",
"def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end",
"def new\n @category_page = CategoryPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category_page }\n end\n end",
"def new\n @question = @page.questions.new\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def new\n @page = Page.new\n @page.section_id = params[:section_id]\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @mod_pag = ModPag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mod_pag }\n end\n end",
"def new\n @new_project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_project }\n end\n end",
"def new\n @pwebsite = Pwebsite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pwebsite }\n end\n end",
"def new\n @page_title = \"Task List New\"\n @task_list = TaskList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_list }\n end\n end",
"def new\n @root_pages = [fetch_root_page].flatten\n if request.post?\n @page = ComatosePage.new params[:page]\n @page.author = fetch_author_name\n if @page.save\n flash[:notice] = \"Created page '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n else\n @page = ComatosePage.new :title=>'New Page', :parent_id=>(params[:parent] || nil)\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @permiso = Permiso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @permiso }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def create\n @learning_module = LearningModule.new(params[:learning_module])\n\n respond_to do |format|\n if @learning_module.save\n flash[:notice] = 'Learning Module was successfully created.'\n format.html { redirect_to(@learning_module) }\n format.xml { render :xml => @learning_module, :status => :created, :location => @learning_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @learning_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_page\n page = Page.new\n page.url = params[:id] if Page.url?(params[:id]) && params[:id] != 'new-page'\n page\n end",
"def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end",
"def new\n @p_stat = PStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @p_stat }\n end\n end",
"def new\r\n @event = Event.new\r\n #@pages = Page.all\r\n @projects_pages = []\r\n projects = Project.all.sort{|a,b| a.name <=> b.name}\r\n projects.each do |project|\r\n @projects_pages << [\"#{project.name}\", project.pages.exclude_placeholder] unless project.pages.blank?\r\n end\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @event }\r\n end\r\n end",
"def new\n @export = Export.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @export }\n end\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @page = Page.new\n # render new.html.erb\n end",
"def new\n @page = Page.new\n # render new.html.erb\n end"
] | [
"0.7211834",
"0.7063084",
"0.7055166",
"0.7029531",
"0.69596004",
"0.6869985",
"0.6794622",
"0.67838895",
"0.67770994",
"0.67291987",
"0.67200124",
"0.6697786",
"0.66902775",
"0.6663735",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.6653849",
"0.6625547",
"0.6620669",
"0.65594995",
"0.6492452",
"0.64822596",
"0.6467307",
"0.64671457",
"0.64606816",
"0.64599967",
"0.6454659",
"0.6421758",
"0.64210194",
"0.64147365",
"0.63946325",
"0.63921064",
"0.6373851",
"0.6367616",
"0.6333097",
"0.62958866",
"0.62951654",
"0.62951654",
"0.6293733",
"0.6280894",
"0.6262647",
"0.6262647",
"0.62466455",
"0.6244328",
"0.6235793",
"0.6226683",
"0.6213691",
"0.6198089",
"0.61950964",
"0.6174537",
"0.6170217",
"0.61692786",
"0.61554205",
"0.6148829",
"0.61242336",
"0.6103104",
"0.60951316",
"0.60943705",
"0.60919327",
"0.609021",
"0.6088988",
"0.60841787",
"0.6078035",
"0.60758096",
"0.6071744",
"0.60713506",
"0.606721",
"0.60640746",
"0.6048522",
"0.6044367",
"0.60371023",
"0.6034637",
"0.60306215",
"0.60305876",
"0.60280746",
"0.6026181",
"0.6020605",
"0.6020108",
"0.601783",
"0.60154927",
"0.60123557",
"0.60123557",
"0.60123557",
"0.60123557",
"0.60123557",
"0.60092545",
"0.6008059",
"0.6006952",
"0.6002398",
"0.59918386",
"0.598982",
"0.5989548",
"0.5989417",
"0.5989111",
"0.59881043",
"0.59881043"
] | 0.8038531 | 0 |
POST /page_modules POST /page_modules.xml | def create
@page_module = PageModule.new(params[:page_module])
respond_to do |format|
if @page_module.save
format.html { redirect_to(@page_module) }
format.xml { render :xml => @page_module, :status => :created, :location => @page_module }
format.json { render :text => '{status: "success", message: "成功创建页面模块!"}'}
else
format.html { render :action => "new" }
format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }
format.json { render :text => "{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}"}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_module = PageModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def rest__create\n module_name = ret_non_null_request_params(:module_name)\n project = get_default_project()\n version = nil #TODO: stub\n local_params = local_params(:node_module, module_name, version: version)\n module_repo_info = NodeModule.create_module(project, local_params)[:module_repo_info]\n\n rest_ok_response module_repo_info\n end",
"def rest__export\n node_module = create_obj(:node_module_id)\n rest_ok_response publish_to_dtkn_helper(node_module)\n end",
"def update\n @page_module = PageModule.find(params[:id])\n\n respond_to do |format|\n if @page_module.update_attributes(params[:page_module])\n format.html { redirect_to(@page_module) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\", message: \"成功更新页面模块!\"}'}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }\n format.json { render :text => \"{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}\"}\n end\n end\n end",
"def create\n @process_module = ProcessModule.new(process_module_params)\n\n respond_to do |format|\n if @process_module.save\n format.html { redirect_to @process_module, notice: 'Process module was successfully created.' }\n format.json { render :show, status: :created, location: @process_module }\n else\n format.html { render :new }\n format.json { render json: @process_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @appmodule = Appmodule.new(params[:appmodule])\n\n respond_to do |format|\n if @appmodule.save\n format.html { redirect_to(@appmodule, :notice => 'Appmodule was successfully created.') }\n format.xml { render :xml => @appmodule, :status => :created, :location => @appmodule }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @appmodule.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @svn_module = SvnModule.new(params[:svn_module])\n\n respond_to do |format|\n if @svn_module.save\n format.html { redirect_to(@svn_module, :notice => 'Svn module was successfully created.') }\n format.xml { render :xml => @svn_module, :status => :created, :location => @svn_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @svn_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def upload(nodes)\n node_manager.assert_known(nodes)\n\tmodule_list = nil \n module_list = self.module_path.gsub(/:/,' ') if self.module_path != nil\n Node.prepare_upload(module_list) do\n for node in nodes\n node_manager.find(node).upload\n end\n end\n end",
"def create\n @page = @club.pages.new(params[:page])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.save\n flash[:notice] = 'Pages was successfully created.'\n\t format.html { redirect_to(admin_club_page_path(@club, @page)) }\n format.xml { render :xml => @page, :status => :created, :location => @page }\n else\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @system_module = SystemModule.new(params[:system_module])\n\n respond_to do |format|\n if @system_module.save\n format.html { redirect_to system_modules_path, notice: 'System module was successfully created.' }\n format.json { render json: @system_module, status: :created, location: @system_module }\n else\n format.html { render action: \"new\" }\n format.json { render json: @system_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def new\n @module_template = ModuleTemplate.new\n\t@module_template.module_parameters.build\n\t@module_template.module_instances.build\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @module_template }\n end\n end",
"def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def create\n @learning_module = LearningModule.new(params[:learning_module])\n\n respond_to do |format|\n if @learning_module.save\n flash[:notice] = 'Learning Module was successfully created.'\n format.html { redirect_to(@learning_module) }\n format.xml { render :xml => @learning_module, :status => :created, :location => @learning_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @learning_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @module5 = Module5.new(module5_params)\n\n respond_to do |format|\n if @module5.save\n format.html { redirect_to @module5, notice: 'Module5 was successfully created.' }\n format.json { render :show, status: :created, location: @module5 }\n else\n format.html { render :new }\n format.json { render json: @module5.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @page_module = PageModule.find(params[:id])\n @page_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_modules_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def post_module_params\n params.require(:admin_post_module).permit(\n :name,\n :position,\n :slot_id\n )\n end",
"def index\n @process_modules = ProcessModule.all\n end",
"def rest__export\n test_module = create_obj(:test_module_id)\n rest_ok_response publish_to_dtkn_helper(test_module)\n end",
"def mod_params\n params.require(:mod).permit(:pid, :parent_id, :name, :code, :prose, :title, :description, :creator_id)\n end",
"def client_modules\n get 'client/modules'\n end",
"def modules\n @modules= GmaModule.all :order=>\"seq\"\n render :layout => false\n end",
"def update\n if @post_module.update(post_module_params)\n PageModule::Service\n .new(@post_module)\n .update_page_module(post_module_params)\n redirect_to admin_page_path(@post_module.page)\n else\n format.html { render :edit }\n end\n end",
"def create\n @module_pack = ModulePack.new(params[:module_pack])\n\n respond_to do |format|\n if @module_pack.save\n format.html { redirect_to @module_pack, notice: 'Module pack was successfully created.' }\n format.json { render json: @module_pack, status: :created, location: @module_pack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @module_pack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest__create\n module_name = ret_non_null_request_params(:module_name)\n namespace = ret_request_param_module_namespace?()\n project = get_default_project()\n version = nil #TODO: stub\n\n opts_local_params = (namespace ? { namespace: namespace } : {})\n local_params = local_params(:test_module, module_name, opts_local_params)\n\n opts_create_mod = Opts.new(\n config_agent_type: ret_config_agent_type()\n )\n module_repo_info = TestModule.create_module(project, local_params, opts_create_mod)[:module_repo_info]\n rest_ok_response module_repo_info\n end",
"def create\n @course_module = CourseModule.new(params[:course_module])\n\n respond_to do |format|\n if @course_module.save\n flash[:notice] = 'CourseModule was successfully created.'\n format.html { redirect_to(@course_module) }\n format.xml { render :xml => @course_module, :status => :created, :location => @course_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @text_module = TextModule.new(params[:text_module])\n\n respond_to do |format|\n if @text_module.save\n flash[:notice] = 'TextModule was successfully created.'\n format.html { redirect_to(params[:back_to] ) }\n format.xml { render :xml => @text_module, :status => :created, :location => @text_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @text_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n @admin_decp_module = Admin::DecpModule.new(params[:admin_decp_module])\r\n\r\n @data_types = %w[boolean date datetime decimal integer string time]\r\n\r\n respond_to do |format|\r\n format.html { render action: \"create_form\" }\r\n # format.json { render json: @admin_decp_module.errors, status: :unprocessable_entity }\r\n end\r\n end",
"def create_module\n puts \"\\n... Creating module '#{@module}' in '#{@dir}'\"\n # Base directory\n create_dir(\"#{@module}\")\n self.create_module_dirs\n self.create_module_files\n self.create_module_file\n self.create_module_database_files\n self.create_module_info_file\n puts 'Module created :)'\n end",
"def new\n @module_pack = ModulePack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @module_pack }\n end\n end",
"def new\n @appmodule = Appmodule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @appmodule }\n end\n end",
"def enable_webform_module\n Log.logger.info(\"Starting test_00_enable_webform_module\")\n login($config['user_accounts']['qatestuser']['user'], $config['user_accounts']['qatestuser']['password'])\n @browser.get(@sut_url + '/admin/modules')\n JQuery.wait_for_events_to_finish(@browser)\n modular = ModuleManager.new(@browser)\n mod_value = modular.read_module_value(\"Webforms\")\n if (mod_value == \"off\")\n Log.logger.info(\"webforms module is not enabled, enabling it\")\n modular.enable_disable_modules(module_names = [\"Webforms\"], module_value = \"on\")\n else\n Log.logger.info(\"Webforms module is already enabled\")\n end\n Log.logger.info(\"Webform module is now enabled\")\n end",
"def create\n @advert_module = AdvertModule.new(params[:advert_module])\n\n respond_to do |format|\n if @advert_module.save\n flash[:notice] = 'AdvertModule was successfully created.'\n format.html { redirect_to(@advert_module) }\n format.xml { render :xml => @advert_module, :status => :created, :location => @advert_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @advert_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sfmodule = Sfmodule.new(sfmodule_params)\n\n respond_to do |format|\n if @sfmodule.save\n format.html { redirect_to sfmodules_path, notice: 'Sfmodule was successfully created.' }\n format.json { render :show, status: :created, location: @sfmodule }\n else\n format.html { render :new }\n format.json { render json: @sfmodule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_module_item(course_id,module_id,module_item__type__,module_item__content_id__,module_item__page_url__,module_item__external_url__,module_item__completion_requirement____min_score__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :module_item__title__,\n :module_item__type__,\n :module_item__content_id__,\n :module_item__position__,\n :module_item__indent__,\n :module_item__page_url__,\n :module_item__external_url__,\n :module_item__new_tab__,\n :module_item__completion_requirement____type__,\n :module_item__completion_requirement____min_score__,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"module_id is required\" if module_id.nil?\n raise \"module_item__type__ is required\" if module_item__type__.nil?\n raise \"module_item__content_id__ is required\" if module_item__content_id__.nil?\n raise \"module_item__page_url__ is required\" if module_item__page_url__.nil?\n raise \"module_item__external_url__ is required\" if module_item__external_url__.nil?\n raise \"module_item__completion_requirement____min_score__ is required\" if module_item__completion_requirement____min_score__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :module_id => module_id,\n :module_item__type__ => module_item__type__,\n :module_item__content_id__ => module_item__content_id__,\n :module_item__page_url__ => module_item__page_url__,\n :module_item__external_url__ => module_item__external_url__,\n :module_item__completion_requirement____min_score__ => module_item__completion_requirement____min_score__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/modules/{module_id}/items\",\n :course_id => course_id,\n :module_id => module_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 ModuleItem.new(response)\n end",
"def create\n\n # retrieve page part attributes from params and assign it to a variable\n page_parts = params[:page][:page_parts_attributes]\n\n # sort the page_parts and reassign it to the params\n params[:page][:page_parts_attributes] = Hash[page_parts.sort]\n\n #creating the page object with its own and child attributes\n @page = Page.new(params[:page])\n\n #retrieving layout id from params and assigning to a variable\n @layout = params[:page][:layout_id]\n\n # calling method to find all pages and page parts\n find_pages_and_parts(@layout)\n\n # sends the data in different formats\n respond_to do |format|\n\n if @page.save #page saved successfully\n\n format.html { redirect_to admin_pages_path, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n\n else #page saving failed, re-render the form\n\n format.html { render action: \"new\", :template => 'mcms_pages/admin/pages/new' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n\n end # end if\n\n end # end respond_to block\n\n end",
"def rest__create\n # setup needed data\n module_name = ret_non_null_request_params(:module_name)\n namespace = ret_request_param_module_namespace?()\n config_agent_type = ret_config_agent_type()\n project = get_default_project()\n\n # local_params encapsulates local module branch params\n opts_local_params = (namespace ? { namespace: namespace } : {})\n local_params = local_params(:component_module, module_name, opts_local_params)\n\n opts_create_mod = Opts.new(\n config_agent_type: ret_config_agent_type()\n )\n\n module_repo_info = ComponentModule.create_module(project, local_params, opts_create_mod)[:module_repo_info]\n\n # only when creating via import-git command\n git_url = ret_request_params(:module_git_url)\n\n unless git_url.empty?\n add_git_url(project.model_handle(:repo_remote), module_repo_info[:repo_id], git_url)\n end\n\n rest_ok_response module_repo_info\n end",
"def save_module\n uni_module = UniModule.find(params[:module_par])\n if(current_user.uni_modules.include?(uni_module))\n current_user.unsave_module(uni_module)\n else\n current_user.save_module(uni_module)\n end\n end",
"def rest__export\n component_module = create_obj(:component_module_id)\n rest_ok_response publish_to_dtkn_helper(component_module)\n end",
"def create\n @prework_module = PreworkModule.new(params[:prework_module])\n\n respond_to do |format|\n if @prework_module.save\n format.html { redirect_to prework_path, notice: 'Prework module was successfully created.' }\n format.json { render json: @prework_module, status: :created, location: @prework_module }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prework_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def module_intems\n # /api/v1/courses/:course_id/modules/:module_id/items\n api_module_intems_url = \"#{@@api_root_url}/courses/#{self.course_id}/modules/#{self.id}/items\" \n @module_items = []\n begin\n module_intems_json = self.get_json(api_module_intems_url)\n rescue RestClient::Unauthorized => e\n else\n module_intems_json.each do |module_intem|\n @module_items << ModuleItem.new(self.course_id, self.id, module_intem)\n end\n @module_items\n end \n end",
"def create\n @page = @parent_page.children.new(params[:page])\n \n @page.site = @site\n @page.created_by = @page.updated_by = current_user\n\n respond_to do |format|\n if @page.save\n flash[:notice] = \"Page was successfully created.\"\n format.html { redirect_to(@parent_page ? admin_site_page_child_path(@site, @parent_page, @page) : admin_site_page_path(@site, @page))}\n format.xml { render :xml => @page, :status => :created, :location => @page }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def admin_blog_module_params\n params.require(:admin_blog_module).permit(\n :name,\n :body,\n :layout,\n :position,\n :slot_id,\n :post_page_id\n )\n end",
"def show\n @page_module = PageModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def add_modules(modules)\n Array(modules).each do |mod|\n case mod\n when Bolt::Puppetfile::Module\n @modules << mod\n when Hash\n @modules << Bolt::Puppetfile::Module.from_hash(mod)\n else\n raise Bolt::ValidationError, \"Module must be a Bolt::Puppetfile::Module or Hash.\"\n end\n end\n\n @modules\n end",
"def add_modules(modules)\n Array(modules).each do |mod|\n case mod\n when Bolt::Puppetfile::Module\n @modules << mod\n when Hash\n @modules << Bolt::Puppetfile::Module.from_hash(mod)\n else\n raise Bolt::ValidationError, \"Module must be a Bolt::Puppetfile::Module or Hash.\"\n end\n end\n\n @modules\n end",
"def rest__list\n diff = ret_request_params(:diff)\n project = get_default_project()\n datatype = :module\n remote_repo_base = ret_remote_repo_base()\n\n opts = Opts.new(project_idh: project.id_handle())\n if detail = ret_request_params(:detail_to_include)\n opts.merge!(detail_to_include: detail.map(&:to_sym))\n end\n\n opts.merge!(remote_repo_base: remote_repo_base, diff: diff)\n datatype = :module_diff if diff\n\n rest_ok_response NodeModule.list(opts), datatype: datatype\n end",
"def create\n @epitech_module = EpitechModule.new(epitech_module_params)\n\n respond_to do |format|\n if @epitech_module.save\n format.html { redirect_to @epitech_module, notice: 'Epitech module was successfully created.' }\n format.json { render :show, status: :created, location: @epitech_module }\n else\n format.html { render :new }\n format.json { render json: @epitech_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def set_Module(value)\n set_input(\"Module\", value)\n end",
"def ects_module_params\n params.require(:ects_module).permit(:name, :course_ids => [])\n end",
"def subscription_module_params\n params.require(:admin_subscription_module).permit(\n :name,\n :body,\n :layout,\n :position,\n :slot_id\n )\n end",
"def create\n @academic_module = AcademicModule.new(params[:academic_module])\n\n respond_to do |format|\n if @academic_module.save\n format.html { redirect_to(@academic_module, :notice => 'Academic module was successfully created.') }\n format.xml { render :xml => @academic_module, :status => :created, :location => @academic_module }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @academic_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @machine_module = MachineModule.new(machine_module_params)\n\n respond_to do |format|\n if @machine_module.save\n format.html { redirect_to @machine_module, notice: 'Machine module was successfully created.' }\n format.json { render :show, status: :created, location: @machine_module }\n else\n format.html { render :new }\n format.json { render json: @machine_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_blog_module\n @page = Page.find(params[:page_id])\n @admin_blog_module = Admin::BlogModule.find(params[:id])\n end",
"def new\n @system_module = SystemModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system_module }\n end\n end",
"def new\n @text_module = TextModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @text_module }\n end\n end",
"def homepage\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/OrgEntry.jsp')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/corner3.png')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/transparent.gif')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService', \n {\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'method' => 'POST',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgOrgRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/SecurityRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|29F4EA1240F157649C12466F01F46F60|org.kuali.student.common.ui.client.service.SecurityRpcService|getPrincipalUsername|1|2|3|4|0|\"\n }\n )\n\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.docSearch.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.actionList.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|lum.application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n end",
"def pm_node_params\n params.require(:pm_node).permit(:percent, :content, :name, :plan_id, :sort_seq, :start_date, :end_date)\n end",
"def create\n #@parent_page = Page.find(params[:page][:parent_id])\n \n @page = Page.new(params[:page])\n #@page.move_to_child_of(@parent_page)\n \n respond_to do |wants|\n if @page.save\n flash[:notice] = 'Страница успешно создана.'\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { render :xml => @page, :status => :created, :location => @page }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def POST; end",
"def create\n @pages_group = PagesGroup.new(pages_group_params)\n respond_to do |format|\n if @pages_group.save\n format.html { redirect_to @pages_group, notice: 'Pages group was successfully created.' }\n format.json { render :show, status: :created, location: @pages_group }\n else\n format.html { render :new }\n format.json { render json: @pages_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def index\n @text_modules = TextModule.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @text_modules }\n end\n end",
"def create\n @ects_module = EctsModule.new(ects_module_params)\n @ects_module.course_ids = params[:ects_module][:course_ids]\n\n respond_to do |format|\n if @ects_module.save\n format.html { redirect_to @ects_module, notice: 'ects module was successfully created.' }\n format.json { render :show, status: :created, location: @ects_module }\n else\n format.html { render :new }\n format.json { render json: @ects_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:cms_page][:parent_id] = 0 if params[:cms_page][:parent_id].blank?\n @cms_page = CmsPage.new(params[:cms_page])\n\n respond_to do |format|\n if @cms_page.save\n expire_page \"/#{@cms_page.path}\" \n flash[:notice] = 'CmsPage was successfully created.'\n format.html { redirect_to(['admin', @cms_page]) }\n format.xml { render :xml => @cms_page, :status => :created, :location => ['admin', @cms_page] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cms_page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def xml_type\n \"MODS\"\n end",
"def method_missing(method, *args, &block)\n data = { method: method, parameters: args }\n request.post(path: nodes_path, data: data, auth_token: auth_token)\n end",
"def create\n @modul = Modul.new(modul_params)\n\n respond_to do |format|\n if @modul.save\n format.html { redirect_to '/product_breakdown_structures/'+Subproduct.find_by(id: @modul.subproduct_id).pbs_id.to_s+'/edit', notice: 'Modul wurde erfolgreich angelegt' }\n format.json { render :show, status: :created, location: @modul }\n else\n format.html { render :new }\n format.json { render json: @modul.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @system_modules = SystemModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @system_modules }\n end\n end",
"def post_to_newgistics\n document = Spree::Newgistics::DocumentBuilder.build_product([self])\n response = Spree::Newgistics::HTTPManager.post('/post_products.aspx', document)\n\n if response.status == 200\n errors = Nokogiri::XML(response.body).css('errors').children.any?\n update_column(:posted_to_newgistics, true) unless errors\n end\n\n end",
"def post_page file, token, key, tags, title\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n\n # Builds the multipart data\n data = MultipartData.new\n data.add_field 'token', token\n data.add_field 'key', key\n data.add_field 'tags', tags\n data.add_field 'title', title\n \n file_content = File.read(file)\n data.add_file 'file', file, 'text/plain', file_content\n \n HttpHelper.post_multipart \"http://#{server}#{addr}/page\", data\n end",
"def new\n @learning_module = LearningModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @learning_module }\n end\n end",
"def index\n @learning_modules = LearningModule.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @learning_modules }\n end\n end",
"def fetchModules\n puts \"Fetching Modules\"\n #direct url to gradeTable\n url = @baseUrl + 'state=htmlbesch&moduleParameter=Student&menuid=notenspiegel&breadcrumb=notenspiegel&breadCrumbSource=menu&asi='\n # pp @sessionId\n gradePage = @agent.get(url + @sessionId)\n\n #fetch curriculum for creditpoints\n #curriculum = agent.get('http://web-1k.rz.fh-wiesbaden.de/bachelorcurriculum.cfm?fb=22&sprachid=1&sid=103&poid=93&detail=ja').body\n\n doc = Hpricot(gradePage.body)\n table = doc.at(\"//table[2]\")\n rows = (table/\"tr\")\n \n modules = []\n \n (1...rows.length).to_a.each do |i|\n size = (rows[i]/\"td\").size\n cells = (rows[i]/\"td\")\n \n #TODO insert debug/log code\n mod = Modul.new(cells[0],cells[1],cells[2],cells[3],cells[4],cells[5],cells[6],cells[7])\n modules.push mod\n end \n puts \"Fetched \" + modules.length.to_s + \" modules\"\n return modules\n end",
"def create\n @page = Page.new(admin_page_params)\n respond_to do |format|\n if @page.save\n format.html { redirect_to admin_pages_url, notice: 'page was successfully created.' }\n format.json { render :show, status: :created, location: @page }\n else\n format.html { render :new }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def admin_page_params\n params.require(:admin_page).permit(\n :display_name,\n :sub_display_name,\n :url_name,\n :description,\n :status,\n :date,\n :date_visible,\n :start_date,\n :end_date,\n :redirect_url,\n :redirect_target,\n :body_id,\n :body_text,\n :meta_id,\n :replace_id,\n :lock_version,\n site_structures_attributes: [\n :id,\n :content_id,\n :category_id,\n :parent_id,\n :primary_cate,\n :sort,\n :page_children_count,\n :category_children_count,\n :is_sub_display_name,\n :_destroy,\n ],\n )\n end",
"def create\n @programme_session = ProgrammeSession.new(programme_session_params)\n @programme_session.modules << ProgrammeModule.all\n respond_to do |format|\n if @programme_session.save\n format.html { redirect_to @programme_session, notice: 'Programme session was successfully created.' }\n format.json { render :show, status: :created, location: @programme_session }\n else\n format.html { render :new }\n format.json { render json: @programme_session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = @club.pages.find(params[:id])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html { redirect_to(admin_club_page_path(@club, @page)) }\n format.xml { head :ok }\n else\n @pagelist = @club.all_pages\n @pagelist = @club.all_pages\n @pagelist -= @page.all_children << @page\n \n @page_title = \"Editing \" + @page.title\n @site_section = \"admin\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_module\n template 'bpmn_module.rb.template', File.join(model_path, \"#{module_name.underscore}.rb\")\n end",
"def index\n @course_modules = CourseModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @course_modules }\n end\n end",
"def page_params\n params.require(:page).permit(:type_id, :title, :body, :slug, :category_id, fields_attributes: [ :field_definition_id, :id, :value] )\n end",
"def add_module_by_normal_module(mod)\n add_class_or_module mod, @modules, @store.modules_hash\n end",
"def deploy_modules\n password_prompt\n system %Q!mlpm install!\n system %Q!mlpm deploy -u #{ @properties['ml.user'] } \\\n -p #{ @ml_password } \\\n -H #{ @properties['ml.server'] } \\\n -P #{ @properties['ml.app-port'] }!\n original_deploy_modules\n end",
"def sfmodule_params\n params.require(:sfmodule).permit(:name, :pillar_id)\n end",
"def create\n @page.brand = website.brand\n respond_to do |format|\n if @page.save\n format.html { redirect_to([:admin, @page], notice: 'Page was successfully created.') }\n format.xml { render xml: @page, status: :created, location: @page }\n website.add_log(user: current_user, action: \"Created page: #{@page.title}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getPtbModule( entity_id, __module, destructive)\n params = Hash.new\n params['entity_id'] = entity_id\n params['module'] = __module\n params['destructive'] = destructive\n return doCurl(\"get\",\"/ptb/module\",params)\n end",
"def create\n @page = Page.new(page_params)\n respond_to do |format|\n if @page.save\n self.build_pages_tree\n format.html { redirect_to @pages_tree[@page.id], notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @page }\n else\n format.html { render :new }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_process(pages)\n end",
"def create\n @pm_node = Pm::Node.new(pm_node_params)\n\n respond_to do |format|\n if @pm_node.save\n format.html { redirect_to @pm_node, notice: 'Node was successfully created.' }\n format.json { render :show, status: :created, location: @pm_node }\n else\n format.html { render :new }\n format.json { render json: @pm_node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_process_module\n @process_module = ProcessModule.find(params[:id])\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def create\n @admin_page = Admin::Page.new(admin_page_params)\n\n respond_to do |format|\n if @admin_page.save\n format.html { redirect_to edit_admin_page_path(@admin_page), notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @admin_page }\n else\n format.html { render :new }\n format.json { render json: @admin_page.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6172559",
"0.5698494",
"0.56774724",
"0.5618915",
"0.5584754",
"0.55631",
"0.54533476",
"0.53862584",
"0.5321248",
"0.5309977",
"0.5309809",
"0.52856034",
"0.5281201",
"0.5243053",
"0.52375484",
"0.52229965",
"0.52229315",
"0.5183277",
"0.51749605",
"0.5171544",
"0.51434743",
"0.5125553",
"0.5121983",
"0.5113083",
"0.51104254",
"0.5072455",
"0.50701976",
"0.5054356",
"0.50466126",
"0.5045692",
"0.50405574",
"0.5039008",
"0.5032198",
"0.50264084",
"0.5026219",
"0.50255",
"0.5024741",
"0.50232166",
"0.50177926",
"0.5017126",
"0.5014068",
"0.5001647",
"0.49932748",
"0.4983311",
"0.49768046",
"0.49768046",
"0.4971894",
"0.49650005",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49513078",
"0.49509335",
"0.49430105",
"0.49372917",
"0.4929117",
"0.49246076",
"0.4923885",
"0.49184334",
"0.49107867",
"0.49093333",
"0.49046648",
"0.4901946",
"0.4892723",
"0.48921025",
"0.4888915",
"0.488493",
"0.48836064",
"0.48829302",
"0.4877739",
"0.4872445",
"0.48704895",
"0.48702103",
"0.48653665",
"0.4859544",
"0.48583257",
"0.4854295",
"0.48394835",
"0.48360988",
"0.4829403",
"0.4828536",
"0.48282143",
"0.48112205",
"0.48034072",
"0.48024693",
"0.48018065",
"0.47988224",
"0.4796528",
"0.4792204",
"0.47919726",
"0.47808942",
"0.47698998",
"0.47683007",
"0.4768119",
"0.4763419",
"0.47623494"
] | 0.674445 | 0 |
PUT /page_modules/1 PUT /page_modules/1.xml | def update
@page_module = PageModule.find(params[:id])
respond_to do |format|
if @page_module.update_attributes(params[:page_module])
format.html { redirect_to(@page_module) }
format.xml { head :ok }
format.json { render :text => '{status: "success", message: "成功更新页面模块!"}'}
else
format.html { render :action => "edit" }
format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }
format.json { render :text => "{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}"}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @page = @club.pages.find(params[:id])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html { redirect_to(admin_club_page_path(@club, @page)) }\n format.xml { head :ok }\n else\n @pagelist = @club.all_pages\n @pagelist = @club.all_pages\n @pagelist -= @page.all_children << @page\n \n @page_title = \"Editing \" + @page.title\n @site_section = \"admin\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @appmodule = Appmodule.find(params[:id])\n\n respond_to do |format|\n if @appmodule.update_attributes(params[:appmodule])\n format.html { redirect_to(@appmodule, :notice => 'Appmodule was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appmodule.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @svn_module = SvnModule.find(params[:id])\n\n respond_to do |format|\n if @svn_module.update_attributes(params[:svn_module])\n format.html { redirect_to(@svn_module, :notice => 'Svn module was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @svn_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |wants|\n if @page.update_attributes(params[:page])\n \n flash[:notice] = 'Страница сохранена.'\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @post_module.update(post_module_params)\n PageModule::Service\n .new(@post_module)\n .update_page_module(post_module_params)\n redirect_to admin_page_path(@post_module.page)\n else\n format.html { render :edit }\n end\n end",
"def update\n @cms_page = CmsPage.find(params[:id])\n params[:cms_page][:parent_id] = 0 if params[:cms_page][:parent_id].blank?\n respond_to do |format|\n if @cms_page.update_attributes(params[:cms_page])\n expire_page \"/#{@cms_page.path}\"\n flash[:notice] = 'CMS Page was successfully updated.'\n format.html { redirect_to(['admin', @cms_page]) }\n format.xml { head :ok }\n else\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cms_page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to([:admin, @page], notice: 'Page was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated page: #{@page.title}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update\n @page = current_cms.pages.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:big_cms_page])\n format.html { render :action => \"edit\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oasis_page = OasisPage.find(params[:id])\n\n respond_to do |format|\n if @oasis_page.update_attributes(params[:oasis_page])\n format.html { redirect_to @oasis_page, notice: 'Oasis page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oasis_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def update\n @system_module = SystemModule.find(params[:id])\n\n respond_to do |format|\n if @system_module.update_attributes(params[:system_module])\n format.html { redirect_to system_modules_path, notice: 'System module was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @system_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n if @carousel_module.update(carousel_module_params)\n PageModule::Service\n .new(@carousel_module)\n .update_page_module(carousel_module_params)\n redirect_to admin_page_carousel_module_path(@page, @carousel_module)\n else\n render :edit\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @page_module = PageModule.new(params[:page_module])\n\n respond_to do |format|\n if @page_module.save\n format.html { redirect_to(@page_module) }\n format.xml { render :xml => @page_module, :status => :created, :location => @page_module }\n format.json { render :text => '{status: \"success\", message: \"成功创建页面模块!\"}'}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }\n format.json { render :text => \"{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}\"}\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update\n respond_to do |format|\n if @ects_module.update(ects_module_params)\n format.html { redirect_to @ects_module, notice: 'ects module was successfully updated.' }\n format.json { render :show, status: :ok, location: @ects_module }\n else\n format.html { render :edit }\n format.json { render json: @ects_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course_module = CourseModule.find(params[:id])\n\n respond_to do |format|\n if @course_module.update_attributes(params[:course_module])\n flash[:notice] = 'CourseModule was successfully updated.'\n format.html { redirect_to(@course_module) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @course_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = t(:page_updated)\n format.html { redirect_back_or_default(admin_page_path(@page)) }\n format.xml { head :ok }\n else\n format.html { render :action => 'edit' }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json {render json: @page, status: :created }\n format.xml {render xml: @page, status: :created}\n end\n \n else\n respond_to do |format|\n format.json {render json: @page.errors, status: :unprocessable_entity}\n format.xml {render xml: @page.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n\n #find the page with given id\n @page = Page.find(params[:id])\n\n #use updated_at manually, it will update the page table if user hits update button.\n # This may not be trivial, so it may change.\n @page.updated_at = Time.now\n\n #retrieving layout id from params and assigning to a variable\n @layout = @page[:layout_id]\n\n # calling method to find all pages and page parts\n find_pages_and_parts(@layout)\n\n #sends in data in different format\n respond_to do |format|\n\n if @page.update_attributes(params[:page]) #page updated successfully\n\n format.html { redirect_to admin_pages_path, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n\n else #page saving failed, re-renders edit template\n\n format.html { render action: \"edit\", :template => 'mcms_pages/admin/pages/edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n\n end # end if\n\n end # end respond_to block\n\n end",
"def upload(nodes)\n node_manager.assert_known(nodes)\n\tmodule_list = nil \n module_list = self.module_path.gsub(/:/,' ') if self.module_path != nil\n Node.prepare_upload(module_list) do\n for node in nodes\n node_manager.find(node).upload\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n\n respond_to do |format|\n if @page_usage_event.update_attributes(params[:page_usage_event])\n flash[:notice] = 'PageUsageEvent was successfully updated.'\n format.html { redirect_to(@page_usage_event) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_usage_event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n else\n respond_to do |format|\n format.json { raise Palani::Api::InvalidUpdateOfRecordJSONException }\n format.xml { raise Palani::Api::InvalidUpdateOfRecordXMLException }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to admin_pages_path, notice: 'Page bien modifiée.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @module_pack = ModulePack.find(params[:id])\n\n respond_to do |format|\n if @module_pack.update_attributes(params[:module_pack])\n format.html { redirect_to @module_pack, notice: 'Module pack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @module_pack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @text_module = TextModule.find(params[:id])\n\n respond_to do |format|\n if @text_module.update_attributes(params[:text_module])\n flash[:notice] = 'TextModule was successfully updated.'\n format.html { redirect_to(params[:back_to] ) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @text_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n restrict('allow only admins') or begin\n @page = Page.find_by_stub(params[:stub]) || Page.find_by_id(params[:id])\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to manage_pages_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors.to_xml }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @process_module.update(process_module_params)\n format.html { redirect_to @process_module, notice: 'Process module was successfully updated.' }\n format.json { render :show, status: :ok, location: @process_module }\n else\n format.html { render :edit }\n format.json { render json: @process_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = @offering.pages.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'OfferingPage was successfully updated.'\n format.html { redirect_to offering_page_url(@offering, @page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(pages_path, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(name, page)\n assert_attributes_set\n path = File.join directory, name\n page.delete 'plugin'\n Store.put_page(path, page, :name => name, :directory => directory)\n end",
"def destroy\n @page_module = PageModule.find(params[:id])\n @page_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_modules_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def edit\n @page = Page.find(params[:id])\n\n respond_to do |format|\n format.json {render json: @page}\n format.xml {render xml: @page}\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def new\n @page_module = PageModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def update\n @pages_dynamic_page = Pages::DynamicPage.find(params[:id])\n\n respond_to do |format|\n if @pages_dynamic_page.update_attributes(params[:pages_dynamic_page])\n format.html { redirect_to(@pages_dynamic_page, :notice => 'Dynamic page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pages_dynamic_page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Siden ble oppdatert.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = :page_updated.l\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @modulo = Modulo.find(params[:id])\n\n respond_to do |format|\n if @modulo.update_attributes(params[:modulo])\n flash[:notice] = 'Modulo was successfully updated.'\n format.html { redirect_to(@modulo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @modulo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @box = Box.find(params[:id])\n \n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to(@box.project, :notice => 'Module was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @box.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @page = @site.pages.find(params[:id])\n @page.updated_by = current_user\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = \"Page was successfully updated.\"\n format.html { redirect_to(@parent_page ? admin_site_page_child_path(@site, @parent_page, @page) : admin_site_page_path(@site, @page)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @modulo = Modulo.find(params[:id])\n\n respond_to do |format|\n if @modulo.update_attributes(params[:modulo])\n flash[:notice] = 'El Modulo se modificó correctamente.'\n format.html { redirect_to(@modulo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @modulo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def change_order\r\n ids = params[:child_nodes]\r\n \r\n # Update\r\n ProductPackageNode.transaction do\r\n ids.each_index do |index|\r\n ProductPackageNode.update ids[index], :position => index + 1\r\n end\r\n end\r\n \r\n render :nothing => true\r\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page, :status => :updated)\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @pages_tree[(@page.id).to_s], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @page = Page.find(params[:id])\r\n respond_to do |format|\r\n if @page.update_attributes(params[:page])\r\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\r\n format.json { head :no_content }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n File.open(target, \"w\") do |f|\r\n f.write(@page.html)\r\n end\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @module5.update(module5_params)\n format.html { redirect_to @module5, notice: 'Module5 was successfully updated.' }\n format.json { render :show, status: :ok, location: @module5 }\n else\n format.html { render :edit }\n format.json { render json: @module5.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n if @book_page.update_attributes(params[:book_page])\n format.html { redirect_to book_series_collection_book_book_page_url(@book_series, @collection, @book, @book_page), notice: 'Book page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @structure_page = Structure::Page.find(params[:id])\n\n respond_to do |format|\n if @structure_page.update_attributes(params[:structure_page])\n format.html { redirect_to @structure_page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @structure_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def link_submodule(params, submodule)\n params[:document_home] ||= {}\n params[:document_home][submodule] ||= []\n self.update_attributes(params[:document_home])\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Die Seite wurde aktualisiert.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @page_module = PageModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def update\n @page = Page.friendly.find(params[:id])\n\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to [:admin, @page], notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @page = Page.new(page_params)\n\n # @page.components.build\n # @page.update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @node = Node.find(params[:id])\n @node.modifier = current_user\n respond_to do |format|\n if @node.update_attributes(params[:node])\n flash[:notice] = 'Project was successfully updated.'\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n @nested_page = Nested::Page.find(params[:id])\n\n respond_to do |format|\n if @nested_page.update_attributes(params[:nested_page])\n format.html { redirect_to @nested_page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nested_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @user = current_user\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_page_params\n params.require(:page).permit(:content, :url, :file)\n end",
"def update\n @academic_module = AcademicModule.find(params[:id])\n\n respond_to do |format|\n if @academic_module.update_attributes(params[:academic_module])\n format.html { redirect_to(@academic_module, :notice => 'Academic module was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @academic_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @page.update(page_params)\n redirect_to admin_pages_path, notice: 'Страница успешно обновлена!'\n else\n render :edit\n end\n end",
"def test_change_ModuleName\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/test_simple.xml\")\n org = XMLParse::get_ModuleList(@root)\n @root_mod = XMLParse::change_ModuleName(@root,\"test\",\"EVA_TOP\")\n mod = XMLParse::get_ModuleList(@root_mod)\n assert_equal(mod - org,[\"EVA_TOP\"])\n assert_equal(org - mod,[\"test\"])\n end",
"def update\n @advert_module = AdvertModule.find(params[:id])\n\n respond_to do |format|\n if @advert_module.update_attributes(params[:advert_module])\n flash[:notice] = 'AdvertModule was successfully updated.'\n format.html { redirect_to(@advert_module) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @advert_module.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = _('Page was successfully updated.')\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n # Clear the page cache for this page... ?\n @page = ComatosePage.find params[:id]\n @root_pages = [fetch_root_page].flatten\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Time.now\n @page.author = fetch_author_name\n if @page.save\n expire_cms_page @page\n expire_cms_fragment @page\n flash[:notice] = \"Saved changes to '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @page_object.update_attributes(params[:page_object])\n flash[:notice] = 'PageObject was successfully updated.'\n format.html { redirect_to(@page_object) }\n format.xml { head :ok }\n format.tson { head :ok }\n else\n render_to_page_object\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_object, :status => :unprocessable_entity }\n format.tson { render :json => @page_object, :status => :unprocessable_entity }\n end\n end\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def update\n # { subsection:\n # {\n # \"id\" : id\n # \"subsection_datum_id\":references\n # }\n # }\n if @subsection.update_attributes(params[:module])\n head :no_content\n else\n render json: @subsection.errors.full_messages,\n status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sfmodule.update(sfmodule_params)\n format.html { redirect_to sfmodules_path, notice: 'Sfmodule was successfully updated.' }\n format.json { render :show, status: :ok, location: @sfmodule }\n else\n format.html { render :edit }\n format.json { render json: @sfmodule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_blog_module\n @page = Page.find(params[:page_id])\n @admin_blog_module = Admin::BlogModule.find(params[:id])\n end",
"def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find_by_slug(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to @page.get_page_path }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n Rails.application.reload_routes!\n format.html { redirect_to admin_page_path(@page), notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n # log\n fields = @page.fields.each do |f| f.inspect end\n register_log \"Page updated: #{@page.inspect} -- Custom type fields: #{fields}\\n\"\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n @pagecontent = @page.pagecontents.find(params[:id])\n\n respond_to do |format|\n if @pagecontent.update_attributes(params[:pagecontent])\n flash[:notice] = 'Pagecontent was successfully updated.'\n format.html {redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagecontent.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @current_category.update_attributes(params[:module])\n head :no_content\n else\n render json: @current_category.errors.full_messages,\n status: :unprocessable_entity\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if page_params[:body]\n @page.versions << Version.new(body: page_params[:body], title: page_params[:title]).save\n page_params.delete :body\n end\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to controller: \"pages\", action: \"show\", slug: @page[:page_slug], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n expire_page :action => :show\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @prework_module = PreworkModule.find(params[:id])\n\n respond_to do |format|\n if @prework_module.update_attributes(params[:prework_module])\n format.html { redirect_to @prework_module, notice: 'Prework module was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prework_module.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: \"Page was successfully updated. #{undo_link}\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :manage, @node\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to @node, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page)\n end",
"def update\n @about_page = AboutPage.find(params[:id])\n\n respond_to do |format|\n if @about_page.update_attributes(params[:about_page])\n format.html { redirect_to @about_page, notice: 'About page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @about_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to admin_subject_pages_path, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @module_template = ModuleTemplate.find(params[:id])\n\n respond_to do |format|\n if @module_template.update_attributes(params[:module_template])\n format.html { redirect_to @module_template, notice: 'Module template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @module_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_page = Page.find(params[:id])\n\n respond_to do |format|\n if @admin_page.update_attributes(params[:page])\n format.html { redirect_to([:admin,@admin_page], :notice => 'Page was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to edit_admin_page_path(@page), notice: 'Page was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @info_page = InfoPage.find(params[:id])\n\n respond_to do |format|\n if @info_page.update_attributes(params[:info_page])\n format.html { redirect_to admin_info_pages_path, notice: 'Info page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @info_page.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.59389526",
"0.5787512",
"0.5784629",
"0.57132316",
"0.57057506",
"0.5674034",
"0.56611675",
"0.56547356",
"0.5620115",
"0.56027734",
"0.5601884",
"0.5565209",
"0.55565965",
"0.55315083",
"0.54726744",
"0.54539186",
"0.5419073",
"0.5417409",
"0.54015625",
"0.5384152",
"0.5365952",
"0.53623974",
"0.5321873",
"0.5313431",
"0.5298704",
"0.5296398",
"0.5295663",
"0.52796555",
"0.527726",
"0.52489716",
"0.5239866",
"0.5236328",
"0.5235197",
"0.5228834",
"0.52262294",
"0.52230716",
"0.5220412",
"0.5203678",
"0.5197897",
"0.51966804",
"0.51884174",
"0.5186126",
"0.51811945",
"0.5179623",
"0.51786447",
"0.5178303",
"0.51681393",
"0.51656055",
"0.5165511",
"0.5158415",
"0.51399976",
"0.5139873",
"0.5138677",
"0.51376414",
"0.5134846",
"0.5129592",
"0.51265055",
"0.51265055",
"0.51182216",
"0.51182216",
"0.51054317",
"0.5105031",
"0.51028365",
"0.5088766",
"0.5086287",
"0.50861853",
"0.50823057",
"0.5079716",
"0.5053158",
"0.5049808",
"0.5044434",
"0.5039339",
"0.50389725",
"0.503755",
"0.5035426",
"0.5026676",
"0.50247234",
"0.5014551",
"0.5011705",
"0.50098103",
"0.5006161",
"0.50015515",
"0.49980557",
"0.49976423",
"0.4995145",
"0.49942228",
"0.49873227",
"0.4986043",
"0.4985351",
"0.49826074",
"0.49822277",
"0.4981605",
"0.4979185",
"0.4973417",
"0.4971119",
"0.4966254",
"0.49653473",
"0.49649438",
"0.49622884",
"0.4961395"
] | 0.6645081 | 0 |
DELETE /page_modules/1 DELETE /page_modules/1.xml | def destroy
@page_module = PageModule.find(params[:id])
@page_module.destroy
respond_to do |format|
format.html { redirect_to(page_modules_url) }
format.xml { head :ok }
format.json { render :text => '{status: "success"}'}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _delete(query_string)\nend",
"def test_delete_Module\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/test001.xml\")\n golden = [\"D78F1070_EVA\",\n \"QLK0RCPUEVA0V3\",\n \"QLK0RCPUEVA0V3_ADR\",\n \"QLK0RCPUEVA0V3_ALU\",\n \"QLK0RCPUEVA0V3_EXE2\",\n \"QLK0RCPUEVA0V3_CLK\",\n \"QLK0RCPUEVA0V3_DEC\"]\n XMLParse::delete_Module(@root,\"QLK0RCPUEVA0V3_EXE\")\n assert_equal(golden,XMLParse::get_ModuleList(@root))\n\n end",
"def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end",
"def destroy\n @appmodule = Appmodule.find(params[:id])\n @appmodule.destroy\n\n respond_to do |format|\n format.html { redirect_to(appmodules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @svn_module = SvnModule.find(params[:id])\n @svn_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(svn_modules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cms_page = CmsPage.find(params[:id])\n @cms_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_cms_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to(admin_pages_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted page: #{@page.title}\")\n end",
"def destroy\n @course_module = CourseModule.find(params[:id])\n @course_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(course_modules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @advert_module = AdvertModule.find(params[:id])\n @advert_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(advert_modules_url) }\n format.xml { head :ok }\n end\n end",
"def delete(p)\n puts \"Deleting page #{p}\"\n FileUtils.rm_rf \"#{p}\"\n end",
"def destroy\n @learning_module = LearningModule.find(params[:id])\n @learning_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(learning_modules_url) }\n format.xml { head :ok }\n end\n end",
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def destroy\n @page = @site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(@parent_page ? admin_site_page_children_url(@site, @parent_page) : admin_site_pages_url(@site)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @academic_module = AcademicModule.find(params[:id])\n @academic_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(academic_modules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @modulo = Modulo.find(params[:id])\n @modulo.destroy\n\n respond_to do |format|\n format.html { redirect_to(modulos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @modulo = Modulo.find(params[:id])\n @modulo.destroy\n\n respond_to do |format|\n format.html { redirect_to(modulos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = @club.pages.find(params[:id])\n\t\t#destroy settings\n\t\t@settings = @club.settings.find(:all, :conditions => ['name = ? AND value = ?', 'pages', @page.id]);\n\t\[email protected] do |setting|\n\t\t\tsetting.destroy\n\t\tend\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_club_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @text_module = TextModule.find(params[:id])\n @text_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(request.referer) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = current_cms.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(big_cms_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_page = Page.find(params[:id])\n @admin_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n end\n end",
"def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end",
"def destroy\r\n @admin_decp_module = Admin::DecpModule.find(params[:id])\r\n @admin_decp_module.destroy_full\r\n\r\n respond_to do |format|\r\n format.html { redirect_to admin_decp_modules_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @menu_page = MenuPage.find(params[:id])\n @menu_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { head :ok }\n end\n end",
"def destroy\n @module5.destroy\n respond_to do |format|\n format.html { redirect_to module5s_url }\n format.json { head :no_content }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete_page(page, commit)\n delete_file(page.url_path, commit)\n end",
"def destroy\n @system_module = SystemModule.find(params[:id])\n @system_module.destroy\n\n respond_to do |format|\n format.html { redirect_to system_modules_url }\n format.json { head :no_content }\n end\n end",
"def delete\r\n \tProductPackageNode.delete params[:node_ids]\r\n render :nothing => true\r\n end",
"def bulk_delete\n module_ids_string = params[:ids]\n module_ids = eval(module_ids_string)\n\n module_ids.each do |id|\n uni_module = UniModule.find(id.to_i)\n can_delete = true\n if !uni_module.nil?\n\n Group.all.each do |group|\n if group.uni_modules.include?(uni_module)\n can_delete = false\n break\n end\n end\n if can_delete\n uni_module.comments.each do |comment|\n logs = UniModuleLog.all.where(:uni_module_id => uni_module.id)\n if logs.size >0\n logs.each do |log|\n log.destroy\n end\n end\n pflogs = PathwaySearchLog.all.where(:first_mod_id => @uni_module.id)\n if pflogs.size >0\n pflogs.each do |log|\n pflogs.destroy\n end\n end \n pslogs = PathwaySearchLog.all.where(:second_mod_id => @uni_module.id)\n if pslogs.size >0\n pslogs.each do |log|\n pslogs.destroy\n end\n end \n comment.destroy\n end\n uni_module.destroy\n end\n\n end\n #uni_module.update_attribute(\"name\", id)\n\n end\n\n head :no_content\n\n end",
"def delete\n @page = ComatosePage.find params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted page '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end",
"def destroy\n @trackkr_module = TrackkrModule.find(params[:id])\n @trackkr_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(trackkr_modules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_path }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @content_page = ContentPage.find(params[:id])\n @content_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(content_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post_module.destroy\n redirect_to admin_post_modules_url\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def remove_page\n\n @page = Page.find(params[:id])\n @[email protected]\n\n @page.move_to_new_document\n\n end",
"def destroy\n restrict('allow only admins') or begin\n @page = Page.find_by_stub(params[:stub]) || Page.find_by_id(params[:id])\n @page.destroy\n respond_to do |format|\n format.html { redirect_to manage_pages_url }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @page = Page.find(params[:id])\r\n @page.destroy\r\n File.delete(\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\")\r\n respond_to do |format|\r\n format.html { redirect_to pages_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n\n # find the page with with\n @page = Page.find(params[:id])\n\n # calling class method of PagePart model to delete page parts of a page\n PagePart.delete_page_parts(@page)\n\n #destroy the page\n @page.destroy\n\n #sends in data in different format to index action\n respond_to do |format|\n\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n\n end # end respond_to block\n\n end",
"def destroy\n @pagecontent = @page.pagecontents.find(params[:id])\n @pagecontent.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n end\n end",
"def remove_page\n @page = Page.find(params[:id])\n @document = @page.document\n\n @page.move_to_new_document\n\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n redirct_to root_path\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Страница успешно удалена!' }\n format.json { head :no_content }\n end\n end",
"def remove_configuration_product\r\n # node = ProductPackageProduct.find(params[:id].to_i).destroy\r\n # redirect_to :action => \"configuration_products\", :id => node.parent_id\r\n ExampleConfigurationProduct.delete params[:id]\r\n redirect_to :action => \"configuration_products\", :id => params[:id]\r\n end",
"def destroy\n @menutree = Menutree.find(params[:id])\n @menutree.destroy\n\n respond_to do |format|\n format.html { redirect_to(menutrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @pages_dynamic_page = Pages::DynamicPage.find(params[:id])\n @pages_dynamic_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_dynamic_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @oasis_page = OasisPage.find(params[:id])\n @oasis_page.destroy\n\n respond_to do |format|\n format.html { redirect_to oasis_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cd_page = CdPage.find(params[:id])\n @cd_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(cd_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @process_module.destroy\n respond_to do |format|\n format.html { redirect_to process_modules_url, notice: 'Process module was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n removeCredits(@registered_for.module_code)\n @registered_for.destroy\n respond_to do |format|\n flash[:success] = \"Module successfully removed!\"\n format.html { redirect_to modules_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @permiso = Permiso.find(params[:id])\n @permiso.destroy\n\n respond_to do |format|\n format.html { redirect_to(permisos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admined_page1 = AdminedPage1.find(params[:id])\n @admined_page1.destroy\n\n respond_to do |format|\n format.html { redirect_to admined_page1s_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page = @user.pages.find_by_permalink(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend",
"def destroy\n @uni_module = UniModule.find(params[:id])\n can_delete = true\n\n # check if being used\n Group.all.each do |group|\n if group.uni_modules.include?(@uni_module)\n can_delete = false\n break\n end\n end\n\n if can_delete\n @uni_module.comments.each do |comment|\n comment.destroy\n end\n logs = UniModuleLog.all.where(:uni_module_id => @uni_module.id)\n if logs.size >0\n logs.each do |log|\n log.destroy\n end\n end\n pflogs = PathwaySearchLog.all.where(:first_mod_id => @uni_module.id)\n if pflogs.size >0\n pflogs.each do |log|\n log.destroy\n end\n end \n pslogs = PathwaySearchLog.all.where(:second_mod_id => @uni_module.id)\n if pslogs.size >0\n pslogs.each do |log|\n log.destroy\n end\n end \n @uni_module.destroy\n tag_clean_up\n flash[:success] = \"Successfully deleted module\"\n redirect_to admin_uni_modules_path\n else\n flash[:error] = \"This module is linked to a course. You must first either unlink or delete those courses.\"\n redirect_to admin_uni_modules_path\n end\n\n end",
"def destroy\n @forms_menutree = FormsMenutree.find(params[:id])\n @forms_menutree.destroy\n\n respond_to do |format|\n format.html { redirect_to(forms_menutrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n head :no_content\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => 'Die Seite wurde geloescht.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = @chapter.pages.find_by_number(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to manga_chapter_url(@manga, @chapter) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url, :notice => 'The page has vanished.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mod_pag = ModPag.find(params[:id])\n @mod_pag.destroy\n\n respond_to do |format|\n format.html { redirect_to mod_pags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:id])\n\t\t@pages = Page.where(:category => 'group', :owner => @group.id)\n\t\[email protected] do |p|\n\t\t\tp.destroy\n\t\tend\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to groups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end",
"def test_set3_04b_delete_group()\n group = \"test_group\"\n user = \"test_user\"\n \n @test_acl.create_principal(user)\n @test_acl.create_group(group, [\"ALL\"], [user])\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n #puts query\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(1, hits)\n \n @test_acl.delete_principal(group)\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @page = current_site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_site_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub_page = SubPage.find(params[:id])\n @sub_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(sub_pages_url) }\n format.xml { head :ok }\n end\n end",
"def test_remove_page\n file = Configuration.TEST_PAGE\n \n # This test depends on a succesfull login\n if test_correct_login\n token = make_login Configuration.USER, Configuration.PASSWORD\n else\n return false\n end\n \n page_key = 'page-test-' + random_string(Configuration.PAGE_KEY_RS_SIZE)\n \n # This test also depends on a succesfull page creation\n if test_create_page\n post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n else\n return false\n end\n \n res = remove_page page_key, token\n puts \"\\nTester#test_remove_page:\\n#{res}\" if Configuration.VERBOSE \n res == Constants.SUCCESS_MESSAGE\n end",
"def destroy\n begin\n @page = Page.find(params[:id])\n @page.destroy\n redirect_to admin_pages_path, :flash => {:success => \"Page Deleted\"}\n rescue ActiveRecord::RecordNotFound\n redirect_to admin_pages_path, :flash => {:error => \"Page not found\"}\n end\n end",
"def destroy\n @page = Page.friendly.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n if @page.protected\n flash[:error] = t(:page_protected)\n else\n @page.destroy \n flash[:notice] = t(:page_deleted)\n end\n\n respond_to do |format|\n format.html { redirect_back_or_default(admin_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page_fetch = PageFetch.find(params[:id])\n @page_fetch.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_fetches_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n @miscellaneous_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(miscellaneous_children_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ects_module.destroy\n respond_to do |format|\n format.html { redirect_to ects_modules_url, notice: 'ects module was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page_layout = PageLayout.find(params[:id])\n @page_layout.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_layouts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_it_module\n @school_module = SchoolModule.find_by(id: params[:id])\n @school_module.destroy\n redirect_to school_modules_path\n end",
"def destroy\n @structure_page = Structure::Page.find(params[:id])\n @structure_page.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @module_template = ModuleTemplate.find(params[:id])\n @module_template.destroy\n\n respond_to do |format|\n format.html { redirect_to module_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree_node_ac_rights = TreeNodeAcRight.find(params[:id])\n @tree_node_ac_rights.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tree_node_tree_node_permissions_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n @article_list = ArticleList.find(params[:id])\n @page_section = @article_list.page_section\n @article_list.destroy\n \n @page = @page_section.page\n @site_section = @page.site_section\n\n\n respond_to do |format|\n format.html { redirect_to site_section_page_url(@site_section, @page) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @static_page = StaticPage.find(params[:id])\n @static_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(static_pages_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.68101585",
"0.66718405",
"0.6510412",
"0.65000826",
"0.6397475",
"0.6387917",
"0.6375594",
"0.628308",
"0.6280498",
"0.62571305",
"0.62564474",
"0.6247245",
"0.6243638",
"0.6240921",
"0.6230516",
"0.6230036",
"0.62296003",
"0.6206045",
"0.6196667",
"0.614248",
"0.60882574",
"0.60842776",
"0.6081875",
"0.6076031",
"0.6075635",
"0.60375816",
"0.6009053",
"0.60062784",
"0.60020393",
"0.5981207",
"0.59751964",
"0.5960655",
"0.5953331",
"0.5950797",
"0.5948104",
"0.5948104",
"0.59470195",
"0.5942874",
"0.59389883",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5938548",
"0.5933344",
"0.5927798",
"0.5923093",
"0.5921293",
"0.5920692",
"0.5916528",
"0.58961487",
"0.5892134",
"0.58687025",
"0.5867428",
"0.58619887",
"0.5851395",
"0.5850944",
"0.5845998",
"0.58454704",
"0.5840787",
"0.5831664",
"0.5821511",
"0.58138925",
"0.5813128",
"0.580013",
"0.5794092",
"0.57918036",
"0.5785277",
"0.57775134",
"0.5765527",
"0.5759859",
"0.5755539",
"0.57432216",
"0.5739765",
"0.5732415",
"0.5709023",
"0.5705573",
"0.5705512",
"0.57044077",
"0.56974727",
"0.5693653",
"0.5693199",
"0.56771344",
"0.5676767",
"0.56733817",
"0.5672582",
"0.56689674",
"0.5668369",
"0.56666934",
"0.56648135",
"0.56614816",
"0.56592345",
"0.5653662",
"0.5650296",
"0.56487584",
"0.5648044",
"0.56454396"
] | 0.73013556 | 0 |
Equality provided mostly for tests. | def ==(other)
stream == other.stream
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other); false; end",
"def ==(*) end",
"def ==(*) end",
"def ==(*) end",
"def eql?(*) end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==\n end",
"def ==(ct); end",
"def ==(ct); end",
"def equal?(other); end",
"def ===(other); end",
"def eql?(ct); end",
"def eql?(ct); end",
"def ==(other)\n end",
"def test_equals\n result = Person.new(\"Fred\", \"Jones\", 34) == Person.new(\"Fred\", \"Jones\", 34)\n assert_equals(true, result, \"The same person was not found to be equal.\")\nend",
"def test_equality_simple\n value1_ = ::Versionomy.create(:major => 2, :minor => 0, :release_type => :alpha, :alpha_version => 5)\n value2_ = ::Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)\n assert_equal(value2_, value1_)\n assert_equal(value2_.hash, value1_.hash)\n end",
"def ==(*)\n true\n end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(p0) end",
"def eql?(other); self == other; end",
"def test_Complex_InstanceMethods_eql?\n\t\tassert_equal(true, Complex(1,0).eql?(Complex(1,0)))\n\t\tassert_equal(false, Complex(1,0).eql?(Complex(1.0,0)))\n\t\tassert_equal(false, Complex(1,0).eql?(1))\n\t\tassert_equal(true, Complex(1,0) == Complex(1,0))\n\t\tassert_equal(true, Complex(1,0) == Complex(1.0, 0))\n\t\tassert_equal(true, Complex(1,0) == 1)\n\tend",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other); end",
"def eql?(other); end",
"def ==(other)\n super\n end",
"def ==(other)\n super\n end",
"def ==(*several_variants)\n #This is a stub, used for indexing\n end",
"def test_Hash_InstanceMethods_Equality\n\t\th1 = { 'a'=>1, 'c'=>2 }\n\t\th2 = { 7=>35, 'c'=>2, 'a'=>1 }\n\t\th3 = { 'a'=>1, 'c'=>2, 7=>35 }\n\t\th4 = { 'a'=>1, 'd'=>2, 'f'=>35 }\n\t\tassert_equal(false, h1 == h2)\n\t\tassert_equal(true, h2 == h3)\n\t\tassert_equal(false, h3 == h4)\n\tend",
"def same(u, p)\n u == p\nend",
"def are_equal(value1, value2)\n EqualityAssertion.new(value1, value2)\n end",
"def same; end",
"def ==(other)\n raise NotImplementedError\n end",
"def ==(other)\n super\n end",
"def ==(other)\n eql?(other)\n end",
"def ==(other)\n eql?(other)\n end",
"def eql?(other)\n return false\n end",
"def eql?(other)\n self==other\n end",
"def ==(other)\n eq(other.parts)\n end",
"def eq\n @ole.EQ\n end",
"def eql?(other)\n super\n end",
"def eql?(other)\n super\n end",
"def equal?(p0) end",
"def === obj\n #This is a stub, used for indexing\n end",
"def eql?(other)\n\n end",
"def ==(other)\n return false unless super\n true\n end",
"def ==(p0) end",
"def ==(p0) end",
"def ==(p0) end",
"def ==(p0) end",
"def ==(p0) end",
"def ==(p0) end",
"def ==(p0) end",
"def ===(other)\n \treturn self.equal?(other)\n end",
"def equals(one, two)\n matched_by(one, two)\n matched_by(two, one)\n end",
"def eqation(a)\n\nend",
"def ==(other)\n self.to_hash == other.to_hash\n end",
"def ==(other)\n `return self.valueOf() === other.valueOf() ? Qtrue : Qfalse;`\n end",
"def ==(other)\n `return self.valueOf() === other.valueOf() ? Qtrue : Qfalse;`\n end",
"def eql?(other)\n self == other\n end",
"def eql?(other)\n self == other\n end",
"def eql?(other)\n self == other\n end",
"def eql?(other)\n self == other\n end",
"def eq(_obj)\n raise NotImplementedError\n end",
"def ===(other)\n return false unless (self == other)\n end",
"def test_equalcomparison\n a = Grade.new(\"A\")\n anotherA = Grade.new(\"A\")\n assert (a == anotherA) # should return true\n end",
"def same(x, y)\n find(x) == find(y)\n end",
"def ==(other)\n self.class==other.class && self.hash==other.hash\n end",
"def eql?(other)\n\t\tself == other\n\tend",
"def ===(other)\n false\n end",
"def eql?(other)\n `return self == other ? Qtrue : Qfalse;`\n end"
] | [
"0.7498505",
"0.7401098",
"0.7401098",
"0.7401098",
"0.7356036",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73252445",
"0.72681564",
"0.72681564",
"0.7242429",
"0.7151943",
"0.7129185",
"0.7129185",
"0.71187866",
"0.7097068",
"0.70809734",
"0.70727265",
"0.69665444",
"0.69665444",
"0.69665444",
"0.69657636",
"0.69657636",
"0.69657636",
"0.69657636",
"0.6885752",
"0.68729985",
"0.68699414",
"0.68699414",
"0.68699414",
"0.68699414",
"0.68699414",
"0.68699414",
"0.68699414",
"0.6869619",
"0.6869619",
"0.6862282",
"0.6849628",
"0.6809747",
"0.6808142",
"0.6806485",
"0.67947596",
"0.6790551",
"0.6755385",
"0.6755385",
"0.6748145",
"0.6732772",
"0.67317545",
"0.6728852",
"0.67266524",
"0.67266524",
"0.67229915",
"0.67105746",
"0.67089313",
"0.66709256",
"0.6663976",
"0.6663976",
"0.6663976",
"0.6663976",
"0.6663976",
"0.6663976",
"0.6663976",
"0.6658714",
"0.66560966",
"0.66513515",
"0.66469496",
"0.6641387",
"0.6641387",
"0.6629678",
"0.6629678",
"0.6629678",
"0.6629678",
"0.6614961",
"0.6610933",
"0.6610738",
"0.65988684",
"0.65971863",
"0.6571621",
"0.6559769",
"0.6555258"
] | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_digest_notifier.weekly_progress_report.subject | def weekly_progress_report(user)
@greeting = "Hi"
user_email = @user.email
mail to: user_email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject\n 'Report a problem'.freeze\n end",
"def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\n email_subject = \"Payroll report for #{sponsor_name}: #{display_date}\"\n end\n return email_subject\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def message_subject=(value)\n @message_subject = value\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def subject\n @mail.subject\n end",
"def subject\n self['subject']\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def subject=(string)\n set('Subject', string)\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def subject=(value)\n @subject = value\n end",
"def formatted_subject(text)\n name = PersonMailer.global_prefs.app_name\n label = name.blank? ? \"\" : \"[#{name}] \"\n \"#{label}#{text}\"\n end",
"def title_for_user_applied_to_travel\n I18n.t(\"notification.user_applied_to_travel.title\")\n end",
"def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject_name=(value)\n @subject_name = value\n end",
"def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def subject\n title \n end",
"def subject_name\n subject_full_name\n end",
"def subject\n message.subject\n end",
"def subject_name\n return @subject_name\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def alert_subject\n \"Field Statuses Have Changed!\"\n end",
"def subject_titles\n @subject_titles ||= sw_subject_titles\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def setSubject(subject)\n @fields['subject'] = subject\n self\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def course_notification_item_details(course)\n t('notifications.subscribe_course')\n end",
"def notification_mail(reports, staff)\n @reports = reports\n @reports_keys = reports.keys\n \n @first_name = staff.first_name\n @last_name = staff.last_name\t\n\t\n\t# This is an AF kludge...need to revisit\n\tsubject = reports.size > 1 ? \"Radar Digest\" : \"Radar #{reports.first[1][0].display_name} #{reports.first[1][0].tag} (#{reports.first[1][0].staff.name})\"\n \n mail(:to => staff.email, :subject => \"#{subject}: \" + Time.now.to_s(:my_time)) \n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_Subject(value)\n set_input(\"Subject\", value)\n end",
"def set_subject(subject)\n\t\tend",
"def get_subject\n\t\tend",
"def data_subject=(value)\n @data_subject = value\n end",
"def subscription_summary_notice(subscription, actions, user)\n @actions = actions\n @subscription = subscription\n @user = user\n\n return nil if @subscription.user.email.blank?\n mail(:to => @subscription.user.email, :subject => \"SocialStreet #{@subscription.frequency == SearchSubscription.frequencies[:daily] ? 'Daily' : 'Weekly'} Summary - #{subscription.name}\") \n end",
"def weekly_analysis_report(user, analysis_results)\n @user = user\n @analysis_results = analysis_results\n @subject = \"Weekly Report of Analysis for Next Week Events\"\n mail(to: @user.email, subject: @subject)\n end",
"def write_subject\n self.subject ||= self.class.instance_variable_get(\"@job_name\")\n end",
"def SetSubject(subject)\n\t\t#Subject of document\n\t\t@subject = subject\n\tend",
"def subject; @message_impl.getSubject; end",
"def subject\n @subject\n end",
"def subject\n @subject\n end",
"def message_subject\n return @message_subject\n end",
"def subject\n @subject\n end",
"def get_email_subject(email_type)\n email_subject = email_type\n case(email_type)\n when \"welcome\"\n email_subject = \"Welcome to Aspera Files\"\n when \"reset\"\n email_subject = \"Password Reset\"\n end\n return email_subject\n end",
"def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end",
"def get_audit_label\n self.mail\n end",
"def report_title; end",
"def report_title; end",
"def email_subject(form)\n \"#{form.type_of_enquiry} - #{reference}\"\n end",
"def raf_submitted(study_subject)\n#\t\t@greeting = \"Hi\"\n\t\t@study_subject = study_subject\n\n\t\tmail to: \"[email protected]\"\n\t\tmail cc: [\"[email protected]\", \"[email protected]\"]\n\t\tmail subject: \"TEST [CCLS Patient Notification Received] Identifier: #{@study_subject.icf_master_id_to_s}\"\n\tend",
"def weekly\n @greeting = \"Hello\"\n mail subject: args[:subject], to: args[:emails]\n mail to: \"[email protected]\"\n end",
"def subject_names\n @subject_names ||= sw_subject_names\n end",
"def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end",
"def title\r\n fail \"There are no messages yet\" if self.messages.size == 0\r\n\r\n @messages[0].subject.size == 0 ? \"No title\" : @messages[0].subject\r\n end",
"def subject\n raise \"Override #subject in the service class\"\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def title_for_received_review\n I18n.t(\"notification.user_received_review.title\")\n end",
"def trainee_report\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/reports/#{@report.id}\")\n subject = \"[bootcamp] #{@report.user.login_name}さんが日報【 #{@report.title} 】を書きました!\"\n mail to: @user.email, subject: subject\n end",
"def set_title\n @title = t(:message_2, :scope => [:controller, :exams])\n end",
"def subject(*extra)\n subject = \"\"\n subject << \"#{@project.name} | \" if @project\n subject << extra.join(' | ') if extra.present?\n subject\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def notification_msg\n author_name = author.firstname\n \"An issue has been reported by #{author_name}\"\n end",
"def set_title\n @title = t(:message_0, :scope => [:controller, :scholarships])\n end",
"def i18n_scope\n \"exhibits.notifications.order.delivery_confirmation_period_elapsed.#{role}\"\n end",
"def notify_course_teaching_assignment( user , course ) \n @course = course\n @subject = @course.subject \n @school = @subject.school\n @user = user\n mail( :to => user.email, \n :subject => \"potoSchool | Tuga Mengajar pelajaran #{@subject.name}, kelas #{@course.name} \" )\n end",
"def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def subject_with_formatting\n (self.subject.blank?) ? 'N/A' : self.subject\n end",
"def subject\n return @subject\n end",
"def subject\n return @subject\n end",
"def subject\n return @subject\n end",
"def subject\n return @subject\n end",
"def subject\n return @subject\n end",
"def subject\n return @subject\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end",
"def notify(type,subject,target=nil)\n self.notices.create :type => type, :subject => subject, :target => target\n end",
"def subjects_taught_question(school_name:)\n translate(\"student_loans.questions.subjects_taught\", school: school_name, financial_year: StudentLoans.current_financial_year)\n end",
"def subject; end",
"def subject; end",
"def subject; end",
"def subject; end",
"def subject; end",
"def subject; end",
"def subject; end",
"def subject; end"
] | [
"0.63985217",
"0.63680905",
"0.62382925",
"0.622144",
"0.60749763",
"0.60481554",
"0.604445",
"0.6021055",
"0.60129136",
"0.6012118",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.5974092",
"0.59584045",
"0.5956085",
"0.5953197",
"0.59258866",
"0.59257346",
"0.59116524",
"0.58863837",
"0.58585054",
"0.5846943",
"0.58150005",
"0.58112586",
"0.5810663",
"0.5796202",
"0.5792293",
"0.5792293",
"0.5792293",
"0.5792293",
"0.5754676",
"0.5751225",
"0.5740324",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56750226",
"0.56615454",
"0.56539655",
"0.56534505",
"0.5625008",
"0.5621222",
"0.5611419",
"0.5600015",
"0.5597374",
"0.5572611",
"0.5572611",
"0.5552269",
"0.5507769",
"0.5467795",
"0.54559726",
"0.5447106",
"0.54229677",
"0.54229677",
"0.54185975",
"0.5410569",
"0.5409018",
"0.54070115",
"0.54024833",
"0.53809613",
"0.53787756",
"0.5376558",
"0.5370905",
"0.5366517",
"0.5348436",
"0.53360796",
"0.532538",
"0.5323627",
"0.53208816",
"0.5315233",
"0.52862036",
"0.5285071",
"0.52665746",
"0.5262571",
"0.52609193",
"0.52609193",
"0.52609193",
"0.52609193",
"0.52609193",
"0.52609193",
"0.52592796",
"0.5257984",
"0.5247266",
"0.5244861",
"0.5240932",
"0.5240932",
"0.5240932",
"0.5240932",
"0.5240932",
"0.5240932",
"0.5240932",
"0.5240932"
] | 0.5862136 | 24 |
Define el usuario con el usuario actual | def set_current_user
@user = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_usuario\n \n end",
"def set_usuario\n @usuario = Usuario.find_by_email(current_usuario.email)\n end",
"def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(session[:alumno_id]) if session[:alumno_id]\n end",
"def set_usuario\n @user = Usuario.select('id,nombre,apellido,usuario,twitter').find(params[:id])\n end",
"def preencher_usuario2 (nome, sobrenome, email, endereco, universidade, profissao, genero, idade)\n self.nome.set nome\n self.sobrenome.set sobrenome\n self.email.set email\n self.endereco.set endereco\n self.universidade.set universidade\n self.profissao.set profissao\n self.genero.set genero\n self.idade.set idade\n self.btn_criar.click\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 set_user; end",
"def set_user\n\t @usuario = User.find(params[:id])\n\t end",
"def set_usuario\n @user = User.find(params[:id])\n end",
"def usuario= valor\n\t\tusuario_element.send_keys valor\n\tend",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_user\n @form_user = User.new(:email => self.user_email, :first_name => self.user_first_name,\n :last_name => self.user_last_name)\n @user = User.where(:email => self.user_email).first\n @new_user = false\n if @user.nil?\n @new_user = true\n @user = @form_user\n end\n end",
"def set_user(v)\n set_userinfo(v, @password)\n v\n end",
"def set_usuario\n #Rails.logger = Logger.new(STDOUT)\n #logger.debug \"current_usuario \" + current_usuario.inspect\n #logger.debug \"params \" + params.inspect\n \n if (params[:id] == '0')\n params[:id] = current_usuario.id\n end\n\n @usuario = Usuario.find(params[:id]) \n if (@usuario != nil)\n if (current_usuario.id_tipo_usuario == 0 or\n @usuario.id == current_usuario.id)\n else\n @usuario = nil\n end\n end\n end",
"def set_usuario\n @usuario = User.find(params[:id])\n end",
"def set_usuario\r\n @usuario = User.find(params[:id])\r\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 usuario_actual\n\t\tif (id_usuario = session[:id_usuario])\n\t\t\t@usuario_actual ||= Usuario.find_by(id: id_usuario)\n\t\telsif (id_usuario = cookies.signed[:id_usuario])\n\t\t\t#raise # Error provocado para la prueba de test/helpers/sesiones_helper_test.rb\n\t\t\tusuario = Usuario.find_by(id: id_usuario)\n\t\t\tif usuario && usuario.autentificado?(:recuerda, cookies[:token_recuerda])\n\t\t\t\tdar_acceso_a usuario\n\t\t\t\t@usuario_actual = usuario\n\t\t\tend\n\t\tend\n\tend",
"def user_from_omni omni=@omni\n #raise omni.to_yaml\n return User.new(\n :email => omni[:info][:email],\n :name => omni[:info][:name],\n :password => pw=Devise.friendly_token[0,20],\n :password_confirmation => pw\n )\n end",
"def set_user_name_field(user_name)\n end",
"def build_from_current_user!(user)\n self.nombres = user.name\n self.email = user.info[\"email\"]\n end",
"def user=(user)\n self.email = user.email\n self.name = user.name\n end",
"def username\n username = self.name + \" \" + self.email\n\t end",
"def user=(value)\n @user = value\n end",
"def user=(value)\n @user = value\n end",
"def current_user\n User.first || User.create(username: 'mario', surname: 'rossi',email:\"[email protected]\")\n end",
"def user\n @user ||= User.find_or_initialize_by email: @auth.info.email do |user|\n user.name = @auth.info.name\n user.nickname = @auth.info.name.downcase.split(/\\W/).join('.')\n user.password = Devise.friendly_token[0, 20]\n user.role = :reporter\n end\n end",
"def set_usuario\n @usu = Usuario.find(params[:id])\n end",
"def set_create_user_fields\n user_id = AuditModule.get_current_user.uid\n self.created_by = user_id\n self.updated_by = user_id\n end",
"def set_user\n @user = User.select('first_name, last_name, email, username, id').find(params[:id])\n end",
"def current_utilisateur=(utilisateur)\n @current_utilisateur = utilisateur\n end",
"def set_user\n @user = User.find(params[:last_name] || params[:id])\n end",
"def update_user_from_auth(auth)\n user = self\n user.username = auth.info.nickname\n user.avatar_url = auth.info.image\n user.location = auth.extra.raw_info.city\n user.country = auth.extra.raw_info.country\n user.name = auth.info.name\n user\n end",
"def set_user\n @user = User.find_by(name: params[:name]) || current_user\n end",
"def set_username\n self.username = \"#{self.email.split('@').first}#{Faker::Number.number(3)}\"\n end",
"def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end",
"def cria_user\n return if user.present?\n User.create(email: self.end_email, password: '123123', password_confirmation: '123123',\n tb_empregado_id: self.id, e_admin: self.e_admin || false).encrypted_password\n end",
"def author_login=(name)\r\n self.user = User.find_by_login(name)\r\n end",
"def create_user(resource)\n session = Puppet::NetDev::CE::Device.session\n\n set_user_xml = '<rpc><edit-config><target><running/></target><default-operation>merge</default-operation><error-option>rollback-on-error</error-option><config><aaa xmlns=\"http://www.huawei.com/netconf/vrp\" content-version=\"1.0\" format-version=\"1.0\"><lam><users><user operation=\"merge\"><userName>' + (resource[:name]).to_s + '</userName>'\n\n if resource[:password]\n set_user_xml += '<password>' + (resource[:password]).to_s + '</password>'\n end\n\n set_user_xml += '</user></users></lam></aaa></config></edit-config></rpc>'\n\n session.rpc.do_config(set_user_xml)\n end",
"def user=(value)\n conf['api']['user'] = value\n end",
"def set_user\n # @user = User.find_by_name create_params[:user_name]\n @user = User.find_by_name session_params[:user_name]\n end",
"def login_user(user = User.create!(email: '[email protected]', password: '123456'))\n \tlogin_as user, scope: :user\n user\n end",
"def make_user\n end",
"def set_user\n @user = @current_user.admin ? User.find(params['id']) : @current_user\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def set_usuario\n @usuario = Usuario.find(params[:id])\n end",
"def user(value = nil)\n value ? @user = value : @user\n end",
"def user_name_set(name)\n self.username.set name if nil_or_empty?(username[:value])\n end",
"def setup_user\n User.new( \n age: 5,\n bio: \"My test bio\",\n password: SecureRandom.hex(6),\n email: SecureRandom.hex(4) + \"@example.com\",\n picture: \"blah.jpg\",\n sex: \"M\",\n username: SecureRandom.hex(4)\n )\n end",
"def set_userinfo(user, password = nil)\n unless password\n user, password = split_userinfo(user)\n end\n @user = user\n @password = password if password\n\n [@user, @password]\n end",
"def creador\n\t\tusuario\n\tend",
"def set_usuario\n @usuario = Usuario.find(params[:celular])\n params[:area] = @usuario.celular.to_s[0,4]\n params[:numero] = @usuario.celular.to_s[4,10]\n end",
"def set_user\n if self.current_user and self.current_user.name == 'admin'\n @user = User.find(params[:id])\n else\n @user = User.find(current_user.id)\n end\n end",
"def set_user\n UserInfo.current_user = session[:user]\n end",
"def set_utilisateur\n @utilisateur = Utilisateur.find(params[:id])\n end",
"def assign_real_user\n if ( hubssolib_logged_in? && @current_user.nil? )\n\n email = hubssolib_get_user_address()\n name = hubssolib_unique_name()\n roles = hubssolib_get_user_roles()\n\n # Not internationalised since these are Should Never Happen exceptions\n # and in production mode, all the user would see is a 500 error.\n\n raise \"Current Hub user appears to have no e-mail address\" if ( email.nil? )\n raise \"Current Hub user's name is unkonwn\" if ( name.nil? )\n raise \"Current Hub user's roles are unknown\" if ( roles.nil? )\n\n user = User.find_by_email( email ) # Want to associate payments by e-mail address\n # since that's the primary association for e.g.\n # PayPal, even though we're also using a human\n # readable person's name that's been made\n # unique by Hub adding the Hub user ID to it.\n\n if ( user.nil? )\n user = User.new\n user.email = email\n user.name = name\n user.admin = roles.include?( :admin ) || roles.include?( :webmaster )\n user.save!\n end\n\n @current_user = user\n else\n @current_user = nil\n end\n\n return @current_user\n end",
"def originator\n self.user ? self.user.name : NOT_SET\n end",
"def set_usuario\n #if UsuarioUsuario.find(params[:id]).exists?\n @usuario = Usuario.find(params[:id])\n #else\n # @usuario = Nil\n #end\n end",
"def set_user\n # @user = User.find(params[:id])\n @user = User.find_by_sql(['SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = ? LIMIT 1', params[:id]])[0]\n end",
"def set_user\n @user = User.find(params[:id]).decorate\n\n end",
"def set_user\n \t#to do\n \t#if cookie authentication_token type facebook\n\n \t#elsif cookie authentication_token type email\n\n \t#end\n \t\t\n \t@user = User.find_by(authentication_token: request.headers['Authorization'])\n end",
"def getUsuario\n\t\treturn @usuario\n\tend",
"def user_instance(username)\n User.new(new_username: username, forename: 'forename', surname: 'surname',\n email_address: '[email protected]', email_address_confirmation: '[email protected]',\n new_password: 'P@ssword001', new_password_confirmation: 'P@ssword001',\n user_is_current: 'Y')\n end",
"def set_usuario\n @usuario = Usuario.where(idUsuario: params[:id])\n end",
"def user=(value)\n conf['dashboard']['user'] = value\n end",
"def current_user\n current_usuario\n end",
"def sync_username\n if self.username.to_s.blank? and !self.email.to_s.blank?\n self.username = self.email\n end\n end",
"def usuario_params\n \n end",
"def set_user\n @cUser = current_user\n puts \"***#{@cUser}\"\n end",
"def user=(usr)\n raise 'You must pass a User class' unless usr.is_a?(User)\n @user = usr\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 set_user\n @user = User.find_by(auth0_id: auth_token[0]['sub'])\n end",
"def set_user\n @user = User.find_by_external_id(params[:id])\n @user = User.create!(name: params[:name], email: params[:email], external_id: params[:external_id]) unless @user\n end",
"def new_username=(value)\n @new_username = (value.nil? ? value : value.upcase)\n end",
"def make_user(params = {})\n self.user= account.users.build_with_fields params.reverse_merge(:email => email, :invitation => self)\n end",
"def set_user\n zeus = User.find(@zeus_user.id)\n zeus.state = User.states['retrieved_password']\n zeus.save!\n \n request.session[:rbac_user_id] = @zeus_user.id\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def setUserField(userName, fieldName, fieldValue)\n\n if userName != nil && fieldName != \"password\"\n user = loadUser(userName)\n user[fieldName] = fieldValue\n saveUser(userName, user)\n end\n end",
"def comprobar_usuario_login\n @usuario_actual=nil\n return unless session[:user_id]\n @usuario_actual = Usuario.find_by_id(session[:user_id])\n end",
"def set_user\n @user = current_agent.users.where('users.username = ?', params[:id]).first\n end"
] | [
"0.7737487",
"0.69332933",
"0.6925791",
"0.6906926",
"0.6869586",
"0.6801229",
"0.67418927",
"0.66249955",
"0.6600067",
"0.65694207",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543413",
"0.6519364",
"0.6505991",
"0.6480298",
"0.64791155",
"0.6467876",
"0.6454887",
"0.64546835",
"0.6415089",
"0.6414043",
"0.6411888",
"0.64031744",
"0.6377616",
"0.6365649",
"0.6365649",
"0.6359581",
"0.6352816",
"0.63526237",
"0.63439614",
"0.6332436",
"0.6326488",
"0.6309256",
"0.63017523",
"0.628817",
"0.62759215",
"0.6258799",
"0.6258497",
"0.62569433",
"0.6255248",
"0.6252699",
"0.62344223",
"0.62226504",
"0.6220548",
"0.6180156",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61791545",
"0.61691874",
"0.61664957",
"0.6164273",
"0.6152375",
"0.61510766",
"0.61431414",
"0.6142089",
"0.61401534",
"0.6125342",
"0.6119762",
"0.6117189",
"0.61169785",
"0.6111303",
"0.61047727",
"0.6104678",
"0.6082183",
"0.6079652",
"0.6079072",
"0.60693735",
"0.6068129",
"0.6065368",
"0.6060242",
"0.60600924",
"0.60583645",
"0.6057796",
"0.6056961",
"0.60561",
"0.60431623",
"0.603894",
"0.603179",
"0.60310966",
"0.60307026",
"0.6025054",
"0.6024573"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def image_create_params
params.require(:user).permit(images_attributes: [:title, :description, :image, :imageable])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.6291174",
"0.62905735",
"0.6283171",
"0.6242344",
"0.62403613",
"0.6218049",
"0.62143815",
"0.62104696",
"0.61949855",
"0.6178671",
"0.6176147",
"0.6173327",
"0.6163395",
"0.6153005",
"0.6151833",
"0.6147288",
"0.61224324",
"0.6118827",
"0.61075264",
"0.61054534",
"0.6092497",
"0.6080082",
"0.60710967",
"0.60627776",
"0.60219413",
"0.60175914",
"0.60153484",
"0.60107356",
"0.60081726",
"0.60081726",
"0.60013986",
"0.6000165",
"0.59978646",
"0.59936947",
"0.59925723",
"0.5992084",
"0.59796256",
"0.5967569",
"0.5960056",
"0.59589803",
"0.5958441",
"0.5958401",
"0.5952607",
"0.5952406",
"0.5944409",
"0.59391016",
"0.593842",
"0.593842",
"0.5933845",
"0.59312123",
"0.5926475",
"0.59248453",
"0.59179676",
"0.59109294",
"0.59101623",
"0.5908172",
"0.59058356",
"0.5899052",
"0.5897749",
"0.5896101",
"0.58942914",
"0.58939576",
"0.5892063",
"0.5887407",
"0.588292",
"0.58797663",
"0.587367",
"0.58681566",
"0.5868038",
"0.5866578",
"0.58665025",
"0.58655846",
"0.58640826",
"0.5863465",
"0.5862226",
"0.586065",
"0.58581287",
"0.5854443",
"0.5854172",
"0.58507544",
"0.5849934"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def image_params
params.require(:image).permit(:title, :description, :image, :_destroy)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289145",
"0.62875307",
"0.6280997",
"0.62420976",
"0.62388235",
"0.6216686",
"0.62122375",
"0.6208949",
"0.619173",
"0.6176307",
"0.6173907",
"0.6170346",
"0.616111",
"0.6150513",
"0.6150023",
"0.61446756",
"0.6120429",
"0.6112975",
"0.6104845",
"0.6102966",
"0.6087884",
"0.6079323",
"0.60699135",
"0.60602236",
"0.60191786",
"0.60170597",
"0.60100305",
"0.6009527",
"0.60052776",
"0.60052776",
"0.600042",
"0.5999317",
"0.59933805",
"0.5991528",
"0.5991221",
"0.5990094",
"0.5979497",
"0.5966058",
"0.5958738",
"0.59579456",
"0.5957759",
"0.5956938",
"0.5951788",
"0.59511644",
"0.59423065",
"0.59373474",
"0.59361076",
"0.59361076",
"0.59331447",
"0.5928005",
"0.5924882",
"0.5924011",
"0.59169155",
"0.5908037",
"0.5907541",
"0.59061426",
"0.59056246",
"0.5897408",
"0.58960444",
"0.58951247",
"0.5893136",
"0.5892312",
"0.5890385",
"0.58853275",
"0.58801144",
"0.58784765",
"0.5872648",
"0.58682626",
"0.5867028",
"0.58661693",
"0.586578",
"0.58643955",
"0.5863193",
"0.58609086",
"0.5859997",
"0.5858935",
"0.5858632",
"0.5853379",
"0.5852741",
"0.584806",
"0.5847703"
] | 0.0 | -1 |
==== Options options :column_width Width (in pixels) of current grid column :gutter_width Width (in pixels) of current grid gutter :output_path Output path of grid.png file | def initialize(options={})
@able_to_generate = Magick::Long_version rescue false
return unless @able_to_generate
@column_width = options[:column_width] || Blueprint::COLUMN_WIDTH
@gutter_width = options[:gutter_width] || Blueprint::GUTTER_WIDTH
@output_path = options[:output_path] || Blueprint::SOURCE_PATH
@baseline_height = (options[:font_size] || Blueprint::FONT_SIZE) * 1.5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate!\n total_width = self.column_width + self.gutter_width\n height = @baseline_height\n RVG::dpi = 100\n\n width_in_inches = (total_width.to_f/RVG::dpi).in\n height_in_inches = (height.to_f/RVG::dpi).in\n rvg = RVG.new(width_in_inches, height_in_inches).viewbox(0, 0, total_width, height) do |canvas|\n canvas.background_fill = \"white\"\n end\n\n white = ChunkyPNG::Color.from_hex(\"ffffff\")\n background = ChunkyPNG::Color.from_hex(\"e8effb\")\n line = ChunkyPNG::Color.from_hex(\"e9e9e9\")\n\n png = ChunkyPNG::Image.new(total_width, height, white)\n png.rect(0, 0, column_width - 1, height, background, background)\n png.rect(0, height - 1, total_width, height - 1, line, line)\n\n FileUtils.mkdir(self.output_path) unless File.exists?(self.output_path)\n png.save(File.join(self.output_path, \"grid.png\"))\n end",
"def grid_image\n s = ''\n s << \" %s %s %s \\n\" % [own(256), own(128), own(64)]\n s << \" %s %s %s \\n\" % [own(32), own(16), own(8)]\n s << \" %s %s %s \\n\" % [own(4), own(2), own(1)]\n s\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 draw_grid\n print_cap\n (0...@vertical).each do |vert_index|\n (0..@v_size).each do |block_height|\n (0...@horizontal).each do |horizontal_index|\n if block_height == (@v_size/2)\n print \"|\" + \" \"*(@h_size/2)\n \"#{print @contents[horizontal_index][vert_index]}|\"\n print \" \"*(@h_size/2-1)\n else\n print \"|\"; print \" \"*@h_size\n end\n end\n print \"|\\n\" \n \n end\n print_cap\n end\n end",
"def display_grid\n # variables for grid display\n @grid = \" A B C \\n\" \\\n \"1 #{@a1} | #{@b1} | #{@c1} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"2 #{@a2} | #{@b2} | #{@c2} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"3 #{@a3} | #{@b3} | #{@c3} \\n\"\n end",
"def grid\n @grid ||= if @opts.key? \"grid\"\n @opts.slice(\"grid\", \",\")\n else\n %w[0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%]\n end\n end",
"def gridhelper ()\n $helper = \"\"\n $g = 0\n items = MEASURES\n $LEN = items.length\n $parsed = 0\n\n until $g == $LEN\n $TYPE = items[$g]['TYPE']\n if $g == 0\n $NAME = \"default\"\n else\n $NAME = \"$bp-\" + items[$g]['NAME']\n end\n $FROM = items[$g]['FROM']\n $COLS = items[$g]['COLS']\n $FLUID = items[$g]['FLUID']\n $RATIOPREGOLDEN = items[$g]['RATIOPREGOLDEN']\n $GOLDEN = items[$g]['GOLDEN']\n $RATIO = $RATIOPREGOLDEN * $GOLDEN\n $COLW = items[$g]['COLW']\n $GUTW = items[$g]['GUTW']\n $MAXW = items[$g]['MAXW']\n $COLBG = items[$g]['COLBG']\n\n \n if $TYPE == \"grid_bp\"\n $helper += \"\\n/* %s GRID */\" % [$NAME]\n $helper += \"\\n@media (min-width: #$FROM){\"\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n $GUTW = \"cal(100%/(#$COLS+(#$COLS*#$RATIO)))\"\n $MRGW = \"cal(50%/(#$COLS+(#$COLS*#$RATIO)))\"\n $COLW = \"cal(100%*#$RATIO/(#$COLS+(#$COLS*#$RATIO)))\" \n\n else \n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n $MRGW = \"cal(#$GUTW/2)\"\n end\n $helper += \"\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n width: #$COLW;\n margin: 0 #$MRGW;\n }\n #grid div.vert.first-line {\n margin-left: #$MRGW;\n }\n #grid div.vert.cols#$COLS { /* this grid uses #$COLS cols */\n margin-right: 0;\n }\n \"\n if $parsed > 0\n $target = $parsed - 1\n $PREVCOLS = getPreviousGridCols ( $target )\n\n $helper += \"\n #grid div.vert.cols#$PREVCOLS { /* reset previous #$PREVCOLS cols grid */\n margin-right: #$MRGW;\n }\n \"\n end\n $helper += \"\\n}\"\n\n $parsed += 1\n else\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n\n else\n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n end\n $helper += \"\n /* extra breakpoint */\n @media (min-width: #$FROM){\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n }\n }\n \"\n end\n $g += 1\n end\n\nreturn $helper\nend",
"def printGrid(number_of_pieces)\n size = number_of_pieces.to_s.length\n print_horizontal_line((size+1) * @width + 1)\n \n (@height - 1).downto(0) do |hIdx|\n print '|'\n @width.times do |wIdx|\n print fixed_string(@grid[wIdx][hIdx].to_s, size)\n print ' ' if wIdx < @width - 1\n end\n print '|'\n print \"\\n\"\n end\n \n print_horizontal_line((size+1) * @width + 1)\n end",
"def console_grid\n i = self.height\n grid.map do |row|\n puts row.map { |cell| \"[#{cell.value.empty? ? \"_\" : cell.value}]\" }.join(\"\") + \" #{i}\"\n i-=1\n end\n end",
"def print_grid\n puts \"Generation: #{@generation}\"\n @width.times do |x|\n @height.times do |y|\n print \"#{@current_generation[x][y]}\" + \" \"\n end\n puts\n end\n puts \"-------------------------------------------------\"\n end",
"def saveGrid(file)\n\t\tdata = @rows.to_s + ' ' + @cols.to_s\n\t\tfor n in (0...@rows) \n\t\t\tfor m in (0...@cols) \n\t\t\t\tdata += (' ')\n\t\t\t\tdata += (@grid[n][m].to_s)\n end\n end\n\t\tdata += \"\\n\"\n\t\tIO.write(file, data)\n\tend",
"def print_grid # prints 3 X 3 grid with values\n puts \"\\n\"\n @grid.each_slice(3) { |row| puts row.join(' | ') }\n puts \"\\n\"\n end",
"def print_grid\n rows = @grid.map do |row|\n row.join(\" \")\n end\n print rows.join(\"\\n\")\n end",
"def show\n 1.upto(width).each { |x| print \" \" + \"#{x}\"}\n print \"\\n\"\n\n grid.each_with_index do |row, index|\n print \"#{index + 1} #{row} \\n\"\n end\n end",
"def display_maze_with_png(grid)\n \nend",
"def render\n puts \"-------------------------------------\"\n @grid.each do |row| \n puts \"| \" + row.map(&:to_s).join(\" | \") + \" |\"\n puts \"-------------------------------------\"\n end\n end",
"def draw_grid(value)\n\t#makes an empty image\n\tgrid = Image.new(TW_SQUARE_SIZE*5, TW_SQUARE_SIZE*5) {self.background_color = \"white\"}\n\t#this draws things\n\tsquares = Magick::Draw.new\n\t#sets the color based on the current value\n\tr, g, b = get_colors(value)\n\tsquares.fill(\"rgb(#{r}, #{g}, #{b})\")\n\n\t#iterates through the value\n\tfor i in 0...5\n\t\tfor j in 0...5\n\t\t\t#checking if each digit is a one or zero\n\t\t\tif value & 2 ** (j + i*5) != 0\n\t\t\t\t#if it's a zero, it draws a square after passing it through the scrambler\n\t\t\t\tx = $scramble[i][j] % 5\n\t\t\t\ty = ($scramble[i][j] - x) / 5\n\t\t\t\tsquares.rectangle(TW_SQUARE_SIZE*x, TW_SQUARE_SIZE*y, TW_SQUARE_SIZE*(x+1), TW_SQUARE_SIZE*(y+1))\n\t\t\tend\n\t\tend\n\tend\n\t#puts all the squares in the empty image\n\tsquares.draw(grid)\n\t#sets the file name\n\tfile_name = \"grid#{value}.png\"\n\t#draws it and saves it\n\tgrid.write(file_name)\n\t#return a file path\n\treturn file_name\nend",
"def cheat\n Board.print_grid(@grid)\n end",
"def draw\n @grid.each do |row|\n puts row.map{|cell|\n cell.to_s\n }.join(\"\")\n end\n end",
"def display\n p \"#{@grid[0..2].join(\" | \")}\"\n p \"--|---|--\"\n p \"#{@grid[3..5].join(\" | \")}\"\n p \"--|---|--\"\n p \"#{@grid[6..8].join(\" | \")}\"\n\n end",
"def draw\n\t\t#\n\t\t# Draw the \"top\" line.\n\t\t#\n\t\tputs \" \" + \"_\" * (@width * 2 - 1)\n\t\n\t\t#\t\n\t\t# Draw each of the rows.\n\t\t#\n\t\[email protected] do |y|\n\t\t\tprint \"|\"\n\t\t\[email protected] do |x|\n\t\t\t\t# render \"bottom\" using \"S\" switch\n\t\t\t\tprint( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t\n\t\t\t\t# render \"side\" using \"E\" switch\t\n\t\t\t\tif @grid[y][x] & @@E != 0\n\t\t\t\t\tprint( ( ( @grid[y][x] | @grid[y][x+1] ) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t\telse\n\t\t\t\t\tprint \"|\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\t# \n\t\t# Output metadata\n\t\t#\n\t\tputs metadata\n\tend",
"def print\n puts \"\"\n puts \"\"\n puts \"Generation #{@generation}\"\n puts \"#{@grid.rows} x #{@grid.cols}\"\n @grid.print()\n end",
"def print_grid\n self.print_head\n puts $line_break\n i = 0\n grid.each do |row|\n printable_row = []\n row.each do |cell|\n printable_row << cell[:display]\n end\n row_string = printable_row.join(\" | \")\n puts \"## #{$abc[i].upcase} #{row_string} ##\"\n # puts \"## #{row_string} ##\"\n puts \"##\" + \"------\" + \"+----\" * 9 + \"##\"\n i += 1\n end\n bottom_row = []\n l = 0\n 10.times do\n bottom_row << \" #{l} \"\n l += 1\n end\n print_row = bottom_row.join(\"|\")\n puts \"## #{print_row}##\"\n puts $line_break\n end",
"def render\n system(\"clear\")\n puts \" #{(0...size).to_a.join(\" \")}\"\n @grid.each_with_index do |row, i|\n puts \"#{i} #{row.join(\" \")}\"\n end\n end",
"def print_grid\n for i in 0..@height-1\n for j in 0..@width-1\n print @grid[i][j]\n print \" \"\n end\n print \"\\n\"\n end\n end",
"def print_grid grid = @grid\n puts (('+-' * grid.first.length) + '+').black\n @y.times do |y|\n @x.times do |x|\n print '|'.black\n print text_representation(grid[x][y])\n end\n print '|'.black\n puts (\"\\n\" + ('+-' * grid[y].length) + '+').black\n end\n end",
"def display_grid\n system(\"clear\")\n grid_font = TTY::Font.new(:doom)\n grid_title = Pastel.new\n puts grid_title.cyan.bold(grid_font.write(\"GRID\", letter_spacing: 2))\n grid = []\n CSV.foreach(\"grid.csv\", headers: true).select { |row| \n grid << [row[\"title\"], row[\"description\"], row[\"code snippet\"]]\n }\n grid_table = TTY::Table.new([\"Title\",\"Description\",\"Code Snippet\"], grid)\n puts grid_table.render(:unicode, multiline: true, alignments: [:left, :left], padding:[1,1])\nend",
"def render\n\t\tprint \"cl1 cl2 cl3 cl4 cl5 cl6 cl7 cl8 cl9 c10\\n\"\n\t\t(0..9).each do |row|\n\t\t\t(0..9).each do |col|\n\t\t\t\tif @grid[row][col].is_flagged\n\t\t\t\t\tprint \"FLG\"\n\t\t\t\telsif @grid[row][col].is_hidden\n\t\t\t\t\tprint \" \"\n\t\t\t\telsif @grid[row][col].surrounding_bombs > 0\n\t\t\t\t\tprint \" #{@grid[row][col].surrounding_bombs} \"\n\t\t\t\telsif @grid[row][col].has_bomb\n\t\t\t\t\tprint \"POW\"\t\t\t\t\t\n\t\t\t\telse print \"xxx\"\n\t\t\t\tend\n\t\t\t\tprint \"|\" unless col == 9\n\t\t\t\tprint \"row#{row + 1}\\n\" if col == 9\n\t\t\tend\n\t\tend\n\tend",
"def print_grid\n @grid.each do |arr|\n puts arr.join(\" \")\n end\n end",
"def render\r\n # puts \"\\e[H\\e[2J\"\r\n\r\n values = @grid\r\n puts \" 0 1 2 3 4 5 6 7 8\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n values.each_with_index do |row, idx|\r\n print \" #{idx} |\".light_black\r\n row.each_with_index do |value, idx|\r\n if idx >= 1\r\n print \"|\".light_black\r\n end\r\n # color coding output to cells\r\n if \" #{value} \".match?(/[0]/) # no values printed for open spaces\r\n print \" \"\r\n elsif value.is_a? String # values changed by player are printed in yellow\r\n print \" #{value} \".yellow\r\n else\r\n print \" #{value} \".light_blue # OG values are printed in blue\r\n end\r\n end\r\n print \"|\\n\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n end\r\n puts # adds newline at end of board\r\n end",
"def div_gutter\n div :class => \"column span-1\" do \n nbsp\n end\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.width).map { |x| shifted_vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n outputs.lines << (0..grid.height).map { |y| shifted_horizontal_line(y) }\n end",
"def render_grid(grid)\n grid.output_buffer.html_safe\n end",
"def render_gridlines_if_needed args\n if args.state.show_gridlines && args.static_lines.length == 0\n args.static_lines << 65.times.map do |i|\n [\n [CENTER_OFFSET + i * TINY_SCALE + 1, 0,\n CENTER_OFFSET + i * TINY_SCALE + 1, 720, 128, 128, 128],\n [CENTER_OFFSET + i * TINY_SCALE, 0,\n CENTER_OFFSET + i * TINY_SCALE, 720, 128, 128, 128],\n [CENTER_OFFSET, 0 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 0 + i * TINY_SCALE, 128, 128, 128],\n [CENTER_OFFSET, 1 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 1 + i * TINY_SCALE, 128, 128, 128]\n ]\n end\n elsif !args.state.show_gridlines\n args.static_lines.clear\n end\nend",
"def grid; @parameters['GRiD']; end",
"def print_board(title, generation, board, scale = 4)\n png = ChunkyPNG::Image.new(board.length * scale, board[0].length * scale, ChunkyPNG::Color('black @ 1.0'))\n board.each_with_index do |row, h|\n row.each_with_index do |cell, w|\n (0...scale).each do |ph|\n (0...scale).each do |pw|\n png[(h * scale) + ph, (w * scale) + pw] = (board[h][w] == 1 ? ChunkyPNG::Color('red @ 1.0') : ChunkyPNG::Color('blue @ 1.0'))\n end\n end\n end\n end\n png.save(\"./output/#{title}/frame_#{generation.to_s.rjust(4, \"0\")}.png\",\n :color_mode => ChunkyPNG::COLOR_INDEXED,\n :compression => Zlib::NO_COMPRESSION,\n :interlace => true)\nend",
"def render\n puts \" #{(0..8).to_a.join(\" \")}\"\n grid.each_with_index do |row, i|\n arr = []\n row.each do |tile|\n if tile.revealed == true\n arr << tile.display_value\n elsif tile.flagged == true\n arr << \"F\"\n else\n arr << \"*\"\n end\n end\n\n puts \"#{i} #{arr.join(\" \")}\"\n end\n end",
"def print\n grid_array = []\n @height.times do |r|\n grid_array << @grid[r * @width, @width].split('') * ' '\n end\n grid_array\n end",
"def display\n grid.each { |line| p line }\n end",
"def draw_and_save_image\n\t\tcolor = @avatar[:color]\n\t\tpng = ChunkyPNG::Image.new(250, 250, ChunkyPNG::Color::WHITE)\n\t\tcolor = ChunkyPNG::Color.rgba(color[:r], color[:g], color[:b], color[:alpha])\n\t\t@colorable_grid.each do |points|\n\t\t\tp1 = points[0]\n\t\t\tp2 = points[1]\n\t\t\tpng.rect(p1[0], p1[1], p2[0], p2[1] , color, color)\n\t\tend\n\t\tpng.save(File.join(Dir.pwd, \"/#{@term}.png\"), :interlace => true)\n\tend",
"def namespace\n 'grid_' + @num_cols.to_s + '_' + @col_width.to_s + '_' + @gutter.to_s\n end",
"def demoExplorerSmallIcons(t)\n demoExplorerList(t)\n t.configure(:orient=>:horizontal, :xscrollincrement=>0)\n t.column_configure(0, :width=>'', :stepwidth=>110, :widthhack=>false)\nend",
"def grid(path, rows=10, cols=10)\n push\n rows.times do |row|\n tx = (row+1) * (self.height / rows) - (self.height / rows) / 2\n cols.times do |col|\n ty = (col+1) * (self.width / cols) - (self.width / cols) / 2\n push\n translate(tx, ty)\n draw(path)\n pop\n end\n end\n pop\n end",
"def display(i,j)\n \t print \"\\e[H\"\n\t puts \" \" + \"_\" * (@width * 2 - 1)\n\t \n\t @grid.each_with_index do |row,y|\n\t print \"|\"\n\t\t row.each_with_index do |cell,x|\n\t\t # \n\t\t\t # Color gray if empty, red if \"current\" cursor\n\t\t\t #\n\t\t\t if cell == 0\n\t\t\t print \"\\e[47m\" \n\t\t\t elsif x == i and y == j\n \t\t\t print \"\\e[41m\"\n\t\t\t end\n\n\t\t\t # render \"bottom\" using \"S\" switch\n\t\t\t print( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t \n\t\t\t # render \"side\" using \"E\" switch\n\t\t\t if @grid[y][x] & @@E != 0\n\t\t\t print( ( ( @grid[y][x] | @grid[y][x+1] ) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t else\n\t\t\t print \"|\"\n\t\t\t end\n\n\t\t\t # \n\t\t\t # Stop coloring\n\t\t\t #\n\t\t\t if cell == 0 or ( x == i and y == j )\n\t\t\t print \"\\e[m\" \n\t\t\t end\n\t\t end\n\t\t puts\n\t end\n\tend",
"def display_print\n @grid.each_with_index do |row, row_idx|\n row.each_with_index do |element, column_idx|\n separator = (column_idx % 3 == 2) ? \" \" : \" \"\n print element.to_s + separator\n end\n puts\n puts if (row_idx % 3 == 2)\n end\n nil\n end",
"def draw_grid(line_width,mosaic=true,r=220,g=220,b=220,alpha=100)\n # Draw mosaic */\n if (mosaic)\n layer_width = @g_area_x2-@g_area_x1\n layer_height = @g_area_y2-@g_area_y1\n\n @layers[0] = image_create_true_color(layer_width,layer_height)\n #c_white = allocate_color(@layers[0],255,255,255)\n image_filled_rectangle(@layers[0],0,0,layer_width,layer_height,255,255,255)\n image_color_transparent(@layers[0],255,255,255)\n\n #c_rectangle =allocate_color(@layers[0],250,250,250)\n\n y_pos = layer_height #@g_area_y2-1\n last_y = y_pos\n i =0\n while(i<=@division_count)\n last_y= y_pos\n y_pos = y_pos - @division_height\n y_pos = 1 if ( y_pos <= 0 )\n image_filled_rectangle(@layers[0],1, y_pos,layer_width-1,last_y,250,250,250) if ( i % 2 == 0 )\n i = i+1\n end\n\n image_copy_merge(@layers[0],@picture,@g_area_x1,@g_area_y1,0,0,layer_width,layer_height,alpha)\n #image_destroy(@layers[0])\n\n end\n\n #Horizontal lines\n y_pos = @g_area_y2 - @division_height\n i=1\n while(i<=@division_count)\n self.draw_dotted_line(@g_area_x1,y_pos,@g_area_x2,y_pos,line_width,r,g,b) if ( y_pos > @g_area_y1 && y_pos < @g_area_y2 )\n y_pos = y_pos - @division_height\n i = i+1\n end\n # Vertical lines\n if (@g_area_x_offset == 0 )\n x_pos = @g_area_x1 + (@division_width) +@g_area_x_offset\n col_count = (@data_count.to_f-2).floor\n else\n\n x_pos = @g_area_x1 +@g_area_x_offset\n col_count = ( (@g_area_x2 - @g_area_x1) / @division_width )\n end\n i= 1\n\n while (i<=col_count)\n if ( x_pos > @g_area_x1 && x_pos < @g_area_x2 )\n self.draw_dotted_line((x_pos).floor,@g_area_y1,(x_pos).floor,@g_area_y2,line_width,r,g,b)\n end\n x_pos = x_pos + @division_width\n i= i+1\n end\n end",
"def formatted_grid\n grid.each do |row|\n puts row.map { |cell| cell.value.empty? ? \"_\" : cell.value }.join(\" \")\n end\n end",
"def print_grid\n @grid.each do |row|\n row.each do |cell|\n if cell == 'X'\n print(cell.red)\n else\n print(cell)\n end\n end\n print(\"\\n\")\n end\n end",
"def draw\n\t\t#\n\t\t# Draw the \"top\" line.\n\t\t#\n\t\tputs \" \" + \"_\" * (@width * 2 - 1)\n\t\n\t\t#\t\n\t\t# Draw each of the rows.\n\t\t#\n\t\[email protected] do |y|\n\t\t\tprint \"|\"\n\t\t\[email protected] do |x|\n\t\t\t\t# render \"bottom\" using \"S\" switch\n\t\t\t\tprint( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t\n\t\t\t\t# render \"side\" using \"E\" switch\t\n\t\t\t\tif @grid[y][x] & @@E != 0\n\t\t\t\t\tprint( ( (@grid[y][x] | @grid[y][x+1]) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t\telse\n\t\t\t\t\tprint \"|\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\t#\t\n\t\t# Output maze metadata.\n\t\t#\n\t\tputs metadata\n\tend",
"def build_grid\n header = [\" \", \" a \", \" b \", \" c \", \" d \", \" e \", \" f \", \" g \", \" h \"]\n grid_display = @board.grid.map.with_index do |row, index|\n [8 - index] + build_row(row, index)\n end\n grid_display.unshift(header)\n end",
"def draw_image(data, row_number, digit)\n size = 28\n png = ChunkyPNG::Image.new(size, size, ChunkyPNG::Color::WHITE)\n data.each_with_index do |value, index|\n png[index % size, index / size] = ChunkyPNG::Color.rgb(255 - value.to_i, 255 - value.to_i, 255 - value.to_i)\n end\n png.save(\"images/#{digit}/digit_row_#{row_number}.png\", interlace: true)\nend",
"def render\n print \" #{(1..9).to_a.join(\" \")}\".light_green.bold\n puts\n puts\n @grid.each.with_index do | row, row_indx |\n print \"#{row_indx + 1} \".light_green.bold\n row.each do | tile |\n if tile.revealed\n print \"#{VALUE_EMOJIS[tile.value]} \"\n elsif tile.flagged\n print \"#{FLAG} \"\n else \n print \"#{HIDDEN} \"\n end\n end\n puts\n puts\n end\n end",
"def draw_file(col)\n ''\n end",
"def draw_grid_square(x,y,color,z,padding=0,xmargin=@xmargin,ymargin=@ymargin)\n super\n end",
"def render_board\n\n\t\t# So, we'll rebuild the render target from scratch\n\t\t(0...@height).each do |row|\n\t\t\t(0...@width).each do |col|\n\n\t\t\t\t# Save myself some typing, and some math cycles...\n\t\t\t\tcell_idx = (row*@width)+col\n\n\t\t\t\t# Check to see if this cell is covered\n\t\t\t\tif @cell_status[cell_idx] == :status_covered\n\t\t\t\t\tcell = @cover_png\n\t\t\t\telsif @cell_status[cell_idx] == :status_gold\n\t\t\t\t\tcell = @gold_png\n\t\t\t\telse\n\t\t\t\t\tif @dragons[cell_idx] == DRAGON\n\t\t\t\t\t\tcell = @dragon_png\n\t\t\t\t\telse\n\t\t\t\t\t\tcell = @cell_png[@dragons[cell_idx]]\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# We know what to draw, so draw it\n\t\t\t\t$gtk.args.render_target( :board ).width = @board_w\n\t\t\t\t$gtk.args.render_target( :board ).height = @board_h\n\t\t\t\t$gtk.args.render_target( :board ).sprites << {\n\t\t\t\t\tx: (col*@cell_size), y: (row*@cell_size),\n\t\t\t\t\tw: @cell_size, h: @cell_size, path: cell,\n\t\t\t\t}\n\n\t\t\tend\n\n\t\tend\n\n\tend",
"def draw\n @width = @image.columns\n @height = @image.rows\n gc = Magick::Draw.new\n gc.stroke(@color)\n \n #draw horizontal lines\n (0...@height).step(cell_height) do |i|\n gc.line(0,i,@width,i)\n i += cell_height\n end\n \n #draw vertical lines\n (0...@width).step(cell_width) do |i|\n gc.line(i,0,i,@height)\n \n end\n gc.draw(@image)\n end",
"def draw\n \t #\n\t # Draw the \"top\" line.\n\t #\n\t puts \" \" + \"_\" * (@width * 2 - 1)\n\n\t #\n\t # Draw each of the rows.\n\t #\n\t @height.times do |y|\n\t \tprint \"|\"\n\t\[email protected] do |x|\n\t\t # TODO --> remote \"grid\" references??\n\t\t # render \"bottom\" using \"S\" switch\n\t\t print( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\n\t\t # render \"side\" using \"E\" switch\n\t\t if @grid[y][x] & @@E != 0\n\t\t print( ( (@grid[y][x] | @grid[y][x+1]) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t else\n\t\t print \"|\"\n\t\t end\n\t\tend\n\t\tputs\n\t end\n\n \t #\n\t # Output maze metadata.\n\t #\n\t puts \"#{$0} #{@width} #{@height} #{@seed}\"\n end",
"def inspect\n @grid.each {|row| p row.join(\" \")}\n nil\n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def grid(*)\n super\n end",
"def render\n puts \" #{(0..7).to_a.join(' ')}\"\n (0..7).each do |row|\n puts \"#{row} #{print_row(@board.grid[row] , row).join('|')}\"\n puts\n end\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def output_image\r\n @image.each do |cell|\r\n puts cell.join\r\n end\r\n end",
"def draw\n @grid.draw\n show_info\n end",
"def print\n @grid.each { |row| p row }\n end",
"def print\n @grid.each { |row| p row }\n end",
"def print\n @grid.each { |row| p row }\n end",
"def print\n @grid.each { |row| p row }\n end",
"def print\n @grid.each { |row| p row }\n end",
"def print\n @grid.each { |row| p row }\n end",
"def render_seperators\n outputs.lines << horizontal_seperator(505, grid.left, 445)\n outputs.lines << horizontal_seperator(353, grid.left, 445)\n outputs.lines << horizontal_seperator(264, grid.left, 445)\n outputs.lines << horizontal_seperator(174, grid.left, 445)\n\n outputs.lines << vertical_seperator(445, grid.top, grid.bottom)\n\n outputs.lines << horizontal_seperator(690, 445, 820)\n outputs.lines << horizontal_seperator(426, 445, 820)\n\n outputs.lines << vertical_seperator(820, grid.top, grid.bottom)\n end",
"def draw_grid\n case view\n when :south_east\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, x, y)\n end\n end\n when :south_west\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, size_x - 1 - y, x)\n end\n end\n when :north_west\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, size_x - 1 - x, size_y - 1- y)\n end\n end\n when :north_east\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, y, size_y - 1 - x)\n end\n end\n else\n throw Exception.new(\"view was out of bounds!\")\n end\n\n end",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def show_grid=(value)\n old = @show_grid\n @show_grid = value\n if old != @show_grid\n @array.each do |tile|\n if @show_grid\n if !tile.sprites[999]\n tile.sprites[999] = Sprite.new($visuals.viewport, {special: true})\n tile.sprites[999].set_bitmap(GRIDBITMAP)\n tile.sprites[999].x = tile.sprites[0].x\n tile.sprites[999].y = tile.sprites[0].y\n tile.sprites[999].z = 999\n end\n else\n if tile.sprites[999]\n tile.sprites[999].dispose\n tile.sprites.delete(999)\n end\n end\n end\n end\n end",
"def print_grid(grid)\n system('cls')\n puts \"1 2 3 4 5 6 7 8\"\n grid.each do |row|\n puts row.join(\" \")\n end\nend",
"def colorable_grid_map(color_option = :even)\n\t\tcolor_cordinates = []\n\t\tpixel_grid = @avatar[:grid].map.with_index(0) do |num, i|\n\t\t\tif num % 2 == 0\n\t\t\t\thorizontal = (i % 5) * 50\n\t\t\t\tvertical = (i / 5) * 50\n\n\t\t\t\ttop_left = [horizontal, vertical]\n\t\t\t\tbottom_right = [horizontal + 50, vertical + 50]\n\t\t\t\t[ top_left, bottom_right ]\n\t\t\tend\n\t\tend\n\t\tpixel_grid.compact\n\tend",
"def printLetterGrid(grid, width, height)\n\n # Iterate through each grid entry\n for y in 0..height-1 do\n\n for x in 0..width-1 do\n\n # Print the entry\n print \"|#{grid[[x, y]]}\"\n\n end \n\n print \"|\\n\"\n\n end \n\nend",
"def print_row(grid_size, distance_from_center)\n\tstars = grid_size - 2 * distance_from_center\n\tnum = '*' * stars\n\tputs num.center(grid_size)\nend",
"def render\n #puts \"current state of the grid:\"\n grid.each do |row|\n row.map do |tile|\n print tile\n end\n puts\n end\n end",
"def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end",
"def columnate ary, sz\n buff=Array.new\n return buff if ary.nil? || ary.size == 0\n \n # determine width based on number of files to show\n # if less than sz then 1 col and full width\n #\n wid = 30\n ars = ary.size\n ars = [$pagesize, ary.size].min\n d = 0\n if ars <= sz\n wid = $gcols - d\n else\n tmp = (ars * 1.000/ sz).ceil\n wid = $gcols / tmp - d\n end\n #elsif ars < sz * 2\n #wid = $gcols/2 - d\n #elsif ars < sz * 3\n #wid = $gcols/3 - d\n #else\n #wid = $gcols/$gviscols - d\n #end\n\n # ix refers to the index in the complete file list, wherease we only show 60 at a time\n ix=0\n while true\n ## ctr refers to the index in the column\n ctr=0\n while ctr < sz\n\n f = ary[ix]\n fsz = f.size\n if fsz > wid\n f = f[0, wid-2]+\"$ \"\n ## we do the coloring after trunc so ANSI escpe seq does not get get\n if ix + $sta == $cursor\n f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n end\n else\n ## we do the coloring before padding so the entire line does not get padded, only file name\n if ix + $sta == $cursor\n f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n end\n #f = f.ljust(wid)\n f << \" \" * (wid-fsz)\n end\n\n if buff[ctr]\n buff[ctr] += f\n else\n buff[ctr] = f\n end\n\n ctr+=1\n ix+=1\n break if ix >= ary.size\n end\n break if ix >= ary.size\n end\n return buff\nend",
"def columnate ary, sz\n buff=Array.new\n return buff if ary.nil? || ary.size == 0\n \n # determine width based on number of files to show\n # if less than sz then 1 col and full width\n #\n wid = 30\n ars = ary.size\n ars = [$pagesize, ary.size].min\n d = 0\n if ars <= sz\n wid = $gcols - d\n else\n tmp = (ars * 1.000/ sz).ceil\n wid = $gcols / tmp - d\n end\n #elsif ars < sz * 2\n #wid = $gcols/2 - d\n #elsif ars < sz * 3\n #wid = $gcols/3 - d\n #else\n #wid = $gcols/$gviscols - d\n #end\n\n # ix refers to the index in the complete file list, wherease we only show 60 at a time\n ix=0\n while true\n ## ctr refers to the index in the column\n ctr=0\n while ctr < sz\n\n f = ary[ix]\n fsz = f.size\n if fsz > wid\n f = f[0, wid-2]+\"$ \"\n ## we do the coloring after trunc so ANSI escpe seq does not get get\n if ix + $sta == $cursor\n f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n end\n else\n ## we do the coloring before padding so the entire line does not get padded, only file name\n if ix + $sta == $cursor\n f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n end\n #f = f.ljust(wid)\n f << \" \" * (wid-fsz)\n end\n\n if buff[ctr]\n buff[ctr] += f\n else\n buff[ctr] = f\n end\n\n ctr+=1\n ix+=1\n break if ix >= ary.size\n end\n break if ix >= ary.size\n end\n return buff\nend",
"def grid_page_size\n GRID_PAGE_SIZE\n end",
"def create_canvas(w, h, bkg_col)\n @draw = Magick::Draw.new\n @draw.pointsize = @@pointsize # TODO Use height\n @draw.pointsize = @options[:font_size] if @options.has_key?(:font_size)\n @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }\n\n # Make room for label and last value\n unless @options[:label].nil?\n if (@options[:has_last].nil?)\n @options[:has_last] = true\n end\n @label_width = calculate_width(@options[:label])\n @data_last_width = calculate_width(formatted_last_data_string)\n\n # TODO: Must figure out correct spacing\n @label_and_data_last_width = @label_width + @data_last_width + @@label_margin * 3.0\n w += @label_and_data_last_width\n end\n\n @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }\n @canvas.format = \"PNG\"\n\n # Draw label and last value\n unless @options[:label].nil?\n if ENV.has_key?('MAGICK_FONT_PATH')\n vera_font_path = File.expand_path('Vera.ttf', ENV['MAGICK_FONT_PATH'])\n @font = File.exists?(vera_font_path) ? vera_font_path : nil\n else\n @font = nil\n end\n @font = @options[:font] if @options.has_key?(:font)\n\n @draw.fill = 'black'\n @draw.font = @font if @font\n @draw.gravity = Magick::WestGravity\n @draw.annotate( @canvas,\n @label_width, 1.0,\n w - @label_and_data_last_width + @@label_margin, h - calculate_caps_height/2.0,\n @options[:label])\n\n @draw.fill = 'red'\n @draw.annotate( @canvas,\n @data_last_width, 1.0,\n w - @data_last_width - @@label_margin, h - calculate_caps_height/2.0,\n formatted_last_data_string)\n end\n end",
"def grid_header_rows\n 1\n end",
"def PrintGrid\n\t\t(0..9).each do |i| #vertical parent grid\n\t\t\t(0..19).each do |j| #horizontal nested array\n\t\t\t\tprint @user_grid[i][j]\n\t\t\tend\n\t\tputs\n\t\tend\n\t\treturn @user_grid\n\tend",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def render\n\t\tclear_screen\n\t\tcenter_this [\"\",\" MINESWEE\\u2691ER\"]\n\n\t\t# Create the upper and lower vertical edges of board\n\t\tboard_vertical_edge = \" +\"\n\t\[email protected] { board_vertical_edge << \"--\" }\n\t\tboard_vertical_edge << \"-+\"\n\n\t\t# Display column headers vertically to save space\n\t\t# Places tens place directly above the ones place, if necessary\n\t\ttens = \" \"\n\t\tones = \" \"\n\t\[email protected] do |x|\n\t\t\tif x >= 10\n\t\t\t\ttens << x.to_s[0] + \" \"\n\t\t\t\tones << x.to_s[1] + \" \"\n\t\t\telse\n\t\t\t\ttens << \" \"\n\t\t\t\tones << x.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tcenter_this tens if @width >= 11\n\t\tcenter_this ones\n\t\tcenter_this board_vertical_edge # Display top edge of board\n\n\t\t# Loop through and display each row\n\t\t@cell_at.each_with_index do |row, row_title|\n\t\t\t# Add the row title, as a letter, to the row contents\n\t\t\trow_contents = row_title.to_s.tr(\"0-9\", \"a-z\").upcase + \" | \"\n\t\t\t# Loop through each cell in row and it to row contents\n\t\t\trow.each do |col|\n\t\t\t\tcase col.state\n\t\t\t\twhen :hidden\n\t\t\t\t\trow_contents << \"\\u2591 \"\n\t\t\t\twhen :flagged\n\t\t\t\t\trow_contents << \"\\u2691 \"\n\t\t\t\twhen :visible\n\t\t\t\t\trow_contents << col.risk unless col.risk == :mine\n\t\t\t\t\trow_contents << \"\\u2699\" if col.risk == :mine\n\t\t\t\t\trow_contents << \" \"\n\t\t\t\tend\n\t\t\tend\n\t\t\trow_contents << \"|\"\n\t\t\tcenter_this row_contents # Display row\n\t\tend\n\t\tcenter_this board_vertical_edge # Display bottom edge of board\n\t\tcenter_this \" FLAGS LEFT: #{@flags_left}\" # Display remaining flags\n\t\tputs\n\t\tputs\n\tend",
"def default_grid\n array = Array.new(8) { Array.new(8) }\n\n array[0][0] = Rook.new('white', [0,0], 'slide')\n array[1][0] = Knight.new('white', [1,0], 'step')\n array[2][0] = Bishop.new('white', [2,0], 'slide')\n array[3][0] = Queen.new('white', [3,0], 'slide')\n array[4][0] = King.new('white', [4,0], 'step')\n array[5][0] = Bishop.new('white', [5,0], 'slide')\n array[6][0] = Knight.new('white', [6,0], 'step')\n array[7][0] = Rook.new('white', [7,0], 'slide')\n array[0..7].each_with_index { |column, index| \n column[1] = Pawn.new('white', [index,1], 'step') }\n\n array[0][7] = Rook.new('black', [0,7], 'slide')\n array[1][7] = Knight.new('black', [1,7], 'step')\n array[2][7] = Bishop.new('black', [2,7], 'slide')\n array[3][7] = Queen.new('black', [3,7], 'slide')\n array[4][7] = King.new('black', [4,7], 'step')\n array[5][7] = Bishop.new('black', [5,7], 'slide')\n array[6][7] = Knight.new('black', [6,7], 'step')\n array[7][7] = Rook.new('black', [7,7], 'slide')\n array[0..7].each_with_index { |column, index| \n column[6] = Pawn.new('black', [index,6], 'step') }\n\n array\n end",
"def grid_container_css_class\n \"#{model_type}-grid-container\"\n end",
"def drawGrid(cX, cY, gX, gY)\n\t# Convert number of intersections into city blocks that start at 0\n\tgX = gX - 2\n\tgY = gY - 2\n\t\n\tg = \"\\t\"\t\n\tfor i in 0..gY\n\t\tcY == 0 && cX == i ? g << \"X____\" : g << \" ____\"\n\tend\n\tg << \"\\n\\t\"\n\tfor i in 0..gY * 2\n\t\tif i % 2 == 0\n\t\t\tfor y in 0..gX\n\t\t\t\ty == gX ? g << \"| |\" : g << \"| \"\n\t\t\tend\n\t\telse\n\t\t\tfor y in 0..gX\n\t\t\t\ty == gX ? g << \"|____|\" : g << \"|____\"\n\t\t\tend\n\t\tend\n\t\tg << \"\\n\\t\"\n end\t\n\tfor i in 0..gY\n\t\ti == gY ? g << \"|____|\" : g << \"|____\"\t\n\tend\n\n\treturn g\nend",
"def grid_modified!\n end",
"def print_row(grid_size, distance_from_edge)\n number_of_stars = 1 + distance_from_edge * 2\n stars = \"*\" * number_of_stars\n puts stars.center(grid_size)\nend",
"def render args\n\n\t\t# Might be useful to know the current FPS\n\t\targs.outputs.debug << { x: 10, y: args.grid.top - 30, text: args.gtk.current_framerate }.label\n\n\t\t# Use a solid to make sure the board is the right colour\n\t\targs.outputs.solids << {\n\t\t\tx: @board_x, y: @board_y, w: @board_w, h: @board_h,\n\t\t\tr: 222, g: 222, b: 222,\n\t\t}\n\n\t\t# Draw a nice border around the board\n\t\t(1..10).each do |index|\n\t\t\targs.outputs.borders << { \n\t\t\t\tx: @board_x - index, y: @board_y - index, \n\t\t\t\tw: @board_w + (index*2), h: @board_h + (index*2),\n\t\t\t\tr: 100 + (index*10), g: 100 + (index*10), b: 100 + (index*10),\n\t\t\t}\n\t\tend\n\n\t\t# Do similar work for the labels\n\t\targs.outputs.solids << {\n\t\t\tx: @label_x, y: @label_time_y, w: @label_width, h: @size_time.y,\n\t\t\tr: 222, g: 222, b: 222,\n\t\t}\n\t\targs.outputs.solids << {\n\t\t\tx: @label_x, y: @label_dragon_y, w: @label_width, h: @size_dragon.y,\n\t\t\tr: 222, g: 222, b: 222,\n\t\t}\n\t\targs.outputs.solids << {\n\t\t\tx: @label_x, y: @label_restart_y, w: @label_width, h: @size_restart.y,\n\t\t\tr: 222, g: 222, b: 222,\n\t\t}\n\n\t\t(1..10).each do |index|\n\t\t\targs.outputs.borders << { \n\t\t\t\tx: @label_x - index, y: @label_time_y - index, \n\t\t\t\tw: @label_width + (index*2), h: @size_time.y + (index*2),\n\t\t\t\tr: 100 + (index*10), g: 100 + (index*10), b: 100 + (index*10),\n\t\t\t}\n\t\t\targs.outputs.borders << { \n\t\t\t\tx: @label_x - index, y: @label_dragon_y - index, \n\t\t\t\tw: @label_width + (index*2), h: @size_dragon.y + (index*2),\n\t\t\t\tr: 100 + (index*10), g: 100 + (index*10), b: 100 + (index*10),\n\t\t\t}\n\t\t\targs.outputs.borders << { \n\t\t\t\tx: @label_x - index, y: @label_restart_y - index, \n\t\t\t\tw: @label_width + (index*2), h: @size_restart.y + (index*2),\n\t\t\t\tr: 100 + (index*10), g: 100 + (index*10), b: 100 + (index*10),\n\t\t\t}\n\t\tend\n\n\t\tif @restart_clicked\n\t\t\targs.outputs.borders << {\n\t\t\t\tx: @label_x + 1, y: @label_restart_y + 1, w: @label_width - 2, h: @size_restart.y - 2,\n\t\t\t\tr: 180, g: 180, b: 180,\n\t\t\t}\n\t\t\targs.outputs.borders << {\n\t\t\t\tx: @label_x + 2, y: @label_restart_y + 2, w: @label_width - 4, h: @size_restart.y - 4,\n\t\t\t\tr: 250, g: 250, b: 250,\n\t\t\t}\n\t\telse\n\t\t\targs.outputs.borders << {\n\t\t\t\tx: @label_x + 1, y: @label_restart_y + 1, w: @label_width - 2, h: @size_restart.y - 2,\n\t\t\t\tr: 250, g: 250, b: 250,\n\t\t\t}\n\t\t\targs.outputs.borders << {\n\t\t\t\tx: @label_x + 2, y: @label_restart_y + 2, w: @label_width - 4, h: @size_restart.y - 4,\n\t\t\t\tr: 180, g: 180, b: 180,\n\t\t\t}\n\t\tend\n\n\n\t\t# Exactly what get's rendered next depends on if we're finished or burniating\n\t\tif @victorious\n\n\t\t\t# Set up the end-of-game labels\n\t\t\tsecs_elapsed = ( @end_tick - @start_tick ).to_i / 60\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_time_y + @size_time.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"%02d:%02d:%02d\" % [(secs_elapsed/3600)%60, (secs_elapsed/60)%60, secs_elapsed%60], \n\t\t\t}\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_dragon_y + @size_dragon.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"#{@dragon_count} Dragons Found!\", \n\t\t\t}\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_restart_y + @size_restart.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"Restart\", \n\t\t\t}\n\n\t\t\t# And a shower of money!\n\t\t\tcoins = [ 400, ( args.tick_count - @end_tick ) ].min\n\t\t\t(0..coins).each { |step|\n\n\t\t\t\t# Decide where to put each coin\n\t\t\t\tcoin_x = @board_x + ( ( @board_w - 24 ) * rand )\n\t\t\t\tcoin_y = @board_y + ( ( @board_h - 24 ) * rand )\n\n\t\t\t\targs.outputs.sprites << {\n\t\t\t\t\tx: coin_x, y: coin_y, path: \"sprites/coin.png\",\n\t\t\t\t\tw: 24, h: 24, angle: rand( 360 ),\n\t\t\t\t}\n\t\t\t}\n\n\t\telsif @burniation == -1\n\n\t\t\t# Set up the labels, which yes could possibly be more ... static\n\t\t\tif @spawned\n\t\t\t\tsecs_elapsed = ( args.tick_count - @start_tick ).to_i / 60\n\t\t\t\targs.outputs.labels << {\n\t\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_time_y + @size_time.y,\n\t\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\t\ttext: \"%02d:%02d:%02d\" % [(secs_elapsed/3600)%60, (secs_elapsed/60)%60, secs_elapsed%60], \n\t\t\t\t}\n\t\t\telse\n\t\t\t\targs.outputs.labels << {\n\t\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_time_y + @size_time.y,\n\t\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\t\ttext: \"--:--:--\",\n\t\t\t\t}\n\t\t\tend\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_dragon_y + @size_dragon.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"#{@dragon_count - @cell_status.count(:status_gold)} Dragons To Find\", \n\t\t\t}\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_restart_y + @size_restart.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"Restart\", \n\t\t\t}\n\n\t\t\t# Send the board content to the output\n\t\t\targs.outputs.sprites << {\n\t\t\t\tx: @board_x, y: @board_y, w: @board_w, h: @board_h, path: :board,\n\t\t\t\tsource_x: 0, source_y: 0, source_w: @board_w, source_h: @board_h,\n\t\t\t}\n\n\t\telse\n\n\t\t\t# Render slightly different labels then\n\t\t\tsecs_elapsed = ( @end_tick - @start_tick ).to_i / 60\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_time_y + @size_time.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"%02d:%02d:%02d\" % [(secs_elapsed/3600)%60, (secs_elapsed/60)%60, secs_elapsed%60], \n\t\t\t}\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_dragon_y + @size_dragon.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"You Poked A Dragon!\", \n\t\t\t}\n\t\t\targs.outputs.labels << {\n\t\t\t\tx: @label_x + ( @label_width/2 ), y: @label_restart_y + @size_restart.y,\n\t\t\t\tsize_enum: @label_size, alignment_enum: 1,\n\t\t\t\ttext: \"Retry\", \n\t\t\t}\n\n\t\t\t# Work out where we are burniating\n\t\t\tcell_y, cell_x = @burniation.divmod( @width )\n\t\t\tcell_x = ( cell_x * @cell_size ) + @board_x\n\t\t\tcell_y = ( cell_y * @cell_size ) + @board_y\n\n\t\t\t# And build up a bunch of flamey things, randomly oriented\n\t\t\t(0..@burn_size).reverse_each { |step| \n\n\t\t\t\t# Work out sizes and positions\n\t\t\t\tflame_size = @cell_size + ( step * 20 )\n\t\t\t\tflame_x = cell_x - (flame_size/2)\n\t\t\t\tflame_y = cell_y - (flame_size/2)\n\n\t\t\t\targs.outputs.sprites << {\n\t\t\t\t\tx: flame_x, y: flame_y, path: \"sprites/burniate.png\",\n\t\t\t\t\tw: flame_size, h: flame_size, \n\t\t\t\t\tangle: ( ( step * 42 ) + args.tick_count ) % 360,\n\t\t\t\t\ta: 100 - (step),\n\t\t\t\t}\n\t\t\t}\n\t\t\t@burn_size = [100, @burn_size+1].min\n\n\t\tend\n\n\tend",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def draw_columns\n @sections[:body][:fields].each do |field, settings|\n settings = [settings[0], @posY, (@defaults.merge (settings[1] || { }).symbolize_keys!)]\n settings[2][:style] = settings[2][:style].to_sym\n set_options settings[2]\n draw_line(@posY + @sections[:body][:settings][:height]/2)\n field = settings[2][:column] || field.to_s.split('_').inject('') do |str, part|\n str << part.camelize << \" \"\n end\n draw_text field, settings\n end\n draw_line(@posY - @sections[:body][:settings][:height]/2)\n set_pos_y @sections[:body][:settings][:height]\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def grid\n @grid ||=\n {\n rows: lines_to_ranges(lines[:horizontal]),\n columns: lines_to_ranges(lines[:vertical])\n }\n end"
] | [
"0.6871367",
"0.6410099",
"0.6394213",
"0.6394213",
"0.63460773",
"0.6181151",
"0.61784434",
"0.61466855",
"0.6085754",
"0.60473514",
"0.5983421",
"0.59493095",
"0.58982646",
"0.5891894",
"0.5871704",
"0.58049023",
"0.5780123",
"0.5710571",
"0.57018894",
"0.5695028",
"0.56888825",
"0.5687125",
"0.5685546",
"0.56730264",
"0.56612635",
"0.5659638",
"0.5656512",
"0.5620609",
"0.56147915",
"0.55980974",
"0.55711555",
"0.55622363",
"0.55521226",
"0.55304533",
"0.55251324",
"0.5518071",
"0.55093193",
"0.5500492",
"0.5499325",
"0.5487709",
"0.5484068",
"0.54720706",
"0.54392904",
"0.5438325",
"0.54257715",
"0.5420858",
"0.54201573",
"0.540727",
"0.53991514",
"0.53980523",
"0.5381478",
"0.5375196",
"0.5360685",
"0.53477997",
"0.53185636",
"0.5308841",
"0.5302668",
"0.52954507",
"0.52880836",
"0.5279286",
"0.5265293",
"0.52617645",
"0.52614474",
"0.5261258",
"0.5260862",
"0.52565557",
"0.52556",
"0.52556",
"0.52556",
"0.52556",
"0.52556",
"0.52556",
"0.5248908",
"0.52488494",
"0.52453715",
"0.5234126",
"0.5227455",
"0.52205104",
"0.5202812",
"0.5202459",
"0.5196957",
"0.51914245",
"0.5183599",
"0.5183599",
"0.5175763",
"0.51644653",
"0.51636046",
"0.51622593",
"0.5162098",
"0.51608324",
"0.51574534",
"0.5145499",
"0.51432115",
"0.5137822",
"0.5126535",
"0.5124387",
"0.5119453",
"0.51185054",
"0.5118124",
"0.51159465"
] | 0.5334401 | 54 |
generates (overwriting if necessary) grid.png image to be tiled in background | def generate!
total_width = self.column_width + self.gutter_width
height = @baseline_height
RVG::dpi = 100
width_in_inches = (total_width.to_f/RVG::dpi).in
height_in_inches = (height.to_f/RVG::dpi).in
rvg = RVG.new(width_in_inches, height_in_inches).viewbox(0, 0, total_width, height) do |canvas|
canvas.background_fill = "white"
end
white = ChunkyPNG::Color.from_hex("ffffff")
background = ChunkyPNG::Color.from_hex("e8effb")
line = ChunkyPNG::Color.from_hex("e9e9e9")
png = ChunkyPNG::Image.new(total_width, height, white)
png.rect(0, 0, column_width - 1, height, background, background)
png.rect(0, height - 1, total_width, height - 1, line, line)
FileUtils.mkdir(self.output_path) unless File.exists?(self.output_path)
png.save(File.join(self.output_path, "grid.png"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{montage_cmd}\")\n\n @background_image = Gosu::Image.new(@window,\n 'media/grid_one/full_map_image.png',\n false)\n\n FileUtils.rm_r Dir.glob('media/tmp/*')\n end",
"def grid_image\n s = ''\n s << \" %s %s %s \\n\" % [own(256), own(128), own(64)]\n s << \" %s %s %s \\n\" % [own(32), own(16), own(8)]\n s << \" %s %s %s \\n\" % [own(4), own(2), own(1)]\n s\n end",
"def _grid\n b = Bitmap.new(360, 360)\n c1, c2 = Color.new(255, 255, 255), Color.new(0, 0, 0)\n b.fill_rect(0, 0, 48, 48, c1)\n b.fill_rect(24, 0, 24, 24, c2)\n b.fill_rect(0, 24, 24, 24, c2)\n c1.alpha = c2.alpha = 128\n b.fill_rect(1, 25, 22, 22, c1)\n b.fill_rect(25, 1, 22, 22, c1)\n b.fill_rect(1, 1, 22, 22, c2)\n b.fill_rect(25, 25, 22, 22, c2)\n b.blt(48, 0, b, Rect.new(0, 0, 48, 48))\n b.blt(0, 48, b, Rect.new(0, 0, 96, 48))\n b.blt(96, 0, b, Rect.new(0, 0, 96, 96))\n b.blt(0, 96, b, Rect.new(0, 0, 192, 96))\n b.blt(192, 0, b, Rect.new(0, 0, 192, 192))\n b.blt(0, 192, b, Rect.new(0, 0, 384, 192))\n return b\n end",
"def draw_and_save_image\n\t\tcolor = @avatar[:color]\n\t\tpng = ChunkyPNG::Image.new(250, 250, ChunkyPNG::Color::WHITE)\n\t\tcolor = ChunkyPNG::Color.rgba(color[:r], color[:g], color[:b], color[:alpha])\n\t\t@colorable_grid.each do |points|\n\t\t\tp1 = points[0]\n\t\t\tp2 = points[1]\n\t\t\tpng.rect(p1[0], p1[1], p2[0], p2[1] , color, color)\n\t\tend\n\t\tpng.save(File.join(Dir.pwd, \"/#{@term}.png\"), :interlace => true)\n\tend",
"def print_board(title, generation, board, scale = 4)\n png = ChunkyPNG::Image.new(board.length * scale, board[0].length * scale, ChunkyPNG::Color('black @ 1.0'))\n board.each_with_index do |row, h|\n row.each_with_index do |cell, w|\n (0...scale).each do |ph|\n (0...scale).each do |pw|\n png[(h * scale) + ph, (w * scale) + pw] = (board[h][w] == 1 ? ChunkyPNG::Color('red @ 1.0') : ChunkyPNG::Color('blue @ 1.0'))\n end\n end\n end\n end\n png.save(\"./output/#{title}/frame_#{generation.to_s.rjust(4, \"0\")}.png\",\n :color_mode => ChunkyPNG::COLOR_INDEXED,\n :compression => Zlib::NO_COMPRESSION,\n :interlace => true)\nend",
"def render_board\n\n\t\t# So, we'll rebuild the render target from scratch\n\t\t(0...@height).each do |row|\n\t\t\t(0...@width).each do |col|\n\n\t\t\t\t# Save myself some typing, and some math cycles...\n\t\t\t\tcell_idx = (row*@width)+col\n\n\t\t\t\t# Check to see if this cell is covered\n\t\t\t\tif @cell_status[cell_idx] == :status_covered\n\t\t\t\t\tcell = @cover_png\n\t\t\t\telsif @cell_status[cell_idx] == :status_gold\n\t\t\t\t\tcell = @gold_png\n\t\t\t\telse\n\t\t\t\t\tif @dragons[cell_idx] == DRAGON\n\t\t\t\t\t\tcell = @dragon_png\n\t\t\t\t\telse\n\t\t\t\t\t\tcell = @cell_png[@dragons[cell_idx]]\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# We know what to draw, so draw it\n\t\t\t\t$gtk.args.render_target( :board ).width = @board_w\n\t\t\t\t$gtk.args.render_target( :board ).height = @board_h\n\t\t\t\t$gtk.args.render_target( :board ).sprites << {\n\t\t\t\t\tx: (col*@cell_size), y: (row*@cell_size),\n\t\t\t\t\tw: @cell_size, h: @cell_size, path: cell,\n\t\t\t\t}\n\n\t\t\tend\n\n\t\tend\n\n\tend",
"def create_image(width, height, background = ChunkyPNG::Color::TRANSPARENT)\n\tpng = ChunkyPNG::Image.new(width, height, background)\nend",
"def display_tile_image\n generate_tile unless @i.nil?\n display_image = @i.scale(8.0)\n display_image.display\n end",
"def render_tiled_image gcode, gmask\n debug \"rendering tiled image\"\n job_id = job_hash\n hyst = -@scale[0]/2\n gcode.comment \"raster gcode for job #{job_id}\"\n gcode.comment \"image: #{@image.filename} #{@image.size.inspect}\"\n gcode.comment \"config: #{@config.inspect}\"\n\n gcode.preamble :feed => @config[:feed], :mask => true\n gmask.preamble\n\n @config[:repeat][1].times do |ytile|\n debug \"begin tile row #{ytile}\"\n ypix = 0\n (0...@tiled_rows).each do |spans|\n debug \"pixel row #{ypix} is empty\" if spans.empty?\n unless spans.empty?\n yinches = y_inches(ytile, ypix)\n forward = spans[0][0] < spans[-1][1]\n dir = forward ? 1 : -1\n\n debug \"pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{spans.size} spans\"\n\n gcode.g0 :x => spans[0][0] - dir*@config[:overshoot], :y => yinches\n gcode.g1 :x => spans[-1][1] + dir*@config[:overshoot], :y => yinches\n gmask.begin_row forward\n spans.each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }\n end # unless spans.empty?\n ypix += 1\n end # @image.each_row\n debug \"end tile row #{ytile}\"\n end # @config[:repeat][i].times\n\n gcode.epilogue\n end",
"def render_tiled_image gcode, gmask\n debug \"rendering tiled image\"\n job_id = job_hash\n hyst = -@scale[0]/2\n gcode.comment \"raster gcode for job #{job_id}\"\n gcode.comment \"image: #{@image.filename} #{@image.size.inspect}\"\n gcode.comment \"config: #{@config.inspect}\"\n\n gcode.preamble :feed => @config[:feed], :mask => true\n gmask.preamble\n\n @config[:repeat][1].times do |ytile|\n debug \"begin tile row #{ytile}\"\n @tiled_rows.each_with_index do |spans, ypix|\n debug \"pixel row #{ypix} is empty\" if spans.empty?\n unless spans.empty?\n yinches = y_inches(ytile, ypix)\n forward = spans[0][0] < spans[-1][1]\n dir = forward ? 1 : -1\n\n debug \"pixel row #{ypix} at #{yinches} inches going #{forward ? 'forward' : 'backward'} with #{spans.size} spans\"\n\n gcode.g0 :x => spans[0][0] - dir*@config[:overshoot], :y => yinches\n gcode.g1 :x => spans[-1][1] + dir*@config[:overshoot], :y => yinches\n gmask.begin_row forward\n spans.each {|span| gmask.span forward, span[0]+hyst, span[1]+hyst }\n end # unless spans.empty?\n end # @image.each_row\n debug \"end tile row #{ytile}\"\n end # @config[:repeat][i].times\n\n gcode.epilogue\n end",
"def display_maze_with_png(grid)\n \nend",
"def generate_tile_image(output_path, type = :png)\n generate_tile unless @i.nil?\n @i.write(File.join(output_path, \"#{name}.#{type}\"))\n end",
"def show_image\n temp_floor_tile = Image.new('tiles\\tile_floor_1.png')\n hex_width = temp_floor_tile.width - 6\n hex_height = temp_floor_tile.width - 4\n temp_floor_tile.remove\n @hexArray.each_with_index do | line, x |\n bottom_y = hex_height * 11\n y_start = bottom_y - (11 - line.size) * (hex_height / 2)\n line.each_with_index do | hex, y |\n cur_x = x * hex_width\n cur_y = y_start - y * hex_height\n\n case hex.type\n when Hex::FLOOR_TYPE\n Image.new('tiles\\tile_floor_1.png', x:cur_x, y:cur_y)\n when Hex::LAVA_TYPE\n Image.new('tiles\\tile_liquid_1.png', x:cur_x, y:cur_y)\n when Hex::EXIT_TYPE\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n Image.new('tiles\\dung_ladderdown.png', x:cur_x, y:cur_y)\n else\n Image.new('tiles\\tile_base.png', x:cur_x, y:cur_y)\n end\n if hex.contained_object != nil && hex.contained_object.type == MovingObject::PLAYER_TYPE\n Image.new('tiles\\player.png', x:cur_x, y:cur_y)\n end\n end\n end\n end",
"def generate_images width=500, height=350\n # Base image with all territories shaded\n canvas = Magick::Image.new(width, height, Magick::TextureFill.new(@@map_bg))\n canvas.format = 'jpg'\n gc = Magick::Draw.new\n Territory.all.each do |t|\n gc.fill(\"transparent\")\n if t.clan\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(0.25)\n end\n gc.stroke('rgb(64, 0, 0)')\n gc.stroke_width(1)\n if t.shape # uses svg-like shapes\n s = t.shape.split(',')\n path = \"M #{s[0]} #{s[1]} \"\n s[2..-1].each_slice(2) do |p|\n path << \"L #{p[0]} #{p[1]} \"\n end\n path << \"z\"\n gc.path(path)\n end\n\n if t.clan\n # draw the small icon for the clan if it exists\n if t.clan.image_filename 16\n gc.composite(t.position_x - 8, t.position_y - 8, 16, 16,\n Magick::Image.read(\"#{RAILS_ROOT}/public/images/#{t.clan.image_filename(16)}\").first)\n else # or draw a circle of their color\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(1);\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n else\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n end\n gc.draw(canvas)\n canvas.write(\"#{RAILS_ROOT}/public/images/map/base.jpg\"){ self.quality = 95 } # TODO tweak the quality\n\n true\n end",
"def draw_custom_image\r\r\n bitmap = Cache.picture($game_map.ach_display.graphic)\r\r\n rect = Rect.new(0,0,bitmap.width,bitmap.height)\r\r\n target = Rect.new(0,0,contents.width,contents.height)\r\r\n contents.stretch_blt(target, bitmap, rect, 255)\r\r\n end",
"def draw_image(data, row_number, digit)\n size = 28\n png = ChunkyPNG::Image.new(size, size, ChunkyPNG::Color::WHITE)\n data.each_with_index do |value, index|\n png[index % size, index / size] = ChunkyPNG::Color.rgb(255 - value.to_i, 255 - value.to_i, 255 - value.to_i)\n end\n png.save(\"images/#{digit}/digit_row_#{row_number}.png\", interlace: true)\nend",
"def draw_grid(value)\n\t#makes an empty image\n\tgrid = Image.new(TW_SQUARE_SIZE*5, TW_SQUARE_SIZE*5) {self.background_color = \"white\"}\n\t#this draws things\n\tsquares = Magick::Draw.new\n\t#sets the color based on the current value\n\tr, g, b = get_colors(value)\n\tsquares.fill(\"rgb(#{r}, #{g}, #{b})\")\n\n\t#iterates through the value\n\tfor i in 0...5\n\t\tfor j in 0...5\n\t\t\t#checking if each digit is a one or zero\n\t\t\tif value & 2 ** (j + i*5) != 0\n\t\t\t\t#if it's a zero, it draws a square after passing it through the scrambler\n\t\t\t\tx = $scramble[i][j] % 5\n\t\t\t\ty = ($scramble[i][j] - x) / 5\n\t\t\t\tsquares.rectangle(TW_SQUARE_SIZE*x, TW_SQUARE_SIZE*y, TW_SQUARE_SIZE*(x+1), TW_SQUARE_SIZE*(y+1))\n\t\t\tend\n\t\tend\n\tend\n\t#puts all the squares in the empty image\n\tsquares.draw(grid)\n\t#sets the file name\n\tfile_name = \"grid#{value}.png\"\n\t#draws it and saves it\n\tgrid.write(file_name)\n\t#return a file path\n\treturn file_name\nend",
"def draw size, x_offset=0, y_offset=0\n x_offset -= 320 * size / 2\n y_offset -= 250 * size / 2\n x_offset += 6 * size\n y_offset += 15 * size\n # draw background first\n 0.upto(WIDTH - 1) do |x|\n (HEIGHT - 1).downto(0) do |y|\n if @tiles[x + WIDTH * y] == :background\n # choose background terrain\n image = @terrain[1]\n # actual top left coordinates\n px = x * TILE_WIDTH * size\n py = y * TILE_HEIGHT * size - TILE_HEIGHT * size\n # draw to the screen scaled to size\n image.draw(px - x_offset, py - y_offset, 0, size, size)\n elsif @tiles[x + WIDTH * y] == :background2\n # choose background terrain\n image = @terrain[3]\n # actual top left coordinates\n px = x * TILE_WIDTH * size\n py = y * TILE_HEIGHT * size - TILE_HEIGHT * size\n # draw to the screen scaled to size\n image.draw(px - x_offset, py - y_offset, 0, size, size)\n end\n end\n end\n\n # draw platforms on top of the background\n 0.upto(WIDTH - 1) do |x|\n (HEIGHT - 1).downto(0) do |y|\n if @tiles[x + WIDTH * y] == :platform\n # choose platform terrain\n image = @terrain[0]\n # actual top left coordinates\n px = x * TILE_WIDTH * size\n py = y * TILE_HEIGHT * size - TILE_HEIGHT * size\n # draw to the screen scaled to size\n image.draw(px - x_offset, py - y_offset, 0, size, size)\n end\n end\n end\n\n for enemy in @enemies\n enemy.draw size, x_offset, y_offset\n end\n\n for candy in @candies\n candy.draw size, x_offset, y_offset\n end\n\n @door.draw size, x_offset, y_offset\n end",
"def render\n canvas = Vips::Image.grey(@width, @height)\n\n @tiles.each do |tile|\n canvas = canvas.insert(tile.image, tile.offset.x, tile.offset.y) # rubocop:disable Style/RedundantSelfAssignment\n end\n\n # add attribution image to bottom corner if available & attribution fits into image\n if add_attribution?\n options = { x: canvas.width - attribution.width, y: canvas.height - attribution.height }\n canvas = canvas.composite2(attribution, :over, **options)\n end\n\n canvas\n end",
"def draw\n # draw background first\n 0.upto(LEVEL_WIDTH - 1) do |x|\n (LEVEL_HEIGHT - 1).downto(0) do |y|\n if @tiles[x + @x_offset + LEVEL_WIDTH * (y + @y_offset)] == :background\n # choose background terrain\n image = @terrain[1]\n # actual top left coordinates\n px = x * 32 * SCALE\n py = y * 25 * SCALE - 25 * SCALE\n # draw to the screen scaled to size\n image.draw(px, py, 0, SCALE, SCALE)\n elsif @tiles[x + @x_offset + LEVEL_WIDTH * (y + @y_offset)] == :background2\n # choose background terrain\n image = @terrain[3]\n # actual top left coordinates\n px = x * 32 * SCALE\n py = y * 25 * SCALE - 25 * SCALE\n # draw to the screen scaled to size\n image.draw(px, py, 0, SCALE, SCALE)\n elsif @tiles[x + @x_offset + LEVEL_WIDTH * (y + @y_offset)] == :none\n image = @terrain[2]\n # actual top left coordinates\n px = x * 32 * SCALE\n py = y * 25 * SCALE - 25 * SCALE\n # draw to the screen scaled to size\n image.draw(px, py, 0, SCALE, SCALE)\n end\n end\n end\n\n # draw platforms on top of the background\n 0.upto(LEVEL_WIDTH - 1) do |x|\n (LEVEL_HEIGHT - 1).downto(0) do |y|\n if @tiles[x + @x_offset + LEVEL_WIDTH * (y + @y_offset)] == :platform\n # choose platform terrain\n image = @terrain[0]\n # actual top left coordinates\n px = x * 32 * SCALE\n py = y * 25 * SCALE - 25 * SCALE\n # draw to the screen scaled to size\n image.draw(px, py, 0, SCALE, SCALE)\n end\n end\n end\n\n for enemy in @enemies do\n enemy.draw SCALE, @x_offset * 32 * SCALE, @y_offset * 25 * SCALE\n end\n\n for candy in @candies do\n candy.draw SCALE, @x_offset * 32 * SCALE, @y_offset * 25 * SCALE\n end\n\n Gosu::Image.from_text(self, @current_selection.to_s, \"Times New Roman\", 24).draw(5, 5, 0, 1, 1, 0xffffffff)\n\n @player_image[0].draw(@player[0] * SCALE - @x_offset * 32 * SCALE, @player[1] * SCALE - @y_offset * 25 * SCALE, 1, SCALE, SCALE) unless @player.nil?\n @door_image[0].draw(@door[0] * SCALE - @x_offset * 32 * SCALE, @door[1] * SCALE - @y_offset * 25 * SCALE, 1, SCALE, SCALE) unless @door.nil?\n\n @target[0].draw(mouse_x, mouse_y, 2, SCALE, SCALE) if @current_type == :candies\n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def render_player x, y \n \tboxsize = 16\n \tgrid_x = (1280 - (@grid_w * boxsize)) / 2\n \tgrid_y = (720 - ((@grid_h - 2) * boxsize)) / 2\n\t\[email protected] << [ grid_x + (x * boxsize), (grid_y) + (y * boxsize), boxsize, boxsize, \"sprites/debug.png\"]\n\tend",
"def show_grid=(value)\n old = @show_grid\n @show_grid = value\n if old != @show_grid\n @array.each do |tile|\n if @show_grid\n if !tile.sprites[999]\n tile.sprites[999] = Sprite.new($visuals.viewport, {special: true})\n tile.sprites[999].set_bitmap(GRIDBITMAP)\n tile.sprites[999].x = tile.sprites[0].x\n tile.sprites[999].y = tile.sprites[0].y\n tile.sprites[999].z = 999\n end\n else\n if tile.sprites[999]\n tile.sprites[999].dispose\n tile.sprites.delete(999)\n end\n end\n end\n end\n end",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def draw\n if @cache.nil?\n prog = CGPProgram.new(@program, 2, 3)\n png = ChunkyPNG::Image.new(Config::image_width,\n Config::image_height, \n ChunkyPNG::Color::TRANSPARENT)\n Config::image_width.times do |x|\n Config::image_height.times do |y|\n # Takes in X,Y, gives HSL\n # For sanity sake, putting X/Y in terms of 0-1\n xf = x.to_f / Config::image_width\n yf = y.to_f / Config::image_height\n o = prog.evaluate([xf, yf])\n # Now, from the chunky_png docs,\n # Hue is 0-360:\n h = o[0] * 360\n # Sat is 0-1\n s = o[1]\n # Val is 0-1\n v = o[2]\n png[x,y] = ChunkyPNG::Color.from_hsv(h,s,v)\n end\n end\n @cache = png\n end\n return @cache\n end",
"def render_background\n render_unvisited\n render_grid_lines\n end",
"def render_wall x, y\n \tboxsize = 16\n \tgrid_x = (1280 - (@grid_w * boxsize)) / 2\n \tgrid_y = (720 - ((@grid_h - 2) * boxsize)) / 2\n\t\t#static_sprites are not cleared each frame and as the walls do not move they can be static which improves performance\n\t\[email protected]_sprites << [ grid_x + (x*boxsize), (grid_y) + (y * boxsize), boxsize, boxsize, \"sprites/wall1.png\"]\n\tend",
"def create_sprites\n # Put bitmaps in cache\n cache_back_bmp = RPG::Cache.windowskin(image_filename('background'))\n cache_up_bmp = RPG::Cache.windowskin(image_filename('up'))\n cache_down_bmp = RPG::Cache.windowskin(image_filename('down'))\n cache_bar_bmp = RPG::Cache.windowskin(image_filename('slider'))\n # Create the background\n size = @size - (cache_down_bmp.height + cache_up_bmp.height) / 2\n create_background(cache_back_bmp, size)\n # Create the up button\n create_button_up(cache_up_bmp)\n # Create the down button\n create_button_down(cache_down_bmp)\n # Create the slider button\n create_button_slider(cache_bar_bmp)\n # Repositionning the sprites\n @direction.reset_sprites_position(\n @background_sprite,\n @button_down_sprite,\n @button_up_sprite,\n @button_slider_sprite,\n @position,\n @target,\n @size,\n @display_offset,\n @viewport\n )\n end",
"def tick args\n args.outputs.background_color = [0, 0, 0]\n args.outputs.borders << { x: 0, y: 0, w: 1280, h: 720, r: 255, g: 255, b: 255 }\n\n args.outputs.labels << { x: 30, y: 30.from_top, text: \"render scale: #{args.grid.native_scale}\", r: 255, g: 255, b: 255 }\n args.outputs.labels << { x: 30, y: 60.from_top, text: \"render scale: #{args.grid.native_scale_enum}\", r: 255, g: 255, b: 255 }\n\n args.outputs.sprites << { x: -640 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: -320 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n\n args.outputs.sprites << { x: 0 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 320 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 640 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 960 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 1280 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n\n args.outputs.sprites << { x: 1600 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 1920 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n\n args.outputs.sprites << { x: 640 - 50, y: 720, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 640 - 50, y: 100.from_top, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 640 - 50, y: 360 - 50, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 640 - 50, y: 0, w: 100, h: 100, path: \"sprites/square.png\" }\n args.outputs.sprites << { x: 640 - 50, y: -100, w: 100, h: 100, path: \"sprites/square.png\" }\nend",
"def setup\n size 200, 200 \n no_stroke\n background 0 \n c = load_image \"cait.jpg\" \n xoff, yoff = 0, 0\n p = 2\n pix = p * 3 \n (c.width * c.height).times do |i| \n pixel = c.pixels[i] \n fill red( pixel ), 0, 0\n rect xoff, yoff, p, pix \n fill 0, green( pixel ), 0\n rect xoff+p, yoff, p, pix \n fill 0, 0, blue( pixel )\n rect xoff+p*2, yoff, p, pix \n xoff += pix\n if xoff >= (width-pix)\n xoff = 0\n yoff += pix\n end\n end \nend",
"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 generate_image\n\t\tset_dimensions()\n\t\t\n\t\t# Create an image from scratch, save as an interlaced PNG.\n\t\tpng = ChunkyPNG::Image.new(@x_length, @y_length, ChunkyPNG::Color::TRANSPARENT)\n\n\t\t# Loop along the string array and write each char as a square.\n\t\ti_line = 0\n\t\t@input_text_array.each do |line|\n\n\t\t\t# Get the colour for the line.\n\t\t\tline_colour_r = @colour_r.next\n\t\t\tline_colour_g = @colour_g.next\n\t\t\tline_colour_b = @colour_b.next\n\n\t\t\t# Loop through each character, and alter the base line colour according\n\t\t\t# to the value of the cell.\n\t\t\ti_char = 0\n\t\t\tline.split('').each do |char|\n\t\t\t\t\n\t\t\t\t# The colour multiplier of the cell.\n\t\t\t\tmultiplier = CHARS.index(char).to_f / @highest_num\n\t\t\t\t\n\t\t\t\t# Wrap in a method using a begin/rescue block.\n\t\t\t\t# Fixes weird bug that I can't seem to replicate.\n\t\t\t\tdef try_colour(multiplier, line_colour)\n\t\t\t\t\tbegin\n\t\t\t\t\t\t(multiplier * line_colour).to_i\n\t\t\t\t\trescue\n\t\t\t\t\t\t255\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcolour_r = try_colour(multiplier,line_colour_r)\n\t\t\t\tcolour_g = try_colour(multiplier,line_colour_g)\n\t\t\t\tcolour_b = try_colour(multiplier,line_colour_b)\n\t\t\t\t\n\t\t\t\t# Handle inversion of colours if necessary.\n\t\t\t\tif @colour_invert\n\t\t\t\t\tcolour_r = 255 - colour_r\n\t\t\t\t\tcolour_g = 255 - colour_g\n\t\t\t\t\tcolour_b = 255 - colour_b\n\t\t\t\tend\n\t\t\t\tcolour = ChunkyPNG::Color.rgba(colour_r, colour_g, colour_b, 255)\n\t\t\t\t\n\t\t\t\t# Draw each square.\n\t\t\t\tpng.rect(i_char, i_line,\n\t\t\t\t\ti_char+@pixel_size-1, i_line+@pixel_size-1,\n\t\t\t\t\tcolour, colour\n\t\t\t\t)\n\n\t\t\t\ti_char += @pixel_size\n\t\t\tend\n\t\t\ti_line += @pixel_size\n\t\tend\n\t\t\n\t\t# Add metadata if necessary.\n\t\tif @metadata\n\t\t\[email protected] do |key, value|\n\t\t\t\tpng.metadata[key.to_s] = value.to_s\n\t\t\tend\n\t\tend\n\n\t\t# Save to disk.\n\t\tpng.save(@image_file, :interlace => true)\n\tend",
"def create_spriteset_and_background(scene_name = ext_text(8997, 3))\n @sprites = UI::SpriteStack.new(@viewport)\n @background = @sprites.push(0, 0, 'GTS/Background')\n @sprites.add_text(25, 3, 0, 16, scene_name, color: 9)\n @sprites.add_text(300, 3, 0, 16, \"Online ID: #{$pokemon_party.online_id}\", 2, color: 9)\n @sprites_base_index = @sprites.stack.size\n end",
"def create_tiles\n # Screen fits exactly 15x10 tiles (for 480x320), but it has a buffer around it\n # so the game has time to refresh without showing a black border during movement.\n tiles = []\n (TOTALSIZE).times { tiles << TileSprite.new($visuals.viewport) }\n @array = tiles\n startx = $visuals.map.real_x / -32 - 1\n starty = $visuals.map.real_y / -32 - 1\n for y in 0...YSIZE\n for x in 0...XSIZE\n mapx = startx + x\n mapy = starty + y\n idx = x + y * XSIZE\n @array[idx].real_x = $visuals.map.real_x + mapx * 32\n @array[idx].real_y = $visuals.map.real_y + mapy * 32\n draw_tile(@array[idx], mapx, mapy)\n end\n end\n $temp_bitmaps = nil\n # Don't dispose the bitmaps hash because tiles reference these instances; they're not clones.\n end",
"def create_image(scale)\n # find the image size\n size = CGSizeMake(WIDTH * scale, HEIGHT * scale)\n # make the image bitmap and draw all of the parts\n image_bitmap(size, scale)\n end",
"def generate_image\n image = Magick::Image.new(@width, @height) do\n self.background_color = \"transparent\"\n end\n\n draw_dots(image)\n\n image\n end",
"def create_graphics\n create_viewport\n create_background\n create_pokemon_sprite\n create_egg_sprite\n end",
"def generate_tile()\n @i = do_generate_tile(@i)\n end",
"def draw_cell(window, cell, is_player, grid_length)\n cell_width = window.width / grid_length\n cell_draw_x = cell.grid_x * cell_width\n cell_draw_y = cell.grid_y * cell_width\n\n\n window.draw_rect(cell_draw_x, cell_draw_y, cell_width, cell_width, Gosu::Color.argb(DARK_GRAY_COLOR)) if cell.show_base_background\n\n if cell.grid_y == grid_length - 1 && cell.grid_x == grid_length - 1\n window.draw_rect(cell_draw_x + PLATFORM_MARGIN,\n cell_draw_y + PLATFORM_MARGIN,\n cell_width - + PLATFORM_MARGIN * 2,\n cell_width - PLATFORM_MARGIN * 2,\n Gosu::Color.argb(LIGHT_GREEN_COLOR))\n end\n\n if is_player\n window.draw_rect(cell_draw_x + PLAYER_MARGIN,\n cell_draw_y + PLAYER_MARGIN,\n cell_width - PLAYER_MARGIN * 2,\n cell_width - PLAYER_MARGIN * 2,\n Gosu::Color.argb(PLAYER_COLOR))\n end\n\n draw_cell_walls(window, cell, cell_width, MAZE_WALL_THICKNESS, Gosu::Color.argb(LIGHT_GRAY_COLOR))\n\nend",
"def tileable(insets=UIEdgeInsetsZero)\n # not necessary, since we don't modify/examine the insets\n # insets = SugarCube::CoreGraphics::EdgeInsets(insets)\n resizableImageWithCapInsets(insets, resizingMode:UIImageResizingModeTile)\n end",
"def tileable(insets=UIEdgeInsetsZero)\n # not necessary, since we don't modify/examine the insets\n # insets = SugarCube::CoreGraphics::EdgeInsets(insets)\n resizableImageWithCapInsets(insets, resizingMode:UIImageResizingModeTile)\n end",
"def generate_image\n matrix_values = compute_values\n max, min = matrix_values.max.to_f, matrix_values.min.to_f\n \n hue_range = HeatPalette::HSL_HUE_MAX - HeatPalette::HSL_HUE_MIN\n matrix_scaled = ((matrix_values - min)*(hue_range-1)/(max-min)).round\n \n contours_values = explicit_range(min..max, @contours).drop(1)\n contours_scaled = contours_values.map{|e| ((e - min)*(hue_range-1)/(max-min)).round}\n rainbow = colorines(contours_scaled)\n \n @metadata[\"max_value\"] = max\n @metadata[\"min_value\"] = min\n @metadata[\"contours_values\"] = contours_values\n \n legend_stream = rainbow.map{|e| ChunkyPNG::Color.from_hex(e)}\n \n @legend = ChunkyPNG::Image.new(hue_range, LEGEND_HEIGHT, legend_stream*LEGEND_HEIGHT)\n \n stream = matrix_scaled.flatten.to_a\n stream.map!{|e| ChunkyPNG::Color.from_hex(\"#{rainbow[e]}\")}\n @img = ChunkyPNG::Image.new(@width, @height, stream).rotate_counter_clockwise\n end",
"def draw_grid\n case view\n when :south_east\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, x, y)\n end\n end\n when :south_west\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, size_x - 1 - y, x)\n end\n end\n when :north_west\n size_y.times do |y|\n size_x.times do |x|\n draw_tile(x, y, size_x - 1 - x, size_y - 1- y)\n end\n end\n when :north_east\n size_x.times do |y|\n size_y.times do |x|\n draw_tile(x, y, y, size_y - 1 - x)\n end\n end\n else\n throw Exception.new(\"view was out of bounds!\")\n end\n\n end",
"def load_editor_background\n x_extra = (self.width / TILE_SIZE.to_f / EDITOR_SCALE_LEVELS[0] / 2).ceil\n y_extra = (self.height / TILE_SIZE.to_f / EDITOR_SCALE_LEVELS[0] / 2).ceil\n\n @editor_background = Gosu.record(1, 1) do\n x = -x_extra\n while (x < EDITOR_WIDTH + x_extra)\n y = -y_extra\n while (y < EDITOR_HEIGHT + y_extra)\n color = position_in_bounds?(x, y) ? Gosu::Color::WHITE : Gosu::Color.new(255 / 2, 255, 255, 255)\n background = @background_images[@track.background_type]\n background.draw(x * TILE_SIZE, y * TILE_SIZE, 0, 1, 1, color)\n y += 1\n end\n x += 1\n end\n end\nend",
"def rasterise \r\n @frames.each do |frame|\r\n printf '.';\r\n canvas = Canvas.new(@width, @height);\r\n @canvases.push(canvas);\r\n if frame.pixmaps.length == 0 then next; end;\r\n frame.pixmaps.each do |pixmap|\r\n img = pixmap.sprite.getImage(pixmap.frame);\r\n pixmap.frame = (pixmap.frame + 1) % (pixmap.sprite.images.length);\r\n canvas.add(img, pixmap.x, pixmap.y);\r\n end\r\n end \r\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def render_target\n outputs.sprites << scale_up(grid.target).merge({ path: 'target.png'})\n end",
"def init_tile_image\n list = Magick::ImageList.new(\"/Users/pmenke/git/eq2_tiler/resources/tiler/overlay-base.png\")\n @i = list.first\n @i\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def image_board\n\t\t(0...@width).map do |i|\n\t\t\t(0...@height).map do |j|\n\t\t\t\t# ([1]*3+[0]*7)[rand 10]\n\t\t\t\trand 2\n\n\n\t\t\t\t# rand 2\n\t\t\tend\n\t\tend\n\tend",
"def create_background\n @background_sprite = Plane.new\n @background_sprite.bitmap = Cache.parallax(Settings::REGISTR_WALLPAPER)\n @background_sprite.x_speed = 1\n @background_sprite.y_speed = 1\n end",
"def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false)\n land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels)\n \n # exit if file already exists\n return false if (!overwrite && File.exists?(land_mass_tile_path))\n \n begin\n # build up square of 4 children tiles\n child_tiles = (0..1).map { |this_x| (0..1).map { |this_y| OpenStruct.new(:x => this_x+x*2, :offset_x => this_x, :y => this_y+y*2, :offset_y => this_y, :zoom => zoom+1) } }.flatten(1)\n \n reduce_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels \n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end\n \n stitch_tiles = child_tiles.select do |tile| \n tile.accuracy_pixels = accuracy_pixels * 2\n tile.path = LandMassTile.tile_path(tile.x, tile.y, tile.zoom, tile.accuracy_pixels)\n tile.exists = File.exists?(tile.path)\n tile.img = Magick::Image.read(tile.path).first if tile.exists\n tile.exists # remove image if tile does not exist\n end unless reduce_tiles.length == 4\n \n if (reduce_tiles.length == 4)\n # We are building a land mass tile from children with the same number of pixels in the tile\n # which means we need to \"squeeze\" 4 tiles into 1\n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels * 2, AppConfig.gmap_tile_size / accuracy_pixels * 2) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n reduce_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n # now resize down to single tile size\n reduced_tile = new_tile.resize(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels)\n \n reduced_tile.write land_mass_tile_path\n elsif (stitch_tiles.length == 4)\n # We are building a land mass tile from children with a lower accuracy level i.e. we need to \n # build up this tile by stitching 4 children tiles together\n \n new_tile = Magick::Image.new(AppConfig.gmap_tile_size / accuracy_pixels, AppConfig.gmap_tile_size / accuracy_pixels) do\n self.background_color = \"transparent\"\n end\n \n child_tile_size = new_tile.columns / 2\n stitch_tiles.each do |tile|\n raise \"Tile#{tile.path} is incorrectly #{tile.img.columns} wide / high\" if ( (tile.img.columns != child_tile_size) || (tile.img.rows != child_tile_size) ) \n pixels = tile.img.export_pixels(0, 0, tile.img.columns, tile.img.rows, \"RGBA\")\n new_tile.import_pixels(tile.offset_x * child_tile_size, tile.offset_y * child_tile_size, tile.img.columns, tile.img.rows, \"RGBA\", pixels)\n end\n \n new_tile.write land_mass_tile_path\n else\n reduce_tiles_info = reduce_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n stitch_tiles_info = stitch_tiles.map{|c| \"#{c.x}:#{c.y} zm #{c.zoom}\" }.join(',')\n SLogger.warn(\"Could not reduce land mass image for position as not all children tiles exist. Tile #{x}:#{y} (zoom #{zoom}). Reduce tiles: #{reduce_tiles_info}. Stitch tiles: #{stitch_tiles_info}\")\n false\n end\n \n rescue Exception => e\n SLogger.warn(\"Could not save reduced land mass image for position #{x}:#{y} (zoom #{zoom}). Error '#{e.message}'\")\n false\n end\n end",
"def draw_map game_map\r\n tiles = game_map.tiles # 2d array of the tiles set!\r\n wooden_plank_image = game_map.wooden_plank # image of the wooden plank \r\n i = 0\r\n j = 0\r\n unit_width = 20\r\n unit_height = 20\r\n\r\n # drawing the background image of the game map\r\n #game_map.background.draw(0,0,0) # 0: for x position, 0: for y position, 0: for ZOrder\r\n\r\n height = tiles.length\r\n width = tiles[0].length\r\n\r\n while i < height\r\n j = 0\r\n while j < width\r\n if(tiles[i][j]==1 || tiles[i][j]==3)\r\n x = j * unit_width\r\n y = i * unit_height\r\n draw_plank(x, y, wooden_plank_image)\r\n j+=4 # increment the value of the j by 4 to skip the next 4 blocks\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\nend",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def create_sub_background\n @sub_background = Sprite.new(@viewport).set_bitmap('tcard/background', :interface)\n end",
"def draw_board\n\t\tfor i in 0..9\n\t\t\t@tile_Array[i].draw\n\t\tend\n\tend",
"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",
"def initialize title, grid\n\t\t@grid = grid\n\t\tsuper @grid.width * 2, @grid.height * 2, false\n\t\tself.caption = title\n\t\t@counter = 0\n\n\t\t@white = Gosu::Image.new(self, \"white.png\", true)\n\t\t@red = Gosu::Image.new(self, \"red.png\", true)\n\n\t\t@time = Time.now\n\tend",
"def draw_grid\n print_cap\n (0...@vertical).each do |vert_index|\n (0..@v_size).each do |block_height|\n (0...@horizontal).each do |horizontal_index|\n if block_height == (@v_size/2)\n print \"|\" + \" \"*(@h_size/2)\n \"#{print @contents[horizontal_index][vert_index]}|\"\n print \" \"*(@h_size/2-1)\n else\n print \"|\"; print \" \"*@h_size\n end\n end\n print \"|\\n\" \n \n end\n print_cap\n end\n end",
"def create_storm_bitmap\r\n @storm_bitmap = Bitmap.new(34, 64)\r\n 32.times do |i|\r\n @storm_bitmap.fill_rect(33-i, i*2, 1, 2, particle_color2)\r\n @storm_bitmap.fill_rect(32-i, i*2, 1, 2, particle_color1)\r\n @storm_bitmap.fill_rect(31-i, i*2, 1, 2, particle_color2)\r\n end\r\n end",
"def create_background\n @background_sprite = Sprite.new(@viewport)\n @background_sprite.set_bitmap('save_background', :interface)\n end",
"def setup \n size 640, 360 \n\tbackground 127 \n\tno_stroke\t\n\t(0...height).step(20) do |i|\n\t\tfill 0 \n\t\trect 0, i, width, 10 \n\t\tfill 255 \n\t\trect i, 0, 10, height \n\tend\nend",
"def render_gridlines_if_needed args\n if args.state.show_gridlines && args.static_lines.length == 0\n args.static_lines << 65.times.map do |i|\n [\n [CENTER_OFFSET + i * TINY_SCALE + 1, 0,\n CENTER_OFFSET + i * TINY_SCALE + 1, 720, 128, 128, 128],\n [CENTER_OFFSET + i * TINY_SCALE, 0,\n CENTER_OFFSET + i * TINY_SCALE, 720, 128, 128, 128],\n [CENTER_OFFSET, 0 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 0 + i * TINY_SCALE, 128, 128, 128],\n [CENTER_OFFSET, 1 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 1 + i * TINY_SCALE, 128, 128, 128]\n ]\n end\n elsif !args.state.show_gridlines\n args.static_lines.clear\n end\nend",
"def render_background\n render_unvisited\n render_grid_lines\n render_labels\n end",
"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 create\n window = Gosu::Window.new(@size, @size, false)\n image = TexPlay.create_image(window, @size, @size, color: Gosu::Color::BLACK)\n image.draw 0, 0, 0\n\n for y in 0...@size\n for x in 0...@size\n grayscale = (@data[x + y * @size] * 4.0) / 1000.0\n image.pixel x, y, color: [grayscale, grayscale, grayscale]\n end\n end\n\n image.save('height_map.png')\n end",
"def create_spriteset_and_background\n super('GTS')\n end",
"def create_background_sprite\n # create background sprite\n @background = Sprite.new(@v)\n create_background_bitmap\n end",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def create_spriteset_and_background\n super(ext_text(8997, 19))\n end",
"def draw_grid(line_width,mosaic=true,r=220,g=220,b=220,alpha=100)\n # Draw mosaic */\n if (mosaic)\n layer_width = @g_area_x2-@g_area_x1\n layer_height = @g_area_y2-@g_area_y1\n\n @layers[0] = image_create_true_color(layer_width,layer_height)\n #c_white = allocate_color(@layers[0],255,255,255)\n image_filled_rectangle(@layers[0],0,0,layer_width,layer_height,255,255,255)\n image_color_transparent(@layers[0],255,255,255)\n\n #c_rectangle =allocate_color(@layers[0],250,250,250)\n\n y_pos = layer_height #@g_area_y2-1\n last_y = y_pos\n i =0\n while(i<=@division_count)\n last_y= y_pos\n y_pos = y_pos - @division_height\n y_pos = 1 if ( y_pos <= 0 )\n image_filled_rectangle(@layers[0],1, y_pos,layer_width-1,last_y,250,250,250) if ( i % 2 == 0 )\n i = i+1\n end\n\n image_copy_merge(@layers[0],@picture,@g_area_x1,@g_area_y1,0,0,layer_width,layer_height,alpha)\n #image_destroy(@layers[0])\n\n end\n\n #Horizontal lines\n y_pos = @g_area_y2 - @division_height\n i=1\n while(i<=@division_count)\n self.draw_dotted_line(@g_area_x1,y_pos,@g_area_x2,y_pos,line_width,r,g,b) if ( y_pos > @g_area_y1 && y_pos < @g_area_y2 )\n y_pos = y_pos - @division_height\n i = i+1\n end\n # Vertical lines\n if (@g_area_x_offset == 0 )\n x_pos = @g_area_x1 + (@division_width) +@g_area_x_offset\n col_count = (@data_count.to_f-2).floor\n else\n\n x_pos = @g_area_x1 +@g_area_x_offset\n col_count = ( (@g_area_x2 - @g_area_x1) / @division_width )\n end\n i= 1\n\n while (i<=col_count)\n if ( x_pos > @g_area_x1 && x_pos < @g_area_x2 )\n self.draw_dotted_line((x_pos).floor,@g_area_y1,(x_pos).floor,@g_area_y2,line_width,r,g,b)\n end\n x_pos = x_pos + @division_width\n i= i+1\n end\n end",
"def draw_fixed_grid(rect, cols, rows, shade=active_shade, state=active_state)\n rect = Convert.Rect(rect)\n w = rect.width\n h = rect.height\n rows.times do |y|\n cols.times do |x|\n draw_shade_rect(r.step(6, x).step(2, y), shade, state)\n end\n end\n end",
"def draw_item_image\n draw_bg_gradient\n if @obj.rename_image\n draw_rename_image\n elsif $imported[\"YEA-ShopOptions\"] && @obj.image\n draw_shop_options_image\n else\n icon_index = @obj.icon_index\n bitmap = Cache.system(\"Iconset\")\n rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)\n target = Rect.new(0, 0, 96, 96)\n contents.stretch_blt(target, bitmap, rect)\n end\n end",
"def draw_board_window\n heightpx = @board.height*@scale\n widthpx = @board.width*@scale\n TkCanvas.new(@root, bg: \"#ffffff\", height: heightpx, width: widthpx) { grid(row: 1, column: 1) }\n end",
"def render_gradiated_background(top_color='#4a465a', bottom_color='black')\n Image.new(@columns, @rows, GradientFill.new(0, 0, 100, 0, top_color, bottom_color))\n end",
"def update_graphics\r\n @tile_id = @character.tile_id\r\n @character_name = @character.character_name\r\n self.visible = !@character_name.empty? || @tile_id > 0\r\n if @tile_id >= 384\r\n update_tile_graphic\r\n else\r\n self.bitmap = RPG::Cache.character(@character_name, 0)\r\n @cw = bitmap.width / 4\r\n @height = @ch = bitmap.height / 4\r\n self.ox = @cw / 2\r\n self.oy = @ch\r\n self.zoom = 1 if zoom_x != 1\r\n src_rect.set(@character.pattern * @cw, (@character.direction - 2) / 2 * @ch, @cw, @ch)\r\n @pattern = @character.pattern\r\n @direction = @character.direction\r\n end\r\n end",
"def create_graphics\n create_viewport\n create_base_ui\n create_sub_background\n create_trainer_sprite\n create_badge_sprites\n create_texts\n end",
"def render_in_background args\n # pool table\n args.outputs.solids << [args.state.tableleft, args.state.tablebottom, args.state.table_width, args.state.table_height, 0, 150, 0, 180]\n\n # pockets\n args.state.pockets.each do |pocket|\n args.outputs.sprites << [pocket[0], pocket[1], pocket[2], pocket[3], pocket[4], 0, 180]\n end\nend",
"def tile_image(image, dpi)\n tilex = @field['tilex']*dpi\n tiley = @field['tiley']*dpi\n\n tiledImage = ImageList.new\n\n temp = image.scale(tilex, tiley)\n\n timesX = (@field['sizex'].to_f/@field['tilex']).ceil\n timesY = (@field['sizey'].to_f/@field['tiley']).ceil\n\n (1..timesX).each do |x|\n (1..timesY).each do |y|\n tiledImage << temp\n end\n end\n\n montage = tiledImage.montage() do |image|\n image.geometry = \"#{tilex}x#{tiley}+0+0\"\n image.background_color = 'transparent'\n image.tile = \"#{timesX}x#{timesY}\"\n end\n tiledImage.clear()\n\n return montage\n end",
"def generate_white_spaces\n #Plain background\n if values_bits[Constants::V_Type_of_BG] > 4.5 \n if @vertical\n @white_space_w = @width - @sides_margin*2 \n @white_space_h = @height - (@main_image.height + @upper_img_margin + @upper_margin*2)\n @white_space_x = @sides_margin\n @white_space_y = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.height+@upper_margin+@upper_img_margin : @upper_margin\n else\n @white_space_w = @width - (@main_image.width + @sides_img_margin + @sides_margin*2)\n @white_space_h = @height - @upper_margin*2\n @white_space_x = values_bits[Constants::V_Image_position] < 4.5 ? @main_image.width+2*@sides_margin : @sides_margin\n @white_space_y = @upper_margin\n end\n #Image as background\n else \n @white_space_w= @width - @sides_margin*2\n @white_space_h= @height - @upper_margin*2\n @white_space_x= @sides_margin\n @white_space_y= @upper_margin\n end\n \n @max_width = (@white_space_w.to_f * 0.60).to_i \n @max_width -= max_width%20 == 0 ? 0 : max_width%20\n # @groups.each do |g|\n # g.max_width = @max_width\n # end\n end",
"def initialize texture_size = [512,512]\n @texture_size = texture_size\n @texture = Array.new(@texture_size[0]) { Array.new(@texture_size[1]) { Array.new(3){1} } }\n @windows = [@texture_size[0]/8, @texture_size[1]/8]\n @texture_link = [0]\n \n @windows[0].times do |i|\n @windows[1].times do |j|\n px_origin = i*8\n py_origin = j*8\n # Got a little 8x8 window with pixel coords starting in px/py origin being topleft corner of window\n \n # Walls\n 8.times do |x|\n @texture[px_origin + x][py_origin] = [0,0,0]\n @texture[px_origin + x][py_origin+7] = [0,0,0]\n @texture[px_origin][py_origin + x] = [0,0,0]\n @texture[px_origin + 7][py_origin + x] = [0,0,0]\n end\n \n # Inside color, either mostly on or mostly off\n if rand > DARK_TO_LIGHT_RATIO\n cr = rand/4.0\n else\n cr = 3.0/4 + rand/4.0\n end\n c = [cr,cr,cr]\n \n # Inside\n 6.times do |x|\n 6.times do |y|\n px = px_origin + 1 + x\n py = py_origin + 1 + y\n \n @texture[px][py] = c\n end\n end \n end\n end\n \n loadTexture\n end",
"def makeImage\n for i in 0...@width\n ti = 2.0*Math::PI*i/ImageWidth.to_f\n for j in 0...@height\n tj = 2.0*Math::PI*j/ImageHeight.to_f\n\n $image[3 * (@height * i + j)] = 127*(1.0 + Math::sin(ti))\n $image[3 * (@height * i + j) +1] = 127*(1.0 + Math::cos(2*tj))\n $image[3 * (@height * i + j) +2] = 127*(1.0 + Math::cos(ti+tj))\n end\n end\n end",
"def construct_board_graphics_overlay(window)\n\t\tdark = false\t\t\t\t\t\t\t\t# this boolean controls the checkerboarding\n\t\tdark_hex = 0xff3f3333\n\t\tlight_hex = 0xff9e9fad\n\t\tself.board.each_with_index do |column, c|\n\t\t\tcolumn.size.times do |r|\n\t\t\t\tx = c*@cell_size\n\t\t\t\ty = r*@cell_size\n\t\t\t\tboard_cell = GraphicsLibrary::Rectangle.new(window, x, y, @cell_size, @cell_size, dark_hex, 0) if dark\n\t\t\t\tboard_cell = GraphicsLibrary::Rectangle.new(window, x, y, @cell_size, @cell_size, light_hex, 0) if !dark\n\t\t\t\tdark = !dark\n\t\t\t\t@board_graphics_overlay << board_cell\t\t\t\t\t# append the cells to the array of cells.\n\t\t\tend\n\t\t\tdark = !dark if (@stagger_cell_color_value % 2 == 0)\t\t# stagger the cell color for even sized boards so that it checkerboards properly.\n\t\t\t\t \n\t\tend\n\tend",
"def print_grid\n puts \"Generation: #{@generation}\"\n @width.times do |x|\n @height.times do |y|\n print \"#{@current_generation[x][y]}\" + \" \"\n end\n puts\n end\n puts \"-------------------------------------------------\"\n end",
"def create_graphics\n create_viewport\n @all_window = UI::SpriteStack.new(@viewport)\n create_background\n create_windows\n @all_window.each { |window| window.visible = false } if @delete_game\n @max_index = @all_window.size - 1\n Graphics.sort_z\n refresh\n end",
"def update_tile_graphic\r\n map_data = Yuki::MapLinker.map_datas\r\n if !map_data || map_data.empty?\r\n self.bitmap = RPG::Cache.tileset($game_map.tileset_name)\r\n tile_id = @tile_id - 384\r\n tlsy = tile_id / 8 * 32\r\n max_size = 4096 # Graphics::MAX_TEXTURE_SIZE\r\n src_rect.set((tile_id % 8 + tlsy / max_size * 8) * 32, tlsy % max_size, 32, @height = 32)\r\n else\r\n x = @character.x\r\n y = @character.y\r\n # @type [Yuki::Tilemap::MapData]\r\n event_map = map_data.find { |map| map.x_range.include?(x) && map.y_range.include?(y) } || map_data.first\r\n event_map.assign_tile_to_sprite(self, @tile_id)\r\n @height = 32\r\n end\r\n self.zoom = TILE_ZOOM # _x=self.zoom_y=(16*$zoom_factor)/32.0\r\n self.ox = 16\r\n self.oy = 32\r\n @ch = 32\r\n end",
"def initialize(save_file=nil)\n super()\n\n @tiles = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-icons-16x16.png\").to_s, \n 16, 16,\n retro: true)\n\n @letters = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-font-8x16.png\").to_s,\n 8, 16,\n retro: true)\n\n @tile_scale = Size[2,2]\n @grid_size = Size[32,32]\n @map_size = Size[25,19]\n @window = Window.new(size: Size[800,608])\n @window.on_input= self.method(:on_input)\n @window.on_update= self.method(:on_update)\n @window.on_draw= self.method(:on_draw)\n\n @prng = Random.new\n\n sword = {\n tile_index: 5,\n card_type: :weapon,\n description: \"sword\",\n cooldown: 3,\n cooldown_timer: -1\n }\n\n magic_missile = {\n tile_index: 6,\n card_type: :spell,\n description: \"magic missile\",\n contamination: 3,\n }\n\n meat = {\n tile_index: 4,\n card_type: :item,\n description: \"hunk of meat\",\n }\n\n @player = { \n name: \"Player\",\n tile_index: 0,\n action: nil,\n position: Point[1,1],\n movement: nil,\n card_state: {\n contaminated: true,\n weapon: sword,\n spell: magic_missile,\n item: meat,\n deck: [],\n }\n }\n\n goblin = {\n name: \"Goblin\",\n tile_index: 1,\n action: nil,\n position: Point[3,3],\n movement: nil,\n ai_method: :goblin_ai,\n }\n\n walls = Bitmap.new(MAP_SIZE).from_s(WALLS).active_coords.map do |pt|\n {\n tile_index: 2,\n position: pt,\n obstructing: true\n }\n end\n\n @movement = [@player, goblin]\n @with_cards = [@player]\n @ai_method = [goblin]\n @action = [@player, goblin]\n @visible = [@player, goblin, *walls]\n\n @map = {\n size: Size[20,20],\n index: {\n @player[:position] => [@player],\n goblin[:position] => [ goblin],\n },\n }\n\n @map[:index].default_proc = Proc.new do |hash, key|\n hash[key]= []\n end\n\n walls.each do |entity|\n pos = entity[:position]\n @map[:index][pos] << entity\n end\n end",
"def create_background\n @background = ShaderedSprite.new(@viewport).set_bitmap(name = background_name, :battleback)\n @grounds = Array.new(@battle_scene.logic.bank_count) do |bank|\n BattleUI::GroundSprite.new(@viewport, name, bank)\n end\n end",
"def create_rain_bitmap\r\n @rain_bitmap = Bitmap.new(7, 42)\r\n 7.times {|i| @rain_bitmap.fill_rect(6-i, i*6, 1, 6, particle_color1) }\r\n end",
"def create_snow_bitmap\r\n @snow_bitmap = Bitmap.new(6, 6)\r\n @snow_bitmap.fill_rect(0, 1, 6, 4, particle_color2)\r\n @snow_bitmap.fill_rect(1, 0, 4, 6, particle_color2)\r\n @snow_bitmap.fill_rect(1, 2, 4, 2, particle_color1)\r\n @snow_bitmap.fill_rect(2, 1, 2, 4, particle_color1)\r\n end",
"def load_frames\n\t\tw,h = @_w, @_h # convenience assignments\n\t\twt = 0.8 * w\n\t\tdw = 0.5 * (w-wt) \n\t img = Surface.new([w,h]).fill(@@bg_color)\n\t img.draw_polygon_s([[0,h], [dw,0], [dw+wt,0], [w,h],[0,h]], BROWN)\n\t return [img]\n\tend",
"def create_background_bitmap\n @background.bitmap = Bitmap.new(@width, @height)\n @background.bitmap.fill_rect(0, 0, @width, @height, BORDER_COLOR)\n @background.bitmap.fill_rect(1, 1, @width - 2, @height - 2, BACK_COLOR)\n end",
"def reboot\n img = ['blue_flower', 'red_flower', 'white_flower', 'pink_flower'].sample\n @image = Gosu::Image.new window, 'images/flowers/' + img +'.png', true\n @drawing = true\n end",
"def draw(bx, by, n)\n cw, ch = 32, 32 # cell size\n bx = bx.to_i\n by = by.to_i\n\n imgs = @imgs[n]\n lenx = @bgarr[0].length\n leny = @bgarr.length\n cx = (bx / cw) % lenx\n cy = (by / ch) % leny\n sx = (bx % cw)\n sy = (by % ch)\n wcnt = @wdw_w / cw + 1\n hcnt = @wdw_h / ch + 1\n hcnt.times do |y|\n wcnt.times do |x|\n k = @bgarr[(cy + y) % leny][(cx + x) % lenx]\n imgs[k].draw(x * cw - sx, y * ch - sy, @z + n)\n end\n end\n end",
"def draw_board_start\n #Places the pawns\n 8.times do |x|\n @b[x][1] = @WP\n @b[x][6] = @BP\n end\n #white, on bottom, the opaque pieces\n @b[0][0] = @WR; @b[7][0] = @WR\n @b[1][0] = @WK; @b[6][0] = @WK\n @b[2][0] = @WB; @b[5][0] = @WB\n @b[3][0] = @WQ\n @b[4][0] = @WKg\n #black, on top, the filled in pieces\n @b[0][7] = @BR; @b[7][7] = @BR\n @b[1][7] = @BK; @b[6][7] = @BK\n @b[2][7] = @BB; @b[5][7] = @BB\n @b[3][7] = @BQ\n @b[4][7] = @BKg\n \n #TESTING PIECES HERE\n\n\n draw_board\n end",
"def init_tiles\n # Determine how many frames of animation this autotile has\n for i in 0..6\n bm = @autotiles[i]\n if bm.nil?\n @total_frames = 1\n elsif bm.height > 32\n @total_frames[i] = bm.width / 256\n else\n @total_frames[i] = bm.width / 32\n end\n @current_frame[i] = 0\n end\n # Turn on flag that the tilemap sprites have been initialized\n @tilemap_drawn = true\n \n @animating_tiles.clear\n # Create a sprite and viewport to use for each priority level.\n (0...((SCREEN[0]/32+2) * (SCREEN[1]/32+2))*3).each{|i|\n @tile_sprites[i/3] = [] if @tile_sprites[i/3].nil?\n @tile_sprites[i/3][i%3] = Sprite.new(@viewport) unless @tile_sprites[i/3][i%3].is_a?(Sprite)\n # Rename to something shorter and easier to work with for below\n tile = @tile_sprites[i/3][i%3]\n # Assign tile's respective ID value\n tile.tile_sprite_id = i\n # Draw sprite at index location (ex. ID 0 should always be the top-left sprite)\n tile.x = (i % ((SCREEN[0]/32+2)*3) / 3 * 32) - 32 + (@ox % 32)\n tile.y = (i / ((SCREEN[0]/32+2)*3) * 32) - 32 + (@oy % 32)\n\n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n @corner_tile_loc = [map_x, map_y] if i == 0\n # If the tile happens to be drawn along the outside borders of the map\n if map_x < 0 || map_x >= $game_map.width || map_y < 0 || map_y >= $game_map.height\n tile.z = 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n else # Tile is actually on the map\n tile_id = @map_data[map_x,map_y,i%3]\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = tile.y + @priorities[tile_id] * 32 + 32\n end\n # No tile exists here\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')#@tileset\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384 # non-autotile\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else # autotile\n tile.bitmap = @autotiles[tile_id/48-1]\n tile.src_rect.set(((tile_id % 48) % 8)*32,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[i] = tile if tile.bitmap.width > 256\n end\n end\n }\n # Sprite ID located at top left corner (ranges from 0..map_width * map_height\n @corner_index = 0\n end",
"def create_graphics\n create_viewport\n create_background\n create_buttons\n init_entering\n end",
"def create_image\n\t\tpng = ChunkyPNG::Image.new(@img_width, @img_height, ChunkyPNG::Color::BLACK)\n\t\tpen = ChunkyPNG::Color.rgb(102, 102, 255)\n\n\t\tprev = nil\n\t\ti = 0\n\n\t\tFile.open( 'significant_stop_times.txt', 'r' ).each do |line|\n\t\t\tparts = line.split(',')\n\t\t\t# trip_id,frame_id,sst_stop_id,lat,lng,x,y\n\t\t\ttrip_id = parts[0]\n\t\t\tx = parts[5].to_i\n\t\t\ty = parts[6].to_i\n\n\t\t\tif (!prev.nil?) and prev[:trip_id] == trip_id\n\t\t\t\ti += 1\n\t\t\t\tputs \"#{i} stops drawn\" if i % 10_000 == 0\n\n\t\t\t\t# Draw a line from the previous stop to this one.\n\t\t\t\tpng.line( \n\t\t\t\t\t\tprev[:x], prev[:y],\n\t\t\t\t\t\tx, y,\n\t\t\t\t\t\tpen\n\t\t\t\t\t)\n\t\t\tend\n\t\t\t\n\t\t\tprev = {:x => x, :y => y, :trip_id => trip_id}\n\t\tend\n\n\t\tputs \"Saving.\"\n\t\tpng.save( 'stops.png' )\n\tend",
"def render\n\n # Sets a black background on the screen (Comment this line out and the background will become white.)\n # Also note that black is the default color for when no color is assigned.\n outputs.solids << grid.rect\n\n # The position, size, and color (white) are set for borders given to the world collection.\n # Try changing the color by assigning different numbers (between 0 and 255) to the last three parameters.\n outputs.borders << state.world.map do |x, y|\n [x * state.tile_size,\n y * state.tile_size,\n state.tile_size,\n state.tile_size, 255, 255, 255]\n end\n\n # The top, bottom, and sides of the borders for collision_rects are different colors.\n outputs.borders << state.world_collision_rects.map do |e|\n [\n [e[:top], 0, 170, 0], # top is a shade of green\n [e[:bottom], 0, 100, 170], # bottom is a shade of greenish-blue\n [e[:left_right], 170, 0, 0], # left and right are a shade of red\n ]\n end\n\n # Sets the position, size, and color (a shade of green) of the borders of only the player's\n # box and outputs it. If you change the 180 to 0, the player's box will be black and you\n # won't be able to see it (because it will match the black background).\n outputs.borders << [state.x,\n state.y,\n state.tile_size,\n state.tile_size, 0, 180, 0]\n end"
] | [
"0.7242048",
"0.69752586",
"0.6765756",
"0.6647319",
"0.6641062",
"0.66382104",
"0.6559242",
"0.64883244",
"0.64482284",
"0.6430685",
"0.641923",
"0.63475573",
"0.6343082",
"0.6322847",
"0.6301475",
"0.6280671",
"0.62604064",
"0.6230976",
"0.6205737",
"0.6153527",
"0.61211485",
"0.6118775",
"0.60862035",
"0.6081653",
"0.6081056",
"0.607921",
"0.60490084",
"0.60414714",
"0.59854776",
"0.5974122",
"0.59706986",
"0.59706986",
"0.59683275",
"0.5939548",
"0.5933107",
"0.5914581",
"0.59112024",
"0.59055483",
"0.590448",
"0.5894011",
"0.58832425",
"0.58832425",
"0.58626425",
"0.5858868",
"0.5858794",
"0.585129",
"0.5821829",
"0.5816562",
"0.58053595",
"0.5786513",
"0.578553",
"0.57757163",
"0.5772279",
"0.5770964",
"0.57643926",
"0.57616305",
"0.5755614",
"0.5755341",
"0.57407427",
"0.5739498",
"0.5728417",
"0.5725363",
"0.5720448",
"0.5720126",
"0.57197785",
"0.5717914",
"0.5703782",
"0.56988037",
"0.5692091",
"0.56265444",
"0.562414",
"0.5606972",
"0.56060976",
"0.56000197",
"0.5597852",
"0.5597755",
"0.55919963",
"0.558804",
"0.55877614",
"0.55851924",
"0.55819947",
"0.55819565",
"0.5581297",
"0.5572186",
"0.5566665",
"0.556483",
"0.55555034",
"0.5540172",
"0.5537735",
"0.5535735",
"0.5535324",
"0.55326736",
"0.5526473",
"0.55212575",
"0.5519553",
"0.5518126",
"0.5516479",
"0.551431",
"0.5511649",
"0.5510372"
] | 0.69902235 | 1 |
f("fixed1", "fixed2", conditional1: true, conditional2: false) => "fixed1 fixed2 conditional1" | def css_classes_for(*args)
return nil if args.empty?
conditions = args.extract_options!
classes = args.dup
conditions.each { |clas, condition| classes << clas if condition }
classes.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foo a\r\n if a==1; \"one\" elsif a==2; \"two\" else \"unknown\" end\r\nend",
"def thing(fave_one, fave_two, fave_three)\n \"I love that #{fave_two} too!\"\nend",
"def yeah_or_boo( a,b )\n (a > b) && 'yeah' || 'boo'\nend",
"def boolean_string(rollercoaster)\r\n\tboolean_string = \"\"\r\n\tif rollercoaster[\"floorless\"] == 1\r\n\t\tboolean_string+=\" and it is floorless, \"\r\n\telse\r\n\t\tboolean_string+=\" and it is not floorless, \"\r\n\tend\r\n\r\n\tif rollercoaster[\"wooden\"] == 1\r\n\t\tboolean_string+=\" and it is wooden.\"\r\n\telse\r\n\t\tboolean_string+=\" and it is not wooden.\"\r\n\tend\r\n\treturn boolean_string\r\nend",
"def breakfast(bfood=\"frosted flakes\")\n \"Breakfast is the right time for #{bfood}\"\nend",
"def f\n F_COND()\n end",
"def yeah_or_booh boolean\n boolean && 'yeah' || 'booh'\nend",
"def conditionally(*) end",
"def conditionally(*) end",
"def breakfast(food=\"oatmeal\")\n \"The most important meal of the day could always be #{food}!\"\nend",
"def bar(param = \"no\")\n p param == \"no\" ? \"yes\" : \"no\"\nend",
"def gen_status_string(params)\n ops_string = ''\n if params['status'] != 'null'\n status_keys = { 'Green' => 'false', 'Yellow' => 'false', 'Red' => 'false' }\n\n status_keys['Green'] = params['Green'] if params.key?('Green')\n status_keys['Yellow'] = params['Yellow'] if params.key?('Yellow')\n status_keys['Red'] = params['Red'] if params.key?('Red')\n\n status_keys.each do |key, value|\n next unless value.downcase == 'true'\n\n ops_string << 'or ' if ops_string != ''\n ops_string << \"status = '#{key}' \"\n end\n ops_string\n end\n end",
"def a_method(var1, var2 = 'Nobody')\n puts \"HEJ! #{var1} AND #{var2}\"\nend",
"def age_num_conditional(age, sum, name, fav1, fav2, fav3) \r\n if age > sum\r\n \t\t\"Your age of #{age} is greater than #{sum}, Which is the sum of your favorite numbers.\"\r\n \telse \r\n \t\t\"Your age of #{age} is less than #{sum}, Which is the sum of your favorite numbers.\"\r\n\tend \r\nend",
"def say_hello name1=\"Oscar\", name2=\"Shane\"\n \"hello, #{name1} and #{name2}\"\nend",
"def breakfast(food=\"frosted flakes\")\n \"Morning is the best time for #{food}!\"\nend",
"def wordify_boolean(bool)\n# bool ? t(:\"shared.boolean.yes\") : t(:\"shared.boolean.no\")\n bool ? \"Ja\" : \"Nein\"\n end",
"def breakfast(cereal=\"frosted flakes\")\n \"Morning is the best time for #{cereal}!\"\nend",
"def say_hello_3 name1=\"Bill\", name2=\"Ted\"\n \"hello, #{name1} and #{name2}\"\nend",
"def say_hello3(name1=\"oscar\", name2=\"shane\")\n \"hello, #{name1} and #{name2}\"\nend",
"def toast_english_muffin (toast = 2)\n \"My english muffins need #{toast} minutes in the toaster.\"\nend",
"def to_s\n # My Solution:\n if @filling_type.nil? and [email protected]?\n return \"Plain with #{@glazing}\"\n elsif !@filling_type.nil? and [email protected]?\n return \"#{@filling_type} with #{@glazing}\"\n elsif @filling_type.nil? and @glazing.nil?\n return \"Plain\" \n end\n \n @filling_type\n \n # Alternate Solution (Simpler):\n filling_string = @filling_type ? @filling_type : \"Plain\"\n glazing_string = @glazing ? \" with #{@glazing}\" : ''\n filling_string + glazing_string\nend",
"def okay_to_drink? age, drinking_age\n check >=0 ? \"Come on in\" : \"I'm sorry #{age} ins't old enough to drink. The minimun age is #{drinking_age}.\"\nend",
"def form_flagstring(f, fall)\n\t\tflagSelectAll = (!fall.nil? && fall.to_s.downcase == \"all\")\n\t\tif(flagSelectAll || f.nil? || f.empty?)\n\t\t\tflagStr = \"all\"\n\t\telse\n\t\t\tflagStr = f.join(\"|\")\n\t\tend\n\n\t\treturn flagStr\n\tend",
"def weatherman (condition, temperature)\n if condition == \"rainy\" && temperature == \"cold\"\n puts \"Better stay inside!\"\n elsif condition == \"rainy\" && temperature == \"hot\"\n puts \"Sounds like a gross combination.\"\n elsif condition == \"sunny\" && temperature == \"hot\"\n puts \"Maybe best to go swimming.\"\n elsif condition == \"windy\" && temperature == \"cold\"\n puts \"Bundle up!\"\n elsif condition == \"windy\" && temperature == \"hot\"\n puts \"Tornado warning!\"\n end\nend",
"def say_hello name1=\"oscar\", name2=\"shane\"\n\t\"hello, #{name1} and #{name2}\"\nend",
"def drink_milk(thirsty = true)\n return \"I am not thirsty\" if thirsty == false\nend",
"def two_strings(string_1, string_2)\n p \"When \" + string_1 + \" met \" + string_2 + \".\"\nend",
"def is_it_a_baby(age)\n age < 2 ? \"baby\" : \"not a baby\"\nend",
"def cog\n @cog * (foo? ? bar_adjustment : baz_adjustment)\nend",
"def string_conc(dog, cat)\n p \"#{dog} #{cat} around the house.\"\nend",
"def say (v, msg)\n if v == true\n puts '+ %s' % [msg]\n end\nend",
"def complete_or_not(bool)\r\n bool ? 'complete' : 'not-complete'\r\n end",
"def boolean_to_string(b)\n if true\n \"true\"\n else\n \"false\"\n end\nend",
"def methodWithArgument(first, second = \"all\")\r\n\treturn \"Message: #{first} #{second}\"\r\nend",
"def defVals(par1, opt1 = \"optional one applied\", opt2 = \"optional two applied\") \n puts \"First parameter => #{par1}\"\n puts \"Second parameter => #{opt1}\"\n puts \"Third parameter => #{opt2}\"\nend",
"def can_join_two_strings(string_1, string_2)\n return \"#{string_1}#{string_2}\"\nend",
"def one_two_or_three(n)\n if n == 1\n return 'one'\n elsif n == 2\n return 'two'\n else\n return 'three'\n end\nend",
"def hello_world(lang)\n lang == \"es\" ? result = \"Hola Mundo\" : lang == \"de\" ? result = \"Hallo Welt\" : result = \"Hello World\"\n p result\nend",
"def fn_if(condition, when_true, when_false)\n {\n \"Fn::If\" => [condition, when_true, when_false]\n }\n end",
"def method_two(arg)\n case\n when arg > 0 then \"positive\"\n when arg < 0 then \"negative\"\t\n else \t\t\t\t\"zero\"\t\n end\nend",
"def ternary(statement, true_result, false_result)\n statement && true_result || false_result\nend",
"def to_s\n \"if \" + @condition.to_s + \" then\\n\" + indent(@then_part.to_s) + (else_part.skip? ? \"\" : (\"\\nelse\\n\" + indent(@else_part.to_s))) + \"\\nend\"\n end",
"def _reduce_337(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def _reduce_337(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def to_s(condition_number = 0)\n s = \"\"\n if condition_number == 0 then\n s << if_string(@conditions.first)\n else\n if @conditions[condition_number] then\n s << elsif_string(@conditions[condition_number])\n else\n s << else_string\n end\n end\n return s\n end",
"def concatenation (blow_dryer_setting, male_first_name)\n puts \"but my friends call me #{blow_dryer_setting} #{male_first_name}\"\nend",
"def true_love(a, b)\n p \"#{a} LOVES #{b}\"\nend",
"def if(condition, true_value, false_value)\n {\"Fn::If\" => [condition, true_value, false_value]}\n end",
"def fizz_buzz_or_both(number)\n a1 = divisible_by_3(number)\n a2 = divisible_by_5(number)\n if a1 == true and a2 == true\n b1 = \"fizzbuzz\"\n\n elsif a1 == true and a2 == false\n b1 = \"fizz\"\n\n elsif a1 == false and a2 == true\n b1 = \"buzz\"\n\n end\n return b1\nend",
"def boolean_to_string(b)\n if b \n \"true\"\n else\n \"false\"\n end\nend",
"def should_eat(food, season)\n if food == \"hot chocolate\" && season == \"summer\"\n return \"False\"\n elsif food == \"ice cream\" && season == \"winter\"\n return \"False\"\n else return \"true\"\n end\nend",
"def label(args,i,bool=false)\n\tif bool then return \"(\" + args + \")\\n\"\n\telse return \"(\" + (FUNCTION.length > 0 ? FUNCTION[-1]+\"$\"+args[0] : args[0]) + \")\\n\" end\nend",
"def even_odd(number)\n number.even? ? \"#{number} is even!\" : \"Noo! #{number} is odd!!!\"\n #last line, one statement, this will be auto returned from defined method\nend",
"def things(thing1, thing2)\n puts \"Hey can you get me #{thing1} and #{thing2}. Cool thanks\"\nend",
"def bool_to_string(value)\n return 'yes' if value == true\n return 'no' if value == false\n value # if it doesn't match anything\n end",
"def pretty_output(t, f)\n return \"Case ##{t}: #{f}\"\nend",
"def pretty_output(t, f)\n return \"Case ##{t}: #{f}\"\nend",
"def introduction_with_language_optional(#{name}, #{language})\n puts \"Hi, my name is #{name} and I am learning to code in #{Ruby}!\nend",
"def get_condition_string(table, real = false, withoutrule = -1,options = {}) \n ret = conditions.select{|c| c.valid?(table) }.map {|c| c.sql(table) }\n ret[withoutrule] = nil if withoutrule != -1\n# if not options[:without_date]\n#\tdc = DateCondition.new(\"date\", from_date, to_date, time_description)\n#\tret << [dc.sql]\t \n# end\n ret = ret.compact\n ret = ret.join(\" AND \")\n return nil if ret == \"\"\n return ret\n \n# if not real then\n#\tif options[:negative_set] then\n#\t ret = \"1=1\" if ret == nil\n#\t ret = \"NOT (#{ret})\"\n#\tend\n#\tif options[:global_rule_number] then\n#\t if options[:banished_set] then\n#\t c = get_condition_string(true,options[:global_rule_number])\n#\t c = \"1=1\" if c == nil\n#\t ret += \" AND #{c}\"\n#\t else\n#\t ret += \" AND #{get_condition(options[:global_rule_number])}\"\n#\t end\n#\tend\n# end \n end",
"def stringy(integer, optional = 1)\n return_string = ''\n if optional == 1\n integer.times { |idx| idx.even? ? return_string << '1' : return_string << '0' }\n elsif optional == 0\n integer.times { |idx| idx.even? ? return_string << '0' : return_string << '1' }\n end\n return_string\nend",
"def buy_burger(menu, potato: true, drink: true)\n \"menu: #{menu} / potato: #{potato} /drink: #{drink}\"\nend",
"def condition(num1,num2)\n if num1<num2\n \"Yes #{num1} < #{num2}\"\n else\n \"No! #{num1} > #{num2}\"\n end\nend",
"def string_argument(drink1, drink2)\n p \"My favorite drink is #{drink1}, but I really like #{drink2} too\"\nend",
"def odd_or_even(number)\n number.odd? ? \"The number is odd\" : \"The number is even\"\nend",
"def pizza_party(pizza_count, cup_count, plate_count = 0)\n # prints interpolated string with 'pizza_count' argument\n puts \"we have #{pizza_count} pizzas\"\n # prints interpolated string with 'cup_count' argument\n puts \"we have #{cup_count} cups\"\n #prints interpolated string with 'plate_count' argument\n puts \"we have #{plate_count} plates\"\n # if all 3 arguments value equals 0 puts string\n if plate_count == 0 || cup_count == 0 || pizza_count == 0\n # prints string\n puts \"Hmm, we need more supplies!\"\n # otherwise, if pizza_count (made into float) modulo 1 does not = 0 puts strings\n # in other words, if pizza_count is not a whole number.\n elsif pizza_count.to_f % 1 != 0\n # prints string\n puts \"did someone already start eating the pizza?\"\n # if both if statements are false, puts string\n else\n # prints string\n puts \"Enough for everyone, let's eat.\"\n # end of if statement\n end\n# end of method\nend",
"def is_goal(x, w, goal)\n return 'NO' if x > goal || (x < goal && w == 0)\n return 'YES' if x == goal\n return ''\n\nend",
"def render_output_of_ternary(ternary_arr, df_data)\n value_for_field_name(ternary_arr[0], df_data).present? ? ternary_arr[1] : ternary_arr[2]\n end",
"def conditional_format packet\n packet.inject([]){ |a, (field_name, field_value)|\n a + ((extensions.conditional_reply_format[field_name] || {})[field_value] || [])\n }\n end",
"def interpolate_strings(string1, string2)\n p \"#{string1} is cooler than #{string2}\"\nend",
"def _reduce_353(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def _reduce_353(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def _reduce_353(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def _reduce_353(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def _reduce_353(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def food(food)\n case food\n when \"burger\"\n \"bad food\"\n when \"apple\"\n \"good\"\n else\n \"nice\"\n end\nend",
"def what_are_filled_in( a=5 , b=4 , c=3 , d=2 , e=1 )\n \"#{a} #{b} #{c} #{d} #{e}\"\nend",
"def short_long_short(string1, string2)\r\n if string1.length > string2.length\r\n \"#{string2}#{string1}#{string2}\"\r\n else\r\n \"#{string1}#{string2}#{string1}\"\r\n end\r\nend",
"def mess_with_vars(_one, _two, _three)\n one = 'two'\n two = 'three'\n three = 'one'\nend",
"def sayHello( name=\"Stranger\", adjective=\"stinky\" )\n puts \"Hello #{ adjective } #{ name }\"\n \"hotdogs hotdogs hotdogs\"\nend",
"def ext_fact(value='BASIC')\n \"test: '#{value}'\"\n end",
"def water_description(temperature)\nif temperature < 0\n return \"ice\"\nelsif temperature > 100\nreturn \"steam\"\nelse\n return \"water\"\nend\nend",
"def conditional_format packet\n packet.inject([]){ |a, (field_name, field_value)|\n a + ((extensions.conditional_request_format[field_name] || {})[field_value] || [])\n }\n end",
"def even_or_odd(number)\n number.even? ? \"Even\" : \"Odd\"\nend",
"def some_method(x)\n if x > 5 && x < 10\n return :a\n elsif x < 5\n return :b\n end # else??\n \n :c\nend",
"def cheese_and_crackers(cheese_count, boxes_of_crackers)\n # print a string that interpolates the cheese_count parameter\n puts \"You have #{cheese_count} cheeses!\"\n # print a string that interpolates the boxes_of_crackers parameter\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n # print a string\n puts \"Man that's enough for a party!\"\n # print a string\n puts \"Get a balnket.\\n\"\nend",
"def foo a\r\n if a==1\r\n then name=\"one\"\r\n elsif a==2\r\n then name=\"two\"\r\n else\r\n name=\"unknown\"\r\n end\r\nend",
"def wrap_text(hello, blank )\n return \"#{blank}#{hello}#{blank}\"\nend",
"def even_or_odd(number)\n number.even? ? 'That number is even ' : 'That number is odd'\nend",
"def _reduce_336(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def breakfast(food=\"Frosted flakes\")\n puts \"#{food} is a great meal for breakfast!\"\nend",
"def _reduce_349(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def fizzbuzz num\n case \"#{num%3 == 0}#{num%5 == 0}\".gsub(/false/,\"-\").gsub(/true/,\"o\")\n when \"o-\" then \"Fizz\"\n when \"-o\" then \"Buzz\"\n when \"oo\" then \"FizzBuzz\"\n when \"--\" then nil\n end\nend",
"def good_recipes(arg1, *rest)\n \"The deserts will be #{arg1} and #{rest.join(', ')}\" # the string has embedded two variables, the second variable 'rest' is defined by the 'join' method, which is basicly saying, join the rest of the strings with a comma and a space\nend",
"def my_method(first: nil, second: nil)\n puts \"First is #{first} and second is #{second}\"\nend",
"def mess_with_vars(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\n return one, two, three\nend",
"def all_optionals_available_condition(prior_segments)\n optional_locals = prior_segments.collect { |s| s.local_name if s.optional? && s.respond_to?(:local_name) }.compact\n optional_locals.empty? ? nil : \" if #{optional_locals * ' && '}\"\n end",
"def make_if test, zero, not_zero\n noop = \":\"\n \"if [ \\\"0\\\" -eq \\\"$#{test}\\\" ]; then #{zero || noop}; else #{not_zero || noop} ; fi\"\n end",
"def _reduce_354(val, _values, result)\n result = s(:if, val[1], val[3], val[4])\n \n result\nend",
"def complex_condition?(condition); end",
"def getFoobar(d)\n\tif (d % 3 == 0 && d % 5 == 0)\n\t return \"Foobar\"\n\telsif (d % 3 == 0)\n\t return \"Foo\"\n\telsif (d % 5 == 0)\n\t return \"Bar\"\n\telse\n\t return d\n\tend \nend"
] | [
"0.62455",
"0.6011409",
"0.58554053",
"0.58431995",
"0.583929",
"0.5825008",
"0.5817523",
"0.57702065",
"0.57702065",
"0.5703952",
"0.56303495",
"0.5625525",
"0.55876",
"0.5579959",
"0.5552538",
"0.5548991",
"0.5539984",
"0.5519309",
"0.549717",
"0.5458062",
"0.54541546",
"0.5451858",
"0.54165405",
"0.53915864",
"0.5388122",
"0.5384552",
"0.5354948",
"0.5344614",
"0.53441375",
"0.5343448",
"0.5342854",
"0.5342585",
"0.5333344",
"0.5328813",
"0.5328348",
"0.5327064",
"0.53193384",
"0.53106886",
"0.5309534",
"0.53090566",
"0.5308015",
"0.5303534",
"0.5302835",
"0.5292712",
"0.5292712",
"0.52616113",
"0.5233975",
"0.52270144",
"0.52239245",
"0.52234966",
"0.5222732",
"0.5220161",
"0.5211552",
"0.5200078",
"0.5195848",
"0.5195322",
"0.5185237",
"0.5185237",
"0.51840216",
"0.5170032",
"0.5167854",
"0.51658213",
"0.5163313",
"0.5155733",
"0.51549226",
"0.5143942",
"0.5142432",
"0.5134832",
"0.5132189",
"0.51231027",
"0.51198024",
"0.51198024",
"0.51198024",
"0.51198024",
"0.51198024",
"0.511618",
"0.5115391",
"0.51064324",
"0.5096083",
"0.50954187",
"0.5093527",
"0.50912",
"0.5090762",
"0.50894827",
"0.508647",
"0.5085053",
"0.50781465",
"0.5070334",
"0.5068639",
"0.50633144",
"0.50601965",
"0.50551337",
"0.5051872",
"0.50501275",
"0.5045065",
"0.50448334",
"0.5044703",
"0.50445735",
"0.5043969",
"0.50421923",
"0.5041998"
] | 0.0 | -1 |
superclass overrides to deal with issues found | def on_callback_path?
# path comparison was failing due to trailing / needed in callback_path option
on_path?(callback_path.delete_suffix("/"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errors\n raise 'Method should implemented in inherit class'\n end",
"def issue(*)\n raise NotImplementedError, 'This should be defined in a subclass'\n end",
"def wrapped_causes; end",
"def failure\n super\n end",
"def onerror(&blk); super; end",
"def process_fix\n super\n end",
"def failure\n super\n end",
"def original_error; end",
"def original_error; end",
"def overrides; end",
"def process_hook\n fail 'child class to implement'\n end",
"def fail(*args)\n super(*args)\n end",
"def process_hook\n fail 'sub class to implement'\n end",
"def errorhandling\n end",
"def process\n raise Error::new(\"This method should be implemented by a subclass\")\n end",
"def exceptions; end",
"def validate\n fail 'sub class to implement'\n end",
"def miss_reason; end",
"def dispatch\n raise(NotImplemetedError, \"subclass responsability\")\n end",
"def tag; raise 'Override this method'; end",
"def repair!\n raise NotImplementedError\n end",
"def cause\n raise NotImplementedError\n end",
"def cause; end",
"def cause; end",
"def special\n override\n end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def actual_flow_control\n super\n end",
"def error!\n throw NotImplementedError\n end",
"def missing; end",
"def private; end",
"def initialize\n @broken = false\n end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def problems\n\t\t\treturn nil\n\t\tend",
"def underlying_exception; end",
"def error?; end",
"def error?; end",
"def error?; end",
"def doManipulation(contents); raise \"Abstract Exception: doManipulation must be extended\"; end",
"def check_errors;\n end",
"def original_exception; end",
"def method_missing(name, *args, &bl)\n @parent ? @parent.__send__(name, *args, &bl) : super\n rescue NoMethodError => ex\n name = ex.message[/`(.*?)'/, 1]\n ::Kernel.raise NoMethodError, \"Not found `#{name}` on #{self}\"\n end",
"def missing?; end",
"def errback &block\n super\n end",
"def errback &block\n super\n end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def inherited(base); end",
"def catch_exceptions; end",
"def exec_fix\n super\n end",
"def implementation\n fail 'Subclasses must implement implementation()!'\n end",
"def validate_options!(_options)\n raise(NotImplemetedError, \"subclass responsability\")\n end",
"def error(description, result)\n raise \"Implement this in a sub-class\"\n end",
"def oops exception\n error \"Unexpected error while checking for issue's parent newspaper object #{exception}\"\n error exception.backtrace\n return nil\n end",
"def errors=(_); end",
"def expected_error(x)\n raise NotImplementedError, \"Define #{__method__}() in the inherited class.\"\n end",
"def continued_exception; end",
"def invalid_reason\n if defined?(super) == \"super\"\n raise Error::RGeoError, \"ValidityCheck MUST be loaded before \" \\\n \"definition of #{self.class}##{__method__}.\"\n end\n\n raise Error::UnsupportedOperation, \"Method #{self.class}##{__method__} not defined.\"\n end",
"def exception_meaning_command_not_found\n subclass_must_implement!\n end",
"def validate_subclasses\n # Validate instance methods\n if not(self.respond_to?(:scrape_article))\n throw Exception.new(\"subclass fails to implement the required scrape method\")\n end\n\n # Validate class methods\n if not(self.class.respond_to?(:source_name))\n throw Exception.new(\"subclass fails to provide source_name\")\n end\n\n end",
"def wrapped_exception; end",
"def failsafe_action\n super\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def invalid; end",
"def update_status_to_processed\n fail 'child class to implement'\n end",
"def missed?; end",
"def failsafe_state\n super\n end",
"def checks; end",
"def method_731(base); end",
"def subclass_responsibility\n raise SubclassResponsibility.exception\n end",
"def base\n @base ||= Failures.new\n end",
"def notify_on_errs\n !(super == false)\n end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def exceptions\n end",
"def fallbacks; end",
"def fallbacks; end",
"def inherited(_sub)\n raise Error, \"cannot subclass #{self}\" unless self == Object\n end",
"def expects_exception?; self.class.expects_exception; end",
"def implementation; end",
"def implementation; end",
"def abstract?; end",
"def underlying_exception=(_arg0); end",
"def generate_new_item_object\n FlyError::raise_superclass_error\n end"
] | [
"0.70418084",
"0.6783789",
"0.6609213",
"0.65850514",
"0.6546582",
"0.65158474",
"0.6497864",
"0.6317366",
"0.6317366",
"0.62574524",
"0.6256722",
"0.6234005",
"0.6222967",
"0.6214903",
"0.6211196",
"0.61958206",
"0.6153782",
"0.61146486",
"0.6104191",
"0.60779",
"0.60733485",
"0.6039106",
"0.601448",
"0.601448",
"0.6011427",
"0.5993608",
"0.5993608",
"0.5993608",
"0.5993608",
"0.5993608",
"0.5993608",
"0.5993608",
"0.5986036",
"0.59788835",
"0.5972924",
"0.5968028",
"0.59595424",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5950476",
"0.5948745",
"0.5946454",
"0.59463185",
"0.59463185",
"0.59463185",
"0.59397554",
"0.5935193",
"0.59305626",
"0.5920089",
"0.59055525",
"0.5903805",
"0.5903805",
"0.5896469",
"0.5896469",
"0.5896469",
"0.5896469",
"0.5896469",
"0.5891199",
"0.587889",
"0.5878531",
"0.587334",
"0.587244",
"0.5871628",
"0.58708656",
"0.5866813",
"0.5866497",
"0.58644044",
"0.5838306",
"0.58345956",
"0.58237076",
"0.5823015",
"0.58212626",
"0.5808511",
"0.5808511",
"0.5808511",
"0.58029807",
"0.580249",
"0.5796981",
"0.5795433",
"0.57921654",
"0.5776879",
"0.5760382",
"0.5757324",
"0.5754534",
"0.5751877",
"0.57450503",
"0.57375365",
"0.57375365",
"0.5722578",
"0.571285",
"0.5710777",
"0.5710777",
"0.57030123",
"0.5692019",
"0.5666934"
] | 0.0 | -1 |
~ Instance methods ......................................................... | def contains?(date_or_time)
starts_on <= date_or_time && date_or_time < ends_on
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def initialize\n\t\t\n\tend",
"def implementation; end",
"def implementation; end",
"def initialize\r\n\r\n end",
"def initialize\n \n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize\n\n end",
"def initialize\n\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize()\r\n\r\n end",
"def initialize() end",
"def initialize\n \n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def initialize()\n\t\tend",
"def initialize\n\n\n\n end",
"def initialize\n \n end",
"def initialize\n \n end",
"def init\n\n end",
"def initialize\n end",
"def instance; end",
"def instance; end",
"def instance; end",
"def initialize\n\t\nend",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize()\n\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def internal; end",
"def initialize()\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n # complete\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize()\n\tend",
"def initialize()\n\tend",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def initialize\n super \n end",
"def custom; end",
"def custom; end",
"def initialize()\n end",
"def initialize()\n end",
"def init; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize\n # nothing here for now\n end",
"def initialize\n end",
"def probers; end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end"
] | [
"0.837986",
"0.74969923",
"0.7377104",
"0.7377104",
"0.73759943",
"0.7366034",
"0.73333216",
"0.73333216",
"0.73333216",
"0.73333216",
"0.7287168",
"0.7287168",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.7225678",
"0.7208306",
"0.7194885",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.7177731",
"0.71206576",
"0.71206576",
"0.7114551",
"0.70504963",
"0.7013548",
"0.7013548",
"0.6986952",
"0.6969038",
"0.6934643",
"0.6934643",
"0.6934643",
"0.6912668",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6899994",
"0.6852726",
"0.6848588",
"0.6848588",
"0.6848588",
"0.6848588",
"0.6848588",
"0.6848588",
"0.68473494",
"0.6841525",
"0.6811998",
"0.6811998",
"0.6811998",
"0.680385",
"0.67996687",
"0.67996687",
"0.67996687",
"0.67962027",
"0.67962027",
"0.67928934",
"0.67928934",
"0.67928934",
"0.67928934",
"0.6789743",
"0.67837834",
"0.67837834",
"0.6779668",
"0.6779668",
"0.6778688",
"0.67555565",
"0.67555565",
"0.67555565",
"0.67555565",
"0.67550117",
"0.67550117",
"0.67550117",
"0.6750649",
"0.67470825",
"0.6744533",
"0.67400134",
"0.67400134",
"0.67179644",
"0.67086",
"0.67086",
"0.67086"
] | 0.0 | -1 |
Returns this user's Holding object for a given outcome. | def holdings_of(outcome)
holdings.where(outcome: outcome).first || NullHolding.new(self, outcome)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_holding\n @holding = current_user.holdings.find(params[:id])\n end",
"def set_user_holding\n @user_holding = UserHolding.find(params[:id])\n end",
"def set_loot_outcome\n @loot_outcome = LootOutcome.find(params[:id])\n end",
"def set_holding\n @holding = Holding.find(params[:id])\n end",
"def hold amount=nil, meta=nil\n self.account.hold(amount, meta, self.uri)\n end",
"def hold amount=nil, meta=nil\n self.account.hold(amount, meta, self.uri)\n end",
"def current_wallet\n # currency_wallet\n @participant ? betting_pool_wallet : points_wallet\n end",
"def create\n @holding = current_user.holdings.build(holding_params)\n\n respond_to do |format|\n if @holding.save\n format.html { redirect_to @holding, notice: 'Holding was successfully created.' }\n format.json { render :show, status: :created, location: @holding }\n else\n format.html { render :new }\n format.json { render json: @holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @user_holdings = UserHolding.all\n end",
"def set_hold\n @hold = Hold.find_by(id: params[:id])\n end",
"def set_hold\n @hold = Hold.find(params[:id])\n end",
"def bowler_winner(id)\n win_bowler = Bowler.find_by_id(id) \n return win_bowler\n end",
"def bought_by(new_owner)\r\n self.owner = new_owner\r\n self.to_inactive\r\n end",
"def create\n @user_holding = UserHolding.new(user_holding_params)\n\n respond_to do |format|\n if @user_holding.save\n format.html { redirect_to @user_holding, notice: 'User holding was successfully created.' }\n format.json { render :show, status: :created, location: @user_holding }\n else\n format.html { render :new }\n format.json { render json: @user_holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def borrower_paid_outside_closing\n purchase_credits.where(:name => 'BorrowerPaidOutsideClosing').first.value rescue nil\n end",
"def user_own(user_id)\n trade_lines.each do |x|\n if x.inventory_own.user_id == user_id\n return x\n end\n end\n end",
"def the_goal\n UserGroup::PAYMENT_GOALS[goal.to_sym] if goal\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @hours_already_bid = @reward.hours_already_bid_by(current_user)\n @hours_entry = HoursEntry.new\n @bid = Bid.new\n end",
"def ts_holds_by_user_and_hold_id(user, hold_id)\n holds.where(:user_id => user.id, :id => hold_id).where.not(status: ['cancelled', 'closed'])\n end",
"def hold amount, meta={}, source_uri=nil\n hold = Hold.new(\n :uri => self.holds_uri,\n :amount => amount,\n :meta => meta,\n :source_uri => source_uri,\n )\n hold.save\n end",
"def holds_for_user(user, hold_id)\n return [] unless user\n \n if hold_id.present?\n ts_holds_by_user_and_hold_id(user, hold_id)\n else\n ts_holds_by_user(user)\n end\n end",
"def betting_pool\n betting_pools.first\n end",
"def fetch_outcome_by_uid(uid, name)\n Rails.cache.fetch(\"outcome_#{uid}_#{name}\") do\n Outcome.find_or_create_by(name: name, uid: uid)\n end\n end",
"def set_outcome\n @outcome = Outcome.find(params[:id])\n end",
"def get_bet\n @bet = @player.make_bet\n end",
"def outcome\n status.first\n end",
"def get_holds(user, **opt)\n return unless (cid = account_id(user))\n get_data('users', cid, 'holds', opt)\n data = response&.body&.presence\n IlsHolds.new(data, error: @exception)\n end",
"def user\n if user_id\n super\n else\n billable_to.owner # always a User\n end\n end",
"def set_stronghold\n @stronghold = Stronghold.find(params[:id])\n end",
"def bid(item, amount)\r\n if can_bid?(item, amount)\r\n previous_winner = item.current_winner\r\n previous_max_bid = item.highest_bid.nil? ? 0 : item.bidders[previous_winner]\r\n\r\n item.bidders[self] = amount\r\n\r\n # reduce money if user is new winner, otherwise nothing happens\r\n current_winner = item.current_winner\r\n current_max_bid = item.bidders[current_winner]\r\n\r\n previous_winner.credits += previous_max_bid unless previous_winner.nil?\r\n current_winner.credits -= current_max_bid\r\n#Do not always send mail for demo purposes\r\n=begin\r\n if !previous_winner.nil? && previous_winner != current_winner\r\n # we got a new winner\r\n\r\n Security::MailDispatcher.send_new_winner_mail(previous_winner.email, item) unless [nil, \"\"].include?(previous_winner.email)\r\n end\r\n=end\r\n else\r\n raise TradeError, \"INVALID_BID\" #Bid is too small or already exists or user doesn't have enough money.\r\n end\r\n end",
"def index\n @holdings = Holding.all\n end",
"def destroy\n @loot_outcome.destroy\n end",
"def show\n @chance = @user.chance\n @loans = @user.loans.order(purchase_date: :desc)\n end",
"def create\n @holding = Holding.new(params[:holding])\n\n respond_to do |format|\n if @holding.save\n format.html { redirect_to @holding, notice: 'Holding was successfully created.' }\n format.json { render json: @holding, status: :created, location: @holding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def held?\n status == 'Held'\n end",
"def held?\n status == 'Held'\n end",
"def choice_a_hold\n item_id = @item_list[@index]\n return action_b if item_id.nil?\n return play_buzzer_se if item_id == 0 || !GameData::Item[item_id].holdable\n\n play_decision_se\n @running = false\n @return_data = @item_list[@index]\n end",
"def balance_for(other_user)\n Money.new(all_balances[other_user.id], 'PLN')\n end",
"def ts_holds_by_user(user)\n holds.where(:user_id => user.id).where.not(status: ['cancelled', 'closed'])\n end",
"def account_locked\n @user = User.find(params[:id])\n end",
"def loot_outcome_params\n params.fetch(:loot_outcome, {})\n end",
"def new_round\n take_bets\n set_hands\n show_hands\n if @player.chip_pool >= @player_bet\n hit_or_stay\n else\n hit_or_stay_cont\n end\n @dealer.hit_til_stay unless @player.hand.bust\n show_dealer_hand\n if !(@dealer.hand.bust)\n winning_hand\n else\n dealer_bust\n end\n end",
"def get(id=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id)\n\t\t\tclient.queue_service_action_call('household', 'get', 'KalturaHousehold', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def set_tombstone_timehold\n @tombstone_timehold = TombstoneTimehold.find(params[:id])\n end",
"def check_if_user_owns_bowling_game\n bowling_game = BowlingGame.where(user_id: current_user.id, id: params[:id]).take\n if !bowling_game\n redirect_to bowling_games_path\n else\n @bowling_game_id = params[:id]\n end\n end",
"def set_user_household_ledger\n @user_household_ledger = UserHouseholdLedger.find(params[:id])\n end",
"def chance_for_mutual(to, champion, probability)\r\n\t\toutput = nil\r\n\t\tif rand < probability\r\n\t\t\tmutual_honor = MutualHonor.where(from: self.player_id, to: to).first\r\n\t\t\tif mutual_honor.nil?\r\n\t\t\t\tmutual_honor = MutualHonor.new\r\n\t\t\t\tmutual_honor.from = self.player_id\r\n\t\t\t\tmutual_honor.to = to\r\n\t\t\tend\r\n\t\t\tmutual_honor.champion = champion\r\n\t\t\tmutual_honor.timestamp = Time.now\r\n\t\t\tmutual_honor.save\r\n\t\t\t\r\n\t\t\t# Reload to ensure that the autogenerated id is filled.\r\n\t\t\toutput = MutualHonor.where(from: self.player_id, to: to).includes(:from_object, :to_object, :champion_object).first\r\n\t\tend\r\n\t\toutput\r\n\tend",
"def top_bidder\n User.find(self.bids.find_by_highest(self.top_bid).user_id)\n end",
"def chose_weapon\n if @class == 'Water'\n chosen_weapon = Weapon.new \n return chosen_weapon.water_weapons\n end\n end",
"def cancel_hold\n if self.status == 'Held'\n create_delivery('HoldCancelled', :details => \"The hold on this validation has been removed without action.\")\n end\n end",
"def user_need(user_id)\n trade_lines.each do |x|\n if x.inventory_need.user_id == user_id\n return x\n end\n end\n end",
"def owned_by_user(user)\n CompletedFeat.find_by_user_id_and_feat_id(user.id, self.id)\n end",
"def fetch_user\n user = Twitter.user(screen_name)\n Lead.from_twitter(user)\n end",
"def create_loan\n # helper method to create a loan and return that loan\n options = { holder: test_holder, borrowed: 1000, term: 2, rate: 2 }\n # hash of key value pairs to initialise loan\n Loan.new(options, 5)\n # creates loan and returns it\n end",
"def cancel_hold\n if self.status == 'Held'\n create_delivery('HoldCancelled', :details => \"The hold on this message has been removed without action.\")\n end\n end",
"def check_checking # returns the user's checking account balance\n puts \"##{@account_number} Checking Amount: $%d\" % @checking_amount\n self\n end",
"def current_poet\n Poet.find_by(id: session[:user_id])\n end",
"def current_ballot\n self.ballots.includes(:nominations, :voting_period).order(:created_at).last\n end",
"def return_item_from_bay(user_input_raw, input_hash)\n user_input_sym = user_input_raw.to_sym\n if input_hash.key?(user_input_sym)\n then return input_hash[user_input_sym]\n else\n print 'No such bay found'\n end\n end",
"def get_due_time(user)\n Borrowing.find_by(user_id: user.id, book_id: self.id)\n .due_date\n end",
"def on_hold?\n status == :inactive\n end",
"def get_target_food_balance\n bal_id = nil\n if self.balance_id.nil? or self.balance_id == 0\n ## Add new standard balance\n new_balance = Balance.create_default_balance(self.id)\n self.balance_id = new_balance.id\n self.save!\n bal_id = new_balance.id\n else\n bal_id = self.balance_id\n end\n\n bal = Balance.find_by_id(bal_id)\n protein = bal.protein\n starch = bal.grain\n vegetable = bal.veg\n return {:protein => protein, :vegetable => vegetable, :starch => starch}\n end",
"def past\n @bookings = Booking.completed(current_user)\n end",
"def get_user(uid)\n @inv = User.find_by_id(uid)\n end",
"def party_worth\n get_worth_of( shared_inventory + actors_inventory )\n end",
"def show\n @holding = Holding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holding }\n end\n end",
"def time_on_hold(current_time = Time.now)\n\n on_hold = ReviewStatus.find(:first,\n :conditions => \"name='Review On-Hold'\")\n\n return 0 if self.review_status_id != on_hold.id\n current_time.age_in_seconds(self.placed_on_hold_on)\n\n end",
"def set_hold_request\n @hold_request = HoldRequest.find(params[:id])\n end",
"def set_hold_request\n @hold_request = HoldRequest.find(params[:id])\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def hold\n action('hold')\n end",
"def loaded_user\n user_type == 'MeetupUser' ? meetup_user : bridgetroll_user\n end",
"def show\n @bid = current_user.bids.where(auction_id: params[:auction_id]).order(amount: :desc).offset(1).first\n end",
"def bookings_requested\n # select * from bookings where patient_id = current_user.id\n @bookings_requested = current_user.bookings\n end",
"def evaluate_item_with_target(target)\r\n target.result.clear\r\n target.make_damage_value(subject, item)\r\n if item.for_opponent?\r\n return target.result.hp_damage.to_f / [target.hp, 1].max\r\n else\r\n recovery = [-target.result.hp_damage, target.mhp - target.hp].min\r\n return recovery.to_f / target.mhp\r\n end\r\n end",
"def current_bid\n return nil if current_user.nil?\n if auction.available? && auction.single_bid?\n auction.bids.detect {|bid| bid.bidder_id == current_user.id }\n else\n auction.current_bid\n end\n end",
"def borrow_object\n @mutex.synchronize {\n if !@idle_list.empty?\n result = @idle_list.shift\n \n elsif @active_list.size < @config.max_active\n result = create_with_timestamp\n \n elsif @active_list.size >= @config.max_active\n raise CommonPoolError, \"Max number of %d active objects reached.\" % @config.max_active\n \n else\n begin\n timeout(@config.timeout){ @cond.wait(@mutex) }\n rescue TimeoutError\n raise TimeoutError, \"#{@config.timeout} seconds request timeout reached.\"\n end\n result = @idle_list.shift\n end\n @active_list.store(result[1].__id__, result)\n \n logger.debug(\"* Get #{result[1]}\") if logger\n result[1]\n }\n end",
"def result # :nodoc:\n winning_strategy && winning_strategy.result\n end",
"def current_dwelling\n @current_dwelling ||= current_user.dwelling if current_user\n end",
"def status(user_id)\n goal_status = self.goal_statuses.where(user_id: user_id).first\n if goal_status.nil?\n goal_status = GoalStatus.new(goal_id: self.id, user_id: user_id)\n goal_status.value = goal_status.progress\n end\n goal_status\n end",
"def get_bills_for_user(user)\n bills = BillPart.where(participant_id:user.id).map(&:id)\n end",
"def check_bet\r\n (padding,pronoun) = self.is_a?(User) ? [29,\"You\"] : [32,\"Player ##{player_id+1}\"]\r\n puts \"\\n%#{padding}s\\n\" % \"#{pronoun} checked.\"\r\n end",
"def ready\n @investment = Investment.where(user_id: current_user.id).last\n end",
"def get_rental_object(rental_made)\n selected_car = select_rented_car(rental_made.car_id)\n Rental.new(selected_car, rental_made, @rules_level)\n end",
"def pay_owner(rental)\n # make credit operation on balanced\n balanced.credit(rental)\n\n # account it on subledger\n subledger.credit(rental)\n end",
"def billable_hours_for_user\n return @billable_hours_for_user if defined?(@billable_hours_for_user)\n\n @billable_hours_for_user = nil\n\n return @billable_hours_for_user if user_id.blank?\n\n scope_for_time_entries = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_user = cf.format.cast_total_value(cf, total)\n end",
"def set_militarystronghold\n @militarystronghold = Militarystronghold.find(params[:id])\n end",
"def find_or_create_household_unit\n if household_units.blank?\n hu = HouseholdUnit.create!\n HouseholdPersonLink.create!(:person => self, :household_unit => hu, :hh_rank_code => 1)\n else\n hu = household_units.first\n end\n return hu\n end",
"def checkout\n @user = User.find(session[:user_id])\n end",
"def get_box\n @picker.clear_hands\n fput \"get ##{@box_id}\"\n @current_box = GameObj.right_hand.id == @box_id ? GameObj.right_hand : GameObj.left_hand\n end",
"def obj\n the_choice\n end",
"def capture_holding_time(totem, waiting_since_hash_user_id)\n user_holding_time_in_seconds = Time.now.to_i - waiting_since_hash_user_id.to_i\n user_holding_time_in_minutes = user_holding_time_in_seconds / 60\n send_gauges_to_signalFX(\"totems:holding_time:#{totem}\",user_holding_time_in_minutes)\n end",
"def holdable_is_holdable\n return unless holdable.present? && !holdable.class.holdable?\n errors.add(:holdable, T.er('holding.must_be_holdable',\n model: holdable.class.to_s))\n end",
"def show\n if logged_in?\n @house_hunter = HouseHunter.find_by(id: current_user.id)\n end\n end",
"def bully\n if self.name[0,1] == \"J\"\n # binding.pry\n self.budget -= 150\n # binding.pry\n return \"The bully stole half of my money!\"\n else\n return \"AHH i'm running away!\"\n end\n end",
"def set_household_item\n @household_item = @moving.household_items.find(params[:id])\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def hold(value)\n key = \"h%020x\" % rand(1 << 80)\n @holdings[key] = value\n key\n end",
"def completed_bid\n completed_response.present? ? completed_response.bid : nil\n end"
] | [
"0.6100916",
"0.5879758",
"0.5676972",
"0.5650062",
"0.5148491",
"0.5148491",
"0.51346636",
"0.5113165",
"0.50934076",
"0.50280094",
"0.5016231",
"0.49437737",
"0.49345815",
"0.49307293",
"0.4896056",
"0.48681924",
"0.48611388",
"0.4850958",
"0.4830227",
"0.48171467",
"0.4786498",
"0.4786141",
"0.47847465",
"0.47655088",
"0.47531462",
"0.47409725",
"0.4736634",
"0.47351155",
"0.472831",
"0.47107512",
"0.4708812",
"0.46934086",
"0.4683909",
"0.46830717",
"0.46696684",
"0.46696684",
"0.46694222",
"0.466106",
"0.46540004",
"0.46500257",
"0.46417263",
"0.46370074",
"0.4634626",
"0.46334228",
"0.46212783",
"0.46168458",
"0.46151003",
"0.46029893",
"0.45892796",
"0.45749936",
"0.45683473",
"0.45535195",
"0.45522767",
"0.45506135",
"0.4543131",
"0.45410264",
"0.45407748",
"0.45385507",
"0.45351812",
"0.4526672",
"0.45245862",
"0.45240048",
"0.4509225",
"0.45061642",
"0.4499903",
"0.44902757",
"0.44829106",
"0.44796667",
"0.44796667",
"0.44683084",
"0.44596276",
"0.4453317",
"0.44531903",
"0.44525102",
"0.44509882",
"0.44488403",
"0.44447187",
"0.4434963",
"0.44285884",
"0.44181374",
"0.44108874",
"0.4407545",
"0.44066232",
"0.44057894",
"0.44027194",
"0.43988362",
"0.4394115",
"0.4392387",
"0.43862054",
"0.43824938",
"0.43814874",
"0.4380715",
"0.43783912",
"0.43771684",
"0.43705705",
"0.43639588",
"0.43623292",
"0.43623292",
"0.4360469",
"0.43590385"
] | 0.7762998 | 0 |
Create a new domain model object based on the given array of models. The given models are assumed to be subclasses of ActiveRecord::Base. | def initialize(models = [], options = {})
@models, @options = models, RailsERD.options.merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instantiate_models(model_class, source)\n return nil if source.nil?\n\n source = prepare_source model_class, source\n\n case source\n when Array\n source.map { |entry| instantiate_models model_class, entry }\n when Hash\n instantiate_model_from_attributes_hash model_class, source\n else\n raise ArgumentError, \"#{model_class}: can't instantiate from a source of type #{source.class}\"\n end\n end",
"def build(data_list)\n @models = []\n\n data_list.each do |data|\n @models << @klass.new(data)\n end\n end",
"def load_models(dirs)\n dirs.each do |base|\n Dir[\"#{base}**/*.rb\"].each do |file|\n model_name = file.gsub(/^#{base}([\\w_\\/\\\\]+)\\.rb/, '\\1')\n next if model_name.nil?\n next if ::ActiveRecord::Base.send(:subclasses).detect { |model| model.name == model_name }\n begin\n model_name.camelize.constantize\n rescue LoadError\n model_name.gsub!(/.*[\\/\\\\]/, '').nil? ? next : retry\n rescue NameError\n next\n end\n end\n end\n end",
"def models=(data_list)\n @models = []\n\n unless data_list.nil? || data_list.empty?\n data_list.each do |data|\n @models << data if data.is_a?(@klass)\n # @todo Put error in logs on invalid types\n end\n end\n end",
"def create_models\n @target_prefix = target.blank? ? '' : (target.camelize + '::')\n models = options[:models] || MODELS\n model_names = options[:names] || MODELS\n models.zip(model_names).each do |original_name, new_name|\n @model_name = new_name.camelize\n template \"#{original_name}.rb\",\n \"app/models/#{target}/#{@model_name.underscore}.rb\"\n end\n end",
"def models!\n # load '../db/schema.rb'\n \n models = Object.constants.map {|c| Object.const_get(c)}.select {|c| c.is_a?(Class) && c.superclass == ActiveRecord::Base}\n models = models.map(&:to_s)\n \n # This erases the class definitions, as long as nothing ELSE is holding onto a ref -- possibly controllers?\n models.each do |c|\n Object.instance_eval {remove_const c}\n end\n \n # Allow Kernel.require to re-load these models when references to them crop up\n # \"tableize.singularize\" is effective, but not airtight\n models.each do |c|\n $\".reject! {|x| x =~ /app\\/models\\/#{c.tableize.singularize}/}\n end\n \n # Hopefully the auto-loader can do the rest of the work for us\n \n # TODO: What about those pesky namespaced models and controllers?\n end",
"def initialize(models, params={})\n @models = models\n @extensions = params[:extensions] || ['.json']\n @identifying_sym = params[:identifying_sym] || :flat_db\n build!\n end",
"def models\n @models ||= self.model_names.map {|x| x.constantize}\n end",
"def instantiate(records, klass, owner = self)\n records = splat(records)\n records.map do |record|\n klass.new(owner, record)\n end\n end",
"def many(model, sql, params={})\n sql_query(sql, params).map { |h| model.new(h) }\n end",
"def retrieve_models(env)\n # Parse either the \"MODEL\" environment variable or the \"MODELS\"\n # environment variable, with \"MODEL\" taking precedence.\n models_env = env['MODEL'] || env['MODELS']\n\n # If there was a use models environment variable, split it and\n # convert the given model string (e.g. \"User\") to an actual\n # model constant (e.g. User).\n #\n # If a models environment variable was not given, use descendants of\n # ActiveRecord::Base as the target set of models. This should be all\n # model classes in the project.\n models = if models_env\n models_env.split(',')\n .collect {|x| x.strip.underscore.singularize.camelize.constantize }\n else\n ActiveRecord::Base.descendants\n end\n\n\n # Filter the set of models to exclude:\n # - The ActiveRecord::SchemaMigration model which is internal to Rails\n # and should not be part of the dumped data.\n # - Models that don't have a corresponding table in the database.\n # - Models whose corresponding database tables are empty.\n filtered_models = models.select do |model|\n !ACTIVE_RECORD_INTERNAL_MODELS.include?(model.to_s) && \\\n model.table_exists? && \\\n model.exists?\n end\n end",
"def generate_models\n (translation.tables + translation.polymorphic_tables).each do |table|\n build_model(table)\n end\n end",
"def instantiate_models(schema, value)\n if schema.type == 'record' && schema.model_class\n if value.is_a? schema.model_class\n value # we get called twice on unions due to schema resolution; only instantiate models once\n elsif schema.model_class < RootModel\n value # allow subclassing of the root model\n else\n schema.model_class.new(value)\n end\n else\n value\n end\n end",
"def classify(obj=[])\n if obj.is_a? Airtable::Record\n [self.new(obj.fields)]\n elsif obj.respond_to? :map\n obj.map{|r| self.new(r.fields) }\n else\n raise AlienObject.new(\"Object is neither an array nor an Airtable::Model\")\n end\n end",
"def load_models(hash, namespaces = [])\n models = []\n\n # first handle all normal models\n if models_hash = hash[\"models\"]\n models_hash.each_pair do |model_name, model_properties|\n models << Model::Base.new(model_name, model_properties, :namespaces => namespaces, :reader => self)\n end\n end\n \n # go into recursion to handle the models under a namespace\n if found_namespaces = hash[\"namespaces\"]\n found_namespaces.each_pair do |namespace, models_under_namespace|\n models += load_models(models_under_namespace, namespaces + [namespace])\n end\n end\n\n models\n end",
"def load_models\n @models = []\n # Load Models and Schema for corresponding orm\n re = /^.*\\/(.*).rb$/\n Dir[\"#{ROOT}/models/#{@orm.to_s}/*\"].each { |c| \n require c \n match = c.match(re)\n @models << Extlib::Inflection.constantize(Extlib::Inflection.camelize(match[1])) if match\n }\n end",
"def create_models\n @name = name.singularize.downcase\n @name_plural = @name.pluralize\n @attributes = attributes\n template(\"./templates/model.erb\", \"./models/#{@name}.rb\")\n end",
"def load_models\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_get_models\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'get'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n\n models = []\n array = json['models']\n array.each do |item|\n model = Dynamicloud::API::Model::RecordModel.new item['id'].to_i\n model.name = item['name']\n model.description = item['description']\n\n models.push model\n end\n\n models\n end",
"def initialize(*elements)\n unless elements.all? {|elt| elt.kind_of?(BasicModel)}\n raise ArgumentError.new(elements)\n end\n @elements = elements\n end",
"def fetch_for_models(models)\n return {} if models.empty?\n\n contact_uuids = models.map(&:contact_uuid)\n fetch_multiple_master_contacts(contact_uuids)\n end",
"def create_indexes(models = ::Mongoid.models)\n models.each do |model|\n next if model.index_specifications.empty?\n unless model.embedded?\n model.create_indexes\n logger.info(\"MONGOID: Created indexes on #{model}:\")\n model.index_specifications.each do |spec|\n logger.info(\"MONGOID: Index: #{spec.key}, Options: #{spec.options}\")\n end\n model\n else\n logger.info(\"MONGOID: Index ignored on: #{model}, please define in the root model.\")\n nil\n end\n end.compact\n end",
"def initialize(join_models, base_model, join_filters=[])\n @join_models = join_models\n @base_model = base_model\n @join_filters = join_filters\n end",
"def models(join_ids = nil, page = nil, where = {})\n models = self.where(where)\n models = models.page(page) unless page.nil?\n models = join_habtm(models, join_ids) if join_ids\n\n models\n end",
"def export_models(models)\n relations_for(models).each(&method(:add_to_package))\n end",
"def load_models(paths = model_paths)\n paths.each do |path|\n if preload_models.resizable?\n files = preload_models.map { |model| \"#{path}/#{model.underscore}.rb\" }\n else\n files = Dir.glob(\"#{path}/**/*.rb\")\n end\n\n files.sort.each do |file|\n load_model(file.gsub(/^#{path}\\// , \"\").gsub(/\\.rb$/, \"\"))\n end\n end\n end",
"def model_to_create(attributes)\n Sufia.config.model_to_create.call(attributes)\n end",
"def model_name(models)\n models.kind_of?(Array) ? models.first.class.name : models.class.name.underscore.singular\n end",
"def model_name(models)\n models.kind_of?(Array) ? models.first.class.name : models.class.name.underscore.singular\n end",
"def create_objects(apps_config, changed_apps = [])\n debug 'create objects'\n apps_config.each do |app_name, app_cfg|\n update_or_create_application(app_name, app_cfg.clone) if changed_apps.include?(app_name)\n end\n\n # sorting applications\n @applications.sort_by!(&:name)\n end",
"def nested_models(*models)\n models.each do |model|\n nested_model model\n end\n end",
"def models\n @models ||= []\n end",
"def preload_models \n ActiveRecord::Base.connection.tables.each do |model| \n begin \n \"#{model.classify}\".constantize \n rescue Exception \n end \n end \n end",
"def initialize(*elts)\n unless elts.empty?\n if elts.find{|val| not(val.kind_of?(BasicModel))}\n raise ArgumentError.new(elts)\n end\n unless elts.map{|val| val.pione_model_type}.uniq.size == 1\n raise ArgumentError.new(elts)\n end\n end\n @values = elts\n end",
"def fullfilled_model=(models)\n if !models.respond_to?(:to_ary)\n raise ArgumentError, \"expected an array, got #{models}\"\n elsif !models.all? { |t| t.kind_of?(Roby::Models::TaskServiceModel) || (t.respond_to?(:<=) && (t <= Roby::Task)) }\n raise ArgumentError, \"expected a submodel of TaskService, got #{models}\"\n end\n\n @fullfilled_model = models\n end",
"def model_classes\n @opts[:models]\n end",
"def load_objects\n instance_variable_set(\"@#{model_name.underscore.pluralize}\", (@instances = model.where(params || {}) rescue nil))\n end",
"def create_model_class(name, columns={}, &class_body)\n if name.is_a?(Hash) && name.size == 1\n class_name, superclass_name = *name.to_a.flatten\n else\n class_name, superclass_name = name, 'ActiveRecord::Base'\n end\n need_table = superclass_name.to_s == 'ActiveRecord::Base'\n\n table_name = class_name.to_s.underscore.pluralize\n if need_table\n ActiveRecord::Base.connection.create_table(table_name) do |table|\n columns.each do |column_name, column_type|\n table.send column_type, column_name\n end\n end\n end\n klass = Class.new(superclass_name.to_s.constantize, &class_body)\n Object.const_set(class_name, klass)\n end",
"def updateModels(json)\n if json.is_a?(Array)\n models = []\n for jsonPart in json\n model = buildModel(jsonPart)\n if model.present?\n model.save\n models << model\n end\n end\n return models\n else\n model = buildModel(json)\n if model.present?\n model.save\n return model\n end\n end\n end",
"def newInstance( params={} )\n model.new( params ).extend( InstanceMethods )\n end",
"def generate_models\n if options[:namespace]\n empty_directory(\"app/models/#{options[:namespace].downcase}\")\n generate_base_namespaced_model\n end\n discovered_tables.each do |table_name|\n @model_name = model_name_from_table_name table_name\n @model_file_name = model_file_name_from_table_name table_name\n @columns = connection.columns(table_name)\n @indexes = connection.indexes(table_name)\n @associations = detected_associations(table_name, @columns)\n template 'model.rb', \"app/models/#{options[:namespace] ? options[:namespace]+'/' : ''}#{@model_file_name}.rb\"\n end\n puts %Q(config.autoload_paths += %W(\\#{config.root}/app/models/#{options[:namespace].downcase})) if options[:namespace]\n end",
"def requested_models(requested_model)\n case requested_model\n when /^(.+)[(](.+)[)]$/ #handle model(with associations), i.e. Image(for scene A)\n base_model = $1.classify.constantize\n scopes = $2.split(',')\n models = base_model\n\n scopes.each do |scope|\n models = models.send(scope.strip)\n end\n\n models.all\n\n when String #is name\n requested_model.singularize.constantize.all\n else\n requested_model.all\n end\nend",
"def initialize(*objs)\n @objs = objs\n end",
"def load_models\n puts \"=> Loading models\"\n Dir.glob(File.join(app_path,'app/models/*.rb')).each { | model | \n require model \n }\n end",
"def create_indexes_for_all_models\n required_types.values.each do |required_type_class_object|\n required_type_class_object.send(:create_indexes)\n end\n end",
"def run\n all_models_superclass.singleton_class.prepend(Valle::ActiveRecordExt)\n end",
"def unpack\n all.each do |model|\n klass = model.name.split('::').last\n Kernel.const_set(klass, model) unless Kernel.const_defined?(klass)\n end\n end",
"def unpack\n all.each do |model|\n klass = model.name.split('::').last\n Kernel.const_set(klass, model) unless Kernel.const_defined?(klass)\n end\n end",
"def create(attrs = {})\n if attrs.is_a?(Array)\n attrs.map { |attr| create(attr) }\n else\n build(attrs).tap(&:save)\n end\n end",
"def create_fedora_objects(model, attributes)\n ::Importer::Factory.for(model.to_s).new(attributes, @files_directory, files(attributes)).run\n end",
"def models\n project_models.select do |klass|\n !klass.abstract_class? &&\n klass.connection.table_exists?(klass.table_name) &&\n !klass.name.include?('HABTM_')\n end\n end",
"def generate_model\n\t\tclasses = CartesianClassifier.get_classes(Sample.find_all_by_classname(params[:classnames].split(',')))\n\t\tclassmodel = ClassModel.new({\n\t\t\t:classnames => params[:classnames], # split and join again for validation?\n\t\t\t:modelstring => ActiveSupport::JSON.encode(classes),\n\t\t\t:author => params[:author],\n\t\t\t:notes => params[:notes]\n\t\t})\n\t\tclassmodel.save\n\t\tredirect_to \"/\"\n end",
"def build(array)\n array.map { |record| Restforce::SObject.new(record, @client) }\n end",
"def load_models\n Dir[File.dirname(__FILE__) + \"#{File::SEPARATOR}models#{File::SEPARATOR}*.rb\"].each do |file|\n load file\n end\n end",
"def load_all_models\n Dir[\"#{Rails.root}/app/models/**/*.rb\"].each { |file_path| require file_path rescue nil }\n end",
"def models\n @models ||= Prepares.models\n end",
"def build(attributes)\n self.model_instance ||= (base.kind_of?(Class) ? base.new(attributes) : base.build(attributes))\n end",
"def ranges_to_models(clazz, *ranges)\n ranges.collect do |min, max|\n clazz.create! min: min, max: max\n end\nend",
"def create(model={})\n create_new_model(model, :create)\n end",
"def add(klass)\n @models << klass\n end",
"def replace(models)\n ids = models.map(&:id)\n\n model.synchronize do\n redis.queue(\"MULTI\")\n redis.queue(\"DEL\", key)\n ids.each { |id| redis.queue(\"SADD\", key, id) }\n redis.queue(\"EXEC\")\n redis.commit\n end\n end",
"def construct_model(record, reflection, id, attributes, seen, model_cache)\n klass = if reflection.polymorphic?\n record.send(reflection.foreign_type).constantize\n else\n reflection.klass\n end\n\n model = model_cache[klass][id] ||= klass.instantiate(attributes)\n other = record.association(reflection.name)\n\n if reflection.collection?\n other.target.push(model)\n else\n other.target = model\n end\n\n other.set_inverse_instance(model)\n model\n end",
"def update_models(json)\n if json.is_a?(Array)\n model_ids = []\n for json_part in json\n model = save_model_with(json_part)\n model_ids << \"#{model.id}\".to_i if model.present?\n end\n where(:id).in model_ids\n else\n model = save_model_with(json)\n return nil if model.blank?\n\n find(\"#{model.id}\".to_i)\n end\n end",
"def create!(attrs = {})\n if attrs.is_a?(Array)\n attrs.map { |attr| create!(attr) }\n else\n build(attrs).tap(&:save!)\n end\n end",
"def build(base, object, type = nil, selected_fields = nil)\n return [] if object.blank?\n return object if object.first.is_a?(Document)\n docs = []\n object.each do |attrs|\n if _loading? && base.persisted?\n docs.push(Factory.execute_from_db(klass, attrs, nil, selected_fields, execute_callbacks: false))\n else\n docs.push(Factory.build(klass, attrs))\n end\n end\n docs\n end",
"def build_model(table)\n model = Mongify::Mongoid::Model.new(class_name: table.name.classify, table_name: table.name)\n model.polymorphic_as = table.polymorphic_as if table.polymorphic?\n #TODO: Might need to check that model doesn't already exist in @models\n @models[table.name.downcase.to_sym] = model\n model\n end",
"def all(model)\n store.all(table: table_name).map {|data| model.new data}\n end",
"def use_with_class_names\n (\n DynamicModel.model_names +\n ExternalIdentifier.model_names +\n ActivityLog.model_names +\n Master::PrimaryAssociations\n )\n .map { |m| m.to_s.singularize }\n .select { |m| m != 'master' }\n end",
"def models(*entities)\n visited_models = Set.new\n filter = lambda {|n| visited_models.add?(n.model)}\n nodes(*entities, filter: filter).map(&:model)\n end",
"def build_model_sequences\n [Organization, Person, Deal, Project, LedgerTransaction, Invoice].each do |model_class|\n\n model_class_name = model_class.name\n if model_sequences.select { |ms| ms.model_class == model_class_name }.empty?\n\n sequence = ModelSequence.new\n sequence.model_class = model_class_name\n\n # Set the current value to 9999 for all but ledger transactions.\n sequence.current_value = 9999 unless model_class == LedgerTransaction\n\n model_sequences << sequence\n\n end\n\n end\n end",
"def create_fedora_objects(attributes)\n fc = factory_class(model)\n f = fc.new(attributes, files_directory)\n f.run\n end",
"def new_model(defaults = {})\n if parent_model\n # is it a has_many\n if parent_model.respond_to?(plural_model_name)\n new_model = parent_model.send(plural_model_name).build(defaults)\n # is is a has_one\n elsif parent_model.respond_to?(model_name)\n new_model = parent_model.send(\"build_#{model_name}\", defaults)\n else\n raise \"can't find association #{model_name} or #{plural_model_name} for #{parent_model.class.name}\"\n end\n else\n new_model = model_name.camelize.constantize.new(defaults)\n end\n return new_model\n end",
"def initialize\n self.models = Hash[\n MongoMapper::Document.descendants.select { |c| c.name }.map { |c|\n [c.name.tableize, c]\n }\n ]\n end",
"def replace(models)\n ids = models.map(&:id)\n\n model.synchronize do\n redis.queue(\"MULTI\")\n redis.queue(\"DEL\", key)\n ids.each { |id| redis.queue(\"RPUSH\", key, id) }\n redis.queue(\"EXEC\")\n redis.commit\n end\n end",
"def build_model_with(json)\n return nil if json.is_a?(Array)\n\n model = where(\"id\").eq(json[\"id\"]).first || self.new \n model.wrap(json)\n end",
"def build(*args)\n model = generate(*args)\n model.save\n model\n end",
"def build(attrs = {})\n attrs[:type] ? attrs[:type].constantize.new(attrs) : new(attrs)\n end",
"def create_or_find_associated_objects(base_object, errors, params, klass, associated_params_key, action = :create_or_find)\n associated_objects = []\n\n return nil unless ap = params[associated_params_key.to_s]\n\n ap.each do |associated_params|\n if associated_params.is_a?(ApplicationRecord)\n associated_objects.push(associated_params)\n else\n if action == :find_only\n errors[associated_params_key] = \"can only have an :id param\"\n else\n associated_object = klass.new(associated_params.merge(account: base_object.account))\n associated_object.valid?\n errors[associated_params_key] = associated_object.errors.messages if associated_object.errors.messages.present?\n associated_objects.push(associated_object)\n end\n end\n end\n\n associated_objects\n end",
"def replace(models)\n ids = models.map(&:id)\n redis.del(key)\n redis.sadd(key, ids) unless ids.empty?\n end",
"def load_models(app)\n return unless ::Mongoid.preload_models\n app.config.paths[\"app/models\"].each do |path|\n Dir.glob(\"#{path}/**/*.rb\").sort.each do |file|\n load_model(file.gsub(\"#{path}/\" , \"\").gsub(\".rb\", \"\"))\n end\n end\n end",
"def add_base_model(model, *keys)\n # {{{\n add_foreign_key_to(model, *keys)\n @base_klasses[model.table_name] = [ model, *keys ]\n @base_klasses_tree[model.table_name] = model.__associations__.base_klasses_tree\n @aggregates_tree[model.table_name] = model.__associations__.aggregates_tree\n keys.flatten.each { |attribute|\n @accessor.__attributes__.set_implicit(@accessor.table_name, attribute)\n }\n @primary_keys.update(model.__associations__.primary_keys)\n @pkey_value_lookup += model.__associations__.pkey_value_lookup\n @pkey_value_lookup << [ model.table_name, \n keys.flatten, \n model.__associations__.primary_keys[model.table_name] ]\n if model.is_polymorphic? then\n @polymorphics[model.table_name] = model.polymorphic_attribute\n model.__associations__.add_concrete_model(@accessor)\n end\n @join_tables << model.table_name\n inherit(model)\n end",
"def load(objects)\n self.records = (objects || []).map { |object| new(object) }\n self.loaded = true\n self\n end",
"def create_model(model, sql, params=[])\n model.new(vertex_to_hash(run_sql(sql, params)))\n end",
"def load_models!\n require \"models\"\n end",
"def random_objects_with_max(max, model_type)\n number_of_objects = Random.rand(1..max)\n objects = []\n number_of_objects.times do |index|\n objects[index] = create(model_type)\n end\n objects\nend",
"def models\n @models ||= {}\n end",
"def load_all_models\n return if @models_loaded\n load_models_from File.join(RAILS_ROOT, 'app', 'models', '**', '*.rb') if(defined? RAILS_ROOT)\n load_models_from File.join(TALIA_CODE_ROOT, 'lib', 'talia_core', 'source_types', '**', '*.rb'), 'TaliaCore::SourceTypes::'\n TaliaCore::Source\n TaliaCore::Collection\n\n @models_loaded = true\n end",
"def load_adaptors(*args)\n adaptors.map do |adaptor_klass|\n next unless adaptor_supports?(adaptor_klass, args)\n instantiate_adaptor(adaptor_klass, args)\n end.compact\n end",
"def generate_model\n invoke \"active_record:model\", [name], :migration => false unless model_exists? && behavior == :invoke\n if store_in == 'active_record'\n invoke \"active_record:model\", [ACTIVE_RECORDABLE], :migration => false unless active_recordable_exists? && behavior == :invoke\n end\n end",
"def scaffold_all_models(*models)\n models = parse_scaffold_all_models_options(*models)\n model_names = []\n scaffold_results = models.collect{|model, options| model_names << model.to_s; scaffold(model, options)}.compact\n code = <<-\"end_eval\"\n def index\n @models = #{model_names.inspect}\n render_scaffold_template(\"index\")\n end\n end_eval\n scaffold_results.length > 0 ? scaffold_results.push(code).join(\"\\n\\n\") : module_eval(code, __FILE__)\n end",
"def new(attrs = {})\n obj = self.model.new\n attrs.each do |k,v|\n obj.send(\"#{k}=\", v)\n end\n obj\n end",
"def load_into_database(options={})\n # necessary to make multiple invocations possible in a single test\n # case possible\n ActiveRecord::Fixtures.reset_cache\n\n # Filter down the models to load if specified\n the_tables = if options.has_key?(:only)\n self.table_names.select {|x| Array(options[:only]).map(&:to_s).include?(x) }\n elsif options.has_key?(:except)\n self.table_names.select {|x| !Array(options[:except]).map(&:to_s).include?(x) }\n else\n self.table_names\n end\n raise \"No models to load, relax your :only or :except filters (or don't bother calling this method)\" if the_tables.empty?\n\n\n #This wraps all the inserts into a single transaction allowing the constraint check to happen at the end.\n ActiveRecord::Base.transaction do\n\n the_tables.each do |table_name|\n class_name = if self.table_name_to_model_name_hash.kind_of?(Hash)\n self.table_name_to_model_name_hash[table_name]\n else\n ActiveSupport::Deprecation.warn \"your fe_manifest.yml does not contain a table_name_to_model_name_hash (as found in 1.0.0 or earlier). Version 2.0.0 will require this. See test cases for how to manually jigger your fe_manifest.ymls to function.\"\n nil\n end\n if options[:map].nil?\n # Vanilla create_fixtures will work fine when no mapping is being used\n ActiveRecord::Fixtures.create_fixtures(self.target_path, table_name)\n else\n # Map table_name via a function (great for prefixing)\n new_table_name = if options[:map].kind_of?(Proc)\n options[:map].call(table_name)\n # Map table_name via a Hash table name mapping\n elsif options[:map][table_name].kind_of? String\n options[:map][table_name]\n else\n table_name # No mapping for this table name\n end\n fixtures = ActiveRecord::Fixtures.new( ActiveRecord::Base.connection,\n new_table_name,\n class_name,\n ::File.join(self.target_path, table_name))\n fixtures.table_rows.each do |the_table_name,rows|\n rows.each do |row|\n ActiveRecord::Base.connection.insert_fixture(row, the_table_name)\n end\n end\n end\n # FIXME: The right way to do this is to fork the oracle enhanced adapter\n # and implement a reset_pk_sequence! method, this is what ActiveRecord::Fixtures\n # calls. aka this code should be eliminated/live elsewhere.\n case ActiveRecord::Base.connection.adapter_name\n when /oracle/i\n model = class_name.constantize\n if model.column_names.include? \"id\"\n sequence_name = model.sequence_name.to_s\n max_id = model.maximum(:id)\n next_id = max_id.nil? ? 1 : max_id.to_i + 1\n begin\n ActiveRecord::Base.connection.execute(\"drop sequence #{sequence_name}\")\n rescue\n puts \"[Iron Fixture Extractor] WARNING: couldnt drop the sequence #{sequence_name}, (but who cares!)\"\n end\n begin\n q=\"create sequence #{sequence_name} increment by 1 start with #{next_id}\"\n ActiveRecord::Base.connection.execute(q)\n rescue\n puts \"[Iron Fixture Extractor] WARNING: couldnt create the sequence #{sequence_name}\"\n end\n end\n else\n # Do nothing, only oracle adapters need this\n end\n end\n end # End transaction\n end",
"def initialize(attrs = {})\n @nested_model_instances = {}\n \n self._nested_models.each do |model|\n model_class = model.to_s.classify.constantize\n \n if attrs.include?(model)\n @nested_model_instances[model] = initialize_nested_model(model_class, attrs[model])\n else\n @nested_model_instances[model] = initialize_nested_model(model_class)\n end\n end\n \n self._dependencies.each do |from, tos|\n tos.each do |to|\n @nested_model_instances[from].public_send(\"#{to.to_s}=\", @nested_model_instances[to])\n end\n end\n end",
"def each_model(options = {}, &block)\n WingedCouch::Model.subclasses.each do |klass|\n if options[:raise_exceptions] and not klass.database.exist?\n raise %Q{Database for model #{klass.name} doesn't exist, run rake winged_couch:db:create}\n end\n block.call(klass)\n end\n end",
"def provided_models\n if model = explicit_fullfilled_model\n [model[0]] + model[1]\n else\n models = self.model.fullfilled_model\n if (task_class = models.find { |m| m.kind_of?(Class) })\n [task_class] + models.find_all { |m| !task_class.has_ancestor?(m) }\n else\n models\n end\n end\n end",
"def require_models\n model_files.each { |model| require_item(model, @model_path) }\n end",
"def test_model_model_get\n models = %w(Model1 Model2 Model3 Model4)\n values = [%w(one1 many1 belong1 att1 ser1), %w(one2 many2 belong2 att2 ser2), %w(one3 many3 belong3 att3 ser3)]\n models.each do |model_name|\n assert model = Microformats::Models.model_get(model_name), \"Failed to get new model #{model}\"\n assert_equal model.name, \"Microformats::Models::#{model_name}\", \"Name for model #{model} not set correctly\"\n # setup the initial values and test they are what we expect\n assert model.have_one << values[0][0], \"Failed to append #{values[0][0]} to #{model.name}.have_one\"\n assert model.have_many << values[0][1], \"Failed to append #{values[0][1]} to #{model.name}.have_many\"\n assert model.belong_to << values[0][2], \"Failed to append #{values[0][2]} to #{model.name}.belong_to\"\n assert model.validations << values[0][3], \"Failed to append #{values[0][3]} to #{model.name}.validations\"\n assert model.serialize << values[0][4], \"Failed to append #{values[0][4]} to #{model.name}.serialize\"\n # check they are there\n assert_equal model.have_one[0], values[0][0], \"Expected #{values[0][0]} but was #{model.have_one[0]}\"\n assert_equal model.have_many[0], values[0][1], \"Expected #{values[0][1]} but was #{model.have_many[0]}\"\n assert_equal model.belong_to[0], values[0][2], \"Expected #{values[0][2]} but was #{model.belong_to[0]}\"\n assert_equal model.validations[0], values[0][3], \"Expected #{values[0][3]} but was #{model.validations[0]}\"\n assert_equal model.serialize[0], values[0][4], \"Expected #{values[0][4]} but was #{model.serialize[0]}\"\n # append a 2nd value\n assert model.have_one << values[1][0], \"Failed to append #{values[1][0]} to #{model.name}.have_one\"\n assert model.have_many << values[1][1], \"Failed to append #{values[1][1]} to #{model.name}.have_many\"\n assert model.belong_to << values[1][2], \"Failed to append #{values[1][2]} to #{model.name}.belong_to\"\n assert model.validations << values[1][3], \"Failed to append #{values[1][3]} to #{model.name}.validations\"\n assert model.serialize << values[1][4], \"Failed to append #{values[1][4]} to #{model.name}.serialize\"\n # check it is there\n assert_equal model.have_one[1], values[1][0], \"Expected #{values[1][0]} but was #{model.have_one}\"\n assert_equal model.have_many[1], values[1][1], \"Expected #{values[1][1]} but was #{model.have_many}\"\n assert_equal model.belong_to[1], values[1][2], \"Expected #{values[1][2]} but was #{model.belong_to}\"\n assert_equal model.validations[1], values[1][3], \"Expected #{values[1][3]} but was #{model.validations}\"\n assert_equal model.serialize[1], values[1][4], \"Expected #{values[1][4]} but was #{model.serialize}\"\n # try to add a duplicate\n assert_nil model.have_one << values[1][0], \"Should not be able to append #{values[1][0]} to #{model.name}.have_one\"\n assert_nil model.have_many << values[1][1], \"Should not be able to append #{values[1][1]} to #{model.name}.have_many\"\n assert_nil model.belong_to << values[1][2], \"Should not be able to append #{values[1][2]} to #{model.name}.belong_to\"\n assert_nil model.validations << values[1][3], \"Should not be able to append #{values[1][3]} to #{model.name}.validations\"\n assert_nil model.serialize << values[1][4], \"Should not be able to append #{values[1][4]} to #{model.name}.serialize\"\n # check the orginals are still valid\n assert_equal model.have_one[0], values[0][0], \"Expected #{values[0][0]} but was #{model.have_one[0]}\"\n assert_equal model.have_many[0], values[0][1], \"Expected #{values[0][1]} but was #{model.have_many[0]}\"\n assert_equal model.belong_to[0], values[0][2], \"Expected #{values[0][2]} but was #{model.belong_to[0]}\"\n assert_equal model.validations[0], values[0][3], \"Expected #{values[0][3]} but was #{model.validations[0]}\"\n assert_equal model.serialize[0], values[0][4], \"Expected #{values[0][4]} but was #{model.serialize[0]}\"\n # re-define the whole shooting match\n# model.have_one, model.have_many, model.belong_to, model.validations = *values[2]\n# assert_equal model.have_one[0], values[2][0], \"Expected #{values[2][0]} but was #{model.have_one[0]}\"\n# assert_equal model.have_many[0], values[2][1], \"Expected #{values[2][1]} but was #{model.have_many[0]}\"\n# assert_equal model.belong_to[0], values[2][2], \"Expected #{values[2][2]} but was #{model.belong_to[0]}\"\n# assert_equal model.validations[0], values[2][3], \"Expected #{values[2][3]} but was #{model.validations[0]}\"\n # and is this the only attribute\n# assert_equal model.have_one.length, 1, \"Expected 1 value but got #{model.have_one}\"\n# assert_equal model.have_many.length, 1, \"Expected 1 value but got #{model.have_many}\"\n# assert_equal model.belong_to.length, 1, \"Expected 1 value but got #{model.belong_to}\"\n# assert_equal model.validations.length, 1, \"Expected 1 value but got #{model.validations}\"\n end\n # test the enumerator\n end",
"def parse_scaffold_all_models_options(*models)\n options = models.pop if models.length > 0 && Hash === models[-1]\n generate = options.delete(:generate) if options\n except = options.delete(:except) if options\n only = options.delete(:only) if options\n except.collect!(&:to_s) if except\n only.collect!(&:to_s) if only\n models = ActiveRecord::Base.all_models if options || models.length == 0\n models.delete_if{|model| except.include?(model)} if except\n models.delete_if{|model| !only.include?(model)} if only\n models.collect do |model|\n scaffold_options = {:suffix=>true, :scaffold_all_models=>true, :generate=>generate, :habtm=>model.to_s.camelize.constantize.scaffold_habtm_reflections.collect{|r|r.name.to_s.singularize}}\n scaffold_options.merge!(options[model.to_sym]) if options && options.include?(model.to_sym)\n scaffold_model = scaffold_options.delete(:model_id) || model.to_sym\n [scaffold_model, scaffold_options]\n end\n end",
"def configure_models(model)\n model_queue.each do |o|\n o.each do |k, v|\n model.add_model k, v\n end unless o.nil?\n end\n end",
"def make_inputs(inputs)\n inputs.map(&method(:new))\n end",
"def models\n work_classes + collection_classes\n end"
] | [
"0.6667679",
"0.6140844",
"0.59559953",
"0.5891997",
"0.5807097",
"0.5717256",
"0.5671524",
"0.56481475",
"0.562234",
"0.5579276",
"0.5532433",
"0.55264795",
"0.5514828",
"0.5514298",
"0.5505385",
"0.53988016",
"0.5269133",
"0.5204758",
"0.5195574",
"0.51075447",
"0.5092658",
"0.50799817",
"0.50643367",
"0.5052637",
"0.50323915",
"0.50215983",
"0.5006422",
"0.5006422",
"0.49961302",
"0.49891362",
"0.49739212",
"0.49661538",
"0.49629575",
"0.49535272",
"0.4928298",
"0.49134102",
"0.48756602",
"0.48671865",
"0.48638806",
"0.48487365",
"0.48428613",
"0.48413312",
"0.48217127",
"0.48168704",
"0.4811571",
"0.4806699",
"0.4806699",
"0.48036054",
"0.48028898",
"0.4796665",
"0.478925",
"0.47889087",
"0.47802633",
"0.4770545",
"0.47625583",
"0.47615904",
"0.4750202",
"0.47404006",
"0.47331238",
"0.47296837",
"0.47198457",
"0.47192642",
"0.4710036",
"0.47037825",
"0.47037548",
"0.46943533",
"0.46825543",
"0.46616027",
"0.46547732",
"0.46360052",
"0.4627085",
"0.46241572",
"0.4620718",
"0.4617964",
"0.46139354",
"0.46099386",
"0.46052206",
"0.45996732",
"0.4598312",
"0.4598207",
"0.4593956",
"0.4576944",
"0.4560557",
"0.4552939",
"0.45385855",
"0.45344546",
"0.45330164",
"0.451748",
"0.45108607",
"0.4508264",
"0.45068446",
"0.45011252",
"0.44975212",
"0.44971132",
"0.44965893",
"0.4494856",
"0.44933373",
"0.4480482",
"0.4474275",
"0.44727793"
] | 0.58664167 | 4 |
Returns the domain model name, which is the name of your Rails application or +nil+ outside of Rails. | def name
defined? Rails and Rails.application and Rails.application.class.parent.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_name\n @model.name.demodulize.downcase # ex: posts\n end",
"def model_name\n @model_class ? @model_class.name.demodulize.underscore : self.controller_name.singularize\n end",
"def app_name\n @app_name ||= Rails.app_class.module_parent_name.demodulize.underscore.dasherize\n end",
"def model_name\n configuration.model_name\n end",
"def get_model_name\n @model_name ||= self.class_simple_name.underscore[0..-12].singularize\n end",
"def model_name\n ::ActiveModel::Name.new(self, nil, ::ActiveSupport::Inflector.demodulize(self))\n end",
"def app_name\n Rails.application.class.to_s.split(\"::\").first\n end",
"def model_name\n fetch('device.model_name')\n end",
"def model_name\n if defined?(ActiveSupport::ModelName)\n ActiveSupport::ModelName.new(name)\n else\n ActiveModel::Name.new(self)\n end\n end",
"def model_name\n model_name = options.fetch(:model_name) do\n ActiveSupport::Inflector.singularize(name.to_s)\n end\n\n Name.new(model_name.to_s)\n end",
"def model_name\n root.singularize.camelize if root.present?\n end",
"def model_name\n self.class.model_name\n end",
"def model_name(model)\n model.class.to_s.downcase\n end",
"def app_name\n to_s.underscore\n end",
"def model_name\n @_model_name ||= begin\n klass = respond_to?(:main_class) ? main_class : self\n\n namespace = klass.parents.detect do |n|\n n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?\n end\n ActiveModel::Name.new(klass, namespace)\n end\n end",
"def model_name\n self.class.name.underscore.split('_').first.singularize\n end",
"def domain\n unless @domain\n if defined? ActiveSupport::CoreExtensions::String::Inflections\n @domain = name.tableize\n else\n @domain = name.downcase\n end\n end\n @domain\n end",
"def model_name\n @model_name ||= if defined?(ActiveModel::Name)\n ActiveModel::Name.new(call(:model)).param_key\n else\n call(:model).name.underscore\n end.to_sym\n end",
"def model_name\n ActiveModel::Name.new(Survey)\n end",
"def model_class_name\n implementation_model_name.ns_camelize\n end",
"def app_name\n @@app_name\n end",
"def model_name\n model.name\n end",
"def name\n @name ||= Rails.application.class.parent_name.underscore\n end",
"def model_name\n @_model_name ||= begin\n namespace = module_parents.detect do |n|\n n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?\n end\n ActiveModel::Name.new(self, namespace)\n end\n end",
"def domain_name\n @domain_name ||= default_name\n end",
"def app_name ; self.class.rootname.snake_case.to_sym ; end",
"def app_name\n return @app_name\n end",
"def app_name\n return @app_name\n end",
"def app_name\n c.application\n end",
"def application_name\n Rails.root.to_s.split('/').last.underscore\n end",
"def name\n self.class.name.split(\"::\").last.downcase\n end",
"def model\n self.klass.constantize.name.demodulize.tableize.singularize.downcase\n end",
"def class_name\n self.to_s.demodulize.underscore\n end",
"def model_name(object)\n object.present? ? object.class.name : object.to_s.classify\n end",
"def get_application_name\r\n root_info = get_rails_root_info\r\n root_info.split('/').last.capitalize\r\n end",
"def model_name\n self.class\n end",
"def csharp_model_fqn( model )\n [ sanitize_model_namespace(model), sanitize_model_class(model) ].compact.join(\".\")\n end",
"def model_name\n self.class.name[/(.*)Controller/,1].singularize.underscore\n end",
"def model_name\n self.class\n end",
"def appname\n \"Application\"\n end",
"def class_name\n self.class.name.split(\"::\").last.downcase\n end",
"def app_name\n ApplicationService.application_name\n end",
"def friendly_name\n self.class.model_name.split(\"::\").join(\" \")\n end",
"def model\n begin\n return controller_name.classify.constantize\n rescue\n return ('SlashAdmin::' + controller_name.classify).constantize\n end\n end",
"def app_model\n Heimdallr.config.application_model\n end",
"def default_model_name\n @object.class.to_s\n end",
"def name\n return self.class.name.split('::').last\n end",
"def model_path\n @model_class.to_s.underscore.split('/').last.pluralize\n end",
"def name\n self.class.name.split('::').last\n end",
"def model_name\n ActiveModel::Name.new(self, nil, name.gsub(/Form\\z/, \"\"))\n end",
"def model(name)\n name.gsub(/\\W+/, '_').classify.constantize\n end",
"def derived_name\n return controller_name if respond_to?(:controller_name)\n return model_name.plural if respond_to?(:model_name)\n name ? name.underscore.pluralize : nil\n end",
"def get_original_model_name(model)\n class_name = model.class.name\n if class_name.end_with?(\"::Version\")\n class_name = class_name.split(\"::\")[0]\n end\n class_name\n end",
"def app_name # :nodoc:\n app_cls = Rails.application.class\n parent = begin\n # Rails 6.1+\n app_cls.module_parent_name\n rescue NoMethodError\n app_cls.parent.to_s\n end\n parent.underscore\n end",
"def name\n self.class.name.demodulize.underscore\n end",
"def name\n self.class.name.split(\"::\").last\n end",
"def domain_name\n return @domain_name\n end",
"def domain_name\n return @domain_name\n end",
"def name\n self.class.name.split('::').last\n end",
"def class_name\n self.class.name.split(\"::\").last\n end",
"def application_name\n return @application_name\n end",
"def implementation_model_name\n nil\n end",
"def framework_name\n self.name.split(\"::\").last.downcase\n end",
"def framework_name\n self.name.split(\"::\").last.downcase\n end",
"def class_name\n self.class.to_s.split('::').last\n end",
"def model_name\n params[:controller].split('/').last.singularize\n end",
"def my_name\n @my_name ||= self.class.name.split(\"::\").last\n end",
"def model_name\n params[:controller].sub(\"Controller\", \"\").underscore.split('/').last.singularize\n end",
"def name\n self.class.name.split('::').last\n end",
"def app_name\n @app_name || Sapience.app_name\n end",
"def model_name\n ''\n end",
"def hyphenated_name\n implementation_model_name.ns_hyphenate\n end",
"def class_name\n @class_name ||= active_record.name\n end",
"def name\n self.class.to_s.split('::').last\n end",
"def sanitize_model_class( model )\n model.name.split(\"::\").last\n end",
"def default_base_title\n Rails.application.class.to_s.split('::').first\n end",
"def appname\n fetch(:appname) || script_name\n end",
"def name\n @name ||= self.to_s.demodulize.underscore\n end",
"def application_name\n @application_name || _application_name_from_namespace || _default_application_name\n end",
"def model_name\n self\n end",
"def name\n model_name\n end",
"def model( resource = nil )\n resource ||= self.class.basename.snake_case\n app::Models[ resource ]\n end",
"def model_name\n @_model_name ||= ActiveModel::Naming.param_key(model.new)\n end",
"def model\n controller_name.classify.constantize\n end",
"def sanitized_app_name\n application.gsub(' ', '_').downcase\n end",
"def app_name\n if CurrentUser.safe_mode?\n \"Safebooru\"\n else\n \"Danbooru\"\n end\n end",
"def app_display_name\n return @app_display_name\n end",
"def app_display_name\n return @app_display_name\n end",
"def app_display_name\n return @app_display_name\n end",
"def application_model\n @application_model ||= application_class.constantize\n end",
"def my_name \n @my_name ||= self.class.name.split(\"::\").last\n end",
"def default_domain_name\n return @default_domain_name\n end",
"def default_domain_name\n return @default_domain_name\n end",
"def model_route\n @model_name.to_s\n end",
"def model_name; end",
"def model_name; end",
"def class_name\n (self.type.to_s || self.class.name).demodulize\n end",
"def json_class_name\n [self.class.domain_module, self.class.name.demodulize].join('::')\n end",
"def get_model_name(model_name)\n model_name.gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').downcase\n end",
"def model_class(model_or_controller_name)\n # site settings isn't a model so it isn't defined\n @model_class = model_or_controller_name.singular.camelcase.constantize rescue nil\n end"
] | [
"0.7263753",
"0.71700656",
"0.71473324",
"0.71356696",
"0.7116998",
"0.7052671",
"0.7023878",
"0.69063574",
"0.6862865",
"0.68619114",
"0.68480366",
"0.68460035",
"0.6825837",
"0.6799385",
"0.67410547",
"0.6709598",
"0.67048955",
"0.66771245",
"0.66571885",
"0.6654276",
"0.66403013",
"0.66396993",
"0.6603299",
"0.6602455",
"0.65869933",
"0.6521596",
"0.6505522",
"0.6505522",
"0.64949346",
"0.64905155",
"0.64828485",
"0.6479434",
"0.6470683",
"0.6464322",
"0.646136",
"0.64589167",
"0.6449282",
"0.64377695",
"0.6436249",
"0.6425522",
"0.6424339",
"0.6422612",
"0.6415892",
"0.641068",
"0.6388653",
"0.6376809",
"0.63705117",
"0.6366305",
"0.6366299",
"0.6353776",
"0.6350934",
"0.63326895",
"0.6330607",
"0.63277614",
"0.63252795",
"0.6320491",
"0.6320006",
"0.6320006",
"0.6317286",
"0.6312886",
"0.63085324",
"0.63013476",
"0.630063",
"0.630063",
"0.6295079",
"0.6293483",
"0.62806803",
"0.6276025",
"0.62724555",
"0.6263521",
"0.6260793",
"0.62533325",
"0.62514514",
"0.624482",
"0.62303835",
"0.6206457",
"0.61956954",
"0.61950415",
"0.61855996",
"0.618278",
"0.61517894",
"0.6144035",
"0.61378413",
"0.6135706",
"0.61351794",
"0.6128642",
"0.6117905",
"0.6117905",
"0.6117905",
"0.6115032",
"0.6112842",
"0.6098595",
"0.6098595",
"0.6096697",
"0.60935324",
"0.60935324",
"0.60688835",
"0.6063344",
"0.6048008",
"0.6038376"
] | 0.63760996 | 46 |
Returns all entities of your domain model. | def entities
@entities ||= Entity.from_models(self, @models)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n Ribs.with_handle(self.database) do |h|\n h.all(self.metadata.persistent_class.entity_name)\n end\n end",
"def retrieve_all_entities\n response = self.execute(\"RetrieveAllEntities\", {\n EntityFilters: \"Entity\",\n RetrieveAsIfPublished: true\n },\n Metadata::RetrieveAllEntitiesResponse)\n end",
"def all\n response = request(:get_all)\n handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }\n\n if handles.size == 1\n # Fetch data for single entity\n find(handles.first)\n elsif handles.size > 1\n # Fetch all data for all the entities\n entity_data = get_data_array(handles)\n\n # Build Entity objects and add them to the proxy\n entity_data.each do |data|\n entity = build(data)\n entity.persisted = true\n end\n end\n\n self\n end",
"def get_all\n Rutodo::Database::Todo.map(&:as_entity)\n end",
"def entities\n @entities ||= []\n end",
"def entities\n @entities\n end",
"def index\n @entities = Entity.all\n end",
"def index\n @entities = Entity.all\n end",
"def entities\n _entities\n end",
"def entities\n _entities\n end",
"def all\n self.class.all\n end",
"def index\n @entities = Entity::Repo.roots\n end",
"def all\n repository.all(self)\n end",
"def all(entity_name) # :nodoc:\n chk_conn\n @hibernate_session.create_criteria(entity_name).list.to_a\n end",
"def get_all_from_database\n model.all\n end",
"def find_entities\n []\n end",
"def all( model )\n model( model ).all\n end",
"def entities_list\n raise 'Not implemented'\n end",
"def all\n result = @dealing_platform.session.get('accounts').fetch :accounts\n\n @dealing_platform.instantiate_models Account, result\n end",
"def all\n db.transaction(true) do\n ids = extract_model_ids(db)\n ids.map { |key| db[key] }\n end\n end",
"def all(offset = 0, limit = 0)\n @client.get(\"/#{@model}s\", {offset: offset, limit: limit})\n end",
"def all\n properties = get_properties\n create_models(properties)\n end",
"def entities; end",
"def entities\n @entities ||= begin\n acc = {}\n @api.routes.filter_map(&:entity).each do |entity|\n collect_entities(acc, entity)\n end\n acc.keys.sort_by(&:name)\n end\n end",
"def all\n folder.data_objects.all(parameters).collect do |data_object|\n model.new(data_object)\n end\n end",
"def all\n self.all\n end",
"def all\n @collection ||= Collection.new model_name\n end",
"def index\n @entities = Entity.all.page(params[:page])\n end",
"def index\n @entity_types = EntityType.all\n end",
"def fetch_all\n self.to_a\n end",
"def all\n self.as_objects(CONNECTION.execute(\"SELECT * FROM #{table_name};\"))\n end",
"def all\n ContactDatabase.get_all\n end",
"def find_all\n execute_sql(:read, :user) { table.map {|u| inflate_model(u) } }\n end",
"def entity_sets\n entity_container.entity_sets\n end",
"def entity_sets\n entity_container.entity_sets\n end",
"def entity_sets\n entity_container.entity_sets\n end",
"def all\n load_all! unless @objs_list\n @objs_list.values\n end",
"def entities\n @entities ||= Entities.from_grpc @grpc\n end",
"def all\n @service.all\n end",
"def all\n ::ActiveRecord::Base.connection_pool.with_connection do\n execute(:all).to_a\n end\n end",
"def all\n @data_adapter.relations\n end",
"def all\n table_name = self.to_s.pluralize.underscore\n results = DATABASE.execute(\"SELECT * FROM #{table_name}\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def list(scope = list_query)\n model.all(scope)\n end",
"def all \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name}\")\n \n return self.results_as_objects(results)\n end",
"def index\n @entities = Entity.find(:all, :limit=>100)\n EntitiesHelper.setModelGraph(\"public/UMLmodel.png\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entities }\n end\n end",
"def all(options={})\r\n find(:all, options)\r\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name}\")\n\n results_as_objects = []\n\n results.each do |results_hash|\n results_as_objects << self.new(results_hash)\n end\n\n return results_as_objects\n end",
"def all\n @users = User.all\n end",
"def all\n @adapter.all(collection)\n end",
"def all\n @document = Document.all\n end",
"def all(options={})\r\n find(:all,options)\r\n end",
"def all(model)\n store.all(table: table_name).map {|data| model.new data}\n end",
"def index\n @aramis_entities = AramisEntity.all\n end",
"def relation_all(model)\n validate_model(model)\n model.all\n end",
"def list \n @employees = Employee.find( :all ) # return an array of all Employees\n end",
"def all\n super | entities | action_instances\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def all\n @posts = Post.all\n @users = User.all\n end",
"def all(*args)\n find(:all, *args)\n end",
"def all(*args)\n find(:all, *args)\n end",
"def entities\n @entities ||= questions.map{|question|question.meta_attribute_entity}.uniq\n end",
"def get_all()\n raise \"Must be overridden\"\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def list\n collection = empty_collection\n all(params[:entity]).each do |bt|\n bt_coll = backend_proxy_for(bt).list\n collection.entities.merge bt_coll.entities\n end\n\n return if collection.only_categories?\n collection.valid!\n\n respond_with collection\n end",
"def fetch_all\n fetch_many0(nil, Array)\n end",
"def all\n @list\n end",
"def get_all\n @user_repository.get_all_users\n end",
"def all_fetched_entries\n @entry_cache.all_entries\n end",
"def all\n table_name = self.table_name\n \n results = CONNECTION.execute(\"SELECT * FROM '#{table_name}';\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def all\n @dealing_platform.gather 'accounts', :accounts, Account\n end",
"def index\n @ems = Em.all\n end",
"def all\n gen_feed Event.find(:all, :limit => @@limit, :order => 'id DESC'), 'All Events';\n end",
"def entities\r\n result = []\r\n result.concat( patches )\r\n result.concat( edges )\r\n result.concat( control_points )\r\n result\r\n end",
"def all(*args)\n find(:all, *args)\n end",
"def all\n@posts = Post.all\nend",
"def records_base(_options = {})\n _model_class.all\n end",
"def all_objects; end",
"def index\n @entregavels = Entregavel.all\n end",
"def all\n where\n end",
"def all_users()\n User.all\n end",
"def all\n @store.transaction do\n @store.roots.map {|id| @store[id] }\n end\n end",
"def load_entities\n {}\n end",
"def find_entities(*query)\n query = create_query(*query)\n ids = find_entity_ids(query)\n load_resources \"entities/#{query.type}\", ids do |id, data|\n create_entity(query.type, id, data)\n end\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = QUIZ.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def entity_objects\n ProjectMedia.where(id: self.entities).to_a\n end",
"def index\n @tipo_entidades = TipoEntidade.all\n end",
"def entities(*values)\n values.inject(self) { |res, val| res._entities(val) }\n end",
"def flattened_entities\n results = []\n \n # Add this organization's entities\n entities.where(:type == 'Person').each do |e|\n results << e\n end\n\n # Add all children organization's entities\n child_organizations.all.each do |o|\n o.flattened_entities.each do |e|\n results << e\n end\n end\n\n # Only return a unique list\n results.uniq{ |x| x.id }\n end",
"def all\n\t\tquery.execute\n end",
"def load_collection\n model_class.all(find_options)\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects(results)\n\n end",
"def index\n @entities = Entity.where(entity_id: nil)\n @entity = Entity.new\n end",
"def all(options = {})\n objs = decorated_class.all.map { |o| new(o) }\n resolve_associations(objs, options)\n end",
"def all\n load[:results]\n end",
"def raw_all\n query_all\n end",
"def all\n []\n end",
"def find_all\n response = fetch()\n new(response)\n end",
"def all\n \n end",
"def all\n self\n end",
"def all\n data\n end"
] | [
"0.78919375",
"0.7597153",
"0.75428873",
"0.7468397",
"0.73357433",
"0.72966325",
"0.71746904",
"0.71746904",
"0.7119073",
"0.7119073",
"0.7065918",
"0.70393616",
"0.7035165",
"0.7013245",
"0.69978917",
"0.6986583",
"0.69726026",
"0.696538",
"0.69212455",
"0.6655511",
"0.6633552",
"0.65636784",
"0.6524649",
"0.6482181",
"0.6450441",
"0.6448475",
"0.6448185",
"0.6418165",
"0.6387326",
"0.63494396",
"0.6332014",
"0.6331031",
"0.6318793",
"0.6294502",
"0.6294502",
"0.6294502",
"0.6283633",
"0.626567",
"0.6261897",
"0.6258086",
"0.62575036",
"0.6226976",
"0.61920816",
"0.61729795",
"0.6168488",
"0.6167011",
"0.6160641",
"0.6158447",
"0.6157604",
"0.6157509",
"0.61528784",
"0.6151719",
"0.6131467",
"0.6114055",
"0.61130357",
"0.6104748",
"0.60720146",
"0.6070722",
"0.6068398",
"0.6068398",
"0.60642314",
"0.60545874",
"0.6047077",
"0.6024342",
"0.60074025",
"0.60048306",
"0.60040206",
"0.59991765",
"0.59853333",
"0.5972889",
"0.5970348",
"0.5965283",
"0.59630513",
"0.5952863",
"0.5947491",
"0.594164",
"0.5938954",
"0.5935296",
"0.5925539",
"0.59228027",
"0.59213626",
"0.59144956",
"0.5901025",
"0.59003013",
"0.5899937",
"0.5888335",
"0.58768946",
"0.58733106",
"0.5868671",
"0.586314",
"0.58608526",
"0.5858306",
"0.58555585",
"0.58550704",
"0.58354187",
"0.58280313",
"0.5822338",
"0.58130664",
"0.58049774",
"0.5800636"
] | 0.7700775 | 1 |
Returns all relationships in your domain model. | def relationships
@relationships ||= Relationship.from_associations(self, associations)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships\n model.relationships(repository.name)\n end",
"def relationships\n return [] if empty?\n\n map { |table| Relationship.new(table, TABLE_R, \"../#{table.pn}\") }\n end",
"def list_relationships\n end",
"def relationships\n @relationships ||= {}\n end",
"def relationships\n @relationships.each do |k, v|\n if v.respond_to?(:uniq!)\n v.uniq!\n @relationships[k] = v.first if v.length == 1\n end\n end\n @relationships\n end",
"def relationships\n return [] if empty?\n\n map { |pivot_table| Relationship.new(pivot_table, PIVOT_TABLE_R, \"../#{pivot_table.pn}\") }\n end",
"def relation_all(model)\n validate_model(model)\n model.all\n end",
"def relationships\n return [] unless has_comments?\n\n comments.relationships\n end",
"def relations\n self.class.relations\n end",
"def relations\n _relations\n end",
"def relations\n _relations\n end",
"def relationships_for(model) # @private :nodoc:\n relationships_mapping[model] or []\n end",
"def all\n @data_adapter.relations\n end",
"def relations\n @relations ||= process_rels\n end",
"def relationships\n r = Relationships.new\n r << Relationship.new(cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, \"../#{cache_definition.pn}\")\n r\n end",
"def get_relations\n # Descobrir as relacoes:\n # Orientados\n # Projetos de Pesquisa\n # Producoes Bibliograficas\n # Consultar o RP de cada uma\n # Somar os RPs e retornar\n orientados = self.get_relations_of_orientados\n projetos = self.get_relations_of_projetos_pesquisa\n producoes = self.get_relations_of_producoes_bibliograficas\n\n relations = (orientados | projetos | producoes).delete self.id\n return relations.to_a\n end",
"def model_relationships; end",
"def all_related_models\n via_assay = related_assays.collect do |assay|\n assay.model_masters\n end.flatten.uniq.compact\n via_assay | related_models\n end",
"def relationships(*ids)\n perform_request_with_collection(:get, '/api/v1/accounts/relationships',\n array_param(:id, ids),\n Mastodon::Relationship)\n end",
"def all_organization_relationships(**args)\n params = parameters(args) do\n required_params :org_id\n optional_params :org_id\n end\n request(:get, 'organizationRelationships', params)\n end",
"def all_associations\n @all_associations ||= (\n # field associations\n @fields.collect { |field|\n field.associations.values\n }.flatten +\n # attribute associations\n @attributes.collect { |attrib|\n attrib.associations.values\n }.flatten\n ).uniq.collect { |assoc|\n # get ancestors as well as column-level associations\n assoc.ancestors\n }.flatten.uniq\n end",
"def all\n ref = Neo4j.instance.ref_node\n ref.relations.outgoing(root_class)\n end",
"def relations\n @relations ||= {}\n end",
"def rels(node)\n @batch_inserter.getRelationships(node)\n end",
"def associations\n model.relationships.to_a.collect { |name,rel|\n {\n :name => name.to_s,\n :type => association_type_lookup( rel ), # :has_many, :has_one, or :belongs_to\n :parent_model => rel.parent_model,\n :parent_key => rel.parent_key.collect { |p| p.name },\n :child_model => rel.child_model,\n :child_key => rel.child_key.collect { |p| p.name },\n :remote_rel => rel.options[:remote_relationship_name],\n :near_rel => rel.options[:near_relationship_name]\n }\n }\n end",
"def rels\n @traversal_result = :rels\n self\n end",
"def rels\n @rels ||= root.data._rels\n end",
"def relationships\n r = Relationships.new\n @worksheets.each do |sheet|\n r << Relationship.new(sheet, WORKSHEET_R, format(WORKSHEET_PN, r.size + 1))\n end\n pivot_tables.each_with_index do |pivot_table, index|\n r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, format(PIVOT_TABLE_CACHE_DEFINITION_PN, index + 1))\n end\n r << Relationship.new(self, STYLES_R, STYLES_PN)\n if use_shared_strings\n r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN)\n end\n r\n end",
"def child_ontology_relationships(options = {}) # :yields: Array of OntologyRelationships\n opt = {\n :relationship_type => 'all' # or a ObjectRelationships#id\n }.merge!(options.symbolize_keys)\n\n # TODO: modify to sort by first(top) label\n if opt[:relationship_type] == 'all'\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ?', self.id]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n else\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ? AND object_relationship_id = ?', self.id, opt[:relationship_type]]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n end\n end",
"def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def model_relationships\n hash = ActiveSupport::OrderedHash.new\n reflect_on_all_associations.map { |i| hash[i.name] = i.macro }\n return hash\n end",
"def print_relationships\n result = []\n self.relationships.each do |elt|\n result << elt.name\n end\n result.sort.join(', ')\n end",
"def jsonapi_relationships\n\t\t\t\t\tjsonapi_model_class.reflect_on_all_associations.collect do |association|\n\t\t\t\t\t\t#type = nil\n\n\t\t\t\t\t\ttype = :to_one if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasOneReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::BelongsToReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\ttype = :to_many if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasManyReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::HasAndBelongsToManyReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\tnext unless type\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: association.name,\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\treceiver: {\n\t\t\t\t\t\t\t\ttype: association.klass.to_s.underscore.pluralize.to_sym,\n\t\t\t\t\t\t\t\tclass: association.klass.to_s.constantize\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tend.compact\n\t\t\t\tend",
"def many_to_one_relationships\n relationships unless @relationships # needs to be initialized!\n @relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end\n end",
"def list_relationships(entity_path, named = nil)\n path = entity_path.is_a?(CanonicalPath) ? entity_path : CanonicalPath.parse(entity_path)\n query_params = {\n sort: '__targetCp'\n }\n query_params[:named] = named unless named.nil?\n query = generate_query_params query_params\n ret = http_get(\"/path#{path}/relationships#{query}\")\n ret.map { |r| Relationship.new(r) }\n end",
"def get_all_related_tables\n tables = [ @table_name ]\n return tables if @relations.nil?\n @relations.each do |n,r|\n tables = tables | get_relation_tables(r)\n end\n tables.sort\n end",
"def relations \n @roots = Category.roots \n @categories = Category.has_children \n @expense_types = ExpenseType.all\n @payment_methods = PaymentMethod.all\n end",
"def visible_relations \n\t\t\tif defined? @visible_relations \n\t\t\t\t@visible_relations\n\t\t\telse\n\t\t\t\tassociation_helper_models = []\n\t\t\t\t# find \n\t\t\t\tself.reflections.keys.each do |key|\n\t\t\t\t\tif self.reflections[key].class == ActiveRecord::Reflection::ThroughReflection\n\t\t\t\t\t\tassociation_helper_models.push self.reflections[key].options[:through]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tkeys = self.reflections.keys.map do |key| key.to_sym end\n keys - association_helper_models\n\t\t\tend\n\t\tend",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def get_relations_from_api(api=Rosemary::API.new)\n api.get_relations_referring_to_object(type, self.id.to_i)\n end",
"def associations\r\n [nil, joins]\r\n end",
"def dangling_relationships\n relationships.select do |relationship|\n relationship.subject.nil? || relationship.objekt.nil?\n end\n end",
"def index\n @relationships = Relationship.all\n end",
"def index\n @relationships = Relationship.all\n end",
"def get_relationships_of_type(type)\n g_command = get_command(type)\n relationships = self.send(g_command.to_sym)\n end",
"def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end",
"def associations\n # is caching ok?\n unless @associations\n @associations = {}\n klass.relations.each{|name,association|\n @associations[name.to_s] = Association.new(association,self)\n }\n end\n @associations\n end",
"def related_models\n via_assay = assays.collect(&:models).flatten.uniq.compact\n via_assay | models\n end",
"def relations_for(node) #:nodoc:\n Enumerator.new do |yielder|\n @description.relations.each do |relation_accessor|\n begin\n relations = relation_accessor[node]\n enumerable = relations.is_a?(Enumerable) ? relations : [relations].compact\n\n enumerable.each { |e| yielder << e unless visited?(e) }\n rescue NoMethodError\n # ignore errors on relation_accessor[node]\n end\n end\n end\n end",
"def each_relationship_for(model)\n # XXX: in dm-core 1.1.0, `Model#relationships` returns a\n # `DataMapper::RelationshipSet`, instead of a `Mash`, which does\n # not provide the `each_value` method.\n model.relationships.each do |args|\n relationship = case args\n when Array then args.last\n else args\n end\n\n unless relationship.respond_to?(:through)\n yield relationship\n end\n end\n end",
"def guardian_relationships\n\t\t([self.guardian_relationship] + VALID_GUARDIAN_RELATIONSHIPS ).compact.uniq\n\tend",
"def index\n respond_with Relationships.all\n end",
"def descendant_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:descendants).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def relationship_data\n data = @objects.try(:map) { |o| o.try(:relationship_data) }\n data.try(:compact!) || data\n end",
"def get_relationships(table_id, qb_realm_hostname, authorization, opts = {})\n data, _status_code, _headers = get_relationships_with_http_info(table_id, qb_realm_hostname, authorization, opts)\n data\n end",
"def relations; enum_relations.to_a end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def relations\n Relations::RelationTraverser.new(@internal_node)\n end",
"def find_relations\n sql = <<-eos\n SELECT\n tc.constraint_name, tc.table_name, kcu.column_name,\n ccu.table_name AS foreign_table_name,\n ccu.column_name AS foreign_column_name\n FROM\n information_schema.table_constraints AS tc\n JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name\n JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name\n WHERE constraint_type = 'FOREIGN KEY'\n eos\n @relations = @connection.exec(sql).values\n end",
"def relationships\n [Relationship.new(self, VML_DRAWING_R, \"../#{vml_drawing.pn}\"),\n Relationship.new(self, COMMENT_R, \"../#{pn}\")]\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.associations}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def relationships_all_channels\n if debug?\n channel_fields = ChannelFieldForm.new\n channel_fields.create_field(\n group_id: 1,\n type: 'Relationships',\n label: 'Relationships',\n fields: {\n limit: 25,\n relationship_order_field: 'Entry Date',\n relationship_order_dir: 'Descending (Z-A)',\n relationship_allow_multiple: 'n',\n relationship_future: '1'\n }\n )\n\n @page.load\n else\n $db.query(IO.read('channel_sets/relationships-all-channels.sql'))\n clear_db_result\n end\n end",
"def initialize_relationships\n @mappers.each do |mapper|\n @relationships.merge(mapper.relationships.find_dependent(@model))\n end\n\n @relationships.freeze\n end",
"def associations; end",
"def clear_relationships\n @relationships = {}\n end",
"def associations\n association_reflections.keys\n end",
"def linked_associations\n associations.values.select(&:linked?)\n end",
"def relations\n return @relations if defined?(@relations)\n\n relations = injected_options.fetch(:relations, nil)\n relations = allowed_options.fetch(:relations, []) if relations.nil?\n\n @relations = Relations.new(relations, includes)\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.association_fields}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def all\n self.class.all\n end",
"def complile_relationships\n relationships = []\n @classifications.each do |classification|\n relationship = Relationship.new(@query, classification)\n relationships << relationship unless relationship.score.zero?\n end\n relationships.sort\n end",
"def my_relationships(name)\n self.class.find_relationship(name).find_by_participant(self)\n end",
"def non_auto_closeable_relationships\n result = []\n\n rules.each do |rule|\n next unless rule.source_jsonmodel_category == :agent\n\n rule.relationship_types.each do |relationship_type|\n if ['creation', 'succession'].include?(relationship_type)\n result << build_relationship_jsonmodel_name(rule, relationship_type)\n end\n end\n end\n\n result\n end",
"def belongs_to_relations(ar_instance)\n\t\t\tcolumns = ar_instance.class.column_names\n\t\t\tparents = columns.map{ |c| c if c =~ /_id/ }.reject{ |c| c.nil? }\n\t\t\tparents.map!{ |parents| parents.gsub('_id', '') }\n\t\tend",
"def relationship_links(source)\n {}\n end",
"def scaffold_all_associations\n relationships.values.select { |v|\n v.send(:target_model).respond_to?(:scaffold_name)\n }\n end",
"def instances_relating_to(obj)\n relationships.map {|relationship_defn|\n relationship_defn.who_participates_with(obj)\n }.flatten\n end",
"def associations\n data[:associations]\n end",
"def group_relations\n relations = EntityGroupRelationship.where(entity_id: self.id)\n relations.sort_by { |r| r[:position] }\n end",
"def to_list\n @graph.clear\n @relations.each do |rel|\n append(rel, false)\t# append to @graph without push to @relations\n end\n end",
"def requested_relationships(fields)\n @_relationships.select do |k, _|\n _conditionally_included?(self.class.relationship_condition_blocks, k)\n end\n end",
"def has_associations\n assocs.each_rel.to_a\n end",
"def gen_relationships\n @parser.relationships.each do |rel|\n through_str = ''\n lines = []\n if rel[:has_relationship]\n has_relationship = rel[:has_relationship].gsub(':', '..')\n case has_relationship\n when '1'\n rel_str = 'belongs_to'\n when 'n'\n rel_str = \"has n,\"\n else\n rel_str = \"has #{has_relationship},\"\n if rel[:through]\n through_str = \", :through => :#{rel[:through]}\"\n else\n through_str = \", :through => Resource\"\n end\n end\n \n if rel[:through]\n lines << \" has n, :#{rel[:through]}\"\n end\n line = \" #{rel_str} :#{rel[:variable]}#{through_str}\"\n line += \" # #{rel[:comment]}\" unless rel[:comment].empty?\n lines << line\n elsif rel[:relationship]\n lines << ' ' + rel[:relationship]\n end\n editor = ModelEditor.new(rel[:filename].snake_case)\n editor.insert(AFTER_PROPERTIES, lines)\n end\n end",
"def distinct_relations(from_cache=false)\n # @@neo = Neography::Rest.new\n begin\n if from_cache\n self_node = self.get_node\n @neo.get_node_properties(node1)\n else\n self_node_id = self.get_node_id\n qur = \"start n=node(\"+self_node_id.to_s+\") match n-[r]->() return distinct(type(r)), count(r), r.magnitude;\"\n response = @@neo.execute_query(qur)\n distinct_relations = response[\"data\"]\n return distinct_relations\n end\n rescue Exception\n return nil\n end\n end",
"def edges\n @pathway.relations.collect do |rel|\n [ rel.node[0], rel.node[1], rel.relation ]\n end\n end",
"def get_all\n Rutodo::Database::Todo.map(&:as_entity)\n end",
"def associations\n @associations.dup\n end",
"def property_relations\n relations = EntityPropertyRelationship.where(entity_id: self.id)\n relations.sort_by { |r| r[:position] }\n end",
"def index\n @relations = Relation.all\n end",
"def each_relation\n\t for rel in relations\n\t\tyield(rel)\n\t end\n\tend",
"def find_relations\n puts '2nd pass: find relations'\n find :relations\n self\n end",
"def each_relationship\n return enum_for(__method__) unless block_given?\n\n each_model do |model|\n each_relationship_for(model) do |relationship|\n yield relationship, model\n end\n end\n end",
"def all_questions_descendants\n # source .descendants is very fast with no db hits! why? How can we use it? It's type is ActiveRecord::Association::CollectionProxy\n ([source] + source.descendants)\n end",
"def relations_info\n self::RELATIONS_INFO\n end",
"def iteration_associations\n [].freeze\n end",
"def rels(*rel_types)\n if rel_types.empty?\n AllRelsDsl.new(@_relationships, _java_node)\n else\n storage = _create_or_get_storage(rel_types.first)\n RelsDSL.new(storage)\n end\n end",
"def to_list\n @graph.clear\n @relations.each do |rel|\n\tappend(rel, false)\t# append to @graph without push to @relations\n end\n end",
"def all(options = {})\n objs = decorated_class.all.map { |o| new(o) }\n resolve_associations(objs, options)\n end"
] | [
"0.81011456",
"0.77505183",
"0.7689656",
"0.74655145",
"0.74451214",
"0.7269916",
"0.7255221",
"0.72459984",
"0.719619",
"0.7099128",
"0.7099128",
"0.70877177",
"0.7014621",
"0.69073766",
"0.6791667",
"0.67849773",
"0.67699486",
"0.675404",
"0.6697717",
"0.6570556",
"0.6524131",
"0.6497749",
"0.6490889",
"0.6487258",
"0.6469509",
"0.64506376",
"0.64493334",
"0.6444354",
"0.6434519",
"0.6406814",
"0.64041495",
"0.6401269",
"0.63859016",
"0.6378324",
"0.63591",
"0.63519037",
"0.6346596",
"0.63460934",
"0.6304133",
"0.6304133",
"0.6304133",
"0.62770087",
"0.62667066",
"0.62625456",
"0.62270486",
"0.62270486",
"0.6224056",
"0.62191695",
"0.6180673",
"0.61743605",
"0.6139818",
"0.61251545",
"0.610939",
"0.6109068",
"0.60985035",
"0.60905474",
"0.6071286",
"0.60634005",
"0.60365695",
"0.6022332",
"0.60207754",
"0.6020435",
"0.6017165",
"0.5992987",
"0.59865624",
"0.59813213",
"0.596824",
"0.59579206",
"0.5934473",
"0.5922641",
"0.5917389",
"0.5897001",
"0.5878189",
"0.5854408",
"0.5848382",
"0.58477664",
"0.58387434",
"0.58298635",
"0.58297163",
"0.5813171",
"0.58101577",
"0.58067065",
"0.58019274",
"0.58010894",
"0.5792568",
"0.5790233",
"0.57747376",
"0.5772014",
"0.5771551",
"0.57698673",
"0.5764476",
"0.5751366",
"0.5748027",
"0.5742378",
"0.57406235",
"0.57299924",
"0.57228756",
"0.57192355",
"0.56985736",
"0.56967413"
] | 0.787333 | 1 |
Returns all specializations in your domain model. | def specializations
@specializations ||= Specialization.from_models(self, @models)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @spec_types = SpecType.all\n end",
"def models\n Typus::Configuration.config.map { |i| i.first }.sort\n end",
"def all\n all_by_type.values.flatten\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def models\n [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact\n end",
"def models\n [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end",
"def specs\n collect_specs_via(:specs)\n end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def all\n self.class.all\n end",
"def models\n ModelHtmlUnitCollection.by_make(make)\n end",
"def elements\n model = self.model.constantize\n model.respond_to?(:generic_listing_elements) ? model.generic_listing_elements : model.all\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def available_models\n\t\t\t\t\tif !self.nature.blank?\n\t\t\t\t\t\tmodel_classname = config(:natures, self.nature.to_sym, :model)\n\t\t\t\t\tend\n\t\t\t\t\tif !model_classname.blank?\n\t\t\t\t\t\tmodel_class = model_classname.constantize\n\t\t\t\t\t\treturn model_class.where(config(:natures, self.nature.to_sym, :filters)).order(id: :asc)\n\t\t\t\t\telse\n\t\t\t\t\t\treturn []\n\t\t\t\t\tend\n\t\t\t\tend",
"def all\n @collection ||= Collection.new model_name\n end",
"def get_all\n get_countries_if_necessary\n get_subjects_if_necessary\n get_qualifications_if_necessary\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @typings = Typing.all\n end",
"def get_all_typographies\n @typographies.values.compact.insert(0, @typography)\n end",
"def index\n @generics = Generic.all\n end",
"def all_collections()\n collections = []\n DrgCms.paths(:forms).each do |path|\n models_dir = File.expand_path(\"../models\", path)\n Dir[\"#{models_dir}/*.rb\"].each do |model_file| \n collection_name = determine_model_name(model_file)\n collections << collection_name if collection_name\n end\n end\n collections.sort\nend",
"def view_types(for_select = true) # get the defined view type partials. e.g. views/views/list.html.erb\n fetch_array_for get_view_types, for_select\n end",
"def all\n @@responders\n end",
"def areas_of_specialization\n self.dig_for_array(\"areasOfSpecialization\")\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def standard_specs\n Array.new(rand(5...10)) { fetch('vehicle.standard_specs') }\n end",
"def variants\n self.class.variant_reflections.map { |reflection| send(reflection[:name]) }\n end",
"def index\n @specialization_categories = SpecializationCategory.all\n end",
"def model_classes\n @opts[:models]\n end",
"def list\n \n @product_types = ProductType.find(:all, :order => \"name\")\n end",
"def ordered_subclasses\n [Question]\n end",
"def get_resource_templates\n @model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'resource_tpl' }.any? }\n end",
"def all_models_by_make(make)\n by_make(make).map(&:model)\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def category_types\n @category_types.each\n end",
"def models\n children = []\n Mongoid.models.each do |model|\n children << model.to_s\n model.descendants.each do |child|\n inh = [child.to_s]\n sk = child.superclass\n while sk != model\n inh << sk.to_s\n sk = sk.superclass\n raise '!' if sk == Object\n end\n\n children << ' ' + inh.reverse.join(' < ')\n end\n end\n children\nend",
"def resourceType\n 'Specimen'\n end",
"def resources\n typed_set(entities, Occi::Core::Resource)\n end",
"def subclasses\n @subclasses\n end",
"def initialize_representations\n []\n end",
"def get_models(model_type)\n model_store.get_collection class_for_type(model_type)\n end",
"def subtypes\n # REVISIT: There's no sorting here. Should there be?\n all_type_inheritance_as_supertype.map{|ti| ti.subtype }\n end",
"def all\n properties = get_properties\n create_models(properties)\n end",
"def index\n @dis_routed_generics = DisRoutedGeneric.all\n end",
"def to_specs\n [to_spec]\n end",
"def array\n @models ||= load\n end",
"def all_subtype\n all_type_inheritance_as_supertype.map(&:subtype)\n end",
"def return_sub_types\n main_type = type_status\n if main_type\n return self.beer_subtypes.map{|type| {id: type.id, name: type.name}}\n else\n return types_for_subtype\n end\n end",
"def load_collection\n model_class.all(find_options)\n end",
"def gender_types\n @gender_types.each\n end",
"def by_type\n return @by_type if @by_type\n\n @by_type = {}\n self.all.each do |set|\n next unless set[:types].count > 0\n\n set[:types].each do |t|\n @by_type[t] ||= []\n @by_type[t] << set\n end\n end\n\n @by_type\n end",
"def all\n Ribs.with_handle(self.database) do |h|\n h.all(self.metadata.persistent_class.entity_name)\n end\n end",
"def get_variants\n return [] if is_pdc?\n get_variants_by_package.values.flatten.uniq\n end",
"def types\n get_metadata unless @types\n return @types\n end",
"def animal_species\n Animal.all.map do |animal|\n animal.specie\n end.uniq\n end",
"def index\n @trait_types = TraitType.all\n end",
"def all_plugin_specs\n @plugin_specs.values\n end",
"def defined_types\n @title = 'Defined Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_defined_type)\n erb(:objects)\nend",
"def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend",
"def all\n @all ||= widget_types.reject(&:abstract?).inject({}) {|res, type| res.deep_merge(type.instances_hash)}\n end",
"def list\n specs = Array.new\n @public_holiday_specifications.each { |phs| specs << phs.to_s }\n specs\n end",
"def collection\n resource_class.all\n end",
"def mechanics\n Mechanic.all.select{|mechanic|mechanic.specialty == self.classification}\n end",
"def index\n @survey_data_types = SurveyDataType.all\n end",
"def get_surveys\n survey_types = SurveyType.all(:conditions=>[\"name != ?\", \"test\"])\n non_empty_survey_types = []\n survey_types.each do |survey_type|\n any_datasets = false\n survey_type.surveys.each do |survey|\n any_datasets = true unless survey.datasets.empty?\n end\n if any_datasets \n non_empty_survey_types << survey_type\n end\n end\n surveys = []\n non_empty_survey_types.each do |survey_type|\n survey_type.surveys.each do |survey|\n unless survey.datasets.empty? \n surveys << survey unless !Authorization.is_authorized?(\"show\", nil, survey, current_user)\n end\n end\n end\n return surveys\n end",
"def proper_types\n Page.distinct(:_type).reject { |type| type.constantize.new.entry? }\n end",
"def index\n @typerelsequences = Typerelsequence.all\n end",
"def blocks_models\n @blocks_model = BlocksModel.all.map{ |bm| bm.model_type.downcase }.uniq\n end",
"def index\n @product_specifications = ProductSpecification.all\n end",
"def all_vms_and_templates\n descendants(:of_type => 'VmOrTemplate')\n end",
"def models\n work_classes + collection_classes\n end",
"def index\n @entity_types = EntityType.all\n end",
"def data_types\n @title = 'Data Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_data_type, :puppet_data_type_alias)\n erb(:objects)\nend",
"def all\n @all ||= property_hashes.map do |hash|\n Entities::PropertyType.new(\n id: hash[\"id\"],\n name: hash[\"rentals_united_name\"],\n roomorama_name: hash[\"roomorama_name\"],\n roomorama_subtype_name: hash[\"roomorama_subtype_name\"]\n )\n end\n end",
"def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end",
"def typus_filters\n\n fields_with_type = ActiveSupport::OrderedHash.new\n\n if self.respond_to?('admin_filters')\n fields = self.admin_filters\n else\n return [] unless Typus::Configuration.config[self.name]['filters']\n fields = Typus::Configuration.config[self.name]['filters'].split(', ').collect { |i| i.to_sym }\n end\n\n fields.each do |field|\n attribute_type = self.model_fields[field.to_sym]\n if self.reflect_on_association(field.to_sym)\n attribute_type = self.reflect_on_association(field.to_sym).macro\n end\n fields_with_type[field.to_s] = attribute_type\n end\n\n return fields_with_type\n\n end",
"def questionnaire_types\n questionnaire_type_list = Array.new\n self.questionnaires.each do |questionnaire|\n if !self.questionnaires.include?(questionnaire.type)\n questionnaire_type_list << questionnaire.type\n end\n end\n questionnaire_type_list\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def form_templates\n FormTemplate.where(lecturer_id: @id)\n end",
"def index\n @dishtypes = Dishtype.all\n end",
"def resources\n Typus::Configuration.roles.keys.map do |key|\n Typus::Configuration.roles[key].keys\n end.flatten.sort.uniq.delete_if { |x| models.include?(x) }\n end",
"def index\n @optypes = Optype.all\n end",
"def model_classes\n ModelClassCollector.new(configuration, mode_map.keys).collect\n end",
"def descendants\n Base.descendants\n end",
"def index\n @car_specific_specs = CarSpecificSpec.all\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def get_all()\n raise \"Must be overridden\"\n end",
"def models\n make = params[:make]\n @models = Databag.find(\"printers/#{make}\").value.keys.reject{ |k| k == \"id\" }.sort\n render :layout => false\n end",
"def sets\n return [EscholSet.new({name: \"everything\", spec: \"everything\"})]\n end",
"def find_specs\n specs_found = []\n # Check for specs the object owns\n if respond_to? :specs\n object_specs = specs\n unless object_specs.nil?\n if object_specs.class == Origen::Specs::Spec\n specs_found << object_specs\n else\n specs_found.concat(object_specs)\n end\n end\n end\n sub_blocks.each do |_name, sb|\n next unless sb.respond_to? :specs\n\n child_specs = sb.specs\n unless child_specs.nil?\n if child_specs.class == Origen::Specs::Spec\n specs_found << child_specs\n else\n specs_found.concat(child_specs)\n end\n end\n end\n specs_found\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def get_all_from_database\n model.all\n end",
"def requested_models(requested_model)\n case requested_model\n when /^(.+)[(](.+)[)]$/ #handle model(with associations), i.e. Image(for scene A)\n base_model = $1.classify.constantize\n scopes = $2.split(',')\n models = base_model\n\n scopes.each do |scope|\n models = models.send(scope.strip)\n end\n\n models.all\n\n when String #is name\n requested_model.singularize.constantize.all\n else\n requested_model.all\n end\nend",
"def all\n @adapter.all(collection)\n end",
"def find_all_uvhp()\n # find all UVHP items\n plates = find(:item, { object_type: { name: \"Unverified Hydra Plate\" } } )\n # convert items back to collections\n plates = plates.map{|plate| Collection.find(plate.id)}\n return plates\n end",
"def index\n @sample_types = SampleType.all\n end",
"def subclasses\n @subclasses ||= []\n end",
"def index\n @question_types = QuestionType.all\n end",
"def index\n @question_types = QuestionType.all\n end",
"def index\n @modeltypes = Modeltype.all\n end"
] | [
"0.62716216",
"0.6215123",
"0.6198799",
"0.6145743",
"0.6068127",
"0.6056818",
"0.60310155",
"0.5995114",
"0.5879379",
"0.5847136",
"0.58442813",
"0.5817161",
"0.5786486",
"0.57570124",
"0.5728031",
"0.57151574",
"0.5676308",
"0.5675259",
"0.5659265",
"0.56174445",
"0.5616258",
"0.55834305",
"0.5582898",
"0.5577052",
"0.55625576",
"0.55570483",
"0.5538551",
"0.54932874",
"0.5483617",
"0.5481796",
"0.548074",
"0.54733396",
"0.54714715",
"0.54639846",
"0.54353577",
"0.54288304",
"0.5427489",
"0.54210883",
"0.5407375",
"0.54060936",
"0.5402366",
"0.53984106",
"0.53969496",
"0.5395784",
"0.5394731",
"0.5392719",
"0.53907436",
"0.5372043",
"0.53671885",
"0.53653145",
"0.5365301",
"0.535706",
"0.5352249",
"0.53509575",
"0.5349385",
"0.53490114",
"0.5347935",
"0.53429437",
"0.5335839",
"0.5333623",
"0.5330829",
"0.53260005",
"0.5324715",
"0.5320688",
"0.5314782",
"0.5313858",
"0.53123325",
"0.5307187",
"0.5299111",
"0.5297962",
"0.5292856",
"0.5288196",
"0.52812624",
"0.5278671",
"0.5259374",
"0.5246606",
"0.5244315",
"0.5241648",
"0.5238179",
"0.52292305",
"0.5218617",
"0.5214847",
"0.5211979",
"0.5200669",
"0.519322",
"0.5193185",
"0.5187955",
"0.51852566",
"0.5174568",
"0.51714873",
"0.5168354",
"0.51560676",
"0.51560295",
"0.51537055",
"0.5153175",
"0.5148965",
"0.514615",
"0.5144998",
"0.5144998",
"0.51442105"
] | 0.8277926 | 0 |
Returns a specific entity object for the given Active Record model. | def entity_for(model) # @private :nodoc:
entity_mapping[model] or raise "model #{model} exists, but is not included in domain"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_model\n model_name.camelize.constantize.find( params[:id] )\n end",
"def fetch_record_by_param\n model.find(params[:id])\n end",
"def get_object(key, model)\n @objects ||= {}\n @objects[key] = model.safe_find(get_integer(key)) unless @objects.key?(key)\n @objects[key]\n end",
"def find_record_from_identifier(entity)\n model = entity.model\n user_token = request.headers[\"X-#{model.to_s.upcase}-TOKEN\"]\n super if model != User || user_token.blank?\n model.find_by authentication_token: user_token\n end",
"def find_record(id)\n @model_class.find(id)\n end",
"def find_record(id)\n @model_class.find(id)\n end",
"def find( model, name )\n model( model )[name ] rescue nil\n end",
"def find_object\n @object = @model_class.find_by_id(params[:id].to_i)\n end",
"def find(model, id)\n key = model.primary_key\n condition = {\"#{key}\" => id}\n data = store.read(condition, table: table_name).first\n fail RecordNotFound.new(condition, table_name) unless data\n\n model.new data\n end",
"def entity_by_id(model_class)\n halt 400 unless (params[:id].to_i.to_s == params[:id])\n model_class[params[:id]] || (halt 404)\n end",
"def get(obj)\n collection, query = get_type_info(obj)\n\n record = retrieve(collection, query, limit: 1).first\n return nil unless record\n\n obj.class.new(record)\n end",
"def find id\n model.find id\n end",
"def find_entity(entity_id, entity_type)\n entity_class = begin; entity_type.constantize; rescue; nil; end\n return if entity_class.nil?\n\n @entity = if entity_class.respond_to?(:visible)\n entity_class.visible.find_by(id: entity_id)\n else\n entity_class.find_by(id: entity_id)\n end\n end",
"def method_missing msg, *args, &block\n model = begin;\n Object.const_get msg\n rescue NameError\n end\n \n if model and model.respond_to?(:descends_from_active_record?) and model.descends_from_active_record?\n model.find args.first\n else\n super\n end\nend",
"def retrieve_entity\n if self.id\n @entity = Deltacloud::Database::Entity::retrieve(@model)\n if @entity.exists?\n after_retrieve\n end\n else\n @entity = nil\n end\n end",
"def entity load=true\n @entity ||= (klass.where(id: id).first if load)\n end",
"def find_model_argument(*args)\n # First a valid model object is searched for.\n model = args.find { |arg|\n arg.is_a?(Sketchup::Model) && model.valid?\n }\n # Then we look for objects that might return a valid model object.\n unless model\n entity ||= args.find { |arg|\n arg.respond_to?(:model) &&\n arg.model.is_a?(Sketchup::Model) && arg.model.valid?\n }\n if entity\n model = entity.model\n end\n end\n # We should only return valid objects.\n unless model && model.valid?\n return nil\n end\n model\n end",
"def get_model(model_type, name)\n klass = class_for_type(model_type)\n result = model_store.get(klass, name) || Backyard.global_store.model_store.get(klass, name)\n if result.nil? && Backyard.name_based_database_lookup\n result = find_model_from_database(klass, name)\n put_model(result, name) if result\n result\n else\n reload_model(result)\n end\n end",
"def find_record\n self.class.model_klass.find(params[:id])\n end",
"def find!(ctx, params:, **)\n ctx[:model] = ::Contact.find_by(uuid: params[:id])\n end",
"def model\n __getobj__\n end",
"def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end",
"def model\n @model ||= resource.model\n end",
"def get(model, id=nil, opts = {})\n name = model_name(model)\n opts.symbolize_keys!\n data = do_restful_action(\"get\", name) do\n self.nagyo[\"#{name}/#{URI.encode(id.to_s)}\"].get({:format => :json, :accept => :json}.merge(opts))\n end\n if id\n # NOTE: if we have an ID and get a Hash - single record matched, \n # otherwise no match and might have returned first page of records\n return data if data.is_a?(Hash)\n else\n return data\n end\n end",
"def get_mobj(mname=nil) @model_class.instance; end",
"def get_entity id\n @entities.each do |e|\n return e if e.id == id\n end\n end",
"def get_model\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/model'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n Person.from_hash(decoded)\n end",
"def find(options = {})\n if(options.class == Integer)\n model = self.new(quickbook_gateway.get(\"#{entity.downcase}/#{options}\")[entity]) \n model.is_new_record = false\n return model\n end\n \n return self.find_all(options, 1)[0]\n end",
"def get!(key)\n model = get(key)\n return model if model\n\n raise ActiveRecord::ShardFor::RecordNotFound\n end",
"def find(id, options = {})\n if model = find_locally(id)\n model\n else\n adapter(model_class).find(id, options)\n end\n end",
"def get_entity( name, parent_context = nil )\n id = @entity_names[ get_entity_unique_name(name, parent_context) ]\n @entity_list[ id ]\n end",
"def find_model(attributes)\n model.find(:first, :conditions => { key => attributes[key] })\n end",
"def find_obj\n @obj = eval(resource_name).find_by(id: params[:id])\n end",
"def model(name_or_type)\n table = Brief::Model.table\n\n table.fetch(name_or_type) do\n table.values.find do |k|\n k.name == name_or_type\n end\n end\n end",
"def model(name_or_type)\n table = Brief::Model.table\n\n table.fetch(name_or_type) do\n table.values.find do |k|\n k.name == name_or_type\n end\n end\n end",
"def one(model, sql, params={})\n model.new(sql_query(sql, params).first)\n end",
"def get_model(model_slug)\n site = get_site\n site.content_types.where(:slug => model_slug).first\n end",
"def model(model_type, name, attributes = {})\n if model_exists?(model_type, name)\n get_model(model_type, name)\n else\n put_model(model_type, name, attributes)\n end\n end",
"def get_object\n class_name = self.target_type.classify\n klass = Object.const_get(class_name)\n return klass.find(self.target_id)\n end",
"def specific_show(model, id)\n model.find(id)\n end",
"def entity\n @entity ||=\n if entity_class.respond_to? :from_token_request\n entity_class.from_token_request request\n else\n entity_class.find_by username: auth_params[:username]\n end\n end",
"def example_entity\n @example_entity ||= model&.last\n end",
"def model\n self.class.const_get(:MODEL)\n end",
"def find_item_by_model(model)\n @models_to_items[model]\n end",
"def get_object_from_db_id(db_object_id)\n get_object_from_db_object(@db_class.find(db_object_id))\n end",
"def [](primary_key_value)\n entity = odata_entity_set[primary_key_value]\n return entity if entity.nil?\n model = self.new\n model.instance_variable_set(:@odata_entity, entity)\n model\n end",
"def set_entity\n @entity = Entity::Repo.find(params[:id])\n end",
"def find( id )\n model.get( id ).extend( InstanceMethods )\n end",
"def find_model(name)\n ole = ole_obj.Models(name)\n model_from_ole(ole)\n rescue\n puts \"model #{name} not found\"\n nil\n end",
"def get(id)\n Ribs.with_handle(self.database) do |h|\n h.get(self.metadata.persistent_class.entity_name, id)\n end\n end",
"def entity(options = {})\n self.class.entity_class.new(self, options)\n end",
"def find_element(id, model)\n case model.downcase\n when 'work'\n return Work.find(id)\n when 'basicfile'\n return BasicFile.find(id)\n when 'singlefileinstance'\n return SingleFileInstance.find(id)\n when 'orderedinstance'\n return OrderedInstance.find(id)\n when 'person'\n return AuthorityMetadataUnit.find(id)\n else\n raise 'Unknown element type'\n end\n end",
"def fetch_object(model, url, params = {}, options = {})\n raise ArgumentError, \"missing model to instantiate\" if model.nil?\n response = do_http_get(url, params, {'Content-Type' => 'text/xml'})\n collection = parse_collection(response, model)\n if collection.is_a?(Quickeebooks::Collection)\n collection.entries.first\n else\n nil\n end\n end",
"def find(handle)\n handle = Entity::Handle.new(handle)\n entity_hash = get_data(handle)\n entity = build(entity_hash)\n entity.persisted = true\n entity\n end",
"def get_model\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/model'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK',\n 'accept' => 'application/json'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the response\n _response = @http_client.execute_as_string(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n decoded = APIHelper.json_deserialize(_response.raw_body)\n return Employee.from_hash(decoded)\n end",
"def model\n self.public_send(self.class._attributes.first)\n end",
"def object_for(object_or_id, klass)\n case object_or_id\n when klass then object_or_id\n when Integer\n klass.find_by(id: object_or_id)\n else\n raise ArgumentError,\n \"must provide a #{ klass } or a valid #{ klass } id\"\n end\n end",
"def find_record\n self.class.resource_model.find(params[:id])\n end",
"def first\n @model_class.first\n end",
"def first\n @model_class.first\n end",
"def model\n @model ||= Model.new(self)\n end",
"def find_object(klass)\n controller_object = controller_session[\"object\"]\n if controller_object.present?\n if controller_object.is_a? ApplicationModel\n return controller_object\n else\n return klass.new(controller_object)\n end\n end\n return nil\n end",
"def find_record\n @record ||= model.find_by_id(params[:id])\n end",
"def obj\n @model\n end",
"def model_class\n self.class.const_get('MODEL')\n end",
"def get_model dataset_id, model_id\n get_project_model @project, dataset_id, model_id\n end",
"def model_from_worker id\n find_worker(id)[:model].to_s.safe_constantize if worker_exists?(id)\n end",
"def get(id)\n klass.find(:first, params: { klass.primary_key => wrap_key(id) })\n end",
"def find_model(name)\n @models[name.to_s.downcase.to_sym]\n end",
"def get(entity_name, id) # :nodoc:\n chk_conn\n @hibernate_session.get(entity_name, java.lang.Integer.new(id))\n end",
"def model\n @model ||= if self.class.path_to_model\n m = eval(self.class.path_to_model)\n if m\n if m.respond_to?(:_controller=)\n m.send(:_controller=, self)\n end\n else\n fail \"No model object found at path: #{self.class.path_to_model}\"\n end\n m\n end\n end",
"def model\n return @model\n end",
"def model\n return @model\n end",
"def fetch_by_id(model, id, filters = {})\n get_resource(\"/v1/public/#{model}/#{id}\", filters) if model_exists?(model) && validate_filters(filters)\n end",
"def identifier(model)\n models[model]\n end",
"def model\n return @model\n end",
"def find_model_for_archive\n @archivable_model = get_model_name.classify.constantize.find params[:id] # rescue nil\n end",
"def get_user(name)\n @model.find_by(name: name)\n end",
"def find_entry\n ms = model_scope\n result = nil\n if params[:id]\n # Requests that retrieve existing records (e.g. show, edit, update, destroy) set an 'id' param\n # The +find+ method raises ActiveRecord::RecordNotFound if no database item has this primary key\n result = ms.find(params[:id])\n elsif params[ms.primary_key]\n # Primary key is a single value provided in the params hash\n # This modification allows the create action to succeed even if the item already exists\n # The +where...first+ methods returns the item from the database or nil if not found\n result = ms.where(ms.primary_key => params[ms.primary_key]).first\n elsif ms.primary_key.instance_of? CompositePrimaryKeys::CompositeKeys\n # primary key is composed of multiple values\n if (ms.primary_key - params.keys).empty?\n # param values are present for all the primary keys\n pk_values = ms.primary_key.map{|k| params[k]}\n result = ms.find(pk_values)\n end\n end\n result\n end",
"def get_entity(ref_key)\n if @entities_store.has_key?(ref_key)\n Entity.new(@entities_store[ref_key]['_type'], @entities_store[ref_key]['name'], ref_key)\n else\n nil\n end\n end",
"def find_record_by(model)\n raise_must_override\n end",
"def load_model model_name=nil\n get_schema.load_model(self.get_instance, model_name)\n end",
"def set_<%= model_var_name %>\n @<%= model_var_name %> = <%= model_class_name %>.find(params[:id])\n end",
"def set_entity\n @entity = Entity.find(params[:id])\n end",
"def entity(dbname, id, params = {})\n version = params.fetch(:t, '-')\n get db_url(dbname, version, 'entity'), params.merge(:e => id)\n end",
"def get_entity(table_name, partition_key, row_key, options={})\n options[:partition_key] = partition_key\n options[:row_key] = row_key\n results = query_entities(table_name, options)\n results.length > 0 ? results[0] : nil\n end",
"def find_model(record)\n raise_must_override\n end",
"def load_entity(entity_id)\n @entities[entity_id]\n end",
"def get(entity)\n @components[entity.id] \n end",
"def get_entity(table_name, partition_key, row_key, options = {})\n options[:partition_key] = partition_key\n options[:row_key] = row_key\n results = query_entities(table_name, options)\n results.length > 0 ? results[0] : nil\n end",
"def find_by(**args)\n where(**args).first\n end",
"def model( resource = nil )\n resource ||= self.class.basename.snake_case\n app::Models[ resource ]\n end",
"def object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length == 1 ? objs[0] : nil\n end",
"def model\n self.class.model\n end",
"def model\n self.class.model\n end",
"def model\n if object[inheritance_column]\n object[inheritance_column].constantize\n else\n original_class\n end\n end",
"def get_object\n class_name.create_from_database(id)\n end",
"def model!(options, params:)\n options['model'] = Event.find(params[:id])\n end",
"def to_model\n __getobj__\n end",
"def set_model\n @model = Model.find(params[:id])\n end"
] | [
"0.6862012",
"0.6601415",
"0.65724206",
"0.6552234",
"0.652704",
"0.652704",
"0.6523794",
"0.651006",
"0.64794374",
"0.64722514",
"0.64207894",
"0.64043504",
"0.636373",
"0.63372946",
"0.633343",
"0.62897295",
"0.62570363",
"0.62390476",
"0.62182724",
"0.6168461",
"0.61416525",
"0.6137149",
"0.60490173",
"0.60348314",
"0.6018123",
"0.599951",
"0.5990916",
"0.5971168",
"0.5962308",
"0.5917883",
"0.58989936",
"0.58970267",
"0.5863432",
"0.585307",
"0.585307",
"0.5842137",
"0.5825484",
"0.5819921",
"0.5804713",
"0.5792677",
"0.57715404",
"0.5771049",
"0.5766944",
"0.57316345",
"0.57287294",
"0.5727391",
"0.5724681",
"0.57206506",
"0.5661901",
"0.5659583",
"0.5659103",
"0.56503123",
"0.5642985",
"0.5641932",
"0.5639477",
"0.5637728",
"0.55905026",
"0.55851626",
"0.5585088",
"0.5585088",
"0.5579341",
"0.55642897",
"0.55640924",
"0.55597794",
"0.555965",
"0.55520695",
"0.5550401",
"0.55384445",
"0.55305564",
"0.55264556",
"0.55245477",
"0.5501532",
"0.5501532",
"0.54973936",
"0.54640496",
"0.54581773",
"0.5455796",
"0.5450813",
"0.5448803",
"0.5447511",
"0.542379",
"0.5413543",
"0.5407453",
"0.54050857",
"0.539435",
"0.53923684",
"0.539169",
"0.5388843",
"0.53822494",
"0.53804487",
"0.53803",
"0.53787935",
"0.53700215",
"0.5369325",
"0.5369325",
"0.5365954",
"0.53644544",
"0.53404796",
"0.53380823",
"0.5334418"
] | 0.69501793 | 0 |
Returns an array of relationships for the given Active Record model. | def relationships_for(model) # @private :nodoc:
relationships_mapping[model] or []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships\n model.relationships(repository.name)\n end",
"def relation_all(model)\n validate_model(model)\n model.all\n end",
"def relationships\n return [] if empty?\n\n map { |table| Relationship.new(table, TABLE_R, \"../#{table.pn}\") }\n end",
"def associations\n model.relationships.to_a.collect { |name,rel|\n {\n :name => name.to_s,\n :type => association_type_lookup( rel ), # :has_many, :has_one, or :belongs_to\n :parent_model => rel.parent_model,\n :parent_key => rel.parent_key.collect { |p| p.name },\n :child_model => rel.child_model,\n :child_key => rel.child_key.collect { |p| p.name },\n :remote_rel => rel.options[:remote_relationship_name],\n :near_rel => rel.options[:near_relationship_name]\n }\n }\n end",
"def relationships\n return [] if empty?\n\n map { |pivot_table| Relationship.new(pivot_table, PIVOT_TABLE_R, \"../#{pivot_table.pn}\") }\n end",
"def relationships\n @relationships ||= Relationship.from_associations(self, associations)\n end",
"def get_belongs_tos_for(model_name)\n associations.select { |a| a.name == model_name }.map(&:belongs_to_model)\n end",
"def each_relationship_for(model)\n # XXX: in dm-core 1.1.0, `Model#relationships` returns a\n # `DataMapper::RelationshipSet`, instead of a `Mash`, which does\n # not provide the `each_value` method.\n model.relationships.each do |args|\n relationship = case args\n when Array then args.last\n else args\n end\n\n unless relationship.respond_to?(:through)\n yield relationship\n end\n end\n end",
"def get_has_manys_for(model_name)\n associations.select { |a| a.belongs_to == model_name }.map(&:model)\n end",
"def relationships\n return [] unless has_comments?\n\n comments.relationships\n end",
"def related_models\n via_assay = assays.collect(&:models).flatten.uniq.compact\n via_assay | models\n end",
"def all_related_models\n via_assay = related_assays.collect do |assay|\n assay.model_masters\n end.flatten.uniq.compact\n via_assay | related_models\n end",
"def model_relationships\n hash = ActiveSupport::OrderedHash.new\n reflect_on_all_associations.map { |i| hash[i.name] = i.macro }\n return hash\n end",
"def associations_scope\n model_class_name.constantize.all\n end",
"def associations_scope\n model_class_name.constantize.all\n end",
"def model_relationships; end",
"def list_relationships\n end",
"def jsonapi_relationships\n\t\t\t\t\tjsonapi_model_class.reflect_on_all_associations.collect do |association|\n\t\t\t\t\t\t#type = nil\n\n\t\t\t\t\t\ttype = :to_one if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasOneReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::BelongsToReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\ttype = :to_many if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasManyReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::HasAndBelongsToManyReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\tnext unless type\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: association.name,\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\treceiver: {\n\t\t\t\t\t\t\t\ttype: association.klass.to_s.underscore.pluralize.to_sym,\n\t\t\t\t\t\t\t\tclass: association.klass.to_s.constantize\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tend.compact\n\t\t\t\tend",
"def belong_tables(model)\n model.reflect_on_all_associations(:belongs_to).map do |belong|\n belong.name.to_s.pluralize\n end.sort\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.associations}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def relations\n self.class.relations\n end",
"def dependencies_for(model)\n dependencies = Set.new\n # Each association is a dependency\n model.reflect_on_all_associations.each do |ass|\n relation_name = ass.name.to_s\n class_name = ass.options[:class_name] || relation_name.singularize.camelize\n\n dependencies.add? class_name\n end\n dependencies\n end",
"def relationships\n r = Relationships.new\n r << Relationship.new(cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, \"../#{cache_definition.pn}\")\n r\n end",
"def all_belongs_to(from_klass)\n monomorphic_relations = from_klass.relations.map(&:second).select do |r| \n r.macro == :belongs_to && !r[:polymorphic]\n end.map do |relation|\n relation.class_name\n end\n \n polymorphic_relations = from_klass.relations.map(&:second).reduce([]) do |memo, r| \n if r.macro == :belongs_to && r[:polymorphic] == true\n models.each do |model_klass_name|\n next unless has_many(model_klass_name.constantize, from_klass).any?\n next if monomorphic_relations.include? model_klass_name\n memo << model_klass_name \n end\n end\n memo\n end\n monomorphic_relations + polymorphic_relations\n end",
"def associations\r\n [nil, joins]\r\n end",
"def get_relationships_of_type(type)\n g_command = get_command(type)\n relationships = self.send(g_command.to_sym)\n end",
"def instances_relating_to(obj)\n relationships.map {|relationship_defn|\n relationship_defn.who_participates_with(obj)\n }.flatten\n end",
"def associations_array\n resource.reflect_on_all_associations.map { |association| association.name.to_s }\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.association_fields}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def relationships\n @relationships ||= {}\n end",
"def hm_associations\n hm = []\n associations = self.reflect_on_all_associations\n associations.map {|x| hm << x.name if x.macro.to_s == \"has_many\"}\n return hm.flatten\n end",
"def relationships\n @relationships.each do |k, v|\n if v.respond_to?(:uniq!)\n v.uniq!\n @relationships[k] = v.first if v.length == 1\n end\n end\n @relationships\n end",
"def get_relations_from_api(api=Rosemary::API.new)\n api.get_relations_referring_to_object(type, self.id.to_i)\n end",
"def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def many_to_one_relationships\n relationships unless @relationships # needs to be initialized!\n @relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end\n end",
"def active_record_has_and_belongs_to_many(model, relation)\n return [] unless relation.macro == :has_and_belongs_to_many\n\n dump_proxy_table(model, relation)\n end",
"def associations\n association_ids = model.association_field_ids\n data.select{|k,v| association_ids.include?(k.to_s) }\n end",
"def relationships\n r = Relationships.new\n @worksheets.each do |sheet|\n r << Relationship.new(sheet, WORKSHEET_R, format(WORKSHEET_PN, r.size + 1))\n end\n pivot_tables.each_with_index do |pivot_table, index|\n r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, format(PIVOT_TABLE_CACHE_DEFINITION_PN, index + 1))\n end\n r << Relationship.new(self, STYLES_R, STYLES_PN)\n if use_shared_strings\n r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN)\n end\n r\n end",
"def scaffold_all_associations\n relationships.values.select { |v|\n v.send(:target_model).respond_to?(:scaffold_name)\n }\n end",
"def has_associations\n assocs.each_rel.to_a\n end",
"def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end",
"def associations\n # is caching ok?\n unless @associations\n @associations = {}\n klass.relations.each{|name,association|\n @associations[name.to_s] = Association.new(association,self)\n }\n end\n @associations\n end",
"def find_relations\n sql = <<-eos\n SELECT\n tc.constraint_name, tc.table_name, kcu.column_name,\n ccu.table_name AS foreign_table_name,\n ccu.column_name AS foreign_column_name\n FROM\n information_schema.table_constraints AS tc\n JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name\n JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name\n WHERE constraint_type = 'FOREIGN KEY'\n eos\n @relations = @connection.exec(sql).values\n end",
"def relations\n _relations\n end",
"def relations\n _relations\n end",
"def associations\n @associations ||= [].tap do |fields|\n @model.reflect_on_all_associations.each do |association|\n fields << resolve(association.macro, association.name)\n end\n end\n end",
"def fetch_model_list\n if parent_model\n return parent_model.send(\"#{model_name.pluralize.downcase}\")\n else\n return model_name.camelize.constantize.find(:all)\n end\n end",
"def relations\n @relations ||= process_rels\n end",
"def get_relations\n # Descobrir as relacoes:\n # Orientados\n # Projetos de Pesquisa\n # Producoes Bibliograficas\n # Consultar o RP de cada uma\n # Somar os RPs e retornar\n orientados = self.get_relations_of_orientados\n projetos = self.get_relations_of_projetos_pesquisa\n producoes = self.get_relations_of_producoes_bibliograficas\n\n relations = (orientados | projetos | producoes).delete self.id\n return relations.to_a\n end",
"def belongs_to_relations(ar_instance)\n\t\t\tcolumns = ar_instance.class.column_names\n\t\t\tparents = columns.map{ |c| c if c =~ /_id/ }.reject{ |c| c.nil? }\n\t\t\tparents.map!{ |parents| parents.gsub('_id', '') }\n\t\tend",
"def model_association_names\n return unless model_associations\n\n model_associations.map do |assoc|\n assoc.name.to_sym\n end\n end",
"def visible_relations \n\t\t\tif defined? @visible_relations \n\t\t\t\t@visible_relations\n\t\t\telse\n\t\t\t\tassociation_helper_models = []\n\t\t\t\t# find \n\t\t\t\tself.reflections.keys.each do |key|\n\t\t\t\t\tif self.reflections[key].class == ActiveRecord::Reflection::ThroughReflection\n\t\t\t\t\t\tassociation_helper_models.push self.reflections[key].options[:through]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tkeys = self.reflections.keys.map do |key| key.to_sym end\n keys - association_helper_models\n\t\t\tend\n\t\tend",
"def frbr_relationships\n frbr_relationships=Array.new()\n for rel in relationships.uniq\n reltype=RelationshipType.find(rel.relationship_type_id)\n \n #Choose the entity_type that does not match this one.\n #Where both are the same, it does not matter which we pick\n my_entity=EntityType.entityTypeToId(rel.ent_entity_type_id)\n if EntityType.entityTypeToId(rel.ent_entity_type_id) == frbr_type() then \n my_entity= EntityType.entityTypeToId(rel.entity_type_id)\n end\n \n related_objects=eval('rel.'+my_entity+'s')\n \n for related_object in related_objects\n if rel.entity_type_id == rel.ent_entity_type_id then\n if related_object.id != id then\n frbr_relationships.push(FrbrRelationship.new(related_object,reltype.relationship_type_desc,my_entity))\n end\n else \n frbr_relationships.push(FrbrRelationship.new(related_object,reltype.relationship_type_desc,my_entity))\n end\n end\n end\n frbr_relationships\n end",
"def has_many_elements(element, target_model)\n element.class.reflect_on_all_associations(:has_many).each do |assoc|\n if assoc.name.to_s == target_model.downcase.pluralize\n model = Object.const_get(target_model.singularize.camelize)\n return element.send(target_model.downcase.pluralize).paginate(:per_page => 10, :page => 1)\n end\n end\n return []\n end",
"def model_associations\n @model_associations ||= Prepares.model_associations\n end",
"def relations_by_type\n relations = {}\n for i in 0..(self.relations.count-1)\n type = self.relations(i).type.first\n relations[type] ||= []\n relations[type] += self.relations(i).id\n end\n relations\n end",
"def associated_acts\n if self.type == \"Person\"\n arr = Array.new\n artist_relations = get_relations(self.relations, \"artist\")\n artist_relations.each do |relation|\n if relation[\"type\"] == \"member of band\"\n arr << relation\n end\n end\n return arr\n else\n return nil\n end\n end",
"def each_relationship\n return enum_for(__method__) unless block_given?\n\n each_model do |model|\n each_relationship_for(model) do |relationship|\n yield relationship, model\n end\n end\n end",
"def non_auto_closeable_relationships\n result = []\n\n rules.each do |rule|\n next unless rule.source_jsonmodel_category == :agent\n\n rule.relationship_types.each do |relationship_type|\n if ['creation', 'succession'].include?(relationship_type)\n result << build_relationship_jsonmodel_name(rule, relationship_type)\n end\n end\n end\n\n result\n end",
"def frbr_relationships\n frbr_relationships=Array.new()\n for rel in relationships.uniq\n reltype=RelationshipType.find(rel.relationship_type_id)\n \n #Choose the entity_type that does not match this one.\n #Where both are the same, it does not matter which we pick\n my_entity=EntityType.entityTypeToId(rel.ent_entity_type_id)\n if EntityType.entityTypeToId(rel.ent_entity_type_id) == frbr_type() then \n my_entity= EntityType.entityTypeToId(rel.entity_type_id)\n end\n \n related_objects=eval('rel.'+my_entity+'s')\n \n for related_object in related_objects\n if rel.entity_type_id == rel.ent_entity_type_id then\n if related_object.id != id then\n frbr_relationships.push(FrbrRelationship.new(related_object,reltype.relationship_type_desc,my_entity))\n end\n else \n frbr_relationships.push(FrbrRelationship.new(related_object,reltype.relationship_type_desc,my_entity))\n end\n end\n end\n frbr_relationships\n end",
"def list_relationships(entity_path, named = nil)\n path = entity_path.is_a?(CanonicalPath) ? entity_path : CanonicalPath.parse(entity_path)\n query_params = {\n sort: '__targetCp'\n }\n query_params[:named] = named unless named.nil?\n query = generate_query_params query_params\n ret = http_get(\"/path#{path}/relationships#{query}\")\n ret.map { |r| Relationship.new(r) }\n end",
"def associations\n association_reflections.keys\n end",
"def relations; enum_relations.to_a end",
"def associations_foreigns\n _reflections.map do |_, reflection|\n cols = [reflection.foreign_key]\n cols << reflection.foreign_type if reflection.polymorphic?\n cols\n end.flatten\n end",
"def relations_for_relation_type(relation_type)\n # Find all the relations that belong to us for this RelationType, ordered by position\n related_ids = relations.where(relation_type_id: relation_type.id).order(:position).select(:related_to_id)\n\n # Construct a query for all these records\n result = relation_type.applies_to.constantize.where(id: related_ids)\n\n # Merge in the relation_filter if it's available\n result = result.merge(relation_filter_for_relation_type(relation_type)) if relation_filter_for_relation_type(relation_type)\n\n # make sure results are in same order as related_ids array (position order)\n if result.present?\n result.where(id: related_ids).order(:position)\n end\n\n result\n end",
"def child_ontology_relationships(options = {}) # :yields: Array of OntologyRelationships\n opt = {\n :relationship_type => 'all' # or a ObjectRelationships#id\n }.merge!(options.symbolize_keys)\n\n # TODO: modify to sort by first(top) label\n if opt[:relationship_type] == 'all'\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ?', self.id]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n else\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ? AND object_relationship_id = ?', self.id, opt[:relationship_type]]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n end\n end",
"def relationships(*ids)\n perform_request_with_collection(:get, '/api/v1/accounts/relationships',\n array_param(:id, ids),\n Mastodon::Relationship)\n end",
"def descendant_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:descendants).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def list_objects\n objects = @model_class.method(:list).arity == 0 ? @model_class.list : @model_class.list(true)\n objects.map { |obj| Array(obj).find { |o| o.is_a?(@model_class) } }\n end",
"def my_relationships(name)\n self.class.find_relationship(name).find_by_participant(self)\n end",
"def reflections_for(main, rel)\n main.class\n .reflect_on_all_associations\n .select { |r| r.macro == rel && r.options[:through].nil? }\n end",
"def get_all_related_tables\n tables = [ @table_name ]\n return tables if @relations.nil?\n @relations.each do |n,r|\n tables = tables | get_relation_tables(r)\n end\n tables.sort\n end",
"def models\n children = []\n Mongoid.models.each do |model|\n children << model.to_s\n model.descendants.each do |child|\n inh = [child.to_s]\n sk = child.superclass\n while sk != model\n inh << sk.to_s\n sk = sk.superclass\n raise '!' if sk == Object\n end\n\n children << ' ' + inh.reverse.join(' < ')\n end\n end\n children\nend",
"def accounts(type=AbstractAccount)\n # See http://stackoverflow.com/questions/3371518/in-ruby-is-there-an-array-method-that-combines-select-and-map/17703276#17703276\n # for why reduce was used here\n self.class.reflect_on_all_associations(:has_one).reduce([]) do |result, association|\n result.push self.send association.name if association.klass < type\n result\n end\n end",
"def associations\n return [] unless self.included_modules.include?(Revisionary::Core)\n [self.revisionary_options[:with]].flatten\n end",
"def get_polymorphic_as_associations_classes(model, reflection)\n classes = []\n @polymorphic_as_reflections.each do |poly_as_reflection|\n if poly_as_reflection.send(:options)[:as] == reflection.send(:name)\n if poly_as_reflection.active_record.send(:compute_type, poly_as_reflection.send(:class_name)).to_s == model.to_s\n classes << poly_as_reflection.active_record.to_s.constantize\n end\n end\n end\n classes\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def all_associations\n @all_associations ||= (\n # field associations\n @fields.collect { |field|\n field.associations.values\n }.flatten +\n # attribute associations\n @attributes.collect { |attrib|\n attrib.associations.values\n }.flatten\n ).uniq.collect { |assoc|\n # get ancestors as well as column-level associations\n assoc.ancestors\n }.flatten.uniq\n end",
"def all\n @data_adapter.relations\n end",
"def models(*entities)\n visited_models = Set.new\n filter = lambda {|n| visited_models.add?(n.model)}\n nodes(*entities, filter: filter).map(&:model)\n end",
"def rels(node)\n @batch_inserter.getRelationships(node)\n end",
"def linked_associations\n associations.values.select(&:linked?)\n end",
"def relationships\n [Relationship.new(self, VML_DRAWING_R, \"../#{vml_drawing.pn}\"),\n Relationship.new(self, COMMENT_R, \"../#{pn}\")]\n end",
"def relation_table(model)\n validate_model(model)\n model.arel_table\n end",
"def get_associations(node)\n node.class.reflect_on_all_associations.select do |assoc|\n [:destroy, :delete_all].include?(assoc.options[:dependent]) &&\n [:has_many, :has_one].include?(assoc.macro)\n end\n end",
"def finalize_managed_models!\n models = []\n if @managed_models\n @managed_models.each do |m|\n models += m.relationships.values.map{|r| r.child_model }\n models += m.relationships.values.map{|r| r.parent_model }\n end\n @managed_models += models\n @managed_models.uniq!\n end\n @managed_models\n end",
"def related_records(name)\n relationship = self.class.find_relationship(name)\n records = relationship.who_participates_with(self)\n\n relationship.wants_array? ? records : records.first\n end",
"def associations\n data[:associations]\n end",
"def resource_associations(association_type)\n resource_class.reflect_on_all_associations(association_type).map(&:name)\n end",
"def models\n Model.all.select {|model| model.make_id == id}\n end",
"def models(join_ids = nil, page = nil, where = {})\n models = self.where(where)\n models = models.page(page) unless page.nil?\n models = join_habtm(models, join_ids) if join_ids\n\n models\n end",
"def joins\n j = []\n associations.each do |association|\n next if association.conditions.blank?\n association_joins = association.joins\n j << (association_joins.blank? ? association.relationship_name.to_sym : {association.relationship_name.to_sym => association_joins})\n end\n j.blank? ? nil : (j.size == 1 ? j.first : j)\n end",
"def models_list\n ModelsList.to_a\n end",
"def relations \n @roots = Category.roots \n @categories = Category.has_children \n @expense_types = ExpenseType.all\n @payment_methods = PaymentMethod.all\n end",
"def complile_relationships\n relationships = []\n @classifications.each do |classification|\n relationship = Relationship.new(@query, classification)\n relationships << relationship unless relationship.score.zero?\n end\n relationships.sort\n end",
"def all( model )\n model( model ).all\n end",
"def related_objects\n related_objects = Array.new\n\n\t\tself.meta_data_group_assignments.uniq.each do |assignment|\n\t\t\tobject_type = assignment.meta_data_group_assignable_type\n\t\t\tobject_id = assignment.meta_data_group_assignable_id\n\n\t\t\trelated_object = eval(object_type+'.find('+object_id.to_s+')')\n\t\t\trelated_objects.push(related_object)\n\t\tend\n\n\t\tputs related_objects.inspect\n\n return related_objects\n end",
"def relations\n @relations ||= {}\n end",
"def associations\n @associations ||= {}.with_indifferent_access\n end",
"def __belongs_to__\n\t\treturn_string = []\n\t\tself.class.reflect_on_all_associations(:belongs_to).each do |association| \n\t\t\tmodel = self.send(association.name)\n\t\t\tif model\n\t\t\t\treturn_string.push model.reference_attribute \n\t\t\tend\n\t\tend\n\t\treturn_string.join \" \"\n\tend"
] | [
"0.7202642",
"0.71134764",
"0.690465",
"0.680955",
"0.6733298",
"0.6652221",
"0.66227376",
"0.6468133",
"0.6446618",
"0.64291877",
"0.64210516",
"0.6378718",
"0.6329107",
"0.6291643",
"0.6291643",
"0.62878793",
"0.6255121",
"0.62406874",
"0.60722697",
"0.6070839",
"0.6057531",
"0.6054536",
"0.60160375",
"0.5974529",
"0.59671044",
"0.59657955",
"0.5948199",
"0.59413993",
"0.59164745",
"0.58896214",
"0.5886556",
"0.5863693",
"0.58603394",
"0.58393604",
"0.58226603",
"0.5771974",
"0.5771922",
"0.5745453",
"0.57031465",
"0.5696179",
"0.567783",
"0.5655975",
"0.56482744",
"0.56467533",
"0.56467533",
"0.5632203",
"0.5615337",
"0.558844",
"0.558546",
"0.5581188",
"0.55796075",
"0.5567532",
"0.55624074",
"0.5556534",
"0.55440664",
"0.551979",
"0.55037725",
"0.55010784",
"0.5495435",
"0.5494972",
"0.5487258",
"0.5456872",
"0.54518974",
"0.5420555",
"0.5411972",
"0.5404146",
"0.538262",
"0.5371629",
"0.53670037",
"0.53616905",
"0.536066",
"0.5347643",
"0.5343822",
"0.5333035",
"0.5331752",
"0.5318609",
"0.5312871",
"0.531162",
"0.5307683",
"0.5285139",
"0.52783597",
"0.52772194",
"0.52676344",
"0.52667683",
"0.5246818",
"0.52412105",
"0.52345395",
"0.5200396",
"0.51994056",
"0.51958156",
"0.51819134",
"0.51809525",
"0.51721066",
"0.516315",
"0.5160464",
"0.51549864",
"0.51537526",
"0.51501846",
"0.5146573",
"0.51388943"
] | 0.8166936 | 0 |
taken from CGI::escape tweaked to fix exception | def escape(string)
string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
$1.nil? ? nil : ('%' + $1.unpack('H2' * $1.bytesize).
compact.join('%').upcase)
end.tr(' ','+')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cgi_escape(input); end",
"def safe_escape(uri); end",
"def check_and_escape(url)\n check url\n CGI.escape url\n end",
"def escape(string); end",
"def uri_escape(input); end",
"def escape(str); end",
"def escape(str)\n CGI.escape(str)\n end",
"def e(value)\n CGI.escape(value)\n end",
"def erb_escape(text)\n # Do not only replace '<%' ! or <r:t>min</r:t>% ==> <% ...\n text.gsub(SECURE_REGEXP) {|code| SAFE_CODE[code]}\n end",
"def htmlEscape(string)\n return string.gsub('&', '&').gsub('>', '>').gsub('<', '<')\nend",
"def parse_escaped_chars; end",
"def u(str)\n CGI.escape(str)\n end",
"def url_encode(string)\n string = CGI.escape string\n end",
"def convert_string(text)\n CGI.escapeHTML text\n end",
"def html_escape(s)\n CGI.escapeHTML(s.to_s)\n end",
"def html_escape(str)\r\n str.gsub('&', '&').str('<', '<').str('>', '>').str('\"', '"')\r\nend",
"def consume_escaped; end",
"def safe(str)\n CGI.unescape(str)\n end",
"def uri_escape(string)\n if string.nil?\n nil\n else\n CGI.escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')\n end\n end",
"def safe_encode(string)\n CGI::escape(string).gsub(/\\+/, '%20')\n end",
"def escape(str)\n URI.escape str, /[:?\\/']/\nend",
"def esc_ht str\n\t\treturn Escape.html str\n\tend",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def escape_html(str, type = T.unsafe(nil)); end",
"def escape_uri(s); Rack::Utils.escape(s); end",
"def safe_encode value\n value = URI.encode_www_form_component(value).gsub(/\\+/,'%20').gsub(/\\*/,'%2A').gsub(/%7E/,'~')\n end",
"def fix_double_escape(escaped)\n escaped.gsub(/&([a-z]+|(#\\d+));/i) { \"&#{$1};\" }\n end",
"def pre_escape_query(query)\n # have to include apostrophe in here too, even though it's NOT\n # in the docs reserved list (and does not generally require URI escaping,\n # in theory) -- still need to double escape it to avoid YBoss returning\n # ' in suggestions! \n #\n # Do not need to double escape spaces even though they do need URI escaping. \n #\n # We are telling it ONLY to escape our list of punctuation that causes\n # trouble for YBoss unless double-escaped. Which means it won't escape\n # diacritics and other non-latin. Which means the output is still UTF8, \n # but ruby URI.escape incorrectly tags it \"ascii\", which causes probelms\n # later with illegal bytes -- so we need to retag as UTF-8 \n return URI.escape(query, \"/?&;:@,$=%\\\"#*<>{}|[]^\\\\`()'\").force_encoding(\"UTF-8\")\n end",
"def encode_string_ex; end",
"def escape(s)\n URI.encode_www_form_component(s)\n end",
"def escape_content\n content.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\") \n end",
"def _encode(source)\n source.gsub(' ','_').gsub(/%.<.+?>/) { |match|\n CGI.escape(match[3..-2]).gsub('%', match[1..1])\n }\n end",
"def html_escape(text)\n Rack::Utils.escape_html(text)\n end",
"def esc(str)\n str = str.to_s.gsub(\"&\", \"&\")\n str = str.gsub(\"\\\"\", \"'\")\n str = str.gsub(\"\\\"\", \""\")\n str = str.gsub(\"<\", \"<\")\n str.gsub(\">\", \">\")\nend",
"def escape(str)\n str.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").force_encoding('US-ASCII')\n end",
"def uri_escape\n CGI.escape(self)\n end",
"def make_html_safe i_string\n\t\t\t# CGI::escapeHTML i_string.to_s\n\t\t\ti_string\n\t\tend",
"def safe *things\n\t\t\tappend! CGI.escapeHTML(things.map(&:to_s).join(\"\\n\"))\n\t\tend",
"def unescape(input)\n CGI.unescapeHTML(input) rescue input\n end",
"def encodeURI s\n URI.escape s, /[^A-Za-z0-9;,\\/?:@&=+$\\-_.!~*'()#]/\nend",
"def valid_escape?(text = T.unsafe(nil)); end",
"def url_encode\n Rack::Utils.escape self\n end",
"def h(string)\n Rack::Utils.escape_html(string) # Escape any html code that appears on page e.g. <script>\nend",
"def escape_value(value)\n CGI.escape(value.to_s).gsub('%20', '+')\n end",
"def h(str)\n CGI.escapeHTML(str)\n end",
"def xml_escape(input); end",
"def cgi_escape(string)\n CGI.escape(string).gsub(\"+\", \" \")\n end",
"def escape(input); input.to_s.gsub('\"', '\\\\\"'); end",
"def uri_escape_key(string)\n if string.nil?\n nil\n else\n CGI.escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~').gsub(\"%2F\", \"/\")\n end\n end",
"def uri_escape(str)\n str.split(//).map {|c| c.match(URI::UNSAFE) ? sprintf('%%%02x',c.ord).upcase : c }.join\nend",
"def uri_escape(str)\n str.split(//).map {|c| c.match(URI::UNSAFE) ? sprintf('%%%02x',c.ord).upcase : c }.join\nend",
"def escape(value)\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def html_escape(clean_me)\n clean_me.to_s.gsub(/[&\"<>]/) do |special|\n { '&' => '&',\n '>' => '>',\n '<' => '<',\n '\"' => '"' }[special]\n end\n end",
"def html_escape(s)\n s.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\")\n end",
"def h(str)\n CGI.unescape_html(str.to_s)\n .gsub('&', '&')\n .gsub('\"', '"')\n .gsub('<', '<')\n .gsub('>', '>')\n end",
"def url_escape(string)\n return '' if string.blank?\n\n string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do\n '%' + $1.unpack('H2' * $1.size).join('%').upcase\n end.tr(' ', '+')\n end",
"def escape_special_chars(data)\n data = data.dup\n data.gsub! /&/n , \"&\"\n data.gsub! /\\\"/n , \""\"\n data.gsub! />/n , \">\"\n data.gsub! /</n , \"<\"\n data.gsub! /'/ , \"'\"\n return data\n end",
"def escape(value)\n _escape(value.to_s.to_str)\n rescue ArgumentError\n _escape(value.to_s.to_str.force_encoding(Encoding::UTF_8))\n end",
"def likeEscape( str )\n str.gsub( \"\\\\\", \"\\\\\\\\\" ).gsub( \"%\", \"\\%\" ).gsub( \"_\", \"\\_\" )\n end",
"def h(str)\n CGI.escapeHTML(str.to_s)\n end",
"def consume_bad_url\n text = String.new\n\n until @s.eos?\n if valid_escape?\n text << consume_escaped\n elsif valid_escape?(@s.peek(2))\n @s.consume\n text << consume_escaped\n else\n char = @s.consume\n\n if char == ')'\n break\n else\n text << char\n end\n end\n end\n\n text\n end",
"def escape(text)\n text.gsub('\"', '\\\"')\nend",
"def escape_text(text)\n text\n end",
"def _bad_parse(post)\n @params ||= Hash.new\n @raw = post.to_s\n #puts (\"-----parsing starts----\") * 8\n for line in @raw.split('&')\n key, value = *line.scan( %r{^([A-Za-z0-9_.-]+)\\=(.*)$} ).flatten\n if key.present?\n if self.class.const_defined?(:FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING) \\\n && self.class::FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING.include?(key)\n params[key] = value.to_s\n else\n params[key] = CGI.unescape(value.to_s)\n end\n end\n end\n #puts (\"-----parsing ends----\") * 8\n @params\n end",
"def escape(str)\n str.dump[1..-2]\nend",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end"
] | [
"0.8084458",
"0.73213637",
"0.7263439",
"0.7167144",
"0.71358263",
"0.7029205",
"0.6817555",
"0.6706272",
"0.66064715",
"0.65852493",
"0.6577379",
"0.65755105",
"0.6549132",
"0.6541183",
"0.65331733",
"0.6502181",
"0.6501331",
"0.649861",
"0.64928687",
"0.649137",
"0.64805925",
"0.64430404",
"0.64291763",
"0.64177597",
"0.63911974",
"0.63760644",
"0.63696635",
"0.6368784",
"0.6367516",
"0.6358403",
"0.6350952",
"0.63463694",
"0.6314975",
"0.6304017",
"0.63018423",
"0.62958443",
"0.6291942",
"0.6290213",
"0.6279744",
"0.6274635",
"0.6268528",
"0.626254",
"0.6260158",
"0.6257734",
"0.62514216",
"0.62462765",
"0.6242167",
"0.6238083",
"0.6221364",
"0.6185161",
"0.6185161",
"0.6155347",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6152332",
"0.6151053",
"0.6149585",
"0.6132645",
"0.6132123",
"0.6104574",
"0.6090706",
"0.6081087",
"0.60762393",
"0.60728145",
"0.60640866",
"0.60506386",
"0.6050078",
"0.60444665",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287",
"0.60341287"
] | 0.0 | -1 |
Sets the default namespace to use to the given value, or (if the value is nil or false) to the value returned by the given block. Example: class Project < ActiveRecord::Base set_table_name "project" end | def set_default_namespace(value = nil, &block)
define_attr_method :default_namespace, value, &block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace(value = nil)\n if value\n @namespace = value\n else\n @namespace\n end\n end",
"def set_table_name(value = nil, &block)\n define_attr_method :table_name_without_shard, value, &block\n end",
"def table_name=(value)\n @original_table_name = @table_name if defined?(@table_name)\n @table_name = value && value.to_s\n @quoted_table_name = nil\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def namespace\n \"#{database.name}.#{name}\"\n end",
"def set_table(table_name)\n @current = table_name\n end",
"def namespaced_table_name\n [self.class.table_namespace, table_name].reject {|s| s.nil? || s.empty?}.join('-')\n end",
"def namespace(value = nil)\n if value\n field_type.namespace(value)\n else\n record.namespace\n end\n end",
"def default_namespace=(url); end",
"def default_namespace=(url); end",
"def default_namespace=(url)\n add_namespace_definition(nil, url)\n end",
"def namespace(namespace = nil)\n @namespace = namespace if namespace\n @namespace\n end",
"def namespace=(value)\n @namespace = value\n end",
"def namespace=(value)\n @namespace = value\n end",
"def roomer_set_table_name_prefix\n self.table_name_prefix = begin\n case @roomer_scope\n when :shared\n roomer_full_table_name_prefix(Roomer.shared_schema_name)\n when :tenanted\n roomer_full_table_name_prefix(Roomer.current_tenant.try(Roomer.tenant_schema_name_column))\n else\n \"\"\n end\n end\n end",
"def table_name(table_name = nil)\n if table_name\n @table_name = table_name\n else\n @table_name\n end\n end",
"def namespace(namespace = nil)\n @namespace = namespace if namespace\n @namespace if defined? @namespace\n end",
"def default_namespace(url)\n @namespaces[''] = url\n end",
"def set_table(table)\n define_class_method(:table) {table.to_s.to_sym}\n end",
"def set_namespace(ns = '')\n settings['namespace'] = ns\n end",
"def set_tab(name, namespace = nil)\n tab_stack[namespace || :default] = name\n end",
"def set_table_name(name) # rubocop:disable Naming/AccessorMethodName\n @table_name = name\n end",
"def set_namespace(namespace)\n return if !active? ||\n Appsignal::Transaction.current.nil? ||\n namespace.nil?\n Appsignal::Transaction.current.set_namespace(namespace)\n end",
"def table_name=(name)\n @table_name = name\n end",
"def namespace(namespace = nil, options = {})\n return @namespace unless namespace\n\n @namespace = namespace.to_sym if namespace\n @base_namespace = options[:base].to_sym if options[:base]\n end",
"def set_namespace\n @namespace = Namespace.find(params[:namespace_id])\n end",
"def default_database_name\n self.name.tableize\n end",
"def table_name\n @table_name ||= self.class.const_get(class_name).table_name\n end",
"def namespace(name, &block)\n @namespace = clean_path(name)\n yield self\n end",
"def namespace=( namespace )\n\t\t@namespace = namespace.nil? ? nil : namespace.to_sym\n\tend",
"def namespace(value)\n _namespace(value) or fail ArgumentError, \"Unknown value for namespace: #{value}\"\n end",
"def namespace_name\n @namespace_name ||= namespaces.join('::')\n end",
"def reset_table_name #:nodoc:\n self.table_name = compute_table_name\n end",
"def namespace=(v)\n cfg_set(:namespace, v)\n end",
"def namespace\n @namespace ||= schema.attributes['Namespace'].value\n end",
"def table_name_prefix \n @table_name_prefix ||= 'gricer_'\n end",
"def namespace=(ns) @namespace = @store.namespace = ns; end",
"def set_schema(name = nil, &block)\n set_dataset(db[name]) if name\n @schema = db.create_table_generator(&block)\n set_primary_key(@schema.primary_key_name) if @schema.primary_key_name\n end",
"def namespace=(v)\n cfg_set(:namespace, v)\n end",
"def namespace(prefix = T.unsafe(nil)); end",
"def namespace=(value)\n self.namespaces = [value]\n end",
"def namespace(ns)\n ns.blank? ? \"nil\" : %|\"#{ns.prefix}\"|\nend",
"def namespace=(ns); end",
"def namespace=(ns); end",
"def default_prefix=(prefix)\r\n # Find default prefix\r\n ns = find_by_prefix(nil)\r\n raise(ArgumentError, \"No default namespace was found\") unless ns\r\n Namespace.new(self.node, prefix, ns.href)\r\n end",
"def set_namespace\n @namespace = Namespace.find(params[:id])\n end",
"def set_namespace\n @namespace = Namespace.find(params[:id])\n end",
"def namespace(value)\n merge(namespace: value.to_s)\n end",
"def namespace\n @namespace || self.class.namespace\n end",
"def namespace(namespace, &block)\n ::Dry::Container::NamespaceDSL.new(\n self,\n namespace,\n config.namespace_separator,\n &block\n )\n\n self\n end",
"def namespace=(namespace)\n @connection = nil\n if namespace.nil?\n @namespace = nil\n else\n @namespace = namespace\n end\n end",
"def namespace(name = nil, url = nil)\n @namespaces[name.to_s] = url\n end",
"def table(table_name)\n tables[table_name] ||= Table.new(self, table_name)\n end",
"def namespace(options={}, &block)\n model = Caracal::Core::Models::NamespaceModel.new(options, &block)\n if model.valid?\n ns = register_namespace(model)\n else\n raise Caracal::Errors::InvalidModelError, 'namespace must specify the :prefix and :href attributes.'\n end\n ns\n end",
"def table_name\n @table_name ||= (superclass == SmallRecord::Base) ? default_table_name : superclass.table_name\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def schema_name=schema_name\n self.table_name_prefix = \"#{schema_name}.\" if schema_name && !schema_name.blank?\n self.table_name = \"#{self.table_name_prefix}#{self.table_name}\" unless self.abstract_class?\n end",
"def namespace=(v); end",
"def default_tablespace\n select_value(<<~SQL.squish, \"SCHEMA\")\n SELECT LOWER(default_tablespace) FROM user_users\n WHERE username = SYS_CONTEXT('userenv', 'current_schema')\n SQL\n end",
"def namespace(name=nil, &block)\n name = name.to_s if name.kind_of?(Symbol)\n name = name.to_str if name.respond_to?(:to_str)\n unless name.kind_of?(String) || name.nil?\n raise ArgumentError, \"Expected a String or Symbol for a namespace name\"\n end\n Rake.application.in_namespace(name, &block)\n end",
"def table_name(class_name = nil)\n if class_name.nil?\n class_name = class_name_of_active_record_descendant(self)\n table_name_prefix + undecorated_table_name(class_name) + table_name_suffix\n else\n table_name_prefix + undecorated_table_name(class_name) + table_name_suffix\n end\n end",
"def set_namespace(namespace)\n return unless namespace\n\n @namespace = namespace\n @ext.set_namespace(namespace)\n end",
"def namespace\n @namespace ||= 'silver_spoon'\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def table_name\n cti_tables ? cti_tables.last : super\n end",
"def mask\n @name == \"default\" ? @namespace : \"#{@namespace}:#{@name}\"\n end",
"def namespace\n @options[:space_name]\n end",
"def namespace\n @namespace ||= metadata.xpath('//Schema').first.attributes['Namespace'].value\n end",
"def table_name_prefix(model)\n return model::Base.table_name_prefix rescue \"\"\n end",
"def table_prefix component, use_table_name = nil\n case use_table_name\n when false, nil\n ''\n when true\n safe_table_name(component)+'.'\n else\n use_table_name+'.'\n end\n end",
"def namespace(new_namespace=nil,name=nil,&block)\n raise ArgumentError, \"Scope must be a string, a symbol, or a hash with string values.\" if !new_namespace.nil? && !(new_namespace.is_a?(String) || new_namespace.is_a?(Symbol) || new_namespace.is_a?(Hash))\n @namespace ||= '/'\n if new_namespace.is_a?(Hash)\n new_namespace.each do |name,new_namespace|\n block_given? ? namespace(new_namespace,name) { block.call } : namespace(new_namespace,name)\n end\n else\n # Here we have just one namespace and *possibly* a name to save for the first route registered with this namespace.\n # Sanitize new namespace to NOT end with a slash OR begin with a slash.\n @next_route_name = new_namespace if new_namespace.is_a?(Symbol)\n new_namespace = new_namespace.to_s.gsub(/(^\\/|\\/$)/,'') if new_namespace\n @next_route_name = name if name\n # Join namespace to previous namespace by a slash.\n if block_given?\n old_namespace = @namespace\n @namespace = @namespace.gsub(/\\/$/,'')+'/'+new_namespace\n yield\n @namespace = old_namespace\n else\n if new_namespace.nil?\n @namespace\n else\n @namespace = @namespace.gsub(/\\/$/,'')+'/'+new_namespace\n end\n end\n end\n end",
"def apply_defaults( table_name, name, *args )\n opts = {}\n opts.merge!( get_defaults( :global ) )\n\n if name[ -1 ] == '?'\n opts[ :null ] = true\n original_name = name\n name = name[ 0..-2 ].to_sym\n end\n\n opts.merge!( get_defaults( name ) )\n opts.merge!( get_defaults( original_name ) ) if original_name\n\n if callback = @callbacks[ name ]\n callback.call( opts, args, table_name )\n end\n\n opts.merge!( args.pop ) if args.last.is_a? Hash\n args << opts unless opts.empty?\n\n [ ( @aliases[ name ] || name ), *args ]\n end",
"def table_name_prefix; end",
"def namespace(name = nil)\n if name\n super\n else\n @namespace ||= super.chomp(\"_command\").sub(/:command:/, \":\")\n end\n end",
"def namespace\n NAMESPACE\n end",
"def qualified(table_name, context:)\n return table_name if table_name['.'].present?\n return table_name if context['.'].blank?\n\n \"#{context.sub(%r{[^.]*$}, '')}#{table_name}\"\n end",
"def namespace\n return NAMESPACE\n end",
"def namespace name\n declare_namespace(resource, name.intern)\n end",
"def change_space(namespace)\n update!(name: namespace)\n end",
"def namespace\n nil\n end",
"def setup_tables(&block)\n return nil unless block_given?\n self.class_eval(&block)\n self.table_settings \n end",
"def naming_convention name=nil \n nc = name.present?? name.to_s : ref_name\n if namespace_prefix.present?\n \t nc.split(namespace_prefix).last.camelize\n else\n nc.camelize\n end\n\trescue\n\t\tnil\n end",
"def models_namespace\n options[:model_namespace]\n end",
"def find_or_new_namespace(name, uri)\n namespace = @namespaces.find { |n| n.namespace == name } || (@namespaces << Restfulie::Common::Builder::Rules::Namespace.new(name, uri)).last\n namespace.uri = uri unless uri.nil?\n namespace\n end",
"def namespace\n nil\n end",
"def set_default_name \n self.name ||= \"Itinerary\" \n end",
"def namespace\n @namespace ||= [request.args.namespace_name, request.args.application_name].compact.join('-')\n end",
"def namespace\n return self.name ? self.name.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(' ', '-') : ''\n end",
"def namespace\n @namespace\n end",
"def cache_setup(host, user, app, name)\n @namespace = [host, user, app, name].compact.join(':')\n Table.create_table?\n @store = Table\n end",
"def table(name, &block)\n if block\n @config[:tables][name] = Docile.dsl_eval(Watchy::Config::TableConfigBuilder.new, &block).build\n else\n @config[:tables][name] = {\n rules: {\n insert: [],\n update: [],\n delete: [ Watchy::DefaultDeleteRule.new ]\n },\n versioning_enabled: true\n }\n end\n\n if @config[:tables][name][:rules][:delete].empty?\n @config[:tables][name][:rules][:delete] << Watchy::DefaultDeleteRule.new\n end\n end",
"def class_name(table_name = table_name) # :nodoc:\n # remove any prefix and/or suffix from the table name\n class_name = Inflector.camelize(table_name[table_name_prefix.length..-(table_name_suffix.length + 1)])\n class_name = Inflector.singularize(class_name) if pluralize_table_names\n return class_name\n end",
"def register_default_namespace(name)\n self.namespace.each do |n|\n if n.to_s == nil\n register_namespace(\"#{name}:#{n.href}\")\n return\n end\n end\n raise \"No default namespace found\"\n end",
"def table(*query_names, &block)\n each_query(query_names) do |query|\n query.table_settings = block\n end\n end",
"def namespace\n self.class.new split(NAMESPACE_SEPARATOR).first\n end",
"def quoted_table_name\n @quoted_table_name ||= \"`#{table_name}`\"\n end",
"def clean_table_name(table_name)\n class_from_table_name(table_name)&.table_name\n end",
"def namespace(path, options = T.unsafe(nil)); end",
"def table_name\n raise \"You must override `table_name' in your class\"\n end"
] | [
"0.6380705",
"0.63291216",
"0.60748833",
"0.5974105",
"0.5974105",
"0.59392923",
"0.5932018",
"0.5927515",
"0.5853463",
"0.5853463",
"0.5810484",
"0.5806982",
"0.5780072",
"0.5780072",
"0.5767254",
"0.5745242",
"0.57407093",
"0.5740127",
"0.5735612",
"0.5721895",
"0.57172245",
"0.5679561",
"0.56420785",
"0.56030506",
"0.55875564",
"0.55791235",
"0.5574604",
"0.5542964",
"0.55295265",
"0.5525284",
"0.5441048",
"0.542663",
"0.5416404",
"0.54148614",
"0.5412708",
"0.5405989",
"0.53930205",
"0.5392933",
"0.5391658",
"0.5384568",
"0.53782266",
"0.5351347",
"0.53366774",
"0.53366774",
"0.53354645",
"0.53333306",
"0.53333306",
"0.53126836",
"0.5307458",
"0.5293622",
"0.5288804",
"0.5278887",
"0.52735454",
"0.526403",
"0.5260738",
"0.5241757",
"0.52172625",
"0.52095014",
"0.52033836",
"0.5198721",
"0.5166804",
"0.5137685",
"0.51159984",
"0.51128745",
"0.51128745",
"0.5064128",
"0.5059214",
"0.50589055",
"0.5048939",
"0.50288606",
"0.502532",
"0.50215524",
"0.5002416",
"0.49962348",
"0.49861678",
"0.49788573",
"0.49704915",
"0.49687055",
"0.4958375",
"0.4938928",
"0.49285996",
"0.492835",
"0.4926604",
"0.49264452",
"0.49059993",
"0.49058682",
"0.49015284",
"0.49013507",
"0.48967278",
"0.48952025",
"0.4880352",
"0.48774448",
"0.4865183",
"0.4855252",
"0.48506302",
"0.48496342",
"0.48303896",
"0.48278192",
"0.48277596",
"0.4825654"
] | 0.7187948 | 0 |
Defines an "attribute" method (like inheritance_column or table_name). A new (class) method will be created with the given name. If a value is specified, the new method will return that value (as a string). Otherwise, the given block will be used to compute the value of the method. The original method will be aliased, with the new name being prefixed with "original_". This allows the new method to access the original value. Example: class A < ActiveRecord::Base define_attr_method :primary_key, "sysid" define_attr_method( :inheritance_column ) do original_inheritance_column + "_id" end end | def define_attr_method(name, value=nil, &block)
sing = class << self; self; end
sing.send :alias_method, "original_#{name}", name
if block_given?
sing.send :define_method, name, &block
else
# use eval instead of a block to work around a memory leak in dev
# mode in fcgi
sing.class_eval "def #{name}; #{value.to_s.inspect}; end"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_attr_method(name, value=nil, &block)\n case self.connection.adapter_name\n\n when 'PostgreSQL'\n sing = class << self; self; end\n self.class.send :alias_method, \"#{name}\", name\n if block_given?\n sing.send :define_method, name, &block\n else\n # use downcased column name\n sing.class_eval \"def #{name}; #{value.to_s.downcase.inspect}; end\"\n end\n\n else\n original_define_attr_method(name, value=nil, &block)\n end\n end",
"def define_attribute_method(column_name, &block)\n return if method_defined? column_name\n\n define_method(:\"#{column_name}=\") do |value|\n instance_variable_set(:\"@#{column_name}\", value)\n end\n\n define_method(:\"#{column_name}\") do\n instance_variable_get(:\"@#{column_name}\")\n end\n end",
"def define_method_attribute(attr_name)\n cast_code = attribute_cast_code(attr_name)\n\n generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1\n def __temp__\n #{internal_attribute_access_code(attr_name, cast_code)}\n end\n alias_method '#{attr_name}', :__temp__\n undef_method :__temp__\n STR\n\n generated_external_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1\n def __temp__(v, attributes, attributes_cache, attr_name)\n #{external_attribute_access_code(attr_name, cast_code)}\n end\n alias_method '#{attr_name}', :__temp__\n undef_method :__temp__\n STR\n end",
"def define_method_attribute(name)\n safe_name = name.unpack1(\"h*\")\n temp_method = \"__temp__#{safe_name}\"\n\n ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name\n sync_with_transaction_state = \"sync_with_transaction_state\" if name == primary_key\n\n generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1\n def #{temp_method}\n #{sync_with_transaction_state}\n name = ::ActiveRecord::AttributeMethods::AttrNames::ATTR_#{safe_name}\n _read_attribute(name) { |n| missing_attribute(n, caller) }\n end\n STR\n\n generated_attribute_methods.module_eval do\n alias_method name, temp_method\n undef_method temp_method\n end\n end",
"def define_attribute_method(name, attributes, default) # :nodoc:\n attribute = attributes.delete(name)\n \n case attribute\n when true\n # true means use the default and define the method\n attribute = default\n yield(attribute)\n \n when false\n # false means use the default, but let the user define the method\n attribute = default\n \n when nil\n # nil is not allowed\n raise \"#{name.inspect} attribute cannot be nil\"\n end\n # ... all other values specify what the method should be,\n # and lets the user define the method.\n\n attribute.to_sym\n end",
"def define_attribute_method(attr_name, _owner: generated_attribute_methods)\n CodeGenerator.batch(_owner, __FILE__, __LINE__) do |owner|\n attribute_method_matchers.each do |matcher|\n method_name = matcher.method_name(attr_name)\n\n unless instance_method_already_implemented?(method_name)\n generate_method = \"define_method_#{matcher.target}\"\n\n if respond_to?(generate_method, true)\n send(generate_method, attr_name.to_s, owner: owner)\n else\n define_proxy_call true, owner, method_name, matcher.target, attr_name.to_s\n end\n end\n end\n attribute_method_matchers_cache.clear\n end\n end",
"def define_attribute_method(method_name)\n attribute_name = method_name.to_s.gsub(/([=\\?]?)$/, '')\n modifier = $1\n \n attribute = PublicEarth::Db::Attribute.find_by_name(attribute_name) || \n PublicEarth::Db::Attribute.find_by_name!(attribute_name.singularize)\n\n singular = attribute.name.singularize\n plural = attribute.name.pluralize\n\n # logger.debug \"Generating methods for #{attribute}\"\n \n unless base_respond_to? singular\n # logger.debug \"Generating #{singular} method\"\n instance_eval <<-DEFINE_METHODS\n def #{singular}(language = @current_language)\n @attributes[language.to_s][:#{attribute.name}]\n end\n DEFINE_METHODS\n end\n \n unless base_respond_to?(plural) \n if !attribute.allow_many?\n # logger.debug \"Aliasing #{plural} method to #{singular} method\"\n instance_eval <<-DEFINE_ALIAS\n alias :#{plural} :#{singular}\n DEFINE_ALIAS\n else\n # logger.debug \"Generating #{plural} method\"\n instance_eval <<-DEFINE_METHODS\n def #{plural}(language = @current_language)\n @attributes[language.to_s][:#{singular}] ||= ManyValues.new(self,\n PublicEarth::Db::Details::Attribute.new(self, nil, \n '#{singular}', nil, nil, @current_language, \n (@current_source_data_set && @current_source_data_set.id || nil), #{attribute.readonly == 't'}, 9999, false, \n false, #{attribute.allow_many == 't'}, '#{attribute.data_type}'))\n end\n DEFINE_METHODS\n end\n end\n\n unless base_respond_to? \"#{singular}=\"\n # logger.debug \"Generating #{singular}= method\"\n instance_eval <<-DEFINE_METHODS\n def #{singular}=(value)\n self['#{singular}'] = value\n end\n DEFINE_METHODS\n end\n \n unless base_respond_to?(\"#{plural}=\") || !attribute.allow_many?\n # logger.debug \"Generating #{plural}= method\"\n instance_eval <<-DEFINE_METHODS\n def #{plural}=(value)\n self['#{singular}'] = value\n end\n DEFINE_METHODS\n end\n \n unless base_respond_to? \"#{singular}?\"\n # logger.debug \"Generating #{singular}? method\"\n instance_eval <<-DEFINE_METHODS\n def #{singular}?\n self['#{singular}'].blank?\n end\n DEFINE_METHODS\n end\n\n unless base_respond_to?(\"#{plural}?\") || !attribute.allow_many?\n # logger.debug \"Generating #{plural}? method\"\n instance_eval <<-DEFINE_METHODS\n def #{plural}?\n self['#{singular}'].blank?\n end\n DEFINE_METHODS\n end\n \n end",
"def derive_attr(name, &block)\n define_method(name) do\n attributes.has_key?(name.to_s) ? attributes[name.to_s] : instance_eval(&block)\n end\n\n derived_attributes[name] = block\n end",
"def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.each_pair do |k,v|\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n ?\n end\n self.class.attribute_methods_generated = true\n end",
"def define_attribute_methods(attr)\n name = attr.name\n return if @attr_methods.has_key?(name)\n ([name] + attr.aliases).each do |ali|\n @attr_methods[ali] = name\n @attr_aliases[Inflector.underscore(ali)] = name\n @normalized_attr_names[normalize_attribute_name(ali)] = name\n end\n end",
"def define_attribute_methods\n super\n self.generated_methods.each do |method|\n if method.to_s =~ Regexp.new(\"^#{self.to_s.underscore}__\")\n new_method_name = $~.post_match\n alias_method(new_method_name, method)\n private method\n self.generated_methods << new_method_name\n end\n end\n end",
"def define_attribute_methods(name, options) # :nodoc:\n define_method name do\n attributes[name] || options[:default]\n end\n\n define_method \"#{name}=\" do |object|\n attributes[name] = object\n end\n\n self.attribute_options[name] = options\n end",
"def method_missing(method_name, *args, &block)\n return super unless define_attribute_methods\n self.send(method_name, *args, &block)\n end",
"def create_attr(real_name, &block)\n attr_reader(real_name) unless method_defined?(real_name)\n\n if !method_defined?(\"#{real_name}=\")\n if block_given?\n define_method(\"#{real_name}=\") do |value|\n instance_variable_set(\"@#{real_name}\", instance_exec(value, &block))\n end\n else\n attr_writer(real_name)\n end\n end\n end",
"def create_attr_methods(name, val)\n self.instance_variable_set \"@#{name}\", val\n self.class.class_eval do\n define_method(\"#{name}\") { val }\n end\n end",
"def attribute_method\n method_options = options\n\n lambda do |name, type = Object, options = {}|\n super(name, type, method_options.update(options))\n end\n end",
"def define_magic_attr(name)\n define_method name do |*attrs|\n raise ArgumentError.new(\"wrong number of arguments\") if attrs.size > 1\n send(\"#{name}=\", attrs.first) if attrs.size == 1\n instance_variable_get(\"@#{name}\")\n end\n\n attr_writer name\n end",
"def create_smart_attribute_methods\n denormalized_attribute_names.each do |denormalized_attribute_name|\n base_method_name = denormalized_attribute_base_name(denormalized_attribute_name)\n define_method(base_method_name) do\n if may_use_denormalized_value?(denormalized_attribute_name)\n self.send(denormalized_attribute_name)\n else\n self.send(self.class.denormalized_compute_method_name(denormalized_attribute_name))\n end\n end\n end\n end",
"def define_attribute_method(key1)\n define_method(key1) do\n @attrs[key1]\n end\n end",
"def define_attribute_methods\n return if attribute_methods_generated?\n @attributes.keys.sort.each do |k|\n # ajay Singh --> skip the loop if attribute is null\n next if !k.present?\n self.class.module_eval %Q?\n def #{k}\n read_attribute :#{k}\n end\n def #{k}=(value)\n write_attribute :#{k},value\n end\n def #{k}\\?\n has_attribute\\? :#{k}\n end\n ?\n end\n \n # return the (polymorphic) parent record corresponding to the parent_id and parent_type attributes\n # (an example of parent polymorphism can be found in the Note module)\n if (@attributes.keys.include? 'parent_id') && (@attributes.keys.include? 'parent_type')\n self.class.module_eval %Q?\n def parent\n (self.class.session.namespace_const.const_get @attributes['parent_type'].singularize).find(@attributes['parent_id'])\n end\n ?\n end\n \n self.class.attribute_methods_generated = true\n end",
"def define_redis_attribute_method(attribute_name, klass)\n define_method(attribute_name) do\n klass.new(parent: self).to_value\n end\n\n define_method(\"#{attribute_name}=\") do |value|\n klass.new(parent: self).set(value)\n end\n end",
"def define_read_method(symbol, attr_name, column)\n\n cast_code = column.type_cast_code('v') if column\n access_code = cast_code ? \"(v=@attributes['#{attr_name}']) && #{cast_code}\" : \"@attributes['#{attr_name}']\"\n\n unless attr_name.to_s == self.primary_key.to_s\n access_code = access_code.insert(0, \"missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); \")\n end\n\n # This is the Hobo hook - add a type wrapper around the field\n # value if we have a special type defined\n if can_wrap_with_hobo_type?(symbol)\n access_code = \"val = begin; #{access_code}; end; wrapper_type = self.class.attr_type(:#{attr_name}); \" +\n \"if HoboFields.can_wrap?(wrapper_type, val); wrapper_type.new(val); else; val; end\"\n end\n\n if cache_attribute?(attr_name)\n access_code = \"@attributes_cache['#{attr_name}'] ||= begin; #{access_code}; end;\"\n end\n\n generated_attribute_methods.module_eval(\"def #{symbol}; #{access_code}; end\", __FILE__, __LINE__)\n end",
"def define_read_method(symbol, attr_name, column)\n cast_code = column.type_cast_code('v') if column\n access_code = cast_code ? \"(v=@attributes['#{attr_name}']) && #{cast_code}\" : \"@attributes['#{attr_name}']\"\n\n unless attr_name.to_s == self.class.primary_key.to_s\n access_code = access_code.insert(0, \"raise NoMethodError, 'missing attribute: #{attr_name}', caller unless @attributes.has_key?('#{attr_name}'); \")\n self.class.read_methods << attr_name\n end\n\n evaluate_read_method attr_name, \"def #{symbol}; #{access_code}; end\"\n end",
"def define_attribute_methods # :nodoc:\n return false if @attribute_methods_generated\n # Use a mutex; we don't want two threads simultaneously trying to define\n # attribute methods.\n generated_attribute_methods.synchronize do\n return false if @attribute_methods_generated\n superclass.define_attribute_methods unless base_class?\n super(attribute_names)\n @attribute_methods_generated = true\n end\n end",
"def alias_column_method(params)\n logical_name = params[:new]\n original_name = params[:original]\n \n define_method logical_name do\n self.send(original_name)\n end \n \n define_method \"#{logical_name}=\" do |arg|\n self.send(original_name, arg)\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n end",
"def define_attribute_method(attribute)\n type = attribute_types[attribute]\n super unless TypeMap.lookup(type, self, attribute)\n end",
"def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{attr_name}', new_value);end\", \"#{attr_name}=\"\n end",
"def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name)\n unless unchangeable_property_names.include?(attr_name.to_sym)\n generated_methods << method_name\n end\n\n begin\n class_eval(method_definition, __FILE__, __LINE__)\n rescue SyntaxError => err\n generated_methods.delete(attr_name)\n if logger\n logger.warn \"Exception occurred during reader method compilation.\"\n logger.warn \"Maybe #{attr_name} is not a valid Ruby identifier?\"\n logger.warn \"#{err.message}\"\n end\n end\n end",
"def denormalized_compute_method_name(attribute_name)\n denormalized_compute_method_prefix + denormalized_attribute_base_name(attribute_name)\n end",
"def method_missing(method_sym, *arguments)\n method_name = method_sym.to_s\n attribute_name = method_name.gsub(/(\\?$)|(=$)/, '')\n if @attributes.include?(attribute_name.to_sym) || method_name[-1] == '=' || method_name[-1] == '?'\n generate_methods!(attribute_name, method_name)\n send(method_sym, *arguments)\n else\n super(method_sym, *arguments)\n end\n end",
"def method_missing(meth, *args, &blk)\n if args.length > 0\n self.class.add_custom_attribute meth\n send meth, *args, &blk\n else\n super meth, *args, &blk\n end\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def define_attribute_methods\n return if generated_methods?\n property_names.each do |name|\n unless instance_method_already_implemented?(name)\n define_read_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}=\")\n define_write_method(name.to_sym)\n end\n unless instance_method_already_implemented?(\"#{name}?\")\n define_question_method(name)\n end\n end\n end",
"def attr(attribute, name: attribute.to_s.camelize(:lower), nullable: nil, description: nil, deprecation_reason: nil, &block)\n name = name.to_sym unless name.is_a?(Symbol)\n\n # Get the description from the column, if it's not provided. Doesn't work in Rails 4 :(\n unless description\n column = @model_type.columns_hash[attribute.to_s]\n description = column.comment if column&.respond_to?(:comment)\n end\n\n options = {\n name: name,\n nullable: nullable,\n description: description,\n deprecation_reason: deprecation_reason,\n }\n\n DefinitionHelpers.define_attribute(@graph_type, @base_model_type, @model_type, @path, attribute, @object_to_model, options, @detect_nulls, &block)\n end",
"def add_alternative_id_method(attr_name)\n define_method attr_name.to_sym do\n alternative_id_value attr_name\n end\n end",
"def method_missing(method_name, *args, &block)\n if method_name.to_s.end_with?('=')\n set_attribute(method_name, *args)\n elsif has_attribute?(method_name)\n get_attribute(method_name)\n else\n super\n end\n end",
"def define_attribute_methods\n define_method :saved_changes do\n (@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new).merge(super())\n end\n\n @attribute_names.each do |name|\n define_method :\"saved_change_to_#{name}?\" do\n previous_changes.include?(Mobility.normalize_locale_accessor(name))\n end\n\n define_method :\"saved_change_to_#{name}\" do\n previous_changes[Mobility.normalize_locale_accessor(name)]\n end\n\n define_method :\"#{name}_before_last_save\" do\n previous_changes[Mobility.normalize_locale_accessor(name)].first\n end\n\n alias_method :\"will_save_change_to_#{name}?\", :\"#{name}_changed?\"\n alias_method :\"#{name}_change_to_be_saved\", :\"#{name}_change\"\n alias_method :\"#{name}_in_database\", :\"#{name}_was\"\n end\n end",
"def add_attribute attribute\n return attribute unless @document_self\n\n # mainly to check for redefinition of an attribute as a method\n # TODO find a policy for 'attr_reader :foo' + 'def foo=()'\n register = false\n\n key = nil\n\n if attribute.rw.index 'R' then\n key = attribute.pretty_name\n known = @methods_hash[key]\n\n if known then\n known.comment = attribute.comment if known.comment.empty?\n elsif registered = @methods_hash[attribute.pretty_name + '='] and\n RDoc::Attr === registered then\n registered.rw = 'RW'\n else\n @methods_hash[key] = attribute\n register = true\n end\n end\n\n if attribute.rw.index 'W' then\n key = attribute.pretty_name + '='\n known = @methods_hash[key]\n\n if known then\n known.comment = attribute.comment if known.comment.empty?\n elsif registered = @methods_hash[attribute.pretty_name] and\n RDoc::Attr === registered then\n registered.rw = 'RW'\n else\n @methods_hash[key] = attribute\n register = true\n end\n end\n\n if register then\n attribute.visibility = @visibility\n add_to @attributes, attribute\n resolve_aliases attribute\n end\n\n attribute\n end",
"def create_method( name, &block )\n self.class.send( :define_method, name, &block )\n end",
"def my_attr_accessor(*attributes)\n attributes.each do |attribute|\n # for each attribute, use String interpolation\n # to generate the methods, and set attr_methods\n # equal to the generated string\n attr_methods = %Q{\n def #{attribute}\n @#{attribute}\n end\n def #{attribute}=(val)\n @#{attribute} = val\n end\n }\n # call class_eval and pass in attr_methods\n class_eval(attr_methods)\n end\n end",
"def method_missing(method_name, *args, &block)\n attributes.send(method_name.to_s, *args, &block)\n end",
"def attribute_method(configuration)\n module_options = self.module_options\n\n lambda do |name, type = Object, options = {}|\n super(name, type, module_options.merge(options))\n end\n end",
"def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end",
"def set_from_column_name(value = nil, &block)\n define_attr_method :from_column_name, value, &block\n end",
"def create_method(name, &block)\n\t\t\tself.class.send(:define_method, name, &block)\n\t\tend",
"def add_attribute(name, &block); end",
"def alias_attribute(new_name, old_name)\n self.attribute_aliases = attribute_aliases.merge(new_name.to_s => old_name.to_s)\n CodeGenerator.batch(self, __FILE__, __LINE__) do |owner|\n attribute_method_matchers.each do |matcher|\n matcher_new = matcher.method_name(new_name).to_s\n matcher_old = matcher.method_name(old_name).to_s\n define_proxy_call false, owner, matcher_new, matcher_old\n end\n end\n end",
"def create_setter(name, meth)\n define_method(\"#{meth}=\") do |value|\n write_attribute(name, value)\n end\n end",
"def define_attribute_method(scope, name, opts = {})\n method = scope == :instance ? :define_singleton_method : :define_method\n\n send(method, name) do\n ivar = instance_variable_get(:\"@#{name}\")\n return ivar unless ivar.nil?\n\n value = @xml_element.locate(opts[:xpath]).first\n value = value.value if value.is_a?(Ox::CData)\n\n unless value.nil?\n value =\n case opts[:type]\n when :integer\n value.to_i\n when :integer_array\n value.split(\",\").map(&:to_i)\n when :numeric\n BigDecimal.new(value)\n when :boolean\n value == \"1\" || value.downcase == \"true\"\n when :string\n value.to_s.strip\n when :datetime\n value.empty? ? nil : Time.parse(value + \" UTC\")\n when :hash\n value.scan(/^(.*?): (.*?)$/).to_h\n end\n end\n\n instance_variable_set(:\"@#{name}\", value)\n end\n end",
"def generate_method(method_name, &block)\n define_method(method_name, &block)\n method = instance_method method_name\n remove_method method_name\n method\n end",
"def attribute(name, type = nil, &block)\n if type.nil?\n type = type_from_block(name, &block)\n else\n raise ArgumentError unless type < Refined\n end\n\n @attributes << type\n @names << name\n\n define_method(name) do\n match.context.dig(:attributes, name)\n end\n end",
"def create_accessors(attribute_name)\n class_eval do\n define_method(attribute_name) do\n odata_entity[property_map[attribute_name]]\n end\n\n define_method(\"#{attribute_name}=\") do |value|\n # unless entity[property_map[attribute_name]] == value\n # send(\"#{attribute_name}_will_change!\") if defined?(::ActiveModel)\n # end\n\n odata_entity[property_map[attribute_name]] = value\n end\n end\n\n nil\n end",
"def define_read_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}; read_attribute('#{attr_name}'); end\" \n end",
"def define_active_enum_write_method(attribute, column)\n class_eval <<-DEF\n def #{attribute}=(arg)\n self.#{column} = self.class.active_enum_get_id_for_#{attribute}(arg)\n end\n DEF\n end",
"def attribute_setter(attribute_name)\n \"set#{attribute_name.to_s.camelcase(:upper)}\"\n end",
"def set_to_column_name(value=nil, &block)\n define_attr_method :to_column_name, value, &block\n end",
"def add_methods_to_flex_column_class!(dynamic_methods_module)\n fn = field_name\n\n dynamic_methods_module.define_method(fn) do\n self[fn]\n end\n\n dynamic_methods_module.define_method(\"#{fn}=\") do |x|\n self[fn] = x\n end\n\n if private?\n dynamic_methods_module.private(fn)\n dynamic_methods_module.private(\"#{fn}=\")\n end\n end",
"def create_attr( name , ro = false)\n unless ro\n create_method( \"#{name}=\".to_sym ) { |val| \n instance_variable_set( \"@\" + name, val)\n }\n end\n\n create_method( name.to_sym ) { \n instance_variable_get( \"@\" + name )\n }\n end",
"def method_missing(meth, *args, &block)\n if attributes.has_key?(meth)\n attributes[meth]\n else\n super\n end\n end",
"def method_missing(method_name, *args)\n # Return the attribute value\n if @attributes.has_key?(method_name)\n read_attribute(method_name)\n \n # If we predefine an attribute, but we don't have it loaded, return nil\n elsif self.class.predefined_attributes.include?(method_name)\n nil\n \n # Check booleans, attribute_name?\n elsif method_name.to_s =~ /\\?$/\n simple_method_name = method_name.to_s.gsub(/\\?$/, '').to_sym\n @attributes[simple_method_name] == true || @attributes[simple_method_name] == 't' || \n @attributes[simple_method_name] == 'true'\n \n # Method to set attribute, attribute_name=\n elsif method_name.to_s =~ /=$/ && !args.empty?\n write_attribute(method_name.to_s.gsub(/=$/, '').to_sym, args.first)\n \n # Default to raising an error\n else\n default_method_missing(method_name, *args)\n end\n end",
"def renameable(attribute = :name)\n define_method :renamed do |renamer|\n send :\"with_#{attribute}\", renamer.new_name_of(send(attribute))\n end\n end",
"def method_missing(method, *args, &block)\n if respond_to_without_attributes?(method, true)\n super\n else\n match = matched_attribute_method(method.to_s)\n match ? attribute_missing(match, *args, &block) : super\n end\n end",
"def ssdb_attr(name, type, options = {})\n unless %i(string integer).include?(type)\n raise \"Type not supported, only `:string` and `:integer` are supported now.\"\n end\n\n @ssdb_attr_definition[name.to_s] = type.to_s\n\n define_method(name) do\n instance_variable_get(\"@#{name}\") || begin\n val = ssdb_attr_pool.with { |conn| conn.get(ssdb_attr_key(name)) } || options[:default]\n instance_variable_set(\"@#{name}\", typecaster(val, type))\n end\n end\n\n define_method(\"#{name}=\") do |val|\n send(\"#{name}_will_change!\") unless typecaster(val, type) == send(name)\n instance_variable_set(\"@#{name}\", val)\n end\n\n define_method(\"#{name}_default_value\") do\n typecaster(options[:default], type)\n end\n\n define_method(\"#{name}_was\") { attribute_was(name) }\n\n define_method(\"#{name}_change\") { attribute_change(name) }\n\n define_method(\"#{name}_changed?\") { attribute_changed?(name) }\n\n define_method(\"restore_#{name}!\") { restore_attribute!(name) }\n\n define_method(\"#{name}_will_change!\") { attribute_will_change!(name) }\n\n end",
"def def_column_alias(meth, column)\n clear_setter_methods_cache\n overridable_methods_module.module_eval do\n define_method(meth){self[column]}\n define_method(\"#{meth}=\"){|v| self[column] = v}\n end\n end",
"def def_column_alias(meth, column)\n clear_setter_methods_cache\n overridable_methods_module.module_eval do\n define_method(meth){self[column]}\n define_method(\"#{meth}=\"){|v| self[column] = v}\n end\n end",
"def alias_attribute(new_name, old_name)\n module_eval <<-STR, __FILE__, __LINE__ + 1\n def #{new_name}; self.#{old_name}; end # def subject; self.title; end\n def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end\n def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end\n STR\n end",
"def method_missing(method_name, *_args)\n if attrs.key?(method_name.to_s)\n attrs[method_name.to_s]\n else\n super(method_name)\n end\n end",
"def [](attribute_name)\n raise NoMethodError, \"The attribute #{attribute_name} is undefined\" unless self.class.attributes.has_key? attribute_name\n default = super(attribute_name)\n self.class.cast(attribute_name, default.is_a?(Proc) ? default.call : default)\n end",
"def def_nested_attribute_method(reflection)\n @nested_attributes_module.class_eval do\n define_method(\"#{reflection[:name]}_attributes=\") do |v|\n set_nested_attributes(reflection[:name], v)\n end\n end\n end",
"def method_missing(method, *args, &block)\n attributes.public_send(method, *args, &block)\n end",
"def bits_attr_accessor name\n class_eval \"def #{name}; self.attributes[#{name.inspect}]; end;\", __FILE__, __LINE__\n class_eval \"def #{name}=(val); self.attributes[#{name.inspect}]=val; end;\", __FILE__, __LINE__\n end",
"def define_attribute_methods(attrs, access_level)\n self.attribute_method_module.module_eval do\n attrs.each do |attr|\n # Normalize for attributes without types\n attr_name = Array.wrap(attr).first\n # Define reader and huh methods\n self.module_eval <<-EOE, __FILE__, __LINE__ + 1\n def #{attr_name}\n read_attribute(:#{attr_name})\n end\n\n def #{attr_name}?\n read_attribute(:#{attr_name}).present?\n end\n EOE\n # Define a writer if this is public\n if access_level == :public\n self.module_eval <<-EOE, __FILE__, __LINE__ + 1\n def #{attr_name}=(new_val)\n write_attribute(:#{attr_name}, new_val)\n end\n EOE\n end\n end\n end\n\n # Now we get all the attribute names as symbols\n # and define_attribute_methods for dirty tracking\n attrs = attrs.collect do |a|\n Array.wrap(a).first.to_sym\n end\n\n super(attrs)\n true\n end",
"def attribute!(name, options={})\n super(name, options)\n define_method(\"#{name}=\") do |value|\n typecast_value = typecast_attribute(typecaster_for(self.class._attribute_type(name)), value)\n send(\"#{name}_will_change!\") unless typecast_value == read_attribute(name)\n super(value)\n end\n end",
"def create_attribute_methods_on(model)\n #model.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1\n model.class_eval %(\n def self.values_for_#{attribute}\n self.bitmask_definitions[:#{attribute}].values\n end\n\n def self.values_with_bitmask_for_#{attribute}\n ret = []\n self.bitmask_definitions[:#{attribute}].values.each_with_index{|v,k| ret.push [v,k]}\n ret\n end\n )\n end",
"def attributes_2_methods(element)\n element.attributes.map do |_k, attr_v|\n define_singleton_method(to_snake_case(attr_v.name).to_sym) { attr_v.value }\n end\n end",
"def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter = match[1], !match[2].blank?\n if setter\n write_attribute(attribute, args.first)\n else\n read_attribute(attribute)\n end\n else\n super(meth, *args, &blk)\n end\n end",
"def alias_attribute(new_name, old_name)\n module_eval <<-STR, __FILE__, __LINE__+1\n def #{new_name}; self.#{old_name}; end # def subject; self.title; end\n def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end\n def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end\n STR\n end",
"def create_getter(name, meth)\n define_method(meth) do\n read_attribute(name)\n end\n end",
"def create_method(name, &block)\n eigen = class << self; self; end\n eigen.send(:define_method, name, &block)\n end",
"def attribute name, *attr\n\n # Add the attribute\n _attr = AttributeDefinition.new( name, *attr )\n attribute_definitions << _attr\n\n # Inject object with getter and setter for attribute\n define_setter_and_getter(name, _attr)\n end",
"def attribute_from_method( methodname )\n\n\t\tcase methodname.to_s\n\t\twhen /^(?:has_)?([a-z]\\w*)\\?$/i\n\t\t\treturn $1.to_sym, :predicate\n\t\twhen /^([a-z]\\w*)(=)?$/i\n\t\t\treturn $1.to_sym, ($2 ? :writer : :reader )\n\t\tend\n\tend",
"def define_nested_attribute_methods(attribute, nested_form_class)\n # Equivalent of \"address_attributes=\" for \"address\" attribute\n define_method(:\"#{attribute}_attributes=\") do |params|\n build_models_from_param_count(attribute, params)\n\n self.send(:\"#{attribute}\").zip(params).each do |model, params_array|\n identifier = params_array[0]\n attributes = params_array[1]\n #TODO: Check the key against id?\n model.fill(attributes)\n end\n end\n end",
"def attribute(attribute_name, options={})\n fauxsql_options[attribute_name] = normalize_options!(options)\n class_eval <<EORUBY, __FILE__, __LINE__\n def #{attribute_name}\n get_fauxsql_attribute(:#{attribute_name})\n end\n\n def #{attribute_name}=(value)\n set_fauxsql_attribute(:#{attribute_name}, value)\n end\nEORUBY\n\n if options[:nest]\n class_eval <<EORUBY, __FILE__, __LINE__\n def #{attribute_name}_attributes=(vals)\n vals = Fauxsql::DSL.normalize_nested_vals!(vals)\n #{attribute_name} = #{attribute_name}.get_nested_record(vals)\n end\nEORUBY\n end\n end",
"def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end",
"def define_accessors\n columns.each do |column|\n underscored_column_name = column.name.underscore\n unless respond_to?(underscored_column_name)\n self.class.send :define_method, underscored_column_name do\n @attributes[column.name.underscore]\n end\n end\n end\n end",
"def create_attribute options\n attributes = options[ :attributes ]\n attr_value = options[ :value ]\n attributes.each do | attr_name |\n self.class.class_eval do\n define_method attr_name do\n instance_variable_get \"@#{ attr_name }\"\n end\n define_method \"#{ attr_name }=\" do | value |\n instance_variable_set( \"@#{ attr_name }\", value )\n end\n end\n self.public_send( \"#{ attr_name }=\", attr_value )\n end\n end",
"def create_field_setter(name, meth, field)\n generated_methods.module_eval do\n define_method(\"#{ meth }=\") do |value|\n instance_variable_set \"@#{ name }\", value\n end\n end\n end",
"def configurable_writer(attribute, code=nil, &block)\n if block_given? and not code\n Halcyon.class.send(:define_method, :\"#{attribute}=\", block)\n elsif code and not block_given?\n Halcyon.class.send(:eval, <<-\"end;\")\n def #{attribute.to_s}=(value)\n #{code % [attribute.to_sym.inspect]}\n end\n end;\n else\n raise ArgumentError.new(\"Either a block or a code string should be supplied.\")\n end\n end",
"def attribute(name)\n attributes << name\n\n if !method_defined?(name) || name == :id\n attr_accessor name\n end\n end",
"def method_missing(method_name, *args, &block)\n if attrs.keys.include? method_name.to_s\n attrs[method_name.to_s]\n else\n super(method_name)\n end\nend",
"def define_method(name, &block)\n name = name.to_sym\n super(name, &block)\n @methods_defined[name] = true\n end",
"def define_piggy_back_read_method(reflection_name, column, prefix)\n attr = column.name\n attr_key = \"#{prefix}_#{attr}\"\n return if instance_methods.include?(attr_key)\n\n cast_code = column.type_cast_code('v')\n access_code = if cast_code\n \"(v=@attributes['#{attr_key}']) && #{cast_code}\"\n else\n \"@attributes['#{attr_key}']\"\n end\n\n self.class_eval <<-\"end_method\"\n def #{attr_key}\n if @attributes.has_key? '#{attr_key}'\n #{access_code}\n else\n #{reflection_name}.#{attr}\n end\n end\n end_method\n end",
"def method_missing(method, *args, &block)\n \n # The getter\n if @metadata.has_key?(method)\n return attribute_get(method)\n else\n # The setter\n \n if (attribute=method.to_s.match(/(.+)=$/).to_a.last)\n attribute_set(attribute, args.first)\n return\n end\n end\n \n super\n \n end",
"def attribute(*args)\n define_expressions(Attribute, args)\n end",
"def method_missing(method_name, *args, &block)\n ignore_list = [:to_hash]\n return if ignore_list.include? method_name\n\n respond_to?(method_name) ? attribute(method_name.to_s.tr('_', '-')) : super\n end",
"def define_method(name, &block)\n name = name.to_sym\n super(name, &block)\n @methods_defined[name] = true\n end"
] | [
"0.76874965",
"0.76735723",
"0.7505815",
"0.7474545",
"0.71693015",
"0.71641016",
"0.7155682",
"0.7054294",
"0.6966722",
"0.6955874",
"0.6834607",
"0.6814022",
"0.67936796",
"0.6706752",
"0.66608965",
"0.6630631",
"0.6578157",
"0.65235114",
"0.65134764",
"0.65099055",
"0.65056616",
"0.6494304",
"0.6481527",
"0.6461479",
"0.6386465",
"0.63837147",
"0.63837147",
"0.6347316",
"0.63253134",
"0.6279827",
"0.62624824",
"0.6227766",
"0.61839306",
"0.61463016",
"0.61463016",
"0.61463016",
"0.6135413",
"0.6134791",
"0.6091136",
"0.6070626",
"0.6061813",
"0.60425395",
"0.6042291",
"0.6037886",
"0.6003767",
"0.59887946",
"0.59562427",
"0.59486616",
"0.5945205",
"0.5940188",
"0.5931234",
"0.591699",
"0.5916611",
"0.58967286",
"0.588062",
"0.5876127",
"0.5871552",
"0.58693916",
"0.5865835",
"0.5863237",
"0.58575517",
"0.5853028",
"0.58440536",
"0.5841841",
"0.5830881",
"0.58155406",
"0.58075917",
"0.5806257",
"0.5806257",
"0.5801975",
"0.5772141",
"0.57574236",
"0.5742625",
"0.5716721",
"0.57150686",
"0.56991744",
"0.56962717",
"0.5695354",
"0.5686237",
"0.56674296",
"0.5665177",
"0.56635344",
"0.56575197",
"0.5655991",
"0.56472063",
"0.56422246",
"0.56414413",
"0.5638397",
"0.563454",
"0.5633748",
"0.5628007",
"0.5626267",
"0.56195587",
"0.5613234",
"0.5612157",
"0.5605859",
"0.55984336",
"0.55961376",
"0.5586892",
"0.55824786"
] | 0.7907928 | 0 |
Confirms a loggedin user. | def require_auth
head :unauthorized unless current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n end\n end",
"def confirm_logged_in\n \tunless session[:user_id]\n \t\tflash[:notice] = \"Please Log in.\"\n \t\tredirect_to(login_path)\n \tend\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n\t\t\tend\n\t\tend",
"def confirm\n if @user = UserConfirmsAccount.new(:token => params[:token]).call\n self.establish_session @user\n redirect_to profile_url, :notice => \"Thanks for confirming #{@user.email}\"\n else\n redirect_to profile_url, :notice => \"There was a problem confirming - try re-sending the email?\"\n end\n end",
"def confirm\n user = User.find(params[:id])\n authorize user\n if user.state != \"active\"\n user.confirm\n user.make_user_a_member\n\n # assume this type of user just activated someone from somewhere else in the app\n flash['notice'] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n unless @user == current_user\n flash[:danger] = 'You are not authorized to do that.'\n redirect_to(root_url)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n if @user != current_user\n flash[:alert] = \"Action not authorized\"\n redirect_to(root_url)\n end\n end",
"def correct_user\n unless helpers.current_user?(@user)\n flash[:danger] = \"You don't have permission to do that\"\n redirect_to root_path\n end\n end",
"def confirm_logged_in\n unless session[:user_id]\n redirect_to login_path, alert: \"Please log in\"\n end\n end",
"def confirm_user_logged_in\n unless logged_in?\n store_url # So that user is sent to the same URL after they log in\n flash[:danger] = \"Please log in.\"\n redirect_to root_url\n end\n end",
"def confirm_logged_in\n unless session[:user_id] != nil\n redirect_to root_path\n end\n end",
"def correct_user\n @user = User.find(params[:user_id])\n redirect_to('/unauthorized') unless current_user?(@user)\n end",
"def confirm\n if current_visitor && current_visitor.has_role?('admin', 'manager')\n user = User.find(params[:id]) unless params[:id].blank?\n if !params[:id].blank? && user && user.state != \"active\"\n user.confirm!\n user.make_user_a_member\n # assume this type of user just activated someone from somewhere else in the app\n flash[:notice] = \"Activation of #{user.name_and_login} complete.\"\n redirect_to(session[:return_to] || root_path)\n end\n else\n flash[:notice] = \"Please login as an administrator.\"\n redirect_to(root_path)\n end\n end",
"def correct_user\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tredirect_to(root_url) unless @user == current_user\n\t\tend",
"def correct_user\n @user = User.find(params[:id])\n if current_user != @user\n flash[:danger] = \"You don't have permission for that\"\n redirect_to(root_url) unless current_user?(@user)\n end\n end",
"def appctrl_confirm_user\n redirect_to( signin_path() ) unless @current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n flash[:danger] = \"Sorry, you're aren't allowed to access that.\"\n redirect_to(\"/#flash\") \n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to root_path, alert: \"You do not have access to that page\" unless current_user == @user\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to root_path unless @user == current_user\n\tend",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n flash[:danger] = \"Admin Access Only.\"\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tif current_user != @user\n\t\t\t\tredirect_back(fallback_location: root_path)\n\t\t\tend\n\t\tend",
"def user_stray\n if !logged_in? || @user == nil\n flash[:alert] = \"You have been logged out of your session. Please log back in to continue.\"\n redirect \"/\"\n elsif @user.id != current_user.id\n flash[:alert] = \"You do not have permission to view or edit other users' content.\"\n redirect \"/\"\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n user = User.find(params[:id])\n unless current_user?(user) \n flash[:danger] = \"Uncorrect user.\"\n redirect_to(root_url) \n end\n end",
"def switch\n authorize!(:manage, :all)\n user = User.find_by(login: params[:login].upcase)\n if user\n session[:original_user_id] = session[:user_id]\n session[:user_id] = user.id\n redirect_to root_url, notice: \"Sie sind nun der Nutzer mit dem Login #{user.login}.\"\n else\n redirect_to root_url, notice: \"Der Nutzer existiert nicht im System.\"\n end\n end",
"def correct_user\n set_user\n unless current_user?(@user)\n flash[:danger] = 'This action is not permitted for this account since you are not the owner'\n redirect_to overview_user_path(current_user)\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user\n end",
"def confirm_user\n if session[:user_id]\n return true\n else\n flash[:notice] = \"please login\"\n redirect_to(:controller => 'manage', :action => 'login')\n return false\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user)\n flash[:danger] = \"Yikes. Sorry, but it doesn't look you have permission to do that 😬\"\n redirect_back(fallback_location: root_url)\n end\n end",
"def correct_user\n\t @user = User.find(params[:id])\n\t unless current_user?(@user)\n\t flash[:danger] = \"You don't have rights\"\n\t\t\tredirect_back_or(root_url)\n\t end\n\tend",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user === current_user\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tredirect_to(root_path) unless current_user?(@user)\n\t\tend",
"def confirm_logged_in\n unless session[:username]\n redirect_to authenticate_login_path\n else\n true\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to root_path unless @user == current_user\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user)\n flash[:danger] = \n \"You do not have permission to access #{@user.name}'s account.\"\n redirect_to(root_url)\n end\n end",
"def correct_user\n @course = Course.find(params[:id])\n @user = @course.users\n unless current_user == @user\n redirect_to(root_url) \n flash[:danger] = \"You are not the authorised user\"\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless @user == current_user # sauf si\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_path) unless current_user?(@user)\n\tend",
"def correct_user\n\t\tunless current_user == @univers.user\n\t\t\tflash[:danger] = \"You have no power there\"\n\t\t\tredirect_to universes_path\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) #checks if current_user == @user\n #current_user? defined in session helper\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n \n redirect_to(login_path) unless current_user?(@user)\n end",
"def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\n redirect_to root_path\n return false # halts the before_action\n else\n return true\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(user_root_path,:notice => 'You cannot access this page') unless current_user == @user\n end",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def correct_user\n\t\t@user = User.find(params[:id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def logged_in_user\n unless !current_user.nil?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n\n if @user != current_user\n redirect_to(root_path)\n else\n # nothing to do\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless current_user?(@user)\n end",
"def correct_user\n @question = Question.find(params[:id])\n redirect_to(root_url) unless current_user == @question.user\n end",
"def confirm_matching\n @user = User.find(params[:id])\n redirect_to root_path unless current_user? @user\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless (current_user.id == @user.id)\n end",
"def correct_user\n @user = User.find(params[:id])\n # current_user?() is a sessions_helper method. The user of the params hash has\n # to match the current user or will be redirected to root\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n\t\t@user = User.find(params[ :id])\n\t\tredirect_to(root_url) unless current_user?(@user)\n\tend",
"def logged_in_user\n unless logged_in?\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end",
"def confirm_logged_in\r\n unless session[:username]\r\n redirect_to authenticate_index_path\r\n else\r\n true\r\n end\r\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) # current_user is method in sessions_helper.rb\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n end"
] | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.6480418",
"0.6479267",
"0.64705276",
"0.64680994",
"0.64656436",
"0.6457351",
"0.64541256",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.64485556",
"0.6445996",
"0.6437721",
"0.64289176",
"0.64260334",
"0.6424799",
"0.6417934",
"0.64177954",
"0.64163303",
"0.6410097",
"0.6401843",
"0.63820904",
"0.63622755",
"0.63595843",
"0.6355515",
"0.635374",
"0.6351282",
"0.6350864",
"0.63502026",
"0.63502026",
"0.63502026",
"0.6347271",
"0.63426447",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.6342538",
"0.63400817",
"0.63345385",
"0.63329995",
"0.6331134",
"0.6330873",
"0.632984",
"0.6325074",
"0.63200074",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605",
"0.63152605"
] | 0.0 | -1 |
auto switch broadcast from live to complete | def validate_broadcast!
# we can't check it each time when user open transmission page
# it generates too many api calls
broadcast_status = Rails.cache.fetch("broadcast_status_#{id}", expires_in: 3.hours) do
broadcast_service.status
end
if broadcast_status == 'complete'
complete!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broadcast\n end",
"def broadcast_example_b1\n end",
"def instant_broadcast_processing?\n true\n end",
"def broadcast_ready_changed\n data = {\n action: 'players_ready'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end",
"def run!\n broadcast!\n super\n end",
"def broadcast\n TestLab::Utility.broadcast(self.address)\n end",
"def send_ready_notification\n\n end",
"def broadcast\n @condition.broadcast\n true\n end",
"def broadcast\n @condition.broadcast\n true\n end",
"def broadcast_change\n # don't broadcast submits from /admin when nothing changed\n BroadcastChangeJob.perform_now(self) unless previous_changes.empty?\n end",
"def receive_ping\n done\n end",
"def send_pending; end",
"def perform(data)\n User.find(data[\"user_id\"]).update(status: false, online: false)\n ActionCable.server.broadcast 'chat_channel', content: \"qwertyuiop\"\n end",
"def listening?; end",
"def broadcast(&block)\n # Use hijack to handle sockets\n hijack do |tubesock|\n begin\n # Assuming restful controllers, the behavior of\n # this method has to change depending on the action\n # it's being used in\n case action_name\n\n # If the controller action is 'index', a collection\n # of records should be broadcast\n when 'index'\n execute_action(tubesock, block)\n\n # The following code will run if an instance\n # variable with the plural resource name has been\n # assigned in yield. For example, if a\n # TacosController's index action looked something\n # like this:\n\n # def index\n # broadcast do\n # @tacos = Taco.all\n # end\n # end\n\n # ...then @tacos will be broadcast to all connected\n # clients. The variable name, in this example,\n # has to be \"@tacos\"\n if collection\n redis_thread = Thread.new do\n redis.subscribe channel do |on|\n # Broadcast messages to all connected clients\n on.message do |channel, message|\n tubesock.send_data message\n end\n\n # Send message to whoever just subscribed\n tubesock.send_data({\n resources: collection\n }.to_json)\n\n close_db_connection\n end\n end\n\n # When client disconnects, kill the thread\n tubesock.onclose do\n redis_thread.kill\n end\n end\n\n # If the controller's action name is 'show', a single record\n # should be broadcast\n when 'show'\n execute_action(tubesock, block)\n\n # The following code will run if an instance variable\n # with the singular resource name has been assigned in\n # yield. For example, if a TacosController's show action\n # looked something like this:\n\n # def show\n # broadcast do\n # @taco = Taco.find(params[:id])\n # end\n # end\n\n # ...then @taco will be broadcast to all connected clients.\n # The variable name, in this example, has to be \"@taco\"\n if member\n redis_thread = Thread.new do\n redis.subscribe channel do |on|\n # Broadcast messages to all connected clients\n on.message do |channel, message|\n tubesock.send_data message\n end\n\n # Send message to whoever just subscribed\n tubesock.send_data({\n resource: member\n }.to_json)\n\n close_db_connection\n end\n end\n\n # When client disconnects, kill the thread\n tubesock.onclose do\n redis_thread.kill\n end\n end\n\n # If the controller's action name is 'create', a record should be\n # created. Before yielding, the params hash has to be prepared\n # with attributes sent to the socket. The actual publishing\n # happens in the model's callback\n when 'create'\n tubesock.onmessage do |m|\n set_resource_params(m)\n execute_action(tubesock, block)\n\n # Send resource that was just created back to client. The resource\n # on the client will be overridden with this one. This is important\n # so that the id, created_at and updated_at and possibly other\n # attributes arrive on the client\n if member\n tubesock.send_data({\n resource: member\n }.to_json)\n end\n\n close_db_connection\n end\n\n # If the controller's action name is 'update', a record should be\n # updated. Before yielding, the params hash has to be prepared\n # with attributes sent to the socket\n when 'update'\n tubesock.onmessage do |m|\n set_resource_params(m)\n execute_action(tubesock, block)\n\n # Send resource that was just updated back to client. The resource\n # on the client will be overridden with this one. This is important\n # so that the new updated_at and possibly other attributes arrive\n # on the client\n if member\n tubesock.send_data({\n resource: member\n }.to_json)\n end\n\n close_db_connection\n end\n\n when 'destroy'\n tubesock.onmessage do |m|\n execute_action(tubesock, block)\n\n # Send resource that was just destroyed back to client\n if member\n tubesock.send_data({\n resource: member\n }.to_json)\n end\n\n close_db_connection\n end\n\n # For every other controller action, simply wrap whatever is\n # yielded in the tubesock block to execute it in the context\n # of the socket. Other custom actions can be added through this\n else\n tubesock.onmessage do |m|\n # If message was sent, attach to params (rescue exception if\n # message not valid JSON or message not present)\n params.merge!(JSON.parse(m)) rescue nil\n\n execute_action(tubesock, block)\n\n close_db_connection\n end\n end\n rescue Exception => e\n Rails.logger.error e\n close_db_connection\n end\n end\n end",
"def broadcast_update\n broadcast broadcast_event_name(:updated), self, previous_changes\n end",
"def intent_listen_stop\n\tbegin\n\t\tdata = { 'myData' => 'This is broadcast data 5!' }\n\t\tif @params['par']\n\t\t\tcase @params['par']\n\t\t\twhen '411'\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"com.rhomobile.BROADCAST\",[\"com.rhomobile.compliancetestruby\"],\"\",\"\",\"\",\"\",data)\n\t\t\twhen '412'\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"\",\"\",\"compliancetestruby\",\"\",\"\",\"\",data)\t\t\t\t\t\n\t\t\twhen '413'\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"\",\"\",\"rhomobile compliancetest_ruby/compliancetestruby.exe\",\"\",\"\",\"\",data)\n\t\t\telse\n\t\t\tend\n\t\tend\n\t\tRho::Intent.startListening(url_for(:action => :listen_callback))\n\t\tRho::Intent.stopListening()\n Rho::Intent.send(@result)\n\trescue => ex\n\t\tjsmethod = 'Ruby.sendValueToJS(\"' + ex.message + '\")'\n\t\tRho::WebView.executeJavascript(jsmethod)\n\tend\nend",
"def notify_ready\n notify(\"READY=1\")\n end",
"def broadcast_messages\n @info = ['Gol', 'Zmiana','Żółta Kartka','Druga Żółta Kartka','Czerwona Kartka',]\n end",
"def broadcast\n signal_next until @waiting_threads.empty?\n self\n end",
"def push_to_online\n transition_to :online\n end",
"def broadcast_after_save\n # ObjectActivity.faye_broadcast(self, self) if verified_changed? | confirmed_at_changed?\n return true unless verified_changed? | confirmed_at_changed? | name_changed? | bio_changed? | job_title_id_changed? | avatar_changed? | gmc_changed?\n # users = User.joins(:user_locations).where(:user_locations => {:location_id => self.locations.collect{|a| a.id}}).all\n # users.each do |u|\n # UpdatesChannel.broadcast_to(u, {loadModels: [self.to_jsonapi]})\n # end\n BroadcastToLocationJob.perform_later(self.locations.all.to_a, {loadModels: [self.to_jsonapi]})\n true\n end",
"def answer_on_incoming()\n update({:state => 'active'})\n reload()\n end",
"def received\n end",
"def listen\r\n end",
"def on_broadcast(name)\n (action, argument) = name.split('_')\n case action\n when \"undefined_broadcast_1\"\n # do something\n when \"undefined_broadcast_2\"\n # do something else\n end\n end",
"def send_events; end",
"def transfer!(options = {}); transfer(options).broadcast!(true); end",
"def transfer!(options = {}); transfer(options).broadcast!(true); end",
"def wait_action_cable_subscription\n sleep 1\n end",
"def announce(msg)\n\tbroadcast = UDPSocket.new\n\tbroadcast.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)\n\tbroadcast.send(msg.to_s, 0, Broadcastaddr[0], Broadcastaddr[1])\n\tbroadcast.close\nend",
"def notify_complete\n @mutex.synchronize do\n @task_running = false\n @task_complete = true\n @token.broadcast\n end\n end",
"def guesser_ready(data)\n game = Game.find data['game_id']\n game.update status: 'playing'\n ActionCable.server.broadcast 'games', status: 'playing'\n end",
"def broadcast_presence\n services = CouchModels::Service.find_all\n users = services.map {|service| service.users }.flatten.uniq\n nodes = users.map {|jid| available(@stream.jid, jid) }\n nodes << services.map do |service|\n service.users.map {|jid| available(service.jid, jid) }\n end\n nodes.flatten!\n @throttle.async_send(nodes)\n end",
"def ready\n @room.user_ready!(current_user)\n broadcast_ready_changed\n end",
"def setup_broadcast_socket\n set_sock_opt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)\n end",
"def broadcasting; end",
"def execute\n return unless active\n process_outbound_ack\n deactivate(@flag)\n end",
"def broadcast!\n broadcast_queue.push(generate)\n end",
"def wake_up()\n # Do nothing by default\n end",
"def broadcast\n @monitor.mon_check_owner\n @cond.broadcast\n end",
"def broadcast(data)\n ActionCable.server.broadcast \"clock_#{@uuid}\", data\n end",
"def live\r\n @state=1\r\n end",
"def goaway!\n goaway block: true\n end",
"def intent_listen_send\n\tbegin\n\t\tif @params['par']\n\t\t\tcase @params['par']\n\t\t\twhen '5'\n\t\t\t\tdata = { 'message' => 'Message to service' }\n\t\t\t\tparams_constructor(Rho::Intent::START_SERVICE,\"\",\"\",\"\",\"com.rhomobile.compliancetestruby\",\"com.rhomobile.rhodes.RhodesService\",\"\",\"\",data)\n\t\t\twhen '11'\n\t\t\t\tdata = { 'reply' => 'This is my broadcast data!' }\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"com.smap.targetapp.mySecondAction\",\"\",\"\",\"\",\"\",\"\",data)\n\t\t\twhen '391'\n\t\t\t\tdata = { 'myData' => 'This is broadcast data 3!' }\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"com.rhomobile.BROADCAST\",[\"com.rhomobile.compliancetestruby\"],\"\",\"\",\"\",\"\",data)\n\t\t\twhen '392'\n\t\t\t\tdata = { 'myData' => 'This is broadcast data 3!' }\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"\",\"\",\"compliancetestruby\",\"\",\"\",\"\",data)\n\t\t\twhen '393'\n\t\t\t\tdata = { 'myData' => 'This is broadcast data 3!' }\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"\",\"\",\"rhomobile compliancetest_ruby/compliancetestruby.exe\",\"\",\"\",\"\",data)\n\t\t\twhen '461'\n\t\t\t\tdata = { 'myData' => 'This is broadcast data!'}\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"com.rhomobile.BROADCAST\",\"\",\"com.rhomobile.compliancetestruby\",\"\",\"\",\"\",data)\n\t\t\twhen '462'\n\t\t\t\tdata = { 'myData' => 'This is broadcast data!'}\n\t\t\t\tparams_constructor(Rho::Intent::BROADCAST,\"\",\"com.rhomobile.BROADCAST\",\"\",\"rhomobile compliancetest_ruby/compliancetestruby.exe\",\"\",\"\",\"\",data)\n\t\t\telse\n\n\t\t\tend\n\t\tend\n\t\tRho::Intent.startListening(url_for(:action => :listen_callback))\n\t\tRho::Intent.send(@result)\n\trescue =>ex\n\t\tjsmethod = 'Ruby.sendValueToJS(\"' + ex.message + '\")'\n\t\tRho::WebView.executeJavascript(jsmethod)\n\tend\nend",
"def broadcast_create\n broadcast broadcast_event_name(:created), self\n end",
"def setup_broadcast\n @model_class.broadcast_events.each { |event| add_callback_to_model(event) }\n end",
"def _inner_broadcast data, ignore_io = nil\n\t\t\t\t\tif data[:target]\n\t\t\t\t\t\tif data[:to_server] == Plezi::Settings.uuid\n\t\t\t\t\t\t\treturn ( ::Iodine::Http::Websockets.unicast( data[:target], data ) || ___faild_unicast( data ) )\n\t\t\t\t\t\tend\n\t\t\t\t\t\treturn ( data[:to_server].nil? && ::Iodine::Http::Websockets.unicast(data[:target], data) ) || ( Plezi::Base::AutoRedis.away?(data[:to_server]) && ___faild_unicast( data ) ) || __inner_redis_broadcast(data)\n\t\t\t\t\telse\n\t\t\t\t\t\t::Iodine::Http::Websockets.broadcast data, ignore_io\n\t\t\t\t\t\t__inner_redis_broadcast data\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\t\ttrue\n\t\t\t\tend",
"def on_message data\n\t\t# broadcast sends an asynchronous message to all sibling instances, but not to self.\n\t\tdata = ERB::Util.html_escape data\n\t\tbroadcast :_print_out, data\n\t\tresponse << \"You said: #{data}\"\n\t\tresponse << (request.ssl? ? \"FYI: Yes, This is an SSL connection...\" : \"FYI: Nope, this isn't an SSL connection (clear text).\") if data.match /ssl\\?/i\nend",
"def broadcast(type)\n redis.publish(ALL, {\n from: @cluster.id,\n type: type,\n time: Time.now.to_i\n }.to_json)\n end",
"def re_up_ready\n rdy(@max_in_flight)\n # assume these messages are coming our way. yes, this might not be the\n # case, but it's much easier to manage our RDY state with the server if\n # we treat things this way.\n @presumed_in_flight = @max_in_flight\n end",
"def spoof()\n\t\tlisten()\n\n\t\tlisten()\n\tend",
"def notify_ready\n if state == :smoking\n puts \"#{name} says: I'm good on smokes, thanks\"\n else\n transition :procuring\n end\n end",
"def broadcast_state(nick, state)\n #TODO: write function\n #get users clist, get the contacts clists and check their authorization to get the state\n #if its fine -> send the message to their queues\n\n return true\nend",
"def listen\n em_run do\n end\n end",
"def call\n transaction do\n discard_drafts\n end\n\n broadcast(:ok)\n end",
"def push_notify_ready\n droid_destinations = patient.devices.map do |device|\n device.token if device.platform == 'android' && device.enabled\n end\n data = {:type => \"READY\", :message =>\n \"Your appointment with #{clinic.name} at #{delayed_date_time_ampm} is ready\" }\n Thread.new do\n GCM.send_notification(droid_destinations, data) unless droid_destinations.empty?\n end\n end",
"def wakeup() end",
"def reload_cards\n broadcast(reload_cards: true)\n end",
"def ctcp_listen(m)\n return unless @has_oauth\n return unless m.action?\n return unless @registry[m.sourcenick + \"_actions\"]\n update_status(m, :status => m.message, :notify => true)\n end",
"def broadcast(public, event)\n core.broadcast(public, event)\n end",
"def post_init\n self.dispatch_event(:on_connect, [self])\n self.send_data(SyncMessage.new($listen_port, $uuid).to_sendable)\n end",
"def notify\n end",
"def on_001 (msg)\n when_ready if respond_to? :when_ready\n end",
"def wakeup; end",
"def listen(p0) end",
"def listen(p0) end",
"def listen(p0) end",
"def broadcast_sync(meth, *args)\n @listeners.select { |listener| listener.class.ann(meth, :stem_sync) }.each { |listener| listener.respond meth, *args }\n end",
"def on_ready\n end",
"def send_ready_signal()\n do_send(Erlang::Tuple.new([Erlang::Atom.new('ready')]))\n end",
"def polling\n while true do\n publish\n end\n end",
"def busy( &block )\n self.connection.status( :dnd, \"Working...\" )\n yield\n self.connection.status( :chat, \"JabberListener waiting for instructions\" )\n end",
"def on_start\n end",
"def notify\n return if destroy_if_old\n\n increase_busy_counter\n\n create_push\n end",
"def after_sync\n super()\n Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {\n success: success?,\n step: 'prepare',\n counts: counts,\n files: files,\n }.tap { |e| e[:duration] = duration if duration })\n Wukong::Deploy.vayacondios_client.set(vayacondios_topic, \"prepare.last\", { state: (success? ? 1 : 0), time: Time.now.utc.to_i })\n end",
"def event_incoming_broadcast(peer, room, msg)\nend",
"def subscribed; end",
"def broadcast\n ActionCable.server.broadcast \"#{self.loggable_type}:#{self.loggable_id}\", self\n end",
"def lift\n @mutex.lock\n\n @once ||= true\n\n @condition.broadcast\n ensure\n @mutex.unlock\n end",
"def unsend!\n @_sended = false\n end",
"def broadcast_users_changed\n data = {\n action: 'players_changed'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end",
"def listener; end",
"def on_broadcast data\n\t\t\t\t\tunless data.is_a?(Hash) && (data[:type] || data[:target]) && data[:method] && data[:data]\n\t\t\t\t\t\tIodine.warn \"Broadcast message unknown... falling back on base broadcasting\"\n\t\t\t\t\t\treturn super(data) if defined? super\n\t\t\t\t\t\treturn false\n\t\t\t\t\tend\n\t\t\t\t\treturn false if data[:type] && data[:type] != :all && !self.is_a?(data[:type])\n\t\t\t\t\t# return (data[:data].each {|e| emit(e)}) if data[:method] == :emit\n\t\t\t\t\treturn ((data[:type] == :all) ? false : (raise \"Broadcasting recieved but no method can handle it - dump:\\r\\n #{data.to_s}\") ) unless self.class.has_super_method?(data[:method])\n\t\t\t\t\tself.__send__(data[:method], *data[:data])\n\t\t\t\tend",
"def discover\n @myself.send_broadcast Net::Packet.helo\n end",
"def deliver(subscription_id, result)\n payload = { result: result.to_h, more: true }\n @action_cable.server.broadcast(stream_subscription_name(subscription_id), payload)\n end",
"def listen\n # TODO\n self\n end",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def run\n listen\n broadcast\n loop do\n sleep(10)\n @all_clients.each {|client| client.puts \"Krazy Joe #{KJ_VERBS.sample} #{KJ_POS.sample} #{KJ_NOUNS.sample}!\"} \n end\nend",
"def handler\r\n\t loop do \r\n\t socket = @rqueue.pop\r\n\t req = Request.new socket \r\n\t if req.broadcast == true\r\n\t handle_broadcast req \r\n\t else\r\n\t handle_listen req\r\n\t end\r\n\t \r\n\t end\r\n \tend",
"def broadcast(event, data)\n #only keep the last 5000 Events\n if @history.size >= 6000\n @history.slice!(0, @history.size - 1000)\n end\n @lastEventId += 1\n @history << {id: @lastEventId, event: event, data: data}\n info \"Sending Event: #{event} Data: #{data} to #{@connections.count} Clients\"\n @connections.each do |socket|\n async.send_sse(socket, data, event, @lastEventId)\n end\n true\n end",
"def stop_stream_from(broadcasting); end",
"def send_ready(subs)\n self.send({\n msg: 'ready',\n subs: subs\n })\n end",
"def notify\n {\n }\n end",
"def notify\n {\n }\n end",
"def connection_completed\n ## start sending KEEP_ALIVE_MESSAGE\n puts 'sending keep_alive sending ...'\n EM::PeriodicTimer.new(KEEP_ALIVE_INTERVAL) { send_data KEEP_ALIVE_MESSAGE }\n end",
"def deliver_now\n deliver!\n end",
"def pong_everyone\n #log \"trying to pong\"\n if @sockets.length > 0 && !self.stopped?\n #log \"ponging\"\n broadcast_message(nil, \"PONG\", [build_handle_list])\n #sleep 5\n clean_handles\n end\n end",
"def on_appear\n @update = true\n unless @checkingCheckins\n update_checkins\n end\n unless @pinging\n location_ping\n end\n @frequency = 20\n end",
"def bridge_multicast_state\n super\n end"
] | [
"0.7423565",
"0.66371185",
"0.6208594",
"0.61926943",
"0.6174324",
"0.599948",
"0.59905565",
"0.5972775",
"0.5972775",
"0.58450663",
"0.58252233",
"0.5815035",
"0.57889396",
"0.5781223",
"0.57754594",
"0.57260394",
"0.5665126",
"0.5638281",
"0.5631563",
"0.5630843",
"0.5629422",
"0.5626739",
"0.5626458",
"0.5623844",
"0.56201446",
"0.5616989",
"0.5593161",
"0.5579227",
"0.5579227",
"0.5577084",
"0.5566377",
"0.5555323",
"0.5544011",
"0.55422276",
"0.55092275",
"0.5494942",
"0.54873",
"0.5487012",
"0.5484507",
"0.54784507",
"0.5462051",
"0.54560155",
"0.5452414",
"0.54352355",
"0.54314274",
"0.5428966",
"0.54201704",
"0.54123443",
"0.54116654",
"0.53863853",
"0.53796",
"0.5376448",
"0.53734684",
"0.53688216",
"0.536845",
"0.53521454",
"0.5335829",
"0.53332263",
"0.5328997",
"0.53265125",
"0.5318003",
"0.53083634",
"0.5307197",
"0.530437",
"0.52979684",
"0.52951765",
"0.52951765",
"0.52951765",
"0.5285716",
"0.52853036",
"0.52801347",
"0.527515",
"0.52700883",
"0.5264628",
"0.5261967",
"0.5253736",
"0.5253358",
"0.5252497",
"0.5251706",
"0.5238998",
"0.52355057",
"0.52351266",
"0.5234783",
"0.5230181",
"0.5223916",
"0.5223498",
"0.52180403",
"0.5205318",
"0.51975787",
"0.51919407",
"0.51878357",
"0.5183268",
"0.51820207",
"0.5179693",
"0.5179693",
"0.51742715",
"0.51702917",
"0.5170234",
"0.51658434",
"0.5153318"
] | 0.57805824 | 14 |
GET /answers GET /answers.json | def index
redirect_to root_path and return unless current_user.admin? #FIXME Make this it is visible to instructors
@answers = Answer.where('assignment_id = ? and active =?', params[:assignment_id], true).order('user_id').order('created_at DESC').paginate(:page => params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end",
"def show\n render json: @answer\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def get_answers\n @answers\n end",
"def answers(options={})\n @answers = self.class.parse_answers(request(singular(question_id) + \"/answers\", options))\n end",
"def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def index\n\t\t@answers = Answer.all\n\tend",
"def index\n @answers = @question.answers.all\n\n respond_to_index\n end",
"def index\n @answers = Answer.all\n \n end",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n question_id = @answer.question\n @body = @answer.body\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end",
"def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end",
"def index\n @answers = @question.answers.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def index\n @answer_respondents = AnswerRespondent.all\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def index\n @answers = Answer.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n @questions = Question.find(params[:id])\n @answers = @question.answers.all\n end",
"def index\n @answers=Answer.all\n end",
"def index\n @answers = Replay.all\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def index\n render status: :ok, json: @simple_question_alternatives\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def show\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end",
"def my_scn_answers\n\t\t#collect all the answers of current user\n\t answers = current_user.answers.all.map(&:question).uniq\n\t\tif answers.present?\n\t\t# response to the JSON\n\t\trender :json=> {success: true, \"answers\" => answers.as_json('my_scn_answers')}\n\t else\n\t render :json=> { success: false, message: \"Answers are not present\" },:status=> 203\n\t end\n\tend",
"def show\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def index\n @m_answers = MAnswer.all\n end",
"def show\n @answer = Answer.find(params[:id])\n authorize! :read, @answer\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end",
"def index\n @question_answers = QuestionAnswer.all\n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer_set = AnswerSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer_set }\n end\n end",
"def show\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def show\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_answer }\n end\n end",
"def answers\n @answers ||= {}\n end",
"def show\n @answer = Answer.find(params[:id])\n end",
"def index\n @asked_to_answers = AskedToAnswer.all\n end",
"def answer\n if answered?\n answers.last.answer\n else\n [{:answer => \"not answered\"}]\n end\n end",
"def render_answer\n request('answers/render')\n end",
"def index\n @given_answers = GivenAnswer.all\n end",
"def show\n\t\t@question = Question.find(params[:id])\n @answers = Answer.where(\"question_id = ?\", @question.id).order('upvote DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: { question: @question, answers: @answers } }\n\t\tend\n\tend",
"def index\n @fake_answers = FakeAnswer.all\n end",
"def show\n @online_answer = OnlineAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @online_answer }\n end\n end",
"def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end",
"def show\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_answer }\n end\n end",
"def answers(ids=nil, **params)\n resource_request(Answer, ids, 'answers', params)\n end",
"def answers\n object.answers.collect do |a|\n {\n id: a.id,\n user_id: a.user_id,\n alternative_id: a.alternative_id\n }\n end\n end",
"def index\n @reply_answers = ReplyAnswer.all\n end",
"def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end",
"def index\n @survey_answer_items = SurveyAnswerItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_answer_items }\n end\n end",
"def index\n @actual_answers = ActualAnswer.all\n end",
"def answers\n @answers ||= generate_answers\n end",
"def show\n # @question_answer = Question::Answer.new\n @question = Question.find(params[:question_id])\n @answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def new # GET /answers/new\n @answer = Answer.new\n end",
"def api\n url = \"https://wagon-dictionary.herokuapp.com/#{@answer}\"\n response = URI.open(url).read\n json = JSON.parse(response)\n return json['found']\n end",
"def answer_by_id(question, id)\n\t\t\t\tbegin\n\t\t\t\t\tanswer = question.answers.find(id)\n\t\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\t\thalt 404\n\t\t\t\tend\n\t\t\tend",
"def get_answers_list\n @answers = Answer.find_all_by_questionare_id params[:q_id]\n unless @answers.blank?\n render :partial => \"answers_list\"\n else\n render :text => \"No Record Found\"\n end\n end",
"def answer_list\n answers = Quiz.where(id: params[:ids]).map{|quiz| [quiz.id => quiz.answer]}\n render json: {status: 200, answers: answers.flatten, msg: \"Success.\"}\n end",
"def index\n @user_answers = UserAnswer.all\n end",
"def verify_answer\n answer = Answer.find(params[:id])\n\n respond_to do |format|\n if answer.verify_answer(params)\n format.json { render :json => true }\n else\n format.json { render :json => false }\n end\n end\n end",
"def index\n @possible_answers = PossibleAnswer.all\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html { render }\n format.json { render json: {question: @question.to_json, insights: @question.insights.order(created_at: :desc)} }\n format.xml { render xml: @question.to_xml }\n end\n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def new\n @answer = Answer.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def index\n @submitted_answers = SubmittedAnswer.all\n end",
"def new\n @textanswer = Textanswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def answers_by_views(options={})\n parse_answers(request(singular(id) + \"answers/views\", options))\n end",
"def show\n respond_to do |format|\n format.html {redirect_to root_path}\n format.text {render text: @answer.response}\n end\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html {render} # render questions/show.html.erb\n format.json {render json: @question.to_json}\n format.xml {render xml: @question.to_xml}\n end\n end",
"def new\n @user_answer = UserAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def show\n query = params[:search]\n puts \"Query: #{query}\"\n if query\n @answers = Answer.search(query)\n respond_to do |format|\n format.js\n end\n else\n @answers = Answer.where([\"id = ?\",1])\n end\n end",
"def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end",
"def show\n if @user\n @answers = @question.answers.shuffle\n @equestion = @question.as_json.merge({:answers => @answers, :hearts => @user.hearts})\n render :json => @equestion\n else \n render text: \"Token failed verification\", status: 422\n end\n end",
"def index\n @my_exams = MyExam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_exams }\n end\n end"
] | [
"0.8011635",
"0.7718146",
"0.7686177",
"0.76641846",
"0.76641846",
"0.76641846",
"0.76641846",
"0.75861204",
"0.75337416",
"0.7378286",
"0.72804594",
"0.72647053",
"0.7170898",
"0.7170898",
"0.7170898",
"0.71279556",
"0.7089768",
"0.7056577",
"0.7055519",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6954055",
"0.6952659",
"0.6905489",
"0.6882457",
"0.68633425",
"0.68224025",
"0.6813208",
"0.6769749",
"0.6766937",
"0.6714333",
"0.66833305",
"0.6670608",
"0.66536295",
"0.6642209",
"0.6641651",
"0.662984",
"0.6625375",
"0.6620381",
"0.6620381",
"0.6617649",
"0.6583174",
"0.65785503",
"0.6565271",
"0.6535554",
"0.6533822",
"0.65067345",
"0.64955264",
"0.64865726",
"0.648566",
"0.6471394",
"0.6462763",
"0.6462006",
"0.64613575",
"0.64604914",
"0.644918",
"0.6435281",
"0.6421099",
"0.6416281",
"0.639091",
"0.6390676",
"0.6378165",
"0.6369827",
"0.6353429",
"0.63508606",
"0.6346074",
"0.6345934",
"0.63389474",
"0.63359904",
"0.633054",
"0.63235176",
"0.63224316",
"0.6310992",
"0.62896556",
"0.62842673",
"0.6247675",
"0.62336624",
"0.6227032",
"0.6226878",
"0.62224305",
"0.6212444",
"0.6210548",
"0.6206024",
"0.61958295",
"0.61861646",
"0.618393",
"0.6183051",
"0.61819905",
"0.61812204",
"0.6179339",
"0.6168425",
"0.61601907",
"0.61535096",
"0.61473626",
"0.6139837",
"0.613889",
"0.6130003",
"0.61249375"
] | 0.0 | -1 |
GET /answers/1 GET /answers/1.json | def show
respond_to do |format|
format.html {redirect_to root_path}
format.text {render text: @answer.response}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def answers\n request('answers')\n end",
"def show\n render json: @answer\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n question_id = @answer.question\n @body = @answer.body\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end",
"def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end",
"def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end",
"def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def new\n @answer_set = AnswerSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer_set }\n end\n end",
"def index\n @answers = @question.answers.all\n\n respond_to_index\n end",
"def index\n @answers = Answer.all\n \n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n end",
"def index\n\t\t@answers = Answer.all\n\tend",
"def show\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_answer }\n end\n end",
"def get_answers\n @answers\n end",
"def show\n if @v1_answer\n render json: @v1_alternative\n else\n render json: get_errors(@v1_alternative), status: :unprocessable_entity\n end\n end",
"def show\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def index\n render status: :ok, json: @simple_question_alternatives\n end",
"def index\n @answers = @question.answers.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def answer_by_id(question, id)\n\t\t\t\tbegin\n\t\t\t\t\tanswer = question.answers.find(id)\n\t\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\t\thalt 404\n\t\t\t\tend\n\t\t\tend",
"def show\n\t\t@question = Question.find(params[:id])\n @answers = Answer.where(\"question_id = ?\", @question.id).order('upvote DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: { question: @question, answers: @answers } }\n\t\tend\n\tend",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n authorize! :read, @answer\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @form = Form.where(id: params[:id]).includes(:questions => :answers).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @form }\n end\n end",
"def show\n @questions = Question.find(params[:id])\n @answers = @question.answers.all\n end",
"def index\n @answers = Answer.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def show\n @online_answer = OnlineAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @online_answer }\n end\n end",
"def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end",
"def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end",
"def show\n idx = params[:id]\n @question = Question.find(params[:id])\n @newAnswer = Answer.new(:question_id => params[:id])\n @Answers = Answer.where(question_id: idx)\n @answer = Answer.all\n end",
"def show\n # @question_answer = Question::Answer.new\n @question = Question.find(params[:question_id])\n @answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def index\n @answer_respondents = AnswerRespondent.all\n end",
"def show\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_answer_item }\n end\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def new # GET /answers/new\n @answer = Answer.new\n end",
"def index\n @answers=Answer.all\n end",
"def show\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def index\n @answers = Replay.all\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html { render }\n format.json { render json: {question: @question.to_json, insights: @question.insights.order(created_at: :desc)} }\n format.xml { render xml: @question.to_xml }\n end\n end",
"def new\n @answer = Answer.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend",
"def render_answer\n request('answers/render')\n end",
"def index\n @m_answers = MAnswer.all\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @report_question_answer = ReportQuestionAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report_question_answer }\n end\n end",
"def index\n @survey_answer_items = SurveyAnswerItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_answer_items }\n end\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html {render} # render questions/show.html.erb\n format.json {render json: @question.to_json}\n format.xml {render xml: @question.to_xml}\n end\n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def show\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_question }\n end\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end",
"def show\n @question = current_node.questions.find(params[:id])\n @question.viewed!(request.remote_ip)\n @answers = (@question.answers.page params[:page]).order_by(current_order)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def index\n @question_answers = QuestionAnswer.all\n end",
"def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def create\n @v1_answer = current_user.answers.new(v1_answer_params)\n if @v1_answer.save\n render json: @v1_answer, status: :created\n else\n render json: @v1_answer.errors, status: :unprocessable_entity\n end\n end",
"def new\n @answer = @question.answers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def new\n @textanswer = Textanswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def new\n @user_answer = UserAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def index\n @given_answers = GivenAnswer.all\n end",
"def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end"
] | [
"0.8064372",
"0.7594417",
"0.7428456",
"0.7428456",
"0.7428456",
"0.7428456",
"0.7339359",
"0.72826004",
"0.72826004",
"0.72826004",
"0.71105605",
"0.7107359",
"0.7090169",
"0.7037905",
"0.70348716",
"0.6962064",
"0.68762743",
"0.6874184",
"0.6832382",
"0.6809381",
"0.6796853",
"0.6741276",
"0.67330605",
"0.67330605",
"0.67059225",
"0.6702718",
"0.6702718",
"0.6702718",
"0.6702718",
"0.6702718",
"0.66917366",
"0.6662445",
"0.6660749",
"0.66486347",
"0.6643981",
"0.66431546",
"0.66280127",
"0.6615376",
"0.66008794",
"0.65849835",
"0.65672404",
"0.656386",
"0.6558294",
"0.6550875",
"0.6544644",
"0.65359575",
"0.6530934",
"0.6523473",
"0.65178174",
"0.65020263",
"0.64906514",
"0.64823055",
"0.64711434",
"0.64520144",
"0.6447939",
"0.6442836",
"0.64281636",
"0.64277345",
"0.6427447",
"0.6427447",
"0.64242446",
"0.64205873",
"0.6418093",
"0.64175045",
"0.64141995",
"0.6412735",
"0.6399224",
"0.638198",
"0.63667166",
"0.6349834",
"0.63492614",
"0.6342175",
"0.62994653",
"0.6294854",
"0.62764657",
"0.62750113",
"0.6274817",
"0.6274817",
"0.6274817",
"0.62747407",
"0.62738556",
"0.6272238",
"0.62715966",
"0.62691414",
"0.62540054",
"0.6247162",
"0.62454844",
"0.62445736",
"0.62445736",
"0.6242495",
"0.6237011",
"0.6220606",
"0.62159985",
"0.62053186",
"0.6202038",
"0.619449",
"0.6187193",
"0.6171213",
"0.6170985",
"0.61696076"
] | 0.62045914 | 94 |
POST /answers POST /answers.json | def create
@answer = Answer.new(answer_params)
@answer.assignment = Assignment.find(params[:assignment_id])
@answer.user = current_user
respond_to do |format|
if @answer.save
format.html { redirect_to (@answer.assignment or @answer), notice: 'Answer was successfully created.' }
format.json { render action: 'show', status: :created, location: @answer }
format.js
else
format.html { render action: 'new' }
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def add_answer\n request('answers/add')\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully created.\" }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_form\n answers_params = params.permit!\n\n render json: Answer.insert_answers(answers_params, current_user[\"id\"])\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = @question.answers.new(answer_params)\n\n if @answer.save\n respond_to_save_success(@answer, [@question, @answer])\n else\n respond_to_save_failure(:new, @answer)\n end\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.build(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = @question.answers.build(answer_params)\n @answer.save\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html {\n redirect_to questions_url,\n notice: 'Answer submit successful.'\n }\n else\n format.html { render :new }\n format.json {\n render json: @answer.errors,\n status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n\n\t\trespond_to do |format|\n\t\t\tif @answer.save\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @answer }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @answers = params[:user_answers]\n @answers.each do |key, value|\n UserAnswer.create(:user_id => current_user.id, :survey_question_id => key.to_i, :text => value)\n end\n redirect_to :root\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Form::Answer.new(answer_params)\n respond_to do |format|\n if @answer.save\n format.html { redirect_to thanks_path, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @v1_answer = current_user.answers.new(v1_answer_params)\n if @v1_answer.save\n render json: @v1_answer, status: :created\n else\n render json: @v1_answer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @answer = AttemptAnswer.new(answer_params) \n \n if @answer.save\n render json: @answer, status: :created \n else\n head(:unprocessable_entity)\n end\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def create\n answer = Answer.new(content: params[:content], upvotes: 0, downvotes:0, user_id: params[:user_id], question_id: params[:question_id])\n \n if answer.save\n render json: {answer: answer, create_time: (answer.created_at.to_f * 1000).to_i, success: true}\n else\n render json: @answer.errors, success: false\n end\n end",
"def create\n @answer_respondent = AnswerRespondent.new(answer_respondent_params)\n\n respond_to do |format|\n if @answer_respondent.save\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully created.' }\n format.json { render :show, status: :created, location: @answer_respondent }\n else\n format.html { render :new }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n\t\tquestionId = params[:questionId]\n\t\tanswerId = params[:answerId]\n\t\tanswer = params[:answer]\n\t\tnumAnswers = params[:numAnswers].to_i\n\n\t\tbegin\n\t\t\tsuccess = ParseManager.createUserAnswer(answer, answerId, questionId)\n\t\t\tnumAnswers -= 1\n\t\tend until numAnswers == 0\n\n\t\trender json:success\n\tend",
"def create\n @answer = Answer.new(answer_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to question_path(@answer.question) }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @answer = Answer.new\n # @answer.user_id = current_user.もid\n # @answer.question_id = params[:question_id]\n # @answer.content = params[:content]\n # @answer.save\n # 一個保存できれば、何個でも保存できる\n if !params[:answer][:content]\n render json: {errors: \"未入力の項目があります。\"}, status: 422\n\n end\n @answer = current_user.answers.build(answer_params)\n @answer.save\n end",
"def sync_user_answers\n return head :ok if params[:user_answers].blank?\n\n user_exam = current_user.user_exams.find(params[:id])\n user_exam.user_answers.create! user_answers_params\n\n head :ok\n end",
"def create\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n @answer = @question.answers.build(params[:answer])\n @answer.user_id = @current_user.id\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end",
"def store_answers\n @user_choice = params[:userChoiceData]\n @user_data = params[:userId]\n is_save = AnswerService.store_answers(@user_choice, @user_data)\n if is_save\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @answer = current_user.answers.new(answer_params)\n @answer.question = @question\n @question.update(cant_answers: @question.cant_answers + 1)\n @answer.puntaje = 0\n @answer.best = false;\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer.question, notice: 'Respuesta creada satisfactoriamente' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:body, :question_id, :status)\n end",
"def create\n @question = Question.create!(question_params.merge({user_id: 1}))\n if question_params[:answers]\n question_params[:answers].with_indifferent_access.each do |answer|\n Answer.create!(name: answer[:name], question_id: @question.id)\n end\n end\n @question.prepare\n @question.broadcast\n render json: @question, status: :created\n end",
"def create\n @submitted_answer = SubmittedAnswer.new(params[:submitted_answer])\n\n respond_to do |format|\n if @submitted_answer.save\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully created.' }\n format.json { render json: @submitted_answer, status: :created, location: @submitted_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_params\n params.require(:answer).permit(:answer)\n end",
"def answer_params\n params.require(:answer).permit(:text, :votes, :question_id)\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def answer_params\n params.require(:answer).permit(:content, :question_id, :response_id)\n end",
"def answers(options={})\n @answers = self.class.parse_answers(request(singular(question_id) + \"/answers\", options))\n end",
"def answer_params\n params.require(:answer).permit(:body)\n end",
"def create\n @asked_to_answer = AskedToAnswer.new(asked_to_answer_params)\n\n respond_to do |format|\n if @asked_to_answer.save\n format.html { redirect_to @asked_to_answer, notice: 'Asked to answer was successfully created.' }\n format.json { render :show, status: :created, location: @asked_to_answer }\n else\n format.html { render :new }\n format.json { render json: @asked_to_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def answer_params\n params.require(:answer).permit(:body, :question_id)\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to(@answer, :notice => 'Answer was successfully created.') }\n format.xml { render :xml => @answer, :status => :created, :location => @answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to(@answer, :notice => 'Answer was successfully created.') }\n format.xml { render :xml => @answer, :status => :created, :location => @answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end",
"def create\n @fake_answer = FakeAnswer.new(fake_answer_params)\n @fake_answer.question_id = params[:question_id]\n respond_to do |format|\n if @fake_answer.save\n format.html { redirect_to question_path(params[:quiz_id], params[:question_id]), notice: 'Fake answer was successfully created.' }\n format.json { render :show, status: :created, location: @fake_answer }\n else\n format.html { render :new }\n format.json { render json: @fake_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = current_user.answers.build(params[:answer])\n if @answer.save\n @post = @answer.post\n Notifier.delay.new_answer(@post.user, @answer)\n if @post.user != current_user\n current_user.update_attributes(cred_count: current_user.cred_count + 10)\n end\n return render status: 200, json: { success: true }\n else\n return render :status => :unprocessable_entity,\n :json => { success: false, :error => \"There was a problem posting your advice.\" }\n end\n end",
"def answer\n params[:answers].each do |question_id, value|\n answer = Answer.find_or_initialize_by_question_id_and_user_id(question_id, current_user.id)\n answer.content = value[:content]\n answer.save\n end if params[:answers]\n\n survey = Survey.find(params[:id])\n redirect_to survey.next_url || root_url, :notice => survey.confirmation\n end",
"def answer_params\n # Rails.logger.debug \"Params: #{params.inspect}\"\n params.require(:answers).permit(:answer, :updated_at, :users_id, :questions_id)\n end",
"def answer_params\n params.require(:answer).permit(:answer, :response, :survey_id, :question_id, :response_id, :user_id)\n end",
"def answer_params\n params.require(:answer).permit(:text, :question_id, :correct)\n end",
"def answer_params\n params.require(:answer).permit(:ans, :user_id, :question_id)\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @m_answer = @m_question.m_answers.build(m_answer_params)\n respond_to do |format|\n if @m_answer.save\n format.html { redirect_to m_question_path(@m_question) }\n format.json { render action: 'show', status: :created, location: @m_answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @m_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_answers(connection_id, answers)\n connection_id.require!(as: 'connection_id')\n answers.require!(as: 'answers')\n answers.each do |answer|\n answer.require!(:answer, :question)\n end\n\n params = { questions: answers.to_json }\n api(:put, \"/connections/#{connection_id}/challenges\", params)\n .fetch('challenges')\n .cast(Challenge)\n end",
"def answer_params\n params.require(:answer).permit(:user_id, :question_id, :content, :is_tweet, :is_anonymous)\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(params[:answer])\n @answer.user = current_user\n @answer.score = 0\n @answer.fav = 0\n @user = User.find(@question.user_id)\n\n respond_to do |format|\n if @answer.save\n UserMailer.answer_email(@user).deliver\n format.html { redirect_to @question, notice: 'Respuesta creada correctamente.' }\n format.json { render json: @question, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def create\n @quizzes_answer = Quizzes::Answer.new(quizzes_answer_params)\n\n respond_to do |format|\n if @quizzes_answer.save\n format.html { redirect_to @quizzes_answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @quizzes_answer }\n else\n format.html { render :new }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :post_id)\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def create\n @actual_answer = ActualAnswer.new(actual_answer_params)\n\n respond_to do |format|\n if @actual_answer.save\n format.html { redirect_to @actual_answer, notice: 'Actual answer was successfully created.' }\n format.json { render :show, status: :created, location: @actual_answer }\n else\n format.html { render :new }\n format.json { render json: @actual_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :question_id)\n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def create\n\t\t@question = Question.find(params[:question_id])\n\t\t@answer = @question.answers.build(answer_params)\n\t\[email protected] = current_user\n\t\tif @answer.save\n\t\t\tflash[:success] = \"answer submitted\"\n\t\t\tredirect_to root_url\n\t\telse\n\t\t\tflash[:danger] = \"some error occured\"\n\t\t\trender 'new'\n\t\tend\n \n end",
"def create\n @user_answer = UserAnswer.new(user_answer_params)\n\n respond_to do |format|\n if @user_answer.save\n format.html { redirect_to @user_answer, notice: 'User answer was successfully created.' }\n format.json { render :show, status: :created, location: @user_answer }\n else\n format.html { render :new }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer\n @assessment = Assessment.new(assessment_params)\n @assessment.user_id = current_user.id\n if @assessment.save\n @assessment.update_attributes(check_user_answer)\n render json: @assessment.as_json(only: [:question_id, :user_option, :is_correct,:is_skipped]), status: :created\n else\n render json: @assessment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @given_answer = GivenAnswer.new(given_answer_params)\n\n respond_to do |format|\n if @given_answer.save\n format.html { redirect_to @given_answer, notice: 'Given answer was successfully created.' }\n format.json { render :show, status: :created, location: @given_answer }\n else\n format.html { render :new }\n format.json { render json: @given_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_answer = StudentAnswer.new(params[:student_answer])\n\n respond_to do |format|\n if @student_answer.save\n format.html { redirect_to @student_answer, notice: 'Student answer was successfully created.' }\n format.json { render json: @student_answer, status: :created, location: @student_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:question_number, :question_response, :taker_id, :question_id)\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n @answer.create_activity :create, owner: current_user\n flash.now[:notice] = 'Answer was successfully created.'\n format.html { redirect_to @answer }\n format.json { render json: @answer, status: :created, location: @answer }\n format.js { render \"answers/create\", :layout => false }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n format.js do\n render \"answers/create\", :layout => false\n end\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:body,:anonymous)\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def answer_params\n params.require(:answer).permit(:text, :color, :score)\n end",
"def create\n @tipo_answer = TipoAnswer.new(tipo_answer_params)\n\n respond_to do |format|\n if @tipo_answer.save\n format.html { redirect_to @tipo_answer, notice: 'Tipo answer was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_answer }\n else\n format.html { render :new }\n format.json { render json: @tipo_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:answer, :question_id, :user_id)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def create\n @survey_user_answer = SurveyUserAnswer.new(survey_user_answer_params)\n\n respond_to do |format|\n if @survey_user_answer.save\n format.html { redirect_to @survey_user_answer, notice: 'Survey user answer was successfully created.' }\n format.json { render :show, status: :created, location: @survey_user_answer }\n else\n format.html { render :new }\n format.json { render json: @survey_user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if answer_params['content'].length == 0\n flash[:alert] = \"Nice try, answer can't be blank!!\"\n redirect_to controller: 'questions', action: 'show', id: answer_params['question_id']\n else\n @answer = Answer.new(answer_params)\n respond_to do |format|\n if @answer.save\n flash[:notice] = \"Answer was successfully created!!\"\n format.html { redirect_to controller: 'questions', action: 'show', id: @answer.question_id}\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @user = User.find(params[:id])\n @user.answer_ids = params[:answers]\n\n unless (StudentsQuiz.find_by(student_id: params[:id], publication_id: params[:quiz][:id]))\n respond_to do |format|\n format.json { render json: { marks: @user.answer_quiz(params[:answers], params[:quiz][:id]), total_marks: Publication.find(params[:quiz][:id]).quiz.marks.to_f } }\n end\n else\n respond_to do |format|\n format.json { render json: { errors: \"You have answered before\" }, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :question_id)\n end",
"def answer_params\n\t params.require(:answer).permit(:title, :description)\n\t end",
"def create\n @client_answer = ClientAnswer.new(params[:client_answer])\n\n respond_to do |format|\n if @client_answer.save\n format.html { redirect_to @client_answer, notice: 'Client answer was successfully created.' }\n format.json { render json: @client_answer, status: :created, location: @client_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :rating_id, :question_id)\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end"
] | [
"0.7289319",
"0.7276055",
"0.7215647",
"0.71726567",
"0.7067945",
"0.7067945",
"0.70665044",
"0.70541114",
"0.70526284",
"0.7042241",
"0.7038466",
"0.69990367",
"0.6996154",
"0.6996154",
"0.69576937",
"0.6925406",
"0.6923861",
"0.6923151",
"0.69152343",
"0.6890862",
"0.68445736",
"0.6787694",
"0.67663765",
"0.67606837",
"0.6734757",
"0.6733456",
"0.6719177",
"0.67022556",
"0.6701353",
"0.667029",
"0.66538435",
"0.6646441",
"0.66051996",
"0.6585625",
"0.6583575",
"0.65709805",
"0.6568713",
"0.6555795",
"0.65520835",
"0.65419173",
"0.653813",
"0.65221125",
"0.6513978",
"0.651091",
"0.64970785",
"0.64970785",
"0.6488378",
"0.6481714",
"0.6480289",
"0.6474002",
"0.6465366",
"0.6463989",
"0.6455522",
"0.6454927",
"0.64372927",
"0.64340526",
"0.641592",
"0.6406454",
"0.64061695",
"0.6399108",
"0.6395842",
"0.6395842",
"0.6387173",
"0.63628584",
"0.6361604",
"0.63467073",
"0.63446856",
"0.6338634",
"0.6336556",
"0.6333958",
"0.63314945",
"0.6325946",
"0.6324988",
"0.6319415",
"0.6317281",
"0.6317281",
"0.6317281",
"0.6317281",
"0.6313461",
"0.6313461",
"0.6313461",
"0.6313461",
"0.6313461",
"0.62997717",
"0.62990373",
"0.62874097",
"0.6286356",
"0.62808603",
"0.6272825",
"0.6265232",
"0.6261785",
"0.6261785",
"0.626145",
"0.62612915",
"0.6261206",
"0.6255331",
"0.6248413",
"0.6248353",
"0.6244207",
"0.62432706",
"0.6242126"
] | 0.0 | -1 |
PATCH/PUT /answers/1 PATCH/PUT /answers/1.json | def update
unless @answer.user == current_user or current_user.instructor_for?(@answer.assignment.course)
redirect_to assignment_path(@answer.assignment), alert: "You can only edit your own answers!" and return
end
if @answer.submitted?
redirect_to @answer.assignment, alert: "You submitted this answer for a review, so you can't change it anymore." and return
end
respond_to do |format|
if @answer.update(answer_params.merge(active: true)) #set active to true so the answer shows up everywhere
format.html { redirect_to (@answer), notice: 'Answer was successfully updated.' }
format.json { head :no_content }
format.js
else
format.html { render action: 'edit' }
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js {flash[:alert] = @answer.errors.full_messages.join(","); render}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def update\n @answer = current_user.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.json { head :no_content }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @answer.update(answer_params)\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to questions_url, notice: 'Answer edited.' }\n else\n format.json {\n render json: @answer.errors,\n status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer.update(answer_params)\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to answers_path, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question_answer = Question::Answer.find(params[:id])\n\n respond_to do |format|\n if @question_answer.update_attributes(params[:question_answer])\n format.html { redirect_to @question_answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Respuesta actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to([@question,@answer], :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:comment])\n format.html { redirect_to @answer }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer_respondent.update(answer_respondent_params)\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_respondent }\n else\n format.html { render :edit }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n answer = Answer.find(params[:answer_id])\n if answer.update(content: params[:content])\n render json: {answer: answer, success: true} \n else\n render json: @answer.errors, success: false \n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find_by_uuid(params[:id])\n @question = @answer.question\n\n respond_to do |format|\n begin\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to answer_path(@answer.uuid), notice: 'Your answer was successfully saved.' }\n format.json { render json: @answer, status: :created, location: answer_path(@answer.uuid) }\n else\n format.html { render action: \"edit\", location: edit_answer_path(@answer.uuid) }\n format.json { render json: @answer.errors, status: :unprocessable_entity, location: edit_answer_path(@answer.uuid) }\n end\n rescue ActiveRecord::ReadOnlyRecord\n format.html { redirect_to answer_path(@answer.uuid), notice: \"You cannot change the answer\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity, location: answer_path(@answer.uuid) }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer.question, notice: 'Respuesta actualizada satisfactoriamente' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @answer.update(answer_params)\n respond_to_save_success(@answer, [@question, @answer])\n else\n respond_to_save_failure(:edit, @answer)\n end\n end",
"def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end",
"def update_answer\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to :planner, notice: 'Answer was successfully updated.' }\n format.json { respond_with_bip(@answer) }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fake_answer.update(fake_answer_params)\n format.html { redirect_to @fake_answer, notice: 'Fake answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @fake_answer }\n else\n format.html { render :edit }\n format.json { render json: @fake_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.post.update(embedded_post_params)\n format.js { head :no_content }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asked_to_answer.update(asked_to_answer_params)\n format.html { redirect_to @asked_to_answer, notice: 'Asked to answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @asked_to_answer }\n else\n format.html { render :edit }\n format.json { render json: @asked_to_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_question.update(api_v1_question_params)\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_question }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n if @submitted_answer.update_attributes(params[:submitted_answer])\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n if @client_answer.update_attributes(params[:client_answer])\n format.html { redirect_to @client_answer, notice: 'Client answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Using first or create allows users to update their answer (or create it obviously)\n answer = Answer.where(:question_id => params[:question_id], :user_id => current_user.id).first_or_create! do |answer|\n answer.user_id = current_user.id\n answer.survey_id = params[:survey_id]\n answer.group_id = current_user.group.id\n answer.question_id = params[:question_id]\n answer.answer = params[:answer]\n\n @created = true\n\n if answer.save\n q = IQuestion.find_by_id(params[:question_id])\n\n if q.present?\n qdes = q.description\n else\n qdes = \"Orphaned question\"\n end\n\n s = ISurvey.find_by_id(params[:survey_id])\n\n if s.present?\n sdes = s.title\n else\n sdes = \"Orphaned survey\"\n end\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"[#{sdes}] #{qdes}:\", params[:answer])\n\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n if !@created && answer\n answer.answer = params[:answer]\n if answer.save\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"Updated Answer: \", params[:answer])\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Answer was successfully updated.'\n format.html { redirect_to answer_url(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors.to_xml }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Answer was successfully updated.'\n format.html { redirect_to(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end",
"def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n @question.update_attributes(params[:question])\n render :json => @question.id if @question.save\n # respond_to do |format|\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def update\n @answer = Answer.find_by_key(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to answer_path(@answer.key), notice: 'Answer was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @answer=AttemptAnswer.find_by_id(params[:id])\n \n @answer.update_attribute(:user_answer, params[:user_answer])\n if @answer.user_answer = params[:user_answer]\n render json: @answer, status: :no_content\n\n else\n head(:unprocessable_entity)\n\n end\n end",
"def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n\n respond_to do |format|\n if @multiple_choice_question.update_attributes(params[:multiple_choice_question])\n format.html { redirect_to @multiple_choice_question, notice: 'Multiple choice question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @multiple_choice_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def update\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.where(:id => params[:id], :problem_set_id => params[:problem_set_id]).first\n @answers = Answer.where(:question_id => @question.id)\n\n ans = [:answer1, :answer2, :answer3, :answer4]\n respond_to do |format|\n if @question.update_attributes(params[:question])\n \n @answers.each_with_index do |a, i|\n a.answer = params[ans[i]][:answer]\n a.correct = params[ans[i]][:correct]\n a.save\n end\n\n if @answers.size < 4 and params[ans[@answers.size]][:answer] != \"\"\n for i in @answers.size..4\n if params[ans[i]][:answer] != \"\"\n a = Answer.new(params[ans[i-1]])\n a.question_id = @question.id\n a.save\n end\n end\n end\n format.html { redirect_to(edit_problem_set_question_path(@problem_set.id, @question.count), :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n if params[:question][:answer].present?\n @question.answered_by = current_user.id\n @question.answered_at = Time.zone.now if @question.answered_at.nil?\n end\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reply_answer.update(reply_answer_params)\n format.html { redirect_to @reply_answer, notice: 'Reply answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @reply_answer }\n else\n format.html { render :edit }\n format.json { render json: @reply_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Admin::Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Admin::Answer was successfully updated.'\n format.html { redirect_to(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n\trespond_to do |format|\n if @question.update(question_param)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\t\n end",
"def update\n respond_to do |format|\n if @submitted_answer.update(submitted_answer_params)\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @submitted_answer }\n else\n format.html { render :edit }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n if @user_answer.update_attributes(params[:user_answer])\n format.html { redirect_to @user_answer, notice: 'User answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quiz_answer.update(quiz_answer_params)\n format.html { redirect_to @quiz_answer, notice: 'Quiz answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quiz_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n if @my_question.update_attributes(params[:my_question])\n format.html { redirect_to @my_question, notice: 'My question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n if @textanswer.update_attributes(params[:textanswer])\n format.html { redirect_to @textanswer, notice: 'Textanswer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @textanswer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Do not support updating an answer for now\n # Once you have answered there is no return\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n if @answer.user == current_user\n @answer.approved = false\n end\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n @answer.create_activity :update, owner: current_user\n flash.now[:notice] = 'Answer was successfully updated.'\n format.html\n format.json { head :no_content }\n format.js { render \"answers/create\", :layout => false }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n format.js { render \"answers/create\", :layout => false }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @answer = Answer.find_by_uuid(params[:id])\n if [email protected]?\n redirect_to(answer_path(@answer.uuid), notice: 'You have already answered this question.') and return\n end\n\n @question = @answer.question\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to new_question_path, notice: 'questions was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: t('alert.question.update_success', default: 'Question was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @actual_answer.update(actual_answer_params)\n format.html { redirect_to @actual_answer, notice: 'Actual answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @actual_answer }\n else\n format.html { render :edit }\n format.json { render json: @actual_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n if (@question.question_type.short_text? || @question.question_type.open_ended_text?)\n path = survey_path(params[:survey_id])\n else\n path = survey_question_path(params[:survey_id],@question.id)\n end\n format.html { redirect_to path, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to model_customer_path(@model, @customer), notice: 'Model was successfully updated.' }\n format.json { render :show, status: :ok, location: @model }\n else\n format.html { render :edit }\n format.json { render json: @model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_answer_comment.update(api_v1_answer_comment_params)\n format.html { redirect_to @api_v1_answer_comment, notice: 'Answer comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_answer_comment }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_answer_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n if @student_answer.update_attributes(params[:student_answer])\n format.html { redirect_to @student_answer, notice: 'Student answer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end",
"def update\n @test_question = TestQuestion.find(params[:id])\n\n respond_to do |format|\n if @test_question.update_attributes(params[:test_question])\n format.html { redirect_to @test_question, :notice => 'Test question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @answer.update(answer_params)\n render json: { answer: view_show(@answer, @user_logged_in) }, status: :ok\n else\n @errors = translateModelErrors @question\n add_prefix_to_field @errors, \"answer:\"\n render json: { errors: @errors }, status: :bad_request\n end\n rescue ActionController::ParameterMissing\n @errors = [Error.new('missing_field', 'answer')]\n render json: { errors: @errors }, status: :bad_request\n end",
"def update\n respond_to do |format|\n if @selected_answer.update(selected_answer_params)\n format.html { redirect_to @selected_answer, notice: 'Selected answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @selected_answer }\n else\n format.html { render :edit }\n format.json { render json: @selected_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_answer.update(tipo_answer_params)\n format.html { redirect_to @tipo_answer, notice: 'Tipo answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_answer }\n else\n format.html { render :edit }\n format.json { render json: @tipo_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @icebreaker_answer.update(icebreaker_answer_params)\n format.html { redirect_to @icebreaker_answer, notice: 'Icebreaker answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @icebreaker_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quizzes_answer.update(quizzes_answer_params)\n format.html { redirect_to quiz_assessments_path(@quizzes_answer.assessment.quiz) }\n format.json { render :show, status: :ok, location: @quizzes_answer }\n else\n format.html { render :edit }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, :notice =>'Question was successfully updated.' }\n format.json { render :show, :status => :ok, :location => @question }\n else\n format.html { render :edit }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.74345315",
"0.7360197",
"0.7190411",
"0.70442027",
"0.70442027",
"0.7028407",
"0.7019093",
"0.6977991",
"0.69718504",
"0.6914882",
"0.6914467",
"0.6898194",
"0.68933165",
"0.68796027",
"0.6867792",
"0.6852608",
"0.68504494",
"0.68504494",
"0.68504494",
"0.67942584",
"0.6787712",
"0.6729326",
"0.67278224",
"0.67278224",
"0.67278224",
"0.6726923",
"0.6710359",
"0.66990787",
"0.66854334",
"0.66788423",
"0.667396",
"0.6662287",
"0.6646871",
"0.6631762",
"0.66216034",
"0.66216034",
"0.66216034",
"0.65988827",
"0.65969366",
"0.6596531",
"0.6585386",
"0.65579724",
"0.65556735",
"0.6553512",
"0.654153",
"0.6532284",
"0.65318286",
"0.65136355",
"0.65091336",
"0.65090483",
"0.65079355",
"0.6506773",
"0.6503185",
"0.6496257",
"0.6492562",
"0.6492111",
"0.6490581",
"0.6469946",
"0.6466663",
"0.6456249",
"0.6446001",
"0.6437286",
"0.64341956",
"0.6432149",
"0.6423559",
"0.6421404",
"0.6415862",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64035285",
"0.63900983",
"0.6381071",
"0.6378936",
"0.63658047",
"0.6357094",
"0.6350861",
"0.63494766",
"0.63476384",
"0.63420963",
"0.63357735",
"0.63352275",
"0.6324395",
"0.6322454",
"0.6320272",
"0.631797",
"0.6313354",
"0.63117105",
"0.6307857",
"0.6307857",
"0.6307857",
"0.6296519",
"0.6286536",
"0.6280592",
"0.6263717",
"0.62589055",
"0.6254193",
"0.62534815",
"0.62414294"
] | 0.0 | -1 |
DELETE /answers/1 DELETE /answers/1.json | def destroy
@assignment = @answer.assignment
@answer.destroy
respond_to do |format|
format.html { redirect_to @assignment }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end",
"def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = current_user.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_answer = Question::Answer.find(params[:id])\n @question_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to question_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t#@answer.destroy\n\t\t#respond_to do |format|\n\t\t#\tformat.html { redirect_to answers_url }\n\t\t#\tformat.json { head :no_content }\n\t\t#end\n\n\tend",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Answer deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n\n head :no_content\n end",
"def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = @question.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(question_answers_url(@question)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answerable = @answer\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @answerable }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n answer = Answer.find params[:id]\n \n if can? :delete, answer\n answer.destroy\n render json: { status: 200 }, status: 200\n else\n render json: { status: 403 }, status: 403\n end\n end",
"def destroy\n @v1_answer.destroy\n end",
"def destroy\n @answer = Admin::Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quiz_answer.destroy\n respond_to do |format|\n format.html { redirect_to quiz_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @submitted_answer = SubmittedAnswer.find(params[:id])\n @submitted_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to submitted_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_answer = UserAnswer.find(params[:id])\n @user_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to user_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_answer = SurveyAnswer.find(params[:id])\n @survey_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(survey_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n @survey_answer_item.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_answer_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @textanswer = Textanswer.find(params[:id])\n @textanswer.destroy\n\n respond_to do |format|\n format.html { redirect_to textanswers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: '回答を削除しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @m_answer.destroy\n respond_to do |format|\n format.html { redirect_to m_question_path(@m_question) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_respondent.destroy\n respond_to do |format|\n format.html { redirect_to answer_respondents_url, notice: 'Answer respondent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @given_answer.destroy\n respond_to do |format|\n format.html { redirect_to given_answers_url, notice: 'Given answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quick_answer = QuickAnswer.find(params[:id])\n @quick_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n @answer = @question.answers.find(params[:id])\n authorize! :destroy, @answer\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n\n @answer = @question.answers.find(params[:id])\n\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_answer.destroy\n respond_to do |format|\n format.html { redirect_to question_answers_url, notice: 'Question answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fake_answer.destroy\n respond_to do |format|\n format.html { redirect_to fake_answers_url, notice: 'Fake answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @[email protected]\n @question.update(cant_answers: @question.cant_answers - 1)\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to @question, notice: 'La respuesta fue borrada con exito' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to community_question_path(params[:community_id], params[:question_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @actual_answer.destroy\n respond_to do |format|\n format.html { redirect_to actual_answers_url, notice: 'Actual answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ask_answer = AskAnswer.find(params[:id])\n @ask_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(ask_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to models_url, notice: 'Model was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_url(params[:survey_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @icebreaker_answer.destroy\n respond_to do |format|\n format.html { redirect_to icebreaker_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @check_answer.destroy\n respond_to do |format|\n format.html { redirect_to check_answers_url, notice: 'Check answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asked_to_answer.destroy\n respond_to do |format|\n format.html { redirect_to asked_to_answers_url, notice: 'Asked to answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @online_answer = OnlineAnswer.find(params[:id])\n @online_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to online_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def destroy\n @answer.destroy\n\n respond_to_destroy(@answer, [@question, :answers])\n end",
"def destroy\n @tipo_answer.destroy\n respond_to do |format|\n format.html { redirect_to tipo_answers_url, notice: 'Tipo answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student_answer = StudentAnswer.find(params[:id])\n @student_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to student_answers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @survey_user_answer.destroy\n respond_to do |format|\n format.html { redirect_to survey_user_answers_url, notice: 'Survey user answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @submitted_answer.destroy\n respond_to do |format|\n format.html { redirect_to submitted_answers_url, notice: 'Submitted answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_record.destroy\n respond_to do |format|\n format.html { redirect_to answer_records_url, notice: 'Answer record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @selected_answer.destroy\n respond_to do |format|\n format.html { redirect_to selected_answers_url, notice: 'Selected answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to surveys_url, notice: \"Le questionnaire vient d'être détruit.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_tag.destroy\n respond_to do |format|\n format.html { redirect_to answer_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n #@question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studanswer.destroy\n respond_to do |format|\n format.html { redirect_to studanswers_url, notice: 'Studanswer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @pre_test_answer.destroy\n respond_to do |format|\n format.html { redirect_to pre_test_answers_url, notice: 'Pre test answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n p request.method\n @answer.destroy\n redirect_to @question, notice: t(:answer_destroy)\n\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n\tend",
"def destroy\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @multiple_choice_question.destroy\n\n respond_to do |format|\n format.html { redirect_to multiple_choice_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_learned.destroy\n respond_to do |format|\n format.html { redirect_to question_question_learneds_path(@question) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.create_activity :destroy, owner: @answer.user\n @answer.destroy\n\n flash.now[:notice] = 'Answer was successfully removed.'\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n format.js { render \"answers/destroy\", :layout => false }\n end\n end",
"def destroy\n @possible_answer.destroy\n respond_to do |format|\n format.html { redirect_to possible_answers_url, notice: 'Possible answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_answer_comment.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_answer_comments_url, notice: 'Answer comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @differentiator_answer = DifferentiatorAnswer.find(params[:id])\n @differentiator_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(differentiator_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_answer.destroy\n respond_to do |format|\n format.html { redirect_to user_answers_url, notice: 'User answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_answer.destroy\n respond_to do |format|\n format.html { redirect_to user_answers_url, notice: 'User answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :ok }\n end\n end"
] | [
"0.78710014",
"0.78369373",
"0.7804042",
"0.7804042",
"0.7779011",
"0.7779011",
"0.77608424",
"0.76613045",
"0.7621687",
"0.7613219",
"0.75670874",
"0.75555795",
"0.75216275",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.75009054",
"0.75009054",
"0.75009054",
"0.75009054",
"0.74951816",
"0.747214",
"0.74698025",
"0.7460743",
"0.7453996",
"0.73829204",
"0.73779947",
"0.73626924",
"0.7360606",
"0.73481834",
"0.734274",
"0.73328507",
"0.7327364",
"0.73267406",
"0.73226994",
"0.7317002",
"0.731659",
"0.730715",
"0.72834295",
"0.7277528",
"0.7270591",
"0.7266836",
"0.7260887",
"0.72577316",
"0.72577316",
"0.72382575",
"0.72338355",
"0.72305",
"0.7225048",
"0.72192615",
"0.72083884",
"0.7195624",
"0.7190657",
"0.71868026",
"0.7185067",
"0.7181885",
"0.7166849",
"0.71583235",
"0.71513003",
"0.714655",
"0.7143906",
"0.71183133",
"0.71046406",
"0.7103197",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.709673",
"0.7093732",
"0.70918494",
"0.70907754",
"0.70711756",
"0.70711756",
"0.7060938",
"0.7050638",
"0.7043618",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70420027",
"0.7040623",
"0.70389163",
"0.70300967",
"0.70286965",
"0.7027665",
"0.7027663",
"0.70262086",
"0.7026065",
"0.7020116",
"0.7015376",
"0.7012475",
"0.7012475",
"0.7012423"
] | 0.0 | -1 |
To import csv answers | def upgrade
#from submitted for early feedback to submitted for final feedback
@answer = Answer.find(params[:id])
@answer.submitted = true
@answer.is_final = true
@answer.submitted_at = Time.now
respond_to do |format|
if @answer.save
format.html {redirect_to assignment_path(@answer.assignment), notice: "Your draft was submitted to be graded"}
format.json { head :no_content }
format.js
else
format.html {redirect_to answer_path(@answer), alert: "We couldn't submit your assignment because " + @answer.errors.full_messages.join(". ")}
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_csv_full\n \n end",
"def import_csv_smart\n \n end",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end",
"def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end",
"def import(filename=\"import/study_units.csv\")\n require 'csv'\n CSV.foreach(filename, headers: true) do |row|\n @row = row.to_hash\n @study_unit = StudyUnit.where(study_id: id, name: @row[\"study_unit.name\"]).first ||\n StudyUnit.create(study_id: id, name: @row[\"study_unit.name\"])\n @logical_product = LogicalProduct.where(study_unit_id: @study_unit.id, name: @row[\"logical_product.name\"]).first ||\n LogicalProduct.create(study_unit_id: @study_unit.id, name: @row[\"logical_product.name\"])\n @concept = Concept.find_or_create_by_name(@row[\"concept.name\"])\n @variable_group = VariableGroup.where(logical_product_id: @logical_product.id, concept_id: @concept.id,\n name: @row[\"variable_group.name\"]).first ||\n VariableGroup.create(logical_product_id: @logical_product.id, concept_id: @concept.id,\n name: @row[\"variable_group.name\"], label: @row[\"variable_group.label\"])\n end\n end",
"def upload_csv\n datafile = params['csv-file']\n begin\n response = Request.post_request(URL_QUESTION, {\n questions: parse_json(datafile['tempfile'])\n })\n rescue\n redirect '/upload-csv'\n end\n @questions = []\n if response.success?\n data = Request.manage_response(response)\n data.each do |question|\n @questions << Question.new(question)\n end\n erb :table, layout: :session\n end\nend",
"def load_questions\n CSV.foreach(\"questions.csv\", { :col_sep => ' | ' }) do |row|\n key = row[0]\n value = row[1]\n RESPONSES[key] = value\n end\n puts \"Questions and responses loaded!\"\n puts \"\"\nend",
"def question_to_csv(array)\n #mete las preguntas y respuestas a el array\n @model.ask_csv(array[0],array[1])\n end",
"def load_file (filename = \"students.csv\")\n CSV.foreach(filename) do |row|\n name, cohort, food = row.map{ |element| element.chomp}\n add_student(name, cohort, food)\n end\nend",
"def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def import_from_csv\n puts 'Which file would you like to import?'\n file_path = gets.chomp\n CsvImporter.new(@database, file_path).import\n puts 'Import complete.'\n rescue FileNotFoundError\n puts 'The specified file was not found.'\n rescue CsvInvalidError => e\n puts e.message\n end",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def import_from_csv(file)\n entries = Keybox::Convert::CSV.from_file(file)\n entries.each do |entry|\n @db << entry\n end\n hsay \"Imported #{entries.size} records from #{file}.\", :information\n end",
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end",
"def import_learners_from_csv\n assessment_id = params[:user][:assessment_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n \n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/assessments/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/assessments/manage_learners/#{assessment_id.to_s}\")\n end\n end",
"def csv_import\n @parsed_file=CSV::Reader.parse(params[:dump][:file], \";\")\n n=0\n @parsed_file.each do |row|\n c=Peca.new\n c.produto_id=row[0]\n c.codigo=row[1]\n c.descr=row[2]\n c.acab=row[3]\n c.larg=row[4]\n c.alt=row[5]\n c.prof=row[6]\n c.qtde=row[7]\n c.total=row[8]\n c.custo=row[9]\n c.fita=row[10]\n c.pino=row[11]\n c.embal=row[12]\n c.mdf=row[13]\n c.mdf2=row[14]\n c.ferr=row[15]\n c.ferr2=row[16]\n if c.save\n n=n+1\n GC.start if n%50==0\n end\n flash.now[:message]=\"Arquivo de peças importado com sucesso, #{n} registros adicionados à tabela.\"\n end\n end",
"def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend",
"def generate_all_csv_answers\n generate_csv_answers(csv_answers_values)\n end",
"def initialize_csv\n CSV.open(\"results.csv\", \"wb\") do |csv|\n csv << [\"class\", \"title of course\", \"credits\"]\n end\nend",
"def import_course_learners_from_csv\n assessment_id = params[:user][:course_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n\n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/courses/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/courses/manage_learners/#{assessment_id.to_s}\")\n end\n end",
"def csv_import\n #n = 0\n CSV.foreach(params[:dump][:file].tempfile,:col_sep => ';', :encoding => 'ISO-8859-1') do |row|\n c = Ticket.new( :ano => row[0],\n :mes => row[1],\n :processo_numero => row[2],\n :solicitacao_data => row[3],\n :solicitacao_hora => row[4],\n :solicitacao_descricao => row[5],\n :solicitacao_regional => row[6],\n :solicitacao_bairro => row[7],\n :solicitacao_localidade => row[8],\n :solicitacao_endereco => row[9],\n :solicitacao_roteiro => row[10],\n :rpa_codigo => row[11],\n :rpa_nome => row[12],\n :solicitacao_microrregiao => row[13],\n :solicitacao_plantao => row[14],\n :solicitacao_origem_chamado => row[15],\n :latitude => row[16],\n :longitude => row[17],\n :solicitacao_vitimas => row[18],\n :solicitacao_vitimas_fatais => row[19],\n :processo_tipo => row[20],\n :processo_origem => row[21],\n :processo_localizacao => row[22],\n :processo_status => row[23],\n :processo_data_conclusao => row[24])\n c.save\n end\n redirect_to :action => \"index\" and return\n end",
"def datat_read\n \n #Read in the csv file\n @@datat_array = CSV.read(@@datat_path_specific)\n \n #Delete the row which contains the database title.\n @@datat_array.delete_at(0)\n \n ######################################\n #puts @@datat_array[2]\n #Verify the conversion has taken place\n #puts @database + \" CSV file converted\"\n ######################################\n \n end",
"def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end",
"def read_vote_csv(file_name)\n begin\n # @type [Array<Array<String>>]\n csv = CSV.read(file_name)\n rescue Errno::ENOENT\n warn format('Sorry, the file %<File>s does not exist', File: file_name)\n exit 1\n end\n csv.delete_if { |line| line.join('') =~ /^\\s*$/ } # delete blank lines\n csv\nend",
"def export_survey_answers(csv_survey_answers, survey_id)\n survey = Survey.find(survey_id)\n header = journal_csv_header.keys + ['follow_up'] + survey.variables.map {|v| v.var}\n \n csv_rows = csv_survey_answers.inject([]) do |rows,csa|\n puts \"csa.journal.nil? #{csa.inspect} #{csa.journal.inspect} sa: #{csa.survey_answer.inspect}\" if csa.journal.nil?\n\n journal_entry = JournalEntry.where(\n survey_answer_id: csa.survey_answer_id,\n center_id: csa.center_id, \n group_id: csa.team_id).first\n info = \n if !journal_entry.nil? && journal_entry.answer_info\n journal_entry.answer_info.split(\";\")\n elsif csa.journal_info\n csa.journal_info.split(\";;\")\n elsif csa.survey_answer\n csa.survey_answer.info.values\n else\n puts \"no answer_info found in journal_entry or survey_answer: #{csa.inspect} je: #{csa.journal_entry.inspect}\"\n [\"ingen info: sa_id: #{csa.survey_answer_id} csa: #{csa.inspect} \"]\n end\n\n if !csa || !csa.answer\n puts \"No csa: #{info.inspect}\"\n end\n rows << info + [FollowUp.to_value(csa.follow_up)] + (csa && csa.answer && csa.answer.split(';;') || [] )\n rows\n end\n\n output = CSV.generate(:col_sep => \";\", :row_sep => :auto, :encoding => 'utf-8') do |csv_output|\n csv_output << header\n csv_rows.each { |line| csv_output << line }\n end\n end",
"def save\n CSV.open(\"./db/gossip.csv\", \"ab\") do |csv|\n csv << [@author, @content]\n end\nend",
"def load_students(filename = \"students.csv\")\n # CSV.open(filename, \"r\") {|file|\n CSV.foreach(filename) do |line| # contains name, cohort\n # file.readlines.each do |line|\n name, cohort = line\n student_into_array(name, cohort.to_sym)\n end\n\nend",
"def export_survey_answers(csv_survey_answers, survey_id)\n survey = Survey.find(survey_id)\n header = journal_csv_header.keys + survey.variables.map {|v| v.var}\n \n csv_rows = csv_survey_answers.inject([]) do |rows,csa|\n header_values = csa.journal_info.split(';;')\n rows << header_values + csa.answer.split(';;')\n rows\n end\n\n output = FasterCSV.generate(:col_sep => \";\", :row_sep => :auto, :encoding => 'u') do |csv_output|\n csv_output << header\n csv_rows.each { |line| csv_output << line }\n end\n end",
"def load_data(csv)\n @hash.each do |sentence, count|\n csv << [sentence, count]\n end\n end",
"def parse_participant_import(csv_file, options, program, session, division)\n \n # This was initially designed to have a previewable import of participants\n # We are bypassing this step and going directly to import\n \n csv_data = FasterCSV.parse(csv_file.read)\n column_indices = map_importable_columns(csv_data[0])\n importable_participants = Array.new\n csv_data[1..csv_data.size-1].each do |csv_data_row|\n importable_participant = Hash.new\n IMPORTABLE_COLUMNS.each_with_index do |column_name, i|\n importable_participant[column_name.to_sym] = csv_data_row[column_indices[i]]\n end\n unless importable_participant[:name].blank?\n unless program.blank?\n importable_participant[:program] = program\n end\n unless session.blank?\n importable_participant[:session] = session\n end\n unless division.blank?\n importable_participant[:division] = division\n end\n importable_participants << importable_participant\n if options == \"load\"\n imported_participant = Participant.create_from_confirm_import(@hub, importable_participant)\n end\n end\n end\n importable_participants \n end",
"def csv(section = 'main', q='google',date='ytd',geo='')\n trend_params = {\"graph\"=>\"all_csv\", \"sa\" => \"N\"}\n trend_params[\"q\"] = q\n trend_params[\"date\"] = date\n if !geo || geo != ''\n trend_params[\"geo\"] = geo\n end\n\n data = @client.get_content(URI.parse(@url_Export), trend_params)\n # empty to return all data\n if section == ''\n return CSV.parse(data)\n end\n # split data into sections\n segments = data.split(\"\\n\\n\\n\")\n if section == 'main'\n section = ['Week', 'Year', 'Day','Month']\n else\n section = [section]\n end\n\n for x in segments do\n if section.include? x.split(',')[0].strip\n maindata = CSV.parse(x)\n return maindata\n end\n end\n end",
"def array_of_articles\n articles = []\n #binding.pry\n CSV.foreach('articles.csv', headers: true) do |row|\n articles << Article.new(row[\"id\"], row[\"title\"], row[\"description\"], row[\"url\"])\n end\n articles\nend",
"def getting_questions(file)\n CSV.foreach(file, :encoding => 'windows-1251:utf-8') do |row|\n @questions << [row[0],row[1],row[2],row[3],row[4],row[5]]\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows. Then create a has for each row.\n # Convert each row_hash to an entry by using add_entry method.\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def import_from_csv(file_name)\n kanbanery_tickets = extract_kanbanery_tickets_from_csv(file_name)\n @cards = extract_cards(kanbanery_tickets)\n end",
"def prepare_data\n data = CSV.read('input.csv', { col_sep: SEPARATOR })\n\n CSV.open('output.csv','wb') do |csv|\n data.each do |row|\n csv << prepare_row(row)\n end\n end\n\n rescue Errno::ENOENT\n puts 'No valid input.csv file present'\n end",
"def load_sites_from_csv(csv_path)\n CSV.foreach(csv_path, headers: true, encoding: 'BOM|UTF-8:UTF-8') do |row|\n trials = Trial.where(nct_id: row[0])\n trials.each do |trial|\n site = Site.create(row.to_hash.except('nct_id'))\n trial.sites << site\n end\n end\nend",
"def recommendation_csv_inputs csv_path\n valid_inputs = []\n\n CSV.foreach(csv_path, {headers: true, header_converters: :symbol}) do |row|\n row = row.to_h\n valid_inputs << row if valid_recommendation_hash?(row)\n end\n\n valid_inputs\n\n rescue => e\n valid_inputs\n end",
"def load()\n\tFile.open(\"instructors.csv\", \"r\") { |f|\n\t\tdata = f.read()\n\t\treturn data\n\t}\nend",
"def csv_convert(file)\n data_rows = []\n f = File.open(file, 'r')\n f.each_line do |line|\n data_rows.push line.chomp.split(',')\n end\n f.close\n return data_rows\nend",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @meals << Meal.new(row)\n end\n end",
"def import(file = nil)\n # A Hash containthe returning messages (one message for each row)\n # The values are Arrays containing the importing results for each row\n msg = {success: [], info: []} \n\n # If file is nil or blank (nil != blank)\n if file.nil? or file == \"\"\n msg[:success] << false \n msg[:info] << \"File name is nil or blank!\" \n return msg\n end\n\n # If the file is non-existant ...\n if file.instance_of?(String) and !(File.file?(file)) \n msg[:success] << false \n msg[:info] << \"File doesn't exist!\" \n return msg\n end\n\n # ??File submitted through html file doesn't exist!\n # http://guides.rubyonrails.org/form_helpers.html#uploading-files\n # 5.1 What Gets Uploaded\n # The object in the params hash is an instance of a subclass of IO.\n # Depending on the size of the uploaded file it may in fact be a StringIO\n # or an instance of File backed by a temporary file.\n if file.instance_of?(StringIO)\n msg[:success] << true \n msg[:info] << \"File is an instance of StringIO!\" \n elsif file.instance_of?(File) \n msg[:success] << true \n msg[:info] << \"File is an instance of File!\" \n else # ActionDispatch::Http::UploadedFile by html form \n msg[:success] << true \n msg[:info] << \"Must be the ActionDispatch::Http::UploadedFile type?\" \\\n \" #{file.class}\" \n end\n\n # Gets the file path\n file_path = file\n file_path = file.path unless file.instance_of?(String)\n #puts \"file_path = #{file_path}\"\n\n # TODO: Checks to see if the headers are correct\n # Imports row after row\n # CSV::Row is part Array & part Hash\n CSV.foreach(file_path, headers: true) do |row|\n vhash = row.to_hash # temporary VLAN record hash\n\n # Find FK lan_id\n # Note: Do not use Symbol :lan_name, Or it will not be found. Very weird!\n # Hence, use String instead of Symbol as the Hash key where necessary\n lan_id = find_lan_id(vhash[\"lan_name\"])\n \n # Go to the next row if an invalid lan_id was found \n unless lan_id > 0\n msg[:success] << false \n msg[:info] << \"Cannot find FK lan_id\" \n next\n end\n\n # Remove lan_name field from the row as it's not a field of table vlans\n vhash.delete(\"lan_name\")\n # and appends the FK lan_id\n vhash[\"lan_id\"] = lan_id\n #puts vhash\n \n # TODO: Need to feedback the result to the user in the future release\n s1 = \"lan_id: \" << lan_id.to_s # a temporary string\n tv = Vlan.new(vhash) # temporary VLAN record\n if tv.invalid? # invalid? triggers the model validation\n msg[:success] << false\n s1 << \", invalid Vlan\"\n else\n msg[:success] << true\n s1 << \", saved\"\n tv.save\n end\n\n msg[:info] << s1\n end\n return msg\n end",
"def csv(csv_file)\n Slacker.get_csv(csv_file)\n end",
"def csv_to_array(csv); end",
"def import(filename = 'yhd.csv')\n # Load CSV rows\n puts 'Attempting to load CSV...'\n data = CsvLoader.load_csv filename\n\n # Error if no data\n unless data\n puts 'ERROR: unable to load data from CSV. Terminating.'\n return\n end\n\n # Extract headers (first row)\n headers = data[0]\n\n puts 'Normalising header names...'\n norm_headers = normalise_headers headers\n\n # Define data rows as the rest of the CSV\n row_range = 1..data.size\n\n # Get data from each row (process it line at a time)\n puts 'Loading data...'\n load_data_from_rows(norm_headers, data[row_range])\n\n puts 'Creating relationships between definitions...'\n create_definition_associations\n\n puts 'Done!'\n\n @error_reporter.print\n end",
"def import_from_csv(file_name)\n # implementation\n csv_text = File.read(file_name)\n # the variable 'csv' is a table type object\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n \n # \n csv.each do |row|\n # create a hash type variable 'row_hash'\n row_hash = row.to_hash\n # use 'add_entry' to change 'row_hash' into 'Entry', also add the new Entry into AddressBook's entries\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end",
"def import_package_learners_from_csv\n assessment_id = params[:user][:package_id]\n unless params[:import][:excel].nil? or params[:import][:excel].blank? then\n @import = Import.new(params[:import])\n mime = (MIME::Types.type_for(@import.excel.path)[0])\n unless mime.nil? or mime.blank? then\n mime_obj = mime.extensions[0]\n #dont process further if the uploaded file is other than xls,xls,csv\n if (!mime_obj.nil? and !mime_obj.blank?) and (mime_obj.include? \"xls\" or mime_obj.include? \"xlsx\" or mime_obj.include? \"ods\" or mime_obj.include? \"csv\" ) then\n if @import.save!\n #check for virus\n if no_virus(@import.excel.path) then\n #If mime_obj is not csv only then create roo_instace\n unless mime_obj.include? \"csv\" then\n @roo = create_roo_instance(@import.excel.path,mime_obj)\n else\n #so, its a csv format\n @roo = \"csv format\"\n end\n #if the uploaded\n unless @roo == \"Upload correct excel format.\" then\n if @roo == \"csv format\" then\n lines = parse_csv_file(@import.excel.path)\n else\n lines = parse_excel_file_roo(@roo)\n end\n\n if lines.size > 0\n @import.processed = lines.size\n i = 1\n failed_to_upload = Array.new\n lines.each do |line|\n if valid_assign(params[:id])\n if valid_learners_excel_upload(line)\n else\n failed_to_upload << i\n end\n else\n flash[:learner_limit_exceeds] = \"You cannot assign more learners\"\n end\n i = i + 1\n end\n @import.save\n\n delete_csv(@import.excel.path)\n\n @import.destroy\n if params.include? 'from_assign_learners_page' then\n redirect_to(\"/packages/assign_learners/\" + assessment_id.to_s)\n else\n total_failed_to_upload = failed_to_upload.join(\",\")\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}?failed_to_upload=#{total_failed_to_upload}\")\n end\n else\n flash[:error] = \"CSV data processing failed.\"\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:virus_error] = \"The file is Infected with virus.\"\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:error] = 'CSV data import failed.'\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n flash[:upload_error] = 'Upload correct excel format.'\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n else\n redirect_to(\"/packages/manage_learners/#{assessment_id.to_s}\")\n end\n end",
"def save_as_csv\n CSV.open(\"./db/#{@name}.csv\", \"wb\") {|csv| @result_scrap.to_a.each {|elem| csv << elem} }\n end",
"def create_assignment_csv(args)\n [:path, :urls].each{|arg| args[arg] or raise Error::Argument, \"Missing arg '#{arg}'\" }\n headers = ['audio_url',\n 'project_id',\n 'unusual',\n 'chunk',\n 'chunk_hours',\n 'chunk_minutes',\n 'chunk_seconds',\n 'voices_count',\n (1 .. args[:voices].count).map{|n| [\"voice#{n}\", \"voice#{n}title\"]}\n ].flatten\n csv = args[:urls].map do |url|\n [url, \n local.id,\n args[:unusual].join(', '),\n interval_as_time_string,\n interval_as_hours_minutes_seconds.map{|n| (n == 0) ? nil : n },\n args[:voices].count,\n args[:voices].map{|v| [v[:name], v[:description]]}\n ].flatten\n end\n local.file(*args[:path]).as(:csv).write_arrays(csv, headers)\n local.file_path(*args[:path])\n end",
"def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort, hobby, country = line.chomp.split(\",\")\n add_student_to_array(name, cohort, hobby, country)\n end\n file.close\nend",
"def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend",
"def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend",
"def import\n CSV.foreach(@file.path, :converters => :all, :return_headers => false, :headers => :first_row) do |row|\n source, first_name, last_name, _, company, phone, *address = *row.to_hash.values\n\n street, city, state, zip, _ = *address\n address = Address.new(:street1 => street, :city => city, :state => state, :zipcode => zip)\n\n lead = Lead.new(:source => source, :first_name => first_name, :last_name => last_name,\n :company => company, :phone => phone)\n\n lead.first_name = \"FILL ME\" if lead.first_name.blank?\n lead.last_name = \"FILL ME\" if lead.last_name.blank?\n lead.access = \"Private\"\n lead.addresses << address\n\n lead.assignee = @assigned if @assigned.present?\n\n lead.save!\n end\n end",
"def import(rows)\n case rows\n when Array\n import_array(rows)\n when String\n labels, table = infer_csv_contents(rows, :headers => false)\n import(table)\n else\n raise ArgumentError, \"Don't know how to import data from #{rows.class}\"\n end\n true\n end",
"def load_csv\n CSV.foreach(@file_path) do |row|\n # Our CSV stores strings only - so we must initialize all our recipes\n recipe = Recipe.new(row[0],row[1])\n # We push them into the cookbook recipes array\n @recipes << recipe\n end\n end",
"def load_csv(csv_filepath)\n gifts = []\n CSV.foreach(csv_filepath) do |row|\n gifts << row[0] # Nosso csv só tem uma coluna\n end\n return gifts\nend",
"def load_csv\n options = { headers: :first_row, header_converters: :symbol }\n\n CSV.foreach(@csv_path, options) do |row|\n row[:id] = row[:id].to_i\n row[:price] = row[:price].to_i\n @elements << Meal.new(row)\n end\n @next_id = @elements.empty? ? 1 : @elements.last.id + 1\n end",
"def parse_csv\n if self.csv_file.present?\n csv_text = Paperclip.io_adapters.for(self.csv_file).read\n csv = CSV.parse(csv_text, :headers => false)\n\n csv_columns = ['l', 'r', 'units']\n\n csv_to_save = {}\n\n csv.each_with_index do |row, i|\n if i == 0\n csv_to_save['weight'] = row[1].split(':')[1] # string is like Weight:201, only want the number\n csv_to_save['shoe_size'] = row[2].split(':')[1] # string is like Shoe Size:9\n elsif i >= 3\n row.each_with_index do |field, j|\n if j >= 1 and !field.blank?\n csv_to_save[generate_csv_row_key(csv_columns, row, i, j)] = field\n end\n end\n end\n end\n\n # Check to see if any of the fields are nil, then we must have not received the correct file\n is_clean = true\n csv_to_save.each do |key, val|\n if val.nil?\n is_clean = false\n break\n end\n end\n\n CsvFile.create!(csv_to_save) if is_clean\n end\n end",
"def get_msan_csv_list\n filename = '../config/msan_alternative_imput.csv'\n result = []\n\n # The [1 .. -1] argument bypass the head row\n CSV.read(filename, 'r', col_sep: ';')[1..-1].each do |row|\n result << { model: row[0], dms_id: row[1], rin: row[2], ip: row[3] }\n end\n\n result\n end",
"def import\n @uploaded_io = params[:q].read()\n Hash.from_xml(@uploaded_io).each do |key, value|\n value.each do |column|\n column.delete(\"id\")\n puts column\n @quote_db = QuoteDb.new(column)\n \n @quote_db.save \n \n \n #puts params[:column][:quote] \n end\n \n end\n \n end",
"def read_scores_from\n teams_data = []\n\n CSV.foreach('scores.csv', headers: true, header_converters: :symbol) do |row|\n teams_data << row.to_hash\n end\n teams_data\nend",
"def read_in_csv_data(csv_file_name)\n begin\n CSV.foreach(csv_file_name, headers: true) do |row|\n @songs << Song.new(row['name'], row['location'])\n end\n rescue Exception\n @songs = nil\n end\n @songs\n end",
"def reprocess_csv(file)\n raw = open(file).read.force_encoding(\"UTF-8\")\n csv = CSV.parse(raw, headers: true, header_converters: :symbol)\n csv.each do |row|\n data = row.to_hash.each { |k, v| v = v.to_s.gsub(/[[:space:]]+/, ' ').strip }\n data[:area_id] = data[:area].downcase\n data[:gender] = data[:gender].downcase\n data[:term] = '2013'\n %i(num).each { |i| data.delete i }\n ScraperWiki.save_sqlite([:name, :name, :term], data)\n end\nend",
"def parse\r\n\t\tCSV.foreach(self.filepath) {|row| @list << row}\r\n\t\[email protected]!\r\n\tend",
"def modelo_productos_cliente\n array_products=[]\n CSV.foreach($productos,headers:true) do |row|\n array_products << [row['producto'],row['precio'],row['num_existencia']]\n end\n array_products\nend",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true)\n # Iterate over the table object's rows\n csv.each do |row|\n # Create a hash for each row\n row_hash = row.to_hash\n # Convert each row_hash to an Entry by using add_entry method\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n\n # Get the number of items parsed by calling the count method\n return csv.count\n end",
"def import_csv_files(users_csv_filename, term_enrollment_csv_files)\n import_proxy = CanvasSisImportProxy.new\n if import_proxy.import_users(users_csv_filename)\n logger.warn(\"User import succeeded\")\n term_enrollment_csv_files.each do |term_id, csv_filename|\n if import_proxy.import_all_term_enrollments(term_id, csv_filename)\n logger.warn(\"Enrollment import succeeded\")\n end\n end\n end\n end",
"def new_qa(category_input_push)\n\n category = category_input_push\n link = \"#{category}.csv\"\n\n puts \"Please input the question\"\n print \"> \"\n question = $stdin.gets.chomp\n puts \"Please input the answer\"\n print \"> \"\n answer = $stdin.gets.chomp\n # skip past the headers by setting the headers to true\n CSV.open(link, 'a+') do |csv_file|\n # add a row to the csv file\n csv_file << [question, answer]\n end\n new_qa_opt\nend",
"def perform(list, file)\n list.import_csv(file)\n end",
"def save_as_csv\n h = get_townhall_urls\n CSV.open('db/emails.csv', 'wb', write_headers: true, headers: ['Mairies du 95', 'Email']) do |csv|\n h.to_a.each { |elem| csv << elem }\n end\n puts \"\\nTon fichier csv est prêt\\n\\n\"\n Index.new.index\n end",
"def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort, hobbies = line.strip.split(',')\n add_student({name: name, cohort: cohort.to_sym, hobbies: hobbies})\n end\n file.close\nend",
"def parse_final_votes\n csv_read 'HYY09_vaalit.exe_final_votes.csv'\n end",
"def parse_csv\n i=0\n output_matrix = []\n trim_return_carriage(fulltext).each_line do |line|\n 5.times { |i| avoid_commas_in_special_strings(line) }\n output_matrix << trim_line_ends(line).split(delimiter) unless i == 0\n i+=1\n end\n output_matrix.each do |rec|\n temp_hsh = {}\n (0..rec.size-1).each do |i|\n temp_hsh.merge! object_attributes[i] => rec[i]\n end\n @output_table_object << temp_hsh\n end\n\n output_table_object\n end",
"def read_data\n\t\t@testers_data = CSV.read(\"data/testers.csv\")\n\n\t\t@testers_device_data = CSV.read(\"data/tester_device.csv\")\n\n\t\t@devices_data = CSV.read(\"data/devices.csv\")\n\n\t\t@bugs_data = CSV.read(\"data/bugs.csv\")\n\tend",
"def import_button(**opt)\n opt[:accept] = 'text/csv,text/comma-separated-values'\n form_button(:import, **opt, type: :file)\n end",
"def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend",
"def import\n pp params\n\n uploaded = params[:csv]\n count = Device.import uploaded\n redirect_to '/devices', notice: \"#{count} devices imported\"\n end",
"def modelo_start\n $productos = 'Productos.csv'\n $clientes = 'Usuarios.csv'\n $vendedores = 'Vendedores.csv'\nend",
"def load(contents, opts={})\n table = infer_csv_contents(contents, opts)\n return nil unless contents\n table.each do |row|\n self.add(*row)\n end\n end",
"def import\n CSV.new(open(uri), headers: :first_row).each_with_index do |csv_row, i|\n begin\n create_departure(csv_row: csv_row)\n rescue => e\n # this is a catch all for all the types of parsing errors that could\n # occur above\n csv_logger.info(\n I18n.t('import_exception', scope: LOCALE, row_number: i)\n )\n csv_logger.error(e)\n end\n end\n end",
"def import_csv\n if current_admin.present? \n updated_user_id = current_admin.id\n create_user_id = current_admin.id\n else\n updated_user_id = current_user.id\n create_user_id = current_user.id\n end\n if (params[:file].nil?)\n redirect_to upload_csv_posts_path, notice: Messages::REQUIRE_FILE_VALIDATION \n elsif !File.extname(params[:file]).eql?(\".csv\")\n redirect_to upload_csv_posts_path, notice: Messages::WRONG_FILE_TYPE \n else\n error_msg = PostsHelper.check_header(Constants::HEADER,params[:file])\n if error_msg.present?\n redirect_to upload_csv_posts_path, notice: error_msg\n else \n Post.import(params[:file],create_user_id,updated_user_id)\n redirect_to posts_path, notice: Messages::UPLOAD_SUCCESSFUL\n end\n end\n end",
"def import\n\n output = ''\n\n country_src = 'tmp/Countries.txt'\n \n rs = File.open(country_src)\n rs.gets # <-- remove first line (columns header) \"CountryID:Title\"\n countries = {}\n City.delete_all\n Region.delete_all\n Country.delete_all\n\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n countries[row[0]] = {:name => row[1], :regions => {}, :model => nil}\n c = Country.new\n c.iso = row[0]\n c.name = row[1]\n c.save\n countries[row[0]][:model] = c\n end\n\n regions_src = 'tmp/Regions.txt'\n \n rs = File.open(regions_src)\n rs.gets # <-- remove the 1st line (header row) #CountryID:RegionID:Title\n while (row = rs.gets) \n row = row.split(':')\n row[0].gsub!(/\\n/, '')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n c = countries[row[0]][:model]\n r = Region.new\n r.iso = row[1]\n r.country_id = c.id\n\n # magic trick to ignore UTF-8 chars for now.\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n r.name = ic.iconv(row[2] + ' ')[0..-2]\n r.save\n countries[row[0]][:regions][row[1]] = r\n\n end\n\n cities_src = 'tmp/Cities.txt'\n \n rs = File.open(cities_src)\n rs.gets # <-- remove 1st row (header) #CountryID:RegionID:Title:Latitude:Longitude\n while(row = rs.gets)\n row = row.split(':')\n row[1].gsub!(/\\n/, '')\n row[2].gsub!(/\\n/, '')\n row[3].gsub!(/\\n/, '')\n row[4].gsub!(/\\n/, '')\n \n r = countries[row[0]][:regions][row[1]]\n if (!r.nil?) \n c = City.new\n ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')\n c.name = ic.iconv(row[2] + ' ')[0..-2] \n c.region_id = r.id\n c.lat = row[3]\n c.lng = row[4]\n c.save\n end\n end\n\n output += '<h1>Import complete</h1>'\n render(:text => output, :layout => false)\n end",
"def import_data path, file_type\n if file_type == :csv\n csv_parse(path).each { |params| Product.new(params).save }\n elsif file_type == :xls\n #xls_parse(path)\n end\nend",
"def from_csv(filename)\n @successes = []\n @problems = []\n @unfound_vita_partners = []\n\n @headers = CSV.foreach(filename).first\n return unless headers_aligned? == true\n\n data = CSV.read(filename, headers: true)\n\n state_routing_pairs = generate_state_routing_pairs(data)\n\n create_records_for_state_routing_pairs(state_routing_pairs)\n\n print_script_messages\n true\n end",
"def do_user_status_csv_import\n if params[:import].nil?\n flash[:message] = 'Please upload a csv file'\n redirect_to admin_user_status_csv_import_path\n return\n end\n file = CSV.parse(params[:import][:csv].read)\n @failures = []\n file.each do |row|\n user_id = row[0]\n # If the user id isn't actually a number, skip this row\n # because that means it is probably a header or a blank line\n # http://stackoverflow.com/questions/10577783/ruby-checking-if-a-string-can-be-converted-to-an-integer\n begin\n user_id = Integer user_id\n rescue\n next\n end\n\n begin\n user = User.find(user_id)\n user.exclude_from_reporting = row[1]\n user.relationship_manager = row[2]\n user.associated_program = row[3]\n user.active_status = row[4]\n user.save!\n rescue\n @failures << user_id\n end\n end\n end",
"def create_movies_db(csv)\nmovies_db = []\n\nCSV.foreach(csv, headers: true, header_converters: :symbol) do |row|\nmovie = {\n id: row[:id],\n title: row[:title],\n year: row[:year],\n synopsis: row[:synopsis],\n rating: row[:rating],\n genre: row[:genre],\n studio: row[:studio]\n }\n\n movies_db << movie\n end\n movies_db\n\nend",
"def load_students(students)\n # open file for read\n file = File.open(\"students.csv\", \"a+\")\n # iterate over lines and read student name and cohort\n file.readlines.each do |line|\n name, cohort = line.chomp.split(\",\")\n students << {name: name, cohort: cohort.to_sym}\n end\n file.close\nend",
"def initialize(csv_file_path)\n # take recipe from csv file\n @csv_file_path = csv_file_path\n @recipes = []\n parse\n end",
"def uploadCSV(arr_of_arrs)\n arr_of_arrs.each do |row|\n wasSaved, keywrd = Keyword.add_keyword_to_database(row[0])\n if wasSaved\n for index in 1..row.size\n Synonym.record_synonym(row[index], keywrd.id)\n end\n end\n end\n end",
"def uploadCSV(arr_of_arrs)\n arr_of_arrs.each do |row|\n wasSaved, keywrd = Keyword.add_keyword_to_database(row[0])\n if wasSaved\n for index in 1..row.size\n Synonym.record_synonym(row[index], keywrd.id)\n end\n end\n end\n end",
"def csv_to_array(file)\n @recipes = []\n CSV.foreach(file){|row| @recipes << Recipe.new(row[0], row[1].to_i, row[2].to_i, row[3].to_i)}\n end",
"def entry_to_csv index\n\t\tcsv_string = \"\\\"\" + @year + \"\\\",\\\"\" + @edition + \"\\\",\" + contents[index].to_csv\n\t\treturn csv_string\n\tend",
"def getData()\n CSV.foreach(\"SkaterProjections.csv\", :headers => true) do |row|\n @skater_data.push(row)\n end\n \n CSV.foreach(\"GoalieProjections.csv\", :headers => true) do |row|\n @goalie_data.push(row)\n end\nend",
"def checkpoints_from_csv(fname)\n begin\n lines = CSV.read(fname)\n header = lines.shift\n # check header\n if header == Checkpoint::CsvColumns\n # import data\n lines.each do |line|\n checkpoints.create(\n location: Location.find_by_name_and_image_id(line[0], Image.id_from_filename(line[1])),\n part_id: Part.find_or_create_by_number(number: line[2], kind: line[3], description: line[4]).id)\n end\n else\n puts \"ERROR: Expecting ''#{Item::CsvColumns.join(',')}' on '#{fname}'. Skipping import of Checkpoints.\"\n false\n end\n rescue Errno::EISDIR\n puts \"ERROR: '#{fname}' is a directory. Checkpoints not imported.\"\n rescue Errno::EACCES\n puts \"ERROR: Permission denied on '#{fname}'. Checkpoints not imported.\"\n rescue Errno::ENOENT\n puts \"ERROR: '#{fname}' not found. Checkpoints not imported.\"\n end\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def load_csv (csv_file)\n\tret = []\n\tFile.open(csv_file, \"r\") do |f|\n\t\tf.each_line do |line|\n\t\t\t#puts line\n\t\t\tret << line.split(';')\n\t\tend\n\tend\n\treturn ret\nend",
"def loadFromCSV\n \tcsv_text = File.read(Rails.root.join('app/assets/files/vocab.txt'))\n\tvocab = []\n\tparsed = CSV.parse(csv_text, :col_sep => \";\")\n\tparsed.each do |w|\n\t\tback = w[0].split('|') #back\n\t\tfront = w[1].split('|') #front\n\t\tvocab << {\"back\" => back, \"front\" => front}\n\tend\n\tvocab\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows, create a string for each row, and convert each row to a Client by using the create_client method.\n csv.each do |row|\n name, facebook_id, twitter_handle = row.to_s.split(\",\").map(&:chomp)\n create_client(name, facebook_id, twitter_handle)\n end\n end"
] | [
"0.7265433",
"0.6926908",
"0.64697284",
"0.64539534",
"0.6453542",
"0.64080936",
"0.6397478",
"0.63435084",
"0.6275576",
"0.62676257",
"0.62381655",
"0.6237344",
"0.62215894",
"0.62123317",
"0.62077856",
"0.6183603",
"0.61436254",
"0.61054975",
"0.6105216",
"0.61006325",
"0.6082002",
"0.607979",
"0.6070697",
"0.60392666",
"0.6037453",
"0.60361195",
"0.6034086",
"0.6031187",
"0.602374",
"0.60124224",
"0.5999957",
"0.5999093",
"0.5990298",
"0.59832865",
"0.59830016",
"0.59776264",
"0.5976786",
"0.5964031",
"0.5959885",
"0.5958995",
"0.5950835",
"0.5950707",
"0.59485936",
"0.5937132",
"0.5932559",
"0.5924983",
"0.5916963",
"0.59127593",
"0.5912268",
"0.59089667",
"0.5906149",
"0.5897989",
"0.589774",
"0.5891145",
"0.58903515",
"0.58871794",
"0.58834445",
"0.58701116",
"0.58693814",
"0.58648205",
"0.58644545",
"0.58542025",
"0.58513016",
"0.5849526",
"0.5828886",
"0.5817858",
"0.5816384",
"0.581024",
"0.5808266",
"0.58075935",
"0.5803265",
"0.57973963",
"0.5796994",
"0.57966375",
"0.57945985",
"0.57930523",
"0.57900465",
"0.5789444",
"0.5787154",
"0.5775184",
"0.57740766",
"0.5771321",
"0.5765574",
"0.576451",
"0.5763138",
"0.5745179",
"0.5743709",
"0.5740926",
"0.5727964",
"0.5726163",
"0.57190436",
"0.57104677",
"0.57104677",
"0.5710443",
"0.57073045",
"0.57038087",
"0.5698675",
"0.56956583",
"0.5695031",
"0.56919503",
"0.5691796"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_answer
@answer = Answer.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def answer_params
params.permit(:assignment_id)
params.permit(:page)
params.require(:answer).permit(:response, :revision_name, :revision_list, :question_id, :user_id, :predicted_score, :current_score, :evaluations_wanted, :total_evaluations, :confidence, :assignment_id,
:reflection, :review_request, :revision_email_sent, :useful_feedback)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
attr_reader attr_writer attr_accessor (both read and write) | def drank_blood_today
return @drank_blood_today
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end",
"def attr_accessor(*fields)\n attr_reader *fields\n attr_writer *fields\n end",
"def attr_accessor_sybling(method)\n attr_reader?(method) ? to_attr_writer(method) : to_attr_reader(method)\n end",
"def internal_attr_accessor(*syms)\n internal_attr_reader(*syms)\n internal_attr_writer(*syms)\n end",
"def attr_internal_accessor(*attrs)\n attr_internal_reader(*attrs)\n attr_internal_writer(*attrs)\n end",
"def attr_internal_accessor(*attrs)\n attr_internal_reader(*attrs)\n attr_internal_writer(*attrs)\n end",
"def attr_internal_accessor(*attrs)\n attr_internal_reader(*attrs)\n attr_internal_writer(*attrs)\n end",
"def mattr_accessor(*syms)\n mattr_reader(*syms) + mattr_writer(*syms)\n end",
"def attr_reader(*)\n end",
"def define_attr_accessor(attr)\n attr_accessor(attr)\n end",
"def attr_accessor(name)\n attr_reader(name)\n attr_writer(name)\n nil\n end",
"def attr_reader(sym, *more) end",
"def attr_writer(sym, *more) end",
"def bits_attr_accessor name\n class_eval \"def #{name}; self.attributes[#{name.inspect}]; end;\", __FILE__, __LINE__\n class_eval \"def #{name}=(val); self.attributes[#{name.inspect}]=val; end;\", __FILE__, __LINE__\n end",
"def define_attr_reader(name)\n define_method(name) do\n instance_variable_get(\"@#{name}\")\n end\n end",
"def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter = match[1], !match[2].blank?\n if setter\n write_attribute(attribute, args.first)\n else\n read_attribute(attribute)\n end\n else\n super(meth, *args, &blk)\n end\n end",
"def definition\n case @rw\n when 'RW' then 'attr_accessor'\n when 'R' then 'attr_reader'\n when 'W' then 'attr_writer'\n end\n end",
"def accessor\n @@accessor ||= nil\n @@accessor\n end",
"def delegate_object_reader_method; end",
"def md_accessor(*accessors)\n md_reader(*accessors)\n md_writer(*accessors)\n end",
"def onetime_attr_accessor(_name)\n attr_reader(_name)\n onetime_attr_writer(_name)\n end",
"def vcattr_accessor(*syms) # :nodoc:\r\n vcattr_reader *syms\r\n vcattr_writer *syms\r\n end",
"def cattr_accessor(*syms)\n cattr_reader(*syms) + cattr_writer(*syms)\n end",
"def cattr_accessor(*syms)\n cattr_reader(*syms)\n cattr_writer(*syms)\n end",
"def attr(symbol, writable=false) end",
"def instance_write(attr, value)\n setter = :\"#{@name_string}_#{attr}=\"\n instance.send(setter, value) if instance.respond_to?(setter)\n end",
"def attr_accessor(sym, *more) end",
"def assert_attr_accessor(obj, method)\n assert_attr_reader obj, method\n assert_attr_writer obj, method\nend",
"def attr_writer(*fields)\n check_fields(fields)\n added_fields = jiak.data.writable(*fields)\n added_fields.each do |field|\n class_eval <<-EOM\n def #{field}=(val)\n @jiak.object.data.#{field} = val\n self.class.do_auto_update(self)\n end\n EOM\n end\n nil\n end",
"def serializable_attr_accessor(*syms)\n attr_accessor(*syms)\n attribute_keys.push(*syms)\n end",
"def define_accessor_methods(mod)\n define_reader_method(mod)\n define_writer_method(mod)\n self\n end",
"def method_missing(method_name, *args, &block)\n # Check if the method missing an \"attr=\" method\n raise unless method_name.to_s.end_with?(\"=\")\n\n setter = method_name\n getter = method_name.to_s.slice(0...-1).to_sym\n instance_var = \"@#{getter}\".to_sym\n\n # attr_writer\n define_singleton_method(setter) do |new_val|\n instance_variable_set(instance_var, new_val)\n end\n\n # attr_reader\n define_singleton_method(getter) { instance_variable_get(instance_var) }\n\n # Ignores all arguments but the first one\n value = args[0]\n\n # Actually sets the value on the instance variable\n send(setter, value)\n rescue MethodMissing\n # Raise error as normal, nothing to see here\n super(method_name, *args, &block)\n end",
"def set_attr_with_readers! hash\n hash.each_pair { |symbol, value|\n instance_variable_set \"@#{symbol}\", value\n singleton_class.class_exec { attr_reader symbol }\n }\n end",
"def field_accessors(name)\n field_reader(name)\n attr_writer(name)\n end",
"def metaattr_accessor(*meths)\n metaclass.instance_eval{attr_accessor(*meths)}\n end",
"def attr_writer(*args)\n sym_args=args_to_sym(args)\n sym_args.each do |value|\n self.instance_eval(\"def #{value}=(arg); @#{value}=arg;end;\")\n end\n \n end",
"def initialize\n @attribute = 'truite'\n @accessor = 'pouet'\n end",
"def key_accessor *keys\n key_writer *keys\n key_reader *keys\n end",
"def define_accessors\n self.metadata.properties_and_identity.each do |name, _|\n self.model.send :attr_accessor, name.downcase\n end\n end",
"def my_attr_reader(*args)\n\targs.each do |a|\n\t\tself.class_eval do\n\t\t\tinstance_variable_set \"@#{a}\", nil\n\t\t\tdefine_method a do\n\t\t\t\tinstance_variable_get \"@#{a}\"\n\t\t\tend\n\t\tend\n\tend\nend",
"def attr_writer(name)\n meth = Rubinius::AccessVariable.set_ivar name\n @method_table.store \"#{name}=\".to_sym, meth, :public\n Rubinius::VM.reset_method_cache name\n nil\n end",
"def mattr_writer(*syms, &proc)\n receiver = self\n options = syms.extract_options!\n syms.each do |sym|\n raise NameError.new('invalid attribute name') unless sym =~ /^[_A-Za-z]\\w*$/\n class_exec do\n define_singleton_method \"#{sym}=\" do |obj|\n class_variable_set(\"@@#{sym}\", obj)\n end\n end\n\n unless options[:instance_writer] == false || options[:instance_accessor] == false\n class_exec do\n define_method \"#{sym}=\" do |obj|\n receiver.class_variable_set(\"@@#{sym}\", obj)\n end\n end\n end\n send(\"#{sym}=\", proc.call) if proc\n end\n end",
"def attr_reader(*vars)\n super *(add_tracked_attrs(true, false, *vars))\n end",
"def private_attr_reader(*method_names)\n attr_reader(*method_names)\n private(*method_names)\n end",
"def key_attr_reader(key)\n define_method key do\n self[key]\n end\n end",
"def sig_attr_accessor(*attr_names, &block)\n sig_attr_reader(*attr_names, &block)\n sig_attr_writer(*attr_names, &block)\n end",
"def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end",
"def representable_property(name, options={})\n attr = add_representable_property(name, options)\n \n attr_reader(attr.getter) unless options[:accessors] == false\n attr_writer(attr.getter) unless options[:accessors] == false\n end",
"def create_reader(klass, member); end",
"def attr_reader(name)\n meth = Rubinius::AccessVariable.get_ivar name\n @method_table.store name, meth, :public\n Rubinius::VM.reset_method_cache name\n nil\n end",
"def create_accessors(field_name)\n define_singleton_method(field_name) { read_attribute(field_name) }\n define_singleton_method(\"#{field_name}=\") { |value| write_attribute(field_name, value) }\n end",
"def attr_class_accessor(*args)\n\t\targs.each{|arg|\n\t\t\tclass_eval %(\n\t\t\t\tdef #{arg}; self.class.#{arg}; end\n\t\t\t\tdef #{arg}=(v); self.class.#{arg} = v; end\n\t\t\t)\n\t\t}\n\tend",
"def initialize_visibility\n default_accessor = @options.fetch(:accessor)\n @reader_visibility = @options.fetch(:reader, default_accessor)\n @writer_visibility = @options.fetch(:writer, default_accessor)\n end",
"def parse_attr_accessor(context, single, tk, comment)\n line_no = tk[:line_no]\n\n args = parse_symbol_arg\n rw = \"?\"\n\n tmp = RDoc::CodeObject.new\n read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS\n # TODO In most other places we let the context keep track of document_self\n # and add found items appropriately but here we do not. I'm not sure why.\n return if @track_visibility and not tmp.document_self\n\n case tk[:text]\n when \"attr_reader\" then rw = \"R\"\n when \"attr_writer\" then rw = \"W\"\n when \"attr_accessor\" then rw = \"RW\"\n else\n rw = '?'\n end\n\n for name in args\n att = create_attr context, single, name, rw, comment\n att.line = line_no\n end\n end",
"def attributes(*args)\n attr_accessor(*args)\n end",
"def singleton_attr_reader( *names )\n\n singleton_class.instance_eval { attr_reader *names }\n \n return self\n\n end",
"def accessor(*args)\n attr_accessor(*args)\n args\n end",
"def name\n return @name\nend\ndef age\n return @age\nend\n#setters, allows you to change or set something\ndef name=(name)\n @name = name\nend",
"def set_accessor\n @accessor = Accessor.find(params[:id])\n end",
"def set_accessor\n @accessor = Accessor.find(params[:id])\n end",
"def attr_reader?(name)\n (instance_methods | private_instance_methods).include?(name)\n end",
"def singleton_attr_writer( *names )\n\n singleton_class.instance_eval { attr_writer *names }\n \n return self\n\n end",
"def set_visibility\n default_accessor = @options.fetch(:accessor, self.class::DEFAULT_ACCESSOR)\n @reader_visibility = @options.fetch(:reader, default_accessor)\n @writer_visibility = @options.fetch(:writer, default_accessor)\n end",
"def metaattr_reader(*meths)\n metaclass.instance_eval{attr_reader(*meths)}\n end",
"def inject_acl_object_getter_setter(method_name)\n inject_acl_object_check(method_name, :read)\n inject_acl_object_check(\"#{method_name}=\",:write)\n end",
"def mattr_writer(*syms)\n syms.each{|sym|\n class_eval(<<-EOS, __FILE__, __LINE__)\n @@#{sym} = nil if !defined?(@@#{sym})\n \n def self.#{sym}=(obj)\n @@#{sym} = obj\n end\n def #{sym}=(obj)\n @@#{sym} = obj\n end\n EOS\n }\n end",
"def add_attr_accessors(p_attributes, p_type = :both)\n p_type.to_h.assert_valid_keys(:read, :write, :both) #validate type\n\n #loop through the accessors to be added\n Array(p_attributes).flatten.each do |k|\n\n #lets set the write reader if needed\n if [:read, :both].include?(p_type) && !self.respond_to?(k.to_s) #is there already one defined\n self.class.send(:define_method, k.to_sym) do #lets create one as requested\n instance_variable_get('@' + k.to_s) # equivalent of an attr_reader is created here\n end\n end\n\n # Lets set the write accessor if needed\n if [:write, :both].include?(p_type) && !self.respond_to?(\"#{k.to_s}=\") #is there already one defined\n self.class.send(:define_method, \"#{k}=\".to_sym) do |value| #lets create one as requested\n instance_variable_set(\"@\" + k.to_s, value) # equivalent of an attr_writer is created here\n end\n end\n\n end # end p_attributes..do\n self #all done return self\n end",
"def define_reader_method(mod)\n reader_method_name = name\n attribute = self\n\n mod.send(:define_method, reader_method_name) { attribute.get(self) }\n mod.send(reader_visibility, reader_method_name)\n\n self\n end",
"def state_accessor(*names, &initializer)\n state_writer(*names)\n state_reader(*names, &initializer)\n end",
"def cattr_writer(*fields)\n metaclass.send :attr_writer, *fields\n end",
"def attr_reader(*fields)\n check_fields(fields)\n added_fields = jiak.data.readable(*fields)\n added_fields.each do |field|\n class_eval <<-EOM\n def #{field}\n @jiak.object.data.#{field}\n end\n EOM\n end\n nil\n end",
"def set_attributes_to_reader\n if [email protected]?\n @attributes.each { |ele|\n self.class.__send__(:attr_reader, ele.downcase)\n }\n end\n\nend",
"def attr_reader_init(*symbols)\n generate_attr_reader(symbols)\n generate_initializer(symbols)\n end",
"def dsl_accessor( attrname )\n\t\t\tdefine_method( attrname ) do |arg=nil|\n\t\t\t\tinstance_variable_set( \"@#{attrname}\", arg ) unless arg.nil?\n\t\t\t\treturn instance_variable_get( \"@#{attrname}\" )\n\t\t\tend\n\t\tend",
"def getters; end",
"def username #for each attribute of a class you have two methods a reader and a writer method (same as a gettter and setter methods)\n return @username #the variable \"@username\" is ONLY created when the WRITER, NOT the reader is called; it's created when lana.username - \"lana\" is called ; if the reader is called and the variable is not in the initialize method and the writer method has not been called the program will give you an error; the @symbol is called an instance variable\n end",
"def accessors\n self.class.accessors\n end",
"def cattr_accessor(*fields)\n metaclass.send :attr_accessor, *fields\n end",
"def definir_reader_et_writer( id )\n DBC.require( id.class == Symbol && id.to_s !~ /=$/,\n \"*** Un attribut ou association doit etre defini via un symbole simple: id = #{id}\" )\n\n define_singleton_method id do\n get_attribut id\n end\n\n define_singleton_method \"#{id}=\" do |x|\n set_attribut id, x\n end\n end",
"def add_attr_accessors_to_self\n instance_variables.each do |name|\n method_name = name[1..-1].to_sym\n MetricFu::Configuration.send(:attr_accessor, method_name)\n end\n end",
"def attr_writer(*vars)\n # avoid tracking attributes that are added by the class_attribute\n # as these are class attributes and not instance attributes.\n tracked_vars = vars.reject {|var| respond_to? var }\n add_tracked_attrs(false, true, *tracked_vars)\n vars.extract_options!\n super\n end",
"def define_readers(attr_names)\n attr_names.each do |attr_name|\n if respond_to?(attr_name)\n if self.class.is_an_association?(attr_name)\n # lazy instantiate associated records\n association_writer = method(\"#{attr_name}=\")\n association_reader = method(attr_name)\n define_singleton_method(attr_name) do\n association_writer.(attributes[attr_name])\n association_reader.()\n end\n else\n raise \"Cannot define accessor: #{attr_name}\"\n end\n else\n define_singleton_method(attr_name) do\n attributes[attr_name]\n end\n end\n end\n end",
"def attr_internal_writer(*attrs)\n attrs.each {|attr_name| attr_internal_define(attr_name, :writer)}\n end",
"def construction_method\n :writer\n end",
"def attr; end",
"def assert_attr_reader(obj, method)\n assert_respond_to obj, method\n assert_equal obj.send(method), obj.instance_variable_get(\"@#{method}\")\nend",
"def cattr_accessor(sym)\n cattr_reader(sym)\n cattr_writer(sym)\n end",
"def attr_internal_writer(*attrs)\n attrs.each do |attr|\n module_eval \"def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end\"\n end\n end",
"def attr_internal_writer(*attrs)\n attrs.each do |attr|\n module_eval \"def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end\"\n end\n end",
"def define_accessors attribute_name\n define_getter attribute_name\n define_setter attribute_name\n\n self.attribute_names ||= []\n attribute_names << attribute_name.to_s\n attribute_names.uniq!\n end",
"def create_accessors(attribute_name)\n class_eval do\n define_method(attribute_name) do\n odata_entity[property_map[attribute_name]]\n end\n\n define_method(\"#{attribute_name}=\") do |value|\n # unless entity[property_map[attribute_name]] == value\n # send(\"#{attribute_name}_will_change!\") if defined?(::ActiveModel)\n # end\n\n odata_entity[property_map[attribute_name]] = value\n end\n end\n\n nil\n end",
"def define_writer_method(mod)\n writer_method_name = \"#{name}=\"\n attribute = self\n\n mod.send(:define_method, writer_method_name) { |value| attribute.set(self, value) }\n mod.send(writer_visibility, writer_method_name)\n\n self\n end",
"def define_accessor\n klass.class_eval <<-ACCESSOR\n def #{@relation}\n #self.dataset.left_outer_join(#{@relation}, :id => :#{klass.primary_key_string}).limit(1)\n puts #{relation_class}\n end\n \n def #{@relation}=(value)\n end\n ACCESSOR\n end",
"def create_accessors!\n self.each do |key,val|\n create_accessor_for(key)\n end\n end",
"def attr_accessor( * )\n fail \"Remember, an Entity is immutable. Use a Services::Service to mutate the underlying data.\"\n end",
"def assign_attributes\n @data.each do |attribute, value|\n self.class.send(:attr_accessor, attribute)\n set(attribute, value)\n end\n end",
"def struct_writer(method)\n class_eval <<-RUBY\n attr_writer :#{method}\n RUBY\n end",
"def create_accessors(name, meth, options = {})\n define_method(meth) { read_attribute(name) }\n define_method(\"#{meth}=\") { |value| write_attribute(name, value) }\n define_method(\"#{meth}?\") do\n attr = read_attribute(name)\n (options[:type] == Boolean) ? attr == true : attr.present?\n end\n end",
"def attr_writer_init(*symbols)\n generate_attr_writer(symbols)\n generate_initializer(symbols)\n end",
"def attr_writer( * )\n fail \"Remember, an Entity is immutable. Use a Services::Service to mutate the underlying data.\"\n end",
"def readwrite(*fields)\n readable(*fields)\n writable(*fields)\n allow(*fields)\n nil\n end"
] | [
"0.7965225",
"0.7577414",
"0.74163663",
"0.74144804",
"0.7346127",
"0.7346127",
"0.7346127",
"0.7315455",
"0.7181794",
"0.7098788",
"0.7067853",
"0.6967938",
"0.6936819",
"0.6773722",
"0.67544323",
"0.66915053",
"0.66883624",
"0.6675539",
"0.6666812",
"0.6634692",
"0.661875",
"0.6609648",
"0.658248",
"0.65343827",
"0.65085804",
"0.6489203",
"0.6484854",
"0.648285",
"0.64779884",
"0.6462016",
"0.6456713",
"0.6443763",
"0.6433075",
"0.63641614",
"0.6356702",
"0.63509643",
"0.6320132",
"0.6312346",
"0.6308503",
"0.6282028",
"0.6260204",
"0.6245111",
"0.6238363",
"0.62361246",
"0.622606",
"0.6224477",
"0.62193304",
"0.6200898",
"0.6195674",
"0.61955345",
"0.61843246",
"0.6177591",
"0.61773133",
"0.61749506",
"0.61732423",
"0.6159431",
"0.61525005",
"0.61432624",
"0.6131966",
"0.6131966",
"0.6130969",
"0.6130257",
"0.6122745",
"0.60768515",
"0.6073426",
"0.60643095",
"0.60590535",
"0.6053934",
"0.6047329",
"0.60298675",
"0.600723",
"0.5996878",
"0.59787494",
"0.59671986",
"0.5966642",
"0.5965087",
"0.595276",
"0.59366435",
"0.5936272",
"0.59313864",
"0.59224224",
"0.59217083",
"0.58946925",
"0.58840555",
"0.5882245",
"0.58798695",
"0.5876321",
"0.58699054",
"0.58699054",
"0.58693504",
"0.58631915",
"0.5853203",
"0.5852252",
"0.5832439",
"0.5831401",
"0.58201224",
"0.58084375",
"0.5805287",
"0.58043826",
"0.5793032",
"0.5787167"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_pay_grade
@pay_grade = PayGrade.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.5332605",
"0.5312215",
"0.5296594",
"0.52965283",
"0.52957606",
"0.5259903",
"0.52443177",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.52329034",
"0.52322394",
"0.5227445",
"0.5222394",
"0.5220348",
"0.5212759",
"0.5207747",
"0.5205933",
"0.5176468",
"0.5173833",
"0.5171983",
"0.51663405",
"0.5159596",
"0.5158247",
"0.51526845",
"0.5152398",
"0.5151361",
"0.5145775",
"0.5140135",
"0.51338995",
"0.51127726",
"0.5112607",
"0.5112607",
"0.5110613",
"0.51067513",
"0.5092337",
"0.508788",
"0.5081578",
"0.5080434",
"0.50679874",
"0.50567716",
"0.5051213",
"0.5048352",
"0.5048352",
"0.5035347",
"0.5026666",
"0.5023127",
"0.5016081",
"0.50129867",
"0.5000684",
"0.4999752",
"0.49979812",
"0.499026",
"0.499026",
"0.49866846",
"0.49800366",
"0.49795717",
"0.49771172",
"0.4968475",
"0.4965813",
"0.4958072",
"0.49561292",
"0.4954901",
"0.49536785",
"0.4953058",
"0.49468648",
"0.49424478",
"0.4932989",
"0.49291888",
"0.49273813",
"0.49271655",
"0.4925948",
"0.49236968",
"0.49203572",
"0.49181753",
"0.49173692",
"0.4916862",
"0.49161318",
"0.49155986"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def pay_grade_params
params.require(:pay_grade).permit(:level, :active)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Input a package. The 'package' can be any of: A name of a package on pypi (ie; easy_install somepackage) The path to a directory containing setup.py The path to a setup.py | def input(package)
path_to_package = download_if_necessary(package, version)
if File.directory?(path_to_package)
setup_py = File.join(path_to_package, "setup.py")
else
setup_py = path_to_package
end
if !File.exist?(setup_py)
logger.error("Could not find 'setup.py'", :path => setup_py)
raise "Unable to find python package; tried #{setup_py}"
end
load_package_info(setup_py)
install_to_staging(setup_py)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input(package)\n installdir = attributes[:virtualenv_install_location]\n m = /^([^=]+)==([^=]+)$/.match(package)\n package_version = nil\n\n is_requirements_file = (File.basename(package) == \"requirements.txt\")\n\n if is_requirements_file\n if !File.file?(package)\n raise FPM::InvalidPackageConfiguration, \"Path looks like a requirements.txt, but it doesn't exist: #{package}\"\n end\n\n package = File.join(::Dir.pwd, package) if File.dirname(package) == \".\"\n package_name = File.basename(File.dirname(package))\n logger.info(\"No name given. Using the directory's name\", :name => package_name)\n package_version = nil\n elsif m\n package_name = m[1]\n package_version = m[2]\n self.version ||= package_version\n else\n package_name = package\n package_version = nil\n end\n\n virtualenv_name = package_name\n\n self.name ||= package_name\n\n if self.attributes[:virtualenv_fix_name?]\n self.name = [self.attributes[:virtualenv_package_name_prefix],\n self.name].join(\"-\")\n end\n\n # prefix wins over previous virtual_install_location behaviour\n virtualenv_folder =\n if self.attributes[:prefix]\n self.attributes[:prefix]\n else\n File.join(installdir,\n virtualenv_name)\n end\n\n virtualenv_build_folder = build_path(virtualenv_folder)\n\n ::FileUtils.mkdir_p(virtualenv_build_folder)\n\n if self.attributes[:virtualenv_system_site_packages?]\n logger.info(\"Creating virtualenv with --system-site-packages\")\n safesystem(\"virtualenv\", \"--system-site-packages\", virtualenv_build_folder)\n else\n safesystem(\"virtualenv\", virtualenv_build_folder)\n end\n\n pip_exe = File.join(virtualenv_build_folder, \"bin\", \"pip\")\n python_exe = File.join(virtualenv_build_folder, \"bin\", \"python\")\n\n # Why is this hack here? It looks important, so I'll keep it in.\n safesystem(python_exe, pip_exe, \"install\", \"-U\", \"-i\",\n attributes[:virtualenv_pypi],\n \"pip\")\n\n extra_index_url_args = []\n if attributes[:virtualenv_pypi_extra_index_urls]\n attributes[:virtualenv_pypi_extra_index_urls].each do |extra_url|\n extra_index_url_args << \"--extra-index-url\" << extra_url\n end\n end\n\n find_links_url_args = []\n if attributes[:virtualenv_find_links_urls]\n attributes[:virtualenv_find_links_urls].each do |links_url|\n find_links_url_args << \"--find-links\" << links_url\n end\n end\n\n target_args = []\n if is_requirements_file\n target_args << \"-r\" << package\n else\n target_args << package\n end\n\n pip_args = [python_exe, pip_exe, \"install\", \"-i\", attributes[:virtualenv_pypi]] << extra_index_url_args << find_links_url_args << target_args\n safesystem(*pip_args.flatten)\n\n if attributes[:virtualenv_setup_install?]\n logger.info(\"Running PACKAGE setup.py\")\n setup_args = [python_exe, \"setup.py\", \"install\"]\n safesystem(*setup_args.flatten)\n end\n\n if ! is_requirements_file && package_version.nil?\n frozen = safesystemout(python_exe, pip_exe, \"freeze\")\n frozen_version = frozen[/#{package}==[^=]+$/]\n package_version = frozen_version && frozen_version.split(\"==\")[1].chomp!\n self.version ||= package_version\n end\n\n ::Dir[build_path + \"/**/*\"].each do |f|\n if ! File.readable? f\n File.lchmod(File.stat(f).mode | 444)\n end\n end\n\n ::Dir.chdir(virtualenv_build_folder) do\n safesystem(\"virtualenv-tools\", \"--update-path\", virtualenv_folder)\n end\n\n if !attributes[:virtualenv_other_files_dir].nil?\n # Copy all files from other dir to build_path\n Find.find(attributes[:virtualenv_other_files_dir]) do |path|\n src = path.gsub(/^#{attributes[:virtualenv_other_files_dir]}/, '')\n dst = File.join(build_path, src)\n copy_entry(path, dst, preserve=true, remove_destination=true)\n copy_metadata(path, dst)\n end\n end\n\n remove_python_compiled_files virtualenv_build_folder\n\n # use dir to set stuff up properly, mainly so I don't have to reimplement\n # the chdir/prefix stuff special for tar.\n dir = convert(FPM::Package::Dir)\n # don't double prefix the files\n dir.attributes[:prefix] = nil\n if attributes[:chdir]\n dir.attributes[:chdir] = File.join(build_path, attributes[:chdir])\n else\n dir.attributes[:chdir] = build_path\n end\n\n cleanup_staging\n # Tell 'dir' to input \".\" and chdir/prefix will help it figure out the\n # rest.\n dir.input(\".\")\n @staging_path = dir.staging_path\n dir.cleanup_build\n\n end",
"def input(vnd_pkg_path)\n\n # general params\n in_bundle = vnd_pkg_path.gsub(/^(.+\\/+)*vendor\\/+|\\/(?=\\/)|\\/+$/, \"\")\n @name = in_bundle.gsub(/[\\W]+/, \"-\")\n json = {}\n if @once\n @once = true\n raise FPM::InvalidPackageConfiguration, \"You can't input multiple bundle names. Only one package can be built at a time currently. Use a shell loop please.\"\n elsif in_bundle =~ /^composer\\/\\w+\\.\\w+/\n raise FPM::InvalidPackageConfiguration, \"composer/*.* files specified as input. Supply only one bundle id.\"\n end\n\n # copying mode\n if File.exist?(\"vendor/\" + in_bundle)\n json = parse_lock(\"composer.lock\", in_bundle)[in_bundle]\n # localize contents below vendor/*/*/ input directory\n ::Dir.chdir(\"./vendor/#{in_bundle}/#{json['target-dir']}/\") do\n FileUtils.cp_r(glob(\"./*\"), build_path)\n end\n else\n # download one package (and dependencies, which are thrown away afterwards)\n ::Dir.chdir(staging_path) do\n ver = attributes[:composer_ver]\n safesystem(\n composer, \"require\", \"--prefer-dist\", \"--update-no-dev\", \"--ignore-platform-reqs\",\n \"--no-ansi\", \"--no-interaction\", in_bundle, *(ver ? [ver] : [])\n )\n # localize Vnd/Pkg folder\n json = parse_lock(\"composer.lock\", in_bundle)[in_bundle]\n FileUtils.mv(glob(\"./vendor/#{in_bundle}/#{json['target-dir']}/*\"), build_path)\n FileUtils.rm_r(glob(\"#{staging_path}/*\"))\n end\n end\n\n #-- staging\n # At this point the build_path contains just the actual class files, etc.\n # Conversion to sys/phar/sysphar is handled in convert() along with the\n # dependency translation.\n composer_json_import(json)\n @target_dir = json.include?(\"target-dir\") ? json[\"target-dir\"] : in_bundle\n attributes[:phar_format] = \"zip+gz\" unless attributes[:phar_format_given?]\n end",
"def package(pkg)\n @pkg = pkg\n end",
"def action_package(type)\n name = prompt('Name : ')\n dest = Automation::Converter.to_unix_path(prompt('Destination : '))\n require REQUIRE_MAP[type] % {name: name}\n\n raise Automation::ConsoleError.new(\"No definition found for package '#{name}'\") unless PACKAGE_CLASS.has_key?(name)\n plugin = PACKAGE_CLASS[name].new\n plugin.package(dest)\n puts \"Packaged '#{type}' - #{plugin.name}\"\n end",
"def package(output_dir = Pathname(Dir.pwd).expand_path)\n # Check the source\n check_source!\n # Turn the source into component parts to build a gem out of\n gem_parts = read_source_parts\n # Write these parts to a directory\n gem_dir = write_gem_dir(gem_parts)\n # Build a .gem file from this directory, and leave it in the `output_dir`\n build_package(gem_dir, output_dir)\n end",
"def needpackage *args\n\t\tpackage *args\n\tend",
"def setup_package(package_name, &block)\n if !block\n raise ConfigError.new, \"you must give a block to #setup_package\"\n end\n\n package_definition = Autoproj.workspace.manifest.package(package_name)\n if !package_definition\n raise ConfigError.new, \"#{package_name} is not a known package\"\n elsif package_definition.autobuild.kind_of?(Autobuild::DummyPackage)\n # Nothing to do!\n else\n package_definition.add_setup_block(block)\n end\nend",
"def add_package(package)\n [package_handler(File.extname(package).tr(\".\", \"\")).add(content, package)].flatten.compact\n end",
"def for_package(package)\n data = File.read(path_for(package))\n hash = JSON.parse(data, symbolize_names: true)\n new(package, hash)\n rescue Errno::ENOENT\n raise NoPackageMetadataFile.new(package.path)\n end",
"def easy_install(package_path)\n upload_package(package_path)\n install_package\n end",
"def package_plugin(name)\n `cd #{@repository_path}; rake feather:package path=#{name} target=#{@build_path}`\n end",
"def package *args\n\t\targs.each do | name |\n\t\t\treturn if haspackage? name\n\t\tend\n\t\[email protected]_logger.notify VERBOSE_MAJOR,\"Skipping - package #{args.join(',')} not installed\"\n\t\traise PackageNotInstalledError.new('Package '+args.join(\",\")+' not installed')\n\tend",
"def package_ruby(pkg, options) \n # update dependencies in any case, i.e. independant if package exists or not\n deps = dependencies(pkg)\n Dir.chdir(pkg.srcdir) do\n begin\n logname = \"obs-#{pkg.name.sub(\"/\",\"-\")}\" + \"-\" + Time.now.strftime(\"%Y%m%d-%H%M%S\").to_s + \".log\"\n gem = FileList[\"pkg/*.gem\"].first\n if not gem \n Packager.info \"Debian: creating gem from package #{pkg.name}\"\n if !system(\"rake gem 2> #{File.join(OBS_LOG_DIR, logname)}\")\n raise \"Debian: failed to create gem from RubyPackage #{pkg.name}\"\n Packager.warn \" check: #{File.expand_path(logname)}\"\n end\n end\n\n gem = FileList[\"pkg/*.gem\"].first\n\n # Make the naming of the gem consistent with the naming schema of\n # rock packages\n #\n # Make sure the gem has the fullname, e.g.\n # tools-metaruby instead of just metaruby\n gem_rename = gem.sub(basename(pkg.name), canonize(pkg.name))\n if gem != gem_rename\n Packager.info \"Debian: renaming #{gem} to #{gem_rename}\"\n FileUtils.mv gem, gem_rename\n gem = gem_rename\n end\n\n Packager.debug \"Debian: copy #{gem} to #{packaging_dir(pkg)}\"\n FileUtils.cp gem, packaging_dir(pkg)\n gem_final_path = File.join(packaging_dir(pkg), File.basename(gem))\n\n # Prepare injection of dependencies\n options[:deps] = deps\n convert_gem(gem_final_path, options)\n # register gem with the correct naming schema\n # to make sure dependency naming and gem naming are consistent\n @ruby_rock_gems << debian_name(pkg)\n rescue Exception => e\n raise \"Debian: failed to create gem from RubyPackage #{pkg.name} -- #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end\n end",
"def find_package_dir arg\n if arg \n if Dir.exist? arg\n File.absolute_path arg\n else\n STDERR.puts \"Error: PACKAGE_DIR not found: #{arg}\"\n end\n else\n STDERR.puts \"Error: no PACKAGE_DIR provided\"\n end\nend",
"def install(pkg)\n package pkg do\n action :install\n end\nend",
"def locate_package(package_name, vers, verbose)\n local = has_local_package?(package_name)\n \n # It's true that we don't have a prerelase check here, but the\n # previous one we had didn't do anything, so it's better to have\n # none than one that doesn't work\n vers = \">= 0\" if vers == \">= 0-pre\"\n src_path = local ? locate_local_package(package_name) : \n BPM::Local.new.source_root(package_name, vers)\n\n return nil unless src_path\n\n pkg = BPM::Package.new(src_path)\n pkg.load_json # throws exception if json invalid\n pkg\n end",
"def package\n @package ||= path.split('/lib/')[0].split('/').last.split('.js').last\n end",
"def path_from_package(package_name)\n ret = package_from_name package_name\n ret && ret.root_path\n end",
"def ask_for_package_set(message)\n ask_for(message,package_sets)\n end",
"def for_package(package)\n data = File.read(path_for(package))\n hash = FFI_Yajl::Parser.parse(data, symbolize_names: true)\n\n # Ensure Platform version has been truncated\n if hash[:platform_version] && hash[:platform]\n hash[:platform_version] = truncate_platform_version(hash[:platform_version], hash[:platform])\n end\n\n # Ensure an interation exists\n hash[:iteration] ||= 1\n\n new(package, hash)\n rescue Errno::ENOENT\n raise NoPackageMetadataFile.new(package.path)\n end",
"def install_package(target_package_path); raise NotImplementedError; end",
"def package\n @options['package']\n end",
"def package(version)\n packages[version] if package_setup.include? version\n end",
"def package\n @package ||= Package.initialize_from_path(path: \"#{resource_path}/package\",\n client: @client)\n end",
"def find_package_definition(name)\n packages[validate_package_name_argument(name, require_existing: false)]\n end",
"def package(pkg, options = Hash.new)\n\n options, unknown_options = Kernel.filter_options options,\n :force_update => false,\n :existing_source_dir => nil,\n :patch_dir => nil\n\n if options[:force_update]\n dirname = File.join(OBS_BUILD_DIR, debian_name(pkg))\n if File.directory?(dirname)\n Packager.info \"Debian: rebuild requested -- removing #{dirname}\"\n FileUtils.rm_rf(dirname)\n end\n end\n\n prepare_source_dir(pkg, options)\n\n if pkg.kind_of?(Autobuild::CMake) || pkg.kind_of?(Autobuild::Autotools)\n package_deb(pkg, options)\n elsif pkg.kind_of?(Autoproj::RubyPackage)\n package_ruby(pkg, options)\n else\n raise ArgumentError, \"Debian: Unsupported package type #{pkg.class} for #{pkg.name}\"\n end\n end",
"def guess_package_name(gem_name, args)\n package_name = nil\n package_name ||= guess_package_name_from_args(gem_name, args)\n package_name ||= guess_package_name_from_environment\n package_name ||= guess_package_name_from_appfile\n package_name ||= guess_package_name_from_config_files\n package_name\n end",
"def input(pacman_pkg_path)\n control = {}\n # Unpack the control tarball\n safesystem(tar_cmd, \"-C\", staging_path, \"-xf\", pacman_pkg_path)\n pkginfo = staging_path(\".PKGINFO\")\n mtree = staging_path(\".MTREE\")\n install = staging_path(\".INSTALL\")\n\n control_contents = File.read(pkginfo)\n FileUtils.rm(pkginfo)\n FileUtils.rm(mtree)\n\n\n control_lines = control_contents.split(\"\\n\")\n control_lines.each do |line|\n key, val = line.split(/ += +/, 2)\n if control.has_key? key\n control[key].push(val)\n else\n control[key] = [val]\n end\n end\n\n self.name = control[\"pkgname\"][0]\n\n # Parse 'epoch:version-iteration' in the version string\n version_re = /^(?:([0-9]+):)?(.+?)(?:-(.*))?$/\n m = version_re.match(control[\"pkgver\"][0])\n if !m\n raise \"Unsupported version string '#{control[\"pkgver\"][0]}'\"\n end\n self.epoch, self.version, self.iteration = m.captures\n\n self.maintainer = control[\"packager\"][0]\n\n # Arch has no notion of vendor, so...\n #self.vendor =\n\n self.url = control[\"url\"][0]\n # Groups could include more than one.\n # Speaking of just taking the first entry of the field:\n # A crude thing to do, but I suppose it's better than nothing.\n # -- Daniel Haskin, 3/24/2015\n self.category = control[\"group\"] && control[\"group\"][0] || self.category\n\n # Licenses could include more than one.\n # Speaking of just taking the first entry of the field:\n # A crude thing to do, but I suppose it's better than nothing.\n # -- Daniel Haskin, 3/24/2015\n self.license = control[\"license\"][0] || self.license\n\n self.architecture = control[\"arch\"][0]\n\n self.dependencies = control[\"depend\"] || self.dependencies\n\n self.provides = control[\"provides\"] || self.provides\n\n self.conflicts = control[\"conflict\"] || self.conflicts\n\n self.replaces = control[\"replaces\"] || self.replaces\n\n self.description = control[\"pkgdesc\"][0]\n\n if control.include? \"backup\"\n self.config_files = control[\"backup\"].map{|file| \"/\" + file}\n else\n self.config_files = []\n end\n\n self.dependencies = control[\"depend\"] || self.dependencies\n \n if attributes[:no_auto_depends?]\n self.dependencies = []\n end\n\n self.attributes[:pacman_optional_depends] = control[\"optdepend\"] || []\n # There are other available attributes, but I didn't include them because:\n # - makedepend: deps needed to make the arch package. But it's already\n # made. It just needs to be converted at this point\n # - checkdepend: See above\n # - makepkgopt: See above\n # - size: can be dynamically generated\n # - builddate: Should be changed to time of package conversion in the new\n # package, so this value should be thrown away.\n\n if File.exist?(install)\n functions = parse_install_script(install)\n if functions.include?(\"pre_install\")\n self.scripts[:before_install] = functions[\"pre_install\"].join(\"\\n\")\n end\n if functions.include?(\"post_install\")\n self.scripts[:after_install] = functions[\"post_install\"].join(\"\\n\")\n end\n if functions.include?(\"pre_upgrade\")\n self.scripts[:before_upgrade] = functions[\"pre_upgrade\"].join(\"\\n\")\n end\n if functions.include?(\"post_upgrade\")\n self.scripts[:after_upgrade] = functions[\"post_upgrade\"].join(\"\\n\")\n end\n if functions.include?(\"pre_remove\")\n self.scripts[:before_remove] = functions[\"pre_remove\"].join(\"\\n\")\n end\n if functions.include?(\"post_remove\")\n self.scripts[:after_remove] = functions[\"post_remove\"].join(\"\\n\")\n end\n FileUtils.rm(install)\n end\n\n # Note: didn't use `self.directories`.\n # Pacman doesn't really record that information, to my knowledge.\n\n end",
"def output_package(pkg_type)\n case pkg_type\n when 'makeself'\n \"#{package_name}-#{build_version}_#{iteration}.sh\"\n when 'msi'\n Packager::WindowsMsi.new(self).package_name\n when 'bff'\n \"#{package_name}.#{bff_version}.bff\"\n when 'pkgmk'\n \"#{package_name}-#{build_version}-#{iteration}.solaris\"\n when 'mac_pkg'\n Packager::MacPkg.new(self).package_name\n when 'mac_dmg'\n pkg = Packager::MacPkg.new(self)\n Packager::MacDmg.new(pkg).package_name\n else # fpm\n require \"fpm/package/#{pkg_type}\"\n pkg = FPM::Package.types[pkg_type].new\n pkg.version = build_version\n pkg.name = package_name\n pkg.iteration = iteration\n if pkg_type == 'solaris'\n pkg.to_s('NAME.FULLVERSION.ARCH.TYPE')\n else\n pkg.to_s\n end\n end\n end",
"def action_install(type)\n from = Automation::Converter.to_unix_path(prompt('Install from : '))\n package_rb = File.join(from, 'package.rb')\n require package_rb\n\n raise Automation::ConsoleError.new(\"No definition found for package '#{package_rb}'\") unless PACKAGE_CLASS.has_key?(package_rb)\n plugin = PACKAGE_CLASS[package_rb].new\n plugin.install(from)\n puts \"Installed '#{type}' - #{plugin.name}\"\n end",
"def check_package(item)\n package = \"Packages/\"+ item +\".rb\"\n result = File.exists?(package)\n if result == true\n require package\n else\n puts \"the monkeys can't find your package\"\n exit\n end\nend",
"def install(package)\n wait_until(\"Installing package\") do\n get \"/invoke/wm.server.packages/packageInstall?activateOnInstall=true&file=#{CGI.escape package.to_s}\"\n end\n end",
"def output_package(pkg_type)\n case pkg_type\n when 'makeself'\n Packager::Makeself.new(self).package_name\n when 'msi'\n Packager::MSI.new(self).package_name\n when 'bff'\n Packager::BFF.new(self).package_name\n when 'solaris'\n Packager::Solaris.new(self).package_name\n when 'pkg'\n Packager::PKG.new(self).package_name\n when 'mac_dmg'\n pkg = Packager::PKG.new(self)\n Packager::MacDmg.new(pkg).package_name\n when 'rpm'\n Packager::RPM.new(self).package_name\n when 'deb'\n Packager::DEB.new(self).package_name\n else\n raise RuntimeError, \"I do not know how to build a `#{pkg_type}'!\"\n end\n end",
"def package(path, target)\n # Load manifest\n puts \"Load manifest...\"\n manifest = YAML::load_file(File.join(path, 'manifest.yml'))\n \n # Target directory for package files\n puts \"Target is: #{target}\"\n Dir.mkdir(target) if not File.exists?(target)\n \n # Package name\n package = \"#{manifest['name']}-#{manifest['version']}\"\n puts \"Package: #{package}\"\n \n # Tgz\n manifest['package'] = \"#{package}.tgz\"\n command = \"tar -czf #{package}.tgz --exclude pkg -C #{path} .\"\n puts \"Packing: #{command}\"\n system command\n \n # Move\n puts \"Finishing..\"\n FileUtils.mv(\"#{package}.tgz\", target)\n File.open(File.join(target, \"#{package}.yml\"), 'w') do |f|\n f.puts(manifest.to_yaml)\n f.close\n end\n \n puts \"Done.\"\nend",
"def package(group_name, package_name, package_version)\n RubyAem::Resources::Package.new(@client, group_name, package_name, package_version)\n end",
"def elm_package(package)\n ElmPackage.read elm_package_path(package)\n end",
"def package(name)\n if name.respond_to? :cache_path\n name\n elsif @versions[name]\n Package.for(@sources[name], @versions[name], @files[name])\n end\n end",
"def pkg_cmd; \"#{pkg_binary}\" end",
"def package(id)\n if pkg = ARTIFACTS[id.to_sym]\n artifact(**pkg)\n else\n die \"Unknown package ID '#{id}'\"\n end\n end",
"def set_package\n @package = Package.find(params[:package_id])\n end",
"def find_autobuild_package(name)\n find_package_definition(name)&.autobuild\n end",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def compile_package_task(input, output=input)\n js_tasks = SproutCore::Compiler::Preprocessors::JavaScriptTask.with_input \"packages/#{input}/lib/**/*.js\", \".\"\n SproutCore::Compiler::CombineTask.with_tasks js_tasks, \"#{SproutCore::Compiler.intermediate}/#{output}\"\nend",
"def package_dir_path\n \"#{package_dir}/#{package_name}\"\n end",
"def convert_package(pkginfo, packaging_dir,\n gem_name: nil,\n patch_dir: nil\n )\n Packager.info \"Package Ruby: '#{pkginfo.name}' with gem_name: '#{gem_name}'\"\n\n # update dependencies in any case, i.e. independent if package exists or not\n deps = pkginfo.dependencies\n Dir.chdir(pkginfo.srcdir) do\n begin\n logname = \"package-ruby-#{pkginfo.name.sub(\"/\",\"-\")}\" + \"-\" + Time.now.strftime(\"%Y%m%d-%H%M%S\").to_s + \".log\"\n logfile = File.join(log_dir, logname)\n\n gem = FileList[\"pkg/*.gem\"].first\n if not gem\n Packager.info \"#{self.class}: preparing gem generation in #{Dir.pwd}\"\n\n # Rake targets that should be tried for cleaning\n gem_clean_success = false\n Gem.clean_alternatives.each do |target|\n msg, status = Open3.capture2e(pkginfo.env, \"bundle exec rake #{target}\")\n if !status.success?\n Packager.info \"#{self.class}: failed to clean package '#{pkginfo.name}' using target '#{target}' #{msg} (see #{logfile})\"\n File.open(logfile,\"a+\") {|f| f.puts msg }\n else\n Packager.info \"#{self.class}: succeeded to clean package '#{pkginfo.name}' using target '#{target}'\"\n gem_clean_success = true\n break\n end\n end\n if not gem_clean_success\n Packager.warn \"#{self.class}: failed to cleanup ruby package '#{pkginfo.name}' -- continuing without cleanup\"\n end\n\n Packager.info \"#{self.class}: ruby package Manifest.txt is being autogenerated\"\n Package2Gem.generate_manifest_txt\n Package2Gem.cleanup_multiple_gemspec(gem_name)\n\n Packager.info \"#{self.class}: creating gem from package #{pkginfo.name} [#{File.join(log_dir, logname)}]\"\n\n if patch_pkg_dir(pkginfo.name, patch_dir, whitelist: [\"*.gemspec\", \"Rakefile\", \"metadata.yml\"])\n Packager.info \"#{self.class}: patched build files for ruby package before gem building: #{pkginfo.name}\"\n end\n\n # Allowed gem creation alternatives\n gem_creation_success = false\n\n # Gemspec often use the 'git ls -z' listings, which\n # might break if hidden files will be removed\n # without commiting -- so temporarily add and revert\n # again, to maintain the original commit id\n # TBD: or leave the commit and list the last N commits in the changelog\n Packager.info \"#{self.class}: temporarily commit changes in #{Dir.pwd}\"\n _,_,git_add_status = Open3.capture3(\"git add -A\")\n msg,git_commit_status = Open3.capture2(\"git commit -m 'Apaka: gem creation' --author 'Apaka Packager, <apaka@autocommit>'\")\n if !git_commit_status.success?\n Packager.info \"#{self.class}: commit failed: #{msg}\"\n end\n Gem.creation_alternatives.each do |target|\n msg, status = Open3.capture2e(pkginfo.env, \"bundle exec rake #{target}\")\n if !status.success?\n Packager.info \"#{self.class}: failed to create gem using target '#{target}' (see #{logfile})\"\n File.open(logfile,\"a+\") do |f|\n f.puts msg\n f.puts pkginfo.env\n end\n else\n Packager.info \"#{self.class}: succeeded to create gem using target '#{target}'\"\n gem_creation_success = true\n break\n end\n end\n if git_commit_status.success?\n Packager.info \"#{self.class}: git package status\"\n msg, git_revert = Open3.capture2(\"git reset --soft HEAD~1\")\n Packager.info \"#{self.class}: reversion of temporary commit failed\"\n end\n if not gem_creation_success\n raise RuntimeError, \"Debian: failed to create gem from RubyPackage #{pkginfo.name}\"\n end\n end\n\n gem = FileList[\"pkg/*.gem\"].first\n\n # Make the naming of the gem consistent with the naming schema of\n # other packages\n #\n # Make sure the gem has the fullname, e.g.\n # tools-metaruby instead of just metaruby\n if gem_name\n gem_name = gem.sub(Packaging.basename(pkginfo.name), gem_name)\n if gem != gem_name\n Packager.info \"#{self.class}: renaming #{gem} to #{gem_name}\"\n end\n else\n gem_name = gem\n end\n Packager.info \"#{self.class}: '#{pkginfo.name}' -- basename: #{Packaging.basename(pkginfo.name)} will be packaged as: #{gem_name}\"\n\n gem_final_path = File.join(packaging_dir, File.basename(gem_name))\n Packager.info \"#{self.class}: copy #{File.join(Dir.pwd, gem)} to #{gem_final_path}\"\n FileUtils.cp gem, gem_final_path\n return gem_final_path\n\n rescue Exception => e\n raise RuntimeError, \"#{self.class}: failed to create gem from RubyPackage #{pkginfo.name} -- #{e.message}\\n#{e.backtrace.drop(1).map{|s| \"\\t#{s}\"}}\"\n end\n end\n end",
"def installed?(package)\n fail LookupFailed, 'No supported package tool found.' if tool.nil?\n\n cmd = tools[tool]\n fail LookupFailed, \"Package tool '#{cmd}' not found.\" if command?(cmd).nil?\n\n send tool, package\n end",
"def install(pkg_name)\n begin\n pkg_build_dir = packaging_dir(pkg_name)\n filepath = Dir.glob(\"#{pkg_build_dir}/*.deb\")\n if filepath.size < 1\n raise RuntimeError, \"No debian file found for #{pkg_name} in #{pkg_build_dir}: #{filepath}\"\n elsif filepath.size > 1\n raise RuntimeError, \"More than one debian file available in #{pkg_build_dir}: #{filepath}\"\n else\n filepath = filepath.first\n Packager.info \"Found package: #{filepath}\"\n end\n install_debfile(filepath)\n rescue Exception => e\n raise RuntimeError, \"Installation of package '#{pkg_name} failed -- #{e}\"\n end\n end",
"def package(pattern, options)\n log.header 'Package'\n each_solution(pattern) do |solution|\n version = solution.package_version\n package_manager = PackageManager.new(solution)\n (solution.configuration['packages'] || []).each do |package|\n package_manager.create_package(package, version, options)\n end\n end\n end",
"def package(pkginfo, options = Hash.new)\n options, unknown_options = Kernel.filter_options options,\n :force_update => false,\n :patch_dir => nil,\n :distribution => nil, # allow to override global settings\n :architecture => nil\n\n options[:distribution] ||= target_platform.distribution_release_name\n options[:architecture] ||= target_platform.architecture\n\n debian_pkg_name = debian_name(pkginfo)\n\n if options[:force_update]\n dirname = packaging_dir(pkginfo)\n if File.directory?(dirname)\n Packager.info \"Debian: rebuild requested -- removing #{dirname}\"\n FileUtils.rm_rf(dirname)\n end\n end\n\n options[:packaging_dir] = packaging_dir(pkginfo)\n options[:release_name] = rock_release_name\n\n begin\n # Set the current pkginfo to set the install directory\n # correctly\n # FIXME: needs to be refactored\n #\n @packager_lock.lock\n @current_pkg_info = pkginfo\n\n pkginfo = prepare_source_dir(pkginfo, options.merge(unknown_options))\n\n if pkginfo.build_type == :orogen || pkginfo.build_type == :cmake || pkginfo.build_type == :autotools\n package_default(pkginfo, options)\n elsif pkginfo.build_type == :ruby\n # Import bundles since they do not need to be build and\n # they do not follow the typical structure required for gem2deb\n if pkginfo.name =~ /bundles/\n package_importer(pkginfo, options)\n else\n package_ruby(pkginfo, options)\n end\n elsif pkginfo.build_type == :archive_importer || pkginfo.build_type == :importer_package\n package_importer(pkginfo, options)\n else\n raise ArgumentError, \"Debian: Unsupported package type #{pkginfo.build_type} for #{pkginfo.name}\"\n end\n ensure\n @current_pkg_info = nil\n @packager_lock.unlock\n end\n end",
"def package_path(extension='.gem')\n File.join(package_dir, package_basename(extension))\n end",
"def package(name)\n Packaged.instance self , name\n end",
"def register_package(package, block = nil, package_set = main_package_set, file = nil)\n invalidate_ignored_package_names\n pkg = PackageDefinition.new(package, package_set, file)\n pkg.add_setup_block(block) if block\n @packages[package.name] = pkg\n metapackage pkg.package_set.name, pkg.autobuild\n metapackage \"#{pkg.package_set.name}.all\", pkg.autobuild\n pkg\n end",
"def pkg_path\n \"pkg/#{spec.full_name}\"\n end",
"def package_and_module_from_path(path)\n path = File.expand_path path.to_s\n pkg = local_deps.find {|cur| path =~ /^#{Regexp.escape cur.root_path.to_s}\\//}\n pkg = self if pkg.nil? && path =~ /^#{Regexp.escape root_path.to_s}/\n raise \"#{path} is not within a known package\" if pkg.nil?\n\n dir_name = nil\n pkg.directories.each do |dname, dpath|\n dpaths = Array(dpath).map{|d| File.expand_path(d, pkg.root_path) }\n dpaths.each do |d|\n # Find a match and see if we can replace\n if path.gsub!(/^#{Regexp.escape(d)}\\//, \"#{dname}/\")\n dir_name = dname\n break\n end\n end\n break if dir_name\n end\n\n if dir_name\n parts = path.split(\"/\")\n else\n parts = Pathname.new(path).relative_path_from(Pathname.new(pkg.root_path)).to_s.split(\"/\")\n dir_name = parts.first\n end\n\n if dir_name == 'lib'\n parts.shift\n else\n parts[0] = \"~#{dir_name}\"\n end\n\n parts[parts.size-1] = File.basename(parts.last, '.*')\n [pkg, parts.join('/')]\n end",
"def ruby_package(options)\n package_common(:ruby, options) do |pkg|\n # Documentation code. Ignore if the user provided its own documentation\n # task, or disabled the documentation generation altogether by setting\n # rake_doc_task to nil\n if !pkg.has_doc? && pkg.rake_doc_task\n pkg.with_doc\n end\n if !pkg.test_utility.has_task?\n if !pkg.test_utility.source_dir\n test_dir = File.join(pkg.srcdir, 'test')\n if File.directory?(test_dir)\n pkg.test_utility.source_dir = test_dir\n end\n end\n\n if pkg.test_utility.source_dir\n pkg.with_tests\n end\n end\n\n yield(pkg) if block_given?\n end\nend",
"def metapackage(name, *packages)\n Autoproj.workspace.manifest.metapackage(name, *packages)\nend",
"def load_package_manifest(pkg)\n if pkg.respond_to?(:to_str)\n pkg_definition = find_package_definition(pkg)\n unless pkg_definition\n raise ArgumentError, \"#{pkg} is not a known package in #{self}\"\n end\n\n pkg = pkg_definition\n end\n package = pkg.autobuild\n package_set = pkg.package_set\n\n # Look for the package's manifest.xml, but fallback to a manifest in\n # the package set if present\n if package.use_package_xml? && package.checked_out?\n manifest_path = File.join(package.srcdir, \"package.xml\")\n raise NoPackageXML.new(package.srcdir), \"#{package.name} from \"\\\n \"#{package_set.name} has use_package_xml set, but the package has \"\\\n \"no package.xml file\" unless File.file?(manifest_path)\n\n manifest = PackageManifest.load(package, manifest_path,\n ros_manifest: true,\n condition_context: @ws.env)\n else\n manifest_paths = [File.join(package.srcdir, \"manifest.xml\")]\n if package_set.local_dir\n manifest_paths << File.join(\n package_set.local_dir, \"manifests\", \"#{package.name}.xml\"\n )\n end\n manifest_path = manifest_paths.find do |path|\n File.file?(path)\n end\n if manifest_path\n manifest = PackageManifest.load(package, manifest_path,\n ros_manifest: false,\n condition_context: @ws.config)\n end\n end\n\n if manifest\n pkg.autobuild.description = manifest\n else\n Autoproj.warn \"#{package.name} from #{package_set.name} \"\\\n \"does not have a manifest\"\n end\n\n pkg.apply_dependencies_from_manifest\n # #description is initialized with a null package manifest\n # return it even if we haven't overriden it\n pkg.autobuild.description\n end",
"def parse_pkg fname\n if File.extname(fname) == @extension\n lines = IO.readlines fname\n lines.each do |l|\n begin\n break if l =~ JTools::CLS_DECL_REGEX # stop if we find the class header\n next if l.strip.start_with? \"/*\", \"*\", \"//\"\n if l =~ JTools::PKG_DCL_REGEX # if package declaration found\n pkg_name = l.gsub JTools::EXTR_PKG, \"\" # extract path\n return pkg_name\n end\n rescue ArgumentError => e\n puts \"Error matching line '#{l}' In #{fname}. \" + e.message\n end\n end\n puts \"Warning: #{File.basename fname} has no or no valid package\" +\n \" declaration. Adding to default package.\" if @verbose\n \"\" # if we found nothing -> default package\n else\n raise ArgumentError.new \"Error. #{fname} is no #{@extension} file.\"\n end\n end",
"def copy_package(package, package_path)\n repository_path = File.join(@git_resolver.repository_path(package), '.')\n\n FileUtils.mkdir_p(package_path)\n FileUtils.cp_r(repository_path, package_path)\n FileUtils.rm_rf(File.join(package_path, '.git'))\n end",
"def set_package_filename\n if @package_name.nil?\n @package_name = get_package_name\n end\n end",
"def find_package_by_name(name)\n @packages[name]\n end",
"def resolve_package(selection)\n matching_packages = find_packages(selection)\n if matching_packages.empty?\n matching_packages = find_packages_with_directory_shortnames(selection)\n end\n\n if matching_packages.size > 1\n # If there is more than one candidate, check if there are some that are not\n # present on disk\n present = matching_packages.find_all { |pkg| File.directory?(pkg.srcdir) }\n matching_packages = present if present.size == 1\n end\n\n if matching_packages.empty?\n raise CLIInvalidArguments, \"cannot find '#{selection}' in the current autoproj installation\"\n elsif matching_packages.size > 1\n raise CLIAmbiguousArguments, \"multiple packages match '#{selection}' in the current autoproj installation: #{matching_packages.map(&:name).sort.join(', ')}\"\n else\n matching_packages.first\n end\n end",
"def install_package(name, version)\n package_provider.install_package\n end",
"def requires(package, *args)\n @packages << [package, args]\n end",
"def source_package(options)\n package_common(options) do |pkg|\n pkg.srcdir = pkg.name\n yield(pkg) if block_given?\n end\nend",
"def package(name, paths=[])\n Package.new(name, paths, self)\n end",
"def map( pkg_path )\n # This is the package we will return\n p = nil\n\n # This will give us a list of all the files the package will install\n pkg_files = traverse( pkg_path + \"/pkg_files\", \"\" )\n\n # We then read the manifest for other data that we need\n mf = pkg_path + \"/MANIFEST.json\"\n\n if( File.file?( mf ) )\n file = File.new( mf, \"r\" )\n buff = \"\"\n while (line = file.gets)\n buff += line\n end\n file.close( )\n meta = JSON.parse( buff )\n p = Package.new( meta[ \"name\" ], meta[ \"version\" ], pkg_files, meta[ \"depends\" ] )\n end\n puts \"PkgCrawler: placing %s-%s in cache\" % [ p.name, p.version ]\n name = \"%s-%s\" % [ p.name, p.version ]\n @pkg_cache[ name ] = p\n return p\n end",
"def run_package_command(cmd)\n if cmd.is_a?(Array)\n command = cmd[0]\n cmd_options.merge!(cmd[1])\n else\n command = cmd\n end\n\n shellout!(command, cwd: config.package_dir)\n end",
"def get_package_version(package_file_name = 'package.json')\n # Is the file there?\n if File.file?(package_file_name)\n # Suck in the file.\n file = File.read(package_file_name)\n\n # Parse the file into a hash.\n package_file = JSON.parse(file)\n\n # Return the value of version.\n return package_file['version']\n else\n # FAIL something went wrong.\n raise Exception.new(\"File #{package_file_name} was not found. Check the file name.\")\n end\nend",
"def install_package host, package_name\n host.install_package package_name\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def set_package\n @package = Package.find(params[:id])\n end",
"def check_package(pkg)\n string = \"Looking for #{pkg}...\"\n installed = `#{ @options[:pkg_chkr] } | grep #{ pkg }`\n if installed !~ /.*#{ pkg }.*/\n installed = false\n else\n installed = true\n end #if\n \n installed\n end",
"def package_from_name(package_name)\n return self if package_name == self.name\n local_deps.find { |pkg| pkg.name == package_name }\n end",
"def create_package( package_name, is_public=true )\n page = \"/frs/admin/\"\n\n form = {\n \"func\" => \"add_package\",\n \"group_id\" => group_id,\n \"package_name\" => package_name,\n \"is_public\" => (is_public ? 1 : 0),\n \"submit\" => \"Create This Package\"\n }\n\n http_post(page, form)\n end",
"def get_nuget_path_of\n out = yield\n out.match(/Successfully created package '([:\\s\\p{Word}\\\\\\/\\d\\.\\-]+\\.symbols\\.nupkg)'./iu) if out.respond_to? :match\n trace \"Got symbols return value: '#{out}', matched: '#{$1}'\" if $1\n return $1 if $1\n\n out.match(/Successfully created package '([:\\s\\p{Word}\\\\\\/\\d\\.\\-]+\\.nupkg)'./iu)if out.respond_to? :match\n trace \"Got NOT-symbols return value: '#{out}', matched: '#{$1}'\"\n\n unless $1\n args = ARGV.inject(\"\") { |state, arg| state + \" \" + '\"' + arg + '\"' }\n warn do\n %{Couldn't match package, please run\n bundle exec rake DEBUG=true #{args} --trace\nand report a bug to albacore with the full output. Here's the nuget process output:\n--- START OUTPUT ---\n#{out}\n--- END OUTPUT ---\n}\n end\n end\n\n $1\n end",
"def download_if_necessary(package, version=nil)\n # TODO(sissel): this should just be a 'download' method, the 'if_necessary'\n # part should go elsewhere.\n path = package\n # If it's a path, assume local build.\n if File.directory?(path) or (File.exist?(path) and File.basename(path) == \"setup.py\")\n return path\n end\n\n logger.info(\"Trying to download\", :package => package)\n\n if version.nil?\n want_pkg = \"#{package}\"\n else\n want_pkg = \"#{package}==#{version}\"\n end\n\n target = build_path(package)\n FileUtils.mkdir(target) unless File.directory?(target)\n\n if attributes[:python_internal_pip?]\n # XXX: Should we detect if internal pip is available?\n attributes[:python_pip] = [ attributes[:python_bin], \"-m\", \"pip\"]\n end\n\n # attributes[:python_pip] -- expected to be a path\n if attributes[:python_pip]\n logger.debug(\"using pip\", :pip => attributes[:python_pip])\n # TODO: Support older versions of pip\n\n pip = [attributes[:python_pip]] if pip.is_a?(String)\n setup_cmd = [\n *attributes[:python_pip],\n \"download\",\n \"--no-clean\",\n \"--no-deps\",\n \"--no-binary\", \":all:\",\n \"-d\", build_path,\n \"-i\", attributes[:python_pypi],\n ]\n\n if attributes[:python_trusted_host]\n setup_cmd += [\n \"--trusted-host\",\n attributes[:python_trusted_host],\n ]\n end\n\n setup_cmd << want_pkg\n\n safesystem(*setup_cmd)\n\n # Pip removed the --build flag sometime in 2021, it seems: https://github.com/pypa/pip/issues/8333\n # A workaround for pip removing the `--build` flag. Previously, `pip download --build ...` would leave\n # behind a directory with the Python package extracted and ready to be used.\n # For example, `pip download ... Django` puts `Django-4.0.4.tar.tz` into the build_path directory.\n # If we expect `pip` to leave an unknown-named file in the `build_path` directory, let's check for\n # a single file and unpack it. I don't know if it will /always/ be a .tar.gz though.\n files = ::Dir.glob(File.join(build_path, \"*.tar.gz\"))\n if files.length != 1\n raise \"Unexpected directory layout after `pip download ...`. This might be an fpm bug? The directory is #{build_path}\"\n end\n\n safesystem(\"tar\", \"-zxf\", files[0], \"-C\", target)\n else\n # no pip, use easy_install\n logger.debug(\"no pip, defaulting to easy_install\", :easy_install => attributes[:python_easyinstall])\n safesystem(attributes[:python_easyinstall], \"-i\",\n attributes[:python_pypi], \"--editable\", \"-U\",\n \"--build-directory\", target, want_pkg)\n end\n\n # easy_install will put stuff in @tmpdir/packagename/, so find that:\n # @tmpdir/somepackage/setup.py\n dirs = ::Dir.glob(File.join(target, \"*\"))\n if dirs.length != 1\n raise \"Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{build_path}\"\n end\n return dirs.first\n end",
"def parsepkg package, force_rhel = nil\n raise \"Can't parse package name '#{package}'\" unless /(?<pkgname>^.*?)-(?<ver>[0-9\\.]*\\d)[.-](?<pkginfo>.*)$/ =~ package\n\n info = { name: pkgname, version: ver }\n pkgparts = pkginfo.split /[.-]/\n case info[:format] = pkgparts.pop\n when 'rpm'\n info[:arch] = pkgparts.pop\n raise \"Architecture '#{info[:arch]}' is not supported\" unless ['x86_64','noarch'].include? info[:arch]\n if pkgparts.detect { |c| /^(?:rh)?el(\\d)(_.*)?$/ =~ c }\n info[:rhel] = $~[1]\n else\n raise \"Can't determine CentOS release for '#{package}'. Force with -c option\" unless force_rhel\n info[:rhel] = force_rhel\n end\n when 'gem'\n else\n raise \"Suffix #{info[:format]} is not a recognized package type\"\n end\n return info\nend",
"def install_packages(app)\n\n `installer -pkg \"#{app}\" -target /`\n\nend",
"def install\n bin.install \"#{PACKAGE_NAME}\"\n end",
"def install_golang_package(resource_name)\n ChefSpec::Matchers::ResourceMatcher.new(:golang_package, :install, resource_name)\n end",
"def set_package\n @package = @product.packages.friendly.find(params[:id])\n end",
"def add_package(package)\n unless package\n raise ArgumentError,\n 'package must be specified'\n end\n unless package.is_a?(::Composer::Package::Package)\n raise TypeError,\n 'package must be a class or superclass of \\\n Composer::Package::Package'\n end\n\n initialize_repository unless @packages\n\n package.repository = self\n\n @packages << package\n\n if package.instance_of?(::Composer::Package::AliasPackage)\n aliased_package = package.alias_of\n if aliased_package.repository === nil\n add_package(aliased_package)\n end\n end\n end",
"def pkginfo_from_pkg(package)\n raise RuntimeError, \"#{self.class} needs to overwrite pkginfo_from_pkg\"\n end",
"def check_for_package host, package_name\n host.check_for_package package_name\n end",
"def package\n unless @package\n @package = package_resource_class.new(download_dest, run_context)\n tailor_package_to_platform\n end\n @package\n end",
"def check_for_package host, package_name\n host.check_for_package package_name\n end",
"def package_by_name(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package_by_name\"\n end",
"def k_package!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n\n type = K_PACKAGE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 341:4: 'package'\n match( \"package\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n\n end",
"def package(*patterns)\n install_package_matching patterns\n end",
"def package_dir\r\n \"${0%/#{target_name}}\"\r\n end",
"def package_from_name\n case name.downcase\n when 'splunk' then package :splunk\n when 'universal_forwarder' then package :universal_forwarder\n else raise 'Package must be specified (:splunk or :universal_forwarder)'\n end\n end",
"def build_package\n # Force timestamp to be initialized before anything else. This gives us a\n # stable timestamp for the process.\n timestamp\n # Prepare the work area: copy files from root_path to work_path based on\n # the resolved Manifest.txt.\n prepare_work_area\n # Anything that has been modified locally needs to be reset.\n restore_modified_files\n # Save both the final release metadata and the in-package release metadata.\n save_release_metadata\n # Vendor the dependencies for the package.\n vendor_dependencies\n # Request that supporting plug-ins build the package.\n request_build_package\n end"
] | [
"0.6721181",
"0.6697817",
"0.66569793",
"0.64866537",
"0.6472683",
"0.63942647",
"0.63173234",
"0.62789947",
"0.6266253",
"0.62093824",
"0.6207135",
"0.61850464",
"0.6180435",
"0.61732876",
"0.6159014",
"0.61224234",
"0.61205924",
"0.61154926",
"0.6093139",
"0.6078945",
"0.6055284",
"0.602561",
"0.60210943",
"0.59780514",
"0.5941704",
"0.59378195",
"0.59366584",
"0.59265435",
"0.5921221",
"0.59091467",
"0.5883105",
"0.58765256",
"0.5875841",
"0.58522344",
"0.5833412",
"0.5832034",
"0.5827974",
"0.5823818",
"0.5821804",
"0.5810206",
"0.58054435",
"0.57923585",
"0.57923585",
"0.5788973",
"0.5758308",
"0.5753285",
"0.57497734",
"0.57475394",
"0.57369095",
"0.5731093",
"0.57267296",
"0.57264704",
"0.5723071",
"0.57198715",
"0.5718044",
"0.57127154",
"0.5694578",
"0.5675125",
"0.56716394",
"0.56645083",
"0.56438553",
"0.56288046",
"0.56105494",
"0.5607084",
"0.5576084",
"0.5573496",
"0.5566416",
"0.55641913",
"0.5563536",
"0.55631524",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.5543242",
"0.55333763",
"0.55323994",
"0.5527706",
"0.5518278",
"0.5516084",
"0.55034816",
"0.55006456",
"0.5491754",
"0.5479496",
"0.5465046",
"0.5464731",
"0.5461464",
"0.5461432",
"0.5452374",
"0.54480505",
"0.54478747",
"0.5446705",
"0.5437337",
"0.54341215",
"0.54212886",
"0.5413534"
] | 0.83499026 | 0 |
def input Download the given package if necessary. If version is given, that version will be downloaded, otherwise the latest is fetched. | def download_if_necessary(package, version=nil)
# TODO(sissel): this should just be a 'download' method, the 'if_necessary'
# part should go elsewhere.
path = package
# If it's a path, assume local build.
if File.directory?(path) or (File.exist?(path) and File.basename(path) == "setup.py")
return path
end
logger.info("Trying to download", :package => package)
if version.nil?
want_pkg = "#{package}"
else
want_pkg = "#{package}==#{version}"
end
target = build_path(package)
FileUtils.mkdir(target) unless File.directory?(target)
if attributes[:python_internal_pip?]
# XXX: Should we detect if internal pip is available?
attributes[:python_pip] = [ attributes[:python_bin], "-m", "pip"]
end
# attributes[:python_pip] -- expected to be a path
if attributes[:python_pip]
logger.debug("using pip", :pip => attributes[:python_pip])
# TODO: Support older versions of pip
pip = [attributes[:python_pip]] if pip.is_a?(String)
setup_cmd = [
*attributes[:python_pip],
"download",
"--no-clean",
"--no-deps",
"--no-binary", ":all:",
"-d", build_path,
"-i", attributes[:python_pypi],
]
if attributes[:python_trusted_host]
setup_cmd += [
"--trusted-host",
attributes[:python_trusted_host],
]
end
setup_cmd << want_pkg
safesystem(*setup_cmd)
# Pip removed the --build flag sometime in 2021, it seems: https://github.com/pypa/pip/issues/8333
# A workaround for pip removing the `--build` flag. Previously, `pip download --build ...` would leave
# behind a directory with the Python package extracted and ready to be used.
# For example, `pip download ... Django` puts `Django-4.0.4.tar.tz` into the build_path directory.
# If we expect `pip` to leave an unknown-named file in the `build_path` directory, let's check for
# a single file and unpack it. I don't know if it will /always/ be a .tar.gz though.
files = ::Dir.glob(File.join(build_path, "*.tar.gz"))
if files.length != 1
raise "Unexpected directory layout after `pip download ...`. This might be an fpm bug? The directory is #{build_path}"
end
safesystem("tar", "-zxf", files[0], "-C", target)
else
# no pip, use easy_install
logger.debug("no pip, defaulting to easy_install", :easy_install => attributes[:python_easyinstall])
safesystem(attributes[:python_easyinstall], "-i",
attributes[:python_pypi], "--editable", "-U",
"--build-directory", target, want_pkg)
end
# easy_install will put stuff in @tmpdir/packagename/, so find that:
# @tmpdir/somepackage/setup.py
dirs = ::Dir.glob(File.join(target, "*"))
if dirs.length != 1
raise "Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{build_path}"
end
return dirs.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_url\n \"https://github.com/arduino/arduino-cli/releases/download/#{@desired_version}/#{package_file}\"\n end",
"def pkg_fetch\n return if File::exists? @srcdir\n\n sysprint \"#{@name} fetch: #{@fetch_url}\"\n\n # Try to guess by package URL extension\n if @fetch_url.match(/\\.git$/i)\n git_clone(@fetch_url, @srcdir)\n return\n end\n\n # Else use the URL to select fetch method\n protocol = @fetch_url.split(':')[0]\n\n if protocol.length == 0\n syserr \"Invalid package source URL #{@fetch_url}\"\n raise\n end\n\n case protocol\n when /^http$/i, /^https$/i, /^ftp$/i\n curl_fetch(@fetch_url, @srcdir)\n when /git/i\n git_clone(@fetch_url, @srcdir)\n else\n syserr \"Unhandled URL type: #{protocol}\"\n raise\n end\n end",
"def download\n @package = Package.find(params[:id])\n if @package.present?\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n else\n render page_not_found\n end\n end",
"def download_and_extract_package\n @fetcher.get_package_file(@package_name, @version)\n Gem::Package::TarReader.new( Zlib::GzipReader.open @fetcher.temp_package_file_path ) do |tar|\n tar.each do |entry|\n next unless entry.file? and entry.full_name.match(\"DESCRIPTION\")\n @package_desc = entry.read\n end\n end\n FileUtils.rm_rf @fetcher.temp_package_file_path\n end",
"def pkg_update\n pkg_fetch unless File::exists? @srcdir\n\n sysprint \"#{@name} update: #{@fetch_url}\"\n\n protocol = @fetch_url.split(':')\n\n if protocol.length == 0\n syserr \"Invalid package source URL #{@fetch_url}\"\n raise\n end\n\n case protocol\n when /^http$/i, /^https$/i, /^ftp$/i\n sysprint \"#{@name}: can't update from protocol #{protocol}\"\n when /git/i\n git_update(@fetch_url)\n else\n syserr \"Unhandled URL type: #{protocol}\"\n raise\n end\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def download_package\n path = download_path\n remote_file path do\n source URL\n action :create\n only_if { !::File.exist?(PATH) }\n end\n end",
"def download_prog(repo_hash)\n if (repo_hash[:source] == \"github\")\n clone_repo(repo_hash)\n elsif (repo_hash[:source] == \"rubygems\")\n puts \"Unpacking gem #{repo_hash[:name]}...\"\n system \"gem unpack #{repo_hash[:name]} --version #{repo_hash[:version]}\"\n else\n raise \"Unexpected source of repo #{repo_hash[:name]}: #{repo_hash[:source]}\"\n end\nend",
"def download_gem(name, version)\n cached = GemCache.get(name, version)\n return cached unless cached.nil?\n\n client.url = \"https://rubygems.org/gems/#{name}-#{version}.gem\"\n client.follow_location = true\n client.http_get\n gemf = client.body_str\n\n GemCache.set(name, version, gemf)\n gemf\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def download(build, installer_name)\n #delete the installer if there is with the similar name to make sure we are running the correct one\n\tFile.delete(installer_name) if File.exist?(installer_name)\n\traise \"Could not determine the latest build\\n\" if build <= 0 #Expected value is more than zero\n\tdownload_result = `scp [email protected]://opt//ctk//builds//numbered//sequenceL-Root-#{build}/#{$os_name}//installer.run #{installer_name}`\n\traise \"Error! The installer was not downloaded\\n\" unless File.exist?(installer_name)\n\t#error if the installer size is less than 5 MB\n\traise \"The installer is broken!\" unless File.size(installer_name)/(1024*1024) > 5\n\nend",
"def download\n # Turned off ssl verification\n # This should be acceptable because it won't happen on a user's machine, just CI\n\n # define a progress-bar printer\n chunk_size = 1024 * 1024 * 1024\n total_size = 0\n dots = 0\n dot_printer = lambda do |size|\n total_size += size\n needed_dots = (total_size / chunk_size).to_i\n unprinted_dots = needed_dots - dots\n @output.print(\".\" * unprinted_dots) if unprinted_dots.positive?\n dots = needed_dots\n end\n\n URI.open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url|\n File.open(package_file, 'wb') { |file| file.write(url.read) }\n end\n rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e\n @output.puts \"\\nArduino force-install failed downloading #{package_url}: #{e}\"\n end",
"def input(package)\n path_to_package = download_if_necessary(package, version)\n\n if File.directory?(path_to_package)\n setup_py = File.join(path_to_package, \"setup.py\")\n else\n setup_py = path_to_package\n end\n\n if !File.exist?(setup_py)\n logger.error(\"Could not find 'setup.py'\", :path => setup_py)\n raise \"Unable to find python package; tried #{setup_py}\"\n end\n\n load_package_info(setup_py)\n install_to_staging(setup_py)\n end",
"def download\n @cookbook = Cookbook.with_name(params[:cookbook]).first!\n @cookbook_version = @cookbook.get_version!(params[:version])\n\n CookbookVersion.increment_counter(:api_download_count, @cookbook_version.id)\n Cookbook.increment_counter(:api_download_count, @cookbook.id)\n Supermarket::Metrics.increment('cookbook.downloads.api')\n\n redirect_to @cookbook_version.tarball.url\n end",
"def fetch(version, extension)\n # Check if tag exists in current repo, if not fetch & recheck\n if !version_present_in_cache?(version)\n update_repository\n raise \"Version #{version} not found in #{extension} source\" if !version_present_in_cache?(version)\n end\n end",
"def fetch type, version, extension=\"tar.gz\"\n core_url = \"#{@base}/#{type}-#{version}.#{extension}\"\n tmp = Galaxy::Temp.mk_auto_file \"galaxy-download\"\n @log.info \"Fetching #{core_url} into #{tmp}\"\n if @base =~ /^http:/\n begin\n output = Galaxy::HostUtils.system(\"curl -D - #{core_url} -o #{tmp} -s\")\n rescue Galaxy::HostUtils::CommandFailedError => e\n raise \"Failed to download archive #{core_url}: #{e}\"\n end\n status = output.first\n (protocol, response_code, response_message) = status.split\n unless response_code == '200'\n raise \"Failed to download archive #{core_url}: #{status}\"\n end\n else\n open(core_url) do |io|\n File.open(tmp, \"w\") { |f| f.write(io.read) }\n end\n end\n return tmp\n end",
"def retrieve\n raise RetrieverError.new(\"download retriever is unavailable\") unless available?\n ::FileUtils.remove_entry_secure @repo_dir if File.exists?(@repo_dir)\n ::FileUtils.remove_entry_secure workdir if File.exists?(workdir)\n ::FileUtils.mkdir_p @repo_dir\n ::FileUtils.mkdir_p workdir\n file = ::File.join(workdir, \"package\")\n\n # TEAL FIX: we have to always-download the tarball before we can\n # determine if contents have changed, but afterward we can compare the\n # previous download against the latest downloaded and short-circuit the\n # remaining flow for the no-difference case.\n @logger.operation(:downloading) do\n credential_command = if @repository.first_credential && @repository.second_credential\n ['-u', \"#{@repository.first_credential}:#{@repository.second_credential}\"]\n else\n []\n end\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = [\n 'curl',\n '--silent', '--show-error', '--location', '--fail',\n '--location-trusted', '-o', file, credential_command,\n @repository.url\n ].flatten\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => workdir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, 'curl', e)\n raise\n end\n end\n\n note_tag(file)\n\n @logger.operation(:unpacking) do\n path = @repository.to_url.path\n if path =~ /\\.gz$/\n extraction = \"xzf\"\n elsif path =~ /\\.bz2$/\n extraction = \"xjf\"\n else\n extraction = \"xf\"\n end\n Dir.chdir(@repo_dir) do\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = ['tar', extraction, file]\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => @repo_dir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, @cmd.first, e)\n raise\n end\n end\n end\n true\n end",
"def set_default_version(version)\n return unless version\n \n self.download_url = version.download.url\n self.save\n end",
"def retrieve_version(name, version)\n path = downloaded_gem_path name, version\n parse :gem => path\n end",
"def download_source\n unless @download_source\n if new_resource.package_url\n res = chase_redirect(new_resource.package_url)\n else\n params = URI.encode_www_form(full: 1,\n plat: node['platform_family'][0..2])\n res = chase_redirect(\"https://www.dropbox.com/download?#{params}\")\n end\n end\n @download_source ||= res\n end",
"def run\n if @name_args.length != 2\n Chef::Log.fatal(\"You must supply a cookbook name and version to download!\")\n exit 42\n end\n \n cookbook_name = @name_args[0]\n cookbook_version = @name_args[1] == 'latest' ? '_latest' : @name_args[1]\n Chef::Log.info(\"Downloading #{cookbook_name} cookbook version #{cookbook_version}\")\n \n cookbook = rest.get_rest(\"cookbooks/#{cookbook_name}/#{cookbook_version}\")\n manifest = cookbook.manifest\n\n basedir = File.join(config[:download_directory], \"#{cookbook_name}-#{cookbook.version}\")\n if File.exists?(basedir)\n if config[:force]\n Chef::Log.debug(\"Deleting #{basedir}\")\n FileUtils.rm_rf(basedir)\n else\n Chef::Log.fatal(\"Directory #{basedir} exists, use --force to overwrite\")\n exit\n end\n end\n \n Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment|\n next unless manifest.has_key?(segment)\n Chef::Log.info(\"Downloading #{segment}\")\n manifest[segment].each do |segment_file|\n dest = File.join(basedir, segment_file['path'].gsub('/', File::SEPARATOR))\n Chef::Log.debug(\"Downloading #{segment_file['path']} to #{dest}\")\n FileUtils.mkdir_p(File.dirname(dest))\n rest.sign_on_redirect = false\n tempfile = rest.get_rest(segment_file['url'], true)\n FileUtils.mv(tempfile.path, dest)\n end\n end\n Chef::Log.info(\"Cookbook downloaded to #{basedir}\")\n end",
"def package(version)\n packages[version] if package_setup.include? version\n end",
"def fetch_gem(name, version)\n http_get(host + \"/gems/#{name}-#{version}.gem\").body\n end",
"def download\n cookbook = Cookbook.with_name(params[:id]).first!\n latest_version = cookbook.latest_cookbook_version\n redirect_to cookbook_version_download_url(cookbook, latest_version)\n end",
"def curl_fetch(url, target, param='')\n file_dist = File::join(DISTFILES, File::basename(url))\n\n unless File::exists? DISTFILES\n FileUtils::mkdir_p(DISTFILES)\n end\n\n if File::exists? file_dist\n sysprint \"Package file #{file_dist} already exists\"\n package_extract(file_dist, target)\n return\n end\n\n result = 0\n unless sysexec(\"curl -# -L #{param} \\\"#{url}\\\" -o \\\"#{file_dist}\\\"\")\n syserr \"cURL failed\"\n raise\n end\n\n package_extract(file_dist, target)\nend",
"def download_src(src_package, src_dir)\n deprec.groupadd(group)\n sudo \"test -d #{src_dir} || sudo mkdir #{src_dir}\" \n sudo \"chgrp -R #{group} #{src_dir}\"\n sudo \"chmod -R g+w #{src_dir}\"\n # XXX check if file exists and if we have and MD5 hash or bytecount to compare against\n # XXX if so, compare and decide if we need to download again\n if defined?(src_package[:md5sum])\n md5_clause = \" && echo '#{src_package[:md5sum]}' | md5sum -c - \"\n end\n sudo <<-SUDO\n sh -c \"cd #{src_dir} && test -f #{src_package[:file]} #{md5_clause} || wget --timestamping #{src_package[:url]}\"\n SUDO\n end",
"def core_fetch_dependency(package_name, vers, type, verbose)\n prerelease = false\n if vers == '>= 0-pre'\n prerelease = true\n vers = '>= 0'\n else\n prerelease = vers =~ /[a-zA-Z]/\n end\n\n dep = LibGems::Dependency.new(package_name, vers, type)\n cur_installed = LibGems.source_index.search(dep)\n\n begin\n installed = BPM::Remote.new.install(package_name, vers, prerelease)\n rescue LibGems::GemNotFoundException\n # If we have it locally but not remote, that's ok\n installed = []\n end\n\n cur_installed.each do |ci|\n installed.reject! { |i| ci.name == i.name && ci.version == i.version }\n end\n\n installed.each do |i|\n say \"~ Fetched #{i.name} (#{i.version}) from remote\"\n end\n\n end",
"def main\n last_good_root = from_file($cache_dir + '/root.txt') ||\n from_file('config/root.txt') ||\n raise(\"Can't find root.txt\")\n\n repository = Gem::TUF::Repository.new(\n root: JSON.parse(last_good_root),\n bucket: FileCachingBucket.new(HttpBucket.new($host))\n )\n\n gem_name = ARGV.shift\n\n specs = repository.target('latest_specs.4.8.gz')\n raise \"could not find latest_specs.4.8.gz\" unless specs\n specs = unmarshal_gz specs\n gem = specs.detect {|x| x[0] == gem_name } || raise(\"Can't find gem #{gem}\")\n\n gem_with_version = \"#{gem[0]}-#{gem[1]}\"\n gem_path = \"gems/#{gem_with_version}.gem\"\n gemspec_path = \"quick/Marshal.4.8/#{gem_with_version}.gemspec.rz\"\n\n repository.target(gemspec_path)\n repository.target(gem_path)\n\n puts \"Downloaded #{gem_path} and #{gemspec_path}\"\nend",
"def download\n respond_to do |format|\n if @package.present?\n format.html do\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n end\n \n format.json { render :text => @package.to_json(:methods => [:name, :display_name]) }\n else\n render page_not_found\n end\n end\n end",
"def download\n respond_to do |format|\n if @package.present?\n format.html do\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n end\n \n format.json { render :text => @package.to_json(:methods => [:name, :display_name]) }\n else\n render page_not_found\n end\n end\n end",
"def download(project:, build_number:, flavor:, name:, pre_apply_hook:, output_dir:)\n raise \"#{self.class}#download not implemented\"\n end",
"def package_download_url\n package_filename_url_safe = Info.release_version.gsub(\"+\", \"%2B\")\n \"https://#{Info.release_bucket}.#{Info.release_bucket_s3_endpoint}/ubuntu-focal/#{Info.package}_#{package_filename_url_safe}_amd64.deb\"\n end",
"def download(url)\n file = File.basename(url)\n # Resume an interrupted download or fetch the file for the first time. If\n # the file on the server is newer, then it is downloaded from start.\n sh \"wget -Nc --no-verbose #{url}\"\n # If the local copy is already fully retrieved, then the previous command\n # ignores the timestamp. So we check with the server again if the file on\n # the server is newer and if so download the new copy.\n sh \"wget -N --no-verbose #{url}\"\n\n # Download Md5\n sh \"wget --no-verbose #{url}.md5\"\n\n # Verify the tarball using md5sum or md5\n if system(\"which md5sum > /dev/null\")\n matched = system(\"md5sum -c #{file}.md5\")\n elsif system(\"which md5 > /dev/null\")\n md5_out = %x[md5 -q #{file}].chomp\n md5_actual = File.read(\"#{file}.md5\").split[0]\n matched = md5_out == md5_actual\n else\n puts \"Cannot find md5sum or md5. Please install md5sum or md5 and try again\"\n exit 1\n end\n\n # Re-download tarball if corrupt; extract otherwise.\n if !matched\n sh \"rm #{file} #{file}.md5\"; download(url)\n else\n sh \"tar xf #{file}\"\n end\nend",
"def download\n @extension = Extension.with_name(params[:extension]).first!\n @extension_version = @extension.get_version!(params[:version])\n\n ExtensionVersion.increment_counter(:api_download_count, @extension_version.id)\n Extension.increment_counter(:api_download_count, @extension.id)\n BonsaiAssetIndex::Metrics.increment('extension.downloads.api')\n\n redirect_to @extension_version.tarball.url\n end",
"def package(name)\n if name.respond_to? :cache_path\n name\n elsif @versions[name]\n Package.for(@sources[name], @versions[name], @files[name])\n end\n end",
"def download!(type, opts={})\n raise ArgumentError, \"Patch #{self.inspect} requires a major number to download\" unless @major\n raise ArgumentError, \"Patch #{self.inspect} requires a minor number to download\" unless @minor\n raise ArgumentError, \"Unknown type #{type.inspect}\" unless URL[type]\n url = URL[type] % self.to_s\n opts = {\n :agent => 'Wget/1.10.2', # default user agent, required by Oracle\n }.merge(opts)\n Solaris::Util.download!(url, opts)\n end",
"def download_build(entry, java_home, version)\n installer = File.join(Dir.tmpdir, \"ibmjava\" + version.to_s + \"-installer\")\n properties = File.join(Dir.tmpdir, \"installer.properties\")\n\n # Create installer properties for silent installation\n file properties do\n content \"INSTALLER_UI=silent\\nUSER_INSTALL_DIR=#{java_home}\\nLICENSE_ACCEPTED=TRUE\\n\"\n action :create\n end\n\n # Download the IBM Java installer from source url to the local machine\n remote_file installer do\n src_url = entry['uri']\n source src_url.to_s\n mode '0755'\n checksum entry['sha256sum']\n action :create\n end\n\n # check_sha(installer, entry['sha256sum'])\n\n # Install IBM Java build\n execute \"#{installer} -i silent -f #{properties}\"\n\n file properties do\n action :delete\n end\n\n file installer do\n action :delete\n end\n end",
"def resolve( name, version )\n # It is possible, and almost inevitable, that we can install two packages that must oscilate\n # at the same time. As a result, we will be relinking a package that has not been installed yet,\n # but will be on the next commit. In this situation, we need keep a cache of packages mapped in\n # this session, so that when this occurs, we can resolve it with no problems. In this way, we\n # maintain an instance variable hash that is added to whenever map() is called\n cached = @pkg_cache[ \"%s-%s\" % [ name, version ] ]\n if( cached != nil )\n return cached\n end\n\n # Past this, we do not want to proceed if the package is not present in the install\n # dir\n\n # We ensure that this package is in fact installed\n if( !File.directory?( Config.instance.install_dir + \"/\" + name + \"/\" + version ) )\n puts \"%s-%s is not installed!\" % [ name, version ]\n return nil\n end\n\n # If the cache file exists and is in fact a file, slurp it up and use that\n # I'd love to do some digest check here to:\n # 1. Ensure that the cache file is intact and valid\n # 2. The directory installed matches the one that this cache file was generated from\n\n # First, we check the cache to see if we've resolved this package before\n # Figure out where the cache file would be if it existed\n cache_file = Config.instance.cache_dir + \"/\" + name + \"-\" + version + \".json\"\n if( File.file?( cache_file ) )\n file = File.new( cache_file, \"r\" )\n buff = \"\"\n while (line = file.gets)\n buff += line\n end\n file.close( )\n pkg = JSON.parse( buff )\n return pkg\n end\n\n # If we haven't, we'll need to do a full trace of the package\n\n # It may be better to store all of our package file in\n # $(install_dir)/$(name)/$(version)/pkg_files\n # and store the manifest next to pkg_files\n # Therefore, when we need to do this, we can just consult the manifest for\n # data such as dependencies\n pkg = map( Config.instance.install_dir + \"/\" + name + \"/\" + version )\n file = File.new( cache_file, \"w\" )\n\n # Write metadata\n file.write( pkg.to_json( ) )\n\n file.close( )\n\n return pkg\n end",
"def package_repository(package_name, desired_version, arch = nil)\n package(package_name, arch, true, false) do |pkg|\n return pkg.repoid if desired_version == pkg.version.to_s\n end\n\n nil\n end",
"def download(*args, &block)\n # options are ignored\n # options = args.last.is_a?(Hash) ? args.pop : Hash.new\n dependency, version = args\n\n sources.each do |source|\n if ( result = try_download(source, dependency, version) )\n if block_given?\n value = yield result\n FileUtils.rm_rf(result)\n return value\n end\n\n return result\n end\n end\n\n raise CookbookNotFound.new(dependency, version, \"in any of the sources\")\n end",
"def get_download_url(author, repository, options)\n release_info = get_release_info(author, repository, options)\n\n if options[:asset] && release_info\n download_url = get_asset(release_info, options[:asset_filepattern], options[:asset_contenttype])\n return download_url unless download_url == ''\n\n get_archive_from_release_info(release_info, options[:use_zip])\n elsif release_info\n get_archive_from_release_info(release_info, options[:use_zip])\n elsif options[:asset_fallback] || !options[:asset]\n build_asset_url(\n author,\n repository,\n options,\n )\n else\n raise ArgumentError(\"Can't find download url for given criteria\")\n end\nend",
"def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end",
"def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end",
"def update!(**args)\n @download_url = args[:download_url] if args.key?(:download_url)\n end",
"def update!(**args)\n @download_url = args[:download_url] if args.key?(:download_url)\n end",
"def update(options = { :build => :rb }) # Options: { :build => :rb/:beta/:dev }\n Bukkit::Server.download(\"http://dl.bukkit.org/latest-#{options[:build].to_s}/craftbukkit.jar\")\n end",
"def download_installer\n puts pe_installer_url\n unless `curl #{pe_installer_url} -o ./file_cache/installers/#{installer_filename}`\n fail \"Error downloading the PE installer\"\n end\n gzip_installer if PRE_RELEASE\nend",
"def from_rubygems(name, version)\n download_gem name, version\n from_gem downloaded_gem_path(name, version)\n end",
"def fetch_file(url)\n url =~ %r{/([^/]*)\\.(tar\\.gz|tar\\.bz2|tgz|zip|tbz)$}\n name = $1\n ext = $2\n filename = \"#{name}.#{ext}\"\n archive = File.join(env.path, \"archives\", filename)\n\n rbvm_md5 = config_md5[filename]\n\n if File.exists?(archive)\n archive_md5 = Digest::MD5.file(archive)\n if rbvm_md5\n if archive_md5.to_s == rbvm_md5\n log(\"Using existing archive for #{filename}.\", \"info\")\n fetch = false\n else\n log(\"Existing archive has bad MD5, backup and download again.\", \"error\")\n FileUtils.mv(archive, File.join(env.path, \"archives\", \"#{filename}-#{Time.now.strftime(\"%Y%m%d%H%M%S\")}.orig\"))\n archive_md5 = nil\n fetch = true\n end\n else\n log(\"Unknown archive: #{archive}\", \"warn\")\n fetch = false\n end\n else\n fetch = true\n end\n\n if fetch\n catch_error(\"Failed to fetch: #{url}\") do\n log(\"#{name} - #fetching\", 'info')\n exec_cmd(\"curl\", \"-s\", \"-S\", \"-L\", \"--create-dirs\", \"-C\", \"-\", \"-o\", archive, url)\n end\n end\n\n return archive\n end",
"def package(name, version=nil, options={:q => true, :y => true})\n name = \"#{name}=#{version}\" unless version.to_s.strip.empty?\n execute \"apt-get install\", name, options\n chain_proxy\n end",
"def download(path)\n Gem.ensure_gem_subdirectories path\n\n if @spec.respond_to? :sources\n exception = nil\n path = @spec.sources.find do |source|\n begin\n source.download full_spec, path\n rescue exception\n end\n end\n return path if path\n raise exception if exception\n\n elsif @spec.respond_to? :source\n source = @spec.source\n source.download full_spec, path\n\n else\n source = Gem.sources.first\n source.download full_spec, path\n end\n end",
"def package\n unless @package\n @package = package_resource_class.new(download_dest, run_context)\n tailor_package_to_platform\n end\n @package\n end",
"def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend",
"def get_version!(version)\n version.gsub!(/_/, '.')\n\n if version == 'latest'\n cookbook_versions.first!\n else\n cookbook_versions.find_by!(version: version)\n end\n end",
"def artifact_download_url_for(node, source)\n # TODO: Move this method into the nexus-cli\n config = data_bag_config_for(node, source)\n nexus_path = config['path']\n group_id, artifact_id, version, extension, classifier = source.split(':')\n uri_for_url = URI(config['url'])\n builder = uri_for_url.scheme =~ /https/ ? URI::HTTPS : URI::HTTP\n is_content_path_enabled = use_content_path node\n query_string = \"g=#{group_id}&a=#{artifact_id}&v=#{version}&e=#{extension}&r=#{config['repository']}&c=#{classifier}\"\n if is_content_path_enabled\n if version.downcase.include? 'snapshot'\n builder.build(:host => uri_for_url.host, :port => uri_for_url.port, :path => \"#{nexus_path}/service/local/artifact/maven/redirect\", :query => query_string).to_s\n else\n ##\n Chef::Log.info \"g-#{group_id} a-#{artifact_id} v-#{version} e-#{extension} c-#{classifier} repo #{config['repository']} url #{config['url']} path #{config['path']}\"\n gav_path=get_gav_path(group_id, artifact_id, version)\n f_name = get_download_fname(artifact_id, version, classifier, extension)\n if nexus_path ==''\n content_url=\"#{config['repository']}/#{gav_path}/#{f_name}\"\n builder.build(:host => uri_for_url.host, :port => uri_for_url.port, :path => \"/#{content_url}\").to_s\n else\n # remove leading trailing /\n path = nexus_path.gsub(/^\\//, '')\n path = \"#{path.gsub(/\\/$/, '')}/content/repositories/#{config['repository']}\"\n content_path = \"#{path}/#{gav_path}\"\n content_url = \"#{content_path}/#{f_name}\"\n Chef::Log.info \"download url #{content_url}\"\n builder.build(:host => uri_for_url.host, :port => uri_for_url.port, :path => \"/#{content_url}\").to_s\n end\n end\n else\n builder.build(:host => uri_for_url.host, :port => uri_for_url.port, :path => \"#{nexus_path}/service/local/artifact/maven/redirect\", :query => query_string).to_s\n end\n end",
"def download!\n\t\traise_if_error C.glyr_opt_download(to_native, true)\n\tend",
"def download!(url, path)\n raise CommandFailed unless download(url, path)\n end",
"def download(url, filename)\n require 'open-uri'\n if File.exists?(\"lib/\" + filename)\n puts \"'#{filename}' is already downloaded... skipped\"\n else\n puts \"'#{filename}' downloading...\"\n File.open(\"lib/\" + filename, \"wb\") do |saved_file|\n open(url + filename, \"rb\") { |read_file| saved_file.write(read_file.read) }\n end\n end\nend",
"def latest\n url = \"https://pypi.python.org/pypi/#{URI.encode(@resource[:name])}/json\"\n result = self.open_jsonurl(url)\n result['info']['version'] if result != nil\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Error in contacting pypi.python.org: #{detail}\"\n end",
"def download_patch!(opts={})\n download!(:patch, opts)\n end",
"def fetch(options = {})\n unless options[:version]\n puts 'You must supply a :version number (or tag) when importing data from Design Sync'\n exit 1\n end\n v = options[:vault]\n f = v.split('/').last\n vault = v.sub(/\\/#{f}$/, '')\n # Consider that similarly named files could exist in different vaults, so attach\n # a representation of the vault to the filename\n vault_hash = Digest::SHA1.hexdigest(vault)\n dir = \"#{import_dir}/#{vault_hash}-#{f}\"\n file = \"#{dir}/#{options[:version]}\"\n if f =~ /.*\\.(.*)/\n file += \".#{Regexp.last_match[1]}\"\n end\n if !File.exist?(file) || options[:force]\n FileUtils.mkdir_p(dir) unless File.exist?(dir)\n driver.import(f, vault, options[:version], dir)\n FileUtils.mv(\"#{dir}/#{f}\", file)\n end\n file\n end",
"def retrieve(name, version=nil)\n version.nil? ? retrieve_latest(name) : retrieve_version(name, version)\n end",
"def addon name,version=@@latest_version\n config = get_config(self._version)\n addon_author,addon_name = name.split(\"/\")\n if File.exists?(\"#{config[\"dirname\"]}/addons/#{addon_name}\")\n puts \"update #{name}\"\n `cd #{config[\"dirname\"]}/addons/#{addon_name} && git pull` \n else\n puts \"clone #{name}\"\n `cd #{config[\"dirname\"]}/addons && git clone https://github.com/#{name}.git` \n end\n end",
"def download(args = {})\n\t # \n\t # parse arguments\n\t # \n\t if args.keys.size == 1 and args.values.size == 1\n\t url = args.keys.first\n\t output_path = args.values.first\n\t else\n\t raise \"download() currently only accepts one {URL => location} pair\"\n\t end\n\t \n\t # \n\t # perform the download\n\t # \n\t \n\t # https://stackoverflow.com/questions/2263540/how-do-i-download-a-binary-file-over-http\n\t # instead of http.get\n\t require 'open-uri'\n\t \n\t File.open(output_path, \"wb\") do |saved_file|\n\t # the following \"open\" is provided by open-uri\n\t open(url, \"rb\") do |read_file|\n\t saved_file.write(read_file.read)\n\t end\n\t end\n\t \n\t return output_path\n\tend",
"def latest_version(name)\n return JSON.parse(open(\"http://rubygems.org/api/v1/gems/#{name}.json\").read)['version']\n end",
"def download_sources(url)\n filename = \"v#{version}.tar.gz\"\n cached_sources = File.join(SOURCES_CACHE_DIR, filename)\n\n if CfObsBinaryBuilder::CACHE_SOURCES\n FileUtils.mkdir_p(SOURCES_CACHE_DIR)\n if !File.exist?(cached_sources)\n system(\"wget #{url} -O #{cached_sources}\")\n end\n FileUtils.copy(cached_sources, filename)\n else\n system(\"wget #{url} -O #{filename}\")\n end\n end",
"def force_install(output = $stdout, version = DESIRED_ARDUINO_IDE_VERSION)\n worker_class = case Host.os\n when :osx then ArduinoDownloaderOSX\n when :windows then ArduinoDownloaderWindows\n when :linux then ArduinoDownloaderLinux\n end\n worker = worker_class.new(version, output)\n worker.execute\n end",
"def download_command(src, name, folder_name, data)\n url = data[:url]\n if src.to_s == \"bandcamp_urls\"\n download_bandcamp_url(folder_name, url)\n elsif src.to_s == \"youtube_urls\"\n download_youtube_url(folder_name, url)\n end\n end",
"def retrieve_latest(name)\n client.url = \"https://rubygems.org/api/v1/gems/#{name}.json\"\n client.http_get\n spec = client.body_str\n gem = parse spec\n gem\n end",
"def get_ai_repo_version(options)\n options = get_ai_publisherurl(options)\n if options['test'] == true || options['host-os-name'].to_s.match(/Darwin/)\n version = \"0.175.1\"\n else\n message = \"Information:\\tDetermining if available repository version from \"+options['publisherurl']\n command = \"pkg info -g #{options['publisherurl']} entire |grep Branch |awk \\\"{print \\\\\\$2}\\\"\"\n version = execute_command(options,message,command)\n version = version.chomp\n version = version.split(/\\./)[0..2].join(\".\")\n end\n return version\nend",
"def _tryDownload?(node, item) \n if node['daris']['use_local_daris_builds'] then\n return false\n elsif node['daris'][item] then\n return true\n else \n version_info = getRelease(node)[item] || ['1.0', '1.0', false]\n return version_info.length < 3 || version_info[2]\n end\n end",
"def package\n p = Package.where(:id => self.package_id).first\n p ||= package_branch.latest(manifest) if package_branch.present?\n p\n end",
"def download_install_file(action, args={})\n company = @company\n username = @user\n password = @password\n url = \"https://#{company}.logicmonitor.com/santaba/do/#{action}?\"\n args.each_pair do |key, value|\n url << \"#{key}=#{value}&\"\n end\n url << \"c=#{company}&u=#{username}&p=#{password}\"\n uri = URI(url)\n begin\n http = Net::HTTP.new(uri.host, 443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(req)\n return response.body\n rescue SocketError => se\n puts \"There was an issue communicating with #{url}. Please make sure everything is correct and try again.\"\n puts se.message\n rescue Error => e\n puts \"There was an issue.\"\n puts e.message\n end\n return nil\nend",
"def download_wordpress\n package = \"/tmp/wordpress-#{@config[:wp_version]}.zip\"\n # Download package file\n if ::File.exists?(package)\n @task.say_warning \"WordPress is already downloaded...\", false, true\n else ::File.exists?(package)\n @task.say_info \"Downloading WordPress...\", false, true\n\n @task.get \"https://wordpress.org/wordpress-#{@config[:wp_version]}.zip\" do |content|\n @task.create_file package, content\n end\n end\n # Return package file\n package\n end",
"def net_http_get_package_info\n thread = @thread\n timestamp = Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S\\+0000\")\n\n uri = URI(\"#{@sendsafely_url}/#{API}/package/#{@thread}/\")\n\n req = Net::HTTP::Get.new(uri)\n req['Content-Type'] = 'application/json'\n req['ss-api-key'] = @sendsafely_key_id\n req['ss-request-timestamp'] = timestamp\n req['ss-request-signature'] = OpenSSL::HMAC.hexdigest(\"SHA256\", @sendsafely_key_secret, @sendsafely_key_id+\"/#{API}/package/#{thread}\"+timestamp)\n\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http|\n http.request(req)\n }\n\n puts res.body\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def fetch\n notify \"Downloading...\"\n @strategy.fetch\n extract\n end",
"def download(required_version = :latest)\n required_version = latest if required_version == :latest\n download_file_name = \"selenium-server-#{required_version}.jar\"\n\n return download_file_name if File.exist? download_file_name\n\n begin\n download_location = available_assets[download_file_name]['browser_download_url']\n released = Net::HTTP.get_response(URI.parse(download_location))\n redirected = URI.parse released.header['location']\n\n File.open(download_file_name, 'wb') do |destination|\n download_server(redirected, destination)\n end\n rescue StandardError\n FileUtils.rm_rf download_file_name\n raise\n end\n\n download_file_name\n end",
"def download(url='http://download.openvz.org/template/precreated/')\n\t\ttemplate = ostemplate\n\t\tfile = @@vzcache + template + '.tar.gz'\n if !File.file? file or File.zero? file\n\t\t\trequire 'open-uri'\n\t\t\tdebug \"Downloading template '\" + template + \"' to directory: '\" + @@vzcache + \"'\"\n\t\t\twriteOut = open(file, \"wb\")\n\t\t\twriteOut.write(open(url + '/' + template + '.tar.gz').read)\n\t\t\twriteOut.close\n\t\tend\n\tend",
"def download name\n @checked += 1\n gem_name = \"#{name}.gem\"\n\n if gem_exists? gem_name then\n @gem_queue.push name\n\n info \"#{gem_name} exists\"\n\n return\n end\n\n uri = @base_uri + \"#{name}.gem\"\n\n source_etag = nil\n dest_etag = nil\n\n @http.request uri do |source_res|\n break unless etag = source_res['ETag']\n source_etag = etag.delete '\"'\n\n dest_etag = @swift.write_object @gems_container, gem_name do |io|\n source_res.read_body do |chunk|\n io.write chunk\n end\n end\n end\n\n if dest_etag == source_etag then\n @gem_queue.push name\n\n info \"#{gem_name} downloaded\"\n\n @downloaded += 1\n else\n @gem_name_queue.push name\n @swift.delete_object @gems_container, gem_name\n\n info \"#{gem_name} download failed\"\n @failed += 1\n end\n end",
"def version_for_cache\n \"download_url:#{source[:url]}|#{digest_type}:#{checksum}\"\n end",
"def download(description = @component_name, &block)\n super_download @version, @uri, description, &block\n end",
"def publish_to_package_manager(version)\nend",
"def publish_to_package_manager(version)\nend",
"def latest_version\n @latest_version ||= with_cache(file_name) { normalize_version(Network.get_url(\"#{base_url}/latest\")[/[^v]*$/]) }\n end",
"def download(command)\n if command[1].nil? || command[1].empty?\n puts \"please specify item to get\"\n elsif command[2].nil? || command[2].empty?\n puts \"please specify full local path to dest, i.e. the file to write to\"\n elsif File.exists?(command[2])\n puts \"error: File #{dest} already exists.\"\n else\n src = '/' + clean_up(command[1])\n dst = command[2]\n out, metadata = @client.files.download(src)\n pp metadata\n open(dst, 'w') { |f| f.puts out }\n puts \"wrote file #{ dst }.\"\n end\n end",
"def download\n trace \"Downloading #{to_spec}\"\n remote = Buildr.repositories.remote_uri\n remote = remote.each { |repo_url| repo_url.path += '/' unless repo_url.path[-1] == '/' }\n fail \"Unable to download #{to_spec}. No remote repositories defined.\" if remote.empty?\n exact_success = remote.find do |repo_url|\n begin\n path = \"#{group_path}/#{id}/#{version}/#{File.basename(name)}\"\n download_artifact(repo_url + path)\n true\n rescue URI::NotFoundError\n false\n rescue Exception=>error\n info error\n trace error.backtrace.join(\"\\n\")\n false\n end\n end\n\n if exact_success\n return\n elsif snapshot?\n download_m2_snapshot(remote)\n else\n fail_download(remote)\n end\n end",
"def download_strategy\n CurlDownloadStrategy\n end",
"def build_command(version, prerelease = false, download_path = nil)\n command = \"curl -sL #{OMNITRUCK} | sudo bash\"\n\n if prerelease || version != :latest || download_path != nil\n command << \" -s --\"\n end\n\n if prerelease\n command << \" -p\"\n end\n\n if version != :latest\n command << \" -v \\\"#{version}\\\"\"\n end\n\n if download_path\n command << \" -d \\\"#{download_path}\\\"\"\n end\n\n command\n end",
"def get_latest_version(opts)\n doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)\n link = doc.at_css('a[title^=\"File:\"]')\n date = link.content.scan(/(\\d+)\\./)[0][0]\n DateTime.strptime(date, '%Y%m%d').to_time.to_i\n end",
"def download(full_spec, path) # :nodoc:\n end",
"def download_strategy\n case url\n when %r[^cvs://] then CVSDownloadStrategy\n when %r[^hg://] then MercurialDownloadStrategy\n when %r[^svn://] then SubversionDownloadStrategy\n when %r[^svn+http://] then SubversionDownloadStrategy\n when %r[^git://] then GitDownloadStrategy\n when %r[^https?://(.+?\\.)?googlecode\\.com/hg] then MercurialDownloadStrategy\n when %r[^https?://(.+?\\.)?googlecode\\.com/svn] then SubversionDownloadStrategy\n when %r[^https?://(.+?\\.)?sourceforge\\.net/svnroot/] then SubversionDownloadStrategy\n when %r[^http://svn.apache.org/repos/] then SubversionDownloadStrategy\n else CurlDownloadStrategy\n end\n end",
"def download(spec, dir=Dir.pwd)\n fetcher = Gem::RemoteFetcher.fetcher\n fetcher.download spec, uri.to_s, dir\n end",
"def download\n res = @stash_identifier.last_submitted_resource\n if res&.download_uri\n res = @stash_identifier.last_submitted_resource\n StashEngine::CounterLogger.version_download_hit(request: request, resource: res) if res\n redirect_to res.merritt_producer_download_uri # latest version, friendly download because that's what we do in UI for object\n else\n render text: 'download for this dataset is unavailable', status: 404\n end\n end",
"def fetch_obs_packages\n log.info \"Fetching all required packages\"\n yast_url.each_with_index do |url, index|\n system \"zypper --root #{cache_dir} ar --no-gpgcheck -p #{index + 1} #{url} \" \\\n \"download-packages-#{index}\"\n end\n system \"xargs -a #{obs_pkg_list_path} zypper --root #{cache_dir} \" \\\n \"--pkg-cache-dir=#{cache_dir} download\"\n\n yast_url.size.times { |i| system \"zypper --root #{cache_dir} rr download-packages-#{i}\" }\n\n log.info \"Fetching packages from extra repositories\"\n @extra_repos.each do |repo|\n system \"zypper --root #{cache_dir} ar --no-gpgcheck #{repo[:server]} \" \\\n \"download-extra-packages\"\n system \"zypper --root #{cache_dir} --pkg-cache-dir=#{cache_dir} \" \\\n \"download #{repo[:packages].join(\" \")}\"\n system \"zypper --root #{cache_dir} rr download-extra-packages\"\n end\n end",
"def download(url)\n Net::HTTP.get_response(url)\n end",
"def check_ai_pkg_repo(options,p_struct,pkg_name,pkg_repo_dir)\n pkg_version=p_struct[pkg_name].version\n message = \"Information:\\tChecking if repository contains \"+pkg_name+\" \"+pkg_version\n command = \"pkg info -g #{pkg_repo_dir} -r #{pkg_name} |grep Version |awk \\\"{print \\\\\\$2}\\\"\"\n output = execute_command(options,message,command)\n repo_pkg_version = output.chomp\n return repo_pkg_version\nend",
"def find_version_entry(url, version)\n finalversion = nil\n version = '1.'.concat(version.to_s) unless version.to_s.include?('.')\n yaml_content = open(url.to_s, &:read)\n entries = YAML.safe_load(yaml_content)\n entries.each do |entry|\n finalversion = entry[1] if entry[0].to_s.start_with?(version.to_s)\n end\n finalversion\n end",
"def get_package request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_package_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::ArtifactRegistry::V1beta2::Package.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def check_version_or_latest_version(version = nil)\n version ||= latest_version\n raise Ajaxlibs::Exception::VersionNotFound unless self.class::Versions.include?(version)\n version\n end"
] | [
"0.66082",
"0.6500708",
"0.65005857",
"0.63652635",
"0.63261336",
"0.6306271",
"0.6284326",
"0.62791574",
"0.6231793",
"0.6183503",
"0.6091942",
"0.6078996",
"0.6056343",
"0.60539496",
"0.60408443",
"0.6037726",
"0.6022357",
"0.59733886",
"0.5967504",
"0.5946641",
"0.59356016",
"0.59231937",
"0.5922443",
"0.59112996",
"0.5898981",
"0.5896867",
"0.5866606",
"0.5864333",
"0.579435",
"0.579435",
"0.5793813",
"0.5768892",
"0.57651836",
"0.57428885",
"0.57272863",
"0.57167816",
"0.5708475",
"0.5703503",
"0.56851757",
"0.5661249",
"0.5660968",
"0.5624615",
"0.5624615",
"0.5622754",
"0.5622754",
"0.5622011",
"0.5606717",
"0.5573155",
"0.556143",
"0.5556359",
"0.55518675",
"0.5542588",
"0.5516344",
"0.55142695",
"0.548943",
"0.54678935",
"0.54669523",
"0.5466627",
"0.546407",
"0.5462691",
"0.54603857",
"0.54546654",
"0.54377437",
"0.5436473",
"0.5432636",
"0.542901",
"0.5427653",
"0.54268867",
"0.5423961",
"0.5405947",
"0.5404142",
"0.54019916",
"0.5394694",
"0.53944576",
"0.5384477",
"0.53844506",
"0.5384085",
"0.5378616",
"0.5372748",
"0.5369132",
"0.535904",
"0.53486514",
"0.53484374",
"0.53484374",
"0.534591",
"0.53398615",
"0.5336918",
"0.5324222",
"0.53235316",
"0.5322883",
"0.5322786",
"0.53197026",
"0.53117",
"0.5311041",
"0.5310051",
"0.5297283",
"0.5289959",
"0.5284777",
"0.5284034",
"0.5284006"
] | 0.69730264 | 0 |
def download Load the package information like name, version, dependencies. | def load_package_info(setup_py)
if !attributes[:python_package_prefix].nil?
attributes[:python_package_name_prefix] = attributes[:python_package_prefix]
end
begin
json_test_code = [
"try:",
" import json",
"except ImportError:",
" import simplejson as json"
].join("\n")
safesystem("#{attributes[:python_bin]} -c '#{json_test_code}'")
rescue FPM::Util::ProcessFailed => e
logger.error("Your python environment is missing json support (either json or simplejson python module). I cannot continue without this.", :python => attributes[:python_bin], :error => e)
raise FPM::Util::ProcessFailed, "Python (#{attributes[:python_bin]}) is missing simplejson or json modules."
end
begin
safesystem("#{attributes[:python_bin]} -c 'import pkg_resources'")
rescue FPM::Util::ProcessFailed => e
logger.error("Your python environment is missing a working setuptools module. I tried to find the 'pkg_resources' module but failed.", :python => attributes[:python_bin], :error => e)
raise FPM::Util::ProcessFailed, "Python (#{attributes[:python_bin]}) is missing pkg_resources module."
end
# Add ./pyfpm/ to the python library path
pylib = File.expand_path(File.dirname(__FILE__))
# chdir to the directory holding setup.py because some python setup.py's assume that you are
# in the same directory.
setup_dir = File.dirname(setup_py)
output = ::Dir.chdir(setup_dir) do
tmp = build_path("metadata.json")
setup_cmd = "env PYTHONPATH=#{pylib}:$PYTHONPATH #{attributes[:python_bin]} " \
"setup.py --command-packages=pyfpm get_metadata --output=#{tmp}"
if attributes[:python_obey_requirements_txt?]
setup_cmd += " --load-requirements-txt"
end
# Capture the output, which will be JSON metadata describing this python
# package. See fpm/lib/fpm/package/pyfpm/get_metadata.py for more
# details.
logger.info("fetching package metadata", :setup_cmd => setup_cmd)
success = safesystem(setup_cmd)
#%x{#{setup_cmd}}
if !success
logger.error("setup.py get_metadata failed", :command => setup_cmd,
:exitcode => $?.exitstatus)
raise "An unexpected error occurred while processing the setup.py file"
end
File.read(tmp)
end
logger.debug("result from `setup.py get_metadata`", :data => output)
metadata = JSON.parse(output)
logger.info("object output of get_metadata", :json => metadata)
self.architecture = metadata["architecture"]
self.description = metadata["description"]
# Sometimes the license field is multiple lines; do best-effort and just
# use the first line.
if metadata["license"]
self.license = metadata["license"].split(/[\r\n]+/).first
end
self.version = metadata["version"]
self.url = metadata["url"]
# name prefixing is optional, if enabled, a name 'foo' will become
# 'python-foo' (depending on what the python_package_name_prefix is)
if attributes[:python_fix_name?]
self.name = fix_name(metadata["name"])
else
self.name = metadata["name"]
end
# convert python-Foo to python-foo if flag is set
self.name = self.name.downcase if attributes[:python_downcase_name?]
if !attributes[:no_auto_depends?] and attributes[:python_dependencies?]
metadata["dependencies"].each do |dep|
dep_re = /^([^<>!= ]+)\s*(?:([~<>!=]{1,2})\s*(.*))?$/
match = dep_re.match(dep)
if match.nil?
logger.error("Unable to parse dependency", :dependency => dep)
raise FPM::InvalidPackageConfiguration, "Invalid dependency '#{dep}'"
end
name, cmp, version = match.captures
next if attributes[:python_disable_dependency].include?(name)
# convert == to =
if cmp == "==" or cmp == "~="
logger.info("Converting == dependency requirement to =", :dependency => dep )
cmp = "="
end
# dependency name prefixing is optional, if enabled, a name 'foo' will
# become 'python-foo' (depending on what the python_package_name_prefix
# is)
name = fix_name(name) if attributes[:python_fix_dependencies?]
# convert dependencies from python-Foo to python-foo
name = name.downcase if attributes[:python_downcase_dependencies?]
self.dependencies << "#{name} #{cmp} #{version}"
end
end # if attributes[:python_dependencies?]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_and_extract_package\n @fetcher.get_package_file(@package_name, @version)\n Gem::Package::TarReader.new( Zlib::GzipReader.open @fetcher.temp_package_file_path ) do |tar|\n tar.each do |entry|\n next unless entry.file? and entry.full_name.match(\"DESCRIPTION\")\n @package_desc = entry.read\n end\n end\n FileUtils.rm_rf @fetcher.temp_package_file_path\n end",
"def set_package_info\n download_and_extract_package\n parse_package_description\n @package_hash = filter_into_package @package_desc\n @version_hash = filter_into_version @package_desc\n @author_hash = filter_into_author @package_desc[\"Author\"]\n @maintainer_hash = filter_into_author @package_desc[\"Maintainer\"]\n end",
"def download_package\n path = download_path\n remote_file path do\n source URL\n action :create\n only_if { !::File.exist?(PATH) }\n end\n end",
"def download\n # Turned off ssl verification\n # This should be acceptable because it won't happen on a user's machine, just CI\n\n # define a progress-bar printer\n chunk_size = 1024 * 1024 * 1024\n total_size = 0\n dots = 0\n dot_printer = lambda do |size|\n total_size += size\n needed_dots = (total_size / chunk_size).to_i\n unprinted_dots = needed_dots - dots\n @output.print(\".\" * unprinted_dots) if unprinted_dots.positive?\n dots = needed_dots\n end\n\n URI.open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url|\n File.open(package_file, 'wb') { |file| file.write(url.read) }\n end\n rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e\n @output.puts \"\\nArduino force-install failed downloading #{package_url}: #{e}\"\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def download\n @package = Package.find(params[:id])\n if @package.present?\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n else\n render page_not_found\n end\n end",
"def download\n create_agent\n login\n fetch_feed\n create_catalog\n download_catalog\n end",
"def package\n unless @package\n @package = package_resource_class.new(download_dest, run_context)\n tailor_package_to_platform\n end\n @package\n end",
"def download\n respond_to do |format|\n if @package.present?\n format.html do\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n end\n \n format.json { render :text => @package.to_json(:methods => [:name, :display_name]) }\n else\n render page_not_found\n end\n end\n end",
"def download\n respond_to do |format|\n if @package.present?\n format.html do\n send_file Munki::Application::PACKAGE_DIR + @package.installer_item_location, :filename => @package.to_s(:download_filename)\n fresh_when :etag => @package, :last_modified => @package.created_at.utc, :public => true\n end\n \n format.json { render :text => @package.to_json(:methods => [:name, :display_name]) }\n else\n render page_not_found\n end\n end\n end",
"def load_details\n @commits = Package.new.git_commits\n @packages = Package.latest_first \n @package = Package.new\n end",
"def package_url\n \"https://github.com/arduino/arduino-cli/releases/download/#{@desired_version}/#{package_file}\"\n end",
"def fetch_obs_packages\n log.info \"Fetching all required packages\"\n yast_url.each_with_index do |url, index|\n system \"zypper --root #{cache_dir} ar --no-gpgcheck -p #{index + 1} #{url} \" \\\n \"download-packages-#{index}\"\n end\n system \"xargs -a #{obs_pkg_list_path} zypper --root #{cache_dir} \" \\\n \"--pkg-cache-dir=#{cache_dir} download\"\n\n yast_url.size.times { |i| system \"zypper --root #{cache_dir} rr download-packages-#{i}\" }\n\n log.info \"Fetching packages from extra repositories\"\n @extra_repos.each do |repo|\n system \"zypper --root #{cache_dir} ar --no-gpgcheck #{repo[:server]} \" \\\n \"download-extra-packages\"\n system \"zypper --root #{cache_dir} --pkg-cache-dir=#{cache_dir} \" \\\n \"download #{repo[:packages].join(\" \")}\"\n system \"zypper --root #{cache_dir} rr download-extra-packages\"\n end\n end",
"def packages; end",
"def download_mut_deps( mut_dir )\n FileUtils.chdir mut_dir, :verbose => verbose?\n cmd = \"puppet module build --render-as=json\"\n puts cmd if verbose?\n tgz = `#{cmd}`.split(\"\\n\").last.gsub('\"','')\n puts \"built module archive: #{tgz}\" if verbose?\n cmd = \"puppet module install #{tgz} \" +\n \"--module_repository=#{@upstream_puppet_forge} \" +\n \"--modulepath=#{@mods_dir} --target-dir=#{@mods_dir}\"\n v1 cmd\n out = `#{cmd}`\n v1 out\n\n # add the\n FileUtils.cp tgz, @tars_dir, :verbose => verbose?\n end",
"def download_metadata\n $metadata_dl_list = {}\n\n meta_dl \"Marshal.4.8\"\n meta_dl \"Marshal.4.8.Z\"\n\n meta_dl \"yaml\"\n meta_dl \"yaml.Z\"\n\n meta_dl \"specs.4.8\"\n meta_dl \"specs.4.8.gz\"\n\n meta_dl \"latest_specs.4.8\"\n meta_dl \"latest_specs.4.8.gz\"\n\n meta_dl \"prerelease_specs.4.8\"\n meta_dl \"prerelease_specs.4.8.gz\"\n\n meta_dl_wait {\n $metadata_dl_list = nil\n yield\n }\nend",
"def packages()\n\t\t\tend",
"def net_http_get_package_info\n thread = @thread\n timestamp = Time.now.utc.strftime(\"%Y-%m-%dT%H:%M:%S\\+0000\")\n\n uri = URI(\"#{@sendsafely_url}/#{API}/package/#{@thread}/\")\n\n req = Net::HTTP::Get.new(uri)\n req['Content-Type'] = 'application/json'\n req['ss-api-key'] = @sendsafely_key_id\n req['ss-request-timestamp'] = timestamp\n req['ss-request-signature'] = OpenSSL::HMAC.hexdigest(\"SHA256\", @sendsafely_key_secret, @sendsafely_key_id+\"/#{API}/package/#{thread}\"+timestamp)\n\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http|\n http.request(req)\n }\n\n puts res.body\n end",
"def fetch\n notify \"Downloading...\"\n @strategy.fetch\n extract\n end",
"def tailor_package_to_platform\n @package.app('Dropbox')\n @package.volumes_dir('Dropbox Installer')\n @package.source(URI.encode(\"file://#{download_dest}\"))\n end",
"def load_library\n\t\t#wget some url\n\tend",
"def main\n last_good_root = from_file($cache_dir + '/root.txt') ||\n from_file('config/root.txt') ||\n raise(\"Can't find root.txt\")\n\n repository = Gem::TUF::Repository.new(\n root: JSON.parse(last_good_root),\n bucket: FileCachingBucket.new(HttpBucket.new($host))\n )\n\n gem_name = ARGV.shift\n\n specs = repository.target('latest_specs.4.8.gz')\n raise \"could not find latest_specs.4.8.gz\" unless specs\n specs = unmarshal_gz specs\n gem = specs.detect {|x| x[0] == gem_name } || raise(\"Can't find gem #{gem}\")\n\n gem_with_version = \"#{gem[0]}-#{gem[1]}\"\n gem_path = \"gems/#{gem_with_version}.gem\"\n gemspec_path = \"quick/Marshal.4.8/#{gem_with_version}.gemspec.rz\"\n\n repository.target(gemspec_path)\n repository.target(gem_path)\n\n puts \"Downloaded #{gem_path} and #{gemspec_path}\"\nend",
"def download(project:, build_number:, flavor:, name:, pre_apply_hook:, output_dir:)\n raise \"#{self.class}#download not implemented\"\n end",
"def download\n @data = HeyDan::Helper.get_data_from_url(HeyDan.cdn + '/' + dataset_file_name)\n end",
"def download_data\n puts 'Downloading data ...'\n\n cmd = \"wget --output-document=#{DATA_PATH} #{SFPD_DATA}\"\n system cmd\n end",
"def _download_module(name)\n command = \"puppet module install #{name} \"\n command += @modulepath + Silence\n\n puts \"Calling '#{command}'\" if @options[:debug]\n system(command)\n end",
"def download\n @doc = Nokogiri::HTML(open(@url))\n\tend",
"def download(download_dir)\n @downloaded_file = File.join(download_dir,\"label_mapping.tsv.gz\")\n \n @log.info \"Downloading from SIDER to #{@downloaded_file}\" if @log\n system(\"curl -o #{@downloaded_file} -i ftp://sideeffects.embl.de/SIDER/latest/label_mapping.tsv.gz\")\n system(\"gunzip #{@downloaded_file}\")\n \n @file = File.join(download_dir,\"label_mapping.tsv\")\n end",
"def download(description = @component_name, &block)\n super_download @version, @uri, description, &block\n end",
"def retrieve\n raise RetrieverError.new(\"download retriever is unavailable\") unless available?\n ::FileUtils.remove_entry_secure @repo_dir if File.exists?(@repo_dir)\n ::FileUtils.remove_entry_secure workdir if File.exists?(workdir)\n ::FileUtils.mkdir_p @repo_dir\n ::FileUtils.mkdir_p workdir\n file = ::File.join(workdir, \"package\")\n\n # TEAL FIX: we have to always-download the tarball before we can\n # determine if contents have changed, but afterward we can compare the\n # previous download against the latest downloaded and short-circuit the\n # remaining flow for the no-difference case.\n @logger.operation(:downloading) do\n credential_command = if @repository.first_credential && @repository.second_credential\n ['-u', \"#{@repository.first_credential}:#{@repository.second_credential}\"]\n else\n []\n end\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = [\n 'curl',\n '--silent', '--show-error', '--location', '--fail',\n '--location-trusted', '-o', file, credential_command,\n @repository.url\n ].flatten\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => workdir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, 'curl', e)\n raise\n end\n end\n\n note_tag(file)\n\n @logger.operation(:unpacking) do\n path = @repository.to_url.path\n if path =~ /\\.gz$/\n extraction = \"xzf\"\n elsif path =~ /\\.bz2$/\n extraction = \"xjf\"\n else\n extraction = \"xf\"\n end\n Dir.chdir(@repo_dir) do\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = ['tar', extraction, file]\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => @repo_dir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, @cmd.first, e)\n raise\n end\n end\n end\n true\n end",
"def get_download\n\tend",
"def _fetch\n curl @url, '-o', @tarball_path\n end",
"def download\n not_implemented(__method__)\n end",
"def download_article_data\n print \"Getting list of articles...\\n\"\n ArticleGetter.new([ARTICLE_SOURCE]).result\n end",
"def fetch_dependencies(verbose=false)\n say \"Fetching packages from remote...\" if verbose\n exp_deps = find_non_local_dependencies(all_dependencies, true)\n core_fetch_dependencies(exp_deps, verbose)\n end",
"def tailor_package_to_platform\n @package.source(URI.encode(download_dest))\n @package.installer_type(:nsis)\n end",
"def fetch_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-v' : '-q')}\"\n end",
"def pkg_fetch\n return if File::exists? @srcdir\n\n sysprint \"#{@name} fetch: #{@fetch_url}\"\n\n # Try to guess by package URL extension\n if @fetch_url.match(/\\.git$/i)\n git_clone(@fetch_url, @srcdir)\n return\n end\n\n # Else use the URL to select fetch method\n protocol = @fetch_url.split(':')[0]\n\n if protocol.length == 0\n syserr \"Invalid package source URL #{@fetch_url}\"\n raise\n end\n\n case protocol\n when /^http$/i, /^https$/i, /^ftp$/i\n curl_fetch(@fetch_url, @srcdir)\n when /git/i\n git_clone(@fetch_url, @srcdir)\n else\n syserr \"Unhandled URL type: #{protocol}\"\n raise\n end\n end",
"def download!\n\t\traise_if_error C.glyr_opt_download(to_native, true)\n\tend",
"def fetch_modules(definition, packages: [], download: nil)\n if download\n download_modules(definition, packages: packages)\n else\n local_files(definition, packages: packages)\n end\n end",
"def core_fetch_dependency(package_name, vers, type, verbose)\n prerelease = false\n if vers == '>= 0-pre'\n prerelease = true\n vers = '>= 0'\n else\n prerelease = vers =~ /[a-zA-Z]/\n end\n\n dep = LibGems::Dependency.new(package_name, vers, type)\n cur_installed = LibGems.source_index.search(dep)\n\n begin\n installed = BPM::Remote.new.install(package_name, vers, prerelease)\n rescue LibGems::GemNotFoundException\n # If we have it locally but not remote, that's ok\n installed = []\n end\n\n cur_installed.each do |ci|\n installed.reject! { |i| ci.name == i.name && ci.version == i.version }\n end\n\n installed.each do |i|\n say \"~ Fetched #{i.name} (#{i.version}) from remote\"\n end\n\n end",
"def package_information\n puts\n puts \"%30s%s\" % [\"Plugin information : \", @package.metadata[:name]]\n puts \"%30s%s\" % [\"-\" * 22, \"-\" * 22]\n puts \"%30s%s\" % [\"Plugin Type : \", @package.plugintype.capitalize]\n puts \"%30s%s\" % [\"Package Output Format : \", @package_type.upcase]\n puts \"%30s%s\" % [\"Version : \", @package.metadata[:version]]\n puts \"%30s%s\" % [\"Iteration : \", @package.iteration]\n puts \"%30s%s\" % [\"Vendor : \", @package.vendor]\n puts \"%30s%s\" % [\"Post Install Script : \", @package.postinstall] if @package.postinstall\n puts \"%30s%s\" % [\"Author : \", @package.metadata[:author]]\n puts \"%30s%s\" % [\"License : \", @package.metadata[:license]]\n puts \"%30s%s\" % [\"URL : \", @package.metadata[:url]]\n\n if @package.packagedata.size > 0\n @package.packagedata = @package.packagedata.select{|k, v| v != nil}\n @package.packagedata.each_with_index do |values, i|\n if i == 0\n puts \"%30s%s\" % [\"Identified Packages : \", values[0]]\n else\n puts \"%30s%s\" % [\" \", values[0]]\n end\n end\n end\n end",
"def run\n if @name_args.length != 2\n Chef::Log.fatal(\"You must supply a cookbook name and version to download!\")\n exit 42\n end\n \n cookbook_name = @name_args[0]\n cookbook_version = @name_args[1] == 'latest' ? '_latest' : @name_args[1]\n Chef::Log.info(\"Downloading #{cookbook_name} cookbook version #{cookbook_version}\")\n \n cookbook = rest.get_rest(\"cookbooks/#{cookbook_name}/#{cookbook_version}\")\n manifest = cookbook.manifest\n\n basedir = File.join(config[:download_directory], \"#{cookbook_name}-#{cookbook.version}\")\n if File.exists?(basedir)\n if config[:force]\n Chef::Log.debug(\"Deleting #{basedir}\")\n FileUtils.rm_rf(basedir)\n else\n Chef::Log.fatal(\"Directory #{basedir} exists, use --force to overwrite\")\n exit\n end\n end\n \n Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment|\n next unless manifest.has_key?(segment)\n Chef::Log.info(\"Downloading #{segment}\")\n manifest[segment].each do |segment_file|\n dest = File.join(basedir, segment_file['path'].gsub('/', File::SEPARATOR))\n Chef::Log.debug(\"Downloading #{segment_file['path']} to #{dest}\")\n FileUtils.mkdir_p(File.dirname(dest))\n rest.sign_on_redirect = false\n tempfile = rest.get_rest(segment_file['url'], true)\n FileUtils.mv(tempfile.path, dest)\n end\n end\n Chef::Log.info(\"Cookbook downloaded to #{basedir}\")\n end",
"def packages\n %w(dtach rtorrent)\nend",
"def package_download_url\n package_filename_url_safe = Info.release_version.gsub(\"+\", \"%2B\")\n \"https://#{Info.release_bucket}.#{Info.release_bucket_s3_endpoint}/ubuntu-focal/#{Info.package}_#{package_filename_url_safe}_amd64.deb\"\n end",
"def fetch\n DownloadManager.fetch(src, target)\n parse\n end",
"def fetch type, version, extension=\"tar.gz\"\n core_url = \"#{@base}/#{type}-#{version}.#{extension}\"\n tmp = Galaxy::Temp.mk_auto_file \"galaxy-download\"\n @log.info \"Fetching #{core_url} into #{tmp}\"\n if @base =~ /^http:/\n begin\n output = Galaxy::HostUtils.system(\"curl -D - #{core_url} -o #{tmp} -s\")\n rescue Galaxy::HostUtils::CommandFailedError => e\n raise \"Failed to download archive #{core_url}: #{e}\"\n end\n status = output.first\n (protocol, response_code, response_message) = status.split\n unless response_code == '200'\n raise \"Failed to download archive #{core_url}: #{status}\"\n end\n else\n open(core_url) do |io|\n File.open(tmp, \"w\") { |f| f.write(io.read) }\n end\n end\n return tmp\n end",
"def download_wordpress\n package = \"/tmp/wordpress-#{@config[:wp_version]}.zip\"\n # Download package file\n if ::File.exists?(package)\n @task.say_warning \"WordPress is already downloaded...\", false, true\n else ::File.exists?(package)\n @task.say_info \"Downloading WordPress...\", false, true\n\n @task.get \"https://wordpress.org/wordpress-#{@config[:wp_version]}.zip\" do |content|\n @task.create_file package, content\n end\n end\n # Return package file\n package\n end",
"def _load_automatic(&block)\n dir = URI.join(@uri, \"dists/#{@suite}/\")\n\n file = signed_download(URI.join(dir, 'Release'), URI.join(dir, 'Release.gpg'))\n\n release = DebParseRelease.new(@app, dir, file)\n c = Collector.new\n c.run_each(@all_archs.product(@components)) do |ac|\n pinfo = release.download(\"#{ac[1]}/binary-#{ac[0]}/Packages\")\n\n parser = DebPackagesParser.new(@app, @uri, pinfo)\n block.call(parser)\n end\n c.wait_throw\n end",
"def download(url)\n STDERR.print \"loading #{url}\"\n response = Faraday.get(url)\n STDERR.puts ' (done)'\n response.body\n end",
"def getPackages\n `wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.4.tar.gz`\n `wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz`\n `wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz`\n `tar zxf nagios-4.0.4.tar.gz`\n `tar zxf nagios-plugins-2.0.tar.gz`\n `tar zxf nrpe-2.15.tar.gz`\n end",
"def package\n @package ||= Package.initialize_from_path(path: \"#{resource_path}/package\",\n client: @client)\n end",
"def compile\n JavaBuildpack::Util.download(@version, @uri, 'Auto Reconfiguration', jar_name(@version), @lib_directory)\n end",
"def download_source\n unless @download_source\n if new_resource.package_url\n res = chase_redirect(new_resource.package_url)\n else\n params = URI.encode_www_form(full: 1,\n plat: node['platform_family'][0..2])\n res = chase_redirect(\"https://www.dropbox.com/download?#{params}\")\n end\n end\n @download_source ||= res\n end",
"def download_prog(repo_hash)\n if (repo_hash[:source] == \"github\")\n clone_repo(repo_hash)\n elsif (repo_hash[:source] == \"rubygems\")\n puts \"Unpacking gem #{repo_hash[:name]}...\"\n system \"gem unpack #{repo_hash[:name]} --version #{repo_hash[:version]}\"\n else\n raise \"Unexpected source of repo #{repo_hash[:name]}: #{repo_hash[:source]}\"\n end\nend",
"def metapackage(name, *packages)\n Autoproj.workspace.manifest.metapackage(name, *packages)\nend",
"def download_translations\n status\n @crowdin.export_translations\n @lang_ready.each do |lang|\n puts \"Downloading '#{lang}' in zip format\"\n @crowdin.download_translation(lang, output: \"#{@download_folder}/output-#{lang}.zip\")\n end\n end",
"def download\n api_url = build_url\n RestClient::Request.execute(method: 'GET', url: api_url, open_timeout: 20)\n end",
"def do_download\n checksum = if new_resource.checksum\n new_resource._?(:checksum, '--checksum=sha-256=').join\n end\n header = if new_resource.header\n \"--header='#{new_resource._?(:header)[1]}'\"\n end\n aria2(checksum, header,\n new_resource._?(:path, '-o'),\n new_resource._?(:directory, '-d'),\n new_resource._?(:split_size, '-s'),\n new_resource._?(:connections, '-x'),\n new_resource._?(:check_cert, '--check-certificate=false'),\n new_resource.source)\n end",
"def download_gem(name, version)\n cached = GemCache.get(name, version)\n return cached unless cached.nil?\n\n client.url = \"https://rubygems.org/gems/#{name}-#{version}.gem\"\n client.follow_location = true\n client.http_get\n gemf = client.body_str\n\n GemCache.set(name, version, gemf)\n gemf\n end",
"def download_readme!(opts={})\n download!(:readme, opts)\n end",
"def get_ver_downloads(ver)\n Gems.downloads @node.name, ver\n end",
"def input(package)\n path_to_package = download_if_necessary(package, version)\n\n if File.directory?(path_to_package)\n setup_py = File.join(path_to_package, \"setup.py\")\n else\n setup_py = path_to_package\n end\n\n if !File.exist?(setup_py)\n logger.error(\"Could not find 'setup.py'\", :path => setup_py)\n raise \"Unable to find python package; tried #{setup_py}\"\n end\n\n load_package_info(setup_py)\n install_to_staging(setup_py)\n end",
"def get_release_packages\n get_local_constraints\n\n if !@force && @installed.include?(@module_name)\n\n raise AlreadyInstalledError,\n :module_name => @module_name,\n :installed_version => @installed[@module_name].first.version,\n :requested_version => @version || (@conditions[@module_name].empty? ? :latest : :best),\n :local_changes => @installed[@module_name].first.local_changes\n end\n\n if @ignore_dependencies && @source == :filesystem\n @urls = {}\n @remote = { \"#{@module_name}@#{@version}\" => { } }\n @versions = {\n @module_name => [\n { :vstring => @version, :semver => SemVer.new(@version) }\n ]\n }\n else\n get_remote_constraints\n end\n\n @graph = resolve_constraints({ @module_name => @version })\n @graph.first[:tarball] = @filename if @source == :filesystem\n resolve_install_conflicts(@graph) unless @force\n\n # This clean call means we never \"cache\" the module we're installing, but this\n # is desired since module authors can easily rerelease modules different content but the same\n # version number, meaning someone with the old content cached will be very confused as to why\n # they can't get new content.\n # Long term we should just get rid of this caching behavior and cleanup downloaded modules after they install\n # but for now this is a quick fix to disable caching\n Puppet::Forge::Cache.clean\n download_tarballs(@graph, @graph.last[:path])\n end",
"def downloads\n @downloads ||= ApiFactory.new 'Projects::Downloads'\n end",
"def download_all\n raise NotImplementedError.new(\"#{self.class.name}#download_all is an abstract method.\")\n end",
"def install\n \n end",
"def download\n open(download_url, \"rb\")\n end",
"def start_download(name, folder_name, url, &blk)\n puts pretty_console_block(\"\\n\\ndownloading #{name}\\n\\n\")\n begin\n blk.call(name, folder_name, url)\n begin\n give_metadata(name, folder_name, url)\n rescue Exception => e\n puts pretty_console_block(\"error setting metadata for #{name}\")\n end\n rescue Exception => e\n handle_download_error(name, folder_name, url, e)\n end\n end",
"def download(f)\n result = \"\"\n prefix = \"dat/\"\n file_names = \"name.dat.txt\"\n file_surna = \"surnames.dat.txt\" \n file_words = \"words.dat.txt\"\n http_names_m = \"http://www.census.gov/genealogy/names/dist.male.first\"\n http_names_f = \"http://www.census.gov/genealogy/names/dist.female.first\"\n http_surnames = \"http://www.census.gov/genealogy/names/dist.all.last\"\n http_words = \"http://www.mieliestronk.com/corncob_lowercase.zip\"\n\n case f\n when 'names'\n print \"Downloading names ... [BUSY]\"\n nm_uri = URI.parse(http_names_m)\n nf_uri = URI.parse(http_names_f)\n (open(nm_uri).read + open(nf_uri).read).each_line {|m|\n result += m.split(/\\s+/)[0].capitalize + \"\\n\"\n }\n File.open(prefix + file_names, \"w\").write( result )\n print \"\\b\\b\\b\\b\\b\\b[DONE]\\n\"\n when 'surnames'\n print \"Downloading surnames ... [BUSY]\"\n sr_uri = URI.parse(http_surnames)\n (open(sr_uri).read).each_line {|m|\n result += m.split(/\\s+/)[0].capitalize + \"\\n\"\n }\n File.open(prefix + file_surna, \"w\").write ( result )\n print \"\\b\\b\\b\\b\\b\\b[DONE]\\n\"\n when 'words'\n print \"Downloading words ... [BUSY]\"\n wr_uri = URI.parse(http_words)\n # Store the zipfile\n File.open(prefix + file_words, \"w\").write(wr_uri.read)\n unzip(prefix + file_words)\n print \"\\b\\b\\b\\b\\b\\b[DONE]\\n\"\n end\n end",
"def download_if_necessary(package, version=nil)\n # TODO(sissel): this should just be a 'download' method, the 'if_necessary'\n # part should go elsewhere.\n path = package\n # If it's a path, assume local build.\n if File.directory?(path) or (File.exist?(path) and File.basename(path) == \"setup.py\")\n return path\n end\n\n logger.info(\"Trying to download\", :package => package)\n\n if version.nil?\n want_pkg = \"#{package}\"\n else\n want_pkg = \"#{package}==#{version}\"\n end\n\n target = build_path(package)\n FileUtils.mkdir(target) unless File.directory?(target)\n\n if attributes[:python_internal_pip?]\n # XXX: Should we detect if internal pip is available?\n attributes[:python_pip] = [ attributes[:python_bin], \"-m\", \"pip\"]\n end\n\n # attributes[:python_pip] -- expected to be a path\n if attributes[:python_pip]\n logger.debug(\"using pip\", :pip => attributes[:python_pip])\n # TODO: Support older versions of pip\n\n pip = [attributes[:python_pip]] if pip.is_a?(String)\n setup_cmd = [\n *attributes[:python_pip],\n \"download\",\n \"--no-clean\",\n \"--no-deps\",\n \"--no-binary\", \":all:\",\n \"-d\", build_path,\n \"-i\", attributes[:python_pypi],\n ]\n\n if attributes[:python_trusted_host]\n setup_cmd += [\n \"--trusted-host\",\n attributes[:python_trusted_host],\n ]\n end\n\n setup_cmd << want_pkg\n\n safesystem(*setup_cmd)\n\n # Pip removed the --build flag sometime in 2021, it seems: https://github.com/pypa/pip/issues/8333\n # A workaround for pip removing the `--build` flag. Previously, `pip download --build ...` would leave\n # behind a directory with the Python package extracted and ready to be used.\n # For example, `pip download ... Django` puts `Django-4.0.4.tar.tz` into the build_path directory.\n # If we expect `pip` to leave an unknown-named file in the `build_path` directory, let's check for\n # a single file and unpack it. I don't know if it will /always/ be a .tar.gz though.\n files = ::Dir.glob(File.join(build_path, \"*.tar.gz\"))\n if files.length != 1\n raise \"Unexpected directory layout after `pip download ...`. This might be an fpm bug? The directory is #{build_path}\"\n end\n\n safesystem(\"tar\", \"-zxf\", files[0], \"-C\", target)\n else\n # no pip, use easy_install\n logger.debug(\"no pip, defaulting to easy_install\", :easy_install => attributes[:python_easyinstall])\n safesystem(attributes[:python_easyinstall], \"-i\",\n attributes[:python_pypi], \"--editable\", \"-U\",\n \"--build-directory\", target, want_pkg)\n end\n\n # easy_install will put stuff in @tmpdir/packagename/, so find that:\n # @tmpdir/somepackage/setup.py\n dirs = ::Dir.glob(File.join(target, \"*\"))\n if dirs.length != 1\n raise \"Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{build_path}\"\n end\n return dirs.first\n end",
"def download_data\n subclass_must_define\n end",
"def perform(package_id)\n package = Package.find(package_id)\n return if package.has_required_details?\n\n response = Net::HTTP.get_response(package.uri)\n raise response.message unless response.code == '200'\n\n ungziped = ungzip(response.body)\n files = untar(ungziped)\n package_description = extract_description(files)\n\n package.update_attributes(\n published_at: package_description['Date/Publication'],\n title: package_description['Title'],\n description: package_description['Description'],\n authors: package_description['Author'],\n maintainers: package_description['Maintainer']\n )\n end",
"def install_package\n path = download_path\n windows_package 'Divvy' do\n source path\n installer_type :nsis\n action :install\n end\n end",
"def download\n super\n rescue\n info \"Failed to download #{to_spec}. Skipping it.\"\n end",
"def download name\n @checked += 1\n gem_name = \"#{name}.gem\"\n\n if gem_exists? gem_name then\n @gem_queue.push name\n\n info \"#{gem_name} exists\"\n\n return\n end\n\n uri = @base_uri + \"#{name}.gem\"\n\n source_etag = nil\n dest_etag = nil\n\n @http.request uri do |source_res|\n break unless etag = source_res['ETag']\n source_etag = etag.delete '\"'\n\n dest_etag = @swift.write_object @gems_container, gem_name do |io|\n source_res.read_body do |chunk|\n io.write chunk\n end\n end\n end\n\n if dest_etag == source_etag then\n @gem_queue.push name\n\n info \"#{gem_name} downloaded\"\n\n @downloaded += 1\n else\n @gem_name_queue.push name\n @swift.delete_object @gems_container, gem_name\n\n info \"#{gem_name} download failed\"\n @failed += 1\n end\n end",
"def get_packages!(path)\n response = Api::Request.new do |request|\n request[:sign] = false\n request[:method] = :GET\n request[:path] = \"/shared/packages/#{path}\"\n end.execute!\n\n Object::File.open(path, 'wb') do |file|\n file.write(response)\n end\n\n path\n end",
"def upgrade_direct!\n remote_file local_path do\n source package_metadata[:url]\n checksum package_metadata[:sha256]\n end\n dpkg_package local_path\n end",
"def build_package\n # Force timestamp to be initialized before anything else. This gives us a\n # stable timestamp for the process.\n timestamp\n # Prepare the work area: copy files from root_path to work_path based on\n # the resolved Manifest.txt.\n prepare_work_area\n # Anything that has been modified locally needs to be reset.\n restore_modified_files\n # Save both the final release metadata and the in-package release metadata.\n save_release_metadata\n # Vendor the dependencies for the package.\n vendor_dependencies\n # Request that supporting plug-ins build the package.\n request_build_package\n end",
"def download_driver_http\n File.write(\n @target_path,\n open(@params[:jdbc_driver_jar]).read\n )\n end",
"def download(event)\n info \"Finished downloading updates\"\n end",
"def download\n @cookbook = Cookbook.with_name(params[:cookbook]).first!\n @cookbook_version = @cookbook.get_version!(params[:version])\n\n CookbookVersion.increment_counter(:api_download_count, @cookbook_version.id)\n Cookbook.increment_counter(:api_download_count, @cookbook.id)\n Supermarket::Metrics.increment('cookbook.downloads.api')\n\n redirect_to @cookbook_version.tarball.url\n end",
"def download(path)\n downloader.get do |req|\n req.url path\n end.body\n end",
"def install\n end",
"def install\n end",
"def publish_to_package_manager(version)\nend",
"def publish_to_package_manager(version)\nend",
"def maven_get(dependencies = DEPENDENCIES)\n #First, make sure the TMPMAVENDIR exists and create it if not.\n FileUtils.mkdir_p(TMPMAVENDIR)\n\n #Now make sure all the dependencies exist.\n dependencies.each do |dependency|\n jar_filename = dependency_to_jar(dependency)\n\n #Check if we already have the jar. Get it if not.\n if !File.exists?(maven_filename(jar_filename))\n url = dependency_to_url(dependency)\n uri = URI(dependency_to_url(dependency))\n $stderr.puts(\"downloading #{jar_filename} from #{uri}...\")\n\n File.open(maven_filename(jar_filename), \"wb\") do |f|\n begin\n f.print open(url, 'User-Agent' => 'ruby').read\n $stderr.puts \"Successfully downloaded #{jar_filename}!\"\n rescue SocketError => e\n $stderr.puts \"SocketError in downloading #{jar_filename}: #{e}\"\n rescue SystemCallError => e\n $stderr.puts \"SystemCallError in downloading #{jar_filename}: #{e}\"\n end\n end\n end\n end\nend",
"def upgrade_direct!\n package \"Chef Development Kit v#{package_metadata[:version]}\" do\n source package_metadata[:url]\n checksum package_metadata[:sha256]\n end\n end",
"def download_installer\n puts pe_installer_url\n unless `curl #{pe_installer_url} -o ./file_cache/installers/#{installer_filename}`\n fail \"Error downloading the PE installer\"\n end\n gzip_installer if PRE_RELEASE\nend",
"def download(full_spec, path) # :nodoc:\n end",
"def download\n @extension = Extension.with_name(params[:extension]).first!\n @extension_version = @extension.get_version!(params[:version])\n\n ExtensionVersion.increment_counter(:api_download_count, @extension_version.id)\n Extension.increment_counter(:api_download_count, @extension.id)\n BonsaiAssetIndex::Metrics.increment('extension.downloads.api')\n\n redirect_to @extension_version.tarball.url\n end",
"def installed_packages()\n\t\t\tend",
"def packages\n manifest.each_with_object({}) do |(src, package_name), hsh|\n next if src.nil? || src.empty?\n hsh[package_name] ||= []\n hsh[package_name] << File.join(Licensed::Git.repository_root, src)\n end\n end",
"def download_src(src_package, src_dir)\n deprec.groupadd(group)\n sudo \"test -d #{src_dir} || sudo mkdir #{src_dir}\" \n sudo \"chgrp -R #{group} #{src_dir}\"\n sudo \"chmod -R g+w #{src_dir}\"\n # XXX check if file exists and if we have and MD5 hash or bytecount to compare against\n # XXX if so, compare and decide if we need to download again\n if defined?(src_package[:md5sum])\n md5_clause = \" && echo '#{src_package[:md5sum]}' | md5sum -c - \"\n end\n sudo <<-SUDO\n sh -c \"cd #{src_dir} && test -f #{src_package[:file]} #{md5_clause} || wget --timestamping #{src_package[:url]}\"\n SUDO\n end",
"def load_dependencies\n result = zh_client.dependencies(repo_name)\n\n result[\"dependencies\"].each do |hash|\n blocking = add_or_find(hash[\"blocking\"])\n blocked = add_or_find(hash[\"blocked\"])\n\n add_edge(blocked, blocking)\n end\n end",
"def download(url, download_to=File.expand_path(\".\")+File::SEPARATOR)\n $LOG.info \" Starting download of fillings from SEC url [\"+url+\"]\"\n files=[]\n content = open(url).read\n @links = Set.new\n uri=URI(url)\n @base_path=\"\"\n @base_path=(uri.scheme+\"://\"+uri.host+((uri.port==80 && \"\") || \":\"+uri.port.to_s)) unless uri.host.nil?\n parse(content)\n download_to += File::SEPARATOR unless download_to.end_with?(File::SEPARATOR)\n mkdir(download_to)\n @links.each do |link|\n file=download_to + link.split(\"/\")[-1]\n dump_to_file(file, open(link).read)\n files << file\n end unless uri.host.nil?\n files\n end",
"def download_install_file(action, args={})\n company = @company\n username = @user\n password = @password\n url = \"https://#{company}.logicmonitor.com/santaba/do/#{action}?\"\n args.each_pair do |key, value|\n url << \"#{key}=#{value}&\"\n end\n url << \"c=#{company}&u=#{username}&p=#{password}\"\n uri = URI(url)\n begin\n http = Net::HTTP.new(uri.host, 443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(req)\n return response.body\n rescue SocketError => se\n puts \"There was an issue communicating with #{url}. Please make sure everything is correct and try again.\"\n puts se.message\n rescue Error => e\n puts \"There was an issue.\"\n puts e.message\n end\n return nil\nend",
"def download_sources(url)\n filename = \"v#{version}.tar.gz\"\n cached_sources = File.join(SOURCES_CACHE_DIR, filename)\n\n if CfObsBinaryBuilder::CACHE_SOURCES\n FileUtils.mkdir_p(SOURCES_CACHE_DIR)\n if !File.exist?(cached_sources)\n system(\"wget #{url} -O #{cached_sources}\")\n end\n FileUtils.copy(cached_sources, filename)\n else\n system(\"wget #{url} -O #{filename}\")\n end\n end",
"def download_resource(loader, src_url)\n # play nice with remote web servers\n sleep(rand / 100) if src_url =~ /^[[:alpha:]]+:/\n begin\n loader.spec_invoke(:data_source, src_url, nil)\n rescue Exception => e\n # FIXME: log\n $stderr.puts \"[NOKOGIRI] Cannot download resource : #{e.message}\"\n $stderr.puts e.backtrace[0,2].join(\"\\n\")\n nil\n end\n end"
] | [
"0.71004707",
"0.6919434",
"0.6706333",
"0.66661835",
"0.6638764",
"0.6534065",
"0.64495856",
"0.6425193",
"0.6380011",
"0.6289728",
"0.6289728",
"0.62469417",
"0.61961335",
"0.6192742",
"0.60085183",
"0.60044193",
"0.5964927",
"0.594745",
"0.59355146",
"0.59159374",
"0.59005517",
"0.58624125",
"0.5842125",
"0.5812099",
"0.58045226",
"0.5801922",
"0.58015263",
"0.57764846",
"0.5744894",
"0.5717854",
"0.5688146",
"0.568359",
"0.5664054",
"0.5659671",
"0.565307",
"0.5652774",
"0.56485486",
"0.56404984",
"0.56302965",
"0.56192553",
"0.56123734",
"0.5611712",
"0.5604696",
"0.5600618",
"0.5594168",
"0.5583622",
"0.55775905",
"0.55758893",
"0.55690235",
"0.5556293",
"0.555301",
"0.55487925",
"0.5548573",
"0.55469984",
"0.5529971",
"0.5522706",
"0.55220354",
"0.5519554",
"0.55195534",
"0.5515365",
"0.5512468",
"0.5510656",
"0.5507286",
"0.55036205",
"0.5495011",
"0.54906416",
"0.5476656",
"0.5475559",
"0.54743415",
"0.5470902",
"0.5470786",
"0.5468965",
"0.5467142",
"0.5458421",
"0.5457216",
"0.5454112",
"0.54512",
"0.5444362",
"0.5441031",
"0.5440111",
"0.5439875",
"0.5427149",
"0.5423375",
"0.5421147",
"0.541505",
"0.541505",
"0.5414581",
"0.5414581",
"0.54128766",
"0.5412169",
"0.5409284",
"0.54064167",
"0.5405644",
"0.5405536",
"0.5400173",
"0.53999054",
"0.53926045",
"0.53903866",
"0.5379421",
"0.5375206",
"0.53723097"
] | 0.0 | -1 |
def load_package_info Sanitize package name. Some PyPI packages can be named 'pythonfoo', so we don't want to end up with a package named 'pythonpythonfoo'. But we want packages named like 'pythonweb' to be suffixed 'pythonpythonweb'. | def fix_name(name)
if name.start_with?("python")
# If the python package is called "python-foo" strip the "python-" part while
# prepending the package name prefix.
return [attributes[:python_package_name_prefix], name.gsub(/^python-/, "")].join("-")
else
return [attributes[:python_package_name_prefix], name].join("-")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_base_package_name\n if project.package_name =~ /\\A[a-z0-9\\.\\+\\-]+\\z/\n project.package_name.dup\n else\n converted = project.package_name.downcase.gsub(/[^a-z0-9\\.\\+\\-]+/, \"-\")\n\n log.warn(log_key) do\n \"The `name' component of IPS package names can only include \" \\\n \"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), \" \\\n \"plus signs (+), and dashes (-). Converting `#{project.package_name}' to \" \\\n \"`#{converted}'.\"\n end\n converted\n end\n end",
"def guess_package_name(gem_name, args)\n package_name = nil\n package_name ||= guess_package_name_from_args(gem_name, args)\n package_name ||= guess_package_name_from_environment\n package_name ||= guess_package_name_from_appfile\n package_name ||= guess_package_name_from_config_files\n package_name\n end",
"def split_name_package(fullname)\n fixing = fullname.gsub(/:/, \".\")\n split = fixing.match(/^(?:((?:\\w+\\.?)*)\\.)?(\\w+)$/) || []\n name = split[2] || \"\"\n package = split[1] || \"\"\n # downcase the first letter of each package name\n package = package.split(\".\").map {|s| s[0].downcase+s[1..-1]}.join(\".\")\n [name, package]\n end",
"def hadoop_package(name)\n return name unless hdp22?\n return name if node['platform_family'] == 'debian'\n fw = name.split('-').first\n pv = hdp_version.tr('.', '_').tr('-', '_')\n nn = \"#{fw}_#{pv}\"\n name.gsub(fw, nn)\n end",
"def package_by_name(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package_by_name\"\n end",
"def parsepkg package, force_rhel = nil\n raise \"Can't parse package name '#{package}'\" unless /(?<pkgname>^.*?)-(?<ver>[0-9\\.]*\\d)[.-](?<pkginfo>.*)$/ =~ package\n\n info = { name: pkgname, version: ver }\n pkgparts = pkginfo.split /[.-]/\n case info[:format] = pkgparts.pop\n when 'rpm'\n info[:arch] = pkgparts.pop\n raise \"Architecture '#{info[:arch]}' is not supported\" unless ['x86_64','noarch'].include? info[:arch]\n if pkgparts.detect { |c| /^(?:rh)?el(\\d)(_.*)?$/ =~ c }\n info[:rhel] = $~[1]\n else\n raise \"Can't determine CentOS release for '#{package}'. Force with -c option\" unless force_rhel\n info[:rhel] = force_rhel\n end\n when 'gem'\n else\n raise \"Suffix #{info[:format]} is not a recognized package type\"\n end\n return info\nend",
"def package_from_name\n case name.downcase\n when 'splunk' then package :splunk\n when 'universal_forwarder' then package :universal_forwarder\n else raise 'Package must be specified (:splunk or :universal_forwarder)'\n end\n end",
"def set_dpkg_package_name(name)\n dpkg_package.name name\n dpkg_package.package_name name\n end",
"def find_package_definition(name)\n packages[validate_package_name_argument(name, require_existing: false)]\n end",
"def pkginfo_from_pkg(package)\n raise RuntimeError, \"#{self.class} needs to overwrite pkginfo_from_pkg\"\n end",
"def load_package_info(setup_py)\n if !attributes[:python_package_prefix].nil?\n attributes[:python_package_name_prefix] = attributes[:python_package_prefix]\n end\n\n begin\n json_test_code = [\n \"try:\",\n \" import json\",\n \"except ImportError:\",\n \" import simplejson as json\"\n ].join(\"\\n\")\n safesystem(\"#{attributes[:python_bin]} -c '#{json_test_code}'\")\n rescue FPM::Util::ProcessFailed => e\n logger.error(\"Your python environment is missing json support (either json or simplejson python module). I cannot continue without this.\", :python => attributes[:python_bin], :error => e)\n raise FPM::Util::ProcessFailed, \"Python (#{attributes[:python_bin]}) is missing simplejson or json modules.\"\n end\n\n begin\n safesystem(\"#{attributes[:python_bin]} -c 'import pkg_resources'\")\n rescue FPM::Util::ProcessFailed => e\n logger.error(\"Your python environment is missing a working setuptools module. I tried to find the 'pkg_resources' module but failed.\", :python => attributes[:python_bin], :error => e)\n raise FPM::Util::ProcessFailed, \"Python (#{attributes[:python_bin]}) is missing pkg_resources module.\"\n end\n\n # Add ./pyfpm/ to the python library path\n pylib = File.expand_path(File.dirname(__FILE__))\n\n # chdir to the directory holding setup.py because some python setup.py's assume that you are\n # in the same directory.\n setup_dir = File.dirname(setup_py)\n\n output = ::Dir.chdir(setup_dir) do\n tmp = build_path(\"metadata.json\")\n setup_cmd = \"env PYTHONPATH=#{pylib}:$PYTHONPATH #{attributes[:python_bin]} \" \\\n \"setup.py --command-packages=pyfpm get_metadata --output=#{tmp}\"\n\n if attributes[:python_obey_requirements_txt?]\n setup_cmd += \" --load-requirements-txt\"\n end\n\n # Capture the output, which will be JSON metadata describing this python\n # package. See fpm/lib/fpm/package/pyfpm/get_metadata.py for more\n # details.\n logger.info(\"fetching package metadata\", :setup_cmd => setup_cmd)\n\n success = safesystem(setup_cmd)\n #%x{#{setup_cmd}}\n if !success\n logger.error(\"setup.py get_metadata failed\", :command => setup_cmd,\n :exitcode => $?.exitstatus)\n raise \"An unexpected error occurred while processing the setup.py file\"\n end\n File.read(tmp)\n end\n logger.debug(\"result from `setup.py get_metadata`\", :data => output)\n metadata = JSON.parse(output)\n logger.info(\"object output of get_metadata\", :json => metadata)\n\n self.architecture = metadata[\"architecture\"]\n self.description = metadata[\"description\"]\n # Sometimes the license field is multiple lines; do best-effort and just\n # use the first line.\n if metadata[\"license\"]\n self.license = metadata[\"license\"].split(/[\\r\\n]+/).first\n end\n self.version = metadata[\"version\"]\n self.url = metadata[\"url\"]\n\n # name prefixing is optional, if enabled, a name 'foo' will become\n # 'python-foo' (depending on what the python_package_name_prefix is)\n if attributes[:python_fix_name?]\n self.name = fix_name(metadata[\"name\"])\n else\n self.name = metadata[\"name\"]\n end\n\n # convert python-Foo to python-foo if flag is set\n self.name = self.name.downcase if attributes[:python_downcase_name?]\n\n if !attributes[:no_auto_depends?] and attributes[:python_dependencies?]\n metadata[\"dependencies\"].each do |dep|\n dep_re = /^([^<>!= ]+)\\s*(?:([~<>!=]{1,2})\\s*(.*))?$/\n match = dep_re.match(dep)\n if match.nil?\n logger.error(\"Unable to parse dependency\", :dependency => dep)\n raise FPM::InvalidPackageConfiguration, \"Invalid dependency '#{dep}'\"\n end\n name, cmp, version = match.captures\n\n next if attributes[:python_disable_dependency].include?(name)\n\n # convert == to =\n if cmp == \"==\" or cmp == \"~=\"\n logger.info(\"Converting == dependency requirement to =\", :dependency => dep )\n cmp = \"=\"\n end\n\n # dependency name prefixing is optional, if enabled, a name 'foo' will\n # become 'python-foo' (depending on what the python_package_name_prefix\n # is)\n name = fix_name(name) if attributes[:python_fix_dependencies?]\n\n # convert dependencies from python-Foo to python-foo\n name = name.downcase if attributes[:python_downcase_dependencies?]\n\n self.dependencies << \"#{name} #{cmp} #{version}\"\n end\n end # if attributes[:python_dependencies?]\n end",
"def package_name\n # TODO: verify renamed packages\n resource['title']\n end",
"def package_name\n raise Puppet::Error, 'luet requires packages have a category set' unless @resource[:category]\n\n \"#{@resource[:category]}/#{@resource[:name]}\"\n end",
"def package_name\n name = package_drop_last(slug_parts)\n name.empty? ? '_root_' : name\n end",
"def package_name\n @version ? \"#{@name}-#{@version}\" : @name\n end",
"def debian_name(pkginfo, with_rock_release_prefix = true, release_name = nil)\n if pkginfo.kind_of?(String)\n raise ArgumentError, \"method debian_name expects a PackageInfo as argument, got: #{pkginfo.class} '#{pkginfo}'\"\n end\n name = pkginfo.name\n\n debianize_name(name,\n build_type: pkginfo.build_type,\n with_rock_release_prefix: with_rock_release_prefix,\n release_name: release_name)\n end",
"def infer_package(names)\n # Package is longest common prefix ending in '.', if any.\n if not names.empty?\n min, max = names.minmax\n last_common_dot = nil\n min.size.times { |i|\n if min[i] != max[i] then break end\n if min[i] == \".\" then last_common_dot = i end\n }\n if last_common_dot\n return min.slice(0, last_common_dot)\n end\n end\n\n nil\n end",
"def hadoop_package(name)\n return name unless hdp22? || iop?\n return name if node['platform_family'] == 'debian'\n fw =\n if name == 'spark-core'\n name\n else\n name.split('-').first\n end\n pv =\n if hdp22?\n hdp_version.tr('.', '_').tr('-', '_')\n else\n node['hadoop']['distribution_version'].tr('.', '_')\n end\n nn = \"#{fw}_#{pv}\"\n name.gsub(fw, nn)\n end",
"def package_name\n @package_name ||=\n Pathname(\"#{cartage.final_name}.tar#{cartage.tar_compression_extension}\")\n end",
"def package_name(val = NULL_ARG)\n @package_name = val unless val.equal?(NULL_ARG)\n @package_name.nil? ? @name : @package_name\n end",
"def get_requirement_version(package_name)\n requirement = File.read(\"requirements/#{package_name}.txt\").strip\n requirement.delete_prefix(\"#{package_name}==\")\nend",
"def package_name(val = NULL)\n if null?(val)\n @package_name || name\n else\n @package_name = val\n end\n end",
"def parse_pkg fname\n if File.extname(fname) == @extension\n lines = IO.readlines fname\n lines.each do |l|\n begin\n break if l =~ JTools::CLS_DECL_REGEX # stop if we find the class header\n next if l.strip.start_with? \"/*\", \"*\", \"//\"\n if l =~ JTools::PKG_DCL_REGEX # if package declaration found\n pkg_name = l.gsub JTools::EXTR_PKG, \"\" # extract path\n return pkg_name\n end\n rescue ArgumentError => e\n puts \"Error matching line '#{l}' In #{fname}. \" + e.message\n end\n end\n puts \"Warning: #{File.basename fname} has no or no valid package\" +\n \" declaration. Adding to default package.\" if @verbose\n \"\" # if we found nothing -> default package\n else\n raise ArgumentError.new \"Error. #{fname} is no #{@extension} file.\"\n end\n end",
"def package_from_name(package_name)\n return self if package_name == self.name\n local_deps.find { |pkg| pkg.name == package_name }\n end",
"def package_name\n raise NotImplementedError\n end",
"def package_info(package_name)\n # return the package hash if it's in the brew info hash\n return brew_info[package_name] if brew_info[package_name]\n\n # check each item in the hash to see if we were passed an alias\n brew_info.each_value do |p|\n return p if p[\"full_name\"] == package_name || p[\"aliases\"].include?(package_name)\n end\n\n {}\n end",
"def package_name\n if supports_ports?\n if makefile_variable_value(\"PKGNAME\", port_path) =~ /^(.+)-[^-]+$/\n $1\n else\n raise Chef::Exceptions::Package, \"Unexpected form for PKGNAME variable in #{port_path}/Makefile\"\n end\n else\n new_resource.package_name\n end\n end",
"def debian_name(pkg)\n if pkg.kind_of?(Autoproj::RubyPackage)\n debian_ruby_name(pkg.name)\n else\n \"rock-\" + canonize(pkg.name)\n end\n end",
"def full_name\n \"#{@package}.#{parameterized_name}\"\n end",
"def version_file_from( name )\n\t\treturn name.\n\t\t\tsplit( /-/ ).\n\t\t\treject {|word| PACKAGE_IGNORE_WORDS.include?(word) }.\n\t\t\tjoin( '/' )\n\tend",
"def find_package_by_name(name)\n @packages[name]\n end",
"def package *args\n\t\targs.each do | name |\n\t\t\treturn if haspackage? name\n\t\tend\n\t\[email protected]_logger.notify VERBOSE_MAJOR,\"Skipping - package #{args.join(',')} not installed\"\n\t\traise PackageNotInstalledError.new('Package '+args.join(\",\")+' not installed')\n\tend",
"def set_package_filename\n if @package_name.nil?\n @package_name = get_package_name\n end\n end",
"def convert_package(pkginfo, packaging_dir,\n gem_name: nil,\n patch_dir: nil\n )\n Packager.info \"Package Ruby: '#{pkginfo.name}' with gem_name: '#{gem_name}'\"\n\n # update dependencies in any case, i.e. independent if package exists or not\n deps = pkginfo.dependencies\n Dir.chdir(pkginfo.srcdir) do\n begin\n logname = \"package-ruby-#{pkginfo.name.sub(\"/\",\"-\")}\" + \"-\" + Time.now.strftime(\"%Y%m%d-%H%M%S\").to_s + \".log\"\n logfile = File.join(log_dir, logname)\n\n gem = FileList[\"pkg/*.gem\"].first\n if not gem\n Packager.info \"#{self.class}: preparing gem generation in #{Dir.pwd}\"\n\n # Rake targets that should be tried for cleaning\n gem_clean_success = false\n Gem.clean_alternatives.each do |target|\n msg, status = Open3.capture2e(pkginfo.env, \"bundle exec rake #{target}\")\n if !status.success?\n Packager.info \"#{self.class}: failed to clean package '#{pkginfo.name}' using target '#{target}' #{msg} (see #{logfile})\"\n File.open(logfile,\"a+\") {|f| f.puts msg }\n else\n Packager.info \"#{self.class}: succeeded to clean package '#{pkginfo.name}' using target '#{target}'\"\n gem_clean_success = true\n break\n end\n end\n if not gem_clean_success\n Packager.warn \"#{self.class}: failed to cleanup ruby package '#{pkginfo.name}' -- continuing without cleanup\"\n end\n\n Packager.info \"#{self.class}: ruby package Manifest.txt is being autogenerated\"\n Package2Gem.generate_manifest_txt\n Package2Gem.cleanup_multiple_gemspec(gem_name)\n\n Packager.info \"#{self.class}: creating gem from package #{pkginfo.name} [#{File.join(log_dir, logname)}]\"\n\n if patch_pkg_dir(pkginfo.name, patch_dir, whitelist: [\"*.gemspec\", \"Rakefile\", \"metadata.yml\"])\n Packager.info \"#{self.class}: patched build files for ruby package before gem building: #{pkginfo.name}\"\n end\n\n # Allowed gem creation alternatives\n gem_creation_success = false\n\n # Gemspec often use the 'git ls -z' listings, which\n # might break if hidden files will be removed\n # without commiting -- so temporarily add and revert\n # again, to maintain the original commit id\n # TBD: or leave the commit and list the last N commits in the changelog\n Packager.info \"#{self.class}: temporarily commit changes in #{Dir.pwd}\"\n _,_,git_add_status = Open3.capture3(\"git add -A\")\n msg,git_commit_status = Open3.capture2(\"git commit -m 'Apaka: gem creation' --author 'Apaka Packager, <apaka@autocommit>'\")\n if !git_commit_status.success?\n Packager.info \"#{self.class}: commit failed: #{msg}\"\n end\n Gem.creation_alternatives.each do |target|\n msg, status = Open3.capture2e(pkginfo.env, \"bundle exec rake #{target}\")\n if !status.success?\n Packager.info \"#{self.class}: failed to create gem using target '#{target}' (see #{logfile})\"\n File.open(logfile,\"a+\") do |f|\n f.puts msg\n f.puts pkginfo.env\n end\n else\n Packager.info \"#{self.class}: succeeded to create gem using target '#{target}'\"\n gem_creation_success = true\n break\n end\n end\n if git_commit_status.success?\n Packager.info \"#{self.class}: git package status\"\n msg, git_revert = Open3.capture2(\"git reset --soft HEAD~1\")\n Packager.info \"#{self.class}: reversion of temporary commit failed\"\n end\n if not gem_creation_success\n raise RuntimeError, \"Debian: failed to create gem from RubyPackage #{pkginfo.name}\"\n end\n end\n\n gem = FileList[\"pkg/*.gem\"].first\n\n # Make the naming of the gem consistent with the naming schema of\n # other packages\n #\n # Make sure the gem has the fullname, e.g.\n # tools-metaruby instead of just metaruby\n if gem_name\n gem_name = gem.sub(Packaging.basename(pkginfo.name), gem_name)\n if gem != gem_name\n Packager.info \"#{self.class}: renaming #{gem} to #{gem_name}\"\n end\n else\n gem_name = gem\n end\n Packager.info \"#{self.class}: '#{pkginfo.name}' -- basename: #{Packaging.basename(pkginfo.name)} will be packaged as: #{gem_name}\"\n\n gem_final_path = File.join(packaging_dir, File.basename(gem_name))\n Packager.info \"#{self.class}: copy #{File.join(Dir.pwd, gem)} to #{gem_final_path}\"\n FileUtils.cp gem, gem_final_path\n return gem_final_path\n\n rescue Exception => e\n raise RuntimeError, \"#{self.class}: failed to create gem from RubyPackage #{pkginfo.name} -- #{e.message}\\n#{e.backtrace.drop(1).map{|s| \"\\t#{s}\"}}\"\n end\n end\n end",
"def set_package_info\n download_and_extract_package\n parse_package_description\n @package_hash = filter_into_package @package_desc\n @version_hash = filter_into_version @package_desc\n @author_hash = filter_into_author @package_desc[\"Author\"]\n @maintainer_hash = filter_into_author @package_desc[\"Maintainer\"]\n end",
"def has_package?(name)\n packages.has_key?(name) || os_package_resolver.include?(name)\n end",
"def prefixed_label(package)\n label = ( package =~ /^#{$prefix}(.*)$/ ) && $1 || package\n label = '.' if label.empty?\n label\nend",
"def check_pkg_info\n return false if options['package_url'].nil? ||\n options['package_name'].nil?\n true\nend",
"def get_short_lookup(gemname)\n md = /^([-a-zA-z_0-9\\.]+)(?:-|\\.)(?:\\d+(?:\\.[\\drc]+)*)$/.match(gemname)\n if (!md)\n puts %{skipping weirdly formed directory: \"#{gemname}\"}\n #raise Exception.new(%{Sorry, we failed to match against \"#{gemname}\"})\n end\n return $1\nend",
"def clean_module_name(module_name)\n module_name.gsub /[\\-@]/, ''\n end",
"def key_for_package(pkg)\n if !pkg.id.nil?\n \"#{pkg.id}-#{@name}\"\n else\n return \"#{pkg.categories.split.first}/#{pkg.name}-#{@name}\"\n end\n end",
"def all_package_names\n each_autobuild_package.map(&:name)\n end",
"def search_for_description pkgname, packages = []\n cache_key = \"description_package_#{pkgname.downcase}\"\n description_package = Rails.cache.fetch(cache_key, :expires_in => 12.hours) do\n if packages.blank?\n packages = Seeker.prepare_result(\"\\\"#{pkgname}\\\"\", nil, nil, nil, nil)\n packages = packages.reject {|p| p.first.type == 'ymp'}\n end\n packages.select {|p| p.name == pkgname}.each do |package|\n description_package = nil\n unless package.description.blank?\n description_package = package\n logger.info \"Found package info for #{pkgname} in: #{package.project}\"\n break\n end\n logger.error \"No package info for #{pkgname} in: #{package.project}\"\n end\n description_package\n end\n end",
"def haspackage? pkgname\n\t\tif @cf.packagelist\n\t\t\treturn @cf.packagelist[pkgname]\n\t\tend\n\t\t# ---- check for direct name of binary using the path\n\t\t`which #{pkgname}` =~ /#{pkgname}/\n\tend",
"def get_app_name(app_name)\n app_file = $pkg_dir+\"/\"+app_name.downcase.gsub(/ |-/,'_')+\".rb\"\n if File.exist?(app_file)\n app_name = eval(\"get_#{app_name.downcase.gsub(/ |-/,'_')}_app_name()\")\n else\n app_list = Dir.entries($pkg_dir)\n tmp_name = app_list.grep(/^#{app_name.downcase.gsub(/ |-/,'_')}/)[0]\n if tmp_name\n tmp_name = tmp_name.gsub(/\\.rb/,\"\")\n else\n puts\n end\n if tmp_name =~ /[A-z]/\n if $verbose == 1\n puts \"Application profile \"+app_name+\" not found\"\n puts \"Found profile \"+tmp_name\n end\n app_name = eval(\"get_#{tmp_name.downcase.gsub(/ |-/,'_')}_app_name()\")\n else\n puts \"Application \"+app_name+\" not found\"\n puts\n puts \"Available Applications:\"\n puts\n print_avail_pkgs()\n puts\n exit\n end\n end\n return app_name\nend",
"def package_name(project)\n \"#{project.name}-#{project.version}-#{project.release}.#{@architecture}.pkg.gz\"\n end",
"def fmri_package_name\n version = project.build_version.split(/[^\\d]/)[0..2].join(\".\")\n platform = Ohai[\"platform_version\"]\n \"#{safe_base_package_name}@#{version},#{platform}-#{project.build_iteration}\"\n end",
"def package_name\n [self.config.organization, self.config.project_name].compact.collect(&:underscore).join('-')\n end",
"def ignore_package(package)\n invalidate_ignored_package_names\n @ignored_packages << validate_package_name_argument(package, require_existing: false)\n end",
"def assertNamespace(name)\n ns, base = DataMetaDom.splitNameSpace(name)\n scalaPackage = DataMetaDom.validNs?(ns, base) ? ns : ''\n packagePath = scalaPackage.empty? ? '' : scalaPackage.gsub('.', File::SEPARATOR)\n\n [scalaPackage, base, packagePath]\n end",
"def fixed_name(file, bad_name)\n if (file.dylib? || file.mach_o_bundle?) && (file.parent + bad_name).exist?\n \"@loader_path/#{bad_name}\"\n elsif file.mach_o_executable? && (lib + bad_name).exist?\n \"#{lib}/#{bad_name}\"\n elsif (abs_name = find_dylib(Pathname.new(bad_name).basename)) && abs_name.exist?\n abs_name.to_s\n else\n opoo \"Could not fix #{bad_name} in #{file}\"\n bad_name\n end\n end",
"def whereis(package_name)\n package_name = validate_package_name_argument(package_name)\n\n matches = [package_name]\n if (source_package = find_package_definition(package_name))\n each_metapackage do |meta|\n matches << meta.name if meta.include?(source_package)\n end\n end\n\n matches.each do |name|\n if (place = normalized_layout[name])\n return place\n end\n end\n \"/\"\n end",
"def StripPath(pkg_name)\n return nil if pkg_name == nil\n\n file_pos = Builtins.findlastof(pkg_name, \"/\")\n\n if file_pos != nil && Ops.greater_than(file_pos, 0)\n # return just the file name\n pkg_name = Builtins.substring(pkg_name, Ops.add(file_pos, 1))\n end\n\n pkg_name\n end",
"def package_basename(extension='.gem')\n [ package_name, version ].join('-') + extension\n end",
"def remove_from_default(*names)\n pkg_set = Autoproj.current_package_set\n Autoproj.workspace.manifest.metapackage(pkg_set.name).packages.delete_if do |pkg|\n names.include?(pkg.name)\n end\nend",
"def lookup(package_name)\n pkgs = @rpms[package_name]\n if pkgs\n pkgs.sort.reverse\n else\n nil\n end\n end",
"def package_name_valid?\n return false if metadata[\"sip-name\"] =~ /^\\./\n return false if metadata[\"sip-name\"] =~ /\"/\n return false if metadata[\"sip-name\"] =~ /'/\n return false if metadata[\"sip-name\"] =~ / /\n return false if metadata[\"sip-name\"].length > 32\n\n true\n end",
"def metapackage(name, *packages)\n Autoproj.workspace.manifest.metapackage(name, *packages)\nend",
"def get_saltstack_package_full_name(package)\n # pillar = YAML.safe_load(File.read('test/salt/pillar/windows.sls'))\n url = 'https://raw.githubusercontent.com/saltstack/salt-winrepo-ng/master/'\n files = [package + '.sls', package + '/init.sls']\n # example: package = \"7zip\"=>{\"version\"=>\"18.06.00.0\", \"refresh_minion_env_path\"=>false}\n saltstack_package_full_name = files.find do |checkme|\n ps = \"$f = (((Get-ChildItem -Path $env:LOCALAPPDATA -Filter 'salt-winrepo-ng' -Recurse -Directory).Fullname[0]) + '\\\\#{checkme.sub('/', '\\\\')}'); if (Test-Path $f -PathType Leaf) {Get-Content -Path $f}\"\n begin\n file = (open(url + checkme) & :read)\n rescue\n begin\n file = (powershell(ps).stdout)\n rescue\n next\n end\n end\n unless file.nil? || file.empty?\n candidate = file.match(/full_name: '([\\S]+).*'/).captures[0]\n end\n break candidate unless candidate.nil?\n end\n Inspec::Log.debug('[get_saltstack_package_full_name] found candidate: ' + saltstack_package_full_name)\n saltstack_package_full_name\nend",
"def is_module_package?(name)\n filename = File.expand_path(name)\n filename =~ /.tar.gz$/\n end",
"def vendored_package_name(package)\n\tFile.join($package_name, 'vendor/src', package)\nend",
"def package(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package\"\n end",
"def package_name(buildno=nil)\n if buildno\n buildno = Time.now.strftime(\"%H*60+%M\")\n versnum = \"#{version}.#{buildno}\"\n else\n versnum = version\n end\n\n if platform\n \"#{name}-#{versnum}-#{platform}\"\n else\n \"#{name}-#{versnum}\"\n end\n end",
"def debianize_name(name, build_type: :cmake, with_rock_release_prefix: true, release_name: rock_release_name)\n if build_type == :ruby\n if with_rock_release_prefix\n rock_release_prefix(release_name) + \"ruby-\" + Deb.canonize(name)\n else\n pkg_prefix_base + \"-ruby-\" + Deb.canonize(name)\n end\n else\n if with_rock_release_prefix\n rock_release_prefix(release_name) + Deb.canonize(name)\n else\n pkg_prefix_base + \"-\" + Deb.canonize(name)\n end\n end\n end",
"def validate(package_name = nil)\n missing = {}\n packages = {}\n if package_name\n if @pkg_to_deb.has_key?(package_name)\n packages[package_name] = @pkg_to_deb[package_name]\n else\n raise ArgumentError, \"#{self} package '#{package_name}'\"\\\n \" is not defined\"\n end\n else\n packages = @pkg_to_deb\n end\n packages.each do |k,v|\n if PackageSelector.available?(v)\n Autoproj.message \"#{k} : #{v} [OK]\"\n else\n Autoproj.warn \"#{k} : #{v} [MISSING]\"\n missing[k] = v\n end\n end\n\n if missing.empty?\n Autoproj.message \"Perfect - all packages point to a known Debian package in your osdeps file.\"\n else\n Autoproj.warn \"Packages #{missing.keys.join(\",\")} are listed to have a debian package,\"\\\n \"but their debian packages are unknown to 'apt'.\\nDid you forget \"\\\n \"to call 'apt update'?\"\n end\n return missing.keys\n end",
"def check_for_package host, package_name\n host.check_for_package package_name\n end",
"def is_metapackage?(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite is_metapackage?\"\n end",
"def package(pkginfo, options = Hash.new)\n options, unknown_options = Kernel.filter_options options,\n :force_update => false,\n :patch_dir => nil,\n :distribution => nil, # allow to override global settings\n :architecture => nil\n\n options[:distribution] ||= target_platform.distribution_release_name\n options[:architecture] ||= target_platform.architecture\n\n debian_pkg_name = debian_name(pkginfo)\n\n if options[:force_update]\n dirname = packaging_dir(pkginfo)\n if File.directory?(dirname)\n Packager.info \"Debian: rebuild requested -- removing #{dirname}\"\n FileUtils.rm_rf(dirname)\n end\n end\n\n options[:packaging_dir] = packaging_dir(pkginfo)\n options[:release_name] = rock_release_name\n\n begin\n # Set the current pkginfo to set the install directory\n # correctly\n # FIXME: needs to be refactored\n #\n @packager_lock.lock\n @current_pkg_info = pkginfo\n\n pkginfo = prepare_source_dir(pkginfo, options.merge(unknown_options))\n\n if pkginfo.build_type == :orogen || pkginfo.build_type == :cmake || pkginfo.build_type == :autotools\n package_default(pkginfo, options)\n elsif pkginfo.build_type == :ruby\n # Import bundles since they do not need to be build and\n # they do not follow the typical structure required for gem2deb\n if pkginfo.name =~ /bundles/\n package_importer(pkginfo, options)\n else\n package_ruby(pkginfo, options)\n end\n elsif pkginfo.build_type == :archive_importer || pkginfo.build_type == :importer_package\n package_importer(pkginfo, options)\n else\n raise ArgumentError, \"Debian: Unsupported package type #{pkginfo.build_type} for #{pkginfo.name}\"\n end\n ensure\n @current_pkg_info = nil\n @packager_lock.unlock\n end\n end",
"def input(pacman_pkg_path)\n control = {}\n # Unpack the control tarball\n safesystem(tar_cmd, \"-C\", staging_path, \"-xf\", pacman_pkg_path)\n pkginfo = staging_path(\".PKGINFO\")\n mtree = staging_path(\".MTREE\")\n install = staging_path(\".INSTALL\")\n\n control_contents = File.read(pkginfo)\n FileUtils.rm(pkginfo)\n FileUtils.rm(mtree)\n\n\n control_lines = control_contents.split(\"\\n\")\n control_lines.each do |line|\n key, val = line.split(/ += +/, 2)\n if control.has_key? key\n control[key].push(val)\n else\n control[key] = [val]\n end\n end\n\n self.name = control[\"pkgname\"][0]\n\n # Parse 'epoch:version-iteration' in the version string\n version_re = /^(?:([0-9]+):)?(.+?)(?:-(.*))?$/\n m = version_re.match(control[\"pkgver\"][0])\n if !m\n raise \"Unsupported version string '#{control[\"pkgver\"][0]}'\"\n end\n self.epoch, self.version, self.iteration = m.captures\n\n self.maintainer = control[\"packager\"][0]\n\n # Arch has no notion of vendor, so...\n #self.vendor =\n\n self.url = control[\"url\"][0]\n # Groups could include more than one.\n # Speaking of just taking the first entry of the field:\n # A crude thing to do, but I suppose it's better than nothing.\n # -- Daniel Haskin, 3/24/2015\n self.category = control[\"group\"] && control[\"group\"][0] || self.category\n\n # Licenses could include more than one.\n # Speaking of just taking the first entry of the field:\n # A crude thing to do, but I suppose it's better than nothing.\n # -- Daniel Haskin, 3/24/2015\n self.license = control[\"license\"][0] || self.license\n\n self.architecture = control[\"arch\"][0]\n\n self.dependencies = control[\"depend\"] || self.dependencies\n\n self.provides = control[\"provides\"] || self.provides\n\n self.conflicts = control[\"conflict\"] || self.conflicts\n\n self.replaces = control[\"replaces\"] || self.replaces\n\n self.description = control[\"pkgdesc\"][0]\n\n if control.include? \"backup\"\n self.config_files = control[\"backup\"].map{|file| \"/\" + file}\n else\n self.config_files = []\n end\n\n self.dependencies = control[\"depend\"] || self.dependencies\n \n if attributes[:no_auto_depends?]\n self.dependencies = []\n end\n\n self.attributes[:pacman_optional_depends] = control[\"optdepend\"] || []\n # There are other available attributes, but I didn't include them because:\n # - makedepend: deps needed to make the arch package. But it's already\n # made. It just needs to be converted at this point\n # - checkdepend: See above\n # - makepkgopt: See above\n # - size: can be dynamically generated\n # - builddate: Should be changed to time of package conversion in the new\n # package, so this value should be thrown away.\n\n if File.exist?(install)\n functions = parse_install_script(install)\n if functions.include?(\"pre_install\")\n self.scripts[:before_install] = functions[\"pre_install\"].join(\"\\n\")\n end\n if functions.include?(\"post_install\")\n self.scripts[:after_install] = functions[\"post_install\"].join(\"\\n\")\n end\n if functions.include?(\"pre_upgrade\")\n self.scripts[:before_upgrade] = functions[\"pre_upgrade\"].join(\"\\n\")\n end\n if functions.include?(\"post_upgrade\")\n self.scripts[:after_upgrade] = functions[\"post_upgrade\"].join(\"\\n\")\n end\n if functions.include?(\"pre_remove\")\n self.scripts[:before_remove] = functions[\"pre_remove\"].join(\"\\n\")\n end\n if functions.include?(\"post_remove\")\n self.scripts[:after_remove] = functions[\"post_remove\"].join(\"\\n\")\n end\n FileUtils.rm(install)\n end\n\n # Note: didn't use `self.directories`.\n # Pacman doesn't really record that information, to my knowledge.\n\n end",
"def remove_package(package, version = nil)\n ext = File.extname(package).tr(\".\", \"\")\n if ext.empty?\n ext = %w(deb) # rpm)\n else\n ext = [ext]\n end\n ext.each do |ext_name|\n package_handler(ext_name).remove(content, package, version)\n end\n end",
"def native_pkg_to_install_string(pkg)\n name = pkg[:metadata][:name]\n version = pkg[:metadata][:version]\n package_version = pkg[:metadata][:package_version]\n pkgname = \"#{name}-#{version}\"\n if package_version\n pkgname << \"-#{package_version}\"\n end\n pkgname\n end",
"def find_name(gem_name, requirement = T.unsafe(nil)); end",
"def debian_meta_name(name, with_rock_release_prefix = true)\n if with_rock_release_prefix\n rock_release_prefix + \"meta-\" + Deb.canonize(name)\n else\n pkg_prefix_base + \"meta-\" + Deb.canonize(name)\n end\n end",
"def differentiate(packages)\n named_groups = Hash.new{|h,k| h[k] = []}\n packages.each{|p| named_groups[p.name] << p }\n named_groups.each do |name, packages| \n if packages.length > 1\n packages.each{|p| p.name = \"#{p.name} (#{p.paths.first})\"} \n end\n end\n end",
"def package(name)\n if name.respond_to? :cache_path\n name\n elsif @versions[name]\n Package.for(@sources[name], @versions[name], @files[name])\n end\n end",
"def check_for_package host, package_name\n host.check_for_package package_name\n end",
"def excluded_in_manifest?(package_name)\n package_name = validate_package_name_argument(package_name)\n manifest_exclusions.any? do |matcher|\n if (pkg_set = metapackages[matcher]) && pkg_set.include?(package_name)\n true\n else\n Regexp.new(matcher) === package_name\n end\n end\n end",
"def python_packages\n PRE_INSTALLED_PYTHON_PACKAGES.join(\" #{NL_TAB}\")\n end",
"def package_filename\n \"#{@package.name}_#{@package.version}_#{@package.architecture}.deb\"\n end",
"def package?(package_name)\n id = @package_ids[package_name]\n return id if id\n\n package_id = nil\n\n page = \"/frs/\"\n\n form = {\n \"group_id\" => group_id\n }\n scrape = http_post(page, form)\n\n restr = ''\n restr << Regexp.escape( package_name )\n restr << '\\s*'\n restr << Regexp.escape( '<a href=\"/frs/monitor.php?filemodule_id=' )\n restr << '(\\d+)'\n restr << Regexp.escape( %{&group_id=#{group_id}} )\n re = Regexp.new( restr )\n\n md = re.match( scrape )\n if md\n package_id = md[1]\n end\n\n @package_ids[package_name] = package_id\n end",
"def resolve( name, version )\n # It is possible, and almost inevitable, that we can install two packages that must oscilate\n # at the same time. As a result, we will be relinking a package that has not been installed yet,\n # but will be on the next commit. In this situation, we need keep a cache of packages mapped in\n # this session, so that when this occurs, we can resolve it with no problems. In this way, we\n # maintain an instance variable hash that is added to whenever map() is called\n cached = @pkg_cache[ \"%s-%s\" % [ name, version ] ]\n if( cached != nil )\n return cached\n end\n\n # Past this, we do not want to proceed if the package is not present in the install\n # dir\n\n # We ensure that this package is in fact installed\n if( !File.directory?( Config.instance.install_dir + \"/\" + name + \"/\" + version ) )\n puts \"%s-%s is not installed!\" % [ name, version ]\n return nil\n end\n\n # If the cache file exists and is in fact a file, slurp it up and use that\n # I'd love to do some digest check here to:\n # 1. Ensure that the cache file is intact and valid\n # 2. The directory installed matches the one that this cache file was generated from\n\n # First, we check the cache to see if we've resolved this package before\n # Figure out where the cache file would be if it existed\n cache_file = Config.instance.cache_dir + \"/\" + name + \"-\" + version + \".json\"\n if( File.file?( cache_file ) )\n file = File.new( cache_file, \"r\" )\n buff = \"\"\n while (line = file.gets)\n buff += line\n end\n file.close( )\n pkg = JSON.parse( buff )\n return pkg\n end\n\n # If we haven't, we'll need to do a full trace of the package\n\n # It may be better to store all of our package file in\n # $(install_dir)/$(name)/$(version)/pkg_files\n # and store the manifest next to pkg_files\n # Therefore, when we need to do this, we can just consult the manifest for\n # data such as dependencies\n pkg = map( Config.instance.install_dir + \"/\" + name + \"/\" + version )\n file = File.new( cache_file, \"w\" )\n\n # Write metadata\n file.write( pkg.to_json( ) )\n\n file.close( )\n\n return pkg\n end",
"def locate_package(package_name, vers, verbose)\n local = has_local_package?(package_name)\n \n # It's true that we don't have a prerelase check here, but the\n # previous one we had didn't do anything, so it's better to have\n # none than one that doesn't work\n vers = \">= 0\" if vers == \">= 0-pre\"\n src_path = local ? locate_local_package(package_name) : \n BPM::Local.new.source_root(package_name, vers)\n\n return nil unless src_path\n\n pkg = BPM::Package.new(src_path)\n pkg.load_json # throws exception if json invalid\n pkg\n end",
"def key\n \"gem-package-#{name}\"\n end",
"def get_setuptools\n\t\tpackage_name = \"python-setuptools\"\n\t\tcase node.platform\n\t\twhen /fedora|redhat|centos|ubuntu/\n\t\t package_name = \"python-setuptools\"\n\t\tend\n\t\tpackage_name\n\tend",
"def run_package_for_specified(bundle_info)\n if $options[:buildAll]\n info 'Packaging all dependencies'\n\n $toPackageDeps = []\n\n all_dependencies.each do |dep|\n files = dep.getInstalledFiles\n\n $toPackageDeps.push dep.Name if files && !files.empty?\n end\n\n puts $toPackageDeps.to_s\n end\n\n package_dependencies $toPackageDeps, bundle_info\nend",
"def package_to_path(str)\n str.to_s.split('.').map{|e| underscore(e) }.join('/')\n end",
"def manifest_name(name, pack_type)\n name.chomp(\".#{pack_type}\")\n end",
"def package(version)\n packages[version] if package_setup.include? version\n end",
"def load_package_manifest(pkg)\n if pkg.respond_to?(:to_str)\n pkg_definition = find_package_definition(pkg)\n unless pkg_definition\n raise ArgumentError, \"#{pkg} is not a known package in #{self}\"\n end\n\n pkg = pkg_definition\n end\n package = pkg.autobuild\n package_set = pkg.package_set\n\n # Look for the package's manifest.xml, but fallback to a manifest in\n # the package set if present\n if package.use_package_xml? && package.checked_out?\n manifest_path = File.join(package.srcdir, \"package.xml\")\n raise NoPackageXML.new(package.srcdir), \"#{package.name} from \"\\\n \"#{package_set.name} has use_package_xml set, but the package has \"\\\n \"no package.xml file\" unless File.file?(manifest_path)\n\n manifest = PackageManifest.load(package, manifest_path,\n ros_manifest: true,\n condition_context: @ws.env)\n else\n manifest_paths = [File.join(package.srcdir, \"manifest.xml\")]\n if package_set.local_dir\n manifest_paths << File.join(\n package_set.local_dir, \"manifests\", \"#{package.name}.xml\"\n )\n end\n manifest_path = manifest_paths.find do |path|\n File.file?(path)\n end\n if manifest_path\n manifest = PackageManifest.load(package, manifest_path,\n ros_manifest: false,\n condition_context: @ws.config)\n end\n end\n\n if manifest\n pkg.autobuild.description = manifest\n else\n Autoproj.warn \"#{package.name} from #{package_set.name} \"\\\n \"does not have a manifest\"\n end\n\n pkg.apply_dependencies_from_manifest\n # #description is initialized with a null package manifest\n # return it even if we haven't overriden it\n pkg.autobuild.description\n end",
"def default_dev_package\n # Check for an override.\n return dev_package_overrides[package_name] if dev_package_overrides.include?(package_name)\n suffix = node.value_for_platform_family(debian: '-dev', rhel: '-devel', fedora: '-devel')\n # Platforms like Arch and Gentoo don't need this anyway. I've got no\n # clue how Amazon Linux does this.\n if suffix\n package_name + suffix\n else\n nil\n end\n end",
"def find_package(name, constraint)\n # implement inside child\n end",
"def find_autobuild_package(name)\n find_package_definition(name)&.autobuild\n end",
"def find_package_set_by_name(name)\n @package_sets[name]\n end",
"def uninstall(packagename)\n\t\t\t\tpackagename.strip!()\n\n\t\t\t\tCfruby.controller.attempt(\"Uninstalling \\\"#{packagename}\\\"\", 'destructive', 'unknown') {\n\t\t\t\t\t# we have to iterate through all the attributes (name, name-version, origin) to properly delete what this could be.\n\t\t\t\t\tpackagetodelete = nil\n\t\t\t\t\tinstalled_packages().each_value() { |package|\n\t\t\t\t\t\tif((packagename == package.name) or (packagename == \"#{package.name}-#{package.version}\"))\n\t\t\t\t\t\t\tpackagetodelete = package.name + '-' + package.version\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\n\t\t\t\t\tif packagetodelete.nil?\n\t\t\t\t\t\tCfruby.controller.attempt_abort(\"package \\\"#{packagename}\\\": not installed\")\n\t\t\t\t\telse\n\t\t\t\t\t\tExec.exec(\"/usr/sbin/pkg_delete #{packagetodelete}`\")\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend",
"def remove_obsolete_installed_orogen_package(name)\n post_install do\n path = File.join(prefix, 'lib', 'pkgconfig')\n Dir.glob(File.join(path, \"#{name}-*.pc\")) do |pcfile|\n Autoproj.message \" removing obsolete file #{pcfile}\", :bold\n FileUtils.rm_f pcfile\n end\n pcfile = File.join(path, \"orogen-project-#{name}.pc\")\n if File.exists?(pcfile)\n Autoproj.message \" removing obsolete file #{pcfile}\", :bold\n FileUtils.rm_f pcfile\n end\n end\n end",
"def apt_packages\n PRE_INSTALLED_OS_PACKAGES[@app.release].join(\" #{NL_TAB}\")\n end",
"def has_local_package?(package_name)\n !!locate_local_package(package_name)\n end",
"def sanitize_mods_name_label(label)\n label.sub(/:$/, '')\n end",
"def find_package_set(name)\n each_package_set.find { |set| set.name == name }\n end",
"def exclusion_reason(package_name)\n package_name = validate_package_name_argument(package_name)\n if (message = automatic_exclusions[package_name])\n return message\n end\n\n unless explicitely_selected_in_layout?(package_name)\n manifest_exclusions.each do |matcher|\n if (pkg_set = metapackages[matcher]) && pkg_set.include?(package_name)\n return \"#{pkg_set.name} is a metapackage listed in the exclude_packages section of the manifest, and it includes #{package_name}\"\n elsif Regexp.new(matcher) === package_name\n return \"#{package_name} is listed in the exclude_packages section of the manifest\"\n end\n end\n end\n nil\n end"
] | [
"0.69934404",
"0.6959691",
"0.6787717",
"0.6310151",
"0.6293955",
"0.62888145",
"0.62537575",
"0.6212074",
"0.6195865",
"0.6192598",
"0.614291",
"0.6097812",
"0.6068529",
"0.605559",
"0.6009521",
"0.60049826",
"0.5959391",
"0.594701",
"0.59226805",
"0.5913534",
"0.5860331",
"0.58454496",
"0.5832183",
"0.58307236",
"0.5816502",
"0.57929045",
"0.5785546",
"0.5784202",
"0.5777751",
"0.5767661",
"0.5762931",
"0.57584476",
"0.5739466",
"0.5730473",
"0.5706363",
"0.566976",
"0.56656283",
"0.56649536",
"0.5646703",
"0.56314707",
"0.56016773",
"0.55931824",
"0.559134",
"0.5577771",
"0.55580986",
"0.5551919",
"0.55454123",
"0.5539231",
"0.5509717",
"0.54938054",
"0.5471012",
"0.5465433",
"0.54628736",
"0.5461863",
"0.54611754",
"0.54602003",
"0.5445937",
"0.5445066",
"0.5437838",
"0.54335964",
"0.54331434",
"0.5427423",
"0.5422318",
"0.54181993",
"0.54110664",
"0.5406505",
"0.5381667",
"0.5366782",
"0.53555924",
"0.5352597",
"0.5352563",
"0.53519255",
"0.5347068",
"0.5339078",
"0.53232414",
"0.53158474",
"0.5311179",
"0.5310318",
"0.5306191",
"0.53002447",
"0.527789",
"0.5269109",
"0.5264347",
"0.52621037",
"0.5253441",
"0.5235223",
"0.5230156",
"0.52252823",
"0.5222696",
"0.52197504",
"0.52153784",
"0.52146983",
"0.5204534",
"0.5192319",
"0.51844066",
"0.5183328",
"0.5173787",
"0.5170709",
"0.51674074",
"0.51670307"
] | 0.7285747 | 0 |
def fix_name Install this package to the staging directory | def install_to_staging(setup_py)
project_dir = File.dirname(setup_py)
prefix = "/"
prefix = attributes[:prefix] unless attributes[:prefix].nil?
# Some setup.py's assume $PWD == current directory of setup.py, so let's
# chdir first.
::Dir.chdir(project_dir) do
flags = [ "--root", staging_path ]
if !attributes[:python_install_lib].nil?
flags += [ "--install-lib", File.join(prefix, attributes[:python_install_lib]) ]
elsif !attributes[:prefix].nil?
# setup.py install --prefix PREFIX still installs libs to
# PREFIX/lib64/python2.7/site-packages/
# but we really want something saner.
#
# since prefix is given, but not python_install_lib, assume PREFIX/lib
flags += [ "--install-lib", File.join(prefix, "lib") ]
end
if !attributes[:python_install_data].nil?
flags += [ "--install-data", File.join(prefix, attributes[:python_install_data]) ]
elsif !attributes[:prefix].nil?
# prefix given, but not python_install_data, assume PREFIX/data
flags += [ "--install-data", File.join(prefix, "data") ]
end
if !attributes[:python_install_bin].nil?
flags += [ "--install-scripts", File.join(prefix, attributes[:python_install_bin]) ]
elsif !attributes[:prefix].nil?
# prefix given, but not python_install_bin, assume PREFIX/bin
flags += [ "--install-scripts", File.join(prefix, "bin") ]
end
if !attributes[:python_scripts_executable].nil?
# Overwrite installed python scripts shebang binary with provided executable
flags += [ "build_scripts", "--executable", attributes[:python_scripts_executable] ]
end
if !attributes[:python_setup_py_arguments].nil? and !attributes[:python_setup_py_arguments].empty?
# Add optional setup.py arguments
attributes[:python_setup_py_arguments].each do |a|
flags += [ a ]
end
end
safesystem(attributes[:python_bin], "setup.py", "install", *flags)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_name(name)\n if name.start_with?(\"python\")\n # If the python package is called \"python-foo\" strip the \"python-\" part while\n # prepending the package name prefix.\n return [attributes[:python_package_name_prefix], name.gsub(/^python-/, \"\")].join(\"-\")\n else\n return [attributes[:python_package_name_prefix], name].join(\"-\")\n end\n end",
"def set_dpkg_package_name(name)\n dpkg_package.name name\n dpkg_package.package_name name\n end",
"def safe_base_package_name\n if project.package_name =~ /\\A[a-z0-9\\.\\+\\-]+\\z/\n project.package_name.dup\n else\n converted = project.package_name.downcase.gsub(/[^a-z0-9\\.\\+\\-]+/, \"-\")\n\n log.warn(log_key) do\n \"The `name' component of IPS package names can only include \" \\\n \"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), \" \\\n \"plus signs (+), and dashes (-). Converting `#{project.package_name}' to \" \\\n \"`#{converted}'.\"\n end\n converted\n end\n end",
"def package(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package\"\n end",
"def package_name\n @package_name ||=\n Pathname(\"#{cartage.final_name}.tar#{cartage.tar_compression_extension}\")\n end",
"def install(packagename, force=false)\n\t\t\t\tpackagename.strip!()\n\n\t\t\t\t# FIXME - check to see if it is already installed\n\n\t\t\t\tCfruby.controller.attempt(\"Installing \\\"#{packagename}\\\"\", 'destructive', 'unknown', 'install') {\n\t\t\t\t\t`#{@rpmbin} -i '#{packagename.gsub(/(\\')/, \"\\\\\\1\")}'`\n\t\t\t\t}\n\t\t\tend",
"def package_by_name(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package_by_name\"\n end",
"def install(packagename, force=false)\n\t\t\t\tpackagename.strip!()\n\n\t\t\t\t# FIXME - check to see if it is already installed\n\n\t\t\t\tCfruby.controller.attempt(\"Installing \\\"#{packagename}\\\"\", 'destructive', 'unknown', 'install') {\n\t\t\t\t\t`#{@finkbin} install '#{packagename.gsub(/(\\')/, \"\\\\\\1\")}'`\n\t\t\t\t}\n\t\t\tend",
"def install!(name:, dir: nil)\r\n end",
"def fix_name\n\t if not self.name\n\t self.name = self.url\n end\n\tend",
"def package_plugin(name)\n `cd #{@repository_path}; rake feather:package path=#{name} target=#{@build_path}`\n end",
"def move_package(name, new_dir)\n Autoproj.workspace.manifest.move_package(name, new_dir)\nend",
"def hadoop_package(name)\n return name unless hdp22?\n return name if node['platform_family'] == 'debian'\n fw = name.split('-').first\n pv = hdp_version.tr('.', '_').tr('-', '_')\n nn = \"#{fw}_#{pv}\"\n name.gsub(fw, nn)\n end",
"def install\n yaourt('--noconfirm', '-Sy', @resource[:name])\n end",
"def tailor_package_to_platform\n @package.app('Dropbox')\n @package.volumes_dir('Dropbox Installer')\n @package.source(URI.encode(\"file://#{download_dest}\"))\n end",
"def set_package_filename\n if @package_name.nil?\n @package_name = get_package_name\n end\n end",
"def install(name:, dir: nil)\r\n end",
"def update_name(new_name)\n ensure_uri\n response = @client.rest_put(@data['uri'], 'body' => { 'name' => new_name, 'type' => 'ArtifactsBundle' })\n @client.response_handler(response)\n @data['name'] = new_name\n true\n end",
"def install_custom!\n package package_name do\n source new_resource.source.to_s\n checksum new_resource.checksum unless new_resource.checksum.nil?\n end\n end",
"def install_fake_pkg(name)\n require_relative 'ci-tooling/lib/dpkg'\n Dir.mktmpdir do |tmpdir|\n Dir.chdir(tmpdir) do\n FileUtils.mkpath(\"#{name}/DEBIAN\")\n File.write(\"#{name}/DEBIAN/control\", <<-EOF.gsub(/^\\s+/, ''))\n Package: #{name}\n Version: 999:999\n Architecture: all\n Maintainer: Harald Sitter <[email protected]>\n Description: fake override package for kubuntu ci install checks\n EOF\n system(\"dpkg-deb -b #{name} #{name}.deb\")\n DPKG.dpkg(['-i', \"#{name}.deb\"])\n end\n end\nend",
"def move_package(package_name, new_dir)\n moved_packages[package_name] = File.join(new_dir, File.basename(package_name))\n end",
"def change_app_name!\n end",
"def install(packagename, force=false)\n\t\t\t\traise(InstallError, \"Automated package installation is not implemented on OpenBSD\")\n\t\t\tend",
"def install_package(name, version)\n package_provider.install_package\n end",
"def upname\n \tself.source_name = self.source_name.upcase\n end",
"def hadoop_package(name)\n return name unless hdp22? || iop?\n return name if node['platform_family'] == 'debian'\n fw =\n if name == 'spark-core'\n name\n else\n name.split('-').first\n end\n pv =\n if hdp22?\n hdp_version.tr('.', '_').tr('-', '_')\n else\n node['hadoop']['distribution_version'].tr('.', '_')\n end\n nn = \"#{fw}_#{pv}\"\n name.gsub(fw, nn)\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 after_packaging\n suffixes = chunk_suffixes\n first_suffix = \"a\" * suffix_length\n if suffixes == [first_suffix]\n FileUtils.mv(\n File.join(Config.tmp_path, \"#{package.basename}-#{first_suffix}\"),\n File.join(Config.tmp_path, package.basename)\n )\n else\n package.chunk_suffixes = suffixes\n end\n end",
"def install\r\n super\r\n automated_install {\r\n @local_gems.flush_gem_cache\r\n gem_name = @override_gem_name.nil? ? installed_as_name_for( self.gem_short_name ) : @override_gem_name\r\n installed_gem = @local_gems.find( gem_name )\r\n fails_to_load gem_name if installed_gem.nil?\r\n installed_gem.activate\r\n }\r\n end",
"def file_name\n \"#{full_name}.gem\"\n end",
"def full_name\n \"#{@package}.#{parameterized_name}\"\n end",
"def prepare_source_dir(orig_pkginfo, options = Hash.new)\n pkginfo = orig_pkginfo.dup\n\n options, unknown_options = Kernel.filter_options options,\n :existing_source_dir => nil,\n :packaging_dir => File.join(@build_dir, debian_name(pkginfo))\n\n pkg_dir = options[:packaging_dir]\n if not File.directory?(pkg_dir)\n FileUtils.mkdir_p pkg_dir\n end\n\n # Only when there is no importer or when the VCS supports distribution (here git)\n # then we allow to use the local version\n support_local_import = false\n if !pkginfo.importer_type || pkginfo.importer_type == :git\n Packager.info \"Import from local repository is supported for #{pkginfo.name}\"\n support_local_import = true\n else\n Packager.info \"Import from local repository is not supported for #{pkginfo.name}\"\n end\n\n Packager.debug \"Preparing source dir #{pkginfo.name}\"\n # If we have given an existing source directory we should use it, \n # but only if it is a git repository\n pkg_target_importdir = File.join(pkg_dir, plain_dir_name(pkginfo))\n if support_local_import && existing_source_dir = options[:existing_source_dir]\n import_from_local_src_dir(pkginfo, existing_source_dir, pkg_target_importdir)\n # update to the new srcdir\n pkginfo.srcdir = pkg_target_importdir\n else\n pkginfo.import(pkg_target_importdir)\n end\n # remove these even on fresh imports. some repositories\n # have prepopulated build directories and similar\n remove_excluded_dirs(pkg_target_importdir)\n remove_excluded_files(pkg_target_importdir)\n\n pkginfo\n end",
"def install_custom!\n remote_file local_path do\n source new_resource.source.to_s\n checksum new_resource.checksum unless new_resource.checksum.nil?\n end\n dpkg_package local_path\n end",
"def remove_version_info name\n add \"find . -maxdepth 1 -name '#{name}*' -a -type d | xargs -I xxx mv xxx #{name}\", check_file(name)\n end",
"def staging_dir\n File.expand_path(\"#{Config.package_tmp}/#{underscore_name}\")\n end",
"def install\n end",
"def install\n end",
"def install\n end",
"def upgrade_package host, package_name\n host.upgrade_package package_name\n end",
"def upgrade_direct!\n package \"Chef Development Kit v#{package_metadata[:version]}\" do\n source package_metadata[:url]\n checksum package_metadata[:sha256]\n end\n end",
"def install\n \n end",
"def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end",
"def vendored_package_name(package)\n\tFile.join($package_name, 'vendor/src', package)\nend",
"def install_package host, package_name\n host.install_package package_name\n end",
"def install_package(target_package_path); raise NotImplementedError; end",
"def post_install; end",
"def install_root\n self.class.install_root.join(name)\n end",
"def package_name\n name = package_drop_last(slug_parts)\n name.empty? ? '_root_' : name\n end",
"def install_package host, package_name, package_version = nil\n host.install_package package_name, '', package_version\n end",
"def install_custom!\n do_dmg_package_resource!\n end",
"def set_name\n @appname = \"Bike London\"\n end",
"def install_gem; end",
"def renamenx(old_name, new_name); end",
"def renamenx(old_name, new_name); end",
"def fixLoadPath(oldpath,libpath,target)\n debug \"#{$install_name_tool} -change #{oldpath} #{$executableId}#{libpath} #{target}\"\n `#{$install_name_tool} -change #{oldpath} #{$executableId}#{libpath} #{target}`\nend",
"def gem!(name)\n self.root = Padrino.gem(name, self)\n end",
"def post_install\n end",
"def fmri_package_name\n version = project.build_version.split(/[^\\d]/)[0..2].join(\".\")\n platform = Ohai[\"platform_version\"]\n \"#{safe_base_package_name}@#{version},#{platform}-#{project.build_iteration}\"\n end",
"def debian_meta_name(name, with_rock_release_prefix = true)\n if with_rock_release_prefix\n rock_release_prefix + \"meta-\" + Deb.canonize(name)\n else\n pkg_prefix_base + \"meta-\" + Deb.canonize(name)\n end\n end",
"def package_name\n raise NotImplementedError\n end",
"def prepare_for_installation; end",
"def package_name\n # TODO: verify renamed packages\n resource['title']\n end",
"def install\n # nothing to do\n end",
"def reinstall\n end",
"def fixed_name(file, bad_name)\n if (file.dylib? || file.mach_o_bundle?) && (file.parent + bad_name).exist?\n \"@loader_path/#{bad_name}\"\n elsif file.mach_o_executable? && (lib + bad_name).exist?\n \"#{lib}/#{bad_name}\"\n elsif (abs_name = find_dylib(Pathname.new(bad_name).basename)) && abs_name.exist?\n abs_name.to_s\n else\n opoo \"Could not fix #{bad_name} in #{file}\"\n bad_name\n end\n end",
"def fix_name(name)\n if name[0,1] == '^'\n return \"#{ARTML.prefix}#{name[1..-1].strip}\"\n else\n return name.strip\n end\n end",
"def remove_obsolete_installed_orogen_package(name)\n post_install do\n path = File.join(prefix, 'lib', 'pkgconfig')\n Dir.glob(File.join(path, \"#{name}-*.pc\")) do |pcfile|\n Autoproj.message \" removing obsolete file #{pcfile}\", :bold\n FileUtils.rm_f pcfile\n end\n pcfile = File.join(path, \"orogen-project-#{name}.pc\")\n if File.exists?(pcfile)\n Autoproj.message \" removing obsolete file #{pcfile}\", :bold\n FileUtils.rm_f pcfile\n end\n end\n end",
"def fix_filename\n unless self.filename.blank?\n self.filename.sub!(/^.*\\/([^\\/]*)$/, '\\1')\n self.filename += '.torrent' unless self.filename =~ /\\.torrent$/\n end\n end",
"def package_set_name(path, branch='master')\n file = dir_git(path,branch,/source\\.yml/)\n raw = raw_file_from_git(path,file[0])\n yaml = YAML.load(raw)\n yaml[\"name\"]\n end",
"def install\n nil\n end",
"def package_name\n @version ? \"#{@name}-#{@version}\" : @name\n end",
"def pre_install; end",
"def package_name\n [self.config.organization, self.config.project_name].compact.collect(&:underscore).join('-')\n end",
"def alias(new_name, old_name)\n registry.alias(new_name, old_name) or\n raise NameError.new(\"Undefined artifact name: #{old_name}\")\n end",
"def copy_name_to_lowercase_name\n self.lowercase_name = File.basename(self.github_url.to_s).presence || name.to_s.downcase.parameterize\n end",
"def original_name # :nodoc:\n if platform == Gem::Platform::RUBY or platform.nil?\n \"#{@name}-#{@version}\"\n else\n \"#{@name}-#{@version}-#{@original_platform}\"\n end\n end",
"def update!(**args)\n @localized_app_name = args[:localized_app_name] if args.key?(:localized_app_name)\n @package_name = args[:package_name] if args.key?(:package_name)\n end",
"def update!(**args)\n @localized_app_name = args[:localized_app_name] if args.key?(:localized_app_name)\n @package_name = args[:package_name] if args.key?(:package_name)\n end",
"def change_import (libpath, import, newimport)\n log \"\\tchange_import called with libpath: #{libpath}, import: #{import}, newimport: #{newimport}\"\n return if newimport == import\n log \"\\tChange import #{import} to #{newimport}\"\n unless system(\"install_name_tool\", \"-change\", import, newimport, libpath)\n fail \"install_name_tool failed\"\n end\nend",
"def install\n end",
"def package_name(project)\n \"#{project.name}-#{project.version}-#{project.release}.#{@architecture}.pkg.gz\"\n end",
"def debian_name(pkg)\n if pkg.kind_of?(Autoproj::RubyPackage)\n debian_ruby_name(pkg.name)\n else\n \"rock-\" + canonize(pkg.name)\n end\n end",
"def public_filename\n \"/packages/#{environment_id}/#{unit_id}/#{installer_item_location}\"\n end",
"def package_from_name\n case name.downcase\n when 'splunk' then package :splunk\n when 'universal_forwarder' then package :universal_forwarder\n else raise 'Package must be specified (:splunk or :universal_forwarder)'\n end\n end",
"def install\n bin.install \"#{PACKAGE_NAME}\"\n end",
"def package_name\n if supports_ports?\n if makefile_variable_value(\"PKGNAME\", port_path) =~ /^(.+)-[^-]+$/\n $1\n else\n raise Chef::Exceptions::Package, \"Unexpected form for PKGNAME variable in #{port_path}/Makefile\"\n end\n else\n new_resource.package_name\n end\n end",
"def install\n system \"make\", \"stat\"\n bin.install \"namei\"\n end",
"def install_dir # :nodoc:\n File.join Gem.dir, 'bundler', 'gems', \"#{@name}-#{dir_shortref}\"\n end",
"def before_package_create(package)\n end",
"def before_package_create(package)\n end",
"def setup_new_package(package_name, parent_ids=[])\n package_id, definition = add_package(package_name, parent_ids)\n\n # update current package id\n set(current_package_id: package_id, current_definition: definition)\n end",
"def package_dir\r\n \"${0%/#{target_name}}\"\r\n end",
"def changeName\r\n\t\tcheckSpace\r\n\tend",
"def post_install_actions\n Dir.chdir(@project_name) do\n SemVer.new.save(SemVer::FILE_NAME)\n end\n end",
"def ftp_name=(new_name)\n return if new_name == @resource.should(:share_name)\n @share_edit_args += [ \"-F\", new_name ]\n end",
"def post_fetch local_filename\n if local_filename.end_with?('.tsv')\n logger.info \"Deploying contents of config file: #{local_filename}\"\n process_config_file local_filename\n\n elsif local_filename.end_with?('.gz')\n logger.info \"Deploying R package: #{local_filename}\"\n execute \"install custom R package #{local_filename}\" do\n command \"R CMD INSTALL #{local_filename}\"\n end\n\n elsif local_filename.end_with?('.deb')\n logger.info \"Deploying Debian package: #{local_filename}\"\n package_base = Regexp.new(\".*/([^/]+)_([^_/]+)\\.deb$\").match(local_filename)[1]\n dpkg_package \"#{package_base}\" do\n action :install\n source local_filename\n end\n end\n end",
"def dmg_package_app\n case new_resource.source\n when :direct\n ::File.basename(package_metadata[:url], '.dmg')\n else\n ::File.basename(new_resource.source.to_s, '.dmg')\n end\n end",
"def install\n FileUtils.mv self.class.extracted_file.to_s, self.class.force_installed_executable.to_s\n end",
"def upgrade_package(name, cmdline_args = '')\n raise \"Package #{name} cannot be upgraded on #{self}\"\n end",
"def upgrade_package(name, cmdline_args = '')\n raise \"Package #{name} cannot be upgraded on #{self}\"\n end",
"def package_override(project, var)\n fail \"I don't know how to set package overrides for #{name}, teach me?\"\n end"
] | [
"0.65917933",
"0.63511",
"0.6306356",
"0.6238577",
"0.61479294",
"0.61351377",
"0.61154866",
"0.61124915",
"0.60569876",
"0.6034344",
"0.59926045",
"0.5987415",
"0.5973787",
"0.5944547",
"0.5918022",
"0.5917931",
"0.59167546",
"0.58606595",
"0.58522594",
"0.5835223",
"0.5791828",
"0.57651776",
"0.5757301",
"0.5715355",
"0.5694892",
"0.56536025",
"0.56441605",
"0.56353426",
"0.5624363",
"0.56118196",
"0.5594208",
"0.557106",
"0.556266",
"0.5556673",
"0.55515325",
"0.5535639",
"0.5535639",
"0.5520916",
"0.5518183",
"0.5514935",
"0.5496635",
"0.5494679",
"0.5491617",
"0.54743236",
"0.5461469",
"0.5454978",
"0.54362845",
"0.54349715",
"0.543173",
"0.54245913",
"0.5409217",
"0.5400427",
"0.53990465",
"0.53990465",
"0.5398778",
"0.5383389",
"0.53813094",
"0.5378692",
"0.5366521",
"0.53584206",
"0.5352506",
"0.5351711",
"0.5347955",
"0.5347201",
"0.5328385",
"0.53280324",
"0.5326984",
"0.53266394",
"0.53236353",
"0.53231436",
"0.5322804",
"0.5321665",
"0.5311794",
"0.5311498",
"0.53014857",
"0.52833575",
"0.5281846",
"0.5281846",
"0.5280962",
"0.52719486",
"0.5269172",
"0.52670926",
"0.52662265",
"0.5260617",
"0.5258416",
"0.52562535",
"0.52433705",
"0.52351743",
"0.52276164",
"0.52276164",
"0.52257437",
"0.5225598",
"0.5224931",
"0.5205977",
"0.52053255",
"0.5202013",
"0.5198302",
"0.5196171",
"0.519102",
"0.519102",
"0.51888806"
] | 0.0 | -1 |
Always true. See Tasknull? | def null?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explain_false(task); end",
"def explain_true(task); end",
"def force_task?(task)\n !!metadata[\"run_#{task}\"]\n end",
"def task_defined?(task_name) \n lookup(task_name) != nil\n end",
"def empty?; tasks.empty? end",
"def compatible_state?(task)\n\t finished? || !(running? ^ task.running?)\n\tend",
"def ignore_complete?(task)\n !get_result(task).nil?\n end",
"def compatible_state?(task)\n finished? || !(running? ^ task.running?)\n end",
"def has_task?(task_name)\n !self[task_name.to_s].nil?\n end",
"def never\n to_unbound_task_predicate.never\n end",
"def do_not_thread\n true\n end",
"def ignore_force?(task)\n !(metadata[\"run_#{task}\"].nil? || metadata[\"run_#{task}\"])\n end",
"def true(_argvs)\n return nil\n end",
"def do_not_thread\n\n true\n end",
"def task_present?(task_name)\n tasks.key? prepare_key(task_name)\n end",
"def has_pre_tasks?\n !@pre_tasks.empty?\n end",
"def taskNull \n \"taskNull\" \n end",
"def do_not_thread\n true\n end",
"def do_not_thread\n true\n end",
"def thread?\n false\n end",
"def semact?; false; end",
"def is_ready\n if self.tasks.empty? and not self.is_done # no tasks assigned for this\n false\n elsif (self.tasks.find_by is_done: false).nil? # can't find any false => all tasks are done\n self.update_attribute(:is_done, true)\n true\n else\n false\n end\n end",
"def always_true\n true\n end",
"def has_tasks?\n return true unless session_tasks.empty?\n false\n end",
"def task_execution_phase?\n @task_execution_phase\n end",
"def null?; false end",
"def do_scheduling?\n\t\t!self.scheduled_at.blank?\n\tend",
"def atomic?\n false\n end",
"def isJunkTask(task)\n return false\n end",
"def null?\n false\n end",
"def assigned?\n self.task_state == TaskState.assigned\n end",
"def ignore_task?(task)\n return true if metadata[\"run_#{task}\"] == false\n\n !clade? && @@INCLADE_TASKS.include?(task) && metadata[\"run_#{task}\"] != true\n end",
"def null?\n true\n end",
"def task_complete?(str, create_if_nil = false)\n task(str, create_if_nil).nil? ? false : task(str, create_if_nil).complete?\n end",
"def tasks_remain?\n\t\ttasks.any?{ |t| t.completed.nil? }\n\tend",
"def completed? # Is task completed? method\n completed_status # True or false\n end",
"def ignore_task?(task)\n why_ignore(task) != :execute\n end",
"def running?\n super\n end",
"def running?\n super\n end",
"def rake_task?\n defined?(::Rake) && !Rake.application.top_level_tasks.empty?\n end",
"def running?\n @mutex.synchronize { @task_running }\n end",
"def null?\n false\n end",
"def null?\n false\n end",
"def future?\n !current? && !complete?\n end",
"def with_tasks?\n options[:with_tasks]\n end",
"def thread_safe?\n false\n end",
"def ===(task)\n\t return unless task.kind_of?(Roby::Task)\n return unless task.arguments.slice(*arguments.keys) == arguments\n return super\n\tend",
"def nil?\n return true\n end",
"def ignore_empty?(_task)\n first_preprocessing.nil?\n end",
"def running?\n\t\t!cancelled?\n\tend",
"def null?\n false\n end",
"def asynchronous?() false end",
"def are_there_self_override_tasks?\n return (self[:all][:self] || self[:command_only][:self] || self[:identifier_only][:self])\n end",
"def complete?\r\n # Both worker and instuction should not be nil and instruction should be complete\r\n !self.worker.blank? && !self.instruction.blank? && self.instruction.try(:complete?)\r\n end",
"def has_delayed_default?\n has_default? && TaskArguments.delayed_argument?(default)\n end",
"def pending?; end",
"def no_pending_tasks?\n if not @record.experiment.supervised\n simulation_run = record.experiment.simulation_runs.where(sm_uuid: record.sm_uuid, to_sent: false, is_done: false).first\n simulation_run.nil? and not @record.experiment.has_simulations_to_run?\n else\n # we assume that in supervised experiment, there are always tasks pending\n false\n end\n end",
"def async?\n false\n end",
"def running?; end",
"def conditionally_true\n\t\t!!self\n\tend",
"def has_run?\n @passed != nil\n end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def in_use?\n !batch.nil?\n end",
"def has_subtasks?\n\t\ttasks.size > 0\n\tend",
"def settled?\n return !self.pending?\n end",
"def ===(task)\n\t !(@op === task)\n\tend",
"def completed?\n !self.finished_at.nil?\n end",
"def not_completed?\n tasks.any? { |task| task.done != 100 }\n end",
"def ready_to_deliver? task\n true\n end",
"def tasks?\n tasks.summary.items?\n end",
"def busy?\n @tasks.each_value { |task| return true if task.busy? }\n false\n end",
"def complete?\n !pending?\n end",
"def complete?\n if threaded?\n !running?\n else\n true\n end\n end",
"def active?\n !done?\n end",
"def in_progress?\n result.nil?\n end",
"def run_once?\n !!@run\n end",
"def null?\n false\n end",
"def null?\n false\n end",
"def pending?\n self.pending\n end",
"def void_true(*args)\n return true\n end",
"def pending?\n @future_result.pending?\n end",
"def asynchronous?\n return false if (pending_value && pending_value[:value].blank?)\n true\n end",
"def busy?\n !@work_queue.empty? || super\n end",
"def done?\n self.done\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n validate_task_has_no_approved\n end",
"def nil?\n false\n end",
"def nil?\n false\n end",
"def running?; started? && !finished? end",
"def pending?\n pending\n end",
"def running?\n started_at.present? && finished_at.nil?\n end",
"def ready_task\n find do |task|\n task.ready?\n end\n end",
"def busy?; end",
"def has_schedule?\n self.schedule != nil\n end",
"def verify_org_task_unique\n true\n end",
"def task_running?(response)\n return true if response.nil?\n return !(response.data['status'].eql?(\"succeeded\") || response.data['status'].eql?(\"failed\"))\n end",
"def immediate?\n !delayed?\n end",
"def pending?\n pending\n end",
"def completed?\n !@time_started.nil? && !@time_completed.nil?\n end"
] | [
"0.73489714",
"0.72424287",
"0.7216759",
"0.70551294",
"0.7000186",
"0.6902323",
"0.6864136",
"0.6852977",
"0.6821365",
"0.67038155",
"0.67016536",
"0.67004806",
"0.66960746",
"0.6691695",
"0.666782",
"0.66551936",
"0.6650127",
"0.66335934",
"0.66335934",
"0.66274774",
"0.65998286",
"0.6548452",
"0.65140194",
"0.6477591",
"0.64623016",
"0.6450997",
"0.6445769",
"0.64452076",
"0.64411736",
"0.64394754",
"0.6433361",
"0.64303493",
"0.6428057",
"0.6423244",
"0.6404439",
"0.64034456",
"0.6399611",
"0.6392366",
"0.6392366",
"0.63893276",
"0.6385741",
"0.63847864",
"0.63847864",
"0.6381049",
"0.63739866",
"0.63734984",
"0.63592505",
"0.6347537",
"0.63448465",
"0.6335289",
"0.63347715",
"0.63335496",
"0.6326755",
"0.6309619",
"0.6303391",
"0.63002664",
"0.62966746",
"0.627982",
"0.6277639",
"0.62763476",
"0.6274817",
"0.6273077",
"0.6273077",
"0.6273077",
"0.6256361",
"0.6251489",
"0.6245208",
"0.6235823",
"0.621492",
"0.6212599",
"0.6200527",
"0.6199288",
"0.619753",
"0.61954397",
"0.61937076",
"0.61936307",
"0.6193248",
"0.61854315",
"0.6184013",
"0.6184013",
"0.6178739",
"0.616141",
"0.615944",
"0.6156881",
"0.6155039",
"0.61489034",
"0.61483645",
"0.6146353",
"0.6146353",
"0.6144662",
"0.6144652",
"0.61421883",
"0.6142032",
"0.6134315",
"0.61326736",
"0.61323977",
"0.61320263",
"0.6129724",
"0.61217815",
"0.6116328"
] | 0.6309867 | 53 |
Set a backup object based on what we have in params. | def set_backup
if params[:id] && !params[:id].blank?
@backup = Backup.new(nil, current_user.id)
@backup.id_from_epoch(params[:id])
else
@backup = Backup.new(nil, current_user.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_backup\n @backup = Backup.find(params[:id])\n end",
"def backup\n BACKUP_MODELS.each do |obj|\n puts \"Preparing to back up #{obj}\"\n self.send(obj.to_sym)\n end \n end",
"def backup_params\n params.require(:backup).permit(:path, :user_id, :host_id)\n end",
"def set_backup_medium\n @backup_medium = BackupMedium.find(params[:id])\n end",
"def cmd_backup argv\n setup argv\n command = @hash['command']\n name = @hash['name']\n response = @api.backup(command, name)\n msg response\n return response\n end",
"def set_backup\n current_user.backup = Farmer.find_by_id(params[:id]).email\n current_user.save\n redirect_to current_user\n end",
"def set_bakery\n @bakery = Bakery.find(params[:id])\n end",
"def backupwallet(destination)\n request(:backupwallet, destination)\n end",
"def set _obj, _args\n \"_obj set _args;\" \n end",
"def create_and_copy_backup(backup_options = nil,backup_name = nil)\n\n end",
"def create\n @backup = Backup.new(backup_params)\n @backup = @client.backups.build(backup_params)\n \n respond_to do |format|\n if @backup.save\n #format.html { redirect_to [@client, @backup], notice: 'Backup was successfully created.' }\n format.html { redirect_to [@client, @backup], notice: 'Backup was successfully created.' }\n format.json { render :show, status: :created, location: @backup }\n else\n format.html { render :new }\n format.json { render json: @backup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_business\n @business = Business.find(params[:id])\n @current_obj = @business\n end",
"def backupwallet(destination)\n coind.backupwallet destination\n end",
"def backup_wallet\n client.make_request('/backup-wallet', 'post', params: {})\n end",
"def create\n @backup = current_user.backups.build(backup_params)\n @backup.user = current_user\n\n respond_to do |format|\n if @backup.save\n format.html { redirect_to backups_path, notice: 'Backup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @backup }\n else\n format.html { render action: 'new' }\n format.json { render json: @backup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def backup\n ModelHelper::backup self\n end",
"def backupwallet(destination)\n @api.request 'backupwallet', destination\n end",
"def make_backup\n @backup = editor.create_snapshot\n end",
"def backup account\n return unless valid_argument?(account, \"backup\")\n @heroku_credentials.backup account\n @ssh_identity.backup account\n end",
"def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end",
"def backup backup_id\n ensure_service!\n grpc = service.get_backup instance_id, backup_id\n Backup.from_grpc grpc, service\n rescue Google::Cloud::NotFoundError\n nil\n end",
"def create_backup_with_data\n @test_backup = @instance.backup @backup_id\n\n return @test_backup if @test_backup\n\n database = create_singers_albums_database\n\n capture do\n write_using_dml project_id: @project_id,\n instance_id: @instance.instance_id,\n database_id: database.database_id\n end\n\n client = @spanner.client @instance.instance_id, database.database_id\n version_time = client.execute(\"SELECT CURRENT_TIMESTAMP() as timestamp\").rows.first[:timestamp]\n\n capture do\n create_backup project_id: @project_id,\n instance_id: @instance.instance_id,\n database_id: database.database_id,\n backup_id: @backup_id,\n version_time: version_time\n\n @test_backup = @instance.backup @backup_id\n end\n\n @test_backup\n end",
"def backup\n #EternosBackup::BackupJobPublisher.add_source(self)\n end",
"def setDestination _obj, _args\n \"_obj setDestination _args;\" \n end",
"def __setobj__(obj); end",
"def create_backup(site_id, datum = nil)\n current_path = \"/api/v1/sites/#{site_id}/backup\"\n @conn.post(current_path, datum.to_json)\n end",
"def backup \n raise NotImplementedError.new\n end",
"def bms_backup(opts = {})\n data, _status_code, _headers = bms_backup_with_http_info(opts)\n data\n end",
"def set_instance\n instance_variable_set \"@#{object_name}\", @object\n end",
"def initBackup \n today = Time.now.wday\n #Do the backup either as planned or in testmode\n if ( \n (@weekdays.include?(today) && TESTMODE === false) || \n (TESTMODE === true && TESTSITE.nil?) || \n (TESTMODE === true && TESTSITE == @name)\n )\n $LOG.info(\"#{@name} : Backup initiated\") \n self.createBackup unless @backupUrl.nil?\n self.ftpDownload\n self.cleanUp\n $LOG.info(\"#{@name} : Backup completed\") \n end\n end",
"def backup\n FileUtils.cp options[:file], backup_file if File.file? options[:file]\n end",
"def copy_backup project_id:, instance_id:, cluster_id:, backup_id:, source_backup:, expire_time:\n tables.copy_backup parent: \"projects/#{project_id}/instances/#{instance_id}/clusters/#{cluster_id}\",\n backup_id: backup_id,\n source_backup: source_backup,\n expire_time: expire_time\n end",
"def backup_target\n data[:backup_target]\n end",
"def backup?\n @backup.nil? ? false : @backup\n end",
"def backup \n begin\n check_if_db_exists\n is_allowed = @conn.exec(\"select datallowconn from pg_catalog.pg_database where datname='#{@options[:database]}'\")[0]['datallowconn']\n if is_allowed == 'f'\n # unquiece temporarily\n set_dataallowcon_to true\n end\n\n # Check to see if the directory for backups exists and if not, create it with parents\n unless File.exist?(@options[:bkdir])\n FileUtils.mkdir_p @options[:bkdir]\n end\n filename = \"postgresbk_#{@options[:database]}_#{Time.new.strftime(\"%m%d%y%H%M%S\")}.dump\"\n\n # The below system call assumes you have passwordless access as the user passed into the executable tool\n # either due to ~/.pgpass or pg_hba.conf has your user as a 'trust' auth method\n `pg_dump -U #{@options[:user]} #{@options[:database]} -F c -f #{@options[:bkdir]}/#{filename}`\n\n rescue Exception => e\n raise e\n ensure\n if is_allowed == 'f'\n # re quiesce \n set_dataallowcon_to false\n end\n end\n end",
"def backup_location\n @location\n end",
"def backup!(file=nil)\n file = file || FILENAME\n dir = root + BACKUP_DIRECTORY\n FileUtils.mkdir(dir.dirname) unless dir.dirname.directory?\n FileUtils.mkdir(dir) unless dir.directory?\n save!(dir + FILENAME)\n end",
"def camSetBank _obj, _args\n \"_obj camSetBank _args;\" \n end",
"def set_backup_policy instance_id, cluster_id, backup_id, policy\n tables.set_iam_policy resource: backup_path(instance_id, cluster_id, backup_id), policy: policy\n end",
"def set_battery_bank\n @battery_bank = BatteryBank.find(params[:id])\n end",
"def backup\n @current_teacher = current_teacher\n @school = School.find(current_teacher.school_id)\n @school_name = School.find(current_teacher.school_id).full_name\n end",
"def set_zbozi\n @zbozi = Zbozi.find(params[:id])\n end",
"def create_backup instance_id:, cluster_id:, backup_id:, source_table_id:, expire_time:\n backup = Google::Cloud::Bigtable::Admin::V2::Backup.new \\\n source_table: table_path(instance_id, source_table_id), expire_time: expire_time\n tables.create_backup parent: cluster_path(instance_id, cluster_id), backup_id: backup_id, backup: backup\n end",
"def backupItem\n\t\tif self.image_id\n\t\t\t@public_id = self.image_id.split('/').last\n\t\t\t@public_id = @public_id.split('#').first\n\t\t\t@public_id = @public_id.split('.').first\n\t\tend\n\tend",
"def set_copy\n @copy = Copy.find(params[:id])\n end",
"def set_copy\n @copy = Copy.find(params[:id])\n end",
"def create_backup(d_b_instance_id, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateBackup'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backup_method\n\t\t\targs[:query]['BackupMethod'] = optional[:backup_method]\n\t\tend\n\t\tif optional.key? :backup_type\n\t\t\targs[:query]['BackupType'] = optional[:backup_type]\n\t\tend\n\t\tif optional.key? :d_b_name\n\t\t\targs[:query]['DBName'] = optional[:d_b_name]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def assignItem _obj, _args\n \"_obj assignItem _args;\" \n end",
"def set_object(object)\n raise EasyCrumbs::InvalidObject unless object.is_a?(ActionController::Base) || object.is_a?(ActiveRecord::Base)\n object\n end",
"def transfer\n\t\tattributes = super\n\t\tself.last_backup_date = Date.today\n\t\tset_next_backup_date\n\t\tself.save\n\t\tlog_transfer(attributes)\n\tend",
"def stage(obj)\n Maglev::PERSISTENT_ROOT[self][obj.__id__] = obj\n end",
"def update!(**args)\n @backup_plans = args[:backup_plans] if args.key?(:backup_plans)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end",
"def i_cloud_block_backup=(value)\n @i_cloud_block_backup = value\n end",
"def var_backup_c()\n backup = extract_params()\n backup[:dureeCours] = @dureeCours\n backup[:dureeTP] = @dureeTP\n backup[:quadri] = @quadri\n backup[:professeur] = @professeur\n return backup\n end",
"def set_params params\n raise \"No Params\" if params.nil?\n params.each do |key, value|\n raise \"key nil\" if key.nil?\n raise \"value nil\" if value.nil?\n self.preferences[key.to_sym] = value if valid_key?(key)\n end\n raise \"save failed: #{errors}\" unless self.save\n assure_created_zip\n end",
"def _middle_copy(object)\n o = object.clone\n object.instance_variables.each do |k|\n v = object.instance_variable_get(k)\n o.instance_variable_set(k, v ? v.clone : v)\n end\n o\n end",
"def before_backup\n end",
"def set_convert_object\n @input_object = BmetWorkOrder.new\n @input_object.wr_origin = nil\n @input_object.pm_origin = @bmet_preventative_maintenance\n @input_object.description = @bmet_preventative_maintenance.description\n @input_object.bmet_item = @bmet_preventative_maintenance.bmet_item\n end",
"def backup?\n @backup || false\n end",
"def set_tasks\n @b_task = backup.b_task.find(params[:id])\n end",
"def lbSetValue _obj, _args\n \"_obj lbSetValue _args;\" \n end",
"def backup(file = nil)\n Chef::Util::Backup.new(new_resource, file).backup!\n end",
"def backup(file = nil)\n Chef::Util::Backup.new(new_resource, file).backup!\n end",
"def set(obj)\n @mutex.synchronize { @obj = obj }\n end",
"def restore\n db = resolve_db(:allow_default => true)\n to_name = db[:name]\n to_url = db[:url]\n\n backup_id = args.shift\n\n if backup_id =~ /^http(s?):\\/\\//\n from_url = backup_id\n from_name = \"EXTERNAL_BACKUP\"\n from_uri = URI.parse backup_id\n backup_id = from_uri.path.empty? ? from_uri : File.basename(from_uri.path)\n else\n if backup_id\n backup = pgbackup_client.get_backup(backup_id)\n abort(\"Backup #{backup_id} already deleted.\") if backup[\"destroyed_at\"]\n else\n backup = pgbackup_client.get_latest_backup\n to_uri = URI.parse backup[\"to_url\"]\n backup_id = File.basename(to_uri.path, '.*')\n backup_id = \"#{backup_id} (most recent)\"\n end\n\n from_url = backup[\"to_url\"]\n from_name = \"BACKUP\"\n end\n\n message = \"#{db[:pretty_name]} <---restore--- \"\n padding = \" \" * message.length\n display \"\\n#{message}#{backup_id}\"\n if backup\n display padding + \"#{backup['from_name']}\"\n display padding + \"#{backup['created_at']}\"\n display padding + \"#{backup['size']}\"\n end\n\n if confirm_command\n restore = transfer!(from_url, from_name, to_url, to_name)\n restore = poll_transfer!(restore)\n\n if restore[\"error_at\"]\n message = \" ! An error occurred and your restore did not finish.\"\n message += \"\\n ! The backup url is invalid. Use `pgbackups:url` to generate a new temporary URL.\" if restore['log'] =~ /Invalid dump format: .*: XML document text/\n abort(message)\n end\n end\n end",
"def backup!(file=nil)\n file = file || FILENAME\n dir = root + BACKUP_DIRECTORY\n FileUtils.mkdir(dir.dirname) unless dir.dirname.directory?\n FileUtils.mkdir(dir) unless dir.directory?\n save!(dir + DOTRUBY_FILENAME)\n end",
"def update!(**args)\n @backup_plan = args[:backup_plan] if args.key?(:backup_plan)\n @cluster = args[:cluster] if args.key?(:cluster)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @etag = args[:etag] if args.key?(:etag)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @restore_config = args[:restore_config] if args.key?(:restore_config)\n @state = args[:state] if args.key?(:state)\n @state_reason = args[:state_reason] if args.key?(:state_reason)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def store\n case procedure.storage_name.to_sym\n when :s3 then Backup::Storage::S3.new(self)\n when :scp then Backup::Storage::SCP.new(self)\n when :ftp then Backup::Storage::FTP.new(self)\n when :sftp then Backup::Storage::SFTP.new(self)\n end\n end",
"def backup_configuration\n settings[\"backup_configuration\"]\n end",
"def setCurrentWaypoint _obj, _args\n \"_obj setCurrentWaypoint _args;\" \n end",
"def update!(**args)\n @backups = args[:backups] if args.key?(:backups)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end",
"def set_object\n set_model_instance(MODEL_CLASS.find(params[:id]))\n end",
"def backup_file\n \"#{options[:file]}.bak\"\n end",
"def system_backup\n\n\n end",
"def backup\n\t\tunless (@options && @options[:path] && @options[:dataset])\n\t\t\traise OptionParser::InvalidArgument, \"Missing arguments for 'backup'.\"\n\t\tend\n\t\t# Only attempt backup if the service is running\n\t\tstate = false\n\t\tself.launch(\"/usr/sbin/serveradmin status postgres\") do |output|\n\t\t\tstate = ((/RUNNING/ =~ output) != nil)\n\t\tend\n\t\torig_state = state\n\t\t$log.debug(\"@options = #{@options.inspect}\")\n\t\tarchive_dir = @options[:path]\n\t\tunless (archive_dir[0] == ?/)\n\t\t\traise OptionParser::InvalidArgument, \"Paths must be absolute.\"\n\t\tend\n\t\twhat = @options[:dataset]\n\t\tunless self.class::DATASETS.include?(what)\n\t\t\traise OptionParser::InvalidArgument, \"Unknown data set '#{@options[:dataset]}' specified.\"\n\t\tend\n\t\t# The passed :archive_dir and :what are ignored because the dump is put\n\t\t# on the live data volume\n\t\tarchive_dir = self.backupDir\n\t\tdump_file = \"#{archive_dir}/#{BACKUP_FILE}\"\n\t\tdump_file_uncompressed = \"#{archive_dir}/#{BACKUP_FILE_UNCOMPRESSED}\"\n\t\t# Create the backup directory as necessary.\n\t\tunless File.directory?(archive_dir)\n\t\t\tif File.exists?(archive_dir)\n\t\t\t\t$log.info \"Moving aside #{archive_dir}...\\n\"\n\t\t\t\tFileUtils.mv(archive_dir, archive_dir + \".applesaved\")\n\t\t\tend\n\t\t\t$log.info \"Creating backup directory: #{archive_dir}...\\n\"\n\t\t\tFileUtils.mkdir_p(archive_dir, :mode => 0700)\n\t\t\t# _postgres:_postgres has uid:gid of 216:216\n\t\t\tFile.chown(216, 216, archive_dir)\n\t\tend\n\t\t# Backup only once a day\n\t\tmod_time = File.exists?(dump_file) ? File.mtime(dump_file) : Time.at(0)\n\t\tif (Time.now - mod_time) >= (24 * 60 * 60)\n\t\t\t# Attempt to start the service if needed\n\t\t\tif (! state)\n\t\t\t\tself.launch(\"/usr/sbin/serveradmin start postgres\") do |output|\n\t\t\t\t\tstate = ((/RUNNING/ =~ output) != nil)\n\t\t\t\tend\n\t\t\tend\n\t\t\tif (! state)\n\t\t\t\t$log.info \"PostgreSQL is not running, skipping database backup\"\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\t$log.info \"Creating dump file \\'#{dump_file}\\'...\"\n\t\t\tsystem(\"/usr/bin/sudo -u _postgres /usr/bin/pg_dumpall > #{dump_file_uncompressed.shellescape}\")\n\t\t\tif ($?.exitstatus != 0)\n\t\t\t\t$log.error \"...Backup failed on pg_dumpall, Status=#{$?.exitstatus}\"\n\t\t\telse\n\t\t\t\tsystem(\"/usr/bin/gzip #{dump_file_uncompressed.shellescape}\")\t\t\t\t\n\t\t\t\tif ($?.exitstatus == 0)\n\t\t\t\t\tFile.chmod(0640, dump_file)\n\t\t\t\t\tFile.chown(216, 216, dump_file)\n\t\t\t\t\t$log.info \"...Backup succeeded.\"\n\t\t\t\telse\n\t\t\t\t\t$log.error \"...Backup failed on gzip! Status=#{$?.exitstatus}\"\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Restore original service state\n\t\t\tif (! orig_state)\n\t\t\t\t# What if a dependent service was launched while we were backing up? We\n\t\t\t\t# don't want to shut down postgres in that case.\n\t\t\t\twiki_state = false\n\t\t\t\tcalendar_state = false\n\t\t\t\taddressbook_state = false\n\t\t\t\tdevicemgr_state = false\n\t\t\t\tself.launch(\"/usr/sbin/serveradmin status wiki\") do |output|\n\t\t\t\t\twiki_state = ((/RUNNING/ =~ output) != nil)\n\t\t\t\tend\n\t\t\t\tself.launch(\"/usr/sbin/serveradmin status calendar\") do |output|\n\t\t\t\t\tcalendar_state = ((/RUNNING/ =~ output) != nil)\n\t\t\t\tend\n\t\t\t\tself.launch(\"/usr/sbin/serveradmin status addressbook\") do |output|\n\t\t\t\t\taddressbook_state = ((/RUNNING/ =~ output) != nil)\n\t\t\t\tend\n\t\t\t\tself.launch(\"/usr/sbin/serveradmin status devicemgr\") do |output|\n\t\t\t\t\tdevicemgr_state = ((/RUNNING/ =~ output) != nil)\n\t\t\t\tend\n\t\t\t\tif (! (wiki_state || calendar_state || addressbook_state || devicemgr_state))\n\t\t\t\t\tself.launch(\"/usr/sbin/serveradmin stop postgres\")\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\t$log.info \"Dump file is less than 24 hours old; skipping.\"\n\t\tend\n\tend",
"def storage_block_google_backup=(value)\n @storage_block_google_backup = value\n end",
"def single_object_db=(v); end",
"def backup_dir\n @backup_dir ||= create_backup_dir\n end",
"def backup(location)\n switch = SSH::Base.get_instance(location, logger)\n logger.info \"#{switch.class.to_s}: {target: #{switch.hostname}, operation: sync_from_switch_to_serv}\"\n switch.sync_from_switch_to_serv\n logger.info \"#{switch.class.to_s}: {target: #{switch.hostname}, operation: sync_from_switch_to_serv} finished\"\n end",
"def setObjectArguments _obj, _args\n \"_obj setObjectArguments _args;\" \n end",
"def instance=(instance); end",
"def setName _obj, _args\n \"_obj setName _args;\" \n end",
"def set_object_instance_variable\n instance_variable_set(:\"@#{object_model_name}\", object)\n end",
"def set(object, value); end",
"def setCurrentTask _obj, _args\n \"_obj setCurrentTask _args;\" \n end",
"def setup_replication_destination_obj(replication)\n # if this is a standard object AND we're copying to a mission AND there exists a copy of this obj in the given mission,\n # then we don't need to create a new object, so return the existing copy\n if is_standard? && replication.has_to_mission? && (copy = copy_for_mission(replication.to_mission))\n obj = copy\n else\n # otherwise, we init and return the new object\n obj = self.class.new\n end\n\n # set flag so that standardizable callback doesn't call replicate again unnecessarily\n obj.changing_in_replication = true\n\n obj\n end",
"def initialize(model, storage_id = nil, &block)\n super(model, storage_id)\n\n @path ||= 'backups'\n\n instance_eval(&block) if block_given?\n end",
"def restore(*args); end",
"def setObjectProxy _obj, _args\n \"_obj setObjectProxy _args;\" \n end",
"def set_bakusokukun\n @bakusokukun = Bakusokukun.find(params[:id])\n end",
"def lbSetData _obj, _args\n \"_obj lbSetData _args;\" \n end",
"def create_backup\n @slice = Xen::Slice.find(params[:id])\n @slice.create_backup\n\n respond_to do |format|\n format.html { redirect_to slice_path(@slice.name)}\n format.xml { render :xml => @backups }\n end\n end",
"def backup(job)\n path = @filesystem.get_tmp_path\n s3 = @storage.parse_location(job['location'])\n db = @db.get_opts(job['db'])\n \n Mongolicious.logger.info(\"Starting job for #{db[:host]}:#{db[:port]}/#{db[:db]}\")\n\n @db.dump(db, path)\n @filesystem.compress(path) \n \n key = \"#{s3[:prefix]}_#{Time.now.strftime('%m%d%Y_%H%M%S')}.tar.bz2\"\n @storage.upload(s3[:bucket], key, path)\n \n @filesystem.cleanup(path)\n @storage.cleanup(s3[:bucket], s3[:prefix], job['versions'])\n \n Mongolicious.logger.info(\"Finishing job for #{db[:host]}:#{db[:port]}/#{db[:db]}\") \n end",
"def backups_to_keep\n @backups_to_keep ||= 2\n end",
"def perform_backup_params\n params.require(:perform_backup).permit(:days, :time)\n end",
"def record\n case procedure.storage_name.to_sym\n when :s3\n record = Backup::Record::S3.new\n record.load_adapter(self)\n record.save\n when :scp\n record = Backup::Record::SCP.new\n record.load_adapter(self)\n record.save\n when :ftp\n record = Backup::Record::FTP.new\n record.load_adapter(self)\n record.save\n when :sftp\n record = Backup::Record::SFTP.new\n record.load_adapter(self)\n record.save\n end\n end",
"def create\n @backup = Backup.new(params[:backup])\n\n respond_to do |format|\n if @backup.save\n flash[:notice] = 'Backup was successfully created.'\n format.html { redirect_to(@backup) }\n format.xml { render :xml => @backup, :status => :created, :location => @backup }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @backup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def assign(params, args)\n params.update(get_default_params())\n end",
"def setWaves _obj, _args\n \"_obj setWaves _args;\" \n end",
"def assign(obj)\n @value = obj\n end"
] | [
"0.72942555",
"0.61201036",
"0.6024181",
"0.585538",
"0.5719127",
"0.56921726",
"0.5686715",
"0.55867815",
"0.5510881",
"0.54973894",
"0.54604304",
"0.54046106",
"0.5393775",
"0.5385141",
"0.5384656",
"0.53843826",
"0.5372695",
"0.53487617",
"0.5341689",
"0.53400165",
"0.5315492",
"0.5306004",
"0.52917147",
"0.5288912",
"0.5262524",
"0.52502173",
"0.5243641",
"0.52337426",
"0.52265984",
"0.5194551",
"0.51900315",
"0.51862496",
"0.51744133",
"0.5144278",
"0.5142511",
"0.51387155",
"0.5131378",
"0.51234096",
"0.51197565",
"0.51034266",
"0.50986433",
"0.50973535",
"0.5095502",
"0.50953925",
"0.5091712",
"0.5091712",
"0.50768286",
"0.5068426",
"0.50674975",
"0.5065935",
"0.5062589",
"0.505776",
"0.5054973",
"0.5038989",
"0.5037893",
"0.5028888",
"0.5012178",
"0.4997711",
"0.49894604",
"0.49877304",
"0.49863887",
"0.49839953",
"0.49839953",
"0.49768165",
"0.49609956",
"0.49600756",
"0.49537626",
"0.49536443",
"0.4952969",
"0.49463713",
"0.49441195",
"0.4940632",
"0.49297762",
"0.49276516",
"0.49246797",
"0.49181625",
"0.49140516",
"0.4909489",
"0.490712",
"0.49028102",
"0.49021474",
"0.48980892",
"0.48948115",
"0.48928186",
"0.48796666",
"0.48782283",
"0.4877016",
"0.48761287",
"0.48657474",
"0.4861719",
"0.48559967",
"0.48557228",
"0.4851124",
"0.48476207",
"0.4838732",
"0.48358837",
"0.4833826",
"0.48314902",
"0.48270938",
"0.4826105"
] | 0.7260783 | 1 |
Create and save a change_log for the backup action. | def create_change_log_entry
@change_log = @backup.create_change_log_entry(params[:action])
@change_log.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log!(action)\n case action\n when :started\n Logger.info \"Performing Backup for '#{label} (#{trigger})'!\\n\" \\\n \"[ backup #{VERSION} : #{RUBY_DESCRIPTION} ]\"\n\n when :finished\n if exit_status > 1\n ex = exit_status == 2 ? Error : FatalError\n err = ex.wrap(exception, \"Backup for #{label} (#{trigger}) Failed!\")\n Logger.error err\n Logger.error \"\\nBacktrace:\\n\\s\\s\" +\n err.backtrace.join(\"\\n\\s\\s\") + \"\\n\\n\"\n\n Cleaner.warnings(self)\n else\n msg = \"Backup for '#{label} (#{trigger})' \".dup\n if exit_status == 1\n msg << \"Completed Successfully (with Warnings) in #{duration}\"\n Logger.warn msg\n else\n msg << \"Completed Successfully in #{duration}\"\n Logger.info msg\n end\n end\n end\n end",
"def log!(action)\n case action\n when :started\n Logger.info \"Performing Backup for '#{ label } (#{ trigger })'!\\n\" +\n \"[ backup #{ VERSION } : #{ RUBY_DESCRIPTION } ]\"\n\n when :finished\n if exit_status > 1\n ex = exit_status == 2 ? Error : FatalError\n err = ex.wrap(exception, \"Backup for #{ label } (#{ trigger }) Failed!\")\n Logger.error err\n Logger.error \"\\nBacktrace:\\n\\s\\s\" + err.backtrace.join(\"\\n\\s\\s\") + \"\\n\\n\"\n\n Cleaner.warnings(self)\n else\n msg = \"Backup for '#{ label } (#{ trigger })' \"\n if exit_status == 1\n msg << \"Completed Successfully (with Warnings) in #{ duration }\"\n Logger.warn msg\n else\n msg << \"Completed Successfully in #{ duration }\"\n Logger.info msg\n end\n end\n end\n end",
"def save_log(description, action, owner_user_id)\n Log.save_log(description, action, owner_user_id, me.id)\n end",
"def save_audit_log\n if (@audit_log && @audit_log.auditable)\n if [\"update\",\"destroy\"].include?(action_name)\n update_and_destroy_audit\n elsif action_name == \"create\"\n create_audit\n end \n end\n end",
"def log_changes(action)\n Rails.logger.tagged \"ApplicationOperatorship #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created application operatorship between #{entity.log_identifier} and #{application.log_identifier}.\"\n else\n # ApplicationOperatorships should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing ApplicationOperatorship. This shouldn't happen. Operatorship is between #{entity.log_identifier} and #{application.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed application operatorship between entity (ID #{entity_id}, #{entity&.log_identifier}) and application (ID: #{application_id}, #{application&.log_identifier}).\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n end\n end",
"def write_activity_log(action = :update)\n set_culprit\n set_referenced\n if (self.respond_to?(:created_at) && Time.now > self.delay_after_create.since(self.created_at)) || action == :create\n r = self.activity_logs.create :action => action.to_s, \n :referenced => @referenced,\n :culprit => @culprit unless @skip_log == true\n end\n @skip_log = false\n return true\n end",
"def write_activity_log(action = :update)\n begin\n # explicitly switch on timestamping for event log\n previous_record_timestamps = ActivityLog.record_timestamps\n ActivityLog.record_timestamps = true\n \n # make sure that no logging is done within :delay_after_create time;\n # if no waiting required && if the filtering not required, write the log straight away\n if (self.respond_to?(:created_at) && !self.created_at.nil? && Time.now > self.delay_after_create.since(self.created_at)) || action == :create || self.created_at.nil?\n write_log = (self.check_log_allowed ? self.log_allowed(action.to_s) : true)\n if write_log\n set_culprit\n set_referenced\n log_entry = ActivityLog.new(:action => action.to_s, :referenced => @referenced, :activity_loggable => self, :culprit => @culprit)\n log_entry.save\n end\n end\n \n ActivityLog.record_timestamps = previous_record_timestamps\n rescue Exception => e\n # something went wrong - exception was thrown\n al = ActivityLog.new(:action => action.to_s, :activity_loggable => self)\n al.save\n \n logger.error \"\\nERROR: acts_as_activity_logged - write_activity_log()\"\n logger.error \"an incomplete log entry in ActivityLog table was still made - ID = #{al.id}\"\n logger.error \"action: #{action.to_s}; activity_loggable: #{self.to_s}\"\n logger.error \"exception caught:\\n\" + e.to_s + \"\\n\"\n end\n return true\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if created_at_changed?\n logger.info \"Created assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n # RoleAssignments should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing RoleAssignment. This shouldn't happen. Assignment is between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def transfer\n\t\tattributes = super\n\t\tself.last_backup_date = Date.today\n\t\tset_next_backup_date\n\t\tself.save\n\t\tlog_transfer(attributes)\n\tend",
"def activity_log_create\n write_activity_log(:create)\n end",
"def log_action(action, user, record, model)\n begin\n # Create a new ActionLog Object\n event = ActionLog.new()\n \n # Add the user to this object\n event.user = user\n \n # Add the action to this object\n event.action = action\n \n # Save the model type and its record ID(s) to this object\n event.target = model.to_s + ':' + record.to_s\n \n # Save the time of the event\n event.time_of_action = (Time.now.getutc - 7*60*60).to_s.gsub('UTC','PST')\n \n # Save this event to database\n event.save!\n\n rescue => e\n \n end\n end",
"def write_history_track!(action, changes={}, modifier_id=HistoryTracker.current_modifier_id)\n changes = modified_attributes_for_destroy if action.to_sym == :destroy\n\n original, modified = transform_changes(changes)\n tracked_attributes = default_history_tracker_attributes(action, modifier_id)\n tracked_attributes[:original] = (action == :create) ? {} : original\n tracked_attributes[:modified] = (action == :destroy) ? {} : modified\n tracked_attributes[:changes] = (action == :destroy) ? {} : changes\n\n clear_trackable_memoization\n history_tracker_class.create!(tracked_attributes)\n end",
"def changelog_file\n tfile = Tempfile.new('changelogs') \n if @package.changelogs.size > 0\n File.open(tfile, 'a') do |f| \n @package.changelogs.reverse_each { |chlog| f.puts chlog }\n end\n else\n ActiveRecord::Base.logger.debug \"Creating a fake changelog.\"\n fake_chlog = @package.changelogs.new \n @package.changelogs = []\n fake_chlog.package = @package\n fake_chlog.version = @package.version\n File.open(tfile, 'a') { |f| f.puts fake_chlog.to_s }\n end\n tfile.path\n end",
"def create_change_log_entry(object_id = nil, user_id = nil, action = nil, comments = nil)\n action = params[:action] if action.nil?\n comments = params[:change_log][:comments] unless !comments.nil? || (params[:change_log].nil? || params[:change_log][:comments].blank?)\n object_id = @object.id if object_id.nil?\n user_id = current_user.id if logged_in?\n if (comments.nil?)\n case action\n when 'create'\n comments = 'Initial creation of ' + params[:controller].singularize + '.'\n when 'update'\n comments = 'Updating information for ' + params[:controller].singularize + '.'\n else\n # Default to just listing the controller name and action\n comments = \"#{params[:controller]} #{params[:action]}\"\n end\n end\n @change_log = ChangeLog.new({:object_id => object_id, :user_id => user_id, :action => action, :comments => comments, :performed_at => Time.now.to_s(:db), :object_class => params[:controller].singularize})\n @change_log.save!\n end",
"def perform_backup\n \n add_memories_to_dropbox! if has_dropbox?\n\n # Clone the repo incase something is writing to it while we are backing up\n run \"cd #{@home} && git clone --bare #{@repo} #{@repo}.mirror\"\n output=run \"backup perform --trigger=daily_backup --log-path #{@dirs[:logs ]}\"\n run \"cd #{@home} && rm -fr #{@repo}.mirror\"\n \n get_timestamp(output)\n end",
"def copy_to_log_file(file,action,options = {})\n if (options[:to_do_list] && action ==\"Task creation\")\n file.puts(\"#{Time.now} : #{action} #{options[:to_do_list].last.description} \")\n end\n if (options[:to_do_list] && action ==\"Task deletion\")\n file.puts(\"#{Time.now} : #{action} #{options[:to_do_list].at(options[:id]).description}\")\n end\n if action ==\"List name update\"\n file.puts(\"#{Time.now} : #{action}\")\n end\n end",
"def save_changes_from(record)\n self.save_base_attributes(record)\n if record.new_record?\n self.log_type = \"created\"\n end\n self.extract_changes_from(record)\n end",
"def make_log(current_employee, old_in, old_out, new_in, new_out)\n self.changelogs.build(:changed_by => current_employee.name, :old_in => old_in, :old_out => old_out, :new_in => new_in, :new_out => new_out)\n self.save!\n end",
"def create_change_log(database)\n silence_ddl_notices(database) do\n connection = session.send(database)\n table_name = \"#{options[:rep_prefix]}_pending_changes\"\n connection.create_table table_name\n connection.add_column table_name, :change_table, :string\n connection.add_column table_name, :change_key, :string\n connection.add_column table_name, :change_new_key, :string\n connection.add_column table_name, :change_type, :string\n connection.add_column table_name, :change_time, :timestamp\n connection.remove_column table_name, 'id'\n connection.add_big_primary_key table_name, 'id'\n end\n end",
"def create_change(change)\n Change.create(:changeset => self,\n :action => change[:action],\n :path => change[:path],\n :from_path => change[:from_path],\n :from_revision => change[:from_revision])\n end",
"def perform!\r\n super\r\n backup\r\n log!(:finished)\r\n end",
"def make_backup\n @backup = editor.create_snapshot\n end",
"def write_log( user = User.anonymous )\n options = { :user => user, :ip_address => user.ip_address }\n @changed_attributes.each do |a, v|\n options[:attribute] = a\n options[:old_value] = v.first\n options[:new_value] = v.last\n self.related_object.log_entries.create options unless options[:old_value].nil?\n end unless @changed_attributes.nil?\n end",
"def after_update(record)\n contents = to_sql_update(record)\n to_logfile(contents)\n end",
"def save_history\n File.open(\".capistrano_history.yml\", 'w') do |f|\n f.write(@capistrano_history.to_yaml)\n end\nend",
"def make_changelog\n @hg_opener.open \"00changelog.i\", \"w\" do |file|\n file.write \"\\0\\0\\0\\2\" # represents revlogv2\n file.write \" dummy changelog to avoid using the old repo type\"\n end\n end",
"def save_cashout_log\n log_request = \"#{Parameter.first.front_office_url}/api/856332ed59e5207c68e864564/cashout/log/orange_money_ci?transaction_id=#{@basket.transaction_id}&order_id=#{@basket.number}&status_id=#{@status_id}&transaction_amount=#{@basket.original_transaction_amount}¤cy=#{@basket.currency.code}&paid_transaction_amount=#{@basket.paid_transaction_amount}&paid_currency=#{Currency.find_by_id(@basket.paid_currency_id).code}&change_rate=#{@basket.rate}&id=#{@basket.login_id}&cashout_account_number=#{@cashout_account_number}&fee=#{@basket.fees}\"\n log_response = (RestClient.get(log_request) rescue \"\")\n\n @basket.update_attributes(\n cashout_notified_to_front_office: (log_response == '1' ? true : false), \n cashout_notification_request: log_request, \n cashout_notification_response: log_response\n )\n end",
"def save( foodDB, foodLog, db_file, log_file )\n puts \"Saving food database and log...\\n\\n\"\n \n if !foodDB.hasChanges\n puts \"No changes have been made to the database.\"\n else\n # get changes for database and save to file\n changesDB = foodDB.getChanges\n db_handle = File.open( db_file, 'a' )\n changesDB.each do |line|\n db_handle.write( line + \"\\n\" )\n end\n db_handle.close\n\tputs \"Success! Database has been saved!\\n\"\n end\n \n if !foodLog.hasChanges\n puts \"No changes have been made to the log.\"\n else\n # get all information for log and save to file\n getLog = foodLog.getLog\n log_handle = File.open( log_file, 'w' )\n\tlog_handle.write( getLog )\n log_handle.close\n\tfoodLog.hasChanges = false\n\tputs \"Success! Log has been saved!\\n\"\n end\nend",
"def create\n @change_log = ChangeLog.new(change_log_params)\n\n respond_to do |format|\n if @change_log.save\n format.html { redirect_to @change_log, notice: 'Change log was successfully created.' }\n format.json { render :show, status: :created, location: @change_log }\n else\n format.html { render :new }\n format.json { render json: @change_log.errors, status: :unprocessable_entity }\n end\n end\n end",
"def Auditlog( mo, msg )\n auditEntry = Audit.new\n auditEntry.message = \"#{mo} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n #auditEntry.origin = ip\n auditEntry.origin = request.remote_ip\n auditEntry.user = !current_user.nil? ? current_user.email : 'no-user'\n auditEntry.datetime = DateTime.now\n\n if !auditEntry.save\n _auditLog.info \"#{user} #{ip} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n end\n\n end",
"def generate_backup\n if Export.launch_export!\n current_user.update(\n last_backup_at: Time.zone.now,\n last_backup_entry_id: current_user.last_entry_id\n )\n redirect_to backup_succeeded_path\n else\n redirect_to backup_failed_path\n end\n end",
"def sys_logger(action_logged)\n log = SysLog.new({:log_date => Time.now, :user_id => session[:user_id], :user_name => session[:user_name], :user_ip => session[:user_ip],\n :action_logged => action_logged}, :as => :logger)\n log.save!\n end",
"def icl_save( args )\n @foodDB.save( args )\n @log.save()\n end",
"def log \n @log #||= Log.create\n end",
"def before_backup\n end",
"def write_to_file(action)\n email = @@new_acc_email\n actioninfo = action\n if action == 'donation'\n email = @@donate_email\n actioninfo = donateinfo\n end\n open(File.join(Dir.pwd, \"submissions/#{action}s.txt\"), 'a') do |f|\n f << \"> #{email} - #{actioninfo} completed on #{@@ENV} at #{Time.now} \\n\"\n end\n end",
"def copy\n actionlist = actionlist(:copy, copylist)\n\n if actionlist.empty?\n report_nothing_to_generate\n return\n end\n\n #logger.report_startup(job, output)\n\n mkdir_p(output) unless File.directory?(output)\n\n backup(actionlist) if backup?\n\n Dir.chdir(output) do\n actionlist.each do |action, fname|\n atime = Time.now\n how = __send__(\"#{action}_item\", Pathname.new(fname))\n report_create(fname, how, atime)\n end\n #logger.report_complete\n #logger.report_fixes(actionlist.map{|a,f|f})\n end\n end",
"def create_log\n UserActivityLog.using_client_shard(client: @client).create!(\n user_id: @user_id,\n admin_id: @admin_id,\n log_type: log_type,\n action: @action,\n action_timestamp: @action_timestamp,\n e_data: @e_extra_data\n )\n end",
"def mk_log(mc)\n log_name = \"#{@t.month}/#{@t.day}/#{@t.year} at #{@t.hour}:#{@t.min}\"\n log_dir = \"#{@archive_folder}/.archive_logs\"\n Dir.mkdir(log_dir) unless Dir.exist?(log_dir)\n\n log_file = \"#{log_dir}/Archive Log.txt\"\n File.new(log_file, 'w+') unless File.exist?(log_file)\n # `a` is for `append`. This appends a new line to the end of the file.\n File.open(log_file, 'a') do |line|\n line.puts \"Moved #{mc} items on #{log_name}\"\n end\nend",
"def historic_copy_to_history\n historic_record_class.create_history_from_current!(self)\n historic_options[:after].to_proc.call(self) if historic_options[:after]\n end",
"def create\n @object = @model_class.new(params[@model_class.name.tableize.singularize.to_sym])\n @model_class.transaction do\n @object.save!\n create_change_log_entry\n end\n respond_to do |format|\n flash[:notice] = @model_class.name.humanize + ' was successfully created.'\n format.html { redirect_to(@object) }\n format.xml { render :xml => @object, :status => :created, :location => @object }\n end\n end",
"def system_backup\n\n\n end",
"def create_backup instance_id:, cluster_id:, backup_id:, source_table_id:, expire_time:\n backup = Google::Cloud::Bigtable::Admin::V2::Backup.new \\\n source_table: table_path(instance_id, source_table_id), expire_time: expire_time\n tables.create_backup parent: cluster_path(instance_id, cluster_id), backup_id: backup_id, backup: backup\n end",
"def create_history(account_id, accounts, action, deposit_withdrawl, current_balance)\n new_transaction_history= {\n date_time: Time.now,\n action: action,\n amount: deposit_withdrawl,\n current_balance: current_balance\n }\n # print new_transaction_history\n accounts[account_id][:transaction].push(new_transaction_history)\nend",
"def history_create\n # history_log('created', created_by_id)\n end",
"def write_log(host, brower,is_admin)\n log = CardLog.new\n log.host = host\n log.brower = brower\n log.is_admin_read = is_admin\n\n if !is_admin && self.first_read_time.nil?\n self.first_read_time = Time.now\n end\n\n self.card_logs << log\n self.save\n end",
"def log(project, project_params, action, status = nil)\n status_change = 0\n if status\n old_status = Status.find(status)\n new_status = Status.find(project.status_id)\n\n status_change = new_status.sorting - old_status.sorting\n end\n\n ProjectLog.create(project_id: project.id, params: project_params.to_json, action: action, status_change: status_change)\n end",
"def audit\n data = {\"changes\" => changes, \"metadata\" => audit_metadata}\n Audit::Tracking.log.record(audit_bucket, self.id, data)\n end",
"def activity_log_create\n write_activity_log(:create)\n raise Exception.new \"Shouldn't be calling activity_log_create\"\n end",
"def command_save\n if @dbChanged == true\n @database.save\n @dbChanged = false\n end\n if @logChanged == true\n @log.save\n @logChanged = false\n end\n end",
"def build_saved_audit(rec, eh)\n build_audit_payload(rec, eh[:new], eh[:current], \"#{rec.class.to_s.downcase}_record_update\", \"Record updated\")\n end",
"def secure_change_in_logs(checksum, this_change) \n log = @filename.to_s + Logger::DELIMITER\n log += @version.to_s + Logger::DELIMITER\n log += checksum + Logger::DELIMITER\n log += this_change.username.to_s + Logger::DELIMITER\n log += this_change.position.node.to_s + Logger::DELIMITER \n log += this_change.position.offset.to_s + Logger::DELIMITER\n\n if this_change.is_a? Insertion\n log += \"insertion\" + Logger::DELIMITER\n log += this_change.content + Logger::DELIMITER\n elsif this_change.is_a? Deletion\n log += \"deletion\" + Logger::DELIMITER\n log += this_change.direction + Logger::DELIMITER\n log += this_change.length.to_s + Logger::DELIMITER\n end\n\n # invoke the logger function to log this to the log file\n # it will add the lsn automatically\n Application.logger.recovery log\n end",
"def write_backup(filename = nil)\n Doing.logger.benchmark(:_write_backup, :start)\n filename ||= Doing.setting('doing_file')\n\n unless File.exist?(filename)\n Doing.logger.debug('Backup:', \"original file doesn't exist (#{filename})\")\n return\n end\n\n backup_file = File.join(backup_dir, \"#{timestamp_filename}___#{File.basename(filename)}\")\n # compressed = Zlib::Deflate.deflate(content)\n # Zlib::GzipWriter.open(backup_file + '.gz') do |gz|\n # gz.write(IO.read(filename))\n # end\n\n FileUtils.cp(filename, backup_file)\n\n prune_backups(filename, Doing.setting('history_size').to_i)\n clear_undone(filename)\n Doing.logger.benchmark(:_write_backup, :finish)\n end",
"def make_backup\n print_title('Data backup')\n\n @backup_type ||= prompt.select('What type of backup do you want?',\n 'Full (redmine root and database)' => :full,\n 'Only database' => :database,\n 'Nothing' => :nothing)\n\n logger.info(\"Backup type: #{@backup_type}\")\n\n # Dangerous option\n if @backup_type == :nothing\n if prompt.yes?('Are you sure you dont want backup?', default: false)\n logger.info('Backup option nothing was confirmed')\n return\n else\n @backup_type = nil\n return make_backup\n end\n end\n\n @backup_root ||= prompt.ask('Where to save backup:', required: true, default: DEFAULT_BACKUP_ROOT)\n @backup_root = File.expand_path(@backup_root)\n\n @backup_dir = File.join(@backup_root, Time.now.strftime('backup_%d%m%Y_%H%M%S'))\n create_dir(@backup_dir)\n\n files_to_backup = []\n Dir.chdir(root) do\n case @backup_type\n when :full\n files_to_backup = Dir.glob(File.join('**', '{*,.*}'))\n end\n end\n\n if files_to_backup.any?\n files_to_backup.delete_if do |path|\n path.start_with?(*BACKUP_EXCLUDE_FILES)\n end\n\n @backup_package = File.join(@backup_dir, 'redmine.zip')\n\n Dir.chdir(root) do\n puts\n puts 'Files backuping'\n Zip::File.open(@backup_package, Zip::File::CREATE) do |zipfile|\n progressbar = TTY::ProgressBar.new(PROGRESSBAR_FORMAT, total: files_to_backup.size, frequency: 2, clear: true)\n\n files_to_backup.each do |entry|\n zipfile.add(entry, entry)\n progressbar.advance(1)\n end\n\n progressbar.finish\n end\n end\n\n puts \"Files backed up on #{@backup_package}\"\n logger.info('Files backed up')\n end\n\n @database = Database.init(self)\n @database.make_backup(@backup_dir)\n\n puts \"Database backed up on #{@database.backup}\"\n logger.info('Database backed up')\n end",
"def action_create\n @original_cron_provider.action_create\n @new_resource.updated_by_last_action(@original_cron_provider.new_resource.updated_by_last_action?)\n true\n end",
"def create_log(param); end",
"def log_activity(at, action = nil)\n unless activity_log\n update_attributes(:activity_log => ActivityLog.create(:user => self))\n end\n activity_log.add(at, action)\n end",
"def save_history(save_it = true)\n if save_it?\n self.backup.set true\n else\n self.backup.set false\n end\n end",
"def setup_logfile\n # strip any trailing '/' in case the user supplied this as part of\n # an absolute path, so we can match it against File.expand_path()\n path = @options.log_path.chomp(\"/\")\n if path.empty?\n path = File.join(Backup::Config.root_path, \"log\")\n elsif path != File.expand_path(path)\n path = File.join(Backup::Config.root_path, path)\n end\n FileUtils.mkdir_p(path)\n log_file = @options.log_file || \"backup.log\"\n path = File.join(path, log_file)\n if File.exist?(path) && !File.writable?(path)\n raise Error, \"Log File at '#{path}' is not writable\"\n end\n\n path\n end",
"def backup\n #EternosBackup::BackupJobPublisher.add_source(self)\n end",
"def save_backup_on_dup\n if self.duplicated_from && self.duplicated_from.restorable? && self.keep_backup\n FileUtils.mkdir_p( File.dirname( self.backup_path ))\n FileUtils.cp( self.duplicated_from.backup_path, self.backup_path )\n end\n end",
"def after_save(subscription)\n attributes = {}\n description = []\n if subscription.state_changed?\n state_changes = subscription.changes['state']\n attributes.merge!(\n :old_state => state_changes.first,\n :new_state => state_changes.last\n )\n if state_changes.first == 'pending' && state_changes.last == 'active'\n if subscription.pending == :payment\n description << subscription.actions.last.try(:payment).try(:description)\n end\n if subscription.pending == :concession_verification\n description << \"Concession: #{subscription.note}\"\n end\n if subscription.pending == :student_verification\n description << \"Student Discount: #{subscription.note}\"\n end\n end\n if state_changes.first == 'pending'\n # Set the pending column to nil if we are no longer pending anything\n subscription.pending = nil\n end\n end\n if subscription.expires_at_changed?\n if subscription.expires_at\n description << \"Expiry Date set to #{subscription.changes['expires_at'].last.strftime(\"%d/%m/%y\")}\"\n else\n description << \"Expiry Date set to nil!\"\n end\n end\n attributes[:description] = description.join(\"; \")\n subscription.log_entries.create(attributes) unless attributes.empty?\n end",
"def write_history; end",
"def save_log( model )\n dir = log_dir model\n\n model.days_index.each do |day, days_logs|\n file = \"#{day.to_s}.yaml\"\n file_path = File.join(dir, file)\n File.delete( file_path ) if File.exists?( file_path )\n\n # don't write to an empty file\n next if days_logs.empty?\n\n File.open( file_path,'a' ) do |f|\n days_logs.each do |log|\n f.puts YAML::dump( log.freeze_dry )\n end\n end\n end\n end",
"def log(user_id, action, id1, id2, id3=nil)\n \n ul = Log.new\n \n if (action =~ /NEW_LIST(\\w+)$/)\n ul.list_id = id1\n end\n \n \n \n if (action =~ /NEW_FEATURE_(\\w+)$/) or action == \"VOTE_UP\" or action == \"VOTE_DOWN\"\n ul.list_id = id1 \n ul.feature_id = id2\n end\n \n if(action =~ /NEW_COMMENT/)\n ul.list_id = id1\n ul.feature_id = id2\n ul.comment_id = id3\n \n end\n \n ul.datetime = Time.now\n ul.user_id = user_id\n ul.action = action\n ul.save\n end",
"def save_journal(operation, changes = {})\r\n if operation == :delete\r\n @record.attributes.each { |k, v| changes[k] = v }\r\n end\r\n changes.except!('created_at', 'updated_at', 'created_by', 'updated_by')\r\n\r\n if (operation != :update) || changes.size > 0\r\n # determine site_id\r\n site_id = @record.site_id if @record && @record.respond_to?('site_id')\r\n site_id = dc_get_site._id if site_id.nil? && dc_get_site\r\n\r\n DcJournal.create(site_id: site_id,\r\n operation: operation,\r\n user_id: session[:user_id],\r\n tables: params[:table],\r\n ids: params[:ids],\r\n doc_id: params[:id],\r\n ip: request.remote_ip,\r\n time: Time.now,\r\n diff: changes.to_json)\r\n end\r\nend",
"def create_and_copy_backup(backup_options = nil,backup_name = nil)\n\n end",
"def after_create(record)\n contents = to_sql_insert(record)\n to_logfile(contents)\n # Send a notification to the admin, if requested:\n if @email_on_create\n AgexMailer.action_notify_mail(\n record.respond_to?(:user) ? record.user : nil,\n \"#{@table_name} row CREATED\",\n contents\n ).deliver\n end\n end",
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def log_file_creation()\n\tcurrent_path = File.dirname(File.realpath(__FILE__))\n\t$csv_path = \"#{current_path}/Attachments.csv\"\n\tif !File.directory?(\"#{current_path}/logs\")\n\t\tFileUtils.mkdir_p \"#{current_path}/logs\"\n\tend\n\t$log_path = \"#{current_path}/logs/jira-attachment-upload.txt\"\n\t$log = Logger.new(\"#{current_path}/logs/jira-attachment-upload.txt\", 'daily')\nend",
"def store_audit_trail(options = {})\n state_machine = self\n state_machine.transition_class_name = (options[:to] || default_transition_class_name).to_s\n state_machine.after_transition do |object, transition|\n state_machine.audit_trail(options[:context_to_log]).log(object, transition.event, transition.from, transition.to)\n end\n\n unless state_machine.action == nil\n state_machine.owner_class.after_create do |object|\n if !object.send(state_machine.attribute).nil?\n state_machine.audit_trail(options[:context_to_log]).log(object, nil, nil, object.send(state_machine.attribute))\n end\n end\n end\n end",
"def create_log_entry\n Rails.logger.debug(\"@@@ create_log_entry: task = #{@task.inspect} event = #{@event.inspect}\")\n params = Hash.new\n params[:user_id] = current_user.id\n params[:role_id] = current_user.role.id\n params[:ot_id] = @task.ot.id\n params[:task_id] = @task.id\n params[:description] = \"Transicion de #{@task.current_state} a #{@task.current_state.events[@event.to_sym].transitions_to}\"\n log_entry = Audit.new(params)\n log_entry.save\n end",
"def log_time_of_backup\n puts \"- Logging the time of this backup\"\n puts \"You can find this by extracting the document with the class type of LastRunDoc\"\n logger = {:class=>\"LastRunLog\",\n :logged_interval=>last_run,\n :ran_at=>Time.now}\n RestClient.post(\"#{@couch_db}\", logger.to_json )\n end",
"def log_changes(location,description,observation=nil,author=nil,description_patch=nil,\n former_type_ids=[],former_location=nil)\n c = Change.new\n c.location = location\n c.description = description\n c.remote_ip = request.headers['CF-Connecting-IP'] || request.remote_ip \n c.user = current_user if user_signed_in?\n c.observation = observation\n c.description_patch = description_patch\n c.former_type_ids = former_type_ids\n c.former_location = former_location\n # adding an observation\n if author.nil? and not observation.nil?\n c.author = observation.author\n # adding a location\n elsif author.nil? and observation.nil? and description == \"added\"\n c.author = location.author\n # editing a location\n elsif not author.nil?\n c.author = author\n end\n c.save\n end",
"def backup\n FileUtils.cp options[:file], backup_file if File.file? options[:file]\n end",
"def create_log\n\t\tApplicationLog.find_or_create_by(\n\t\t\tchecksum: self.checksum,\n\t\t)\n\tend",
"def backup_data(src_file)\n backup_path = src_file + '.simplib_migration.bak.' + Time.now.strftime('%Y_%m_%d_%s')\n puts %Q(Making backup at #{backup_path})\n FileUtils.cp_r(src_file, backup_path)\nend",
"def log\n logger.info \"Apply migration #{version}\\n\"\n end",
"def touch \n set_actionstamps\n save\n end",
"def save_diff_file( data_import_session )\n return unless sql_diff_text_log.to_s.length > 0\n full_pathname = db_diff_full_pathname( data_import_session )\n # If the file exists, just add another transaction on it:\n File.open( full_pathname, 'a+' ) do |f|\n # Produce a condensed stack trace on the first line of comment:\n f.puts \"-- caller: #{ caller[0..3].map{|c| c.split(':in `').first.split('/').last }.join(' | ') }\" if caller\n f.puts \"SET SQL_MODE = \\\"NO_AUTO_VALUE_ON_ZERO\\\";\"\n f.puts \"SET AUTOCOMMIT = 0;\"\n f.puts \"START TRANSACTION;\"\n f.puts \"SET time_zone = \\\"+00:00\\\";\"\n f.puts \"/*!40101 SET NAMES utf8 */;\"\n f.puts \"\\r\\n--\\r\\n\"\n\n f.puts sql_diff_text_log\n\n f.puts \"\\r\\n--\\r\\n\"\n f.puts \"COMMIT;\\r\\n\\r\\n\"\n end if Rails.env != 'test' # (Avoid creating thousands of files during specs running)\n # Use phase_1_log column to store unique, produced db-diff filenames:\n unless data_import_session.phase_1_log.to_s.include?( full_pathname )\n # Add a display-friendly separator to the list of filenames when needed:\n if data_import_session.phase_1_log.to_s.size > 0\n data_import_session.phase_1_log = data_import_session.phase_1_log + \", \"\n end\n data_import_session.phase_1_log = data_import_session.phase_1_log + full_pathname\n data_import_session.save!\n end\n end",
"def create_log_data\n UpdateLog.create(over_tag_id: self.id, table_name: \"over_tag\", log_type: \"create\")\n end",
"def save_action; end",
"def log_transaction\n repo.log_action(user_name: @user.user_name, context: @context.context, route_url: @context.route_url)\n end",
"def create_log(content)\n @note.title = to_utf8(@name) + \" - \" + Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n @note.tags = @tag.get\n @note.content = to_utf8(content)\n @note.create\n Logger.log_internal { \"Create note: #{@note.guid}\" }\n end",
"def log(project, line_item_id, line_item_params, action)\n ProjectLog.create(project_id: project.id, line_item_id: line_item_id, params: line_item_params.to_json, action: action)\n end",
"def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end",
"def log\n parametros = {}\n parametros['action'] = params['action']\n parametros['controller'] = params['controller']\n parametros['fecha'] = Time.zone.now\n parametros['token'] = false\n puts parametros\n log = Log.create(parametros)\n\n # parametros['usuario'] = revisar_token()\n parametros['token'] = true\n log.update(parametros)\n end",
"def tmpbkup(action=:create)\n bkup=@bkup\n begin\n if action == :create\n # Thx SO; https://stackoverflow.com/questions/88311/how-to-generate-a-random-string-in-ruby\n marker = (0...8).map { ('a'..'z').to_a[rand(26)] }.join\n\n Pem::Logger.logit(\"Creating backup of #{@location} to #{@location}#{marker}\")\n FileUtils.mv(@location,\"#{@location}#{marker}\")\n return \"#{@location}#{marker}\"\n elsif action == :restore\n Pem::Logger.logit(\"Backup cannot be nil!\", :fatal) if bkup.nil?\n raise('Backup cannot be nil!') if bkup.nil?\n\n Pem::Logger.logit(\"Restoring backup of #{@location} from #{bkup}\")\n FileUtils.rm_rf(@location)\n FileUtils.mv(bkup,@location)\n return nil\n elsif action == :purge\n Pem::Logger.logit(\"Backup cannot be nil!\", :fatal) if bkup.nil?\n raise('Backup cannot be nil!') if bkup.nil?\n\n Pem::Logger.logit(\"Purging backup of #{@location} from #{bkup}\")\n FileUtils.rm_rf(bkup)\n return nil\n end\n rescue StandardError => err\n Pem::Logger.logit(err, :fatal)\n raise(err)\n end\n end",
"def store_log_file_permanently!\n f = Tempfile.new(\"processing_log\")\n f.write(log_contents)\n f.close\n store_permanently!(f.path)\n end",
"def save_history(file=DEF_HISTORY_FILE)\n begin\n f = File.new(file, File::CREAT|File::TRUNC|File::RDWR, 0644)\n f.puts(@rundate)\n @currprocstat.each do |username,time|\n f.puts(\"#{username} #{time} #{@currprociowait[username]}\")\n end\n f.close\n rescue => e\n puts \"Cannot save history data: #{e}\"\n end\n end",
"def log_saves \n s_log = File.open(\"../saves/log.yml\", \"w\")\n s_log.puts @@save_count\n s_log.close\n end",
"def set_database_change_log\n @database_change_log = DatabaseChangeLog.find(params[:id])\n end",
"def save_journal(operation, changes = {})\r\n# return unless session[:save_journal]\r\n if operation == :delete\r\n @record.attributes.each {|k,v| changes[k] = v}\r\n# elsif operation == :new\r\n# changes = {}\r\n end\r\n#\r\n if (operation != :update) or changes.size > 0\r\n# determine site_id\r\n site_id = @record.site_id if @record.respond_to?('site_id')\r\n site_id = dc_get_site._id if site_id.nil? and dc_get_site\r\n DcJournal.create(site_id: site_id,\r\n operation: operation,\r\n user_id: session[:user_id],\r\n tables: params[:table],\r\n ids: params[:ids],\r\n doc_id: params[:id],\r\n ip: request.remote_ip,\r\n time: Time.now,\r\n diff: changes.to_json)\r\n end\r\nend",
"def change_log\r\n ChangeLogController.instance\r\n end",
"def log_message\n #History.new(\n # mailbox_name: 'N/A',\n # name: @updater,\n # message: Array(@msg).join(',')\n #).save!\n end",
"def log_action(object, method, opts)\n object_id = object.data_object_id if object.class.name == \"DataObjectsHierarchyEntry\" || object.class.name == \"CuratedDataObjectsHierarchyEntry\" || object.class.name == \"UsersDataObject\"\n object_id = object.id if object_id.blank?\n\n if object.class.name == \"DataObjectsHierarchyEntry\" || object.class.name == \"CuratedDataObjectsHierarchyEntry\"\n he = object.hierarchy_entry\n elsif object.class.name == \"HierarchyEntry\"\n he = object\n end\n\n if method == :add_association || method == :remove_association\n changeable_object_type = ChangeableObjectType.send(\"CuratedDataObjectsHierarchyEntry\".underscore.to_sym)\n else\n changeable_object_type = ChangeableObjectType.send(object.class.name.underscore.to_sym)\n end\n\n auto_collect(@data_object) # SPG asks for all curation to add the item to their watchlist.\n CuratorActivityLog.create(\n :user => current_user,\n :changeable_object_type => changeable_object_type,\n :object_id => object_id,\n :activity => Activity.send(method),\n :data_object => @data_object,\n :hierarchy_entry => he,\n :created_at => 0.seconds.from_now\n )\n end",
"def set_actionstamps_on_save \n return unless dirty?\n set_actionstamps\n end",
"def log_activity(activity, start_time, end_time)\n File.open(log_filename, \"a\") do |logFile|\n logStr = \"#{activity}\\t#{start_time}\\t#{end_time}\\n\"\n logFile.syswrite(logStr)\n end\n\n store_activity_end_time\n \nend",
"def backup_request(client, filename, message)\n filename = \"BACKUP_#{filename}\"\n aFile = File.open(filename, 'w+')\n if aFile\n File.write(filename, message)\n puts \"Updated: #{filename}\"\n else\n client.puts \"ERROR: Unable to open file #{filename}\"\n end\n aFile.close\n return\n end"
] | [
"0.6761372",
"0.66833407",
"0.64603484",
"0.6280295",
"0.6056268",
"0.60428065",
"0.6022665",
"0.60060525",
"0.6004752",
"0.60007346",
"0.59747875",
"0.5862887",
"0.5823843",
"0.58127964",
"0.5797069",
"0.5739223",
"0.5724134",
"0.57126516",
"0.56855327",
"0.55084604",
"0.5478891",
"0.54527175",
"0.5446767",
"0.5438437",
"0.54256433",
"0.5424306",
"0.5363705",
"0.53500175",
"0.5340557",
"0.53256977",
"0.53236914",
"0.5320528",
"0.53186464",
"0.53182125",
"0.5316516",
"0.5314751",
"0.5308578",
"0.53055626",
"0.5301402",
"0.52882755",
"0.5286086",
"0.5269314",
"0.5263512",
"0.5258668",
"0.5253174",
"0.5244876",
"0.5203266",
"0.5202742",
"0.5198659",
"0.5184345",
"0.5183569",
"0.51788384",
"0.5176199",
"0.5165698",
"0.5162282",
"0.51483",
"0.5143001",
"0.5138541",
"0.5136877",
"0.513547",
"0.5135257",
"0.51245236",
"0.51227987",
"0.51154256",
"0.5108286",
"0.5105323",
"0.5104132",
"0.5097503",
"0.50937694",
"0.50931805",
"0.50635064",
"0.5062923",
"0.5061773",
"0.5050859",
"0.5045998",
"0.5045205",
"0.50441676",
"0.5042035",
"0.5036402",
"0.50315267",
"0.5022398",
"0.5008215",
"0.49995697",
"0.49975845",
"0.49944714",
"0.4994288",
"0.49824136",
"0.498222",
"0.49712637",
"0.49683002",
"0.4966475",
"0.49632898",
"0.49614346",
"0.49537462",
"0.4948879",
"0.49470037",
"0.49454358",
"0.4944208",
"0.49438202",
"0.49360466"
] | 0.8248232 | 0 |
Lists all Metric Descriptors. | def all(filter: nil, page_size: nil, page_token: nil)
data = service.list_metric_descriptors(
:filter => filter,
:page_size => page_size,
:page_token => page_token
).to_h[:metric_descriptors] || []
load(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(options = {})\n data = service.list_metric_descriptors(options).body[\"metricDescriptors\"] || []\n load(data)\n end",
"def all(options = {})\n data = service.list_metric_descriptors(options).body['metrics'] || []\n load(data)\n end",
"def index\n @metrics = Metric.all\n end",
"def all(options = {})\n data = service.list_monitored_resource_descriptors(options).body[\"resourceDescriptors\"] || []\n load(data)\n end",
"def list\n all.each { |device| puts(device.pretty_name) }\n end",
"def list_metrics\n define_type_on_metric_def_if_needed\n\n gauges = Hawk.metrics.gauges.query\n gauges.each { |g| g.type = 'GAUGE' }\n counters = Hawk.metrics.counters.query\n counters.each { |c| c.type = 'COUNTER' }\n strings = Hawk.metrics.strings.query\n strings.each { |c| c.type = 'STRING' }\n\n tree_root = build(::HTreeItem)\n tree_root.kind = :none\n tree_root.value = 'Metrics'\n metrics = gauges.concat counters\n metrics = metrics.concat strings\n\n ascend_sort = ->(m1, m2) { m1.id <=> m2.id }\n metrics.sort(&ascend_sort).each do |metric_def|\n icon = ::HawkHelper.metric_icon metric_def.type\n iv = ::HawkHelper.create_icon icon\n\n new_metric = build(::HTreeItem)\n new_metric.kind = :metric\n new_metric.value = metric_def.id\n new_metric.graphic = iv\n\n # Create a Metric type of Inventory\n # from the metric dev obtained from H-Metrics\n m_hash = {\n 'name' => metric_def.id,\n 'id' => metric_def.id,\n 'type' => { 'type' => metric_def.json['type'].upcase },\n # :unit => metric_def.unit\n }\n mt = create_metric_type_from_metric_def(metric_def)\n m = ::Hawkular::Inventory::Metric.new m_hash, mt\n\n new_metric.raw_item = m\n\n tree_root.children.add new_metric\n end\n # bind to the view from fxml\n @FXMLtreeView.setRoot(tree_root)\n tree_root.expanded = true\n end",
"def get_all_metrics()\n return nil unless Config.metrics\n f = Fiber.current\n resp = metrics.find().defer_as_a\n resp.callback do |doc|\n f.resume doc\n end\n resp.errback do |err|\n raise *err\n end\n docs = Fiber.yield\n # convert ids to int\n docs.collect{|doc| doc['_id'] = doc['_id'].to_i ; doc }\n end",
"def get_metrics_list\n\t\turi = \"#{@base_url}/data\"\n\t\tresults = json_metrics_list uri\n\t\tlist = []\n\t\tresults[:hosts][0..@hosts_limit].each {|h|\n\t\t\thost_results = json_metrics_list \"#{uri}/#{h}/\"\n\t\t\tlist << host_results[:metrics].map{|r| \"#{h}/#{r}\"}\n\t\t}\n\t\treturn list.flatten\n\tend",
"def all_metrics\n output = `cube_info #{@fname} -l`\n output.split(\"\\n\")\n end",
"def index\n @descriptors = Descriptor.all\n end",
"def index\n @descriptors = Descriptor.all\n end",
"def list_measures\n exec_req_and_parse_response \"/measure/list\"\n end",
"def all_metrics\n valid_configs = MetricSample.all.where(:project_id => id)\n return [] if valid_configs.nil?\n metrics_name_ary = []\n valid_configs.each do |config|\n metrics_name_ary << config.metric_name\n end\n metrics_name_ary.uniq\n end",
"def metrics\n with_stats_lock do\n @stats_hash.keys.map { |spec| spec.to_s }\n end\n end",
"def delete_all_metrics\n connection = Librato::Metrics.client.connection\n Librato::Metrics.list.each do |metric|\n #puts \"deleting #{metric['name']}...\"\n # expects 204\n connection.delete(\"metrics/#{metric['name']}\")\n end\n end",
"def histograms\n metrics(Histogram)\n end",
"def metric_names\n @metrics.keys\n end",
"def index\n @throughput_metrics = ThroughputMetric.all.order(\"description\")\n end",
"def metrics\n manager_instance(MetricManager)\n end",
"def index\n @metric_sources = MetricSource.all\n end",
"def counters\n metrics(Counter)\n end",
"def get_metrics_list\n\t\ttest_file\n\t\t[@metric]\n end",
"def all\n describe(resource_uri)\n end",
"def summary_metrics\n []\n end",
"def metric_devices\n return @metric_devices\n end",
"def all\n @@all_metrics ||= self.from_file(\n File.join(Rails.root, 'config', 'metrics.yml')\n )\n end",
"def index\n @vspecs = @metric.vspecs.all\n end",
"def index\n @admin_sub_metrics = Admin::SubMetric.all\n end",
"def get_capability_adapter_unit_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_adapter_unit_descriptor_list_with_http_info(opts)\n data\n end",
"def scorable_metrics\n Card.search(type_id: Card::MetricID,\n right_plus: [\"*metric type\",\n content: scorable_metric_type_content.unshift(\"in\")],\n sort: \"name\",\n return: :name).sort\n end",
"def index\n @channel_statistics = ChannelStatistic.all\n end",
"def list_all_metric_values(opts = {})\n data, _status_code, _headers = list_all_metric_values_with_http_info(opts)\n data\n end",
"def list_all_metric_values(opts = {})\n data, _status_code, _headers = list_all_metric_values_with_http_info(opts)\n data\n end",
"def metrics\n @metrics ||= collect_metrics\n end",
"def get_capability_switch_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_switch_descriptor_list_with_http_info(opts)\n data\n end",
"def metrics\n @metrics ||= []\n end",
"def list_attractions\n RhodyAttractions::Attraction.all.each do |attraction|\n attraction.print_description(\"short\")\n puts \"\"\n end\n end",
"def metrics\n report[\"columnHeader\"][\"metricHeader\"][\"metricHeaderEntries\"].map { |metric| metric[\"name\"] }\n end",
"def get_firmware_cimc_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_cimc_descriptor_list_with_http_info(opts)\n data\n end",
"def list\n load_all\n @facts.keys\n end",
"def metrics_for_metric_name\n @metrics = Metric.includes(:metric_name).where(metric_name_id: metric_name_id[:id]);\n render json: @metrics.order({created_at: :asc}),include: [:metric_name], status: :ok\n end",
"def device_list\n @devices = Device.all\n end",
"def get_capability_chassis_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_chassis_descriptor_list_with_http_info(opts)\n data\n end",
"def get_metrics\n {\n method: \"Performance.getMetrics\"\n }\n end",
"def device_list(opts = {})\n data, _status_code, _headers = device_list_with_http_info(opts)\n data\n end",
"def get_firmware_mswitch_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_mswitch_descriptor_list_with_http_info(opts)\n data\n end",
"def report_metrics(metrics=MetricFu.metrics)\n MetricFu.configuration.metrics.sort_by! {|x| x == :hotspots ? 1 : 0 }\n MetricFu.configuration.metrics\n end",
"def get_firmware_dimm_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_dimm_descriptor_list_with_http_info(opts)\n data\n end",
"def meters \n metrics(Meter)\n end",
"def index\n @unit_of_measures = UnitOfMeasure.all\n end",
"def index\n @api_v1_metrics_dashboards_segments = Api::V1::MetricsDashboardsSegment.all\n end",
"def get_capability_cimc_firmware_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_cimc_firmware_descriptor_list_with_http_info(opts)\n data\n end",
"def timers\n metrics(Timer)\n end",
"def index\n @therm_resources = ThermResource.all\n end",
"def index\n @measurement_categories = MeasurementCategory.all\n end",
"def metrics\n standard.unit.convert_to_metric imperials\n end",
"def index\n @unit_measures = UnitMeasure.all\n end",
"def list_sobjects\n describe.collect { |sobject| sobject['name'] }\n end",
"def index\n @collectors = ::Collector.includes(:collector_versions)\n end",
"def names\n @metrics.keys.dup.freeze\n end",
"def index\n @attribute_displays = AttributeDisplay.all\n end",
"def get_capability_io_card_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_io_card_descriptor_list_with_http_info(opts)\n data\n end",
"def index\n @selectfs = @metric.selectfs.all\n end",
"def list()\n puts \"Listing all endpoints\"\n load_manifest\n\n pp manifest.keys\n\n end",
"def index\n @api_v1_user_device_infos = Api::V1::UserDeviceInfo.all\n end",
"def measures\n @dimensions.describe\n end",
"def index\n @k_measurements = KMeasurement.all\n end",
"def get_capability_sioc_module_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_sioc_module_descriptor_list_with_http_info(opts)\n data\n end",
"def index\r\n @meter_records = MeterRecord.all\r\n end",
"def list_definitions(resource, filter = nil)\n resource_id = resource.respond_to?(:id) ? resource.id : resource\n version = configuration.provider_default_api_version(provider, 'metricDefinitions')\n\n url = File.join(\n configuration.environment.resource_url,\n resource_id,\n 'providers/microsoft.insights/metricdefinitions'\n )\n\n url << \"?api-version=#{version}\"\n url << \"&$filter=#{filter}\" if filter\n\n response = rest_get(url)\n\n Azure::Armrest::ArmrestCollection.create_from_response(\n response,\n Azure::Armrest::Insights::MetricDefinition\n )\n end",
"def describe_all_instances\n @os_aws.describe_all_instances\n end",
"def all_counters\n @counters.values\n end",
"def stats\n with { |c| c.stats }\n end",
"def metrics(*fields)\n @metrics ||= ListParameter.new(:metrics, [])\n @metrics << fields\n end",
"def index\n @measurements = Measurement.all\n end",
"def index\n @measurements = Measurement.all\n end",
"def index\n @measurements = Measurement.all\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def all_statistics\n super\n end",
"def list_all_metric_values_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.list_all_metric_values ...'\n end\n allowable_values = [\"asn\", \"asset_id\", \"browser\", \"browser_version\", \"cdn\", \"continent_code\", \"country\", \"custom_1\", \"custom_2\", \"custom_3\", \"custom_4\", \"custom_5\", \"custom_6\", \"custom_7\", \"custom_8\", \"custom_9\", \"custom_10\", \"exit_before_video_start\", \"experiment_name\", \"live_stream_id\", \"operating_system\", \"operating_system_version\", \"playback_id\", \"player_autoplay\", \"player_error_code\", \"player_mux_plugin_name\", \"player_mux_plugin_version\", \"player_name\", \"player_preload\", \"player_remote_played\", \"player_software\", \"player_software_version\", \"player_version\", \"preroll_ad_asset_hostname\", \"preroll_ad_tag_hostname\", \"preroll_played\", \"preroll_requested\", \"region\", \"source_hostname\", \"source_type\", \"stream_type\", \"sub_property_id\", \"video_encoding_variant\", \"video_id\", \"video_series\", \"video_title\", \"view_drm_type\", \"view_has_ad\", \"view_session_id\", \"viewer_connection_type\", \"viewer_device_category\", \"viewer_device_manufacturer\", \"viewer_device_model\", \"viewer_device_name\", \"viewer_user_id\"]\n if @api_client.config.client_side_validation && opts[:'dimension'] && !allowable_values.include?(opts[:'dimension'])\n fail ArgumentError, \"invalid value for \\\"dimension\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/data/v1/metrics/comparison'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'timeframe[]'] = @api_client.build_collection_param(opts[:'timeframe'], :multi) if !opts[:'timeframe'].nil?\n query_params[:'filters[]'] = @api_client.build_collection_param(opts[:'filters'], :multi) if !opts[:'filters'].nil?\n query_params[:'dimension'] = opts[:'dimension'] if !opts[:'dimension'].nil?\n query_params[:'value'] = opts[:'value'] if !opts[:'value'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ListAllMetricValuesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"MetricsApi.list_all_metric_values\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MetricsApi#list_all_metric_values\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def getClusterMetrics\n @admin.getClusterMetrics\n end",
"def list\n owner.json_api_command('sensor', nil, '-l')&.fetch(:sensors)\n end",
"def index\n @pursuit_metrics = PursuitMetric.all\n end",
"def index\n @emergencies = Emergency.all\n end",
"def index\n @devices = Device.all\n end",
"def index\n @devices = Device.all\n end",
"def index\n @devices = Device.all\n end",
"def index\n @devices = Device.all\n end",
"def index\n @devices = Device.all\n end",
"def describe methods=nil\n methods ||= %i[count mean std min max]\n description = methods.map { |m| send(m) }\n Daru::Vector.new(description, index: methods, name: :statistics)\n end"
] | [
"0.78932357",
"0.7837211",
"0.6679147",
"0.6605859",
"0.639798",
"0.6339336",
"0.62915057",
"0.62335235",
"0.6220586",
"0.61459005",
"0.61459005",
"0.6113629",
"0.603261",
"0.60318696",
"0.5982686",
"0.5971572",
"0.5931032",
"0.586969",
"0.58605045",
"0.58431226",
"0.57919186",
"0.5761516",
"0.5732272",
"0.57278436",
"0.57154745",
"0.5695667",
"0.5669819",
"0.56078744",
"0.5605962",
"0.55902636",
"0.5585636",
"0.5571831",
"0.5571831",
"0.5568709",
"0.5554833",
"0.55400944",
"0.5524842",
"0.5522631",
"0.55177414",
"0.5483861",
"0.546465",
"0.5442876",
"0.54268855",
"0.5423957",
"0.54200935",
"0.5408031",
"0.54077977",
"0.5354816",
"0.5340248",
"0.53386945",
"0.53356266",
"0.5328878",
"0.5324969",
"0.53195155",
"0.5315379",
"0.5306737",
"0.5303898",
"0.5303383",
"0.52973235",
"0.5294403",
"0.52908707",
"0.52742654",
"0.5240567",
"0.5223574",
"0.5223471",
"0.521947",
"0.5213632",
"0.5201505",
"0.5184113",
"0.5182773",
"0.5178425",
"0.5173647",
"0.51704",
"0.5168404",
"0.5164685",
"0.5164685",
"0.5164685",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.5154837",
"0.51515186",
"0.5150951",
"0.5129513",
"0.5122269",
"0.51030606",
"0.5088186",
"0.5088186",
"0.5088186",
"0.5088186",
"0.5088186",
"0.5085715"
] | 0.66986626 | 2 |
Get a Metric Descriptors. | def get(metric_type)
data = service.get_metric_descriptor(metric_type).to_h
new(data)
rescue ::Google::Apis::ClientError => e
raise e unless e.status_code == 404
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(options = {})\n data = service.list_metric_descriptors(options).body['metrics'] || []\n load(data)\n end",
"def get_metrics\n {\n method: \"Performance.getMetrics\"\n }\n end",
"def all(options = {})\n data = service.list_metric_descriptors(options).body[\"metricDescriptors\"] || []\n load(data)\n end",
"def metrics\n with_stats_lock do\n @stats_hash.keys.map { |spec| spec.to_s }\n end\n end",
"def metrics\n manager_instance(MetricManager)\n end",
"def histograms\n metrics(Histogram)\n end",
"def counters\n metrics(Counter)\n end",
"def metric_devices\n return @metric_devices\n end",
"def get(id)\n Hawkular::Metrics::MetricDefinition::new(@client.http_get(\"/#{@resource}/#{id}\"))\n end",
"def get_all_metrics()\n return nil unless Config.metrics\n f = Fiber.current\n resp = metrics.find().defer_as_a\n resp.callback do |doc|\n f.resume doc\n end\n resp.errback do |err|\n raise *err\n end\n docs = Fiber.yield\n # convert ids to int\n docs.collect{|doc| doc['_id'] = doc['_id'].to_i ; doc }\n end",
"def metrics\n @metrics ||= collect_metrics\n end",
"def meters \n metrics(Meter)\n end",
"def metric_names\n @metrics.keys\n end",
"def get_metrics_list\n\t\turi = \"#{@base_url}/data\"\n\t\tresults = json_metrics_list uri\n\t\tlist = []\n\t\tresults[:hosts][0..@hosts_limit].each {|h|\n\t\t\thost_results = json_metrics_list \"#{uri}/#{h}/\"\n\t\t\tlist << host_results[:metrics].map{|r| \"#{h}/#{r}\"}\n\t\t}\n\t\treturn list.flatten\n\tend",
"def metrics\n standard.unit.convert_to_metric imperials\n end",
"def metrics\n @metrics ||= []\n end",
"def metrics\n report[\"columnHeader\"][\"metricHeader\"][\"metricHeaderEntries\"].map { |metric| metric[\"name\"] }\n end",
"def get_metrics_list\n\t\ttest_file\n\t\t[@metric]\n end",
"def get_metric_statistics(options={})\n # Period (60 sec by default)\n period = (options[:period] && options[:period].to_i) || 60\n # Statistics ('Average' by default)\n statistics = Array(options[:statistics]).flatten\n statistics = statistics.blank? ? ['Average'] : statistics.map{|statistic| statistic.to_s.capitalize }\n # Times (5.min.ago up to now by default)\n start_time = options[:start_time] || (Time.now.utc - 5*60)\n start_time = start_time.utc.strftime(\"%Y-%m-%dT%H:%M:%S+00:00\") if start_time.is_a?(Time)\n end_time = options[:end_time] || Time.now.utc\n end_time = end_time.utc.strftime(\"%Y-%m-%dT%H:%M:%S+00:00\") if end_time.is_a?(Time)\n # Measure name\n measure_name = options[:measure_name] || 'CPUUtilization'\n # Dimentions (a hash, empty by default)\n dimentions = options[:dimentions] || {}\n #\n request_hash = { 'Period' => period,\n 'StartTime' => start_time,\n 'EndTime' => end_time,\n 'MeasureName' => measure_name }\n request_hash['Unit'] = options[:unit] if options[:unit]\n request_hash['CustomUnit'] = options[:custom_unit] if options[:custom_unit]\n request_hash['Namespace'] = options[:namespace] if options[:namespace]\n request_hash.merge!(amazonize_list('Statistics.member', statistics))\n # dimentions\n dim = []\n dimentions.each do |key, values|\n Array(values).each { |value| dim << [key, value] }\n end\n request_hash.merge!(amazonize_list(['Dimensions.member.?.Name', 'Dimensions.member.?.Value'], dim))\n #\n link = generate_request(\"GetMetricStatistics\", request_hash)\n request_info(link, GetMetricStatisticsParser.new(:logger => @logger))\n end",
"def query(tags)\n tags = tags.map do |k,v|\n \"#{k}:#{v}\"\n end\n @client.http_get(\"/metrics/?type=#{@type}&tags=#{tags.join(',')}\").map do |g|\n Hawkular::Metrics::MetricDefinition::new(g)\n end\n end",
"def get_metric_statistics (measure_name, stats, start_time, end_time, unit, options={})\n\n period = options[:period] || 60\n dimensions = options[:dimensions] || nil\n custom_unit = options[:custom_unit] || nil\n namespace = options[:namespace] || \"AWS/EC2\"\n\n params = {}\n params['MeasureName'] = measure_name\n i =1\n stats.each do |s|\n params['Statistics.member.'+i.to_s] = s\n i = i+1\n end\n params['Period'] = period\n if (dimensions != nil)\n i = 1\n dimensions.each do |k, v|\n params['Dimensions.member.'+i.to_s+\".Name.\"+i.to_s] = k\n params['Dimensions.member.'+i.to_s+\".Value.\"+i.to_s] = v\n i = i+1\n end\n end\n params['StartTime'] = start_time\n params['EndTime'] = end_time\n params['Unit'] = unit\n #params['CustomUnit'] = customUnit always nil\n params['Namespace'] = namespace\n\n link = generate_request(\"GetMetricStatistics\", params)\n resp = request_info(link, QMonGetMetricStatistics.new(:logger => @logger))\n\n rescue Exception\n on_exception\n end",
"def all(filter: nil, page_size: nil, page_token: nil)\n data = service.list_metric_descriptors(\n :filter => filter,\n :page_size => page_size,\n :page_token => page_token\n ).to_h[:metric_descriptors] || []\n\n load(data)\n end",
"def measures\n @dimensions.describe\n end",
"def summary_metrics\n []\n end",
"def get_metric_statistics ( options ={} )\n options = { :custom_unit => nil,\n :dimensions => nil,\n :end_time => Time.now(), #req\n :measure_name => \"\", #req\n :namespace => \"AWS/EC2\",\n :period => 60,\n :statistics => \"\", # req\n :start_time => (Time.now() - 86400), # Default to yesterday\n :unit => \"\" }.merge(options)\n\n raise ArgumentError, \":end_time must be provided\" if options[:end_time].nil?\n raise ArgumentError, \":end_time must be a Time object\" if options[:end_time].class != Time\n raise ArgumentError, \":start_time must be provided\" if options[:start_time].nil?\n raise ArgumentError, \":start_time must be a Time object\" if options[:start_time].class != Time\n raise ArgumentError, \":start_time must be before :end_time\" if options[:start_time] > options[:end_time]\n raise ArgumentError, \":measure_name must be provided\" if options[:measure_name].nil? || options[:measure_name].empty?\n raise ArgumentError, \":statistics must be provided\" if options[:statistics].nil? || options[:statistics].empty?\n\n params = {\n \"CustomUnit\" => options[:custom_unit],\n \"EndTime\" => options[:end_time].iso8601,\n \"MeasureName\" => options[:measure_name],\n \"Namespace\" => options[:namespace],\n \"Period\" => options[:period].to_s,\n \"StartTime\" => options[:start_time].iso8601,\n \"Unit\" => options[:unit]\n }\n\n # FDT: Fix statistics and dimensions values\n if !(options[:statistics].nil? || options[:statistics].empty?)\n stats_params = {}\n i = 1\n options[:statistics].split(',').each{ |stat|\n stats_params.merge!( \"Statistics.member.#{i}\" => \"#{stat}\" )\n i += 1\n }\n params.merge!( stats_params )\n end\n\n if !(options[:dimensions].nil? || options[:dimensions].empty?)\n dims_params = {}\n i = 1\n options[:dimensions].split(',').each{ |dimension|\n dimension_var = dimension.split('=')\n dims_params = dims_params.merge!( \"Dimensions.member.#{i}.Name\" => \"#{dimension_var[0]}\", \"Dimensions.member.#{i}.Value\" => \"#{dimension_var[1]}\" )\n i += 1\n }\n params.merge!( dims_params )\n end\n\n return response_generator(:action => 'GetMetricStatistics', :params => params)\n\n end",
"def metric(*names)\n metrics = names.map do |name|\n id = name.to_s.downcase.gsub(/\\W+/, '_').to_sym\n Vanity.playground.metrics[id] ||= Vanity::Metric.new(Vanity.playground, name)\n end\n names.size == 1 ? metrics.first : metrics\n end",
"def metrics_with_methods\n {metrics: @metrics, methods: @methods}\n end",
"def metrics_with_methods\n {metrics: @metrics, methods: @methods}\n end",
"def metrics\n # NOTE: There is one entry in the `row[\"metrics\"]` array for each date range.\n # Since currently we only support one date range, this following index is\n # always 0.\n row[\"metrics\"][0][\"values\"]\n end",
"def metrics_for_metric_name\n @metrics = Metric.includes(:metric_name).where(metric_name_id: metric_name_id[:id]);\n render json: @metrics.order({created_at: :asc}),include: [:metric_name], status: :ok\n end",
"def [](key)\n @metrics[key]\n end",
"def list_metrics\n define_type_on_metric_def_if_needed\n\n gauges = Hawk.metrics.gauges.query\n gauges.each { |g| g.type = 'GAUGE' }\n counters = Hawk.metrics.counters.query\n counters.each { |c| c.type = 'COUNTER' }\n strings = Hawk.metrics.strings.query\n strings.each { |c| c.type = 'STRING' }\n\n tree_root = build(::HTreeItem)\n tree_root.kind = :none\n tree_root.value = 'Metrics'\n metrics = gauges.concat counters\n metrics = metrics.concat strings\n\n ascend_sort = ->(m1, m2) { m1.id <=> m2.id }\n metrics.sort(&ascend_sort).each do |metric_def|\n icon = ::HawkHelper.metric_icon metric_def.type\n iv = ::HawkHelper.create_icon icon\n\n new_metric = build(::HTreeItem)\n new_metric.kind = :metric\n new_metric.value = metric_def.id\n new_metric.graphic = iv\n\n # Create a Metric type of Inventory\n # from the metric dev obtained from H-Metrics\n m_hash = {\n 'name' => metric_def.id,\n 'id' => metric_def.id,\n 'type' => { 'type' => metric_def.json['type'].upcase },\n # :unit => metric_def.unit\n }\n mt = create_metric_type_from_metric_def(metric_def)\n m = ::Hawkular::Inventory::Metric.new m_hash, mt\n\n new_metric.raw_item = m\n\n tree_root.children.add new_metric\n end\n # bind to the view from fxml\n @FXMLtreeView.setRoot(tree_root)\n tree_root.expanded = true\n end",
"def convert_metric_descriptor view, metric_prefix\n descriptor = Google::Api::MetricDescriptor.new(\n type: make_metric_type(metric_prefix, view.name),\n display_name: view.measure.name,\n metric_kind: convert_metric_kind(view.aggregation),\n value_type: convert_metric_value_type(view),\n unit: view.measure.unit,\n labels: convert_labels(view.columns)\n )\n\n descriptor.description = view.description if view.description\n descriptor\n end",
"def index\n @metrics = Metric.all\n end",
"def list_measures\n exec_req_and_parse_response \"/measure/list\"\n end",
"def metric(metric_id)\n from_resource :metric,\n connection.get(api_uri(\"metrics/#{metric_id}\"))\n end",
"def supported_metrics\n supported_metrics = Set.new\n self.trackers.all.each do |tracker|\n metrics = tracker.tracker_type.data_type\n metrics.each do |metric|\n supported_metrics.add?(metric)\n end\n end\n return supported_metrics\n end",
"def timers\n metrics(Timer)\n end",
"def collect(metrics)\n metrics\n end",
"def collect_metrics\n\n # Build a set of matchers to match the paths we need to find metrics\n # for.\n path_matchers = []\n @paths.each do |path|\n path_matchers << { :path => matcher_for_path(path) }\n end\n\n # Figure out what metric model to use (Metric or one of the average\n # models).\n metric_model = metric_model_for_timespan\n\n # Build a query to locate the metrics.\n query = metric_model.where(:$or => path_matchers)\n query = query.where(:node_id => @node_id)\n query = query.where(:timestamp.gte => @from)\n query = query.where(:timestamp.lte => @to)\n query = query.sort(:timestamp.asc)\n metrics = query.all\n\n # Return a data set based on the collection of metrics.\n data_set_for_metrics(metrics)\n\n end",
"def resourceType\n 'DeviceMetric'\n end",
"def metrics(*fields)\n @metrics ||= ListParameter.new(:metrics, [])\n @metrics << fields\n end",
"def counter_metric_names\n counters.map { |op| op.first }\n end",
"def metrics(data)\n results = Crack::XML.parse(perform('/stats', :data => data))['scores']\n return if results.nil? # we have no stats about our data\n AfterTheDeadline::Metrics.new results['metric']\n end",
"def scorable_metrics\n Card.search(type_id: Card::MetricID,\n right_plus: [\"*metric type\",\n content: scorable_metric_type_content.unshift(\"in\")],\n sort: \"name\",\n return: :name).sort\n end",
"def all_metrics\n valid_configs = MetricSample.all.where(:project_id => id)\n return [] if valid_configs.nil?\n metrics_name_ary = []\n valid_configs.each do |config|\n metrics_name_ary << config.metric_name\n end\n metrics_name_ary.uniq\n end",
"def list_definitions(resource, filter = nil)\n resource_id = resource.respond_to?(:id) ? resource.id : resource\n version = configuration.provider_default_api_version(provider, 'metricDefinitions')\n\n url = File.join(\n configuration.environment.resource_url,\n resource_id,\n 'providers/microsoft.insights/metricdefinitions'\n )\n\n url << \"?api-version=#{version}\"\n url << \"&$filter=#{filter}\" if filter\n\n response = rest_get(url)\n\n Azure::Armrest::ArmrestCollection.create_from_response(\n response,\n Azure::Armrest::Insights::MetricDefinition\n )\n end",
"def metrics(*args)\n @metrics = args.map { |id| @playground.metric(id) } unless args.empty?\n @metrics\n end",
"def get_metric(key)\n metrics[key] || meta[key]\n end",
"def gauges\n metrics(Gauge)\n end",
"def metric_values\n return @metric_values\n end",
"def names\n @metrics.keys.dup.freeze\n end",
"def get_metrics(path, query={}, headers={})\n url = Client::make_url(URI_TEMPLATE, {:path=>path} )\n response = get( url, query, headers )\n if block_given?\n yield response\n end\n validate_response(url, query, response) \n return JSON.parse( response.content ) \n end",
"def get_capability_adapter_unit_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_adapter_unit_descriptor_list_with_http_info(opts)\n data\n end",
"def all(options = {})\n data = service.list_monitored_resource_descriptors(options).body[\"resourceDescriptors\"] || []\n load(data)\n end",
"def get_metric_statistics(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'GetMetricStatistics'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :interval\n\t\t\targs[:query]['Interval'] = optional[:interval]\n\t\tend\n\t\tif optional.key? :length\n\t\t\targs[:query]['Length'] = optional[:length]\n\t\tend\n\t\tif optional.key? :metric_name\n\t\t\targs[:query]['MetricName'] = optional[:metric_name]\n\t\tend\n\t\tif optional.key? :namespace\n\t\t\targs[:query]['Namespace'] = optional[:namespace]\n\t\tend\n\t\tif optional.key? :next_token\n\t\t\targs[:query]['NextToken'] = optional[:next_token]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def get_metrics_hash(messages)\n metrics = []\n messages.each do |m|\n metric = m['metrics']\n if metric != nil\n metric.each do |name, value|\n\t\t metrics[name] = value\n\t end\n end\n end\n return metrics\n end",
"def get_metrics_hash(messages)\n metrics = []\n messages.each do |m|\n metric = m['metrics']\n if metric != nil\n metric.each do |name, value|\n\t\t metrics[name] = value\n\t end\n end\n end\n return metrics\n end",
"def metrics(time)\n ms = {}\n histos = ScoutApm::Agent.instance.request_histograms_by_time[time]\n histos.each_name do |name|\n percentiles.each do |percentile|\n meta = MetricMeta.new(\"Percentile/#{percentile}/#{name}\")\n stat = MetricStats.new\n stat.update!(histos.quantile(name, percentile))\n ms[meta] = stat\n end\n end\n\n # Wipe the histograms we just collected data on\n ScoutApm::Agent.instance.request_histograms_by_time.delete(time)\n\n ms\n end",
"def metric\n provider.find_metric(metric_key)\n end",
"def collect_metrics(*)\n raise NotImplementedError, 'Must implement collect_metrics'\n end",
"def all_metrics\n output = `cube_info #{@fname} -l`\n output.split(\"\\n\")\n end",
"def metrics_by_category metrics\n # Converts Dactylogram metric format\n # {\"FleschKincaidService::grade_level\"=>-4.029999999999999, \"FleschKincaidService::age_minimum\"=>\"\", \"FleschKincaidService::reading_ease\"=>121.22000000000003}\n # to categorized-by-service format to pass to view\n # {\"FleschKincaidService\"=>[{\"grade_level\"=>-4.029999999999999}, {\"age_minimum\"=>\"\"}, {\"reading_ease\"=>121.22000000000003}]}\n categorized_metrics = {}\n\n metrics.each do |key, value|\n category, method = key.split '::'\n\n categorized_metrics[category] ||= []\n categorized_metrics[category] << { method => value }\n end\n\n categorized_metrics\n end",
"def additional_metrics\n []\n end",
"def getClusterMetrics\n @admin.getClusterMetrics\n end",
"def metric_desc\n \"#{config[:metric_name]} for #{config[:efs_name]}\"\n end",
"def descriptors(arg = nil)\n if arg.nil?\n storage.map { |_, (descriptor, _)| descriptor }\n else\n with_interest(arg).map { |_, descriptor, _| descriptor }\n end\n end",
"def metrics\n @metrics ||= parent_klass.metrics.dup\n end",
"def timer_metric_names\n timers.map { |op| op.first }\n end",
"def usage_measures\n request = get '/1/reporting/measures'\n convert_to_mashes request\n end",
"def get_metrics metrics, since\n # compute the length of the interval between the last time\n # this monitor ran and now\n last_report_timestamp = accumulators.get(report_timestamp_key).to_i\n now = Time.now.to_i\n interval = now - last_report_timestamp\n\n accumulators.keys.each do |target|\n next if target == report_timestamp_key\n next unless regexp && regexp =~ target\n current_count = accumulators.getset(target, 0) rescue 0.0\n\n # if we don't know when the last time we ran was, we bail,\n # resetting the accumulated count to 0 in preparation for\n # the next iteration\n #\n # we lost a data point this way (say the monitor went down\n # for a while and we brought it back up) but we also don't\n # ruin the scale of the graph...\n next if last_report_timestamp == 0\n \n rate = current_count.to_f / interval.to_f rescue 0.0\n metrics << [target, rate] # no need to scope as targets are pre-scoped\n end\n\n # store the timestamp for this run for the next\n accumulators.set(report_timestamp_key, now)\n end",
"def describe methods=nil\n methods ||= %i[count mean std min max]\n description = methods.map { |m| send(m) }\n Daru::Vector.new(description, index: methods, name: :statistics)\n end",
"def list(provider, resource_type, resource_name, resource_group = nil, options = {})\n resource_group ||= configuration.resource_group\n\n raise ArgumentError, \"no resource group provided\" unless resource_group\n\n url = build_url(provider, resource_type, resource_name, resource_group, options)\n\n response = rest_get(url)\n\n Azure::Armrest::ArmrestCollection.create_from_response(\n response,\n Azure::Armrest::Insights::MetricDefinition\n )\n end",
"def get_metrics_for(app_id)\n return nil unless Config.metrics\n f = Fiber.current\n resp = metrics.find_one('_id' => app_id)\n resp.callback do |doc|\n f.resume doc\n end\n resp.errback do |err|\n raise *err\n end\n doc = Fiber.yield\n # convert id to int\n doc['_id'] = doc['_id'].to_i unless doc.nil?\n doc\n end",
"def get_firmware_mswitch_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_mswitch_descriptor_list_with_http_info(opts)\n data\n end",
"def get_capability_switch_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_switch_descriptor_list_with_http_info(opts)\n data\n end",
"def gauge_metrics(metrics, params = { :ago => DEFAULT_RANGE })\n metrics_request_string = metrics.join(',')\n metrics_json = query_api(metrics_request_string, params)\n\n metrics.map { |metric_name| metrics_json[metric_name] }\n end",
"def get_firmware_cimc_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_cimc_descriptor_list_with_http_info(opts)\n data\n end",
"def instance_metrics\n metrics = Dir.glob(\"tmp/drb-process-metrics-*.sock\").map do |filename|\n application_metrics = DRbObject.new_with_uri(\"drbunix:#{filename}\")\n application_metrics.update_process_metrics\n rescue IOError, DRb::DRbConnError\n # XXX Ignore any errors we may receive when fetching metrics from a remote process that has shut down (usually by the Puma worker killer)\n Danbooru::Metric::Set.new\n end\n\n metrics.reduce(&:merge) || Danbooru::Metric::Set.new\n end",
"def convert_metric(i)\n case report.metric_type(i)\n when \"INTEGER\"\n # INTEGER Integer metric.\n metrics[i].to_i\n when \"FLOAT\", \"PERCENT\"\n # FLOAT Float metric.\n # PERCENT Percentage metric.\n metrics[i].to_f\n when \"CURRENCY\"\n # CURRENCY Currency metric.\n # TODO: Do this better.\n metrics[i].to_f\n when \"TIME\"\n # Google documentation claims to following:\n # TIME Time metric in HH:MM:SS format.\n # It also says it's seconds, and that's what I see in real results.\n # So comment out the following:\n # (metrics[i][0..1].to_i +\n # metrics[i][3..4].to_i * 60 +\n # metrics[i][6..7].to_i * 24 * 60)\n # Simply make it a float.\n metrics[i].to_f\n else\n # METRIC_TYPE_UNSPECIFIED Metric type is unspecified.\n metric[i]\n end\n end",
"def collect_metrics(data: {}, labels: {})\n metric(:pool_jobs_waiting_total)&.observe(data['pool_jobs_waiting_total'].to_i, labels)\n metric(:pool_ready_workers_total)&.observe(data['pool_ready_workers_total'].to_i, labels)\n metric(:pool_workers_total)&.observe(data['pool_workers_total'].to_i, labels)\n metric(:pool_initial_size)&.observe(data['pool_initial_size'].to_i, labels)\n metric(:poll_period)&.observe(data['poll_period'].to_i, labels)\n metric(:thread_pool_exhausted)&.observe(data['thread_pool_exhausted'].to_i, labels)\n end",
"def metric_with_unit(unit)\n metrics.select {|m| Unit.new(m) <=> Unit.new(unit)}\n end",
"def metric name\n ensure_connection!\n resp = connection.get_metric name\n return Metric.from_gapi(resp.data, connection) if resp.success?\n return nil if resp.status == 404\n fail ApiError.from_response(resp)\n end",
"def find_metric(name)\n @metrics.detect{|m| m.name == name }\n end",
"def metric(name = :mandatory, *opts)\n raise OEDLMissingArgumentException.new(:metric, :name) if name == :mandatory\n\n \t # For each of the metrics...\n \t opts.each do |parameter|\n # Get its detail from the application definition\n #appDef = AppDefinition[@application.to_s]\n appDef = @application.appDefinition\n \t measurementDef = appDef.measurements[@mdef]\n \t metricDef = measurementDef.metrics[parameter]\n # Set the default filter based on the metric type\n \t if metricDef[:type] == \"xsd:float\" || metricDef[:type] == \"xsd:int\" \\\n || metricDef[:type] == \"xsd:long\" || metricDef[:type] == \"xsd:short\"\n filterType = 'avg'\n \t else\n filterType = 'first'\n \t end\n # Build and Add the metric to this Measurement Stream\n filter = OMF::EC::OML::Filter.new(filterType, \"#{name}_#{parameter}\", {:input => parameter})\n \t @filters << filter\n \t end\n end",
"def describe_metric(metric, period, project, start_time, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'DescribeMetric'\n\t\targs[:query]['Metric'] = metric\n\t\targs[:query]['Period'] = period\n\t\targs[:query]['Project'] = project\n\t\targs[:query]['StartTime'] = start_time\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def metrics\n @metrics ||= Mongo.collection(\"slanger.metrics.data\")\n end",
"def get_vulnerability_metrics(opts = {})\n data, _status_code, _headers = get_vulnerability_metrics_with_http_info(opts)\n data\n end",
"def to_metric\n Metric.new(\n Instrumentation.series,\n {\n duration: real_time.in_milliseconds.to_i,\n cpu_duration: cpu_time.in_milliseconds.to_i,\n call_count: call_count\n },\n method: @name\n )\n end",
"def get_firmware_dimm_descriptor_list(opts = {})\n data, _status_code, _headers = get_firmware_dimm_descriptor_list_with_http_info(opts)\n data\n end",
"def cost_measures\n response = get '/1/reporting/cost/measures'\n convert_to_mashes response\n end",
"def headers\n dimensions + metrics\n end",
"def get_capability_cimc_firmware_descriptor_list(opts = {})\n data, _status_code, _headers = get_capability_cimc_firmware_descriptor_list_with_http_info(opts)\n data\n end",
"def get_metrics metric\n\turi = URI.parse(\"http://#{@HOST}:#{@METR}/metrics\")\n\tresponse = Net::HTTP.get_response(uri)\n\tresult = -9\n\tresponse.body.each_line do |m|\n\t\tif not m[0].include? \"#\" and m.include? metric\n\t\t\tresult = m.split(\" \").last.to_f.to_i\n\t\tend\n\tend\n\tresult\nend",
"def to_a\n dimensions + metrics\n end",
"def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end",
"def list_all_metric_values_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.list_all_metric_values ...'\n end\n allowable_values = [\"asn\", \"asset_id\", \"browser\", \"browser_version\", \"cdn\", \"continent_code\", \"country\", \"custom_1\", \"custom_2\", \"custom_3\", \"custom_4\", \"custom_5\", \"custom_6\", \"custom_7\", \"custom_8\", \"custom_9\", \"custom_10\", \"exit_before_video_start\", \"experiment_name\", \"live_stream_id\", \"operating_system\", \"operating_system_version\", \"playback_id\", \"player_autoplay\", \"player_error_code\", \"player_mux_plugin_name\", \"player_mux_plugin_version\", \"player_name\", \"player_preload\", \"player_remote_played\", \"player_software\", \"player_software_version\", \"player_version\", \"preroll_ad_asset_hostname\", \"preroll_ad_tag_hostname\", \"preroll_played\", \"preroll_requested\", \"region\", \"source_hostname\", \"source_type\", \"stream_type\", \"sub_property_id\", \"video_encoding_variant\", \"video_id\", \"video_series\", \"video_title\", \"view_drm_type\", \"view_has_ad\", \"view_session_id\", \"viewer_connection_type\", \"viewer_device_category\", \"viewer_device_manufacturer\", \"viewer_device_model\", \"viewer_device_name\", \"viewer_user_id\"]\n if @api_client.config.client_side_validation && opts[:'dimension'] && !allowable_values.include?(opts[:'dimension'])\n fail ArgumentError, \"invalid value for \\\"dimension\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/data/v1/metrics/comparison'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'timeframe[]'] = @api_client.build_collection_param(opts[:'timeframe'], :multi) if !opts[:'timeframe'].nil?\n query_params[:'filters[]'] = @api_client.build_collection_param(opts[:'filters'], :multi) if !opts[:'filters'].nil?\n query_params[:'dimension'] = opts[:'dimension'] if !opts[:'dimension'].nil?\n query_params[:'value'] = opts[:'value'] if !opts[:'value'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'ListAllMetricValuesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"MetricsApi.list_all_metric_values\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MetricsApi#list_all_metric_values\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def build_metrics\n {}\n end",
"def [](collector_name)\n CollectorRegistry.lookup(collector_name)\n end",
"def descriptors( &block )\n\t\t\tif @log_file && @message_descriptors.empty?\n\t\t\t\tif @descriptor_cache && @descriptor_cache.exist?\n\t\t\t\t\t@message_descriptors = @descriptor_cache.read_descriptors\n\t\t\t\telse\n\t\t\t\t\t@message_descriptors = LogFile::read_descriptors( @log_file, @descriptor_cache, &block )\n\t\t\t\tend\n\n\t\t\t\t@message_descriptors[ FORMAT_MESSAGE.type ] = FORMAT_MESSAGE\n\t\t\tend\n\n\t\t\treturn @message_descriptors\n\t\tend"
] | [
"0.6498434",
"0.64717406",
"0.64246106",
"0.61260754",
"0.61247015",
"0.59966314",
"0.59639174",
"0.5959368",
"0.5916593",
"0.5909137",
"0.58886355",
"0.58862513",
"0.587014",
"0.5859049",
"0.58295923",
"0.5827986",
"0.579407",
"0.5791534",
"0.5762079",
"0.56138515",
"0.5602903",
"0.5510895",
"0.5500077",
"0.5446092",
"0.54431385",
"0.5442918",
"0.54090893",
"0.54090893",
"0.54052216",
"0.5376664",
"0.5369188",
"0.5367018",
"0.53506374",
"0.53501403",
"0.5348683",
"0.5336271",
"0.5326937",
"0.5325339",
"0.53137565",
"0.52704203",
"0.5268851",
"0.5251279",
"0.52432895",
"0.52340823",
"0.52138984",
"0.5191745",
"0.5170219",
"0.516623",
"0.5160591",
"0.51518476",
"0.5111759",
"0.51016366",
"0.5097163",
"0.5068407",
"0.5060671",
"0.50562924",
"0.50534815",
"0.50534815",
"0.5046043",
"0.5043399",
"0.5037762",
"0.50294393",
"0.5024378",
"0.5023552",
"0.50071883",
"0.49984202",
"0.49685898",
"0.49661678",
"0.4963108",
"0.49535757",
"0.49475428",
"0.49449417",
"0.4940152",
"0.49300802",
"0.49268147",
"0.4926456",
"0.4920495",
"0.4903108",
"0.48846996",
"0.48802516",
"0.486874",
"0.48667356",
"0.48663184",
"0.48640257",
"0.48419434",
"0.48411638",
"0.4840544",
"0.4837707",
"0.48307556",
"0.48305064",
"0.482096",
"0.48133427",
"0.48125014",
"0.48055837",
"0.4803471",
"0.4795214",
"0.4786824",
"0.47863987",
"0.47827125",
"0.47707173"
] | 0.5752902 | 19 |
Encodes a request msg | def encoderequest(sender, target, msg, requestid, filter={})
serialized = Marshal.dump(msg)
digest = makehash(serialized)
@log.debug("Encoding a request for '#{target}' with request id #{requestid}")
request = {:body => serialized,
:hash => digest,
:senderid => @config.identity,
:requestid => requestid,
:msgtarget => target,
:filter => filter,
:msgtime => Time.now.to_i}
# if we're in use by a client add the callerid to the main client hashes
request[:callerid] = callerid if @initiated_by == :client
Marshal.dump(request)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(msg)\n proc.call msg\n end",
"def encode_body\n body = ''\n body += encode_bits(@connack_flags)\n body += encode_bytes(@return_code.to_i)\n body\n end",
"def encoderequest(sender, target, msg, requestid, filter={})\n @log.debug(\"Encoding a request for '#{target}' with request id #{requestid}\")\n request = {:body => msg,\n :senderid => @config.identity,\n :requestid => requestid,\n :msgtarget => target,\n :filter => filter,\n :msgtime => Time.now.to_i}\n\n # if we're in use by a client add the callerid to the main client hashes\n request[:callerid] = callerid if @initiated_by == :client\n\n YAML.dump(request)\n end",
"def send_request_string( request_name, data, want_reply=false )\n msg = @buffers.writer\n msg.write_string data.to_s\n send_request request_name, msg, want_reply\n end",
"def encoderequest(sender, msg, requestid, filter, target_agent, target_collective, ttl=60)\n req = create_request(requestid, filter, \"\", @initiated_by, target_agent, target_collective, ttl)\n\n ssl_msg = {:ssl_msg => msg,\n :ssl_ttl => ttl,\n :ssl_msgtime => req[:msgtime]}\n\n serialized = serialize(ssl_msg)\n digest = makehash(serialized)\n\n req[:hash] = digest\n req[:body] = serialized\n\n serialize(req)\n end",
"def encoderequest(sender, target, msg, requestid, filter={}, target_agent=nil, target_collective=nil)\n serialized = Marshal.dump(msg)\n digest = makehash(serialized)\n\n req = create_request(requestid, target, filter, serialized, @initiated_by, target_agent, target_collective)\n req[:hash] = digest\n\n Marshal.dump(req)\n end",
"def request(msg)\n print(msg)\n gets.chomp\n end",
"def send(request)\n # clear socket\n puts \"flushing socket\" if @debug\n @socket.flush\n\n puts \"sending request: #{request.inspect}\" if @debug\n response = ''\n @socket.puts request.bencode\n\n while r = @socket.recv(1024)\n response << r\n break if r.length < 1024\n end\n\n puts \"bencoded reply: #{response.inspect}\" if @debug\n response = response.bdecode\n\n puts \"bdecoded reply: #{response.inspect}\" if @debug\n response\n end",
"def encode_body(buffer)\n buffer << action.to_msgpack\n end",
"def send_request(type, msg, flags=NLM_F_REQUEST, sockaddr=SOCKADDR_DEFAULT, seq=next_seq, pid=@pid, vflags=0, controls=[])\n @socket.sendmsg(\n build_message(type, msg, flags, seq, pid),\n vflags, sockaddr, *controls\n )\n end",
"def raw_request_message(params)\n params[:api_id] = api_id\n params[:api_partialkey] = api_key.slice(0, 64)\n JSON.generate(params)\n end",
"def send_request(request)\n message = RemoteMessage.new(request_message: request).serialize_to_string\n message_size = [message.length].pack('N')\n @ssl_client.write(message_size + message)\n end",
"def send(request)\n # Translate path so that underscores are converted to minuses\n # Don't change the original input value\n request.path = request.path.gsub('_', '-')\n request.tag = 0\n data = request.serialize_to_string\n # An additional header is added to the request indicating the size of the request\n head = [data.length].pack(\"N\")\n logger.trace('Sending') {request.to_hash}\n @socket.write(head+data)\n end",
"def encode\n \"#{global_id}|#{message_id}|#{channel.gsub(\"|\", \"$$123$$\")}|#{data}\"\n end",
"def encode(msg)\n doc = REXML::Document.new\n doc << REXML::XMLDecl.default\n root = doc.add_element(\"fipa-message\", { \"act\" => msg.performative, \"conversation-id\" => msg.conversation_id })\n msg.receivers.each do |recv|\n el = root.add_element(\"receiver\")\n el.add_element(\"agent-identifier\")\n end\n el = root.add_element(\"sender\")\n el.add_element(\"agent-identifier\")\n root.add_element(\"content\", { \"href\" => nil })\n root.add_element(\"language\", { \"href\" => nil })\n root.add_element(\"encoding\", { \"href\" => nil })\n root.add_element(\"ontology\", { \"href\" => nil })\n root.add_element(\"protocol\", { \"href\" => nil })\n root.add_element(\"reply-with\", { \"href\" => nil })\n root.add_element(\"in-reply-to\", { \"href\" => nil })\n root.add_element(\"reply-by\", { \"time\" => nil, \"href\" => nil })\n el = root.add_element(\"reply-to\")\n msg.reply_to.each do |repl|\n el.add_element(\"agent-identifier\")\n end\n root.add_element(\"conversation-id\", { \"href\" => nil })\n root.add_element(\"user-defined\")\n doc.to_s\n end",
"def encode\r\n self.offset *= -1 if self.negate\r\n actual_offset = self.offset\r\n\r\n # We invert the offset used if we are trying to decode the message\r\n actual_offset *= -1 if self.mode == :decode\r\n\r\n msg = self.message.chars.map do |ch|\r\n case ch\r\n when \"A\"..\"Z\"\r\n idx = ALPHABET_UPPER.index(ch)\r\n ALPHABET_UPPER[(idx + actual_offset) % 26]\r\n when \"a\"..\"z\"\r\n idx = ALPHABET_LOWER.index(ch)\r\n ALPHABET_LOWER[(idx + actual_offset) % 26]\r\n when \"0\"..\"9\"\r\n idx = NUMBERS.index(ch)\r\n NUMBERS[(idx + actual_offset) % 10]\r\n else\r\n ch\r\n end\r\n end.join\r\n\r\n self.print <<~HEREDOC\r\n Message #{ self.mode == :decode ? \"decoded\" : \"encoded\" } with offset #{ self.offset }:\r\n\r\n #{ msg }\r\n HEREDOC\r\n end",
"def encode_body(buffer)\n buffer << prior_action_ids.to_msgpack\n end",
"def channel_request( type )\n writer = @buffers.writer\n writer.write_byte CHANNEL_REQUEST\n writer.write_long 0 # channel id\n writer.write_string type\n writer.write_byte 0 # want_confirm\n \n @session.send_message writer\n end",
"def encode_begin(real_payload, reqs)\n end",
"def encode_end(real_payload, reqs, encoded)\n encoded\n end",
"def encode_message(type, body)\n if type.is_a? Integer\n type_num = type\n elsif type.is_a? String\n type_num = type.ord\n else\n fail ArgumentError, 'type must be a String or Integer'\n end\n\n [UNFRAGMENTED_HEADER, type_num ].pack('NC') + body\n end",
"def format_request(payload); end",
"def format_request(payload); end",
"def encode_body\n if @return_codes.empty?\n raise 'no granted QoS given when serialising packet'\n end\n body = encode_short(@id)\n return_codes.each { |qos| body += encode_bytes(qos) }\n body\n end",
"def send_request(req); end",
"def send msg\n rencoded = REncode.dump([msg]).pack('C*')\n #rencoded = [193, 196, 1, 139, 100, 97, 101, 109, 111, 110, 46, 105, 110, 102, 111, 192, 102].pack('C*')\n compressed = Zlib::Deflate.deflate(rencoded)\n raw = compressed.bytes\n\n # all commented out stuff is for version 4, which we do not yet support\n # Store length as a signed integer (using 4 bytes), network byte order\n # header = [raw.length].pack('N').bytes\n\n #every message begins with an ASCII 'D'\n # header.insert(0, 'D'.ord)\n\n # header_str = header.pack('C*')\n message_str = raw.pack('C*')\n\n # puts \"Writing header:\"\n # p header_str.bytes\n # puts\n # puts \"Writing message:\"\n # p rencoded.bytes\n # puts\n\n\n # @con.write(header_str)\n @con.write(message_str)\n @con.flush\n\n nil\n end",
"def started_request_message(*args)\n \"\"\n end",
"def encode_body\n body = ''\n if @topic.nil? || @topic.to_s.empty?\n raise 'Invalid topic name when serialising packet'\n end\n body += encode_string(@topic)\n body += encode_short(@id) unless qos.zero?\n body += payload.to_s.dup.force_encoding('ASCII-8BIT')\n body\n end",
"def send(msg)\n @connection.write(\n @serializer.en(msg))\n rescue Exception => e\n raise\n end",
"def encode( msg )\r\n msg = msg.gsub(/[^A-Za-z]/, '').upcase\r\n msg += \"X\"*(5 - (msg.length % 5)) unless msg.length % 5 == 0\r\n\r\n msgNumbers = to_numbers( msg )\r\n cipherNumbers = to_numbers( generate_keystream( msg.length ) )\r\n\r\n resultNumbers = []\r\n msgNumbers.each_with_index do |item, index|\r\n temp = item + cipherNumbers[index]\r\n temp = temp - 26 if temp > 26\r\n resultNumbers << temp\r\n end\r\n\r\n return to_chars( resultNumbers )\r\n end",
"def marshallMsg\n msgstr = String.new(@istr) \n @@cmdSeqNo = @@cmdSeqNo + 1\n seqstr = to_s_i(@@cmdSeqNo)\n msgstr[0] = seqstr[0]\n msgstr[1] = seqstr[1]\n msgstr[2] = seqstr[2]\n msgstr[3] = seqstr[3]\n t = Time.now\n timestr = to_s_i(t.to_i)\n msgstr = msgstr + timestr \n msgstr[8] = @pktFormat\n msgstr[9] = 0\n msgstr[10] = @cmd\n msgstr[11] = 0\n ipstr = to_s_i(@myIp)\n msgstr = msgstr + ipstr \n msgstr = msgstr + @version\n msgstr[18] = @nodeType\n msgstr[19] = 0\n msgstr = msgstr + @cmStatus.to_s\n msgstr = msgstr + @mac11.to_s \n msgstr = msgstr + @mac12.to_s\n msgstr = msgstr + @mac13.to_s \n msgstr = msgstr + @mac14.to_s\n\n return msgstr\n end",
"def _send_message data\n response << data\n end",
"def send_data(msg)\n send_request RequestMessage.new(data_message: Data1.new(type: \"com.google.tv.string\", data: msg))\n end",
"def encode\n Logger.debug \"encoding #{self.inspect}\"\n class_mapper = RocketAMF::ClassMapper.new\n ser = RocketAMF::Serializer.new class_mapper\n\n if amf3?\n ser.stream << \"\\x00\"\n end\n\n ser.serialize 0, command\n ser.serialize 0, transaction_id\n\n if amf3?\n ser.stream << \"\\x05\"\n ser.stream << \"\\x11\"\n ser.serialize 3, values.first\n else\n values.each do |value|\n ser.serialize 0, value\n end\n end\n\n ser.stream\n end",
"def send_request\n request_wrapper = Protobuf::Socketrpc::Request.new\n request_wrapper.service_name = @options[:service].name\n request_wrapper.method_name = @options[:method].to_s\n \n if @options[:request].class == @options[:request_type]\n request_wrapper.request_proto = @options[:request].serialize_to_string\n else\n expected = @options[:request_type].name\n actual = @options[:request].class.name\n fail :INVALID_REQUEST_PROTO, 'Expected request type to be type of %s, got %s instead' % [expected, actual]\n end\n \n log_debug '[client-cnxn] Sending Request: %s' % request_wrapper.inspect\n request_buffer = Protobuf::Rpc::Buffer.new(:write, request_wrapper)\n send_data(request_buffer.write)\n @stats.request_size = request_buffer.size\n end",
"def encode_message\n self.convert(@numeric_encoded_message, @encoded_message)\n end",
"def encoded\n ready_to_send!\n buffer = header.encoded\n buffer << \"\\r\\n\"\n buffer << body.encoded(content_transfer_encoding)\n buffer\n end",
"def send_message(msg, type)\n # Build the message and get it's size\n message = wrap_message(msg, type).serialize_to_string\n message_size = [message.length].pack('N')\n\n # Write the message to the SSL client and get the response\n @gtv.ssl_client.write(message_size + message)\n data = \"\"\n @gtv.ssl_client.readpartial(1000,data)\n @gtv.ssl_client.readpartial(1000,data)\n\n # Extract the response from the Google TV\n outer = OuterMessage.new\n outer.parse_from_string(data)\n\n return outer\n end",
"def _send_request(connection, req_bytes)\r\n\t\tconnection.print([req_bytes.size].pack('N') + req_bytes)\r\n\t\t@request_count += 1\r\n end",
"def request(mc, pb_msg=nil)\n clear\n\n @req_message_code = mc\n @response = RESPONSE_CLASS_FOR[mc].new unless RESPONSE_CLASS_FOR[mc].nil?\n\n with_socket do |socket|\n begin\n begin\n @req_message = assemble_request mc, pb_msg.serialize_to_string\n rescue NoMethodError\n @req_message = assemble_request mc\n end\n\n socket.write(@req_message)\n self.parse_response socket.sysread(@limit)\n\n end while(false == (@response[:done] rescue true))\n\n socket.flush\n end # with_socket\n\n return(@response)\n end",
"def encode(options={})\n sanitize_request\n send(\"to_#{self.class.format.extension}\", options)\n end",
"def encode_headers(msg)\n buffer = BytesBuffer.new('')\n msg.headers.each do |k, v|\n # header key\n buffer << pack_uint8(k.bytesize)\n buffer << k\n\n # header value\n pattern, val_len, idx = Types.pattern[v.type]\n buffer << pack_uint8(idx)\n # boolean types doesn't need to specify value\n next if !!pattern == pattern\n buffer << pack_uint16(v.value.bytesize) unless val_len\n pattern ? buffer << [v.value].pack(pattern) :\n buffer << v.value\n end\n if buffer.bytesize > MAX_HEADERS_LENGTH\n raise Aws::EventStream::Errors::EventHeadersLengthExceedError.new\n end\n buffer\n end",
"def send_act(conn, act)\r\n conn.respond(Yajl::Encoder.encode(act))\r\n end",
"def encode(message, io = nil)\n encoded = encode_message(message).read\n if io\n io.write(encoded)\n io.close\n else\n encoded\n end\n end",
"def encode_send(method_name, args)\n MessagePack.pack([method_name, args])\n end",
"def encode_body\n body = ''\n\n if @version == '3.1.0'\n raise 'Client identifier too short while serialising packet' if @client_id.nil? || @client_id.bytesize < 1\n raise 'Client identifier too long when serialising packet' if @client_id.bytesize > 23\n end\n\n body += encode_string(@protocol_name)\n body += encode_bytes(@protocol_level.to_i)\n\n if @keep_alive < 0\n raise 'Invalid keep-alive value: cannot be less than 0'\n end\n\n # Set the Connect flags\n @connect_flags = 0\n @connect_flags |= 0x02 if @clean_session\n @connect_flags |= 0x04 unless @will_topic.nil?\n @connect_flags |= ((@will_qos & 0x03) << 3)\n @connect_flags |= 0x20 if @will_retain\n @connect_flags |= 0x40 unless @password.nil?\n @connect_flags |= 0x80 unless @username.nil?\n body += encode_bytes(@connect_flags)\n\n body += encode_short(@keep_alive)\n body += encode_string(@client_id)\n unless will_topic.nil?\n body += encode_string(@will_topic)\n # The MQTT v3.1 specification says that the payload is a UTF-8 string\n body += encode_string(@will_payload)\n end\n body += encode_string(@username) unless @username.nil?\n body += encode_string(@password) unless @password.nil?\n body\n end",
"def request(params=Hash.new, &result_cbk)\n\n cmd = params.delete :cmd\n prefix = params.delete :prefix\n cont = params.delete :cont\n offset = params.delete :offset\n len = params.delete :len\n\n if cont.is_a? String\n cont=request_string(cont)\n elsif cont.is_a? Integer\n cont=request_int(cont)\n end\n raise ArgumentError, \":cont should be an Enumerable\" if !cont.nil? and !cont.is_a? Enumerable\n if len.nil?\n len=(cont.nil?) ? 0 : cont.length\n end\n\n offset||=0\n\n\n if (!cont.nil?)\n raise \":cont shouldn't contain anything but Fixnum\" if cont.any? {|v| !v.is_a? Fixnum}\n if (offset>=cont.length)\n cont=nil;len=0\n elsif (len>cont.length-offset)\n len=cont.length-offset\n end\n end\n offset=0 if offset<0\n len=0 if len<0\n contlen=(cont.nil?) ? 0 : len\n contlen+=prefix.length if (!prefix.nil? and prefix.length>0)\n\n hdr=Array.new(16)\n set_int(cmd,hdr,0)\n set_int(contlen,hdr,4);\n 8.upto(15) {|i| hdr[i]=0}\n if (cmd!=-1)\n io.write(hdr.pack(\"C*\"))\n if (!prefix.nil? && prefix.length>0)\n io.write(prefix.pack(\"C*\"))\n debug \"SEND PREFIX #{prefix}\"\n end\n if (!cont.nil? and cont.length>0)\n debug \"SEND CONTENT #{cont.slice(offset, len)} (#{offset},#{len})\"\n io.write(cont.slice(offset, len).pack(\"C*\"))\n end\n end\n\n io.on_recv(16) do |chunk|\n #\"Expecting 16 bytes...\" if $DEBUG\n ih = chunk.unpack(\"C*\")\n if (ih.length != 16)\n debug \"Received #{ih.length} of expected 16.\"\n result_cbk.call(nil)\n return\n end\n debug \"Answer: #{ih.to_s}\"\n\n rep=get_int(ih, 0);\n rl =get_int(ih,4);\n\n debug \"rep: #{rep} #{rep.class} #{rep & 0x00FFFFFF}\"\n debug \"rl: #{rl} #{rl.class}\"\n\n if (rl>0)\n ct=Array.new();\n io.on_recv(rl) do |chunk|\n ct = chunk.unpack(\"C*\")\n debug \"ct: #{ct.size}\"\n result_cbk.call(Rserve::Packet.new(rep, ct))\n end\n else\n result_cbk.call(Rserve::Packet.new(rep, nil))\n end\n end\n end",
"def _send_request request_payload\n _write request_payload, stream\n end",
"def message_get( type, url, message, extra_parameters = {} )\n\t\t\tparams = Hash.new\n\t\t\tif extra_parameters\n\t\t\t\tparams.merge!(extra_parameters)\n\t\t\tend\n\t\t\t# compress GET requests to try and stay under that 8KB request limit\n\t\t\tparams[type] = encode( deflate( message ) )\n\t\t\t\n\t\t\tLogging.debug \"#{type}=#{params[type]}\"\n\t\t\t\n\t\t\turi = Addressable::URI.parse(url)\n\t\t\tif uri.query_values == nil\n\t\t\t\turi.query_values = params\n\t\t\telse\n\t\t\t\t# solution to stevenwilkin's parameter merge\n\t\t\t\turi.query_values = params.merge(uri.query_values)\n\t\t\tend\n\t\t\turl = uri.to_s\n\t\t\t#url = @URL + \"?SAMLRequest=\" + @request_params[\"SAMLRequest\"]\n\t\t\tLogging.debug \"Sending to URL #{url}\"\n\t\t\treturn url\n\t\tend",
"def send_request(data)\n \n if $DEBUG\n puts \"[request]data--------------\"\n puts data\n puts \"--------------------------\" \n end\n \n outgoing = Blix.to_binary_data(data)\n options = {}\n \n options[:key] = \"\"\n options[:reply_to] = @reply_to\n options[:content_type] = \"text/xml\"\n options[:message_id] = \"#{@time.to_i}#{rand(9999)}\"\n @out_exch.publish(outgoing, options )\n \n incoming = nil\n while (!incoming)\n msg = @in_queue.pop\n payload = msg[:payload]\n incoming = payload unless payload == :queue_empty\n end\n # \n if $DEBUG\n puts \"[request]response data-----\"\n puts incoming\n puts \"--------------------------\" \n end\n incoming\n end",
"def started_request_message(request); end",
"def encode\n\n # Set defaults if necessary\n HEADER_DEFAULTS.each do |k, v|\n send(\"#{k}=\", v) if instance_variable_get(\"@#{k}\").nil?\n end\n\n h_type = HEADER_LENGTHS.invert[header_length]\n\n buffer = Buffer.new\n buffer.write_bitfield [h_type, 2], [channel_id, 6]\n\n if header_length >= 4\n buffer.write_uint24_be timestamp\n end\n\n if header_length >= 8\n buffer.write_uint24_be body_length\n buffer.write_uint8 message_type_id\n end\n\n if header_length == 12\n buffer.write_uint32_le message_stream_id\n end\n\n buffer.string\n end",
"def encode(io)\n io.write RTunnel::Command.registry.code_for(self.class)\n end",
"def request(payload)\n payload = payload + \"\\0\" * ((16 - payload.length) % 16)\n req = [ @extra ].pack('S>')\n blocks = payload.length / 16\n req << blocks.chr\n req << @flags.chr\n req << @key\n req << @iv\n req << payload\n @udp.connect(@host, 1331)\n start_time = Time.now\n @udp.send(req, 0)\n resp = @udp.recvfrom(req.length).first\n end_time = Time.now\n reserved = resp.unpack('L>').first\n [ resp[4..-1], end_time - start_time ]\n end",
"def encode_string; end",
"def message_post( type, url, message, extra_parameters = {} )\n\t\t\tparams = Hash.new\n\t\t\tif extra_parameters\n\t\t\t\tparams.merge!(extra_parameters)\n\t\t\tend\n\t\t\t\n\t\t\t# POST requests seem to bomb out when they're deflated\n\t\t\t# and they probably don't need to be compressed anyway\n\t\t\tparams[type] = encode(message)\n\t\t\t\n\t\t\t#Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n\t\t\t# kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n\t\t\t# and REXML doesn't work well with quote characters\n\t\t\tstr = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n\t\t\tstr += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n\t\t\t# we could change this in the future to associate a temp auth session ID\n\t\t\tstr += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n\t\t\tparams.each_pair do |key, value|\n\t\t\t\tstr += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n\t\t\t\t#str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n\t\t\tend\n\t\t\tstr += \"</form></body></html>\\n\"\n\t\t\t\n\t\t\tLogging.debug \"Created form:\\n#{str}\"\n\t\t\treturn str\n\t\tend",
"def notification(method, *args)\n data = Request.new(method, args, nil).data\n RPC.log \"CLIENT ENCODE NOTIFICATION #{data.inspect}\"\n data.to_json\n end",
"def build_message(type, body, flags=NLM_F_REQUEST, seq=next_seq, pid=@pid)\n body = body.to_str\n header = [\n body.bytesize + NLMSGHDR_SIZE,\n type, flags, seq, pid\n ].pack(NLMSGHDR_PACK)\n # assume the header is already aligned\n header + body\n end",
"def send_request(ref, msg_id, arg, b)\n @msg.send_request(stream, ref, msg_id, arg, b)\n end",
"def encodeWithCoder encoder\n encoder.encodeObject self.message, forKey: \"message\"\n encoder.encodeObject self.id, forKey: \"id\"\n end",
"def encode_body(buffer)\n buffer << property_id.to_msgpack\n end",
"def to_http_query\n\t\t\t\t\tparams = {\n\t\t\t\t\t\t'message' => @message,\n\t\t\t\t\t\t'msisdn' => @recipient,\n\t\t\t\t\t\t'msg_class' => @msg_class,\n\t\t\t\t\t\t'want_report' => @want_report,\n\t\t\t\t\t\t'routing_group' => @routing_group,\n\t\t\t\t\t\t'source_id' => @source_id,\n\t\t\t\t\t\t'test_always_succeed' => @test_always_succeed,\n\t\t\t\t\t\t'test_always_fail' => @test_always_fail,\n\t\t\t\t\t\t'allow_concat_text_sms' => @concat_text_sms,\n\t\t\t\t\t\t'concat_text_sms_max_parts' => @concat_max_parts\n\t\t\t\t\t}\n\t\t\t\t\tquery_string = params.collect { |x, y| \"#{x}=#{y}\" }.join('&')\n\t\t\t\t\tURI.encode(query_string)\n\t\t\t\tend",
"def send_request request\n request.create_identifier! if needs_request_identifier?\n _log_result [ :send_request, :request, request ] do\n request_payload = encoder.dup.encode(request)\n opaque = _send_request(request_payload)\n response = receive_response opaque\n _log { [ :send_request, :response, response ] }\n if response\n if exc = response.exception\n exc.invoke!\n else\n response.result\n end\n else\n response\n end\n end\n end",
"def encode_body(data)\n @serializer.encode(data)\n end",
"def encode_body(data)\n @serializer.encode(data)\n end",
"def encode\n type_byte + encode_data\n end",
"def encode_body\n encode_short(@id)\n end",
"def encode_body\n encode_short(@id)\n end",
"def encode_body\n encode_short(@id)\n end",
"def encode(bytes)\n [bytes.to_s].pack(\"m\").gsub(\"\\n\", '')\n end",
"def serialize(message)\n message.to_msgpack\n end",
"def encode_header(s); s; end",
"def encode!; end",
"def packed()\n body = @status.chr + \n @flags.chr + \n TacacsPlus.pack_int_net(@server_msg_len,2) + \n TacacsPlus.pack_int_net(@data_len,2) \n \n body << @server_msg if (@server_msg)\n body << @data if (@data) \n return(body)\n end",
"def send_message(params)\n uri = URI.parse(@uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n parameters = \"\"\n params.each do |k,v|\n if parameters.empty?\n parameters = \"#{k}=#{v}\"\n else\n parameters += \"&#{k}=#{v}\"\n end\n end\n sig = generate_signature(params)\n parameters += \"&signature=#{sig}\"\n puts parameters \n response = http.post(\"/api/2/apps/#{@key}/messages.json\", \"#{URI.escape(parameters)}\")\n puts response\n return response.body\n end",
"def send_request( request_name, data, want_reply=false )\n msg = @buffers.writer\n msg.write_byte CHANNEL_REQUEST\n msg.write_long @remote_id\n msg.write_string request_name\n msg.write_bool want_reply\n msg.write data.to_s\n @connection.send_message msg\n self\n end",
"def msg_add(c)\n\t@msg_buf << c\n end",
"def display(msg)\n puts \"=\" * 15 + \" REQUEST \" + \"=\" * 15 \n puts msg\n puts \"=\" * 15 + \" EOF REQUEST \" + \"=\" * 15\n end",
"def send_message(msg); end",
"def message_params\n params.require(:message).permit(:msg_code, :message, :upd_uid)\n end",
"def send_request method, params, &block\n message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params,\n id: @next_request_id\n }\n json = message.to_json\n requests[@next_request_id] = Request.new(@next_request_id, &block)\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n @next_request_id += 1\n end",
"def do_request(request, want_reply, data); end",
"def encode(string); end",
"def on_request( channel, request, want_reply, data )\n end",
"def status(msg)\n if msg.respond_to?(:force_encoding)\n msg.force_encoding(Encoding::UTF_8)\n end\n info msg.gsub(BOL, STATUS_PREFIX)\n end",
"def create_json_request(code)\n parameters = {\n \t\"code\" => code,\n\t\"level\" => self.level,\n\t\"format\" => \"json\",\n\t\"info\" => self.op\n }\n end",
"def buildRequest(payload)\n # ...\n end",
"def request_type; \"RequestType\"; end",
"def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end",
"def write_request(request, client)\n puts request\n filename = request[6..request.length]\n request = client.gets.chomp\n puts request\n start_n = request[6..request.length].to_i\n contents = client.gets\n puts contents\n if File.exist?(filename)\n IO.binwrite(filename, contents, start_n)\n client.puts \"\\nOK:#{filename}\\nSTART:#{start_n}\\n\\n\"\n else client.puts @error1\n end\n end",
"def pack(code = nil, reason = nil)\n\t\t\t\tif code\n\t\t\t\t\tif reason and reason.encoding != Encoding::UTF_8\n\t\t\t\t\t\treason = reason.encode(Encoding::UTF_8)\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tsuper([code, reason].pack(FORMAT))\n\t\t\t\telse\n\t\t\t\t\tsuper()\n\t\t\t\tend\n\t\t\tend",
"def write(msg)\n\t\tinfo(msg)\n\tend",
"def info(msg, request=nil)\n super(with_extra_request_info(msg, request))\n end",
"def to_s\n \"IntentRequest: #{name} requestID: #{request_id} Slots: #{slots}\"\n end",
"def send(msg=\"\")\n\t\tif @connected\n\t\t\[email protected] \"\\1#{msg}\\r\\n\" # leading \\1 for terse reply\n\t\tend\n\tend",
"def message_get( type, url, message, extra_parameters = {} )\n params = Hash.new\n if extra_parameters\n params.merge!(extra_parameters)\n end\n # compress GET requests to try and stay under that 8KB request limit\n #deflate of samlrequest\n params[type] = encode( deflate( message ) )\n #Logging.debug \"#{type}=#{params[type]}\"\n \n uri = Addressable::URI.parse(url)\n if uri.query_values == nil\n uri.query_values = params\n else\n # solution to stevenwilkin's parameter merge\n uri.query_values = params.merge(uri.query_values)\n end\n url = uri.to_s\n #Logging.debug \"Sending to URL #{url}\"\n return url\n end",
"def message_get( type, url, message, extra_parameters = {} )\n params = Hash.new\n if extra_parameters\n params.merge!(extra_parameters)\n end\n # compress GET requests to try and stay under that 8KB request limit\n #deflate of samlrequest\n params[type] = encode( deflate( message ) )\n #Logging.debug \"#{type}=#{params[type]}\"\n \n uri = Addressable::URI.parse(url)\n if uri.query_values == nil\n uri.query_values = params\n else\n # solution to stevenwilkin's parameter merge\n uri.query_values = params.merge(uri.query_values)\n end\n url = uri.to_s\n #Logging.debug \"Sending to URL #{url}\"\n return url\n end",
"def encode_message(message)\n # create context buffer with encode headers\n ctx_buffer = encode_headers(message)\n headers_len = ctx_buffer.bytesize\n # encode payload\n if message.payload.length > MAX_PAYLOAD_LENGTH\n raise Aws::EventStream::Errors::EventPayloadLengthExceedError.new\n end\n ctx_buffer << message.payload.read\n total_len = ctx_buffer.bytesize + OVERHEAD_LENGTH\n\n # create message buffer with prelude section\n buffer = prelude(total_len, headers_len)\n\n # append message context (headers, payload)\n buffer << ctx_buffer.read\n # append message checksum\n buffer << pack_uint32(Zlib.crc32(buffer.read))\n\n # write buffered message to io\n buffer.rewind\n buffer\n end",
"def send_message(msg)\n # Build the message and get it's size\n message = msg.serialize_to_string\n message_size = [message.length].pack('N')\n\n # Try to send the message\n try_again = true\n begin\n data = \"\"\n @ssl_client.write(message_size + message)\n @ssl_client.readpartial(1000,data)\n rescue\n # Sometimes our connection might drop or something, so\n # we'll reconnect to the unit and try to send the message again.\n if try_again\n try_again = false\n connect_to_unit\n retry\n else\n # Looks like we couldn't connect to the unit after all.\n puts \"message not sent\"\n end\n end\n\n return data\n end",
"def reencode(body, content_type = T.unsafe(nil)); end"
] | [
"0.6424981",
"0.63148844",
"0.6269933",
"0.62282616",
"0.6210985",
"0.61697453",
"0.61449206",
"0.6130633",
"0.6104965",
"0.60915184",
"0.6008699",
"0.5921019",
"0.58890426",
"0.5834426",
"0.579513",
"0.57921994",
"0.57860625",
"0.5757325",
"0.57281667",
"0.5721147",
"0.57181937",
"0.5707766",
"0.5707766",
"0.57031024",
"0.56843936",
"0.566515",
"0.564401",
"0.56331706",
"0.56315595",
"0.5614295",
"0.5569697",
"0.55263865",
"0.55199075",
"0.55140746",
"0.54993415",
"0.5492313",
"0.54773724",
"0.5471898",
"0.5439691",
"0.5429908",
"0.54132473",
"0.5397541",
"0.53966767",
"0.53890765",
"0.5380961",
"0.53559655",
"0.5346476",
"0.5343397",
"0.53388643",
"0.5334549",
"0.5333426",
"0.5329222",
"0.5301296",
"0.53010136",
"0.5287634",
"0.52835697",
"0.5282391",
"0.52732867",
"0.52698964",
"0.52481955",
"0.52411085",
"0.5240555",
"0.5208683",
"0.52006936",
"0.52006936",
"0.51971817",
"0.5197124",
"0.5197124",
"0.5197124",
"0.5189473",
"0.5189129",
"0.51880294",
"0.5187337",
"0.51786894",
"0.51707774",
"0.5166448",
"0.51635385",
"0.51444376",
"0.51392823",
"0.51287466",
"0.5119348",
"0.5118091",
"0.51058733",
"0.51045793",
"0.51021",
"0.5098168",
"0.5095219",
"0.50818086",
"0.5081151",
"0.50758123",
"0.5070487",
"0.50698334",
"0.5066718",
"0.50629807",
"0.50592285",
"0.5053771",
"0.5053771",
"0.5053334",
"0.50452834",
"0.50433105"
] | 0.655947 | 0 |
Checks the md5 hash in the request body against our psk, the request sent for validation should not have been deserialized already | def validrequest?(req)
digest = makehash(req[:body])
if digest == req[:hash]
@stats[:validated] += 1
return true
else
@stats[:unvalidated] += 1
raise("Received an invalid signature in message")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n return false unless @digest_parts.any? # RUBY\n\n a2 = @request.method + ':' + @digest_parts['uri']\n\n if @digest_parts['qop'] == 'auth-int'\n # Making sure we support this qop value\n return false unless @qop & QOP_AUTHINT\n\n # We need to add an md5 of the entire request body to the A2 part of the hash\n body = @request.body_as_string\n @request.body = body\n\n a2 << ':' + ::Digest::MD5.hexdigest(body)\n else\n # We need to make sure we support this qop value\n return false unless @qop & QOP_AUTH\n end\n\n a2 = ::Digest::MD5.hexdigest(a2)\n valid_response = ::Digest::MD5.hexdigest(\"#{@a1}:#{@digest_parts['nonce']}:#{@digest_parts['nc']}:#{@digest_parts['cnonce']}:#{@digest_parts['qop']}:#{a2}\")\n\n @digest_parts['response'] == valid_response\n end",
"def validrequest?(req)\n ssl = SSL.new(\"/home/rip/.mcollective.d/rip.pem\")\n\n ssl.verify_signature(req[:hash], SSL.md5(req[:body]), true)\n\n req[:callerid] = \"webuser=%s\" % ssl.rsa_decrypt_with_public(ssl.base64_decode(req[:callerid]))\n req[:body] = deserialize(req[:body])\n\n @stats.validated\n\n true\n rescue\n @stats.unvalidated\n raise(SecurityValidationFailed, \"Received an invalid signature in message\")\n end",
"def quick_verify\n cached_md5 == remote_md5 and remote_md5 == md5\n end",
"def valid_integrity?(body, headers)\n request_signature = headers['X-Hub-Signature']\n signature_parts = request_signature.split('sha1=')\n request_signature = signature_parts[1]\n calculated_signature = OpenSSL::HMAC.hexdigest('sha1', @secret, body)\n calculated_signature == request_signature\n end",
"def check_signature(body)\n received_signature = request.env['HTTP_X_HUB_SIGNATURE'] || ''\n signature = 'sha1=' + hmac_sha1(settings.github_secret, body)\n\n if !Rack::Utils.secure_compare(signature, received_signature)\n build_failed('signature mismatch')\n end\nend",
"def md5\n return self.body_data.md5\n end",
"def validrequest?(req)\n message = req[:body]\n signature = req[:hash]\n\n Log.debug(\"Validating request from #{req[:callerid]}\")\n\n if verify(public_key_file(req[:callerid]), signature, message.to_s)\n @stats.validated\n return true\n else\n @stats.unvalidated\n raise(SecurityValidationFailed, \"Received an invalid signature in message\")\n end\n end",
"def valid_signature?\n params['verifier'] == Digest::MD5.hexdigest([ params['id'], params['snuid'], params['currency'], Offerpal.secret_key ].join(':'))\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def check_signature!\n request.body.rewind\n payload_raw = request.body.read # We need the raw text of the body to check the webhook signature\n begin\n @payload = JSON.parse payload_raw\n rescue\n @payload = {}\n end\n\n # Check X-Hub-Signature to confirm that this webhook was generated by GitHub, and not a malicious third party.\n # The way this works is: We have registered with GitHub a secret, and we have stored it locally in WEBHOOK_SECRET.\n # GitHub will cryptographically sign the request payload with this secret. We will do the same, and if the results\n # match, then we know that the request is from GitHub (or, at least, from someone who knows the secret!)\n # If they don't match, this request is an attack, and we should reject it.\n # The signature comes in with header x-hub-signature, and looks like \"sha1=123456\"\n # We should take the left hand side as the signature method, and the right hand side as the\n # HMAC digest (the signature) itself.\n their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, payload_raw)\n halt 401 unless their_digest == our_digest\n @payload\n end",
"def check\n req = GData::HTTP::Request.new(@base_uri + '/' + @model)\n sign_and_request(req)\n end",
"def md5_of_body\n data[:md5_of_body]\n end",
"def is_checksum_valid?(received_params)\n paytmparams = Hash.new\n\n keys = received_params.keys\n keys.each do |k|\n paytmparams[k] = received_params[k]\n end\n\n checksum_hash = paytmparams[\"CHECKSUMHASH\"]\n paytmparams.delete(\"CHECKSUMHASH\")\n\n Rails.logger.debug \"HERE\"\n Rails.logger.debug \"paytmparams #{paytmparams}\"\n Rails.logger.debug \"checksum_hash #{checksum_hash}\"\n Rails.logger.debug \"PAYTM_MERCHANT_KEY #{ENV[\"PAYTM_MERCHANT_KEY\"]}\" \n \n return new_pg_verify_checksum(paytmparams, checksum_hash, ENV[\"PAYTM_MERCHANT_KEY\"])\n end",
"def receive_verify_post(params, request)\n if request.post?\n [:action, :email, :send_id, :sig].each { |key| return false unless params.has_key?(key) }\n\n return false unless params[:action] == :verify\n\n sig = params[:sig]\n params.delete(:sig)\n return false unless sig == TriggermailClient.get_signature_hash(params, @secret)\n\n _send = self.get_send(params[:send_id])\n return false unless _send.has_key?(:email)\n\n return false unless _send[:email] == params[:email]\n\n return true\n else\n return false\n end\n end",
"def validrequest?(req)\n Log.info \"Caller id: #{req[:callerid]}\"\n Log.info \"Sender id: #{req[:senderid]}\"\n message = req[:body]\n\n #@log.info req.awesome_inspect\n identity = (req[:callerid] or req[:senderid])\n verifier = SSH::Key::Verifier.new(identity)\n\n Log.info \"Using name '#{identity}'\"\n\n # If no callerid, this is a 'response' message and we should\n # attempt to authenticate using the senderid (hostname, usually)\n # and that ssh key in known_hosts.\n if !req[:callerid]\n # Search known_hosts for the senderid hostname\n verifier.add_key_from_host(identity)\n verifier.use_agent = false\n verifier.use_authorized_keys = false\n end\n\n signatures = Marshal.load(req[:hash])\n if verifier.verify?(signatures, req[:body])\n @stats.validated\n return true\n else\n @stats.unvalidated\n raise(SecurityValidationFailed, \"Received an invalid signature in message\")\n end\n end",
"def validate_update(body, headers)\n unless @secret\n raise AppSecretNotDefinedError, \"You must init RealtimeUpdates with your app secret in order to validate updates\"\n end\n\n request_signature = headers['X-Hub-Signature'] || headers['HTTP_X_HUB_SIGNATURE']\n return unless request_signature\n\n signature_parts = request_signature.split(\"sha1=\")\n request_signature = signature_parts[1]\n calculated_signature = OpenSSL::HMAC.hexdigest('sha1', @secret, body)\n calculated_signature == request_signature\n end",
"def validate_digest_response(request, realm, &password_procedure); end",
"def verify_content(body, signature)\n hmac = HMAC::SHA1.hexdigest(@secret, body)\n check = \"sha1=\" + hmac\n check == signature\n end",
"def validateMD5Hash(data, hash)\n\t\tnewhash = self.createMD5Hash(data)\n\t\tif newhash == hash\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['WEBHOOK_SECRET_TOKEN'], payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\nend",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def valid_post_body?(post_body, signature)\n hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), @channel.line_channel_secret, post_body)\n Base64.strict_encode64(hash) == signature\n end",
"def verified_request?; end",
"def check_digest(request)\n header = request['Bugsnag-Integrity']\n\n if header.nil? && Maze.config.enforce_bugsnag_integrity && %i[sessions errors traces].include?(@request_type)\n raise \"Bugsnag-Integrity header must be present for #{@request_type} according to Maze.config.enforce_bugsnag_integrity\"\n end\n return if header.nil?\n\n # Header must have type and digest\n parts = header.split ' '\n raise \"Invalid Bugsnag-Integrity header: #{header}\" unless parts.size == 2\n\n # Both digest types are stored whatever\n sha1 = Digest::SHA1.hexdigest(request.body)\n simple = request.body.bytesize\n $logger.trace \"DIGESTS computed: sha1=#{sha1} simple=#{simple}\"\n\n # Check digests match\n case parts[0]\n when 'sha1'\n raise \"Given sha1 #{parts[1]} does not match the computed #{sha1}\" unless parts[1] == sha1\n when 'simple'\n raise \"Given simple digest #{parts[1].inspect} does not match the computed #{simple.inspect}\" unless parts[1].to_i == simple\n else\n raise \"Invalid Bugsnag-Integrity digest type: #{parts[0]}\"\n end\n\n {\n sha1: sha1,\n simple: simple\n }\n end",
"def has_valid_payload?\n\t\treturn self.payload_hash == self.calculate_payload_hash\n\tend",
"def intact?\n @signature.md5 == Digest::MD5.digest(@content)\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def validate_proxy\n\t\t\t# Remove and save the \"signature\" entry\n\t\t\tsignature = @query.delete(\"signature\")\n\t\t\tsorted_params = @query.collect{ |k, v| \"#{k}=#{Array(v).join(',')}\" }.sort.join\n\t\t\t\n\t\t\tcalculated_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), shared_secret, sorted_params)\n\n\t\t\traise 'Invalid signature' if signature != calculated_signature\n\t\tend",
"def needs_md5sums\n false\n end",
"def check_server_signature(payload_data)\n if verifier = payload_data['v']\n if compare_digest(verifier, server_signature)\n @server_verified = true\n else\n raise Error::InvalidSignature.new(verifier, server_signature)\n end\n end\n end",
"def check(params)\n params = params.dup\n\n signature = params.delete('sig')\n\n ::JWT::SecurityUtils.secure_compare(signature, digest(params))\n end",
"def validate_token_hash; end",
"def verify_md5_hash?(url, expected_hash, secret_key)\n url_no_hash = \"#{url[ 0..-33 ]}#{secret_key}\"\n actual_hash = Digest::MD5.hexdigest(url_no_hash)\n\n return (expected_hash == actual_hash)\n end",
"def valid?\n # If payload does not contain the sha_sign definitely return false.\n return false unless payload.sha_sign\n\n signature == payload.sha_sign\n end",
"def signature_valid?\n hmac.validate_url_signature(request.url, secret)\n end",
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_GEOTIX_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, \"#{auth_token}#{@payload_raw}\")\n halt [401, \"Signatures don't match.\"] unless their_digest == our_digest\n end",
"def cram_md5_challenge; end",
"def valid?\n utils = Amazon::FPS::SignatureUtilsForOutbound.new(@access_key, @secret_key);\n utils.validate_request(:parameters => @params, :url_end_point => @url_end_point, :http_method => \"GET\")\n end",
"def valid_signature?\n Rack::Utils.secure_compare(signature, signature_for(body))\n end",
"def can_validate_checksums?\n true\n end",
"def correct_signature?\n client = RestClient.where(:api_key => @api_key).first\n sign=client.nil? ? \"\" : client.secret + @request_uri.gsub(/\\?.*/,\"\")+@timestamp\n calculated_sign= (Digest::SHA256.new << sign).to_s\n Digest::SHA1.hexdigest(@signature)==Digest::SHA1.hexdigest(calculated_sign)\n end",
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, ENV['GITHUB_WEBHOOK_SECRET'], @payload_raw)\n halt 401 unless their_digest == our_digest\n\n log_action\n end",
"def verify!(request, secret)\n query = query_string(request, request.params[\"nonce\"])\n unless request.params[\"signature\"] == sign(query, secret)\n raise OauthStateMiddlewareException, \"OAuth state signatures do not match\"\n end\n end",
"def check_message_id_md5\n return true if message_id.blank?\n\n self.message_id_md5 = Digest::MD5.hexdigest(message_id.to_s)\n end",
"def verify_signatures?; end",
"def valid_AmazonMarketplace_request?(request_hash)\n hash = request_hash.symbolize_keys\n signature = hash.delete(:signature) || ''\n AmazonMarketplace::SignatureUtils.authentic?(hash, signature)\n end",
"def _verify\n unless (@_headers['x-allopass-response-signature'] || []).include?(@_signature)\n raise Allorails::ApiFalseResponseSignatureError\n end\n end",
"def check_email_hash\n if self.class.column_names.include?(\"email_hash\")\n if email_changed?\n require 'digest/md5'\n self.email_hash = Digest::MD5.hexdigest(self.email.to_s.downcase.strip)\n end\n end\n end",
"def validate_image_md5sum\n result = true\n if upload_md5sum.present? && save_to_temp_file\n sum = File.open(upload_temp_file) do |f|\n Digest::MD5.hexdigest(f.read)\n end\n if sum == upload_md5sum\n result = true\n else\n errors.add(:image, :validate_image_md5_mismatch.\n t(actual: sum.split.first, expect: upload_md5sum))\n result = false\n end\n end\n result\n end",
"def validate_checksum?\n self[:checksum] !~ /time/\n end",
"def verify_authenticity_token; end",
"def validate_request req\n id, method, params = req.id, req.method.sub(/^block\\./,''), req.params\n\n case method\n when \"notify\"\n coin_code, password, hash = *params\n raise Rpc::InvalidParams.new( extra_msg: \"coin_code is invalid : #{coin_code}\" ) if ! coin_code =~ /^\\w{3,5}$/\n else\n raise JSON_RPC::MethodNotFound.new( method: \"block.#{method}\" )\n end\n\n emit( method, req )\n\n true\n end",
"def validate_checksum_state\n super\n end",
"def security_key\n params['x_MD5_Hash']\n end",
"def security_key\n params['x_MD5_Hash']\n end",
"def verify_params(params)\n return false if params['Body'].to_s.empty?\n return false if params['Body'].to_s.bytes.size > 1600\n return false unless /\\+\\d+$/.match(params['To'])\n true\n end",
"def validate!(payload:, state:)\n return @error = 'payload is not a hash' unless payload.is_a? Hash\n\n key = 'persona:payload'\n return @error = \"payload missing key #{key}\" unless payload.key? key\n\n @payload = decode_and_parse_payload(payload)\n return @error = 'payload is not valid JSON' if @payload.nil?\n\n state_error = 'payload state does not match provided'\n return @error = state_error if @payload['state'] != state\n\n signature_error = 'payload signature does not match expected'\n return @error = signature_error unless signature_valid?(@payload)\n\n @user = build_user(@payload)\n end",
"def verify_hash\r\n raise \"Line #{total_block_number}: hash was incorrectly calculated\" unless @current_hash == @computed_hash\r\n\r\n true\r\n end",
"def verify_key; end",
"def verify_key; end",
"def body_hash_required?\n false\n end",
"def verify\n if (buffer.offset + @_model.fbe_offset - 4) > buffer.size\n return false\n end\n\n fbe_full_size = read_uint32(@_model.fbe_offset - 4)\n if fbe_full_size < @_model.fbe_size\n return false\n end\n\n @_model.verify\n end",
"def verify\n if (buffer.offset + @_model.fbe_offset - 4) > buffer.size\n return false\n end\n\n fbe_full_size = read_uint32(@_model.fbe_offset - 4)\n if fbe_full_size < @_model.fbe_size\n return false\n end\n\n @_model.verify\n end",
"def verify\n if (buffer.offset + @_model.fbe_offset - 4) > buffer.size\n return false\n end\n\n fbe_full_size = read_uint32(@_model.fbe_offset - 4)\n if fbe_full_size < @_model.fbe_size\n return false\n end\n\n @_model.verify\n end",
"def verify\n if (buffer.offset + @_model.fbe_offset - 4) > buffer.size\n return false\n end\n\n fbe_full_size = read_uint32(@_model.fbe_offset - 4)\n if fbe_full_size < @_model.fbe_size\n return false\n end\n\n @_model.verify\n end",
"def webhook_valid?(transaction, ip)\n sanity_check!\n md5sum = Digest::MD5.hexdigest([\n id,\n transaction[:tr_id],\n transaction[:tr_amount],\n transaction[:tr_crc],\n security_code\n ].join)\n Tpay.valid_ip?(ip) && transaction[:md5sum] == md5sum\n end",
"def check\n @response = nil\n verified?\n end",
"def signature_ok?\n generate_md5 == vps_signature\n end",
"def verification_hash_verified\n verified = false\n hash = VerificationHash.where(hash_value: params[:hash]).last\n verified = hash.verified if hash\n render json: { verified: verified }, status: 200\n end",
"def valid_request?\n signature = github_signature\n my_signature = 'sha1=' + OpenSSL::HMAC.hexdigest(\n OpenSSL::Digest.new('sha1'),\n ENV['GITHUB_WEBHOOK_SECRET'],\n github_payload_raw\n )\n\n json_response(json_access_denied, :unauthorized) unless Rack::Utils.secure_compare(my_signature, signature)\n rescue StandardError => e\n msg = \"#{self.class}##{__method__} An error occurred while determine if request is valid\"\n Rails.logger.error(\n message: msg,\n exception: e\n )\n\n json_response(json_access_denied(errors: { message: \"#{msg}, exception: #{e.message}\" }), :unauthorized)\n end",
"def verify_request(request)\n verify_signature(\n # url without query string\n request.protocol + request.host_with_port + request.path,\n # raw parameters\n request.get? ? request.query_string : request.raw_post\n )\n end",
"def check_hash=(flag)\r\n @conf[:use_md5_digest] = flag\r\n end",
"def validate_and_sanitize\n r = validate\n return invalid_credentials_response('a_ar_b_vas_1') unless r.success?\n\n @parsed_request_time = Time.at(@request_timestamp.to_i)\n\n return invalid_credentials_response(\"um_vac_1\") unless @parsed_request_time && (@parsed_request_time.between?(Time.now - expiry_window, Time.now + expiry_window))\n\n @request_parameters.permit!\n\n [\"signature\"].each do |k|\n @request_parameters.delete(k)\n end\n\n success\n end",
"def verify\n end",
"def valid?\n @hydra.queue(request('verify'))\n end",
"def validate_digest_response(request, realm, &password_procedure)\n credentials = decode_credentials_header(request)\n valid_nonce = validate_nonce(request, credentials[:nonce])\n\n if valid_nonce && realm == credentials[:realm] && opaque == credentials[:opaque]\n password = password_procedure.call(credentials[:username])\n method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD']\n\n [true, false].any? do |password_is_ha1|\n expected = expected_response(method, request.env['REQUEST_URI'], credentials, password, password_is_ha1)\n expected == credentials[:response]\n end\n end\n end",
"def md5_query\n params.require(:query)\n end",
"def verify_signature\n @spki.verify(public_key)\n end",
"def validate_reset_token\n\n return invalid_url_error('um_rp_4') if @user_validation_hash_obj.blank?\n\n return invalid_url_error('um_rp_5') if @user_validation_hash_obj.validation_hash != @reset_token\n\n return invalid_url_error('um_rp_6') if @user_validation_hash_obj.status != GlobalConstant::UserValidationHash.active_status\n\n return invalid_url_error('um_rp_7') if @user_validation_hash_obj.is_expired?\n\n return invalid_url_error('um_rp_8') if @user_validation_hash_obj.kind != GlobalConstant::UserValidationHash.reset_password\n\n success\n\n end",
"def md5?; @md5; end",
"def verify()\n # TODO\n end",
"def line_bot_auth\n body = request.body.read\n\n signature = request.env['HTTP_X_LINE_SIGNATURE']\n unless client.validate_signature(body, signature)\n puts \"Error: bad_request. Line invalidate signature.\"\n bad_request\n end\n end",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def verify_signature(result); end",
"def check_digests(streamer_response:, file_model:)\n out = streamer_response\n upload = file_model\n if out[:response].nil? || out[:response][:checksum].nil?\n raise FileError, \"Error streaming file to Zenodo. No md5 digest returned:\\n#{out[:response]}\\nFile:#{upload.inspect}\"\n end\n\n if out[:response][:checksum] != \"md5:#{out[:digests]['md5']}\"\n raise FileError, \"Error MD5 digest doesn't match zenodo:\\nResponse: #{out[:response][:checksum]}\\nCalculated: md5:#{out[:digests]['md5']}\"\n end\n\n return unless upload.digest_type.present? && upload.digest.present? && out[:digests][upload.digest_type] != upload.digest\n\n raise FileError, \"Error #{upload.digest_type} digest doesn't match database value:\\nCalculated:#{out[:digests][upload.digest_type]}\\n\" \\\n \"Database: #{upload.digest}\"\n end",
"def request_signature_verification\n return @request_signature_verification\n end",
"def secure?\n self.generated_signature == self.signature\n end",
"def hashes_match?\n ar = @ar.clone\n\n digest_value = ar.at_css(\n 'xmlns|DigestValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content.strip\n\n ar.at_css(\n \"xmlns|Signature\",\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).remove\n\n actual_digest = calculate_digest(ar)\n\n if digest_value == actual_digest\n true\n else\n false\n end\n end",
"def verify_state?(state)\n return false if state.nil? || state.empty?\n Rack::Utils.secure_compare(csrf_token, state)\nend",
"def verify!(ha)\n passed_signature = ha[:sig] || ha[\"sig\"]\n raise Tampered, \"No signature given\" unless passed_signature\n raise Tampered, \"Checksum differs\" unless compute_checksum(ha) == passed_signature.to_s\n true\n end",
"def md5_of_message_attributes\n data[:md5_of_message_attributes]\n end",
"def passive\t\t\n\tif @body.size > 4\n\t\thash=Digest::MD5.hexdigest(@body[0..500])\t\n\t\t[{:name=>\"hash\",:string=>hash}]\n\telse\n\t\t[]\n\tend\nend",
"def verify_check_string(data)\n # The documentation about how to calculate the hash was woefully\n # under-documented, however through some guessing I was able to\n # determine that it creates an MD5 from the values of the fields\n # starting with OrderID and ending with TranData, concatenated with\n # the Shop Password.\n fields = [\n 'OrderID',\n 'Forward',\n 'Method',\n 'PayTimes',\n 'Approve',\n 'TranID',\n 'TranDate'\n ]\n values_string = ''\n check_string = nil\n\n CGI.parse(data).each do |key, value|\n if value.length == 1\n value = value[0]\n end\n if fields.include?(key)\n values_string += value\n end\n if key == 'CheckString'\n check_string = value\n end\n end\n values_string += @options[:password]\n our_hash = Digest::MD5.hexdigest(values_string)\n check_string == our_hash\n end",
"def validate_hash(info)\r\n\t\t# passes in the parsed info\r\n\t\tstring_to_hash = get_string_to_hash(info)\r\n\t\tcorrect_hash = get_hash(string_to_hash)\r\n\t\t#puts string_to_hash\r\n\t\treturn correct_hash.strip == info['self_hash'].strip\r\n\tend",
"def verify\n @sigs = []\n @orig_data = request.params['data']\n if @orig_data.nil?\n # XXX: Implement HTTP error here.\n end\n begin\n GPGME::verify(request.params['data'], nil, @plain) do |signature|\n @sigs << signature\n end\n rescue GPGME::Error => e\n @error = \"GPGME Error: #{e.to_s}\"\n #rescue\n # @error = \"Unspecified Error.\"\n end\n end",
"def verify_signature(data)\n Signature.valid?(data.merge('api_key' => api_key))\n end",
"def verify_slack_request\n timestamp = request.headers['X-Slack-Request-Timestamp']\n if (Time.now.to_i - timestamp.to_i).abs > 60 * 5\n head :unauthorized\n return\n end\n\n sig_basestring = \"v0:#{timestamp}:#{request.raw_post}\"\n signature = \"v0=\" + OpenSSL::HMAC.hexdigest(\"SHA256\", ENV['SLACK_SIGNING_SECRET'], sig_basestring)\n slack_signature = request.headers['X-Slack-Signature']\n\n if !ActiveSupport::SecurityUtils.secure_compare(signature, slack_signature)\n head :unauthorized\n end\n end",
"def check_signature(secret)\n digest = OpenSSL::Digest::SHA256.new\n expected = OpenSSL::HMAC.hexdigest(digest, secret, @body)\n if @signature == expected\n return true\n else\n Pusher.logger.warn \"Received WebHook with invalid signature: got #{@signature}, expected #{expected}\"\n return false\n end\n end"
] | [
"0.71422464",
"0.6615576",
"0.6254384",
"0.6179126",
"0.6147874",
"0.60476065",
"0.60288227",
"0.5990138",
"0.5988776",
"0.59881806",
"0.5977048",
"0.59718204",
"0.59566367",
"0.59323597",
"0.5925171",
"0.59047824",
"0.59033847",
"0.5784152",
"0.57425696",
"0.57300836",
"0.56836516",
"0.56817424",
"0.56817424",
"0.5659707",
"0.5651916",
"0.5647322",
"0.563261",
"0.5630343",
"0.56302047",
"0.56022877",
"0.5554487",
"0.5546726",
"0.5546247",
"0.5533704",
"0.5530773",
"0.55278677",
"0.55234337",
"0.5486846",
"0.5482629",
"0.54803586",
"0.5472778",
"0.5459891",
"0.5415436",
"0.54056394",
"0.53973097",
"0.5395173",
"0.5388109",
"0.5372607",
"0.53673273",
"0.53652364",
"0.53621",
"0.5355405",
"0.53486514",
"0.5347932",
"0.5334384",
"0.5331273",
"0.5329931",
"0.5326158",
"0.5324491",
"0.53181916",
"0.5317264",
"0.5317264",
"0.53111064",
"0.5310448",
"0.5310448",
"0.5310448",
"0.5310448",
"0.5304068",
"0.53006154",
"0.52870333",
"0.52848256",
"0.5279135",
"0.52770835",
"0.5274497",
"0.5269263",
"0.52584165",
"0.5243157",
"0.5242591",
"0.523902",
"0.5237669",
"0.52341264",
"0.52324426",
"0.52292466",
"0.5223828",
"0.52223194",
"0.52118593",
"0.52064013",
"0.5203898",
"0.51973426",
"0.5196278",
"0.51947486",
"0.51890165",
"0.51818645",
"0.5178033",
"0.5162281",
"0.51616955",
"0.51604325",
"0.5157678",
"0.5154532",
"0.5153506"
] | 0.67861265 | 1 |
Retrieves the value of plugin.psk and builds a hash with it and the passed body | def makehash(body)
if ENV.include?("MCOLLECTIVE_PSK")
psk = ENV["MCOLLECTIVE_PSK"]
else
raise("No plugin.psk configuration option specified") unless @config.pluginconf.include?("psk")
psk = @config.pluginconf["psk"]
end
Digest::MD5.hexdigest(body.to_s + psk)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makehash(body)\n signer = SSH::Key::Signer.new\n if @config.pluginconf[\"sshkey\"]\n signer.add_key_file(@config.pluginconf[\"sshkey\"])\n signer.use_agent = false\n end\n signatures = signer.sign(body).collect { |s| s.signature }\n return Marshal.dump(signatures)\n end",
"def get_body(secret_value)\n { 'value' => secret_value }.to_json\n end",
"def build_register_body\n signable_str = self.signable_string\n {\n :type => :client_associate,\n :signed_string => Base64.encode64(signable_str),\n :signature => Base64.encode64(LygneoClient.sign(signable_str))\n }\n end",
"def body\n {\n :client_id => self.client_id,\n :secret => self.secret\n }\n end",
"def makehash(body)\n Log.debug(\"Creating message hash using #{private_key_file}\")\n\n sign(private_key_file, body.to_s)\n end",
"def passive\t\t\n\tif @body.size > 4\n\t\thash=Digest::MD5.hexdigest(@body[0..500])\t\n\t\t[{:name=>\"hash\",:string=>hash}]\n\telse\n\t\t[]\n\tend\nend",
"def key_pem; end",
"def pubek(status)\n pass_file = \"#{Puppet[:vardir]}/simp/tpm_ownership_owner_pass\"\n enabled = status['enabled'] == 1\n owned = status['owned'] == 1\n\n out = Hash.new\n raw = ''\n\n if !enabled\n out['_status'] = 'error: tpm not enabled'\n return out\n elsif !owned\n raw = get_pubek_unowned\n out['_status'] = 'success: tpm unowned'\n else\n if File.exists?(pass_file)\n owner_pass = Facter::Core::Execution.execute(\"cat #{pass_file} 2>/dev/null\")\n if owner_pass.eql? \"\"\n out['_status'] = 'error: the password file is empty'\n return out\n else\n raw = get_pubek_owned(owner_pass)\n out['_status'] = 'success: raw pubek grabbed' unless raw.nil?\n end\n else\n out['_status'] = 'error: password file not found'\n return out\n end\n end\n\n if raw.nil? or raw == \"\"\n out['_status'] = 'error: trousers is not running, the tpm is not enabled, or the password in the password file is incorrect'\n else\n pubek = YAML.load(raw.gsub(/\\t/,' '*4).split(\"\\n\").drop(1).join(\"\\n\"))\n pubek['Public Key'].gsub!(/ /, '')\n pubek['raw'] = raw\n out.merge!( Hash[pubek.map{ |k,v| [k.downcase.gsub(/ /, '_'), v] }] )\n out['_status'] = 'success: raw parsed'\n end\n\n out\n end",
"def secure_hash\r\n params['secureHash']\r\n end",
"def type_to_form_ready_hash_site\n {\n username: resource[:username],\n password: resource[:password],\n configStoreConnection: JSON.generate(type_to_form_ready_hash_configstore),\n settings: JSON.generate(type_to_form_ready_hash_logsettings),\n runAsync: false,\n }\n end",
"def security_key\n params['callbackPW']\n end",
"def body_retrieve\n ret = Hash.new\n ret[:access_token] = self.access_token\n ret[:type] = self.institution\n ret[:email] = self.email\n ret.merge(body)\n end",
"def params_auth_hash; end",
"def post_data(params)\n {\n gateway_username: options[:login],\n gateway_password: options[:password],\n payload: encrypt(params.to_json)\n }.to_json\n end",
"def parse(post)\n \n rc4 = RubyRc4.new(self.secret_key)\n params = (Hash[ rc4.encrypt(Base64.decode64(post.gsub(/ /,'+'))).split('&').map { |x| x.split(\"=\") } ]).slice(* NECESSARY )\n self.params = params\n \n end",
"def plugin_hash; end",
"def make_plugin_hash; end",
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def bridgepay_config\n Hash(\n username: ::BridgePay.username,\n password: ::BridgePay.password,\n merchant_code: ::BridgePay.code,\n merchant_account: ::BridgePay.account\n ) \n end",
"def serialize\n except_ch_psk = values.reject do |ex|\n ex.extension_type == ExtensionType::PRE_SHARED_KEY &&\n ex.msg_type == HandshakeType::CLIENT_HELLO\n end\n binary = except_ch_psk.map(&:serialize).join\n\n psk = super_fetch(ExtensionType::PRE_SHARED_KEY, nil)\n binary += psk.serialize if psk&.msg_type == HandshakeType::CLIENT_HELLO\n\n binary.prefix_uint16_length\n end",
"def secret_key; end",
"def body_parameters\n p = Hash.new\n p\n end",
"def key_details(key_id)\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/keys/#{key_id}\", {headers: $headers}).parsed_response\nend",
"def ssl_params; end",
"def set_receipt_tps_string\r\n [@SECRET_KEY, \r\n @ACCOUNT_ID, \r\n @PARAM_HASH['RECEIPT_FORM_ID'], \r\n @PARAM_HASH['RETURN_URL'], \r\n @PARAM_HASH['DBA'], \r\n @PARAM_HASH['AMEX_IMAGE'], \r\n @PARAM_HASH['DISCOVER_IMAGE'], \r\n @receipt_tps_def].join('')\r\n end",
"def set_receipt_url\r\n if @PARAM_HASH['RECEIPT_FORM_ID']== 'remote_url'\r\n return @PARAM_HASH['REMOTE_URL']\r\n else\r\n return 'https://secure.bluepay.com/interfaces/shpf?SHPF_FORM_ID=' + @PARAM_HASH['RECEIPT_FORM_ID'] + \r\n '&SHPF_ACCOUNT_ID=' + @ACCOUNT_ID + \r\n '&SHPF_TPS_DEF=' + url_encode(@receipt_tps_def) + \r\n '&SHPF_TPS_HASH_TYPE=' + url_encode(@PARAM_HASH['RECEIPT_TPS_HASH_TYPE']) +\r\n '&SHPF_TPS=' + url_encode(@receipt_tamper_proof_seal) + \r\n '&RETURN_URL=' + url_encode(@PARAM_HASH['RETURN_URL']) + \r\n '&DBA=' + url_encode(@PARAM_HASH['DBA']) + \r\n '&AMEX_IMAGE=' + url_encode(@PARAM_HASH['AMEX_IMAGE']) + \r\n '&DISCOVER_IMAGE=' + url_encode(@PARAM_HASH['DISCOVER_IMAGE'])\r\n end\r\n end",
"def create_tps_hash(data, hash_type)\n return \"SECRET KEY NOT PROVIDED\" if !defined? @SECRET_KEY\n case hash_type \n when 'HMAC_SHA256'\n OpenSSL::HMAC.hexdigest('sha256', @SECRET_KEY, data)\n when 'SHA512'\n Digest::SHA512.hexdigest(@SECRET_KEY + data)\n when 'SHA256'\n Digest::SHA256.hexdigest(@SECRET_KEY + data)\n when 'MD5'\n Digest::MD5.hexdigest(@SECRET_KEY + data)\n else\n OpenSSL::HMAC.hexdigest('sha512', @SECRET_KEY, data)\n end\n end",
"def value_from_plist(key)\n `/usr/libexec/PlistBuddy -c 'Print :#{key}' /dev/stdin <<< $(security cms -D -i #{@mobileprovision_file})`\n end",
"def full_wp_sk text, vars\r\n\tvars_js = vars.map{|var, v| \"var #{var} = #{v.to_json};\" }.join(\"\\n\")\r\n\t\r\n\tctx = ExecJS.compile(WPSKJS + \"\\n\\n\" + BASE64JS + \"\\n\\n\" + vars_js)\r\n\t\r\n\t# we all love encodings\r\n\t# base64 prevents crazy artifacts\r\n\tnew = Base64.decode64(ctx.eval(\"Base64.encode(wp_sk.cleaner(Base64.decode(#{Base64.encode64(text.force_encoding 'binary').to_json})))\")).force_encoding('utf-8')\r\n\t\r\n\treturn new\r\nend",
"def pubek\r\n Tem::Key.new_from_ssl_key endorsement_cert.public_key\r\n end",
"def server_public_key\n raise(\"No ssl_server_public configuration option specified\") unless @config.pluginconf.include?(\"ssl_server_public\")\n return @config.pluginconf[\"ssl_server_public\"]\n end",
"def client_secret; end",
"def hash\n [allow_insecure_certificates, basic_auth, body, body_type, cookies, device_ids, follow_redirects, headers, locations, metadata, public_id, _retry, start_url, variables].hash\n end",
"def payer_auth\n params['payerAuth']\n end",
"def config\n config_yml['PAYMENT']\n end",
"def set_receipt_url\r\n if @PARAM_HASH['RECEIPT_FORM_ID']== 'remote_url'\r\n return @PARAM_HASH['REMOTE_URL']\r\n else\r\n return 'https://secure.bluepay.com/interfaces/shpf?SHPF_FORM_ID=' + @PARAM_HASH['RECEIPT_FORM_ID'] + \r\n '&SHPF_ACCOUNT_ID=' + ACCOUNT_ID + \r\n '&SHPF_TPS_DEF=' + url_encode(@receipt_tps_def) + \r\n '&SHPF_TPS=' + url_encode(@receipt_tamper_proof_seal) + \r\n '&RETURN_URL=' + url_encode(@PARAM_HASH['RETURN_URL']) + \r\n '&DBA=' + url_encode(@PARAM_HASH['DBA']) + \r\n '&AMEX_IMAGE=' + url_encode(@PARAM_HASH['AMEX_IMAGE']) + \r\n '&DISCOVER_IMAGE=' + url_encode(@PARAM_HASH['DISCOVER_IMAGE'])\r\n end\r\n end",
"def create_secret_text(**args)\n\t\t\t\t\tjson_body = {\n\t\t\t\t\t\t'' => '3',\n\t\t\t\t\t\tcredentials: args.merge(\n\t\t\t\t\t\t\t'$class' => 'org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl'\n\t\t\t\t\t\t)\n\t\t\t\t\t}.to_json\n\t\t\t\t\tcreate_(\"json=#{::CGI.escape json_body}\")\n\t\t\t\tend",
"def sign_params(method, p)\n p[:format] = 'json'\n p[:nojsoncallback] = 1\n \n if p[:auth] || p[\"auth\"] || p[:auth_token] || p[\"auth_token\"]\n p.delete(:auth)\n p.delete(\"auth\")\n sigp = p\n sigp[:method] = method\n sigp[:api_key] = @api_key\n p[\"api_sig\"] = api_sig(sigp)\n end\n \n p\n end",
"def sign_params(method, p)\n p[:format] = 'json'\n p[:nojsoncallback] = 1\n \n if p[:auth] || p[\"auth\"] || p[:auth_token] || p[\"auth_token\"]\n p.delete(:auth)\n p.delete(\"auth\")\n sigp = p\n sigp[:method] = method\n sigp[:api_key] = @api_key\n p[\"api_sig\"] = api_sig(sigp)\n end\n \n p\n end",
"def mining_hash\n Utils.keccak(rlp_encode skip_keys: [:mix_hash, :nonce])\n end",
"def public_key_data\n @public_key\n end",
"def profile_hash(details, creds)\n params = {}\n params[:api_type] = details[:api_type]\n params[:license_key] = creds[:license_key]\n params[:login_id] = creds[:login_id]\n params[:version] = details[:version]\n params\n end",
"def generate_lazada_signature(parameter_list, seller)\n api_key = seller.api_key\n #Sort parameter_list by key\n sorted_params = Hash[parameter_list.sort]\n string_to_be_formed = []\n # concatinate key value with\n sorted_params.each do |key,value|\n case key\n when \"ShippingProvider\"\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+URI::escape(\"#{value}\")\n when \"SkuSellerList\"\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\").gsub(\"+\", \"%20\")\n else\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")\n end\n end\n singnature_string = string_to_be_formed.join('&')\n #Compute signature and add it to parameters\n signature_key = OpenSSL::HMAC.hexdigest('sha256', api_key, singnature_string)\n return signature_key\n end",
"def general_payload\n payload = Hash.new\n payload['PayloadVersion'] = 1 # do not modify\n payload['PayloadUUID'] = UUIDTools::UUID.random_create().to_s # should be unique\n\n # string that show up in UI, customisable\n payload['PayloadOrganization'] = \"ACME Inc.\"\n payload\nend",
"def get_key(aliaz, password)\n\n end",
"def extra_fields_to_set\n {\n decrypted_secret_key: decrypted_secret_key\n }\n end",
"def ssh_data\n <<-SSH_DATA\n ssh-keys = \"#{@user}:#{@public_key_value}}\"\n enable-oslogin = \"FALSE\"\n SSH_DATA\n end",
"def hash\n to_pem.hash\n end",
"def hash\n to_pem.hash\n end",
"def select_host_key_verifier(verifier); end",
"def key_data; end",
"def key_data; end",
"def host_key_verifier; end",
"def signing_key; end",
"def signing_input; end",
"def signing_input; end",
"def body(method)\n {\n :ApplicationId => method,\n :RequestId => method,\n :Sessionid => method,\n :Username => @arubacloud_username,\n :Password => @arubacloud_password\n }\n end",
"def prepare_payload(pld)\n pld\n end",
"def value\n if show_secret\n secret\n else\n Digest::SHA1.hexdigest secret\n end\n end",
"def hmac_secret\n 'super_secret'\n end",
"def set_receipt_tps_string\r\n [@ACCOUNT_ID, \r\n @PARAM_HASH['RECEIPT_FORM_ID'], \r\n @PARAM_HASH['RETURN_URL'], \r\n @PARAM_HASH['DBA'], \r\n @PARAM_HASH['AMEX_IMAGE'], \r\n @PARAM_HASH['DISCOVER_IMAGE'], \r\n @receipt_tps_def,\r\n @PARAM_HASH['RECEIPT_TPS_HASH_TYPE']].join('')\r\n end",
"def get_hash_sha512_pbkdf2(user)\n begin\n shadowhashdata = user['ShadowHashData'][0]\n embedded_bplist = NSPropertyListSerialization.objc_send(\n :propertyListFromData, shadowhashdata,\n :mutabilityOption, NSPropertyListMutableContainersAndLeaves,\n :format, nil,\n :errorDescription, nil\n )\n plist = embedded_bplist.values[0].to_ruby\n resource = {}\n resource['iterations'] = plist['iterations'].to_s\n resource['salt'] = plist['salt'].description.to_ruby.gsub!(/<|>/,\"\").split.join\n resource['entropy'] = plist['entropy'].description.to_ruby.gsub!(/<|>/,\"\").split.join\n resource\n rescue\n return Hash.new\n end\n end",
"def http_query_string_sgcb\n <<-END_POST\nbody=%5B%22KOSE%E9%AB%98%E4%B8%9D%E9%9B%AA%E8%82%8C%E7%B2%BE%E6%B4%97%E9%A2%9C%E4%B9%B3%22%5D&buyer_email=18611543280&buyer_id=2088902582208882&exterface=create_direct_pay_by_user&is_success=T¬ify_id=RqPnCoPT3K9%252Fvwbh3InQ8703uAICbLI7SGaz7f3Qe96t7vC6a1YKnYuOZTls2t9kw%252F6z¬ify_time=2014-11-11+17%3A59%3A28¬ify_type=trade_status_sync&out_trade_no=R990240665&payment_type=1&seller_email=acct-ali%40shiguangcaibei.com&seller_id=2088611493982911&subject=%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%3AR990240665&total_fee=1.43&trade_no=2014111159601788&trade_status=TRADE_SUCCESS&sign=a25c543b8b84166f6c5f556c2f229fb1&sign_type=MD5\n END_POST\n .chomp!\n end",
"def client_secret=(_arg0); end",
"def hash\n [uri, parameters, username, password, verify_mode].hash\n end",
"def get_post_body(name, params)\n { 'method' => name, 'params' => params, 'id' => 'jsonrpc' }\n end",
"def set_shpf_tps_string \r\n shpf = ([@SECRET_KEY,\r\n @PARAM_HASH['SHPF_FORM_ID'], \r\n @ACCOUNT_ID, \r\n @PARAM_HASH['DBA'], \r\n @bp10emu_tamper_proof_seal, \r\n @PARAM_HASH['AMEX_IMAGE'], \r\n @PARAM_HASH['DISCOVER_IMAGE'], \r\n @bp10emu_tps_def, \r\n @shpf_tps_def].join(''))\r\n return add_string_protected_status(shpf)\r\n end",
"def public_key_params\n params.require(:public_key).permit(:body, :algorithm)\n end",
"def http_query_string\n <<-END_POST\nbody=%5B%22KOSE%E9%AB%98%E4%B8%9D%E9%9B%AA%E8%82%8C%E7%B2%BE%E6%B4%97%E9%A2%9C%E4%B9%B3%22%5D&buyer_email=18611543280&buyer_id=2088902582208882&exterface=create_direct_pay_by_user&is_success=T¬ify_id=RqPnCoPT3K9%252Fvwbh3InQ8703uAICbLI7SGaz7f3Qe96t7vC6a1YKnYuOZTls2t9kw%252F6z¬ify_time=2014-11-11+17%3A59%3A28¬ify_type=trade_status_sync&out_trade_no=R990240665&payment_type=1&seller_email=acct-ali%40shiguangcaibei.com&seller_id=2088611493982911&subject=%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%3AR990240665&total_fee=1.43&trade_no=2014111159601788&trade_status=TRADE_SUCCESS&sign=1c3e7b66a6a7e704f0ad2ed0bc25ee04&sign_type=MD5\n END_POST\n .chomp!\n end",
"def payload\n PARAMS.each_with_object({}) do |k, hash|\n hash[k] = send(k)\n end\n end",
"def to_body\r\n to_hash\r\n end",
"def key_info\n authenticated_post(\"key_info\").body\n end",
"def compute_shared_secret(server_ecdh_pubkey); end",
"def sign_key; end",
"def plugin_info\n {\n 'name' => plugin_name,\n 'description' => 'Generic authentication plugin',\n 'link' => 'http://sabre.io/dav/authentication/'\n }\n end",
"def to_hash\n body.to_hash\n end",
"def http_auth_hash; end",
"def hmac; end",
"def __prepare_body(data)\n data[:customer][:confirm_password] = data[:customer][:password]\n data[:customer][:confirm_email] = data[:customer][:email]\n\n timezone = data[:customer][:timezone]\n if timezone.empty?\n data[:customer][:timezone] = 'UTC'\n end\n\n data\n end",
"def payload(secret)\n secret.data[:data]\n end",
"def get_dphash(dpobj)\n dp_hash = Hash[\n 'ppmethod' => dpobj.at_xpath(\"postprocessormethod\").text,\n 'name' => dpobj.at_xpath(\"name\").text,\n 'desc' => dpobj.at_xpath(\"description\").text,\n 'ppparam' => dpobj.at_xpath(\"postprocessorparam\").text,\n 'alert_trigger' => dpobj.at_xpath(\"alertexpr\").text,\n 'alert_transint' => dpobj.at_xpath(\"alertTransitionIval\").text,\n 'alert_msgbody' => dpobj.at_xpath(\"alertbody\").text,\n ]\n\n return Hash[dp_hash.sort]\n end",
"def pubkey\n end",
"def api_key; @opts[:api_key]; end",
"def recieve_hash\n\t\t#recvd_json = params[:q_data]\n\t\t#p recvd_json\n\n\tend",
"def hmac_client; end",
"def public_key_params\n params[:public_key]\n end",
"def public_key_params\n params[:public_key]\n end",
"def peer_hash_defaults(phash)\n\t\t\tdata = phash.dup\n\t\t\tdata[:port] ||= 3333 # @todo Network;:DEFAULT_PORT\n\t\t\tdata[:name] ||= \"SwarmNode_#{data[:uuid]}\"\n\t\t\tdata[:hive_version] ||= hive_version\n\t\t\tdata[:handler] ||= handler_type\n\t\t\tdata[:protocol] ||= protocol_type\n\t\t\tdata[:ssl] ||= 1\n\t\t\tdata[:peers] ||= []\n\t\t\tif data[:peers].is_a?(Array)\n\t\t\t\tdata[:peers] = data[:peers].join(',')\n\t\t\tend\n#\t\t\tdata[:created_at] ||= DateTime.now.to_s\n#\t\t\tdata[:updated_at] ||= DateTime.now.to_s\n\t\t\tdata\n\t\tend",
"def generate(opts)\n if opts\n if opts[:ssid] and opts[:password]\n o, s = Open3.capture2(\"#{AIRPORT} -P --ssid #{opts[:ssid]} --password #{opts[:password]}\")\n if s.success?\n @psk = o.strip\n else\n raise WillowRunError.new(\"Unable to generate psk with SSID: #{opts[:ssid]} and PASSWORD: #{opts[:password]}\")\n end\n else\n raise WillowRunError.new(\"Unable to generate psk, requires both an ssid and password; only got: #{opts}.\")\n end\n else\n raise WillowRunError.new(\"Unable to generate psk, requires both an ssid and password.\")\n end\n @psk\n end",
"def hmac_server; end",
"def raw_params(auth); end",
"def payload_for_signed_request(payment)\n json = {\n shop: shop_id,\n amount: payment.amount,\n currency: payment.currency,\n reference: payment.order_id,\n country: @country_code,\n locale: @language,\n preferred_method: @payment_method\n }.to_json\n\n {\n json: json,\n mac: Digest::SHA512.hexdigest(json + api_secret).upcase\n }\n end",
"def auth_settings\n {\n 'apikey' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'api-key',\n value: api_key_with_prefix('api-key')\n },\n 'userid' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'user-uid',\n value: api_key_with_prefix('user-uid')\n },\n }\n end",
"def data\n @p7.to_pem\n end",
"def generate!\n raise ArgumentMissingError unless has_all_required_inputs?\n payload = Base64.urlsafe_encode64(data.to_json).gsub(/[\\=\\n]/, '')\n signature = Base64.urlsafe_encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest.new('sha256'),\n secret,\n HEADER + '.' + payload\n )\n ).strip.gsub(/[\\=\\n]/, '')\n [HEADER, payload, signature].join('.')\n end",
"def body\n {:client_id => client_id, :grant_type => :password}\n end",
"def consumer_secret; config[:consumer_secret]; end",
"def buyer_auth_result\n params['3DSecureStatus']\n end"
] | [
"0.6142206",
"0.5646437",
"0.543187",
"0.5422822",
"0.54045266",
"0.53697145",
"0.5309388",
"0.5285571",
"0.5274934",
"0.52340317",
"0.519007",
"0.51736236",
"0.5155452",
"0.5137371",
"0.513657",
"0.5126693",
"0.51163393",
"0.50850827",
"0.50850827",
"0.50850827",
"0.50826174",
"0.506712",
"0.50420094",
"0.5030999",
"0.5012728",
"0.49884894",
"0.49769098",
"0.496402",
"0.49622586",
"0.4953971",
"0.494971",
"0.4945873",
"0.49378267",
"0.49213222",
"0.49044067",
"0.4899015",
"0.48973435",
"0.48952815",
"0.48858684",
"0.48783466",
"0.48783466",
"0.4875798",
"0.4871529",
"0.48682553",
"0.48672488",
"0.48670253",
"0.4866231",
"0.48633084",
"0.4849068",
"0.48473325",
"0.48473325",
"0.4839779",
"0.4832294",
"0.4832294",
"0.48281747",
"0.48250738",
"0.4816837",
"0.4816837",
"0.48002607",
"0.47887534",
"0.4787831",
"0.47865325",
"0.4779699",
"0.47794342",
"0.47786152",
"0.4770701",
"0.47667313",
"0.476324",
"0.47629812",
"0.47626472",
"0.4762524",
"0.47597554",
"0.47566527",
"0.47543773",
"0.47470677",
"0.47282934",
"0.4726139",
"0.47238404",
"0.47174942",
"0.47172028",
"0.47163603",
"0.47084266",
"0.47013932",
"0.47008657",
"0.46985155",
"0.46861959",
"0.46851406",
"0.4685008",
"0.4685008",
"0.46781144",
"0.46754947",
"0.46735048",
"0.4669082",
"0.4661856",
"0.4661093",
"0.46576297",
"0.4657304",
"0.4657004",
"0.46556914",
"0.46511638"
] | 0.77462536 | 0 |
TODO delete this once docker image uses new selector class for clean | def max_age= max_age
self[:max_age] = max_age
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_selector(input); end",
"def build_selectors\n temp_release_docs.uniq(&:kubernetes_role_id).flat_map(&:build_selectors).uniq\n end",
"def selectors\n self.class.selectors\n end",
"def io_selector_backend(backend); end",
"def acts_as_selector\n define_method(\"is_selector?\") { true }\n end",
"def selectors\n @selectors ||= []\n end",
"def convert_selector(selector)\n if (!selector.is_a? String)\n self.quit\n raise ArgumentError, \"fatal: convert_selector() expected String, got #{selector.class}\\n\" +\n \"(#{__FILE__}:#{__LINE__})\"\n end\n # split into name, #id, .classes\n matches = /([a-zA-Z0-9_\\-\\[\\]]*)?(#[a-zA-Z0-9_\\-\\[\\]]*)?(\\.[a-zA-Z0-9_\\-\\[\\]\\.]*)?/.match(selector)\n return printf(\"No match (#{selector} ~> nil)\\n\") if matches.nil?\n pieces = {}\n pieces[:name] = matches[1]\n pieces[:id] = matches[2][1..-1] if matches[2] # Remove the leading # marker\n pieces[:class] = matches[3][1..-1].gsub(\"\\.\",\" \") if matches[3] # \".class1.class2\" => \"class1 class2\"\n pieces.delete_if{|k,v| v.to_s.empty?} # strip nil's as find_element() is silly and doesn't ignore them.\n pieces\nend",
"def selectors\n raise \"GroupControl#selectors must be implemented by subclasses!\"\n end",
"def selector\n @selector ||= _base.atomic_selector\n end",
"def selector_name\n 'summary/move_selector'\n end",
"def selections\n selector.send(selector_method) rescue nil\n end",
"def match_selector(...)\n Matchers::MatchSelector.new(...)\n end",
"def get_selector(name)\n doc = Hpricot(response.body)\n Hpricot(doc.search(\"[@id='#{name}']\").to_html)\nend",
"def generate_selector(node, full_selector)\n full_selector << node.selector\n unless node.parent.selector == 'root'\n generate_selector(node.parent, full_selector)\n end\n return full_selector\nend",
"def expire_selector\n @selector = nil\n end",
"def process_selector(selector)\n # Parse the first piece as a selector, defaulting to DIV tag if none is specified\n if selector.length > 0 and ['#', '.'].count(selector[0]) > 0\n @tag = 'div'\n else\n delimiter_index = nil\n i = 0\n for char in selector.split(\"\") do\n if ['#', '.'].count(char) > 0\n delimiter_index = i\n break\n end\n i += 1\n end\n \n if delimiter_index == nil\n @tag = selector * 1\n selector = \"\"\n else\n @tag = selector[0..delimiter_index-1]\n selector = selector[@tag.length..-1]\n end\n end\n \n @tag_id = nil\n @tag_classes = []\n while true do\n next_delimiter_index = nil\n if selector == \"\"\n break\n \n else\n i = 0\n for char in selector.split(\"\") do\n if i > 0 and ['#', '.'].count(char) > 0\n next_delimiter_index = i\n break\n end\n i += 1\n end\n \n if next_delimiter_index == nil\n if selector[0] == '#'\n @tag_id = selector[1..-1]\n elsif selector[0] == \".\"\n @tag_classes << selector[1..-1]\n end\n \n selector = \"\"\n \n else\n if selector[0] == '#'\n @tag_id = selector[1..next_delimiter_index-1]\n elsif selector[0] == \".\"\n @tag_classes << selector[1..next_delimiter_index-1]\n end\n \n selector = selector[next_delimiter_index..-1]\n end\n end\n end\n \n self\n end",
"def supported_selector?(selector)\n # This method is too slow to run in production\n return false if Rails.env.production?\n\n find_selector(selector).present?\n end",
"def >(selector); end",
"def >(selector); end",
"def methodSignatureForSelector(selector)\n super(selector)\n end",
"def select_regexp_matching_images(re_hn)\n Docker::Image.all.select { |img|\n info_map = img.info\n info_map && info_map['RepoTags'] && info_map['RepoTags'].any? { |n| n.match re_hn }\n }\nend",
"def selector\n s = @selectors.pop\n @selectors.unshift s\n s\n end",
"def selector\n @selector ||= [socket]\n end",
"def deepCss selector\n # TODO: syntax will change from /deep/ to >>> at some point.\n { css: '* /deep/ ' + selector }\n end",
"def define_selectors_(type, name, selector)\n define_method(\"#{name}_#{type}_selector\") do |text = nil|\n text ? extend_selector(selector, :text, text) : selector\n end\n\n define_method(\"#{name}_selector\") do |text = nil|\n text ? extend_selector(selector, :text, text) : selector\n end\n end",
"def get_by(selector)\n\n end",
"def define_selectors(type, name, selector)\n define_method(\"#{name}_#{type}_selector\") { selector }\n define_method(\"#{name}_selector\") { selector }\n end",
"def select_tag(name, option_tags = T.unsafe(nil), options = T.unsafe(nil)); end",
"def getSelector()\n if @meta_data[@platform].key?(:id)\n selector = @meta_data[@platform][:id]\n validator = :id\n elsif @meta_data[@platform].key?(:css)\n selector = @meta_data[@platform][:css]\n validator = :css\n elsif @meta_data[@platform].key?(:xpath)\n selector = @meta_data[@platform][:xpath]\n validator = :xpath\n else\n raise \"Can not find valid selector.\"\n end\n \n return {:selector => selector, :validator => validator}\n end",
"def select; end",
"def select; end",
"def apply( node )\n bug( \"you must override Selector.apply()\" )\n end",
"def elements(name, selector, type = nil)\n if selector.respond_to?(:__deserialise_all, true)\n @__selectors << Selector::NestedMultiple.new(name, selector, type)\n\n elsif type.respond_to?(:__deserialise_all, true)\n cloned_type = type.clone\n cloned_type.instance_variable_set(:@__root, selector)\n @__selectors << Selector::NestedMultiple.new(name, cloned_type)\n\n else\n @__selectors << Selector::Nodes.new(name, selector, type)\n end\n end",
"def css_selector *args\n tag = @tag\n type = :full\n args.each { |a|\n case\n when a.is_a?(Symbol)\n type = a\n else\n tag = a\n end\n }\n\n metaphor = (de_ref(tag) || {}.freeze)\n\n final = case\n\n when type == :full && tag?(metaphor, :group)\n css = metaphor[:children].inject([]) { |memo, c|\n if !(tag?(c, :group)) && !c[:__parent]\n memo << css_selector(c, :full)\n end\n memo\n }\n\n if css\n css.join COMMA\n else\n nil\n end\n\n when tag?(metaphor, :style)\n p = metaphor[:parent]\n if p\n css_selector p, type\n end\n\n when type == :full && parent?(metaphor, :group)\n grand_parent = metaphor[:parent][:parent]\n grand_css = grand_parent && css_selector(grand_parent, :full)\n use_grand = !(metaphor[:__] && metaphor[:__children].detect { |e| tag?(e, :_) })\n\n if grand_css && use_grand\n grand_css.split(COMMA).map { |css|\n css << SPACE << css_selector(metaphor, :tag)\n }.join COMMA\n else\n css_selector metaphor, :tag\n end\n\n when type == :tag\n id = metaphor[:id]\n name = if id\n '#' << Clean.html_id(id).to_s\n else\n metaphor[:tag_name].to_s\n end\n\n if metaphor[:class]\n name << '.'.freeze\n name.<<(\n metaphor[:class].map { |name|\n Clean.css_class_name(name.to_s)\n }.join('.'.freeze)\n )\n end\n\n if metaphor[:pseudo]\n name << \":#{metaphor[:pseudo]}\"\n end\n\n if tag[:__]\n name << SPACE << tag[:__children].map { |c|\n css_selector(c, :tag)\n }.join(SPACE)\n end\n\n name = if name.empty?\n nil\n else\n name\n end\n\n when type == :ancestor\n if metaphor[:id]\n nil\n else\n selectors = []\n p = metaphor[:parent]\n while p\n selectors.unshift(css_selector(p, :tag)) unless [:style, :group].freeze.include?(p[:tag_name])\n p = p[:id] ? nil : p[:parent]\n end # === while\n\n selectors.compact.join(SPACE)\n end\n\n else\n [css_selector(metaphor, :ancestor), css_selector(metaphor, :tag)].compact.join SPACE\n end\n\n return nil if !final || final.empty?\n final.gsub(' _!:'.freeze, ':'.freeze)\n end",
"def depatch_io\n IO.class_exec do\n class << self\n alias_method :select, :select_for_real\n end\n end\nend",
"def selector(&block)\n @selector = block if block_given?\n @selector\n end",
"def method_missing(selector, *args, &block); end",
"def grouped_collection_select(object, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def element(name, selector, type = nil)\n if selector.respond_to?(:__deserialise, true)\n @__selectors << Selector::Nested.new(name, selector)\n\n elsif type.respond_to?(:__deserialise, true)\n cloned_type = type.clone\n cloned_type.instance_variable_set(:@__root, selector)\n @__selectors << Selector::Nested.new(name, cloned_type)\n\n else\n @__selectors << Selector::Node.new(name, selector, type)\n end\n end",
"def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def selector\n @selector ||= climb({ \"_id\" => _root.id }) do |document, value|\n value[\"#{document.path}._id\"] = document.id; value\n end\n end",
"def test_06c\r\n db = build\r\n db.images.grep(/image-1/)\r\n end",
"def select(scope) # abstract\n end",
"def crop_selector driver, selector, image_location\n el = driver.find_element(:css, selector)\n image = MiniMagick::Image.open(image_location)\n image.crop \"#{el.rect.width}x#{el.rect.height}+#{el.rect.x}+#{el.rect.y}\"\n image.write(image_location)\n end",
"def country_selector\n $tracer.trace(format_method(__method__))\n\t tag = ToolTag.new(@tag.find.select.className(create_ats_regex_string(\"ats-countryfield\")), format_method(__method__))\n return CommonSelector.new(tag)\n end",
"def filter_select(match, metadata)\n # Break on container_name mismatch\n unless match.hosts.empty? || match.hosts.include?(metadata[:host])\n return false\n end\n # Break on host mismatch\n unless match.container_names.empty? || match.container_names.include?(metadata[:container])\n return false\n end\n # Break if list of namespaces is not empty and does not include actual namespace\n unless match.namespaces.empty? || match.namespaces.include?(metadata[:namespace])\n return false\n end\n\n match_labels(metadata[:labels], match.labels)\n end",
"def state_selector\n # unit_test_no_generate: state_selector, select.className(create_ats_regex_string(\"ats-usstate\"));GameStopSelector\n $tracer.trace(__method__)\n return GameStopSelector.new(ToolTag.new(get_self.select.className(create_ats_regex_string(\"ats-usstate\")), __method__), self)\n end",
"def collection_select(method, collection, value_method, text_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def resolve_specified_selectors(unresolved_specified_selectors, resolved_ignore_selectors)\n resolve_versions_and_add_ids(unresolved_specified_selectors, :specified, SelectorIgnorer.new(resolved_ignore_selectors))\n end",
"def label_selector\n {label_selector: \"cron-kubernetes-identifier=#{CronKubernetes.identifier}\"}\n end",
"def css(selector)\n raise NotImplementedError, 'query by CSS selector unsupported'\n end",
"def docker_build\n sh 'docker images | grep --quiet \"^centos *6.6-msm\"', verbose: false\nrescue RuntimeError\n sh 'docker build --tag centos:6.6-msm .', verbose: false\nend",
"def private; end",
"def click_selector(sym,id,selector_value)\n option = Selenium::WebDriver::Support::Select.new(driver.find_element(sym.to_sym,id))\n option.select_by(:text, selector_value)\n end",
"def method_type selector\n case selector\n when '.', nil then :both\n when '#' then :instance\n else :class\n end\n end",
"def method_type selector\n case selector\n when '.', nil then :both\n when '#' then :instance\n else :class\n end\n end",
"def document_selector\n attributes.fetch(:documentSelector)\n end",
"def document_selector\n attributes.fetch(:documentSelector)\n end",
"def matches?(selector); end",
"def matches?(selector); end",
"def select(elem, selector)\n case selector\n when :element then elem\n when :inner_text, :inner_html, :outer_html then elem.send(selector)\n when /^@./ then elem[selector[1..-1]]\n when /^\\$[0-9]+$/\n i = selector[1..-1].to_i\n scrape_data(elem, i..i)\n when /^\\$[0-9]+(\\.\\.\\.?[0-9]+)?$/\n m = /\\.\\.\\.?/.match(selector)\n first, last = m.pre_match[1..-1].to_i, m.post_match.to_i\n last -= 1 if m[0] == \"...\"\n scrape_data(elem, first..last)\n else raise \"invalid selector #{selector.inspect} given\"\n end\n end",
"def [] selector\n query selector\n end",
"def matching selector\n super primary_key_transform.normalize(selector)\n end",
"def credit_card_selector_hops\n $tracer.trace(__method__)\n #unit_test_no_generate: credit_card_selector_hops, get_self.select.id(\"ValidationModel_cc_type\"); GameStopMobileSelector\n return GameStopMobileSelector.new(\n ToolTag.new(get_self.select.id(\"ValidationModel_cc_type\"), __method__, self), self\n )\n end",
"def state_province_selector\n $tracer.trace(format_method(__method__))\n\t tag = ToolTag.new(@tag.find.select.className(create_ats_regex_string(\"ats-usstate\")), format_method(__method__))\n return CommonSelector.new(tag)\n end",
"def dom_class; end",
"def dom_class; end",
"def dom_class; end",
"def dom_class; end",
"def select_none; end",
"def partition_selector\n @subhash = {}\n @filters = {}\n\n partition_selector_hash @selector, []\n end",
"def osd_select\n \n end",
"def docker_execdriver() ; info[:docker_execdriver] ; end",
"def selector_string()\n return Sass::Script::String.new(environment.selector.to_s)\n end",
"def selector=(sel)\n @selector = case sel\n when nil\n {}\n when Code\n {\"$where\" => sel}\n when String\n {\"$where\" => Code.new(sel)}\n when Hash\n sel\n end\n end",
"def by_selector\n @by_selector ||= Hash.new {|h,k| h[k] = ServiceGroup.new}\n end",
"def search_image(name)\n `docker search #{name}`\n end",
"def element_selector_string\n return @parent.element_selector_string\n end",
"def select(*) end",
"def select(&block)\n @_componentable_container.select(&block)\n end",
"def parse selector\n @warned ||= false\n unless @warned\n $stderr.puts('Nokogiri::CSS::Parser.parse is deprecated, call Nokogiri::CSS.parse(), this will be removed August 1st or version 1.4.0 (whichever is first)')\n @warned = true\n end\n new.parse selector\n end",
"def test_more_summarized_selectors\n assert_selector_parses(':not(s)')\n assert_selector_parses(':not(s1, s2)')\n assert_selector_parses(':matches(s1, s2)')\n assert_selector_parses(':has(s1, s2)')\n assert_selector_parses(':has(> s1, > s2)')\n assert_selector_parses('.warning')\n assert_selector_parses('#myid')\n assert_selector_parses('[foo]')\n assert_selector_parses('[foo=\"bar\"]')\n assert_selector_parses('[foo=\"bar\" i]')\n assert_selector_parses('[foo~=\"bar\"]')\n assert_selector_parses('[foo^=\"bar\"]')\n assert_selector_parses('[foo$=\"bar\"]')\n assert_selector_parses('[foo*=\"bar\"]')\n assert_selector_parses('[foo|=\"en\"]')\n assert_selector_parses(':dir(ltr)')\n assert_selector_parses(':lang(fr)')\n assert_selector_parses(':lang(zh, *-hant)')\n assert_selector_parses(':any-link')\n assert_selector_parses(':link')\n assert_selector_parses(':visited')\n assert_selector_parses(':local-link')\n assert_selector_parses(':local-link(0)')\n assert_selector_parses(':target')\n assert_selector_parses(':scope')\n assert_selector_parses(':current')\n assert_selector_parses(':current(s)')\n assert_selector_parses(':past')\n assert_selector_parses(':future')\n assert_selector_parses(':active')\n assert_selector_parses(':hover')\n assert_selector_parses(':focus')\n assert_selector_parses(':enabled')\n assert_selector_parses(':disabled')\n assert_selector_parses(':checked')\n assert_selector_parses(':indeterminate')\n assert_selector_parses(':default')\n assert_selector_parses(':in-range')\n assert_selector_parses(':out-of-range')\n assert_selector_parses(':required')\n assert_selector_parses(':optional')\n assert_selector_parses(':read-only')\n assert_selector_parses(':read-write')\n assert_selector_parses(':root')\n assert_selector_parses(':empty')\n assert_selector_parses(':first-child')\n assert_selector_parses(':nth-child(n)')\n assert_selector_parses(':last-child')\n assert_selector_parses(':nth-last-child(n)')\n assert_selector_parses(':only-child')\n assert_selector_parses(':first-of-type')\n assert_selector_parses(':nth-of-type(n)')\n assert_selector_parses(':last-of-type')\n assert_selector_parses(':nth-last-of-type(n)')\n assert_selector_parses(':only-of-type')\n assert_selector_parses(':nth-child(n of selector)')\n assert_selector_parses(':nth-last-child(n of selector)')\n assert_selector_parses(':nth-child(n)')\n assert_selector_parses(':nth-last-child(n)')\n\n # From http://dev.w3.org/csswg/css-scoping-1/\n assert_selector_parses(':host(s)')\n assert_selector_parses(':host-context(s)')\n end",
"def remove_parent(selector); end",
"def css\n options.fetch :css, CSS_SELECTOR\n end",
"def xpath_for(selector, options = T.unsafe(nil)); end",
"def chkout_select_state\n $tracer.trace(__method__)\n #unit_test_no_generate: chkout_select_state, get_self.select.className(create_ats_regex_string(\"ats-usstate\")); GameStopMobileSelector\n return GameStopMobileSelector.new(ToolTag.new(get_self.select.className(create_ats_regex_string(\"ats-usstate\")), __method__, self), self)\n end",
"def cc_expiration_year_selector\n #unit_test_no_generate: cc_expiration_year_selector, get_self.select.className(create_ats_regex_string(\"ats-ccexpyrselector\")); GameStopSelector\n $tracer.trace(__method__)\n tag = ToolTag.new(get_self.select.className(create_ats_regex_string(\"ats-ccexpyrselector\")), __method__)\n return GameStopSelector.new(tag)\n end",
"def select_default_image\n Fog::Brightbox::Compute::ImageSelector.new(list_images).latest_ubuntu\n end",
"def parameterize_selector_name selector_name\n return selector_name unless selector_name.include?(':')\n\n params = selector_name.split(':')\n result = \"#{params.shift} p1\"\n params.each_with_index do |param, i|\n result << \",#{param}:p#{i + 2}\"\n end\n result\n end",
"def get_docker_image_id_from_name(options)\n image_id = \"none\"\n images = get_docker_image_list(options)\n images.each do |image|\n values = image.split(/\\s+/)\n image_name = values[0]\n image_id = values[2]\n if image_name.match(/#{options['name']}/)\n return image_id\n end\n end\n return image_id\nend",
"def build_selection(selectors)\n return @selected_files if selectors.empty?\n\n mode = :absolute\n\n first_rel = !!(selectors.first =~ /^[+-]/)\n\n sel = first_rel ? Set.new(@selected_files) : Set.new\n\n selectors.each do |selector|\n case selector\n when 'all'\n raise OggAlbumTagger::ArgumentError, \"Cannot use the \\\"#{selector}\\\" selector after a cumulative selector (+/-...)\" if mode == :cumulative\n sel.replace @files\n when /^([+-]?)([1-9]\\d*)$/\n i = $2.to_i - 1\n raise OggAlbumTagger::ArgumentError, \"Item #{$2} is out of range\" if i >= @files.size\n\n items = [@files.slice(i)]\n case $1\n when '-'\n sel.subtract items\n mode = :cumulative\n when '+'\n sel.merge items\n mode = :cumulative\n else\n raise OggAlbumTagger::ArgumentError, \"Cannot use the \\\"#{selector}\\\" selector after a cumulative selector (+/-...)\" if mode == :cumulative\n sel.merge items\n end\n when /^([+-]?)(?:([1-9]\\d*)-([1-9]\\d*))$/\n i = $2.to_i - 1\n j = $3.to_i - 1\n raise OggAlbumTagger::ArgumentError, \"Range #{$2}-#{$3} is invalid\" if i >= @files.size or j >= @files.size or i > j\n\n items = @files.slice(i..j)\n case $1\n when '-'\n sel.subtract items\n mode = :cumulative\n when '+'\n sel.merge items\n mode = :cumulative\n else\n raise OggAlbumTagger::ArgumentError, \"Cannot use the \\\"#{selector}\\\" selector after a cumulative selector (+/-...)\" if mode == :cumulative\n sel.merge items\n end\n else\n raise OggAlbumTagger::ArgumentError, \"Unknown selector \\\"#{selector}\\\".\"\n end\n end\n\n return sel\n end",
"def [](sel); end",
"def select_list; end",
"def clean\n # TODO: help?\n # TODO: check for unknown args\n\n # Can give the following\n # Error response from daemon: conflict: unable to delete cfc459985b4b (cannot be forced)\n # image is being used by running container a7108a524a4d\n command = \"docker images -q -f='dangling=true' | xargs docker rmi --force\"\n run command\nend",
"def selector_parse(selector)\n parse_selector(selector, :selector).to_sass_script\n end",
"def create_selector(input)\n create_node(:selector,\n :value => parse_value(input),\n :tokens => input)\n end",
"def select(*a)\n page.select selector_for(*a)\n end",
"def request_select\n end",
"def apply_latest_and_tag_to_inferred_selectors(selectors, options)\n all_pacticipant_names = all_pacticipant_names_in_specified_matrix(selectors)\n specified_names = selectors.collect{ |s| s[:pacticipant_name] }\n inferred_names = all_pacticipant_names - specified_names\n\n inferred_selectors = inferred_names.collect do | pacticipant_name |\n selector = {\n pacticipant_name: pacticipant_name,\n }\n selector[:tag] = options[:tag] if options[:tag]\n selector[:latest] = options[:latest] if options[:latest]\n selector\n end\n\n selectors + look_up_version_numbers(inferred_selectors, options)\n end",
"def selectors(arguments, options)\n colors = $stdout.tty?\n\n description = <<-END_OF_DESCRIPTION.gsub(/^ {8}/, '') # |<- 80 cols ends here\n \\e[1mSELECTORS\\e[0m\n\n \\e[1mDescription\\e[0m\n Selectors are used to identify what tests to run. Baretest knows 3 kinds of\n selectors: globs, tags and last-run-states. All of these can be preceeded\n with a minus sign (-), to negate the expression.\n Beware that you must use negated expressions only after a -- separator,\n as otherwise baretest will try to interpret them as short options (like -f).\n \n \\e[1mExample\\e[0m\n `baretest -- test/suite -test/suite/foo :a -:b %failure -%pending`\n\n This will run all tests that\n * Are in the directory test/suite or any of its subdirectories\n * Are NOT in the directory test/suite/foo, or any of its subdirectories\n * Have the tag 'a'\n * Do NOT have the tag 'b'\n * Terminated with a failure status on the last run\n * Did NOT terminate with a pending status on the last run\n \n \\e[1mGlobs\\e[0m\n * '**' recursively matches all files and directories\n * '*' wildcard, matches any amount of any character\n * '?' wildcard, matches one character \n * '{a,b,c}' alternation, matches any pattern in the comma separated list\n * Directories are equivalent to `directory/**/*` patterns\n\n \\e[1mTags\\e[0m\n Tags are preceeded with a ':'.\n Examples:\n baretest :focus\n baretest -- -:hocus\n baretest -- :focus :important -:irrelevant -:obsolete\n\n \\e[1mLast-run-status\\e[0m\n Last run states are preceeded with a %.\n * %new, %success, %failure, %error, %skipped, %pending\n * %error, %skipped and %pending are a subset of %failure\n * %pending is a subset of %skipped\n * %new matches tests that are run for the very first time\n\n END_OF_DESCRIPTION\n\n description.gsub!(/\\e.*?m/, '') unless colors\n\n puts description\n end",
"def find css_selector\n @scene.lookup css_selector\n end"
] | [
"0.6032926",
"0.58167946",
"0.5771887",
"0.56665564",
"0.5619729",
"0.55234057",
"0.5514823",
"0.5497935",
"0.5491535",
"0.54881376",
"0.5315589",
"0.5288512",
"0.52695775",
"0.5254959",
"0.52051276",
"0.5161834",
"0.51610154",
"0.5154018",
"0.5154018",
"0.5149632",
"0.5146862",
"0.5127702",
"0.51112145",
"0.5080481",
"0.50719947",
"0.50625306",
"0.50533766",
"0.5051209",
"0.5030954",
"0.5012604",
"0.5012604",
"0.4987932",
"0.498522",
"0.49808732",
"0.49775085",
"0.49438366",
"0.4942747",
"0.49419242",
"0.49370852",
"0.49331793",
"0.48799735",
"0.48741406",
"0.4863836",
"0.48632258",
"0.48502523",
"0.4836734",
"0.47981122",
"0.4791402",
"0.4778454",
"0.4778171",
"0.47732192",
"0.47563303",
"0.47530952",
"0.4749831",
"0.47383296",
"0.47383296",
"0.47301537",
"0.47301537",
"0.4727973",
"0.4727973",
"0.47219062",
"0.47164485",
"0.47128153",
"0.47070655",
"0.47057888",
"0.4704408",
"0.4704408",
"0.4704408",
"0.4704408",
"0.46992972",
"0.46983537",
"0.46942782",
"0.46929526",
"0.4689583",
"0.46545357",
"0.46480232",
"0.46342",
"0.4633025",
"0.46328422",
"0.46279988",
"0.46213895",
"0.46196583",
"0.46191004",
"0.46174622",
"0.4614195",
"0.46109632",
"0.46102172",
"0.46041748",
"0.4598788",
"0.4593754",
"0.4579565",
"0.45785946",
"0.45749888",
"0.4572071",
"0.45624602",
"0.4553588",
"0.4551173",
"0.454999",
"0.45498693",
"0.4549054",
"0.4545701"
] | 0.0 | -1 |
12 == 21 513 = 531 2017 = 2071 if no bigger digit return 1 input: a positive integer output: the next biggest integer using the same digits Rules: if there is no bigger integer return 1 return 1 if all the numbers are the same if the number is already sorted in its highest possible iteration, return 1 Algorithm: we will return 1 if all the digits are the same. we will return if the digits after being sorted are in the same state as the original integer intialiaze a local variable called combinations with the return value of the possibl permutations make the combinations whole digits by iterating over each combination and transforming it to a string and then to a integer iterate over the combinations and select the combination that is the current number select the index + 1 end | def next_bigger_num(num)
return -1 if num if num.digits.all? {|digit| digit == num[0]}
return -1 if num.digits.sort! {|a,b| b <=> a}.join.to_i == num
combinations = num.digits.permutation(num.digits.length).to_a
combinations.map! do |arr|
arr.join.to_i
end.sort!
combinations.each.with_index do |number, index|
return combinations[index + 1] if number == num
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_bigger_num(num)\r\n digits = num.digits\r\n sorted_digits = digits.sort { |a, b| b <=> a }\r\n if digits.count(digits[0]) == digits.size || digits.size < 2 || sorted_digits == digits.reverse\r\n return -1\r\n end\r\n \r\n permutation = digits.permutation.to_a.map do |sub_arr|\r\n sub_arr.join('').to_i\r\n end\r\n \r\n sorted_permutation = permutation.sort\r\n \r\n sorted_permutation.each do |current_num|\r\n return current_num if current_num > num\r\n end\r\nend",
"def solution(digits)\n\tlargest = (digits[0]+digits[1]+digits[2]+digits[3]+digits[4]).to_i\n\ti = 4\n\twhile i < digits.length\n\t\ttester = (digits[i-4]+digits[i-3]+digits[i-2]+digits[i-1]+digits[i]).to_i\n\t\tif tester > largest\n\t\t\tlargest = tester\n\t\tend \n\t\ti += 1\n\tend \n\tlargest\nend",
"def permuted_nums()\r\n\t# *2...*6 must have the same digits (and length) as the original.\r\n\t# That's why the first character must be 1.\r\n\t# And the second character must be less that 7.\r\n\trunner = 123455\r\n\tmax = 170000\r\n\twhile runner < max\r\n\t\trunner += 1\r\n\t\t\r\n\t\tmult_count = 1\r\n\t\t(2..6).each{ |mult_num| \r\n\t\t\ttmp = runner * mult_num\r\n\t\t\t\r\n\t\t\tif !is_permutation_of(tmp, runner)\r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\t\tif mult_num == 6\r\n\t\t\t\treturn runner\r\n\t\t\tend\r\n\t\t\tmult_count += 1\r\n\t\t}\r\n\tend\r\n\tputs ''\r\n\treturn false\r\nend",
"def next_bigger(n)\n return -1 if n / 10 == 0 || same_digits?(n) || biggest?(n)\n digits_array = n.to_s.chars.map(&:to_i)\n n_length = digits_array.length\n i = 1\n until i == n_length\n if digits_array[n_length - i] > digits_array[n_length - 1 - i]\n # find next bigger num from the right\n b = digits_array[(n_length - i)..-1].sort.find { |x| x > digits_array[n_length - 1 - i] }\n digits_array.insert(n_length - 1 - i, b)\n # sort everything on the right and delete inserted num\n sorted = digits_array[(n_length - i)..-1].sort!\n sorted.delete_at(sorted.index(b))\n digits_array[(n_length - i)..-1] = sorted\n return digits_array.join.to_i\n end\n i += 1\n end\nend",
"def solve\n max = nil\n\n # Start with the longest possible and work down. \n 9.downto( 1 ) do |i|\n max = Array.new( i ) {|j| 1 + j}.permutation.to_a.map! {|j| j.join.to_i}.select {|j| j.prime? }.max\n break if max\n end\n \n max\n end",
"def next_bigger(input)\n puts \"input = #{input}\"\n puts '------------------'\n puts\n puts\n\n digits = input.to_s.chars.map(&:to_i)\n\n return -1 if all_digits_are_the_same?(digits)\n\n result = input\n tail = -1\n next_tail = -1\n next_tail_digit = nil\n\n puts 'Starting iterations to find the bigger number by permutating digits from right to left...'\n puts\n while(tail.abs < digits.length && result <= input)\n next_tail = tail -1\n tail_digit = digits[tail]\n next_tail_digit = digits[next_tail]\n\n if to_number(next_tail_digit, tail_digit) > to_number(tail_digit, next_tail_digit)\n puts \"SKIPPING flipping since #{next_tail_digit}#{tail_digit} > #{tail_digit}#{next_tail_digit}\"\n else\n puts \"FLIPPING digits...\"\n puts \"digits before = #{digits}\"\n digits[tail] = next_tail_digit\n digits[next_tail] = tail_digit\n puts \"digits after = #{digits}\"\n\n result = digits.join.to_i\n\n puts \"tail = #{tail} digit = #{tail_digit}\"\n puts \"next_tail = #{next_tail} digit = #{next_tail_digit}\"\n puts \"result = #{result}\"\n end\n\n tail -= 1\n puts \"new_tail = #{tail}\"\n puts '--'\n puts ''\n end\n\n return -1 if result == input\n\n replaced_digit = next_tail_digit\n winning_digit = digits[next_tail]\n\n puts\n puts \"Iterations Completed and Bigger number found: #{result}\"\n puts \" - Digit that won was: #{winning_digit}.\"\n puts \" - It replaced the digit: #{replaced_digit} from input: #{input} at index #{next_tail}.\"\n puts\n puts \"Let see if we can make the number smaller by sorting the numbers to the right from bigger to smaller\"\n\n digits_before = digits.slice(0..next_tail)\n digits_after = digits.slice((next_tail+1)..-1)\n sorted_digits_after = sort_desc(digits_after)\n\n puts\n puts \"digits_before: #{digits_before}, digits_after: #{digits_after}\"\n puts \"Sorting digits after: #{sorted_digits_after}\"\n puts \"Resulting Number: #{array_to_number(digits_before + sorted_digits_after)}\"\n puts\n puts \"Now let see if we can find any number to the right of the winning position that\" \\\n \" is smaller than the number that won #{winning_digit} but bigger than the replaced digit #{replaced_digit}...\"\n\n index_of_digit_smaller_than_winner = sorted_digits_after.find_index { |d| d < winning_digit && d > replaced_digit }\n\n if index_of_digit_smaller_than_winner\n digit_smaller_than_the_winner = sorted_digits_after[index_of_digit_smaller_than_winner]\n puts\n puts \"We found it one! Since the array was already sorted we can trust that the one we found is the smalles one.\"\n puts \"Index: #{index_of_digit_smaller_than_winner} and number: #{digit_smaller_than_the_winner}\"\n puts \"Lets switch the winning number by this one now.\"\n puts \"Before: #{digits_before} + #{sorted_digits_after}\"\n\n digits_before[-1] = digit_smaller_than_the_winner\n sorted_digits_after[index_of_digit_smaller_than_winner] = winning_digit\n\n puts \"After: #{digits_before} + #{sorted_digits_after}\"\n puts\n puts \"We now have to sort the digits again because they may be out of order:\"\n sorted_digits_after = sort_desc(sorted_digits_after)\n puts \"After Re-Sorting: #{digits_before} + #{sorted_digits_after}\"\n puts\n end\n\n result = digits_before + sorted_digits_after\n result.join.to_i\nend",
"def solution(digits)\n\tstop = digits.length - 4\n\tgo = 0\n\tlargest_number = 0\n\tindex = 0\n\n\twhile go < stop\n\t\ttest = \"\"\n\t\textra_index = index\n\t\t5.times do \n\t\t\ttest += digits[extra_index].to_s\n\t\t\textra_index += 1 \n\t\tend\n\t\tif test.to_i > largest_number\n\t\t\tlargest_number = test.to_i\n\t\tend \n\t\tindex += 1\n\t\tgo += 1 \n\tend \n\tlargest_number\nend",
"def next_smaller(n)\n result = n.digits.permutation.select { |p| p.join.to_i < n && p.first != 0 }\n result.empty? ? -1 : result.last.join.to_i\nend",
"def solution(digits)\n digits.chars.each_cons(5).max_by(&:itself).join.to_i\nend",
"def PermutationStep(num)\n possibilities = []\n possibilities = num.to_s.chars.map(&:to_i).permutation.to_a\n possibilities.reject! {|comb| comb.join.to_i <= num}\n possibilities.map! {|comb| comb.join.to_i}\n possibilities.empty? ? -1 : possibilities.min\nend",
"def biggest_possible_digit_factorial\n digits = 1\n \n loop do \n digits += 1\n break if digits * factorial(9) < ('9' * digits).to_i\n end\n ('9' * digits).to_i\nend",
"def solution(digits)\n greatest = 0\n (0..(digits.size - 1)).each do |pos|\n num = digits[pos..pos+5].to_i\n greatest = num if num > greatest\n end\n greatest \nend",
"def min_permutation n\n n.to_s.chars.sort.join.to_i\nend",
"def solution(digits)\n digits.split('').each_cons(5).max.join.to_i\nend",
"def solution(digits)\n digits.to_s.split(\"\").each_cons(5).max.join.to_i\nend",
"def comb n\n #if integer has more than 1 digit \n if n >= 10\n #if the first digit is less than the second digit of the integer\n if get_first_digit(n) < get_first_digit(drop1(n))\n #switch first and second digits, continue combing\n (round_1_sig_fig(drop1(n)) * 10) + comb( (round_1_sig_fig(n) / 10) + drop1(drop1(n)) )\n else\n #digits are in correct positions, contiune combing\n round_1_sig_fig(n) + comb(drop1(n))\n end\n else\n #last digit reached, comb finshed.\n n\n end\n\nend",
"def max_permutation n\n min_permutation(n).to_s.reverse.ljust(4, '0').to_i\nend",
"def greatest_adjacent_product\n the_number = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\n digits = 13\n number_array = the_number.to_s.split('')\n current_test_array = []\n greatest_product = 0\n current_iter = 0\n while current_iter < 987\n for i in 0..12 do current_test_array[i] = number_array[i + current_iter].to_i end\n # for i in 0..12\n # current_test_array[i] = number_array[i + current_iter]\n # end\n temp_product = 1\n current_test_array.each { |num| temp_product *= num }\n greatest_product = temp_product if temp_product > greatest_product\n current_iter += 1\n end\n greatest_product\nend",
"def greatest_product(digits)\r\n\t# Get Number in one string. Can probably do this with greater optimization\r\n\tnumber = \"73167176531330624919225119674426574742355349194934\"\r\n number += \"96983520312774506326239578318016984801869478851843\"\r\n\tnumber += \"85861560789112949495459501737958331952853208805511\"\r\n\tnumber += \"12540698747158523863050715693290963295227443043557\"\r\n\tnumber += \"66896648950445244523161731856403098711121722383113\"\r\n\tnumber += \"62229893423380308135336276614282806444486645238749\"\r\n\tnumber += \"30358907296290491560440772390713810515859307960866\"\r\n\tnumber += \"70172427121883998797908792274921901699720888093776\"\r\n\tnumber += \"65727333001053367881220235421809751254540594752243\"\r\n\tnumber += \"52584907711670556013604839586446706324415722155397\"\r\n\tnumber += \"53697817977846174064955149290862569321978468622482\"\r\n\tnumber += \"83972241375657056057490261407972968652414535100474\"\r\n\tnumber += \"82166370484403199890008895243450658541227588666881\"\r\n\tnumber += \"16427171479924442928230863465674813919123162824586\"\r\n\tnumber += \"17866458359124566529476545682848912883142607690042\"\r\n\tnumber += \"24219022671055626321111109370544217506941658960408\"\r\n\tnumber += \"07198403850962455444362981230987879927244284909188\"\r\n\tnumber += \"84580156166097919133875499200524063689912560717606\"\r\n\tnumber += \"05886116467109405077541002256983155200055935729725\"\r\n\tnumber += \"71636269561882670428252483600823257530420752963450\"\r\n\t\r\n\tanswer = 0\r\n\r\n\t# Run through all possible 13 digit combinations\r\n\t(0..number.length-digits).each do |x|\r\n\t\t# Set localized product to the first digit in combo\r\n\t\tproduct = number[x].to_i\r\n\t\t# Multiply the rest of the digits in combo together\r\n\t\t((x+1)...x+digits).each do |n|\r\n\t\t\tproduct *= number[n].to_i\r\n\t\tend\r\n\t\t# If localized product is highest so far, set to answer\r\n\t\tanswer = product if product > answer\r\n\tend\r\n\tputs answer\r\nend",
"def max_number(n)\nn = n.to_s\narr = []\n n.length.times do |i|\n arr << n[i].to_i\n end\narr.sort!.reverse!\nstr= \"\"\narr.each do |i| str = str + \"#{i}\"\nend\nstr.to_i\nend",
"def solution(n)\n max = 0\n tmp = 0\n n.to_s(2).each_char do |s|\n if s == \"0\"\n tmp += 1\n else\n max = [tmp, max].max\n tmp = 0\n end\n end\n max\nend",
"def maxNumber(num)\n \n num.digits.sort {|a,b| b <=> a}.join.to_i\n \nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def solution(n)\n n.to_s(2).reverse.to_i.to_s.split('1').map(&:length).max || 0\nend",
"def solution(n)\n binary_n = convert_to_binary(n)\n current, longest = 0, 0\n seen_start_one = false\n seen_end_one = false\n\n binary_n.each_char do |c|\n if c == \"0\"\n current += 1\n longest = [longest, current].max\n else\n current = 0\n end\n end\n\n longest\nend",
"def max_product(num, adjacent_digits)\r\n\tnum_array = ((num.to_s).split '').map { |i| i.to_i }\r\n\tmax_product_of_sub_array = 0\r\n\tmax_sub_array = []\r\n\tindex = 1\r\n\twhile (num_array.length - index) >= (adjacent_digits - 1)\r\n\t\tsub_array = num_array[(num_array.length-index - (adjacent_digits - 1))..(num_array.length-index)]\r\n\t\t\r\n\t\tproduct_of_sub_array = sub_array.reduce(:*)\r\n\t\tif product_of_sub_array > max_product_of_sub_array\r\n\t\t\tmax_sub_array = sub_array\r\n\t\t\tmax_product_of_sub_array = product_of_sub_array\r\n\t\tend\r\n\t\t\r\n\t\tindex += 1\r\n\tend\r\n\tputs max_sub_array.to_s\r\n\treturn max_product_of_sub_array\r\nend",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def permutation_step(num)\r\n perms = num.to_s.chars.map {|x| x.to_i}.permutation.to_a.map do |perm_arr|\r\n perm_arr.map {|x| x.to_s}.join.to_i\r\n end\r\n\r\n perms.select {|n| n > num}.min.nil? ? -1 : perms.select {|n| n > num}.min\r\nend",
"def solution(n)\n # write your code in Ruby 2.2\n a = n.to_s(2)\n arr = []\n if a[-1] == '1'\n arr = a.split('1')\n else\n arr = a.split('1')\n arr.pop\n end\n if arr.max.nil?\n 0\n else\n arr.max.length\n end\nend",
"def highestProductOfConsecutiveDigits( seriesLength )\n longNum = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450'\n\n largestProduct = 1\n\n Range.new( 0, longNum.length - seriesLength ).each do | pos |\n slice = longNum[ pos, seriesLength ]\n newProduct = 1\n slice.each_char do | digit |\n newProduct *= digit.to_i\n end\n largestProduct = newProduct if newProduct > largestProduct\n end\n\n return largestProduct\nend",
"def solution(digits)\n result = 0\n digits.size.times do |n|\n new_number = digits[n...(n + 5)].to_i\n result = new_number if new_number > result\n end\n result\nend",
"def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend",
"def number_shuffle(number)\n no_of_combinations = number.to_s.size == 3 ? 6 : 24\n digits = number.to_s.split(//)\n combinations = []\n combinations << digits.shuffle.join.to_i while \n combinations.uniq.size!=no_of_combinations\n combinations.uniq.sort\nend",
"def next_bigger(input) \n\treturn -1 if input <= 10\n\treversed_input = input.to_s.split(\"\").reverse.map { |m| m.to_i } # = [7,1,0,2]\n\treversed_input.each_with_index do |m,i|\n if m > reversed_input[i+1] # 7 > 1 then switch and break\n \tswitch = reversed_input[i+1]\n \treversed_input[i+1] = m\n \treversed_input[i] = switch\n \tbreak\n end \n\tend # reversed_input = [1,7,0,2] \n reversed_input.reverse.join(\"\").to_i # returns 2071\nend",
"def problem8(text)\n\tdigits = text.split('').map {|x| x.to_i }\n\t\n\treturn -1 if digits.length < 5\n\ti = 0\n\tj = 4\n\t\n\tmax = 1\n\tdigits[0..4].each do |d|\n\t\tmax *= d\n\tend\n\t\n\tmaxdigits = digits[0..4]\n\t\n\tbuffernum = max\n\twhile j < (digits.length - 1)\n\n\t\t#pop left digit\n\t\tif digits[i] == 0\n\t\t\tbuffernum = 1\n\t\t\tdigits[i+1..j].each { |x| buffernum *= x}\n\t\t\tputs buffernum\n\t\telse\n\t\t\tbuffernum /= digits[i]\n\t\tend\n\t\ti += 1\n\n\t\t#push right digit\n\n\t\tj += 1\n\t\tbuffernum *= digits[j]\n\t\tif buffernum > max\n\t\t\tmax = buffernum\n\t\t\tmaxdigits = digits[i..j]\n\t\tend\n\t\t\n\n\n\tend\n\t\n puts \"Max Product : #{max}\"\n\tputs \"Max Digits : #{maxdigits}\"\n\t\n\t\nend",
"def largest_palindrome_for_even_digits(n)\n max_val = 0\n multiplier_x = get_multiplier_x(n)\n n.downto(100) { |y|\n multiplier_x.each { |x|\n product = x * y\n if product.to_s == product.to_s.reverse\n max_val = [max_val, product].max\n end\n }\n }\n max_val\nend",
"def number_shuffle(number)\n no_of_combinations = number.to_s.size == 3 ? 6 : 24\n digits = number.to_s.split(//)\n combinations = []\n combinations << digits.shuffle.join.to_i while combinations.uniq.size!=no_of_combinations\n combinations.uniq.sort\nend",
"def find_mult_3(num)\n nums = num.digits\n i = 1\n array = []\n until i > nums.count\n a = nums.permutation(i).to_a.map{ |num| num.join.to_i }\n b = a.select{|num| num != 0 && num % 3 == 0}\n array << b.uniq\n i += 1\n end\n result = array.flatten.uniq\n return [result.count, result.max]\nend",
"def digit_factorial_equal(max)\n solutions = []\n (3..max).each do |num|\n solutions << num if num == digit_factorial_sum(num)\n end\n puts solutions.inject(:+)\nend",
"def max_rotation(num)\n arr = num.to_s.split(\"\")\n first_rotation = arr[1..-1] + [arr[0]]\n result = first_rotation\n if arr.size == 1\n return num\n elsif arr.size == 2\n return first_rotation.join.to_i\n else\n rotation_times = first_rotation.size - 2\n\n 1.upto(rotation_times) do |i|\n rotating_digit = result.delete_at(i)\n result.push(rotating_digit)\n end\n end\n return result.join.to_i\nend",
"def largest_possible_product(num_of_digits)\n return ((\"9\" * num_of_digits).to_i) ** 2\nend",
"def findLargestProduct\n \n solution = 0\n last = 4\n n = \"73167176531330624919225119674426574742355349194934969835203127745063262395783180169\n 8480186947885184385861560789112949495459501737958331952853208805511125406987471585238630\n 5071569329096329522744304355766896648950445244523161731856403098711121722383113622298934\n 2338030813533627661428280644448664523874930358907296290491560440772390713810515859307960\n 8667017242712188399879790879227492190169972088809377665727333001053367881220235421809751\n 2545405947522435258490771167055601360483958644670632441572215539753697817977846174064955\n 1492908625693219784686224828397224137565705605749026140797296865241453510047482166370484\n 4031998900088952434506585412275886668811642717147992444292823086346567481391912316282458\n 6178664583591245665294765456828489128831426076900422421902267105562632111110937054421750\n 6941658960408071984038509624554443629812309878799272442849091888458015616609791913387549\n 9200524063689912560717606058861164671094050775410022569831552000559357297257163626956188\n 2670428252483600823257530420752963450\"\n dataArray = n.chars.map(&:to_i)\n\n (0..995).each do |start| \n possible_sol = dataArray[start..last].inject(:*)\n \tsolution = possible_sol if possible_sol > solution \n \tlast += 1\n end\n\n solution\n\nend",
"def solution(n)\n # write your code in Ruby 2.2\n bin = n.to_s(2)\n return 0 unless bin =~ /0/i\n\n max = 0\n count = 0\n\n bin.each_char do |s|\n if s == '1'\n max = count if count > max\n count = 0\n else\n count += 1\n end\n end\n\n return max\nend",
"def lowest_number(number_list)\n number_list.map(&:to_s)\n .permutation\n .map(&:join)\n .map(&:to_i)\n .min\nend",
"def solution(n)\n # write your code in Ruby 2.2\n max = 0\n count = 0\n\n n.to_s(2).sub(/^0*/, '').each_char do |d|\n if d == '0'\n count += 1\n else\n max = count if max < count\n count = 0\n end\n end\n \n max\nend",
"def solution(a)\n numbers = a.sort\n (0..numbers.length-3).each do |index|\n triplet = numbers[index..index + 2]\n max_value = triplet.max\n sum = triplet.min(2).inject(&:+)\n\n return 1 if sum > max_value\n end\n\n 0\nend",
"def largest_number(nums)\n nums.map { |x| x.to_s }.sort { |x, y| (x + y) <=> (y + x) }.reverse.join.sub(/^0+/, \"0\")\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend",
"def solve(nums)\n sorted = nums.sort\n largest = 0\n (0...sorted.length - 1).each do |i|\n if (sorted[i+1] - sorted[i]) > largest\n largest = (sorted[i+1] - sorted[i])\n end\n end\n return largest\n\nend",
"def solution(digits)\n digits.scan(/\\d{5}/).max.to_i\nend",
"def max_rotation(nums)\n digits = nums.digits.reverse\n n = 0\n digits.size.times do\n rotated_num = digits[n..-1].shift\n digits.delete_at(n)\n digits = digits.push(rotated_num)\n n += 1\n end\n digits.join.to_i\nend",
"def number_shuffle(number)\n no_of_combinations = number.to_s.size == 3 ? 6 : 24\n digits = number.to_s.split(//)\n combinations = []\n combinations << digits.shuffle.join.to_i while\n combinations.uniq.size!=no_of_combinations\n combinations.uniq.sort\n\n end",
"def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend",
"def max_rotation(int)\n rotated = int\n count = int.digits.size\n\n until count < 2\n rotated = rotate_rightmost_digits(rotated, count)\n count -= 1\n end\n rotated\nend",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def largest_product_series(number, length)\n x = [1]\n string = number.to_s\n (string.length - length).times do |i|\n array = []\n length.times do \n array << string[i].to_i\n i += 1\n end\n if array.inject(:*) > x.inject(:*)\n x = array\n end\n end\n p x\n p x.inject(:*)\nend",
"def lex_permutation(n, digits)\n fact = factorial(digits.size-1)\n lead_digit = n / fact\n count = lead_digit * fact\n perms = (digits - [lead_digit]).permutation.to_a\n ([lead_digit] + perms[n - count - 1]).join\nend",
"def largest_palindrome_product\n # palindromes = palindromes.reverse\n integer = 999\n n = 0\n while palindromes.reverse[n] % integer != 0\n while palindromes.reverse[n] % integer != 0 && integer > 99\n integer -= 1 \n end\n n += 1\n end\n palindromes.reverse[n]\nend",
"def max_rot(n)\n result = n\n n = n.to_s.chars\n len = n.length - 1\n n.each.with_index do |_value, i|\n n.push(n[i])\n n.delete_at(i)\n temp = n.join('').to_i\n if temp > result\n result = temp\n elsif i == len\n puts result\n return result\n end\n end\nend",
"def solution(n, a)\n counter = [0] * n\n counter_max, max = 0, 0\n\n a.each do |c|\n i = c-1\n\n if c == n + 1\n counter_max = max\n else\n # should ensure start number after max_counter applied\n counter[i] = counter_max if counter[i] < counter_max\n counter[i] += 1\n\n max = [max, counter[i]].max\n end\n end\n\n # should ensure start number after max_counter applied\n counter.map { |c| [c, counter_max].max }\nend",
"def solution(a)\n min_index = nil\n max_index = nil\n\n a.each_with_index do |num, index|\n if index < a.length-1\n if num > a[index + 1]\n min_index = index\n break\n end\n end\n end\n\n reversed_array = a.reverse\n\n reversed_array.each_with_index do |num, index|\n if index < reversed_array.length-1\n if num < reversed_array[index + 1]\n max_index = a.length - index - 1\n break\n end\n end\n end\n\n if min_index.nil? && max_index.nil?\n return 0\n end\n\n until a.sort == a[0...min_index] + a[min_index..max_index].sort + a[max_index+1..-1]\n minimum_in_sub = a[min_index..max_index].sort.first\n maximum_in_sub = a[min_index..max_index].sort.last\n\n new_min_index = a[0...min_index].reverse.index(a[0...min_index].reverse.find{|n| n >= minimum_in_sub})\n\n if new_min_index\n min_index = min_index - new_min_index - 1\n end\n\n new_max_index = a[max_index+1..-1].index(a[max_index+1..-1].find{|n| n <= maximum_in_sub})\n\n if new_max_index\n max_index = max_index + new_max_index + 1\n end\n end\n\n max_index - min_index + 1\nend",
"def delete_digit_x(n)\n n.digits.reverse.combination(n.digits.size-1).max.join.to_i\nend",
"def delete_digit(n)\n (s = n.to_s.chars).combination(s.size-1).max.join.to_i\nend",
"def largest_consecutives_5(number)\n\tnumber = number.split('')\n\tproduct= 0 \n\n\twhile number.size > 0\n\t\tnew_product = number[0].to_i * number[1].to_i * number[2].to_i * number[3].to_i * number[4].to_i \n#convert the splitted digits to single ones\n\t\tproduct = new_product > product ? new_product : product\n #if the new product is greater than the original, then the new_product becomes the original. if true, the variable before the ':' will pass. if not, the latter\n \t\tnumber.shift\n #removes the first number and returns it\n \tend\n \tproduct\n end",
"def greatest_product(n)\r\n\r\n num_array = n.gsub(/\\n/,'').split('').map(&:to_i)\r\n max = 0\r\n i = 0\r\n while i < num_array.length - 13\r\n sum = num_array[i..i+12].reduce(:*)\r\n if sum > max\r\n max = sum\r\n end\r\n i += 1\r\n end\r\n max\r\nend",
"def largestPalindromicNumber(n_digits)\n # palindromes = []\n startPoint = (10**n_digits-1)**2\n endPoint = (10**(n_digits-1))**2\n i = startPoint\n while i >= endPoint do\n if isAPalindrome(i) && isNumAProductOfTwoNDigitNumbers(i, n_digits)\n puts i\n return i\n end\n i -= 1\n end\n p 'no product/palindromes found'\nend",
"def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def largest_palindrome(digits)\n\tnumbers = []\n\tx = (\"9\"*digits).to_i\n\ty = (\"9\"*digits).to_i\n\tlimit = ((\"9\"*(digits-1)).to_i)\n\twhile x > limit\n\t\ty.downto(limit+1) do |i|\n\t\t\tx*i == (x*i).to_s.reverse.to_i ? numbers << x*i : \"\"\n\t\tend\n\t\tx -= 1\n\tend\n\treturn numbers.sort.last\nend",
"def find_three_num_combos(nums)\n combos = []\n 0.upto(nums.size - 3) do |i1|\n 1.upto(nums.size - 2) do |i2|\n 2.upto(nums.size - 1) do |i3|\n combos << [nums[i1], nums[i2], nums[i3]] if i3 > i2 && i2 > i1\n end\n end\n end\n combos\nend",
"def GetLargestPalindromic\r\n @product = 0\r\n \r\n @size.downto(1) { |i|\r\n @size.downto(1) { |j|\r\n @product = i * j\r\n \r\n if IsPalindromic(@product)\r\n puts \"Largest Palindromic = #{@product}\"\r\n return\r\n end\r\n }\r\n }\r\n\r\n puts \"Largest Palindromicaa = #{@product}\"\r\n end",
"def largest_palindrome(num_of_digits)\r\n\tmax_number_string = \"\"\r\n\tnum_of_digits.times { max_number_string += \"9\"}\r\n\tmax_product = max_number_string.to_i ** 2\t\t# e.g: 999* 999 = 998001\r\n\t\r\n\tsub_string = (max_product.to_s)[0..(max_product.to_s).length/2 - 1]\r\n\tsub_string_number = sub_string.to_i \r\n\t\r\n\tdelta = 1\r\n\tdelta.upto(sub_string_number) { |x|\r\n\t\tpalindrome = ((sub_string_number - x).to_s + (sub_string_number - x).to_s.reverse).to_i\r\n\t\t\r\n\t\tfactor = sub_string_number\r\n\t\tfactor.downto(10**(num_of_digits - 1)) { |div|\r\n\t\t\treturn div, (palindrome/div) if (palindrome % div == 0) and (palindrome/div).to_s.length == num_of_digits\r\n\t\t}\r\n\t}\r\nend",
"def decent_num num\n\n arr = []\n\n if num % 5 == 0\n arr << (\"3\"*num).to_i\n end\n\n num.downto(1).each do |fi|\n th = num - fi\n if th % 5 == 0 && fi % 3 == 0\n arr << (\"5\"*fi + \"3\"*th).to_i\n break\n end\n end\n\n\n if arr.empty?\n -1\n else\n arr.max\n end\n\nend",
"def solution(n)\n # write your code in Ruby 2.2\n max_gap, current_gap, one_detected = 0, 0, false\n\n bin = n.to_s(2).split(\"\")\n\n bin.each do |elem|\n one_detected = true if elem == \"1\"\n if one_detected && elem == \"0\"\n current_gap += 1\n else\n current_gap = 0\n end\n max_gap = current_gap if current_gap > max_gap\n end\n\n return max_gap\nend",
"def greatest_product(n)\n idx = 0\n largest_product = 0\n\n loop do\n sum = n[idx, 5].chars.map(&:to_i).inject { |mem, num| mem * num }\n largest_product = sum if sum > largest_product\n idx += 1\n break if idx >= n.length - 4\n end\n largest_product\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend",
"def max_rotation(number)\n num_array = number.to_s.split(//)\n rotation = num_array.length\n loop do\n break if rotation == 1\n number = rotate_rightmost_digits(number, rotation)\n rotation -= 1\n end\n number\nend",
"def solution(a)\n # write your code in Ruby 2.2\n a.sort!\n min =1\n a.each{|x|\n if (x==min)\n min = min+1\n end\n }\n return min\nend",
"def biggest(nums)\n n = nums.map(&:to_s).sort{ |k,l| l+k <=> k+l }.join\n n.to_i == 0 ? '0' : n\nend",
"def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend",
"def solution_reg(n)\n n.to_s(2)\n .scan(/(?<=1)0+(?=1)/)\n .map(&:length)\n .max.to_i\nend",
"def selection_sort3(array)\n n = array.length\n n.times do |i|\n # assume the min number is the leftmost one, until proven otherwise\n minimum_index = i\n # checking all the digits to the right of i\n ((i + 1)..n - 1).each do |j|\n # if one of those digits is smaller than the one at i, we have a new min\n minimum_index = j if array[j] < array[minimum_index]\n end\n # once the min has been found, we swap it with the leftmost one.\n array[i], array[minimum_index] = array[minimum_index], array[i]\n p array\n end\n array\nend",
"def lrg_product(digits)\r\n num = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\r\n\r\n products = []\r\n\r\n # Convert to string then to array and back to integers\r\n num_str = num.to_s.split(\"\").map {|x| x.to_i}\r\n\r\n num_str.each_cons(digits) do |a|\r\n products << a.inject(:*)\r\n end\r\n\r\n products.max\r\nend",
"def largest_palindrome_product\n largest_palindrome = 0\n\n 999.downto(100) do |i|\n i.downto(100) do |j|\n result = i * j\n largest_palindrome = result if result > largest_palindrome && result.to_s == result.to_s.reverse\n break if result <= largest_palindrome\n end\n end\n largest_palindrome\nend",
"def greatest_product(n, start_index = 0, greatest_product = 0)\n while start_index < (n.length - 4)\n product = n[start_index, 5].chars.map(&:to_i).reduce(:*)\n greatest_product = product if product > greatest_product\n start_index += 1\n end\n greatest_product\nend",
"def longest_sequence(num, numbers)\n\tputs \"calculating for #{num}; #{100*num / 999983}% complete\"\n\tresults = [0]\n\tleft,right = 0,0\n\tsum = numbers[0]\n\twhile numbers[left] < num\n# \t\tputs \"sum=#{sum}\"\n# \t\tputs \"real sum=#{numbers[left..right].sum}\"\n\t\tcase sum <=> num\n\t\t\twhen -1: right += 1; sum += numbers[right]\n\t\t\twhen 0: results << (right - left + 1) ; sum-= numbers[left]; left+=1\n\t\t\twhen 1: sum-= numbers[left]; left+=1\n\t\tend\n\t\t\t\t\n\tend\n\treturn results.max\nend",
"def number_shuffle(number)\n digits = number.to_s.split(//).uniq\n factorial = (1..digits.length).inject(:*) || 1\n\n res = []\n res << digits.shuffle.join.to_i while res.uniq.size != factorial\n\n res.uniq.sort\nend",
"def solution(n)\n open = false\n current = 0\n max = 0\n begin\n if n % 2 == 1\n open = true\n max = [max, current].max\n current = 0\n else\n current += 1 if open\n end\n end while (n /= 2) > 0\n max\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(arr.size - 1) do |i|\n sub_arr = arr[i..-1]\n rot_arr = sub_arr[1..-1] + [sub_arr[0]]\n arr[i..-1] = rot_arr\n end\n arr.join.to_i\nend",
"def find_max_nth_power(n)\r\n\tnum_of_digits = 2\r\n\r\n\t(num_of_digits += 1) until (num_of_digits * 9 ** n) < ((\"9\" * num_of_digits).to_i + 1)\r\n\r\n\t(\"9\" * (num_of_digits)).to_i\r\nend",
"def greatestProduct(num)\n numArr = num.to_s.split('')\n windowSize = 12\n maxProduct = -1\n for currentWindowStartIndex in 0...(numArr.count - windowSize) do\n currentProduct = numArr[currentWindowStartIndex..(currentWindowStartIndex + windowSize)].inject(1) { |result, element | result * element.to_i }\n if currentProduct > maxProduct\n maxProduct = currentProduct\n end\n end\n return maxProduct\nend",
"def max_rotation(int)\n int_digits = int.to_s.length\n rotation_iterations = int_digits - 1\n rotated_number = int\n rotation_iterations.times { |iteration| rotated_number = rotate_rightmost_digits(rotated_number, int_digits - iteration) }\n rotated_number\nend",
"def max_rotation(num)\n num_out = num\n num.to_s.length.downto(1) {|n|\n num_out = rotate_rightmost_digits(num_out, n)\n }\n num_out.to_i\nend",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def combinations(num_digits)\n combos = []\n (1..num_digits).each do |len|\n combos += (0...num_digits).to_a.combination(len).to_a\n end\n combos\nend",
"def featured(int)\n next_num = 0\n loop do\n next_num = int.succ\n break if next_num.odd? && next_num % 7 == 0\n int = next_num\n end\n loop do\n break if next_num >= 9_876_543_210\n if next_num.to_s.chars.uniq == next_num.to_s.chars\n return next_num\n else next_num += 14\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend",
"def max_rot(num)\n numbers = []\n array = num.to_s.split('').map! {|x|x.to_i}\n i = 0\n while i < num.to_s.length\n array.insert(-1, array.delete_at(i))\n numbers << array.join('').to_i\n i+=1\n end\n numbers << num\n # numbers.uniq!.max\nend"
] | [
"0.7711993",
"0.7032367",
"0.70059085",
"0.69975924",
"0.69776857",
"0.69644326",
"0.69474304",
"0.69390625",
"0.6934768",
"0.69321847",
"0.68976086",
"0.68664044",
"0.6816182",
"0.68135726",
"0.6739254",
"0.6727198",
"0.66841376",
"0.6656685",
"0.6629968",
"0.66275394",
"0.6619398",
"0.66036713",
"0.6596074",
"0.6577764",
"0.6550112",
"0.65445274",
"0.6536776",
"0.65209013",
"0.6514268",
"0.6511855",
"0.648504",
"0.64837086",
"0.64781475",
"0.6462767",
"0.6459964",
"0.64554864",
"0.64539325",
"0.645297",
"0.6449516",
"0.6420092",
"0.6419785",
"0.6412241",
"0.64109516",
"0.6402702",
"0.6391268",
"0.63862455",
"0.63693595",
"0.6356735",
"0.635174",
"0.6332629",
"0.63317126",
"0.63184214",
"0.63057625",
"0.6275123",
"0.6266401",
"0.6263677",
"0.6257939",
"0.6255776",
"0.6248126",
"0.62404466",
"0.62351364",
"0.62232345",
"0.6221391",
"0.6212357",
"0.61894923",
"0.6179731",
"0.61654484",
"0.61586714",
"0.61536485",
"0.61532015",
"0.61508006",
"0.61452353",
"0.6118176",
"0.6088539",
"0.6088203",
"0.60736823",
"0.6073101",
"0.6070226",
"0.60661155",
"0.60658014",
"0.6062402",
"0.60598326",
"0.60588306",
"0.60553604",
"0.6048876",
"0.60473806",
"0.60436267",
"0.60419077",
"0.6037621",
"0.6037568",
"0.6037489",
"0.60374165",
"0.6035995",
"0.60329014",
"0.6032062",
"0.60261965",
"0.60255355",
"0.602544",
"0.6020628",
"0.60114926"
] | 0.82220703 | 0 |
Complete or uncomplete transaction. If the move is FROM a real account, don't debit the account until after transaction is completed. If the move is TO an envelope, credit the envelope when transaction is initiated and debit the envelope when completed. | def complete_xaction
if valid?
# For new records, certain types of transactions will be automatically set as completed.
self.completed = true if new_record? && (to.is_account? && (from_id.nil? || from.is_account?))
# If amount changes, we have to update the envelope amount if it's still pending; otherwise update just the account amount.
if !new_record? && dirty_attributes.keys.include?(Xaction.properties[:amount])
if completed
# update the debited account
diff = amount - Xaction.get(id).amount
from.update_attributes(:actual_amount => from.actual_amount.to_f + diff)
else
# update the envelope amount
diff = amount - Xaction.get(id).amount
to.update_attributes(:actual_amount => to.actual_amount.to_f + diff)
end
end
# Complete/Pending
if dirty_attributes.keys.include?(Xaction.properties[:completed])
# Envelope side
if to && !to.is_account?
if new_record? && !completed
# credit the envelope
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
end
if !new_record?
if completed
# debit the envelope
to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)
to.budget.update_attributes(:amount => amount.to_f < from.budget.amount.to_f ? to.budget.amount.to_f - amount.to_f : 0) # If spending, take it out of the current budget too.
else
# undo the debit
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
to.budget.update_attributes(:amount => amount.to_f < to.budget.amount.to_f ? to.budget.amount.to_f + amount.to_f : 0) # If spending, take it out of the current budget too.
end
end
end
# Debiting from Account
if from && from.is_account?
if completed
# debit the account
from.update_attributes(:actual_amount => from.actual_amount.to_f - amount.to_f)
elsif !new_record? && !completed
# undo the debit
from.update_attributes(:actual_amount => from.actual_amount.to_f + amount.to_f)
end
end
# Crediting to Account
if to && to.is_account?
if completed
# debit the account
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
elsif !new_record? && !completed
# undo the debit
to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete\n\t\t\[email protected]_of_cash(@amount) if @from.balance < @amount\n\t\t\tamount_to_pay = ( @from.balance >= @amount ? @amount : @from.balance )\n\n\t\t\[email protected](amount_to_pay)\n\t\t\[email protected](amount_to_pay)\n\t\t\tpaying_to = @to.owner.name\n\n\t\t\tif amount_to_pay < amount\n\t\t\t\[email protected] '[%s] Unable to pay £%d to %s%s! Paid £%d instead' % [ @from.owner.name, amount, paying_to, ( @reason ? ' for %s' % @reason : '' ), amount_to_pay ]\n\t\t\t\[email protected]!(@to.owner) if @from.owner.respond_to? :bankrupt!\n\t\t\t\tfalse\n\t\t\telse\n\t\t\t\[email protected] '[%s] Paid £%d to %s%s (balance: £%d)' % [ @from.owner.name, amount, paying_to, ( @reason ? ' for %s' % @reason : '' ), @from.balance ]\n\t\t\t\ttrue\n\t\t\tend\n\n\t\t\t@completed = true\n\t\tend",
"def execute_transaction\n if valid? && sender.balance > amount && status == \"pending\"\n receiver.balance += amount\n sender.balance -= amount\n self.status = \"complete\"\n else \n reject_transfer\n end\n end",
"def execute_transaction\n if valid? && sender.balance > amount && self.status == \"pending\"\n sender.balance -= amount\n receiver.balance += amount\n self.status = \"complete\"\n else\n reject_transfer\n end\n\n end",
"def execute_transaction\n#each transfer can only happen once\n if valid? && sender.balance > amount && self.status == \"pending\"\n receiver.balance += amount\n sender.balance -= amount\n self.status = \"complete\"\n else\n#rejects a transfer if the sender doesn't have a valid account\n reject_transfer\n end\n end",
"def execute_transaction\n if valid? && @sender.balance > amount && @status == \"pending\"\n @sender.balance -= amount\n @receiver.balance += amount\n @status = \"complete\"\n else\n reject\n end\n end",
"def complete_transactions!\n pending_transactions.each do |transaction|\n ActiveRecord::Base.transaction do\n transaction.entries.create!(amount: transaction.amount, entry_type: 'D', transaction: transaction, account: Account.mimo_assets)\n transaction.entries.create!(amount: transaction.amount, entry_type: 'C', transaction: transaction, account: wallet)\n transaction.destination_user = self\n transaction.complete! unless transaction.completed?\n end\n transaction.source_user.send_pending_sent_transfer_completed(transaction)\n self.send_pending_received_transfer_completed(transaction)\n end\n end",
"def reverse_transfer\n#can only reverse executed accounts\n if valid? && receiver.balance > amount && self.status == \"complete\"\n receiver.balance -= amount\n sender.balance += amount\n self.status = \"reversed\"\n else\n#rejects a transfer if an account isn't valid\n reject_transfer\n end\n end",
"def reverse_transfer\n if valid? && receiver.balance > amount && self.status == \"complete\"\n receiver.balance -= amount\n sender.balance += amount\n self.status = \"reversed\"\n end\n end",
"def complete!\n now = Time.current\n transaction do\n transfer_items.each do |item|\n source.present? && source.destock!(item, now, self)\n destination.present? && destination.restock!(item, now, self)\n end\n update completed_at: now\n end\n end",
"def execute_transaction\n if self.valid? == true && status != \"complete\"\n self.receiver.balance += self.amount\n self.sender.balance -= self.amount\n self.status = \"complete\"\n else\n self.status = \"rejected\"\n return \"Transaction rejected. Please check your account balance.\"\n end\n end",
"def execute_transaction\n if valid? && sender.balance > amount && self.status == \"pending\"\n sender.balance -= amount\n receiver.balance += amount\n self.status = \"complete\"\n else \n self.status = \"rejected\"\n \"Transaction rejected. Please check your account balance.\" \n end\n end",
"def reverse_transfer\n if valid? && receiver.balance > amount && self.status == \"complete\"\n receiver.balance -= amount\n sender.balance += amount\n self.status = \"reversed\"\n\n else \n reject_transfer\n end\n\n end",
"def execute_transaction\n if valid?\n self.sender.balance -= self.amount\n self.receiver.balance += self.amount\n self.status = 'complete'\n elsif !valid?\n self.status = 'rejected'\n return \"Transaction rejected. Please check your account balance.\"\n end\n end",
"def reverse_transfer\n if self.status == \"complete\"\n self.sender.balance += self.amount\n self.receiver.balance -= self.amount\n self.status = \"reversed\"\n end\n end",
"def reverse_transfer \n if @status == \"complete\" \n sender.balance += @amount\n receiver.balance -= @amount\n @status = \"reversed\"\n end \n end",
"def reverse_transfer\n if @status == \"complete\"\n @sender.balance += amount\n @receiver.balance -= amount\n @status = \"reversed\"\n end\n end",
"def move(accountid, moveto, amount, confirms = 6)\n raise # TODO\n end",
"def cancel!\n if transfer.present? && transfer.complete?\n return!\n update cancelled_at: Time.current\n else\n transfer.destroy! if transfer.present?\n destroy!\n end\n order.update_shipped!\n end",
"def reverse_transfer\n if self.status == 'complete'\n self.sender.balance += self.amount\n self.receiver.balance -= self.amount\n self.status = 'reversed'\n end\n end",
"def execute_transaction\n if self.status == \"pending\" && self.sender.balance > self.amount && self.valid?\n self.sender.balance -= self.amount\n self.receiver.balance += self.amount\n self.status = \"complete\"\n else\n self.status = \"rejected\"\n \"Transaction rejected. Please check your account balance.\"\n end\n end",
"def reverse_transfer\n if receiver.balance > amount && status == \"complete\"\n receiver.balance -= amount\n sender.balance += amount\n self.status = \"reversed\"\n end\n end",
"def reverse_transfer\n if self.status == \"complete\"\n self.receiver.deposit(-self.amount)\n self.sender.deposit(self.amount)\n self.status = \"reversed\"\n end\n end",
"def complete!\n return false unless pending? && transfer.feasible?\n transfer.complete!\n update shipped_at: Time.current\n order.update_shipped!\n email.shipment(to: order.billing_recipient)&.deliver_later if order.billing_address.present?\n email.shipment(to: order.shipping_recipient, bcc: false)&.deliver_later if order.has_contact_email?\n true\n end",
"def execute_transaction\n if self.valid? == true && @sender.balance > amount && @status == 'pending'\n @sender.balance -= amount\n @receiver.balance += amount\n @status = 'complete'\n else\n @status = 'rejected'\n \"Transaction rejected. Please check your account balance.\"\n end\n end",
"def reverse_transfer\n if @status == \"complete\" || @reversal_eligibility == \"yes\"\n receiver.withdraw(amount)\n sender.deposit(amount)\n @status = \"reversed\"\n @reversal_eligibility = \"no\"\n \"The transfer was successfully reversed. $#{amount} was returned to the account of origin.\"\n else\n \"Unable to reverse transaction.\"\n end\n end",
"def execute_transaction\n if self.sender.balance > self.amount && self.status == \"pending\" && self.valid?\n self.receiver.deposit(self.amount)\n self.sender.deposit(-self.amount) \n self.status = \"complete\"\n else\n self.status = \"rejected\" \n \"Transaction rejected. Please check your account balance.\"\n end\n end",
"def complete_operation\n transfer_request = OwnershipTransferRequest.find_by(\n transfer_key: params[:transfer_key]\n )\n\n if transfer_request.nil? || transfer_request.recipient != current_user\n render status: 404, json: {\n error: 'Invalid key or you don\\'t have property to receive'\n } and return\n end\n\n begin\n OwnershipTransfer::CompleteRequest.call(transfer_request)\n\n render status: 200, json: { success: true }\n rescue StandardError => e\n render status: 422, json: { error: e.message }\n end\n end",
"def complete_transaction(trans)\n trans = trans.split('>')\n\n return 1 if trans.size != 2\n\n s = trans[0]\n r = trans[1].split('(')[0]\n x = trans[1].split('(')[1].chomp(')')\n\n return 1 unless s.length == r.length && s.length == 6 && x.to_i.to_s == x\n\n sender = @wallets[s.to_i]\n recipient = @wallets[r.to_i]\n x = x.to_i\n\n # update sender wallet\n if @wallets[s.to_i].nil?\n @wallets[s.to_i] = Wallet.new(s, x * -1)\n else\n sender.balance -= x\n @negs.push(sender) if sender.address != 'SYSTEM' && sender.balance.negative?\n end\n\n # update recipients wallet\n if @wallets[r.to_i].nil?\n @wallets[r.to_i] = Wallet.new(r, x)\n else\n recipient.balance += x\n end\n\n @actives.add(s)\n @actives.add(r)\n end",
"def reverse_transfer\n if @status == 'complete' # Transfer Transfer #reverse_transfer it can only reverse executed transfers\n @sender.balance += amount\n @receiver.balance -= amount\n @status = 'reversed'\n end\n end",
"def test_successful_purchase_and_declined_cancellation_anda\n omit\n credit_card = credit_card('6031998427187914', month: '12', year: '2024',\n verification_value: '111', first_name: 'Santiago', last_name: 'Navatta')\n\n purchase = @gateway.purchase(@amount, credit_card, @options)\n assert_success purchase\n\n assert void = @gateway.void(purchase.authorization, @cancel_options)\n assert_failure void\n end",
"def move(fromaccount, toaccount, amount, minconf = 1, comment = nil)\n coind.move fromaccount, toaccount, amount, minconf, comment\n end",
"def capture_and_cash\n if self.active? && self.pending_purchase_order && self.accepted_receiver\n\n # start transaction\n ActiveRecord::Base.transaction do\n capture = self.pending_purchase_order.capture\n if capture.success?\n \n sales_order = self.accepted_receiver.sell_to(self.sender, self.accepted_receiver.cart.cart_line_item(self))\n cash = sales_order.cash(self.accepted_receiver.piggy_bank)\n \n if cash.success?\n self.pending_purchase_order.update_origin_address_from(self.accepted_receiver)\n \n service_fee_product = Product.service_fee(:country_code => self.accepted_receiver.default_country)\n \n if service_fee_product\n reward_item = self.accepted_receiver.cart.add(self)\n service_fee_item = self.accepted_receiver.cart.add(service_fee_product, 1, :dependent => reward_item)\n \n purchase_order = self.accepted_receiver.purchase(service_fee_item,\n :seller => Organization.probono)\n charge = purchase_order.pay(self.accepted_receiver.piggy_bank)\n \n if charge.success?\n probono = Organization.probono\n\n if probono\n\n probono_sales_order = probono.sell_to(self.accepted_receiver, service_fee_item)\n probono_cash = probono_sales_order.cash(probono.piggy_bank)\n\n if probono_cash.success?\n # congrats, we are done!\n return true\n else\n logger.error \"Error cashing service fee sales order {#{probono_sales_order.id}} \" +\n \"for reward {#{self.id}} kase {#{self.kase.id}}\\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n \n else\n logger.error \"Error probono organization not found for reward {#{self.id}} kase {#{self.kase.id}} \\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n\n else\n logger.error \"Error when charging service fee to partner on order \" + \n \"##{purchase_order.number} for kase {#{self.kase.id}} \\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n else\n logger.error \"Error could not find service fee for accepted_receiver {#{self.accepted_receiver.id}}, \" + \n \"country code \\\"#{self.accepted_receiver.default_country}\\\" for kase {#{self.kase.id}} \\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n \n else\n logger.error \"Error when cashing sales order {#{sales_order.id}} #{sales_order.number} for kase {#{self.kase.id}}\\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n \n else\n logger.error \"Error when capturing pending order {#{self.pending_purchase_order.id}} #{self.pending_purchase_order.number} for kase {#{self.kase.id}} \\\"#{self.kase.title}\\\"\"\n raise ActiveRecord::Rollback\n end\n end\n end\n false\n end",
"def execute_transaction\n if self.valid?\n @sender.balance -= @amount\n @receiver.balance += @amount\n @amount -= @amount\n @status = \"complete\"\n else\n @status = \"rejected\"\n \"Transaction rejected. Please check your account balance.\"\nend\nend",
"def cancel!\n if AccountTransaction.transfer(self.num * self.price, self.startup.account, self.startup.account, :escrow, :balance).new_record?\n self.errors.add(:num, 'could not be refunded to your startup\\'s balance') \n return false\n end\n if self.responses.count > 0\n self.num = 0\n self.save\n else\n self.destroy\n end\n end",
"def transfer\n return false if @source_account_id == @destination_account_id\n return false unless @amount > 0\n return false unless Account.exists?(@source_account_id) &&\n Account.exists?(@destination_account_id)\n return false if AccountService.new(@source_account_id).balance < @amount\n\n create_traders\n end",
"def will_transfer(amount, *args)\n do_scheduled_transaction :transfer_out, amount, *args\n end",
"def finish_downlink_transaction\n\n conditionCode = create_file\n\n writeLog(\"Cleaning buffer from transaction #{@ID}\")\n CFDP::CFDPEngine.instance.clean_buffer(@ID)\n\n # transaction is complete, send FINISHED Pdu\n finishedPdu = CFDP.generatePDU(\"FINISHED\", {sourceID:DESTINATIONID, destinationID:MYID, conditionCode:conditionCode, endSystemStatus:1,\n deliveryCode:(conditionCode == 0 ? 0 : 1), fileStatus:(conditionCode == 4 ? 1 : 2), direction:1, transmissionMode:0, sequenceNumber:@ID[DESTINATIONID]})\n writeLog(\"Generated FINISHED PDU: #{finishedPdu.pack.to_s}\")\n update(finishedPdu)\n\n CFDP::CFDPEngine.instance.insertIntoBuffer(finishedPdu)\n\n CFDP::CFDP_Indication(\"Transaction #{@ID} finished with <#{CFDP.conditionCodeToStr(conditionCode)}> condition.\")\n writeLog(\"Transaction #{@ID} finished with <#{CFDP.conditionCodeToStr(conditionCode)}> condition.\")\n end",
"def finish\n transition_to(:successful) unless transition_to(:waiting_funds)\n end",
"def allpay_complete\n\n # RtnCode's value 1 means the transaction was success.\n # In this method, just like the other callback handlers, updating the order payment status.\n if params['RtnCode'] == '1' || params['RtnCode'] == '3'\n registration_payment = RegistrationPayment.find_by_registration_id!(params['MerchantTradeNo'].delete('R').split('t')[0])\n\n registration_payment.trade_no = params['TradeNo']\n registration_payment.trade_time = params['TradeDate']\n registration_payment.payment_time = params['PaymentDate']\n registration_payment.completed = true\n registration_payment.completed_time = Time.now\n registration_payment.save!\n\n RegistrationMailer.completed_confirmation(registration_payment.registration_id).deliver_later\n\n render text: '1|OK'\n else\n\n # Return the result to allpay server\n render text: '0|Failed! Transaction was interrupted and not completed when AllPay handling the payment.'\n end\n end",
"def test_successful_purchase_and_declined_refund_anda\n omit\n credit_card = credit_card('6031997614492616', month: '12', year: '2024',\n verification_value: '111', first_name: 'Santiago', last_name: 'Navatta')\n\n purchase = @gateway.purchase(@amount, credit_card, @options)\n assert_success purchase\n\n assert refund = @gateway.refund(@amount, purchase.authorization, @cancel_options)\n assert_failure refund\n assert_equal 'An internal error occurred. Contact support.', refund.message\n end",
"def transfer_to(account, amount)\n # `account.name` is accessing the name of the account we are transfering to\n debit amount, \"Transfer to #{account.name}\"\n account.credit amount, \"Transfer from #{@name}\"\n end",
"def move_no_cleanup(*args)\n # Abort if the movement is already complete\n raise Orp::MovementAlreadyComplete if completed\n\n raise Orp::MovementValidationError if !self.valid?\n self.update(*args) if args.length > 0\n\n # This mutex prevents against two attempts to complete the same move\n # simultaneously. The movement remains editable throughout.\n #\n # BUT: Do we even need this? If the movement is only created just in time\n # then nothing else is going to have that instance \n# mutex(0.01) do\n\t# Commit the issue\n\tself.issue_committed = self.source_target.issue(self) ? true : false\n\t\n\t# Commit the receipt if the issue succeeded\n\tif self.issue_committed\n\t self.issue_time = Time.now.to_f\n\t # Recalculate the destination unit cost in case the source\n\t # overrided the source unit cost\n\t self.dest_amount.ucost = Rational(self.source_amount.value / self.dest_amount.qty)\n\t self.rcpt_committed = self.dest_target.receive(self) ? true : false\n\telse\n\t raise Orp::MovementIssueError\n\tend\n\t\n\t# Reverse the issue if the receipt failed\n\tif self.rcpt_committed\n\t self.rcpt_time = Time.now.to_f\n\telse\n\t self.issue_committed = self.source_target.reverse_issue(self) ? false : true\n\t if !self.issue_committed\n\t # If issue_committed is still true, then the issue reversal also\n\t # failed!\n\t raise Orp::MovementReverseIssueError\n\t else\n\t self.issue_time = nil\n\t raise Orp::MovementRcptError\n\t end\n\tend\n\t\n # Movement is now done\n self.completed = true\n self.completion_time = Time.now.to_f\n# end\n self.save\n end",
"def close_account\n self.void_pending_authorizations\n if probono = Organization.probono\n if probono.piggy_bank && probono.piggy_bank.reload && probono.piggy_bank != self\n result = self.transfer(probono.piggy_bank, self.available_balance, :limits => false) if probono.piggy_bank\n raise BankError, \"remaining funds could not be transferred\" if !result || !result.success?\n end\n end\n end",
"def end_turn(turn)\n #todo have another turn???\n @@cli.say \"Your turn is over!\"\n @purchased_card = nil\n end",
"def update_contract\n case status.to_sym\n when :started then lock_contract\n when :successful then complete_contract\n when :failed then release_contract unless contract.flights.in_progress.any?\n else lock_contract\n end\n true\n end",
"def execute_transaction\n if @counter != 0\n @status = 'rejected'\n false\n elsif [email protected]? || @sender.balance <= @amount\n @status = 'rejected'\n \"Transaction rejected. Please check your account balance.\"\n else\n @sender.balance = @sender.balance - @amount\n @receiver.balance = @receiver.balance + @amount\n @counter += 1\n @status = 'complete'\n end\n end",
"def perform_complete_move(player_number, from_id, to_id, promote = false)\n from = squares.find_by_id(from_id)\n to = squares.find_by_id(to_id)\n\n captured = to.occupied? ? to : nil\n\n @last_change = { type: 'move', data: { player_number: player_number, from: from_id, to: to_id } }\n\n perform_move(player_number, from, to, captured)\n\n promote_piece(to) if promote\n pass_turn\n end",
"def process_cancellation!\n if payment.settled?\n # If we have the money, refund it.\n if payment.refund!\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Credited #{formatted_total}\")\n else\n fail!(\"Could not refund payment due to a problem with the payment provider\")\n end\n else\n # If the payment provider supports voiding, void\n if payment.can_void?\n if payment.void!\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Payment has been voided\")\n else\n fail!(\"Could not void payment due to a problem with the payment provider\")\n end\n else\n # Let the authorization expire:\n return_stock\n IslayShop::OrderMailer.cancelled(self).deliver\n next!(\"Payment can't be voided: the authorization will expire, usually within 7 days.\")\n end\n end\n end",
"def end_transaction(result = nil)\n agent&.end_transaction(result)\n end",
"def after_complete\n #remove the order from the session\n session[:order_id] = nil\n\n #add the order access token to the session so user can see thank you window\n #and order status, all through the orders controller.\n session[:access_token] ||= @order.token\n\n # trigger the photo copy and preparation, this is done here because normal state machine transitions\n # happen in a transaction and could allow resque work to begin too soon. See comment in order_decorator.rb\n @order.prepare!\n\n if current_user\n # If a user is looged in, save addresses and creditcard as default\n # Backup order addresses with addresses that cannot be modified by user.\n # creditcards are non editable just erasable.\n #(no need to do this for guests)\n original_ship = @order.ship_address\n original_bill = @order.bill_address\n\n new_ship = Address.create( original_ship.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n @order.ship_address_id = new_ship.id\n if original_ship.id == original_bill.id\n @order.bill_address_id = new_ship.id\n else\n if original_ship.same_as?( original_bill )\n @order.bill_address.id = new_ship.id\n else\n @order.bill_address = Address.create( original_bill.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n end\n end\n @order.save\n\n # new creditcards should be saved in the user's wallet\n if @order.payment.source.user.nil?\n @order.payment.source.update_attributes!(\n :user_id => current_user.id\n )\n end\n\n #make addresses, creditcard user's default\n @order.user.update_attributes!(\n :bill_address_id => original_bill.id,\n :ship_address_id => original_ship.id,\n :creditcard_id => @order.payment.source.id\n )\n end\n end",
"def order_complete\n load_order\n if @order.state == 'canceled'\n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n @order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def add_card_complete_payment\n @billing_id = params[:billing_address_id]\n @shipping_id = params[:shipping_id]\n billing_address = Spree::Address.where(:id => @billing_id).first\n shipping_address = Spree::Address.where(:id => @shipping_id).first\n user = current_user\n\n @card = Creditcard.new(creditcard_params)\n if @card.valid? #checking @card validation before pushing it over braintree for validation.\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\n @braintree_cc_return = result.success? ? result.credit_card : nil\n\n if @braintree_cc_return.present?\n @card.save\n @card.update_attributes(:user_id => user.id)\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\n billing_address.update_attributes(is_complete: true)\n shipping_address.update_attributes(is_complete: true)\n end\n else\n logger.info @card.errors.messages\n end\n\n end",
"def refund!\n if charged && !canceled\n transaction = Stripe::Charge.retrieve(trans_id)\n if transaction.refund\n update updated: true, canceled: true\n else\n raise result.errors\n end\n end\n end",
"def redirect_or_complete_order\n @order = Spree::Order.find_by_number!(params[:id])\n payment = @order.payments.find { |pt| pt.source && pt.source.redirect? && !pt.source.redirect_success? }\n\n if @order.complete? && payment&.pending?\n redirect_to solidus_stripe_sources.redirect_path(@order.number) and return\n end\n end",
"def transfer(to_account, amount)\n to_acc = Account.find_by(id: to_account)\n\n if to_acc.nil?\n self.errors.add(\"Transaction denied! Cannot get data of account.\")\n return\n end\n\n if self.balance<amount\n self.errors.add(\"Transaction denied! Insufficient ballance to cover transfer amount.\")\n return\n end\n\n Transaction.transfer(self.id, to_account, amount, \"A2A\")\n end",
"def transferMoneyFromCard\n results1 = postTransaction(@current_user[\"id\"], @current_user[\"id\"], params[:money]) # create initial state\n transact = results1.parsed_response # transact object to get the id in the rest of the process\n if results1.code == 201\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"initial\", 0)\n resultsGet = HTTParty.get(\"http://192.168.99.104:3003/credit_card?id=\"+params[:cardId].to_s)\n userA = (resultsGet[\"user_id\"])\n if userA != (@current_user[\"id\"])\n renderError(\"Forbidden\",403,\"current user has no access\")\n return -1\n else\n if (resultsGet[\"amount\"]<(params[:money]).to_i)\n renderError(\"Bad Request\", 400, \"The credit card do not have enough money\")\n else\n actualMoney=checkMoneyUser(userA)\n newMoneyUser=(actualMoney[\"money\"]).to_f + (params[:money]).to_i\n newMoneyCard=resultsGet[\"amount\"].to_i - (params[:money]).to_i\n optionsCd = {\n :body => {\"amount\": newMoneyCard}.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n resultCd = HTTParty.put(\"http://192.168.99.104:3003/credit_cards?id=\"+params[:cardId].to_s, optionsCd)#subtract money from card\n if resultCd.code == 204\n logUpdateCard(params[:cardId], newMoneyCard, 0)\n results2 = updateTransaction(\"pending\", transact[\"id\"])# put pending state\n if results2.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"pending\", 0)\n else\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results4.parsed_response, status: results4.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n else\n ##########ERROR EN UPDATE A TARJETA###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultCd.parsed_response, status: resultCd.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n resultUs = updateMoney(newMoneyUser, userA.to_s) #add money to user\n if resultUs.code == 204\n logUpdateMoney(userA.to_s, newMoneyUser, 0)\n results3 = updateTransaction(\"complete\", transact[\"id\"])# put complete state\n if results3.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"complete\", 0)\n subject = \"Transferencia de tarjeta de credito\"\n content = \"Has recibido una transferencia de la cuenta \" + params[:cardId].to_s + \" por valor de $\" + (params[:money]).to_s\n createNotification(@current_user[\"id\"],subject, content, @current_user_notification_key)\n head 201 # transaction created and state complete\n else\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results3.parsed_response, status: results3.code\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n else\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultUs.parsed_response, status: resultUs.code\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n end\n end\n else\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"incomplete\", 1)\n end\n render json: results1.parsed_response, status: results1.code\n end\n end",
"def test_successful_purchase_and_declined_refund_sodexo\n omit\n credit_card = credit_card('5058647731868699', month: '12', year: '2024',\n verification_value: '111', first_name: 'Santiago', last_name: 'Navatta')\n\n purchase = @gateway.purchase(@amount, credit_card, @options)\n assert_success purchase\n\n assert refund = @gateway.refund(@amount, purchase.authorization, @cancel_options)\n assert_failure refund\n assert_equal 'An internal error occurred. Contact support.', refund.message\n end",
"def move(from_account, to_account, amount, minconf = 1, comment = nil)\n request :move, from_account, to_account, amount, minconf, comment\n end",
"def transfer(from, to, amount, options={})\n if from.is_a? PiggyBankAccount\n return from.transfer(to, amount, options)\n end\n false\n end",
"def after_cancel\n restock_items!\n\n #TODO: make_shipments_pending\n Spree::OrderMailer.cancel_email(self).deliver\n Spree::OrderMailer.cancel_email_retailer(self).deliver\n unless %w(partial shipped delivered).include?(shipment_state)\n self.payment_state = 'credit_owed'\n end\n end",
"def order_complete\n load_order\n if @order.state == 'canceled' \n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n \[email protected]_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def capture(money, authorization, options = {})\n txn_number, order_id = authorization.split(';')\n\n parameters = {\n :txn_number => txn_number,\n :order_id => order_id,\n :comp_amount => amount(money),\n :crypt_type => options[:crypt_type] || @options[:crypt_type]\n }\n\n commit('completion', parameters) \n end",
"def finalize!\n update_attribute(:completed_at, Time.now)\n InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n\t\n envia_correos_notific # Envío de correos...\n\n self.state_events.create({\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :name => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end",
"def check_user_ownership_and_set_message\n if @source_account && @source_account.user == current_user\n if @destination_account.present?\n @transaction.message = 'Transfer'\n return true\n end\n @transaction.message = 'Withdrawal'\n return true\n end\n\n if @destination_account.user == current_user\n @transaction.message = 'Deposit'\n return true\n end\n\n false\n rescue StandardError\n false\n end",
"def finished?\n FINAL_STATUSES.include?(transaction_status) || status == COMPLETED\n end",
"def mark_complete\n ActiveRecord::Base.transaction do\n find_order\n separate_shipment_costs\n assert_refund_adjustments params['refund_items'], true\n @order.update!\n end\n settle_payments_if_desired\n render text: @settlement_results.to_json\n end",
"def capture\n begin \n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # go through all order_payments\n order_payments = self.order_payments\n if order_payments.size == 0\n p \"No order_payments to process.\"\n raise PaymentError, \"No order_payments to process.\"\n end\n for order_payment in order_payments\n order_payment.capture!\n end\n self.upgrade_coupons!\n # update order\n self.update_attributes!(:state => Order::PAID, :paid_at => Time.zone.now)\n end\n # send confirmation email\n user = User.find_by_id(self.user_id)\n if user and user.send_confirmation(self.deal_id)\n return true\n else\n logger.error \"Order.capture: Confirmation email failed to send: #{self.inspect}\"\n return false\n end\n rescue PaymentError => pe\n p \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{pe}\"\n rescue ActiveRecord::RecordInvalid => invalid\n p \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n logger.error \"Order.capture: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end",
"def success\n authorize! :view_sofort_thankyou_page, @order\n @address = @order.address\n @product = @order.product.decorate\n return render 'signup/orders/show' if @order.confirmed?\n transaction = ::Sofort::FinishTransaction.new(@order)\n transaction.run do\n @order.status = :paid\n @order.confirm\n return render 'signup/orders/show'\n end\n # customer opens success-page, but transaction is not complete\n flash.now[:notice] = t(:transaction_no_confirmation)\n render 'signup/orders/show'\n end",
"def purchase_with_card!\n puts 'purchase_with_card!'\n unless validate_card \n puts 'card invalid'\n puts 'calling err'\n err!\n puts 'state'\n puts self.state\n puts 'saving...'\n self.save!\n puts 'saved. state is'\n puts self.state\n puts 'valid?'\n puts self.valid?\n puts self.errors.full_messages\n return false \n end\n \n mode = self.account.gateway.mode\n gateway = self.account.gateway.authorize_net\n \n response = gateway.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", \n :amount => price_in_cents, \n :response => response,\n :meth => 'card',\n :origin => 'web',\n :gateway_mode => mode)\n \n puts \"RESPONSE.success?\"\n puts response.success?\n \n if response.success?\n puts \"calling FINALIZE\"\n finalize!\n puts \"STATE\"\n puts state\n else\n puts \"calling ERR!\"\n err!\n puts 'STATE:'\n puts state\n end\n \n # response.success?\n end",
"def refund!\n response = credit_card.credit!(total_amount_in_cents, payment.authorization)\n self.response = response\n self.description = response.message\n self.authorization = response.authorization\n if response.success?\n invoice.update_attribute(:status, \"closed\")\n self.status = \"cleared\"\n self.save!\n return true\n else\n self.status = \"failed\"\n for item in self.line_items\n item.amount = 0\n end\n self.save!\n return false\n end\n end",
"def after_transition(order, transition)\n if transition.attributes[:event].to_s == \"complete\" && order.user\n if order.bill_address.id && order.ship_address.id\n order.user.update_attributes!(\n :bill_address_id => order.bill_address.id,\n :ship_address_id => order.ship_address.id\n )\n end\n end\n end",
"def purchase(_money, _credit_card, _options = {})\n ActiveMerchant::Billing::Response.new(true, 'PayUIn Gateway: Forced success', {}, test: test?)\n end",
"def force_bounce!(trx_id)\n if trx_id.to_s.size == 0\n warning \"Empty transaction id.\"\n return\n end\n\n init_transactions\n \n totals = {}\n transaction = Radiator::Transaction.new(chain_options.merge(wif: active_wif))\n \n @transactions.each do |index, tx|\n type = tx['op'].first\n next unless type == 'transfer'\n \n id = tx.trx_id\n next unless id == trx_id\n \n op = tx['op'].last\n from = op.from\n to = op.to\n amount = op.amount\n memo = op.memo\n timestamp = op.timestamp\n \n next unless to == account_name\n \n author, permlink = parse_slug(memo) rescue [nil, nil]\n \n if author.nil? || permlink.nil?\n warning \"Could not find author or permlink with memo: #{memo}\"\n end\n \n comment = find_comment(author, permlink)\n \n if comment.nil?\n warning \"Could not find comment with author and permlink: #{author}/#{permlink}\"\n end\n \n unless comment.author == author\n warning \"Comment author and memo author do not match: #{comment.author} != #{author}\"\n end\n \n totals[amount.split(' ').last] ||= 0\n totals[amount.split(' ').last] += amount.split(' ').first.to_f\n warning \"Need to bounce #{amount} (original memo: #{memo})\"\n \n transaction.operations << bounce(from, amount, id)\n end\n \n totals.each do |k, v|\n info \"Need to bounce total: #{v} #{k}\"\n end\n \n return true if transaction.operations.size == 0\n \n response = transaction.process(true)\n \n if !!response && !!response.error\n message = response.error.message\n \n if message.to_s =~ /missing required active authority/\n error \"Failed transfer: Check active key.\"\n \n return false\n elsif message.to_s =~ /unknown key/\n error \"Failed vote: unknown key (testing?)\"\n \n return false\n elsif message.to_s =~ /tapos_block_summary/\n warning \"Retrying vote/comment: tapos_block_summary (?)\"\n \n return false\n elsif message.to_s =~ /now < trx.expiration/\n warning \"Retrying vote/comment: now < trx.expiration (?)\"\n \n return false\n elsif message.to_s =~ /signature is not canonical/\n warning \"Retrying vote/comment: signature was not canonical (bug in Radiator?)\"\n \n return false\n end\n end\n \n info response unless response.nil?\n\n response\n end",
"def after_confirmation\n Transfer.create(\n receiver: self,\n amount: 1_000.0,\n source_currency: 'USD',\n target_currency: 'USD',\n exchange_rate: 1.0,\n status: Transfer::SUCCESS\n )\n super\n end",
"def transaction_complete\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def completed\n\n @order = current_order\n \n posted_xml = params[:xml]\n\n # Remove XHTML character encoding (hopefully won't need to do this when we receive XML message from RomanCart!)\n xml = posted_xml.sub(\"<?xml version='1.0' encoding='UTF-8'?>\", \"\")\n \n xml_doc = Nokogiri::XML(xml) \n \n if @order = current_order\n \n @order.email = xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/email\").first.content\n \n @order.user_id = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content\n \n @order.number = xml_doc.xpath(\"/romancart-transaction-data/orderid\").first.content \n flash[:message] = \"Order number taken from current time!\"\n @order.number = Time.now.to_i.to_s\n \n # ----------------------- Billing Address -------------------------------\n @order.bill_address = romancartAddress(xml_doc)\n # ----------------------- Delivery Address ------------------------------ \n #<delivery-address1/>\n if xml_doc.xpath(\"/romancart-transaction-data/sales-record-fields/delivery-address1\").first.content.empty?\n @order.use_billing = true\n else\n @order.ship_address = romancartAddress(xml_doc, \"delivery-\")\n end\n \n # Spree StateMachine = 1)cart -> 2)address -> 3)delivery -> 4)payment -> 5)confirm -> 6)complete\n\n # If the order is just for samples then it'll be free so no payment is required\n if @order.item_total == 0\n \n while @order.state != \"complete\"\n @order.next!\n end\n \n else\n \n while @order.state != \"payment\"\n @order.next!\n end\n \n if xml_doc.xpath(\"/romancart-transaction-data/paid-flag\").first.content.eql?(\"True\")\n\n unless @order.payments.exists?\n @order.payments.create!(:amount => @order.total)\n @order.payments.last.payment_method = Spree::PaymentMethod.find_by_name(\"RomanCart\")\n end\n \n # '@order.payments' is an array so need to get last one entered to access 'Spree::Payment' methods\n @order.payments.last.complete\n \n @order.payment_total = @order.total\n\n # To 6 - Complete\n @order.state = \"complete\"\n @order.completed_at = Time.now\n \n @order.save!\n end\n end\n\n end\n\n end",
"def transfer(amount, destination_account, options={})\n process('transfer', amount, options) do |gw|\n gw.transfer(amount.cents, destination_account, options)\n end\n end",
"def cancel_tranzaction()\n\t\tself.tranzaction.reverse_completed_goals(self)\n\t\tself.tranzaction.disable_active_goals(self)\n\n\t\ttrue\n\tend",
"def move(amount, target)\n if amount.sign < 0\n raise ArgumentError, \"Can't move negative amounts!\"\n end\n\n current_balance = balance\n target_account_name = find_account_name target\n\n case\n when target_account_name == name\n raise ArgumentError, \"Can't move amount to own account!\"\n when current_balance < amount\n raise ArgumentError, \"Moving #{amount} would overdraw account!\"\n end\n\n rpc.move name, target_account_name, amount\n end",
"def debit_customer_account\n end",
"def transfer_funds()\n vendor = Portfolio.find(self.seller_id)\n customer = Portfolio.find(self.buyer_id)\n amount = self.transaction_cost\n customer.balance -= amount\n vendor.balance += amount\n \n Transactor.transaction do \n raise \"Transaction of funds failed!\" unless customer.save && vendor.save\n end\n end",
"def contact_us_to_complete_payment\n # Horrible hack: when the user triggers a £40 edit charge, chooses a payment\n # method but then navigates backward, we get into a state where we can no\n # longer compare the \"old\" and \"new\" carrier types (because we no longer\n # know what the \"old\" type was as its now been overwritten in Mongo). This\n # means the new charge determination will output no charge, potentially\n # making the change of carrier type free.\n setup_registration('payment', true)\n render_not_found and return unless @registration\n end",
"def transfer_funds_to(amount, target)\n self.balance -= amount\n target.balance += amount\n Account.transaction do\n raise \"Transaction Failed\" unless self.save && target.save && self.balance >0\n end\n end",
"def complete\n handle_callback_params!\n redirect_to redirect_path(@payment.try(:order))\n end",
"def set_transaction_complete_flag()\n @is_transaction_complete = true\n end",
"def revert_complete\n QcInspection.transaction do\n self.set_status STATUS_IN_PROGRESS\n end\n end",
"def transaction_already_completed?\n if self.status != \"pending\"\n return false\n else\n true\n end\n end",
"def confirm_mandate\n begin\n redirect_flow = GO_CARDLESS_CLIENT.redirect_flows.complete(\n params[:redirect_flow_id],\n params: { session_token: \"#{current_user.id}\" }\n )\n current_user.go_cardless_customer = redirect_flow.links.customer\n current_user.go_cardless_mandate = redirect_flow.links.mandate\n\n if current_user.save(validate: false)\n create_gocardless_subscription\n flash[:notice] = 'Your payment has been successfully completed and subscription added to your GoCardless bank account.'\n else\n flash[:error] = 'Something went wrong!'\n end\n rescue StandardError => e\n flash[:error] = e\n end\n redirect_to root_path\n end",
"def release(account, merchant, transaction_id)\n delete \"/#{CGI::escape(account)}/transactions/#{transaction_id}\" + \"?merchant=#{merchant}\"\n expect_status! 'CANCELLED'\n end",
"def transferir(conta_destino, valor)\n sacar(valor)\n conta_destino.depositar(valor)\n end",
"def move(fromaccount, toaccount, amount, minconf = 1, comment = nil)\n @api.request 'move', fromaccount, toaccount, amount, minconf, comment\n end",
"def call!\n account_from.update_balance!(side: :-, amount: amount)\n account_to.update_balance!(side: :+, amount: amount)\n end",
"def complete_order_step(order, order_step)\n original_state = order.state\n order.state = order_step\n\n if !order.next\n order.state = original_state\n order.save(validate: false) # store data from paypal. user will be redirect to 'personal' tab\n end\n end",
"def check_for_completeness\n mark_complete(Time.now) if paid? && received?\n end",
"def move_paid_status\n # This is not a transformation, it's just to prevent accounting problems, an invoice\n # should never make this transformation.\n if self.status_constant_was == Invoice::PAID and self.status_constant == Invoice::UNPAID\n errors.add(:invoice, \"Paid invoices can never be set to unpaid.\")\n return false\n end\n end",
"def finish(transfer, force=false)\n\n # print changes, return if none\n Modder.status transfer\n return if transfer.empty?\n\n if force || Modder.confirm?\n Modder.execute transfer, force\n puts \"Modifications complete.\"\n else\n puts \"No modifications done.\"\n end\n end",
"def move(name_or_account, amount)\n to_name = if name_or_account.is_a?(Bitbank::Account)\n name_or_account.name\n else\n name_or_account\n end\n\n @client.request('move', name, to_name, amount)\n end",
"def customer_credit_card_txn_void_or_refund_rq(authorization, options)\n xml = Builder::XmlMarkup.new(:indent => 2)\n\n create_qbmsxml_msgs_rq(xml,options) {\n xml.tag!('CustomerCreditCardTxnVoidOrRefundRq') do\n xml.tag!('TransRequestID', options[:order_id])\n xml.tag!('CreditCardTransID', authorization)\n xml.tag!('Amount', options[:amount])\n end\n }\n \n xml.target!\n end",
"def braintree_refund_transaction transaction\n if transaction and !transaction.is_refund and !transaction.superceded\n # Attempt to refund the requested amount\n if [:settled, :settling].include? transaction.status.to_sym\n result = Braintree::Transaction.refund(transaction.transaction_id, amount)\n elsif [:authorized, :submitted_for_settlement].include? transaction.status.to_sym\n result = Braintree::Transaction.void(transaction.transaction_id)\n else\n # Cannot handle the current transaction state\n return false\n end\n\n result_data = self.braintree_result_data result\n\n if result_data[:transaction_id]\n # Create the select order transaction row\n t = Select::SelectOrderTransaction.create(\n # Snappea data\n user_id: user.id,\n select_event_id: self.select_event.id,\n select_order_id: self.id,\n card_id: nil, # TODO\n account_id: nil, # TODO\n timestamp: Time.now,\n amount: transaction.amount,\n is_refund: true,\n notes: transaction.notes,\n # Braintree data\n superceded: false,\n customer_id: nil, # TODO\n transaction_id: result_data[:transaction_id],\n transaction_type: result_data[:transaction_type],\n status: result_data[:status],\n response: result_data[:response],\n # Metadata\n cc_last4: result_data[:cc_last4],\n card_type: result_data[:card_type],\n expiration_date: result_data[:expiration_date]\n )\n\n # Update the existing transaction by superceding it\n transaction.update_attributes({\n superceded: true,\n notes: transaction.notes + \"; Superceded by transaction: \" + t.id.to_s\n })\n end\n\n # Return true if successful\n result.success?\n else\n # No such transaction id\n false\n end\n end",
"def cancel status=:canceled\n result = true\n\n # Refund all transactions associated with order\n self.select_order_transactions.payments.each do |t|\n result = self.braintree_refund_transaction t\n end\n\n # Mark the order as canceled if all braintree refunds succeeded\n if result\n self.edit_mode = false\n self.status = status\n self.save\n end\n\n # Return result\n result\n end"
] | [
"0.6982691",
"0.65402544",
"0.6481989",
"0.64782345",
"0.62614524",
"0.6249735",
"0.62164265",
"0.61531687",
"0.6118449",
"0.6071084",
"0.6047062",
"0.6001378",
"0.5998204",
"0.59557205",
"0.59552795",
"0.5935379",
"0.5930211",
"0.59248596",
"0.592124",
"0.59104985",
"0.59075344",
"0.5894233",
"0.5892421",
"0.5844665",
"0.5815193",
"0.5813526",
"0.5807054",
"0.5778776",
"0.57654953",
"0.57554555",
"0.5752889",
"0.57491964",
"0.57272965",
"0.5686375",
"0.5670723",
"0.56652796",
"0.56566817",
"0.56340885",
"0.5620944",
"0.55663514",
"0.5559889",
"0.5540458",
"0.55313295",
"0.55239505",
"0.55133",
"0.5502198",
"0.5498565",
"0.54692143",
"0.5461782",
"0.5431865",
"0.5416376",
"0.54032594",
"0.5391848",
"0.53740245",
"0.53561175",
"0.5348713",
"0.5334093",
"0.5333597",
"0.532502",
"0.5322767",
"0.5309795",
"0.5294505",
"0.5280489",
"0.5271204",
"0.52610344",
"0.52580583",
"0.5252722",
"0.52447486",
"0.52420956",
"0.5216169",
"0.5210316",
"0.5207889",
"0.5207755",
"0.5207228",
"0.5193766",
"0.51905566",
"0.51837534",
"0.51642144",
"0.5162734",
"0.5160876",
"0.516028",
"0.51584816",
"0.51580626",
"0.5155181",
"0.51488453",
"0.5136988",
"0.51302755",
"0.51288325",
"0.512472",
"0.512338",
"0.5122034",
"0.5121242",
"0.5112946",
"0.51117814",
"0.5109661",
"0.51047856",
"0.51043403",
"0.5103954",
"0.50964737",
"0.5094428"
] | 0.7126264 | 0 |
This is customized because GENCAT don't Processes Groups on Index Page | def collection
@collection ||= participatory_processes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_groups; end",
"def index\n @title = \"groups_title\"\n #save_navi_state(['groups_title', 'browse_groups']) #moved to filter\n public_group_ids = Group.get_public_group_ids(session[:cookie])\n # add groups to Kassi db if there are new (made in other services)\n Group.add_new_groups_to_kassi_db(public_group_ids)\n \n @groups = Group.paginate( public_group_ids ,{:page => params[:page], :per_page => per_page})\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def index\r\n return jump_to(\"/groups/all\") unless has_login?\r\n \r\n account_id = session[:account_id]\r\n \r\n account_setting = AccountSetting.get_account_setting(account_id)\r\n module_group_index = account_setting.get_setting_value(:module_group_index)\r\n \r\n url = case module_group_index\r\n when \"all\"\r\n \"all\"\r\n when \"recent\"\r\n \"recent/#{account_id}\"\r\n when \"join\"\r\n \"list/#{account_id}\"\r\n when \"admin\"\r\n \"list_admin/#{account_id}\"\r\n else\r\n \"recent/#{account_id}\"\r\n end\r\n jump_to(\"/groups/#{url}\")\r\n end",
"def group; end",
"def current_group\n end",
"def groups()\n\t\t\tend",
"def iii_groups; end",
"def ii_groups; end",
"def render\n @groups.each_value do |grp|\n #print(\"#{grp.name} \")\n glCallList( grp.displaylist ) # call precahed operation to save gpu/cpu\n end\n end",
"def in_frontend_groups\n # groups = []\n # xrefs = self.racc_route_destination_xrefs\n \n # vlabels = self.racc_routes.map {|rr| rr.vlabel_map }\n # vlabels.compact!\n # vlabels.delete_if {|v| v.group.category != \"f\" || v.group.group_default == false}\n # groups = vlabels.map {|v| Operation.first(:conditions => {:app_id => v.app_id, :newop_rec => v.vlabel}).group }\n Group.all(:conditions => [\"name IN \n (SELECT vlabel_group FROM racc_op WHERE newop_rec IN \n (SELECT vlabel FROM racc_vlabel_map WHERE vlabel IN \n (SELECT route_name FROM racc_route WHERE route_id IN \n (SELECT route_id FROM racc_route_destination_xref WHERE app_id = :app_id AND destination_id = :id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id AND category = :category AND group_default = :group_default\", {:id => self.id, :app_id => self.app_id, :category => 'f', :group_default => false}])\n end",
"def index\n @groups = Group.all\n @bc_title = t('bc.Groups')\n end",
"def girl_groups; end",
"def index\n @groups = current_trainer.groups\n end",
"def render_list_pack_groups()\n\n @can_edit = authorise(program_name?, 'production_run_setup', session[:user_id])\n\n @current_page = session[:pack_groups_page] if session[:pack_groups_page]\n\n @current_page = params['page'] if params['page']\n\n @pack_groups = eval(session[:query]) if !@pack_groups\n\n @caption = \"list of pack groups for schedule: #{session[:current_closed_schedule].production_schedule_name} and run #{session[:current_production_run].production_run_number}\"\n\n render :inline => %{\n <% grid = build_pack_groups_grid(@pack_groups,@can_edit) %>\n <% grid.caption = @caption %>\n <% @header_content = grid.build_grid_data %>\n\n <% @pagination = pagination_links(@pack_groups_pages) if @pack_groups_pages != nil %>\n <%= grid.render_html %>\n <%= grid.render_grid %>\n }, :layout => 'content'\n end",
"def group\n @group\n end",
"def index\n\t#Once sessions are implemented, return all groups where the user has a priveledge\n\t#A table including all subgroups will be generated.\n\tGroup.rebuild! if nil.|Group.find(:first).rgt\n\n\t@groups = current_user.get_unique_group_branches\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def show_group\r\n show_group_by_id()\r\n end",
"def index\n @groups = Group.paginate :page => (params[:page]||1), :order => 'name ASC', :per_page => 10\n \n @self_member_groups = Group.find(User.find(current_user).group_members.map(&:group_id)) \n @self_created_groups = User.find(current_user).groups\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def set_main_group(group)\r\n #@main_group = group\r\n\t\t@groups[10] = group\r\n\tend",
"def group\n @group\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def index\n @member_groups = ContentfulClient.instance.member_groups.sort_by do |member_group|\n member_group.name.gsub(/\\bThe \\b/, '')\n end\n end",
"def index\n @groups = @flr.groups.all\n end",
"def display_group\n self.groups.each do |group|\n if group != Group.find_by_name(\"Default\")\n if group != Group.find_by_name(\"Global\")\n return group.name\n end\n end\n end\n return \"N/A\"\n end",
"def index(g)\n\t\t\[email protected](g)\n\t\tend",
"def index\r\n if current_user.master_user?\r\n @groups = current_user.account.groups\r\n else\r\n @groups = current_user.groups\r\n end\r\n @ids_for_earth = []\r\n @groups.each { |group| @ids_for_earth << group.id unless group.incivents.unarchived.count == 0 && group.tasks.unarchived.count == 0 && group.stories.unarchived.count == 0 && group.measurements.unarchived.count == 0 }\r\n end",
"def postprocess(groups)\n end",
"def index\n if @course.groups.size.zero? && @course.students.size.positive? && @course.projects.size.positive?\n group_service = GroupCreationManager::GroupMatcher.new\n group_service.determine_algo_and_match(@course, params)\n @course.update(has_group: true)\n end\n if @course.has_group && @course.state != \"view_groups\"\n @course.update(state: \"view_groups\")\n end\n @groups = @course.groups\n @group ||= @course.groups.first\n if current_user.type == 'Professor'\n current_user.current_course_id = @course.id\n current_user.save\n end\n respond_to do |format|\n format.html\n format.csv {send_data @groups.to_csv, filename: \"groups-#{Date.today}.csv\"}\n end\n end",
"def index\n @title = \"Grupos\"\n @previa_groups = PreviaGroup.all\n end",
"def index\n @groups = Group.display_for_user(current_user)\n end",
"def index\n @groups = current_user.groups.active\n render 'groups/welcome' if @groups.blank?\n end",
"def index\n @groups = @groups.order(:name)\n end",
"def index\n @groups = Group.all\n @users = User.all\n @tags = ActsAsTaggableOn::Tag.most_used\n if params[:search]\n @groups = Group.search(params[:search]).order(name: :asc)\n @pgheader = 'Search Results'\n elsif params[:tag]\n @groups = Group.tagged_with(params[:tag])\n else\n# @groups = Group.all.order(name: :asc)\n \n# by adding limit we only produce 5 results, and order random will choose the results at random.\n @groups = Group.limit(3).order(\"RANDOM()\")\n @pgheader = 'How about joining...'\n end\n end",
"def index\n @groups = Group.paginate :page => (params[:page] or 1)\n display @groups\n end",
"def groups\n @groups ||= {}\n end",
"def act\n @page_title = _('Bulk_management')\n @page_icon = 'groups.png'\n end",
"def index\n @pages_groups = PagesGroup.all\n end",
"def group\n nil\n end",
"def render_group_selection_page\n # Remove any group_id param in the url\n saml_url_without_group_id = request.original_url.gsub(/(&group_id=[^&]*)/,\"\")\n\n # Build SAML replay url for each group\n @saml_replay_urls = {}\n @user_group_access_list.each do |group|\n @saml_replay_urls[group.id] = \"#{saml_url_without_group_id}&group_id=#{group.uid}\"\n end\n\n render template: \"api/v1/auth/select_group_to_login\", layout: 'application'\n end",
"def send_group_list\n I3.server.send_object(I3.directory.find_all_groups)\n end",
"def index\n @groups_with_el = Provider.pluck(:group_id).uniq - [nil, 0]\n \n @groups = Provider.where(is_group: true).order(:name).map{|g| {\n id: g.id, \n name: g.name,\n spec: g.spec,\n allow_delete: !@groups_with_el.include?(g.id),\n goods_types_array: g.goods_type_names_array.join(', ')\n }}\n\n store_providers_path\n end",
"def groups\n #@groups = Kaminari.paginate_array(current_user.publications(Group)).page(params[:page])\n @groups = current_user.publications(Group)\n @in_search_page = true\n respond_to do |format|\n format.any(:html, :wml) {\n # render :template=>'groups/index'\n }\n format.json { render :json => @groups }\n end\n end",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def index\n @study_process_graphics = @year.study_process_graphics\n @search = @study_process_graphics.search(params[:q])\n @[email protected](:distinct => true)\n end",
"def groups=(_arg0); end",
"def group_info\n super\n end",
"def index\n @groups = SuperSimpleCms::Group.find(:all, :order=>:position)\n\n respond_to do |format|\n format.html { render :template => 'admin/groups/index' }\n format.xml { render :xml => @groups }\n end\n end",
"def ListView_GetGroupInfoByIndex(hwnd, iIndex, pgrp)\n send_listview_message(hwnd, :GETGROUPINFOBYINDEX, wparam: iIndex, lparam: pgrp)\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def group\n @group.name\n end",
"def index\n groupname = params[:groupname]\n @groups = Group.all\n @users = User.all\n end",
"def grouping\n @grouping ||= :clustered\n end",
"def list\n @session[:clustername]=nil\n @session[:clustername1]=nil\n @group_pages, @groups = paginate :groups, :per_page => 10\n end",
"def index\n @home = Home.find_by_ublog_name(@user)\n @groups = Home.find_all_by_is_group(1, :order => \"ublog_name\") # when set to 1, the account is a group\n # Narrow and mobile views use the same form\n request.format = :mobile if session[:narrow_view]\n \n respond_to do |format|\n format.html # index.html.erb\n format.mobile\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @tqrdc_groups = Tqrdc::Group.all.page\n end",
"def do_list_groups()\n I18n.t(\"sms.some_groups\") + \": \" + Group.primary_group_abbrevs\n end",
"def index_email_distribution_groups\n engines_api_system.index_email_distribution_groups\n end",
"def index\n if user_signed_in?\n @groups = current_user.groups.includes(:meetings, :lessons_through_meetings)\n @open_groups = @groups.select { |group| group.is_open? }\n @finished_groups = @groups.select { |group| group.is_finished? }\n @user_lesson_states = current_user.user_lesson_states\n .where(['lesson_id IN(?)', @groups.map {|group| group.lessons_through_meetings.map(&:id) }.flatten.uniq])\n\n template= 'index'\n else\n @groups = Group.includes(:meetings).publicly_searchable.all\n template= 'public_index'\n end\n\n respond_to do |format|\n format.html { render template: \"groups/#{template}\" }\n format.json { render json: @groups }\n end\n end",
"def current_group\n view_context.current_group\n end",
"def set_group\n data[:group]\n end",
"def hyrax_group_names\n groups\n end",
"def show\n save_navi_state(['groups_title', 'browse_groups'])\n begin\n @group = Group.find(params[:id])\n @members = @group.members(session[:cookie]).paginate :page => params[:page], :per_page => per_page\n rescue RestClient::ResourceNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n rescue ActiveRecord::RecordNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n end\n end",
"def index_global\n authorize UserGroup\n @user_groups = UserGroup.where(institution: nil).order(:name)\n end",
"def index\n\t\t# si rol mayor a desarrollador, listar todos los grupos \n \tif has_role_with_hierarchy?(:administrador) \n\t\t\t@groups = Group.all\n\t\t# si rol es desarrollador, listar solo sus grupos\n\t\telse\n\t\t\t@groups = Group.all :conditions => { :user_id, current_user.id }\n\t\tend\n end",
"def groups\n @groups = init_groups\n end",
"def show\n @groups = @form.groups\n end",
"def accord_all_groups\n gr3+gr4+gr5+gr6+gr7+gr8+gr9\n end",
"def index\n if coordinator? || admin?\n @groups = Group.all\n elsif professor?\n @groups = Group.where(course_id: Course.where(professor_id: current_user.id).all.ids ).all\n elsif student?\n @groups = User.find(current_user.id).groups.references( :students ).where( students: { user_id: current_user.id })\n\n end\n end",
"def index\n authorize! :see, Group\n @groups = Group.all\n end",
"def display_name\n group_name\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def place_groups\n Features.place_groups(features)\n end",
"def index\n @groups = Group.all\n @mentors = Mentor.all\n @profiles = Profile.all\n @home_url = authenticated_root_path\n @profile_url = \"#{current_user.role}/#{current_user.id}\" \n @group_url = \"/groups/#{@groups.name}\"\n @page_title = current_user.role.capitalize\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end",
"def get_groups\n `id -nG #{name}`.split(' ')\n end",
"def group_name\n @sg.group_name\n end",
"def group_name\n @sg.group_name\n end",
"def index\n @class_groups = @current_user.class_groups\n @class_group = ClassGroup.new\n end",
"def list_farm_groups\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:farm_groups_page] = params['page']\n\n\t\t render_list_farm_groups\n\n\t\t return \n\telse\n\t\tsession[:farm_groups_page] = nil\n\tend\n\n\tlist_query = \"@farm_group_pages = Paginator.new self, FarmGroup.count, @@page_size,@current_page\n\t @farm_groups = FarmGroup.find(:all,\n\t\t\t\t :limit => @farm_group_pages.items_per_page,\n\t\t\t\t :offset => @farm_group_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_farm_groups\nend",
"def render_grouped_document_index(locals = nil)\n render_template('group_default', locals)\n end",
"def show_groups\n content = Accio::Parser.read\n content.groups.each do |group|\n puts \"#{group.title}\\n\"\n end\n end",
"def index\n @small_groups = SmallGroup.all\n end",
"def show\n @grocery_groups = @grocery.groups\n end",
"def groups\n hyrax_groups.map(&:name)\n end",
"def ListView_InsertGroup(hwnd, index, pgrp)\n send_listview_message(hwnd, :INSERTGROUP, wparam: index, lparam: pgrp)\n end"
] | [
"0.720992",
"0.7156306",
"0.71492815",
"0.71492815",
"0.71492815",
"0.67437506",
"0.6737039",
"0.671414",
"0.66787845",
"0.6656012",
"0.66070586",
"0.65212923",
"0.64800763",
"0.64789146",
"0.6470866",
"0.64298844",
"0.6407856",
"0.64005226",
"0.6335072",
"0.63215625",
"0.6320579",
"0.63070863",
"0.63028175",
"0.6285178",
"0.6285178",
"0.6285178",
"0.62535787",
"0.62523633",
"0.6246932",
"0.62414265",
"0.6205024",
"0.6201266",
"0.6194042",
"0.6181908",
"0.617564",
"0.61734056",
"0.6169956",
"0.61648464",
"0.61533266",
"0.6150747",
"0.61383504",
"0.61288255",
"0.6126616",
"0.61191803",
"0.61106956",
"0.6109768",
"0.61067",
"0.6106584",
"0.60980445",
"0.60892504",
"0.60831475",
"0.60830224",
"0.60820657",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6077981",
"0.6070746",
"0.60698175",
"0.6067706",
"0.6064916",
"0.60538816",
"0.6042735",
"0.601418",
"0.6010545",
"0.6008",
"0.6004047",
"0.6000393",
"0.5997011",
"0.59955907",
"0.5993633",
"0.59894294",
"0.59779555",
"0.5970946",
"0.5965622",
"0.59645325",
"0.5946393",
"0.5942515",
"0.5935715",
"0.593258",
"0.592973",
"0.59287834",
"0.5911157",
"0.59078026",
"0.59078026",
"0.5905215",
"0.58987695",
"0.5895556",
"0.58947945",
"0.5894574",
"0.5893685",
"0.5893246",
"0.58843225"
] | 0.0 | -1 |
This is customized because GENCAT don't Processes Groups on Index Page | def filtered_processes
search.results.where(decidim_participatory_process_group_id: Rails.application.config.regulation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_groups; end",
"def index\n @title = \"groups_title\"\n #save_navi_state(['groups_title', 'browse_groups']) #moved to filter\n public_group_ids = Group.get_public_group_ids(session[:cookie])\n # add groups to Kassi db if there are new (made in other services)\n Group.add_new_groups_to_kassi_db(public_group_ids)\n \n @groups = Group.paginate( public_group_ids ,{:page => params[:page], :per_page => per_page})\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def index\r\n return jump_to(\"/groups/all\") unless has_login?\r\n \r\n account_id = session[:account_id]\r\n \r\n account_setting = AccountSetting.get_account_setting(account_id)\r\n module_group_index = account_setting.get_setting_value(:module_group_index)\r\n \r\n url = case module_group_index\r\n when \"all\"\r\n \"all\"\r\n when \"recent\"\r\n \"recent/#{account_id}\"\r\n when \"join\"\r\n \"list/#{account_id}\"\r\n when \"admin\"\r\n \"list_admin/#{account_id}\"\r\n else\r\n \"recent/#{account_id}\"\r\n end\r\n jump_to(\"/groups/#{url}\")\r\n end",
"def group; end",
"def current_group\n end",
"def groups()\n\t\t\tend",
"def iii_groups; end",
"def ii_groups; end",
"def render\n @groups.each_value do |grp|\n #print(\"#{grp.name} \")\n glCallList( grp.displaylist ) # call precahed operation to save gpu/cpu\n end\n end",
"def in_frontend_groups\n # groups = []\n # xrefs = self.racc_route_destination_xrefs\n \n # vlabels = self.racc_routes.map {|rr| rr.vlabel_map }\n # vlabels.compact!\n # vlabels.delete_if {|v| v.group.category != \"f\" || v.group.group_default == false}\n # groups = vlabels.map {|v| Operation.first(:conditions => {:app_id => v.app_id, :newop_rec => v.vlabel}).group }\n Group.all(:conditions => [\"name IN \n (SELECT vlabel_group FROM racc_op WHERE newop_rec IN \n (SELECT vlabel FROM racc_vlabel_map WHERE vlabel IN \n (SELECT route_name FROM racc_route WHERE route_id IN \n (SELECT route_id FROM racc_route_destination_xref WHERE app_id = :app_id AND destination_id = :id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id AND category = :category AND group_default = :group_default\", {:id => self.id, :app_id => self.app_id, :category => 'f', :group_default => false}])\n end",
"def index\n @groups = Group.all\n @bc_title = t('bc.Groups')\n end",
"def girl_groups; end",
"def index\n @groups = current_trainer.groups\n end",
"def render_list_pack_groups()\n\n @can_edit = authorise(program_name?, 'production_run_setup', session[:user_id])\n\n @current_page = session[:pack_groups_page] if session[:pack_groups_page]\n\n @current_page = params['page'] if params['page']\n\n @pack_groups = eval(session[:query]) if !@pack_groups\n\n @caption = \"list of pack groups for schedule: #{session[:current_closed_schedule].production_schedule_name} and run #{session[:current_production_run].production_run_number}\"\n\n render :inline => %{\n <% grid = build_pack_groups_grid(@pack_groups,@can_edit) %>\n <% grid.caption = @caption %>\n <% @header_content = grid.build_grid_data %>\n\n <% @pagination = pagination_links(@pack_groups_pages) if @pack_groups_pages != nil %>\n <%= grid.render_html %>\n <%= grid.render_grid %>\n }, :layout => 'content'\n end",
"def group\n @group\n end",
"def index\n\t#Once sessions are implemented, return all groups where the user has a priveledge\n\t#A table including all subgroups will be generated.\n\tGroup.rebuild! if nil.|Group.find(:first).rgt\n\n\t@groups = current_user.get_unique_group_branches\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @groups = Group.paginate :page => (params[:page]||1), :order => 'name ASC', :per_page => 10\n \n @self_member_groups = Group.find(User.find(current_user).group_members.map(&:group_id)) \n @self_created_groups = User.find(current_user).groups\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def show_group\r\n show_group_by_id()\r\n end",
"def set_main_group(group)\r\n #@main_group = group\r\n\t\t@groups[10] = group\r\n\tend",
"def group\n @group\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def index\n @member_groups = ContentfulClient.instance.member_groups.sort_by do |member_group|\n member_group.name.gsub(/\\bThe \\b/, '')\n end\n end",
"def index\n @groups = @flr.groups.all\n end",
"def display_group\n self.groups.each do |group|\n if group != Group.find_by_name(\"Default\")\n if group != Group.find_by_name(\"Global\")\n return group.name\n end\n end\n end\n return \"N/A\"\n end",
"def index(g)\n\t\t\[email protected](g)\n\t\tend",
"def index\r\n if current_user.master_user?\r\n @groups = current_user.account.groups\r\n else\r\n @groups = current_user.groups\r\n end\r\n @ids_for_earth = []\r\n @groups.each { |group| @ids_for_earth << group.id unless group.incivents.unarchived.count == 0 && group.tasks.unarchived.count == 0 && group.stories.unarchived.count == 0 && group.measurements.unarchived.count == 0 }\r\n end",
"def postprocess(groups)\n end",
"def index\n if @course.groups.size.zero? && @course.students.size.positive? && @course.projects.size.positive?\n group_service = GroupCreationManager::GroupMatcher.new\n group_service.determine_algo_and_match(@course, params)\n @course.update(has_group: true)\n end\n if @course.has_group && @course.state != \"view_groups\"\n @course.update(state: \"view_groups\")\n end\n @groups = @course.groups\n @group ||= @course.groups.first\n if current_user.type == 'Professor'\n current_user.current_course_id = @course.id\n current_user.save\n end\n respond_to do |format|\n format.html\n format.csv {send_data @groups.to_csv, filename: \"groups-#{Date.today}.csv\"}\n end\n end",
"def index\n @title = \"Grupos\"\n @previa_groups = PreviaGroup.all\n end",
"def index\n @groups = Group.display_for_user(current_user)\n end",
"def index\n @groups = current_user.groups.active\n render 'groups/welcome' if @groups.blank?\n end",
"def index\n @groups = @groups.order(:name)\n end",
"def index\n @groups = Group.all\n @users = User.all\n @tags = ActsAsTaggableOn::Tag.most_used\n if params[:search]\n @groups = Group.search(params[:search]).order(name: :asc)\n @pgheader = 'Search Results'\n elsif params[:tag]\n @groups = Group.tagged_with(params[:tag])\n else\n# @groups = Group.all.order(name: :asc)\n \n# by adding limit we only produce 5 results, and order random will choose the results at random.\n @groups = Group.limit(3).order(\"RANDOM()\")\n @pgheader = 'How about joining...'\n end\n end",
"def index\n @groups = Group.paginate :page => (params[:page] or 1)\n display @groups\n end",
"def groups\n @groups ||= {}\n end",
"def act\n @page_title = _('Bulk_management')\n @page_icon = 'groups.png'\n end",
"def index\n @pages_groups = PagesGroup.all\n end",
"def group\n nil\n end",
"def render_group_selection_page\n # Remove any group_id param in the url\n saml_url_without_group_id = request.original_url.gsub(/(&group_id=[^&]*)/,\"\")\n\n # Build SAML replay url for each group\n @saml_replay_urls = {}\n @user_group_access_list.each do |group|\n @saml_replay_urls[group.id] = \"#{saml_url_without_group_id}&group_id=#{group.uid}\"\n end\n\n render template: \"api/v1/auth/select_group_to_login\", layout: 'application'\n end",
"def send_group_list\n I3.server.send_object(I3.directory.find_all_groups)\n end",
"def index\n @groups_with_el = Provider.pluck(:group_id).uniq - [nil, 0]\n \n @groups = Provider.where(is_group: true).order(:name).map{|g| {\n id: g.id, \n name: g.name,\n spec: g.spec,\n allow_delete: !@groups_with_el.include?(g.id),\n goods_types_array: g.goods_type_names_array.join(', ')\n }}\n\n store_providers_path\n end",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def groups\n #@groups = Kaminari.paginate_array(current_user.publications(Group)).page(params[:page])\n @groups = current_user.publications(Group)\n @in_search_page = true\n respond_to do |format|\n format.any(:html, :wml) {\n # render :template=>'groups/index'\n }\n format.json { render :json => @groups }\n end\n end",
"def index\n @study_process_graphics = @year.study_process_graphics\n @search = @study_process_graphics.search(params[:q])\n @[email protected](:distinct => true)\n end",
"def groups=(_arg0); end",
"def index\n @groups = SuperSimpleCms::Group.find(:all, :order=>:position)\n\n respond_to do |format|\n format.html { render :template => 'admin/groups/index' }\n format.xml { render :xml => @groups }\n end\n end",
"def ListView_GetGroupInfoByIndex(hwnd, iIndex, pgrp)\n send_listview_message(hwnd, :GETGROUPINFOBYINDEX, wparam: iIndex, lparam: pgrp)\n end",
"def group_info\n super\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def index\n @groups = Group.all\n end",
"def group\n @group.name\n end",
"def index\n groupname = params[:groupname]\n @groups = Group.all\n @users = User.all\n end",
"def grouping\n @grouping ||= :clustered\n end",
"def list\n @session[:clustername]=nil\n @session[:clustername1]=nil\n @group_pages, @groups = paginate :groups, :per_page => 10\n end",
"def index\n @home = Home.find_by_ublog_name(@user)\n @groups = Home.find_all_by_is_group(1, :order => \"ublog_name\") # when set to 1, the account is a group\n # Narrow and mobile views use the same form\n request.format = :mobile if session[:narrow_view]\n \n respond_to do |format|\n format.html # index.html.erb\n format.mobile\n format.xml { render :xml => @groups }\n end\n end",
"def index\n @tqrdc_groups = Tqrdc::Group.all.page\n end",
"def do_list_groups()\n I18n.t(\"sms.some_groups\") + \": \" + Group.primary_group_abbrevs\n end",
"def index_email_distribution_groups\n engines_api_system.index_email_distribution_groups\n end",
"def index\n if user_signed_in?\n @groups = current_user.groups.includes(:meetings, :lessons_through_meetings)\n @open_groups = @groups.select { |group| group.is_open? }\n @finished_groups = @groups.select { |group| group.is_finished? }\n @user_lesson_states = current_user.user_lesson_states\n .where(['lesson_id IN(?)', @groups.map {|group| group.lessons_through_meetings.map(&:id) }.flatten.uniq])\n\n template= 'index'\n else\n @groups = Group.includes(:meetings).publicly_searchable.all\n template= 'public_index'\n end\n\n respond_to do |format|\n format.html { render template: \"groups/#{template}\" }\n format.json { render json: @groups }\n end\n end",
"def current_group\n view_context.current_group\n end",
"def set_group\n data[:group]\n end",
"def hyrax_group_names\n groups\n end",
"def show\n save_navi_state(['groups_title', 'browse_groups'])\n begin\n @group = Group.find(params[:id])\n @members = @group.members(session[:cookie]).paginate :page => params[:page], :per_page => per_page\n rescue RestClient::ResourceNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n rescue ActiveRecord::RecordNotFound => e\n flash[:error] = :group_not_found\n redirect_to groups_path\n end\n end",
"def index_global\n authorize UserGroup\n @user_groups = UserGroup.where(institution: nil).order(:name)\n end",
"def index\n\t\t# si rol mayor a desarrollador, listar todos los grupos \n \tif has_role_with_hierarchy?(:administrador) \n\t\t\t@groups = Group.all\n\t\t# si rol es desarrollador, listar solo sus grupos\n\t\telse\n\t\t\t@groups = Group.all :conditions => { :user_id, current_user.id }\n\t\tend\n end",
"def groups\n @groups = init_groups\n end",
"def show\n @groups = @form.groups\n end",
"def accord_all_groups\n gr3+gr4+gr5+gr6+gr7+gr8+gr9\n end",
"def index\n if coordinator? || admin?\n @groups = Group.all\n elsif professor?\n @groups = Group.where(course_id: Course.where(professor_id: current_user.id).all.ids ).all\n elsif student?\n @groups = User.find(current_user.id).groups.references( :students ).where( students: { user_id: current_user.id })\n\n end\n end",
"def index\n authorize! :see, Group\n @groups = Group.all\n end",
"def display_name\n group_name\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def place_groups\n Features.place_groups(features)\n end",
"def index\n @groups = Group.all\n @mentors = Mentor.all\n @profiles = Profile.all\n @home_url = authenticated_root_path\n @profile_url = \"#{current_user.role}/#{current_user.id}\" \n @group_url = \"/groups/#{@groups.name}\"\n @page_title = current_user.role.capitalize\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end",
"def get_groups\n `id -nG #{name}`.split(' ')\n end",
"def group_name\n @sg.group_name\n end",
"def group_name\n @sg.group_name\n end",
"def index\n @class_groups = @current_user.class_groups\n @class_group = ClassGroup.new\n end",
"def list_farm_groups\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:farm_groups_page] = params['page']\n\n\t\t render_list_farm_groups\n\n\t\t return \n\telse\n\t\tsession[:farm_groups_page] = nil\n\tend\n\n\tlist_query = \"@farm_group_pages = Paginator.new self, FarmGroup.count, @@page_size,@current_page\n\t @farm_groups = FarmGroup.find(:all,\n\t\t\t\t :limit => @farm_group_pages.items_per_page,\n\t\t\t\t :offset => @farm_group_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_farm_groups\nend",
"def render_grouped_document_index(locals = nil)\n render_template('group_default', locals)\n end",
"def index\n @small_groups = SmallGroup.all\n end",
"def show_groups\n content = Accio::Parser.read\n content.groups.each do |group|\n puts \"#{group.title}\\n\"\n end\n end",
"def show\n @grocery_groups = @grocery.groups\n end",
"def groups\n hyrax_groups.map(&:name)\n end",
"def ListView_InsertGroup(hwnd, index, pgrp)\n send_listview_message(hwnd, :INSERTGROUP, wparam: index, lparam: pgrp)\n end"
] | [
"0.720833",
"0.7154749",
"0.7147088",
"0.7147088",
"0.7147088",
"0.67428076",
"0.6735224",
"0.67125964",
"0.6676358",
"0.66545063",
"0.66057444",
"0.65207285",
"0.6478785",
"0.6477006",
"0.6468802",
"0.6428491",
"0.64075553",
"0.6398134",
"0.63345194",
"0.6318886",
"0.6318827",
"0.6304599",
"0.6300379",
"0.62829864",
"0.62829864",
"0.62829864",
"0.6251597",
"0.6251013",
"0.62441397",
"0.62404054",
"0.62038356",
"0.6201968",
"0.61929625",
"0.61809754",
"0.6174105",
"0.6172195",
"0.6168066",
"0.61632705",
"0.61518097",
"0.6148175",
"0.61382264",
"0.61285686",
"0.6124371",
"0.6117423",
"0.61091655",
"0.61076677",
"0.6106257",
"0.6104795",
"0.6097943",
"0.6087256",
"0.6081418",
"0.6081138",
"0.6080597",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60764647",
"0.60680443",
"0.6067752",
"0.60662156",
"0.6063837",
"0.60533255",
"0.60413265",
"0.6011517",
"0.6010414",
"0.6006641",
"0.60030526",
"0.5997059",
"0.59948856",
"0.5992856",
"0.5991382",
"0.5987173",
"0.59753174",
"0.59697086",
"0.5963983",
"0.59625614",
"0.5944544",
"0.5939365",
"0.5933761",
"0.5930922",
"0.59278166",
"0.59269816",
"0.5909961",
"0.59054136",
"0.59054136",
"0.59042567",
"0.58981234",
"0.5895066",
"0.5893738",
"0.58929664",
"0.58921707",
"0.58915293",
"0.5882825"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.