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
extension_config do |config| config.gem 'someawesomegem' config.after_initialize do run_something end end See your config/routes.rb file in this extension to define custom routes
def activate Page.send(:include, ArchiveChildrenTags) # tab 'Content' do # add_item "Archive Children", "/admin/archive_children", :after => "Pages" # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_routes; end", "def external_routes; end", "def after_initialize\n super\n extension_loader.activate_extensions # also calls initialize_views\n TrustyCms::Application.config.add_controller_paths(extension_loader.paths(:controller))\n TrustyCms::Application.config.add_eager_load_paths(extension_loader.paths(:eager_load))\n end", "def named_routes; end", "def add_extension_routes(options)\n ext_routes = \"#{database_route(options[:database])}#{mailer_route(options[:skip_mailer])}#{sidekiq_route(options)}\"\n routes_str = if options[:noauth]\n <<~ROUTES\n # If authentication has not been used; only allow this routes to be used in development to prevent authorized access\n if Rails.env.development?\n #{ext_routes.squeeze(\"\\n\").strip}\n end\n ROUTES\n else\n <<~ROUTES\n # Require the person hitting this page ot be an application admin\n authenticate :user, -> (user) { user.admin? } do\n #{ext_routes.squeeze(\"\\n\").strip}\n end\n ROUTES\n end\n optimize_indentation(routes_str, 2)\n end", "def initialize_routing\n configuration.add_controller_paths(extension_loader.paths(:controller))\n configuration.add_eager_load_paths(extension_loader.paths(:eager_load))\n super\n end", "def named_route; end", "def inject_mei_routes\n unless IO.read(\"config/routes.rb\").include?('Mei::Engine')\n marker = 'Rails.application.routes.draw do'\n insert_into_file \"config/routes.rb\", :after => marker do\n %q{\n mount Mei::Engine => '/'\n}\n end\n\n end\n end", "def url_helpers_module; end", "def add_url_helper(name, defaults, &block); end", "def anchored_routes; end", "def live_route_ar\n route_descriptor_ar(ActionController::Routing::Routes)\n end", "def define_path_helpers; end", "def add_route_helpers\n template \"route_helpers.js.coffee\", \"#{ember_path}/route_helpers.js.coffee\"\n end", "def _routes; end", "def url_helpers\n Rails.application.routes.url_helpers\n end", "def inject_vlr_routes\n unless IO.read(\"config/routes.rb\").include?('CommonwealthVlrEngine::Engine')\n marker = 'Rails.application.routes.draw do'\n insert_into_file \"config/routes.rb\", :after => marker do\n %q{\n\n root :to => 'pages#home'\n\n # routes for CommonwealthVlrEngine\n mount CommonwealthVlrEngine::Engine => '/commonwealth-vlr-engine'\n\n # user authentication\n devise_for :users, :controllers => {:omniauth_callbacks => \"users/omniauth_callbacks\", :registrations => \"users/registrations\", :sessions => \"users/sessions\"}\n}\n end\n\n bl_root_marker = 'root to: \"catalog#index\"'\n gsub_file(\"config/routes.rb\", bl_root_marker, \"\")\n\n end\n end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def setup_router(scope); end", "def inject_routes\n routing_code = \"Hydra::BatchEdit.add_routes(self)\"\n sentinel = /HydraHead.add_routes\\(self\\)/\n inject_into_file 'config/routes.rb', \"\\n #{routing_code}\\n\", { :after => sentinel, :verbose => false }\n\n routing_code = \"\\n # This must be the very last route in the file because it has a catch all route for 404 errors.\n # This behavior seems to show up only in production mode.\n mount Sufia::Engine => '/'\\n\"\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }\n \n end", "def mount_engine\n puts \"Mounting Cadenero::Engine at \\\"/\\\" in config/routes.rb...\"\n insert_into_file(\"#{Rails.root}/config/routes.rb\", :after => /routes.draw.do\\n/) do\n %Q{\n mount Cadenero::Engine, :at => \"/\" # This line mounts Cadenero's routes at / by default.\n # This means, any requests to the / URL of your application will go to Cadenero::V1:Account::DashboardController#index.\n # If you would like to change where this extension is mounted, simply change the :at option to something different\n # but that is discourage, the idea is to protect the whole site\n\n}\n end\n end", "def controller\n 'setup_custom_start_point'\n end", "def custom_setup(args)\n if(args[:api_endpoint].to_s.end_with?('/'))\n args[:api_endpoint] = args[:api_endpoint][0, endpoint.length - 1]\n end\n end", "def initialize\n #load_config\n load_routes\n end", "def plugin_setup!; end", "def named_routes=(_arg0); end", "def update_routes\n insert_into_file 'config/routes.rb', %(\n root :to => 'portal#page'\n DrgCms.routes\n\n put '/portal/process_login'\n post '/reports/diary'\n\n resources :init # remove after initial run\n\n get '*path' => 'portal#page'\n\n),\n after: 'Rails.application.routes.draw do'\nend", "def path_helpers_module; end", "def url_helpers\n Rails.application.routes.url_helpers\n end", "def define_handler(*extensions, &block)\n Figgy::Root.handlers += extensions.map { |ext| [ext, block] }\n end", "def register_framework_extensions\n register Padrino::Mailer if padrino_mailer?\n register Padrino::Helpers if padrino_helpers?\n register Padrino::Admin::AccessControl if authentication?\n end", "def routes(context={})\n \n routes = [{:path => '/admin/worker-jobs',\n :regular_expression => /^\\/admin\\/worker-jobs/, \n :title => 'Delayed jobs', \n :description => 'Query delayed jobs',\n :fit => 1,\n :module => :system }]\n \n end", "def mount_engine\n puts \"Mounting engine into routes.rb...\"\n insert_into_file 'config/routes.rb', \"\\n\\nmount Touchstone::Engine, :at => '/touchstone/'\", :after => 'routes.draw do'\n end", "def all_application_helpers; end", "def path_helper\n Rails.application.routes.url_helpers\n end", "def path_helper\n Rails.application.routes.url_helpers\n end", "def extended_modules; end", "def before_resolution\n end", "def add_route(*args)\n custom_routes << args\n end", "def finalize_artifacts\n \n return if skip_method(__method__)\n \n puts \"finalize Rails routes in config/routes.rb\"\n \n add_routes(@@rails_routes)\n \n # create the navigation menu\n finalize_menu\n \n end", "def extension; end", "def extension; end", "def extension; end", "def extension; end", "def define_url_helper(mod, name, helper, url_strategy); end", "def around_hooks; end", "def init_ext()\n \n end", "def after_initialize_with_appable_plugins\n after_initialize_without_appable_plugins\n inject_controller_paths\n \n # Inject dependencies when being loaded after initialization in case\n # loaded_plugins was loaded as a gem midway through application initialization\n inject_dependencies(:after_initialize)\n end", "def add_routes(routes)\n \n return if skip_method(__method__)\n \n write_artifact(\"config/routes.rb\") do |file|\n file.puts(\"Rails.application.routes.draw do\")\n file.puts(\"\n concern :common_routes do\n get :range, on: :collection\n # handles requests where relation is a query param (RestAngularBuilder)\n # e.g. users/1/related.json?relation=department\n get :related \n post :search\n end\")\n \n if namespace\n file.puts(\" namespace :#{namespace} do\")\n end\n routes.each do |route|\n namespace.nil? ? file.puts(route) : file.puts(indent(route))\n end\n if namespace\n file.puts(\" end\")\n end\n file.puts(\"end\")\n end\n\n end", "def load_routes_with_test_helper!\n if defined?(RAILS_ROOT) && defined?(::ActionController::Routing::Routes) && self == ::ActionController::Routing::Routes\n routes_path = File.join(\"#{RAILS_ROOT}/config/routes.rb\")\n routes_path = File.join(\"#{HELPER_RAILS_ROOT}/config/routes.rb\") if !File.exists?(routes_path)\n \n load File.join(routes_path)\n else\n add_route \":controller/:action/:id\"\n end\n end", "def install_devmode_route\n super\n ActionController::Routing::RouteSet.class_eval do\n return if defined? draw_without_test_route\n\n def draw_with_test_route\n draw_without_test_route do |map|\n map.connect(':controller/:action/:id')\n yield(map)\n end\n end\n alias_method_chain(:draw, :test_route)\n end\n # Force the routes to be reloaded\n ActionController::Routing::Routes.reload!\n end", "def add_plugin_routes(map)\n # these are in use\n map.connect 'users/:id/password', :controller => 'users', :action => 'password'\n map.connect 'users/:id/social', :controller => 'users', :action => 'social'\n map.user_contact '/contact', :controller => 'users', :action => 'contact', :conditions => { :method => :get }\n map.conference_account '/conferences/:id/account', :controller => 'conferences', :action => 'account', :conditions => { :method => :get }\n map.conference_dashboard '/conferences/:id/dashboard', :controller => 'conferences', :action => 'dashboard', :conditions => { :method => :get }\n map.conference_workspace '/conferences/:id/workspace', :controller => 'conferences', :action => 'workspace', :conditions => { :method => :get }\n map.conference_invitation '/invitation/:id', :controller => 'conferences', :action => 'invitation', :conditions => { :method => :get }\n\n # pretty sure these are depreciated\n map.numbers '/numbers', :controller => 'conferences', :action => 'numbers', :conditions => { :method => :get }\n map.reference '/reference', :controller => 'conferences', :action => 'reference', :conditions => { :method => :get }\n map.resources :conferences, :has_many => :callees\n map.account_rates '/rates', :controller => 'accounts', :action => 'rates', :conditions => { :method => :get }\n map.email_remove '/emails/:id/remove', :controller => 'emails', :action => 'remove'\n\n # no idea about these ...\n map.modify_conference '/conferences/:id/modify', :controller => 'conferences', :action => 'modify', :conditions => { :method => :get }\n map.user_search '/users_search', :controller => 'users', :action => 'search', :conditions => { :method => :get }\n map.start '/start', :controller => 'conferences', :action => 'start', :conditions => { :method => :get }\n map.guest '/guest', :controller => 'conferences', :action => 'guest', :conditions => { :method => :get }\n\n map.upload '/upload.:format', :controller => 'media_files', :action => 'upload', :conditions => { :method => :post }\n map.upload '/upload.:format', :controller => 'media_files', :action => 'options', :conditions => { :method => :options }\n\n Hobo.add_routes(map)\n end", "def add_gem_paths; end", "def url_for_main; end", "def url_for_main; end", "def start_registering_extension\n @register_path = caller_files[2]\n end", "def add_extend ext\n add_to @extends, ext\n\n ext\n end", "def setup_handler\n end", "def route_index; end", "def add_url_helper(name, defaults, &block)\n helper = CustomUrlHelper.new(name, defaults, &block)\n path_name = :\"#{name}_path\"\n url_name = :\"#{name}_url\"\n\n @path_helpers_module.module_eval do\n redefine_method(path_name) do |*args|\n helper.call(self, args, true)\n end\n end\n\n @url_helpers_module.module_eval do\n redefine_method(url_name) do |*args|\n helper.call(self, args, false)\n end\n end\n\n @path_helpers << path_name\n @url_helpers << url_name\n\n self\n end", "def url_after_create\n # your special path\n end", "def method_missing(method, *args, &block)\n if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)\n main_app.send(method, *args, &block)\n else\n super\n end\n end", "def define_handler(*extensions, &block)\n @handlers += extensions.map { |ext| [ext, block] }\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def startup_hook; end", "def add_route path, controller, &block\n\t\t\t\t@active_host ||= add_host :default\n\t\t\t\t@active_host.routes << ::Plezi::Base::Route.new(path, controller, &block)\n\t\t\tend", "def route\n @extname = File.extname(request.path_info)\n @extname = nil if @extname.empty?\n args = super\n\n unless args.empty? || extname == nil\n args.last.chomp!(extname)\n end\n\n args\n end", "def install_post_hook\n end", "def initialize\n self.class.send :include, Rails.application.routes.url_helpers\n self.class.send :include, Rails.application.helpers\n Rails.configuration.makeover.helpers.each do |helper|\n self.class.send :include, helper\n end\n end", "def method_missing(method, *args, &block)\n if method.to_s.end_with?('_path', '_url')\n if main_app.respond_to?(method)\n main_app.send(method, *args)\n else\n super\n end\n else\n super\n end\n end", "def extend_rails(type, &block)\n on_load(type, &block)\n end", "def route_for(name, *args); end", "def add_routes(&block)\n @router ||= Routes.new\n @router.define(&block)\n url.router = @router\n end", "def setup_route\n route \"resources :tooltips do\\n\" +\n \" collection do\\n\" +\n \" get 'tooltip_content'\\n\" +\n \" end\\n\" +\n \" end\"\n end", "def before_setup; end", "def reload_routes!; end", "def reload_routes!; end", "def util_fake_extension(spec, name = \"a\", script = nil)\n mkrf_conf = File.join(\"ext\", name, \"mkrf_conf.rb\")\n\n spec.extensions << mkrf_conf\n\n dir = spec.gem_dir\n FileUtils.mkdir_p dir\n\n Dir.chdir dir do\n FileUtils.mkdir_p File.dirname(mkrf_conf)\n File.open mkrf_conf, \"w\" do |f|\n if script\n f.write script\n else\n f.write <<-EOF\n File.open 'Rakefile', 'w' do |rf| rf.puts \"task :default\" end\n EOF\n end\n end\n end\n end", "def pre_connect_hooks; end", "def pre_connect_hooks; end", "def post_install; end", "def util_fake_extension(spec, name = \"a\", script = nil)\n mkrf_conf = File.join(\"ext\", name, \"mkrf_conf.rb\")\n\n spec.extensions << mkrf_conf\n\n dir = spec.gem_dir\n FileUtils.mkdir_p dir\n\n Dir.chdir dir do\n FileUtils.mkdir_p File.dirname(mkrf_conf)\n File.open mkrf_conf, \"w\" do |f|\n if script\n f.write script\n else\n f.write <<~EOF\n File.write('Rakefile', \"task :default\")\n EOF\n end\n end\n end\n end", "def method_missing method, *args, &block\n method.to_s.end_with?('_path', '_url') and main_app.respond_to?(method) ? main_app.send(method, *args) : super\n end", "def after_view_setup\n end", "def init_routes\n puts \"Adding the caboose store routes...\"\n \n filename = File.join(@app_path,'config','routes.rb')\n return if !File.exists?(filename)\n return if !@force\n \n str = \"\" \n str << \"\\t# Catch everything with caboose\\n\" \n str << \"\\tmount CabooseStore::Engine => '/'\\n\"\n \n file = File.open(filename, 'rb')\n contents = file.read\n file.close \n if (contents.index(str).nil?)\n arr = contents.split('end', -1)\n str2 = arr[0] + \"\\n\" + str + \"\\nend\" + arr[1]\n File.open(filename, 'w') {|file| file.write(str2) }\n end \n end", "def route_name; end", "def route_name; end", "def initialize_extension_partials\n @extension_partials = []\n end", "def add_my_custom_path\n prepend_view_path(\"app/views/custom/\")\n end" ]
[ "0.69148207", "0.65548897", "0.60935384", "0.59472436", "0.593951", "0.58708704", "0.57642835", "0.56205094", "0.5617361", "0.5609739", "0.56045693", "0.5589057", "0.55866235", "0.5565984", "0.55591667", "0.55579543", "0.55560505", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.55175877", "0.5517219", "0.5483841", "0.54492044", "0.54490566", "0.5448696", "0.54392904", "0.54301023", "0.539998", "0.53955305", "0.53896147", "0.5369441", "0.5359247", "0.5331601", "0.5317327", "0.5307182", "0.52991277", "0.5293818", "0.5293818", "0.5262749", "0.5249123", "0.5241697", "0.52191484", "0.5218486", "0.5218486", "0.5218486", "0.5218486", "0.52090144", "0.5205131", "0.52050245", "0.5199129", "0.51848304", "0.5174203", "0.5168318", "0.5156037", "0.51477706", "0.5143545", "0.5143545", "0.5139837", "0.51384753", "0.5136413", "0.5132017", "0.5129561", "0.51205677", "0.5100494", "0.50978935", "0.50899607", "0.50899607", "0.50899607", "0.50887775", "0.5085516", "0.5071809", "0.5055897", "0.50422573", "0.5037517", "0.5024593", "0.5023429", "0.50215936", "0.50163335", "0.5013272", "0.5012311", "0.5012311", "0.50090015", "0.50051266", "0.50051266", "0.5001789", "0.49989772", "0.49969256", "0.4992527", "0.49851257", "0.49822864", "0.49822864", "0.4975139", "0.49726814" ]
0.0
-1
Catch common beginner mistake and give a helpful error message on stderr
def execute(*) file, line, = caller.first.split(":") colors = SSHKit::Color.new($stderr) $stderr.puts colors.colorize("Warning: `execute' should be wrapped in an `on' scope in #{file}:#{line}.", :red) $stderr.puts $stderr.puts " task :example do" $stderr.puts colors.colorize(" on roles(:app) do", :yellow) $stderr.puts " execute 'whoami'" $stderr.puts colors.colorize(" end", :yellow) $stderr.puts " end" $stderr.puts raise NoMethodError, "undefined method `execute' for main:Object" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(subject = nil, message)\n $stderr.puts \"#{name}: #{message}\"\n saved = $stdout\n begin\n $stdout = $stderr\n Formatter.usage(grammar)\n exit 1\n ensure\n $stdout = saved\n end\n end", "def error(msg) $stderr.puts(\"Error: #{msg}\") end", "def error(message) puts(message) || exit end", "def write_fatal_error message\n puts \"Error: #{message}. See spritemaster -h for usage\"\n exit\n end", "def error(message)\n print(1, message)\n end", "def error(message)\n STDERR.puts message\nend", "def stderr; end", "def stderr; end", "def stderr; end", "def stderr; end", "def complain something\n puts angry_dude_format something\n end", "def error\n raise StandardError, 'Error parsing input'\n end", "def errmsg(message)\n print(\"*** #{message}\\n\")\n end", "def error(msg)\n STDERR.puts \"#{@progname}: FAIL: #{msg}\"\n end", "def usage_error\n $stderr.printf(\"%s\\n\", usage)\n exit(-1)\n end", "def errmsg(*args)\n if Debugger.annotate.to_i > 2\n aprint 'error-begin'\n print(*args)\n aprint ''\n else\n print '*** '\n print(*args)\n end\n end", "def error(string); end", "def error(string); end", "def error(message)\n Kernel.puts \" !\"\n message.split(\"\\n\").each do |line|\n Kernel.puts \" ! #{line.strip}\"\n end\n Kernel.puts \" !\"\n exit 1\nend", "def consume_stderr(text)\n @@log.warn {\"Unexpected line on stderr: '#{text}'. Verify that scripts are not broken.\"}\n end", "def error\n\t\tputs \"*********************\"\n\t\tputs \"<ERROR> Invalid input\"\n\t\tputs \"*********************\"\n\tend", "def error\n print \"That is not a valid input. \\n\"\n end", "def err(message)\n stderr.puts message\n end", "def chew_error_and_print_message(e)\n case e.message\n when 'ARTICLE_NIL_REQUIRED_VALUE_ERROR'\n puts \"Artigo com título ou autor nulos.\".yellow\n # log_article_error_to_file(article, a_link)\n # interrupt(interrupt_option)\n when \"ARTICLE_ALREADY_IN_DB_ERROR\"\n puts \"Artigo já está no Banco de Dados.\".green\n # log_article_error_to_file(article, a_link)\n when \"FORBIDDEN_ARTICLE_TITLE_ERROR\"\n puts \"Artigo com título proibido.\".yellow\n # interrupt(interrupt_option)\n # log_article_error_to_file(article, a_link)\n else\n puts e.message\n end\n puts \"Ignorando artigo com problemas... OK\\n\"\nend", "def recoverable_error e, msg = \"Error\", bt = []\n puts \"#{msg} at time #{clock}\"\n puts \"From \" + bt[0..2].join(\"\\n \") unless bt.empty\n puts \" ...\" if bt.length > 3\n shell.run\n end", "def err(message)\n warn \" > #{message}\"\nend", "def error(msg)\n return if @nolog\n puts msg\n exit 5\n end", "def error(text)\n STDERR.puts red_term_text(text)\n end", "def error( text )\n puts \"Script #{@name} #{version} - Error: #{text}\"\n exit 1\n end", "def err(msg)\n puts msg.red\n exit(1)\n end", "def err(message)\n STDERR.puts(message)\n exit 1\n end", "def errmsg(message); end", "def obvious_error(message, e)\n \"#{stars}\\n#{message}\\n#{stars}\\n#{e.message}#{stars}\"\n end", "def error(rc)\n return rc[0].strip if rc[2].success?\n\n puts \"ERROR: #{rc[1]}\"\n\n exit(-1)\nend", "def print_error\n puts @error_text if @error_text\n print_usage\n end", "def bold_error(*args); end", "def error_message(msg)\n STDERR.puts msg\n end", "def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsif !(invalid_packages.empty? && invalid_metadata_files.empty?)\n error_message\n exit 2\n # We don't have checksums for some packages?\n elsif unverifiable_package_count != 0\n unverifiable_packages_message\n exit 2\n else\n success_message\n exit 0\n end\n end", "def error(msg)\n stderr(\"error: #{msg}\")\n end", "def error\n\tputs \" - Dis donc #{@name}, tu vois pas que c'est pas possible ?!? Allez rejoue ! \"\n\tputs \" \"\n end", "def format_compile_error(file_name, file_path, reason,\n line, cursor); EMPTY; end", "def err(input)\n puts \"[#{Time.now.strftime(\"%T\").purple} \" + \"ERROR\".red + \"] \" + \"#{input.red}\"\n end", "def fatal; end", "def error(message)\n STDERR.puts <<-EOS\n\\u001b[1;91mERROR\\u001b[0m \\u001b[1m#{message}\\u001b[0m\n\n#{self.banner}\n EOS\n exit 1\n end", "def setup_fail(message)\n puts '-'*50\n message.each { |line| puts line }\n puts '-'*50\n exit\n end", "def errmsg(message)\n error.print(\"*** #{message}\\n\")\n end", "def fatal?; end", "def fatal?; end", "def error(message, line, column)\n puts \"*-*-* error at #{line}:#{column}: #{message}\"\n end", "def alert_error(statement, question=nil)\n @errs.puts \"ERROR: #{statement}\"\n ask(question) if question\n end", "def handle_error(cmd, stderr)\n summary = \"\\rError running \\`#{cmd}\\`\"\n details = readable_curr_time << \"\\n\\n\"\n details << \"**************************************************************\\n\"\n details << \"#{summary}\\n\"\n details << \"**************************************************************\\n\"\n details << stderr << \"\\n\\n\"\n File.open(@err_path, 'a') { |file| file.write(details) }\n summary\nend", "def error(message)\n STDERR.puts red(message)\n end", "def error\n raise Exception, \"An example of what an error looks like if you make a mistake using Commandable.\"\n end", "def print_error(msg='')\n end", "def error(*args); say $terminal.color(format(*args), :red); end", "def problem(reason_for_error)\n\tputs \"\\aOops, we have a problem here.\" #\\a escape character Bell for error warning\n\tputs \"Your entry '#{reason_for_error}' is incorrect.\"\n\tputs\nend", "def print_error\n puts $0 + \": illegal option \" + ARGV[0]\n print_usage\nend", "def errorCheck()\n\t# Debug output\n\tif $DEBUG then STDERR.puts \"in errorCheck()\" end\n\n\t# no args -> quit\n\tif ARGV.length == 0\n\t\tputs \"incorrect argument(s). usage: 'ruby name2number.rb <name1> <name2> <name3>..\"\n\t\texit\n\tend\n\n\t# special characters / numbers -> quit\n\tARGV.each do |arg|\n\t\tif arg !~ /^[a-zA-Z]+$/ then\n\t\t\tputs \"non-alphabetical character(s) detected. usage: 'ruby name2number.rb <name1> <name2> <name3>..\"\n\t\t\texit\n\t\tend \n\tend\nend", "def unexpected_error(format)\n msg = \"Hi #{@user.first_name},\"\n msg << \"\\n\\n\"\n msg << 'Something weird and unexpected happened when you tried posting to MindHub via an '\n msg << \"email. The site is automatically sending this email out to let you know, and it's \"\n msg << 'CCing the site Admins so they can look into what happened. In the meantime, '\n msg << \"take a look at the #{faq_link_for(format)} and make sure you follow the rules \"\n msg << 'for posting via email.'\n msg << \"\\n\\n\"\n msg << \"We're sorry this happened and if this is our fault, will try to fix this ASAP! \"\n msg << \"Here's what you tried posting:\"\n msg << \"\\n\"\n\n msg\n end", "def output_error(string)\n if Command.ui\n Command.ui.error string\n else\n $stderr.puts \"ERROR: #{string}\"\n end\n end", "def error message, exit_on_print = true\n\t\traise \"Error message only takes 'String' or 'Array'\" if !message.is_a?(Array) && !message.is_a?(String)\n\n\t\tsay \"\\n-----------------------------------------------------------------\".red\n\t\tsay \" Error:\\n\".red\n\t\tsay \" \" + message if message.is_a?(String)\n\t\tmessage.each {|line| say \" \" + line if line.is_a?(String) } if message.is_a?(Array)\n\t\tsay \"-----------------------------------------------------------------\\n\".red\n\t\texit if exit_on_print\nend", "def fatal_error(error)\n $stderr.puts \"#{$0}: error: #{error}\"\n exit 1\nend", "def output_error(cmd)\n puts \"La commande '#{cmd}' n'existe pas ou a été mal formulée.\".red\n end", "def error(text = nil)\n estream.puts text\n end", "def script_error(path, error); end", "def error(msg)\n puts red(bold(\"[!] #{msg}\"))\n end", "def error(*args); end", "def display_error\n error <<~MSG\n Sorry, please check\n your input to verify it\n is correct.\n MSG\n prompt error\nend", "def error(message)\n $stderr.puts message\n end", "def error?; end", "def error?; end", "def error?; end", "def handle_error(program, e)\n stderr.puts \"#{program}: Error - #{e.message}\"\n true\n end", "def error(msg)\n puts \"#{msg}\\n\\n\"\n exit -1\nend", "def search_error()\n error = TTY::Box.warn(\"Sorry no record found. Try another log.\")\n puts error\nend", "def type_error(line_number, message)\n\tputs \"ERROR: #{line_number}: Type-Check: #{message}\"\n\texit\nend", "def type_error(line_number, message)\n\tputs \"ERROR: #{line_number}: Type-Check: #{message}\"\n\texit\nend", "def error(msg = '')\n\t\toutput.print_error(msg)\n\tend", "def error(msg, exc: nil)\n must \"message\", msg, be: String\n\n tell(colorize(\"☠ \", :magenta) + colorize(msg, :red))\n\n if exc\n raise exc.new(msg)\n else\n exit(-1)\n end\n end", "def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + details\n\tend", "def fatalerror( err_msg )\n# Display a fatal error and quit. -----------------------------------\n if ($gTest_params[\"logfile\"])\n $fLOG.write(\"\\nsubstitute-h2k.rb -> Fatal error: \\n\")\n $fLOG.write(\"#{err_msg}\\n\")\n end\n print \"\\n=========================================================\\n\"\n print \"substitute-h2k.rb -> Fatal error: \\n\\n\"\n print \" #{err_msg}\\n\"\n print \"\\n\\n\"\n print \"substitute-h2k.rb -> Other Error or warning messages:\\n\\n\"\n print \"#{$ErrorBuffer}\\n\"\n exit() # Run stopped\nend", "def print_error(msg = '')\n $stderr.puts \"[ERROR] #{msg}\"\n end", "def error(msg)\n puts \"\\n#{@red}[Error] #{msg}!#{@ncl}\\n\"\n end", "def describe_error(error)\n tell_user [\n nil,\n '!!!'.red,\n '!!! RUBY ERROR!'.red,\n \"#{'!!!'.red} #{error.message}\", '!!!'.red,\n error.backtrace.map{|m| \"#{'!!!'.red} #{m}\" },\n '!!!'.red\n ].flatten\n end", "def test_bad_argument\n assert_equal 1, go_with_args(%w(--this_is_really_redonculouslywrong))\n assert_match(/Error: bad arguments/, @stderr_io.string )\n end", "def abort_if_errors\n unless $warnings.empty?\n STDERR.puts\n STDERR.puts \"The following warnings were generated:\"\n STDERR.puts\n $warnings.each do |w|\n STDERR.puts \"\\tWarning: #{w}\"\n end\n STDERR.puts\n end\n unless $errors.empty?\n STDERR.puts\n STDERR.puts \"Correct the following errors and try again:\"\n STDERR.puts\n $errors.each do |e|\n STDERR.puts \"\\t#{e}\"\n end\n STDERR.puts\n exit(-1)\n end\nend", "def abort_if_errors\n unless $warnings.empty?\n STDERR.puts\n STDERR.puts \"The following warnings were generated:\"\n STDERR.puts\n $warnings.each do |w|\n STDERR.puts \"\\tWarning: #{w}\"\n end\n STDERR.puts\n end\n unless $errors.empty?\n STDERR.puts\n STDERR.puts \"Correct the following errors and try again:\"\n STDERR.puts\n $errors.each do |e|\n STDERR.puts \"\\t#{e}\"\n end\n STDERR.puts\n exit(-1)\n end\nend", "def test_code_4\n string = \"Line 2: Unknown keyword dog\\n\"\n assert_output(string) { Errorcode.error(4, 2, 'dog') }\n end", "def handle_errors(output)\n if $? != 0\n puts output\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n puts \"~ FATAL: Command failed with status #{$?}\"\n exit 1\n end\nend", "def this_has_error\n puts ''\n end", "def handle_validation_fail(comment = \"Arguments had conflicts\")\n clear\n\n puts Rainbow(\"Validation Fail: #{comment}\\n\\n\").red\nend", "def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend", "def failure(message)\n $stderr.puts \"#{name}: #{message}\"\n exit 1\n end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def fatal_error(message)\n puts message\n exit -1\nend" ]
[ "0.70461905", "0.70320886", "0.7019609", "0.6917713", "0.69021195", "0.6890441", "0.6858042", "0.6858042", "0.6858042", "0.6858042", "0.6854831", "0.68482393", "0.68349856", "0.68303424", "0.6797989", "0.6792575", "0.67924803", "0.67924803", "0.6765834", "0.67567736", "0.675664", "0.67464304", "0.67339486", "0.6722741", "0.67225844", "0.6711387", "0.6710888", "0.6701715", "0.67001283", "0.66972125", "0.669482", "0.66824746", "0.6640703", "0.66088265", "0.6606171", "0.65857303", "0.6577819", "0.6562736", "0.6539674", "0.65277654", "0.6516697", "0.6507172", "0.6499846", "0.64944774", "0.6486849", "0.64840585", "0.64816946", "0.64816946", "0.648043", "0.6476041", "0.6474061", "0.6460704", "0.64566755", "0.6454852", "0.6443458", "0.64431614", "0.64394426", "0.6437383", "0.64308155", "0.64270717", "0.64186573", "0.6411996", "0.6411515", "0.64097685", "0.6407371", "0.6398863", "0.63983935", "0.63973063", "0.63943416", "0.6387005", "0.6387005", "0.6387005", "0.6386835", "0.6383871", "0.6383498", "0.6383309", "0.6383309", "0.63778704", "0.6367508", "0.63629556", "0.6361885", "0.6358755", "0.635767", "0.6349399", "0.6343796", "0.6341513", "0.6341513", "0.6340997", "0.63315344", "0.6328739", "0.6328402", "0.63279295", "0.63212895", "0.6319386", "0.6319386", "0.6319386", "0.6319386", "0.6319386", "0.6319386", "0.6319386", "0.63107646" ]
0.0
-1
FUNCTIONS a_anno 0:chr 1:pos 3:oldBase 4:newBase 5:quality 10:gene 11:/+ 12:exon/intron/promotor a_gen 1:gene 2:chr 3:+/ 4:start 5:stop 6:start_coding 7:end_coding 8:ofExons 9:ExonStarts 10:exonEnds
def mutations_effect(a_anno, a_gen) if $locus[a_anno[10]] && a_anno[3].length == a_anno[4].length $cdna.pos = $locus[a_anno[10]] transcript = original() exon_starts = a_gen[9].split(',') exon_ends = a_gen[10].split(',') mutation_position,exon_num = position_on_transcript(a_anno[1],a_gen[3],exon_starts,exon_ends,a_gen[6],a_gen[7]) a_anno[12] = "exon#{exon_num}" start_triplet = (mutation_position/3 * 3) - 1 if start_triplet >= 0 code = transcript[start_triplet..start_triplet+2] pos_in_triplet = mutation_position%3 original_aa = $codes[code] code[pos_in_triplet] = a_anno[4] mutated_aa = $codes[code[0..2]] if original_aa != mutated_aa a_anno[13] = pos_in_triplet + 1 a_anno[14] = original_aa[:name] a_anno[15] = mutated_aa[:name] puts a_anno.join("\t") else a_anno[13] = "same_AA" STDERR.puts a_anno.join("\t") end end else if $locus_non_coding[a_anno[10]] a_anno[13] = "ncrna" STDERR.puts a_anno.join("\t") else if (a_anno[3].length > a_anno[4].length || a_anno[3].length < a_anno[4].length) a_anno[13] = "indel" puts a_anno.join("\t") else a_anno[13] = "?" STDERR.puts a_anno.join("\t") end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def annotate\n genes={}\n File.open(ANNOTATION,'r').each do |line|\n temp=line.split\n genes[temp[9]]={}\n genes[temp[9]][\"start\"]=temp[3].to_i\n genes[temp[9]][\"end\"]=temp[4].to_i\n genes[temp[9]][\"strand\"]=temp[6]\n genes[temp[9]][\"length\"]=temp[4].to_i - 1 - temp[3].to_i\n end\n return genes\nend", "def gene_obj_mapping(line, query_name, columns_info)\n return line.start_with?('http://togogenome.org/gene/') unless\n line.force_encoding('UTF-8')\n line = line.encode(\"UTF-16BE\", \"UTF-8\", :invalid => :replace, :undef => :replace, :replace => '?').encode(\"UTF-8\")\n columns = line.split('^@')\n values = {}\n columns_info.each do |column|\n if column[\"is_identify\"]\n gene_no = columns[column[\"column_number\"]].strip.gsub('http://togogenome.org/gene/','')\n values[\"@id\"] = \"http://togogenome.org/gene/#{gene_no}\"\n values[\"gene_id\"] = to_utf(gene_no)\n else # expect id columns are\n value = columns[column[\"column_number\"]].split(\"|||\").map do |entry|\n # irregular case\n if column[\"column_name\"] == 'uniprot_id'\n to_utf(entry.strip.split('/').last)\n elsif query_name == 'protein_cross_references' && column[\"column_name\"] == 'up_xref_ids'\n to_utf(entry.strip.split('/').last)\n elsif query_name == 'protein_sequence_annotation' && column[\"column_name\"] == 'up_seq_anno_feature_ids'\n to_utf(entry.strip.strip.gsub('http://purl.uniprot.org/annotation/',''))\n else\n to_utf(entry.strip)\n end\n end\n values[column[\"column_name\"]] = value\n end\n end\n values\nend", "def create_parts_and_annotations_mcd(part)\n \n puts\n puts \"== Creating/finding SD part for #{part.biofab_id} ==\"\n\n sd_sequence = part.sequence[$msd1]\n sd_part = Part.find_by_sequence(sd_sequence)\n if !sd_part\n sd_part = Part.new\n sd_part.sequence = sd_sequence\n sd_part.description = \"The Shine-Dalgarno / RBS sequence in a mono-cistronic design.\"\n sd_part.part_type = $sd_type\n sd_part.save!\n puts \"--created sd part\"\n else\n puts \"--found sd part\"\n end\n puts \"---- #{sd_part.sequence}\"\n\n puts\n puts \"== Creating start part for #{part.biofab_id} ==\"\n\n start_sequence = part.sequence[$mstart]\n start_part = Part.find_by_sequence(start_sequence)\n if !start_part\n start_part = Part.new\n start_part.sequence = start_sequence\n start_part.description = \"Start codon.\"\n start_part.part_type = $start_type\n start_part.save!\n puts \"--created start part\"\n else\n puts \"--found start part\"\n end\n \n puts\n puts \"== Annotating #{part.biofab_id} ==\"\n\n annot_type_name = \"Mono-cistronic 5' UTRs\"\n annot_type = AnnotationType.find_by_name(annot_type_name)\n if !annot_type\n annot_type = AnnotationType.new\n annot_type.name = annot_type_name\n annot_type.save!\n puts \"-- created annotation type for mono-cistronic 5' UTRs\"\n else\n puts \"-- found annotation type for mono-cistronic 5' UTRs\"\n end\n \n sd_label = \"Mutated SD\"\n start_label = \"Start\"\n\n create_annotation(part, sd_part, annot_type, $msd1.begin, $msd1.end, sd_label)\n create_annotation(part, start_part, annot_type, $mstart.begin, $mstart.end, start_label)\n\nend", "def annotator; end", "def initialize(seq_name,seq_fasta,seq_qual, seq_comment = '')\n super\n\n @actions = []\n @seq_fasta_orig = seq_fasta\n @seq_fasta = seq_fasta\n \n @seq_qual_orig = seq_qual\n @seq_qual = seq_qual \n \n @insert_start = 0\n @insert_end = seq_fasta.length-1 \n \n @stats={}\n @comments=[]\n \n @file_tags=[]\n \n # for paired ends\n @order_in_tuple=0\n @tuple_id=0\n @tuple_size=0\n @file_tag_tuple_priority=0\n \n end", "def target_def; genomic.definition; end", "def annotations; end", "def annotations; end", "def annotations; end", "def annotations; end", "def annotations; end", "def annotations; end", "def annotations; end", "def annotations; end", "def pubannos(data)\n \n result = JSON.parse(data)\n \n if result.has_key? 'Error'\n raise BioInterchange::Exceptions::InputFormatError, 'Error parsing the JSON input file: #{result[\"Error\"]}'\n end\n \n \n text = result['text']\n #doc_uri = \"http://pubannotation.dbcls.jp/pmdocs/\" + result['pmid'].to_s\n doc_uri = result['docurl']\n \n doc = Document.new(doc_uri)\n docContent = Content.new(0, text.length, Content::DOCUMENT, @process)\n docContent.setContext(doc)\n doc.add(docContent)\n \n #so our document requires content of type document or abstract\n #should it hold the content string?\n\n #hash to remember annotation in case they are needed for building upon based on ids later\n contents = {}\n\n if result['catanns']\n result['catanns'].each do |annot| \n start_offset = 0\n end_offset = 0\n if annot['span']\n start_offset = annot['span']['begin']\n end_offset = annot['span']['end']\n elsif annot['begin'] and annot['end']\n start_offset = annot['begin']\n end_offset = annot['end']\n end\n length = end_offset - start_offset\n\n category = annot['category']\n id = annot['id']\n \n entity = text.slice(start_offset..end_offset)\n \n #phrase = type for NE\n con = Content.new(start_offset, length, Content::PHRASE, @process)\n con.setContext(doc)\n doc.add(con)\n\n contents[id] = con \n \n #set process.date = updated_time?\n end\n end\n \n if result['insanns']\n result['insanns'].each do |annot|\n \n #unsure what to do about this (con1), 'E1' is the ID of something not created yet.\n #it is perhaps a case of making a new content, but with what params...?\n #need to conform what this is refering to with JDK\n con1 = nil \n con2 = contents[annot['object']]\n \n #get annotation type\n type = ContentConnection::UNSPECIFIED\n case annot['type']\n when 'subClassOf'\n type = ContentConnection::SUBCLASS\n end\n connection = ContentConnection.new(con1, con2, type, @process)\n connection.setContext(doc)\n doc.add(connection)\n\n contents[annot['id']] = connection\n\n end\n end\n \n if result['relanns']\n result['relanns'].each do |annot|\n con1 = contents[annot['subject']] \n con2 = contents[annot['object']]\n \n #get annotation type\n type = ContentConnection::UNSPECIFIED\n case annot['type']\n when 'equivalentTo'\n type = ContentConnection::EQUIVALENCE\n when 'themeOf'\n type = ContentConnection::THEME\n end\n connection = ContentConnection.new(con1, con2, type, @process)\n connection.setContext(doc)\n doc.add(connection)\n\n contents[annot['id']] = connection\n\n end\n end\n \n if result['modanns']\n result['modanns'].each do |annot|\n \n #in this case, it is a modification of an already existing content object (speculation/negation). \n con = contents[annot['object']]\n \n #get annotation type\n type = ContentConnection::UNSPECIFIED\n case annot['type']\n when 'Speculation'\n type = ContentConnection::SPECULATION\n when 'Negation'\n type = ContentConnection::NEGATION\n end\n connection = ContentConnection.new(con, nil, type, @process)\n connection.setContext(doc)\n doc.add(connection)\n\n contents[annot['id']] = connection\n\n end\n end\n \n doc\n end", "def process_alignment\n # init vars\n @names = []\n @seqs = []\n \n @alignment = \"-B #{@basename}.aln\"\n\n # import alignment file\n @content = IO.readlines(@infile).map {|line| line.chomp}\n \n #check alignment for gap-only columns\n remove_inserts\n \n #write query-file\n File.open(@infile, \"w\") do |file|\n file.write(\">#{@names[0]}\\n\")\n file.write(\"#{@seqs[0]}\\n\")\n end\n \n #write aln-file\n File.open(@basename + \".aln\", \"w\") do |file|\n @names.each_index do |num|\n file.write(\"Sequence#{num} \")\n file.write(\" \") if (num < 10)\n file.write(\" \") if (num < 100)\n file.write(\"#{@seqs[num]}\\n\")\n end\n end\n end", "def aon; end", "def _print_ace(a,b,species)\n ace=String.new\n a.each{|_a|\n next if b.nil? || _a.nil? ||b.size<1\n ace << \"Gene : \\\"#{_a}\\\"\\n\"\n b.each{|_b|\n ace << \"Ortholog #{_b} \\\"#{species}\\\" Inferred_automatically OrthoMCL\\n\"\n }\n ace << \"\\n\"\n }\n return ace\nend", "def _print_ace(a,b,species)\n ace=String.new\n a.each{|_a|\n next if b.nil? || _a.nil? ||b.size<1\n ace << \"Gene : \\\"#{_a}\\\"\\n\"\n b.each{|_b|\n ace << \"Ortholog #{_b} \\\"#{species}\\\" Inferred_automatically OrthoMCL\\n\"\n }\n ace << \"\\n\"\n }\n return ace\nend", "def annotate_GO(ids,db=\"uniprot\",field=\"dr\") #annotate with GO from uniprot cross refferences\n annotations=[]\n ids.each do |id|\n resp = InteractionNetwork.fetch(\"http://togows.org/entry/#{db}/#{id}/#{field}.json\")\n \n if resp\n res=JSON.parse(resp.body)[0]\n res[\"GO\"].each do |term| #dr format is hashes --> list of lists GO lists have three elements: GO-id,GOterm(class:definition)\n if term[1]=~/P:/ #P=biological processes class\n goid=term[0]\n goterm=term[1].match(/:(.+)/)[1]\n annotations << [goid,goterm]\n end\n end\n return annotations.uniq # some GO terms are repeated in this database\n end\n end \n end", "def handle_agent_notes(notes)\n notes.each do |note|\n prefix = case note['jsonmodel_type']\n when 'note_dimensions'; \"Dimensions\"\n when 'note_physdesc'; \"Physical Description note\"\n when 'note_materialspec'; \"Material Specific Details\"\n when 'note_physloc'; \"Location of resource\"\n when 'note_phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'note_physfacet'; \"Physical Facet\"\n when 'note_processinfo'; \"Processing Information\"\n when 'note_separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n marc_args = case note['jsonmodel_type']\n\n when 'arrangement', 'fileplan'\n ['351','b']\n when 'note_odd', 'note_dimensions', 'note_physdesc', 'note_materialspec', 'note_physloc',\n 'note_phystech', 'note_physfacet', 'note_processinfo', 'note_separatedmaterial'\n ['500','a']\n when 'accessrestrict'\n ['506','a']\n when 'note_scopecontent'\n ['520', '2', ' ', 'a']\n when 'note_abstract'\n #check settings for enabling tag 520 and indicator 3\n if(MarcExportSettings.m_export_settings['tag_520_ind1_3'])\n ['520', '3', ' ', 'a']\n end\n when 'note_prefercite'\n ['524', ' ', ' ', 'a']\n when 'note_acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'note_relatedmaterial'\n ['544','a']\n when 'note_bioghist'\n ['545', '1', ' ','a']\n when 'note_custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n when 'note_appraisal'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'note_accruals'\n ['584', 'a']\n when 'note_altformavail'\n ['535', '2', ' ', 'a']\n when 'note_originalsloc'\n ['535', '1', ' ', 'a']\n when 'note_userestrict', 'note_legalstatus'\n ['540', 'a']\n when 'note_langmaterial'\n ['546', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n if handle_settings(marc_args)\n text = prefix ? \"#{prefix}: \" : \"\"\n #Strip hard returns\n if(MarcExportSettings.m_export_settings['tag_ss_1'])\n text += ASpaceExport::Utils.extract_note_text(note).delete(\"\\n\")\n else\n text += ASpaceExport::Utils.extract_note_text(note)\n end\n #add access restriction\n if(marc_args[0] == '506')\n if( MarcExportSettings.m_export_settings['tag_506_sc_a_ss_1'])\n urls = text.scan(/(?:http|https):\\/\\/[a-z0-9]+(?:[\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(?:(?::[0-9]{1,5})?\\/[^\\s]*)?/ix)\n unless urls.empty?\n text = text.gsub(/(\\. )[\\s\\S]*/, '. This collection has been digitized and is available online.')\n ead_text = if MarcExportSettings.m_export_settings['tag_856_ss_1'].nil? then MarcExportSettings.m_export_settings['tag_856_ss_1'] else \"Finding aid online:\" end\n df('856', '4', '2').with_sfs(\n ['z', ead_text],\n ['u', urls[0].chomp(\".\")]\n )\n end\n end\n end\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n end\n end", "def parse_annotation_file filename\n lines = File.open(filename,'r').read.split(\"\\n\")\n puts lines.size\n bad_header = lines.shift.split(\"\\t\")\n header = %w'seq_id reciprocal_id reciprocal_rank sp_symbol sp_evalue sp_description pfam_ids go_ids'\n data = []\n lines.each do |line|\n fields = line.split(\"\\t\")\n fields = fields.collect {|f| (f == \"#N/A\") ? nil : f}\n d = Hash[header.zip(fields)]\n d['pfam_ids'] = (d['pfam_ids']) ? d['pfam_ids'].split(\";\") : []\n\n d['go_ids'] = (d['go_ids']) ? d['go_ids'].split(\";\") : []\n data << d\n end\n data\nend", "def create_onfidoers(filename)\n\tlines = get_lines_from(filename)\n\t#iterate over each line and create new Onfidoer with the params \n\tlines.map do | line | \n\t\tparams = get_params_from(line)\n\t\tonfidoer = Onfidoer.new(*params) # * is a splat operator\n\t\t\"#{onfidoer.first_name} #{onfidoer.last_name}\"\n\tend\nend", "def create_features_ensembl_seq_obj(bioseq,targets)\r\n targets.each do |key,value|\r\n f1 = Bio::Feature.new(\"target_CTTCTT\",\"#{key[0]}..#{key[1]}\")\r\n #im no sure if it is a interior coding exon \r\n f1.append(Bio::Feature::Qualifier.new('interior coding exon', \"#{value[0]}\"))\r\n f1.append(Bio::Feature::Qualifier.new('strand', \"#{value[1]}\"))\r\n bioseq.features << f1\r\n end\r\nend", "def create_onfidoers(filename)\n\tlines = get_lines_from(filename)\n\t# iterate over each line and create a new onfidoer with the params\n\tlines.map do | line |\n params = get_params_from(line)\n onfidoer = Onfidoer.new(*params) # Have you ever seen this? It's called splat operator\n \"#{onfidoer.first_name} #{onfidoer.last_name}\"\n end\nend", "def run_align_assess\n filename = self.generate_fasta_alignment_file_for_all\n string = \"./lib/AlignAssess_wShorterID #{filename} P\"\n seq_array = Array.new\n if system(string)\n seq_id_array = self.sequences.map{|s| s.seq_id}\n new_filename = filename + \"_assess\"\n f = File.new(new_filename, \"r\")\n flag = false\n read_row= 999999999\n cur_row = 0\n while (line = f.gets)\n if cur_row > read_row && flag\n if line == \"\\n\"\n flag =false\n else\n seq_array << line.split(\"\\t\")\n end\n elsif line == \"Pair-wise %ID over shorter sequence:\\n\"\n flag=true\n read_row = cur_row + 2\n end\n cur_row +=1\n end\n range = seq_array.length - 1\n #seq_array.each do |row|\n for row_num in 0..range\n for i in 1..range#(row_num) \n PercentIdentity.first_or_create(:seq1_id=>seq_id_array[row_num],\n :seq2_id=>seq_id_array[i],\n :alignment_name => self.alignment_name,\n :percent_id=>seq_array[row_num][i])\n # print \"[#{row_num}:#{i-1}=>#{row[i]}],\"\n end\n #print \"\\n\"\n end\n end\n end", "def extract_annotations_from(file, pattern); end", "def fasta\n chars = 60\n lines = (length / chars.to_f).ceil\n defline = \">#{accession} #{title}\"\n seqlines = (1..lines).map {|i| to_s[chars * (i - 1), chars]}\n [defline].concat(seqlines).join(\"\\n\")\n end", "def annotate_samples\n # hash to connect metadata\n exp_hash = create_metadata_hash(@exp_metadata, 0) # { expid => [metadata] }\n bs_hash = create_metadata_hash(@bs_metadata, 0) # { biosampleid => [metadata] }\n srs_hash = create_metadata_hash(@bs_metadata, 1) # { sampleid => [metadata] }\n date_hash = received_date_by_experiment # { expid => date_received }\n\n annotated = Parallel.map(open(@samples_fpath).readlines.drop(1), :in_threads => @@nop) do |line|\n data = line.chomp.split(\"\\t\")\n sample_md = bs_hash[data[0]] || srs_hash[data[0]]\n sample_info = if sample_md\n coverage = if sample_md[3] != \"NA\"\n data[7].to_f / sample_md[3].to_f * 1_000_000\n else\n \"NA\"\n end\n [\n sample_md,\n coverage,\n ]\n else\n \"NA\\tNA\\tNA\\tNA\" # secondary sample id, taxon id, taxonomic name, coverage\n end\n [\n data,\n sample_info,\n exp_hash[data[1]],\n date_hash[data[1]],\n ].flatten.join(\"\\t\")\n end\n open(output_fpath(\"quanto.annotated.tsv\"), 'w'){|f| f.puts([annotated_header.join(\"\\t\"), annotated]) }\n end", "def parse_autolink; end", "def annotate(file, revision=nil, opts={})\n changeset = self[revision]\n changeset[file].annotate opts[:follow_copies], opts[:line_numbers]\n end", "def annotate_header header, fname\n genome = genome_from_fname fname\n\n \"#{genome}____#{header}\"\n end", "def getFtsSequences\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n loc = \"c#{ft.locations[0].to_s}\" if ft.locations[0].strand == -1\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n dna = getDna(ft,@gb.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{ftH[\"protein_id\"][0]}|#{gene[0]}|#{product[0]}|#{@org}\",60)\n puts seqout\n end\nend", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def _lex_index_offsets=(_arg0); end", "def vlg_oen_gen(io_name, io_ctrl, str)\n str << TAB;\n str << \"assign #{io_name}_oen =\";\n last_item_no = io_ctrl.size - 1;\n 0.upto(last_item_no) {|i|\n if(i != last_item_no)\n str << \" #{io_ctrl[i][1]} |\";\n else\n str << \" #{io_ctrl[i][1]};\\n\";\n end\n }\nend", "def handle_notes(notes)\n\n notes.each do |note|\n\n prefix = case note['type']\n when 'dimensions'; \"Dimensions\"\n when 'physdesc'; \"Physical Description note\"\n when 'materialspec'; \"Material Specific Details\"\n when 'physloc'; \"Location of resource\"\n when 'phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'physfacet'; \"Physical Facet\"\n when 'processinfo'; \"Processing Information\"\n when 'separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n #20160829LJD: Add additional note types for export.\n marc_args = case note['type']\n\n when 'arrangement', 'fileplan'\n ['351','b']\n when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'processinfo', 'separatedmaterial'\n ['500','a']\n when 'accessrestrict'\n ['506','a']\n # when 'scopecontent'\n # ['520', '2', ' ', 'a']\n when 'abstract'\n ['520', '3', ' ', 'a']\n when 'prefercite'\n ['524', '8', ' ', 'a']\n when 'acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'relatedmaterial'\n ['544','n']\n # when 'bioghist'\n # ['545','a']\n when 'custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n when 'appraisal'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'accruals'\n ['584', 'a']\n when 'altformavail'\n ['535', '2', ' ', 'a']\n when 'originalsloc'\n ['535', '1', ' ', 'a']\n when 'userestrict', 'legalstatus'\n ['540', 'a']\n when 'langmaterial'\n ['546', 'a']\n # when 'otherfindaid'\n # ['555', '0', ' ', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n text = prefix ? \"#{prefix}: \" : \"\"\n text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished, true)\n\n # only create a tag if there is text to show (e.g., marked published or exporting unpublished)\n if text.length > 0\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n\n end\n end", "def to_annoj\n ##this is the list of features that will be grouped for parenting in AnnoJ. Can be extended...\n ## why is there a list? why not all parented features??? - Its an AnnoJ thing, it overlies some valid features\n ## with the same parent, this is a kludge for the most common feature types that will get parented.\n case self.feature\n when 'intron', 'exon', 'CDS', 'five_prime_UTR', 'three_prime_UTR', 'start_codon', 'stop_codon', 'match_part'\n if self.has_parent?\n [Feature.find(self.parents[0].parent_feature).gff_id, self.id, self.strand, self.feature, self.start, self.end - self.start + 1]\n else\n [nil, self.gff_id, self.strand, self.feature, self.start, self.end - self.start + 1]\n end\n else\n [nil, self.gff_id, self.strand, self.feature, self.start, self.end - self.start + 1]\n end\n end", "def output_idmap(refseq_data, up)\n taxid = refseq_data[:taxid]\n gene_label_url = URI.escape(refseq_data[:gene_label])\n up = up.split(\"-\").first if up.index(\"-\") # with \"-\" means isoform's ID. expect to protein's ID\n\n unless $gene_up_list[\"#{refseq_data[:gene_rsrc]}:#{up}\"]\n $output_ttl.puts triple(\"<http://togogenome.org/gene/#{taxid}:#{gene_label_url}>\", \"rdfs:seeAlso\", \"upid:#{up}\")\n $output_ttl.puts triple(\"upid:#{up}\", \"rdf:type\", \"<http://identifiers.org/uniprot>\")\n $output_ttl.puts triple(\"upid:#{up}\", \"rdfs:seeAlso\", \"up:#{up}\")\n $output_ttl.puts triple(\"up:#{up}\", \"dct:publisher\", \"<http://identifirs.org/miriam.resource/MIR:00100134>\") # UniProt (www.uniprot.org)\n $output_ttl.puts triple(\"upid:#{up}\", \"rdfs:seeAlso\", \"tax:#{taxid}\")\n $gene_up_list[\"#{refseq_data[:gene_rsrc]}:#{up}\"] = true # to prevent duplicate output\n $taxid_list[taxid] = true\n end\nend", "def scan_gene_blo_seqs\n GeneBloSeq.destroy_all\n\n genes = Gene.find(:all)\n\n genes.each { |gn|\n\n #assemble gene file location\n gene_blo_runs_f = \"#{AppConfig.gene_blo_runs_dir}/#{gn.name}.fasta\"\n gene_blo_seqs_f = \"#{AppConfig.gene_blo_seqs_dir}/#{gn.name}.fasta\"\n gene_blo_seqs_p = \"#{AppConfig.gene_blo_seqs_dir}/#{gn.name}.phy\"\n\n \n gene_blo_runs_oa = @ud.fastafile_to_original_alignment(gene_blo_runs_f)\n gene_blo_seqs_oa = Bio::Alignment::OriginalAlignment.new\n\n\n\n puts \"gn.seqs_orig_nb:#{gn.seqs_orig_nb} oa_size: #{gene_blo_runs_oa.size}\"\n\n #schould be equal\n #should insert assertion here or make an rspec to detect source\n #puts oa.keys\n\n gene_blo_runs_oa.each_pair { |key, seq|\n puts key, seq\n gbs = GeneBloSeq.new\n #find corresponding gi\n ns = NcbiSeq.find_by_vers_access(key)\n #link to objects gene and gi\n gbs.gene = gn\n gbs.ncbi_seq = ns\n gbs.save\n gene_blo_seqs_oa.add_seq(seq,ns.id)\n\n }\n \n #save fasta file \n @ud.string_to_file(gene_blo_seqs_oa.output(:fasta),gene_blo_seqs_f)\n #save phylip file\n @ud.string_to_file(gene_blo_seqs_oa.output(:phylip),gene_blo_seqs_p)\n\n\n\n\n }\n\n end", "def walk(data)\n @refs = [];\n @start_columns = 0\n @columns = nil;\n data << \"\\n\"\n eof = data.length\n \n# line 30 \"lib/vorax/parser/grammars/alias.rb\"\nclass << self\n\tattr_accessor :_alias_actions\n\tprivate :_alias_actions, :_alias_actions=\nend\nself._alias_actions = [\n\t0, 1, 1, 1, 2, 1, 3, 1, \n\t6, 1, 8, 1, 9, 1, 10, 1, \n\t16, 1, 17, 1, 18, 1, 19, 1, \n\t20, 1, 21, 1, 23, 1, 24, 1, \n\t25, 1, 26, 1, 27, 1, 28, 1, \n\t29, 2, 1, 21, 2, 1, 23, 2, \n\t3, 21, 2, 3, 23, 2, 5, 2, \n\t2, 6, 22, 2, 7, 0, 2, 10, \n\t2, 2, 10, 4, 2, 10, 11, 2, \n\t10, 12, 2, 10, 13, 2, 10, 14, \n\t2, 10, 15, 3, 10, 7, 0, 3, \n\t10, 7, 4\n]\n\nclass << self\n\tattr_accessor :_alias_key_offsets\n\tprivate :_alias_key_offsets, :_alias_key_offsets=\nend\nself._alias_key_offsets = [\n\t0, 9, 10, 11, 12, 13, 15, 17, \n\t19, 21, 26, 40, 41, 55, 56, 62, \n\t76, 77, 78, 79, 87, 88, 89, 90, \n\t92, 100, 101, 102, 103, 104, 105, 107, \n\t108, 109, 110, 111, 113, 114, 115, 116, \n\t117, 119, 121, 123, 125, 130, 144, 145, \n\t158, 159, 160, 161, 162, 163, 165, 173, \n\t174, 182, 183, 184, 185, 186, 187, 189, \n\t190, 191, 192, 193, 195, 197, 199, 201, \n\t203, 205, 211, 228, 229, 230, 231, 232, \n\t234, 236, 238, 243, 250, 251, 252, 253, \n\t254, 256, 258, 260, 262, 267, 268, 269, \n\t270, 271, 273, 275, 277, 279, 283, 285, \n\t287, 289, 291, 293, 295, 297, 299, 301, \n\t303, 305, 307, 309, 311, 313, 315, 317, \n\t319, 321, 322, 330, 332, 334, 336, 338, \n\t340, 342, 344, 346, 348, 350, 351, 352, \n\t353, 354, 356, 358, 360, 362, 364, 369, \n\t370, 371, 372, 373, 375, 377, 379, 384, \n\t397, 398, 403, 410, 411, 412, 413, 414, \n\t416, 418, 424, 430, 443, 444, 449, 456, \n\t457, 458, 459, 460, 462, 464, 470, 471, \n\t472, 473, 474, 476, 490, 491, 492, 493, \n\t494, 496, 497, 498, 499, 500, 502, 503, \n\t504, 505, 506, 508, 522, 523, 524, 525, \n\t526, 528, 541, 550, 558, 564, 581, 588, \n\t594, 609, 625, 631, 646, 653, 653, 662, \n\t668, 673, 687, 702, 718, 723, 724, 725, \n\t726, 727, 728, 730, 735, 737, 742, 744\n]\n\nclass << self\n\tattr_accessor :_alias_trans_keys\n\tprivate :_alias_trans_keys, :_alias_trans_keys=\nend\nself._alias_trans_keys = [\n\t32, 45, 47, 70, 74, 102, 106, 9, \n\t13, 45, 10, 42, 42, 42, 47, 82, \n\t114, 79, 111, 77, 109, 32, 45, 47, \n\t9, 13, 32, 34, 40, 45, 47, 95, \n\t9, 13, 35, 36, 65, 90, 97, 122, \n\t34, 32, 34, 44, 45, 47, 95, 9, \n\t13, 35, 36, 65, 90, 97, 122, 34, \n\t32, 44, 45, 47, 9, 13, 32, 34, \n\t40, 45, 47, 95, 9, 13, 35, 36, \n\t65, 90, 97, 122, 34, 45, 10, 34, \n\t95, 35, 36, 65, 90, 97, 122, 34, \n\t42, 42, 42, 47, 34, 95, 35, 36, \n\t65, 90, 97, 122, 34, 45, 10, 42, \n\t42, 42, 47, 45, 10, 42, 42, 42, \n\t47, 45, 10, 42, 42, 42, 47, 79, \n\t111, 73, 105, 78, 110, 32, 45, 47, \n\t9, 13, 32, 34, 40, 45, 47, 95, \n\t9, 13, 35, 36, 65, 90, 97, 122, \n\t34, 32, 34, 45, 47, 95, 9, 13, \n\t35, 36, 65, 90, 97, 122, 34, 45, \n\t10, 42, 42, 42, 47, 34, 95, 35, \n\t36, 65, 90, 97, 122, 34, 34, 95, \n\t35, 36, 65, 90, 97, 122, 34, 45, \n\t10, 42, 42, 42, 47, 34, 39, 10, \n\t42, 42, 47, 84, 116, 82, 114, 65, \n\t97, 67, 99, 84, 116, 32, 40, 45, \n\t47, 9, 13, 32, 45, 47, 68, 72, \n\t77, 83, 84, 89, 100, 104, 109, 115, \n\t116, 121, 9, 13, 45, 10, 42, 42, \n\t42, 47, 65, 97, 89, 121, 32, 45, \n\t47, 9, 13, 32, 45, 47, 70, 102, \n\t9, 13, 45, 10, 42, 42, 42, 47, \n\t82, 114, 79, 111, 77, 109, 32, 45, \n\t47, 9, 13, 45, 10, 42, 42, 42, \n\t47, 79, 111, 85, 117, 82, 114, 73, \n\t79, 105, 111, 78, 110, 85, 117, 84, \n\t116, 69, 101, 78, 110, 84, 116, 72, \n\t104, 69, 101, 67, 99, 79, 111, 78, \n\t110, 68, 100, 73, 105, 77, 109, 69, \n\t101, 90, 122, 79, 111, 78, 110, 69, \n\t101, 95, 65, 72, 77, 82, 97, 104, \n\t109, 114, 66, 98, 66, 98, 73, 105, \n\t69, 101, 71, 103, 73, 105, 79, 111, \n\t78, 110, 69, 101, 65, 97, 45, 10, \n\t42, 42, 42, 47, 76, 108, 69, 101, \n\t67, 99, 84, 116, 32, 45, 47, 9, \n\t13, 45, 10, 42, 42, 42, 47, 84, \n\t116, 72, 104, 32, 45, 47, 9, 13, \n\t32, 34, 45, 47, 95, 9, 13, 35, \n\t36, 65, 90, 97, 122, 34, 32, 45, \n\t47, 9, 13, 32, 45, 47, 65, 97, \n\t9, 13, 45, 10, 42, 42, 42, 47, \n\t83, 115, 32, 40, 45, 47, 9, 13, \n\t32, 44, 45, 47, 9, 13, 32, 34, \n\t45, 47, 95, 9, 13, 35, 36, 65, \n\t90, 97, 122, 34, 32, 45, 47, 9, \n\t13, 32, 45, 47, 65, 97, 9, 13, \n\t45, 10, 42, 42, 42, 47, 83, 115, \n\t32, 40, 45, 47, 9, 13, 45, 10, \n\t42, 42, 42, 47, 32, 45, 47, 95, \n\t9, 13, 35, 36, 48, 57, 65, 90, \n\t97, 122, 45, 10, 42, 42, 42, 47, \n\t45, 10, 42, 42, 42, 47, 45, 10, \n\t42, 42, 42, 47, 32, 45, 47, 95, \n\t9, 13, 35, 36, 48, 57, 65, 90, \n\t97, 122, 45, 10, 42, 42, 42, 47, \n\t32, 34, 39, 45, 47, 69, 83, 87, \n\t101, 115, 119, 9, 13, 32, 45, 47, \n\t70, 74, 102, 106, 9, 13, 32, 44, \n\t45, 46, 47, 64, 9, 13, 32, 44, \n\t45, 47, 9, 13, 32, 44, 45, 46, \n\t47, 64, 95, 9, 13, 35, 36, 48, \n\t57, 65, 90, 97, 122, 32, 44, 45, \n\t47, 64, 9, 13, 32, 44, 45, 47, \n\t9, 13, 32, 44, 45, 47, 95, 9, \n\t13, 35, 36, 48, 57, 65, 90, 97, \n\t122, 32, 44, 45, 47, 64, 95, 9, \n\t13, 35, 36, 48, 57, 65, 90, 97, \n\t122, 32, 44, 45, 47, 9, 13, 32, \n\t44, 45, 47, 95, 9, 13, 35, 36, \n\t48, 57, 65, 90, 97, 122, 32, 45, \n\t46, 47, 64, 9, 13, 95, 35, 36, \n\t48, 57, 65, 90, 97, 122, 32, 45, \n\t47, 64, 9, 13, 32, 45, 47, 9, \n\t13, 32, 45, 47, 95, 9, 13, 35, \n\t36, 48, 57, 65, 90, 97, 122, 32, \n\t45, 47, 64, 95, 9, 13, 35, 36, \n\t48, 57, 65, 90, 97, 122, 32, 45, \n\t46, 47, 64, 95, 9, 13, 35, 36, \n\t48, 57, 65, 90, 97, 122, 32, 45, \n\t47, 9, 13, 34, 39, 39, 45, 42, \n\t88, 120, 32, 45, 47, 9, 13, 69, \n\t101, 32, 45, 47, 9, 13, 73, 105, \n\t32, 44, 45, 47, 9, 13, 0\n]\n\nclass << self\n\tattr_accessor :_alias_single_lengths\n\tprivate :_alias_single_lengths, :_alias_single_lengths=\nend\nself._alias_single_lengths = [\n\t7, 1, 1, 1, 1, 2, 2, 2, \n\t2, 3, 6, 1, 6, 1, 4, 6, \n\t1, 1, 1, 2, 1, 1, 1, 2, \n\t2, 1, 1, 1, 1, 1, 2, 1, \n\t1, 1, 1, 2, 1, 1, 1, 1, \n\t2, 2, 2, 2, 3, 6, 1, 5, \n\t1, 1, 1, 1, 1, 2, 2, 1, \n\t2, 1, 1, 1, 1, 1, 2, 1, \n\t1, 1, 1, 2, 2, 2, 2, 2, \n\t2, 4, 15, 1, 1, 1, 1, 2, \n\t2, 2, 3, 5, 1, 1, 1, 1, \n\t2, 2, 2, 2, 3, 1, 1, 1, \n\t1, 2, 2, 2, 2, 4, 2, 2, \n\t2, 2, 2, 2, 2, 2, 2, 2, \n\t2, 2, 2, 2, 2, 2, 2, 2, \n\t2, 1, 8, 2, 2, 2, 2, 2, \n\t2, 2, 2, 2, 2, 1, 1, 1, \n\t1, 2, 2, 2, 2, 2, 3, 1, \n\t1, 1, 1, 2, 2, 2, 3, 5, \n\t1, 3, 5, 1, 1, 1, 1, 2, \n\t2, 4, 4, 5, 1, 3, 5, 1, \n\t1, 1, 1, 2, 2, 4, 1, 1, \n\t1, 1, 2, 4, 1, 1, 1, 1, \n\t2, 1, 1, 1, 1, 2, 1, 1, \n\t1, 1, 2, 4, 1, 1, 1, 1, \n\t2, 11, 7, 6, 4, 7, 5, 4, \n\t5, 6, 4, 5, 5, 0, 1, 4, \n\t3, 4, 5, 6, 3, 1, 1, 1, \n\t1, 1, 2, 3, 2, 3, 2, 4\n]\n\nclass << self\n\tattr_accessor :_alias_range_lengths\n\tprivate :_alias_range_lengths, :_alias_range_lengths=\nend\nself._alias_range_lengths = [\n\t1, 0, 0, 0, 0, 0, 0, 0, \n\t0, 1, 4, 0, 4, 0, 1, 4, \n\t0, 0, 0, 3, 0, 0, 0, 0, \n\t3, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 1, 4, 0, 4, \n\t0, 0, 0, 0, 0, 0, 3, 0, \n\t3, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 1, 1, 0, 0, 0, 0, 0, \n\t0, 0, 1, 1, 0, 0, 0, 0, \n\t0, 0, 0, 0, 1, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 1, 0, \n\t0, 0, 0, 0, 0, 0, 1, 4, \n\t0, 1, 1, 0, 0, 0, 0, 0, \n\t0, 1, 1, 4, 0, 1, 1, 0, \n\t0, 0, 0, 0, 0, 1, 0, 0, \n\t0, 0, 0, 5, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 5, 0, 0, 0, 0, \n\t0, 1, 1, 1, 1, 5, 1, 1, \n\t5, 5, 1, 5, 1, 0, 4, 1, \n\t1, 5, 5, 5, 1, 0, 0, 0, \n\t0, 0, 0, 1, 0, 1, 0, 1\n]\n\nclass << self\n\tattr_accessor :_alias_index_offsets\n\tprivate :_alias_index_offsets, :_alias_index_offsets=\nend\nself._alias_index_offsets = [\n\t0, 9, 11, 13, 15, 17, 20, 23, \n\t26, 29, 34, 45, 47, 58, 60, 66, \n\t77, 79, 81, 83, 89, 91, 93, 95, \n\t98, 104, 106, 108, 110, 112, 114, 117, \n\t119, 121, 123, 125, 128, 130, 132, 134, \n\t136, 139, 142, 145, 148, 153, 164, 166, \n\t176, 178, 180, 182, 184, 186, 189, 195, \n\t197, 203, 205, 207, 209, 211, 213, 216, \n\t218, 220, 222, 224, 227, 230, 233, 236, \n\t239, 242, 248, 265, 267, 269, 271, 273, \n\t276, 279, 282, 287, 294, 296, 298, 300, \n\t302, 305, 308, 311, 314, 319, 321, 323, \n\t325, 327, 330, 333, 336, 339, 344, 347, \n\t350, 353, 356, 359, 362, 365, 368, 371, \n\t374, 377, 380, 383, 386, 389, 392, 395, \n\t398, 401, 403, 412, 415, 418, 421, 424, \n\t427, 430, 433, 436, 439, 442, 444, 446, \n\t448, 450, 453, 456, 459, 462, 465, 470, \n\t472, 474, 476, 478, 481, 484, 487, 492, \n\t502, 504, 509, 516, 518, 520, 522, 524, \n\t527, 530, 536, 542, 552, 554, 559, 566, \n\t568, 570, 572, 574, 577, 580, 586, 588, \n\t590, 592, 594, 597, 607, 609, 611, 613, \n\t615, 618, 620, 622, 624, 626, 629, 631, \n\t633, 635, 637, 640, 650, 652, 654, 656, \n\t658, 661, 674, 683, 691, 697, 710, 717, \n\t723, 734, 746, 752, 763, 770, 771, 777, \n\t783, 788, 798, 809, 821, 826, 828, 830, \n\t832, 834, 836, 839, 844, 847, 852, 855\n]\n\nclass << self\n\tattr_accessor :_alias_trans_targs\n\tprivate :_alias_trans_targs, :_alias_trans_targs=\nend\nself._alias_trans_targs = [\n\t0, 1, 3, 6, 41, 6, 41, 0, \n\t201, 2, 201, 0, 2, 4, 201, 5, \n\t4, 5, 0, 4, 7, 7, 201, 8, \n\t8, 201, 9, 9, 201, 10, 36, 38, \n\t10, 201, 10, 11, 210, 36, 38, 205, \n\t10, 205, 205, 205, 201, 203, 11, 12, \n\t13, 15, 17, 21, 211, 12, 211, 211, \n\t211, 201, 204, 13, 14, 15, 31, 33, \n\t14, 201, 15, 16, 210, 26, 28, 205, \n\t15, 205, 205, 205, 201, 203, 16, 18, \n\t201, 12, 18, 20, 209, 209, 209, 209, \n\t201, 206, 20, 22, 201, 23, 22, 23, \n\t12, 22, 25, 208, 208, 208, 208, 201, \n\t207, 25, 27, 201, 15, 27, 29, 201, \n\t30, 29, 30, 15, 29, 32, 201, 14, \n\t32, 34, 201, 35, 34, 35, 14, 34, \n\t37, 201, 10, 37, 39, 201, 40, 39, \n\t40, 10, 39, 42, 42, 201, 43, 43, \n\t201, 44, 44, 201, 45, 58, 60, 45, \n\t201, 45, 46, 220, 58, 60, 219, 45, \n\t219, 219, 219, 201, 212, 46, 47, 48, \n\t49, 51, 214, 47, 214, 214, 214, 201, \n\t213, 48, 50, 201, 47, 50, 52, 201, \n\t53, 52, 53, 47, 52, 55, 218, 218, \n\t218, 218, 201, 215, 55, 57, 217, 217, \n\t217, 217, 201, 216, 57, 59, 201, 45, \n\t59, 61, 201, 62, 61, 62, 45, 61, \n\t201, 63, 223, 64, 202, 65, 67, 66, \n\t67, 202, 66, 69, 69, 201, 70, 70, \n\t201, 71, 71, 201, 72, 72, 201, 73, \n\t73, 201, 73, 74, 133, 135, 73, 201, \n\t74, 75, 77, 80, 98, 101, 109, 114, \n\t131, 80, 98, 101, 109, 114, 131, 74, \n\t201, 76, 201, 74, 76, 78, 201, 79, \n\t78, 79, 74, 78, 81, 81, 201, 82, \n\t82, 201, 83, 84, 86, 83, 201, 83, \n\t84, 86, 89, 89, 83, 201, 85, 201, \n\t83, 85, 87, 201, 88, 87, 88, 83, \n\t87, 90, 90, 201, 91, 91, 201, 92, \n\t92, 201, 227, 93, 95, 227, 201, 94, \n\t201, 227, 94, 96, 201, 97, 96, 97, \n\t227, 96, 99, 99, 201, 100, 100, 201, \n\t82, 82, 201, 102, 106, 102, 106, 201, \n\t103, 103, 201, 104, 104, 201, 105, 105, \n\t201, 82, 82, 201, 107, 107, 201, 108, \n\t108, 201, 82, 82, 201, 110, 110, 201, \n\t111, 111, 201, 112, 112, 201, 113, 113, \n\t201, 82, 82, 201, 115, 115, 201, 116, \n\t116, 201, 117, 117, 201, 118, 118, 201, \n\t119, 119, 201, 120, 120, 201, 121, 121, \n\t201, 122, 201, 123, 98, 125, 126, 123, \n\t98, 125, 126, 201, 124, 124, 201, 100, \n\t100, 201, 102, 102, 201, 127, 127, 201, \n\t128, 128, 201, 129, 129, 201, 130, 130, \n\t201, 82, 82, 201, 132, 132, 201, 100, \n\t100, 201, 134, 201, 73, 134, 136, 201, \n\t137, 136, 137, 73, 136, 139, 139, 201, \n\t140, 140, 201, 141, 141, 201, 142, 142, \n\t201, 229, 143, 145, 229, 201, 144, 201, \n\t229, 144, 146, 201, 147, 146, 147, 229, \n\t146, 149, 149, 201, 150, 150, 201, 151, \n\t196, 198, 151, 201, 151, 152, 196, 198, \n\t195, 151, 195, 195, 195, 201, 153, 152, \n\t154, 155, 157, 154, 201, 154, 155, 157, \n\t160, 160, 154, 201, 156, 201, 154, 156, \n\t158, 201, 159, 158, 159, 154, 158, 161, \n\t161, 201, 161, 231, 190, 192, 161, 201, \n\t162, 163, 185, 187, 162, 201, 163, 164, \n\t180, 182, 179, 163, 179, 179, 179, 201, \n\t165, 164, 166, 167, 169, 166, 201, 166, \n\t167, 169, 172, 172, 166, 201, 168, 201, \n\t166, 168, 170, 201, 171, 170, 171, 166, \n\t170, 173, 173, 201, 173, 231, 174, 176, \n\t173, 201, 175, 201, 173, 175, 177, 201, \n\t178, 177, 178, 173, 177, 166, 167, 169, \n\t179, 166, 179, 179, 179, 179, 201, 181, \n\t201, 163, 181, 183, 201, 184, 183, 184, \n\t163, 183, 186, 201, 162, 186, 188, 201, \n\t189, 188, 189, 162, 188, 191, 201, 161, \n\t191, 193, 201, 194, 193, 194, 161, 193, \n\t154, 155, 157, 195, 154, 195, 195, 195, \n\t195, 201, 197, 201, 151, 197, 199, 201, \n\t200, 199, 200, 151, 199, 202, 221, 222, \n\t224, 225, 226, 228, 230, 226, 228, 230, \n\t202, 201, 0, 1, 3, 6, 41, 6, \n\t41, 0, 201, 12, 15, 17, 19, 21, \n\t24, 12, 201, 14, 15, 31, 33, 14, \n\t201, 12, 15, 17, 19, 21, 24, 205, \n\t12, 205, 205, 205, 205, 201, 12, 15, \n\t17, 21, 24, 12, 201, 12, 15, 17, \n\t21, 12, 201, 12, 15, 17, 21, 208, \n\t12, 208, 208, 208, 208, 201, 12, 15, \n\t17, 21, 24, 209, 12, 209, 209, 209, \n\t209, 201, 12, 15, 17, 21, 12, 201, \n\t14, 15, 31, 33, 211, 14, 211, 211, \n\t211, 211, 201, 47, 49, 54, 51, 56, \n\t47, 201, 201, 214, 214, 214, 214, 214, \n\t201, 47, 49, 51, 56, 47, 201, 47, \n\t49, 51, 47, 201, 47, 49, 51, 217, \n\t47, 217, 217, 217, 217, 201, 47, 49, \n\t51, 56, 218, 47, 218, 218, 218, 218, \n\t201, 47, 49, 54, 51, 56, 219, 47, \n\t219, 219, 219, 219, 201, 47, 49, 51, \n\t47, 201, 201, 63, 223, 64, 64, 201, \n\t65, 201, 66, 201, 68, 68, 201, 227, \n\t93, 95, 227, 201, 138, 138, 201, 229, \n\t143, 145, 229, 201, 148, 148, 201, 162, \n\t163, 185, 187, 162, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 201, 201, 201, 201, \n\t201, 201, 201, 201, 0\n]\n\nclass << self\n\tattr_accessor :_alias_trans_actions\n\tprivate :_alias_trans_actions, :_alias_trans_actions=\nend\nself._alias_trans_actions = [\n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t39, 0, 39, 0, 0, 0, 39, 0, \n\t0, 0, 0, 0, 0, 0, 39, 0, \n\t0, 39, 0, 0, 39, 0, 0, 0, \n\t0, 39, 0, 59, 87, 0, 0, 83, \n\t0, 83, 83, 83, 39, 13, 0, 0, \n\t3, 0, 0, 0, 62, 0, 62, 62, \n\t62, 31, 13, 0, 0, 0, 0, 0, \n\t0, 31, 0, 59, 87, 0, 0, 83, \n\t0, 83, 83, 83, 31, 13, 0, 0, \n\t31, 0, 0, 0, 13, 13, 13, 13, \n\t31, 13, 0, 0, 31, 0, 0, 0, \n\t0, 0, 0, 13, 13, 13, 13, 31, \n\t13, 0, 0, 31, 0, 0, 0, 31, \n\t0, 0, 0, 0, 0, 0, 31, 0, \n\t0, 0, 31, 0, 0, 0, 0, 0, \n\t0, 39, 0, 0, 0, 39, 0, 0, \n\t0, 0, 0, 0, 0, 39, 0, 0, \n\t39, 0, 0, 39, 0, 0, 0, 0, \n\t39, 0, 59, 87, 0, 0, 83, 0, \n\t83, 83, 83, 39, 13, 0, 0, 3, \n\t0, 0, 3, 0, 3, 3, 3, 35, \n\t0, 0, 0, 35, 0, 0, 0, 35, \n\t0, 0, 0, 0, 0, 0, 13, 13, \n\t13, 13, 35, 13, 0, 0, 13, 13, \n\t13, 13, 35, 13, 0, 0, 39, 0, \n\t0, 0, 39, 0, 0, 0, 0, 0, \n\t15, 0, 68, 0, 71, 0, 0, 0, \n\t0, 71, 0, 0, 0, 37, 0, 0, \n\t37, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 0, 0, 0, 0, 0, 37, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t37, 0, 37, 0, 0, 0, 37, 0, \n\t0, 0, 0, 0, 0, 0, 37, 0, \n\t0, 37, 0, 0, 0, 0, 37, 0, \n\t0, 0, 0, 0, 0, 37, 0, 37, \n\t0, 0, 0, 37, 0, 0, 0, 0, \n\t0, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 77, 0, 0, 77, 37, 0, \n\t39, 77, 0, 0, 39, 0, 0, 0, \n\t77, 0, 0, 0, 37, 0, 0, 37, \n\t0, 0, 37, 0, 0, 0, 0, 37, \n\t0, 0, 37, 0, 0, 37, 0, 0, \n\t37, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 0, 0, 37, 0, 0, 37, \n\t0, 0, 37, 0, 0, 37, 0, 0, \n\t37, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 0, 0, 37, 0, 0, 37, \n\t0, 0, 37, 0, 0, 37, 0, 0, \n\t37, 0, 37, 0, 0, 0, 0, 0, \n\t0, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 0, 0, 37, 0, 0, 37, \n\t0, 0, 37, 0, 0, 37, 0, 0, \n\t37, 0, 0, 37, 0, 0, 37, 0, \n\t0, 37, 0, 37, 0, 0, 0, 37, \n\t0, 0, 0, 0, 0, 0, 0, 37, \n\t0, 0, 37, 0, 0, 37, 0, 0, \n\t37, 74, 0, 0, 74, 37, 0, 39, \n\t74, 0, 0, 39, 0, 0, 0, 74, \n\t0, 0, 0, 37, 0, 0, 37, 0, \n\t0, 0, 0, 37, 0, 53, 0, 0, \n\t53, 0, 53, 53, 53, 37, 0, 0, \n\t5, 5, 5, 5, 37, 0, 0, 0, \n\t0, 0, 0, 37, 0, 37, 0, 0, \n\t0, 37, 0, 0, 0, 0, 0, 0, \n\t0, 37, 0, 65, 0, 0, 0, 37, \n\t0, 0, 0, 0, 0, 33, 0, 53, \n\t0, 0, 53, 0, 53, 53, 53, 33, \n\t0, 0, 5, 5, 5, 5, 33, 0, \n\t0, 0, 0, 0, 0, 33, 0, 33, \n\t0, 0, 0, 33, 0, 0, 0, 0, \n\t0, 0, 0, 33, 0, 65, 0, 0, \n\t0, 33, 0, 33, 0, 0, 0, 33, \n\t0, 0, 0, 0, 0, 5, 5, 5, \n\t0, 5, 0, 0, 0, 0, 33, 0, \n\t33, 0, 0, 0, 33, 0, 0, 0, \n\t0, 0, 0, 33, 0, 0, 0, 33, \n\t0, 0, 0, 0, 0, 0, 37, 0, \n\t0, 0, 37, 0, 0, 0, 0, 0, \n\t5, 5, 5, 0, 5, 0, 0, 0, \n\t0, 37, 0, 37, 0, 0, 0, 37, \n\t0, 0, 0, 0, 0, 80, 13, 80, \n\t13, 13, 80, 80, 13, 80, 80, 13, \n\t80, 17, 0, 0, 0, 0, 0, 0, \n\t0, 0, 39, 1, 1, 1, 0, 1, \n\t0, 1, 41, 5, 5, 5, 5, 5, \n\t47, 1, 1, 1, 0, 1, 0, 13, \n\t1, 13, 13, 13, 13, 41, 1, 1, \n\t1, 1, 0, 1, 41, 1, 1, 1, \n\t1, 1, 41, 1, 1, 1, 1, 13, \n\t1, 13, 13, 13, 13, 41, 1, 1, \n\t1, 1, 0, 13, 1, 13, 13, 13, \n\t13, 41, 0, 0, 0, 0, 0, 25, \n\t5, 5, 5, 5, 13, 5, 13, 13, \n\t13, 13, 47, 1, 1, 0, 1, 0, \n\t1, 44, 50, 0, 0, 0, 0, 0, \n\t50, 1, 1, 1, 0, 1, 44, 1, \n\t1, 1, 1, 44, 1, 1, 1, 13, \n\t1, 13, 13, 13, 13, 44, 1, 1, \n\t1, 0, 13, 1, 13, 13, 13, 13, \n\t44, 1, 1, 0, 1, 0, 13, 1, \n\t13, 13, 13, 13, 44, 0, 0, 0, \n\t0, 27, 15, 0, 68, 0, 0, 19, \n\t0, 29, 0, 29, 0, 0, 29, 77, \n\t0, 0, 77, 23, 0, 0, 29, 74, \n\t0, 0, 74, 21, 0, 0, 29, 7, \n\t7, 7, 7, 7, 56, 39, 39, 39, \n\t39, 39, 39, 39, 39, 39, 39, 39, \n\t39, 31, 31, 31, 31, 31, 31, 31, \n\t31, 31, 31, 31, 31, 31, 31, 31, \n\t31, 31, 31, 31, 31, 31, 31, 31, \n\t31, 39, 39, 39, 39, 39, 39, 39, \n\t39, 39, 39, 39, 35, 35, 35, 35, \n\t35, 35, 35, 35, 35, 35, 35, 39, \n\t39, 39, 39, 39, 37, 39, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 39, 39, 39, 39, 39, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 39, 39, 39, 39, \n\t39, 37, 37, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 37, 33, \n\t33, 33, 33, 33, 33, 33, 33, 33, \n\t33, 33, 33, 33, 33, 33, 33, 33, \n\t33, 33, 33, 33, 33, 33, 33, 33, \n\t33, 33, 33, 37, 37, 37, 37, 37, \n\t37, 37, 37, 37, 37, 37, 39, 41, \n\t47, 41, 41, 41, 41, 41, 25, 47, \n\t44, 50, 50, 44, 44, 44, 44, 44, \n\t27, 29, 29, 19, 29, 29, 29, 23, \n\t29, 21, 29, 56, 0\n]\n\nclass << self\n\tattr_accessor :_alias_to_state_actions\n\tprivate :_alias_to_state_actions, :_alias_to_state_actions=\nend\nself._alias_to_state_actions = [\n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 9, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0\n]\n\nclass << self\n\tattr_accessor :_alias_from_state_actions\n\tprivate :_alias_from_state_actions, :_alias_from_state_actions=\nend\nself._alias_from_state_actions = [\n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 11, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0, \n\t0, 0, 0, 0, 0, 0, 0, 0\n]\n\nclass << self\n\tattr_accessor :_alias_eof_trans\n\tprivate :_alias_eof_trans, :_alias_eof_trans=\nend\nself._alias_eof_trans = [\n\t1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, \n\t1063, 1063, 1063, 1063, 897, 897, 897, 897, \n\t897, 897, 897, 897, 897, 897, 897, 897, \n\t897, 897, 897, 897, 897, 897, 897, 897, \n\t897, 897, 897, 897, 1063, 1063, 1063, 1063, \n\t1063, 1063, 1063, 1063, 1063, 1063, 1063, 919, \n\t919, 919, 919, 919, 919, 919, 919, 919, \n\t919, 919, 1063, 1063, 1063, 1063, 1063, 1062, \n\t1063, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1063, 1063, 1063, \n\t1063, 1063, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1063, \n\t1063, 1063, 1063, 1063, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 1062, 1051, 1051, 1051, 1051, 1051, 1051, \n\t1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, \n\t1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, \n\t1051, 1051, 1051, 1051, 1051, 1051, 1062, 1062, \n\t1062, 1062, 1062, 1062, 1062, 1062, 1062, 1062, \n\t1062, 0, 1063, 1070, 1072, 1070, 1070, 1070, \n\t1070, 1070, 1071, 1072, 1080, 1075, 1075, 1080, \n\t1080, 1080, 1080, 1080, 1081, 1091, 1091, 1084, \n\t1091, 1091, 1091, 1088, 1091, 1090, 1091, 1092\n]\n\nclass << self\n\tattr_accessor :alias_start\nend\nself.alias_start = 201;\nclass << self\n\tattr_accessor :alias_first_final\nend\nself.alias_first_final = 201;\nclass << self\n\tattr_accessor :alias_error\nend\nself.alias_error = -1;\n\nclass << self\n\tattr_accessor :alias_en_main\nend\nself.alias_en_main = 201;\n\n\n# line 108 \"lib/vorax/parser/grammars/alias.rl\"\n \n# line 712 \"lib/vorax/parser/grammars/alias.rb\"\nbegin\n\tp ||= 0\n\tpe ||= data.length\n\tcs = alias_start\n\tts = nil\n\tte = nil\n\tact = 0\nend\n\n# line 109 \"lib/vorax/parser/grammars/alias.rl\"\n \n# line 724 \"lib/vorax/parser/grammars/alias.rb\"\nbegin\n\t_klen, _trans, _keys, _acts, _nacts = nil\n\t_goto_level = 0\n\t_resume = 10\n\t_eof_trans = 15\n\t_again = 20\n\t_test_eof = 30\n\t_out = 40\n\twhile true\n\t_trigger_goto = false\n\tif _goto_level <= 0\n\tif p == pe\n\t\t_goto_level = _test_eof\n\t\tnext\n\tend\n\tend\n\tif _goto_level <= _resume\n\t_acts = _alias_from_state_actions[cs]\n\t_nacts = _alias_actions[_acts]\n\t_acts += 1\n\twhile _nacts > 0\n\t\t_nacts -= 1\n\t\t_acts += 1\n\t\tcase _alias_actions[_acts - 1]\n\t\t\twhen 9 then\n# line 1 \"NONE\"\n\t\tbegin\nts = p\n\t\tend\n# line 754 \"lib/vorax/parser/grammars/alias.rb\"\n\t\tend # from state action switch\n\tend\n\tif _trigger_goto\n\t\tnext\n\tend\n\t_keys = _alias_key_offsets[cs]\n\t_trans = _alias_index_offsets[cs]\n\t_klen = _alias_single_lengths[cs]\n\t_break_match = false\n\t\n\tbegin\n\t if _klen > 0\n\t _lower = _keys\n\t _upper = _keys + _klen - 1\n\n\t loop do\n\t break if _upper < _lower\n\t _mid = _lower + ( (_upper - _lower) >> 1 )\n\n\t if data[p].ord < _alias_trans_keys[_mid]\n\t _upper = _mid - 1\n\t elsif data[p].ord > _alias_trans_keys[_mid]\n\t _lower = _mid + 1\n\t else\n\t _trans += (_mid - _keys)\n\t _break_match = true\n\t break\n\t end\n\t end # loop\n\t break if _break_match\n\t _keys += _klen\n\t _trans += _klen\n\t end\n\t _klen = _alias_range_lengths[cs]\n\t if _klen > 0\n\t _lower = _keys\n\t _upper = _keys + (_klen << 1) - 2\n\t loop do\n\t break if _upper < _lower\n\t _mid = _lower + (((_upper-_lower) >> 1) & ~1)\n\t if data[p].ord < _alias_trans_keys[_mid]\n\t _upper = _mid - 2\n\t elsif data[p].ord > _alias_trans_keys[_mid+1]\n\t _lower = _mid + 2\n\t else\n\t _trans += ((_mid - _keys) >> 1)\n\t _break_match = true\n\t break\n\t end\n\t end # loop\n\t break if _break_match\n\t _trans += _klen\n\t end\n\tend while false\n\tend\n\tif _goto_level <= _eof_trans\n\tcs = _alias_trans_targs[_trans]\n\tif _alias_trans_actions[_trans] != 0\n\t\t_acts = _alias_trans_actions[_trans]\n\t\t_nacts = _alias_actions[_acts]\n\t\t_acts += 1\n\t\twhile _nacts > 0\n\t\t\t_nacts -= 1\n\t\t\t_acts += 1\n\t\t\tcase _alias_actions[_acts - 1]\nwhen 0 then\n# line 5 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @t_start = p\n\t\tend\nwhen 1 then\n# line 9 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @table_ref = data[(@t_start..p-1)]\n\t\tend\nwhen 2 then\n# line 13 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @a_start = p\n @alias_value = nil\n\t\tend\nwhen 3 then\n# line 18 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n text = data[(@a_start..p-1)]\n @alias_value = text unless @not_alias.include?(text.upcase)\n\t\tend\nwhen 4 then\n# line 23 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @subquery_text = Parser.walk_balanced_paren(data[(p..-1)]).gsub(/^\\(|\\)$/, '')\n p += 1\n @subquery_range = (p..p+@subquery_text.length-1)\n p += @subquery_text.length\n te = p\n\t\tend\nwhen 5 then\n# line 31 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @alias_value = nil\n @subquery_range = nil\n @subquery_text = nil\n\t\tend\nwhen 6 then\n# line 37 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n @refs << ExprRef.new(@subquery_text, @subquery_range, @alias_value)\n @alias_value = nil\n @subquery_range = nil\n @subquery_text = nil\n\t\tend\nwhen 7 then\n# line 44 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n\n add_tableref\n\t\tend\nwhen 10 then\n# line 1 \"NONE\"\n\t\tbegin\nte = p+1\n\t\tend\nwhen 11 then\n# line 73 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nact = 1;\t\tend\nwhen 12 then\n# line 75 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nact = 3;\t\tend\nwhen 13 then\n# line 76 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nact = 4;\t\tend\nwhen 14 then\n# line 77 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nact = 5;\t\tend\nwhen 15 then\n# line 81 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nact = 9;\t\tend\nwhen 16 then\n# line 74 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p+1\n\t\tend\nwhen 17 then\n# line 81 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p+1\n\t\tend\nwhen 18 then\n# line 73 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1;\t\tend\nwhen 19 then\n# line 76 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1; begin @start_columns = te end\n\t\tend\nwhen 20 then\n# line 77 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1;\t\tend\nwhen 21 then\n# line 78 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1; begin @columns = data[(@start_columns..ts)] unless @columns end\n\t\tend\nwhen 22 then\n# line 79 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1;\t\tend\nwhen 23 then\n# line 80 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1;\t\tend\nwhen 24 then\n# line 81 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\nte = p\np = p - 1;\t\tend\nwhen 25 then\n# line 78 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n begin p = ((te))-1; end\n begin @columns = data[(@start_columns..ts)] unless @columns end\n\t\tend\nwhen 26 then\n# line 79 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n begin p = ((te))-1; end\n\t\tend\nwhen 27 then\n# line 80 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n begin p = ((te))-1; end\n\t\tend\nwhen 28 then\n# line 81 \"lib/vorax/parser/grammars/alias.rl\"\n\t\tbegin\n begin p = ((te))-1; end\n\t\tend\nwhen 29 then\n# line 1 \"NONE\"\n\t\tbegin\n\tcase act\n\twhen 4 then\n\tbegin begin p = ((te))-1; end\n @start_columns = te end\n\twhen 9 then\n\tbegin begin p = ((te))-1; end\nend\n\telse\n\tbegin begin p = ((te))-1; end\nend\nend \n\t\t\tend\n# line 987 \"lib/vorax/parser/grammars/alias.rb\"\n\t\t\tend # action switch\n\t\tend\n\tend\n\tif _trigger_goto\n\t\tnext\n\tend\n\tend\n\tif _goto_level <= _again\n\t_acts = _alias_to_state_actions[cs]\n\t_nacts = _alias_actions[_acts]\n\t_acts += 1\n\twhile _nacts > 0\n\t\t_nacts -= 1\n\t\t_acts += 1\n\t\tcase _alias_actions[_acts - 1]\nwhen 8 then\n# line 1 \"NONE\"\n\t\tbegin\nts = nil;\t\tend\n# line 1007 \"lib/vorax/parser/grammars/alias.rb\"\n\t\tend # to state action switch\n\tend\n\tif _trigger_goto\n\t\tnext\n\tend\n\tp += 1\n\tif p != pe\n\t\t_goto_level = _resume\n\t\tnext\n\tend\n\tend\n\tif _goto_level <= _test_eof\n\tif p == eof\n\tif _alias_eof_trans[cs] > 0\n\t\t_trans = _alias_eof_trans[cs] - 1;\n\t\t_goto_level = _eof_trans\n\t\tnext;\n\tend\nend\n\tend\n\tif _goto_level <= _out\n\t\tbreak\n\tend\n\tend\n\tend\n\n# line 110 \"lib/vorax/parser/grammars/alias.rl\"\n data.chop!\n\n # needed to finalize the last pending tableref\n add_tableref\n end", "def process_omims\n omim2ensp=get_ensmart_hash\n ensp2omim=omim2ensp.invert\n infile=File.new('ranjana','r')\n reg = Oniguruma::ORegexp.new('(WBGene\\d+).*OMIM:\\s((\\d+\\s)+)')\n infile.each_line{|line|\n match_data=reg.match(line)\n #puts line,match_data.inspect\n next if match_data.nil?\n wbgene=match_data[1].to_s\n ensembl_proteins=match_data[2].chop.split(\" \").map{|o|\n $stderr.puts \"cannot find EnsEMBL id for WormBase #{wbgene} -> OMIM #{o}\" if omim2ensp[o].nil?\n omim2ensp[o]\n }\n yield [wbgene,ensembl_proteins,ensp2omim]\n }\nend", "def refseq_sequence\n \"NC_0000\" + chrom.sub(/X/, \"23\").sub(/Y/, \"24\")\n end", "def annotate_sources\n item_names.each do |source_name|\n with_valid_source source_name do |source_card|\n tag_with_report_type source_card\n tag_with_company source_card\n tag_with_year source_card\n end\n end\nend", "def genes()\n puts 'vcf_life gene'\n return nil if @data[:info].blank?\n return nil if @data[:info][:ann].blank?\n #return nil if @data[:info][:hgvs].blank?\n VcfTools.get_genes_from_ann( @data[:info][:ann] )\n end", "def candidates2fa(input_file, fasta, read_length, output_file, exoncov=8)\n\t\tchromosomes = {}\n\t\tpositions = []\n\t\t\n\t\t# Input into hash sorted by chromosomes\n\t\tFile.open(input_file, 'r').readlines.each do |line|\n\t\t\tline = line.strip.split(\"\\t\")[0..-2]\n\t\t\tchr_a, pos_a, strand_a, chr_b, pos_b, strand_b = line[0..5]\n\t\t\tpos = [chr_a, pos_a, chr_b, pos_b].join(':')\n\t\n\t\t\tchromosomes[chr_a] = {} if !chromosomes.has_key?(chr_a)\n\t\t\t\n\t\t\tif !chromosomes.has_key?(chr_b)\n\t\t\t\tchromosomes[chr_a][chr_b] = [line]\n\t\t\n\t\t\t# 2nd elsif to exclude reads that map on same junction but opposite ends\t\t\n\t\t\telsif chromosomes[chr_a].has_key?(chr_b) && !positions.include?(pos)\n\t\t\t\tchromosomes[chr_a][chr_b].push(line)\n\t\t\t\tpositions << pos\n\t\t\tend\n\t\tend\n\n\t\t# Output\n\t\toutput = File.open(output_file, 'w') do |output|\n\t\t\tchromosomes.each do |chr_a, values|\n\t\t\t\tfasta_file = File.open(\"#{fasta}#{chr_a}.fa\", 'r')\n\t\t\t\theader = fasta_file.gets.strip\n\t\t\t\tdna_a = fasta_file.read.gsub(/\\n/, '')\n\t\t\t\t\n\t\t\t\tvalues.each do |chr_b, values|\n\t\t\t\t fasta_file = File.open(\"#{fasta}#{chr_b}.fa\", 'r')\n\t\t\t\t\theader = fasta_file.gets.strip\n\t\t\t\t\tdna_b = fasta_file.read.gsub(/\\n/, '')\n\n\t\t\t\t\tvalues.each do |v|\n\t\t\t\t\t\tbp_a, bp_b = v[1].to_i, v[4].to_i\n\t\t\t\t\t\tstrand_a, strand_b = v[2], v[5]\n\t\t\t\t\t\toverlap = v[-1].to_i - read_length\n\t\t\t\t\t\tl = read_length - exoncov \n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tupstream = dna_a[bp_a..bp_a + overlap + l].upcase\t\n\t\t\t\t\t\tdownstream = dna_b[bp_b - l - overlap + 1..bp_b - overlap].upcase\n\t\t\t\t\t\n\t\t\t\t\t\tif strand_a == '1' && strand_b == '-1'\n\t\t\t\t\t\t\tdownstream = Alignment.reverse_complement(dna_b[bp_b..bp_b + l].upcase)\n\t\t\t\t\t\telsif strand_a == '-1' && strand_b == '1'\n\t\t\t\t\t\t\tupstream = Alignment.reverse_complement(dna_a[bp_a - l + 1..bp_a].upcase)\n\t\t\t\t\t\tend\n\t\t\n\t\t\t\t\t\tid = [v[0..1], v[3..4]].join(':')\n\t\t\t\t\t\toutput.puts [\">#{id}\", downstream + upstream].join(\"\\n\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t$logfile.puts \"#{Time.new.strftime(\"%c\")}: Wrote loci to fasta-file.\"\n\tend", "def adj_read_bases\n # mapping quality after '^' symbol is substituted\n # to avoid splitting at non indel + or - characters\n # read ends marking by '$' symbol is substituted\n # insertion and deletion marking by '*' symbol is substituted\n self.read_bases.gsub!(/\\^./, '')\n self.read_bases.delete! '$'\n self.read_bases.delete! '*'\n # warn about reads with ambiguous codes\n # if self.read_bases.match(/[^atgcATGC,\\.\\+\\-0-9]/)\n # warn \"Ambiguous nucleotide\\t#{self.read_bases}\"\n # end\n end", "def initialize\n @original_line = \"\"\n @id = -1\n @pos = []\n @grade = \"\"\n @classifier = false\n @headword_trad = \"\"\n @headword_simp = \"\"\n @headword_en = \"\"\n @pinyin = \"\"\n @pinyin_diacritic = \"\"\n @meanings = []\n @is_erhua_variant = false\n @is_archaic_variant = false\n @variant_of = false\n @priority_word = false\n \n # There can be more than one of these\n @references = []\n end", "def read_genotypes (filename, people)\n file = File.open(filename)\n\n header = file.readline.strip.split(/\\s+/)\n header.shift # omit the first field, \"Marker\"\n\n file.readlines.each do |line|\n marker = line[0..8].gsub(/\\s/, \"\")\n line = line[9..-1]\n header.each_with_index do |person, i|\n start = i*7\n people[person].gen[marker] = parse_genotype line[start..(start+6)]\n end\n end\nend", "def initialize(start_pos,end_pos)\n # puts \" #{start_pos} #{end_pos} #{self.class.to_s}\" \n \n @start_pos = start_pos.to_i\n @end_pos = end_pos.to_i \n \n #@notes = '' \n @left_action = false\n @right_action = false\n @message = ''\n @found_definition=[] #array when contaminant or vectors definitions are saved, each separately\n @cut = false \n @informative = false\n @reversed = false\n # puts \" #{@start_pos} #{@end_pos} #{self.class.to_s}\" \n @tag_id =''\n \n end", "def initialize (params={})\n @name=params.fetch(:name, \"Unknown\")\n @atcode=params.fetch(:atcode, \"Unknown\")\n regexp_atcode = Regexp.new(/A[tT][1-5][gG](\\d{5})/) # This checks if Arabidopsis gene name has the correct\n # nomenclature. If the regular expression doesn't match the input name, it won't become that gene name.\n if regexp_atcode.match(@atcode).to_s != @atcode\n puts \"WARNING: input string doesn't match Arabidopsis thaliana gene pattern.\"\n @atcode=\"Unknown\"\n end\n @seedcode=params.fetch(:seedcode, \"Unknown\")\n end", "def getFt \n kword = ARGV[1]\n seq = @gb.to_biosequence\n seqoptions = \"\"\n\n for c in 2..ARGV.length-1\n seqoptions += \"#{ARGV[c]},\"\n end\n \n # look through all features\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n gene = []\n product = []\n if (!ftH[\"gene\"].nil? && ftH[\"gene\"][0].downcase.include?(kword.downcase)) or\n (!ftH[\"product\"].nil? && ftH[\"product\"][0].downcase.include?(kword.downcase)) \n sbeg = loc[0].from.to_i\n send = loc[0].to.to_i\n fasta = Bio::Sequence::NA.new(seq.subseq(sbeg,send))\n position = \"#{sbeg}..#{send}\"\n if loc[0].strand == -1\n fasta.reverse_complement!\n position = \"c#{position}\"\n end\n pep = Bio::Sequence.new(fasta.translate)\n gene = ftH[\"gene\"][0] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"][0] if !ftH[\"product\"].nil?\n if seqoptions.downcase.include?(\"pep\") or seqoptions.downcase.include?(\"prot\")\n puts pep.output_fasta(\"#{@accession}|#{position}|#{ftH[\"protein_id\"][0]}|#{gene}|#{product}|#{@org}\", 60)\n else\n dna = Bio::Sequence.auto(fasta)\n puts dna.output_fasta(\"#{@accession}|#{position}|#{ftH[\"protein_id\"][0]}|#{gene}|#{product}|#{@org}\",60)\n end\n end\n end\nend", "def hit_to; @genomic.to; end", "def handle_notes(notes)\n\n notes.each do |note|\n\n prefix = case note['type']\n when 'dimensions'; \"Dimensions\"\n when 'physdesc'; \"Physical Description note\"\n when 'materialspec'; \"Material Specific Details\"\n when 'physloc'; \"Location of resource\"\n when 'phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'physfacet'; \"Physical Facet\"\n #when 'processinfo'; \"Processing Information\"\n when 'separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n marc_args = case note['type']\n\n when 'arrangement', 'fileplan'\n ['351', 'a']\n # Remove processinfo from 500\n when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'separatedmaterial'\n ['500','a']\n # we would prefer that information from both the note and subnote appear in subfields of a 506 element, like this:\n # <datafield ind1=\"1\" ind2=\" \" tag=\"506\">\n # <subfield code=\"a\">Restricted until 2020</subfield> <!-- from the subnote/text/content field -->\n # <subfield code=\"f\">Available</subfield> <!-- from the category list -->\n # </datafield>\n when 'accessrestrict'\n ind1 = note['publish'] ? '1' : '0'\n if note['publish'] || @include_unpublished\n if note['rights_restriction']\n result = note['rights_restriction']['local_access_restriction_type']\n if result != []\n result.each do |lart|\n df('506', ind1).with_sfs(['a', note['subnotes'][0]['content']], ['f', lart])\n end\n else\n df('506', ind1).with_sfs(['a', note['subnotes'][0]['content']])\n end\n else\n ['506', ind1 ,'', 'a']\n end\n end\n when 'scopecontent'\n ['520', '2', ' ', 'a']\n when 'abstract'\n ['520', '3', ' ', 'a']\n when 'prefercite'\n ['524', ' ', ' ', 'a']\n when 'acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'relatedmaterial'\n ['544','d']\n when 'bioghist'\n ['545','a']\n when 'custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n # Add processinfo to 583\n when 'appraisal', 'processinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'accruals'\n ['584', 'a']\n when 'altformavail'\n ['535', '2', ' ', 'a']\n when 'originalsloc'\n ['535', '1', ' ', 'a']\n when 'userestrict', 'legalstatus'\n ['540', 'a']\n when 'langmaterial'\n ['546', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n text = prefix ? \"#{prefix}: \" : \"\"\n text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished)\n\n # only create a tag if there is text to show (e.g., marked published or exporting unpublished) and if there are not multiple local access restriction types (if there are, that's already handled above)\n unless note['type'] == 'accessrestrict' && note['rights_restriction']\n if text.length > 0\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n end\n\n end\n end", "def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 1818685 (45.36%) aligned concordantly exactly 1 time\n 206999 (5.16%) aligned concordantly >1 times\n ----\n 1983557 pairs aligned concordantly 0 times; of these:\n 409503 (20.64%) aligned discordantly 1 time\n ----\n 1574054 pairs aligned 0 times concordantly or discordantly; of these:\n 3148108 mates make up the pairs; of these:\n 1009275 (32.06%) aligned 0 times\n 35392 (1.12%) aligned exactly 1 time\n 2103441 (66.82%) aligned >1 times\n 3612671 (47.40%) were unpaired; of these:\n 498719 (13.80%) aligned 0 times\n 2246121 (62.17%) aligned exactly 1 time\n 867831 (24.02%) aligned >1 times\n=end\n #puts(liszt);exit\n dict={}; liszt.shift\n dict[\"total\"]=liszt.shift.split[0]; #liszt.shift\n dict[\"paired\"]=liszt.shift.split[0]; liszt.shift #conc 0\n dict[\"conc_once\"]=liszt.shift.split[0]\n dict[\"conc_mult\"]=liszt.shift.split[0]\n liszt.shift(2); dict[\"disc_once\"]=\"\"; dict[\"disc_mult\"]=\"\"\n line=liszt.shift\n line.include?(\">1 times\") ? dict[\"disc_mult\"]=line.split[0] : dict[\"disc_once\"]=line.split[0]\n liszt.shift\n dict[\"unaligned_pairs\"]=liszt.shift.split[0]\n liszt.shift\n dict[\"unmates\"]=liszt.shift.split[0] #unaligned mates\n dict[\"mate_once\"]=liszt.shift.split[0]\n dict[\"mate_mult\"]=liszt.shift.split[0]\n dict[\"unpaired\"]=liszt.shift.split[0]\n dict[\"unpair_unaligned\"]=liszt.shift.split[0]\n dict[\"unpair_once\"]=liszt.shift.split[0]\n dict[\"unpair_mult\"]=liszt.shift.split[0]\n dict\nend", "def process_annotation(params=nil)\n validate_params_solr_population(Sinatra::Helpers::SearchHelper::ALLOWED_INCLUDES_PARAMS)\n params ||= @params\n params_copy = params.dup\n\n text = params_copy.delete(\"text\")\n error 400, 'A text to be annotated must be supplied using the argument text=<text to be annotated>' if text.nil? || text.strip.empty?\n\n acronyms = restricted_ontologies_to_acronyms(params_copy)\n params_copy.delete(\"ontologies\")\n semantic_types = semantic_types_param(params_copy)\n params_copy.delete(\"semantic_types\")\n expand_class_hierarchy = params_copy.delete(\"expand_class_hierarchy\").eql?('true') # default = false\n class_hierarchy_max_level = params_copy.delete(\"class_hierarchy_max_level\").to_i # default = 0\n use_semantic_types_hierarchy = params_copy.delete(\"expand_semantic_types_hierarchy\").eql?('true') # default = false\n longest_only = params_copy.delete(\"longest_only\").eql?('true') # default = false\n expand_with_mappings = params_copy.delete(\"expand_mappings\").eql?('true') # default = false\n exclude_nums = params_copy.delete(\"exclude_numbers\").eql?('true') # default = false\n whole_word_only = params_copy.delete(\"whole_word_only\").eql?('false') ? false : true # default = true\n min_term_size = params_copy.delete(\"minimum_match_length\").to_i # default = 0\n exclude_synonyms = params_copy.delete(\"exclude_synonyms\").eql?('true') # default = false\n recognizer = (Annotator.settings.enable_recognizer_param && params_copy[\"recognizer\"]) || 'mgrep'\n params_copy.delete(\"recognizer\")\n\n annotator = nil\n\n # see if a name of the recognizer has been passed in, use default if not or error\n begin\n recognizer = recognizer.capitalize\n clazz = \"Annotator::Models::Recognizers::#{recognizer}\".split('::').inject(Object) {|o, c| o.const_get c}\n annotator = clazz.new\n rescue\n annotator = Annotator::Models::Recognizers::Mgrep.new\n end\n\n if params_copy[\"stop_words\"]\n annotator.stop_words = params_copy.delete(\"stop_words\")\n end\n\n params_copy.delete(\"display\")\n options = {\n ontologies: acronyms,\n semantic_types: semantic_types,\n use_semantic_types_hierarchy: use_semantic_types_hierarchy,\n filter_integers: exclude_nums,\n expand_class_hierarchy: expand_class_hierarchy,\n expand_hierarchy_levels: class_hierarchy_max_level,\n expand_with_mappings: expand_with_mappings,\n min_term_size: min_term_size,\n whole_word_only: whole_word_only,\n with_synonyms: !exclude_synonyms,\n longest_only: longest_only\n }\n options = params_copy.symbolize_keys().merge(options)\n\n begin\n annotations = annotator.annotate(text, options)\n\n unless includes_param.empty?\n # Move include param to special param so it only applies to classes\n params[\"include_for_class\"] = includes_param\n params.delete(\"display\")\n params.delete(\"include\")\n env[\"rack.request.query_hash\"] = params\n\n orig_classes = annotations.map {|a| [a.annotatedClass, a.hierarchy.map {|h| h.annotatedClass}, a.mappings.map {|m| m.annotatedClass}]}.flatten\n classes_hash = populate_classes_from_search(orig_classes, acronyms)\n annotations = replace_empty_classes(annotations, classes_hash) do |a|\n replace_empty_classes(a.hierarchy, classes_hash)\n replace_empty_classes(a.mappings, classes_hash)\n end\n end\n rescue LinkedData::Models::Ontology::ParsedSubmissionError => e\n error 404, e.message\n rescue Annotator::Models::NcboAnnotator::BadSemanticTypeError => e\n error 404, e.message\n end\n\n reply 200, annotations\n end", "def handle_notes(notes)\n\n notes.each do |note|\n\n prefix = case note['type']\n when 'dimensions'; \"Dimensions\"\n when 'physdesc'; \"Physical Description note\"\n when 'materialspec'; \"Material Specific Details\"\n when 'physloc'; \"Location of resource\"\n when 'phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'physfacet'; \"Physical Facet\"\n when 'processinfo'; \"Processing Information\"\n when 'separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n marc_args = case note['type']\n\n when 'arrangement', 'fileplan'\n ['351', 'b']\n when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'processinfo', 'separatedmaterial'\n ['500','a']\n when 'accessrestrict'\n ['506','a']\n #when 'scopecontent'\n #['520', '2', ' ', 'a']\n when 'abstract'\n ['520', '3', ' ', 'a']\n when 'prefercite'\n ['524', '8', ' ', 'a']\n when 'acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'relatedmaterial'\n ['544','n']\n #when 'bioghist'\n #['545','a']\n when 'custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n when 'appraisal'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'accruals'\n ['584', 'a']\n when 'altformavail'\n ['535', '2', ' ', 'a']\n when 'originalsloc'\n ['535', '1', ' ', 'a']\n when 'userestrict', 'legalstatus'\n ['540', 'a']\n when 'langmaterial'\n ['546', 'a']\n when 'otherfindaid'\n ['555', '0', ' ', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n text = prefix ? \"#{prefix}: \" : \"\"\n text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished, true)\n\n # only create a tag if there is text to show (e.g., marked published or exporting unpublished)\n if text.length > 0\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n\n end\n end", "def hseq; @genomic.seq; end", "def annotate_one_file(file_name, info_block, position, options = T.unsafe(nil)); end", "def emit_instr(base_addr = 0x0600)\n #by convention, stack is 0x0100-0x01FF\n #so we try tolay out our program starting from 0x0200\n #\n #errr.... turns out 6502asm.com starts userspace addrs at 0x0600\n \n #2-pass compilation:\n #first pass, we lay out all the instr except for goto-labels\n addr = base_addr\n \n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n #p \"opcode #{i}\"\n i.addr = addr\n \n #increment by number of instructions used: 1 for opcode + 1-2 for args\n addr = addr + 1 + i.args_len\n when InstrBase::LABEL_HOME\n #p \"label #{i}\"\n i.addr = addr\n i.label_addr = addr\n \n #also, need to update @def_labels structure for lookups later\n @def_labels[i.label_name][1] = addr \n when InstrBase::MACRO\n #p \"macro #{i.to_s}\" \n # set addr of macro to starting addr\n i.addr = addr\n \n # increment addr by length of macro's args\n addr = addr + i.args.length\n \n #actual opcode is captured in @args of macro, get it later\n else\n #p \"else #{i.instr_type}\"\n end\n }\n \n #second pass, we link in all the goto-labels\n @instr.each { |i|\n case i.instr_type\n when InstrBase::OPCODE\n if i.args.respond_to?(:instr_type)\n if i.args.instr_type == InstrBase::LABEL_GOTO\n \n #if we have a relative addr, args_len = 1\n #add signed 1byte disp to instr. counter\n if i.args_len == 1\n disp =@def_labels[i.args.label_addr][1] - (i.addr + 2)\n i.args = disp\n else #replace label goto with mapped addr to it\n i.args = @def_labels[i.args.label_addr][1]\n end\n \n else\n #raise exception here\n raise \"Unknown opcode arg-type \\\"#{i.args}\\\" found\"\n end\n end\n else\n #p \"else #{i.instr_type}\" \n end\n }\n \n \n \n end", "def write_gff_files(gene,fo,f1,f2)\r\n bioseq_seq, chr_id, chr_cord = obtain_data_from_ebi(gene) \r\n target_hash = obtain_target_from_seq(bioseq_seq)\r\n create_features_ensembl_seq_obj(bioseq_seq,target_hash)\r\n chr_target_hash=change_cord(target_hash,chr_cord)\r\n if target_hash.empty?\r\n f1.puts \"#{gene} \\n\"\r\n else\r\n #for chr gff file, #this is for the parent gene chr_id,. --> source, \"gene\", the coordinates in the chr, . --> score, strand, . --> phase, gene_id\r\n f2.puts \"#{chr_id}\\t.\\tgene\\t#{chr_cord[0]}\\t#{chr_cord[1]}\\t.\\t+\\t.\\tID=#{gene}\"\r\n end\r\n #this is for the chromosomas, chr_id, . --> source, featuretype, cordinates of the target, . --> score, strand, . --> phase, exon id and the Parent identifiers, ID=exon00001;Parent=mrna0001\r\n chr_target_hash.each do |key,value|\r\n f2.puts \"#{chr_id}\\t.\\tinterior coding exon\\t#{key[0]}\\t#{key[1]}\\t.\\t#{value[1]}\\t.\\t#{value[0]};Parent=#{gene}\"\r\n end\r\n # each loop for write in the gff file\r\n bioseq_seq.features.each do |feature|\r\n featuretype = feature.feature\r\n next unless featuretype == \"target_CTTCTT\"\r\n position = feature.position\r\n qual = feature.assoc \r\n positionss= position.split(\"..\")\r\n fo.puts\"#{gene}\\t.\\t#{featuretype}\\t#{positionss[0]}\\t#{positionss[1]}\\t.\\t#{qual[\"strand\"]}\\t.\\t#{qual[\"interior coding exon\"]}\"\r\n end\r\nend", "def summary_img\n num_tracks_needed = 1\n\n begin\n p = Bio::Graphics::Page.new(:width => 962, :height => 150, :number_of_intervals => 10)\n\n #separate features into mRNA or gene features\n\n genes = @features.select { |x| x.feature == 'gene' }\n if not genes.empty?\n gene_track = p.add_track(:glyph => :directed,\n :fill_color => :green_white_radial,\n :label => false\n )\n # mrna_track = p.add_track(:glyph => :transcript,\n # :exon_fill_color => :red_white_h,\n # :utr_fill_color => :blue_white_h\n # )\ngenes.each do |gene|\n feat = Bio::Graphics::MiniFeature.new(:start => gene.start,\n :end => gene.end,\n :strand => gene.strand,\n :id => gene.gff_id)\n gene_track.add(feat)\nend\nend\n\nproteins = @features.select { |x| x.feature == 'protein' }\n\nif not proteins.empty?\n protein_track = p.add_track(\n :glyph => :generic,\n :fill_color => :yellow_white_radial,\n :label => false\n )\n proteins.each do |protein|\n feat = Bio::Graphics::MiniFeature.new(:start => protein.start,\n :end => protein.end,\n :id => protein.gff_id\n )\n protein_track.add(feat)\n end\nend\n\n\nmrnas = @features.select { |x| x.feature == 'mRNA' }\n@mrnas = mrnas\nif not mrnas.empty?\n mrna_track = p.add_track(:glyph => :transcript,\n :exon_fill_color => :red_white_h,\n :utr_fill_color => :blue_white_h,\n :label => false,\n :gap_marker => 'angled'\n )\n mrnas.each do |m|\n exons = []\n utrs = []\n m.children.each do |d|\n if d.feature == 'exon'\n exons << d.start\n exons << d.end\n end\n if d.feature == 'five_prime_UTR' or d.feature == 'three_prime_UTR'\n utrs << d.start\n utrs << d.end\n end\n exons.sort!\n utrs.sort!\n end\n @exons = exons\n @utrs = utrs\n\n if exons.empty?\n exons = [m.start, m.end]\n end\n\n if utrs.empty?\n utrs = [m.start, m.end]\n end\n feat = Bio::Graphics::MiniFeature.new(\n :start => m.start,\n :end => m.end,\n :strand => m.strand,\n :exons => exons,\n :utrs => utrs,\n :id => m.gff_id\n )\n mrna_track.add(feat)\n end\nend\n@svg = p.get_markup\nrescue\n @svg = \"\"\nend\n\nend", "def genetic_code_table; 11; end", "def extra_annotations; end", "def add_actions_no_left_rigth_parameters(actions)\n \n if !actions.empty?\n start_pos=0\n end_pos = 0\n cut = false \n\n max_end_pos = 0 \n \n \n \n p_beg = @insert_start\n p_end = @seq_fasta.length-1+@insert_start \n # p_end = @seq_fasta.length-1 \n \n # puts 'actions ' + actions.inspect \n # para cada accion ordenada por start_pos\n actions.sort!{|e,f| e.start_pos<=>f.start_pos}.each do |action| \n # puts ' current ' + action.inspect\n # puts \" UUUUUUUUUU1 \"\n # puts \"vect in pos #{action.start_pos} #{action.end_pos}\" if (action.type=='ActionVectors') \n # puts \" UUUUUUUUUU2 \" \n \n # puts \"ADD ACTION:\",action.to_json\n \n # añadir el inicio del inserto si es necesario \n if action.start_pos !=0 or action.end_pos != 0\n action.start_pos+=@insert_start \n action.end_pos+=@insert_start \n end \n \n # guardar accion \n a = add_action(action)\n \n start_pos= a.start_pos \n end_pos=a.end_pos \n \n \n # si hay que cortar y es accion izquierda\n # if (a.cut && ( left_action(@seq_fasta,start_pos-p_beg,end_pos) || # action is left in insert\n if (a.cut && ( left_action(@seq_fasta,start_pos-p_beg,end_pos-p_beg) || # action is left in insert\n (start_pos==p_beg)) ) # action is right in insert but it's continous to the before action \n \n puts \"in seq w action left act #{start_pos} #{end_pos} pbeg #{p_beg} p_end #{p_end}\" \n \n p_beg=end_pos+1\n cut=true \n a.left_action=true\n # puts \"in seq w action left act #{start_pos} #{end_pos} pbeg #{p_beg} p_end #{p_end}\" \n \n # elsif (a.cut && right_action(@seq_fasta,start_pos-p_beg,end_pos)) # action is rigth in insert \n elsif (a.cut && right_action(@seq_fasta,start_pos-p_beg,end_pos-p_beg)) # action is rigth in insert \n puts \"in seq w action right act #{start_pos} #{end_pos} pbeg #{p_beg} p_end #{p_end}\" \n p_end = start_pos-1 \n a.right_action=true\n cut=true \n # puts \"in seq w action right act #{start_pos} #{end_pos} pbeg #{p_beg} p_end #{p_end}\" \n elsif !a.cut\n puts \"NO cut action\"\n if right_action(@seq_fasta,start_pos-p_beg,end_pos-p_beg)\n a.right_action=true\n end\n \n end \n \n \n \n end\n \n \n if cut then \n \n @seq_fasta = @seq_fasta_orig[p_beg..p_end] \n @seq_qual = @seq_qual_orig[p_beg..p_end] if !@seq_qual_orig.nil?\n \n # puts \"in seq w action1 #{@insert_start} #{@insert_end}\"\n @insert_start = p_beg\n size_cut_right = @insert_end - p_end\n @insert_end -= size_cut_right \n # puts \"in seq w action2 #{@insert_start} #{@insert_end}\" \n \n \n \n end \n end\n end", "def line_range=(_arg0); end", "def genomic_sequence\n genome_id = params[:genome][:id]\n reference_id = params[:reference]\n strand = params[:strand].presence || '+'\n\n ref = Reference.find(:first, :conditions => {:name => reference_id, :genome_id => genome_id})\n\n if ref.present?\n seq = Bio::Sequence::NA.new(\"#{ref.sequence.sequence.to_s}\")\n start = params[:start].presence || 1\n stop = params[:end].presence || seq.length\n @subseq = seq.subseq(start.to_i, stop.to_i)\n @subseq = @subseq.reverse_complement if strand == '-'\n end\n\n id = \"#{ref.name} #{start}..#{stop} #{strand}\"\n render :text => @subseq.to_fasta(id, 60), :content_type => 'text/plain'\n end", "def genomic\n unless defined?(@genomic)\n @genomic = SeqDesc.parse(@d0.find { |x| /^Genomic\\:/ =~ x })\n end\n @genomic\n end", "def buildup_interaction (cols)\n\t\tif cols.length < 31\n\t\t\tnil\n\t\tend\n\n\t\tacc1 = cols[0][/[A-Z0-9]{6}/]\n\t\tebi1 = cols[0][/EBI\\-(\\d){,6}/]\n\t\tacc2 = cols[1][/[A-Z0-9]{6}/]\n\t\tebi2 = cols[1][/EBI\\-(\\d){,6}/]\n\n\t\ttax1 = cols[9][6..cols[9].length]\n\t\ttax2 = cols[10][6..cols[10].length]\n\n\t\tconf_val = cols[14][15..cols[14].length].to_f\n\n\t\tintr1 = {:uniprot => acc1, :ebi => ebi1, :altIds => cols[2], :aliases => cols[4], :taxId => tax1}\n\t\tintr2 = {:uniprot => acc2, :ebi => ebi2, :altIds => cols[3], :aliases => cols[5], :taxId => tax2}\n\t\tlink = {:edgeid => cols[13], :confVal => conf_val, :detect => cols[6], :pubmed => cols[8], :type => cols[11]}\n\t\tinteraction = {:a => intr1, :b => intr2, :edge => link}\n\tend", "def on_process_sequence(seq_name,seq_fasta)\n # subclasses may override this method\n end", "def handle_orr(tokens, outer_span, options); end", "def handle_orr(tokens, outer_span, options); end", "def output_information_methods(snps, outfile, cuttoff_genotype, cuttoff_snp, info = true)\r\n\r\n strains = Strain.all\r\n\r\n outfile.puts \"pos_of_SNP_in_ref\\tref_base\\tSNP_base\\tsynonymous or non-synonymous\\tGene_annotation\\tpossible_pseudogene?\\tamino_acid_original\\tamino_acid_change\\tchange_in_hydrophobicity_of_AA?\\tchange_in_polarisation_of_AA?\\tchange_in_size_of_AA?\\t#{strains.map{|strain| strain.name}.join(\"\\t\") if info}\"\r\n\r\n snps_counter = 0\r\n cds_snps_counter = 0\r\n total_number_of_syn_snps = 0\r\n total_number_of_non_syn_snps = 0\r\n total_number_of_pseudo = 0\r\n\r\n snps.each do |snp|\r\n ActiveRecord::Base.transaction do\r\n snp.alleles.each do |allele|\r\n next if snp.alleles.any?{|allele| allele.base.length > 1} # indel\r\n if allele.id != snp.reference_allele_id\r\n\r\n # get annotation (if there is any) for each SNP\r\n features = Feature.joins(:snps).where(\"snps.id = ?\", snp.id)\r\n \r\n # get snp quality for each snp\r\n snp_qual = Snp.find_by_sql(\"select qual from snps where snps.id = #{snp.id}\")\r\n # ignore snp if the snp qual is less than cuttoff.\r\n next if snp_qual.any?{|snps_quality| snps_quality.qual < cuttoff_snp.to_i}\r\n \r\n\r\n # get all genotype qualities for each snp.\r\n gqs = Genotype.find_by_sql(\"select geno_qual from genotypes inner join alleles on alleles.id = genotypes.allele_id inner join snps on snps.id = alleles.snp_id where snps.id = #{snp.id}\")\r\n # ignore snp if any of its genotype qualities is lower than the cuttoff. \r\n next if gqs.any?{|genotype_quality| genotype_quality.geno_qual < cuttoff_genotype.to_i}\r\n \r\n ref_base = Bio::Sequence.auto(Allele.find(snp.reference_allele_id).base)\r\n snp_base = Bio::Sequence.auto(allele.base)\r\n # count snps now: after you have selected the snps with gqs and snp_qual greater than the threshold.\r\n snps_counter += 1 \r\n # If the feature is empty then just output basic information about the snp.\r\n\r\n if features.empty?\r\n outfile.puts \"#{snp.ref_pos}\\t#{features.map{|feature| feature.strand == 1} ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{features.map{|feature| feature.strand == 1} ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\"\r\n else \r\n features.each do |feature|\r\n if feature.name == \"CDS\"\r\n\r\n cds_snps_counter +=1\r\n\r\n annotation = Annotation.where(\"annotations.qualifier = 'product' and annotations.feature_id = ?\", feature.id).first\r\n #if annotation is nil, or empty\r\n if annotation.nil?\r\n outfile.puts \"#{snp.ref_pos}\\t#{feature.strand == 1 ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{feature.strand == 1 ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\"\r\n else\r\n\r\n feature_sequence = feature.sequence\r\n\r\n feature_sequence_bio = Bio::Sequence::NA.new(feature_sequence)\r\n\r\n #Mutate sequence with SNP\r\n feature_sequence_mutated = feature.sequence\r\n feature_sequence_snp_pos = (snp.ref_pos-1) - (feature.start-1)\r\n feature_sequence_mutated[feature_sequence_snp_pos] = allele.base\r\n feature_sequence_mutated_bio = Bio::Sequence::NA.new(feature_sequence_mutated)\r\n\r\n # Translate the sequences\r\n if feature.strand == -1\r\n mutated_seq_translated = feature_sequence_mutated_bio.reverse_complement.translate\r\n original_seq_translated = feature_sequence_bio.reverse_complement.translate\r\n\r\n else\r\n mutated_seq_translated = feature_sequence_mutated_bio.translate\r\n original_seq_translated = feature_sequence_bio.translate\r\n\r\n end\r\n\r\n # Remove the star at the end of each translated sequence.\r\n mutated_seq_translated_clean = mutated_seq_translated.gsub(/\\*$/,\"\")\r\n original_seq_translated_clean = original_seq_translated.gsub(/\\*$/,\"\")\r\n\r\n # Amino acid properties\r\n hydrophobic = [\"I\", \"L\", \"V\", \"C\", \"A\", \"G\", \"M\", \"F\", \"Y\", \"W\", \"H\", \"T\"]\r\n non_hydrophobic = [\"K\", \"E\", \"Q\", \"D\", \"N\", \"S\", \"P\", \"B\"]\r\n\r\n polar = [\"Y\", \"W\", \"H\", \"K\", \"R\", \"E\", \"Q\", \"D\", \"N\", \"S\", \"P\", \"B\"]\r\n non_polar = [\"I\", \"L\", \"V\", \"C\", \"A\", \"G\", \"M\", \"F\", \"T\"]\r\n\r\n small = [\"V\",\"C\",\"A\",\"G\",\"D\",\"N\",\"S\",\"T\",\"P\"]\r\n non_small = [\"I\",\"L\",\"M\",\"F\",\"Y\",\"W\",\"H\",\"K\",\"R\",\"E\",\"Q\"]\r\n\r\n # Get alleles for each strain\r\n bases_from_alleles = []\r\n strains.each do |strain|\r\n \r\n allele_for_strains = Allele.joins(:genotypes => :strain).where(\"strains.id = ? AND alleles.snp_id = ?\", strain.id, snp.id).first\r\n # allele_for_strains = Allele.find_by_sql(\"select * from alleles inner join genotypes on genotypes.allele_id = alleles.id inner join strains on strains.id = genotypes.strain_id where strains.id = #{strain.id} and alleles.snp_id = #{snp.id}\")\r\n puts allele_for_strains.inspect\r\n # next if bases_from_alleles.empty?\r\n bases_from_alleles << allele_for_strains.base\r\n end\r\n\r\n # If no difference between the amino acids then its synonymous SNP, if different then its non-synonymous.\r\n if original_seq_translated_clean == mutated_seq_translated_clean\r\n total_number_of_syn_snps +=1\r\n if mutated_seq_translated_clean =~ /\\*/\r\n total_number_of_pseudo +=1\r\n outfile.puts \"#{snp.ref_pos}\\t#{features.map{|feature| feature.strand == 1} ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{features.map{|feature| feature.strand == 1} ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\\tsynonymous\\t#{annotation.value}\\tYes\\tN/A\\tN/A\\tN/A\\tN/A\\tN/A\\t#{bases_from_alleles.join(\"\\t\") if info}\"\r\n else\r\n outfile.puts \"#{snp.ref_pos}\\t#{features.map{|feature| feature.strand == 1} ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{features.map{|feature| feature.strand == 1} ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\\tsynonymous\\t#{annotation.value}\\tNo\\tN/A\\tN/A\\tN/A\\tN/A\\tN/A\\t#{bases_from_alleles.join(\"\\t\") if info}\"\r\n end\r\n else\r\n total_number_of_non_syn_snps +=1\r\n diffs = Diff::LCS.diff(original_seq_translated_clean, mutated_seq_translated_clean)\r\n\r\n if mutated_seq_translated_clean =~ /\\*/\r\n total_number_of_pseudo +=1\r\n outfile.puts \"#{snp.ref_pos}\\t#{features.map{|feature| feature.strand == 1} ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{features.map{|feature| feature.strand == 1} ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\\tnon-synonymous\\t#{annotation.value}\\tYes\\t#{diffs[0][0].element}\\t#{diffs[0][1].element}\\t#{'Yes' if (hydrophobic.include? diffs[0][0].element) == (non_hydrophobic.include? diffs[0][1].element)}#{'No' if (hydrophobic.include? diffs[0][0].element) != (non_hydrophobic.include? diffs[0][1].element)}\\t#{'Yes' if (polar.include? diffs[0][0].element) == (non_polar.include? diffs[0][1].element)}#{'No' if (polar.include? diffs[0][0].element) != (non_polar.include? diffs[0][1].element)}\\t#{'Yes' if (small.include? diffs[0][0].element) == (non_small.include? diffs[0][1].element)}#{'No' if (small.include? diffs[0][0].element) != (non_small.include? diffs[0][1].element)}\\t#{bases_from_alleles.join(\"\\t\") if info}\"\r\n else\r\n outfile.puts \"#{snp.ref_pos-1}\\t#{features.map{|feature| feature.strand == 1} ? \"#{ref_base.upcase}\" : \"#{ref_base.reverse_complement.upcase}\"}\\t#{features.map{|feature| feature.strand == 1} ? \"#{snp_base.upcase}\" : \"#{snp_base.reverse_complement.upcase}\"}\\tnon-synonymous\\t#{annotation.value}\\tNo\\t#{diffs[0][0].element}\\t#{diffs[0][1].element}\\t#{'Yes' if (hydrophobic.include? diffs[0][0].element) == (non_hydrophobic.include? diffs[0][1].element)}#{'No' if (hydrophobic.include? diffs[0][0].element) != (non_hydrophobic.include? diffs[0][1].element)}\\t#{'Yes' if (polar.include? diffs[0][0].element) == (non_polar.include? diffs[0][1].element)}#{'No' if (polar.include? diffs[0][0].element) != (non_polar.include? diffs[0][1].element)}\\t#{'Yes' if (small.include? diffs[0][0].element) == (non_small.include? diffs[0][1].element)}#{'No' if (small.include? diffs[0][0].element) != (non_small.include? diffs[0][1].element)}\\t#{bases_from_alleles.join(\"\\t\") if info}\"\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end\r\n puts \"Total SNPs added so far: #{snps_counter}\" if snps_counter % 100 == 0 \r\n end\r\n end\r\n end\r\n end\r\n puts \"Total number of snps: #{snps_counter} with Genotype quality cutoff at #{cuttoff_genotype} and SNP quality cutoff at #{cuttoff_snp}\"\r\n puts \"Total number of snps in CDS region: #{cds_snps_counter}\"\r\n puts \"Total number of synonymous SNPs: #{total_number_of_syn_snps}\"\r\n puts \"Total number of non-synonymous SNPs: #{total_number_of_non_syn_snps}\"\r\n puts \"Total number of pseudogenes: #{total_number_of_pseudo}\"\r\n outfile.puts \"Total number of snps: #{snps_counter}\"\r\n outfile.puts \"Total number of snps in CDS region: #{cds_snps_counter}\"\r\n outfile.puts \"Total number of synonymous SNPs: #{total_number_of_syn_snps}\"\r\n outfile.puts \"Total number of non-synonymous SNPs: #{total_number_of_non_syn_snps}\"\r\n outfile.puts \"Total number of possible pseudogenes: #{total_number_of_pseudo}\"\r\nend", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def _lex_index_offsets; end", "def each_gene_seq\n each_gene do | id, reclist, component |\n if component\n sequence = @sequencelist[component.seqname]\n # p sequence\n if sequence\n yield description(id,component,reclist), assemble(sequence,component.start,reclist)\n else \n warn \"No sequence information for\",id\n end\n end\n end\n end", "def aetiology_processor(line)\n\t\tline.strip.scan(/^(Aetiology and immunopathogenesis|Aetiology)$/) do |match|\n\t\t\treturn [\"on\",line.strip]\n\t\tend\n\t\treturn [\"off\",line.strip]\n\tend", "def insert_highlighting(new_code, vars)\n string_indexes = scan_for_index_start_and_end(new_code, regex_find_strings) +\n scan_for_index_start_and_end(new_code, /\\d+\\.\\d+/)\n # scan also for floating point numbers to prevent wrong\n # handling of the \".\"\n string_indexes\n operation_indexes = scan_for_index_start_and_end(new_code, regex_find_operations)\n # Set the array of tracing variables to empty, if there only is\n # the underscore, which by default in erlang is undefined.\n vars = [] if vars.length == 1 && vars[0] == '_'\n\n unless vars.empty?\n # fill array for operation_indexes with indexes of given variables\n vars.each do |var|\n if var != '_'\n operation_indexes += scan_for_index_start_and_end(new_code, Regexp.new(\"\\\\b#{var}\\\\b\"))\n end\n end\n operation_indexes = operation_indexes.sort_by { |hsh| hsh[:starts] }\n end\n\n unless string_indexes.empty? && operation_indexes.empty?\n new_code = insert_prefix(new_code, operation_indexes, string_indexes)\n end\n\n # insert information of line numbers\n new_code = change_prefix_2_line_number(new_code)\n\n # insert debugging functionality\n new_code = change_prefix_2_debug(new_code, vars) unless vars.empty?\n\n # delete all for processing inserted prefixes\n new_code.gsub!(regex_lineprefix, '')\n\n new_code\nend", "def convert_alignment(args={})\n i, o = args[:in], args[:out]\n \n ff = Bio::FlatFile.auto(i).to_a\n aln = Bio::Alignment.new(ff)\n File.open(o, 'w') do |o|\n o.write aln.output :phylip\n end\n \nend", "def _lex_indicies=(_arg0); end", "def _lex_indicies=(_arg0); end", "def _lex_indicies=(_arg0); end", "def _lex_indicies=(_arg0); end", "def completions_at(filename, line, column); end", "def range_from_diagram(str_arr, dir, aoe = false)\n \n if !aoe\n @tbs_spec_range = {} \n @tbs_spec_range[dir] = []\n else\n @tbs_aoe_range = {}\n @tbs_aoe_range[dir] = []\n end\n \n ox,oy = -1,-1\n \n # initial pass finds origin\n str_arr.each_with_index do |arr,i|\n arr.each_with_index do |letter,j|\n if TactBattleManager.orig_char?(letter)\n ox, oy = j, i\n end\n end\n end\n \n raise \"Invaid range in db notes for skill #{@id}.\\n\" if ox == -1 || oy == -1\n \n # second pass offsets coordinates based on origin\n str_arr.each_with_index do |arr,i|\n arr.each_with_index do |letter,j|\n \n if TactBattleManager.hit_char?(letter)\n case aoe\n when false # pos relative to player\n @tbs_spec_range[dir].push(Vertex.new(j-ox,i-oy))\n when true\n @tbs_aoe_range[dir].push(Vertex.new(j-ox,i-oy))\n end\n end # if TactBattleManager.hit_char?(letter)\n \n end # arr.each_with_index\n end # str_arr.each_with_index\n \n if aoe\n load_other_ranges(dir, @tbs_aoe_range)\n else\n load_other_ranges(dir, @tbs_spec_range)\n r = @tbs_spec_range\n @tbs_spec_range[:all] = r[:up] + r[:down] + r[:right] + r[:left]\n end\n end", "def parse_taxon_ids full_document\n full_document.gsub(/%t(\\d+)/) do\n try_linking_taxon_id $1\n end\n end", "def obtain_target_from_seq(bioseq_seq)\r\n #we are going to keep all the targets from each gene,\r\n #hash of hashes :)\r\n targets=Hash.new\r\n len_bioseq = bioseq_seq.length + 1\r\n nstrand_targets = []\r\n pstrand_targets = []\r\n for i in (0..bioseq_seq.length-5)\r\n if bioseq_seq.complement[i..i+5] == \"cttctt\"\r\n nstrand_targets << [i,i+5]\r\n end\r\n if bioseq_seq[i..i+5] == \"cttctt\"\r\n pstrand_targets << [i,i+5]\r\n end\r\n end\r\n #im going to obtein the exon sites\r\n bioseq_seq.features.each do |feature|\r\n position = feature.position\r\n #not remote entries\r\n next unless (feature.feature == 'exon' ) && (not position =~ /[A-Z]/)\r\n exon_id = feature.qualifiers[0].value.gsub('exon_id=', '')\r\n #we can find exons in the the complement or the postive strand, so the way for obtaining the data is different\r\n #i wanna keep the strand forward or reverse\r\n if position =~/complement/\r\n exon_site_negative=position.tr('complement()',\"\")\r\n aux=exon_site_negative =~ /\\./ \r\n #we have to change the start and final point, the ebi documentation shows --> x..y, y is the start point and x is the final point\r\n #location 1 --> l1 \r\n #location 2 --> l2\r\n l1= len_bioseq - exon_site_negative[0,aux].to_i\r\n l2= len_bioseq - exon_site_negative[aux+2,exon_site_negative.length].to_i\r\n exon_site_negative=[l2,l1] # they are the location of the exons\r\n #we are going to check if the target that we did before is in the exon site\r\n is_inside_exon = check_target_in_exon(exon_id,nstrand_targets,'reverse',len_bioseq,exon_site_negative)\r\n #is_inside_exon will be a hash with positions, exon_id and the strand for the gff file\r\n unless is_inside_exon.nil? #if the hash is not nil i could keep it in other hash\r\n targets = targets.merge(is_inside_exon)\r\n end\r\n else\r\n exon_site_positive=position\r\n aux=exon_site_positive =~ /\\./ \r\n l1= exon_site_positive[0,aux].to_i\r\n l2= exon_site_positive[aux+2,exon_site_positive.length].to_i\r\n exon_site_positive=[l1,l2]\r\n is_inside_exon = check_target_in_exon(exon_id,pstrand_targets,'forward',len_bioseq,exon_site_positive)\r\n #is_inside_exon will be a hash with positions, exon_id and the strand for the gff file\r\n unless is_inside_exon.nil? #if the hash is not nil i could keep it in other hash\r\n targets = targets.merge(is_inside_exon)\r\n end\r\n end\r\n end\r\n return targets\r\nend", "def identifier(file)\n\t\tlineNum = 0\n\t\tcommline = 0 \n\t\tcommcol = 0 \n\t\terrComm = false #pen\n\n\t\tfile.each_line do |line|\n\t\t\t# En cada iteracion (salto de linea), el numero de linea aumenta.\n\t\t\t# y el numero de columna vuelve a 1.\n\t\t\tlineNum += 1\n\t\t\tcolNum = 1\n\t\t\t# Cuando lo que queda de la linea es un salto de pagina, pasamos a la\n\t\t\t# proxima linea (arriba)\n\t\t\twhile line != \"\"\n\n\t\t\t\t#Revisa que no esta leyendo dentro de un comentario.\n\t\t\t\tif errComm == true then\t\n\t\t\t\t\tcase line\n\t\t\t\t\t#Si encuentra el fin del comentario no da error. \t\n\t\t\t\t\twhen /(.*?)\\-}/\t\t\n\t\t\t\t\t\terrComm = false\n\t\t\t\t\t\tword = line[/(.*?)\\-}/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\telse \t\n\t\t\t\t\t\t#Sigue buscando en lineas el fin del comentario\n\t\t\t\t\t\tif line =~ /^[\\s]+/\n\t\t\t\t\t\t\tword = line[/^[\\s]+/] \n\t\t\t\t\t\telse\t\n\t\t\t\t\t\t\tword = line[/(.*)/] \n\t\t\t\t\t\tend\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\t\t\t\t\t\tnext \n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# Este case sirve para matchear regexs con los 'when' en lo que quede de linea.\n\t\t\t\t\tcase line\n\n\t\t\t\t\t#Si encuentra {- ignora todo hasta encontrar -}, si no lo encuentra da error. \n\t\t\t\t\twhen /^{\\-/\t\t\n\t\t\t\t\t\terrComm = true\n\t\t\t\t\t\tword = line[/^{\\-/]\n\t\t\t\t\t\tcommcol = colNum\n\t\t\t\t\t\tline = line.partition(word).last\t\n\t\t\t\t\t\tcolNum += word.size\t\t\n\t\t\t\t\t\tcommline = lineNum\n\n\t\t\t\t\t# Este es para las tabulaciones, las cuenta como 4 espacios. \n\t\t\t\t\twhen /^\\t+/\n\t\t\t\t\t\tword = line[/^\\t+/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += 4\n\t\t\t\t\n\t\t\t\t\t# Este es para los espacios en blanco o saltos de linea.\n\t\t\t\t\twhen /^\\s+/\n\t\t\t\t\t\tword = line[/^\\s+/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# AGREGANDO TOKENS LIST.\n\t\t\t\t\t# Va a matchear con read. \n\t\t\t\t\twhen /^read/\n\t\t\t\t\t\tword = line[/^read/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:READ, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con write. \n\t\t\t\t\twhen /^write/\n\t\t\t\t\t\tword = line[/^write/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:WRITE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con true, tipo boolean llamado TRUE. \n\t\t\t\t\twhen /^true/\n\t\t\t\t\t\tword = line[/^true/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TRUE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con false, tipo boolean llamado FALSE. \n\t\t\t\t\twhen /^false/\n\t\t\t\t\t\tword = line[/^false/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:FALSE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todas las palabras, son de tipo IDENTIFIER. \n\t\t\t\t\t# \\w = [a-zA-Z0-9_]\n\t\t\t\t\twhen /^[a-zA-Z]\\w*/\n\t\t\t\t\t\tword = line[/^[a-zA-Z]\\w*/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:IDENTIFIER, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos los numeros, son de tipo NUMBER.\n\t\t\t\t\t# \\d = [0-9]. En caso de exceder el limite es un token no valido. \n\t\t\t\t\twhen /^\\d+/\n\t\t\t\t\t\tword = line[/\\d+/]\n\t\t\t\t\t\tif word.to_i > 2147483647\n\t\t\t\t\t\t\t@errList << Token.new(\"\", word, [lineNum, colNum])\n\t\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t\t@tokensList << Token.new(:NUMBER, word, [lineNum, colNum])\n\t\t\t\t\t\tend\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear los @, son de tipo AT. \n\t\t\t\t\twhen /^[@]/\n\t\t\t\t\t\tword = line[/^[@]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:AT, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos !, son de tipo EXCLAMATION MARK. \n\t\t\t\t\twhen /^[!]/\n\t\t\t\t\t\tword = line[/^[!]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:EXCLAMATION_MARK, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos los .., son de tipo TWO POINTS.\n\t\t\t\t\twhen /^\\.\\./\n\t\t\t\t\t\tword = line[/^\\.\\./]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TWO_POINTS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\t\t\t\t\t\t\n\t\t\t\t\t# Va a matchear todos }, es de tipo LCURLY. \n\t\t\t\t\twhen /^[{]/\n\t\t\t\t\t\tword = line[/^[{]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LCURLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos }, es de tipo RCURLY. \n\t\t\t\t\twhen /^[}]/\n\t\t\t\t\t\tword = line[/^[}]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RCURLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos ), es de tipo RPARENTHESIS. \n\t\t\t\t\twhen /^[)]/\n\t\t\t\t\t\tword = line[/^[)]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RPARENTHESIS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos (, es de tipo LPARENTHESIS. \n\t\t\t\t\twhen /^[(]/\n\t\t\t\t\t\tword = line[/^[(]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LPARENTHESIS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ], es de tipo RBRACKET\n\t\t\t\t\twhen /^(\\])/\n\t\t\t\t\t\tword = line[/(\\])/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RBRACKET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos [, es de tipo LBRACKET. \n\t\t\t\t\twhen /^\\[/\n\t\t\t\t\t\tword = line[/^\\[/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LBRACKET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos |, es de tipo PIPE. \n\t\t\t\t\twhen /^[|]/\n\t\t\t\t\t\tword = line[/^[|]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PIPE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos ;, es de tipo SEMICOLON. \n\t\t\t\t\twhen /^[;]/\n\t\t\t\t\t\tword = line[/^[;]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:SEMICOLON, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ?, es de tipo QUESTIONMARK. \n\t\t\t\t\twhen /^[\\?]/\n\t\t\t\t\t\tword = line[/^[\\?]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:QUESTION_MARK, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos -, es de tipo MINUS. \n\t\t\t\t\twhen /^[-]/\n\t\t\t\t\t\tword = line[/^[-]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:MINUS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos $, es de tipo ROTATION. \n\t\t\t\t\twhen /^\\$/\n\t\t\t\t\t\tword = line[/^\\$/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:ROTATION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ', es de tipo TRANSPOSITION. \n\t\t\t\t\twhen /^'/\n\t\t\t\t\t\tword = line[/^'/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TRANSPOSITION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos ^, es de tipo boolean, llamado NEGATION. \n\t\t\t\t\twhen /^\\^/\n\t\t\t\t\t\tword = line[/^\\^/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:NEGATION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos \\/, es de tipo boolean, llamado OR. \n\t\t\t\t\twhen /^\\\\\\//\n\t\t\t\t\t\tword = line[/^\\\\\\//]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:OR, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos /\\, es de tipo boolean, llamado AND. \n\t\t\t\t\twhen /^\\/\\\\/\n\t\t\t\t\t\tword = line[/^\\/\\\\/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:AND, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\t\n\n\t\t\t\t\t# Va a matchear todos los lienzos menos el vacio, es de tipo CANVAS. \n\t\t\t\t\twhen /^<->/ , /^<\\|>/ , /^<\\_>/ , /^<\\s>/ , /^<\\/>/ , /^<\\\\>/\n\t\t\t\t\t\tword = line[/^<.>/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:CANVAS, word[1], [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear con #(lienzo vacio), es de tipo CANVAS. \n\t\t\t\t\twhen /^#/ \n\t\t\t\t\t\tword = line[/^#/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:CANVAS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear los &, es de tipo ET\n\t\t\t\t\twhen /^&/\n\t\t\t\t\t\tword = line[/^&/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:ET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear los ~, es de tipo TILDE\n\t\t\t\t\twhen /^~/\n\t\t\t\t\t\tword = line[/^~/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TILDE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear LOS <=, es de tipo GREATER OR EQUAL. \n\t\t\t\t\twhen /^>=/\n\t\t\t\t\t\tword = line[/^>=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:GREATER_OR_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear LOS <=, es de tipo LESS OR EQUAL. \n\t\t\t\t\twhen /^<=/\n\t\t\t\t\t\tword = line[/^<=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LESS_OR_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\t\t\t\t\t\n\t\t\t\t\t# Va a matchear LOS >, es de tipo GREATER THAN.\n\t\t\t\t\twhen /^>/\n\t\t\t\t\t\tword = line[/^>/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:GREATER_THAN, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\n\n\t\t\t\t\t# Va a matchear LOS <, es de tipo LESS THAN. \n\t\t\t\t\twhen /^</\n\t\t\t\t\t\tword = line[/^</]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LESS_THAN, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos =, es de tipo NOT EQUAL. \n\t\t\t\t\twhen /^\\/=/\n\t\t\t\t\t\tword = line[/^\\/=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:NOT_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos =, es de tipo EQUALS. \n\t\t\t\t\twhen /^=/\n\t\t\t\t\t\tword = line[/^=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:EQUALS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos :, es de tipo COLON. \n\t\t\t\t\twhen /^:/\n\t\t\t\t\t\tword = line[/^:/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:COLON, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\n\t\t\t\t\t# Va a matchear todos ;, es de tipo PERCENT. \n\t\t\t\t\twhen /^[%]/\n\t\t\t\t\t\tword = line[/^[%]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PERCENT, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos +, es de tipo PLUS. \n\t\t\t\t\twhen /^[+]/\n\t\t\t\t\t\tword = line[/^[+]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PLUS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos +, es de tipo PLUS. \n\t\t\t\t\twhen /^[*]/\n\t\t\t\t\t\tword = line[/^[*]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:MULTIPLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos /, es de tipo DIVISION. \n\t\t\t\t\twhen /^[\\/]/\n\t\t\t\t\t\tword = line[/^[\\/]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:DIVISION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# y esto es para todo lo que no sean palabras validas (letras en este ejemplo).\n\t\t\t\t\telse\n\t\t\t\t\t\tword = line[/^./]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@errList << Token.new(\"\", word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\t\t# Si hubo un comentario sin cerrarse, la funcion devuelve false\n\t\tif errComm == true \n\t\t\tputs \"ERROR: Comment section opened but not closed at line: \" \\\n\t\t\t\t\t\t\"#{commline}, column: #{commcol} \\n\"\n\t\t\treturn false\n\t\telse \n\t\t# Si hubo algun caracter invalido, se devuelve .\n\t\t\tif (@errList.length > 0)\n\t\t\t\t@tokensList.drop(@tokensList.length)\n\t\t\t\tfor err in @errList\n\t\t\t\t\tputs \"ERROR: Unexpected character: '#{err.symbol}' at line: \" \\\n\t\t\t\t\t\t\t\t\"#{err.position[0]}, column: #{err.position[1]} \\n\"\n\t\t\t\tend\n\t\t\t\treturn false\n\t\t\t# Si todos los caracteres son validos, se retorna true.\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\t\n\tend", "def split_refseq\n # prepare output files\n system(%Q[cut -f4 #{$prepare_dir}/refseq_genes_result.tsv | cut -c1-5 | sort | uniq > #{$prepare_dir}/refp_prefix_list.txt ]) # get exist prefix list of protein_id\n FileUtils.mkdir_p(\"#{$prepare_dir}/refp\") unless File.exist?(\"#{$prepare_dir}/refp\")\n refp_output = {}\n File.open(\"#{$prepare_dir}/refp_prefix_list.txt\") do |f|\n f.each_line do |line|\n prefix = line.chomp.strip\n refp_output[prefix] = File.open(\"#{$prepare_dir}/refp/#{prefix}.dat\", \"w\")\n end\n end\n refp_output[\"no_protein_id\"] = File.open(\"#{$prepare_dir}/refp/no_protein_id.dat\", \"w\") # protein_id is optional\n\n File.open(\"#{$prepare_dir}/refseq_genes_result.tsv\") do |f|\n f.each_line do |line|\n columns = line.chomp.strip.split(\"\\t\")\n prefix = (columns[3].nil? || columns[3] == \"\") ? \"no_protein_id\" : columns[3][0..4] # protein_id is optional\n refp_output[prefix].puts line.chomp.strip\n end\n end\n refp_output.each do |k, v|\n v.flush\n v.close\n end\nend", "def phylipstring_to_fastastring(phystr)\n ph=Bio::Phylip::PhylipFormat.new(phystr)\n return ph.alignment.output(:fasta) #output_fasta\n\n end", "def parse_eob_marker; end", "def definitions_at(filename, line, column); end", "def at(*args); end", "def at(*args); end", "def at(*args); end", "def at(*args); end" ]
[ "0.64421415", "0.5789212", "0.56554943", "0.56016725", "0.55067724", "0.5491933", "0.54730046", "0.54730046", "0.54730046", "0.54730046", "0.54730046", "0.54730046", "0.54730046", "0.54730046", "0.53668576", "0.533807", "0.530334", "0.5302836", "0.5302836", "0.5301391", "0.52266234", "0.5214809", "0.5211529", "0.5211461", "0.51956326", "0.5154058", "0.514261", "0.5112991", "0.5074125", "0.5071927", "0.50494474", "0.5047589", "0.5037765", "0.50079143", "0.50079143", "0.50079143", "0.50079143", "0.50062054", "0.4981334", "0.49810523", "0.49784365", "0.4973429", "0.49706936", "0.49582678", "0.49551672", "0.49496478", "0.49465984", "0.49412456", "0.49302232", "0.4929418", "0.4929372", "0.49288684", "0.49259663", "0.49218434", "0.49188727", "0.49076372", "0.49032557", "0.48912188", "0.48797813", "0.48619118", "0.4856995", "0.4848545", "0.48342654", "0.48310193", "0.48276708", "0.48217592", "0.4819832", "0.48173344", "0.48147207", "0.48100287", "0.48078507", "0.4807139", "0.4804689", "0.4804689", "0.4797749", "0.47918034", "0.47918034", "0.47918034", "0.47918034", "0.47897562", "0.47843078", "0.47813654", "0.47743818", "0.4764447", "0.4764447", "0.4764447", "0.4764447", "0.4763928", "0.4762553", "0.47612166", "0.47527787", "0.47513226", "0.47434962", "0.4743148", "0.47351775", "0.47344494", "0.47315368", "0.47315368", "0.47315368", "0.47315368" ]
0.6931948
0
$ rake 2:1 Write a program that reads in two integers typed on the keybaord and outputs their sum, difference, and product Standard input will be like "9 2\n" and will expect you to print "11\n7\n18\n" to standard output.
def sum_difference_product a , b, c = gets.split.map { |num| num.to_i } puts a + b + c puts a - b - c puts a * b * c end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_difference_product\n a , b = gets.split.map { |num| num.to_i }\n puts a + b\n puts a - b\n puts a * b\n end", "def sum_difference_product\n # your code goes here\n a , b = gets.split.map {|x| x.to_i}\n puts a + b\n puts a - b\n puts a * b\nend", "def sum_difference_product\n # your code goes here\n puts \"Enter two numbers seperated by space\"\n arr = gets.split.map(&:to_i)\n puts arr[0] + arr[1]\n puts arr[0] - arr[1]\n puts arr[0] * arr[1]\nend", "def sum_difference_product\nx , y = gets.split.map { |s| s.to_i }\nputs x + y ; puts x - y ; puts x * y\nend", "def sum_difference_product\n # your code goes here\n\tarr = gets.split(\" \") \n\ta = arr[0].to_f\n\tb = arr[1].to_f \n\tprint((a + b),\"\\n\", a - b ,\"\\n\", (a * b),\"\\n\")\nend", "def sum_difference_product #defines the method\na, b = gets.split #uses the split mehtod to split the input into var a and b\n a = a.to_i #converts a to an int\n b = b.to_i #converts b to an int\n puts a + b #puts the sum of a and b\n puts a - b #puts the difference between a and b\n puts a * b #puts the product of a and b\nend", "def sum_difference_product\n\tanswer = \"\"\n \tinput = $stdin.readline\n \tnum = input.split\n \tsum = num[0].to_i + num[1].to_i\n \tdif = num[0].to_i - num[1].to_i\n \tpro = num[0].to_i * num[1].to_i\n\n answer += sum.to_s + \"\\n\" + dif.to_s + \"\\n\" + pro.to_s + \"\\n\"\n $stdout.puts answer\nend", "def sum_difference_product\n input_nums = gets\n a, b = input_nums[/^-?\\d+/].to_i, input_nums[/(?<=\\s)\\d+/].to_i\n \tputs (a+b)\n puts (a-b)\n \tputs (a*b)\nend", "def sum_difference_product\n print \"Type two integers separated by a space:\"\n integers = gets.chomp\n arr = integers.split(\" \").map {|s| s.to_i}\n a = arr[0]\n b = arr[1]\n puts \"#{a+b}\\n#{a-b}\\n#{a*b}\"\n \nend", "def sum_difference_product\n # your code goes here\n two_integers = gets.chomp.split(' ')\n\n puts (two_integers[0].to_i + two_integers[1].to_i)\n puts (two_integers[0].to_i - two_integers[1].to_i)\n puts (two_integers[0].to_i * two_integers[1].to_i)\nend", "def sum_difference_product\n\tnums = gets.chomp.split\n\tnums[0] = nums[0].to_i\n\tnums[1] = nums[1].to_i\n\tputs (nums[0]+nums[1]).to_s\n\tputs (nums[0]-nums[1]).to_s\n\tputs (nums[0]*nums[1]).to_s\nend", "def sum_difference_product\n\tinput = gets.chomp\n\ti = input.split.collect{|x| x.to_i}\n\tputs (i[0] + i[1])\n\tputs (i[0] - i[1])\n\tputs (i[0] * i[1])\nend", "def sum_difference_product\n int = gets.chomp\n int_arr = int.split\n int1 = int_arr[0].to_i\n int2 = int_arr[1].to_i\n int_sum = int1 + int2\n int_dif = int1 - int2\n int_prod = int1 * int2\n print \"#{int_sum}\\n#{int_dif}\\n#{int_prod}\\n\"\nend", "def sum_difference_product(input)\n puts \"give me an integer\"\n input= gets.chomp\narray_of_input = input.split(\"\").map {|numb| numb.to_i }\nsum = array_of_input[0]+ array_of_input[2]\nputs \"#{sum}\"\nputs \"#{array_of_input[0] - array_of_input[2]}\"\nputs array_of_input[0] * array_of_input[2]\n\nend", "def sum_difference_product\n # your code goes here\n\n user_response = gets\n\n puts \"#{user_response}\"\n\na = user_response.split(\" \")[0].to_i\nb = user_response.split(\" \")[1].to_i\n\nputs \"#{a+b}\" + \"\\n\" + \"#{a-b}\" + \"\\n\" + \"#{a*b}\" + \"\\n\"\n\nend", "def sum_difference_product\n puts \"First number: \"\n first_number = gets.chomp.to_i\n puts \"Second number: \"\n second_number = gets.chomp.to_i\n \n puts \"The sum of these two numbers is #{first_number + second_number}.\"\n puts \"The difference between these two numbers is #{(first_number - second_number).abs}.\"\n puts \"The product of these two numbers is #{first_number * second_number}.\"\nend", "def sum_difference_product\n answer = gets.chomp\n array1 = answer.split(\" \")\n sum = array1[0].to_i + array1[1].to_i\n diff = (array1[0].to_i - array1[1].to_i)\n prod = (array1[0].to_i * array1[1].to_i)\n puts sum\n puts diff\n puts prod\nend", "def sum_difference_product\n puts \"Please enter 2 integers:\"\n input = gets.chomp\n nums = input.split(\" \").map(&:to_i)\n sum = nums.inject(:+)\n difference = nums.inject(:-)\n product = nums.inject(:*)\n puts \"#{sum}\\n#{difference}\\n#{product}\\n\"\nend", "def sum_difference_product\n a = gets.chomp.split' '\n a = a.map{|i| i.to_i}\n sum = a.inject(0, :+)\n diff = a[0] - a[1]\n product = a.inject(1, :*)\n\n puts \"#{sum}\\n#{diff}\\n#{product}\"\nend", "def sum_difference_product\n input = gets.chomp \n nums = input.split(' ').map{|x| x.to_i}\n puts nums[0] + nums[1]\n puts nums[0] - nums[1]\n puts nums[0] * nums[1]\n \nend", "def sum_difference_product\n input = gets.split\n numbers = input.map {|num| num.to_i}\n sum = numbers.inject(:+)\n difference = numbers.inject(:-)\n product = numbers.inject(:*)\n\n puts sum\n puts difference\n puts product\n \nend", "def sum_difference_product\n # get input\n input = gets.chomp\n #split into array by space\n array = input.split(\" \").map {|s| s.to_i}\n x = array[0]\n y = array[1]\n #output\n puts (x + y).to_s + \"\\n\" + (x - y).to_s + \"\\n\" + (x * y).to_s + \"\\n\" \nend", "def sum_difference_product\n puts \"Please input a number:\"\n number_string = gets.chomp\n number = number_string.split(' ')\n sum = number[0].to_i + number[1].to_i\n difference = number[0].to_i - number[1].to_i\n product = number[0].to_i * number[1].to_i\n puts sum\n puts difference\n puts product\nend", "def arithmetic_ops\n puts \"Enter first number:\"\n num1 = gets.to_i\n puts \"Enter the second number:\"\n num2 = gets.to_i\n\n puts \"#{num1} + #{num2} = #{num1 + num2}\" \n puts \"#{num1} - #{num2} = #{num1 - num2}\" \n puts \"#{num1} * #{num2} = #{num1 * num2}\" \n puts \"#{num1} / #{num2} = #{num1 / num2}\" \n puts \"#{num1} % #{num2} = #{num1 % num2}\" \n puts \"#{num1} ** #{num2} = #{num1 ** num2}\"\n \nend", "def addition\nprint \"What is your first number? \"\nfirst_num = gets().to_i\n\nprint \"What is the second number? \"\nsecond_num = gets().to_i\n\nresult = first_num + second_num\nputs \"#{first_num} + #{second_num} = #{result}\"\nend", "def addition\n print \"What is your first number? \"\n first_num = gets().to_i\n\n print \"What is your second number? \"\n second_num = gets().to_i\n\n result = first_num + second_num\n puts \"#{first_num} + #{second_num} = #{result}\"\nend", "def add_function \n\tputs \"Enter the numbers\"\n\tn1 = gets.to_i\n\tn2 = gets.to_i\n\tputs \"The sum is #{n1+n2}\"\nend", "def main\n input = STDIN.read.each_line.to_a\n input.shift # Discard first line\n while input.any?\n a, b = input.first.split.map{ |i| i.to_i }\n puts (Fib.get(b) - Fib.get(a))\n input.shift\n end\nend", "def subtraction\n print \"What is your first number? \"\n first_num = gets().to_i\n\n print \"What is your second number? \"\n second_num = gets().to_i\n\n result = first_num - second_num\n puts \"#{first_num} - #{second_num} = #{result}\"\n end", "def add\n #ask for some inputs , after some text\n #turn those inputs into a float, and save it in some variable\n print \"what is your first number? \"\n first_number = gets.to_f\n print \"what is your second number? \"\n second_number = gets.to_f\n # Add the two inputs given togrther and save the result\n result = first_number + second_number\n #print\n puts \"The result is #{result}\"\nend", "def sum_two(num1, num2)\n p \"#{num1} + #{num2} = #{num1 + num2}\"\nend", "def multiplication\n\tputs \"which numbers would you like to multiply\"\n\tmult_number_1 = gets.chomp\n\tmult_number_2 = gets.chomp\n\tputs mult_number_1.to_f * mult_number_2.to_f\nend", "def add\n# ask for some input , after the text\n#turn those input into a float . and saves it in some variable\n print 'what is your first number?'\n first_number = gets.to_f\n print 'what is your second number?'\n second_number = gets.to_f\n\n # add the two inputs given together and save result\n result = first_number + second_number\n\n# pritn these things out\n puts \"The result is #{result}\"\nend", "def multiply\n puts \"enter first number \"\n a = gets.to_f\n puts \"enter second numb4\ner\"\n b = gets.to_f\n result = a * b\n puts result\nend", "def calc_sum_two(first, second)\n\n puts \"the sum of #{first} and #{second} is #{first + second}\"\n\nend", "def add\n print \"What is the first number? \"\n first_number = gets.to_f\n\n print \"What is the second number? \"\n second_number = gets.to_f\n\n result = first_number + second_number\n\n puts \"The results is #{result}.\"\nend", "def subtraction\n\tputs \"which numbers would you like to subtract\"\n\tsub_number_1 = gets.chomp\n\tsub_number_2 = gets.chomp\n\tputs sub_number_1.to_f - sub_number_2.to_f\nend", "def sum_numbers(num_1,num_2)\n puts \"The sum of #{num_1} and #{num_2} is #{num_1 + num_2}\"\nend", "def numbers(a, b)\n p \"#{a} + #{b}\"\n return a + b\nend", "def addition(input_number1, input_number2)\n\tsum = input_number1 + input_number2\n\tputs \"The sum of #{input_number1} and #{input_number2} is #{sum}\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\nend", "def run_interface\n k = gets.split(' ').map(&:to_i)\n puts solution(k)\n end", "def add(num1, num2)\n # print \"put one number: \"\n #num1= gets.chomp\n # print \"put another number: \"\n # num2 = gets.chomp\n num1 + num2\nend", "def multiplication(input_number1, input_number2)\n\tproduct = input_number1 * input_number2\n\tputs \"The product of #{input_number1} and #{input_number2} is #{product}.\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\nend", "def add\n # ask for some inputs, after some text.\n # turn those inputs into a float, and saves it in some variable.\n print \"What is your first number?\"\n first_number = gets.to_f\n\n print \"What is your second number?\"\n second_number = gets.to_f\n\n # add the two inputs given together and save the result.\n result = first_number + second_number\n\n # Print these things out ot the screen\n puts \"The result is #{result}\"\nend", "def add\n# nums()\n puts \"\"\n puts \"What is your first number?\"\n first_num = gets.chomp.to_f\n\n puts \"What is your second number?\"\n second_num = gets.chomp.to_f\n\n result = first_num + second_num\n puts \"#{first_num} + #{second_num} = #{result}\"\nend", "def calculator(a,b)\n puts \"The sub of #{a} and #{b} is #{a + b}\"\n puts \"The difference of #{a} and #{b} is #{a - b}\"\n puts \"The multiplication of #{a} and #{b} is #{a * b}\"\n end", "def two_numbers(one, two)\n p \"This is the sum of #{one} and #{two}\"\nend", "def sum_two_num(a, b)\n puts a + b\nend", "def subtraction(input_number1, input_number2)\n\tdifference = input_number1 - input_number2\n\tputs \"The difference between #{input_number1} and #{input_number2} is #{difference}.\"\n\tputs \"Thank you for using the calculator. Goodbye!\"\nend", "def maths2(firstNum, secondNum)\n total = firstNum + secondNum\n puts \"firstNum is #{firstNum}\"\n puts \"the secondnum is #{secondNum}\"\n puts \"and the total is #{total} \"\n puts firstNum\n puts secondNum\n puts total\n puts \"firstNum is firstNum\"\n puts \"the secondnum is secondNum\"\n puts \"and the total is total\"\nend", "def main\n test_num = gets.chomp.to_i\n test_num.times do |t|\n # input\n s, k = gets.chomp.split(' ')\n k = k.to_i\n\n ans = calc(s, k)\n \n puts \"Case ##{t+1}: #{ans}\"\n end\nend", "def add()\n puts \"{what numbers do yu want to add?\"\n num1 = gets.chomp\n num2 = gets.chomp\n result =@num1 + @num2\n puts \"your answer is {result = @num1 + @num2}\"\n end", "def add\n puts \"\"\n puts \"what is you forst number\"\n first_num = gets.chomp.to_f\n puts \"what is you forst number\"\n second_num = gets.chomp.to_f\n\n puts \"#{first_num} + #{second_num} = #{first_num+second_num}\"\nend", "def mathy\n print \"what is the first number?\"\n first = gets.chomp.to_i\n\n print \"what is the second number\"\n second = gets.chomp.to_i\n\n puts \"\\n #{first} + #{second} = #{first + second}\\n\n #{first} - #{second} = #{first - second} \\n\n #{first} * #{second} = #{first * second} \\n\n #{first} / #{second} = #{first / second}\"\nend", "def add(num_one,num_two)\n puts \"#{num_one} + #{num_two} = #{num_one + num_two}\"\nend", "def sub_two_numbers(num1, num2)\n puts \"OK, let's solve your math problem!\"\n num1 - num2\nend", "def sum(num1, num2)\n puts \"Really? #{num1 + num2} foxes?!\"\nend", "def menu\n puts \"______Calculator_______\"\n puts \"\\t1) Enter first number\"\n puts \"\\t2) Enter modifier\"\n puts \"\\t3) Enter second number\"\n puts \"\\t4) The result is:\"\n return gets.strip.to_i\nend", "def add\n # Ask for some inputs, after some text\n # Turn those inputs into a float, and save it in some variable\n print \"What is your first number? \"\n first_number = gets.to_f\n\n print \"What is your second number? \"\n second_number = gets.to_f\n\n # binding.pry\n\n # Add the two inputs given together and save the result\n result = first_number + second_number\n\n # Print these things out to the screen\n puts \"The result is #{result}\"\nend", "def sum(a, b)\n puts \"Sum total: #{a} + #{b} = #{10 + 20}\"\n\nend", "def add_nums(num1, num2)\n p \"Addition of #{num1} + #{num2} = #{num1 + num2}\"\nend", "def sub_operation()\n print_message \"Write number and press ENTER to substract more or press 'r' to show result\"\n result = 0\n sub = gets.chomp\n if sub != 'r'\n result = sub.to_i\n end\n begin\n begin\n sub = gets.chomp\n if sub != 'r'\n result -= sub.to_i\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Substraction operation.\\n#{e.message}\"\n sub = 'r'\n end\n end while sub.downcase != 'r'\n print_message \"Result of substracting: #{result.to_s}\"\n end", "def basic_calc\n puts \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n basic = gets.chomp.downcase\n\n get_two_numbers\n\n case basic\n when \"a\"\n \tputs addition($num1, $num2)\n when \"s\"\n \tputs subtraction($num1, $num2)\n when \"m\"\n \tputs multiplication($num1, $num2)\n when \"d\"\n \tputs division($num1, $num2)\n end\n\nend", "def subtraction(value1, value2)\n result = value1 - value2\n puts \"The sum of #{ value1 } - #{ value2 } = #{ result }\"\nend", "def print_results(num_1, num_2)\n puts \"addition #{num_1 + num_2}\"\n puts \"subtraction #{num_1 - num_2}\"\n puts \"product #{num_1 * num_2}\"\n puts \"remainder #{num_1 % num_2}\"\n puts \"quotient #{num_1 / num_2}\"\n puts \"power #{num_1 ** num_2}\"\n\nend", "def input\n\tputs 'What sorta math do ya wanna do?'\n\tputs '1 for addition'\n\tputs '2 for subtraction'\n\tputs '3 for multiplication'\n\tputs '4 for division'\n\tputs '5 for exponent'\n\tputs '6 for squaring'\n\tputs '7 for cubing'\n\tputs '8 for square rooting'\n\tgets.chomp.to_i\nend", "def subtract(num_one, num_two)\n puts \"#{num_one} - #{num_two} = #{num_one + num_two}\\n\"\nend", "def sum_these_numbers(a, b)\n puts a + b\nend", "def add_it\n puts \"Ok, we're adding. What is the first number?\"\n first = gets.chomp\n first = verify(first)\n puts \"What number do you want to add to #{look_pretty(first)}?\"\n second = gets.chomp\n second = verify(second)\n puts \"The sum of #{look_pretty(first)} and #{look_pretty(second)} is #{look_pretty(addition(first,second))}\"\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n gets.chomp.downcase\nend", "def Multiplicacion\n print \"Ingrese El numero 1: \"\n numero1 = gets.chomp.to_f\n print \"Ingrese El numeor 2: \"\n numero2 = gets.chomp.to_f\n\n puts \"\\nMultiplicacion: #{numero1 * numero2}\"\n end", "def calculator\n puts \"Welcome to the DPL Ruby Calculator!\"\n puts \"Type 'clear' to clear the calculator at anytime\"\n puts \"Type 'exit' to exit the calculator at anytime\"\n first_number\n get_modifier\n second_number\n put_result \nend", "def multiply(a,b)\n puts \"Multiplying #{a} and #{b} to get #{a * b}\"\nend", "def math_problem(num1, num2)\n p \"I am solving this hard math problem\"\n return num1 + num2\n p num1 - num2 #this won't get executed\nend", "def add(num1,num2)\n\tputs \"num1 has the value : #{ num1 }\"\n\tputs \"num2 has the value : #{ num2 }\"\n\tresults = num1 + num2\n\tputs \"results is then: #{ results}\"\nend", "def numbers(num1, num2)\n puts \"#{num1} + #{num2}\"\n return num1 + num2\nend", "def sum_these_numbers(a,b)\n puts a + b\nend", "def print_sum(num1, num2)\n p num1 + num2\nend", "def sum(a, b)\n puts \"The sum of #{a} + #{b} = \" + \"#{(a + b)}\"\n #return a + b not needed for this\nend", "def multiply(number_1, number_2)\n product = number_1 * number_2\n puts \"#{number_1} * #{number_2} = #{product}\"\n puts \"Hooray for math!\"\nend", "def main\n # determine whether to use verbose outpuut\n verbose = false\n if ARGV[0] != nil and ARGV[0].downcase == \"-v\"\n verbose = true\n end\n\n # get input\n puts \"Instructions: enter a mathematical expression using +, -, *, /, **, or (q)uit\"\n puts \"Calculator follows order of operations\"\n puts \"All elements must be separated by spaces\"\n puts \"e.g. ( 4 + 5 ) * 6\"\n print \"Enter an expression: \"\n expr = STDIN.gets.strip\n\n # continue calculating expressions until user quits\n until expr.downcase.start_with?(\"q\")\n # send to calc() and print result\n result = calc(expr, verbose)\n\n if result == nil\n puts \"Please enter a valid expression\"\n puts \"Common error: all elements should be separated by spaces\"\n elsif result % 1 == 0 # print int if result is integer\n puts result.to_i\n else\n puts result\n end\n\n print \"enter another expression, or (q)uit: \"\n expr = STDIN.gets.strip\n end\nend", "def mult_operation()\n print_message \"Write number and press ENTER to multiply more or press 'r' to show result\"\n result = 0\n mult = gets.chomp\n if mult != 'r'\n result = mult.to_i\n end\n begin\n begin\n mult = gets.chomp\n if mult != 'r'\n result *= mult.to_i\n end\n rescue StandardError => e\n print_error_message \"Invalid number. Ending Multiplication operation.\\n#{e.message}\"\n mult = 'r'\n end\n end while mult.downcase != 'r'\n print_message \"Result of multiplying: #{result.to_s}\"\n end", "def add(a, b)\n puts \"SUM #{a} + #{b}\"\n return a + b\nend", "def multiply(num_one, num_two)\n puts \"#{num_one} * #{num_two} = #{num_one * num_two}\\n\"\nend", "def add(a,b)\n puts \"Adding these numbers #{a}, #{b}\"\n a + b\n end", "def add_sum(a, b)\n puts \"ADDING #{a} + #{b}\"\n return a + b\nend", "def sum_these_numbers (a, b)\n puts a + b\nend", "def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n operation = gets.chomp.downcase\n print \"first number: \"\n a = gets.to_f\n print \"second number: \"\n b = gets.to_f\n \n case operation\n when 'a'\n puts \"#{a + b}\"\n when 's'\n puts \"#{a - b}\"\n when 'm'\n puts \"#{a * b}\"\n when 'd'\n puts \"#{a / b}\"\n else\n puts \"WRONG!!!!!\"\n basic_calc\n end\n\n gets\nend", "def consec_ints\n puts \">> Please enter an integer greater than 0:\"\n num = gets.chomp.to_i\n arr = Array.new(num) { |i| i + 1 }\n puts \">> Enter 's' to compute the sum, 'p' to compute the product.\"\n method = gets.chomp.downcase\n if method == 's'\n puts \"#{arr.reduce(&:+)}\"\n else\n puts \"#{arr.reduce(&:*)}\"\n end\nend", "def numbers(num1, num2)\n p num1 + num2\nend", "def sum(num1, num2)\n puts num1 + num2\nend", "def calc_subtract(num1, num2)\n puts \"#{num1} - #{num2} = #{num1 - num2}\"\nend", "def sum_these_numbers(num1,num2)\n p num1 + num2\nend", "def calculate(num1, sym, num2)\n\tputs eval \"#{num1} #{sym} #{num2}\"\nend", "def user_prompt(*args)\n print(*args)\n to_return = gets.strip.split\n to_return.collect {|value| Integer(value)}\nend", "def add_two_numbers( x, y )\n puts x + y\nend", "def do_addition(number_1, number_2)\n\tfinal_number = number_1 + number_2\n\tputs \"Your first number, #{$first_number}, plus your second number, #{$second_number}, equals #{final_number}.\"\nend", "def add_two(num1, num2)\n\tnumber = num1 + num2\n\tputs number\nend", "def numbers(a, b)\n puts \"First number is #{a}\"\n puts \"Second number is #{b}\"\n return a + b\nend", "def main\n one = first_number\n two = second_number\n addit(one, two)\nend" ]
[ "0.79599655", "0.7917274", "0.77308846", "0.7644165", "0.75703704", "0.75413847", "0.75002897", "0.7398552", "0.7395946", "0.73153496", "0.72797805", "0.72483873", "0.7208441", "0.705538", "0.70248014", "0.70197755", "0.6995165", "0.6991467", "0.6981296", "0.68775386", "0.687459", "0.68414664", "0.6808467", "0.6714121", "0.66511416", "0.6617587", "0.65585315", "0.65554816", "0.6552784", "0.65294844", "0.65199876", "0.6482062", "0.64561355", "0.64451784", "0.64284194", "0.6421532", "0.63855773", "0.6373221", "0.63186514", "0.63135576", "0.62991446", "0.6296654", "0.6277829", "0.6271078", "0.6267675", "0.6261808", "0.6259617", "0.6243249", "0.62334746", "0.62319505", "0.6202153", "0.6169796", "0.6155478", "0.61549747", "0.6136476", "0.61187667", "0.6108561", "0.6106701", "0.61058384", "0.6093606", "0.60868585", "0.6081412", "0.606343", "0.6051678", "0.605117", "0.60505325", "0.6040132", "0.60372716", "0.60150254", "0.5998897", "0.5998449", "0.5987899", "0.598512", "0.59787893", "0.59716696", "0.59625286", "0.5960778", "0.5948068", "0.5945875", "0.59373313", "0.5931008", "0.5930179", "0.5916408", "0.5914886", "0.59142643", "0.59124523", "0.5911443", "0.5909676", "0.5903456", "0.5899604", "0.5896565", "0.58912355", "0.58883834", "0.5874947", "0.58721024", "0.5870513", "0.5868338", "0.5862023", "0.5859088", "0.5855998" ]
0.76710844
3
GET /slow_things GET /slow_things.json
def index @slow_things = SlowThing.all respond_with @slow_things if stale? @slow_things, public: true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_with @slow_thing if stale? @slow_thing, public: true\n end", "def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end", "def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end", "def index\n render json: {\n status: :success,\n urls: ShortUrl::top_100\n }\n end", "def index\n @urls = Url.get_top(25)\n # render json: @urls\n end", "def get_reading\n\t\turi = URI.parse('http://localhost:5000/thermometers.json')\n\t\tthermo_response = Net::HTTP.get_response(uri)\n\t\tcheck = thermo_response.body\n\t\tj = JSON.parse(check)\n\tend", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def test_monkey_slash_recent_endpoint\n # See Email: monkey/recent constantly timing out\n skip_message = 'Dickson & Jorge are looking into monkey/recent timing out in the db: This sql took 38 seconds to run in stg and only .005 second in production.'\n assign_http(Config['monkey']['host'])\n\n get '/recent', {}\n skip(\"#{skip_message} -- #{@parsed_response['message']}\") if @parsed_response['message'] =~ /Gateway\\:\\:GatewayTimeout/\n assert_response(@response, :success)\n end", "def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def index\n @bottlings = handle_sorting(:bottling, :sku, :wine, :bottle_size)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bottlings }\n end\n end", "def index\n @slowlogexts = Slowlogext.get_all(params[:page])\n end", "def set_slow_thing\n @slow_thing = SlowThing.find(params[:id])\n end", "def work()\n # FIXME : .rel[...].get doesn't update $client.rate_limit...\n\n rate_limit = $client.rate_limit\n dbgp \"#{rate_limit.remaining} API calls left.\"\n\n # A little buffer in case we use a feature from octokit\n # which doesn't update rate_limit on `$client`.\n if rate_limit.remaining < 5 then\n reset = rate_limit.resets_in + 10\n puts \"💤 zleepy timez (back in #{reset} seconds)\"\n sleep(reset)\n end\n\n begin\n yield\n rescue Octokit::BadGateway, Octokit::InternalServerError => e\n puts \"Uuuh... github is having a bad time :( #{e.response_status}\"\n pp \"=====\"\n pp \"=====\"\n pp e.response_body\n pp \"=====\"\n pp e.response_headers\n pp \"=====\"\n pp \"=====\"\n sleep 10\n retry\n end\nend", "def show\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing }\n end\n end", "def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end", "def index\n @somethings = Something.all\n render json: @somethings\n end", "def make_search(url)\n #make the web request\n data = RestClient.get url\n JSON.parse(data)\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end", "def json_get(url)\n get url, :parse=>true\n end", "def get_json(uri)\n start = Time.now\n attempt = 0\n begin\n res = @http.get(\n uri,\n 'Accept' => 'text/plain',\n 'User-Agent' => user_agent,\n 'Accept-Encoding' => ''\n )\n raise Error, \"Failed to retrieve #{uri} (#{res.code}): #{res.body}\" unless res.code == '200'\n info(\"GET #{uri}: #{res.code}/#{res.body.length}b in #{age(start)}\")\n JSON.parse(res.body)\n rescue StandardError => e\n attempt += 1\n raise e if attempt >= @attempts\n retry\n end\n end", "def index\n render json: {time: Time.now}\n end", "def create\n @slow_thing = SlowThing.new(slow_thing_params)\n\n respond_to do |format|\n if @slow_thing.save\n\n domain = URI(root_url)\n Net::HTTP.start(domain.host, domain.port) do |http|\n Rails.logger.debug \"purging #{domain}\"\n http.request( Purge.new(domain) )\n\n Rails.logger.debug \"purging #{slow_things_url}\"\n http.request( Purge.new(URI(slow_things_url)) )\n end\n\n format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully created.' }\n format.json { render :show, status: :created, location: @slow_thing }\n else\n format.html { render :new }\n format.json { render json: @slow_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end", "def get_model_years_fast\n start = Time.now\n\n # open the json file of all cars and models\n json = JSON.parse(File.read(@all_cars_file))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n # get all of the car ids with model ids\n # model_ids = json.map{|key, value| value['models'].keys}.flatten\n car_model_ids = json.map{|key, value| [key, value['models'].keys]}\n\n if car_model_ids.nil? || car_model_ids.length == 0\n puts \"ERROR - could not find model ids\"\n exit\n end\n\n puts \"- found #{car_model_ids.length} cars with a total of #{car_model_ids.map{|x| x[1]}.flatten.length} models\"\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_left_to_process = car_model_ids.length\n\n car_model_ids.each_with_index do |car, index|\n puts \"-------------------\"\n puts \"#{index} cars download so far in #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n\n car[1].each do |model_id|\n puts \"- car #{car[0]}, model #{model_id}\"\n request = Typhoeus::Request.new(\"#{@model_years_url}#{model_id}\",\n :headers=>{\"User-Agent\" => @user_agent}, followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0)\n\n request.on_complete do |response|\n # save years\n json[car[0]]['models'][model_id]['years'] = JSON.parse(response.response_body)\n\n # decrease counter of items to process\n total_left_to_process -= 1\n if total_left_to_process == 0\n puts \"TOTAL TIME TO DOWNLOAD = #{((Time.now-start)/60).round(2)} minutes\"\n\n elsif total_left_to_process % 10 == 0\n puts \"\\n\\n- #{total_left_to_process} files remain to download; time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n end\n hydra.queue(request)\n end\n end\n\n hydra.run\n\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend", "def index\n @textures = Texture.find(:all, :limit => 20, :order=> 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @textures }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors do\n result = model.find_by_id(params[:id])\n halt 404 if result.nil?\n json result\n end\n end\n\n post \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.create(@json_payload) }\n end\n\n patch \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.update(params[:id], @json_payload) }\n end\n\n delete \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { model.delete(params[:id]) }\n end\n\n private\n def catch_errors()\n begin\n yield\n rescue Exception => e\n logger.fatal(\"Exception: #{e}\")\n status 500\n json({'error' => e})\n end\n end\nend", "def microservice_i(id)\r\n my_port = 8082\r\n store_message = \"/store/#{id}/#{$light}/#{$suit}/#{$wealth}/#{$sword}/#{$amulet}/#{$axe}/#{$food}/#{0}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{store_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n\r\n $light = my_json['light']\r\n $suit = my_json['suit']\r\n $wealth = my_json['wealth']\r\n $sword = my_json['sword']\r\n $amulet = my_json['amulet']\r\n $axe = my_json['axe']\r\n $food = my_json['food']\r\n puts(\"#{my_json['text']}\\n\")\r\n\r\n if id == 4\r\n food_units = gets.strip.to_i\r\n buy_food(7,food_units)\r\n end\r\nend", "def index\n @http_requests = HttpRequest.order(\"created_at DESC\").page(params[:page]).per(10)\n end", "def index \n render json: Tuning.all\n end", "def client_choose(offset = 10, limit = 20)\n response = Net::HTTP.get(\n URI(\"https://pokeapi.co/api/v2/pokemon/?offset=#{offset}&limit=#{limit}\")\n )\n \n JSON.parse(response)\nend", "def index\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json do\n out = meetings.per(500).map(&:to_json_attributes)\n out.each { |m| m[:url] = meeting_path(m[:url]) }\n render json: out\n end\n format.xml { render xml: meetings }\n end\n end", "def retrieve\n sort = 'created_at DESC'\n\n case params[:sort]\n when 'recent'\n sort = 'created_at DESC'\n when 'popular'\n sort = 'views DESC, likes DESC'\n else\n\n end\n\n stories = Story.where(\"LOWER(name) LIKE ?\", '%' + params[:query].downcase + '%').order(sort).offset(params[:offset]).limit(params[:limit])\n\n render json: stories\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def get_tweet(search,since_id = 0, throtle = 20)\n\turl = 'http://search.twitter.com/search.json?q='+search+'&rpp='+throtle.to_s+'&since_id='+since_id.to_s\n\tprint \"Asking with this url \" + url+ \"\\n\"\n\tresp = Net::HTTP.get_response(URI.parse(url))\n\tresponse_array = JSON.parse(resp.body)\nend", "def index\n @tasks = Task.all\n response = @tasks.map{|task| get_task_hash(task)}\n render json: response\n end", "def index\n @clothings = Clothing.all\n @clothing_types = ClothingType.all\n @genders = Gender.all\n @clothing_sizes = ClothingSize.all\n\n @clothings = Clothing.all\n if params[:search]\n @clothings = Clothing.search(params[:search]).order(\"created_at DESC\")\n else\n @clothings = Clothing.all.order(\"created_at DESC\")\n end\n end", "def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend", "def job_data\n fetch_data('https://www.themuse.com/api/public/jobs?&category=Engineering&category=Project+%26+Product+Management&level=Mid+Level&level=Entry+Level&location=Boston%2C+MA&location=New+York%2C+NY&location=San+Francisco%2C+CA&page=1&descending=true')[\"results\"]\nend", "def show\n @thing = current_user.things.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing }\n end\n end", "def index\n @bikes = Bike.all.order(\"display_order\")\n render json: @bikes.includes(:specifications) #each_serializer: Web::V1::BikeSerializer\n end", "def slow_down_api_request\n sleep 1.0\n end", "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def show\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stuff }\n end\n end", "def index\n @shorties = Shorty.per_user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shorties }\n end\n end", "def get_random_pokemon(number)\n uri = URI(\"https://pokeapi.co/api/v2/pokemon/#{number}\")\n res = Net::HTTP.get_response(uri)\n JSON.parse(res.body)\nend", "def get_blockchain_stats\n stats = HTTParty.get(\"http://webbtc.com/stats.json\")\nend", "def index\n find_ongoing_tasks\n render json: OngoingTaskBlueprint.render(@ongoing_tasks)\n rescue ActiveRecord::RecordNotFound\n render json: { error: $ERROR_INFO.message }, status: :not_found\n end", "def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end", "def api_get_json(url, page, o = {})\n u = absolute_url(url)\n\n options = {}.merge(o)\n options[:_page] = page if page.is_a? Integer\n resp = []\n\n time_taken = Benchmark.measure do\n while u\n json = get_json(u, options)\n result = json['result']\n\n resp.concat(result['items']) unless item_endpoint?(page)\n resp = result['primaryTopic'] if item_endpoint?(page)\n\n u = (fetch_all?(page) || fetch_more?(o, resp)) && more?(result)\n options.delete(:_page) if u\n end\n end\n\n Rails.logger.debug(\"Completed remote JSON LDA execution in: #{time_taken}\")\n resp\n end", "def fetch_job\n JSON.parse(RestClient.get(url).body)\n end", "def go_slow\n puts \"I am safe and driving slow.\"\n end", "def slow_thing_params\n params.require(:slow_thing).permit(:name)\n end", "def index\n @timers = Timer.all\n\n render json: @timers\n end", "def go_very_slow\n puts \"I am a heavy truck and like going very slow.\"\n end", "def index\n @things = Thing.all.order('updated_at DESC')\n end", "def slowapi(number)\n if correct_number?(number)\n times = number.to_i\n puts \"Starting request to slowapi\"\n begin\n do_request_and_write_response(times)\n rescue => e\n puts 'Some problem occurred when connecting to Slowapi, try later'\n return false\n end\n else\n puts \"Some parameter is missing or not valid, you need to run it, like this:\" \\\n 'development_challenge slowapi --test -n 300'\n return false\n end\n end", "def get_monster_info\n monster_string = RestClient.get('http://www.dnd5eapi.co/api/monsters/')\n monster_hash = JSON.parse(monster_string)\n monster_info = monster_hash[\"results\"]\n monster_info\nend", "def index\n @joys = Joy.all\n render json: @joys\n end", "def get\n raise NoMethodError unless is_full_route? @cur_route\n @retrieved_url = @cur_url\n response = HTTParty.get(\"https://api.uwaterloo.ca/v2#{@cur_url}.json\", { query: { key: @api_key, format: 'json' } })\n case response.code\n when 400...600\n raise \"UWaterloo API Server returned a #{response.code} error\"\n end\n @response = RecursiveOpenStruct.new response, recurse_over_arrays: true\n @meta = response['meta']\n @response.data\n end", "def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end", "def get_all\n hitches = ::Hitch.where(shared?: true).where(\"submit_time > now()\").near([params[:user_latitude],params[:user_longitude]], 20)\n\n serializer = HitchSerializer.new(hitches, { params: { user_latitude: params[:user_latitude], user_longitude: params[:user_longitude] } })\n render json: serializer.serializable_hash\n end", "def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end\n end", "def show\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @stuff }\n end\n end", "def do_query(params) \n link = @api_url + \"/brief/json/\" + params\n return MultiJson.load( open(link).read )\n end", "def make_request(url)\n response = RestClient.get(url)\n parsed_response = JSON(response)[\"items\"]\nend", "def index\n # Request 500px API for popular photos stream\n uri = URI.parse(FiveHundredPX_API_URL + '/photos?' + \n {feature: 'popular', image_size: 3, rpp: 100, consumer_key: FiveHundredPX_API_CONSUMER_KEY}.to_query\n )\n # In case network error\n res = begin\n Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|\n req = Net::HTTP::Get.new(uri.request_uri)\n res = http.request(req)\n end\n rescue Exception => e\n puts e.message\n puts e.backtrace.join(\"\\n\")\n {}\n end\n # Parse response string\n ret_hash = if res.kind_of?(Net::HTTPResponse)\n begin\n JSON.parse(res.body)\n rescue Exception => e\n puts e.message\n puts e.backtrace.join(\"\\n\")\n {}\n end\n else\n {}\n end\n ret = ActiveSupport::HashWithIndifferentAccess.new(ret_hash)\n\n # Although for task 1 there's no need to go further by creating/contructing Photo objects\n # We do it for forward-compatibility\n @photos = ret[:photos].to_a.map do |fivehundredpx_photo|\n photo = Photo.new\n photo.setup_from_fivehundredpx fivehundredpx_photo\n photo\n end\n\n render :index\n end", "def show\n @hetong = Hetong.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hetong }\n end\n end", "def polling\n @locations = Location.where(\"picture IS NOT NULL\").group('vehicle_id').order('location_timestamp desc')\n render :json => {\"vehicles\"=>@locations }\n end", "def call_poke_url(url)\n JSON.parse(\n HTTP\n .get(URI(url))\n )\nend", "def index\n\n # use a shooting collection cache\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n @shootings = Shooting.get_shootings_from_yammer(Yammer::TokenClient.new(token: current_user.access_token))\n render json: { shootings: @shootings }\n end\n end\n end", "def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend", "def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index\n jobs = Job.all.map do |job|\n { title: job.title, timerange: job.timerange }\n end\n \n render json: { results: jobs }.to_json, status: :ok\n end", "def http( *args )\n p http_get( *args )\n end", "def index\n limit = params.fetch(:limit, 10).to_i\n @playings = Playing.order(:created_at).reverse_order.limit(limit)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @playings }\n end\n end", "def index\n @loves = Love.all\n render json: @loves\n end", "def magic\n\t @word = Word.find(params[:id])\n\t\ttitle = @word.title\n if params[:more]\n\t\t @pics = Rails.cache.fetch(\"olive/#{title}\",:expires_in => 5.hours) do\n \t\t\tresults = Parallel.map([Olive::Tumblr,Olive::Instagram,Olive::Px]) do |p|\n \t\t\t\tphotos(p,title)\n \t\t\tend\n \t\t\tresults[0] + results[1] + results[2]\n \t\tend\n \telse\n \t opt = params[:ctag].blank? ? '' : @word.ctag_list.join(\" \")\n @pics = Grape::WordImage.new(title).parse(opt)[0..14]\n\t end\n\n\t\trender_json 0,\"ok\",@pics\n\tend", "def get_thing(query_hash)\n query = {\"type\" => \"/type/edition\"}.merge(query_hash)\n response = open(@api_url + \"/things?query=\" + CGI.escape(query.to_json) ).read\n JSON.parse(response)\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def scrape_etsy(url)\n data = Net::HTTP.get(url)\n parsed_data = JSON(data)\n # count_listings(parsed_data)\n return parsed_data\nend", "def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end", "def index\n page_title \"View all things\"\n @things = Thing.all\n\n @things.each do |thing|\n # TODO: make this into a helper\n thing.description = thing.description[0..500]\n\n # stop at the end of the first paragraph\n thing.description = thing.description.split(\"\\r\\n\\r\\n\")\n thing.description = thing.description[0]\n\n # remove the last word (fragment)\n thing.description = thing.description.split(\" \")\n thing.description = thing.description[0..-1]\n thing.description = thing.description.join(\" \")\n thing.description = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true).render(thing.description)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @things }\n end\n end", "def go_get_raw(url)\n begin\n puts \"Connecting to URL: \" + url\n response = HTTParty.get(url, timeout: Rails.configuration.x.network_time_out)\n rescue Exception => e\n puts \"Connection ERROR: \" + e.message\n return nil\n end\n return response\n end", "def index\n @jobs = Job.all\n render json: @jobs\n end", "def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end", "def index\n @jobs = Job.all\n\n render json: @jobs\n end", "def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end", "def index\n @whoarewes = Whoarewe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @whoarewes }\n end\n end", "def pokemon_api_caller\nresponse = RestClient.get \"https://pokeapi.co/api/v2/pokemon/?offset=0&limit=807\"\nresponse_JSON = JSON.parse(response)\nresponse_JSON[\"results\"]\nend", "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end", "def all_works\n #start = numeric( params[:start], DEFAULT_START )\n #limit = numeric( params[:limit], DEFAULT_LIMIT )\n\n works = batched_get( {} )\n respond_to do |format|\n format.json do\n if works.empty?\n render_json_works_response(:not_found )\n else\n # dont provide fileset information here, it takes too long and we just want work information\n render_json_works_response(:ok, work_transform( works, EXCLUDE_FILESETS ) )\n end\n end\n format.csv do\n # provide fileset information here because this is used for work export\n render_csv_works_response( work_transform( works, INCLUDE_FILESETS ) )\n end\n end\n\n end" ]
[ "0.5984558", "0.59120774", "0.5740068", "0.57172483", "0.5641928", "0.55835277", "0.55741984", "0.5570309", "0.5537178", "0.55098784", "0.5508085", "0.55048484", "0.5489543", "0.5489199", "0.5468746", "0.546777", "0.546486", "0.54524916", "0.54512143", "0.5450417", "0.5424806", "0.5415147", "0.5407549", "0.53954077", "0.5390758", "0.5388925", "0.53882533", "0.5376936", "0.5341222", "0.53393817", "0.53393817", "0.5309978", "0.5308063", "0.5305523", "0.53042454", "0.52973133", "0.52852774", "0.52688444", "0.52534354", "0.5251524", "0.5247516", "0.5224328", "0.5220819", "0.521177", "0.52090085", "0.52078855", "0.52007425", "0.51933837", "0.5189827", "0.5187984", "0.51816267", "0.517687", "0.5171594", "0.51699346", "0.51694465", "0.51688284", "0.51684725", "0.51668715", "0.5162633", "0.51599693", "0.51584166", "0.515799", "0.5154847", "0.51525617", "0.51504713", "0.51496613", "0.5144604", "0.5142456", "0.5140721", "0.5140531", "0.51404536", "0.51403", "0.513804", "0.5136171", "0.5134335", "0.5133928", "0.5133634", "0.5126494", "0.51260114", "0.5124267", "0.5123467", "0.5119776", "0.51162755", "0.5115701", "0.5113788", "0.5113752", "0.511093", "0.51104975", "0.5109056", "0.5108051", "0.5102331", "0.50976986", "0.5094653", "0.509356", "0.5088855", "0.5087458", "0.5087254", "0.5086404", "0.5086361", "0.50854266" ]
0.7145652
0
GET /slow_things/1 GET /slow_things/1.json
def show respond_with @slow_thing if stale? @slow_thing, public: true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @slow_things = SlowThing.all\n respond_with @slow_things if stale? @slow_things, public: true\n end", "def show\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing }\n end\n end", "def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end", "def index\n render json: {\n status: :success,\n urls: ShortUrl::top_100\n }\n end", "def set_slow_thing\n @slow_thing = SlowThing.find(params[:id])\n end", "def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def create\n @slow_thing = SlowThing.new(slow_thing_params)\n\n respond_to do |format|\n if @slow_thing.save\n\n domain = URI(root_url)\n Net::HTTP.start(domain.host, domain.port) do |http|\n Rails.logger.debug \"purging #{domain}\"\n http.request( Purge.new(domain) )\n\n Rails.logger.debug \"purging #{slow_things_url}\"\n http.request( Purge.new(URI(slow_things_url)) )\n end\n\n format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully created.' }\n format.json { render :show, status: :created, location: @slow_thing }\n else\n format.html { render :new }\n format.json { render json: @slow_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def microservice_i(id)\r\n my_port = 8082\r\n store_message = \"/store/#{id}/#{$light}/#{$suit}/#{$wealth}/#{$sword}/#{$amulet}/#{$axe}/#{$food}/#{0}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{store_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n\r\n $light = my_json['light']\r\n $suit = my_json['suit']\r\n $wealth = my_json['wealth']\r\n $sword = my_json['sword']\r\n $amulet = my_json['amulet']\r\n $axe = my_json['axe']\r\n $food = my_json['food']\r\n puts(\"#{my_json['text']}\\n\")\r\n\r\n if id == 4\r\n food_units = gets.strip.to_i\r\n buy_food(7,food_units)\r\n end\r\nend", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def get_reading\n\t\turi = URI.parse('http://localhost:5000/thermometers.json')\n\t\tthermo_response = Net::HTTP.get_response(uri)\n\t\tcheck = thermo_response.body\n\t\tj = JSON.parse(check)\n\tend", "def index\n @urls = Url.get_top(25)\n # render json: @urls\n end", "def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def index\n @somethings = Something.all\n render json: @somethings\n end", "def test_monkey_slash_recent_endpoint\n # See Email: monkey/recent constantly timing out\n skip_message = 'Dickson & Jorge are looking into monkey/recent timing out in the db: This sql took 38 seconds to run in stg and only .005 second in production.'\n assign_http(Config['monkey']['host'])\n\n get '/recent', {}\n skip(\"#{skip_message} -- #{@parsed_response['message']}\") if @parsed_response['message'] =~ /Gateway\\:\\:GatewayTimeout/\n assert_response(@response, :success)\n end", "def show\n @microtask = Microtask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microtask }\n end\n end", "def index\n render json: {time: Time.now}\n end", "def get_random_pokemon(number)\n uri = URI(\"https://pokeapi.co/api/v2/pokemon/#{number}\")\n res = Net::HTTP.get_response(uri)\n JSON.parse(res.body)\nend", "def client_choose(offset = 10, limit = 20)\n response = Net::HTTP.get(\n URI(\"https://pokeapi.co/api/v2/pokemon/?offset=#{offset}&limit=#{limit}\")\n )\n \n JSON.parse(response)\nend", "def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors do\n result = model.find_by_id(params[:id])\n halt 404 if result.nil?\n json result\n end\n end\n\n post \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.create(@json_payload) }\n end\n\n patch \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.update(params[:id], @json_payload) }\n end\n\n delete \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { model.delete(params[:id]) }\n end\n\n private\n def catch_errors()\n begin\n yield\n rescue Exception => e\n logger.fatal(\"Exception: #{e}\")\n status 500\n json({'error' => e})\n end\n end\nend", "def index\n @textures = Texture.find(:all, :limit => 20, :order=> 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @textures }\n end\n end", "def get_thing(query_hash)\n query = {\"type\" => \"/type/edition\"}.merge(query_hash)\n response = open(@api_url + \"/things?query=\" + CGI.escape(query.to_json) ).read\n JSON.parse(response)\n end", "def show\n @thing = current_user.things.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing }\n end\n end", "def get_json(uri)\n start = Time.now\n attempt = 0\n begin\n res = @http.get(\n uri,\n 'Accept' => 'text/plain',\n 'User-Agent' => user_agent,\n 'Accept-Encoding' => ''\n )\n raise Error, \"Failed to retrieve #{uri} (#{res.code}): #{res.body}\" unless res.code == '200'\n info(\"GET #{uri}: #{res.code}/#{res.body.length}b in #{age(start)}\")\n JSON.parse(res.body)\n rescue StandardError => e\n attempt += 1\n raise e if attempt >= @attempts\n retry\n end\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def index \n render json: Tuning.all\n end", "def json_get(url)\n get url, :parse=>true\n end", "def show\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stuff }\n end\n end", "def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend", "def work()\n # FIXME : .rel[...].get doesn't update $client.rate_limit...\n\n rate_limit = $client.rate_limit\n dbgp \"#{rate_limit.remaining} API calls left.\"\n\n # A little buffer in case we use a feature from octokit\n # which doesn't update rate_limit on `$client`.\n if rate_limit.remaining < 5 then\n reset = rate_limit.resets_in + 10\n puts \"💤 zleepy timez (back in #{reset} seconds)\"\n sleep(reset)\n end\n\n begin\n yield\n rescue Octokit::BadGateway, Octokit::InternalServerError => e\n puts \"Uuuh... github is having a bad time :( #{e.response_status}\"\n pp \"=====\"\n pp \"=====\"\n pp e.response_body\n pp \"=====\"\n pp e.response_headers\n pp \"=====\"\n pp \"=====\"\n sleep 10\n retry\n end\nend", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def show\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @stuff }\n end\n end", "def index\n @bottlings = handle_sorting(:bottling, :sku, :wine, :bottle_size)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bottlings }\n end\n end", "def update\n respond_to do |format|\n if @slow_thing.update(slow_thing_params)\n\n domain = URI(root_url)\n Net::HTTP.start(domain.host, domain.port) do |http|\n Rails.logger.debug \"purging #{domain}\"\n http.request( Purge.new(domain) )\n\n Rails.logger.debug \"purging #{slow_things_url}\"\n http.request( Purge.new(URI(slow_things_url)) )\n\n Rails.logger.debug \"purging #{slow_thing_url(@slow_thing)}\"\n http.request( Purge.new(URI(slow_thing_url(@slow_thing))) )\n end\n\n format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @slow_thing }\n else\n format.html { render :edit }\n format.json { render json: @slow_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @shorties = Shorty.per_user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shorties }\n end\n end", "def do_query(params) \n link = @api_url + \"/brief/json/\" + params\n return MultiJson.load( open(link).read )\n end", "def show\n @hetong = Hetong.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hetong }\n end\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def show\n @therapist = Therapist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @therapist }\n end\n end", "def make_search(url)\n #make the web request\n data = RestClient.get url\n JSON.parse(data)\nend", "def show \n @toy = Toy.find(params[:id]) \n # render json: Toy.find_by_id(params[:id]), status: :ok\n end", "def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end", "def fetch_job\n JSON.parse(RestClient.get(url).body)\n end", "def show\n refresh_date = Time.at(params[:id].to_i/1000)\n player_updates = Player.where(\"updated_at > ?\", refresh_date)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => {:server_time => Time.now.to_i, :players => player_updates}}\n end\n end", "def index\n find_ongoing_tasks\n render json: OngoingTaskBlueprint.render(@ongoing_tasks)\n rescue ActiveRecord::RecordNotFound\n render json: { error: $ERROR_INFO.message }, status: :not_found\n end", "def show\n @mostsmallresource = Mostsmallresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallresource }\n end\n end", "def show\n @take = Take.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @take }\n end\n end", "def slowapi(number)\n if correct_number?(number)\n times = number.to_i\n puts \"Starting request to slowapi\"\n begin\n do_request_and_write_response(times)\n rescue => e\n puts 'Some problem occurred when connecting to Slowapi, try later'\n return false\n end\n else\n puts \"Some parameter is missing or not valid, you need to run it, like this:\" \\\n 'development_challenge slowapi --test -n 300'\n return false\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def get_model_years_fast\n start = Time.now\n\n # open the json file of all cars and models\n json = JSON.parse(File.read(@all_cars_file))\n\n if json.nil?\n puts \"ERROR - could not find json file\"\n exit\n end\n\n # get all of the car ids with model ids\n # model_ids = json.map{|key, value| value['models'].keys}.flatten\n car_model_ids = json.map{|key, value| [key, value['models'].keys]}\n\n if car_model_ids.nil? || car_model_ids.length == 0\n puts \"ERROR - could not find model ids\"\n exit\n end\n\n puts \"- found #{car_model_ids.length} cars with a total of #{car_model_ids.map{|x| x[1]}.flatten.length} models\"\n\n hydra = Typhoeus::Hydra.new(max_concurrency: @max_concurrency)\n request = nil\n total_left_to_process = car_model_ids.length\n\n car_model_ids.each_with_index do |car, index|\n puts \"-------------------\"\n puts \"#{index} cars download so far in #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n\n car[1].each do |model_id|\n puts \"- car #{car[0]}, model #{model_id}\"\n request = Typhoeus::Request.new(\"#{@model_years_url}#{model_id}\",\n :headers=>{\"User-Agent\" => @user_agent}, followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0)\n\n request.on_complete do |response|\n # save years\n json[car[0]]['models'][model_id]['years'] = JSON.parse(response.response_body)\n\n # decrease counter of items to process\n total_left_to_process -= 1\n if total_left_to_process == 0\n puts \"TOTAL TIME TO DOWNLOAD = #{((Time.now-start)/60).round(2)} minutes\"\n\n elsif total_left_to_process % 10 == 0\n puts \"\\n\\n- #{total_left_to_process} files remain to download; time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n end\n hydra.queue(request)\n end\n end\n\n hydra.run\n\n\n puts \"FINISHED DOWNLOAD DATA!!\"\n\n # save to file\n File.open(@all_cars_file_with_years, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend", "def retrieve\n sort = 'created_at DESC'\n\n case params[:sort]\n when 'recent'\n sort = 'created_at DESC'\n when 'popular'\n sort = 'views DESC, likes DESC'\n else\n\n end\n\n stories = Story.where(\"LOWER(name) LIKE ?\", '%' + params[:query].downcase + '%').order(sort).offset(params[:offset]).limit(params[:limit])\n\n render json: stories\n end", "def index\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json do\n out = meetings.per(500).map(&:to_json_attributes)\n out.each { |m| m[:url] = meeting_path(m[:url]) }\n render json: out\n end\n format.xml { render xml: meetings }\n end\n end", "def show\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jetty }\n end\n end", "def index\n @shots = Shot.all\n\n render json: @shots\n end", "def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end", "def index\n @thing = Thing.new\n @things = Thing.all\n end", "def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end", "def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end", "def show\n pet = BattlePet.find(params[:id])\n render json: pet, status: :ok\n end", "def show\n @wait = Wait.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @wait }\n end\n end", "def get_monster_info\n monster_string = RestClient.get('http://www.dnd5eapi.co/api/monsters/')\n monster_hash = JSON.parse(monster_string)\n monster_info = monster_hash[\"results\"]\n monster_info\nend", "def show\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interesting }\n end\n end", "def each_company_onethings(company_id, interval)\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_indvidual_company'])\n\t\t url_params = {\"comapny_id\" => company_id, \"interval\" => interval}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traffic }\n end\n end", "def show\n story = Story.find(params[:id])\n render json: story\n end", "def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end", "def get_tweet(search,since_id = 0, throtle = 20)\n\turl = 'http://search.twitter.com/search.json?q='+search+'&rpp='+throtle.to_s+'&since_id='+since_id.to_s\n\tprint \"Asking with this url \" + url+ \"\\n\"\n\tresp = Net::HTTP.get_response(URI.parse(url))\n\tresponse_array = JSON.parse(resp.body)\nend", "def index\n @http_requests = HttpRequest.order(\"created_at DESC\").page(params[:page]).per(10)\n end", "def slow_thing_params\n params.require(:slow_thing).permit(:name)\n end", "def pokemon_api_caller\nresponse = RestClient.get \"https://pokeapi.co/api/v2/pokemon/?offset=0&limit=807\"\nresponse_JSON = JSON.parse(response)\nresponse_JSON[\"results\"]\nend", "def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend", "def index\n @thumbs = Thumb.all\n\n render json: @thumbs\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end", "def current\n batles = BatlePool.instance.all\n render json: batles,\n except: :location_id,\n include: [:heroes, :threat],\n status: :ok\n end", "def load_poke url\n output = JSON.parse(RestClient.get(url))\n if Poke.find_by(id: output['id'])\n Poke.update(output['id'],\n name: output['name'],\n weight: output['weight'],\n order: output['order'])\n else\n Poke.create(id: output['id'],\n name: output['name'],\n weight: output['weight'],\n order: output['order'])\n end\n print 'p' + output['id'].to_s + ' ' if VERBOSE==1\nend", "def index\n @hits = Hit.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hits }\n end\n end", "def index\n @short_term_goals = ShortTermGoal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @short_term_goals }\n format.json {\n #Format Response\n results = Array.new\n puts \"Print some tags: \"\n @short_term_goals.each do |goal|\n results << {\n 'id' => goal.id,\n 'name' => goal.name,\n 'description' => goal.description,\n 'long_term_goal_id' => goal.long_term_goal_ids, \n 'school_year' => goal.school_year,\n 'tasks' => Array.new, \n 'tag' => goal.tag.name.gsub!(/\\s*/,'').downcase,\n }\n goal.tasks.each do |task|\n results[results.length-1]['tasks'] << {\n 'id' => task.id,\n 'name' => task.name,\n 'description' => task.description\n }\n end\n end \n #send response\n render :json => results\n }\n end\n end", "def make_request(url)\n response = RestClient.get(url)\n parsed_response = JSON(response)[\"items\"]\nend", "def index\n @api_v1_todos = Todo.all\n render json: @api_v1_todos\n end", "def index\n\n # use a shooting collection cache\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n @shootings = Shooting.get_shootings_from_yammer(Yammer::TokenClient.new(token: current_user.access_token))\n render json: { shootings: @shootings }\n end\n end\n end", "def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end\n end", "def show\n tile = Tile.find(params[:id]) \n render json: tile\n end", "def index\n @things = Thing.all.order('updated_at DESC')\n end", "def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end", "def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end", "def call_poke_url(url)\n JSON.parse(\n HTTP\n .get(URI(url))\n )\nend", "def show\n @timer = Timer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timer }\n end\n end", "def get_single_job_sample(client)\n response = client[\"jobs/#{$job_id}\"].get\n\n p ''\n p 'Get single job'\n p response\nend", "def index\n render json: Story.all\n end", "def benchmark_request(number=1)\n uri = URI.parse('http://thefuckingweather.com/?RANDLOC=')\n time = Benchmark.realtime do\n uri.open\n end\n puts \"Request #{number} took #{time} secs\"\nend", "def show\n @building = Building.find(params[:id])\n\n if stale? @building\n render json: @building\n end\n end" ]
[ "0.6930858", "0.58509856", "0.5813788", "0.5804802", "0.57894963", "0.5727108", "0.5678024", "0.5666806", "0.5627441", "0.5572159", "0.5568189", "0.55662334", "0.5565507", "0.5562831", "0.55625254", "0.55625254", "0.55449766", "0.5539758", "0.5525033", "0.55235505", "0.5519967", "0.5487472", "0.5481973", "0.5477689", "0.547745", "0.5468111", "0.5462514", "0.54556733", "0.5442459", "0.54400146", "0.5432256", "0.5420175", "0.5399921", "0.5393651", "0.5385523", "0.5371021", "0.5350381", "0.53481746", "0.5345062", "0.53445435", "0.5339891", "0.5335035", "0.5304961", "0.5302543", "0.5300755", "0.5287372", "0.52859217", "0.5284629", "0.5282408", "0.52766216", "0.5275345", "0.5274657", "0.527391", "0.52719206", "0.5267559", "0.52668756", "0.525884", "0.52549267", "0.5254755", "0.5246664", "0.5246563", "0.5244825", "0.5244393", "0.5244237", "0.5241432", "0.52334476", "0.52307373", "0.52279246", "0.52276427", "0.5227398", "0.52257353", "0.52186924", "0.52123404", "0.52115345", "0.52090967", "0.5208757", "0.5208112", "0.52078164", "0.5207127", "0.52039236", "0.5203405", "0.51987636", "0.5189706", "0.51879984", "0.51855934", "0.5184076", "0.51836807", "0.5183637", "0.5182486", "0.51820993", "0.5181575", "0.51813674", "0.5179601", "0.5178942", "0.51759046", "0.51745623", "0.51741934", "0.51740557", "0.51715404", "0.51695573" ]
0.60379285
1
POST /slow_things POST /slow_things.json
def create @slow_thing = SlowThing.new(slow_thing_params) respond_to do |format| if @slow_thing.save domain = URI(root_url) Net::HTTP.start(domain.host, domain.port) do |http| Rails.logger.debug "purging #{domain}" http.request( Purge.new(domain) ) Rails.logger.debug "purging #{slow_things_url}" http.request( Purge.new(URI(slow_things_url)) ) end format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully created.' } format.json { render :show, status: :created, location: @slow_thing } else format.html { render :new } format.json { render json: @slow_thing.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def slow_thing_params\n params.require(:slow_thing).permit(:name)\n end", "def long_slow_post(host, rate_limit, keep_alive) \r\n\trequest = \"POST /\" + (Digest::MD5.hexdigest(srand.to_s)) + \" HTTP/1.1\\r\\n\";\r\n request += \"Host: #{$host}\\r\\n\"\r\n request += \"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0\\r\\n\"\r\n request += \"Keep-Alive: #{keep_alive}\\r\\n\"\r\n request += \"Content-Length: 1000000000\\r\\n\";\r\n request += \"Content-Type: application/x-www-form-urlencoded\\r\\n\";\r\n request += \"Accept: *.*\\r\\n\";\r\n TCPSocket.open(host, 80) do |socket|\r\n\t\tsocket.write request\r\n\t\tloop {\r\n\t\t\tbegin \t\t\t\r\n\t\t\t\t# Writing one character to socket\r\n\t\t\t\tsocket.write \".\"\r\n\t\t\t\t# Printing request indicator to console\t\t\t\r\n\t\t\t\tprint '.'\r\n\t\t\t\t# Suspending this thread for 1 second to rate limit data sent to target\r\n\t\t\t\tsleep rate_limit\r\n\t\t\trescue\r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\t}\t\r\n\tend\t\r\n\tsocket.close\r\nend", "def index\n @slow_things = SlowThing.all\n respond_with @slow_things if stale? @slow_things, public: true\n end", "def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def create\n params[:thing][:time] = 0\n @thing = Thing.new(thing_params)\n\n respond_to do |format|\n if @thing.save\n format.html { redirect_to root_path, notice: 'The thing was created.' }\n else\n format.html { render :new }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def postReadings(info, state)\r\n params = {\r\n :device_id => info.deviceId,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\",\r\n :value => state.temperature,\r\n :time => Time.now.to_i\r\n },\r\n {\r\n :type => \"Humidity\",\r\n :value => state.humidity,\r\n :time => Time.now.to_i\r\n }\r\n ]\r\n }\r\n res = apiPostJson(\"readings\", params)\r\n if res.status != 201\r\n $LOG.warn(\"Failed to post readings to backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n end", "def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors do\n result = model.find_by_id(params[:id])\n halt 404 if result.nil?\n json result\n end\n end\n\n post \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.create(@json_payload) }\n end\n\n patch \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.update(params[:id], @json_payload) }\n end\n\n delete \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { model.delete(params[:id]) }\n end\n\n private\n def catch_errors()\n begin\n yield\n rescue Exception => e\n logger.fatal(\"Exception: #{e}\")\n status 500\n json({'error' => e})\n end\n end\nend", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def test_no_request_retry_post\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.post(\"http://127.0.0.1:9080/api/delay-sec/20?backend_counter_id=#{unique_test_id}\", http_options)\n assert_response_code(504, response)\n assert_match(\"Inactivity Timeout\", response.body)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def create\n @slowlogext = Slowlogext.new(slowlogext_params)\n\n respond_to do |format|\n if @slowlogext.save\n format.html { redirect_to @slowlogext, notice: 'Slowlogext was successfully created.' }\n format.json { render :show, status: :created, location: @slowlogext }\n else\n format.html { render :new }\n format.json { render json: @slowlogext.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end", "def set_slow_thing\n @slow_thing = SlowThing.find(params[:id])\n end", "def create \n render json: Tuning.create(tuning_params)\n end", "def create_songs\n 5.times do |i|\n url = \"https://stg-resque.hakuapp.com/songs.json?album_id=#{i+1}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n songs = JSON.parse(response)\n\n songs.each do |song|\n Song.create!(song.except('id'))\n end\n end\nend", "def test_concurrent_requests_to_same_url_different_http_method\n start_time = Time.now.utc\n\n get_thread = Thread.new do\n Thread.current[:response] = Typhoeus.get(\"http://127.0.0.1:9080/api/delay-sec/5\", http_options)\n end\n\n # Wait 1 second to ensure the first GET request is fully established to the\n # backend.\n sleep 1\n\n post_thread = Thread.new do\n Thread.current[:response] = Typhoeus.post(\"http://127.0.0.1:9080/api/delay-sec/5\", http_options)\n end\n\n get_thread.join\n post_thread.join\n total_time = Time.now.utc - start_time\n\n assert_equal(200, get_thread[:response].code)\n assert_equal(200, post_thread[:response].code)\n\n # Sanity check to ensure the 2 requests were made in parallel and\n # overlapped.\n assert_operator(total_time, :>, 5)\n assert_operator(total_time, :<, 9)\n end", "def test_no_request_retry_post\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.post(\"http://127.0.0.1:9080/api/timeout\", http_options)\n assert_response_code(504, response)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def slow_down_api_request\n sleep 1.0\n end", "def test_proxies_concurrent_requests_properly\n hydra = Typhoeus::Hydra.new\n requests = Array.new(20) do |index|\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/echo_delayed_chunked\", http_options.deep_merge({\n :params => {\n :input => \"#{unique_test_id}-#{index}-#{SecureRandom.hex(40)}\",\n },\n }))\n hydra.queue(request)\n request\n end\n hydra.run\n\n assert_equal(20, requests.length)\n requests.each do |request|\n assert_response_code(200, request.response)\n assert(request.original_options[:params][:input])\n assert_equal(request.original_options[:params][:input], request.response.body)\n end\n end", "def create\n @thing = Thing.new(params[:thing])\n\n respond_to do |format|\n if @thing.save\n format.html { redirect_to @thing, notice: 'Thing was successfully created.' }\n format.json { render json: @thing, status: :created, location: @thing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def slowapi(number)\n if correct_number?(number)\n times = number.to_i\n puts \"Starting request to slowapi\"\n begin\n do_request_and_write_response(times)\n rescue => e\n puts 'Some problem occurred when connecting to Slowapi, try later'\n return false\n end\n else\n puts \"Some parameter is missing or not valid, you need to run it, like this:\" \\\n 'development_challenge slowapi --test -n 300'\n return false\n end\n end", "def test_json_over_https\n dir = File.dirname(__FILE__)\n d = create_driver(CONFIG + %[\n use_ssl\n ssl_keys [\"#{File.join(dir, 'server.key')}\", \"#{File.join(dir, 'server.cert')}\"]\n ])\n\n time = Time.parse(\"2011-01-02 13:14:15 UTC\").to_i\n\n d.expect_emit \"tag1\", time, {\"a\" => 1}\n d.expect_emit \"tag2\", time, {\"a\" => 2}\n\n d.run do\n d.expected_emits.each { |tag,time,record|\n res = post(\"/#{tag}\", {\"json\" => record.to_json, \"time\" => time.to_s}, {}, true)\n assert_equal \"200\", res.code\n }\n end\n end", "def post_to_fancyhands\n post_to_fancyhands_now\n end", "def create\n #client scale 1-very happy 7-angry, lets revers it, later on we will add mor complex\n @mood = Mood.new(params[:mood])\n @mood.mood = (8-@mood.mood)\n @user = User.find(params[:user_id])\n @mood.user_id = params[:user_id]\n @mood.report_time = Time.now\n @mood_desc = @mood.desc\n if params[:fb_id] != nil\n @mood.fb_id = params[:fb_id]\n end\n updateMoodCounters(@mood.mood,@mood.user_id)\n Resque.enqueue(WordCounter,@mood.desc, @mood.mood, @mood.user_id)\n respond_to do |format|\n if @mood.save\n format.json { render :json => {:report_time=>@mood.report_time,:val=>@mood.mood,:desc=>@mood.desc,:id=>@mood.id}, :status => :created}\n format.js # redirect_fbct_fb.js.erb\n else\n format.json { render :json => @mood.errors, :status => :unprocessable_entity }\n format.js { render 'fail_create.js.erb' }\n end\n end\n end", "def create\n # @thing = Thing.new(thing_params)\n\n # respond_to do |format|\n # if @thing.save\n # format.html { redirect_to @thing, notice: 'Thing was successfully created.' }\n # format.json { render :show, status: :created, location: @thing }\n # else\n # format.html { render :new }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n\t\tjob = Job.new\n\t\tjob.user_id = current_user.id\n\t\tjob.http_method \t= params[:http_method]\n\t\tjob.http_uri \t\t= params[:http_uri]\n\t\tjob.http_host \t\t= params[:http_host]\n\t\tjob.http_headers\t= params[:http_headers]\n\t\tjob.http_data\t\t= params[:http_data]\n\n\t\t# Set job type to bruteforce by default. This will change, but\n\t\t# for now we don't care about responses.\n\t\tjob.attack_type\t\t\t= \"repeat\"\n\n\t\t# Set status to pending by default -- this may change in future\n\t\tjob.status \t\t\t= \"pending\"\n\n\t\tjob.save\n\n\t\trender :json => job.to_json\n\tend", "def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def create\n @workout = Workout.new(name: params[:name], steps: params[:steps], description: params[:description], time: params[:time], image_url: params[:image_url], video_url: params[:video_url], running: params[:running], weightlifting: params[:weightlifting], swimming: params[:swimming], circuit_training: params[:circuit_training], cycling: params[:cycling], creator_id: current_athlete.id, workout_creator: current_athlete.username)\n\n if @workout.save\n AthleteWorkout.create(workout_id: @workout.id, athlete_id: current_athlete.id)\n render 'create.json.jbuilder', status: :created\n else\n render json: { errors: @athlete.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create_twit(twit)\n RestClient.post configuration.base_url + '/twits',\n { twit: twit }.to_json,\n content_type: :json,\n accept: :json\n end", "def test_all_the_dogs_are_in_one_pack\n @params = {\n packs: [\n {\n dogs: ['Spot', 'Fido', 'Rover'],\n location: 'San Francisco',\n },\n {\n dogs: ['Doggie', 'Lassie'],\n location: 'Canada',\n },\n ],\n }\n\n\n post \"/dogs\", params = @params\n assert_equal 'Spot, Fido, Rover, Doggie, and Lassie are all in one pack. Oh no!', last_response.body\n end", "def create\n url = ShortenedUrl.find_by_long_url(shortened_urls_params[:long_url])\n \n if url\n render json: {shortUrl: url[:short_url]}\n else\n shortened_url = ShortenedUrl.new(shortened_urls_params)\n \n if shortened_url.save\n short_url = shortened_url.generate_short_url\n shortened_url.update_attribute(\"short_url\", short_url)\n \n render json: { shortUrl: shortened_url[:short_url], success: true }\n else\n render json: { error: true }\n end\n end\n end", "def microservice_i(id)\r\n my_port = 8082\r\n store_message = \"/store/#{id}/#{$light}/#{$suit}/#{$wealth}/#{$sword}/#{$amulet}/#{$axe}/#{$food}/#{0}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{store_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n\r\n $light = my_json['light']\r\n $suit = my_json['suit']\r\n $wealth = my_json['wealth']\r\n $sword = my_json['sword']\r\n $amulet = my_json['amulet']\r\n $axe = my_json['axe']\r\n $food = my_json['food']\r\n puts(\"#{my_json['text']}\\n\")\r\n\r\n if id == 4\r\n food_units = gets.strip.to_i\r\n buy_food(7,food_units)\r\n end\r\nend", "def post url\n Timeout.timeout(60) do\n puts \"POST: #{url}\" if config[:debug]\n \n tags = (Hpricot(open(\"http://del.icio.us/url/check?url=#{CGI.escape(url)}\"))/\n '#top-tags'/'li')[0..10].map do |li| \n (li/'span').innerHTML[/(.*?)<em/, 1]\n end.join(\" \")\n puts \"POST-TAGS: #{tags}\" if config[:debug]\n \n description = begin\n Timeout.timeout(5) do \n (((Hpricot(open(url))/:title).first.innerHTML or url) rescue url)\n end\n rescue Timeout::Error\n puts \"POST: URL timeout\" if config[:debug]\n url\n end\n \n query = { :url => url, :description => description, :tags => tags, :replace => 'yes' }\n\n http = Net::HTTP.new('api.del.icio.us', 443) \n http.use_ssl = true \n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.start do |http|\n post_url = '/v1/posts/add?' + query.map {|k,v| \"#{k}=#{CGI.escape(v)}\"}.join('&')\n puts \"POST: post url #{post_url}\" if config[:debug]\n req = Net::HTTP::Get.new(post_url, {\"User-Agent\" => \"Kirby\"})\n req.basic_auth config[:delicious_user], config[:delicious_pass]\n http.request(req)\n end.body\n\n puts \"POST: #{response.inspect}\" if config[:debug]\n end\n rescue Exception => e\n puts \"POST: #{e.inspect}\" if config[:debug]\n end", "def submit_form_2122\n validate_json_schema\n\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_using_identifier_and_source(header_md5: header_md5,\n source_name: source_name)\n unless power_of_attorney&.status&.in?(%w[submitted pending])\n power_of_attorney = ClaimsApi::PowerOfAttorney.create(\n status: ClaimsApi::PowerOfAttorney::PENDING,\n auth_headers: auth_headers,\n form_data: form_attributes,\n source_data: source_data,\n header_md5: header_md5\n )\n\n unless power_of_attorney.persisted?\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_by(md5: power_of_attorney.md5)\n end\n\n power_of_attorney.save!\n end\n\n ClaimsApi::PoaUpdater.perform_async(power_of_attorney.id)\n\n render json: power_of_attorney, serializer: ClaimsApi::PowerOfAttorneySerializer\n end", "def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def test_create_a_task_with_valid_attributes\n post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1 } } # post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1, status_id: 1 } }\n assert_equal 1, Task.count # count is a method that ActiveRecord gives us\n assert_equal 200, last_response.status\n assert_equal \"created!\", last_response.body\n end", "def postEntityBackground( entity_id, number_of_employees, turnover, net_profit, vat_number, duns_number, registered_company_number)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number_of_employees'] = number_of_employees\n params['turnover'] = turnover\n params['net_profit'] = net_profit\n params['vat_number'] = vat_number\n params['duns_number'] = duns_number\n params['registered_company_number'] = registered_company_number\n return doCurl(\"post\",\"/entity/background\",params)\n end", "def test_concurrent_requests_to_same_url_different_http_method\n delay = $config[\"nginx\"][\"proxy_read_timeout\"] - 1\n assert_operator(delay, :>, 0)\n\n start_time = Time.now.utc\n\n get_thread = Thread.new do\n Thread.current[:response] = Typhoeus.get(\"http://127.0.0.1:9080/api/delay-sec/#{delay}\", http_options)\n end\n\n # Wait 1 second to ensure the first GET request is fully established to the\n # backend.\n sleep 1\n\n post_thread = Thread.new do\n Thread.current[:response] = Typhoeus.post(\"http://127.0.0.1:9080/api/delay-sec/#{delay}\", http_options)\n end\n\n get_thread.join\n post_thread.join\n total_time = Time.now.utc - start_time\n\n assert_response_code(200, get_thread[:response])\n assert_response_code(200, post_thread[:response])\n\n # Sanity check to ensure the 2 requests were made in parallel and\n # overlapped.\n assert_operator(get_thread[:response].total_time, :>=, delay - BUFFER_TIME_LOWER)\n assert_operator(get_thread[:response].total_time, :<, delay + BUFFER_TIME_UPPER)\n assert_operator(post_thread[:response].total_time, :>=, delay - BUFFER_TIME_LOWER)\n assert_operator(post_thread[:response].total_time, :<, delay + BUFFER_TIME_UPPER)\n assert_operator(total_time, :>=, delay + 1 - BUFFER_TIME_LOWER)\n assert_operator(total_time, :<, delay + (BUFFER_TIME_UPPER * 2))\n assert_operator(total_time, :<, (delay * 2) - 1)\n end", "def postBusinessJsonProcess( entity_id, json)\n params = Hash.new\n params['entity_id'] = entity_id\n params['json'] = json\n return doCurl(\"post\",\"/business/json/process\",params)\n end", "def update\n respond_to do |format|\n if @slow_thing.update(slow_thing_params)\n\n domain = URI(root_url)\n Net::HTTP.start(domain.host, domain.port) do |http|\n Rails.logger.debug \"purging #{domain}\"\n http.request( Purge.new(domain) )\n\n Rails.logger.debug \"purging #{slow_things_url}\"\n http.request( Purge.new(URI(slow_things_url)) )\n\n Rails.logger.debug \"purging #{slow_thing_url(@slow_thing)}\"\n http.request( Purge.new(URI(slow_thing_url(@slow_thing))) )\n end\n\n format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @slow_thing }\n else\n format.html { render :edit }\n format.json { render json: @slow_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def postEntityBulkJson( data)\n params = Hash.new\n params['data'] = data\n return doCurl(\"post\",\"/entity/bulk/json\",params)\n end", "def build_body(metric, timestamp, value)\n {\n \"metric\" => metric,\n \"timestamp\" => timestamp,\n \"value\" => value,\n \"tags\" => { \"status\" => \"test\" }\n }.to_json\nend", "def post_request(device_id, epoch_time)\n uri = URI.parse(BASE_URL)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = false\n request = Net::HTTP::Post.new(\"/#{device_id}/#{epoch_time}\")\n response = http.request(request)\n response.code == \"200\"\nend", "def create\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\n if @timing.save\n render json: @timing\n else\n render json: { error: 'error: could not save timing' }\n end\n end", "def post(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend", "def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def do_post host, jsonArray_data\n (jsonArray_data).each do |data|\n\n @no_hits +=1\n\n index = data['_index']\n type = data['_type']\n id = data['_id']\n source= data['_source'].to_json\n\n esUri = URI.parse 'http://'+host+'/'+index+'/'+type+'/'+id\n http = Net::HTTP.new(esUri.host, esUri.port)\n response = http.post(esUri.path, source)\n\n if (response.code.to_i > 400)\n puts \"Error posting to: \" + esUri.to_s + \", source_object: \" + data.to_json\n end\n\n case\n when @total_hits_to_import.to_i/4 == @no_hits\n puts \"Imported 25%\"\n when @total_hits_to_import.to_i/2 == @no_hits\n puts \"Imported 50%\"\n when (@total_hits_to_import.to_i*3)/4 == @no_hits\n puts \"Imported 75%\"\n end\n end\nend", "def create\n @thing = current_user.things.new(params[:thing])\n\n respond_to do |format|\n if @thing.save\n format.html { redirect_to things_path }\n format.json { render json: @thing, status: :created, location: @thing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def postSignal( entity_id, country, gen_id, signal_type, data_type, inactive_reason, inactive_description, feedback)\n params = Hash.new\n params['entity_id'] = entity_id\n params['country'] = country\n params['gen_id'] = gen_id\n params['signal_type'] = signal_type\n params['data_type'] = data_type\n params['inactive_reason'] = inactive_reason\n params['inactive_description'] = inactive_description\n params['feedback'] = feedback\n return doCurl(\"post\",\"/signal\",params)\n end", "def thing_params\n params.require(:thing).permit(:name, :thing_id, :created_at, :updated_at)\n end", "def request(state)\n case state\n\n when :start\n puts 'got to request, case \"start\"'\n jdata = JSON.generate({sprinkle_agent_id: @sprinkle_agent_id, state: 1, key: @key})\n puts \"jdata --> #{jdata}\"\n RestClient.put \"http://#{@host_with_port}/sprinkles/1\", jdata, {:content_type => :json}\n\n when :stop\n jdata = JSON.generate({sprinkle_id: @sprinkle_id, state: 'stop', key: @key})\n puts \"jdata --> #{jdata}\"\n # RestClient.put \"http://#{@host_with_port}/sprinkle_agents/1\", jdata, {:content_type => :json}\n end\n end", "def test_send_long()\n # Parameters for the API call\n value = 5147483647\n\n # Perform the API call through the SDK function\n result = self.class.controller.send_long(value)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 200)\n\n # Test whether the captured response is as we expected\n assert_not_nil(result)\n expected_body = JSON.parse('{\"passed\":true}')\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def submit\n \n # check if user is blacklisted\n\t\tblacklist_entry = IpBlacklist.find_by_ip_address(request.remote_ip)\n\t\tif blacklist_entry\n\t\t\tif blacklist_entry.status == 0\n\t\t\t\trender json: {:status => \"blacklisted\", :name => blacklist_entry.user_name}\n\t\t\t\treturn\n elsif blacklist_entry.status == 2\n @boost = true\n elsif blacklist_entry.status == 3\n @solo = true\n end\n\t\tend\n \n # check if someone is soloing\n solo_entry = IpBlacklist.find_by_status(3)\n if solo_entry\n if solo_entry.ip_address != request.remote_ip\n render json: {:status => \"solo\", :name => solo_entry.user_name}\n return\n end\n end\n\n c = Suggestion.where(\"status = 1 AND avatar_id = :avatar_id AND voting_started_at > :limit\", :avatar_id => suggestion_params[:avatar_id], :limit => 1.minute.ago.to_i).count \n logger.debug c\n if c >= Setting.first.num_display_suggestions - 1\n render json: {:status => \"full\"}\n return\n end\n \n # create a new suggestion\n\t\t@suggestion = Suggestion.new(\n\t\t\t\t:time_string => Time.now.to_i,\n :voting_started_at => Time.now.to_i,\n\t\t\t\t:content => suggestion_params[:content], \n\t\t\t\t:name => suggestion_params[:name],\n\t\t\t\t:avatar_id => suggestion_params[:avatar_id],\n\t\t\t\t:user_hash => cookies['user_hash'],\n\t\t\t\t:score => 0,\n\t\t\t\t:status => 1, # go directly to voting\n\t\t\t\t:ip_address => request.remote_ip\n\t\t) \n\n if suggestion_params[:name] == \"\"\n @suggestion.name = \"Gast\"\n end\n\n if @boost # boost, go directly to transmit\n boost_suggestion(@suggestion)\n\t\tend\n\n if @solo \n @suggestion.name2 = \"solo\"\n end\n\n\t\tif @suggestion.save\n Pusher.trigger('chez_ois_chat', 'update_suggestions_' + suggestion_params[:avatar_id], load_suggestions(suggestion_params[:avatar_id]))\n\n # check in after timeout seconds and retire suggestion\n Thread.new(@suggestion.id, params) do |id, params|\n logger.debug \"starting vote countdown thread\"\n sleep 60\n suggestion = Suggestion.find(id)\n if suggestion.status == 1\n logger.debug \"retiring suggestion that didn't reach the top\"\n retire_suggestion(suggestion, params)\n end\n ActiveRecord::Base.connection.close\n logger.debug \"closing thread\"\n end\n\n #Pusher['chez_ois_chat'].trigger('update_suggestions_' + suggestion_params[:avatar_id], load_suggestions(params[:avatar_id]))\n if @boost\n render json: {:status => \"boost\"}\n else\n\t\t\t render json: @suggestion\n end\n \tend\n end", "def create\n @task = Task.new(task_params)\n @task.save\n render json: full_task(@task)\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def index\n # sleep 3 # simulate a slow connection\n render json: Secret.all.reverse\n end", "def log(data)\n t = Thread.new do\n uri = URI(\"http://logs-01.loggly.com/inputs/.../tag/ost/\")\n req = Net::HTTP::Post.new(uri)\n req['content-type'] = \"content-type:application/x-www-form-urlencoded\"\n req.body = data.to_json\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n end\nend", "def create\n @litter = Litter.new(params[:litter])\n @pig = Pig.find(@litter.sow_id)\n @no_of_piglets = params[:no_of_piglets].to_i\n \n @no_of_piglets.times do\n Pig.create(name: @pig.name + ' piglet', status: alive_id, dob: Time.now, litter: @litter)\n end\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to @litter, notice: 'Litter was successfully created with ' + @no_of_piglets.to_s + ' piglets' }\n format.json { render json: @litter, status: :created, location: @litter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_thing( thing )\n data = {\n token: @applicationToken,\n name: thing.name,\n display_name: thing.display_name\n }\n if( thing.product_type.length > 0 )\n data[:product_type] = thing.product_type\n end\n\n @httpHelper.post_data( 'thing', data )\n end", "def create\n @fast = Fast.new(fast_params)\n\n respond_to do |format|\n if @fast.save\n format.html { redirect_to @fast, notice: 'Fast was successfully created.' }\n format.json { render action: 'show', status: :created, location: @fast }\n else\n format.html { render action: 'new' }\n format.json { render json: @fast.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n reading_id = Reading.generate_id\n params.delete :action\n params.delete :controller\n params.merge!(\"thermostat_id\" => @thermostat.id)\n $redis.set(reading_id, params)\n CreateReadingWorker.perform_async(params, reading_id)\n render json: {reading_id: reading_id}\n end", "def buy_food(id,food_units)\r\n my_port = 8082\r\n store_message = \"/store/#{id}/#{$light}/#{$suit}/#{$wealth}/#{$sword}/#{$amulet}/#{$axe}/#{$food}/#{food_units}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{store_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n\r\n $light = my_json['light']\r\n $suit = my_json['suit']\r\n $wealth = my_json['wealth']\r\n $sword = my_json['sword']\r\n $amulet = my_json['amulet']\r\n $axe = my_json['axe']\r\n $food = my_json['food']\r\n puts(\"#{my_json['text']}\\n\")\r\nend", "def http_post(url, data)\n\turi = URI(url)\n\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n req.body = data.to_json\n response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n return response\nend", "def test_send_long()\n # Parameters for the API call\n value = 5147483647\n\n # Perform the API call through the SDK function\n result = @controller.send_long(value)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_backend_remains_in_rotation_after_timeouts\n timeout_hydra = Typhoeus::Hydra.new\n timeout_requests = Array.new(50) do\n delay = $config[\"nginx\"][\"proxy_connect_timeout\"] + 5\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/delay-sec/#{delay}\", http_options)\n timeout_hydra.queue(request)\n request\n end\n timeout_hydra.run\n\n info_hydra = Typhoeus::Hydra.new\n info_requests = Array.new(50) do\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/info/\", http_options)\n info_hydra.queue(request)\n request\n end\n info_hydra.run\n\n assert_equal(50, timeout_requests.length)\n timeout_requests.each do |request|\n assert_response_code(504, request.response)\n end\n\n assert_equal(50, info_requests.length)\n info_requests.each do |request|\n assert_response_code(200, request.response)\n end\n end", "def api_request(name) \n\tresponse = HTTParty.post('https://api.talentiq.co/v2/person', \n :body => {:name => name }.to_json,\n :headers => { 'Content-Type' => 'application/json', \n \t\t\t'x-api-key:' => 'e058cdd334c69c31d45d87e44b405d128a9e8937939e7d0ab2496334',\n 'Accept' => 'application/json' })\n puts response.body\nend", "def create\n start_time = Time.now\n cpu_cores_number = check_cpu\n do_something(cpu_cores_number)\n end_time = Time.now\n @post = Post.new(body: end_time - start_time, title: \"cores were used: #{cpu_cores_number}\")\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_post_invalid\n header 'Content-Type', 'application/json'\n\n json = JSON.generate [{ latitude: 'wrong', longitude: 'wrong' }]\n post('/traces', json, 'CONTENT_TYPE': 'application/json')\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def post; end", "def do_request_and_write_response(times)\n File.open('response_log.txt', 'a+') do |file|\n (1..times).each do |iteration|\n response = do_request_to_slowapi\n file.puts(\"response_#{iteration}: \" + response.body)\n end\n puts 'Done!'\n return true\n end\n end", "def create_new_recipe2 user_id, user_name, params\n recipe = Recipe.new\n recipe.name = params[:recipe_name]\n recipe.create_time = Time.now().to_i\n recipe.user_id = user_id\n recipe.user_name = user_name\n recipe.picture = \"uploads/user#{user_id}recipe#{recipe.create_time}.jpg\" if params[:recipe_file] != nil\n raise Error::CreateRecipeError, recipe.errors.messages.values[0][0] unless recipe.save\n\n threads = []\n if params[:recipe_file] != nil\n threads << Thread.new { File.open(\"public/#{recipe.picture}\", \"wb\") { |file| file.write params[:recipe_file][:tempfile].read } }\n end\n\n ingredients = JSON.parse params[:ingredients]\n ingredients.length.times do |i|\n Ingredient.create(name: ingredients[i][\"name\"], recipe_id: recipe.id, amount: ingredients[i][\"amount\"])\n end\n\n steps = params[:steps].to_i\n steps_text = JSON.parse params[:steps_text]\n steps.times do |i|\n step = Step.new(recipe_id: recipe.id, index: i+1, content: steps_text[i])\n if (params[\"steps_file#{i+1}\"] != nil)\n step.picture = \"uploads/recipe#{recipe.id}step#{i+1}.jpg\"\n threads << Thread.new { File.open(\"public/#{step.picture}\", \"wb\") { |file| file.write params[\"steps_file#{i+1}\"][:tempfile].read } }\n end\n step.save\n end\n\n recipe\n end", "def post_as_json(data)\n uri = URI.parse(LISTENER)\n http = Net::HTTP.new(uri.host, uri.port)\n http.read_timeout = 0.5\n begin\n request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})\n request.body = data.to_json\n http.request(request){|res| puts \"Post status: #{res.body}\" }\n rescue StandardError => e\n puts \"Failed sending data: #{e.message}\"\n end\nend", "def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end", "def api_post(endpoint, key, data)\n tries ||= 3\n response = do_post(endpoint, key, data)\n raise unless response.code == '200'\n return if response.body.empty?\n parsed = Oj.load(response.body)\n raise unless parsed['success']\n parsed['data']\n rescue StandardError => e\n tries -= 1\n sleep 2 && retry unless tries.zero?\n log_error(e, update_service: @update_service,\n sentry_extra: { query: data,\n response_body: response&.body,\n language: @wiki.language,\n project: @wiki.project })\n end", "def fire_post(url_or_path, entity, options = {}, &block)\n url = absolute_url(url_or_path)\n headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON}.\n merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n body = encode_entity(entity)\n response = Typhoeus::Request.post(url, headers: headers, timeout: timeout, body: body)\n handle_response(response, method: :post, url: url, default_data: options[:default_data],\n raise_on_error: options[:raise_on_error], &block)\n end", "def five_hundred(_error)\n json_response({ message: Message.something_went_wrong }, :internal_server_error)\n end", "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def post_to_tumblr(options={})\n tries = 3\n if options[:type] && options[:date] && options[:source] && options[:caption] && options[:state]\n tags = options[:tags]\n begin\n response = Curl::Easy.http_post(\"#{@api_endpoint_tumblr}/api/write\", \n Curl::PostField.content('generator', GENERATOR),\n Curl::PostField.content('email', @email), \n Curl::PostField.content('password', @password),\n Curl::PostField.content('type', options[:type]),\n Curl::PostField.content('date', options[:date]),\n Curl::PostField.content('source', options[:source]),\n Curl::PostField.content('caption', options[:caption]),\n Curl::PostField.content('state', options[:state]),\n Curl::PostField.content('tags', tags)\n )\n rescue Curl::Err => err\n @log.error \"Failure in Curl call: #{err}\"\n tries -= 1\n sleep 3\n if tries > 0\n retry\n else\n response = nil\n end\n end\n end\n response\n end", "def POST; end", "def create_task\n\n #Assign url\n url=\"https://api.scaleapi.com/v1/task/phonecall\"\n\n #Auth credentials setup\n auth = {:username=>ENV[\"SCALE_API_KEY\"], :password=>\"\"}\n \n #Assign headers\n headers = {\"Content-Type\"=>\"application/json\"}\n\n #Create payload\n params = {callback_url: 'https://mysterious-ridge-35983.herokuapp.com/survey_callback',\n instruction: \"Call this person and ask him his calorie counts for yesterday and the number of coffees he drank. Then, ask him if he took his morning and evening medications.\",\n script: \"Hey! (pause) How many calories did you eat yesterday? (pause) What about protein grams (pause)?\"\\\n \" What about carbohydrate grams (pause)? What about fat grams (pause)? What about fiber grams (pause)?\"\\\n \" How many coffees did you drink (pause)? Did your take your morning and evening meds (pause)?\",\n phone_number: ENV[\"PHONE_NUMBER\"],\n entity_name: ENV[\"OWNER_NAME\"],\n fields: { total_calories: 'Total Calories',\n protein_grams: 'Protein Grams',\n carbohydrate_grams: 'Carbohydrate Grams',\n fiber_grams: 'Fiber Grams',\n fat_grams: 'Fat Grams',\n number_of_coffees: 'Coffees per Day'},\n urgency: \"immediate\",\n choices: ['only_took_morning_meds', 'only_took_evening_meds', 'took_both_morning_and_evening','no_meds_taken']}\n\n #Send request\n begin\n\n request=HTTParty.post(url,:basic_auth=>auth, :headers=> headers, :body=>params.to_json)\n\n #Receive request and store response\n self.scale_api_id=request[\"task_id\"]\n self.json_data=JSON.dump(request)\n\n rescue\n\n #If there's an error, raise an exception to prevent DailySurvey object being created\n raise \"Bad Scale API request\"\n \n end\n \n end", "def create\n @potluck_recipe = PotluckRecipe.new(potluck_recipe_params)\n if @potluck_recipe.save\n render json: {result: @potluck_recipe}\n else\n render json: { result: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end", "def slowlogext_params\n params.require(:slowlogext).permit(:name, :key, :duration, :date, :value)\n end", "def do_POST(request, response)\n\n content_type = request['Content-Type']\n\n # For JSON, pull the instructions from the body. Otherwise, take them from the query string.\n if content_type == 'application/json'\n body = JSON.parse(request.body)\n delay_ms = body['delay_ms']\n status = body['status']\n else\n query = Rack::Utils.parse_nested_query(request.query_string)\n delay_ms = query['delay_ms']\n status = query['status']\n end\n\n reflect response, delay_ms, status\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n $logger.error msg\n response.status = 418\n rescue StandardError => e\n $logger.error \"Invalid request: #{e.message}\"\n response.status = 500\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend", "def create\n @tarot_bot = TarotBot.new(tarot_bot_params)\n\n if @tarot_bot.save\n render json: { status: :ok }\n else\n render json: { status: :internal_server_error }\n end\n end", "def create\n reading_id = Reading.next_sequence_id\n params.merge!(\"thermostat_id\" => @thermostat.id)\n $redis.set(reading_id, params)\n ::BackgroundWorker::CreateReading.perform(params, reading_id)\n render status: 200, :json=>{:sequence_id => reading_id} and return\n end", "def create\n #sleep 1\n @user = User.new(user_params)\n @user.save\n #sleep 1\n respond_with @user\n end", "def submit(verb, data)\n start do |connection|\n request = http verb\n request.body = data\n connection.request request\n end\n end", "def create\n GpsJob.perform_later(request_params)\n head(:ok)\n end", "def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end", "def snooze!\n log \"Sending #{@method} to Snooze.io\"\n handle_post_response { Snooze::Post.send(@method, @clock_id) }\n end" ]
[ "0.59808415", "0.58987194", "0.5499058", "0.54937506", "0.5456881", "0.54096574", "0.53225213", "0.5315783", "0.5288149", "0.5279808", "0.5272885", "0.52636254", "0.52452856", "0.52263284", "0.5198195", "0.51827645", "0.5175397", "0.5158314", "0.5157859", "0.515723", "0.51291025", "0.5118878", "0.51172745", "0.5114913", "0.50838894", "0.5083887", "0.50568557", "0.5045065", "0.5041912", "0.50418824", "0.50411636", "0.50332296", "0.50032556", "0.49732152", "0.49636006", "0.495952", "0.49567932", "0.495569", "0.4951246", "0.4948874", "0.49436635", "0.49233687", "0.49225837", "0.4918095", "0.48999286", "0.48958692", "0.48936766", "0.48899826", "0.488787", "0.48853052", "0.48812106", "0.48753947", "0.4873568", "0.4867752", "0.48634738", "0.48614883", "0.48574546", "0.48544464", "0.4854228", "0.48479754", "0.48451215", "0.48444957", "0.48380756", "0.48360327", "0.48252076", "0.4820081", "0.48165455", "0.4810748", "0.48104322", "0.48084843", "0.48082826", "0.47991255", "0.47953588", "0.47892404", "0.4789116", "0.47871912", "0.477193", "0.47707182", "0.47636652", "0.47596958", "0.4756353", "0.47547147", "0.47485802", "0.47458762", "0.47418138", "0.47405684", "0.47399795", "0.47388914", "0.47328094", "0.47326306", "0.47320774", "0.47302082", "0.47292018", "0.47244802", "0.4723611", "0.4717185", "0.4715614", "0.47155225", "0.47144267", "0.4711552" ]
0.6336423
0
PATCH/PUT /slow_things/1 PATCH/PUT /slow_things/1.json
def update respond_to do |format| if @slow_thing.update(slow_thing_params) domain = URI(root_url) Net::HTTP.start(domain.host, domain.port) do |http| Rails.logger.debug "purging #{domain}" http.request( Purge.new(domain) ) Rails.logger.debug "purging #{slow_things_url}" http.request( Purge.new(URI(slow_things_url)) ) Rails.logger.debug "purging #{slow_thing_url(@slow_thing)}" http.request( Purge.new(URI(slow_thing_url(@slow_thing))) ) end format.html { redirect_to @slow_thing, notice: 'Slow thing was successfully updated.' } format.json { render :show, status: :ok, location: @slow_thing } else format.html { render :edit } format.json { render json: @slow_thing.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def patch!\n request! :patch\n end", "def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend", "def patch(path, **args); end", "def put!\n request! :put\n end", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update\n @thing = current_user.things.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def patch_model dataset_id, model_id, patched_model_gapi, etag = nil\n patch_with_backoff = false\n options = { skip_deserialization: true }\n if etag\n options[:header] = { \"If-Match\" => etag }\n # The patch with etag operation is considered idempotent\n patch_with_backoff = true\n end\n execute backoff: patch_with_backoff do\n json_txt = service.patch_model @project, dataset_id, model_id, patched_model_gapi, options: options\n JSON.parse json_txt, symbolize_names: true\n end\n end", "def fire_patch(url_or_path, entity, options = {}, &block)\n url = absolute_url(url_or_path)\n headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON_PATCH}.\n merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n body = encode_entity(entity)\n response = Typhoeus::Request.run(url, headers: headers, timeout: timeout, body: body, method: :patch)\n handle_response(response, method: :patch, url: url, default_data: options[:default_data],\n raise_on_error: options[:raise_on_error], &block)\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n if @stuff.update_attributes(params[:stuff])\n format.html { redirect_to @stuff, :notice => 'Stuff was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @stuff.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def patch\n end", "def patch(action, **args); end", "def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @microtask = Microtask.find(params[:id])\n\n respond_to do |format|\n if @microtask.update_attributes(params[:microtask])\n format.html { redirect_to @microtask, notice: 'Microtask was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microtask.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @awesome_stuff.update(awesome_stuff_params)\n format.html { redirect_to @awesome_stuff, notice: 'Awesome stuff was successfully updated.' }\n format.json { render :show, status: :ok, location: @awesome_stuff }\n else\n format.html { render :edit }\n format.json { render json: @awesome_stuff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @interesting_thing.update(interesting_thing_params)\n format.html { redirect_to student_interesting_things_path(@student), notice: 'Interesting thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @interesting_thing }\n else\n format.html { render :edit }\n format.json { render json: @interesting_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Patch.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend", "def update\n respond_to do |format|\n if @fast.update(fast_params)\n format.html { redirect_to @fast, notice: 'Fast was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fast.errors, status: :unprocessable_entity }\n end\n end\n end", "def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors do\n result = model.find_by_id(params[:id])\n halt 404 if result.nil?\n json result\n end\n end\n\n post \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.create(@json_payload) }\n end\n\n patch \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.update(params[:id], @json_payload) }\n end\n\n delete \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { model.delete(params[:id]) }\n end\n\n private\n def catch_errors()\n begin\n yield\n rescue Exception => e\n logger.fatal(\"Exception: #{e}\")\n status 500\n json({'error' => e})\n end\n end\nend", "def update_pet_with_http_info(pet, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.update_pet ...'\n end\n # verify the required parameter 'pet' is set\n if @api_client.config.client_side_validation && pet.nil?\n fail ArgumentError, \"Missing the required parameter 'pet' when calling PetApi.update_pet\"\n end\n # resource path\n local_var_path = '/pet'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/xml'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(pet)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.update_pet\",\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#update_pet\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update_job(job:)\n response = HTTParty.put(\"#{@host}/api/jobs/#{job[:id]}\", body: {job: job, api_key: @api_key})\n \n return response.success?\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def patch; end", "def patch; end", "def update\n respond_to do |format|\n if @task.update(task_params)\n @task.whenever_reset unless task_params[:every].blank? && task_params[:at].blank?\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end", "def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end", "def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end", "def update\n task = Task.find(params[:id])\n if task.update(task_params)\n render json: task\n else\n render_errors(task)\n end\n end", "def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_to_do }\n else\n format.html { render :edit }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n flash[:notice] = 'Thing was successfully updated.'\n format.html { redirect_to(@thing) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def update\n head :ok\n end", "def patch(*args, &block); end", "def update\n respond_to do |format|\n if @clothing.update(clothing_params)\n format.html { redirect_to @clothing, notice: 'Clothing was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing }\n else\n format.html { render :edit }\n format.json { render json: @clothing.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n respond_to do |format|\n if @slowlogext.update(slowlogext_params)\n format.html { redirect_to @slowlogext, notice: 'Slowlogext was successfully updated.' }\n format.json { render :show, status: :ok, location: @slowlogext }\n else\n format.html { render :edit }\n format.json { render json: @slowlogext.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update\n respond_to do |format|\n if @some_thing.update(some_thing_params)\n format.html { redirect_to @some_thing, notice: 'Some thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @some_thing }\n else\n format.html { render :edit }\n format.json { render json: @some_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @anything.update(anything_params)\n format.html { redirect_to @anything, notice: 'Anything was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @anything.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update!(sobject, attrs)\n id = attrs.has_key?(:Id) ? attrs.delete(:Id) : attrs.delete('Id')\n raise 'Id field missing.' unless id\n api_patch \"sobjects/#{sobject}/#{id}\", attrs\n true\n end", "def update\n @thing = Thing.find(params[:id])\n params[:thing][:place_id] = place_id_from_form\n params[:thing][:owner_ids] = [ ] if params[:thing][:owner_ids].nil?\n params[:thing][:keeper_ids] = [ ] if params[:thing][:keeper_ids].nil?\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to(@thing, :notice => 'Thing was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @something = Something.find(params[:id])\n\n respond_to do |format|\n if @something.update_attributes(params[:something])\n format.html { redirect_to @something, notice: 'Something was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @something.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @wait = Wait.find(params[:id])\n\n respond_to do |format|\n if @wait.update_attributes(params[:wait])\n format.json { head :no_content }\n else\n format.json { render json: @wait.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stuck.update(stuck_params)\n format.html { redirect_to @stuck, notice: 'Stuck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stuck.errors, status: :unprocessable_entity }\n end\n end\n end", "def partial_update_object(object, objectID = nil, create_if_not_exits = true, request_options = {})\n client.post(Protocol.partial_object_uri(name, get_objectID(object, objectID), create_if_not_exits), object.to_json, :write, request_options)\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(uri, options = T.unsafe(nil)); end", "def patch(url, options = {}, &block)\n request HttpPatch, url, options, &block\n end", "def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def update\n byebug\n respond_to do |format|\n if @job.update(send(\"#{@job.type.underscore.to_sym}_params\"))\n format.html { redirect_to @job, notice: 'Job was successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def patch\n req.patch?\n end", "def update\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n if @jetty.update_attributes(params[:jetty])\n format.html { redirect_to @jetty, notice: 'Jetty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jetty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @operation.update(operation_params)\n format.html { redirect_to @operation, notice: 'Operation was successfully updated.' }\n format.json { render :json => @operation.to_json(:include => :task) }\n else\n format.html { render json: @operation.errors, status: :unprocessable_entity }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n if @thing_with_error.update_attributes(params[:thing_with_error])\n format.html { redirect_to @thing_with_error, notice: 'Thing with error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing_with_error.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.61767423", "0.6167336", "0.60733217", "0.5991576", "0.5977999", "0.5906642", "0.58816624", "0.5870645", "0.5865846", "0.5850524", "0.5814966", "0.5812773", "0.5788376", "0.5788376", "0.5788376", "0.5770086", "0.5765108", "0.5759052", "0.57523924", "0.5696049", "0.5691312", "0.5691312", "0.5682493", "0.567292", "0.567292", "0.5667716", "0.562644", "0.5606528", "0.5594858", "0.55863905", "0.55823106", "0.5580131", "0.5578282", "0.5566695", "0.556188", "0.55475867", "0.55455995", "0.55355525", "0.5533362", "0.5516145", "0.5515762", "0.5505933", "0.55023235", "0.55018747", "0.54948527", "0.5493379", "0.5488723", "0.54866123", "0.54862845", "0.5476332", "0.54592454", "0.54592454", "0.5448919", "0.5448194", "0.5438591", "0.5420285", "0.5420285", "0.54190767", "0.5416675", "0.5416128", "0.5411315", "0.5407276", "0.54024345", "0.53968376", "0.539499", "0.53928345", "0.53924316", "0.5387844", "0.5387557", "0.5386586", "0.5381094", "0.5381094", "0.5381094", "0.5381094", "0.53802127", "0.537093", "0.5365427", "0.5363059", "0.5362949", "0.5362949", "0.53571224", "0.53524566", "0.5350156", "0.534939", "0.5349359", "0.5347882", "0.53373945", "0.5329762", "0.53277504", "0.5323273", "0.5318804", "0.53182256", "0.53168017", "0.5309703", "0.53046745", "0.5302647", "0.5293511", "0.5287269", "0.5285086", "0.5283177" ]
0.6187133
0
DELETE /slow_things/1 DELETE /slow_things/1.json
def destroy @slow_thing.destroy respond_to do |format| format.html { redirect_to slow_things_url, notice: 'Slow thing was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to things_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to things_url }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete(*rest) end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuff_index_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete!\n request! :delete\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @thing.destroy\n respond_to do |format|\n format.html { redirect_to things_url, notice: 'The thing was deleted.' }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to(things_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n @stuff = Stuff.find(params[:id])\n @stuff.destroy\n\n respond_to do |format|\n format.html { redirect_to stuffs_url }\n format.json { head :ok }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n if @short_url.destroy\n render json: { status: \"Deleted\" }\n else\n render json: { head: \"no content\" }\n end \n end", "def destroy\n # @thing.destroy\n # respond_to do |format|\n # format.html { redirect_to things_url, notice: 'Thing was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @fast.destroy\n respond_to do |format|\n format.html { redirect_to fasts_url }\n format.json { head :no_content }\n end\n end", "def hard_delete(id, force = false)\n uri = \"#{endpoint}/#{id}/hard_delete\"\n uri = \"#{uri}?force=true\" if force\n @http.delete(uri)\n end", "def destroy\n @thing = current_user.things.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to things_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete(id)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\"\n return HTTParty.delete(url, :timeout => 4)\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n request(:delete)\n end", "def delete!(*rest) end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to(highscore_brands_url) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @thing_to_do.destroy\n respond_to do |format|\n format.html { redirect_to thing_to_dos_url }\n format.json { head :no_content }\n end\n end", "def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend", "def test_delete1()\n key = \"_Delete1\"\n c = Scalaroid::JSONConnection.new(url = Scalaroid::DEFAULT_URL)\n rdht = Scalaroid::ReplicatedDHT.new(conn = c)\n sc = Scalaroid::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n\n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n\n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n\n c.close()\n end", "def destroy\n @something = Something.find(params[:id])\n @something.destroy\n\n respond_to do |format|\n format.html { redirect_to somethings_url }\n format.json { head :no_content }\n end\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end", "def destroy\n @serving = Serving.find(params[:id])\n @serving.destroy\n\n respond_to do |format|\n format.html { redirect_to servings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_stuff.destroy\n respond_to do |format|\n format.html { redirect_to test_stuffs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @thirtyone.destroy\n respond_to do |format|\n format.html { redirect_to thirtyones_url }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n request(:delete, *args)\n end", "def delete\n api_client.delete(url)\n end", "def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end", "def delete(thing)\n if thing.is_a? Integer\n @index = @index.delete_if {|idx| idx.r_id == thing }\n @records = @records.delete_if {|idx, data| idx == thing }\n else\n if thing.respond_to?(:r_id)\n r_id = thing.r_id\n @index = @index.delete_if {|idx| idx.r_id == r_id }\n @records = @records.delete_if {|idx, data| data == thing}\n end\n end\n res_index = @header.resource_index\n res_index.number_of_records = @index.length\n @header.resource_index = res_index\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete\n render json: Like.delete(params[\"id\"])\n end", "def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end", "def delete\n \n end", "def destroy\n @slowlogext.destroy\n respond_to do |format|\n format.html { redirect_to slowlogexts_url, notice: 'Slowlogext was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end", "def test_delete_post\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Delete.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @massive_load = MassiveLoad.find(params[:id])\n @massive_load.destroy\n\n respond_to do |format|\n format.html { redirect_to massive_loads_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def destroy\n @wait = Wait.find(params[:id])\n @wait.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete\n\n end", "def delete(url)\n do_request(\"delete\", url)\n end", "def destroy\n @thirtytwo.destroy\n respond_to do |format|\n format.html { redirect_to thirtytwos_url }\n format.json { head :no_content }\n end\n end", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def destroy\n @thing_to_do.destroy\n respond_to do |format|\n format.html { redirect_to thing_to_dos_url, notice: 'Thing to do was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete(path, opts = {})\n request(:delete, path, opts).body\n end", "def destroy\n @microtask = Microtask.find(params[:id])\n @microtask.destroy\n\n respond_to do |format|\n format.html { redirect_to microtasks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shot = Shot.find(params[:id])\n @shot.destroy\n\n respond_to do |format|\n format.html { redirect_to shots_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def test_valid_delete_returns_204\n db = DB.get\n\n valid_entry = SEED_ENTRIES.first\n insert_entry(db, valid_entry)\n\n assert_equal 1, db.execute('select * from entries').count\n\n delete \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.no_content?\n\n assert_equal 0, db.execute('select * from entries').count\n end", "def destroy\n @mostsmallresource = Mostsmallresource.find(params[:id])\n @mostsmallresource.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallresources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def testDelete1()\n key = \"_Delete1\"\n c = Scalaris::JSONConnection.new(url = Scalaris::DEFAULT_URL)\n rdht = Scalaris::ReplicatedDHT.new(conn = c)\n sc = Scalaris::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n \n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n \n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n \n c.close()\n end", "def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end", "def destroy\n Todo.find(params[:id]).destroy\n render :json => {:message => \"Record deleted\", :item_id => params[:id]}\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def destroy\n @shorty = Shorty.find(params[:id])\n @shorty.destroy\n\n respond_to do |format|\n format.html { redirect_to shorties_url }\n format.json { head :ok }\n end\n end", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def delete\n end" ]
[ "0.6906653", "0.6830822", "0.6699254", "0.6637343", "0.6631996", "0.6631996", "0.6583462", "0.65665853", "0.65101385", "0.65005887", "0.64581996", "0.6431477", "0.6429327", "0.6394287", "0.6376216", "0.6370607", "0.6327913", "0.6327492", "0.6314071", "0.63041776", "0.63016164", "0.6300735", "0.62986475", "0.62823296", "0.62784874", "0.6267702", "0.6266653", "0.6262483", "0.625758", "0.62494636", "0.62353307", "0.6231171", "0.623022", "0.62277937", "0.62277937", "0.62223035", "0.6215882", "0.6203265", "0.619733", "0.6189082", "0.6185662", "0.61726016", "0.6168058", "0.6164524", "0.616346", "0.6160303", "0.61474353", "0.61474353", "0.61474353", "0.61474353", "0.61392987", "0.6137847", "0.61370647", "0.61366993", "0.6136115", "0.6131857", "0.6129438", "0.61215293", "0.610802", "0.61064553", "0.61062473", "0.6101413", "0.60949427", "0.60948795", "0.60937697", "0.60889924", "0.6085218", "0.607955", "0.60742444", "0.6074089", "0.60702944", "0.6066167", "0.6065977", "0.6065233", "0.60619956", "0.6056901", "0.60548496", "0.6050719", "0.60476786", "0.60406005", "0.6039946", "0.60339653", "0.60318106", "0.6031258", "0.60312384", "0.6028908", "0.60155445", "0.6012974", "0.6011627", "0.60102105", "0.6007978", "0.60072255", "0.5998406", "0.5997909", "0.5995354", "0.59937984", "0.5993546", "0.599321", "0.5992219", "0.59878945" ]
0.69605523
0
Use callbacks to share common setup or constraints between actions.
def set_slow_thing @slow_thing = SlowThing.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 slow_thing_params params.require(:slow_thing).permit(:name) 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
Preview this email at
def password_reset user = User.first user.reset_token = User.new_token UserMailer.password_reset(user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end", "def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end", "def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end", "def preview_email\r\n invitation = Invitation.new(:user => current_user, :code => Code.new)\r\n mail = Mailers::Debate.create_invitation(current_user, @resource, invitation)\r\n @mail_body = mail.body.sub('No message provided', 'YOUR PERSONALIZED NOTE GOES HERE')\r\n\r\n render :inline => %Q{<%= simple_format(@mail_body, {:style => 'margin: 8px 0px'}) %>}\r\n end", "def demo\n preview(DemoMailer.demo)\n end", "def demo\n preview(DemoMailer.demo)\n end", "def call(email, params = {})\n preview = new(params)\n message = preview.public_send(email)\n inform_preview_interceptors(message)\n message\n end", "def call(email)\n preview = self.new\n preview.public_send(email)\n end", "def preview_newsletter\n @newsletter = @structure.newsletters.friendly.find params[:id]\n\n # Send email to no recipients to generate mail object\n mail = NewsletterMailer.send_newsletter(@newsletter, nil)\n @body = MailerPreviewer.preview(mail)\n\n render layout: false\n end", "def preview\n task = MailTasks::Task.new( params[:task] )\n recipient = StoreUser.find( params[:id], :include => \"customer\", :readonly => true )\n mail = task.generate_mails( [recipient], false, mail_layout_options ).first\n render :text => mail.content_with_layout( mail_layout_options ), :layout => false\n # rescue => exception\n # headers[\"Content-Type\"] = \"text/plain\"\n # render :text => exception.to_yaml, :layout => false\n end", "def preview_to(recipient)\n @newsletter = build_newsletter\n mail = build_mail\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end", "def show_body\n I18n.with_locale @email_locale do\n @mail_body = mail_body(@preview, @part_type)\n render :show_body, layout: 'rails_email_preview/email'\n end\n end", "def process_explanation_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.process_explanation_mail(Petition.live.first)\n end", "def content_for_preview( layout_options )\r\n content = self.body.dup\r\n content.gsub!( /<%=\\s?(@[^%]+)\\s?%>/, '<code>\\1</code>' )\r\n mail = Mail.new( :token => \"\" )\r\n mail.content = Render::Base.new( content ).mail_content\r\n template = IO.read(\"#{RAILS_ROOT}/app/views/mail_tasks/mailer/this_mail.text.html.rhtml\")\r\n \r\n render = Render::Base.new( template, layout_options.merge( :mail => mail ) )\r\n render.mail_content\r\n end", "def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end", "def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end", "def preview\n end", "def preview\n end", "def show\n @decrypted = @autocrypt.decrypt(@email)\n @reply_params = {\n to: @email.from,\n subject: 'Re: ' + @email.subject,\n body: (@decrypted || @email.body).gsub(/^/, '> ')\n }\n end", "def preview\n attachments.first.file.url(:preview)\n rescue StandardError => exc\n logger.error(\"Message for the log file while retrieving preview #{exc.message}\")\n 'empty_file.png'\n end", "def preview\n redirect_to preview_url\n end", "def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end", "def preview_announcement(subject)\n frm.link(:text=>subject).click\n PreviewAnnouncements.new(@browser)\n end", "def show\n if @sent_email.photo.nil?\n @display_name = ''\n @title = ''\n @flickr_url = ''\n else\n @display_name = @sent_email.photo.member.display_name\n @title = @sent_email.photo.title\n @flickr_url = @sent_email.photo.get_flickr_url\n end\n end", "def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end", "def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end", "def send_preview(recipients, personalize=\"fallback\")\n options = { :body => {\n :PreviewRecipients => recipients.kind_of?(String) ? [ recipients ] : recipients,\n :Personalize => personalize }.to_json }\n response = post \"sendpreview\", options\n end", "def create\n @mail = Mail.new(params[:mail])\n @mail.user = current_user\n \n if params[:preview_button] || !@mail.save\n render :action => \"new\"\n else\n flash[:notice] = 'Mail was successfully created.'\n redirect_to(@mail)\n end\n end", "def last_message_preview=(value)\n @last_message_preview = value\n end", "def edit\n yield @editor\n @mail = @editor.mail\n @message = @mail.to_s\n end", "def preview_text\n return @preview_text\n end", "def preview_text\n return @preview_text\n end", "def preview\n return @preview\n end", "def inspect\n \"#<Envelope::Message to=#{formatted_to} from=#{formatted_from} cc=#{formatted_cc} bcc=#{formatted_bcc} reply_to=#{formatted_reply_to} subject=\\\"#{subject}\\\" text_part=\\\"#{preview = (text_part || html_part); (preview && preview.gsub(/\\s+/, ' ') || 'No preview available')[0..50]}...\\\">\"\n end", "def petition_announcement_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.petition_announcement_mail(Petition.live.first)\n end", "def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end", "def preview() @page.find(input_elements[:preview]) end", "def preview(channel_id, msg_id, data)\n channel_config, message_config, text =\n prepare_message(channel_id, msg_id, data)\n chats = channel_config.chat_ids\n connector = channel_config.connector\n\n if message_allowed?(message_config, data)\n connector.preview(chats, text, message_config)\n else\n puts \"No message sent beacuse it's not allowed\"\n end\n end", "def improve_and_reopen_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.improve_and_reopen_mail(Petition.live.first)\n end", "def hand_over_to_office_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.hand_over_to_office_mail(Petition.live.first)\n end", "def content_preview\n self.send(content_preview_method)\n end", "def write_about_hand_over_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.write_about_hand_over_mail(Petition.live.first)\n end", "def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end", "def preview=(value)\n @preview = value\n end", "def preview_path_for_attachment(attachment)\n preview_attachment_path(id: attachment.attachment_data.id, file: attachment.filename.split('.').first, extension: attachment.file_extension)\n end", "def preview(attachment, options)\n Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)\n end", "def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end", "def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end", "def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end", "def last_message_preview\n return @last_message_preview\n end", "def preview\n @preview ||= Preview.new(self) #if has_preview?\n end", "def tweet_reviewed_by_influencer(tweet)\n @tweet = tweet\n\n set_attachments\n\n mail(to: tweet.campaign.advertiser.user.email, subject: \"Notificaciones @ Social Target - Uno de tus tweets fue revisado/modificado por una empresa\")\n end", "def body_preview=(value)\n @body_preview = value\n end", "def preview\n content[0..19]\n end", "def view(review, recipient)\n @review = review\n\n mail(to: recipient.email, subject: \"#{@review.review_type == \"cto\" ? @review.booking.user.first_name : @review.booking.offer.user.first_name} vous a laissé un commentaire\")\n end", "def new_review_email (review)\n\t@book = review.book\n\t@review = review\n\tmail :to => @book.readers.collect{|r| r.email},\n\t :subject=>\"New review for #{@book.title}\"\n end", "def preview(element_key)\n parameter = { basic_auth: @auth }\n self.class.get(\"/elements/#{element_key}/preview\", parameter)\n end", "def open\n mail = MailTasks::Mail.find_by_token( params[:id] )\n raise ActiveRecord::RecordNotFound unless mail # raise 404 if mail is not found\n \n options = {\n :post_back_url => url_for( :controller => \"/email\", :action => \"red_logo\" ),\n :base => [request.protocol, request.host].join\n }\n render :text => mail.content_with_layout( options ), :layout => false\n end", "def emailOnMetareview(revieweeId)\r\n puts \"in Metareview\"\r\n participant = Participant.find_by_id(revieweeId).user_id\r\n asstId = Participant.find_by_id(revieweeId).parent_id\r\n user=User.find_by_id(participant)\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review_of_review\"\r\n if(user.email_on_review_of_review)\r\n email(user.email,\"Metareview\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end", "def body_preview\n return @body_preview\n end", "def preview(*)\n nil\n end", "def preview(*)\n nil\n end", "def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end", "def reference_number_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.reference_number_mail(Petition.live.first)\n end", "def ask_office_for_answer_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.ask_office_for_answer_mail(Petition.live.first)\n end", "def show\n set_retail\n end", "def preview_name\n name.sub(/Preview$/, '').underscore\n end", "def preview\n mixpanel_tab_event(\"View Item\", \"Get Preview URL\")\n begin\n embed_url = user_client.embed_url(params[:id])\n redirect_to embed_url\n rescue\n redirect_to no_support_url\n end\n\n end", "def blog_preview\n object._challenge\n end", "def show\n session[:applicant_token] = params[:id] unless current_user\n @email = ERB.new(Settings.email_template).result(get_binding)\n p EMAIL: @email\n end", "def ping_reviewer(review)\n\n to_list = [review[:user].email]\n cc_list = []\n subject = 'Your unresolved Design Review(s)'\n\n @user = review[:user]\n @result = review[:results]\n \n if review[:urgent]\n attachments.inline['warning.png'] = File.read('app/assets/images/warning.png')\n headers['Importance'] = 'high'\n headers['X-Priority'] = '1'\n headers['X-MSMail-Priority'] = 'High'\n end\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list,\n ) \n end", "def preview_text(maxlength = 30)\n return \"\" if description.blank?\n my_contents = description[\"contents\"]\n return \"\" if my_contents.blank?\n content_flagged_as_preview = my_contents.select { |a| a[\"take_me_for_preview\"] }.first\n if content_flagged_as_preview.blank?\n content_to_take_as_preview = my_contents.first\n else\n content_to_take_as_preview = content_flagged_as_preview\n end\n preview_content = self.contents.select { |content| content.name == content_to_take_as_preview[\"name\"] }.first\n return \"\" if preview_content.blank? || preview_content.essence.blank?\n text = preview_content.essence.preview_text(maxlength)\n text.size > maxlength ? \"#{text[0..maxlength]}...\" : text\n end", "def link_to_preview(text, type_id, *args)\n link_to_function text, \"CCPEVE.showPreview(#{type_id.inspect})\", *args\n end", "def preview_text=(value)\n @preview_text = value\n end", "def preview_text=(value)\n @preview_text = value\n end", "def resume_confirm(email, username, filename)\n subject 'You have uploaded your resume to YouIntern'\n recipients email\n from 'support@youintern.com'\n sent_on Time.now\n \n body :username => username, :filename => filename\n end", "def preview_text(max_length = 30)\n attachment&.name.to_s[0..max_length - 1]\n end", "def display_resume\n\t profile_resume = Profile.find_by_id(params[:id]).resume\n send_data(profile_resume.attachment_binary.data,\n\t\t\t\t :filename => profile_resume.name,\n\t\t\t\t :type => profile_resume.content_type,\n\t\t\t\t :disposition => \"attachment\"\n\t\t\t\t )\n end", "def generate_complete_timeline_preview_url(given_timeline_id)\n tl_entry_to_use = Timeline.find(given_timeline_id)\n target_page_path = timeline_path(tl_entry_to_use)\n \n protocol_host_port = \"#{request.protocol}#{request.host_with_port}\"\n main_url = \"#{protocol_host_port}#{target_page_path}?preview=true\"\n \n url_to_return = URI::encode(main_url)\n return url_to_return\n end", "def preview(article)\n unless article.published_at.nil?\n article_path(article)\n else\n preview_path(article.preview_hash)\n end\n end", "def post_edit_email\n NotificationMailer.post_edit_email('default@email.com')\n end", "def reviewed(inquiry)\n @inquiry = inquiry\n mail to: inquiry.email, subject: 'Verteo Biopharma Inquiry Reviewed'\n end", "def update\n @mail = Mail.find(params[:id]) \n if !@mail.update_attributes(params[:mail]) || params[:preview_button]\n \n render :action => \"edit\"\n else\n flash[:notice] = 'Mail was successfully updated.'\n redirect_to(@mail)\n end\n end", "def to_s\n \"Last Modified: #{@modifiedAt}\\nStatus: #{@status}\\nAssigned to: #{@owner}\\nSubject: #{@subject}\\n#{@preview}\"\n end", "def show\n #TRACKER.track(current_user['email'], \"READ_EMAIL\", {\"email_id\" => @email.id, \"email_reference\" => @email.reference_id})\n TRACKER.track(current_user['email'], \"READ_EMAIL\", @email.id, @email.reference_id)\n end", "def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end", "def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end", "def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end", "def show\n # notification_email\n end", "def preview\n self.content.split(' ')[0...5].join(' ') + '...'\n end", "def apply(interviewee,interviewer)\n @interviewee = interviewee\n @interviewer = interviewer\n mail(to: @interviewee.email + \",\" + @interviewer.email, subject: '面接日程承認のお知らせ')\n end", "def to_s\n '#<Twilio::REST::Preview>'\n end", "def to_s\n '#<Twilio::REST::Preview>'\n end", "def email_approved_proposal\n ProposalMailer.email_approved_proposal\n end", "def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end", "def set_preview\n @preview = Preview.find(params[:id])\n end", "def preview_msg(msg_params_with_name)\n uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\\\n \"&type=10&token=#{@token}&lang=zh_CN\"\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\\\n \"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}\",\n host: 'mp.weixin.qq.com',\n x_requested_with: 'XMLHttpRequest'\n }\n resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)\n\n res = resource[uri].post msg_params_with_name\n # \"ret\":\"0\", \"msg\":\"preview send success!\", \"appMsgId\":\"201796045\", \"fakeid\":\"\"\n JSON.parse res.to_s\n end", "def review_posted(email,permalink) \n @service_permalink = permalink \n subject = \"A review was posted for your service\"\n setup_email(email, subject)\n end", "def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end", "def emailOnReview(revieweeId)\r\n puts \"we are in email on review\"\r\n @team_member = TeamsUser.find_all_by_team_id(revieweeId)\r\n asstId = Team.find_by_id(revieweeId).parent_id\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review\"\r\n @team_member.each do |team_Member|\r\n # get parameters for sending mail\r\n user=User.find_by_id(team_Member.user_id)\r\n puts \"teammate name = #(user.name)\"\r\n if(user.email_on_review)\r\n email(user.email,\"Review\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end\r\n end", "def preview_edit\n\n layout_style = nil\n if (params[:layout])\n layout_style = params[:layout]\n end\n\n\n begin\n @bulletin = Bulletin.find(params[:id])\n @bulletin_layout = @bulletin.layout_for_editing(layout_style, self)\n headers[\"Content-Type\"] = @bulletin_layout.filetype + \"; charset=\" + @bulletin_layout.charset\n render :text => @bulletin_layout.rendered, :layout => 'bulletin'\n return\n rescue SyntaxError\n @error = _('A fatal error has occurred while compiling the temlpate!') + \n '<br /><br />ERROR: '+$!\n end\n render :action => 'error', :layout => 'bulletin'\n end" ]
[ "0.71475905", "0.71186084", "0.70552814", "0.6985626", "0.6848472", "0.6848472", "0.6832406", "0.6663229", "0.64324814", "0.631654", "0.6304366", "0.6181875", "0.6167911", "0.61338973", "0.61305445", "0.6115152", "0.61100966", "0.61100966", "0.60882556", "0.60132533", "0.5982547", "0.5970752", "0.5921947", "0.5854165", "0.58256847", "0.58256847", "0.5801412", "0.5798907", "0.57861274", "0.5756108", "0.57435614", "0.57311475", "0.5694853", "0.5693586", "0.56733876", "0.56689703", "0.5667859", "0.56230783", "0.5584482", "0.5580056", "0.556691", "0.5565034", "0.553256", "0.55282027", "0.5521174", "0.55182135", "0.54865557", "0.54802716", "0.54802716", "0.5475045", "0.54698133", "0.5462231", "0.54592174", "0.5457588", "0.54561025", "0.5434102", "0.54326165", "0.5418592", "0.5416024", "0.5406969", "0.5398783", "0.5398783", "0.5390498", "0.53865004", "0.53677875", "0.5354904", "0.53483963", "0.53450906", "0.53428084", "0.5339015", "0.5331245", "0.5324016", "0.5320464", "0.52986485", "0.52971554", "0.52956325", "0.52885884", "0.52866477", "0.52858466", "0.52848935", "0.5274558", "0.52651525", "0.5261375", "0.5255958", "0.52543974", "0.52372897", "0.52372897", "0.5235101", "0.522828", "0.5226132", "0.5213765", "0.52118236", "0.52118236", "0.52064675", "0.5192629", "0.5186882", "0.5167913", "0.51622766", "0.5158241", "0.515572", "0.5152641" ]
0.0
-1
PUT /resource We need to use a copy of the resource because we don't want to change the current user in place.
def update self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email) resource_updated = update_resource(resource, account_update_params) error_flag = false if resource.real_name == true unless resource.first_name.present? && resource.last_name.present? set_flash_message :error, :not_real_name resource.real_name = false resource.save! error_flag = true end end yield resource if block_given? if resource_updated if is_flashing_format? flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ? :update_needs_confirmation : :updated unless error_flag == true && flash_key == :updated set_flash_message :notice, flash_key end end sign_in resource_name, resource, bypass: true if error_flag == true redirect_to edit_user_registration_path(resource) and return end respond_with resource, location: after_update_path_for(resource) else clean_up_passwords resource respond_with resource end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end", "def set_resource\n @user = current_user\n @resource = Resource.find(params[:id])\n end", "def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end", "def update_resource(resource, params)\n resource.role_id = 1\n resource.update_without_password(params)\n end", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend", "def put(resource_path, body:, headers: {}, prefix: API_PREFIX)\n request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)\n end", "def update_resource(resource, attributes)\n resource.attributes = attributes\n resource.save\n resource\n end", "def put(resource, **params)\n\n execute(Net::HTTP::Put, 'PUT', resource, **params)\n\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update\n resource.update_attributes params[params_key], as: current_role\n respond_with resource\n end", "def update\n @user_resource = UserResource.find(params[:id])\n\n respond_to do |format|\n if @user_resource.update_attributes(params[:user_resource])\n format.html { redirect_to user_preferences_path(@user), notice: 'User resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_resource(resource, params)\n check_id_uniformity(params)\n resource.assign_attributes(json_api_attributes(params))\n authorize resource, :update?\n resource.save!\n resource\n end", "def update_resource(resource, params)\n resource.update_without_password(params)\n end", "def update\n if @resource.update(resource_params)\n flash[:notice] = notification_message('edit_success')\n render json: { redirect_url: request.referrer }, status: :created\n else\n render json: { message: notification_message('edit_failure') }, status: :unprocessable_entity\n end\n end", "def manage_resource(resource)\n unless resource.is_a?(OMF::SFA::Model::Resource)\n raise \"Resource '#{resource}' needs to be of type 'Resource', but is '#{resource.class}'\"\n end\n\n resource.account_id = _get_nil_account.id\n resource.save\n resource\n end", "def update\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n if @resource.update(resource_params)\n render json: @resource, status: :ok\n else\n render json: @resource.errors, status: :unprocessable_entity\n end\n end", "def put(path, request_options = {}, resource_options = {})\n response(:put, resource(resource_options)[path], request_options)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update_resource(resource, params)\n resource.update_with_password(params)\n end", "def update\n respond_to do |format|\n if @resource.update(resource_params)\n @resource.saved_by(current_admin)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(resource, attributes = {})\n resource.client = self\n resource.update(attributes)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update_resource(object, attrs)\n object.update_with_password(*attrs)\n end", "def update_resource(resource_desc, resource_type, authorizer, new_attributes)\n resource = find_resource(resource_desc, resource_type, authorizer)\n authorizer.can_modify_resource?(resource, resource_type)\n resource.update(new_attributes)\n resource\n end", "def update_resource(resource, params)\n # abort params.inspect\n resource.update_without_password(params)\n end", "def set_resource(resource = nil)\n resource ||= resource_class.find(params[:id])\n check_action_whitelisted!(params[:action])\n authorize! params[:action].to_sym, resource\n instance_variable_set(\"@#{resource_name}\", resource)\n end", "def update\n authorize! :update, resource\n current_model_service.update resource, params\n yield if block_given? # after_update\n respond_with resource, location: helpers.show_path(resource)\n end", "def update(resource, id, format=@default_format)\n options = { resource: resource.class, id: id, format: format }\n reply = put resource_url(options), resource, fhir_headers(options)\n reply.resource = parse_reply(resource.class, format, reply)\n reply.resource_class = resource.class\n reply\n end", "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @resource = Resource.find(params[:id])\n \n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_resource(resource, params)\n if [\"facebook\", \"github\", \"google_oauth2\"].include? current_user.provider\n params.delete(\"email\")\n params.delete(\"avatar\")\n resource.update_without_password(params)\n else\n resource.update_with_password(params)\n end\n end", "def update!(**args)\n @resource_id = args[:resource_id] if args.key?(:resource_id)\n end", "def update\n @resource = Resource.find(params[:id])\n\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n redirect_to @resource\n else\n render :action => \"edit\"\n end\n end", "def new\n super\n @resource.user = current_user\n end", "def send_put(resource, data)\n\n url = URI.parse(primavera_path(resource))\n req = Net::HTTP::Put.new(url.to_s, initheader = {'Content-Type' => 'application/json'})\n req.body = data\n\n puts 'Sending PUT request to ' + url.to_s\n\n send_request(url, req)\n end", "def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def update\n begin\n @resource = Entity.find params[:id]\n @resource.update_attributes! params[:entity]\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update_profile_resource(resource, params)\n resource.update_without_password(params)\n end", "def update \n begin\n @resource = Account.find(params[:id])\n @resource.update_attributes!(params[:account])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def resource=(new_resource)\n @resource = @resource.merge(new_resource)\n end", "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end", "def update_resource(resource, params)\n # if params['email'] != current_user.email || params['password'].present?\n # resource.update_with_password(params)\n # else\n resource.update_without_password(params.except('password', 'password_confirmation', 'current_password'))\n # end\n end", "def update\n user = self.resource = User.to_adapter.get!(send(:\"current_user\").to_key)\n\n if user.update_with_password(resource_params)\n set_flash_message :notice, :updated\n sign_in resource_name, user, :bypass => true\n respond_with user, :location => after_update_path_for(user)\n else\n clean_up_passwords user\n respond_with user\n end\n end", "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:success] = 'Resource was successfully updated.'\n format.html { redirect_to admin_resource_path(@resource.id) }\n format.json { head :ok }\n else\n flash[:error] = @resource.errors.full_messages.join('')\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end", "def put(request, response)\n @resource.put(request, response)\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def put(header = {})\n url = \"#{ApiClient.config.path}#{self.class.resource_path}\"\n response = ApiClient::Dispatcher.put(url, self.to_hash, header)\n attributes = ApiClient::Parser.response(response, url)\n update_attributes(attributes)\n end", "def update\n @resource = Resource.find(params[:id])\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to(edit_admin_resource_path(@resource), :notice => 'Resource was successfully updated.') }\n format.xml { head :ok }\n else\n get_resource_info\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end", "def base_update(resource, id, options, format = nil, headers = nil)\n headers ||= {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers[:content_type] = \"#{format}\"\n headers[:prefer] = @return_preference if @use_return_preference\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format\n options[:id] = id\n reply = put resource_url(options), resource, fhir_headers(headers)\n reply.resource = parse_reply(resource.class, format, reply) if reply.body.present?\n reply.resource_class = resource.class\n reply\n end", "def put!\n request! :put\n end", "def find_and_update_resource\n model = class_name.find(params[:id])\n model.tap do |m|\n m.update get_secure_params\n set_resource_ivar m\n end\n end", "def update_resource(object, attributes)\n object.update(*attributes)\n end", "def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end", "def update_card_resource(card_id, resource, *paths)\n paths, options = extract_options(camp(resource), *paths)\n put card_path(card_id, *paths), options\n end", "def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end", "def put(name,&block)\n build_resource(name, :put, &block)\n end", "def update_resource(resource, params)\n if !current_user.provider.nil?\n params.delete(\"current_password\")\n resource.update_without_password(params)\n else\n resource.update_with_password(params)\n end\n end", "def update!(**args)\n @full_resource_name = args[:full_resource_name] if args.key?(:full_resource_name)\n @permission = args[:permission] if args.key?(:permission)\n @principal = args[:principal] if args.key?(:principal)\n end", "def update!(**args)\n @full_resource_name = args[:full_resource_name] if args.key?(:full_resource_name)\n @permission = args[:permission] if args.key?(:permission)\n @principal = args[:principal] if args.key?(:principal)\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update\n # make sure user is authorized\n unless @resource\n return render json: {\n success: false,\n errors: ['Unauthorized']\n }, status: 401\n end\n\n # ensure that password params were sent\n unless password_resource_params[:password] and password_resource_params[:password_confirmation]\n return render json: {\n success: false,\n errors: ['You must fill out the fields labeled \"password\" and \"password confirmation\".']\n }, status: 422\n end\n\n if @resource.update_attributes(password_resource_params)\n return render json: {\n success: true,\n data: {\n user: @resource,\n message: \"Your password has been successfully updated.\"\n }\n }\n else\n return render json: {\n success: false,\n errors: @resource.errors\n }, status: 422\n end\n end", "def update!(**args)\n @granted = args[:granted] if args.key?(:granted)\n @permission = args[:permission] if args.key?(:permission)\n @resource = args[:resource] if args.key?(:resource)\n @resource_attributes = args[:resource_attributes] if args.key?(:resource_attributes)\n end", "def save_resource\n resource.save\n end", "def accept_resource\n resource = resource_class.accept_invitation!(update_resource_params)\n @user = User.find(resource.invited_by_id)\n resource.company_id = @user.company.id\n resource.save\n resource\n end", "def update!(**args)\n @resource_key = args[:resource_key] if args.key?(:resource_key)\n end", "def update_resource(resource, params)\n # Require current password if user is trying to change password.\n return super if params['password']&.present?\n\n # Allows user to update registration information without password.\n resource.update_without_password(params.except('current_password'))\n end", "def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n\n if resource.update_attributes(params[resource_name])\n if is_navigational_format?\n if resource.respond_to?(:pending_reconfirmation?) && resource.pending_reconfirmation?\n flash_key = :update_needs_confirmation\n end\n set_flash_message :notice, flash_key || :updated\n end\n sign_in resource_name, resource, :bypass => true\n respond_with resource, :location => after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end", "def update_resource(resource, params)\n # Require current password if user is trying to change password.\n return super if params[\"password\"]&.present?\n # Allows user to update registration information without password.\n resource.update_without_password(params.except(\"current_password\"))\n end" ]
[ "0.722461", "0.70050365", "0.6981741", "0.69709957", "0.69548756", "0.69534856", "0.6753882", "0.6746122", "0.6743065", "0.6716734", "0.6716734", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.6707082", "0.670286", "0.6698732", "0.66940147", "0.668611", "0.6682288", "0.6666141", "0.6660427", "0.66436166", "0.6627017", "0.6627017", "0.6627017", "0.6627017", "0.6627017", "0.6627017", "0.6627017", "0.6577445", "0.65646654", "0.65402246", "0.6510667", "0.65105873", "0.65092087", "0.64347297", "0.64277655", "0.6389447", "0.6382447", "0.6382447", "0.6344394", "0.6326642", "0.63202906", "0.63134766", "0.6304301", "0.62872994", "0.62760025", "0.6275582", "0.6259052", "0.62589234", "0.62528414", "0.6233613", "0.6233613", "0.6232376", "0.6222734", "0.6215455", "0.62058866", "0.61857015", "0.61748755", "0.6168341", "0.61654085", "0.61590236", "0.6149402", "0.61492103", "0.61483043", "0.6142899", "0.61332667", "0.6132377", "0.6127592", "0.61271596", "0.6126065", "0.6126065", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.6118827", "0.61175793", "0.6113161", "0.61098456", "0.6106519", "0.6103693", "0.61005735", "0.60932857", "0.60883135", "0.60883135", "0.6088225", "0.6085087", "0.6083782" ]
0.0
-1
gathers all the required information about the user to view his/her profile
def show @member = User.find(params[:id]) conn = Connection.where(:user_id => @current_user.id).pluck(:connection_id) user = Connection.where(:connection_id => @current_user.id).pluck(:user_id) all = user + conn @connections = User.where(:id => all) @member = User.find(params[:id]) @reviews = UsersQuest.where(:assignee_id => @current_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile\n\t\t\n\t\tif !current_user\n\t\t\tredirect_to root_url and return\n\t\tend\n\t\t\n\t\t@user = current_user\n\t\t\n\tend", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info['query']['results'][\"profile\"]\n end", "def show\n @user = User.find(params[:id])\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n @can_edit = can_edit_hash[:has_permission]\n\n #max needs\n @can_see_pref= Permissions.is_at_least_manager(@current_user)\n\n profile_attrs = [:first_name,:last_name, :email,:phone_number]\n @first_name = @user.first_name\n @last_name = @user.last_name\n @email = @user.email\n @phone_number = @user.phone_number\n @role = @user.role\n end", "def profile\n\t@user = current_user\n\t@title = \"This is your profile page\"\n end", "def profile\n\t\t# determine which user's profile page\n\t\t@user = User.find_by_login(params[:username])\n\t\t# retrieve all bids by this user\n\t @bids = Bid.find_all_by_bidder_id(@user.id, :group => 'item_id')\n\t\t# get all comments for this user\n\t @comments = @user.user_comments\n\t\t# get all user_items by this user\n\t @user_items = @user.posted_items\n\n\t\t# code for facebox\n\t respond_to do |format|\n\t\t\tformat.html\n format.js { render_to_facebox }\n end\n\tend", "def profile\n\t\t@user = User.find(current_user)\n\tend", "def profile\n\t\t@user = current_user\n\tend", "def profile\n @user = current_user\n end", "def profile\n \n end", "def profile\n @user = @current_user\n\n render :show\n\n end", "def profile\n @profile = current_user\n end", "def profile\n\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def manage_profile\n begin\n @has_link_access = true\n if @actor.is_fan? # in case of fan profile login\n @user = @actor\n @additional_info = current_user.additional_info\n get_user_associated_objects\n render :template =>\"/fan/manage_profile\" and return\n elsif @actor.is_artist? # in case of artist profile login\n @user = current_user\n @artist = @actor\n @artist_user = ArtistUser.for_user_and_artist(current_user, @artist).first || ArtistUser.new\n get_artist_objects_for_right_column(@artist)\n render :template =>\"/artist/edit\" and return\n elsif @actor.is_venue? # in case of venue profile login\n @user = current_user\n @venue = @actor\n @venue_user = VenueUser.for_user_and_venue(current_user, @venue).first || VenueUser.new\n get_venue_objects_for_right_column(@venue)\n render :template =>\"/venue/edit\" and return\n end\n rescue =>exp\n logger.error \"Error in User#ManageProfile :=> #{exp.message}\"\n render :nothing => true and return\n end\n respond_to do |format|\n format.js\n format.html\n end\n end", "def user_data\n {:username => self.username,\n :pic_url => self.user_pic,\n :profile_url => self.profile_url\n }\n end", "def small_profile\n\t\t# determine which user's profile page\n \t@user = User.find_by_login(params[:username])\n\t\t# get all comments for this user\n\t @comments = @user.user_comments\n\t\t# get all user_items by this user\n\t @user_items = current_user.user_items\n\t\trespond_to do |format|\n\t\t\tformat.html\n format.js { render_to_facebox }\n end\n\tend", "def profile\n @profile ||= @request.do_request { FacebookUserProfile.populate(user) }\n end", "def show\n @profile = @user.profile\n end", "def show\n @profile = current_user.profile\n\n # ToDo: error message if no profile is found for user\n\n puts 'Got profile='\n pp @profile\n \n\n puts 'got other_names='\n pp @profile.other_names\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile }\n format.json { render :json => @profile }\n end\n \n end", "def profile\n check_auth :profile\n \n response = connection.post do |req|\n req.url '/user/profile'\n req.body = { :format => @format }\n end\n response.body[0]\n end", "def profile\n if !GraderConfiguration['system.user_setting_enabled']\n redirect_to :controller => 'main', :action => 'list'\n else\n @user = current_user;\n end\n end", "def show\n @user_picture = @user.profile_image.expiring_url(3600, :square)\n @bookmarks = @user.bookmarks\n @enrollments = @user.courses\n @enrollments_visible = @user.course_enrollments_visible_for_user(current_user)\n @completions_visible = @user.course_results_visible_for_user(current_user)\n end", "def profile\r\n if params[:id] && User.exists?(params[:id])\r\n @prof = User.find(params[:id])\r\n else\r\n redirect_to_info_page t(:redir)\r\n return\r\n end\r\n end", "def show\n if current_user.is_normal?\n @user = User.find( params[:id] )\n render :profile\n else\n redirect_to user_profile_path\n end\n end", "def profile\n \t@user = UsersService.findUserById(params[:id])\n end", "def profile\n @user = UserService.getUserById(params[:id])\n end", "def user_information\n @current_user = current_user\n\n render :partial => 'home/user_info'\n end", "def show\n unless params[:id].blank?\n @user = User.find_by_id(params[:id])\n else\n if logged_in?\n @user = current_user\n else\n require_login and return\n end\n end\n \n if @user.blank?\n flash[:error] = \"User not found\"\n redirect_to root_path and return\n end\n\n @own_profile = (logged_in? && (@user.id == current_user.id))\n\n @page_title = @own_profile ? \"My profile\" : \"View profile\"\n\n @memberships = @user.liga_users.approved.map(&:league)\n end", "def user_details\n @user = current_user\n invitation = @user.invitation\n if invitation.present?\n solo_restaurant_name = invitation.restaurant_id ? \n Restaurant.find(invitation.restaurant_id).name :\n invitation.restaurant_name\n @user.build_default_employment(:solo_restaurant_name => solo_restaurant_name, \n :restaurant_role => invitation.restaurant_role, :subject_matters => invitation.subject_matters)\n else\n @user.build_default_employment\n end\n @user.build_profile\n end", "def set_user_and_profile\n @user = User.find(params[:id])\n @profile = @user.profile\n end", "def load_user_and_profile\n\t\t@user = current_user\n\t\t@user.load_profile\n\t\t@profile = @user.profile\n\tend", "def user_profile\n @current_user = current_user\n\n if params[:id] == 'me'\n @user = @current_user\n else\n @user = User.find_by_id(params[:id])\n end\n end", "def user_information\n { \"username\": @user.username, \"email\": @user.email, \"id\": @user.id }\n end", "def profile\n # grab the username from the URL as :id\n @user = User.find(session[:user_id])\n #@followers = Relationship.all.where(\"followed_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@following = Relationship.all.where(\"follower_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[\"id\"]).id)\n end", "def index\n\n\t\t@user=current_user\n\n\t\t# We need to tell the view what to do with the profile\n\t\t# If a profile exists then display some profile information\n\t\t# If a profile doesn't exist then display a message saying to click the edit button to add a new profile\n\n\t\t# Does a valid profile exist on the user?\n\t\t@valid_profile = Profile.exists?(user_id: @user.id)\n\n\t\t# Valid profile exists\n\t\tif @valid_profile\n\n\t\t\t@user_profile = Profile.find_by(user_id: @user.id)\n\n\t\telse\n\n\t\t\t# No valid profile exists\n\t\t\t# The user can either create a new profile or request an existing one\n\t\t\t#@user_profile_requests = @user.profile_requests\n\n\t\t\t# if !current_user.profile_requests.approved(false).empty? %>\n\n\t\t\t# Create a list of user profile requests that are not set yet\n\t\t\t@user_profile_requests_not_set = @user.profile_requests.status_not_set\n\n\t\t\tif @user_profile_requests_not_set.blank?\n\n\t\t\t\t@available_profiles_collection = Profile.where(user_id: nil).order(:lastname)\n\n\t\t\tend\n\n\t\t\t# Create a list of user profile requests that are denied\n\t\t\t@user_profile_requests_denied = @user.profile_requests.status_denied\n\n\t\tend\n\n\n\n\n\tend", "def show\n\n\t\t@current_profile = Profile.get_profile params[:id], \"asdf\"\n\n\t\tpretty_render \"api/public_user\"\t\n\n\tend", "def set_profile\n @user = current_user\n @profile = @user.profile\n end", "def profile\r\n\t\tif User.exists?(id: params[:id])\r\n\t\t\t@user = User.where(id: params[:id])\r\n\t\t\t@name = @user[0].username\r\n\t\t\t@member_since = @user[0].member_since\r\n\t\t\t@email = @user[0].email\r\n\t\t\t@xp = @user[0].xp\r\n\t\t\t@answercount = @user[0].no_comment\r\n\t\t\t@postcount = @user[0].no_thread\r\n\t\t\t\r\n\t\t\t#add achievements\r\n\t\t\tif @u_id == params[:id].to_i\r\n\t\t\t\t@achievements = Achievement.find(:all)\r\n\t\t\t\t@achievements.each do |a|\r\n\t\t\t\t\tif @xp >= a.condition\r\n\t\t\t\t\t\tif UserAchievement.where(user_id: @u_id, achievement_id: a.id).empty?\r\n\t\t\t\t\t\t\t@ua = UserAchievement.new(:user_id => @u_id, :achievement_id => a.id)\r\n\t\t\t\t\t\t\t@ua.save\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t# retrieves achievements to be displayed\r\n\t\t\t@achievement = UserAchievement.where(user_id: params[:id])\r\n\t\t\t\r\n\t\telse\r\n\t\t\tredirect_to root_path\r\n\t\tend\r\n\tend", "def show\n\n if @user.id == current_user.id\n add_breadcrumb \"My Profile\"\n else\n add_breadcrumb @user.name\n end\n\n # get the @prev_record_path and @next_record_path view vars\n get_next_and_prev_object_keys(@user, INDEX_KEY_LIST_VAR)\n @prev_record_path = @prev_record_key.nil? ? \"#\" : user_path(@prev_record_key)\n @next_record_path = @next_record_key.nil? ? \"#\" : user_path(@next_record_key)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end", "def profile\n @user = User.find(params[:id])\n end", "def profile\n render_json 0,\"ok\",current_member.as_profile\n end", "def show\n @user = User.find(params[:id])\n\n if @user.state != 'active' or @user.login == 'admin'\n return redirect_to users_path\n end\n \n @page_ancestors = [{:name=>'Community', :url=> users_path}]\n @bc_title = 'User Profile'\n \n respond_to do |format|\n format.html # show.html.erb\n format.iphone\n format.xml { render :xml => @user }\n end\n end", "def set_profiledetail\n @profiledetail = current_user.profiledetail\n end", "def loginViewFetchedUserInfo( loginView, user: user )\n\t\t# here we use helper properties of FBGraphUser to dot-through to first_name and\n\t\t# id properties of the json response from the server; alternatively we could use\n\t\t# NSDictionary methods such as objectForKey to get values from the my json object\n\t\t@labelFirstName.text = \"Hello #{user[ :first_name ]}!\"\n\n\t\t# setting the userID property of the FBProfilePictureView instance\n\t\t# causes the control to fetch and display the profile picture for the user\n\t\t@profilePic.userID = user[ :id ]\n\t\t@loggedInUser = user\n\tend", "def show\n \n @user = logged_in_user \n @questions = logged_in_user.user_attribute_details \n @change_list = ContentManager.calculate_change_list(@user) \n @campaigns_to_show = 5\n @owned_campaigns = logged_in_user.owned_campaigns.not_deleted\n @is_org_user = @user.has_role? \"OrganizationUser\"\n @orgs = OrganizationUser.find_all_by_user_id(@user.id).map(&:organization) if @is_org_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile }\n end\n end", "def profile\n @user = current_user_with_auths\n @connected = @user.authorizations.collect{|a| a.provider}\n @to_connect = providers - @connected\n unless @user\n redirect_to root_path, :notice => \"Sorry, try logging back in\"\n end\n end", "def index\n @profiles = current_user\n end", "def show\n op = present User::Show\n redirect_to edit_user_profile_path(current_user, op.model.profile) && return if op.new_profile?\n redirect_to user_profile_path(current_user, op.model.profile)\n end", "def user_info\n\t\t\"name: #{name} \\n\"+\n\t\t\"email: #{email}\"\n\t\t\t\n\tend", "def profile\n service_response = UserManagement::ProfileDetail.new(params).perform\n render_api_response(service_response)\n end", "def profile\n super\n end", "def profile\n super\n end", "def collect_user_info(get_password=true, \n first_time=false,\n third_party=false,\n need_email=true)\n\n values = {\n \"form_target\" => url(:handle_collect_user_info, \n get_password, \n third_party,\n need_email),\n \"user_affiliate_opts\" => Affiliate.options,\n \"first_time\" => first_time,\n \"third_party\" => third_party\n }\n\n \n @data.user.add_to_hash(values)\n\n standard_page(\"Create New User\",\n values,\n Login::EDIT_USER)\n end", "def set_profile\n @profile = User.friendly.find(params[:user_id]).profile\n end", "def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info[\"person\"]\n end", "def user_details\n if (params[:user_uid] != nil)\n user = User.select(:name, :blood_group, :age, :id, :user_picture).find_by(user_uid: params[:user_uid])\n path = user.user_picture.path.present? ? user.user_picture.path.gsub(\"/home/altius/Uma/project/BC4_api/public\", \"http://192.168.1.238:4020/\") :nil\n contacts = EmergencyDetail.where(user_id: user.id)\n health_detail = HealthDetail.find_by(user_id: user.id, name: \"health\")\n policy_details = HealthDetail.find_by(user_id: user.id, name: \"policy\")\n render json: { user: user, profile_picture: path, contacts: contacts, health_detail: health_detail, policy_details: policy_details }, status: :ok\n else\n render json: { \"error\": \"Give the user UID\" }, status: :unprocessable_entity\n end\n end", "def user_info\n @user_info ||= raw_info\n end", "def getProfile\n account = current_user.account\n if account.nil?\n render status: 400, json: {error: \"Invalid User\"}\n else\n if current_user.registered && (account.referral_code.nil? || account.referral_code.blank?)\n account.generate_referral_code\n end\n render status: 200, json: {username: current_user.username,\n email: current_user.email,\n firstName: current_user.first_name,\n lastName: current_user.last_name,\n company: current_user.company,\n balance: account.balance,\n registered: current_user.registered,\n referralCode: account.referral_code}\n end\n end", "def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend", "def userinfo\n @participant = Participant.find(session[:user])\n end", "def show()\n @authentication = Authentication.find(params[:id])\n\n if @authentication.provider == \"facebook\"\n me = FbGraph::User.me(@authentication.token).fetch\n current_user.fname = me.name.split.first\n current_user.lname = me.name.split.last\n current_user.email = me.email\n current_user.gender = me.gender\n birthday = me.birthday\n current_user.birthday = Chronic.parse(birthday) if birthday\n\n location = me.location\n current_user.location = location if location and location.is_a? String\n current_user.location = location.try(:[], :name) if location and location.is_a? Hash\n pictureurl = me.picture+'?type=large'\n begin\n tempfile = Tempfile.new(['', '.jpg'])\n open(tempfile.path, 'wb') do |file|\n file << open(URI.parse(pictureurl)).read\n end\n current_user.avatar = tempfile\n rescue\n end\n end\n\n current_user.save\n redirect_to edit_user_path\n end", "def show\n @profile = Profile.find(:first, :conditions => {:user_id => params[:user_id]})\n end", "def get_profile_information\n # body = {\n # cmd: \"get_profile_information\"\n # }\n\n end", "def show\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n current_user\n end\n\n @profile = @user.profile\n authorize! :show, @profile\n\n @progress_remaining = @profile.profile_progress\n @progress = Profile::PROFILE_STEPS - @progress_remaining\n @progress_percent = ((@progress/Profile::PROFILE_STEPS.to_f) * 100).round(0)\n\n #here is code for creating a \"view\" event in the Views table\n unless current_user.id == @user.id\n @view = View.new\n @view.profile_id = @profile.user_id\n @view.viewer_id = current_user.id\n @view.save\n end\n #end of code relating to the view\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end", "def user_info\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n\n respond_to do |format|\n name = @current_user.name\n username = @current_user.username\n format.json {\n render json: {\n :name => name,\n :username => username,\n }.to_json, status: 200\n }\n end\n end", "def show\n render json: get_full_user_details(user), status: :ok\n rescue => e\n log_and_render_users_controller_error(e, \"get user details failed\")\n end", "def profile\n @presenter = Users::ProfilePresenter.new(current_user.id)\n @message = Message.new\n end", "def profile_edit\n @user = User.find(current_user.id)\n end", "def show\n @user = User.find(params[:id])\n if $current_user.nil? or $current_user.id != @user.id\n redirect_to signin_path\n else\n @title = \"#{@user.userName}'s profile\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end\n end", "def show\n if current_user\n @user = User.find(params[:id])\n @user = current_user\n render :show\n else\n flash[:error] = \"Must be signed in to see your profile!!\"\n redirect_to \"/\"\n end\n end", "def show\n totalPicture=Timeline.where(\"user_id=#{@user.id}\").count\n @user_info ={profileImage:\"#{@user.profileImage}\", totalPicture:\"#{totalPicture}\"}\n end", "def profile\n \t\t@patient = Patient.all\n #@current_user = User.find(params[:id])\n end", "def get_user_profile_description\n get_profile_description(\"Users\")\n end", "def profile(username = nil, uid = nil)\n\n end", "def show\n @profile = current_user.profile\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end", "def user\n\n \n @profile = Profile.find_by_user_id(params[:id])\n\n\nend", "def edit\n\t\t@user = User.find( params[:user_id] )\n\t\t@profile = @user.profile\n\tend", "def get_user_detail\n user_id = params[:id]\n user = User.find(user_id)\n\n render json: UserSerializer.new(user).profile_detail_hash\n end", "def get_user_profile(uid,fields)\n begin\n @user_details = graph.get_object(\"#{uid}\",\"fields\" => \"#{fields}\")\n rescue Exception => e\n error(\"get_user_profile :: #{e.message}\")\n end\n end", "def show\n user = load_user\n expose user, serializer: UserProfileSerializer\n end", "def set_profile\n if current_user.nil?\n redirect_to :home, notice: t( 'profiles.notice.pls_signon') \n else\n @person = Person.find( current_user.person_id )\n @user_id = current_user.id\n set_final_breadcrumb( action_name )\n end\n self.feature_help_file = :profile\n end", "def set_profile\n @user = User.find(params[:id])\n @profile = @user.profile\n end", "def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end", "def profile\n\t\tif user_signed_in?\n\t\t\tdb_entry = UserSetting.where(username: current_user.username)[0]\n\t\t\tif db_entry != nil\n\t\t\t\thandle = db_entry.handle\n\t\t\t\t@problems_solved, @contests_attempted = build_solved_problems_and_attempted_contests(handle)\n\t\t\t\t@@handle_shared = handle\n\t\t\t\t@@problems_solved_shared = @problems_solved\n\t\t\t\t@@contests_attempted_shared = @contests_attempted\n\t\t\tend\n\t\tend\n\tend", "def profile\n unless @profile\n if associated_profile\n @profile = Profile.new(associated_profile)\n else\n options = {:fields => 'user_id', :includes => 'Profile'}\n options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)\n tmp = User.find(username, options)\n @profile = Profile.new(tmp.associated_profile)\n end\n end\n @profile\n end", "def profile\n if(current_user)\n render 'layouts/loggedin'\n else\n render \"layouts/guest\"\n end\n end", "def show\n\n @user = User.find(params[:id])\n @is_an_interest = !Visible.where(hidden_user: params[:id], user_of_interest: @user).nil?\n\n if @user.event_id.present?\n @event = Location.find(Event.find(@user.event_id).location_id).name\n end\n\n # used to show a person link to editing his profile\n @is_user = false\n if @user.id == session[:user_id]\n @is_user = true\n end\n\n @is_female = false\n if @user.gender.eql? \"F\"\n @is_female = true\n end\n\n if @user.visible || @is_user || @is_an_interest\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n redirect_to root_url, notice: \"Nice Try\"\n end\n end", "def profile\n\t\t@user = User.where(username: params[:username])[0]\n\t\t@pics = Picture.where(user_id: @user.id).reverse\n\n\tend", "def info\n\t@user = User.find(params[:id])\n end", "def user_details\n\t\t@user_data = Hash.new\n\t\t@user_data[\"first_name\"] = @first_name\n\t\t@user_data[\"username\"] = @username\n\t\t@user_data[\"password\"] = @password\n\t\t@user_data[\"balance\"] = @balance\n\tend", "def show\n @profile = Profile.find(params[:id]) || current_user.profile\n end", "def userinfo\n object.fetch(:userinfo) {\n @object[:userinfo] = (format_userinfo(\"\") if @object[:user])\n }\n end", "def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end", "def show\n @user = User.find(params[:id])\n @links = Link.where(user_id: @user.id)\n @link = Link.new\n render :full_profile\n end", "def show\n @profile = current_user.profile\n @hash = Gmaps4rails.build_markers(@profile) do |profile, marker|\n marker.lat profile.latitude\n marker.lng profile.longitude\n marker.infowindow profile.first_name\n end\n end", "def show\n @user = User.find(params[:id]) \n @user_me = retrieve_authenticated_user\n end" ]
[ "0.7608364", "0.75591236", "0.7515988", "0.75147974", "0.75045276", "0.7493715", "0.7471606", "0.74644065", "0.7442741", "0.7392975", "0.73781127", "0.73598516", "0.7304206", "0.7304206", "0.7304206", "0.7304206", "0.7304206", "0.7304206", "0.7303646", "0.72504574", "0.72158", "0.72135437", "0.7192339", "0.718392", "0.71641", "0.7163514", "0.716059", "0.7135316", "0.7122217", "0.7119034", "0.70924777", "0.7083446", "0.70812035", "0.7078089", "0.70669234", "0.704504", "0.7036861", "0.70145655", "0.7006672", "0.70029724", "0.6986301", "0.6978686", "0.6966057", "0.6951855", "0.693103", "0.6916691", "0.69121283", "0.6906113", "0.6902839", "0.68870556", "0.6883335", "0.68795466", "0.68775696", "0.6872984", "0.6872966", "0.6871358", "0.6871358", "0.68674535", "0.68674296", "0.6867143", "0.6859597", "0.6855537", "0.68463576", "0.6839003", "0.68281007", "0.6823821", "0.68139803", "0.6813702", "0.68134266", "0.6811236", "0.68103266", "0.6809228", "0.6801982", "0.68007326", "0.6799347", "0.6795723", "0.6789685", "0.67868316", "0.6783025", "0.6778885", "0.6765675", "0.6756798", "0.6754872", "0.6753245", "0.67379457", "0.6724439", "0.67242146", "0.6721783", "0.6718814", "0.671792", "0.67172784", "0.6716925", "0.67035383", "0.66968334", "0.6694123", "0.6689574", "0.66738653", "0.6671034", "0.66691065", "0.6666575", "0.6662679" ]
0.0
-1
edit user profile view
def edit @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n\t\t@user = User.find( params[:user_id] )\n\t\t@profile = @user.profile\n\tend", "def profile_edit\n @user = User.find(current_user.id)\n end", "def edit\n @user = User.find (params[:user_id])\n @profile = @user.profile\n end", "def edit\n user = User.find(params[:user_id])\n @profile = user.profile\n end", "def edit\n @user = User.find(params[:user_id])\n @profile = @user.profile\n \n end", "def user_profile_edit\n\n\n end", "def edit_profile\n \t@user = UsersService.findUserById(params[:id])\n \tuser = UsersService.findUserById(params[:id])\n \t@user_profile_form = UserProfileForm.new(UserProfileForm.attributes(user, :edit_profile))\n end", "def edit\n @profile = User.find(params[:id])\n end", "def edit_profile\n @user = User.find params[:id]\n end", "def edit\n @user = current_user\n @profile = current_user.profile\n end", "def edit_profile\n \t@user = current_user\n end", "def edit_profile\n end", "def edit\n @profile = Profile.find(current_user.id)\n end", "def edit\n @user.profile ||= Profile.new\n @profile = @user.profile\n end", "def edit_profile\n @user = UserService.getUserById(params[:id])\n @profile_form = ProfileForm.new(ProfileForm.initialize(@user, :new_profile))\n end", "def edit\n @title = \"Edit Profile\"\n @user = current_user\n @user.profile ||= Profile.new\n @profile = @user.profile\n if param_posted?(:profile)\n if @user.profile.update_attributes(params[:profile])\n flash[:notice] = \"Changes saved.\"\n # redirect_to :controller => \"profile\", :action => \"index\"\n end\n end\n end", "def edit\n\t@user = User.find(params[:id])\n\t@title = \"Edit user\"\n end", "def edit\n @page_title = 'Edit user'\n @user = User.find(params[:id])\n end", "def edit\n @user.build_user_profile unless @user.user_profile\n end", "def update\n if current_user.update(user_params)\n redirect_to user_path(current_user), notice: 'Your profile was successfully updated.'\n else\n render :edit\n end\n end", "def edit\n \n @user = User.find(params[:id])\n \n end", "def edit\n redirect_to action: 'edit_profile'\n end", "def update\n if current_user.update(user_params)\n redirect_to current_user, notice: t(\"profile.updated\")\n else\n render \"edit\"\n end\n end", "def edit\n\t\tRails.logger.warn(\"Rendering account settings page.\")\n\t\t@user = User.find(params[:id])\n\tend", "def update\n @user = User.find_by_id(current_user.id)\n if @user.update(user_params)\n redirect_to profile_index_path\n else\n render profile_edit_path\n end\n end", "def update\n # Retrieve user from the database\n @user = User.find(params[:user_id])\n # Assign user profile to an instance variable\n @profile = @user.profile\n # Mass assign edited profile attributes and save. \n if @profile.update_attributes(profile_params)\n flash[:success] = \"Profile updated!\"\n # Redirect to profile page. \n redirect_to user_path(id: params[:user_id])\n else\n # TODO: don't dump the user's inputs if save to database fails. \n render action: :edit\n end\n end", "def edit\n #set @profile to the current profile, which was linked from the home index view\n @profile = Profile.find(params[:id]) \n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n case form[:steps].last[:option].to_i\n when 1\n user = User.load\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password],\n gopay: user.gopay\n )\n user.save!\n form[:user] = user\n view_profile(form)\n when 2\n view_profile(form)\n else\n form[:flash_msg] = 'Wrong option entered, please retry'\n edit_profile(form)\n end\n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n case form[:steps].last[:option].to_i\n # when edit profile\n when 1\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password]\n )\n user.save!\n\n # Assigning form[:user] with user object\n form[:user] = user\n\n # Returning the form\n form\n # when 2 back to view profile\n when 2\n\n view_profile(form)\n else\n form[:flash_msg] = \"Wrong option entered, please retry.\"\n edit_profile(form)\n end\n view_profile(form)\n end", "def edit\n user = User.find_by username: params[:username]\n if !user || user.id != session[:user_id]\n flash[:error] = \"You are not authorized to edit this user's profile.\"\n redirect_to user_path params[:username]\n else\n @user = User.find_by username: params[:username]\n end\n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n case form[:steps].last[:option].to_i\n when 1\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password]\n )\n user.save!\n\n form[:user] = user\n view_profile(form)\n form\n when 2\n view_profile(form)\n else\n form[:flash_msg] = 'Wrong option entered, please retry.'\n edit_profile(form)\n end\n end", "def edit\n # return an HTML form for editing a specific user\n @user = User.find(params[:id])\n end", "def edit\n\t\t@user = User.find(params[:id])\n\tend", "def edit\n\t\t@user = User.find(params[:id])\n\tend", "def edit\n\t\t@user = User.find(params[:id])\n\tend", "def edit\n\t\t@user = User.find(params[:id])\n\tend", "def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n redirect_to @user, :notice => {\n :message => \"Your profile was updated.\"\n }\n else\n render :edit\n end\n end", "def edit\n @user = User.all.deep.find(current_user.id)\n authorize! :edit, @user\n\n render 'users/settings'\n end", "def update\n @user = User.find( params[:user_id] ) #establish which user profile we are editing \n @profile = @user.profile #store user profile data in @profile variable \n if @profile.update_attributes(profile_params) # checking in db if data is updated\n flash[:success] = \"Profile Updated!\"\n redirect_to user_path( params[:user_id] ) # display the edited profile\n else\n render action: :edit #redirecting user to edit page\n end\nend", "def update\n # Main content\n @user = User.find(params[:id])\n if @user.update_attributes(user_params)\n flash[:success] = \"Profile has been updated\"\n redirect_to users_path\n else\n render 'edit'\n end\n end", "def update\n @user = User.find(current_user.id)\n @profile = @user.profile\n \n if @profile = params[:profile]\n redirect_to user_profile_path(current_user.name)\n else\n redirect_to edit_user_profile_path\n end\n end", "def update\n @profile = Profile.find_by_user_id params[:user_id]\n\n if @profile.update_attributes(params[:profile])\n redirect_to user_profile_path(params[:user_id])\n else\n flash[:alert] = @profile.errors.full_messages.join(\",\")\n render :template => \"profiles/edit\"\n end\n\n end", "def update\n @profile = User.find(params[:id])\n \n respond_to do |format|\n if @profile.update(profile_params)\n format.html { redirect_to profile_path(@profile) }\n else\n flash[:alert] = \"unable to update. Please check the data.\"\n format.html { render 'edit' }\n end\n end\n end", "def edit\n @userToEdit = User.find(params[:id])\n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n case form[:steps].last[:option].to_i\n when 1\n valid_msg = User.validate(form)\n if !valid_msg.empty?\n form[:flash_msg] = valid_msg\n edit_profile(form)\n else\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password]\n )\n user.save!\n # Assigning form[:user] with user object\n form[:user] = user\n form[:flash_msg] = 'Your profile has been updated.'\n end\n when 2\n form[:flash_msg] = 'You canceled your profile changes.'\n else\n form[:flash_msg] = 'Wrong option entered, please retry.'\n edit_profile(form)\n end\n\n view_profile(form)\n end", "def edit\n @user.build_profile if @user.profile.blank?\n end", "def editProfile\n user = User.find(session[:user_id])\n user.firstName = params[:user][:firstName]\n user.lastName = params[:user][:lastName]\n user.age = params[:user][:age]\n user.about = params[:user][:about]\n user.location = params[:user][:location]\n user.save\n redirect_to :controller => :users, :action => :home\n end", "def update\n unless current_user == @user.user\n respond_to do |format|\n format.html { redirect_to profiles_path, alert: 'You have improper permissions to edit this profile.' }\n format.json { head :no_content }\n end\n return\n end\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to profile_path, notice: 'Profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n # find the user we want to edit by id\n # this will send the @user to the edit page with a form\n @user = User.find(params[:id])\n end", "def update\n\t\t# if admin, allow editing user's profile\n if current_user.is_admin?\n @user = User.find(params[:id])\n else\n @user = current_user\n end\n\n\t\t# update user profile with regards to the parameters\n if @user.update_attributes(params[:user])\n gflash :success => \"Profile Successfully Updated\"\n if current_user.is_admin?\n\t\t\t\t# if admin, go back to the user list\n redirect_to :action => 'list'\n else\n\t\t\t\t# if normal user, go back to profile page\n redirect_to :action => 'profile', :username => current_user.login\n end\n else\n\t\t\t# update_attributes failed, go back to edit page\n render :action => 'edit', :id => params[:id]\n end\n end", "def update\n\t\t@user = User.find( params[:user_id] )\n\t\t@profile = @user.profile\n\t\tif @profile.update_attributes(profile_params)\n\t\t\tflash[:success] = \"Page Updated\"\n\t\t\tredirect_to user_path(id: params[:user_id] )\n\t\telse\n\t\t\trender action: :edit\n\t\tend\n\tend", "def edit\n @user = User.find(params[:id])\n end", "def edit\n @user = User.find(params[:id])\n end", "def edit\n set_user\n end", "def edit\n @title = \"Edit user\"\n @user = User.find(params[:id])\n\n end", "def edit\n\t\t@user = User.find(params(:id))\n\tend", "def edit\n @user = User.find(params[:user_id])\n end", "def edit\n @user = User.find(params[:user_id])\n end", "def edit\n # @user = User.find(params[:id]) -- not needed bc of correct_user\n end", "def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n redirect_to users_path(), notice: \"Profile updated!\"\n else\n render 'edit'\n end\n end", "def edit\n @user = User.find(params[:id])\n # @user は編集対象のユーザー\n # current_user はログインしているユーザー \n\n end", "def edit\n @user = current_user\n render 'edit'\n end", "def edit\n @user = User.find(params[:id])\n end", "def edit\n @user = User.find(params[:id])\n @user.update(user_params)\n end", "def edit\n\t@user = User.find(params[:id])\nend", "def update\n # Button press on edit page\n\n # Read the user and update the attributes (don't save at this point)\n @user = User.find(params[:id])\n render_error h \"Der Spezialbenutzer #{@user.username} kann nicht editiert werden.\" and return if @user.special?\n @user.attributes=params[:user] if params[:user]\n\n # Subpages\n select_person and return if params['select_person']\n\n if params['commit']\n # 'Save' button\n render 'edit' and return if !@user.save\n\n flash[:notice] = \"Der Benutzer #{@user.username} wurde gespeichert.\"\n redirect_to_origin(default=@user)\n return\n end\n\n render 'edit'\n end", "def edit\n @user = User.find(session[:user_id])\n end", "def edit\n\t\tthe_user_id = params[\"id\"]\n \t@user = User.find_by(:id => the_user_id)\n\tend", "def edit\n # this finds the current user\n @user = User.find params[:id]\n end", "def edit \t\t\t\t\t\t\t #render user page \n \t@user = User.find(session[:user_id])\n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password]\n )\n\n case form[:steps].last[:option].to_i\n when 1\n error = user.validate\n if error.empty?\n user.save!\n form[:user] = user\n form[:flash_msg] = \"Your account was successfully updated\"\n view_profile(form)\n else\n form[:flash_msg] = [\"Your account was not successfully updated\"]\n form[:flash_msg] << error\n view_profile(form)\n end\n when 2\n view_profile(form)\n else\n form[:flash_msg] = \"Wrong option entered, please retry.\"\n edit_profile(form)\n end\n\n form\n end", "def edit\n @profile = @author.profile\n end", "def edit\n \n # Pass through the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Check that the current user is the specified user, or an\n # administrator\n unless @user == current_user or admin_logged_in?\n flash[:error] = 'You cannot edit the profile of another user.'\n redirect_to :controller => 'sessions', :action => 'new'\n else\n render :layout => 'dialog'\n end\n end", "def update \n # note the use of user_params strong parameters to avoid mass assignment vulnerability\n # see below what attributes are allowed to be passed in the user_params definition\n if @user.update_attributes(user_params)\n flash[:success] = \"Profile updated\"\n redirect_to @user\n # rerender the edit page on unsuccessful update\n else\n render 'edit'\n end\n end", "def edit\r\n \t@user = current_user\r\n end", "def edit\n \t@user = User.find params[:id]\n end", "def update\n if current_user.update_attributes(user_params)\n redirect_to current_user, notice: 'Profile successfully updated.'\n else\n render 'edit'\n end\n end", "def edit\n\t\t\t@user = User.find(params[:id])\n\t\t\t@jobseeker1 = Jobseeker.find_by(:user_id => @user.id)\n\n\t\tif @jobseeker1\n\t\t\t@jobseeker = @jobseeker1\n\t\t\t@title = \"Edit Profile\"\n\t\telse\n\t\t\tflash[:notice] = \"we don't have your profile yet, create one!\"\n\t\t\t#don't use render 'new' because it refers to @jobseeker from this action(and in this section of action, its nil.)\n\t\t\tredirect_to new_jobseeker_path\n\t\tend\n\t\t\n\tend", "def update\n return redirect_to(@user) if @user != current_user\n if @user.update_attributes params[:user]\n flash[:notice] = I18n.t('profile_updated')\n return redirect_to(@user)\n else\n render :template => 'users/edit'\n end\n end", "def edit\r\n jump_to(\"/profiles/#{session[:account_id]}/basic\")\r\n end", "def update\n @profile = Profile.find(params[:id])\n @profile.user_id = current_user.id\n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = 'Profile was successfully updated.'\n format.html { redirect_to(show_user_path(current_user.username)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.8624624", "0.8552577", "0.85287625", "0.84501415", "0.8438943", "0.8346119", "0.8324389", "0.8299431", "0.824615", "0.81268436", "0.81160253", "0.81139135", "0.8058832", "0.7926156", "0.79151404", "0.7912449", "0.77825755", "0.77814955", "0.7771191", "0.77525836", "0.7749092", "0.77347094", "0.77298206", "0.7726107", "0.76733327", "0.76643604", "0.76501757", "0.76423717", "0.7640707", "0.7640421", "0.7640312", "0.7633693", "0.7604044", "0.7604044", "0.7604044", "0.7604044", "0.75965357", "0.75917673", "0.7591727", "0.758688", "0.75789917", "0.75765765", "0.7569266", "0.75624275", "0.7555564", "0.75515294", "0.7540757", "0.7535111", "0.7525341", "0.75177324", "0.75125766", "0.750329", "0.750329", "0.75016326", "0.74961203", "0.74920547", "0.74919534", "0.74919534", "0.7485736", "0.7485227", "0.7482766", "0.7477659", "0.7472678", "0.7471591", "0.74696976", "0.74691075", "0.7465213", "0.7461816", "0.74544895", "0.74533755", "0.74472666", "0.74466974", "0.7446165", "0.7443067", "0.7441188", "0.74405223", "0.74395186", "0.7435248", "0.7434903", "0.7433006", "0.74319744" ]
0.0
-1
add an item and optional quantity remove an item list Update quantity Print view the list Method create_list Method to create a list input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: create new list LOOP Through Items on List If Item already exists Add 1 to the quantity Else it creates it with quantity 1 End IF End Loop call the 'print_list' method to display the list. output:nothing Method to add an item to a list add_item input: item name and optional quantity steps: check if item already exists If Item already exists Add 1 to the quantity Else it creates it with quantity 1 if no quantity, quantity if there End IF output: nothing Method to remove an item from the list input: item name steps: Checks if item exists on list If it exists Delete Item Print "item" deleted Else print "item" is not on list on screen. output: Method to update the quantity of an item input: item name and quantity steps: Check if item Exists If it exists change quantity of item Print quantity item now Else Print item doesn't exist. output: nothing Method to print a list and make it look pretty input: nothing steps: Loop through list print item and quantities End Loop output: nothing INITIAL CODE:
def initialize_list(desired_start_items) arr = desired_start_items.split(' ') # The each loop will run once for every element in the array. arr.each do |item_name| add_item(item_name) # this will be updating $list_items end display_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list\r\n list[item] = quantity\r\n# output: shopping list with the added item and quantity\r\n printlist(list)\r\nend", "def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# output: complete list, updated\r\nend", "def update_item(list, item, quantity)\r\n add_item(list, item, quantity)\r\n# input: Shopping list, item to be updated, new quantity\r\n# steps:\r\n # Use shopping list as input\r\n # Use item to be updated as input\r\n # Use new quantity to be updated as input\r\n # Update the quantity of the item on the list\r\n # list[item] = quantity\r\n# output: shopping list with updated quantity\r\n # printlist(list)\r\nend", "def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend", "def add_to_list(list,item,quantity)\n\tupdate_item(list,item,quantity)\nend", "def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend", "def update_quantity (grocery_list, item, quantity)\n if grocery_list[item] == nil\n \tputs \"Item not on list.\"\n else\n \tadd_item(grocery_list,item,quantity)\n end\n return grocery_list\n print_list(grocery_list)\nend", "def add_item(item,amount=1,the_lists)\r\n\t# steps: accept 2 arguments. Item name and Quantity (with default)\r\n\tif the_lists[item] != nil\r\n\t puts \"Item is already on the List !\"\r\n\t puts \"Added amount to the quantity\"\r\n\t the_lists[item] += amount\r\n\telse\r\n the_lists[item] = amount\r\n\tend\r\n\r\n\tprint_list(the_lists)\r\nend", "def create_list(input_string)\n grocery_list = {}\n items = input_string.split(' ')\n items.each do |item|\n add_item_to_list(grocery_list, item, 1)\n end\n\n print_list(grocery_list)\n\n add_item_to_list(grocery_list, \"milk\", 1)\n update_item_from_list(grocery_list, \"Lemonade\", 2)\n update_item_from_list(grocery_list, \"Tomatoes\", 3)\n update_item_from_list(grocery_list, \"Onions\", 10)\n update_item_from_list(grocery_list, \"iceCream\", 20)\n\n print_list(grocery_list)\n\n remove_item_from_list(grocery_list, \"IceCream\")\n\n print_list(grocery_list)\n\nend", "def update_quanity(list, item, quantity)\r\n# input: list, item and quantity to be updated to\r\n# steps:\r\n # check if item exists\r\n # update quantity\r\n list[item] = quantity\r\n # print success \"your cart has been updated!\"\r\n puts \"The quantity for #{item.upcase} has been updated in your grocery list!\"\r\n p list\r\n# output: updated list with new quantity\r\nend", "def add_item(list_name, item, quantity=1)\r\n# input: list, item name, and optional quantity\r\n# steps: add item and its quantity to the hash\r\n list_name.store(item, quantity)\r\n# output: hash with new item\r\n p list_name\r\nend", "def create_list(list_name,list_of_items)\n # create empty array\n list_name = []\n # for each item in string, use add item method to add item to grocery list (set default quantity to 1)\n shopping_items = list_of_items.split(' ')\n shopping_items.each do |thing_to_add|\n add_item_to_list(list_name,thing_to_add,1)\n end\n # print the list to the console\n print_list(list_name)\nend", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, add_item, add_quantity=1)\n# steps:\n # Add item as key and quantity as value to final_list hash(item and quantity will be user inputs)\n list[add_item] = add_quantity\n # Return updated hash\n list\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_items(list, item_name, quantity=0)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend", "def update(item, quantity, list)\n\t# steps: if the item is in the list\n\tif list.include? item.to_sym\n\t\t# update the quantity\n\t\tlist[item.to_sym] = quantity\n\telse \n\t\tadd_item(item, quantity, list)\n\tend\n\t# output: return the updated list\n\tlist\nend", "def add_item(list, name, quantity = 1) \r\n# input: item name and optional quantity\r\n# steps: \r\n# create add method with name and optional quantity arguments\r\n# add name and quantity to hash\r\n list[name] = quantity\r\n# output: print \"your item has been added to the hash\"\r\n return list\r\nend", "def update_item_quantity(list, updateitem, new_qty, print=true)\n\t# input: list, item name (string), new quantity (int or string)\n\t# output: updated list\n\n\tmatch_index = find_item(list, updateitem)\n\tif not match_index\n\t\t# alert if not found\n\t\tmsg = \"\\n\\n** WARNING update_item_quantity failure: item \"\n\t\tmsg += \"\\\"#{removeitem}\\\" not found in list. List unchanged. **\"\n\t\treturn list\n\telse\t\t\t\n\t\t# update list\n\t\tlist.delete_at(match_index)\n\t\tlist.insert(match_index, [updateitem.strip.capitalize, new_qty.to_s])\n\t\t# print success message\n\t\tmsg = \"\\n\\nList updated: item '#{updateitem}' quantity \"\n\t\tmsg += \"updated to '#{new_qty}'.\\n\"\n\t\tputs msg\n\t\t# print updated list\n\t\tprint_list(list) if print\n\t\treturn list\n\tend\nend", "def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend", "def add(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(my_list, item, quantity)\r\n #input: a string seperated by an integer \r\n #steps: use a method that adds an item and quantity to the hash.\r\n my_list.store(item, quantity)\r\n # use a hash or store method hash.merge!(key => value) \r\n #output = hash with the updated item/quantity. \r\n my_list\r\n \r\nend", "def add_item(list, item, quantity)\n\n\tlist[item] = quantity\n\tlist\n\nend", "def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend", "def add_new_items(list, item_name, quantity=1)\n list[item_name] = quantity\n list\nend", "def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend", "def updating_item(list,item,quantity)\r\n\r\n adding_item(list,item, quantity)\r\n\r\nend", "def add_item(list, item, quantity=0)\n\tlist[item] = quantity\n\tlist\nend", "def add_item(list, item, quantity)\n\tlist[item] = quantity\n\tp list\nend", "def add_item(item, quantity, list)\n\t# steps: \n\t# if the item is already in the list\n\tif list[item.to_sym] \n\t\t# add to the quantity\n\t\t#list[item.to_sym] = list[item.to_sym] + quantity\n\t\tlist[item.to_sym] += quantity\n\t# otherwise\n\telse\n\t\t# make a new key with the input quantity\n\t\tlist[item.to_sym] = quantity\n\tend\n\t# output:\n\t\t# updated list\n\tlist\nend", "def add_item(grocery,item_name,quantity)\n # input: list, item name, and optional quantity\n # steps: insert item_name as a key and quantity as a value to the hash \n grocery[item_name] = quantity\n # output:display the latest list\n display_list(grocery)\nend", "def add_item_to_list(grocery_list, grocery_item, quantity = 1)\n grocery_list.store(grocery_item,quantity)\n puts \"I've added #{grocery_item} to the list. Please pick up #{quantity} of these.\"\nend", "def add_list(item_name, item_list, quantity = 1)\n item_list[item_name] = quantity\nend", "def add_change_items(list, item, quantity)\r\n\t#NOTE if changing item make sure to type in 'item' correctly\r\n list[item] = quantity\r\n p list\r\nend", "def add_item(new_list, item_name, quantity=1)\r\n \r\n new_list[item_name] = quantity\r\n \r\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def update_list(list, item_name, quantity=1)\r\n list[item_name] = quantity\r\n list\r\nend", "def update_list(list, item, quantity)\n\tlist[item] = quantity\n\tp list\nend", "def adding_item(list,item,quantity = 1)\r\n# if quantity == nil\r\n# quantity = 1\r\n# end\r\n list[item] = quantity\r\n list\r\nend", "def update(list, item, qty)\n add_item(list, item, qty)\nend", "def add_item_to_list(list_name,item_to_add,quantity_to_add = 1)\n#create a hash element with the item name and the quantity, if specified\n#if no quantity is specified, default value = 1\n new_item = { \n item_name: item_to_add,\n quantity: quantity_to_add\n }\n# insert the hash into array \n list_name.push(new_item)\n new_item\nend", "def lets_go_shopping\r\n\r\n current_list = new_grocery_list\r\n add_new_item(current_list)\r\n remove_an_item(current_list)\r\n update_item_quantity(current_list)\r\n \r\n current_list.each do |key, value|\r\n puts \"Food: #{key}\"\r\n puts \"Qty: #{value}\" \r\n end\r\nend", "def create_list(items)\n\titem_list = {}\n\titem_array = items.split(\" \")\n\tdefault_quantity = 1\n\titem_array.each do |item|\n\t\titem_list[item] = default_quantity\n\tend\n\tpretty_list(item_list) \nend", "def update_quantity(grocery,item_name,new_quantity)\n # input:list, item name, and new_quantity\n # steps: change old value of item_name with the new_quantity\n grocery[item_name] = new_quantity\n # output: display the latest list\n display_list(grocery)\nend", "def update_quantity(list, item_name, quantity)\n # steps:\n # check IF item is included in list\n # update the item’s quantity\n # ELSE, print a message to the user\n list.include?(item_name) ? list[item_name] = quantity : puts(\"No #{item_name} on the list.\")\n\n # output: return the updated hash or the original hash\n list\nend", "def add_item(list, item_name, optional_quantity)\n\nlist[item_name] = optional_quantity\n\n# input: list, item name, and optional quantity\n# steps:\n # Add new hash key based on item name\n # Tell method there may or may not be a argument passed in for quantity\n # assign quantity to 'optional-quantity' argument in method definition\n # Access method that contains initialized hash def add_item(create_list, item_name, quantity = 3)\n# output:\n # updated grocery list\nend", "def add_item(item,quantity,first_list)\n if quantity == \"\"\n quantity = 1\n else\n quantity\n end\n first_list[item] = quantity\n\nend", "def add_item(list, item, quantity=1)\r\n\tlist[item] = quantity\r\n#\tp list\r\nend", "def shopping_list(items)\n\t# separate the items into an array\n\titems = items.split\n\tputs \"Here are the items you entered.\"\n\tputs items\t\n\t# create the list to add items into.\n\t$list = Hash.new\n\t# enter quantity of each item.\n\titems.each_index do |x|\n\t\tputs \"Enter quantity with no spaces for #{items[x]}.\"\n\t\tquantity = gets.chomp\n\t\t# assign each quantity to the item and add to list\n\t\t$list[:\"#{items[x]}\"] = quantity\n\tend\n\tputs \"Here is your shopping list.\"\n\tputs $list\nend", "def add_item(grocery_list,item,quantity = nil)\n\tif quantity == nil \n\t\tgrocery_list[item] = 1\n\telse\n\t grocery_list[item] = quantity\n\tend\n\treturn grocery_list\n\tprint_list(grocery_list)\nend", "def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend", "def add_item(shopping_list, item, quantity=1)\r\n\r\n\tshopping_list[item] = quantity\r\n#\treturn shopping_list\r\nend", "def input (list, item, quantity)\n\tlist[item] = quantity\nend", "def additem(list, item, number = 1)\n# input: hash, item name and optional quantity\n# steps: push an item into the hash\n list.store(item, number)\nend", "def printlist(list)\r\n# input: shopping list\r\n# steps:\r\nlist.each {|item, quantity| puts \"Please buy #{quantity} #{item}\"}\r\n # Print each item on the shopping list in a readable fashion\r\nend", "def print_list(title,list)\n# steps:\n # print title of list (will ask user for this input)\n puts \"**********************\"\n puts \" #{title.upcase}:\"\n puts \"**********************\"\n # print headers of item and quantity\n puts \" # ITEM\"\n puts \"----------------------\"\n # print each item and it's quantity, bulleted if possible\n list.each {|item,quantity| puts \" #{quantity} #{item}\"}\n puts \"**********************\"\n # print today's date\n date = Time.new\n puts \" Made on: #{date.month}/#{date.day}/#{date.year}\"\nend", "def add_item(item, quantity, list)\r\n list[item] = quantity\r\n p list\r\n list\r\nend", "def add_item(existing_list, new_item, item_integer)\n\t# input: item name and optional quantity\n\t# steps: pass in item name as key and assign value\n\texisting_list[new_item] = item_integer\n\t# output: hash\n\tp existing_list\nend", "def list_add(list, item_name, quantity=1)\n list[item_name] = quantity\n p list\nend", "def update_quantity(list, item, quantity)\n\tlist[item] = quantity\n\tp list\nend", "def add_item(item,quantity,list)\n\tlist[item] = quantity\nend", "def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity.to_i\n\tlist\nend", "def add_item(name, quantity, list)\n list[name] = quantity\n p list\n return list\nend", "def update_quantity (grocery_list, item, quantity)\n\tif grocery_list[item] == nil\n\t\tputs \"Item not on list.\"\n\telse\n\t\tadd_item(grocery_list, item, quantity)\n\tend\n\treturn grocery_list\nend", "def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend", "def update_quantity(new_list, item_name, quantity)\r\n \r\n new_list[item_name] = quantity\r\nend", "def add_item(shopping_list, item, quantity)\r\n\tshopping_list[item] = quantity\r\n\tshopping_list\r\nend", "def update_quantity(list, item, quantity)\n\tlist[item] = quantity\n\tlist\nend", "def add_item (list, item, quantity = 1)\n\tlist[item] = quantity\n\treturn list\nend", "def update(list, item, quantity)\n\tlist[item] = quantity\n\tlist\nend", "def add_item(list, item, qty=nil, print=true)\n\t# input: \n\t# existing list, \n\t# item name (string), \n\t# quantity qty (int or string or nil(default)), \n\t# print? (t(default)/f)\n\t# output: updated list (array)\n\t\n\t# format list item \n\tif qty\n\t\tqty = qty.to_s\n\tend\n\titem = [item.strip.capitalize, qty]\n\t# append to list\n\tlist = list.push(item)\n\t# print list if print=true\n\tif print\n\t\tputs \"\\n\\nList updated: added item '#{item}'\\n\"\n\t\tprint_list(list)\n\tend\n\treturn list\nend", "def update_quantity(grocery_list,item,new_quantity)\n # if item on the list\n grocery_list.store(item,new_quantity)\n puts \"When you pick up #{item}, make sure to grab #{new_quantity} instead.\"\nend", "def add_item\n\t puts \"What is the name of the item you'd like to add?\"\n\t\t@item_name = gets.chomp\n\t\tputs \"And how many?\"\n\t\t@quantity = gets.chomp.to_i\n\t\tif @quantity <= 0\n\t\t puts \"Please enter a number higher than 0.\"\n\t\t puts \"(Also, must be '1' not 'one'.)\"\n\t\telse\n\t\t @grocery_list[@item_name] = @quantity\n\t\tend\n\t\tget_item\n\tend", "def update(list, item, quantity)\r\n\tif list[item] \r\n\tlist[item] = quantity\r\n\telse\r\n\t\tputs \"Your item is not on the list\"\r\n\tend\r\n\tlist\r\nend", "def create_list_items(input_string)\n \n hsh = {}\n \n # create an array containing each item \n array_input = input_string.split(' ')\n \n # create a hash from the array (iterate), containing the information of key/value pairs \n array_input.each do |item|\n # set default quantity as value\n hsh[item] = 0\n end \n \n # print the list to the console (we will use the last method)\n print_list(hsh)\n \n # output: hash data structure of key/value pairs\n return hsh\nend", "def add_item(list, item, quantity=0)\n list[item] = quantity\n list\nend", "def add(list, item, quantity)\r\n# input: item name and optional quantity\r\nlist.include?(item) ? list[item] += quantity : list[item] = quantity\r\np list\r\nend", "def add(list, item, quantity)\r\n\tlist[item] = quantity\r\n\tlist\r\nend", "def update_item(list, name, quantity)\r\n # steps: \r\n # check if item is present\r\n if list[name] != nil\r\n # update with new amount\r\n list[name] = quantity\r\n end\r\n return list\r\n # output: list\r\nend", "def print_list(list)\r\n# input: completed list\r\n# steps:\r\n # iterate over list and print formatted list\r\n puts \"Your Grocery List\"\r\n list.each do |item, quantity|\r\n puts \"#{item}, qty: #{quantity}\"\r\n end\r\n # format: each item with its own line\r\n # \"item - quantity\"\r\n# output: implicit return of list\r\nend", "def update_quantity(grocery_list, item, quantity)\r\n add_item(grocery_list, item, quantity)\r\n \r\nend", "def add_item(list_item,user_list)\n#user_list is later defined/used to store a new list of information created when create_list method is called.\n#Uses create_list method to format information properly before allowing edits and updates to be done. \n#user_list = create_list(string) \n user_list[list_item] = 1\n user_list\nend", "def add_item(list, item, qty=1)\n list[item] = qty\n p \"#{item} : #{list[item]}\"\nend", "def add_an_item(list_hash,item_name)\n puts 'Adding the item: #{item_name}.'\n puts 'Specify a quantity or type \"default\".'\n quantity = gets.chomp.to_s\n\n if quantity.downcase == 'default'\n quantity = '1'\n end\n\n puts list_hash\n\n if !list_hash[item_name]\n puts 'Added the item: #{item_name}.'\n list_hash[item_name] = quantity\n else\n puts 'Item already exists.'\n end\n\n list_hash\n\nend", "def print_list(list, item_name, quantity)\n list.each do |item|\n puts \"We need #{quantity} #{item_name}\"\n end\nend", "def update_quantity(grocery_list, item_name, qty = 1)\r\n\tgrocery_list = add_item(grocery_list, item_name, qty)\r\n\treturn grocery_list\r\nend", "def update_quantity(grocery_list, item_name, quantity)\n\tadd_item(grocery_list, item_name, quantity)\n\treturn grocery_list\nend", "def add_item(list, item, quantity)\n list[item] = quantity\n p list\nend", "def add_list(list,new_item,quantity=1)\n list[new_item] = quantity\n list\nend", "def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend", "def update_item(list, name, change_in_quantity)\n normalize_string(name)\n if (list[name] + change_in_quantity <= 0)\n remove_item(list, name)\n else\n list[name] += change_in_quantity\n return list\n end\nend", "def add_item(list, item_name_string, quantity=1)\r\n\titem_key = item_name_string.to_sym\r\n\tlist[item_key] = quantity\r\n\treturn list\r\nend", "def list_adder(list, item_name, quantity=1)\n\tlist.store(item_name, quantity)\n\tp list\nend", "def add_item(list, item, quantity)\n list[item] = quantity\n list\nend", "def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def list_add(list, item_name, quantity=1)\r\n list[item_name] = quantity\r\n p list\r\nend" ]
[ "0.8221839", "0.7965753", "0.770645", "0.7647205", "0.75484306", "0.75223047", "0.7494351", "0.7486487", "0.74571157", "0.7446799", "0.7404277", "0.74034816", "0.73914915", "0.73914915", "0.73631907", "0.7359511", "0.73593175", "0.73593175", "0.73519444", "0.7350253", "0.7345117", "0.7341208", "0.7337538", "0.72939646", "0.7271828", "0.7255579", "0.7240904", "0.72059184", "0.71901417", "0.7181211", "0.71718735", "0.71689516", "0.7164969", "0.71600014", "0.71492845", "0.71468216", "0.7135604", "0.71295404", "0.71062374", "0.71062374", "0.7102724", "0.7098967", "0.7097649", "0.7095604", "0.7083032", "0.7077098", "0.7076418", "0.7074812", "0.7064544", "0.70636845", "0.7050642", "0.70345813", "0.7031952", "0.7027249", "0.7011328", "0.70078903", "0.69984263", "0.69978696", "0.6992597", "0.69910675", "0.69891125", "0.69860405", "0.6980943", "0.69802856", "0.6979519", "0.69789004", "0.6971002", "0.69702715", "0.69636947", "0.6960518", "0.69550264", "0.6952504", "0.69484335", "0.69446975", "0.693996", "0.69393224", "0.6937756", "0.69360906", "0.693415", "0.6931989", "0.6930416", "0.6924768", "0.69245595", "0.6920868", "0.6919233", "0.6916206", "0.69117033", "0.69102293", "0.69081455", "0.69043756", "0.69023556", "0.69022197", "0.6900012", "0.68995297", "0.68974656", "0.68933594", "0.68930787", "0.6892638", "0.6892105", "0.68919593", "0.6885247" ]
0.0
-1
assert(FileTest.zero?('test/test_fq/_lock')) assert(FileTest.zero?('test/test_fq/_log')) assert_equal(0, Dir.glob('test/test_fq/_tmp/').length, Dir.glob('test/test_fq/_tmp')) assert_equal(1, Dir.glob('test/test_fq/que/').length) assert_equal(0, Dir.glob('test/test_fq/run/').length) assert_equal(0, Dir.glob('test/test_fq/pause/').length) assert_equal(0, Dir.glob('test/test_fq/done/').length) assert_equal(0, Dir.glob('test/test_fq/_err/').length)
def test_insert_file job1 = @fq.insert_file(@tmp_name1) assert(job1, 'invalid job1: false : ' + @fq.read_log) assert_equal({:que => 1}, @fq.all_lengths) assert_equal(1, @fq.length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_files\n `touch ../harness/test/foo ../harness/test/bar`\n f = @td.files\n assert_equal(2, f.length)\n assert(f.find \"foo\")\n assert(f.find \"bar\")\n end", "def test_basic_file_ops\n assert_equal(0, @dir.file_count(), \"directory should be empty\")\n assert(! @dir.exists?('filename'), \"File should not exist\")\n @dir.touch('tmpfile1')\n assert_equal(1, @dir.file_count(), \"directory should have one file\")\n @dir.touch('tmpfile2')\n assert_equal(2, @dir.file_count(), \"directory should have two files\")\n assert(@dir.exists?('tmpfile1'), \"'tmpfile1' should exist\")\n @dir.delete('tmpfile1')\n assert(! @dir.exists?('tmpfile1'), \"'tmpfile1' should no longer exist\")\n assert_equal(1, @dir.file_count(), \"directory should have one file\")\n end", "def test_directory_has_no_files\n assert_equal([], @td.files)\n end", "def test_bad_log_file\n FileUtils.rm_rf('test/test_fq/_log')\n assert(! @fq.verify_store, 'Failed to verify as false')\n assert_equal('bad queue dir: file \\'_log\\' does not exist', @fq.last_error, 'Failed to have correct error message')\n end", "def test_find_files_to_test\n @a.last_mtime = Time.at(0)\n assert @a.find_files_to_test(@files)\n\n @a.last_mtime = @files.values.sort.last + 1\n deny @a.find_files_to_test(@files)\n end", "def verify_file_creation list_of_files\n list_of_files.each do |path|\n rm_rf path\n File.exists?(path).should be_false \n end\n yield\n list_of_files.each do |path|\n File.exists?(path).should be_true \n end\nend", "def test_run_num_files\n\t\tf = FolderWalker.new(\"./TestFolders/\")\n\t\tf.run\n\t\tassert_equal(6,f.files.length)\n\tend", "def mktestfiles(testdir)\n @@tmpfiles << testdir\n assert_nothing_raised {\n files = %w{a b c d e}.collect { |l|\n name = File.join(testdir, \"file#{l}\")\n File.open(name, \"w\") { |f|\n f.puts rand(100)\n }\n\n name\n }\n\n return files\n }\n end", "def test_files\n Dir.open(TESTS_CODE) do |dir|\n dir.entries.grep(/^#{TEST_PREFIX}/)\n end\nend", "def test_missing_files(desc, dir1, dir2)\n files1 = dir_files(dir1).map {|f| f.sub(dir1,'') }\n files2 = dir_files(dir2).map {|f| f.sub(dir2,'') }\n\n missing = []\n\n (files2 - files1).each do |file|\n missing << File.join(dir1, file)\n end\n\n (files1 - files2).each do |file|\n missing << File.join(dir2, file)\n end\n\n if !missing.empty?\n @failures << {\n desc: \"#{desc}\\nMissing files:\\n\",\n result: \" - \" + missing.join(\"\\n - \")\n }\n\n pout 'F'.red\n else\n pout '.'.green\n end\nend", "def test_picture_files\n tested('auto rms.jpg')\n files = Dir.glob(temp_dir('generated' + '/*'))\n\n assert_equal(6, files.length)\n assert_includes stdout, 'Generating'\n end", "def test_file\n assert_pattern_match [ \"/directory\", \"component.vwf\", nil, nil ], \"/directory/component.vwf/\"\n end", "def count_tests\n Dir.entries(@path.to_s + \"sandbox\").each do |currFile|\n isFile = currFile.to_s =~ /\\.java$|\\.py$|\\.c$|\\.cpp$|\\.js$|\\.php$|\\.rb$|\\.hs$|\\.clj$|\\.go$|\\.scala$|\\.coffee$|\\.cs$|\\.groovy$\\.erl$/i\n\n unless isFile.nil?\n file = @path.to_s + \"sandbox/\" + currFile.to_s\n begin\n case @language.to_s\n when \"Java-1.8_JUnit\"\n if File.open(file).read.scan(/junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Mockito\"\n if File.open(file).read.scan(/org\\.mockito/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Powermockito\"\n if File.open(file).read.scan(/org\\.powermock/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Approval\"\n if File.open(file).read.scan(/org\\.approvaltests/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Python-unittest\"\n if File.open(file).read.scan(/unittest/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Python-pytest\"\n if file.include?\"test\"\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-TestUnit\"\n if File.open(file).read.scan(/test\\/unit/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-Rspec\"\n if File.open(file).read.scan(/describe/).count > 0\n @totaltests += File.open(file).read.scan(/it /).count\n end\n when \"C++-assert\"\n if File.open(file).read.scan(/cassert/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"C++-GoogleTest\"\n if File.open(file).read.scan(/gtest\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-CppUTest\"\n if File.open(file).read.scan(/CppUTest/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-Catch\"\n if File.open(file).read.scan(/catch\\.hpp/).count > 0\n @totaltests += File.open(file).read.scan(/TEST_CASE\\(/).count\n end\n when \"C-assert\"\n if File.open(file).read.scan(/assert\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"Go-testing\"\n if File.open(file).read.scan(/testing/).count > 0\n @totaltests += File.open(file).read.scan(/func /).count\n end\n when \"Javascript-assert\"\n if File.open(file).read.scan(/assert/).count > 0\n @totaltests += File.open(file).read.scan(/assert/).count - 2 #2 extra because of library include line\n end\n when \"C#-NUnit\"\n if File.open(file).read.scan(/NUnit\\.Framework/).count > 0\n @totaltests += File.open(file).read.scan(/\\[Test\\]/).count\n end\n when \"PHP-PHPUnit\"\n if File.open(file).read.scan(/PHPUnit_Framework_TestCase/).count > 0\n @totaltests += File.open(file).read.scan(/function /).count\n end\n when \"Perl-TestSimple\"\n if File.open(file).read.scan(/use Test/).count > 0\n @totaltests += File.open(file).read.scan(/is/).count\n end\n when \"CoffeeScript-jasmine\"\n if File.open(file).read.scan(/jasmine-node/).count > 0\n @totaltests += File.open(file).read.scan(/it/).count\n end\n when \"Erlang-eunit\"\n if File.open(file).read.scan(/eunit\\.hrl/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(\\)/).count\n end\n when \"Haskell-hunit\"\n if File.open(file).read.scan(/Test\\.HUnit/).count > 0\n @totaltests += File.open(file).read.scan(/TestCase/).count\n end\n when \"Scala-scalatest\"\n if File.open(file).read.scan(/org\\.scalatest/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(/).count\n end\n when \"Clojure-.test\"\n if File.open(file).read.scan(/clojure\\.test/).count > 0\n @totaltests += File.open(file).read.scan(/deftest/).count\n end\n when \"Groovy-JUnit\"\n if File.open(file).read.scan(/org\\.junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Groovy-Spock\"\n if File.open(file).read.scan(/spock\\.lang/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count - 1 #1 extra because of object def\n end\n else\n @totaltests = \"NA\"\n end\n rescue\n puts \"Error: Reading in count_tests\"\n end\n end\n end\nend", "def files_match(actual, expected)\n FileCompareAssertion.new(actual, expected)\n end", "def test_data_glob\n file = 'foo.dat'\n assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.data.glob(file))\n file = 'bar.dat'\n assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.data.glob(file))\n end", "def test_get_list_files()\n\n path = 'folder1'\n storage = 'First Storage'\n request = GetListFilesRequest.new(path, storage)\n\n result = @storage_api.get_list_files(request)\n assert result.code == 200, 'Error while getting list files'\n assert result.files != nil\n\n end", "def test_read_bad_file\n assert_raises SystemExit do\n assert_output 'File does not exist', @verify.read('sample_test.txt')\n end\n end", "def test_root_file\n assert_pattern_match [ \"/\", \"component.vwf\", nil, nil ], \"/component.vwf/\"\n end", "def initialize(test_glob = DEFAULT_TEST_GLOB)\n @total_test_files = 0\n @total_source_files = 0\n @test_glob = test_glob\n end", "def test_add100\n\n # make new file and fill with data\n\t\tfill_file(100)\n\t\t \t\n \tfb=Fastabin.new(TEST_FILE,'r') \t \t\n assert_equal(100,fb.count)\n fb.close\n \t\t\n end", "def setup_run_artifacts\n FileUtils.mkdir_p(\"./#{Dir.glob(\"#{$VALUE}/\").max_by { |f| File.mtime(f) }}test_logs\")\n FileUtils.mkdir_p(\"./#{Dir.glob(\"#{$VALUE}/\").max_by { |f| File.mtime(f) }}test_report\")\n FileUtils.mkdir_p(\"./#{Dir.glob(\"#{$VALUE}/\").max_by { |f| File.mtime(f) }}test_results\")\n FileUtils.mkdir_p(\"./#{Dir.glob(\"#{$VALUE}/\").max_by { |f| File.mtime(f) }}test_screenshots\") unless File.exist?(\"./#{Dir.glob(\"#{$VALUE}/\").max_by { |f| File.mtime(f) }}test_screenshots\")\nend", "def test_files\n files = tests\n files = files.map{ |f| Dir[f] }.flatten\n files = files.map{ |f| File.directory?(f) ? Dir[File.join(f, '**/*.rb')] : f }\n files = files.flatten.uniq\n files = files.map{ |f| File.expand_path(f) }\n files\n end", "def test_application_session_as_file\n assert_pattern_match [ \"/\", \"component.vwf\", \"0000000000000000\", nil ], \"/component.vwf/0000000000000000\"\n assert_pattern_match [ \"/directory\", \"index.vwf\", \"0000000000000000\", nil ], \"/directory/0000000000000000\"\n assert_pattern_match [ \"/directory\", \"component.vwf\", \"0000000000000000\", nil ], \"/directory/component.vwf/0000000000000000\"\n end", "def test_foreach\n\t\tOle::Storage.open(@io) {\n\t\t\t|zf|\n\n\t\t\tblockCalled = false\n\t\t\tassert_raise(Errno::ENOENT, \"No such file or directory - noSuchDir\") {\n\t\t\t\tzf.dir.foreach(\"noSuchDir\") { |e| blockCalled = true }\n\t\t\t}\n\t\t\tassert(! blockCalled)\n\n\t\t\tassert_raise(Errno::ENOTDIR, \"Not a directory - file1\") {\n\t\t\t\tzf.dir.foreach(\"file1\") { |e| blockCalled = true }\n\t\t\t}\n\t\t\tassert(! blockCalled)\n\n\t\t\tentries = []\n\t\t\tzf.dir.foreach(\".\") { |e| entries << e }\n\t\t\tassert_equal(['.', '..', \"dir1\", \"dir2\", \"file1\"].sort, entries.sort)\n\n\t\t\tentries = []\n\t\t\tzf.dir.foreach(\"dir1\") { |e| entries << e }\n\t\t\tassert_equal(['.', '..', \"dir11\", \"file11\", \"file12\"], entries.sort)\n\t\t}\n\tend", "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_dirs(desc, dir1, dir2)\n\n test_missing_files(desc, dir1, dir2)\n\n dir_files(dir1).each do |file|\n file2 = file.sub(dir1, dir2)\n if File.exist?(file2)\n if diff = diff_file(file, file2)\n @failures << {\n desc: \"#{desc}\\nDiff of file: #{file.sub(dir1+'/', '')}\\n\",\n result: format_diff(diff)\n }\n pout 'F'.red\n else\n pout '.'.green\n end\n end\n end\nend", "def test_cachedel_non_empty_file\n _generic_cachedel_test 4000\n end", "def _test_interface(test_info)\n File.write(test_info.actual_file_path, '') if File.exist?(test_info.actual_file_path)\n yield\n diffs = diff_files(test_info.expected_file_path, test_info.actual_file_path)\n unless diffs.empty?\n puts 'EXPECTED'\n puts File.read(test_info.expected_file_path)\n puts 'ACTUAL'\n puts File.read(test_info.actual_file_path)\n puts 'END'\n end\n assert_empty(diffs, test_info.actual_file_path)\n end", "def test_cases\n @test_cases ||= Dir.glob(test_glob)\n end", "def test_operator_file_errors\n optest_command_ok(\"reset\")\n optest_command_ok(\"load data/Tests/Default/JD.yml data/Tests/Default/ED.yml OK\")\n optest_file_error(\"add data/Tests/Default/CC0.yml\")\n File.chmod(0222,\"data/Tests/Validation/CC3_Write_Only.yml\")\n optest_file_error(\"add data/Tests/Validation/CC3_Write_Only.yml\")\n File.chmod(0644,\"data/Tests/Validation/CC3_Write_Only.yml\")\n optest_file_error(\"add tabulator.rb\")\n optest_file_error(\"add data/Tests/Default/ED.yml\")\n optest_file_error(\"add data/Tests/Validation/ARRAY.yml\")\n optest_file_error(\"add data/Tests/Validation/CC2_Syntax_Error.yml\")\n end", "def test_files\n get_folder_files(TESTS_PATH)\n end", "def test_nonexistant_files_do_not_exist\n t = Crd::Target.new BAD\n assert_equal( false, t.exists? )\n end", "def test_file_begin_is_created\n file_name = 'some_file.txt'\n assert(!File.exist?(file_name))\n FileBegin.new(file_name)\n assert(File.exist?(file_name))\n File.unlink(file_name)\n end", "def all_files\n Dir[@test_pattern].sort\n end", "def test_application_as_file\n assert_pattern_match [ \"/\", \"component.vwf\", nil, nil ], \"/component.vwf\"\n assert_pattern_match [ \"/directory\", \"index.vwf\", nil, nil ], \"/directory\"\n assert_pattern_match [ \"/directory\", \"component.vwf\", nil, nil ], \"/directory/component.vwf\"\n end", "def test_fallback_exists\n File.unstub :exist?\n tested 'fallback rms.jpg'\n\n files = Dir.glob(temp_dir('generated') + '/rms-35-?????????.webp')\n\n assert_equal 1, files.length\n end", "def test_all_causes_uploaded\n assert_equal(30, @file_handler.good_causes_array.length)\n end", "def test_empty_log_file\n Logbook.log(TOPIC, LOGGER, MSG)\n Logbook.empty_logfile(TOPIC)\n assert(!File.size?(Logbook.file_name(TOPIC)) != nil)\n end", "def assert_directory_exist(filename, msg = nil)\n full_message = build_message(msg, \"Directory ? should have been found.\", filename)\n assert_block(full_message) do\n File.directory?(filename)\n end\nend", "def test_directory_with_index\n assert_pattern_match [ \"/directory\", \"index.vwf\", nil, nil ], \"/directory/\"\n end", "def testing_begin(files)\n end", "def find_files dir = test_dir\n glob file_pattern(dir)\n end", "def test_file_size_differs\n TestHelper::FillContents($source_dir, {\n 'A.txt' => {\n type: 'file',\n contents: 'SuperLongFileThatHasLotsOfStuff',\n }\n })\n TestHelper::FillContents($backup_dir, {\n 'A.txt' => {\n type: 'file',\n contents: 'ShortFile',\n }\n })\n expected_results = {\n items_processed: 2,\n similarities: 1,\n differences: 1,\n skipped: 0,\n errors: 0,\n }\n actual_results = TestHelper::RunVerification(\n [$source_dir, $backup_dir]\n )\n assertResultsAsExpected(expected_results, actual_results)\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 test_tresholds\n assert_raise(Test::Unit::AssertionFailedError) do\n assert_flog(__FILE__, :treshold => 10) \n end\n assert_raise(Test::Unit::AssertionFailedError) do\n assert_flog(__FILE__, :treshold => 30, :tresholds => {'TestAssertions#test_extract_files_and_options' => 20}) \n end\n \n assert_flog(__FILE__, :treshold => 10, :tresholds => {'TestAssertions#test_extract_files_and_options' => 23})\n end", "def process(files) #called at end of script\n if files.class==Array \n files.each {|f| \n puts \"\\n\\n--------------------\\n#{f}:\\n\\n\"\n result=system(\"#{$PROGRAM_NAME} #{f} #{ARGV}\")\n puts \"\\n\\nERRORS IN TEST #{f}!!!\\n\\n\" unless result\n }\n else\n test_name=File.basename(files).sub(/\\..*?$/,'')\n test_case=Class.new(Test::Unit::TestCase)\n Object.const_set(:\"Test#{test_name.capitalize}\", test_case)\n mk_test_context(files, test_case)\n end\nend", "def testUselessProcessesSourceFiles\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'VolCorrection',\n :Factor => '2db'\n },\n {\n :Name => 'VolCorrection',\n :Factor => '-2db'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n assert Dir.glob('05_Mix/*.wav').empty?\n assert_wave_lnk 'Empty', '05_Mix/Final/Final.wav'\n end\n end", "def test_subdirectories\n sd = @td.subdirectories\n assert_equal(5, sd.length)\n assert(sd.find \"failed\")\n assert(sd.find \"inactive\")\n assert(sd.find \"new\")\n assert(sd.find \"passed\")\n assert(sd.find \"unclassified\")\n end", "def with_baselines(path, pattern, options={}, &block)\n count = 0\n errors = []\n Dir.glob(\"#{datadir}/#{path}/*\").each do |filename|\n next unless filename =~ pattern\n count += 1\n output = yield(*($LAST_MATCH_INFO.to_a))\n begin\n assert_testdata_equal(filename, output, options)\n rescue Test::Unit::AssertionFailedError => ex\n errors << ex\n end\n end\n assert count > 0, \"no test data files found in #{datadir} - check the test environment\"\n\n flunk errors.map(&:message).join(\"\\n\\n\") if errors.present?\n end", "def test_read_file\r\n hash_calc = Minitest::Mock.new('test_hash_calculator')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n account_tracker = Minitest::Mock.new('account_tracker')\r\n def block_checker.read_next_line; nil; end\r\n def account_tracker.print_accounts; nil; end\r\n assert_nil @g.read_file(hash_calc, block_checker, account_tracker)\r\n end", "def setup\n\n for i in 1..ROOT_FILES_X\n File.open(\"/rootfilex#{i}.txt\", 'w+').chmod(0777) #Just using random permissions aside from having world execute bit included or not\n # puts \"rootfilex#{i}.txt\"\n end\n\n for i in (ROOT_FILES_X + 1)..(ROOT_FILES + ROOT_FILES_X)\n File.open(\"/rootfile#{i}.txt\", 'w+').chmod(0660)\n # puts \"rootfile#{i}.txt\"\n end\n\n for i in 1..HIDDEN_FILES_X\n File.open(\"/.hiddenfilex#{i}\", 'w+').chmod(0555)\n # puts \".hiddenfile#{i}\"\n end\n\n for i in (HIDDEN_FILES_X + 1)..(HIDDEN_FILES + HIDDEN_FILES)\n File.open(\"/.hiddenfile#{i}\", 'w+').chmod(0442)\n # puts \".hiddenfile#{i}\"\n end\n\n make_test_dirs_with_files(\"/\", 1)\n\n end", "def test_delete_log_file\n# Logbook.log(TOPIC, LOGGER, MSG)\n# Logbook.delete_logfile(TOPIC)\n# assert(!File.exists?(Logbook.file_name(TOPIC)))\n end", "def testNominalShort\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 '-u', 'ReleaseUser',\n '-b', 'BranchName',\n '-c', 'ReleaseComment',\n '-v', '0.0.1.20100317',\n '-t', iTasksFileName,\n '-k', iTicketsFileName,\n '-s', 'MySVNRep',\n '-d', '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 log_files\n files = []\n Find.find(File.join(Dir.pwd, 'features', 'logs')) do |p|\n next if FileTest.directory? p\n files << p\n end\n files\nend", "def test_file_exists?(host, file_rel_path)\n host.execute(\"test -f \\\"#{get_test_file_path(host, file_rel_path)}\\\"\",\n :acceptable_exit_codes => [0, 1]) do |result|\n return result.exit_code == 0\n end\nend", "def testNominalWithSeveralDeliverables\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_2DummyGems ]\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/DummyGem1.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ],\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem2.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end", "def test_seenewfiles\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n\n newfile = File.join(testdir, \"newfile\")\n\n # go through the whole schtick again...\n file = nil\n checks = Puppet::Network::Handler.fileserver::CHECKPARAMS\n\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n list = nil\n sfile = \"/test/\"\n assert_nothing_raised {\n list = server.list(sfile, :manage, true, false)\n }\n\n # create the new file\n File.open(newfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n\n newlist = nil\n assert_nothing_raised {\n newlist = server.list(sfile, :manage, true, false)\n }\n\n # verify the list has changed\n assert(list != newlist)\n\n # and verify that we are specifically seeing the new file\n assert(newlist =~ /newfile/)\n end", "def fs_case_sensitivity_test\n dirs = []\n dirs << @movie_dir if @movie_dir\n dirs << @tvdir if @tvdir\n dirs.each do |dst|\n test_directory = \"#{dst}/#{$$}\"\n if File.directory? dst\n if not File.directory? test_directory\n $options_fs = {}\n #$options_fs = {:noop=>true,:verbose=> true} if $opt[\"dry\"]\n $options_fs = {:noop=>true} if $opt[\"dry\"]\n \n FileUtils.mkdir_p(test_directory,$options_fs) \n file1 = \"#{test_directory}/file\"\n file2 = \"#{test_directory}/FILE\"\n FileUtils.touch(file1,$options_fs)\n FileUtils.touch(file2,$options_fs)\n \n count = 0\n \n if File.exist? test_directory\n Find.find(test_directory) do |file| \n next if FileTest.directory?(file)\n count = count + 1\n end\n \n FileUtils.rm(file1,$options_fs)\n FileUtils.rm(file2,$options_fs) if count == 2\n FileUtils.rmdir(test_directory,$options_fs)\n \n $config[\"settings\"][\"fs_case_sensitive\"] = true if count == 2\n $config[\"settings\"][\"fs_case_sensitive\"] = false if count == 1 \n log(\"fs_case_sensitivity_test on #{dst} (#{$config[\"settings\"][\"fs_case_sensitive\"]})\") if $opt[\"debug\"]\n end\n end\n end \n end\nend", "def test_does_not_duplicate_if_file_already_exists\n test_file = 'extractor_test_small_sample'\n src_directory = File.join('testRawData', 'pdf/')\n dst_directory = File.join('testExtractedData', 'pdf/')\n\n\tnumber_files_before = TestUtils.count_files_directory(dst_directory)\n\n # Order of tests is not guaranteed, so create the file if necessary\n if (not File.exists?(\"#{dst_directory}#{test_file}.txt\"))\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_files_before = number_files_before + 1\n end\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_of_files_after = TestUtils.count_files_directory(dst_directory)\n \n assert_equal number_files_before, number_of_files_after\n end", "def test_import_files\n fnsarray = [[\"afile\", \"bfile\", \"../cfile\"], \n \"./adir/afile\", \n \"\", \n [false, true, 1234],\n ]\n fnsarray.each do |fns|\n $mock.expect :add_import, true, [fns]\n import fns\n assert $mock.verify\n end\n\tend", "def test_validate_file\n file_list = [\n '0|0|SYSTEM>569274(100)|1553184699.650330000|288d',\n '1|288d|569274>735567(12):735567>561180(3):735567>689881(2):SYSTEM>532260(100)|1553184699.652449000|92a2',\n '2|92a2|569274>577469(9):735567>717802(1):577469>402207(2):SYSTEM>794343(100)|1553184699.658215000|4d25'\n ]\n assert validate_file file_list, [0, 0], '0'\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_existing_file\n assert verify_parameters(['verifier_tests.rb'])\n end", "def test_em_watch_file_unsupported\n assert true\n end", "def test_file(path)\n return File.file?(path)\nend", "def test_file1\n File.new(\"#{TEST_DIR}/fixtures/uploads/test_file1.txt\")\n end", "def assert_empty_directory( file, msg = nil )\n assert_fwf_filepath( file )\n msg = message(msg){ \"Empty directory should exist at <#{file}>.\" }\n assert file.directory? && file.empty?\n end", "def test_045\n test_000\n login(\"root\",\"root\")\n register_master(\"normal\", MASTER_FILES[\"normal\"])\n master_chosen = Master.find(:last)\n all_temp_file_of_master = TempFile.find_all_by_master_id(master_chosen)\n delete_master\n wait_for_text_present(_(\" deleted successfully!\"))\n all_temp_file_of_master = TempFile.find_all_by_master_id(master_chosen)\n assert_equal all_temp_file_of_master, []\n logout\n end", "def test_invalid_file_correct_args_length\n assert_output(\"File not found!\\n\") {@grapher.make_graph(['hi.txt'])}\n end", "def assert_non_destructive \n assert_equal(\"C:\\\\Program Files\\\\Windows NT\\\\Accessories\", @fpath)\n assert_equal(\"C:\\\\Program Files\\\\Windows NT\\\\Accessories\", @bpath)\n assert_equal(\"C:\\\\Program Files\\\\File[5].txt\", @dpath)\n assert_equal(\"C:\\\\PROGRA~1\\\\WINDOW~1\\\\ACCESS~1\", @spath)\n assert_equal(\"\\\\\\\\foo\\\\bar\\\\baz\", @upath)\n assert_equal(\"foo\\\\bar\\\\baz\", @npath)\n assert_equal(\"Z:\\\\\", @rpath)\n assert_equal(\"\\\\\\\\foo\\\\bar\", @xpath)\n assert_equal(\"\\\\\\\\foo\", @ypath)\n assert_equal(\"\\\\\\\\\", @zpath)\n assert_equal(\"\", @epath)\n assert_equal(\"C:\\\\foo\\\\bar\\\\\", @ppath)\n assert_equal(\"C:\\\\foo\\\\..\\\\bar\\\\.\\\\baz\", @cpath)\n end", "def test_glob\n return @test_glob ||= File.join(path, test, '**', '?*Test.as')\n end", "def test_file_block_is_created\n file_name = 'some_file.txt'\n assert(!File.exist?(file_name))\n FileBlock.new(file_name)\n assert(File.exist?(file_name))\n File.unlink(file_name)\n end", "def has_unit_tests? # :nodoc:\n not test_files.empty?\n end", "def test_setup\n flags = %w(-s -f 500 -u 100 -g 200 -l foo.log) + [\"-p\", @prefix, @default_filename]\n IO.popen([@binary] + flags, \"r+\") {|f| f.close_write; f.close_read}\n assert_equal(0, $?.exitstatus, \"#{@binary} exited non-zero when testing flags\")\n end", "def test_lock (backup_path)\n Dir.foreach(backup_path) do |f|\n if f.include?(\"flock\") then\n puts \"Error! #{f} exists!\"\n return true\n end\n end\n return false\nend", "def has_tests?\n FileList[test_pattern].any?\n end", "def test_templates\n assert Rake::Task[:test_flash_player].invoke\n assert(File.exists?(@xml), 'XML File should have been created!')\n assert(File.exists?(@swf), 'SWF File should have been created!')\n end", "def test_simsddxmls_are_defined_sdd_rt_tests\n all_sddsimxml_paths = Dir.glob(File.join($SddSimDir, '*.xml'));\n all_sdd_simxml_filenames = all_sddsimxml_paths.map{|p| File.basename(p)};\n\n content = File.read('SDD_tests.rb');\n\n sdd_rt_test_re = Regexp.new('def test_RT_.*\\n(?:\\s*#)*\\s+sdd_rt_test\\(\\'(?<filename>.*\\.xml)\\'\\)\\n(?:\\s*#)*\\s+end')\n xmls_in_sdd_test = content.scan(sdd_rt_test_re).map{|m| m.first}\n missing_xmls = all_sdd_simxml_filenames - xmls_in_sdd_test\n\n # These are the XMLs we expect NOT to find in a sdd_rt_test\n expected_sdd_missing = []\n missing_xmls = missing_xmls - expected_sdd_missing\n\n assert missing_xmls.empty?, \"Error in SDD_tests.rb: The following XMLs are not in any sdd_rt_tests:\\n * #{missing_xmls.join(\"\\n * \")}\"\n end", "def test_bin\n Dir.chdir(File.expand_path(__dir__))\n assert_command('../bin/chuckle url_file.txt')\n end", "def test_get_list_file_versions\n\n path = 'folder1/FileTest.pdf'\n storage = 'First Storage'\n request = GetListFileVersionsRequest.new(path, storage)\n\n result = @storage_api.get_list_file_versions(request)\n assert result.code == 200, 'Error get list file versions'\n assert result.file_versions != nil\n\n end", "def test_empty_tasks()\n [3, 10].each() do |concurrent_duties|\n [true, false].each() do |persistent_workers|\n [true, false].each() do |perform_now|\n assert_nothing_thrown() do\n s = generate_spawner(concurrent_duties, persistent_workers, 0,\n @jobs_log_file, @spawner_log_file)\n generate_tasks_addition(s, 10, perform_now, 3) {}\n end\n\n assert_equal(0, File.stat(@jobs_log_file).size(), \"The jobs log is not empty, while it should\")\n end\n end\n end\n end", "def test_file(f)\n\treturn (File.file?(f) and File.readable?(f) and File.size?(f).to_i < C_max_filesize*1024*1024 and not (File.socket?(f) or File.blockdev?(f) or File.chardev?(f)))\nend", "def setupTestDir\r\n @start = Dir.getwd\r\n teardownTestDir\r\n begin\r\n\tDir.mkdir(\"_test\")\r\n rescue\r\n $stderr.puts \"Cannot run a file or directory test: \" + \r\n \"will destroy existing directory _test\"\r\n\t# VMS maps exit status 99 (octal 143) as a meaningless\r\n\t# message \"%SYSTEM-?-DRVERR, fatal drive error\".\r\n\texit\r\n# exit(99)\r\n end\r\n File.open(File.join(\"_test\", \"_file1\"), \"w\", 0644) {}\r\n File.open(File.join(\"_test\", \"_file2\"), \"w\", 0644) {}\r\n @files = %w(. .. _file1 _file2)\r\n end", "def verify_required_data_files!\n unless File.exists?(\"#{@working_directory}/drupal-filesystem.tar.gz\") && File.exists?(\"#{@working_directory}/drupal-db.sql.gz\")\n raise StandardError.new(\"Cannot locate both 'drupal-filesystem.tar.gz' and 'drupal-db.sql.gz' in directory '#{@working_directory}'.\")\n end\n end", "def assert_no_valgrind_errors\n return if not @valgrind\n\n errors = 0\n filenames = []\n valgrindlogs = Dir.glob(dirs.valgrindlogdir+\"/*\")\n #assert(valgrindlogs.length > 0, \"No valgrind logfiles found in #{dirs.valgrindlogdir}\")\n\n valgrindlogs.each do |filename|\n IO.foreach(filename) do |line|\n if line =~ /ERROR SUMMARY: (\\S+) errors from (\\S+) contexts/\n if $1.to_i > 0\n errors += 1\n filenames << filename\n end\n end\n end\n end\n assert_equal(0, errors, \"Valgrind logfiles containing errors:\\n#{filenames.join(\"\\n\")} (on #{Socket.gethostname})\")\n end", "def test_accesslogpattern(accesslogpattern)\n verbose \" \"\n file_matches = `ls #{accesslogpattern} 2>&1`\n if $CHILD_STATUS != 0\n puts \"ls #{accesslogpattern} matched nothing\"\n puts \"Have you enabled the wildcard option?\"\n exit\n else\n verbose \"Log files matched:\"\n verbose file_matches\n end\n verbose \" \"\nend", "def test_get_is_exist()\n\n path = 'folder7'\n versionId = nil\n storage = 'First Storage'\n request = GetIsExistRequest.new(path, versionId, storage)\n\n result = @storage_api.get_is_exist(request)\n assert result.code == 200, 'Error get is file or folder exist'\n assert result.file_exist != nil\n\n end", "def empty?\n Dir['./tmp/specs/*'].empty?\n end", "def test_output_dir\n assert(File.exist?(@output_dir))\n end", "def assert_empty_file( file, msg = nil )\n assert_fwf_filepath( file )\n msg = message(msg){ \"Empty file should exist at <#{file}>.\" }\n assert file.file? && file.empty?, msg\n end", "def testPrepareFileFail\n initTestCase do\n setupTempFile do |iTmpFileName|\n lTransferFile = WEACE::Master::TransferFile.new(iTmpFileName)\n $Context[:SlaveActions] = [\n [ 'DummyTool', 'DummyAction', [lTransferFile] ]\n ]\n $Context[:DummySenderPrepareError] = RuntimeError.new('Preparing error')\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser' ],\n :Repository => 'Dummy/MasterServerInstalledWithDummySender',\n :AddRegressionProcesses => true,\n :AddRegressionSenders => true,\n :Error => RuntimeError\n ) do |iError|\n assert_equal( [\n [ 'prepareFileTransfer', [ iTmpFileName ] ]\n ],\n $Variables[:DummySenderCalls]\n )\n assert(File.exists?(iTmpFileName))\n assert_equal(\n [\n [ 'DummyUser',\n { 'DummyTool' => {\n 'DummyAction' => [\n [lTransferFile]\n ]\n }\n }\n ]\n ],\n getSlaveClientQueue\n )\n assert_equal({iTmpFileName => 1}, getTransferFiles)\n end\n end\n end\n end", "def start_tests(files)\n end", "def test_it_can_count_empty_list\n\n assert_equal 0, jb.count\n end", "def file_stat? dir, deadline, rel_filename, detailed, file_format, file_count\n count = 0\n Dir.chdir(ARGV[0] + dir)\n Dir.glob(ARGV[0] + dir + \"**/#{file_format}\") do |file|\n if file.include?(rel_filename)\n count += 1 \n return status?(deadline, file, detailed) if count == file_count\n end\n end\n return [0,0,0]\n end", "def file_exists?(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"test -f #{file}\", 'root', 500)\n code.zero?\nend", "def file_exists?(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"test -f #{file}\", 'root', 500)\n code.zero?\nend", "def run(fs)\n @expected_files_collection = fs.database['expected.files']\n @expected_chunks_collection = fs.database['expected.chunks']\n act(fs)\n prepare_expected_collections(fs)\n result\n end", "def initialize\n #get a list of all folders, then get a list of all\n #test files for each folder\n @base_dir = __FILE__ + '../../../test/functional/'\n \n @func_areas = Hash.new\n test_dir = Dir.new(@base_dir)\n \n folders = test_dir.entries\n \n folders.each do |folder|\n \n if !File.basename(@base_dir + folder).index(\".\") \n if File.ftype(@base_dir + folder)== \"directory\"\n @func_areas[File.basename(folder)]= get_test_files_for_dir(folder)\n end\n end\n end\n end", "def test_file_exists?(host, file_rel_path)\n file_exists?(host, get_test_file_path(host, file_rel_path))\nend", "def expected_files?(files)\n files = supported(files)\n hn = highest_number(files)\n\n return true if hn == files.size\n\n raise Aur::Exception::LintDirBadFileCount, \"#{files.size}/#{hn}\"\n end" ]
[ "0.7399939", "0.7046132", "0.67277825", "0.6698579", "0.66247195", "0.6606405", "0.65651715", "0.65431124", "0.65171593", "0.64648783", "0.64236677", "0.6385257", "0.6257858", "0.6187212", "0.61722034", "0.614127", "0.6133284", "0.610395", "0.6097351", "0.60643697", "0.6055007", "0.60437584", "0.60157144", "0.60088927", "0.5983506", "0.5979887", "0.59723866", "0.5964226", "0.5949739", "0.5947093", "0.5938194", "0.5926665", "0.5922205", "0.5913315", "0.59038925", "0.590282", "0.5891659", "0.5890666", "0.5868701", "0.58677363", "0.58616763", "0.58534724", "0.5826917", "0.582665", "0.5808839", "0.58012605", "0.5792656", "0.57914025", "0.578041", "0.57789576", "0.5778489", "0.57735544", "0.57734555", "0.57698923", "0.57651", "0.576319", "0.5762413", "0.5761648", "0.5747792", "0.57447654", "0.57222277", "0.5721321", "0.572127", "0.5711738", "0.5702096", "0.5697656", "0.5692784", "0.5687521", "0.5687082", "0.5684038", "0.5675033", "0.5673868", "0.56718105", "0.5659667", "0.5658251", "0.56562954", "0.56451094", "0.5641119", "0.5637226", "0.56187826", "0.56132793", "0.56078094", "0.5603606", "0.5603385", "0.5602992", "0.55984104", "0.559799", "0.5586864", "0.5585875", "0.5572207", "0.55679977", "0.5559663", "0.5559498", "0.5557351", "0.5555799", "0.5555799", "0.5549966", "0.55483824", "0.554528", "0.5541171" ]
0.646268
10
the actual users finish watching a video
def calendar @videos = Video.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_video_added!\n start! if waiting?\n end", "def video_watched?(user, video)\n @watched_video = WatchedVideo.where(user_id: user.id, video_id: video.id).first\n if @watched_video && @watched_video.watched == true\n true\n else\n false\n end\n end", "def videos_test\n end", "def check_live(video)\n return true if video.live == \"1\"\nend", "def video_ended(ref,event)\n return false unless ref\n return true if ref.video && !event.video\n return true if ref.video && ref.video != event.video\n false\n end", "def finished?\n @episodes.last.watched?\n end", "def pausevideo\n Pusher['photo-call'].trigger('pause-video' , {\n control: \"1\"\n })\n render text: \"ok\"\n end", "def complete\n @video_id = vimeo.complete(id, filename)\n end", "def each_turns_next_video\n videos = user_rota.all.map{ |user| Video.next_for(user) }.compact\n if videos.any?\n videos\n else\n Video.pending\n end\n end", "def verify_user_owns_video\n ruby_code_from_view.ruby_code_from_view do |rb_from_view|\n if we_should_show_og_tags && !@video.blank? \n # Facebook OpenGraph protocol for embedding our video link back to Brevidy \n public_video_url(:public_token => @video.public_token) \n @video.title \n @video.description \n @video.get_thumbnail_url(@video.selected_thumbnail) \n public_video_url(:public_token => @video.public_token) \n else \n # Standard meta tags \n image_path('meta_tag_logo.png') \n end \n browser_title \n # Logged In CSS \n cache_buster_path('/stylesheets/i_love_lamp-1.0.3.min.css') \n # Site-wide JS \n javascript_include_tag \"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" \n cache_buster_path('/javascripts/functions.min.js') \n cache_buster_path('/javascripts/i_love_lamp-1.0.3.min.js') \n javascript_include_tag \"player/player.js\" \n javascript_include_tag \"http://html5shiv.googlecode.com/svn/trunk/html5.js\" \n # Fav Icon and CSRF meta tag \n favicon_link_tag \n csrf_meta_tag \n get_background_for_user \n # Top navigation header \n link_to(image_tag(\"brevidy_rgb_white.png\", :size => \"135x35\", :alt => \"Brevidy - The Soul of Video\"), signed_in? ? user_stream_path(current_user) : :root, :class => \"brand\") \n video_search_path \n if signed_in? \n link_to(\"Explore\", explore_path) \n link_to(\"Upload\", new_user_video_path(current_user)) \n link_to(\"Share a Link\", user_share_dialog_path(current_user), :remote => true, \"data-method\" => \"GET\") \n link_to(\"Invite\", user_invitations_path(current_user)) \n end \n if signed_in? \n link_to(user_path(current_user), :class => \"dropdown-toggle\") do \n image_tag(\"#{current_user.image.blank? ? 'default_user_35px.jpg' : current_user.image_url(:small_profile) }\", :alt => \"#{current_user.name}\", :size => \"35x35\") \n current_user.username \n end \n link_to(\"My Channels\", user_channels_path(current_user)) \n link_to(\"Account Settings\", user_account_path(current_user)) \n link_to(\"Find People\", find_people_path) \n link_to(\"Help\", \"http://getsatisfaction.com/brevidy\", :target => \"_blank\") \n link_to(\"Logout\", logout_path, :remote => true, \"data-method\" => \"DELETE\") \n else \n link_to(\"Explore\", explore_path) \n link_to(\"Sign up\", signup_path) \n link_to(\"Login\", login_path) \n end \n \n # Main container \n # Dark Content Wrapper \n # Main (White) Content Wrapper \n link_to \"Go back\", :back \n image_tag(\"okayguy.png\", :alt => \"Okay\", :size => \"256x275\") \n # Lower navigation \n unless @page_has_infinite_scrolling \n succeed \" \" do \n link_to(\"FAQ\", faq_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Blog\", \"http://blog.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Status\", \"http://status.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Contact\", contact_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Terms\", tos_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Privacy\", privacy_path, :class => \"inlinelink\") \n end \n \n end \n # GetSatisfaction Feedback Widget & Google Analytics \n # Google Analytics \n # GetSatisfaction Code \n # AddThis script \n \n # Scroll back to top \n\nend\n\n end", "def video\n first_stream_of :video\n end", "def current_video\n last_poll = Room.find(id).video_polls.second_to_last\n if last_poll\n if last_poll.played_video\n last_poll.played_video\n else\n last_poll.candidate_videos.first.video\n end\n else\n playlist.videos.first\n end\n end", "def cycle_video\n video_polls.reload\n # 'poll id: ' + current_video_poll.id.to_s\n if video_polls.length >= 1\n current_poll = Room.find(id).video_polls.last\n puts 'WINNER: ' + current_poll.select_winner.title\n current_poll.played_video.title\n end\n puts \"count before\" + video_polls.count.to_s\n new_poll = self.generate_video_poll\n if new_poll.candidate_videos.length == 0\n throw 'generated empty poll!'\n end\n puts \"count after\" + video_polls.count.to_s\n\n RoomsChannel.broadcast_state self\n end", "def update\n respond_to do |format|\n if @jeux_video.update(jeux_video_params)\n @jeux_video.create_activity :update, owner: current_user, read: false\n format.html { redirect_to @jeux_video, notice: 'Jeux video was successfully updated.' }\n format.json { render :show, status: :ok, location: @jeux_video }\n else\n format.html { render :edit }\n format.json { render json: @jeux_video.errors, status: :unprocessable_entity }\n end\n end\n end", "def show; @video.show; end", "def has_video?\n false\n end", "def getVideoURL\n if (request.post?)\n cVideoID = self.findKeyInJSON(params[:params], \"VideoID\", 2)\n cOS = self.findKeyInJSON(params[:params], \"OS\", 2)\n \n case cOS.to_s\n when \"100\"\n # We have that file stored in S3 yet?\n # Check it later!\n # Just hard-code it\n returnFileName = \"http://ec2-50-112-145-58.us-west-2.compute.amazonaws.com:1935/vods3/_definst_/mp4:s3/\"\n returnFileName += cVideoID + \".mov\"\n returnFileName += \"/playlist.m3u8\"\n when \"101\"\n # android\n returnFileName = \"rtsp://ec2-50-112-145-58.us-west-2.compute.amazonaws.com:1935/vod/_definst_/mp4:s3/\"\n returnFileName += cVideoID + \".mov\"\n else\n # ignore\n end\n \n # Update Video Played Count\n begin\n b = Videotemp.find(cVideoID)\n if(b.playedCount == nil || b.playedCount == '')\n playedCount = 1\n else\n playedCount = b.playedCount\n playedCount = playedCount.to_i + 1\n end\n b.playedCount = playedCount.to_i\n b.save\n rescue Exception => e\n # ignore\n end\n \n # Return JSON response\n cRequestID = self.findKeyInJSON(params[:params], \"RequestID\", 1)\n rData = {\"VideoStreamUrl\" => returnFileName}\n self.jsonRender(rData, 'WOWZA URL', cRequestID, '100')\n end\n end", "def watched\n if !@video.video_watched?(@user, @video)\n @watched_video = @video.watched_videos.build(watched_params)\n @watched_video.user = @user\n @watched_video.save \n redirect_to new_video_rating_path(@video)\n else\n redirect_to video_path(@video)\n flash[:error] = \"You have already marked this video watched, are you trying to delete the view status?\"\n end\n #only positive views, if you havent seen a video then you dont have an entry in the join table,\n # if you want to delete a view, then you just delete the entry from the table\n end", "def watching\n Birdman::Requester.get(\"movies/#{id}/watching\")\n end", "def finish_events\n audio_event = @vj.fetch_last_event(:audio)\n audio_event.set_duration_now! unless audio_event.nil?\n video_event = @vj.fetch_last_event(:video)\n video_event.set_duration_now! unless video_event.nil?\n end", "def update\n @video = self.current_user.videos.find(params[:id])\n respond_to do |format|\n if @video.update_attributes(params[:video])\n if params[:video][:upload_ticket]\n # data is coming from asynchronous swf upload form page\n unless @video.asset\n @asset = @video.attach_uploaded_asset!(Videoasset) \n else\n @asset = @video.asset\n end\n if @asset\n format.html { render :partial => \"videos/video_info_form\", :locals => {:all_done => true}}\n else\n format.html { render :partial => \"videos/waiting_for_upload\"}\n end\n else\n # all-in-one upload page\n flash[:notice] = 'Video was successfully updated.'\n format.html { redirect_to(@video) }\n format.xml { head :ok }\n end\n else\n if params[:video][:upload_ticket]\n # data is coming from asynchronous swf upload form page\n format.html { render :partial => \"videos/video_info_form\"} \n else\n # all-in-one upload page\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @video.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def show\n # if not @video.view_grabber_working?\n # Resque.enqueue(VideoViewsGrabberJob, @video.id)\n # end\n end", "def forwardvideo\n Pusher['photo-call'].trigger('next-video' , {\n control: \"1\"\n })\n render text: \"ok\"\n end", "def playvideo\n if(params.has_key?(:id))\n id = params[:id]\n end\n Pusher['photo-call'].trigger('play-video' , {\n control: \"1\", video_id: id\n })\n render text: \"ok\"\n end", "def show\n @video = Video.find(params[:id])\n @video.views ||= 0\n @video.views += 1\n\n @video.save\n if owner? @video.user_id #for logged in owners of the video\n @owner_type = \"owner\" \n elsif not_signed_in_owner? @video #for non logged in owners of the video\n @owner_type = \"not signed in\"\n else #normal view of the video\n @owner_type = \"not owner\"\n end\n\n end", "def set_video_based_on_user\n video_id = params[:video_id] || params[:id]\n\n begin\n if current_user?(@user)\n @video ||= @user.videos.where(:id => video_id).joins(:video_graph).where(:video_graphs => { :status => Video.statuses_to_show_to_current_user }).first\n else\n @video ||= @user.videos.where(:id => video_id).joins(:video_graph).where(:video_graphs => { :status => VideoGraph.get_status_number(:ready) }).first\n end\n rescue ActiveRecord::StatementInvalid\n @video = nil\n end\n \n ruby_code_from_view.ruby_code_from_view do |rb_from_view|\n if we_should_show_og_tags && !@video.blank? \n # Facebook OpenGraph protocol for embedding our video link back to Brevidy \n public_video_url(:public_token => @video.public_token) \n @video.title \n @video.description \n @video.get_thumbnail_url(@video.selected_thumbnail) \n public_video_url(:public_token => @video.public_token) \n else \n # Standard meta tags \n image_path('meta_tag_logo.png') \n end \n browser_title \n # Logged In CSS \n cache_buster_path('/stylesheets/i_love_lamp-1.0.3.min.css') \n # Site-wide JS \n javascript_include_tag \"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" \n cache_buster_path('/javascripts/functions.min.js') \n cache_buster_path('/javascripts/i_love_lamp-1.0.3.min.js') \n javascript_include_tag \"player/player.js\" \n javascript_include_tag \"http://html5shiv.googlecode.com/svn/trunk/html5.js\" \n # Fav Icon and CSRF meta tag \n favicon_link_tag \n csrf_meta_tag \n get_background_for_user \n # Top navigation header \n link_to(image_tag(\"brevidy_rgb_white.png\", :size => \"135x35\", :alt => \"Brevidy - The Soul of Video\"), signed_in? ? user_stream_path(current_user) : :root, :class => \"brand\") \n video_search_path \n if signed_in? \n link_to(\"Explore\", explore_path) \n link_to(\"Upload\", new_user_video_path(current_user)) \n link_to(\"Share a Link\", user_share_dialog_path(current_user), :remote => true, \"data-method\" => \"GET\") \n link_to(\"Invite\", user_invitations_path(current_user)) \n end \n if signed_in? \n link_to(user_path(current_user), :class => \"dropdown-toggle\") do \n image_tag(\"#{current_user.image.blank? ? 'default_user_35px.jpg' : current_user.image_url(:small_profile) }\", :alt => \"#{current_user.name}\", :size => \"35x35\") \n current_user.username \n end \n link_to(\"My Channels\", user_channels_path(current_user)) \n link_to(\"Account Settings\", user_account_path(current_user)) \n link_to(\"Find People\", find_people_path) \n link_to(\"Help\", \"http://getsatisfaction.com/brevidy\", :target => \"_blank\") \n link_to(\"Logout\", logout_path, :remote => true, \"data-method\" => \"DELETE\") \n else \n link_to(\"Explore\", explore_path) \n link_to(\"Sign up\", signup_path) \n link_to(\"Login\", login_path) \n end \n \n # Main container \n # Dark Content Wrapper \n # Main (White) Content Wrapper \n link_to \"Go back\", :back \n image_tag(\"okayguy.png\", :alt => \"Okay\", :size => \"256x275\") \n # Lower navigation \n unless @page_has_infinite_scrolling \n succeed \" \" do \n link_to(\"FAQ\", faq_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Blog\", \"http://blog.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Status\", \"http://status.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Contact\", contact_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Terms\", tos_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Privacy\", privacy_path, :class => \"inlinelink\") \n end \n \n end \n # GetSatisfaction Feedback Widget & Google Analytics \n # Google Analytics \n # GetSatisfaction Code \n # AddThis script \n \n # Scroll back to top \n\nend\n\n end", "def after_play\n\n end", "def is_video_active(args = {})\n receive_video_id? args\n args = receive_should_validate? args\n\n get('redtube.Videos.isVideoActive', args,\n [:video_id], args[:should_validate])\n end", "def play\n @video_id = params[:id]\n begin\n @video = get_video(@video_id)\n @page_title = @video['title']\n render_template\n rescue\n redirect_to \"http://youtube.com/watch?v=#{@video_id}\", status: :moved_permanently and return false\n end\n end", "def touch_duration\n video = Video.find(params[:id])\n # Calculate time different then convert to duration\n duration = [current_time] - [started_watching_at]\n video.user.update_attribute(:watching_duration, duration)\n respond_to do |format|\n format.js { render nothing: true }\n end\nend", "def percent\n (self.time_watched/self.video.duration)*100\n end", "def queue_video(file)\n if video?(file) or contains_any?(file, :avi, :mpg, :mkv, :rm, :mp4)\n puts ''\n puts file\n local = \"/Volumes/Samba/clamps/\"\n dir = prompt_for_path(local)\n \n remote_path = \"#{ REMOTE_VIDEO_PATH }#{ dir[local.length, dir.length] }#{ Pathname.new(file).basename }\"\n QUEUE << [ file, remote_path ]\n end\nend", "def postprocess\n video_params = JSON.parse(params[\"upload_response\"])\n @video = Video.new(:panda_video_id => video_params[\"id\"], :title => \"Title-to-be-edited-later\")\n\n if @video.save\n render :json => {:play_url => url_for(@video), :id => @video_id}\n end\n end", "def get_video_progress\n @current_object = Video.find(params[:id].to_i)\n if params[:check] && params[:check] == 'true'\n render :text => @current_object.state\n elsif params[:status]\n render :text => @current_object.state\n else\n render :update do |page|\n page.replace_html \"states\", :partial => 'player', :object => @current_object\n end\n end\n end", "def show_play_complete_player\n\t\t# nothing\n\tend", "def create \n @video = Video.new() #get the attachemnt and create a video object with it\n\n if @video.save #if it saves then get the urll\n @video.create_url(params[:filepath]) \n\n if signed_in? #if the user is signed in add the video to their account\n current_user.videos << @video \n\n else #if they arent't uses sessions and a delete key\n @video.session_id = SecureRandom.urlsafe_base64(15) \n @video.delete_key = SecureRandom.urlsafe_base64(30) \n session[:owned_videos] ||= [] #if the current session doesn't have any owned_videos then create the array\n session[:owned_videos] << @video.session_id #add videos session id to array\n end\n\n @video.save \n send_to_heywatch @video\n render json: {url: \"/videos/#{@video.id}\"}\n else #error saving the video take them back to try again TODO show errors\n redirect_to \"/\"\n \n end\n end", "def add_to_channel_dialog\n @video ||= Video.where(:id => params[:video_id]).joins(:video_graph).where(:video_graphs => { :status => VideoGraph.get_status_number(:ready) }).first\n render :json => { :error => \"That video could not be found.\" }, :status => :not_found and return if @video.blank?\n \n if @video.channel.private? && !current_user_owns?(@video)\n render :json => { :error => \"This video is in a private channel so it cannot be shared.\" }, \n :status => :unprocessable_entity\n else \n @user ||= get_object_owner(@video)\n if user_can_access_channel \n respond_with(@user, @video)\n else\n render :json => { :error => \"You do not have permission to share this video.\" },\n :status => :unauthorized\n end\n end\nruby_code_from_view.ruby_code_from_view do |rb_from_view|\n if we_should_show_og_tags && !@video.blank? \n # Facebook OpenGraph protocol for embedding our video link back to Brevidy \n public_video_url(:public_token => @video.public_token) \n @video.title \n @video.description \n @video.get_thumbnail_url(@video.selected_thumbnail) \n public_video_url(:public_token => @video.public_token) \n else \n # Standard meta tags \n image_path('meta_tag_logo.png') \n end \n browser_title \n # Logged In CSS \n cache_buster_path('/stylesheets/i_love_lamp-1.0.3.min.css') \n # Site-wide JS \n javascript_include_tag \"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" \n cache_buster_path('/javascripts/functions.min.js') \n cache_buster_path('/javascripts/i_love_lamp-1.0.3.min.js') \n javascript_include_tag \"player/player.js\" \n javascript_include_tag \"http://html5shiv.googlecode.com/svn/trunk/html5.js\" \n # Fav Icon and CSRF meta tag \n favicon_link_tag \n csrf_meta_tag \n get_background_for_user \n # Top navigation header \n link_to(image_tag(\"brevidy_rgb_white.png\", :size => \"135x35\", :alt => \"Brevidy - The Soul of Video\"), signed_in? ? user_stream_path(current_user) : :root, :class => \"brand\") \n video_search_path \n if signed_in? \n link_to(\"Explore\", explore_path) \n link_to(\"Upload\", new_user_video_path(current_user)) \n link_to(\"Share a Link\", user_share_dialog_path(current_user), :remote => true, \"data-method\" => \"GET\") \n link_to(\"Invite\", user_invitations_path(current_user)) \n end \n if signed_in? \n link_to(user_path(current_user), :class => \"dropdown-toggle\") do \n image_tag(\"#{current_user.image.blank? ? 'default_user_35px.jpg' : current_user.image_url(:small_profile) }\", :alt => \"#{current_user.name}\", :size => \"35x35\") \n current_user.username \n end \n link_to(\"My Channels\", user_channels_path(current_user)) \n link_to(\"Account Settings\", user_account_path(current_user)) \n link_to(\"Find People\", find_people_path) \n link_to(\"Help\", \"http://getsatisfaction.com/brevidy\", :target => \"_blank\") \n link_to(\"Logout\", logout_path, :remote => true, \"data-method\" => \"DELETE\") \n else \n link_to(\"Explore\", explore_path) \n link_to(\"Sign up\", signup_path) \n link_to(\"Login\", login_path) \n end \n \n # Main container \n # Lower navigation \n unless @page_has_infinite_scrolling \n succeed \" \" do \n link_to(\"FAQ\", faq_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Blog\", \"http://blog.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Status\", \"http://status.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Contact\", contact_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Terms\", tos_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Privacy\", privacy_path, :class => \"inlinelink\") \n end \n \n end \n # GetSatisfaction Feedback Widget & Google Analytics \n # Google Analytics \n # GetSatisfaction Code \n # AddThis script \n \n # Scroll back to top \n\nend\n\n end", "def show_play_complete_player\n # nothing\n end", "def set_video\n if current_user.present?\n @video = current_user.videos.where(id: params[:id]).includes(:video_views).first\n if @video.nil?\n respond_to do |format|\n format.html { redirect_to videos_path(), notice: 'Você não tem permissão para acessar esse vídeo.' }\n end\n end\n else\n @video = Video.find(params[:id])\n end\n end", "def destroy\n @jeux_video.create_activity :destroy, owner: current_user, read: false\n @jeux_video.destroy\n respond_to do |format|\n format.html { redirect_to jeux_videos_url, notice: 'Jeux video was successfully destroyed.' }\n format.json { head :no_content }\n format.js { render :layout => false }\n end\n end", "def call\n if context.dj.player.stopped?\n related = context.dj.add_related\n if related\n context.dj.switch!\n context.message = [ \"Autoplaying.. #{ related }\" ].join(\" \")\n else\n context.errors = \"Failed getting related video.\"\n context.fail!\n end\n else\n current_video = context.dj.current_video\n context.message = \"Skipping!\"\n next_title = context.dj.switch!\n if next_title\n context.message = [ context.message, \"Playing #{ next_title }\" ].join(\" \")\n else\n context.message = \"Nothing to play, add some songs to playlist.\"\n end\n end\n end", "def timelapse\n raise NoSnapshotError if Dir.glob(saving_path+'/*.jpg').count.zero?\n\n puts \"Generate video...\"\n MovieMaker.build\n puts \"Video is ready.\"\n end", "def watch(movie)\n if self.genres_enjoyed.member?(movie.genre)\n puts \"#{self.name} is watching #{movie.title}\"\n else\n puts \"I am not watching #{movie.title}\"\n end\n end", "def get_video_status\n Skype.send_ :command => \"get call #{id} video_status\"\n end", "def download_video\n\t\t# preview_video_url = \"https://video.tvspielfilm.de/ivideo/video/10/9700610_1.mp4\"\n\n\t\tif preview_video_url.present?\t\n\t\t\tfilename = Pathname.new(preview_video_url).basename\n\t\t\tfilename = filename.to_s rescue \"#{Time.now.to_i}.mp4\"\n\t\t\t\n\t\t\tfilename = \"#{id}_#{filename}\"\n\n\t\t\tnew_file_path = \"#{Rails.root.to_s}/public/videos/#{filename}\"\n\t\t\topen(new_file_path, \"wb\") do |file| \n\t\t\t file.print open(preview_video_url).read\n\t\t\tend\n\t\t\tupload_video_at_s3(filename, new_file_path) \n\t\tend\n\tend", "def verify_user_can_access_channel_or_video\n public_token = params[:channel_token]\n user_can_access_either_one = (public_token and public_token.strip == @video.channel.public_token) || user_can_access_channel\n \n ruby_code_from_view.ruby_code_from_view do |rb_from_view|\n if we_should_show_og_tags && !@video.blank? \n # Facebook OpenGraph protocol for embedding our video link back to Brevidy \n public_video_url(:public_token => @video.public_token) \n @video.title \n @video.description \n @video.get_thumbnail_url(@video.selected_thumbnail) \n public_video_url(:public_token => @video.public_token) \n else \n # Standard meta tags \n image_path('meta_tag_logo.png') \n end \n browser_title \n # Logged In CSS \n cache_buster_path('/stylesheets/i_love_lamp-1.0.3.min.css') \n # Site-wide JS \n javascript_include_tag \"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" \n cache_buster_path('/javascripts/functions.min.js') \n cache_buster_path('/javascripts/i_love_lamp-1.0.3.min.js') \n javascript_include_tag \"player/player.js\" \n javascript_include_tag \"http://html5shiv.googlecode.com/svn/trunk/html5.js\" \n # Fav Icon and CSRF meta tag \n favicon_link_tag \n csrf_meta_tag \n get_background_for_user \n # Top navigation header \n link_to(image_tag(\"brevidy_rgb_white.png\", :size => \"135x35\", :alt => \"Brevidy - The Soul of Video\"), signed_in? ? user_stream_path(current_user) : :root, :class => \"brand\") \n video_search_path \n if signed_in? \n link_to(\"Explore\", explore_path) \n link_to(\"Upload\", new_user_video_path(current_user)) \n link_to(\"Share a Link\", user_share_dialog_path(current_user), :remote => true, \"data-method\" => \"GET\") \n link_to(\"Invite\", user_invitations_path(current_user)) \n end \n if signed_in? \n link_to(user_path(current_user), :class => \"dropdown-toggle\") do \n image_tag(\"#{current_user.image.blank? ? 'default_user_35px.jpg' : current_user.image_url(:small_profile) }\", :alt => \"#{current_user.name}\", :size => \"35x35\") \n current_user.username \n end \n link_to(\"My Channels\", user_channels_path(current_user)) \n link_to(\"Account Settings\", user_account_path(current_user)) \n link_to(\"Find People\", find_people_path) \n link_to(\"Help\", \"http://getsatisfaction.com/brevidy\", :target => \"_blank\") \n link_to(\"Logout\", logout_path, :remote => true, \"data-method\" => \"DELETE\") \n else \n link_to(\"Explore\", explore_path) \n link_to(\"Sign up\", signup_path) \n link_to(\"Login\", login_path) \n end \n \n # Main container \n # Dark Content Wrapper \n # Main (White) Content Wrapper \n link_to \"Go back\", :back \n image_tag(\"okayguy.png\", :alt => \"Okay\", :size => \"256x275\") \n # Lower navigation \n unless @page_has_infinite_scrolling \n succeed \" \" do \n link_to(\"FAQ\", faq_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Blog\", \"http://blog.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Status\", \"http://status.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Contact\", contact_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Terms\", tos_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Privacy\", privacy_path, :class => \"inlinelink\") \n end \n \n end \n # GetSatisfaction Feedback Widget & Google Analytics \n # Google Analytics \n # GetSatisfaction Code \n # AddThis script \n \n # Scroll back to top \n\nend\n\n end", "def create_videos\n end", "def show\n video = Video.mediakey(Time.now.strftime(\"%Y%m%d\").to_i)\n # Assuming Video belongs_to User, User has two fields called started_watching_at and duration \n video.user.update_attribute(:started_watching_at, [current_time])\n video.user.update_attribute(:watching_duration, 0)\nend", "def finished_at\n @episodes.last.first_watched\n end", "def video_content_removed( video_content )\n\t\t# schedule an upload\n\t\tCDNLimelightCoreStorageRemoveVideoContentFileTask.make_task( video_content )\n\tend", "def destroy\n user_authorised?(@video)\n @video.destroy\n redirect_to athlete_path(current_user)\n end", "def video_content_ready_for_upload( video_content )\n\t\t# schedule an upload\n\t\tCDNLimelightCoreStorageUploadVideoContentFileTask.make_task( video_content )\n\tend", "def decide_interested_video_type\n \n end", "def show_video\n\t\t@video = OldFlashFile.find(params[:id]) \n\t\tif @video\n\t\t@status=request.protocol+request.host_with_port+@video.video.url\n\t\telse\n\t\t@status = {\"status-msg\"=>\"Video not exist\"}\n\t\tend\n\n render :json =>@status.to_json\n\t\tend", "def in_play?\n started? || in_progress?\n end", "def show\n @video = Video.find(params[:id])\n @run = Run.find(@video.run_id)\n @videos = @run.visiblevideos\n @video.counter += 1\n @video.save\n \n @videocomments = Videocomment.find(:all, :conditions => {:video_id => @video.id})\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @video }\n end\n end", "def index\n redirect_to videos_url\n end", "def video?\n !!video_stream\n end", "def create\n @video = self.current_user.videos.new(params[:video])\n respond_to do |format|\n if @video.save\n if params[:video][:upload_ticket]\n # data is coming from asynchronous swf upload form page\n @asset = @video.attach_uploaded_asset!(Videoasset)\n if @asset\n format.html { render :partial => \"videos/video_info_form\", :locals => {:all_done => true} }\n else\n format.html { render :partial => \"videos/waiting_for_upload\"}\n end\n else\n # all-in-one upload page\n flash[:notice] = 'Video was successfully created.'\n format.html { redirect_to(video_path(@video)) }\n format.xml { render :xml => @video, :status => :created, :location => @video }\n end\n else\n if params[:video][:upload_ticket]\n # data is coming from asynchronous swf upload form page\n format.html { render :partial => \"videos/video_info_form\"}\n else\n # all-in-one upload page\n format.html { render :action => \"new\" }\n format.xml { render :xml => @video.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def playlist_end playlist\n end", "def call\n video = search_youtube\n if video.present?\n context.playlist.add_video!(\n title: video.title,\n url: \"https://www.youtube.com/watch?v=#{video.id}\",\n user: context.user\n )\n context.dj.new_video_added!\n context.message = \"Success! #{video.title} was added to the playlist.\"\n else\n context.errors = \"Sorry but couldn't find any vides for #{query}.\"\n context.fail!\n end\n end", "def add_video_to_queue(video)\n visit home_path\n click_on_video_on_home_page(video) # This method is in macros.rb\n click_link \"+ My Queue\"\n end", "def playable?\n video_source\n end", "def update\n @video = Video.find(params[:id])\n if owner?(@video.user_id)|| not_signed_in_owner?(@video)\n @video.update(video_title)\n redirect_to video_path(@video.id)\n else\n #TODO not authorized error\n redirect_to \"/\"\n end\n end", "def notify_movie_list\n files = Dir[\"#{DONE_ROOT}/*.m4v\"].sort\n if files.empty?\n notify(\"There are no completed shows at the mo.\")\n else\n msg = \"Here are your completed shows:\\n\"\n files.each_with_index do |path, index|\n msg << \"#{index+1}) #{File.basename(path, '.*')}\\n\"\n end\n notify(msg)\n end\n end", "def verify_user_owns_channel\n ruby_code_from_view.ruby_code_from_view do |rb_from_view|\n if we_should_show_og_tags && !@video.blank? \n # Facebook OpenGraph protocol for embedding our video link back to Brevidy \n public_video_url(:public_token => @video.public_token) \n @video.title \n @video.description \n @video.get_thumbnail_url(@video.selected_thumbnail) \n public_video_url(:public_token => @video.public_token) \n else \n # Standard meta tags \n image_path('meta_tag_logo.png') \n end \n browser_title \n # Logged In CSS \n cache_buster_path('/stylesheets/i_love_lamp-1.0.3.min.css') \n # Site-wide JS \n javascript_include_tag \"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" \n cache_buster_path('/javascripts/functions.min.js') \n cache_buster_path('/javascripts/i_love_lamp-1.0.3.min.js') \n javascript_include_tag \"player/player.js\" \n javascript_include_tag \"http://html5shiv.googlecode.com/svn/trunk/html5.js\" \n # Fav Icon and CSRF meta tag \n favicon_link_tag \n csrf_meta_tag \n get_background_for_user \n # Top navigation header \n link_to(image_tag(\"brevidy_rgb_white.png\", :size => \"135x35\", :alt => \"Brevidy - The Soul of Video\"), signed_in? ? user_stream_path(current_user) : :root, :class => \"brand\") \n video_search_path \n if signed_in? \n link_to(\"Explore\", explore_path) \n link_to(\"Upload\", new_user_video_path(current_user)) \n link_to(\"Share a Link\", user_share_dialog_path(current_user), :remote => true, \"data-method\" => \"GET\") \n link_to(\"Invite\", user_invitations_path(current_user)) \n end \n if signed_in? \n link_to(user_path(current_user), :class => \"dropdown-toggle\") do \n image_tag(\"#{current_user.image.blank? ? 'default_user_35px.jpg' : current_user.image_url(:small_profile) }\", :alt => \"#{current_user.name}\", :size => \"35x35\") \n current_user.username \n end \n link_to(\"My Channels\", user_channels_path(current_user)) \n link_to(\"Account Settings\", user_account_path(current_user)) \n link_to(\"Find People\", find_people_path) \n link_to(\"Help\", \"http://getsatisfaction.com/brevidy\", :target => \"_blank\") \n link_to(\"Logout\", logout_path, :remote => true, \"data-method\" => \"DELETE\") \n else \n link_to(\"Explore\", explore_path) \n link_to(\"Sign up\", signup_path) \n link_to(\"Login\", login_path) \n end \n \n # Main container \n # Dark Content Wrapper \n # Main (White) Content Wrapper \n link_to \"Go back\", :back \n image_tag(\"okayguy.png\", :alt => \"Okay\", :size => \"256x275\") \n # Lower navigation \n unless @page_has_infinite_scrolling \n succeed \" \" do \n link_to(\"FAQ\", faq_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Blog\", \"http://blog.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Status\", \"http://status.brevidy.com\", :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Contact\", contact_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Terms\", tos_path, :class => \"inlinelink\") \n end \n succeed \" \" do \n link_to(\"Privacy\", privacy_path, :class => \"inlinelink\") \n end \n \n end \n # GetSatisfaction Feedback Widget & Google Analytics \n # Google Analytics \n # GetSatisfaction Code \n # AddThis script \n \n # Scroll back to top \n\nend\n\n end", "def after_destroy(video) \n expire_cache_for(video) \n end", "def video\n YouTubeApi.find_video(youtube_id)\n end", "def show\n def video_exists?(url)\n url = URI.parse(url)\n url.is_a?(URI::HTTP) && !url.host.nil?\n rescue URI::InvalidURIError\n false\n end\n\n @video = Video.find(params[:id])\n\n if video_exists?(@video[:video_url])\n @video_exists = true\n @youtube_id = @video[:video_url].split('=')[1]\n end\n\n @links = [{:name => \"Home\", :path => root_path}, {:name => \"Back to Videos\", :path => videos_path}]\n end", "def video?\n self.type == \"Video\"\n end", "def destroy\n\t@video_participant = VideoParticipant.find(params[:id])\n\t@video = @video_participant.video\n if @video_participant.destroy\n\t\trespond_to do |format|\n\t\t format.html { redirect_to video_path(@video) }\n\t\t format.xml { head :ok }\n\t\tend\n\telse\n\t\tredirect_to video_path(@video)\n\tend\n end", "def backwardvideo\n Pusher['photo-call'].trigger('previous-video' , {\n control: \"1\"\n })\n render text: \"ok\"\n end", "def video\n \"#{self.video_file_name}\"\n end", "def add_video(tag)\n\n @driver.find_element(:link, 'Add Video').click\n\n wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds\n wait.until { @driver.find_element(:link_text, \"Save Video\") }\n\n # Type in URL of video into\n @driver.find_element(:id, 'videoUrlField').send_keys(tag)\n @driver.find_element(:link_text, \"Save Video\").click\n\n # Wait while video is processed\n wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds\n wait.until { @driver.find_element(:link_text, \"Edit Video\") }\n end", "def destroy\n @video = Video.find(params[:id])\n\tif @video.user == current_user or user_type == 'admin' or user_type == 'super_admin'\n\t\t@video.destroy\n\n\t\trespond_to do |format|\n\t\t format.html { redirect_to videos_url }\n\t\t format.json { head :no_content }\n\t\tend\n\telse\n\t\tredirect_to '/404'\n\tend\n end", "def create\n @video = current_user.videos.build(params[:video])\n\n @url = params[:video][:url]\n\n\n require 'uri'\n\n\n if(@url.downcase.include? 'youtube.com')\n ##create ways to catch if user is using \n query_string = URI.parse(params[:video][:url]).query\n parameters = Hash[URI.decode_www_form(query_string)]\n puts parameters['v'] # => aNdMiIAlK0g\n video_id = parameters['v']\n elsif (@url.downcase.include? 'y2u.be')\n puts video_id = @url.match(/\\.be\\/(.+)$/)[1]\n @url = 'http://www.youtube.com/watch?v='+video_id\n @video.url = @url \n elsif (@url.downcase.include? 'youtu.be')\n puts video_id = @url.match(/\\.be\\/(.+)$/)[1]\n @url = 'http://www.youtube.com/watch?v='+video_id\n @video.url = @url\n end\n \n \n\n @yt_client = YouTubeIt::Client.new(:dev_key => \"AI39si6hkRNCL77mzzv1LycIohZtksVIi0L5S9lQMx6crqOfGdyKcB2U2M5WHeNBUT2VLgTVzjR9rxPa1RJZw-sZ6wqtnaZ7AA\")\n @video.youtube_id = video_id # => aNdMiIAlK0g\n\n this_video = @yt_client.video_by(video_id)\n\n\n @video.duration = this_video.duration \n\n\n\n respond_to do |format|\n if @video.save ##and video is over 60 seconds in duration \n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def next_video\n if episode?\n episode = content.next_ep\n unless episode.nil?\n return episode.video\n end\n end\n end", "def video_session\n filename.split(\"_\").first\n end", "def video?\n self.type == \"Assetabler::Video\"\n end", "def completed?(step)\n case step\n when :begin\n true\n when :waiver\n @player.signed_waiver?\n when :squad\n @player.joined_squad?\n when :off_campus\n !@player.off_campus.nil?\n when :confirm\n true\n when :done\n @player.registered == true\n end\n end", "def play\r\n return if self.finished?\r\n self.update\r\n end", "def show\n @room = @video.room\n authorize! @room\n @stream_url_ready = S3_BUCKET_HLS.object(\"#{ENV[\"SERVER_STAGE\"]}/stream/#{@video.s3_key}/index.m3u8\").exists?\n @page_title = @video.title\n end", "def validate_video(input)\n if input[:watched_list].include? input[:video_id]\n Success(input)\n else\n Failure('Please first request this project to be added to your list')\n end\n end", "def pause\n\n end", "def update\n @video = Video.find(params[:id])\n\n flash[:success] = 'Video was successfully updated.' if @video.update_attributes(params[:video])\n respond_with(current_user,@video)\n end", "def perform(url = nil)\n # 以此影片為範例,出處: Videvo\n url = 'https://cdn.videvo.net/videvo_files/video/free/2013-05/originalContent/DigitalCountdownTimerVidevo.mov'\n video_name = parse_video_name(url)\n video_file_path(video_name)\n download_video(url)\n converter\n rescue StandardError => e\n logger.error \"[Video::HandleVideoWorker] ERROR:\\n #{e.inspect}\\n #{e.backtrace}\"\n end", "def update\n @video = @user.videos.find(params[:id])\n respond_to do |format|\n if @video.update(video_params)\n format.html { redirect_to user_videos_path(@user), notice: 'Video was successfully updated.' }\n format.json { render :show, status: :ok, location: @video }\n else\n format.html { render :edit }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def opentok_callback\n Rails.logger.info \"================= opentok_callback called: #{params.inspect}\"\n if params[:token] == ENV['OPENTOK_CALLBACK_TOKEN']\n live_video = ContentLiveVideo.find_by_archive_id(params[:id])\n if params[:status] == 'stopped' && !live_video.finished? # finished by opentok server (not by user broadcaster)\n live_video.stop_streaming!\n end\n \n if params[:status] == 'uploaded'\n live_video.playback_uploaded!\n end\n render inline: ''\n else\n Rails.logger.error \"******** Error: Invalid OPENTOK_CALLBACK_TOKEN received (please review opentok admin panel -> Callback URL)\"\n render_error_messages(['Invalid Token'])\n end\n end", "def update\n respond_to do |format|\n if @video.update(video_params)\n format.html { redirect_to @video.competition, notice: 'Video modificado correctamente..' }\n format.json { render :show, status: :ok, location: @video }\n else\n format.html { render :edit }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_current_video\n\t\t@current_video ||= if params[:video_id].present?\n\t\t\tVideo.find(params[:video_id])\n\t\tend\n\tend", "def show\n begin\n @active_page = \"videos\"\n @video.increament_no_of_views\n uvh_record = UserVideoHistory.update_view_history(current_user.id, @video.id)\n @like_dislike_status = uvh_record.like_dislike_status\n respond_with(@video)\n rescue Exception => e\n log_error(e, \"Error occured in Show action of VideosController\")\n flash_error(t('videos.show_page_load_error'))\n end\n end", "def after_save(video) \n expire_cache_for(video) \n end", "def show\n #@video.create_log_entry('Video', current_user.id, DateTime.now)\n end", "def set_video\n @video = @user.videos.find(params[:id])\n end", "def favourite\n Video.add_to_favourite_by_media_id_and_user(params[:id], current_user)\n respond_to do |format|\n format.html {video = Video.find_by_id(params[:id]); redirect_to video_view_path(video.id, video.title)}\n format.js {render :nothing => true}\n end\n end", "def finished; end", "def video\n\t\tVideo.find(self.video_id)\n\tend", "def destroy\n @video = @user.videos.find(params[:id])\n @video.destroy\n respond_to do |format|\n format.html { redirect_to user_videos_url(@user), notice: 'Video was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def valid_videos\n self.videos.select{ |video|\n video.exist? && video.embed? && video.auto_play?\n }\n end", "def create\n @video = Video.new(params[:video])\n @video.user = current_user\n\n flash[:success] = 'Video has been uploaded and is being processed.' if @video.save\n respond_with(current_user,@video)\n end", "def download_all_videos_from_pl id,d_name\n\tmy_directory = \"#{@dir}#{d_name}\"\n\n\t videos_already_saved_array = get_all_titles_from_dir my_directory\n\n\t videos_already_saved_titles, videos_already_saved_paths = \n\t \t\t\t\t\tvideos_already_saved_array.map{|e| e[0]}, videos_already_saved_array.map{|e| e[2]}\n\n\t@current_playlist_video_titles.each do |v|\n\t\t\tsource = 'youtube'\n\t\t\tindex = @current_playlist_video_titles.index(v)\n\t\t\tp index\n\t\t\tvid = @current_playlist_video_ids[index]\n\t\t\tp vid\n\n\t\tif !videos_already_saved_titles.include?(v)\t\n\t\t\t\n\t\t\tvideo_string = \"http://www.youtube.com/watch?v=#{vid}\"\n\t\t\tdownload_video = \"viddl-rb #{video_string} -d 'aria2c' -s '#{my_directory}'\"\n\n\t\t\tcaptured_stdout = ''\n\t\t\tcaptured_stderr = ''\n\t\t\tstdin, stdout, stderr, wait_thr = Open3.popen3(\"#{download_video}\")\n\t\t\tpid = wait_thr.pid\n\t\t\tstdin.close\n\t\t\tcaptured_stdout = stdout.gets(nil)\n\t\t\taborted = captured_stdout.include? \"Download aborted\"\n \t\t\t# captured_stderr = stderr.read\n\t\t\twait_thr.value # Process::Status object returned\n\n\t# extract the info we need\n\t\t\tputs \"STDOUT: \" + captured_stdout\n\t\t\t# puts \"STDERR: \" + captured_stderr\n\n\t\t\t# go to Vimeo to download if it doesnt work\n\t\t\tif aborted\n\t\t\t\tartist_match_results = match_best v, @rule_artists\n\t\t\t\t@song_artist = artist_match_results[0]\n\t\t\t\tremaining_words = artist_match_results[1]\n\t\t\t\tsong_match_results = match_best remaining_words, @rule_titles\n\t\t\t\t@song_title = song_match_results[0]\n\n\t\t\t\tsource='vimeo'\n\t\t\t\tget_vimeo_manually @song_artist,@song_title,@mydir,\"vimeo\"\n\t\t\t\t# Process.kill(\"KILL\", stream.pid)\n\t\t\t\t# get_vimeo_manually v,my_directory,source \n\t\t\tend\n\n\t\t\tp \"already have it\" if videos_already_saved_titles.include?(v)\n\t\tend\n\n\n\tend\n\n\t\nend" ]
[ "0.6808604", "0.63277876", "0.62168425", "0.6162259", "0.6148543", "0.61454415", "0.6127088", "0.60524744", "0.5973399", "0.59597635", "0.59560174", "0.59123904", "0.5903585", "0.58820915", "0.58287007", "0.58057064", "0.5805127", "0.5775226", "0.5756984", "0.5750114", "0.5743069", "0.5736672", "0.573222", "0.570939", "0.56863594", "0.5677302", "0.56687725", "0.5665318", "0.5650047", "0.5642972", "0.56251574", "0.5618745", "0.5593875", "0.55901384", "0.55818605", "0.5580672", "0.5576581", "0.5576235", "0.5575105", "0.55625874", "0.5544188", "0.55435055", "0.5534237", "0.55277663", "0.5512376", "0.5510727", "0.5508932", "0.5507739", "0.5499738", "0.549568", "0.54956335", "0.54903066", "0.548572", "0.5485084", "0.5481196", "0.5479657", "0.5479406", "0.5476839", "0.54752386", "0.5469562", "0.5468533", "0.54670316", "0.5457601", "0.5457449", "0.54566187", "0.54514545", "0.5450432", "0.543904", "0.5429725", "0.54192245", "0.54166126", "0.5406344", "0.53877836", "0.5384966", "0.538493", "0.5375725", "0.5374472", "0.5368227", "0.53568757", "0.5356429", "0.53432715", "0.53369755", "0.5332954", "0.53244585", "0.5323715", "0.53217435", "0.53216803", "0.5311569", "0.530897", "0.53075737", "0.52969766", "0.52937245", "0.5285824", "0.5281409", "0.52806187", "0.52780026", "0.5276944", "0.5275455", "0.52741474", "0.5271879", "0.5270473" ]
0.0
-1
Takes an array of strings, each representing a line Draws a box around the lines, and returns a new array padding may be provided
def box_it(array_of_lines, padding = 1, _box_colour = :bc_cyan) max_length = max_box_line_length(array_of_lines) pad_string = "\s" * padding box_lines = [ # Set the top box line "#{BOX_TOP_LEFT}#{BOX_HORIZONTAL_LINE * (max_length + (padding + 1))}#{BOX_TOP_RIGHT}" ] array_of_lines.each do |line| line_length = line.sanitize.length box_lines << "#{BOX_SIDE}#{pad_string}" + line.to_s + "#{"\s" * (max_length - line_length)}#{pad_string}#{BOX_SIDE}" end # Set the bottom box line box_lines << "#{BOX_BOTTOM_LEFT}#{BOX_HORIZONTAL_LINE * (max_length + (padding + 1))}#{BOX_BOTTOM_RIGHT}" box_lines end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_line(arr)\n x = TTY::Screen.width - 2\n small_items = 12\n first_item = x - 5 * small_items\n\n output = \"\"\n arr.each_with_index do |l, i|\n if i == 0\n output << l.to_s[0..first_item].ljust(first_item)\n else\n output << l.to_s[0..small_items].ljust(small_items)\n end\n end\n output\n end", "def pad_two_dimensionnal_array(array)\n column_count = array[0].length\n longests = Array.new(column_count, 0)\n array.each do |line|\n line.each_with_index do |cell, column|\n cell = '' if cell.nil?\n length = cell.size\n longest = longests[column]\n longests[column] = length if length > longest\n end\n end\n\n padded_array = array.map do |line|\n line.map.with_index do |cell, index|\n cell = '' if cell.nil?\n cell.ljust(longests[index])\n end\n end\n padded_array\n end", "def lines(txt, border, filler)\n print border\n (txt.length + 2).times do\n print filler\n end\n print border\n print \"\\n\"\nend", "def print_in_box(string)\n lines = string.scan(/.{1,76}/)\n width = lines.first.to_s.size + 2\n top_bot = \"+#{'-' * width}+\"\n padding = \"|#{' ' * width}|\"\n text = lines.map { |line| \"| #{line.ljust(width - 2)} |\" }\n puts [top_bot, padding, text, padding, top_bot]\nend", "def break_text_with_image(width, textarray, draw)\n tokens = textarray.flat_map{ |x| x.respond_to?(:split) ? x.split(/ /) : x }\n tokens = tokens.flat_map{ |x| x.respond_to?(:split) ? x.split(/(?<=\\n)/) : x }\n\n result = []\n line = []\n linelength = 0\n\n tokens.each_with_index do |item, i|\n itemlength = item.class == Image ?\n item.columns : draw.get_type_metrics(item + ' ').width\n\n if (line.empty?)\n line << item\n else\n if (width != 0 && itemlength + linelength > width)\n result << line\n line = [item]\n linelength = 0\n else\n t = line.pop\n\n if (t.class != Image)\n t += ' '\n elsif (item.class != Image)\n item = ' ' + item\n end\n\n if (t.class == Image or item.class == Image)\n line << t << item\n else\n line << t + item\n end\n end\n end\n\n if (item.class != Image and item.include?(\"\\n\"))\n line[0].sub!(\"\\n\", '')\n result << line\n line = []\n linelength = 0\n next\n end\n\n linelength += itemlength\n end\n\n unless (line.empty?)\n result << line\n end\n\n return result\n end", "def determine_rects(rect, spacing, right_pad)\n rects = []\n \n # Rects Initialization\n rects[0] = [Rect.new(rect.x,rect.y,90,24),\n Rect.new(rect.x,rect.y,100,24)]\n rects[1] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[2] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[3] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[4] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[5] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[6] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[7] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[8] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[9] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[10] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[11] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n \n gauge_value_width = rect.width - 24 - 25 - right_pad\n stats_value_width = rect.width - 24 - 50 - right_pad\n gauge_y = 16\n \n # Rects Adjustments\n \n # ucActStates\n rects[0][1].x += rects[0][0].width\n \n # ucHpStat\n rects[1][0].y += spacing\n rects[1][1].x += rects[1][0].width\n rects[1][1].y = rects[1][0].y\n rects[1][2].x = rects[1][1].x + rects[1][1].width\n rects[1][2].y = rects[1][0].y\n rects[1][2].width = gauge_value_width\n \n # cHpStatGauge\n rects[2].y += rects[1][0].y+gauge_y\n rects[2].height = rects[1][0].height-gauge_y\n \n # ucMpStat\n rects[3][0].y += spacing*2\n rects[3][1].x += rects[3][0].width\n rects[3][1].y = rects[3][0].y\n rects[3][2].x = rects[3][1].x + rects[3][1].width\n rects[3][2].y = rects[3][0].y\n rects[3][2].width = gauge_value_width\n \n # cMpStatGauge\n rects[4].y += rects[3][0].y+gauge_y\n rects[4].height = rects[3][0].height-gauge_y\n \n # ucAtkStat\n rects[5][0].y += spacing*3\n rects[5][1].x += rects[5][0].width\n rects[5][1].y = rects[5][0].y\n rects[5][2].x = rects[5][1].x + rects[5][1].width\n rects[5][2].y = rects[5][0].y\n rects[5][2].width = stats_value_width\n \n # ucDefStat\n rects[6][0].y += spacing*4\n rects[6][1].x += rects[6][0].width\n rects[6][1].y = rects[6][0].y\n rects[6][2].x = rects[6][1].x + rects[6][1].width\n rects[6][2].y = rects[6][0].y\n rects[6][2].width = stats_value_width\n \n # ucSpiStat\n rects[7][0].y += spacing*5\n rects[7][1].x += rects[7][0].width\n rects[7][1].y = rects[7][0].y\n rects[7][2].x = rects[7][1].x + rects[7][1].width\n rects[7][2].y = rects[7][0].y\n rects[7][2].width = stats_value_width\n \n # ucAgiStat\n rects[8][0].y += spacing*6\n rects[8][1].x += rects[8][0].width\n rects[8][1].y = rects[8][0].y\n rects[8][2].x = rects[8][1].x + rects[8][1].width\n rects[8][2].y = rects[8][0].y\n rects[8][2].width = stats_value_width\n \n # ucEvaStat\n rects[9][0].y += spacing*7\n rects[9][1].x += rects[9][0].width\n rects[9][1].y = rects[9][0].y\n rects[9][2].x = rects[9][1].x + rects[9][1].width\n rects[9][2].y = rects[9][0].y\n rects[9][2].width = stats_value_width\n \n # ucHitStat\n rects[10][0].y += spacing*8\n rects[10][1].x += rects[10][0].width\n rects[10][1].y = rects[10][0].y\n rects[10][2].x = rects[10][1].x + rects[10][1].width\n rects[10][2].y = rects[10][0].y\n rects[10][2].width = stats_value_width\n \n # ucCriStat\n rects[11][0].y += spacing*9\n rects[11][1].x += rects[11][0].width\n rects[11][1].y = rects[11][0].y\n rects[11][2].x = rects[11][1].x + rects[11][1].width\n rects[11][2].y = rects[11][0].y\n rects[11][2].width = stats_value_width\n \n return rects\n end", "def padded_slices\n normalize_plaintext.chars.each_slice(size).to_a.tap do |*_, last|\n (size - last.size).times { last << nil } \n end\n end", "def lPad(thePad = '')\n theCopy = TextRect.new(@theLines)\n theCopy.lPad!(thePad)\n end", "def normalised_lines(lines)\n max_length = lines.collect(&:visual_length).max\n lines.map do |line|\n FTT::Text.new(line.to_s).right_pad(max_length)\n end\n end", "def box msgs, box_char=@box_char, box_size=@box_size\n self.liner box_char, box_size\n [msgs].flatten.each do |text|\n text.each_line do |line|\n self.<< '# ' + box_char + ' ' + line.chomp + \"\\n\"\n end\n end\n self.liner box_char, box_size\n end", "def line_split (in_string)\n my_string_array = in_string.split(\"\\n\")\n\n my_string_array.each_index do |index|\n # determine digits in largest line num, digits in current line num, & necessary padding\n max_line_digits = my_string_array.count.to_s.length\n this_line_digits = (index+1).to_s.length\n padding = ' ' * (max_line_digits - this_line_digits)\n\n # output the line\n puts \"Line #{padding}#{index + 1}: #{my_string_array[index]}\"\n end\nend", "def format_lines(lines)\n prev = lines[0]\n slices = lines.slice_before do |e|\n (prev + 1 != e).tap { prev = e }\n end\n slices.map { |slice_first, *, slice_last| slice_last ? (slice_first..slice_last) : slice_first }\n end", "def lines\n @lines[oy...(oy + bordered_height)] || []\n end", "def justify(array, max_length=16)\n words_per_line = 0\n character_count = 0\n per_line = []\n\n array.each_with_index do |word, index|\n if (character_count + word.length) > max_length\n per_line << words_per_line\n character_count = 0\n words_per_line = 0\n end\n character_count += word.length + 1\n words_per_line += 1\n end\n\n per_line << array.size - per_line.inject(:+) if (array.size - per_line.inject(:+)) != 1\n\n result = []\n number_of_lines = per_line.size\n\n 0.upto(number_of_lines - 1) do |i|\n line = array.first(per_line[i])\n array = array.drop(per_line[i])\n\n num_of_chars = line.join(\" \").size\n num_of_chars_to_fill = max_length - num_of_chars\n num_of_words = per_line[i]\n num_of_words == 1 ? num_of_spaces = 1 : num_of_spaces = (num_of_words - 1)\n\n if num_of_chars_to_fill % num_of_spaces == 0\n 0.upto(num_of_spaces-1) do |space|\n line[space] << \" \" * (num_of_chars_to_fill/num_of_spaces)\n ##will only occur when number of chars to fill is less than the num of spaces.\n if num_of_chars_to_fill > 0 && num_of_chars_to_fill/num_of_spaces == 0\n ## Add the num_of_chars_to_fill to the most lefterly spaces.\n count = 0\n until count == num_of_chars_to_fill\n line[count] << \" \"\n count += 1\n end\n end\n end\n elsif num_of_chars_to_fill % num_of_spaces != 0\n if num_of_chars_to_fill == 1\n line[0] << \" \"\n elsif num_of_chars_to_fill > 1\n 0.upto(num_of_spaces-1) do |space|\n line[space] << \" \" * (num_of_chars_to_fill/num_of_spaces)\n line[0] << \" \"\n if num_of_chars_to_fill > 0 && num_of_chars_to_fill/num_of_spaces == 0\n ## Add the num_of_chars_to_fill to the most lefterly spaces.\n ## Count == as we have already placed one.\n count = 1\n until count == num_of_chars_to_fill\n line[count] << \" \"\n count += 1\n end\n end\n end\n end\n end\n line = line.join(\" \")\n result << line\n end\n\n unless array.empty?\n last_line = array[0] + (\" \" * (max_length - array[0].size))\n result << last_line\n end\n\n puts result\nend", "def box(n)\n result = []\n 3.times do |i|\n row = (n.to_i / 3) * 3 + i\n # puts \"row: #{n} -> #{row}\"\n 3.times do |j|\n col = (n % 3) * 3 + j\n # puts \" col: #{n} -> #{col}\"\n result << @lines[row][col]\n end\n end\n result\n end", "def rPad!(thePad = '')\n len = @theLines.length\n padArray = Array.new(len, thePad)\n padTR = TextRect.new(padArray)\n self.join!(padTR)\n end", "def context_line(lines, index, padding, prefix=nil)\n return '' if index < 1 || index > lines.size\n margin = prefix ? prefix * index.to_s.size : index.to_s\n \"#{margin}#{' ' * ([padding - margin.size, 0].max)} #{lines[index - 1]}\"\n end", "def fold!(width, number = nil, breaker = nil)\n\n # If the TextRect has no lines, just return immediately.\n\n len = @theLines.length\n return self if len == 0\n\n # Create an array of line numbers. Make sure they are right adjusted.\n # When the array is complete, make up a left fill for those broken lines\n # that will not be copied. Also remember the length of the numbering\n # header.\n\n theNums = Array.new(len, '')\n\n if not number.nil? \n 0.upto(len-1) { |i| theNums[i] = \"#{(i+number).to_s}. \" }\n numWide = theNums.last.length\n theNums.collect! { |s| s.rjust(numWide) }\n end\n\n theFill = theNums.last.tr(theNums.last, ' ')\n numLen = theNums.last.length\n\n # Now process the strings of the original TextRect one by one. The new\n # lines are collected into an initially empty Array. Each line from the\n # receiver is processed in turn.\n\n theRes = Array.new\n\n @theLines.each_index do |i|\n\n # Get a line from the receiver and split it into words. Set of an array\n # of replacement lines and initialize the first replacement line to \n # be the number for the line followed by the first word and a space. \n # Every working line will end with a space (to be removed later).\n\n theWords = @theLines[i].split\n newLines = Array.new\n newLine = theNums[i] + theWords.delete_at(0) + ' '\n \n # In this loop, process each word in turn. Notice that as the line\n # already includes the first word and has a space at the end. If the line\n # cannot take one more word, take the trailing blank off, put it into\n # the accumulating array of new lines, and initialize the next new\n # line -- which must exist because there is a word pending -- with the\n # the left fill. Then, regardless of whether a line was saved, put the\n # word and a space at the end of the current line.\n\n theWords.each do |w|\n if newLine.length + w.length > width\n newLine.chomp!(' ')\n newLines << newLine\n newLine = String.new(theFill)\n end\n newLine << w << ' '\n end\n \n # All the words from this original line have been processed. Make sure\n # the last partial line gets into the array. Then put the folded lines\n # into the result. If this isn't the last line and the breaker isn't\n # NIL, put in a breaker line.\n\n newLines << newLine \n theRes.concat(newLines)\n theRes << breaker unless breaker.nil? or i == @theLines.length - 1\n\n end\n\n @theLines = theRes\n\n return self\n\n end", "def render_all pad, arr\n pre_render\n @content_cols = @source.pad_cols\n @clearstring = \" \" * @content_cols\n @list = arr\n\n att = @attr || NORMAL\n FFI::NCurses.wattron(pad, @cp | att)\n\n arr.each_with_index { |line, ix|\n render pad, ix, line\n }\n FFI::NCurses.wattroff(pad, @cp | att)\n end", "def print_in_box(str)\n dash_inserts = '-' * str.length\n horiz_border = '+-' + dash_inserts + '-+'\n space_inserts = ' ' * str.length\n padding_border = '| ' + space_inserts + ' |'\n puts horiz_border\n puts padding_border\n puts '| ' + str + ' |'\n puts padding_border\n puts horiz_border\nend", "def print_in_box(str)\n size = str.size\n border_line = '+-' + ('-' * size) + '-+'\n empty_line = '| ' + (' ' * size) + ' |'\n text_line = '| ' + str + ' |'\n \n puts border_line\n puts empty_line\n puts text_line\n puts empty_line\n puts border_line\nend", "def normalize\n @height = @text_lines.size\n @width = 0\n @sltn_lines = [ ]\n @text_lines.each do |line|\n len = line.length\n @width = len if (len > @width)\n @sltn_lines << '+' * len\n end\n (0...@text_lines.size).each do |i|\n no_pad_chars = @width - @text_lines[i].length\n 1.upto(no_pad_chars) do\n @text_lines[i] << '+'\n @sltn_lines[i] << '+'\n end\n end\n end", "def wrap(width)\n width ||= 80\n output = []\n indent = ''\n\n text = gsub(/\\t/, ' ')\n\n text.lines do |line|\n line.chomp! \"\\n\"\n if line.length > width\n indent = if line.uncolor =~ /^(\\s*(?:[+\\-*]|\\d+\\.) )/\n ' ' * Regexp.last_match[1].length\n else\n ''\n end\n new_lines = line.split_line(width)\n\n while new_lines.length > 1 && new_lines[1].length + indent.length > width\n output.push new_lines[0]\n\n new_lines = new_lines[1].split_line(width, indent)\n end\n output += [new_lines[0], indent + new_lines[1]]\n else\n output.push line\n end\n end\n output.map!(&:rstrip)\n output.join(\"\\n\")\n end", "def spot_legs\n lines = []\n indent = 0\n spacer = @width - @padding\n\n draw_legs(lines, indent, spacer)\n lines\n end", "def draw_multi(text, x, y, width, lines = -1, base_color = Color.new(255,255,255), shadow_color = nil,\n outline = false, y_line_diff = 24, allow_split_in_words = false)\n self.bmp.draw_multi(text, x, y, width, lines, base_color, shadow_color,\n outline, y_line_diff, allow_split_in_words)\n end", "def pretty_board(board_array)\n\toutput = \"\\n\"\n\tboard_array.each do |row|\n\t\trow.each do |box|\n\t\t\toutput << \" #{box}\"\n\t\tend\n\t\toutput << \"\\n\"\n\tend\n\toutput << \"\\n\"\n\n\treturn output\nend", "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,80,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[1] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,80,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[2] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,80,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[3] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[4] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n \n # Rects Adjustments\n \n # ucEncounters\n rects[0][1].x += rects[0][0].width\n rects[0][2].x = rects[0][1].x + rects[0][1].width\n rects[0][2].width = rect.width - rects[0][0].width - rects[0][1].width\n \n # ucDefeated\n rects[1][0].y += spacing\n rects[1][1].x += rects[1][0].width\n rects[1][1].y = rects[1][0].y\n rects[1][2].x = rects[1][1].x + rects[1][1].width\n rects[1][2].y = rects[1][0].y\n rects[1][2].width = rect.width - rects[1][0].width - rects[1][1].width\n \n # ucEscaped\n rects[2][0].y += spacing*2\n rects[2][1].x += rects[2][0].width\n rects[2][1].y = rects[2][0].y\n rects[2][2].x = rects[2][1].x + rects[2][1].width\n rects[2][2].y = rects[2][0].y\n rects[2][2].width = rect.width - rects[2][0].width - rects[2][1].width\n \n # ucExp\n rects[3][0].y += spacing*3\n rects[3][1].x += rects[3][0].width\n rects[3][1].y = rects[3][0].y\n rects[3][2].x = rects[3][1].x + rects[3][1].width\n rects[3][2].y = rects[3][0].y\n rects[3][2].width = rect.width - rects[3][0].width - rects[3][1].width\n \n # ucGold\n rects[4][0].y += spacing*4\n rects[4][1].x += rects[4][0].width\n rects[4][1].y = rects[4][0].y\n rects[4][2].x = rects[4][1].x + rects[4][1].width\n rects[4][2].y = rects[4][0].y\n rects[4][2].width = rect.width - rects[4][0].width - rects[4][1].width\n \n return rects\n end", "def build_canvas(lines_of_text_blocks)\n # Grab the greatest values for each line\n line_baseline = []\n line_height = []\n line_width = []\n lines_of_text_blocks.each_index do |i|\n baselines = (lines_of_text_blocks[i].sort { |a,b| a.baseline <=> b.baseline })\n heights = (lines_of_text_blocks[i].sort { |a,b| a.height <=> b.height })\n line_baseline << baselines.last.baseline\n line_height << heights.last.height - heights.last.line_spacing\n width = 0\n lines_of_text_blocks[i].each { |l| width += l.width }\n line_width << width\n end\n \n # set up canvas height and width\n @width = line_width.sort.last\n height = 0\n line_spacing_height = 0\n line_height.each { |h| height += h ; line_spacing_height += (h * (@options[:line_spacing] || 0)) }\n line_spacing_height -= (line_height.last * (@options[:line_spacing] || 0))\n @height = height + line_spacing_height\n \n options = nil\n if @options[:matte]\n options = @options.dup\n options[:bgcolor] = 'transparent'\n else\n options = @options\n end\n \n @canvas = IQ::Image::Canvas.new(@width, @height, options)\n \n # actually go through the lines and do stuff with them to make the canvas\n # for each line align each text block with the baseline\n top = 0\n lines_of_text_blocks.each_index do |i|\n left = 0\n lines_of_text_blocks[i].each do |text_block|\n offset = (line_baseline[i] - text_block.baseline)\n @canvas.overlay!(text_block.to_canvas, :dest_x => left, :dest_y => top + offset)\n left += text_block.width\n end\n top += line_height[i] + ((@options[:line_spacing] || 0) * line_height[i])\n end\n @canvas\n end", "def space_mask(lines)\n max_line_length = lines.map{ |a| a.length }.max\n lines.inject([true] * max_line_length){ |mask, line|\n mask.zip(line).\n map{ |a, b| a && (!b || b == SPACE) }}\n end", "def build_spans on_range\n # TODO: rewrite in terms of each_row\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end", "def print_in_box(str)\n sub_strings = sub_strings(str, 76)\n largest_sub_string = sub_strings.max_by { |str| str.size } # A bug caused by the fact\n # That an array may be \n # empty.\n size = largest_sub_string ? largest_sub_string.size : 0\n \n border_line = '+-' + ('-' * size) + '-+'\n empty_line = '| ' + (' ' * size) + ' |'\n \n puts border_line\n puts empty_line\n sub_strings.each do |str|\n puts '| ' + str.ljust(size) + ' |'\n end\n puts empty_line\n puts border_line\nend", "def line_formatter(array)\n if array.any? {|item| item.is_a?(Array)}\n cols = []\n array.each do |item|\n if item.is_a?(Array)\n item.each_with_index { |val,idx| cols[idx] = [cols[idx]||0, (val || '').length].max }\n end\n end\n cols.map { |col| \"%-#{col}s\" }.join(\" \")\n else\n \"%s\"\n end\n end", "def line_formatter(array)\n if array.any? {|item| item.is_a?(Array)}\n cols = []\n array.each do |item|\n if item.is_a?(Array)\n item.each_with_index { |val,idx| cols[idx] = [cols[idx]||0, (val || '').length].max }\n end\n end\n cols.map { |col| \"%-#{col}s\" }.join(\" \")\n else\n \"%s\"\n end\n end", "def rPad(thePad = '')\n theCopy = TextRect.new(@theLines)\n theCopy.rPad!(thePad)\n end", "def columnate(theWidth, thePad = ' ')\n theCopy = TextRect.new(@theLines)\n return theCopy.columnate!(theWidth, thePad)\n end", "def format_lines(lines, indentation)\n lines.gsub(/\\n/, \"\\n\" + indentation)\n end", "def diamond(length)\n diamonds = (1..length).select { |num| num.odd? }\n shape_array = []\n spaces = length / 2\n length.times do |num|\n index = length / 2 - spaces.abs\n shape_array << \"#{' ' * spaces.abs}#{'*' * diamonds[index]}\"\n spaces -= 1\n end\n shape_array\nend", "def line_items\n move_down 20\n data = line_item_data\n options = { width: bounds.width }\n header_styles = {\n border_width: 2,\n border_color: \"333333\"\n }\n table data, options do |table|\n table.rows(0).style(table_style.merge(header_styles))\n table.rows(1).style(table_style.merge(padding_top: 30))\n table.rows(2..data.length-1).style(table_style)\n end\n move_down 10\n stroke_color \"999999\"\n stroke_horizontal_rule\n end", "def as_box(opts={})\n opts = {:max_cols => Inf, :padding => 0}.merge opts\n return inspect unless cols = ENV['COLUMNS']\n cols = cols.to_i\n cell_size = map {|e| e.inspect.csize}.max + opts[:padding]*2\n if n = [(1..cols/2).max {|i| i*(cell_size+1) < cols}, opts[:max_cols]].min\n table = div(n)\n border = '+'+('-'*cell_size+'+')*n\n need_lb = border.size < cols\n border << \"\\n\" if need_lb\n last_border = table.last.size == n ? \n border : \n '+'+('-'*cell_size+'+')*table.last.size + '-'*((cell_size+1)*(n-table.last.size)-1) + '+'\n table.map {|rows| \n str = '|'+rows.map {|cell| cell.inspect.ccenter(cell_size)}*'|'+'|'\n str << ' '*((cell_size+1)*(n-rows.size)-1)+'|' if rows.size < n\n border + str + (\"\\n\" if need_lb)\n }.join + last_border\n else inspect\n end\n end", "def assign_spaces_to_rows\n space_names.each_slice(@length).to_a\n end", "def determine_rects(rect, spacing, right_pad)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,100,24)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[2] = Rect.new(rect.x,rect.y,rect.width,24)\n rects[3] = [Rect.new(rect.x,rect.y,rect.width,18),\n Rect.new(rect.x,rect.y,18,18)]\n rects[4] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[5] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[6] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[7] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[8] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[9] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n \n gauge_value_width = rect.width - right_pad\n gauge_y = 16\n \n # Rects Adjustments\n \n # ucActStates\n rects[0].x += ((rect.width - rects[0].width) / 2).floor\n rects[0].y += spacing*3\n \n # cCharImage\n rects[1].height -= spacing*3\n \n # cCharName\n # Nothing to do\n \n # ucCharLvl\n rects[3][0].y += spacing\n rects[3][0].width -= rects[3][1].width\n rects[3][1].x += rects[3][0].width\n rects[3][1].y = rects[3][0].y\n \n # ucHpStat \n rects[4][0].y += rect.height - spacing*4\n rects[4][1].x += rects[4][0].width\n rects[4][1].y = rects[4][0].y\n rects[4][2].y = rects[4][0].y + spacing\n rects[4][2].width = gauge_value_width\n \n # cHpStatGauge\n rects[5].y = rects[4][0].y+gauge_y\n rects[5].height = rects[4][0].height-gauge_y\n \n # ucMpStat\n rects[6][0].y += rect.height - spacing*2\n rects[6][1].x += rects[6][0].width\n rects[6][1].y = rects[6][0].y\n rects[6][2].y = rects[6][0].y + spacing\n rects[6][2].width = gauge_value_width\n \n # cMpStatGauge\n rects[7].y = rects[6][0].y+gauge_y\n rects[7].height = rects[6][0].height-gauge_y\n \n # ucExpStat\n rects[8][0].y += spacing\n rects[8][1].x += rects[8][0].width\n rects[8][1].y = rects[8][0].y\n rects[8][2].y = rects[8][0].y + spacing\n rects[8][2].width = gauge_value_width\n \n # cExpGauge\n rects[9].y = rects[8][0].y+gauge_y\n rects[9].height = rects[8][0].height-gauge_y\n \n return rects\n end", "def rect(a, b, screen)\n screen[0...b].each do |row|\n row[0...a] = (\"#\"*a).split(\"\")\n end\n\n screen\nend", "def box_lines\n return [] if output.match NO_BOXES\n output.lines\n end", "def horizontalLines\n (0...@height).inject([]) { |arr, row| arr << @modified.row(row) }\n end", "def pad(line, l, tw)\n # FIXME: Probably more efficient to pre-create\n # one. Wont this pass through the ANSI parser?\n # FIXME: The + 1 obscures cutoff indicators.\n c = tw - l + 1 #text_width #@out.w-line.length-6\n if c > 0\n line << \"\\e[48m\"+\" \"*c\n end\n end", "def padding(values)\n values = build_padding_values(values)\n position = padding_position(values)\n width, height = padding_size(values)\n bounding_box(position, width: width, height: height) { yield }\n end", "def print_in_box(string)\n length = string.length\n upper_lower_box = \"\"\n top_bottom = \"+-\" + multi_char(length, \"-\") + \"-+\"\n padding = \"| \" + multi_char(length, \" \") + \" |\"\n line = \"| \" + string + \" |\"\n puts top_bottom, padding, line, padding, top_bottom\nend", "def print_in_box(text)\n length = text.size\n horizontal_border = \"+-\" + (\"-\" * length) + \"-+\"\n empty_border = \"| \" + (\" \" * length) + \" |\"\n content = \"| #{text} |\"\n \n puts horizontal_border\n puts empty_border\n puts content\n puts empty_border\n puts horizontal_border\nend", "def print_employee_graphics_box(box)\n\n # Horizontal lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n self.line_width = 0.01.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n self.line_width = 0.02.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.125.in\n stroke_line([x, y], [x + 1.25.in, y])\n y -= 0.125.in\n self.line_width = 0.01.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n\n # Vertical lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n stroke_line([x, y], [x, y - 4.75.in])\n stroke_line([x + 2.6.in, y], [x + 2.6.in, y - 0.25.in])\n stroke_line([x + 3.75.in, y], [x + 3.75.in, y - 4.75.in])\n self.line_width = 0.02.in\n y -= 0.25.in\n stroke_line([x, y], [x, y - 0.375.in])\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n stroke_line([x + 3.75.in, y], [x + 3.75.in, y - 0.25.in])\n y -= 0.25.in\n self.line_width = 0.01.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 0.125.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n y -= 0.125.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 2.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.5.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 1.25.in])\n y -= 0.5.in\n stroke_line([x + 1.in, y], [x + 1.in, y - 0.75.in])\n y -= 0.75.in\n stroke_line([x + 0.3.in, y], [x + 0.3.in, y - 0.25.in])\n stroke_line([x + 1.4.in, y], [x + 1.4.in, y - 0.375.in])\n stroke_line([x + 2.6.in, y], [x + 2.6.in, y - 0.375.in])\n y -= 0.375.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.375.in])\n\n # Text (top to bottom, left to right).\n x = box[:x]\n y = box[:y]\n self.vms_text_box(box[:title], x + 0.1, y, 2.4, 0.25, 7, :bold, :left, :center, nil, 'ff0000')\n self.vms_text_box(\"41-0852411\\nOMB No. 1545-0008\", x + 2.6, y, 1.15, 0.25, 6, :normal, :center, :center)\n y -= 0.25\n self.vms_text_box(\"<strong>a</strong> Employee's soc. sec. no.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>1</strong> Wages, tips, other comp.\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>2</strong> Federal income tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>3</strong> Social security wages\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>4</strong> Social security tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>b</strong> Employer ID number (EIN)\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>5</strong> Medicare wages and tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>6</strong> Medicare tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>c</strong> Employer's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>d</strong> Control number\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>e</strong> Employee's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"Suff.\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :right, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>7</strong> Social security tips\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>8</strong> Allocated tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>9</strong> Verification code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>10</strong> Dependent care benefits\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>11</strong> Nonqualified plans\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12a</strong> Code (See inst. for box 12)\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>13</strong> Statutory employee\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>14</strong> Other\", x + 1.05, y - 0.02, 1.4, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12b</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Retirement plan\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12c</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Third-party sick pay\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12d</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.5\n self.vms_text_box(\"<strong>15</strong> State Employer's ID Number\", x + 0.05, y - 0.02, 1.3, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>16</strong> State wages, tips, etc.\", x + 1.45, y - 0.02, 1.1, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>17</strong> State income tax\", x + 2.65, y - 0.02, 1.05, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>18</strong> Local wages, tips, etc.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>19</strong> Local income tax\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>20</strong> Locality name\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.375\n self.vms_text_box(\"2018\", x, y - 0.02, 3.75, 0.25, 8, :bold, :center, :top, nil, 'ff0000')\n self.vms_text_box(\"Form W-2 Wage and Tax Statement\", x, y - 0.04, 3.75, 0.125, 6, :bold, :left, :top, nil, 'ff0000')\n self.vms_text_box(\"Dept. of the Treasury -- IRS\", x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n y -= box[:bottom_left_offset]\n self.vms_text_box(box[:bottom_left], x, y - 0.04, 3.75, box[:bottom_left_height], 6, :normal, :left, :top)\n y -= box[:bottom_right_offset]\n self.vms_text_box(box[:bottom_right], x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n\n end", "def print_in_box(text)\n top_bottom_border = \"+\" + (\"-\" * (text.size + 2)) + \"+\"\n spacer_line = \"|\" + (\" \" * (text.size + 2)) + \"|\"\n message_line = \"| \" + text + \" |\"\n\n puts top_bottom_border\n puts spacer_line\n puts message_line\n puts spacer_line\n puts top_bottom_border\nend", "def draw_entry_array(x, y, w, array)\n draw_icon(array[0].to_i, x, y + (line_height - 24) / 2)\n change_color(text_color(MARW_CONFIGURATION[:colour_name]))\n tw_r = array[2] ? text_size(array[2].to_s).width + 4 : 0\n draw_text(x + 24, y, w - 24 - tw_r, line_height, array[1].to_s)\n change_color(text_color(MARW_CONFIGURATION[:colour_amount]))\n draw_text(x + 24, y, w - 24, line_height, array[2].to_s, 2) if array[2]\n end", "def add_line_breaks(arr)\n arr.map {|element| element[0..-1] + [\"\\n\"]}\nend", "def lines\n lines = [{line: '', width: 0.0}]\n current_line = lines.last\n\n tokens.each do |token|\n width = string_width(token)\n\n if (current_line[:width] > 0) && ((current_line[:width] + width) > @max_width.to_f)\n lines << {line: '', width: 0.0}\n current_line = lines.last\n end\n\n current_line[:line] = current_line[:line] + token\n current_line[:width] = current_line[:width] + width\n end\n\n lines\n end", "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,24,rect.height)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[2] = Rect.new(rect.x,rect.y,64,rect.height)\n rects[3] = Rect.new(rect.x,rect.y,24,rect.height)\n rects[4] = Rect.new(rect.x,rect.y,32,rect.height)\n \n # Rects Adjustments\n \n # ucIcon\n # Nothing to do\n \n # cItemName\n rects[1].x += rects[0].width\n rects[1].width = rect.width - rects[0].width - rects[2].width - rects[3].width - rects[4].width - (spacing*3)\n \n # cItemPrice\n rects[2].x += rect.width - rects[2].width - rects[3].width - rects[4].width - (spacing*2)\n \n # cItemPossess \n rects[3].x += rect.width - rects[3].width - rects[4].width - spacing\n \n # ucItemNumber\n rects[4].x += rect.width - rects[4].width\n \n return rects\n end", "def printStrings strArr, maxLength\n strArr.each_with_index do |str, i|\n # center strings, add spaces on left to add shifting effect\n puts ' ' * i * 2 + str.center(maxLength)\n end\nend", "def print_in_box(str)\n str_length = str.length\n puts first_horizontal_line = \"+ #{\"-\" * str_length} +\"\n puts second_horizontal_line = \"| #{\" \" * str_length} |\"\n puts third_horizontal_line = \"| #{str} |\"\n puts fourth_horizontal_line = \"| #{\" \" * str_length} |\"\n puts fifth_horizontal_line = \"+ #{\"-\" * str_length} +\"\nend", "def how_to_render_borders args\n # Render a square at 0, 0 with a width and height of 3\n args.nokia.borders << { x: 0, y: 0, w: 3, h: 3, a: 255 }\n\n # Render a square at 3, 3 with a width and height of 3\n args.nokia.borders << { x: 3, y: 3, w: 4, h: 4, a: 255 }\n\n # Render a square at 5, 5 with a width and height of 4\n args.nokia.borders << { x: 7, y: 7, w: 5, h: 5, a: 255 }\nend", "def numbered_lines_section_around(filename, center_line_number, padding = 1)\n lines_range = range_around(center_line_number, padding)\n max_digits = max_digits_in(lines_range)\n\n all_lines = File.open(filename).readlines # TODO : optimize (don't read lines after the range limit)\n\n filename_line = \"| File : #{filename}\"\n hr = '+' + '-'*filename_line.length\n\n [].tap do |formatted_lines|\n formatted_lines << hr\n formatted_lines << filename_line\n formatted_lines << hr\n formatted_lines << lines_range.collect { |nbr|\n raw_line = all_lines[nbr-1].chomp\n numbered_line = \"| line %#{max_digits}s : %s\" % [nbr, raw_line]\n (center_line_number==nbr) ?\n colour_current_line(numbered_line) :\n numbered_line\n }\n formatted_lines << hr\n end\n end", "def pad(text, padding, fill: SPACE, separator: nil)\n padding = Strings::Padder.parse(padding)\n text_copy = text.dup\n sep = separator || text[LINE_BREAK] || NEWLINE\n line_width = max_line_length(text, sep)\n output = []\n\n filler_line = fill * line_width\n\n padding.top.times do\n output << pad_around(filler_line, padding, fill: fill)\n end\n\n text_copy.split(sep).each do |line|\n line = line.empty? ? filler_line : line\n output << pad_around(line, padding, fill: fill)\n end\n\n padding.bottom.times do\n output << pad_around(filler_line, padding, fill: fill)\n end\n\n output.join(sep)\n end", "def pad_around(text, padding, fill: SPACE)\n fill * padding.left + text + fill * padding.right\n end", "def format ary\n #buff = Array.new\n buff = Array.new(ary.size)\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 # ix refers to the index in the complete file list, wherease we only show 60 at a time\n ix=0\n ctr=0\n pad = false\n pad = true if ary.size > 25\n ary.each do |f|\n ## ctr refers to the index in the column\n ind = get_shortcut(ix)\n ind = ind.ljust(2) if pad\n mark=SPACE\n cur=SPACE\n cur = CURMARK if ix + $sta == $cursor\n #mark=GMARK if $selected_files.index(ary[ix])\n # we are not doing selection here\n # but maybe today's articles can be starred\n age_in_hours = article_age_in_hours(f) \n mark=DOTMARK if age_in_hours < 24\n mark=GMARK if age_in_hours < 8\n\n if $long_listing\n begin\n f = get_long_list f\n rescue Exception => e\n #f = \"%10s %s %s\" % [\"?\", \"??????????\", f]\n end\n end\n\n s = \"#{ind}#{mark}#{cur}#{f}\"\n # I cannot color the current line since format does the chopping\n # so not only does the next lines alignment get skeweed, but also if the line is truncated\n # then the color overflows.\n #if ix + $sta == $cursor\n #s = \"#{RED}#{s}#{CLEAR}\"\n #end\n\n buff[ctr] = s\n\n ctr+=1\n ix+=1\n end\n return buff\nend", "def p( colsizes, align = nil, padding = 3 )\n\t\t\t\tprint \"#{@color}\"\n\t\t\t\tidx = 0\n\t\t\t\t@cols.each do |item|\n\t\t\t\t\tif align and align[idx] == \"r\"\n\t\t\t\t\t\tprint \" \" * ( colsizes[ idx ] - item.to_s.length_utf8 )\n\t\t\t\t\tend\n\t\t\t\t\tprint item\n\t\t\t\t\tif align==nil or (align and align[idx] == \"l\")\n\t\t\t\t\t\tprint \" \" * ( colsizes[ idx ] - item.to_s.length_utf8 )\n\t\t\t\t\tend\n\t\t\t\t\tprint \" \"*padding if idx < colsizes.length - 1\n\t\t\t\t\tidx += 1\n\t\t\t\tend\n\t\t\t\tputs \"\\033[0m\"\n\t\t\tend", "def build_spans on_range\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end", "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,24,rect.height)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[2] = Rect.new(rect.x,rect.y,32,rect.height)\n \n # Rects Adjustments\n \n # ucIcon\n # Nothing to do\n \n # cItemName\n rects[1].x += rects[0].width\n rects[1].width = rect.width - rects[0].width - rects[2].width - spacing\n \n # cItemNumber\n rects[2].x += rect.width - rects[2].width\n \n return rects\n end", "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,24,rect.height)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[2] = Rect.new(rect.x,rect.y,32,rect.height)\n \n # Rects Adjustments\n \n # ucIcon\n # Nothing to do\n \n # cItemName\n rects[1].x += rects[0].width\n rects[1].width = rect.width - rects[0].width - rects[2].width - spacing\n \n # cItemNumber\n rects[2].x += rect.width - rects[2].width\n \n return rects\n end", "def print_in_box(str)\n border = '+' + ('-' * (str.size + 2)) + '+'\n padding = '|' + (' ' * (str.size + 2)) + '|'\n text = '| ' + str + ' |'\n puts border, padding, text, padding, border\nend", "def border(column_widths, location)\n result = []\n result << @symbols[:\"#{location}_left\"]\n column_widths.each.with_index do |width, i|\n result << @symbols[:\"#{location}_center\"] if i != 0\n result << (@symbols[:line] * (width + 2))\n end\n result << @symbols[:\"#{location}_right\"]\n @pastel.decorate(result.join, *@theme[:table])\n end", "def make_outline_row(width, stars)\n if stars == 1\n \"*\".center(width)\n else\n (\"*\" + (\" \" * (stars - 2)) + \"*\").center(width)\n end\nend", "def tabbed_text(text, spaces = 0)\n Array(text).join(\"\\n\").gsub(\"\\n\", \"\\n#{' ' * (4 + spaces.to_i)}\").strip\n end", "def determine_rects(rect, spacing, right_pad)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,96,96)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,24)\n rects[2] = [Rect.new(rect.x,rect.y,rect.width,18),\n Rect.new(rect.x,rect.y,18,18)]\n rects[3] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[4] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[5] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[6] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n \n gauge_value_width = rect.width - right_pad\n gauge_y = 16\n \n # Rects Adjustments\n \n # ucCharFace\n rects[0].x += ((rect.width - rects[0].width) / 2).floor\n rects[0].y += spacing*2\n \n # cCharName\n # Nothing to do\n \n # ucCharLvl\n rects[2][0].y += spacing\n rects[2][0].width -= rects[2][1].width\n rects[2][1].x += (rects[2][0].width / 2).floor + rects[2][1].width\n rects[2][1].y = rects[2][0].y\n \n # ucHpStat \n rects[3][0].y += rect.height - spacing*4\n rects[3][1].x += rects[3][0].width\n rects[3][1].y = rects[3][0].y\n rects[3][2].y = rects[3][0].y + spacing\n rects[3][2].width = gauge_value_width\n \n # cHpStatGauge\n rects[4].y = rects[3][0].y+gauge_y\n rects[4].height = rects[3][0].height-gauge_y\n\n # ucMpStat\n rects[5][0].y += rect.height - spacing*2\n rects[5][1].x += rects[5][0].width\n rects[5][1].y = rects[5][0].y\n rects[5][2].y = rects[5][0].y + spacing\n rects[5][2].width = gauge_value_width\n \n # cMpStatGauge\n rects[6].y = rects[5][0].y+gauge_y\n rects[6].height = rects[5][0].height-gauge_y\n \n return rects\n end", "def determine_rects(rect, spacing, right_pad)\n rects = []\n \n # Rects Initialization\n rects[0] = Rect.new(rect.x,rect.y,96,96)\n rects[1] = Rect.new(rect.x,rect.y,rect.width,24)\n rects[2] = [Rect.new(rect.x,rect.y,rect.width,18),\n Rect.new(rect.x,rect.y,18,18)]\n rects[3] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[4] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n rects[5] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,25,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[6] = Rect.new(rect.x,rect.y,rect.width,rect.height)\n \n gauge_value_width = rect.width - right_pad\n gauge_y = 16\n \n # Rects Adjustments\n \n # ucCharFace\n rects[0].x += ((rect.width - rects[0].width) / 2).floor\n rects[0].y += spacing*2\n \n # cCharName\n # Nothing to do\n \n # ucCharLvl\n rects[2][0].y += spacing\n rects[2][0].width -= rects[2][1].width\n rects[2][1].x += (rects[2][0].width / 2).floor + rects[2][1].width\n rects[2][1].y = rects[2][0].y\n \n # ucHpStat \n rects[3][0].y += rect.height - spacing*4\n rects[3][1].x += rects[3][0].width\n rects[3][1].y = rects[3][0].y\n rects[3][2].y = rects[3][0].y + spacing\n rects[3][2].width = gauge_value_width\n \n # cHpStatGauge\n rects[4].y = rects[3][0].y+gauge_y\n rects[4].height = rects[3][0].height-gauge_y\n\n # ucMpStat\n rects[5][0].y += rect.height - spacing*2\n rects[5][1].x += rects[5][0].width\n rects[5][1].y = rects[5][0].y\n rects[5][2].y = rects[5][0].y + spacing\n rects[5][2].width = gauge_value_width\n \n # cMpStatGauge\n rects[6].y = rects[5][0].y+gauge_y\n rects[6].height = rects[5][0].height-gauge_y\n \n return rects\n end", "def topToBottomWraparound(grid, width, height)\n\n strings = topToBottom(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend", "def print_in_box (string)\n a = \"+-#{string.chars.fill(\"-\").join}-+\"\n b = \"| #{string.chars.fill(\" \").join} |\"\n c = \"| #{string} |\"\n\n box = [a, b, c, b, a]\n box.each {|x| puts x}\nend", "def make_line(text_array, len)\n start = rand(text_array.length)\n val = start\n line = \"\"\n while true\n val = val + 1\n line = \"#{line} #{text_array[val]}\"\n if line.to_phrase.syllables == len\n line.gsub!('\"','')\n return line\n end\n if line.to_phrase.syllables > len\n line = \"\"\n start = start + 1\n val = start\n end\n end\n end", "def padded(padding = 2, &block)\n r = bounds\n padding ||= 2\n bounding_box([padding, r.top - padding], width: r.width - (2 * padding), &block)\n end", "def make_rectangle sentence\n arr = sentence.split\n max_length = arr.max_by(&:length).length\n\n puts \"*\" * (max_length + 4)\n arr.each do |word|\n diff = max_length - word.length\n print \"* \"\n print word\n print \" \" * diff\n puts \" *\"\n end\n puts \"*\" * (max_length + 4)\nend", "def print_employer_graphics_box(box)\n\n # Horizontal lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n self.line_width = 0.01.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.125.in\n stroke_line([x, y], [x + 1.25.in, y])\n y -= 0.125.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n\n # Vertical lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n stroke_line([x, y], [x, y - 4.75.in])\n stroke_line([x + 2.1.in, y], [x + 2.1.in, y - 0.25.in])\n stroke_line([x + 2.7.in, y], [x + 2.7.in, y - 0.25.in])\n stroke_line([x + 3.75.in, y], [x + 3.75.in, y - 4.75.in])\n y -= 0.25.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 0.25.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 0.125.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n y -= 0.125.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 2.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.5.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 1.25.in])\n y -= 0.5.in\n stroke_line([x + 1.in, y], [x + 1.in, y - 0.75.in])\n y -= 0.75.in\n stroke_line([x + 0.3.in, y], [x + 0.3.in, y - 0.25.in])\n stroke_line([x + 1.4.in, y], [x + 1.4.in, y - 0.375.in])\n stroke_line([x + 2.6.in, y], [x + 2.6.in, y - 0.375.in])\n y -= 0.375.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.375.in])\n\n # Text (top to bottom, left to right).\n x = box[:x]\n y = box[:y]\n self.vms_text_box(\"Employers State, Local, or File Copy\", x + 0.1, y, 1.9, 0.25, 7, :bold, :left, :center)\n self.vms_text_box(\"22222\", x + 2.1, y + 0.015, 0.6, 0.25, 10, :normal, :center, :center, 'SF Mono')\n self.vms_text_box(\"2018\", x + 2.7, y, 0.5, 0.25, 12, :bold, :center, :center, 'Whitney Bold')\n self.vms_text_box(\"OMB No.\\n1545-0008\", x + 3.2, y, 0.55, 0.25, 6, :normal, :center, :center)\n y -= 0.25\n self.vms_text_box(\"<strong>a</strong> Employee's soc. sec. no.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>1</strong> Wages, tips, other comp.\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>2</strong> Federal income tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>3</strong> Social security wages\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>4</strong> Social security tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>b</strong> Employer ID number (EIN)\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>5</strong> Medicare wages and tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>6</strong> Medicare tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>c</strong> Employer's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>d</strong> Control number\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>e</strong> Employee's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"Suff.\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :right, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>7</strong> Social security tips\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>8</strong> Allocated tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>9</strong> Verification code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>10</strong> Dependent care benefits\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>11</strong> Nonqualified plans\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12a</strong> Code (See inst. for box 12)\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>13</strong> Statutory employee\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>14</strong> Other\", x + 1.05, y - 0.02, 1.4, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12b</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Retirement plan\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12c</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Third-party sick pay\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12d</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.5\n self.vms_text_box(\"<strong>15</strong> State Employer's ID Number\", x + 0.05, y - 0.02, 1.3, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>16</strong> State wages, tips, etc.\", x + 1.45, y - 0.02, 1.1, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>17</strong> State income tax\", x + 2.65, y - 0.02, 1.05, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>18</strong> Local wages, tips, etc.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>19</strong> Local income tax\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>20</strong> Locality name\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.375\n self.vms_text_box(\"Form W-2 Wage and Tax Statement\\nFor Privacy Act and Paperwork Reduction\\nAct Notice, see separate instructions.\", x, y - 0.04, 3.75, 0.375, 6, :bold, :left, :top)\n self.vms_text_box(\"Dept. of the Treasury -- IRS\", x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n y -= box[:bottom_right_offset]\n self.vms_text_box(box[:bottom_right], x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n\n end", "def print_separator_line\nline = \"\"\n3.times do\n3.times { line << SEPARATOR[:horizontal] }\nline << SEPARATOR[:cross]\nend\nputs line[0...line.length - 1]\nprint \"\\t\"\nend", "def line_stroke(left_border, junc_border, right_border, &block)\n stroke = ''\n stroke += left_border if settings.border.left?\n dimensions.num_cols.times do |col_num|\n stroke += junc_border if col_num > 0 && settings.border.inner_vert?\n stroke += yield\n end\n stroke += right_border if settings.border.right?\n stroke\n end", "def boxes\n box_lines.map {|l| parse_line l.match(PARSE_BOX) }.to_set\n end", "def print_row(grid_size, distance_from_center)\n number_of_spaces = distance_from_center - 1\n spaces = ' ' * number_of_spaces\n output = Array.new(3, '*').join(spaces)\n puts output.center(grid_size)\nend", "def print_row(grid_size, distance_from_center)\n number_of_spaces = distance_from_center - 1\n spaces = ' ' * number_of_spaces\n output = Array.new(3, '*').join(spaces)\n puts output.center(grid_size)\nend", "def bullet_lines(line, spaces)\n line.split(\".\\n\").map { |paragraph| bullet_line(paragraph, spaces) }\n end", "def display_board(board_array)\n row_sep = \"-----------\"\n row_1 = \" #{board_array[0]} | #{board_array[1]} | #{board_array[2]} \"\n row_2 = \" #{board_array[3]} | #{board_array[4]} | #{board_array[5]} \"\n row_3 = \" #{board_array[6]} | #{board_array[7]} | #{board_array[8]} \"\n puts row_1\n puts row_sep\n puts row_2\n puts row_sep\n puts row_3\nend", "def draw_sample\n \t\" #{@sample[:space_1]} | #{@sample[:space_2]} | #{@sample[:space_3]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_4]} | #{@sample[:space_5]} | #{@sample[:space_6]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_7]} | #{@sample[:space_8]} | #{@sample[:space_9]}\\n\" +\n \t\t\t\t\t\t \" | | \\n\\n\"\n\n end", "def draw\n lines = []\n\n indent = @height - 1\n draw_braches(lines, indent)\n\n lines\n end", "def create_grid\n grid = Array.new(8) { Array.new(8) { [] } }\n grid.map! do |row|\n if grid.index(row).even?\n row.each { |space| row.index(space).even? ? space << 'white' : space << 'black' }\n else\n row.each { |space| row.index(space).even? ? space << 'black' : space << 'white' }\n end\n row.map! do |space|\n space << [grid.index(row), row.index(space)]\n end\n end\n grid.reverse\n end", "def fold(width, number = nil, breaker = nil)\n theCopy = TextRect.new(@theLines)\n theCopy.fold!(width, number, breaker)\n end", "def label_list(x, y, strings, min_h: 20, se: 0, ae: 0, r: 255, g: 255, b: 255, a: 255)\n return strings.take_while.with_index { |_, i| y - 20*i > min_h }.map_with_index do |str, i|\n str = y - 20*i > min_h + 20 ? str : '[...]'\n { x: x,\n y: y - 20*i,\n text: str,\n size_enum: se,\n alignment_enum: ae,\n r: r,\n g: g,\n b: b,\n a: a }.label\n end\nend", "def alignContinuations(theLines)\n\n\tsplitAndAlign(theLines, /^(.*?)\\s+(\\\\)$/, \"\");\n\nend", "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,50,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[1] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n \n value_width = ((rect.width - rects[0][0].width - rects[0][1].width - rects[1][0].width - spacing)/2).floor\n \n # Rects Adjustments\n \n # ucStat\n rects[0][1].x += rects[0][0].width\n rects[0][2].x = rects[0][1].x + rects[0][1].width\n rects[0][2].width = value_width\n \n # ucCompareStat\n rects[1][0].x = rects[0][2].x + rects[0][2].width + spacing\n rects[1][1].x = rects[1][0].x + rects[1][0].width\n rects[1][1].width = value_width\n \n return rects\n end", "def wrap(text, length, indent=0, padding=0)\n if text.length > length - indent\n paragraphs = []\n line = ''\n text.split(/\\s+/).map(&:chomp).reject(&:empty?).each do |fragment|\n if line.length < length - indent\n line << fragment + ' '\n else\n paragraphs << line\n line = padding + fragment + ' '\n end\n end\n paragraphs << line\n text = paragraphs.join(\"\\n\")\n end\n text\n end", "def kill_cells_in_borders\n (0..@long - 1).each do |long|\n (0..@width - 1).each do |width|\n @matriz[long][width] = ' . ' if long.zero? || (long == @long - 1) || width.zero? || (width == @width - 1)\n end\n end\n end", "def draw_string_array(instructions, start_x, start_y, max_width)\n draw_string_y = start_y\n string_height = 20\n instructions_font = Gosu::Font.new(string_height)\n instructions.each do |instruction|\n wrapped_instruction = wrap_string(instruction, instructions_font, max_width)\n instructions_font.draw_text(wrapped_instruction[0],\n start_x,\n draw_string_y,\n 1)\n draw_string_y += string_height * (wrapped_instruction[1] + 1)\n end\nend", "def print_in_box(text)\n text = text[0, MAX_SIZE]\n pad1 = ''.center(text.size, '-')\n pad2 = ''.center(text.size, ' ')\n\n puts(\"+-#{pad1}-+\n| #{pad2} |\n| #{text} |\n| #{pad2} |\n+-#{pad1}-+\")\nend", "def horizontalSpacer(n , text)\n n.times {print \" \"}\n puts text\nend", "def array_newlines(array_input)\n n0 = array_input[0]\n n1 = array_input[1]\n n2 = array_input[2]\n n3 = array_input[3]\n \n m0 = [n0, 1].min\n m1 = [n1, 2].min\n m2 = [n2, 2].min\n m3 = [n3, 2].min\n return [m0, m1, m2, m3]\n end", "def win_lines\n\t\t(\n\t\t\t(0..@size.pred).each_slice(@dim).to_a +\n\t\t\t(0..@size.pred).each_slice(@dim).to_a.transpose +\n\t\t\t[ (0..@size.pred).step(@dim.succ).to_a ] +\n\t\t\t[ (@dim.pred..(@size-@dim)).step(@dim.pred).to_a ]\n\t\t).map { |line| line.map { |idx| @board[idx] }}\n\tend", "def surround(word, pad_width=word.length/2)\n \"[\" * pad_width + word + \"]\" * pad_width\nend", "def build_board(choices)\n line = []\n board = []\n 0.upto(choices.length) do |i|\n line << fig(choices[i], i + 1)\n if ((i + 1) % 3).zero?\n board << line\n line = []\n end\n end\n board\n end" ]
[ "0.6492443", "0.6049305", "0.6040567", "0.60036755", "0.59825855", "0.5976544", "0.58638805", "0.5800494", "0.57781017", "0.5757104", "0.5705841", "0.5682537", "0.5593508", "0.5583972", "0.5553343", "0.551409", "0.54761165", "0.54586524", "0.54494214", "0.54325145", "0.5430626", "0.5407989", "0.53936636", "0.5389952", "0.5374082", "0.53694916", "0.5347461", "0.53464454", "0.5342545", "0.53239423", "0.53182", "0.5313708", "0.5313708", "0.531185", "0.53116345", "0.5310861", "0.53059363", "0.5300332", "0.52969426", "0.5286689", "0.52781767", "0.52759874", "0.52677613", "0.52626973", "0.5258433", "0.5255977", "0.525303", "0.5249001", "0.5245366", "0.52428925", "0.5232196", "0.5226575", "0.5221261", "0.5213672", "0.52099717", "0.52077913", "0.5200653", "0.5194689", "0.5192778", "0.51876384", "0.51858133", "0.5184898", "0.518486", "0.5179874", "0.5179874", "0.51785284", "0.5175996", "0.516857", "0.51601624", "0.515243", "0.515243", "0.5152169", "0.51471657", "0.5146566", "0.51388216", "0.5135548", "0.51347077", "0.5123337", "0.512276", "0.51109856", "0.5107536", "0.5107536", "0.5106106", "0.50922084", "0.5080491", "0.50769687", "0.5076613", "0.5072618", "0.5071203", "0.50676715", "0.50630057", "0.5058797", "0.50569373", "0.5055099", "0.504185", "0.50370526", "0.5031843", "0.5029454", "0.50244826", "0.50239" ]
0.7717645
0
Define the installation steps
def install # Define GOPATH ENV["GOPATH"] = buildpath/"go" ENV["GOBIN"] = buildpath/"go/bin" # Create the required directory structure (buildpath/"go/bin").mkpath (buildpath/"go/pkg").mkpath (buildpath/"go/src").mkpath (buildpath/"go/src/github.com/Dids/clobber").mkpath # Copy everything to the Go project directory (except the go/ folder) system "rsync -a ./ go/src/github.com/Dids/clobber/" # Switch to the Go project directory Dir.chdir 'go/src/github.com/Dids/clobber' do ohai "Switched to directory: #{Dir.pwd}" # Print out target version ohai "Building version #{version}.." # Build the application system "make", "deps" system "make", "build", "BINARY_VERSION=#{version}", "BINARY_OUTPUT=#{buildpath}/clobber" system "make", "test" # Print the version system buildpath/"clobber", "--version" # Install the application bin.install buildpath/"clobber" # Test that the version matches if "clobber version #{version}" != `#{bin}/clobber --version`.strip odie "Output of 'clobber --version' did not match the current version (#{version})." end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install\n end", "def install\n end", "def prepare_for_installation; end", "def install\n end", "def install\n end", "def install\n \n end", "def post_install; end", "def post_install\n end", "def install_sequence\n commands = pre_commands(:install) + [ install_commands ] + post_commands(:install)\n flatten commands\n end", "def execute_installation\n #start logging\n set_log_file @options[:log]\n \n download_and_decompress(@options[:prefix], [REDIS_URL, SQLITE3_URL, NGINX_URL])\n \n install_redis if @options[:redis]\n install_sqlite\n configure_nginx @options\n\n install_all_gems\n install_rhoconnect\n \n #remove downloaded tarballs\n cleanup options[:prefix]\n end", "def pre_install; end", "def install(env); end", "def install_instructions\n []\n end", "def install_sequence\n stop\n \n backup_database\n install_pre_hook\n pre_migrate_database\n copy_files\n freeze_rails\n create_default_config_files\n fix_permissions\n create_directories\n create_initial_database\n set_initial_port_number\n expand_template_files\n \n migrate\n install_post_hook\n save\n \n run_rails_tests\n \n start\n end", "def install\n # nothing to do\n end", "def install\n invoke \"totem:lodestar:install:javascripts\"\n invoke \"totem:lodestar:install:stylesheets\"\n invoke \"totem:lodestar:install:images\"\n invoke \"totem:lodestar:install:configs\", [file_name]\n invoke \"totem:lodestar:install:databases\", [file_name]\n invoke \"totem:lodestar:install:routes\"\n invoke \"totem:lodestar:install:documents\"\n invoke \"totem:lodestar:install:travis_ci\", [file_name]\n invoke \"totem:lodestar:install:views\", [file_name]\n end", "def install\n #python executable files\n end", "def install args = []\n\t\t\tputs \"Starting to install ...\"\n\n\t\t\t# step 1, run migration files\n\t\t\tdb args\n\n\t\t\t# step 2, run the gemfile\n\t\t\tbundle args\n\n\t\t\t# step 3, submit the data to database\n\t\t\tsubmit args\n\n\t\t\tputs \"Successfully installed\"\n\t\tend", "def install\n raise \"Not implemented yet!\"\n end", "def install\n install_init\n install_plan\n install_apply\n install_refresh\n install_destroy\n install_write_tf_vars\n install_output\n end", "def install\n bin.install \"alb2psql\" => \"alb2psql\"\n # include.install \"utils.bash\"\n\n # bash_completion.install \"completion/kubectx.bash\" => \"kubectx\"\n # bash_completion.install \"completion/kubens.bash\" => \"kubens\"\n # zsh_completion.install \"completion/kubectx.zsh\" => \"_kubectx\"\n # zsh_completion.install \"completion/kubens.zsh\" => \"_kubens\"\n end", "def install\n copy_envrc\n copy_database_yml\n copy_docker_db_setup_sh\n system(`direnv allow`)\n print(\"#{readme}\\n\")\n end", "def install\n nil\n end", "def install\n cd_and_sh( pkg_dir, install_commands )\n end", "def install(&_block)\n pre_install\n instructions.each { |e| yield e }\n end", "def install_commands\n raise 'Concrete installers implement this to specify commands to run to install their respective packages'\n end", "def action_install\n run_package_action(:install)\n end", "def run_install(install_path)\n require 'fileutils'\n install_path ||= '.'\n FileUtils.mkdir_p install_path unless File.exists?(install_path)\n install_file \"#{CC_ROOT}/config/config.example.yml\", \"#{install_path}/config.yml\"\n install_file \"#{CC_ROOT}/config/config.example.ru\", \"#{install_path}/config.ru\"\n install_file \"#{CC_ROOT}/config/database.example.yml\", \"#{install_path}/database.yml\"\n install_file \"#{CC_ROOT}/actions\", \"#{install_path}/actions\", true\n end", "def install\n run \"bundle exec backup generate:config --config-path=config/backup\" unless File.exists?(\"config/backup/config.rb\")\n template \"general.rb\", \"config/backup/models/general.rb\"\n if File.exists? \".env\"\n append_file \".env\" do\n File.read(File.expand_path(find_in_source_paths('env.env')))\n end\n else\n template \"env.env\", \".env\"\n end\n run \"bundle exec wheneverize .\" unless File.exists?(\"config/schedule.rb\")\n append_file \"config/schedule.rb\" do\n File.read(File.expand_path(find_in_source_paths('schedule.rb')))\n end\n end", "def install\n each { |m| m.install }\n end", "def steps\n %i[upload setup order]\n end", "def install\n result = @dependency_manager.install_dependencies\n if @dependency_manager.should_install?('libvirt')\n result = result.and_then { install_vagrant_plugins }\n .and_then { create_libvirt_pool }\n .and_then { export_libvirt_default_uri }\n end\n if @dependency_manager.should_install?('terraform')\n result = result.and_then { install_terraform }\n end\n if result.error?\n @ui.error(result.error)\n else\n @ui.info('Dependencies successfully installed.')\n @ui.info('Please restart your computer in order to apply changes.')\n end\n result\n end", "def perform_install!\n warning \"If you are planning to use #{y('Ruby')} and #{y('Passenger')} then #{r(\"DON'T\")} use this NginX installer.\"\n warning \"Instead, use the Passenger module to install it.\"\n standard \"\\n\\s\\s#{y(\"heavenly passenger install to #{y(e.name)}\")}\\n\\n\"\n \n message \"If you do not plan on using #{y('Ruby')} on this server, then this stand-alone installation should be fine.\"\n message \"Do you want to continue?\"\n exit unless yes?\n \n prompt_for_root_password!\n \n Spinner.return :message => \"Installing NginX web server..\" do\n e.install!('nginx')\n g('Done!')\n end\n message \"NginX has been installed in #{y('/etc/nginx')}.\"\n GitPusshuTen::Initializer.new('nginx', 'setup', 'for', \"#{e.name}\")\n end", "def prerequisites\n\tKitchenplan::Application.fatal! \"Don't run this as root!\" if running_as_superuser?\n\tKitchenplan::Log.warn \"Platform version too low. Your version: #{self.version}\" unless version_supported?\n\tinstall_bundler\n\t# needed for proper librarian usage\n\tinstall_git\n\tkitchenplan_bundle_install\n end", "def prepare_installation\n InstallOptions.configs = true\n InstallOptions.batch_files = true\n\n ARGV.options do |opts|\n opts.banner = \"Usage: #{File.basename($PROGRAM_NAME)} [options]\"\n opts.separator ''\n opts.on('--[no-]configs', 'Prevents the installation of config files', 'Default off.') do |onconfigs|\n InstallOptions.configs = onconfigs\n end\n opts.on('--destdir[=OPTIONAL]',\n 'Installation prefix for all targets',\n 'Default essentially /') do |destdir|\n InstallOptions.destdir = destdir\n end\n # opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc') do |configdir|\n # InstallOptions.configdir = configdir\n # end\n opts.on('--bindir[=OPTIONAL]',\n 'Installation directory for binaries',\n 'overrides RbConfig::CONFIG[\"bindir\"]') do |bindir|\n InstallOptions.bindir = bindir\n end\n opts.on('--ruby[=OPTIONAL]',\n 'Ruby interpreter to use with installation',\n 'overrides ruby used to call install.rb') do |ruby|\n InstallOptions.ruby = ruby\n end\n opts.on('--sitelibdir[=OPTIONAL]',\n 'Installation directory for libraries',\n 'overrides RbConfig::CONFIG[\"sitelibdir\"]') do |sitelibdir|\n InstallOptions.sitelibdir = sitelibdir\n end\n opts.on('--mandir[=OPTIONAL]',\n 'Installation directory for man pages',\n 'overrides RbConfig::CONFIG[\"mandir\"]') do |mandir|\n InstallOptions.mandir = mandir\n end\n opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |_full|\n InstallOptions.configs = true\n end\n opts.on('--no-batch-files', 'Prevents installation of batch files for windows', 'Default off') do |_batch_files|\n InstallOptions.batch_files = false\n end\n opts.separator('')\n opts.on_tail('--help', 'Shows this help text.') do\n warn opts\n exit\n end\n\n opts.parse!\n end\n\n version = [RbConfig::CONFIG['MAJOR'], RbConfig::CONFIG['MINOR']].join('.')\n libdir = File.join(RbConfig::CONFIG['libdir'], 'ruby', version)\n\n # Mac OS X 10.5 and higher declare bindir\n # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin\n # which is not generally where people expect executables to be installed\n # These settings are appropriate defaults for all OS X versions.\n RbConfig::CONFIG['bindir'] = '/usr/bin' if RUBY_PLATFORM =~ /^universal-darwin[\\d\\.]+$/\n\n # if InstallOptions.configdir\n # configdir = InstallOptions.configdir\n # elsif windows?\n # path = File.join(File.dirname(__FILE__), \"lib\", \"custom_facts\", \"util\", \"config.rb\")\n # require_relative(path)\n\n # configdir = File.join(LegacyFacter::Util::Config.windows_data_dir, \"PuppetLabs\", \"facter\", \"etc\")\n # else\n # configdir = File.join('/', 'etc', 'puppetlabs', 'facter')\n # end\n\n bindir = InstallOptions.bindir || RbConfig::CONFIG['bindir']\n\n if InstallOptions.sitelibdir\n sitelibdir = InstallOptions.sitelibdir\n else\n sitelibdir = RbConfig::CONFIG['sitelibdir']\n if sitelibdir.nil?\n sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }\n if sitelibdir.nil?\n sitelibdir = File.join(libdir, 'site_ruby')\n elsif sitelibdir !~ Regexp.quote(version)\n sitelibdir = File.join(sitelibdir, version)\n end\n end\n end\n\n mandir = InstallOptions.mandir || RbConfig::CONFIG['mandir']\n\n # This is the new way forward\n destdir = InstallOptions.destdir || ''\n\n # configdir = join(destdir, configdir)\n bindir = join(destdir, bindir)\n mandir = join(destdir, mandir)\n sitelibdir = join(destdir, sitelibdir)\n\n # makedirs(configdir) if InstallOptions.configs\n makedirs(bindir)\n makedirs(mandir)\n makedirs(sitelibdir)\n\n InstallOptions.site_dir = sitelibdir\n # InstallOptions.config_dir = configdir\n InstallOptions.bin_dir = bindir\n InstallOptions.lib_dir = libdir\n InstallOptions.man_dir = mandir\n end", "def install\n\t\tbin.install \"cpu-sentinel\"\n\t\tconfigdir.install \"procs.conf\"\n\tend", "def prerequisites\n\tKitchenplan::Application.fatal! \"Don't run this as root!\" unless running_as_normaluser?\n\tKitchenplan::Application.fatal! \"#{ENV['USER']} needs to be part of the 'admin' group!\" unless user_is_admin?\n\tKitchenplan::Application.fatal! \"Platform version too low. Your version: #{self.version}\" unless version_supported?\n\tinstall_bundler\n\t# needed for proper librarian usage\n\tinstall_git\n\tkitchenplan_bundle_install\n end", "def prerequisites\n\tKitchenplan::Application.fatal! \"Don't run this as root!\" unless running_as_normaluser?\n\tKitchenplan::Application.fatal! \"#{ENV['USER']} needs to be part of the 'admin' group!\" unless user_is_admin?\n\tKitchenplan::Application.fatal! \"Platform version too low. Your version: #{self.version}\" unless version_supported?\n\tinstall_bundler\n\t# needed for proper librarian usage\n\tinstall_git\n\tkitchenplan_bundle_install\n end", "def install\n raise NotImplementedError\n end", "def install\n raise NotImplementedError\n end", "def install\n AdminModule.configuration.credentials.keys.each do |e|\n valid_actions.each do |action|\n AdminModule::Rake::PpmTasks.new(\"am:#{e}:ppm:#{action}\", \"#{action} #{e} ppms\") do |t|\n t.env = e\n t.action = action\n end\n end\n end\n end", "def install_management\n # Needed to play with the configuration database.\n package 'debconf'\n package 'debconf-utils'\n\n # Keys for Debian packages.\n package 'debian-archive-keyring'\n\n # Fetch files via HTTP.\n package 'curl'\n package 'wget'\n\n package 'dpkg-dev' # Builds packages from source.\n package 'openssh-server' # SSH into the box.\n\n # For gems with native extensions.\n package 'build-essential'\n package 'g++'\n\n # Pull code from version control.\n package 'subversion'\n package 'git-core'\n\n package 'avahi-daemon' # mDNS, a.k.a. Bonjour\n package 'ddclient' # dynamic DNS\n end", "def custom_install_commands #:nodoc:\n dress @options[:custom_install], nil, :install\n end", "def define\n namespace :install do\n @project.builds.each do |build,packages|\n path = packages[:gem]\n\n task build => path do\n status \"Installing #{File.basename(path)} ...\"\n\n install(path)\n end\n end\n end\n\n desc \"Installs all built gem packages\"\n gemspec_tasks :install\n\n task :install_gem => :install # backwards compatibility with Hoe\n end", "def make_install\n run_with_failure_handler(\"cd #{@extracted_path} ; sudo make install\", 'make install')\n end", "def install\n # # Changes log level to default value\n # inreplace \"etc/baetyl/conf.yml\" do |s|\n # s.gsub! \"level: debug\", \"\"\n # end\n\n bin.install Dir[\"bin/*\"]\n etc.install Dir[\"etc/*\"]\n end", "def apply_step\n # Create deploy directories\n cap 'deploy:setup'\n # Deploy the configured step\n $?.success? ? (cap 'deploy') : (return $?)\n # Download dynamic step modules through librarian-puppet\n $?.success? ? (cap 'puppet:bundle_modules') : (return $?)\n # Install the step provision through puppet\n $?.success? ? (cap 'puppet:apply') : (return $?)\n $?\n end", "def install!\n cmd = [attributes.gem_binary, 'install']\n cmd << '-v' << attributes.version if attributes.version\n cmd << '--source' << attributes.source if attributes.source\n cmd << '--prerelease' if attributes.prerelease\n cmd << attributes.package_name\n\n run_command(cmd)\n end", "def main\n generate_config unless $dont_gen_conf\n\n if $just_gen_conf\n puts \"\\nSkips installing, just generated the config file!\".pink\n exit(0)\n end\n \n install_dependencies if $install_req\n\n install_to_directory\nend", "def install\n Core.install(gem_name: gem_name, base: base, **options)\n Badges.install(gem_name: gem_name, base: base, **options)\n Travis.install(gem_name: gem_name, base: base, **options)\n end", "def action_install\n install_bundler\n run_bundler('install')\n set_state\n end", "def run\n before_install\n run_steps\n return true\n rescue Abort\n puts\n return false\n rescue SignalException, SystemExit\n raise\n rescue PlatformInfo::RuntimeError => e\n new_screen\n puts \"<red>An error occurred</red>\"\n puts\n puts e.message\n exit 1\n rescue Exception => e\n show_support_options_for_installer_bug(e)\n exit 2\n ensure\n after_install\n end", "def action_install\n grunt_package.run_action(:install)\n wh_package.run_action(:install)\n new_resource.installed = true\n end", "def install\r\n automated_install {\r\n installer = Gem::Installer.new( @gem_path,\r\n :domain => :both,\r\n :generate_rdoc => true,\r\n :generate_ri => true,\r\n :force => true,\r\n :test => false,\r\n :wrappers => true,\r\n :install_dir => Gem.dir,\r\n :security_policy => nil\r\n )\r\n installer.install\r\n }\r\n end", "def after_install(path, options = {})\n timestamp = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n unless options['skip-bundle']\n bundle_install(path, options)\n if options['skip-patches']\n J1.logger.info \"#{timestamp} - GENERATE: Install build-in patches skipped ...\"\n else\n patch_install(options)\n end\n end\n timestamp = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n if options['force']\n J1.logger.info \"#{timestamp} - GENERATE: Generated Jekyll site force installed in folder #{path}\"\n else\n J1.logger.info \"#{timestamp} - GENERATE: Generated Jekyll site installed in folder #{path}\"\n end\n J1.logger.info \"#{timestamp} - GENERATE: Installation (bundle) of RubyGems skipped\" if options['skip-bundle']\n end", "def handle_postinstall(options)\n\n definition.postinstall_files.each do |postinstall_file|\n # Filenames of postinstall_files are relative to their definition\n filename=File.join(definition.path,postinstall_file)\n self.copy_to_box(filename,File.basename(filename))\n if not (definition.winrm_user && definition.winrm_password)\n self.exec(\"chmod +x \\\"#{File.basename(filename)}\\\"\")\n end\n end\n\n # Prepare a pre_poinstall file if needed (not nil , or not empty)\n unless definition.pre_postinstall_file.to_s.empty?\n pre_filename=File.join(definition.path, definition.pre_postinstall_file)\n self.copy_to_box(pre_filename,File.basename(pre_filename))\n if (definition.winrm_user && definition.winrm_password)\n # not implemented on windows yet\n else\n self.exec(\"chmod +x \\\"#{File.basename(pre_filename)}\\\"\")\n # Inject the call to the real script by executing the first argument (it will be the postinstall script file name to be executed)\n self.exec(\"execute=\\\"\\\\n# We must execute the script passed as the first argument\\\\n\\\\$1\\\" && printf \\\"%b\\\\n\\\" \\\"$execute\\\" >> #{File.basename(pre_filename)}\")\n end\n end\n\n # Now iterate over the postinstall files\n definition.postinstall_files.each do |postinstall_file|\n # Filenames of postinstall_files are relative to their definition\n filename=File.join(definition.path,postinstall_file)\n\n unless File.basename(postinstall_file).start_with?(\"_\")\n\n unless definition.pre_postinstall_file.to_s.empty?\n raise 'not implemented on windows yet' if (definition.winrm_user && definition.winrm_password)\n # Filename of pre_postinstall_file are relative to their definition\n pre_filename=File.join(definition.path, definition.pre_postinstall_file)\n # Upload the pre postinstall script if not already transfered\n command = \"./\" + File.basename(pre_filename)\n command = sudo(command) + \" ./\"+File.basename(filename)\n\n self.exec(command)\n else\n if (definition.winrm_user && definition.winrm_password)\n # no sudo on windows, batch files only please?\n self.exec(File.basename(filename))\n else\n self.exec(sudo(\"./\"+File.basename(filename)))\n end\n end\n\n else\n env.logger.info \"Skipping postinstallfile #{postinstall_file}\"\n end\n end\n end", "def install\n bin.install \"appsody\"\n bin.install \"appsody-controller\" \n ohai \"Checking prerequisites...\"\n #system \"docker\"\n retval=check_prereqs\n\n if retval\n ohai \"Done.\"\n else\n opoo \"Docker not detected. Please ensure docker is installed and running before using appsody.\"\n end\n end", "def install\n AdminModule.configuration.credentials.keys.each do |e|\n valid_actions.each do |action|\n AdminModule::Rake::SnapshotTasks.new(\"am:#{e}:snapshot:#{action}\", \"#{action} #{e} snapshot defn(s)\") do |t|\n t.env = e\n t.action = action\n end\n end\n end\n end", "def install!\n include_recipe 'zypper'\n super\n end", "def install(context={})\n \n SystemConfiguration::Variable.first_or_create({:name => 'cms.author_url'},\n {:value => '/profile/%s', :description => 'author url. Example /profile/%s', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.comments.pager'},\n {:value => 'page_list', :description => 'comments pager', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.comments.page_size'},\n {:value => '10', :description => 'comments page size', :module => :cms})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.templates.page_size'},\n {:value => '20', :description => 'templates page size', :module => :cms})\n\n ContentManagerSystem::ContentType.first_or_create({:id => 'page'},\n {:name => 'Pagina', :description => 'Representa una página web. Es una forma sencilla de gestionar información que no suele cambiar como la página acerca de o condiciones. Suelen mostrarse en el menú.'})\n \n ContentManagerSystem::ContentType.first_or_create({:id => 'story'},\n {:name => 'Articulo', :description => 'Tiene una estructura similar a la página y permite crear y mostrar contenido que informa a los visitantes del sitio. Notas de prensa, anuncios o entradas informales de blog son creadas como páginas.'})\n\n ContentManagerSystem::ContentType.first_or_create({:id => 'fragment'},\n {:name => 'Fragmento', :description => 'Representan bloques de información que se pueden mostrar en diferentes páginas. Banners son creados como fragmentos.'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'cms.force_trailing_slash'},\n {:value => 'false', :description => 'Force trailing slash in urls', :module => :cms})\n \n Site::Menu.first_or_create({:name => 'primary_links'},\n {:title => 'Primary links menus', :description => 'Primary links menu'})\n\n Site::Menu.first_or_create({:name => 'secondary_links'},\n {:title => 'Secondary links menu', :description => 'Secondary links menu'})\n\n Site::Menu.first_or_create({:name => 'members'},\n {:title => 'Members menu', :description => 'Members menu'})\n\n Users::Group.first_or_create({:group => 'editor'},\n {:name => 'Editor', :description => 'Web content editor'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'site.editor_front_page'},\n {:value => '', \n :description => 'Editor front page (dashboard)', \n :module => :cms})\n\n Users::Group.first_or_create({:group => 'webmaster'},\n {:name => 'Webmaster', :description => 'Webmaster'})\n\n SystemConfiguration::Variable.first_or_create({:name => 'site.webmaster_front_page'},\n {:value => '', \n :description => 'Webmaster front page (dashboard)', \n :module => :cms})\n\n\n ContentManagerSystem::View.first_or_create({:view_name => 'stories'},\n {\n :description => 'Published stories',\n :model_name => 'content',\n :query_conditions => {:operator => '$and', :conditions => [\n {:field => 'type', :operator => '$eq', :value => 'story'},\n {:field => 'publishing_state_id', :operator => '$eq', :value => 'PUBLISHED'}\n ]},\n :query_order => [{:field => 'publishing_date', :order => :desc}],\n :query_arguments => [],\n :style => :teaser,\n :v_fields => [],\n :render => :div,\n :render_options => {},\n :view_limit => 0,\n :pagination => true,\n :ajax_pagination => false,\n :page_size => 10,\n :pager => :default,\n :block => false,\n :url => 'stories'\n })\n \n ContentManagerSystem::View.first_or_create({:view_name => 'last_stories'},\n {\n :description => 'Last published stories',\n :model_name => 'content',\n :query_conditions => {:operator => '$and', :conditions => [\n {:field => 'type', :operator => '$eq', :value => 'story'},\n {:field => 'publishing_state_id', :operator => '$eq', :value => 'PUBLISHED'}\n ]},\n :query_order => [{:field => 'publishing_date', :order => :desc}],\n :query_arguments => [],\n :style => :fields,\n :v_fields => [\n {:field => 'photo_url_small', :image => true, :link => '#{element.path}', \n :image_alt => '#{element.summary}', :image_class => 'view_div_mini_youtube_img'},\n {:field => 'title', :link => '#{element.path}',\n :class => 'view_div_mini_youtube_title'},\n {:field => 'summary', :class => 'view_div_mini_youtube_body'}\n ],\n :render => :div,\n :render_options => {:container_class => 'view_div_mini_youtube_container',\n :container_element_class => 'view_div_mini_youtube_element'},\n :view_limit => 5,\n :pagination => false,\n :ajax_pagination => false,\n :page_size => 0,\n :pager => :default,\n :block => true\n })\n\n Media::Album.first_or_create({name: 'resources'},\n {description: 'Album for common resources'})\n Media::Album.first_or_create({name: 'content_resources'},\n {description: 'Album for content resources'})\n\n # Sitemap.xml and robots.txt templates\n sitemap_xml = <<-SITEMAP\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n <url>\n <loc>https://mysite.com/</loc>\n <lastmod>2018-11-02T00:24:48+00:00</lastmod>\n <priority>1.00</priority>\n </url>\n</urlset>\n SITEMAP\n\n robots_txt = <<-ROBOTS\n# Rule\nUser-agent: *\nAllow: /\n\nSitemap: http://mysite.com/sitemap.xml \n ROBOTS\n\n ContentManagerSystem::Template.first_or_create({:name => 'sitemap_xml'},\n {description: 'Plantilla para sitemap.xml',\n text: sitemap_xml })\n\n ContentManagerSystem::Template.first_or_create({:name => 'robots_txt'},\n {description: 'Plantilla para robots.txt',\n text: robots_txt})\n\n end", "def action_install\n notifying_block do\n install_scl_repo\n flush_yum_cache\n install_scl_package(:install)\n install_scl_devel_package(:install) if new_resource.dev_package\n end\n end", "def install_dependencies\n raise 'Not implemented'\n end", "def install\n\tsystem \"make\"\n end", "def perform_post_install_actions\n run_plugins_post_install_hooks\n warn_for_deprecations\n warn_for_installed_script_phases\n warn_for_removing_git_master_specs_repo\n print_post_install_message\n end", "def action_install\n install_requirements(upgrade: false)\n end", "def install_dependencies\n\t\tself.prompt.say \"Installing dependencies\"\n\t\truby '-S', 'gem', 'i', '-Ng'\n\tend", "def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend", "def install\n desc \"Update README (table of contents)\"\n task :doc do\n builder.doc\n end\n\n desc \"Clean gem artifacts\"\n task :clean do\n builder.clean\n end\n\n task :validate do\n builder.validate\n end\n\n desc \"Build #{gem_spec.package_file_name} package\"\n task build: %i[clean doc validate] do\n builder.build gem_spec\n end\n\n desc \"Install #{gem_spec.package_file_name} package\"\n task install: :build do\n builder.install gem_spec\n end\n\n desc \"Build, tag as #{gem_spec.version_label} (#{signed_label}), \" \\\n \"and push #{gem_spec.package_file_name} to RubyGems\"\n task publish: :build do\n publisher.publish\n end\n end", "def install!\n refresh_file_accessors\n prepare_pod_groups\n add_source_files_references\n add_frameworks_bundles\n add_vendored_libraries\n add_resources\n add_developer_files unless sandbox.development_pods.empty?\n link_headers\n end", "def run\n header\n what_is_installed?\n install_pianobar\n setup_config_file\n make_fifos\n setup_auto_play_station\n end", "def install\n cd(@project_name) do\n puts `rake db:automigrate`\n puts `rake action=\"all\" dev:gen:view`\n puts `thor merb:gem:install`\n puts `bin/rake doc:diagrams`\n end\n end", "def _install\n args = Array.new\n # If the project contains a makefile, it is a candidate for a derivative build.\n # In such case, protect 'libraries', 'modules' and 'themes' subdirectories\n # from deletion.\n if component.makefile\n args << '-f' << 'P /libraries/***' # this syntax requires rsync >=2.6.7.\n args << '-f' << 'P /modules/***'\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'P /themes/***'\n end\n if component.drupal?\n args = Array.new\n args << '-f' << 'R /profiles/default/***' # D6\n args << '-f' << 'R /profiles/minimal/***' # D7\n args << '-f' << 'R /profiles/standard/***' # D7\n args << '-f' << 'R /profiles/testing/***' # D7\n args << '-f' << 'P /profiles/***'\n args << '-f' << 'R /sites/all/README.txt'\n args << '-f' << 'R /sites/default/default.settings.php'\n args << '-f' << 'P /sites/***'\n end\n args << '-a'\n args << '--delete'\n component.ignore_paths.each { |p| args << \"--exclude=#{p}\" }\n dst_path = platform.local_path + platform.dest_path(component)\n dont_debug { dst_path.mkpath }\n args << component.local_path.to_s + '/'\n args << dst_path.to_s + '/'\n begin\n runBabyRun 'rsync', args\n rescue => ex\n odie \"Installing or updating #{component.name} failed: #{ex}\"\n end\n end", "def install_instructions\n [\n \"wget -q '#{jmeter_download_url}' -O #{jmeter_download_file}\",\n \"tar -xzf #{jmeter_download_file}\",\n \"ln -s #{user_home}/#{jmeter_directory} #{user_home}/jmeter\"\n ]\n end", "def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end", "def install\n system \"make\", \"-f\", \"LINUX/Makefile\"\n bin.install 'xum1541cfg'\n end", "def install\n generate \"rspec:install\"\n generate \"cucumber:install\"\n template 'features/support/poltergeist.rb'\n end", "def SetInitialInstallation\n SetXENExceptions()\n\n Builtins.y2milestone(\"Adjusting language settings\")\n\n # properly set up initial language\n Installation.encoding = Console.SelectFont(Language.language)\n if Ops.get_boolean(UI.GetDisplayInfo, \"HasFullUtf8Support\", true)\n Installation.encoding = \"UTF-8\"\n end\n\n UI.SetLanguage(Language.language, Installation.encoding)\n WFM.SetLanguage(Language.language, \"UTF-8\")\n UI.RecordMacro(Ops.add(Directory.logdir, \"/macro_inst_initial.ycp\"))\n\n Builtins.y2milestone(\"Adjusting first stage modules\")\n\n show_addons = ProductFeatures.GetBooleanFeature(\"globals\", \"show_addons\")\n addons_default = ProductFeatures.GetBooleanFeature(\n \"globals\",\n \"addons_default\"\n )\n # default fallback\n show_addons = true if show_addons == nil\n addons_default = false if addons_default == nil\n\n Builtins.y2milestone(\n \"Control file definition for add-on, visible: %1, selected: %2\",\n show_addons,\n addons_default\n )\n if show_addons\n ProductControl.DisableModule(\"add-on\")\n else\n ProductControl.EnableModule(\"add-on\")\n end\n Installation.add_on_selected = addons_default\n\n show_online_repositories = ProductFeatures.GetBooleanFeature(\n \"globals\",\n \"show_online_repositories\"\n )\n online_repositories_default = ProductFeatures.GetBooleanFeature(\n \"globals\",\n \"online_repositories_default\"\n )\n # default fallback\n show_online_repositories = false if show_online_repositories == nil\n online_repositories_default = true if online_repositories_default == nil\n\n Builtins.y2milestone(\n \"Control file definition for productsources, visible: %1, selected: %2\",\n show_online_repositories,\n online_repositories_default\n )\n if show_online_repositories\n ProductControl.EnableModule(\"productsources\")\n else\n ProductControl.DisableModule(\"productsources\")\n end\n Installation.productsources_selected = online_repositories_default\n\n Builtins.y2milestone(\"Disabling second stage modules\")\n # First-stage users module will enable them again only if needed\n ProductControl.DisableModule(\"root\")\n ProductControl.DisableModule(\"user\")\n # bnc #401319\n ProductControl.DisableModule(\"user_non_interactive\")\n ProductControl.DisableModule(\"auth\")\n\n Builtins.y2milestone(\"Adjusting automatic configuration\")\n # FATE #303396, Make second stage non-interactive\n enable_autoconfiguration = ProductFeatures.GetBooleanFeature(\n \"globals\",\n \"enable_autoconfiguration\"\n )\n autoconfiguration_default = ProductFeatures.GetBooleanFeature(\n \"globals\",\n \"autoconfiguration_default\"\n )\n\n # bnc#679435: leave normal second stage for autoYaST\n if Mode.autoinst\n enable_autoconfiguration = false\n autoconfiguration_default = false\n end\n\n # Enabled only when AC is selected\n InstData.enable_autoconfiguration = enable_autoconfiguration == true\n # Default state\n ProductControl.SetUseAutomaticConfiguration(\n autoconfiguration_default == true\n )\n # Enables or disables some modules, etc.\n AdjustAutomaticConfiguration()\n\n nil\n end", "def install\n args = std_cmake_args\n\n system \"cmake\", \".\", *args\n system \"make\", \"install\"\n prefix.install \"install_manifest.txt\"\n end", "def setup\n install_latest_ruby\n\n install_global_gems\n end", "def install(name:, dir: nil)\r\n end", "def custom\n Athenry::build.target(\"install_pkgmgr\", \"update_everything\", \"rebuild\", \"update_configs\", \"install_overlays\", \"install_sets\", \"rebuild\")\n end", "def install\n bin.install \"SwiftyScripts\"\n end", "def install!(name:, dir: nil)\r\n end", "def install\n bin.install \"job\"\n end", "def install\n system \"cargo\", \"install\", \"--no-default-features\", \"--features\", \"default-no-update\",\n *std_cargo_args(path: \"cargo-nextest\")\n end", "def install!\n src = package_source\n chk = package_checksum\n windows_package 'Chef Development Kit' do\n source src\n checksum chk\n end\n end", "def install_gem; end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/bash ./#{SETUP_ENV_SCRIPT}\"\n end", "def install\n package_install\n changes = setup_data_dir\n changes += pg_configure\n if changes.empty?\n pg_start\n else\n pg_restart\n end\n changes\n end", "def install_message; end", "def install(opts=nil, &block)\n communicate.sudo(install_dependencies_cmd, opts, &block)\n super\n end", "def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/sh ./#{SETUP_ENV_SCRIPT}\"\n end", "def install(dry = false)\n create_dirs(dry) unless @needs_dir.nil?\n link(dry) unless @links.nil?\n run_shell_commands(dry) unless @commands.empty?\n end", "def create_tasks\n Application.features[self].each{ |f|\n extend Rake::DSL\n taskname = \"#{f.to_s.split('::').last}\"\n desc \"Feature\"\n task taskname => [\"#{taskname}:install\"] do\n end\n namespace taskname do\n desc \"install #{taskname}\"\n task :install do\n puts \"----> installing #{taskname}\"\n puts \"#{self} | #{f}\"\n Application.install[f.name].each{ |c|\n puts \"#{c}\"\n }\n end\n end \n } if Application.features[self]\n end", "def install\n system \"make\"\n system \"make install PREFIX=#{prefix}\"\n end", "def action_before_deploy\n install_packages\n end", "def install_pre_hook\n end", "def install(options = {})\n yield nil\n end", "def install(options = {})\n yield nil\n end", "def install_packages(app)\n\n `installer -pkg \"#{app}\" -target /`\n\nend", "def install\n # ENV.deparallelize\n printf `whoami`\n cmd = \"echo mv * #{ENV['HOME']}/Library/Dictionaries/\"\n printf `echo #{cmd}`\n printf `echo This Formula do not work!`\n printf `echo Pls use LangdaoDict.sh instead!`\n #cmd = \"mv * #{Dir.home}/Library/Dictionaries/\"\n #printf `echo #{cmd}`\n #`#{cmd}`\n end" ]
[ "0.74743325", "0.7460755", "0.73897916", "0.7368869", "0.7368869", "0.72830504", "0.7140854", "0.71113795", "0.7066509", "0.70359045", "0.6995226", "0.69939077", "0.6938373", "0.6924086", "0.692373", "0.6906379", "0.6887951", "0.68700236", "0.68122405", "0.672026", "0.657647", "0.6565112", "0.6541884", "0.6507091", "0.64865106", "0.64750546", "0.6458421", "0.64573485", "0.6453667", "0.6452125", "0.64327693", "0.6428595", "0.6409875", "0.63965416", "0.6372561", "0.63719654", "0.63698447", "0.63698447", "0.63641673", "0.63641673", "0.63582087", "0.63519686", "0.63332903", "0.63287693", "0.63173956", "0.6312211", "0.6307666", "0.62923265", "0.62706906", "0.6254347", "0.62440145", "0.62297434", "0.6227071", "0.6209494", "0.6190526", "0.61872", "0.61690253", "0.61673397", "0.6165891", "0.61593443", "0.61463076", "0.6130534", "0.61173046", "0.6093877", "0.6090449", "0.6090385", "0.6084852", "0.6083057", "0.6080705", "0.6076678", "0.6073995", "0.60702866", "0.6063761", "0.6062004", "0.6058766", "0.60409945", "0.6023687", "0.60196465", "0.6016072", "0.60090286", "0.6002332", "0.6000905", "0.5997575", "0.59971184", "0.5990898", "0.59904283", "0.5988784", "0.5988672", "0.59850013", "0.5980812", "0.5963586", "0.59612596", "0.59569186", "0.5942501", "0.59323776", "0.5922007", "0.59125537", "0.591139", "0.591139", "0.590963", "0.5905843" ]
0.0
-1
MUST BE CALLED BY User.deliver_inactive_notification!
def inactive_notification(user) setup_email(user) @subject += subject_from_sym :inactive_notification @body[:name] = user.full_name || 'Eternos user' @body[:link] = account_setup_url(:id => user.perishable_token) add_category_header "Inactive Account Notice" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inactive_message; end", "def inactive_message; end", "def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end", "def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end", "def do_notify_disabled(transition)\n if user && Rails.application.settings.enforce_rules\n UserMailer.access_revoked(user, self).deliver_later\n end\n end", "def inactive_message\n !deactivated_at ? super : :deactivated_account\n end", "def after_save(user)\n UserNotifier.deliver_activation(user) if user.recently_activated?\n end", "def inactive_message\n # In order of priority\n if pending_deletion_since\n :pending_deletion\n elsif suspended_account\n :suspended\n else\n super\n end\n end", "def inactive_message\n login_email = multi_email.login_email_record\n\n if login_email && !login_email.primary? && !login_email.confirmed?\n :unconfirmed\n else\n super\n end\n end", "def inactive_message\n deactivated_at.present? ? 'Account has been deactivated' : super\n end", "def inactive_message\n isActive ? super : :inative_account\n end", "def inactive_message\n !confirmed? ? :unconfirmed : super\n end", "def after_save(user)\n UserMailer.deliver_activation(user) if user.pending?\n end", "def remove_upcoming_registrations_if_inactive\n remove_upcoming_registrations if !self.active \n end", "def inactive_message\n !active? ? :inactive : super\n end", "def disable_inactivity_email\n @user.update_attributes(:is_receiving_inactivity_email => false)\n @notice = \"You have disabled inactivity notifications.\"\n \n respond_to do |format|\n format.html {\n redirect_to(manage_email_notifications_path, notice: @notice) and return\n return \n }\n format.js {\n render :unsubscribe\n }\n end\n end", "def inactive_message\n # this method actually is not implemented by devise_token_auth\n # instead, use devise_token_auth locales file or override #render_create_error_not_confirmed in controller\n # still not sure why it uses not_confirmed anyway, but at least I'm not the only one. See below\n #\n # This incomplete PR corrects it:\n # https://github.com/lynndylanhurley/devise_token_auth/pull/533\n # https://github.com/lynndylanhurley/devise_token_auth/pull/533/files\n end", "def inactive\n end", "def inactive_message\n \t!deleted_at ? super : :deleted_account\n end", "def notify_incomplete\n Notification.notify_incomplete\n end", "def remove_registrations_if_inactive\n remove_upcoming_registrations if !self.active \n end", "def camaleon_mailchimp_on_inactive(plugin)\n end", "def inactive_message\n !disabled ? super : :account_has_been_disabled\n end", "def notify_unlocked\n ::Notification.create!(\n from: user,\n user_id: user_id,\n seen: false,\n target: self,\n kind: :ACHIEVEMENT_UNLOCKED\n )\n end", "def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end", "def inactive_message\n\t\t\"Sorry, this account not active by admin. Will Contact you soon.\"\n\tend", "def confirm\r\n # Change user status to active\r\n update(status: :active)\r\n # Update all pending company_roles to active\r\n company_roles.update_all(status: 1)\r\n NotifyMailer.welcome_mail(self).deliver_later\r\n super\r\n end", "def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n Mailer.activation_request(user).deliver_later\n MessageLog.log_activation_email(user.person)\n end\n else\n Rails.logger.info(\"User with invalid person - #{user.id}\")\n end \n end\n end", "def activate_user\n self.save\n self.send_user_notification_email\n end", "def inactive_message\n !self.deleted_at ? super : :deleted_account\n end", "def inactive_message\n \"This account has been deactivated or doesn't have account.\"\n end", "def inactive_message\n\n date_restricted? ? :account_date_restricted : super\n\n end", "def inactive_message \n !is_deleted ? super : :deleted_account \n end", "def booked_not_confirmed\n NotificationMailer.booked_not_confirmed\n end", "def skip_email_changed_notification!; end", "def skip_confirmation_notification!; end", "def all_activated(user, email_alert_definition)\n true\n end", "def fulfilled_without_acceptance\n UserNotifier.deliver_ready(self, user)\n end", "def inactive_message\n \t!deleted_at ? super : :deleted_account\n end", "def inactive_message\n \t!deleted_at ? super : :deleted_account\n end", "def pending_any_confirmation; end", "def inactive_message\n if !approved?\n :not_approved\n else\n super # mensaje\n end\n end", "def do_pending \n make_activation_code\n ClaimingMailer.deliver_confirmation_request(self) if self.email && self.activation_code\n end", "def remove_pending\n authorize! :update, @user, :message => t('errors.messages.not_authorized_as_manager')\n\n @user = User.find(params[:id])\n @marina = Marina.find(params[:marina])\n @marina.pending_users.delete(@user)\n\n @user.marina_state= \"\"\n UserNotifier.remove_pending(@user).deliver\n @user.save\n @marina.save\n redirect_to marina_path(@marina), :notice => t('errors.messages.remove_pending')\n #\"Bertholder and marina are now connected. a notification email has been sent\"\n\n\n\n end", "def inactive_message\n !disabled_at ? super : :deleted_account\n end", "def stale_notification\n user = User.joins(:notifications).merge(Notification.not_confirmed).take\n\n NotifierMailer.stale_notification user\n end", "def inactive_message\n if !approved?\n :not_approved\n else\n super\n end\n end", "def after_suspend(user, transition)\n UserMailer.deliver_suspension_notice(user)\n end", "def notify_user(ad)\n #create notification for the user\n notification = self.notifications.unviewed.event(:new_relevant_ad).new\n notification.user = self.user\n notification.ad = ad\n notification.save!\n end", "def make_inactive\n self.status = \"I\"\n end", "def inactive_message \n \t!deleted_at ? super : :deleted_account \n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n\t\t\t!delete_flag ? super : :deleted_account\n\t\tend", "def inactive_message \n !deleted_at ? super : :deleted_account \n end", "def if_family_inactive\n if self.active == false\n remove_future_registrations\n inactive_students\n end\n end", "def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end", "def unpaid_user_notification(user)\n mail(to: user.email, subject: I18n.t('user_mailer.unpaid_user_notification.subject'))\n end", "def inactive_message\n !deleted_at ? super : :deleted_account \n end", "def inactive_message \n if !approved? \n :not_approved \n else \n super # Use whatever other message \n end \n end", "def reject_user\n # set the enabled flag to false for the user\n # clear activation code (prevents user from showing up as pending user)\n # send out rejection notification\n end", "def do_notify_restricted(transition)\n if user && Rails.application.settings.enforce_rules\n UserMailer.access_revoked(user, self).deliver_later\n end\n end", "def inactive_message\n sms_confirmation_required? && !confirmed_sms? ? :unconfirmed_sms : super\n end", "def inactive_message\n 'Sorry, this account has been deactivated.'\n end", "def deactivate\n @listing.update(\n active: false\n )\n flash[:notice] = \"You have successfully deactivated your listing.\"\n redirect_to user_path(current_user.id)\n\n favourited_users = @listing.favourited_users\n favourited_users.each do |user|\n user.notifications.create(\n title: \"Someone deactivated your favourite\",\n body: \"#{current_user.first_name} has deactivated your favourite #{@listing.title}\",\n read: false,\n )\n end\n end", "def inactive_message \n if !is_approved? \n :not_approved \n else \n super # Use whatever other message \n end \n end", "def inactive_date\n\t\tif inactive_changed?\n\t\t\tif inactive?\n\t\t\t\tself.inactive_from = Time.now\n\t\t\telse\n\t\t\t\tself.inactive_from = nil\n\t\t\tend\n\t\tend\n\n\t\tdef new_ownership\n\t\t\t@user = User.find(self.created_by)\n\t\t\tOwnership.create(business_id: self.id, user_id: self.created_by, \n\t\t\t\temail_address: @user.email, created_by: self.created_by)\n\t\tend\n\tend", "def send_activation_email\n unless notified?\n Notifier.email_activation(self).deliver\n self.update_attribute(:notified, true)\n end\n end", "def inactive_message \n approved? ? super : :not_approved\n end", "def new_user_notification\n\t\tUserMailer.new_user_notification('test@test.com',User.where(:administrator => nil).first)\n end", "def notify_member_expire_1\n users, event = User.unpaid_membership_expires_in_1_day\n users.each do |user|\n UserMailer.deliver_membership_expires_in_1_day(user)\n User.add_email_event(user, event)\n end\n end", "def check_user_background\n self.status = Status::PENDING_ADMIN_ACTION if offender && offender.new_user?\n end", "def inactive_post(email)\n end", "def inactive_message\n if !approved?\n :not_approved\n else\n super # Use whatever other message\n end\n end", "def notify_member_expire_7\n users, event = User.unpaid_membership_expires_in_7_days\n users.each do |user|\n UserMailer.deliver_membership_expires_in_7_days(user)\n User.add_email_event(user, event)\n end\n end", "def inactive_message\n deactivated? ? :deactivated : super\n end", "def send_active_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: true)\n end", "def handle_activation(user)\n\t\t\n\tend", "def inactive_user?\n self.status == \"Inactive\"\n end", "def dmail_inactive_approvers!\n days_until_next_month = (Date.current.next_month.beginning_of_month - Date.current).to_i\n return unless days_until_next_month <= 21\n\n inactive_approvers.each do |user|\n Dmail.create_automated(to: user, title: \"You will lose approval privileges soon\", body: <<~BODY)\n You've approved fewer than #{MINIMUM_APPROVALS} posts in the past\n #{APPROVAL_PERIOD.inspect}. You will lose your approval privileges in\n #{days_until_next_month} #{\"day\".pluralize(days_until_next_month)}\n unless you have approved at least #{MINIMUM_APPROVALS} posts by the end\n of the month.\n BODY\n end\n end", "def admin_notify\n UserMailer.signup_notification(self).deliver_later!(wait: 1.minute)\n end", "def can_notify? user\n return false if self.id == user.id\n not notification_exists? user\n end", "def is_pending_activation?\n ! self.activated? and self.verification_key ? true : false\n end", "def after_save(user)\n UserMailer.deliver_activation(user) if user.recently_activated?\n UserMailer.deliver_forgot_password(user) if user.recently_forgot_password?\n UserMailer.deliver_reset_password(user) if user.recently_reset_password?\n end", "def send_notification(new_state, current_user_id, recipient_id)\n if current_user_id != user_id\n UserMailer.new_event(id, user.email).deliver_now\n end\n\n if ['verification', 'approval', 'execution'].include? new_state\n if recipient_id != user_id # must not be double delivering\n recipient_email = User.find_by(id: recipient_id).try(:email)\n UserMailer.new_event(id, recipient_email).deliver_now\n end\n end\n end" ]
[ "0.70507026", "0.70507026", "0.70283043", "0.70283043", "0.69109446", "0.6864436", "0.6834575", "0.6804752", "0.679606", "0.6727194", "0.6695414", "0.66756546", "0.66666704", "0.66268843", "0.6583416", "0.65809834", "0.65647185", "0.6552468", "0.6536999", "0.6518272", "0.6498561", "0.64917225", "0.6484092", "0.6467135", "0.64352226", "0.64264923", "0.64192706", "0.64049613", "0.6402727", "0.6401543", "0.6394053", "0.63923055", "0.63917685", "0.63801277", "0.6364076", "0.63634866", "0.6360341", "0.6357319", "0.6355272", "0.6355272", "0.6345722", "0.63445824", "0.6330231", "0.6325964", "0.6324022", "0.63172615", "0.62880415", "0.6282931", "0.6274518", "0.6269553", "0.6255076", "0.6253766", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.6251215", "0.624923", "0.62373966", "0.62348235", "0.623268", "0.6215375", "0.6208798", "0.62066656", "0.62046874", "0.6202454", "0.62011874", "0.61974573", "0.61928356", "0.6181836", "0.61690414", "0.616827", "0.6167299", "0.6162504", "0.61538297", "0.61528724", "0.6152165", "0.6144656", "0.6144416", "0.6141091", "0.6138794", "0.61061865", "0.60983986", "0.6095777", "0.60850793", "0.60807323", "0.60691905", "0.606438", "0.6061917" ]
0.77993435
0
MUST BE CALLED BY User.deliver_account_setup_reminder!
def account_setup_reminder(user) setup_email(user) @subject = subject_from_sym :account_setup_reminder @body[:name] = user.full_name @body[:setup_url] = account_setup_url(:id => user.perishable_token, :ref => 'asr1') add_category_header "Account Setup Reminder" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_activation_or_reset_mail\n end", "def after_create_action\n sign_up_lead_rescuer\n send_email_to_lead_rescuer\n end", "def after_save(user)\n\n UserMailer.deliver_activation(user) if user.recently_activated? unless user.setup\n UserMailer.deliver_forgot_password(user) if user.recently_forgot_password?\n UserMailer.deliver_reset_password(user) if user.recently_reset_password?\n UserMailer.deliver_forgot_username(user) if user.recently_forgot_username?\n\n end", "def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end", "def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end", "def setup_email_account\n email_accounts.create!(email: email, primary: true, confirmed: !confirmed_at.blank?)\n end", "def save!\n User.transaction do\n user.save!\n user.create_setup!\n end\n MarketingMailer.user_has_registered(user).deliver\n end", "def user_setup\n\t\tif self.id.blank?\n\t\t\tself.id = self.email\n\t\t\n\t\tend\n\tend", "def deliver_activation_instructions!\n Notifier.delay.signup_notification(self.id)\n end", "def register_confirmation\n @account.deliver_register_confirmation unless @account.checked\n end", "def after_save(user)\n UserMailer.deliver_activation(user) if user.pending?\n end", "def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end", "def do_pending \n make_activation_code\n ClaimingMailer.deliver_confirmation_request(self) if self.email && self.activation_code\n end", "def send_on_create_confirmation_instructions; end", "def send_on_create_confirmation_instructions; end", "def pre_lesson_reminder(user)\n @day = day_of_week_string(Date.tomorrow)\n @user = user\n mail to: user.email, subject: \"Reminder: Complete Pre-Lesson Information\"\n end", "def activate_user\n self.save\n self.send_user_notification_email\n end", "def add_reminder; end", "def reminder_sent\n end", "def after_create_account(user, auth)\n # not required\n end", "def send_post_registration_email\n IdealsMailer.account_registered(self).deliver_now\n end", "def pending_any_confirmation; end", "def after_create_account(result)\n\n end", "def after_create(user)\n #user.reset_perishable_token! # set the perishable token to some value\n #UserNotifier.deliver_signup_notification(user.email, user)\n end", "def check_if_needs_approval\r\n self.suspended_at = Time.now if Setting.user_signup == :needs_approval && !self.admin\r\n end", "def send_activation_email\n DoctorMailer.account_activation(self).deliver_now\n end", "def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end", "def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end", "def deliver_activation_instructions!\n if Settings.uses_resque_for_background_emails\n Resque.enqueue(Jobs::SendSignUpNotification, self.id)\n else\n Notifier.signup_notification(self.id).deliver_later\n end\n end", "def account_activation\n user = User.first\n user.activation_sent_at = Time.current\n UserMailer.account_activation(user)\n end", "def after_redeem() end", "def after_confirmation # Send welcome mail after user is successfully registered\n send_user_mail\n end", "def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def prepare_for_validation\n self.reset_perishable_token!\n Notifier.account_validation_instructions(self).deliver\n end", "def meetup_auto_create_account?\n self.meetup_auto_create_account\n end", "def admin_notify\n UserMailer.signup_notification(self).deliver_later!(wait: 1.minute)\n end", "def on_users_account\n true\n end", "def send_pre_lesson_reminder_email\n UserMailer.lesson_reminder(mentor).deliver_now\n end", "def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end", "def send_welcome_email\n UserMailer.signup_email(self) #removed .delay\n end", "def send_on_create_confirmation_instructions\n end", "def after_update_challenge\n send_email_after_canceled_reactive\n send_email_after_change_start_date\n end", "def resend_activation_email\n create_activation_digest\n save\n send_activation_email\n end", "def deliver_confirmation_email_instructions!\n # TODO\n end", "def after_save(user)\n UserMailer.deliver_activation(user) if user.recently_activated?\n UserMailer.deliver_forgot_password(user) if user.recently_forgot_password?\n UserMailer.deliver_reset_password(user) if user.recently_reset_password?\n end", "def activation_needed_email(user)\n @user = user\n @account_activation_url = activate_user_url(user.activation_token)\n mail to: user.email, subject: \"ACTION NEEDED: Activate your VCDelta.org account\"\n end", "def send_activation_request\n end", "def send_on_create_confirmation_instructions\n end", "def after_create\n super\n create_account\n end", "def deliver_activation_instructions!\n reset_perishable_token!\n Mailer.deliver_activation_instructions(self)\n end", "def approval_needed(user)\n @user = user\n\n mail to: ENV['ADMIN_EMAIL'], subject: \"User wants approval for Thumbline Set List\"\n end", "def setup_all\n setup_all_options\n save_validate_user { setup_successfull }\n end", "def finish_signup_later\n user = User.first\n UserMailer.finish_signup_later(user)\n end", "def set_attr_for_create\n self.agreement_status ||= 0 #unsigned\n self.trans_type = TRANS_TYPE[:AccountSetup]\n self.acct_open_date = Date.today\n self.last_trans_date = Date.today\n log_event(\"Customer\", self.id, \"Account Created\")\n end", "def referral_confirmation_email\n\n end", "def send_confirmation_instructions; end", "def send_activation_email\n\t\tUserMailer.account_activation(self).deliver_now\n\tend", "def meteor_create_initial_email\n add_to_set(emails: build_meteor_mail_hash(email, confirmed?))\n end", "def send_auto_reminder?\n self.auto_reminder_days > 0\n end", "def initial_setup\n # Give him friends\n f = [User.least_email(\"upstill\"), User.least_email(\"arrone\"), User.super_id ]\n f << self.invited_by_id if self.invited_by_id\n self.followee_ids = f\n\n # Give him some lists \"Keepers\", \"To Try\", \"Now Cooking\"\n List.assert \"Keepers\", self, create: true\n List.assert \"To Try\", self, create: true\n List.assert \"Now Cooking\", self, create: true\n\n self.save\n\n # Make the inviter follow the newbie.\n if self.invited_by_id\n begin\n invited_by = User.find(self.invited_by_id)\n invited_by.followees << self\n rescue\n end\n end\n end", "def send_account_created_instructions\n token = set_reset_password_token\n send_account_created_instructions_notification(token)\n\n token\n end", "def send_account_created_instructions\n token = set_reset_password_token\n send_account_created_instructions_notification(token)\n\n token\n end", "def send_reset_password_instructions \n if self.confirmed?\n super \n else\n errors.add :base, \"You must receive an invitation before you set your password.\" \n end\n end", "def send_reset_password_instructions\n return unless EMAILS_ENABLED && !deleted?\n\n super\n end", "def check_schedule_confirmed\n\t\t# Picked a random 'check' user service and temporary set it's status to schedule_confirmed\n\t\tuser_service \t\t= UserService.find_by(relationship_type: 'check')\n\t\tuser_service.date \t= Time.now\n\t\tuser_service.status = 'schedule_confirmed'\n\t\tUserServicesMailer.check_updated(user_service)\n\tend", "def invited_startups!\n self.setup << :invite_startups\n save\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end", "def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end", "def complete_signup\n if self.habitats_count < 1\n self.errors.add(:habitats, \"User not done if they don't have a habitat\")\n false\n else\n self.completed_signup_at ||= Time.now\n if self.save\n self.generate_confirmation_token!\n enqueue_welcome_email\n true\n else\n false\n end\n end\n end", "def signup_confirmation\n FreelanceMailerMailer.signup_confirmation\n end", "def email_activate\n self.email_confirmed = true\n self.confirm_token = nil\n # Redundant, but makes sure we don't run into password validation issues\n save!(validate: false)\n end", "def admin_account_activation(member)\r\n @member = member\r\n mail(to: member.user_name, subject: \"Admin Account Activation\") \r\n end", "def check_schedule_unconfirmed\n\t\t# Picked a random 'check' user service and temporary set it's status to scheduled_unconfirmed\n\t\tuser_service \t\t= UserService.find_by(relationship_type: 'check')\n\t\tuser_service.date \t= Time.now\n\t\tuser_service.status = 'schedule_unconfirm'\n\t\tUserServicesMailer.check_updated(user_service)\n\tend", "def activation_welcome\n PharmacistMailer.activation_welcome\n end", "def control_reminder\n UserMailer.control_reminder(User.control.first)\n end", "def after_save\n begin\n # https://redmine.corp.halomonitor.com/issues/3215\n #\n unless user.blank?\n # \n # Wed Feb 9 23:26:29 IST 2011, ramonrails\n # * this is the panic 'timestamp'\n # * we do not want any difference at all between timestamp in panic & user intake\n # \n # Thu Feb 10 23:17:52 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4180\n # * tiemstamp may really not be the recent one. We need Time.now\n _time_now = Time.now\n #\n # buffer for last panic row related to this user\n user.update_attribute( :last_panic_id, id) # no validations\n # * this is only for cucumber purpose\n if user.has_caregivers.any?(&:raises_exception?)\n raise \"Custom exception for BDD tests only\" # WARNING: this will not send emails until exception handling is added here\n end\n #\n # \n # \"Ready to Bill\" state if panic is\n # * after \"Desired Installation Date\"\n # * senior is member of safety care, but in test mode (partial test mode)\n # * only apply \"ready to bill\" state when current state is any of\n # * Ready to Install or Install Overdue\n # * \"Installed\" means, panic button was ok. user was \"Bill\"ed by human action\n _allowed_states = [User::STATUS[:install_pending], User::STATUS[:overdue]]\n if !user.desired_installation_date.blank? && (_time_now > user.desired_installation_date) && _allowed_states.include?( user.status.to_s)\n # \n # Fri Dec 17 21:01:27 IST 2010, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/3891\n if user.order_placed_online?\n # transition the user from \"Ready to Install\" => \"Ready to Bill\"\n # * We need \"bill\" state when order was placed online\n if user.subscription_successful?\n # * already \"billed\". we can simply go to \"Installed\" state\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n else\n user.update_attribute( :status, User::STATUS[:bill_pending]) # \"Ready to bill\". no validations\n end\n else\n # * just mark the user \"Installed\", when created directly from user intake\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n end\n # # \n # # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # # * Pro rata is charged from the date we received panic button after \n # user.user_intakes.first.update_attribute( :panic_received_at, _time_now) unless user.user_intakes.blank?\n #\n # add triage_audit_log with a message\n _message = \"Automatically transitioned from 'Ready to Insall' to 'Ready to Bill' state at 'Panic button'\"\n\n # \n # Wed Dec 1 03:36:39 IST 2010, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/3786\n # * if subscription was already charged, mark user \"installed\"\n elsif (user.status.to_s == User::STATUS[:bill_pending]) && user.subscription_successful?\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n # # \n # # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # # * Pro rata is charged from the date we received panic button after \n # user.user_intakes.first.update_attribute( :panic_received_at, _time_now) unless user.user_intakes.blank?\n #\n # add triage_audit_log with a message\n _message = \"Automatically transitioned from any existing state to 'Installed' state at 'Panic button' because subscription started before panic event.\"\n end\n # \n # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # * Pro rata is charged from the date we received panic button after \n # Fri Dec 17 21:03:40 IST 2010, ramonrails\n # * This is common method call for \"if\" conditions above\n unless user.user_intakes.blank?\n _intake = user.user_intakes.first\n # \n # Fri Feb 11 00:48:03 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4181\n # * we need panic_received_at and installed_at to reflect the actual timestamp\n # * we cannot however switch the status to \"Installed\" as we want a concurrent \"Ready to Bill\" status\n # if panic < desired \n # panic_received_at is not updated and stays blank\n # elsif (panic > desired or desired.blank?)\n if _intake.installation_datetime.blank? || ( _time_now > _intake.installation_datetime )\n # only the first panic updates panic_received_at, ignore subsequent panics\n if _intake.panic_received_at.blank?\n _intake.update_attribute( :panic_received_at, _time_now)\n # send \"<halouser> installed\" email\" \n user.notify_about_installation\n # \n # update User.installed_at\n # Tue May 24 23:08:25 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4486\n # * Installed at should not be updated when panic button is sent before \"Ready for Approval\" state\n # * status.blank? means 'Not Submitted'\n user.update_attribute( :installed_at, _time_now) unless user.status.blank?\n # \n # make all caregivers active\n # Fri Feb 4 01:06:31 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4147\n # all caregivers are active now\n user.has_caregivers.each { |e| e.set_active_for( user, true) }\n # Installed timestamp in the \"Status\" column of Single Row User Intake\n # * updated in _user_intake_row.html.erb\n #\n # Completely disable test mode (User.test_mode = false)\n # \n # Fri Feb 4 22:31:15 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4152\n # * make user out of test mode here\n user.test_mode = false\n user.send( :update_without_callbacks)\n end\n end\n # # \n # # Fri Jan 28 02:15:27 IST 2011, ramonrails\n # # * https://redmine.corp.halomonitor.com/issues/4111#note-7\n # # * update the Panic.after_save, only store the first panic after installation_datetime, not every subsequent panic\n # if _intake.installation_datetime.blank?\n # # Installation date time blank?\n # ## First panic stored\n # ## Subsequent panics do not over-write the first stored one\n # _intake.update_attribute( :panic_received_at, _time_now) if _intake.panic_received_at.blank?\n # \n # elsif _intake.panic_received_at.blank? || (_intake.panic_received_at < _intake.installation_datetime)\n # # Installation date time given?\n # ## First panic after the timestamp, is stored. Overwriting any existing one that might have existed before the timestamp\n # ## Subsequent panics do not overwrite the existing stored one\n # _intake.update_attribute( :panic_received_at, _time_now)\n # end\n end\n\n #\n # add to triage audit log with a message\n if defined?( _message) && !_message.blank?\n #\n # add a row to triage audit log\n # cyclic dependency is not created. update_withut_callbacks is used in triage_audit_log\n attributes = {\n :user => user,\n :is_dismissed => user.last_triage_status,\n :status => user.status,\n :created_by => user.id,\n :updated_by => user.id,\n :description => _message\n }\n TriageAuditLog.create( attributes)\n end\n\n # Wed Nov 3 23:33:00 IST 2010, ramonrails \n # Old logic: \"Installed\" state can only be achieved by manual human action by clicking \"Bill\" in user intake\n # shifted now to user_intake.rb\n # # \n # # Ready for Install > Installed (green) is automatically transitioned\n # # Check for panic button test (must occur after the install date)\n # auto_install = ((user.status == User::STATUS[:install_pending]) && (_time_now > user.desired_installation_date))\n # if auto_install\n # user.status = User::STATUS[:installed]\n # #\n # # explicitly send email to group admins, halouser, caregivers. tables are saved without callbacks\n # [ user,\n # user.user_intakes.collect(&:caregivers),\n # user.user_intakes.collect(&:group).flatten.uniq.collect(&:admins)\n # ].flatten.uniq.each do |_user|\n # UserMailer.deliver_user_installation_alert( _user)\n # end\n # end\n #\n # Wed Nov 3 23:34:26 IST 2010, ramonrails \n # used update_attribute with validation skipping instead\n # user.send(:update_without_callbacks) # quick fix to https://redmine.corp.halomonitor.com/issues/3067\n # \n # Wed Nov 3 23:37:05 IST 2010, ramonrails \n # user is already a member when partial test mode was activated\n # user.is_halouser_of( Group.safety_care!) # user should also be opted in to call center\n end\n #\n # ramonrails: Thu Oct 14 02:05:21 IST 2010\n # return TRUE to continue executing further callbacks, if any\n true\n rescue Exception => e\n # \n # Wed Feb 9 23:16:17 IST 2011, ramonrails\n # * at least send an email about this error\n CriticalMailer.deliver_monitoring_failure( \"Technical exception #{e}\", self)\n true # no matter what, execute critical_device_event_observer.after_save\n end\n end", "def send_user_reminder_notice(user)\n return if user.email.nil?\n return if user.last_reminder.sent_at < one_week_ago\n EmailSender.send_notice_to(user.email)\nend", "def send_activation_email\n UserMailer.account_activation(self).deliver\n end", "def new_user_setup\n self.create_timer\n self.groups.create( {name: self.username})\n g=self.groups.first\n self.wrapper_group=g\n self.promote_in_group g\n cam=Campaign.create({ name: \"My Journey\", description: \"A collection of to-dos and notes that don't fit anywhere else\", group_id: g.id, status: \"Open\"})\n Quest.create({name: \"To Do's\", description: \"Odds and ends that still need to get done\", parent_id: cam.id, campaign_id: cam.id, group_id: g.id, status: \"Open\"})\n Quest.create({name: \"Regular Rituals\", description: \"Frequent chores, repeated tasks, or any other habitual activity\", parent_id: cam.id, campaign_id: cam.id, group_id: g.id, status: \"Open\"})\n q=Quest.create({name: \"Unsorted Musings\", description: \"A place to store those notes that doen't fit elsewhere\", parent_id: cam.id, campaign_id: cam.id, group_id: g.id, status: \"Open\"})\n enc = Encounter.create({ user: self})\n Round.create_event(cam, \"create\", cam, self)\n Round.create_event(q, \"Create\", cam, self)\n self.active_quest=q\n self.save\n self.reload\n Round.create_event(q, \"Create\", cam, self)\n enc.end_time = Time.now.utc\n enc.save\n\n UserConfig.create({\n user_id: self.id,\n auto_timer: true,\n encounter_duration: 25*60,\n short_break_duration: 5*60,\n extended_break_duration: 15*60,\n encounter_extend_duration: 5*60,\n timezone_name: \"US/Eastern\",\n utc_time_offset: -14400\n })\n end", "def send_reminder_email \n UserMailer.reminder_email(self).deliver\n end", "def ensure_freckle_set_up\n case current_user.establish_freckle_connection\n when :field_missing\n flash[:alert] = 'Please set up your Freckle account'\n redirect_to account_settings_path\n when :invalid_email\n flash[:alert] = 'No user found with Freckle email address'\n redirect_to account_settings_path\n when :invalid_api_token\n flash[:alert] = 'Invalid API token'\n redirect_to account_settings_path\n end\n end", "def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end", "def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end", "def send_activation_email\n UserMailer.account_activation(self).deliver_now\n update_attribute(:activation_sent_at, Time.zone.now)\n end", "def fulfilled_without_acceptance\n UserNotifier.deliver_ready(self, user)\n end", "def send_activation_email\n ensure_activation_token_set\n UserMailer.account_activation(self, activation_token).deliver_later unless activated?\n end", "def reminder\n RequestMailer.reminder\n end", "def send_on_create_confirmation_instructions\n Devise::Mailer.delay.confirmation_instructions(self)\n end", "def send_mail_to_associates\n unless self.matter_people.blank?\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end\n end" ]
[ "0.6606731", "0.6575148", "0.6507075", "0.6507047", "0.64802533", "0.6461195", "0.641412", "0.64070123", "0.6403233", "0.640216", "0.6299094", "0.6288094", "0.6287524", "0.6253214", "0.6253214", "0.62082803", "0.62022585", "0.6196795", "0.61901027", "0.61893815", "0.61779714", "0.61744785", "0.61483216", "0.6147788", "0.61412334", "0.6132039", "0.6120595", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.6112639", "0.61016244", "0.61016244", "0.6101189", "0.61002976", "0.6084762", "0.608395", "0.60716736", "0.6044636", "0.6041959", "0.60307753", "0.60265166", "0.60210615", "0.6020644", "0.60092294", "0.6008203", "0.60043037", "0.60029167", "0.59975755", "0.59971523", "0.59944135", "0.59742624", "0.5968439", "0.5967239", "0.5953185", "0.592656", "0.59256995", "0.5923851", "0.5916566", "0.5915758", "0.59127855", "0.5903347", "0.5903134", "0.5901235", "0.59009916", "0.58999014", "0.58999014", "0.5889745", "0.5888138", "0.58826107", "0.5880779", "0.5879947", "0.58774453", "0.5862826", "0.58623534", "0.58594924", "0.5855188", "0.58548754", "0.58548373", "0.58547217", "0.58492935", "0.58481884", "0.58405143", "0.5839337", "0.5838695", "0.5838125", "0.5835925", "0.5835925", "0.58254594", "0.5824028", "0.5823099", "0.58172184", "0.5812507", "0.5812151" ]
0.7663771
0
Get all users project GET /api/projects.json
def index @projects = current_user.projects.order("created_at ASC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def projects\n request(method: 'getAllProjects')\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end", "def all_projects()\n @endpoint = \"/projects.json?limit=100\"\n setup_get\n res = @http.request(@req)\n return JSON.load(res.body)[\"projects\"].sort_by { |proj| proj[\"name\"] }\n end", "def get_projects\n me = request('/services/v5/me')\n me['projects']\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def index\n @user = User.find(current_user.id)\n @projects = @user.projects.all\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def list\n get 'projects'\n end", "def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @user = current_user\n @projects = @user.projects.all\n end", "def index\n @projects = current_user.projects.all\n end", "def index\r\n @projects = current_user.projects\r\n end", "def get_users\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n render json: @project.project_users, 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 project found with id of #{params[:id]}\" }, status: 404\n end\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = current_user.projects\n end", "def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end", "def index\n @user_projects = UserProject.all\n end", "def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def list\r\n @projects = Project.where(user:current_user).order(created_at: :desc).page(params[:page])\r\n respond_with(@projects)\r\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def index\n @projects = Project.where(user_id: @current_user.id)\n end", "def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @userprojects = Userproject.all\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def index\n\t\tif present_user.role? 'admin'\n\t\t\t@projects = Project.all\n\t\telse\n\t\t\t@projects = present_user.projects\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @projects }\n\t\tend\n\tend", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def users_for_a_project\n uri = \"#{@api_url}/#{@project_id}/users?access_token=#{@access_token}\"\n get uri\n end", "def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end", "def index\n\tif @current_user.is_admin?\n\t\t@projects = Project.all\n\telse \n\t\t@projects = @current_user.projects\n\tend\n end", "def index\n\t\t@projects = Project.where(user_id: current_user.id).order(created_at: :asc)\n\tend", "def projects\n @projects ||= begin\n user = api('user')\n api(\"users/#{user['id']}/projects\").sort_by { |p| p['id'] }\n end\nend", "def available_projects_list\n uri = \"#{@api_url}?access_token=#{@access_token}\"\n get uri\n end", "def all\n @projects\n end", "def all\n @projects\n end", "def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end", "def get_projects\n @params=task_params\n @client=current_user.clients.find(@params[:client_id])\n counter=0\n @res=[]\n @client.projects.each do |c|\n if c.users.include? current_user\n @res[counter]={\n project_id: c.id, \n name: c.name\n }\n counter+=1\n end\n end\n respond_to do |format|\n format.json {render json: @res.uniq}\n end\n end", "def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end", "def index\n @project_users = ProjectUser.all\n render json: @project_users\n end", "def show_all_projects\r\n json = GoodData.get GoodData.profile.projects\r\n puts \"You have this project available:\"\r\n json[\"projects\"].map do |project|\r\n pid = project[\"project\"][\"links\"][\"roles\"].to_s\r\n puts \"Project name: #{project[\"project\"][\"meta\"][\"title\"].bright} Project PID: #{pid.match(\"[^\\/]{32}\").to_s.bright}\"\r\n end\r\n end", "def users_projects(user_id, params = {})\n make_get_request(\"/user/#{user_id}/projects\", params)\n end", "def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end", "def index\n @all_projects = Project.by_user_plan_and_tenant(params[:tenant_id], current_user)\n end", "def index\n # @user = User.find(params[:user_id]) \n @projects = current_user.projects\n end", "def get_project_resources\n project = Project.where(id: params[:project_id]).first\n if project\n user_ids = project.project_resources.pluck(:user_id)\n users = User.where(id: user_ids)\n render json: users, status: :ok\n else\n render json: {error: \"Project does not exist\"} , status: :unprocessable_entity\n end\n end", "def index\n @projects = Project.find_all_by_user_id(current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @projects }\n end\n end", "def index\n if(current_user.has_role?(:developer))\n @projects = Project.joins(:developers).where(\"users.id= #{current_user.id}\")\n else\n @projects = Project.all\n end\n render json: @projects\n end", "def projects\n PivotalTracker::Project.all\n end", "def index\n @project_users = ProjectUser.all\n end", "def index\n get_logged_in_user\n @projects = Project.all.select {|project| project.user_id == logged_in_user_id }\n end", "def index\n\t\t@projects = Project.all\n\tend", "def index\n @user = User.find( params[:user_id] )\n\t@user = current_user unless @user || current_user.is_admin?\n @projects = Project.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @projects }\n end\n end", "def index\n\t\trender json: Project.find(params[:project_id]).users.map { |user| user.id }.join(\",\").to_json\n\tend", "def index\n @user = get_user\n @projects = Project.all\n # render :inline => @projects.to_json\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def index()\n @projects = Project.where(:id => Team.select(:project_id).where(user_id: session[:user_id] ).map(&:project_id))\n \n @users = User.all\n end", "def projects\n @projects ||= Harvest::API::Projects.new(credentials)\n end", "def index\n @projects = Project.all\n end", "def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end", "def index\n if current_user.school\n @projects = current_user.school.projects\n elsif current_user.site\n @projects = current_user.site.projects\n else\n @projects = Project.all\n end\n @projects = @projects.order('updated_at DESC', 'id DESC').limit(400)\n end", "def index\n @users = User.all\n if current_user.pivitol_tracker_token != nil\n tracker_api = TrackerAPI.new\n @tracker_projects = tracker_api.projects(current_user.pivitol_tracker_token)\n end\n end", "def index\n @projects = Project.all\n render json: @projects\n end", "def index\n @memberships = Membership.where(user_id: current_user_id).includes(:project)\n project_array = []\n @memberships.each do |membership|\n project_array.push membership.project\n end\n json_response(project_array)\n end", "def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end", "def index\n \t@projects = Project.all\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def index\n @projects = @namespace.projects.all\n end", "def index\n @user = Luser.find(:first, :conditions => {:name => params[:username]})\n @luser_projects = LuserProject.find(:all, :conditions => { :luser_id => @user.id })\n @projects = @luser_projects.map { |l| l.project }\n @user_name = params[:username]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def index\n @project = Project.where(\"id=?\", params[:project_id]).first\n if @project.nil?\n redirect_to \"/\", error: 'Not exist project'\n return\n else\n @project_users = @project.project_users\n end\n end", "def index\n projects = current_user.admin_projects.paginate(:page => params[:page])\n render json: projects\n end", "def index\n authorize Project\n # Only index projects of the current user\n @projects = current_user.projects\n @public_projects = policy_scope(Project)\n @help_context = \"Projects\"\n end", "def get\n CircleCi.request(conf, '/projects').get\n end", "def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def index\n @projects = current_user.active_projects.includes(:project_errors)\n @project_invitations = current_user.user_projects.pending\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects\n resource 'projects'\n end", "def project_users(project_id, params = {})\n make_get_request(\"/projects/#{project_id}/users\", params)\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def index\n if user_signed_in?\n @search = current_user.projects.search(params[:search])\n else\n @search = Project.search(params[:search])\n end\n\n @projects = @search.paginate per_page: 15, page: params[:page],\n order: \"name\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end", "def projects(params = nil)\n params = params.merge({ :current_user => @options[:current_user]})\n params = params.except(:manufacturer_id, :catg_slug, :office_id, :max_matches)\n params[:order] ||= 'recently_active'\n\n @projects_response = ProjectsIndexPresenter.new(params[:current_user], params).response\n projects = @projects_response[:projects] || []\n projects\n end", "def projects(options = {})\n get(\"projects\", options).projects\n end", "def index\n @projects = Project.order_by_company_and_project.paginate(page: params[:page] || 1, per_page: helpers.pager_per_page)\n respond_to do |format|\n message = @projects.present? ? \"\" : \"There are no projects available at this time\"\n format.json do\n status = @projects.present? ? :ok : :not_found\n render json: { response: @projects, status: status, message: message }\n end\n format.html do\n # Only authorize html format, json is okay because we use it as\n # an api.\n authorize(:project)\n flash[:alert] = message unless message.blank?\n @projects\n end\n end\n end", "def index\n respond_with Project.all\n # cookies[:user_id] = current_user.id\n\n end", "def listProjects\n if user_signed_in?\n @project_lists = ProjectStrong.where(user_id: current_user.id)\n end\n end", "def index\n @projects = Project.all\n render json: @projects, layout: false\n end", "def projects\n if is_deploy_key\n [project]\n else\n user.projects\n end\n end", "def index\n @projects = Project.page(params[:page]).per(10)\n end", "def project_users\n request :user\n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end", "def index\n @projects = Project.all\n end" ]
[ "0.8651807", "0.83269894", "0.8294777", "0.81892705", "0.8158667", "0.8060737", "0.8043675", "0.8034202", "0.79545933", "0.7952948", "0.7927512", "0.7914423", "0.79008406", "0.7880019", "0.78759515", "0.78759515", "0.78759515", "0.78759515", "0.78759515", "0.78759515", "0.78759515", "0.78759515", "0.7873863", "0.78677624", "0.78443474", "0.7835531", "0.78021175", "0.7792692", "0.77863765", "0.7785066", "0.77674705", "0.77644897", "0.7717809", "0.7702388", "0.7695178", "0.7676985", "0.76690084", "0.7665414", "0.7651389", "0.7651375", "0.7651375", "0.761969", "0.7619228", "0.7606877", "0.7597671", "0.75925905", "0.7587197", "0.7562888", "0.7554459", "0.75536263", "0.7544607", "0.7540301", "0.7522356", "0.7512072", "0.75012815", "0.7500521", "0.74853224", "0.747354", "0.7460763", "0.7452981", "0.7451281", "0.74472857", "0.74437255", "0.7425712", "0.74246055", "0.74147016", "0.7410229", "0.74046373", "0.73853827", "0.7366564", "0.7363832", "0.7359596", "0.73505133", "0.7347421", "0.73462045", "0.7345294", "0.7342823", "0.7335739", "0.7328492", "0.73238945", "0.7321279", "0.7320968", "0.73098123", "0.73082715", "0.72996294", "0.729719", "0.72925824", "0.7287605", "0.7282455", "0.7282228", "0.7281318", "0.72807723", "0.7277305", "0.7272618", "0.7270488", "0.7269786", "0.7268115", "0.7268115", "0.7268115", "0.7268115" ]
0.7430357
63
Get project GET /api/projects/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n CircleCi.request(conf, '/projects').get\n end", "def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end", "def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def find_project(name)\n get(\"/projects/#{name}\")\n end", "def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end", "def list\n get 'projects'\n end", "def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end", "def project\n request :project\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def details\n get(\"project/details\")[\"project\"]\n end", "def project(project_id)\n resource \"projects/#{project_id}\"\n end", "def projects\n request(method: 'getAllProjects')\n end", "def projects\n resource 'projects'\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end", "def project\n @client.project(:id => project_id)\n end", "def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def get_project(project_id)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Get.new(\"/projects/#{project_id}.json\")\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n @result = false\n return {}\n end\n\n result = JSON.parse(response.body, symbolize_names: true)\n return result\n end", "def show \n project= Project.find(params[:id])\n\n render json: project\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n end", "def getProject(project)\r\n\t\t\t\tproject_json = JSON.parse project\r\n\t\t\t\tproject_array = project_json[\"projects\"]\r\n\t\t\t\treturn jsonToProject(project_array[0])\r\n\t\t\tend", "def project(options = {})\n raise Unfuddled::Error.new(\"No options given for project, cannot query\") if options == {}\n \n raise Unfuddled::Error.new(\"Can only supply one of :id and :name\") if options.keys.include?([:id , :name])\n \n url = \"/api/v1/projects/#{options[:id]}.json\" if options.keys.include?(:id)\n url = \"/api/v1/projects/by_short_name/#{options[:name]}.json\" if options.keys.include?(:name)\n\n Unfuddled::Project.from_response( send(:get , url)[:body] , self)\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end", "def get_project_by_id(id)\n require_relative 'telerivet/project'\n Project.new(self, self.do_request(\"GET\", get_base_api_path() + \"/projects/#{id}\"))\n end", "def project(options = {})\n options = {project_id: options} if options.is_a?(String)\n project_id = options.fetch(:project_id, @project_id)\n options[:query] = {project_id: project_id}\n resp = get Project.path(project_id), options\n Bim360::Project.new(resp)\n # objects_from_response(resp, Bim360::Project)\n end", "def get_projects\n me = request('/services/v5/me')\n me['projects']\n end", "def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end", "def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end", "def get_project\n @project ||= Project.find(params[:project_id])\n end", "def show\n @project = Project.find_by(id: params[:id])\n if @project\n render :json => @project\n else\n render :json => 422\n end\n end", "def getProject(projectName)\n data = CLIENT.repository(projectName)\n return data\nend", "def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectsApi.get_projects ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Token']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Projects')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n @project = Project.find(params[:id])\n end", "def show\n render json: Project.where(id: params.fetch(:id))\n end", "def show\n @current_project = CurrentProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_project }\n end\n end", "def find_project(name)\n login unless authenticated?\n response = RestClient.get(resource_url(\"projects/#{URI.escape(name)}\"), :cookies => @cookies)\n project = JSON.parse response.body\n return project['name'] == name ? project : nil\n rescue RestClient::ResourceNotFound\n return nil\n end", "def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end", "def get_project_with_http_info(name, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_project ...'\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling ProjectApi.get_project\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling ProjectApi.get_project\"\n end\n # resource path\n local_var_path = '/v1/project/lookup'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'name'] = name\n query_params[:'version'] = version\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[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Project' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @project = Project.find(params[:project_id])\n end", "def show\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get_project_with_http_info(project_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectsApi.get_project ...'\n end\n # verify the required parameter 'project_key' is set\n if @api_client.config.client_side_validation && project_key.nil?\n fail ArgumentError, \"Missing the required parameter 'project_key' when calling ProjectsApi.get_project\"\n end\n # resource path\n local_var_path = '/projects/{projectKey}'.sub('{' + 'projectKey' + '}', project_key.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Token']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Project')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#get_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def projects(params = {})\n fetch_all('projects', 'projects', params)\n end", "def show\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n render json: Project.build_project_object(@project, 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 project found with id of #{params[:id]}\" }, status: 404\n end\n end", "def project_info(project_key)\n request = ServiceHelper.new base_url: @jira_url, path: \"rest/api/3/project\"\n request.auth 'basic', @jira_user, @jira_token\n request.headers.add 'Accept', 'application/json'\n request.append_to_route project_key\n response = request.get\n raise Exception, response.body unless response.ok?\n\n response.parsed_body\n end", "def show\n @show_project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @show_project }\n end\n end", "def show\n if @project\n render json: @project, status: :ok\n else\n render json: {error: \"Project does not exist\"} , status: :unprocessable_entity\n end\n end", "def get_projects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_projects ...'\n end\n # resource path\n local_var_path = '/v1/project'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'excludeInactive'] = opts[:'exclude_inactive'] if !opts[:'exclude_inactive'].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[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Project>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_projects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @projectresource = Projectresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projectresource }\n end\n end", "def show\n render json: @project\n end", "def list_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'ListProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :project_owner\n\t\t\targs[:query]['ProjectOwner'] = optional[:project_owner]\n\t\tend\n\t\tself.run(args)\n\tend", "def show\n @ourproject = Ourproject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ourproject }\n end\n end", "def show\n @projects = find_projects\n end", "def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end", "def get_project(id)\n project = new(get(\"/rest/api/2/project/#{id}\"))\n @@project_cache[project.name] = project\n @@project_cache[project.id] = project\n @@project_cache[project.key] = project\n return project\n end", "def project(id)\n self.projects(\"all\").detect { |p| p.id == id }\n end", "def fetch_project(key)\n client.Project.find(key)\n rescue\n log.error('JIRA HTTPError')\n nil\n end", "def show\n respond_with(@project) do |format|\n format.json { render json: @project.as_json }\n format.html\n end\n end", "def project(project_id = nil)\n account = Config.details \n c = FreshBooks::Client.new(account[\"account\"], account[\"token\"])\n if project_id.nil?\n c.project.list[\"projects\"]\n else\n c.project.get :project_id => project_id\n end\n end", "def show\n @project = Project.find(params[:id])\n\t@user = User.find(@project.user_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def get_project1_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_project1 ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling ProjectApi.get_project1\"\n end\n # resource path\n local_var_path = '/v1/project/{uuid}'.sub('{' + 'uuid' + '}', CGI.escape(uuid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Project' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_project1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n set_surrogate_key_header \"api/platforms/#{@platform.id}/projects\"\n set_cache_control_headers 3600\n end", "def get_project_with_http_info(project_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_project ...'\n end\n # verify the required parameter 'project_id' is set\n if @api_client.config.client_side_validation && project_id.nil?\n fail ArgumentError, \"Missing the required parameter 'project_id' when calling ProjectApi.get_project\"\n end\n # resource path\n local_var_path = '/projects/{project_id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\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] || 'Project'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.get_project\",\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: ProjectApi#get_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show \n render :json => Project.find_by_id(params[:id])\n end", "def get(name)\n path = \"/projects/#{project.name}/resources/#{name}\"\n resp = client.get(path)\n build_resource(resp)\n end", "def index\n @projects = Project.all\n render json: @projects, status: :ok\n end", "def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html\n end\n end", "def find_project\n @project = Project.find(params[:id])\n end", "def show_by_gitpath\n @project = Project.includes(:users).includes(:technos).find_by_gitpath(params[:gitpath])\n\n respond_to do |format|\n format.json { render json: @project, status: 200 }\n end\n end", "def projects\n records \"project\", \"/project/list\"\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end", "def project\n @project ||= Attask::API::Project.new(@credentials)\n end" ]
[ "0.81674176", "0.80733174", "0.8039097", "0.7970646", "0.7956753", "0.7956753", "0.7943712", "0.7905961", "0.7896075", "0.78843266", "0.7835149", "0.7788574", "0.7781394", "0.7748255", "0.77458256", "0.77359885", "0.7729073", "0.7715742", "0.7655781", "0.76465195", "0.7607879", "0.75969315", "0.75677776", "0.7536307", "0.7535608", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.7506257", "0.749994", "0.7499891", "0.74966544", "0.74821955", "0.7426285", "0.7420611", "0.7420611", "0.74200493", "0.740543", "0.7400273", "0.7397723", "0.73542213", "0.73404324", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.7330872", "0.73185253", "0.7303511", "0.7284003", "0.7278441", "0.7277002", "0.72642684", "0.7238345", "0.7238003", "0.72321033", "0.72218263", "0.72143656", "0.71964705", "0.71919113", "0.7190994", "0.71897084", "0.7188455", "0.71861005", "0.7184135", "0.7180792", "0.7170915", "0.7170068", "0.7165627", "0.7162329", "0.7144854", "0.71432716", "0.7137896", "0.7123334", "0.7115459", "0.7114806", "0.70871806", "0.7086925", "0.7079347", "0.7077307", "0.70765436", "0.7075788", "0.7069347", "0.706807", "0.70666414", "0.70628774" ]
0.0
-1
Create project POST /api/projects.json
def create @project = current_user.projects.new(project_params) respond_to do |format| if @project.save format.json { render :show, status: :created } else format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_project(name)\n post('projects', {:name => name})[\"project\"]\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: :created\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def create\n @api_project = Project.new(api_project_params)\n\n respond_to do |format|\n if @api_project.save\n format.html { redirect_to @api_project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @api_project }\n else\n format.html { render :new }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: :created, location: @project }\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project] || JSON.parse(request.body.read))\n\n if (params[:id])\n @project.id = params[:id]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n format.json { render :json => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n format.json { render :text => \"error creating project via http/json\" }\n end\n end\n end", "def create_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'CreateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tself.run(args)\n\tend", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.json { render :json => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: t('models.project.create') }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attributes={})\n raw_response = post_request('projects', project: attributes)\n parse_response(raw_response, :project)\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render action: 'show', status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #byebug\n @project = Project.new(create_params)\n @project.user_id = @current_user.id\n @project.save\n #@project = Project.create(name_project: \"prueba\", subsidy: true, parking: true, user_id: @current_user.id)\n #byebug\n render json: @project, status: :created\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, flash: {success: 'Project was successfully created.'} }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.create(project_params)\n if @project.errors.blank?\n flash[:success] = t('controllers.projects.create.success', project: @project.name)\n else\n flash.now[:alert] = @project.errors.full_messages.unshift(t('controllers.projects.create.failure'))\n end\n respond_with @project, location: projects_url\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to admin_projects_url, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_project(params)\n elektron_identity.post(\"projects\") { { project: params } }.body[\n \"project\"\n ]\n end", "def create\n @project = current_user.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@project = Project.new(project_params)\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.html { redirect_to projects_url, notice: 'Project was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @project }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n respond_to do |format|\n if project.save\n format.html { redirect_to project, notice: 'Project was successfully created.' }\n format.json { render json: project, status: ':created', location: project }\n else\n format.html { render action: 'new' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n if @project.save\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n end", "def create\n @project = Project.new(project_params)\n \n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n \n if @project.save\n flash[:success] = \"Project created\" \n redirect_to projects_url\n else\n flash[:danger] = \"Cannot create project\"\n render 'new'\n end\n end", "def create\n @user = current_user\n @project = @user.projects.build(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @create_project = current_user.projects.build(params[:project])\n flash[:notice] = \"Project #{@create_project.description} successfully created\" if @create_project.save\n respond_with(@create_project, layout: !request.xhr?)\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n flash[:alert] = \"Project created successfully.\"\n format.html { redirect_back(fallback_location: root_path) }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.create(params[:project])\n \n if @project.save\n record_activity(\"created new project: \" + @project.id.to_s)\n redirect_to root_path, :notice => \"Project created successfully\"\n else\n render 'new'\n end\n end", "def create_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\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? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tself.run(args)\n\tend", "def create\n @project = Project.new(project_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @project.save\n format.json { render :show, status: :created, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_project(key, name, params = {})\n params[:key] = key\n params[:name] = name\n post('projects', params)\n end", "def create\n # authenticate_user!\n @project = Project.new\n @project[:category] = params[:category]\n @project[:title] = params[:title]\n @project[:body] = params[:body]\n @project[:location] = params[:location]\n @project[:image_link] = params[:image_link]\n @project[:project_url] = params[:project_url]\n @project[:year] = params[:year]\n @project[:likes] = params[:likes]\n @project.save\n\n render json: @project\n end", "def create\n @project = Project.new(params[:project])\n\n if @project.save\n flash[:notice] = t('projects.create.notice')\n redirect_to projects_path\n else\n render :action => \"new\"\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html {redirect_to \"/projects\", notice: \"Project was successfully created.\"}\n format.json {render :show, status: :created, location: @project}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @project.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n build_projects_user\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_project_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.create_project ...'\n end\n # resource path\n local_var_path = '/projects'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_project_body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'Project'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.create_project\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#create_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @project = Project.new(project_params)\n authorize! :create, @project\n @project.user_id ||= current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user = current_user\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n\t\t@project = Project.new(project_params)\n\t\t@project.creator = current_user.id\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\t\t@project.user_id =current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n begin\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n @project.destroy\n respond_to do |format|\n format.html { render :new }\n format.json { render json: e.as_json, status: :service_unavailable }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = @user.id\n if @project.save\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def create_project(project)\n create_or_update(project, nil, 'project', 'projects')\n end", "def create\n @project = current_user.projects.build(params[:project])\n if @project.save\n flash[:success] = \"Project was successfully created.\"\n redirect_to root_path\n else\n flash[:error] = \"Failed to make project.\"\n render 'new'\n end\n end", "def create\n @project = Project.new(project_params)\n @new_task = Task.new\n\n unless @project.save\n head :unprocessable_entity\n end\n end", "def create_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"createproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to [:user, @project], notice: 'Project temp was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n flash[:notice] = 'Project was successfully created.'\n format.html { redirect_to(project_path(@project)) }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to root_path, notice: 'Enhorabuena! Tienes un nuevo proyecto. A trabajar!' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(client_projects_url(@client), notice: 'Project was successfully created.') }\n format.xml { render xml: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.owner = current_user unless @project.owner\n if @project.save\n render :show, status: :created, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@project = Project.new(params[:project].merge({:user_id => present_user.id}))\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.created') }\n\t\t\t\tformat.json { render json: @project, status: :created, location: @project }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @project.save\n flash[:success] = 'Project was saved!'\n redirect_to root_path\n else\n render 'new'\n end\n end", "def create\n @project = Project.new(project_params)\n flash[:notice] = 'Project was successfully created.' if @project.save\n respond_with @project\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n flash[:notice] = 'Project was successfully created.'\n format.html { redirect_to(@project) }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n flash[:notice] = 'Project was successfully created.'\n format.html { redirect_to(@project) }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project = @client.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @client, notice: 'Project was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(project_params)\n\n render text: params[:project].inspect\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Proyecto creado sastifactoriamente' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n flash[:notice] = 'Project was successfully created.'\n format.html { redirect_to project_url(@project) }\n format.xml { head :created, :location => admin_project_url(@project) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors.to_xml }\n end\n end\n end", "def create\n @project = current_user.projects.new(project_params)\n if @project.save\n render :show\n else\n render json: { errors: @project.errors }\n end\n end", "def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: projects_path }\n else\n @companies = Company.none\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.8449553", "0.8404636", "0.83733124", "0.8357639", "0.8272967", "0.82667786", "0.82585603", "0.823478", "0.82323015", "0.8198822", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81782615", "0.81720364", "0.8132161", "0.81225264", "0.811752", "0.8104345", "0.8101151", "0.80905634", "0.80787873", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.80729145", "0.8070121", "0.8069911", "0.8069374", "0.80643034", "0.8064173", "0.8046998", "0.8024052", "0.80067635", "0.7963519", "0.7961013", "0.7953709", "0.7947822", "0.7934865", "0.7928899", "0.7922927", "0.79094046", "0.7894136", "0.7892441", "0.7873311", "0.7854141", "0.78531796", "0.7848141", "0.783149", "0.7830362", "0.78227013", "0.7807522", "0.7763383", "0.7754391", "0.77535737", "0.7751028", "0.77491415", "0.77443796", "0.7729653", "0.7714668", "0.7713108", "0.7711532", "0.77105075", "0.77045774", "0.77032536", "0.77032536", "0.77032536", "0.76989037", "0.7685049", "0.76621664", "0.76509565", "0.76458997", "0.76454794", "0.76359314", "0.7632363", "0.76317036", "0.76317036", "0.76315963", "0.76254225", "0.76254225", "0.76211417", "0.76187307", "0.7604542", "0.7599626" ]
0.8036626
48
Update selected project PATCH/PUT /api/projects/1.json
def update respond_to do |format| if @project.update(project_params) format.json { render :show, status: :ok } else format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @project.update(project_params)\n render :show, status: :ok, location: api_v1_project_url(@project)\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\n render 'projects/error', status: 422\n end\n end", "def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\n if @project.update(project_params)\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = current_user.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, :notice => 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_project.update(api_project_params)\n format.html { redirect_to @api_project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_project }\n else\n format.html { render :edit }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n if params[:name] == \"project_name\"\n project_name = params[:value]\n @project.project_name = project_name\n end\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n\n @projects = Project.all\n format.html {\n render :action => \"index\"\n }\n format.json { render json: @project }\n else\n logMessage = self.class.to_s + \"#\" + __method__.to_s + \" \" + current_user.username + \" errors:\" + @project.errors.full_messages.to_s\n logger.info logMessage\n\n format.html {\n flash[:error] = 'Project was not successfully updated.'\n redirect_to action: \"index\"\n }\n errorMsg = @project.errors.full_messages.to_s.split(\"\\\"\")\n format.json { render json: errorMsg[1], status: 500 }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@project = Project.find(params[:id])\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @project.update_attributes(params[:project])\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.updated') }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @edit_project = Project.find(params[:id])\n\n respond_to do |format|\n if @edit_project.update_attributes(params[:project])\n format.html { redirect_to @edit_project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @edit_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n if @project.update(project_params)\n render :show, status: :ok, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end", "def update\n authenticate_user!\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render :show, status: :ok, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = current_user.active_projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to admin_path, notice: 'Project was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @project = @client.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to([@client, @project], notice: 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if project.update(project_params)\n format.html { redirect_to project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end", "def update\n project = Project.find(params[:id])\n\n respond_to do |format|\n if project and project.update_attributes(params[:project])\n format.html { redirect_to project }\n else\n format.html { redirect_to projects_path }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_project\n\t\t@project = Project.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @project.update_attributes(project_update_params)\n\t\t format.html { redirect_to(@project, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@project) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@project) }\n\t\t end\n\n \t end\n\tend", "def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\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? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\t\t\t\t\t\t\t\t\t# Actually modifies the data and redirects (probably to index or show? depends)\n\t\t#@project = Project.find(params[:id])\t# Taken out because of the before action GENIUS!\n\n\t\trespond_to do |format|\n \t\t if @project.update(projects_params)\n \t\tformat.html { redirect_to @project, notice: 'Project was successfully updated.' }\n \t\tformat.json { render :show, status: :ok, location: @project }\n \t\telse\n \t\tformat.html { render :edit }\n \t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend", "def update\n @project = Project.find_by_slug(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to add_path(@project), notice: 'Project was successfully updated.' }\n format.json { render :add, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: projects_path }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :edit, @project\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n handle_params_categories\n add_http_if_necessary\n\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project.update(project_params)\n redirect_to root_path\n else\n render \"edit\"\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to user_projects_path(current_user), notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n \t\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.8239176", "0.81822395", "0.814375", "0.8133785", "0.81273574", "0.80790484", "0.80762637", "0.80606025", "0.80606025", "0.80540913", "0.80533713", "0.80533713", "0.80533713", "0.80533713", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.80482584", "0.8043912", "0.8012539", "0.8009487", "0.8008062", "0.80054504", "0.80054504", "0.8002737", "0.8002737", "0.8000376", "0.799616", "0.7981146", "0.7980185", "0.7980185", "0.795372", "0.7933116", "0.7920422", "0.79191214", "0.79052246", "0.78877616", "0.78529996", "0.7836882", "0.7836", "0.7827427", "0.78196114", "0.78134984", "0.7809936", "0.78078645", "0.7804766", "0.7804766", "0.78008574", "0.7782707", "0.7781433", "0.7773228", "0.7766044", "0.776333", "0.776333", "0.7761092", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187", "0.7759187" ]
0.79767334
41
Remove selected project DELETE /api/projects/1.json
def destroy @project.destroy respond_to do |format| format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delproject(project)\n post('delproject.json', project: project)\n end", "def destroy\n @project = Project.find(params[:id])\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n end", "def destroy\n @project.destroy\n\n head :no_content\n end", "def destroy\n @project = @user.projects.find(params[:id])\n @project.remove!\n\n respond_to do |format|\n format.html { redirect_to(projects_url(:subdomain => @user.subdomain)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @project = current_user.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = current_user.active_projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def delete_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'DELETE'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'DeleteProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def destroy\n @project.destroy\n head :no_content\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.json { head :ok }\n end\n end", "def destroy\n\t\t@project = Project.find(params[:id])\n\t\t@project.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to projects_url }\n\t\t\tformat.json { head :ok }\n\t\tend\n\tend", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_projects_path }\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n project = Project.find(params[:id])\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n # @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.delete\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n render json: {message: 'Projeto Excluido'}, status: :ok\n end", "def backend_deleteProject(param) \n @Projects.delete(param) if @Projects.include? param \n end", "def destroy\n @project = Admin::Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n redirect_to(projects_url)\n end", "def destroy\n standard_destroy(Project, params[:id])\n end", "def destroy\n authorize! :destroy, @project\n @project.destroy\n\n head :no_content\n end", "def delete_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DeleteProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\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? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def destroy\n @current_project = CurrentProject.find(params[:id])\n @current_project.destroy\n\n respond_to do |format|\n format.html { redirect_to current_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.status = 'deleted'\n @project.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end", "def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"deleteproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy \n @project = Project.find(params[:id])\n @project.destroy\n redirect_to root_url\n end", "def delete\r\n\t\t\trender json: Project.delete_by_id(params[:id])\r\n\t\tend", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n @project.users.delete_all\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_project.destroy\n respond_to do |format|\n format.html { redirect_to api_projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_path, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@project = Project.find(params[:id])\n \t#ap @project\n \t#abort\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n # Se busca el proyecto por el id\n @project = Project.find(params[:id])\n # Se destruye\n @project.destroy\n redirect_to projects_url\n end", "def _project_delete(acronym)\n delete \"/projects/#{acronym}\"\n _response_status(204, last_response)\n end", "def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @ourproject = Ourproject.find(params[:id])\n @ourproject.destroy\n\n respond_to do |format|\n format.html { redirect_to ourprojects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project.destroy\n end", "def destroy\n @project.destroy\n end", "def destroy\n @project.destroy\n end", "def destroy\n @project.destroy\n end", "def destroy\n @project.destroy\n end", "def delete_project(id)\n elektron_identity.delete(\"projects/#{id}\")\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authenticate_user!\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = @user.project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project.destroy_all\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'The project was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find params[:id]\n @project.destroy\n redirect_to projects_path, notice: 'The project was deleted'\n end", "def destroy\r\n @project.destroy\r\n respond_to do |format|\r\n format.html { redirect_to projects_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @project = @client.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to @client }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project has been successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @project\n @project.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: t('models.project.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.xml { head :ok }\n end\n end", "def destroy\t\t\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Successfully deleted project.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @new_nav = true;\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to project_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to user_projects_path(current_user), notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.active = false\n @project.save\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.8279231", "0.8141084", "0.81074184", "0.80811274", "0.80683035", "0.8063254", "0.8060939", "0.8051967", "0.8040429", "0.8040429", "0.8040429", "0.8040429", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.803842", "0.80374694", "0.8031763", "0.80129206", "0.80073535", "0.8002349", "0.8000685", "0.7989665", "0.79796827", "0.7979598", "0.7952491", "0.79425836", "0.7942569", "0.7929723", "0.79255486", "0.79177177", "0.7916307", "0.7906024", "0.7905496", "0.7905342", "0.79021335", "0.7895396", "0.7892022", "0.7891576", "0.7891576", "0.7891576", "0.7891576", "0.7891576", "0.7886724", "0.7884914", "0.78845733", "0.78835267", "0.78819966", "0.78763354", "0.78668195", "0.7866654", "0.78628635", "0.78606516", "0.78551036", "0.78488064", "0.7846929", "0.7846929", "0.7846929", "0.7846929", "0.7846929", "0.78462356", "0.7845967", "0.7831132", "0.78081495", "0.7807735", "0.7803675", "0.7802332", "0.7800843", "0.7800115", "0.7796391", "0.77906096", "0.77905077", "0.7788392", "0.7782226", "0.7777468", "0.7773901", "0.77708817", "0.7760073", "0.77586305", "0.77586305", "0.77586305", "0.77586305" ]
0.8092468
3
Use callbacks to share common setup or constraints between actions.
def set_project @project = current_user.projects.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 set_actions\n actions :all\n end", "def define_action_helpers?; 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 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 before_action \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 after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; 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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); 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", "def duas1(action)\n action.call\n action.call\nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def call\n setup_context\n super\n end" ]
[ "0.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", "0.5312988", "0.529798", "0.52968603", "0.52962637", "0.52577317", "0.5244704", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5236856", "0.5233461", "0.52322435", "0.5227552", "0.52224743", "0.5217851", "0.521241", "0.52069896", "0.5206555", "0.5176617", "0.51738507", "0.51725876", "0.51660734", "0.51605034", "0.51571786", "0.5152762", "0.5152164", "0.5151477", "0.5145819", "0.51408994", "0.5134412", "0.5114031", "0.5113695", "0.5113695", "0.5108603", "0.5107358", "0.5090405", "0.50889385", "0.50817686", "0.5081617", "0.50658226", "0.50551206", "0.5051746", "0.5049091", "0.5049091", "0.5034681", "0.5024972", "0.5021291", "0.5016024", "0.50134826", "0.50008893", "0.50000244", "0.4999155", "0.49907947", "0.49907947", "0.49853387", "0.49796683", "0.4979596", "0.49778128", "0.49673793", "0.49662578", "0.49587822", "0.4956063", "0.49550167", "0.49523485", "0.4951614", "0.49452996", "0.49442068", "0.49336892", "0.49306205", "0.49264124", "0.49259305", "0.4925823", "0.49229056", "0.4918999", "0.49171805", "0.49167436", "0.4916559", "0.49153692", "0.49148256" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def project_params params.require(:project).permit(:name) 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 valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 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 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 filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.6292164", "0.62917984", "0.62836355", "0.6242686", "0.6241917", "0.62210834", "0.6214862", "0.62125784", "0.619428", "0.617912", "0.617705", "0.61735916", "0.6163706", "0.61532795", "0.6152666", "0.6148062", "0.6123372", "0.61180484", "0.61088324", "0.6106139", "0.60925204", "0.608326", "0.60711503", "0.606551", "0.60216546", "0.6018924", "0.6015004", "0.60106766", "0.6008301", "0.6008301", "0.60028726", "0.60020626", "0.5999236", "0.59931505", "0.5993037", "0.59917194", "0.5982164", "0.5968051", "0.5960277", "0.5960268", "0.5960012", "0.59594494", "0.5954652", "0.5954304", "0.59440255", "0.59404963", "0.59404963", "0.59401006", "0.593522", "0.5932182", "0.5925528", "0.5924541", "0.5918796", "0.59123147", "0.5910144", "0.5909186", "0.5907257", "0.5899382", "0.5897783", "0.58972496", "0.58958495", "0.58948576", "0.5892734", "0.5888056", "0.58843875", "0.58818483", "0.5873746", "0.58700997", "0.5870056", "0.5869255", "0.58668107", "0.58662325", "0.5865003", "0.5862908", "0.5862406", "0.58614665", "0.5859661", "0.585562", "0.5855185", "0.58523446", "0.58504915" ]
0.0
-1
Returns the current status of the state. This includes: Player status Room description Room's treasure Room's monster
def status output = StringIO.new output << @game.player.to_s output << "\n" output << "#{@game.current_room_model.description}\n" treasure = @game.current_room_model.treasure output << "\nThere is treasure here worth $#{treasure}.\n" if treasure && treasure > 0 monster = @game.current_room_model.monster if monster output << "\nDANGER... THERE IS A MONSTER HERE....\n\n" output << "#{@game.current_room_model.monster}\n\n" end if @game.current_room_model.name != "Exit" output << "\nWhat do you want to do? " end output.string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n monster = @game.current_room_model.monster\n return unless monster\n\n weapons = @game.player.weapons\n\n output = \"Fighting against #{monster.name}\\n\"\n weapons.each_with_index do |weapon, i|\n output << \"#{i + 1} - #{weapon}\\n\"\n end\n\n output\n end", "def current_status\n case status\n when NOT_STARTED\n return 'Game not started yet'.freeze\n when RUNNING\n return 'Game is running'.freeze\n when WIN\n return 'Game is won'.freeze\n when DRAWN\n return 'Game is drawn'.freeze\n when ABANDONED\n return 'Game is abandoned'.freeze\n end\n end", "def status\n return STATUSES[:hidden] unless hit\n return STATUSES[:water] unless occupied?\n boat.sunk? ? STATUSES[:sunk] : STATUSES[:hit]\n end", "def state\n status[\"state\"]\n end", "def status\n puts \"Player #{@playerNo}\".center(60)\n puts \"Name: #{@name}\".center(60)\n puts \"Class: #{@fightClass[:name]}\".center(60)\n puts \"Race: #{@race[:name]}\".center(60)\n puts \"HP: #{@hp}\".center(60)\n puts \"Level: #{@level}\".center(60)\n puts \"Actions: #{@actions.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Attacks: #{@attacks.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Inventory: #{@inventory.join(', ')}\".center(60)\n puts \"\"\n end", "def get_status\n return @player_status\n end", "def status\n STATUSES[self.status_id]\n end", "def status\n stat = Hash.new(\"Empty!\")\n stat[:name] = @name\n stat[:level] = @level\n stat[:hp_cur] = @cur_health\n stat[:hp_max] = @max_health\n stat[:str] = @strength\n stat[:exp_cur] = @cur_exp\n stat[:exp_max] = @max_exp\n\n return stat\n\n #\"Name: #{@name}\\n\" +\n #\"Level: #{@level}\\n\" +\n #\"Health: #{@cur_health}/#{@max_health}\\n\" +\n #\"Strength: #{@strength}\"\n end", "def current_status\n return status if [:finished, :failed].include? status\n if address&.start_with?(\"0x\")\n state = HacksContract::Hackathon.new(address).state\n s = case state\n when 0\n :preparation\n when 1\n :crow_funding\n when 2\n :apply_participation\n when 3\n :gaming\n when 4\n :voting\n when 5\n :finished\n else\n :failed\n end\n else\n current = Time.now\n s = if current < crow_funding_start_at\n :preparation\n elsif current < apply_start_at\n :crow_funding\n elsif current < game_start_at\n :apply_participation\n elsif current < vote_start_at\n :gaming\n elsif current < finished_at\n :voting\n else\n :finished\n end\n end\n\n if s != status\n update_column(:status, s)\n end\n s\n end", "def status\n return 'Appealed' if self.punishment.appealed?\n return 'Closed' if !self.open || self.locked\n return 'Escalated' if self.escalated\n return 'Open'\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n @status ||= STATUS[mapping_for(:status)]\n end", "def status\n STATUSES[self.status_id || 0]\n end", "def get_status()\n\n puts \"Rounds: #{@rounds}\"\n puts \"Player wins: #{@player_wins}\"\n puts \"Computer wins: #{@computer_wins}\"\n puts \"Ties: #{@ties}\\n\\n\"\n \n\n end", "def get_status\n return @m_status\n end", "def state\n status.state name\n end", "def status\n info['status']\n end", "def status\n info[\"Status\"]\n end", "def status\n @status\n end", "def status\n @status\n end", "def get_status\n\t\tstatus\n\tend", "def status\n result = \"online\"\n if Current.room.ready? && Current.room.poker_records.find_by(user_id: object.id).present?\n result += \" played\"\n end\n result\n end", "def status\n @status\n end", "def status\n @status\n end", "def status\n output = \"\"\n player = @game.player\n output << \"You won!! you have scaped with life from the castle!!! \"\n output << \"WELL DONE!!\"\n end", "def status\n short_state_str=SHORT_VM_STATES[state_str]\n\n if short_state_str=='actv'\n short_state_str=SHORT_LCM_STATES[lcm_state_str]\n end\n\n short_state_str\n end", "def status\n short_state_str=SHORT_VM_STATES[state_str]\n\n if short_state_str==\"actv\"\n short_state_str=SHORT_LCM_STATES[lcm_state_str]\n end\n\n short_state_str\n end", "def status\n Status.find(self.status_id).name\n end", "def status\n\t\treturn @status\n\tend", "def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend", "def status\n return I18n.t('activerecord.attributes.item.building') if rq_prod_point > built_point\n if mob.blank?\n return I18n.t('activerecord.attributes.item.not_equiped')\n else\n return mob.name + I18n.t('activerecord.attributes.item.equiping')\n end\n end", "def status\n if status_code.present?\n if status_code['HL7 ActStatus']\n status_code['HL7 ActStatus'].first()\n elsif status_code['SNOMED-CT']\n case status_code['SNOMED-CT'].first()\n when '55561003'\n 'active'\n when '73425007'\n 'inactive'\n when '413322009' \n 'resolved'\n end\n end\n end\n end", "def show_status\r\n puts \"Status for room #{id}:\"\r\n if @contents.empty?\r\n puts \" The room is empty.\"\r\n else\r\n puts \" Contents: #{sorted_contents.join(', ')}\"\r\n end\r\n if @exits.empty?\r\n puts \" No exits.\"\r\n else\r\n doors = []\r\n doors << 'north' if @exits[:north]\r\n doors << 'south' if @exits[:south]\r\n doors << 'east' if @exits[:east]\r\n doors << 'west' if @exits[:west]\r\n puts \" There are exits to the #{doors.join(', ')}.\"\r\n end\r\n end", "def get_Status()\n \t return @outputs[\"Status\"]\n \tend", "def state\n @game.state\n end", "def player_state\n @ole.PlayerState\n end", "def getStatus\n @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def getStatus\n @@statuses[@status]\n end", "def state\n @gameState.state\n end", "def status\n inspect\n end", "def status\n get_json('status.json')\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n @attributes[:status]\n end", "def status\n instance_get(:status)\n end", "def status\n value_for('status')\n end", "def status\n case @status\n when 0 then :off\n when 1 then :on\n end\n end", "def get_current_game_state(lobby_id)\n find_lobby(lobby_id).game_state\n end", "def status\n \"#{@description} #{@status}\"\n end", "def status\n data[:status]\n end", "def status\n return :code => info[:statuscode].to_i, :messages => info[:messages]\n end", "def current_status\n status ? 'Active' : 'Inactive'\n end", "def status(player_id)\n load_data unless @data_loaded\n\n if @player.id == player_id\n YOU\n elsif @alliance_player_ids.include?(player_id)\n ALLY\n elsif @nap_player_ids.include?(player_id)\n NAP\n elsif player_id.nil?\n NPC\n else\n ENEMY\n end\n end", "def status_info\n current_path = '/api/v1/status'\n @conn.get(current_path)\n end", "def status_object\n @status\n end", "def outcome\n status.first\n end", "def do_status\n return pretty_status(current_status)\n end", "def player_status(player)\n return \"Draw\" if draw?\n player.id == winner_id ? \"Won\" : \"Lost\"\n end", "def status\n data.status\n end", "def status()\r\n\t\treturn to_s() + \", #{total_guess_count()} guesses (#{bad_guess_count()} bad), won? #{won?}, lost? #{lost?}\"\r\n\tend", "def state()\n info[:state]\n end", "def status\n STATUSES[code] || 'Unknown'\n end", "def status_text\n case @state\n when 0\n H87Enchant::ST1\n when 1\n H87Enchant::ST2\n when 2\n H87Enchant::STQ\n when 3\n H87Enchant::ST3\n when 4\n H87Enchant::ST4\n when 5\n H87Enchant::ST5\n else\n ; 'ERRORE 01'\n end\n end", "def status\n @__status\n end", "def state\n info[:state]\n end", "def status\n \"#{@name}: #{@lives}/3 \"\n end", "def get_game_state\n @game_state\n end", "def status\n status = \"\"\n if points < 4000\n status = \"Baby Seeder\"\n elsif points < 8000\n status = \"Aspiring Gardener\"\n elsif points < 15000\n status = \"Garden Hero\"\n else\n status = \"Plant Wizard\"\n end\n end", "def status\n o = @api.status\n OpenStruct.new o\n end", "def state\n self.well_info.state\n end", "def status\n @status ||= status_line.split(/: /)\n end", "def game_status\n puts\n game_status_str = @game_status.join(' ')\n puts game_status_str\n end", "def status\n @object.status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end" ]
[ "0.7418323", "0.7196079", "0.71288174", "0.695458", "0.6867524", "0.6855135", "0.68458354", "0.67172885", "0.6707165", "0.6702644", "0.6693608", "0.6693608", "0.6685253", "0.66622025", "0.6658545", "0.66447294", "0.65976554", "0.6577174", "0.6545302", "0.6545302", "0.6540487", "0.6514976", "0.6511043", "0.6511043", "0.64828134", "0.6470015", "0.64640254", "0.6462621", "0.6439961", "0.6416526", "0.64022577", "0.6390334", "0.6384339", "0.6373691", "0.6364677", "0.6357669", "0.6352121", "0.6344733", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.634444", "0.63417494", "0.63350755", "0.6331741", "0.6318504", "0.62981564", "0.62981564", "0.62981564", "0.62981564", "0.6274818", "0.625272", "0.6250227", "0.6227307", "0.62180847", "0.62179375", "0.620924", "0.61997294", "0.6191325", "0.6191268", "0.61856717", "0.61738884", "0.61553586", "0.61552805", "0.6154856", "0.6151032", "0.61420935", "0.6141264", "0.61263794", "0.6123614", "0.6117818", "0.61112833", "0.6104306", "0.6098923", "0.60941255", "0.60869473", "0.60842645", "0.60770357", "0.60737", "0.6073375", "0.6073375" ]
0.7400184
1
Handles a command for this state. +command+ must be a symbol Possible commands: :north : Moves you to north :south : Moves you to south :east : Moves you to east :west : Moves you to west :up : Moves you to up :down : Moves you to down :tally : Shows you the current score and number of monsters killed :run : Tries to run from the current room :magic : Uses the player's Amulet to randomly move to another room :pick_up : Picks the room's treasure if there is any :fight : Fights with the monster in the room :consume : Eats food to gain strength
def handle(command) puts "Doing #{command}..." method = command case command when :north then method = :move when :south then method = :move when :east then method = :move when :west then method = :move when :up then method = :move when :down then method = :move end output = "" if method == :move output << self.send(method, command) else output << self.send(method) end output << "\n" output << self.status output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_commands(command) # rubocop:todo Metrics/CyclomaticComplexity\n case command\n when '/start'\n greet_user\n when '/stop'\n send_message \"Bye, #{message.from.first_name}\"\n when '/help'\n send_message \"Please enter any of the following commands: #{@commands}\"\n when '/news'\n handle_news\n when '/subscribe'\n handle_subscribe command\n when '/update'\n handle_update\n when '/add_birthday'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n when '/add_my_birthday'\n prompt_user command\n when '/add_anniversary'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n\n end\n end", "def do(full_command)\n self.command = Command.new\n if command.valid?(full_command) && already_placed?\n case command.command\n when Command::WHITE_LIST[0] # PLACE\n place\n report {|msg| $log.info msg}\n when Command::WHITE_LIST[1] # MOVE\n move\n report {|msg| $log.info msg}\n when Command::WHITE_LIST[2] # RIGHT\n right\n report {|msg| $log.info msg}\n when Command::WHITE_LIST[3] # LEFT\n left\n report {|msg| $log.info msg}\n when Command::WHITE_LIST[4] # REPORT\n report {|msg| $log.info msg}\n report {|msg| puts msg}\n end\n else\n puts error\n end\n end", "def execute(command)\n if command =~ /^PLACE\\s+\\d+\\s*,\\s*\\d+\\s*,\\s*(NORTH|SOUTH|EAST|WEST)$/\n command, x, y, direction = command.gsub(',', ' ').split\n robot.place(table, Position.new({x: x.to_i, y: y.to_i, direction: direction}))\n elsif command == \"MOVE\"\n robot.move(table)\n elsif command == \"LEFT\"\n robot.left\n elsif command == \"RIGHT\"\n robot.right\n elsif command == \"REPORT\"\n robot.report\n else\n \"Invalid command!\"\n end\n end", "def run_command(command)\n args = command [1..-1]\n case command[0]\n when 'q', 'quit' then @running = false\n when 'help', '?' then puts HELP\n when 'create' then create_object(args)\n when 'add-station' then add_station(args)\n when 'remove-station' then remove_station(args)\n when 'add-wagon' then add_wagon(args)\n when 'remove-wagon' then remove_wagon(args)\n when 'stations' then stations\n when 'assign' then assign(args)\n when 'trains' then trains(args)\n when 'move' then move(args)\n when 'require' then occupy(args)\n when 'take-seat' then take_seat(args)\n when 'wagons' then wagons(args)\n when 'producer' then producer(args)\n else\n raise TUIException, \"There is no command '#{command[0]}'\"\n end\n end", "def execute_move_command(command)\n validate command => [Symbol, Array]\n command, args = command if command.is_a?(Array)\n case command\n when :down\n @ydist << 32\n @ytrav << 0\n @ystart << (@ystart[0] ? @ystart.last + @ydist.last : @relative_y)\n @anim << [0, 16]\n @game_event.direction = 2\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n @game_event.y += 1\n when :left\n @xdist << -32\n @xtrav << 0\n @xstart << (@xstart[0] ? @xstart.last + @xdist.last : @relative_x)\n @anim << [0, -16]\n @game_event.direction = 4\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n @game_event.x -= 1\n when :right\n @xdist << 32\n @xtrav << 0\n @xstart << (@xstart[0] ? @xstart.last + @xdist.last : @relative_x)\n @anim << [0, 16]\n @game_event.direction = 6\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n @game_event.x += 1\n when :up\n @ydist << -32\n @ytrav << 0\n @ystart << (@ystart[0] ? @ystart.last + @ydist.last : @relative_y)\n @anim << [0, -16]\n @game_event.direction = 8\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n @game_event.y -= 1\n when :turn_down\n @game_event.direction = 2\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n next_move\n when :turn_left\n @game_event.direction = 4\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n next_move\n when :turn_right\n @game_event.direction = 6\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n next_move\n when :turn_up\n @game_event.direction = 8\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n next_move\n when :turn_to_player\n @game_event.turn_to_player\n @sprite.src_rect.y = (@game_event.direction / 2 - 1) * @sprite.src_rect.height if @setdir\n next_move\n when :wait\n @moveroute_wait = args[:frames]\n else\n raise \"Invalid move route command #{command.inspect}\"\n end\n @moveroute_moving_command = [:down, :left, :right, :up].include?(command)\n end", "def give_command(command)\n\t\tif command.start_with? \"PLACE\"\n\t\t\tif @robot.robot_placed?\n\t\t\t\tputs \"\"\n\t\t\t\tputs \"Only one robot permitted in this small world\"\n\t\t\telse\n\t\t\t\tplace(command)\n\t\t\tend\n\t\telsif command == \"EXIT\"\n\t\t\tif OS.mac?\n\t\t\t\tcmd =(\"say 'Bye bye, #{$account}!'\" )\n\t\t\t\tsystem cmd\n\t\t\tend\n\t\t\texit\n\t\telsif !valid_command?(command)\n\t\t\tputs \"\"\n\t\t\tputs \"Sorry but \\\"#{command}\\\" is not a valid command\"\n\t\telsif !@robot.robot_placed?\n\t\t\tputs \"\"\n\t\t\tputs \"Sorry #{$account}, but you need to place the robot before \\\"#{command}\\\" will be accepted\"\n\t\telse\n\t\t\tcase command\n\t\t\twhen \"SELFDESTRUCT\" then destruct\n\t\t\twhen \"MOVE\" then move\n\t\t\twhen \"REPORT\" then report\n\t\t\twhen \"LEFT\" then rotate(\"LEFT\")\n\t\t\twhen \"RIGHT\" then rotate(\"RIGHT\")\n\t\t\t#rotate to allow for more directions (e.g. other angles than 90 degrees)\n\t\t\tend\n\t\tend\n\tend", "def performAction(command)\n command = command.strip.split(/ *, */)\n # Force upper case for the command word\n command[0] = command[0].upcase\n if(command.size >= 3)\n # Standardize formatting of amounts\n command[2].slice! \"$\"\n command[2] = \"$%.2f\" % command[2]\n end\n\n # Execute the appropriate command based on the first word in the message\n case command[0]\n when \"BOUGHT\" then buy(command)\n when \"BUY\" then buy(command)\n when \"SOLD\" then sell(command)\n when \"SELL\" then sell(command)\n when \"RECENT\" then recent()\n when \"PAST\" then recent()\n when \"BALANCE\" then balance\n when \"HELP\" then help\n when \"REGISTER\" then register(command)\n else unknownCommand\n end\nend", "def handle_commands\n begin\n # obtain params for valid first input and pass them to model\n if Helper.valid_place?(@commands.first)\n params = @commands.first.split(\" \")[1].split(\",\")\n x = params[0].to_i\n y = params[1].to_i\n f = params[2]\n robot = Robot.new(x, y, f, @size_x, @size_y)\n # skip first commands and apply robot movement according to commands\n @commands[1..-1].each do |command|\n if Helper.valid_command?(command)\n case command\n when \"MOVE\"\n robot.move\n when \"LEFT\"\n robot.left\n when \"RIGHT\"\n robot.right\n when \"REPORT\"\n break\n end\n end\n end\n end\n robot.report\n rescue => ex\n puts \"error: #{ex.message}\"\n end\n end", "def read_command(command)\n if command =~ /^PLACE\\s+\\d+\\s*,\\s*\\d+\\s*,\\s*(NORTH|SOUTH|EAST|WEST)$/\n command, x, y, direction = command.tr(',', ' ').split\n\n Place.new(@robot, @table, Position.new(x.to_i, y.to_i, direction))\n elsif command =~ /^MOVE$/\n Move.new(@robot, @table)\n elsif command =~ /^LEFT$/\n Left.new(@robot)\n elsif command =~ /^RIGHT$/\n Right.new(@robot)\n elsif command =~ /^REPORT$/\n Report.new(@robot)\n end\n end", "def proccess_command(command)\n # branch based on command type\n case command[0]\n when COMScript # script [code]\n # evaluate script\n result = eval(command[1])\n when COMWait # wait [int]\n # decrease wait counter by 1\n command[1] -= 1\n # proceed if wait time is up\n return command[1] <= 0\n when COMMove # move [int, int]\n # add to move commands\n @moves.push(command)\n when COMTurn # turn [int]\n # add to move commands\n @moves.push(command)\n when COMJump # jump [int, int]\n # add to move commands\n @moves.push(command)\n when COMAttack # attack\n # use attack\n @ch.use_attack\n when COMSkill # skill [int]\n # use skill\n @ch.use_skill($data_skills[command[1]])\n when COMItem # item [int]\n # use item\n @ch.use_item($data_items[command[1]])\n when COMDefend # defend [int]\n # decrease time\n time = command[1] - 1\n # use defend\n @ch.use_defend\n # set penalty\n @ch.set_action(1)\n # if not done with command\n if time > 0\n # update the command counter\n command[1] = time\n # do not proceed\n return false\n end\n when COMCharacter # character [CH, value]\n # handle based on sub-command\n case command[1]\n when CHSpeed # move speed\n # set movement speed\n @ch.move_speed = command[2]\n when CHFrequency # move frequency\n # set movement frequency\n @ch.move_frequency = command[2]\n when CHSprite # change sprite\n # set sprite\n @ch.character_name = command[2]\n when CHAnimation # play animation\n # set animation\n @ch.animation_id = command[2]\n when CHFix # direction fix\n # set direction fix flag\n @ch.direction_fix = command[2]\n when CHThrough # through\n # set through flag\n @ch.through = command[2]\n when CHOnTop # always on top\n # set always on top flag\n @ch.always_on_top = command[2]\n when CHOpacity # opacity\n # set opacity\n @ch.opacity = command[2] \n end\n when COMInput # create input window [int, [keys], IN, int]\n # create new input window\n @inputs[command[1]] = [command[2], command[3], command[4], false]\n when COMVariable # variable [VAR, value1, '=', VAR, value2]\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '+=' then val2 = val1 + val2 # add\n when '-=' then val2 = val1 - val2 # subtract\n when '*=' then val2 = val1 * val2 # multiply\n when '/=' then val2 = val1 / val2 # divide\n when '%=' then val2 = val1 % val2 # modulo\n end\n # set the variable\n set_variable(command[1], command[2], val2)\n when COMCondition # condition [VAR, value1, '==', VAR, value2]\n # initialize result\n result = false\n # initialize values\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '==' # equal to\n # result is value 1 equal to value 2\n result = val1 == val2\n when '!=' # not equal to\n # result is value 1 not equal to value 2\n result = val1 != val2\n when '>' # greater than\n # result is value 1 equal to value 2\n result = val1 > val2\n when '>=' # greater than or equal to\n # result is value 1 not equal to value 2\n result = val1 >= val2\n when '<=' # less than\n # result is value 1 equal to value 2\n result = val1 < val2\n when '<=' # less than or equal to\n # result is value 1 not equal to value 2\n result = val1 <= val2\n end \n # if input or script\n if command[1] == VARInput || command[1] == VARScript\n # value 1 contains the result\n result = val1\n # do not proceed if waiting on an input window\n if command[1] == VARInput && @inputs[command[2]][2] > 0 && !result\n return false\n end\n end\n # skip next command if exists and condition not met\n @commands.delete_at(1) if !result && @commands.size > 1\n when COMFreeze # freeze input [bool]\n # set freeze input flag\n @freeze_character = command[1]\n when COMCompletion # wait for move completion\n # proceed if no more moves and character no longer moving\n return @moves.size == 0 && !@ch.moving?\n when COMGoTo # go to action [int]\n raise 'ERROR: Invalid action' if !is_valid_action?(command[1])\n # setup the action\n setup_action(command[1])\n # do not proceed - new set of commands\n return false\n when COMAbort # abort\n # set ended flag\n @ended = true\n end\n return true\n end", "def processCommand(command)\n # Check if the command is nil\n unless command.nil?\n # Convert command to all uppercase\n command = command.upcase\n # Find out the type of command, PLACE, LEFT, RIGHT, MOVE or REPORT\n commandConst = Command.validate(command)\n # Only process non-PLACE command when robot is placed\n unless commandConst.nil? || (commandConst != Command::P && !@robot.placed)\n case commandConst\n when Command::P\n # Get x and y \n position = command.scan(/\\d+/)\n x = position[0].to_i\n y = position[1].to_i\n face = command.scan(/#{Direction::N}|#{Direction::E}|#{Direction::S}|#{Direction::W}$/)[0]\n @robot.update(x, y, face)\n when Command::L\n @robot.turnLeft\n when Command::R\n @robot.turnRight\n when Command::M\n @robot.move\n when Command::RP \n @view.displayOutput(@robot.x, @robot.y, @robot.face)\n end\n return true\n end\n end\n # Invalid command\n return false\n end", "def execCommand(command)\n if checkCommand(command) == :placecmd\n cmds = parsePlaceCommand(command)\n @robot.place(cmds[0], cmds[1], cmds[2])\n elsif checkCommand(command) == :cmd\n case command.upcase\n when 'REPORT'\n puts @robot.report\n when 'MOVE'\n @robot.move\n when 'LEFT'\n @robot.left\n when 'RIGHT'\n @robot.right\n end\n else\n raise NoSuchCommand\n end\n end", "def execute(command)\n case command\n when 'M'\n move_forward\n when 'R'\n # rotate 90 right\n change_direction(DIRECTION_MAPPING[@direction] + 90)\n when 'L'\n # rotate 90 left\n change_direction(DIRECTION_MAPPING[@direction] - 90)\n end\n end", "def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Branch by command sprite cursor position\n case @command_window.index\n when 0 # buy\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Change windows to buy mode\n @command_window.active = false\n @dummy_window.visible = false\n @buy_window.active = true\n @buy_window.visible = true\n @buy_window.refresh\n @status_window.visible = true\n when 1 # sell\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Change windows to sell mode\n @command_window.active = false\n @dummy_window.visible = false\n @sell_window.active = true\n @sell_window.visible = true\n @sell_window.refresh\n when 2 # quit\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to map screen\n $scene = Scene_Map.new\n end\n return\n end\n end", "def instruction (command)\n\t\t\t@actor.tell @actor.state.prompt + command\n\t\t\t@actor.perform command\n\t\tend", "def run_commands\n raise \"First command must be: PLACE\" unless (/PLACE/).match @commands.first\n\n\n @commands.each do |cmd|\n @action = cmd.split(\" \").first\n case @action\n when \"PLACE\"\n place = cmd.split(/\\s|\\,/)\n @x = Integer(place[1])\n @y = Integer(place[2])\n raise \"Placement is out of bounds\" unless @tabletop.table_boundary?(@x, @y)\n @direction = place[3].to_s\n raise \"Not a valid direction. Must be either: NORTH, EAST, SOUTH, WEST.\" unless DIRECTIONS.include?(@direction)\n @placed = true\n when \"MOVE\"\n move\n when \"LEFT\"\n rotate_left\n when \"RIGHT\"\n rotate_right\n when \"REPORT\"\n report\n end\n end\n end", "def handle_commands(player_inputs)\n filter_commands(player_inputs)\n case @player_move\n when 'PLACE'\n @new_commands.valid_placement(@position_x, @position_y, @direction)\n when 'MOVE'\n @new_commands.move_robot\n when 'LEFT'\n @new_commands.turn_left\n when 'RIGHT'\n @new_commands.turn_right\n when 'OBSTACLE'\n @new_commands.create_obstacle(@obs_postion_x, @obs_postion_y)\n @new_commands.check_obstacles(@obs_postion_x, @obs_postion_y)\n when 'PATH'\n @new_commands.find_path(@path_position_x, @path_position_y)\n when 'REPORT'\n @new_commands.report_position\n else\n puts 'INVALID COMMAND -- Plase select a valid command:'\n end\n end", "def update_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Branch by command window cursor position\r\n case @command_window.index\r\n when 0 # buy\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Change windows to buy mode\r\n @command_window.active = false\r\n @dummy_window.visible = false\r\n @buy_window.active = true\r\n @buy_window.visible = true\r\n @buy_window.refresh\r\n @status_window.visible = true\r\n when 1 # sell\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Change windows to sell mode\r\n @command_window.active = false\r\n @dummy_window.visible = false\r\n @sell_window.active = true\r\n @sell_window.visible = true\r\n @sell_window.refresh\r\n when 2 # quit\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n end\r\n return\r\n end\r\n end", "def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If command other than save or end game, and party members = 0\n if $game_party.actors.size == 0 and @command_window.index < 4\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Branch by command sprite cursor position\n case @command_window.index\n when 0 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to item screen\n $scene = Scene_Item.new\n when 1 # skill\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 2 # equipment\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 3 # status\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 4 # save\n # If saving is forbidden\n if $game_system.save_disabled\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to save screen\n $scene = Scene_Save.new\n when 5 # end game\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to end game screen\n $scene = Scene_End.new\n end\n return\n end\n end", "def command(command)\n output = \"\"\n\n # LETTER: equivalent to +LETTER\n if (command.match(\"^([A-Z])$\")) then\n command = \"+#{$1}\"\n end\n\n # +WORD : add words to table\n if (command.match(\"^\\\\+([A-Z ]+)$\"))\n new_words = $1.split(\" \").delete_if{|word|word.empty?}\n @words += new_words\n output += \"Added #{new_words.inspect} to table.\\n\"\n output += format_words\n\n # -WORD : remove words from table\n elsif (command.match(\"^-([A-Z ]+)$\"))\n remove_words = $1.split(\" \").delete_if{|word|word.empty?}\n words_copy = @words.dup\n valid = true\n remove_words.each do |word|\n index = words_copy.index(word)\n if index then\n words_copy.delete_at(index)\n else\n output += \"Invalid removal: Not enough #{word.inspect}s on the table.\\n\"\n valid = false\n end\n end\n if valid then\n @words = words_copy\n output += \"Removed #{remove_words.inspect} from table.\\n\"\n end\n output += format_words\n\n elsif ([\"@\",\"/WORDS\"].include?(command))\n output += format_words\n\n # # : number of moves\n elsif ([\"#\",\"/num\"].include?(command))\n output += \"Number of possible moves: #{moves.size}\"\n\n # ? : what moves can we make\n elsif ([\"?\",\"/moves\"].include?(command))\n output += \"Possible moves:\\n\"+@dictionary.format_moves(moves)\n\n # number : make that move\n elsif (command.match(\"^([0-9]+)$\"))\n move = moves[$1.to_i]\n if (move) then\n result = move(move)\n if result==true then\n output += \"Made move: #{dictionary.format_move(move)}\\n\"+format_words\n else\n output += result\n end\n else\n output += \"Unrecognized move #{$1.inspect}. Enter '?' for a list of valid moves.\" \n end\n\n else\n output += \"Unrecognized command #{command.inspect}\"\n end\n\n return output\n end", "def execute_command(cmd)\n command, args = parse_input(cmd)\n\n case command\n when :place\n place_robot(args)\n when :move, :left, :right\n @toy_robot.send(command)\n when :report\n puts @toy_robot.report\n when :exit\n puts 'Leaving...'\n\n exit\n end\n rescue => e\n puts \"Error: #{e.message}\"\n end", "def parse(command)\n case command\n when 'exit', 'quit' then exit\n when /(?:face|turn) (#{DIRECTION})/\n robot.face(Regexp.last_match[1])\n when /(?:(?:move|go) )?(#{DIRECTION})(?: (\\d+))?/\n robot.move(*Regexp.last_match.captures)\n when /(?:move|go)(?: (\\d+))?/\n robot.forward(Regexp.last_match[1])\n else raise \"Command not recognised: #{command}\"\n end\n end", "def command data, command_groups=[:global], from_input=false\n data.strip!\n return unless data != \"\"\n command_name,args = data.split(' ', 2)\n # if args is nil, lets make it a string.\n args ||= \"\"\n\n # either - is there a command?\n # or, there is an exit in this room/a standard exit by that name.\n # elsewise, \"you can't do that.\"\n begin\n if com = Commands::find_command(command_name, command_groups) \n com.enact(self, args)\n elsif room.has_exit?(command_name)|| (Room::DIRS.keys + Room::DIRS.values).include?(command_name.to_sym)\n Commands::find_command(\"move\", [:global]).enact(self,data)\n #room.leave_to(self,command_name).arrive_from(self,command_name)\n else\n hear_line \"You can't do that!\"\n end\n rescue NoBalanceError => e\n hear_line \"You can't do that off balance.\"\n rescue Exception => e\n hear_line \"You've triggered an uncaught exception. Please report this to the mud....\"\n puts \"There has been an uncaught exception, triggered by #{display_name} trying to do a command with #{data}\"\n puts \"It raised #{e} at\"\n puts e.backtrace\n end\n end", "def execute(command)\n case command.split.first\n when \"list\"\n list(@command)\n when \"play\"\n # if @library.empty? || @library.length.even?\n # puts \"that doesn't make any sense\"\n # prompt\n # else\n play(@command)\n # end\n when \"select\"\n if @library.empty? \n # || @library.length.even?\n puts \"that doesn't make any sense\"\n prompt\n else\n select(@command, @library)\n end\n when \"clear\"\n clear\n else\n puts \"The commands are: play, select, etc\"\n prompt\n end\n end", "def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If command other than save or end game, and party members = 0\n if $game_party.actors.size == 0 and @command_window.index < 4\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Branch by command window cursor position\n case @command_window.index\n when 0 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to item screen\n $scene = Scene_Item.new\n when 1 # skill\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 2 # equipment\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 3 # piercings\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 5 # status\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 6 # save\n # If saving is forbidden\n if $game_system.save_disabled\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to save screen\n $scene = Scene_Save.new\n when 7 # end game\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to end game screen\n $scene = Scene_End.new\n end\n return\n end\n end", "def update_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Return if Disabled Command\r\n if disabled_main_command?\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Command Input\r\n main_command_input\r\n return\r\n end\r\n end", "def handle_command(c)\n\tcase c\n\twhen \"p\"\n\t\tprint_table\n\twhen \"q\"\n\t\texit\n\twhen \"g\"\n\t\tread_table\n\twhen \"c\"\n\t\tinit_table\n\twhen \"?s\"\n\t\tputs $score\n\twhen \"?n\"\n\t\tputs $cleared_lines\n\twhen \"s\"\n\t\tupdate_table\n\twhen *Tetromino.types\n\t\t$active_tetromino = Tetromino.new(c)\n\twhen \"t\"\n\t\tputs $active_tetromino.to_s\n\tend\nend", "def m_command(i)\n begin\n case @heading\n when \"N\"\n if !@grid.valid_location?(@xcoord, @ycoord + 1)\n raise Errors::InvalidMoveError\n else\n @ycoord += 1\n end\n when \"E\"\n if !@grid.valid_location?(@xcoord + 1, @ycoord)\n raise Errors::InvalidMoveError\n else\n @xcoord += 1\n end\n when \"S\"\n if !@grid.valid_location?(@xcoord, @ycoord - 1)\n raise Errors::InvalidMoveError\n else\n @ycoord -= 1\n end\n when \"W\"\n if !@grid.valid_location?(@xcoord - 1, @ycoord)\n raise Errors::InvalidMoveError\n else\n @xcoord -= 1\n end\n end\n rescue Errors::InvalidMoveError\n puts \"Command ##{i} in rover ##{@number}'s command list causes it to drive off the edge. Halting execution of this rover.\"\n return false\n end\n end", "def interpret_place(command)\n matches = command.upcase.match(/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(NORTH|SOUTH|EAST|WEST)/)\n raise CommandError, \"Invalid place command.\" if matches.nil?\n \n xpos = matches[1].to_i\n ypos = matches[2].to_i\n direction = matches[3]\n \n coords = Coordinate.new(xpos, ypos)\n direction = Direction[direction]\n \n if @robot.nil?\n @robot = Robot.new(coords, direction, @table)\n else\n @robot.place(coords, direction, @table)\n end\n end", "def update_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If command other than save or end game, and party members = 0\r\n if $game_party.actors.size == 0 and @command_window.index < 4\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Branch by command window cursor position\r\n case @command_window.index\r\n when 0 # item\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to item screen\r\n $scene = Scene_Item.new\r\n when 1 # skill\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 2 # equipment\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 3 # status\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 4 # save\r\n # If saving is forbidden\r\n if $game_system.save_disabled\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to save screen\r\n $scene = Scene_Save.new\r\n when 5 # end game\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to end game screen\r\n $scene = Scene_End.new\r\n end\r\n return\r\n end\r\n end", "def update_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Return if Disabled Command\r\n if disabled_main_command?\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n main_command_input\r\n return\r\n end\r\n end", "def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If command other than save or end game, and party members = 0\n if $game_party.actors.size == 0 and @command_window.index < 4\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Branch by command window cursor position\n case @command_window.index\n when 0 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n @command_window.active = false\n @info_window.visible = false\n @title_window.visible = true\n @title_window.active = true\n @help_window.visible = true\n when 1 # アイテム\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # アイテム画面に切り替え\n $scene = Scene_Item.new\n when 2 # 装備\n # 決定 SE を演奏\n $game_system.se_play($data_system.decision_se)\n # 装備画面に切り替え\n $scene = Scene_Equip.new\n when 3 # 衣服\n # 決定 SE を演奏\n $game_system.se_play($data_system.decision_se)\n # 衣服ウィンドウをアクティブにする\n @command_window.active = false\n @command_window.visible = false\n @status_window.visible = false\n @change_window.visible = true\n @change_window.active = true\n\n if $game_switches[2] == true #着替えコマンドが禁止の場合\n @change_window.disable_item(0)\n @change_window.disable_item(1)\n end\n when 4 # セーブ\n # セーブ禁止の場合\n if $game_system.save_disabled\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to save screen\n $scene = Scene_Save.new\n when 5 # end game\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to end game screen\n $scene = Scene_End.new\n end\n return\n end\n end", "def move(command)\n command = command.upcase\n return false unless ALLOWED_COMMANDS.include?(command)\n\n (command == 'M') ? walk : turn(command)\n end", "def menu_choice(cmd)\n hplayer = @human_player\n action = cmd\n\n # define possible actions for the player\n if action == \"a\"\n hplayer.search_weapon\n elsif action == \"s\"\n hplayer.search_health_pack\n elsif action.match(/^(\\d)+$/) # check if action is a number\n hplayer.attacks(@enemies[action.to_i])\n if @enemies[action.to_i].life_points <= 0\n kill_player(@enemies[action.to_i])\n end\n end\n \n end", "def command_handler(input) \n list = input.split(\",\")\n list.each do |instruction| \n instruction = instruction.upcase.gsub(/\\s+/, \"\")\n if !(/^([a-zA-Z]+)([0-9]+)$/.match?(instruction))\n puts \"\\nInvalid input command. Please type `i` to refer to the instructions\"\n return\n end \n command = instruction[0..(instruction.index(/\\d/)-1)].upcase\n if COMMANDS.include? command \n unit = instruction[(instruction.index(/\\d/))..(instruction.length-1)].to_i\n (MOVEMENT_COMMANDS.include? command)? move_robot(command, unit) : rotate_robot(command, (unit % 4))\n else\n puts \"\\nInvalid input command. Please type `i` to refer to the instructions\"\n return\n end \n end\n puts \"\\n[------ Minimum distance to origin is `#{$x.abs() + $y.abs()}` ------]\"\n $x = 0\n $y = 0\n $current_direction = 0\nend", "def interpret_move(command)\n ensure_placed\n @robot.move_forward\n end", "def command (command_string)\n begin\n command_string.each_char do |c|\n case c\n when 'F'\n motion(:forward)\n when 'B'\n motion(:backward)\n when 'L'\n turn(:left)\n when 'R'\n turn(:right)\n end\n end\n rescue RuntimeError\n return $!.message\n end\n end", "def handle(command)\n action, context = command.split('__')\n\n handler(action).call(context) if handler_exists_for?(action)\n end", "def neighborhoodLoop(command, home)\n\t\tcase command.getCommand()\n\t\twhen 'left'\n\t\t\tif(@player.location % 3 != 1)\n\t\t\t\t@player.location = @player.location - 1;\n\t\t\t\tputs \"You have moved west to another house.\"\n\t\t\telse\n\t\t\t\tputs \"You are at the edge of your neighborhood and cannot go further west.\"\n\t\t\tend\n\t\twhen 'right'\n\t\t\tif(@player.location % 3 != 0)\n\t\t\t\t@player.location = @player.location + 1;\n\t\t\t\tputs \"You have moved east to another house.\"\n\t\t\telse\n\t\t\t\tputs \"You are at the edge of your neighborhood and cannot go further east.\"\n\t\t\tend\n\t\twhen 'up'\n\t\t\tif(@player.location + 3 < 10)\n\t\t\t\t@player.location = @player.location + 3;\n\t\t\t\tputs \"You have moved north to another house.\"\n\t\t\telse\n\t\t\t\tputs \"You are at the edge of your neighborhood and cannot go further north.\"\n\t\t\tend\n\t\twhen 'down'\n\t\t\tif(@player.location - 3 > 0)\n\t\t\t\t@player.location = @player.location - 3;\n\t\t\t\tputs \"You have moved south to another house.\"\n\t\t\telse\n\t\t\t\tputs \"You are at the edge of your neighborhood and cannot go further south.\"\n\t\t\tend\n\t\twhen 'si'\n\t\t\tputs \"Weapon Name\\t-\\tUses\"\n\t\t\t@player.inventory.each do |weapon|\n\t\t\t\tif(weapon.uses < 0)\n\t\t\t\t\tputs \"#{weapon.name}\\t-\\tUnlimited uses\";\n\t\t\t\telse\n\t\t\t\t\tputs \"#{weapon.name}\\t-\\t#{weapon.uses} uses\";\n\t\t\t\tend\n\t\t\tend\n\t\twhen 'sm'\n\t\t\tputs \"You lost the map and connot use it anymore\";\n\t\t\t# print map of houses and monster count info\n\t\t\t# TODO: print map of neighborhood\n\t\twhen 'eh'\n\t\t\tputs \"You entered house number #{@player.location}\";\n\t\t\thome = @neighborhood.homes[@player.location - 1];\n\t\twhen 'ns'\n\t\t\t@neighborhood.stats();\n\t\telse\n\t\t\tputs \"That is not a command.\";\n\t\tend\n\t\t\n\t\treturn home\n\tend", "def go_room(command)\n if @current_room.has_exit?(command) \n # current room has this exit \n exit_room = @current_room.get_exit(command) # return string of room name\n # Search for instance of this room\n # update current room\n @game_rooms.each do |room|\n if room.is_room?(exit_room)\n @current_room = room # update current room\n end\n end\n puts \"\\nYou have entered the #{@current_room.print_name}!\\n\"\n else \n puts \"That is not a direction you can travel.\\n\"\n end\n end", "def move_disambig(direction)\n\t\t\t@north_cmds = [\"n\", \"up\", \"north\"]\n\t\t\t@east_cmds = [\"e\", \"right\", \"east\"]\n\t\t\t@west_cmds = [\"w\", \"left\", \"west\"]\n\t\t\t@south_cmds = [\"s\", \"down\", \"south\"]\n\n\t\t\t\t\txy = $hero.location.xy.split(\", \")\n\t\t\t\t\tx = xy[0].to_i\n\t\t\t\t\ty = xy[1].to_i\n\t\t\t\tif @north_cmds.include?(direction)\n\t\t\t\t\tif $hero.location.exits.include?(\"north\")\n\t\t\t\t\t\tcheck_room(\"north\", x, (y + 1))\n\t\t\t\t\t\tmove(\"north\")\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"There is no exit to the north!\"\n\t\t\t\t\tend\n\t\t\t\telsif @east_cmds.include?(direction)\n\t\t\t\t\tif $hero.location.exits.include?(\"east\")\n\t\t\t\t\t\tcheck_room(\"east\", (x + 1), y)\n\t\t\t\t\t\tmove(\"east\")\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"There is no exit to the east!\"\n\t\t\t\t\tend\n\t\t\t\telsif @west_cmds.include?(direction)\n\t\t\t\t\tif $hero.location.exits.include?(\"west\")\n\t\t\t\t\t\tcheck_room(\"west\", (x - 1), y)\n\t\t\t\t\t\tmove(\"west\")\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"There is no exit to the west!\"\n\t\t\t\t\tend\n\t\t\t\telsif @south_cmds.include?(direction)\n\t\t\t\t\tif $hero.location.exits.include?(\"south\")\n\t\t\t\t\t\tcheck_room(\"south\", x, (y - 1))\n\t\t\t\t\t\tmove(\"south\")\n\t\t\t\t\telse \n\t\t\t\t\t\tputs \"There is no exit to the south!\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\tend", "def move_robot(command, unit)\n if /#{FORWARD}/.match?(command)\n case $current_direction \n when 0\n $y += unit\n when 1\n $x += unit\n when 2\n $y -= unit\n else\n $x -= unit\n end\n elsif /#{BACKWARD}/.match?(command)\n case $current_direction \n when 0\n $y -= unit\n when 1\n $x -= unit\n when 2\n $y += unit\n else\n $x += unit\n end \n end \nend", "def check\n case $input\n when 'inv'\n list\n when 'get'\n get\n add\n when 'n', 'north'\n $player.go($player.location.n)\n when 's', 'south'\n $player.go($player.location.s)\n when 'e', 'east'\n $player.location.go('e')\n when 'w', 'west'\n $player.location.go('w')\n when 'search'\n $player.location.search\n when 'buy'\n buy\n when 'l', 'look'\n $player.location.look\n when 'help'\n help\n when 'info'\n info\n when 'stats'\n $player.stats\n else puts 'That is not a valid command.' \n end\n end", "def handle(input)\n instructions = input.split(' ')\n instruction = instructions.first\n\n if @robot && instructions.length == 1\n if ['move', 'left', 'right'].include?(instruction)\n @robot.send(instruction)\n elsif instruction == 'report'\n puts @robot.report\n end\n elsif instructions.length == 2\n if instruction == 'place'\n arguments = instructions.last.split(',')\n # TODO: Fix handling of these arguments.\n @robot ? @robot.place(*arguments) : @robot = Robot.new(*arguments)\n end\n end\n end", "def handle_command(message)\n text = period = tomorrow = subscribe = type = nil\n valid = false\n case message.text\n when CONST::COMMANDS[:lunch]\n valid = true\n period = :lunch\n when CONST::COMMANDS[:dinner]\n valid = true\n period = :dinner\n when CONST::COMMANDS[:tomorrow]\n valid = true\n tomorrow = true\n when CONST::COMMANDS[:next]\n valid = true\n when CONST::COMMANDS[:unsubscribe]\n valid = true\n subscribe = :destroy\n when CONST::COMMANDS[:subscribe]\n valid = true\n subscribe = :create\n when CONST::COMMANDS[:config]\n valid = true\n text = ''\n @bot.start_config message.from, message.chat\n when CONST::COMMANDS[:update]\n valid = true\n tag = @bandejao.update_pdf ? 'success' : 'error'\n text = CONST::TEXTS[:\"pdf_update_#{tag}\"]\n when CONST::COMMANDS[:feedback]\n valid = true\n text = send_feedback message\n when CONST::COMMANDS[:papoco]\n valid = true\n text = ''\n @bot.start_papoco message.chat\n else\n CONST::COMMANDS.each do |k, v|\n text = CONST::TEXTS[k] if v.match(message.text)\n end\n end\n if subscribe\n type = message.chat.type == 'private' ? :private : :group\n success = @bot.start_subscription subscribe, message\n text = CONST::SUBSCRIBE[subscribe][type][success]\n end\n tomorrow = CONST::COMMANDS[:tomorrow] =~ message.text\n unless valid\n text = '' unless message.chat.type == CONST::CHAT_TYPES[:private]\n end\n [text, period, tomorrow]\n end", "def player_action(command)\n case command\n when 'player.wait'\n return true\n when /^player\\.move_/\n direction = get_direction('player.move', command)\n destination = @level.creature_destination(@player, direction)\n if @level.creature_can_move?(@player, destination)\n @level.move_creature(@player, destination)\n return true\n else\n # TODO Try another action on the cell\n return false\n end\n when /^player.open_close/\n direction = get_direction('player.open_close', command)\n target = @level.creature_destination(@player, direction)\n # TODO Ensure that target is reachable\n @level.creature_open_close(@player, target)\n else\n return false\n end\n end", "def proccess_move(command)\n # branch based on command type\n case command[0]\n # move\n when COMMove\n # get direction\n dir = get_direction(command[1])\n # get number of steps remaining\n steps = command[2] - 1\n # make character move depending on direction\n case dir\n when 1 then @ch.move_lower_left\n when 2 then @ch.move_down(dir)\n when 3 then @ch.move_lower_right\n when 4 then @ch.move_left(dir)\n when 6 then @ch.move_right(dir)\n when 7 then @ch.move_upper_left\n when 8 then @ch.move_up(dir)\n when 9 then @ch.move_upper_right\n end\n # proceed if no more steps\n return true if steps == 0\n # update steps counter\n command[2] = steps\n # do not proceed as there are more steps to be executed\n return false\n # turn\n when COMTurn\n # make character turn to face direction\n @ch.direction = get_direction(command[1])\n # jump\n when COMJump\n # get direction\n dir = get_direction(command[1])\n # get range\n range = command[2]\n # set jumping direction\n x, y = BlizzABS::Cache::DirOffsets[dir]\n # jump into direction with range\n @ch.jump(x*range, y*range, dir)\n end\n # proceed\n return true\n end", "def determine_unit_commands\n commands = [] # Shall push all the commands into this variable\n \n # If the cursor is choosing a spot where a different unit exists (ignores hidden)\n other_unit = $game_map.get_unit(*@command.move, false)\n if other_unit != nil and other_unit != @unit\n # If the unit is the same army type\n if other_unit.army == @unit.army\n # If units can join with each other\n if @unit.can_join?(other_unit)\n commands.push(\"Join\")\n # If unit can be loaded into this other unit\n elsif other_unit.carry_capability(@unit)\n commands.push(\"Load\")\n end\n end\n # Because this unit is ending its turn on another unit, the other commands\n # like Fire, Capture, and Wait do not need to be evaluated\n return commands\n end\n \n # If this unit can attack another unit directly\n if @unit.max_range == 1 and (@unit.ammo > 0 or @unit.secondary)\n ranges = calc_pos(unit, \"direct\", *@command.move)\n ranges.flatten.compact.each{|r|\n # Continue block if a valid tile to attack\n next unless valid?(r.x, r.y)\n # Get the unit at this spot\n u = $game_map.get_unit(r.x, r.y, false)\n # If no unit exists at this spot\n if !u.is_a?(Unit)\n tile = $game_map.get_tile(r.x, r.y)\n # If this is a tile that can be destroyed\n if tile.is_a?(Structure) and tile.hp > 0 and @unit.can_attack?(tile)\n commands.push(\"Fire\")\n break\n end\n # If enemy unit (will need edit for allied armies)\n elsif u.army != @unit.army and @unit.can_attack?(u)\n commands.push(\"Fire\")\n break\n end\n }\n # If this unit can attack indirectly (and didn't move)\n elsif @unit.max_range > 1 and (@unit.ammo > 0 or @unit.secondary) and\n unit == $game_map.get_unit(*@command.move)\n # Get ranges by calling calc_pos. Then evaluate each spot.\n # If it finds an enemy, push \"Fire\". Else, push \"Fire \" (can't fire).\n ranges = calc_pos(unit, \"attack\")\n ranges.flatten.compact.each{|r|\n next unless valid?(r.x, r.y)\n u = $game_map.get_unit(r.x, r.y, false)\n # If a unit doesn't exist at this spot\n if !u.is_a?(Unit)\n tile = $game_map.get_tile(r.x, r.y)\n if tile.is_a?(Structure) and tile.hp > 0 and @unit.can_attack?(tile)\n commands.push(\"Fire\")\n break\n end\n elsif u.army != @unit.army and @unit.can_attack?(u)\n commands.push(\"Fire\")\n break\n end\n }\n # Couldn't find a valid target--\"Unable to Fire\" command is added\n commands.push(\"Fire \") if !commands.include?(\"Fire\")\n end\n \n # If this unit can capture a building\n tile = $game_map.get_tile(*@command.move)\n if @unit.can_capture and tile.is_a?(Property)\n # If this is a missile silo\n if tile.id == TILE_SILO\n commands.push(\"Launch\") unless tile.launched\n # If this is a normal property\n else\n commands.push(\"Capt\") if tile.army != unit.army\n end\n end\n \n # If unit is holding another unit and can drop it\n if @unit.holding_units.size > 0 and @unit.valid_drop_spot(*@command.move)\n units_nearby = $game_map.get_nearby_units(*@command.move)\n tiles_nearby = $game_map.get_nearby_tiles(*@command.move)\n for u in 0...@unit.holding_units.size\n held_unit = @unit.holding_units[u]\n for i in 0...units_nearby.size\n # If the space is empty or if the unit in question is the same as the one\n # being given orders right now\n if units_nearby[i].nil? or units_nearby[i] == @unit\n if @unit.test_drop_tile(tiles_nearby[i], held_unit)\n commands.push(\"Drop\") if u == 0\n commands.push(\"Drop \") if u == 1\n break\n end\n end\n end\n end\n end\n \n # If this unit can supply other units\n if @unit.can_supply\n # Get surrounding units\n units_nearby = $game_map.get_nearby_units(*@command.move)\n units_nearby.each{|u|\n # If the space is empty\n next unless u.is_a?(Unit)\n # If the unit is of the same army and has low supplies\n if u != @unit and u.army == @unit.army and u.need_supplies\n commands.push(\"Supply\")\n break\n end\n }\n end\n \n # If unit can dive or hide\n if @unit.can_dive or @unit.can_hide\n if @unit.hiding\n commands.push(\"Surface\") if @unit.can_dive\n commands.push(\"Appear\") if @unit.can_hide\n else\n commands.push(\"Dive\") if @unit.can_dive\n commands.push(\"Hide\") if @unit.can_hide\n end\n end\n \n # Push 'Wait' by default, unless 'Join' or 'Load' is possible\n commands.push(\"Wait\")\n return commands\n end", "def command room, device, state\n # @todo get the device name in here...\n device = device.to_s\n # Command structure is <transaction number>,<Command>|<Action>|<State><cr>\n if room and device and !device.empty? and state\n '666,!' + room['id'] + room['device'][device]['id'] + state + '|Turn ' + room['name'] + ' ' + device + '|' + state + ' via @pauly'\n else\n '666,!' + room['id'] + state + '|Turn ' + room['name'] + '|' + state + ' via @pauly'\n end\n end", "def command_processor(user_input)\r\n case user_input.downcase\r\n when \"help\"\r\n list_available_commands\r\n when \"create\"\r\n ui_create_event\r\n when \"view-day\"\r\n ui_view_by_day\r\n when \"view-month\"\r\n ui_view_by_month\r\n when \"delete\"\r\n ui_delete_event\r\n when \"modify\"\r\n ui_modify_event\r\n else\r\n puts \"#{user_input} is not a command. type 'help' to see a list of commands\"\r\n end\r\nend", "def dispatch(command, event)\n whole_command, first_word_command = dispatch_method_names(command)\n\n if respond_to?(whole_command)\n send(whole_command, event)\n elsif respond_to?(first_word_command)\n send(first_word_command, event, *command[1..-1])\n elsif event.message.author.id == USERS[:archenoth]\n admin_dispatch(command, event)\n end\n end", "def move(direction)\n movements = @game.current_room_model.movement\n monster = @game.current_room_model.monster\n\n if direction == :north and not movements.north\n return \"No exit that way\"\n elsif direction == :south and not movements.south\n return \"There is no exit south\"\n elsif direction == :east and not movements.east\n return \"You cannot go in that direction\"\n elsif direction == :west and not movements.west\n return \"You cannot move through solid stone\"\n elsif direction == :up and not movements.up\n return \"You cannot go up this floor\"\n elsif direction == :down and not movements.down\n return \"You cannot go down this floor\"\n end\n\n return \"Monster shouts: YOU SHALL NOT PASS!!\" if monster && rand < 0.1\n\n @game.current_room = movements.send(direction)\n @game.player.tally += 1\n @game.player.strength -= 5\n\n if @game.player.strength < 1\n @game.state = DeadState.new @game\n else\n @game.state = WinnerState.new(@game) if @game.current_room == \"Exit\"\n end\n\n \"You moved to another room...\"\n end", "def phase3_basic_command_input\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Attack # attack\r\n phase3_command_attack\r\n when SDK::Scene_Commands::Scene_Battle::Skill # skill\r\n phase3_command_skill\r\n when SDK::Scene_Commands::Scene_Battle::Guard # guard\r\n phase3_command_guard\r\n when SDK::Scene_Commands::Scene_Battle::Item # item\r\n phase3_command_item\r\n end\r\n end", "def run(command)\n\t\t\t\tcase command[0]\n\t\t\t\t# ** Map functionality\n\t\t\t\twhen 'add_fun'\n\t\t\t\t\t@mapper.add_function command[1]; true\n\t\t\t\twhen 'add_lib'\n\t\t\t\t\t@mapper.add_libraries command[1]\n\t\t\t\t\t@reducer.add_libraries command[1]; true\n\t\t\t\twhen 'map_doc'\n\t\t\t\t\t@mapper.map command[1]\n\t\t\t\twhen 'reset'\n\t\t\t\t\t@config = command[1] || {}\n\t\t\t\t\t@mapper = Mapper.new(self); true\n\t\t\t\t\n\t\t\t\t# ** Reduce functionality\n\t\t\t\twhen 'reduce'\n\t\t\t\t\t@reducer.reduce command[1], command[2]\n\t\t\t\twhen 'rereduce'\n\t\t\t\t\t@reducer.rereduce command[1], command[2]\n\t\t\t\t\n\t\t\t\t# ** Design document functionality\n\t\t\t\twhen 'ddoc'\n\t\t\t\t\tif command[1] == 'new'\n\t\t\t\t\t\t@designer.create(command[2], command[3]); true\n\t\t\t\t\telse\n\t\t\t\t\t\t@designer.run(command[1], command[2], command[3])\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Exception => exception\n\t\t\t\terror_for_exception(exception)\n\t\t\tend", "def place(command)\n\t\tcommand.sub!(\"PLACE\", \"\")\n\t\tif (command =~ /\\s*\\d,\\d,\\w+/).nil?\n\t\t\tputs \"\"\n puts \"You forgot to tell the robot where to be placed or ..\"\n else\n \t\t@x, @y, @robot_direction = command.split(\",\")\n \t\t@x = number_or_nil(@x)\n \t\t@y = number_or_nil(@y)\n end\n\t\t#validates the location of the placement\n\t\tif valid_placement?\n\t\t\t@robot.location(@x, @y, @robot_direction)\n\t\t\tputs \"\"\n\t\t\tputs \"The robot has been placed at #{@x} #{@y} facing #{@robot_direction}. Let\\'s go on a rampage!\"\n\t\telse\n\t\t\tputs \"..the place command is incorrectly formatted or outside the table bounds. \"\n\t\t\tputs \"The boundries of this world reach from #{@min},#{@min} up to #{@width - 1},#{@height - 1}\"\n\t\t\tputs \"A place command looks like \\'PLACE 0,0,North \\' \"\n\t\tend\n\tend", "def run(command_string)\n\n command, param1, param2, param3 = command_string.strip().gsub(' ', ',').squeeze(',').upcase().split(',')\n\n\n # raise exception if 'PLACE' command has not been called earlier\n raise \"'PLACE' command has not been called earlier\" unless @placed or command == 'PLACE'\n\n\n # blank or invalid command\n raise 'Invalid command' unless COMMAND.key?(command)\n\n if command == 'PLACE'\n # PLACE command should have three parameters attached\n raise 'Missing parameter' unless (param1 and param2 and param3)\n\n place(Coordinates.new(param1, param2), Direction.new(param3))\n\n else\n self.public_send(COMMAND[command])\n end\n end", "def input_logic(input,character,world)\n\t\t\n\t\t#\"Up\" command logic\n\t\tif(input==\"w\")\n\t\t\tmove_char(@y_position-2,@x_position,world)#Move the character up\n\t\t\tworld.draw_world(@y_position,@x_position)#and the map is drawn.\n\t\t\ttest_conditions(character,\"y\") #Test conditions\n\n\t\t#\"Down\" command logic\t\n\t\telsif(input==\"s\")\n\t\t\tmove_char(@y_position+2,@x_position,world)#Move the character down\n\t\t\t\n\t\t\tworld.draw_world(@y_position,@x_position) #and the map is drawn.\n\t\t\ttest_conditions(character,\"y\") #Test conditions\n\n\t\t#\"Left\" command logic\t\n\t\telsif(input==\"a\")\n\t\t\tmove_char(@y_position,@x_position-1,world)#Move the character left\n\t\t\t\n\t\t\tworld.draw_world(@y_position,@x_position) #and the map is drawn.\n\t\t\ttest_conditions(character,\"x\") #Test conditions\n\n\t\t#\"Right\" command logic\t\n\t\telsif(input==\"d\") \n\t\t\tmove_char(@y_position,@x_position+1,world) #Move the character right\n\t\t\t\n\t\t\tworld.draw_world(@y_position,@x_position) #and the map is drawn\n\t\t\ttest_conditions(character,\"x\") #Test conditions\n\t\telsif(input==\"0\") #For adding an enemy to the map.\n\t\t\tenemy = Enemy.new(23,8,@y_position,@x_position,world)\n\t\t\tenemy.add_to_world\n\t\tend\n\tend", "def do_command\n if @index == 0\n call_scene(SearchMethod)\n elsif @index == 1\n do_command1\n elsif display_message(ext_text(8997, 32), 2, ext_text(8997, 33), ext_text(8997, 34)) == 0\n $game_system.se_play($data_system.cancel_se)\n @running = false\n end\n end", "def method_missing(action)\n if [:move, :left, :right].include? action\n @state = @state.send(action) if on_table?\n end\n end", "def call\n if event.command? && command_aliases.include?(event.command)\n handle_command\n end\n end", "def verify_command(command)\n if [\"list\", \"l\"].include?(command)\n list_command()\n elsif [\"create\", \"c\"].include?(command)\n list_command() if create_command()\n elsif [\"delete\", \"d\"].include?(command)\n list_command() if delete_command()\n elsif [\"search\", \"s\"].include?(command)\n search_command()\n elsif [\"food\", \"f\"].include?(command)\n food_command()\n elsif [\"wash\", \"w\"].include?(command)\n wash_command()\n elsif [\"alive\", \"a\"].include?(command)\n alive_command()\n elsif [\"help\", \"h\"].include?(command)\n help()\n else\n help()\n end\n end", "def method_missing(m, *args, &block)\n if Communicator::COMMANDS.keys.include?(m.to_sym)\n if m.to_sym == :shots then\n @hq.send(m, &block)\n else\n @hq.send(m, @tank.index, *args, &block)\n end\n else\n puts \"Failed to find method '#{m}'\"\n raise NameError\n end\n end", "def handle_command(command)\n cmd = command.command\n return Response.new unless cmd\n if cmd.start_with?(\"'\")\n cmd = \"say \" + cmd[1, cmd.length-1]\n end\n if cmd.start_with?('say ')\n command.say = cmd[4, cmd.length-4].strip\n end\n command.command = cmd.downcase\n\n handlers = find_handlers(command.body)\n response = Response.new\n response.command = command.command\n handlers.each { |h|\n h.handle(response, command)\n if response.handled; return response end\n }\n if !response.handled && response.direction\n response.message = \"You can't go that way.\"\n response.handled = true\n end\n response\n end", "def run_command(command)\n\t\tif is_command_valid?(command[:method])\n\t\t\tif is_there_a_lot? && is_a_create_command?(command[:method])\n\t\t\t\tputs \"A Parking lot already exists, You can close parking lot by 'close_parking_lot'\"\n\t\t\telse\n\t\t\t\tresult = @@lot.public_send command[:method], @@slots, @@cars, command[:arguments]\n\t\t\t\tputs \"\\n\" + result.to_s if result\n\t\t\tend\n\t\telse\n\t\t\tputs \"Invalid Command, Command: #{command[:method]}\"\n\t\tend\n\tend", "def room9\n #state 1 = new\n #state 2 = no boulder\n #state 3 = boulder\n\n if @room9 == 1\n\tputs 'You are on a footing parallel to a stream of water running east and west. The water originates from an opening to the east'\n\tputs 'and ends on the western wall. It is hitting what seems to be a door.'\n puts 'The pressure of the water is so great, you don\\'t think you could navigate through it to get to the door.'\n @room9 = 2\n end\n\n while true\n\n cmd = take_input\n\n if cmd.include? 'help'\n help\n elsif cmd.include? 'exit'\n exit_game\n elsif cmd.include? 'inventory'\n list_inventory\n elsif cmd.include? 'look'\n puts 'You are in a small round room with a passageways heading east and west.'\n elsif cmd.include? 'use'\n puts 'You can\\'t use that here'\n elsif cmd.include? 'climb' or cmd.include? 'ladder' or cmd.include? 'down'\n room9\n elsif cmd.include? 'east'\n room8\n else\n invalid_action\n end\n end\nend", "def handle_command(command)\n case command\n when 'stop'\n stop\n else\n raise \"Unknown command received: #{command}\"\n end\n self\n end", "def parse_command_state\n case @state_arg\n when :append\n name_token = expect_token :name\n\n @app.perform_append(name_token.value, parse_expression)\n when :list\n expect_token :terminator\n\n @app.perform_list\n when :exit\n expect_token :terminator\n\n @app.perform_exit\n when :print\n @app.perform_print parse_expression\n when :printlength\n @app.perform_printlength parse_expression\n when :printwords\n @app.perform_printwords parse_expression\n when :printwordcount\n @app.perform_printwordcount parse_expression\n when :set\n name_token = expect_token :name\n\n @app.perform_set(name_token.value, parse_expression)\n when :reverse\n name_token = expect_token :name\n\n @app.perform_reverse name_token.value\n else\n raise_parser_error \"Unexpected keyword #{current_token.value}... this shouldn't happen. Please report bug.\"\n end\n\n debug \"Command for #{@state_arg} completed. Resetting parser state to :root\"\n reset_state :root\n end", "def direction_parser(word)\n if (word == \"north\" or word == \"n\") and hero.location.north_room\n hero.location = hero.location.north_room\n elsif (word == \"south\" or word == \"s\") and hero.location.south_room\n hero.location = hero.location.south_room\n elsif (word == \"east\" or word == \"e\") and hero.location.east_room\n hero.location = hero.location.east_room\n elsif (word == \"west\" or word == \"w\") and hero.location.west_room\n hero.location = hero.location.west_room\n elsif (word == \"up\" or word == \"u\") and hero.location.up_room\n hero.location = hero.location.up_room\n elsif (word == \"down\" or word == \"d\") and hero.location.down_room\n hero.location = hero.location.down_room\n else\n invalid_direction\n end\n end", "def process_command(command)\n model = generate_model_from_text_file(command[:filename])\n case command[:command]\n when 'list'\n list_todos(model)\n when 'add'\n add_one_todo(model, command[:modifier])\n when 'remove'\n remove_one_todo(model, command[:modifier])\n when 'complete'\n mark_todo_complete(model, command[:modifier])\n end\n save_model_to_text_file(command[:filename], model)\n end", "def parse_command_string(command_string)\n # Split our command into segments to be further parsed\n command_segments = command_string.split(\" \")\n\n # Iterate over each command segment with the current index (i)\n command_segments.each_with_index do |command_segment, i|\n # Skip any command parameters, checks if segment contains a delimiter (,)\n next if command_segment.include? \",\"\n\n # Check which commdand we want to execute and execute the appropriate method\n case command_segment.upcase.to_sym\n when :MOVE\n self.move\n when :PLACE\n # Get our X, Y and direction information from the command params\n place_params = self.get_command_coords_and_direction(command_segments, i)\n\n # Pass the X and Y co-ordinates to the place method\n if place_params != false\n self.place place_params[:x], place_params[:y], place_params[:direction]\n end\n when :LEFT\n self.rotate :left\n when :RIGHT\n self.rotate :right\n when :REPORT\n self.report\n end\n end\n end", "def turn(command)\n @direction = ALLOWED_TURNS[ next_position_index(command) ]\n end", "def do_instruction(x)\n case x\n when x = \"L\"\n then turn_left\n when x = \"R\"\n then turn_right\n when x = \"M\"\n then move_forward\n else\n puts \"This is not a valid instruction\"\n end\n end", "def execute(command)\n if valid_command?(command)\n apply_command(command)\n else\n return 'Invalid command.'\n end\n end", "def room5\n #state 1 = new\n #state 2 = chest closed, locked\n #state 3 = chest closed, unlocked\n #state 4 = chest open, unlocked\n #state 5 = sword taken\n\n if @room5 == 1\n puts 'You walk down the narrow passageway into a small alcove. The room is barely big enough for you to stand in.'\n puts 'There is a treasure chest, a somewhat intricate designed etched into its wood panels. It emits a faint eerie glow.'\n @room5 = 2\n else\n puts 'You are in the small room with a treasure chest'\n end\n\n while true\n\n cmd = take_input\n\n if cmd.include? 'help'\n help\n elsif cmd.include? 'exit'\n exit_game\n elsif cmd.include? 'inventory'\n list_inventory\n elsif cmd.include? 'look'\n if @room5 == 2 or @room5 == 3\n puts 'You are in a very small room, with a treasure chest.'\n\t elsif @room5 == 4\n puts 'You are in a very small room, with an opened treasure chest. There is a sword inside of it.'\n\t elsif @room5 == 5\n puts 'You are in a very small room, with an opened empty treasure chest.'\n end\n elsif cmd.include? 'use'\n has_item, item = use_item cmd\n if has_item\n if item.eql? 'key'\n if @room5 == 2\n puts 'You insert the key into the keyhole and give it a quick turn.'\n\t\t puts 'The key audibly clicks into place and then snaps in half. Key has been removed from your inventory.'\n\t\t\t@inventory.delete('key')\n\t\t @room5 = 3\n\t\t end\n end\n end\n\t elsif cmd.include? 'open' or cmd.include? 'chest' or cmd.include 'unlock'\n\t if @room5 == 2\n\t puts 'You try to open the chest, but it seems to be locked.'\n\t elsif @room5 == 3\n\t puts 'You lift the lid of the chest, revealing a sword inside.'\n\t\t @room5 = 4\n\t else\n\t puts 'The chest is already open'\n\t end\t\n elsif cmd.include? 'sword'\n if @room5 == 4\n puts 'You take the sword. The glow surrounding the treasure chest slowly fades away.'\n @inventory.push('sword')\n @room5 = 5\n elsif @room5 == 5\n puts 'You already took the sword'\n\t else\n\t invalid_action\n\t end\n elsif cmd.include? 'west'\n room3\n else\n invalid_action\n end\n end\nend", "def dispatch(command)\n raise Commands::InvalidCommand unless command.valid?\n \n handler = @router.handler_for(command, @repository)\n handler.execute(command)\n end", "def room8\n #state 1 = new\n #state 2 = boulder\n #state 3 = boulder pushed\n if @room8 == 1\n puts 'You are standing on an open ledge, fairly high up from the ground beneath you. There is a huge boulder right on the edge.'\n puts 'The ground below you to the north has an opening from the east with water rushing out at high speeds towards a doorway to the west.'\n puts 'There is a passageway to the east.'\n @room8 = 2\n end\n\n while true\n\n cmd = take_input\n\n if cmd.include? 'help'\n help\n elsif cmd.include? 'exit'\n exit_game\n elsif cmd.include? 'inventory'\n list_inventory\n elsif cmd.include? 'look'\n puts 'You are on an open ledge, with a boulder and running water down below. The water is pouring out'\n puts 'of an opening from the east towards a doorway on the west.'\n elsif cmd.include? 'use'\n puts 'You can\\'t use that here'\n elsif cmd.include? 'boulder' or cmd.include? 'push'\n if @room8 == 2\n puts 'You give the boulder a heavy push. It rolls off the ledge to the ground below. It lands in the opening where the water'\n puts 'is pouring out of, completely stopping the flow of water.'\n @room8 = 3\n elsif @room == 3\n puts 'You already pushed the boulder. You see it in the ground below, blocking the east passageway.'\n\t end\n elsif cmd.include? 'west'\n room6\n elsif cmd.include? 'jump' or cmd.include? 'down'\n puts 'You jump down. The ledge was too high up, and your body can\\'t support the weight as you land.'\n die\n else\n invalid_action\n end\n end\nend", "def handle\r\n action_klass = Battle.find_action_klass(self.combat_command)\r\n if (!action_klass)\r\n client.emit_failure t(battle.unknown_command)\r\n return\r\n end\r\n\r\n self.names.each do |name|\r\n\r\n Battle.with_a_combatant(name, client, enactor) do |combat, combatant|\r\n if (combatant.is_subdued? && self.combat_command != \"escape\")\r\n client.emit_failure t('battle.must_escape_first')\r\n next\r\n end\r\n Battle.set_action(client, enactor, combat, combatant, action_klass, self.action_args)\r\n end\r\n end\r\n end", "def call_command\n verb = match.captures[match.names.index('command')]\n verb = normalize_command_string(verb)\n public_send(verb)\n end", "def update_phase3_basic_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Go to command input for previous actor\r\n phase3_prior_actor\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.index\r\n when 0 # attack\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 0\r\n # Start enemy selection\r\n start_enemy_select\r\n when 1 # skill\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 1\r\n # Start skill selection\r\n start_skill_select\r\n when 2 # guard\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 1\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n when 3 # item\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 2\r\n # Start item selection\r\n start_item_select\r\n end\r\n return\r\n end\r\n end", "def execute_action(action)\n case action\n when 1\n create_station\n when 2\n stations.size > 1 ? create_route : (puts 'Для создания маршрута нужно хотя бы 2 станции.')\n gets\n when 3\n routes.empty? ? (puts 'Маршрутов не создано.') : edit_route \n when 4\n create_train\n when 5\n system 'clear'\n move_train \n when 6\n system 'clear'\n add_carriage_to_train\n when 7\n remove_carriage\n when 8\n set_route\n when 9\n system 'clear'\n display_all_stations\n when 0\n abort\n else\n puts \"Неизвестная команда!\"\n end\n end", "def route(command)\n if command.count(\" \") == 2\n @code_writer.send(command.split(' ')[1], command.split(' '))\n else\n @code_writer.send(command)\n end\n end", "def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend", "def run_command(command)\n if command and respond_to?(command)\n send(command)\n else\n log_and_exit read_template('help')\n end\n end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def do_command( cmd )\n case cmd['command']\n when 'start_worker'\n start_worker( cmd, find_revision(cmd['revision']) )\n when 'signal_worker'\n manage_worker( cmd )\n when 'start_auto'\n start_auto( cmd, find_revision(cmd['revision']) )\n when 'stop_auto'\n stop_auto( cmd )\n when 'stop_daemon'\n @RUN_DAEMON= false\n when 'restart_workers_on_latest_revision' # Rolling restart on same daemon\n @RRESTART= true\n when 'restart_workers_on_latest_revision_and_quit' # Shutdown daemon and restart on another one\n @RRESTART= true\n @QUITTING= true \n when 'kill_daemon'\n send_status( 'Error', \"A kill request has been received, the daemon on #{@HOST} is now brutally terminating by calling exit()\")\n i_am_dead\n exit # Bye\n else\n send_status( 'Error', \"Unknown command '#{cmd['command']}'\" )\n end\n end", "def tick(command)\n return unless player_action(command)\n\n @creatures.each do |c|\n # TODO Calculate FOV if player is in range\n @level.do_fov(c)\n dest = @level.lookup(@player.x, @player.y)\n # TODO Use scent + decay to help creature chase the player.\n if c.fov.include?(dest)\n c.last_destination = dest\n start = @level.lookup(c.x, c.y)\n next if start == dest\n path = level.get_path(start, dest, true)\n if path\n dest = level.lookup(path[1].x, path[1].y)\n if level.creature_can_move?(c, dest)\n level.move_creature c, dest\n end\n end\n end\n end\n\n true\n end", "def interaction(character, world, current_room)\n\n loop do\n print \"***>\".indent(10)\n action = gets.chomp.downcase\n case action\n # Quit game.\n when \"quit\"\n quit_game(character)\n # Show help options.\n when \"help\"\n print_help\n # Show available exits.\n when \"exits\"\n puts\n current_room.print_exits\n puts\n # Check if entered direction is possible and move if yes. \n when \"north\", \"south\", \"east\", \"west\"\n if current_room.check_exits.include?(action)\n puts\n puts \"You move #{action}\".indent(10)\n puts\n location = current_room.exits[action]\n character.location = location\n current_room = world.load_room(location)\n current_room.print_room\n else\n puts\n puts \"You can not go that way!\".colorize(:red).indent(10)\n puts\n end\n else\n puts \"That is not a valid action, please try again. Type 'help' if you are stuck.\".colorize(:red).indent(10)\n end\n end\n\nend", "def input_commands\n @new_prompt.command_selection\n command = gets.chomp.upcase\n while command != 'EXIT GAME'\n @player_command = command\n handle_commands(@player_command)\n @new_prompt.command_selection\n command = gets.chomp.upcase\n end\n @new_prompt.exit_screen\n end", "def action_do(action)\n\t\tif action == \"a\"\n\t\t\tself.search_weapon\n\t\telsif action == \"s\"\n\t\t\tself.search_health_pack\n\t\telsif action == \"0\"\n\t\t\tself.attacks(@@ennemis[action.to_i])\n\t\telsif action == \"1\"\n\t\t\tself.attacks(@@ennemis[action.to_i])\n\t\tend\n\t\tputs \"\"\t\t\n\tend", "def command(key)\n keys = configuration.instance.keys\n cmd = eval \"#{keys}.#{key}\"\n cmd.capitalize! << \"Command\"\n case cmd\n when /QuitCommand/\n QuitCommand.new(@terminal)\n else\n NoOpCommand.new\n end\n end", "def run\n #Load the Hero File\n load_hero_file\n #Load dungeon at top level\n load_dungeon_file(@current_level)\n #display the hero's starting spot\n clear_message_box\n #get input either an action or a movement.\n while true\n update_screen\n key = @ui.instr\n case key\n when 'B','b' #turn left\n @hero_direction = POS_TURN.rotate!(-1)[0]\n when 'N','n' #turn right\n @hero_direction = POS_TURN.rotate!(1)[0]\n when 'M','m' #move ahead\n move_hero\n when 'A','a' #attack\n hero_attack if @monster_detected\n when 'C','c' #cast\n if @stats[:aura] > 0 && !@spells.empty?\n cast_spell\n else\n @ui.place_text('FIZZZZ....'.ljust(20),1,2,DungeonOfDoom::C_BLACK_ON_YELLOW)\n @ui.place_text(MSG_NOTHING.ljust(20),1,3,DungeonOfDoom::C_BLACK_ON_YELLOW)\n end\n when 'G','g' #get\n get_object\n when 'P','p' #potion\n drink_potion\n when 'R','r' #reveal\n light_room\n when 'S','s' #save?\n #not implemented yet\n when 'Q','q' #quit\n if ask_question('DO YOU REALLY WANT', 'TO QUIT? (Y/N)') == 'Y'\n break\n else\n clear_message_box\n end\n else\n #do nothing\n end\n #automated game elements\n\n #monster detected\n monster_attack if @monster_detected\n #hero died\n if @stats[:strength] <= 0\n game_over\n break\n end\n #hero gets idol!\n if @idol_found\n win_game\n break\n end\n end\n end", "def getcommand(msg)\n msg.message =~ /#{$COMMAND}(\\w+)/\n commandused = $1\n case commandused\n when 'roll', 'nobotch', 'special'\n if msg.message =~ /#{commandused}\\s*help\\s*$/\n # show command help\n \"#{HELP_TEXT(commandused)}\"\n elsif msg.message =~ /#{commandused}\\s+(.*)\\s*$/\n begin\n \"<b>#{$names[msg.actor]}: </b>#{substitute($1,commandused)}\"\n rescue ArgumentError => e\n \"\\\"<b>Error</b>: #{e}</b>\\\",#{[msg.actor]}\"\n end\n end\n \n when 'help'\n \"<br>I'm here to make your V20 playing much more pleasureable!<br><br>\n Commands:<br>\n <b>#{$COMMAND}roll</b> &lt;input&gt; - Regular ol' dice rollin!<br>\n <b>#{$COMMAND}nobotch</b> &lt;input&gt; - Roll dice where 1s don't botch!<br>\n <b>#{$COMMAND}special</b> &lt;input&gt; - Make those 10s count DOUBLE!<br><br>\n\n use '<b>help</b>' as the input for more information on any command!\"\n else\n #wat r u doin dolan pls\n \"wat r u doin stahp\"\n end\nend", "def get_command\r\n\r\n print \"\\nType a Command to get to work (e.g. make-list to start a new list of todo´s)\r\n \\n( type <show-commands> to see your options)\r\n \\n\"\r\n\r\n cmd, target, *args = gets.chomp.downcase.split(' ')\r\n\r\n \r\n case cmd\r\n when 'up'\r\n @lists[target].up(*args.map(&:to_i))\r\n\r\n when 'down'\r\n @lists[target].down(*args.map(&:to_i))\r\n\r\n when 'swap'\r\n @lists[target].swap(*args.map(&:to_i))\r\n\r\n when 'sort'\r\n @lists[target].sort_by_date!\r\n\r\n when 'priority'\r\n if @lists[target].items.empty?\r\n puts \"\\nList #{target} does not contain any Todos yet! You can add some next.\r\n \\nWould you like to do that now?\r\n \\n[y] to create new Todo in #{target}\r\n \\n[n] to go back home.\r\n \\n\"\r\n what = gets.chomp.downcase\r\n\r\n if what == \"y\"\r\n @lists[target].add_item(*TodoBoard.todo_configurator(target))\r\n puts \"\\nYay, you created a new Todo! \\n\"\r\n @lists[target].print_priority\r\n else\r\n return true\r\n end\r\n\r\n else\r\n @lists[target].print_priority\r\n end\r\n\r\n when 'print'\r\n if args.empty?\r\n @lists[target].print\r\n else\r\n @lists[target].print_full_item(*args.first.to_i)\r\n end\r\n\r\n when 'make-list'\r\n @lists[target] = List.new(target.to_s)\r\n puts \"\\nList '#{target}' was successfully created!\\n\"\r\n\r\n when 'ls'\r\n @lists.each_key do |key|\r\n puts key\r\n end\r\n\r\n when 'showall'\r\n @lists.each do |k, v|\r\n v.print\r\n end\r\n\r\n when 'all-priorities'\r\n @lists.each do |k, v|\r\n v.print_priority\r\n end\r\n\r\n when 'make-todo'\r\n @lists[target].add_item(*TodoBoard.todo_configurator(target)) # make-todo calls self.todo_configurator to get arguments for add_item\r\n puts \"\\nYay, you created a new Todo! \\n\"\r\n\r\n when 'remove'\r\n self.remove_todo(*args.first.to_i, target)\r\n\r\n when 'delete-list'\r\n @lists.delete(target)\r\n\r\n when 'quit'\r\n return false\r\n\r\n when 'check'\r\n @lists[target].toggle_item(*args.first.to_i)\r\n\r\n when 'purge'\r\n @lists[target].purge\r\n\r\n when 'show-commands' || '<show-commands>' || 'show commands'\r\n puts \"--COMMANDS--\"\r\n p \"You can type the following commands, followed by the parameters (all seperated by \" \" and withouth the <>)\"\r\n puts \"---\"\r\n puts \"CREATE LISTS AND TODO-ITEMS\"\r\n p \"make-list <list name>\"\r\n p \"=> (Create a new list)\"\r\n p \"make-todo <list name>\"\r\n p \"=> (Create a new todo)\"\r\n p \"---\"\r\n p \"DISPLAY LISTS AND TODO ITEMS\"\r\n p \"print <list name>\"\r\n p \"=> (Print a specific list)\"\r\n p \"print <list name> <item-index>\"\r\n p \"=> (shows more detail on specific item on list)\" \r\n p \"ls\" \r\n p \"=> (shows all lists)\"\r\n p \"priority <list name>\"\r\n p \"=> (shows top item on list)\"\r\n p \"all-priorities\"\r\n p \"=> (displays all priority items from all lists)\"\r\n p \"---\"\r\n p \"MANAGE LISTS AND TODO ITEMS\"\r\n p \"sort <list name>\"\r\n p \"=> (sorts list by deadline)\"\r\n p \"swap <list name> <index1> <index2>\"\r\n p \"=> (swaps items with the indexes on list)\"\r\n p \"up <list name> <index> <optional amount of ups>\"\r\n p \"=> (moves item with index UP on list. If no amout is put, item is moved up once. If amount is put, item is moved up amount times.\"\r\n p \"down <index> <optional amount of downs>\"\r\n p \"=> (moves item with index DOWN on list. If no amout is put, item is moved down once. If amount is put, item is moved down amount times.\"\r\n p \"remove <list name> <item-index>\"\r\n p \"=> (Removes item with index on list)\"\r\n p \"check < list name> <item-index>\"\r\n p \"=> (Checks off/marks as done item index on list)\"\r\n p \"---\"\r\n p \"END THE PROGRAM\"\r\n p \"quit\"\r\n p \"=> (ends program)\"\r\n\r\n else\r\n print \"Sorry, that command is not recognized.\"\r\n end\r\n\r\n true\r\n end", "def send_command(house_and_unit, command)\n house_code, unit_code = select_code(house_and_unit)\n @marshaller.send(X10_PREFIX + house_code + unit_code + ADDRESS_SUFFIX)\n @marshaller.send(X10_PREFIX + house_code + COMMAND_CODE_TABLE[command] +\n COMMAND_SUFFIX)\n end", "def r_command\n @heading = case @heading\n when \"N\" then \"E\"\n when \"E\" then \"S\"\n when \"S\" then \"W\"\n when \"W\" then \"N\"\n end\n end" ]
[ "0.72250944", "0.694959", "0.68654424", "0.68584615", "0.6844924", "0.68447775", "0.6775846", "0.66902363", "0.6613155", "0.65450585", "0.65082353", "0.6505146", "0.64745176", "0.6458155", "0.6451383", "0.6414209", "0.6382764", "0.6365964", "0.6321472", "0.63044596", "0.63027173", "0.6272814", "0.62691486", "0.6261668", "0.6252972", "0.6224381", "0.6220361", "0.6210109", "0.61995167", "0.6182838", "0.6140697", "0.61084014", "0.6102182", "0.6095202", "0.60877", "0.60816884", "0.6077242", "0.6064203", "0.60580295", "0.6043927", "0.6041071", "0.60100913", "0.6009008", "0.599614", "0.5991757", "0.59889406", "0.5981063", "0.59696233", "0.5968044", "0.5967396", "0.5956336", "0.5955051", "0.5934635", "0.5914817", "0.59103805", "0.59067243", "0.589152", "0.58892536", "0.58857954", "0.5880363", "0.5870863", "0.5862268", "0.58549595", "0.5827526", "0.58228946", "0.58139044", "0.58007985", "0.5774428", "0.5747534", "0.5745642", "0.5732527", "0.5730772", "0.5706734", "0.56873465", "0.5684369", "0.56842214", "0.5681849", "0.56800884", "0.5662273", "0.56586164", "0.5655615", "0.5644249", "0.5642101", "0.56269366", "0.56269366", "0.56269366", "0.56269366", "0.56269366", "0.56269366", "0.56267935", "0.5624541", "0.5621546", "0.5616505", "0.5615142", "0.5615119", "0.5608515", "0.560812", "0.5605698", "0.5604822", "0.5602076" ]
0.7829914
0
Returns the current player's score
def tally player = @game.player output = "" output << "Tally at present is #{player.score}\n" output << "You have killed #{player.monsters_killed} monsters so far...\n" if rand > 0.5 puts output output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_score()\r\n return @player.score()\r\n end", "def score\n \n case @points\n when 0 \n @player_score[@points] = 'Love'\n return @player_score[@points]\n when 1 \n @player_score[@points] = 'Fifteen'\n return @player_score[@points]\n when 2 \n @player_score[@points] = 'Thirty'\n return @player_score[@points]\n when 3 \n @player_score[@points] = 'Forty'\n return @player_score[@points]\n else \n return @points \n end\n end", "def score\n puts \"\\n---PLAYER 1: #{self.players_score} -- DEALER: #{self.dealers_score}---\"\n end", "def score(player)\n @score[player]\n end", "def score\n puts \"---#{player.name.upcase}: #{player.score} -- #{dealer.name.upcase}: #{dealer.score}---\"\n end", "def score\n return @score\n end", "def player_score()\n\t\tparams.each do |name, guess| #recieves guess from form on guess.slim\n\t\t\tsession[:player].each do |z|\n\t\t\t\tif z.name == name\n\t\t\t\t\tz.guess = guess.to_i\n\t\t\t\t\tz.round_score = (z.guess - session[:movie][session[:round_count]].ratings['critics_score'].to_i).abs\n\t\t\t\t\tz.total_score += (z.guess - session[:movie][session[:round_count]].ratings['critics_score'].to_i).abs\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def get_score()\n score = Hash.new(0)\n players.each {|player| score[player.name] = player.score}\n score\n end", "def current_score\n \"Score: #{@player_1_name} has #{@player_1_wins} points, #{@player_2_name} has #{@player_2_wins} points.\"\nend", "def userScore\n settings.score = session[:user].getScore(settings.username)\n end", "def find_score \n player = self.find_winner\n if player == 1\n return @player_1.life\n end\n return @player_2.life\n end", "def call_score\n if @player1.points == @player2.points\n tie_score\n elsif advantage?\n advantage \n else \n \"#{current_server.score} #{current_server.opponent.score}\"\n end\n end", "def score(game)\n if game.winner.nil?\n 0\n elsif game.winner == game.computer_player\n 1\n else\n -1\n end\n end", "def score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{c_score}\"\n puts \" \"\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3 && opponent.points != 3 # Three points scored by each side and a player has 1 more point than his/her opponent.\n return 'advantage' if @points > 3 && @points == opponent.points + 1 # Three points scored by each side and a player has 1 more point than his/her opponent.\n return 'deuce' if @points >= 3 && @points == opponent.points # Both players score at least 3 points and the scores are equal.\n return 'win' if @points > 3 && @points == opponent.points + 2 # The first player to have at least 4 points total and at least 2 more points than opponent.\n end", "def game_score\n \n if (@player1.points > 3 || @player2.points > 3) && (@player2.points - @player1.points > 1 || @player1.points - @player2.points > 1)\n return \"#{@player1.score}\"\n elsif (@player1.points >= 3 && @player2.points >= 3) && (@player2.points - @player1.points == 1 || @player1.points - @player2.points == 1)\n return \"#{@player1.score}\"\n elsif @player1.points >= 3 && @player2.points - @player1.points == 0\n return \"#{@player1.score}\"\n elsif @player1.points == @player2.points && @player1.points < 3 \n return \"#{@player1.score} all\"\n elsif @player1.points != @player2.points && @player1.points <= 3 && @player2.points <= 3 \n return \"#{@player1.score}: #{@player2.score}\"\n else\n return \"this is an unfamiliar scoring situation\"\n end\n end", "def score\n #When the player doesn't have enough points to win the game\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n \n #When the player has exactly enough points to potentially end the game\n if @points == 3 \n if deuce?\n return 'deuce' \n else\n return 'forty'\n end\n end\n\n #When player has more than enough point to end a game deuce/advantage \n if @points > 3\n if deuce?\n 'deuce'\n elsif advantage?\n 'advantage'\n elsif disadvantage?\n 'disadvantage'\n elsif won_game?\n 'won game' \n else\n 'lost game'\n end\n end \n end", "def score\n @score\n end", "def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end", "def score_player(player)\n score = 0\n player.hand.each do |card|\n score += card.value\n end\n player.update_score(score)\n end", "def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end", "def score(player)\n\t$running = false\n\tplayer.score += 1\n\t$gui.show_scored(player.name)\n\t$gui.show_info()\n\t$gui.update_score($p1.score, $p2.score)\nend", "def score\n return nil if won?\n return super if tie_break?\n return 'Deuce' if deuce?\n\n case advantage\n when 1 then \"Advantage #{player1}\"\n when 2 then \"Advantage #{player2}\"\n else game_score\n end\n end", "def current_score\n\t\treturn @game_stack\n\tend", "def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end", "def score(board, player)\n winner = board.find_winner\n return 1000000 if winner && winner == player\n return -1000000 if winner && winner == opponent(player)\n score_for(board, player) - score_for(board, opponent(player))\n end", "def score\n calculator.score\n end", "def player_score(score)\n @grand_total += (score)\n end", "def score\n properties['score']\n end", "def score\n rate.score\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'duece' if @points == 3 && @opponent.points == 3\n return 'forty' if @points == 3\n game_won?\n end", "def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end", "def formulate_score()\n @player_score = @player_score.sort!().reverse!().join().to_i()\n p \"#{@players[0].get_name}'s score is #{@player_score}\"\n check_score()\n end", "def score\n @score || calculate_score\n end", "def print_score\n puts \"Player Score: #{@player_score}\\tComputer Score: #{@computer_score}\"\n end", "def total_score\n return @plays.reduce(0) { |memo, word| memo + Scrabble::Scoring.score(word) }\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3 && @opponent.points != 3\n return 'deuce!' if @points >= 3 && @points == @opponent.points \n return 'advantage' if @points > 3 && @points == @opponent.points + 1\n return 'winner' if @points > 3 && @points == @opponent.points + 2\n end", "def next_score(player)\n if player == 1\n get_score(@player1,@player2)\n else\n get_score(@player2,@player1)\n end\n\n end", "def updateScore(score, result)\n\tif result == \"P1 wins!\"\n\t\tscore[\"Player 1\"] += 1\n\telsif result == \"P2 wins!\"\n\t\tscore[\"Player 2\"] += 1\n\tend\n\tputs result\n\tputs \"Current score:\\n Player 1: \" + score[\"Player 1\"].to_s + \" Player 2: \" + score[\"Player 2\"].to_s + \"\\n\\n\"\n\treturn score\nend", "def score\n @result.to_i\n end", "def player_win_percentage\n (games_won/user_games)\n end", "def score\n return 'win' if (@points >= 4 && @points >= opponent.points + 2)\n return 'deuce' if (@points >= 3 && @points == opponent.points)\n return 'advantage' if (@points >= 3 && @points == opponent.points + 1)\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3\n end", "def formulate_score()\n @player_score = @player_score.sort!().reverse!().join().to_i()\n p \"#{@players_joined[0]}'s score is #{@player_score}\"\n check_score()\n end", "def get_score\n @score ||= calculate_score\n end", "def total_score\n total_score = 0\n plays.each do |word|\n total_score += Scrabble::Scoring.score(word)\n end\n return total_score\n end", "def update_score\n if @round_won\n @player.increment_rounds_won\n else\n @player.increment_rounds_lost\n end\n end", "def to_i\n return self.score\n end", "def get_total_score\n\t\tquestion_scores = Question_score.for_game_record(self.id)\n\t\tscore = 0\n\t\tquestion_scores.length.times do |i|\n\t\t\tscore += question_scores[i].score\n\t\tend\n\t\tscore\n\tend", "def score_game\n self.score = frames.reduce(0) { |sum, frame| sum + score_frame(frame) } \n end", "def total_score\n plays.inject(0) { |sum, word| sum + Scoring.score(word) }\n end", "def score\n 2 * won + drawn + noresult\n end", "def scores\n return Game.score(self.card_numbers self.user_id), Game.score(self.card_numbers nil)\n end", "def get_score\n \"#{@name} #{@lives}/3\"\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3\n end", "def score\n @scores[ result.key ]\n end", "def result\n @user_score\n end", "def score\n unless self.opponent.points > 3 \n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n end\n if @points == 3 && (self.opponent.points < 3)\n return 'forty' \n elsif @points - self.opponent.points == 0 \n return 'deuce'\n elsif @points - self.opponent.points == 1\n return \"advantage: #{self.name}\"\n elsif self.opponent.points - @points == 1\n return \"advantage: #{self.opponent.name}\"\n elsif @points - self.opponent.points >= 2\n return \"game: #{self.name}\"\n else \n return \"game: #{self.opponent.name}\"\n end\n\n end", "def show_score\n puts\n @@score.each do |player, score|\n print \"- #{player.capitalize}: #{score} -\"\n end\n puts\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3 \n end", "def position\n if !@scores.nil? and @scores.include? @name\n begin\n (@scores[@name] - @scores.values.min) / (@scores.values.max - @scores.values.min)\n rescue ZeroDivisionError\n # For cases when max is equal to min, which can happen any time or always\n # when only one player is playing.\n 1.0\n end\n else\n 1.0\n end\n end", "def updateScore(score, result)\n\tif result == \"Player 1 wins this round!\"\n\t\tscore[0] += 1\n\telsif result == \"Player 2 wins this round!\"\n\t\tscore[1] += 1\n\telsif result == \"Tie!\"\n\t\tscore[2] += 1\n\tend\n\treturn score\nend", "def get_score\n\t\t# ruby is rounding here\n\t\tthis_score = 2.3 * self.imdb_score\n\t\t# had to add this if/else because some movies are missing years\n\t\tif self.year == nil\n\t\t\tthat_score = 0\n\t\telse\n\t\t\tthat_score = self.year / 2000\n\t\tend\n\t\tthe_score = this_score - that_score\n\t\treturn the_score + self.sci_fi_bonus\n\tend", "def calculate_score\n #set default user score value to 0 in the database but to prevent any errors and remove database dependencies i am including this line in the model as well\n score || 0\n self.games.each do |game|\n score+=game.points\n end\n score\n end", "def score\n last_30_score\n end", "def handle\n self.status\n output << \"Your final score is => #{player.score}\\n\"\n end", "def get_games_won()\n return @score_count.get_games_won()\n end", "def update_score()\r\n @score += GAME_PRESET[\"score_increment\"]\r\n end", "def get_score(num)\n return @game[num]\n end", "def update_score()\n\t\t# Uses ELO rating to calculate new rank for both users. Ref: https://metinmediamath.wordpress.com/2013/11/27/how-to-calculate-the-elo-rating-including-example/\n\t\t# Updates score by adding game scores to players score\n\tend", "def score \n return 'love' if @points == 0 \n return 'fifteen' if @points == 1 \n return 'thirty' if @points == 2 \n return 'forty' if @points == 3\n end", "def givepoints \n x = comparison(@player_choice, @opponent_choice)\n if x == -1\n @player_score += 1\n elsif x == 0\n @player_score += 0\n @opponent_score += 0\n elsif x == 1\n @opponent_score += 1\n end \n return x\n end", "def score\n @cards.map(&:value).inject(:+)\n end", "def score\n active_set.score\n end", "def score\n @total_score = 0\n @current_roll = 0\n @frame = 1\n\n while rolls?\n set_roll_logic\n if @frame > 10\n return @total_score\n else\n score_frame\n end\n end\n return @total_score\n end", "def total_score\n score || 0 #pos - neg\n end", "def score\n @score ||= (\n total = 0\n words.each do |word, rank|\n total += score_word(word, rank)\n end\n total\n )\n end", "def score\n suit_score = [\n Suit.spades,\n Suit.clubs,\n Suit.diamonds,\n Suit.hearts,\n Suit.none\n ].index(suit) * 20 + 40\n\n (number - 6) * 100 + suit_score\n end", "def get_score\n\t\tscore = ((360000/((@end_time - @start_time).to_f + @save_time.to_f))*((@number_of_correct-@number_of_hint).fdiv(@number_of_correct+1))).truncate(2)\n\t\tif score < 0\n\t\t\treturn 0\n\t\telse\n\t\t\treturn score\n\t\tend\n\tend", "def gen_score\n ## Calculate the score here!\n\n total_score = victories + coins/3 + blues + yellows + purples + leaders + blacks\n ## Greens\n greens = [tablets, compasses, gears]\n total_score += (greens.min*7) + greens[0]**2 + greens[1]**2 + greens[2]**2\n self.score = total_score\n end", "def add_to_player_score (player)\r\n\tplayer.player_wins += 1\r\n\t@total_number_of_plays += 1\r\n\tend", "def score_player(player,score)\n\t\tputs \"|#{player[0]}: #{score[0]} |_SCORE_| #{player[1]}: #{score[1]}|\\n\\n\".colorize(:red) \n\tend", "def final_score(player1, player2)\n puts \"======FINAL SCORE======\"\n if player1.score > player2.score\n puts \"#{player1.name} wins!\"\n else\n puts \"#{player2.name} wins!\"\n end\n player1.display_score\n player2.display_score\n end", "def calculateScore\n\t\tif @game\n @score += [@gridPick.associatedTimer-@game.time,0].max\n\t\telse\n\t\t\t@score = 0\n\t\tend\n\tend", "def score\n # add score caching\n total = 0\n self.votes.each do |vote|\n total += vote.value\n end\n total\n end", "def current_pts\n self.score\n end", "def score\n @grpc.score\n end", "def display_scores\n puts \"P1: #{@player1.lives}/3 vs P2: #{@player2.lives}/3\"\n end", "def score(depth)\n # print depth\n # If state has already been calculated as win or loss,\n # Return score\n if @score != nil\n return @score\n end\n # If @game is over, return appropriate score\n if won?\n best_score = self.class::MAX_SCORE - depth # player won\n elsif lost?\n best_score = -self.class::MAX_SCORE + depth # player lost\n elsif done?\n best_score = 0 # draw\n elsif depth > self.class::MAX_DEPTH && !force_analysis\n # If too deep, use game-specific scoring\n # Default is just to give score of 1 (slightly better than draw)\n # print \".\"\n best_score = heuristic_score\n else\n # Otherwise find and score best move for opponent\n best_score = best_move_with_score(depth + 1)[1]\n end\n # Add score to master list and return it\n if best_score == self.class::MAX_SCORE || best_score == -self.class::MAX_SCORE\n @score = best_score\n end\n # print best_score\n best_score\n end", "def get_expected_score(player_rating, opponent_rating)\n 1.0 / (1.0 + 10.0 ** ((opponent_rating.to_f - player_rating.to_f) / 400.0))\n end", "def score\n score_list = [self.wins.size, self.losses.size, self.tie.size]\n return score_list\n end", "def score(board, player)\n new_words(board).reduce(player.rack_capacity == @move.size ? 20 : 0) do |total, word|\n total += word.score\n end\n end", "def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end", "def increment_win_score\n PlayerModelContracts.invariant(self)\n @score = @score + 1\n end", "def get_score(point_winner,point_loser)\n if point_winner.points < 40\n point_winner.points = point_winner.next_point\n if point_winner.points == 40 && point_loser.points == 40\n point_winner.stage = point_loser.stage = 'Deuce'\n else\n \"#{@player1.points}-#{@player2.points}\"\n end\n else\n stage = get_stage(point_winner,point_loser)\n if stage == 'Game'\n \"Game won by #{point_winner.name}\"\n elsif stage == 'Advantage'\n \"Advantage #{point_winner.name}\"\n else\n \"Deuce\"\n end\n end\n end", "def score_player\n raise 'Method score_player cannot be called directly. It must be overridden in a child class first.'\n end", "def score\n populate_frames.inject(0) {|a,v| a+ v.frame_total}\n end", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def num_points_scored(playerName)\n player_stats(playerName)[:points]\nend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def display_score\n puts \"-----#{@name}-----\"\n puts \"Score: #{@score} \"\n puts \"Lives left: #{@lives}\"\n puts \"---------------\"\n end" ]
[ "0.8814937", "0.79552794", "0.790004", "0.7848975", "0.7746376", "0.7688142", "0.76390046", "0.75503564", "0.7495383", "0.7464075", "0.7458346", "0.7428482", "0.7374574", "0.73685807", "0.73591703", "0.7312185", "0.7303318", "0.7273319", "0.72651696", "0.723318", "0.7214507", "0.719158", "0.71800286", "0.71663487", "0.7160316", "0.71273786", "0.7114288", "0.7097553", "0.7083851", "0.70653045", "0.7048353", "0.704819", "0.70450574", "0.701842", "0.7016489", "0.7014944", "0.70008564", "0.6964247", "0.6961556", "0.6947811", "0.6897259", "0.687544", "0.687347", "0.6852719", "0.6846011", "0.68389416", "0.6825912", "0.6822491", "0.6822355", "0.6817056", "0.6803268", "0.680299", "0.6793295", "0.6783899", "0.6783899", "0.67787063", "0.67534566", "0.67525715", "0.67474085", "0.67446995", "0.67415184", "0.673755", "0.67321074", "0.67283165", "0.6722028", "0.67063457", "0.67025673", "0.6701922", "0.6698691", "0.66863585", "0.6681155", "0.6679922", "0.6676658", "0.6658921", "0.6658173", "0.66414213", "0.6634575", "0.6633371", "0.66303784", "0.66200054", "0.66164607", "0.66120803", "0.6605165", "0.660178", "0.66012156", "0.65921146", "0.658788", "0.65791965", "0.65777755", "0.6575935", "0.657319", "0.65648806", "0.65338135", "0.65320843", "0.6520017", "0.6519612", "0.65105927", "0.6505871", "0.64822394", "0.64821804", "0.64804256" ]
0.0
-1
Allows the player to change the current state of the game to FightingState
def fight monster = @game.current_room_model.monster player = @game.player return unless monster @game.state = FightingState.new @game if not player.weapons.empty? @game.state.status # Ask for weapon else @game.state.handle( nil ) # Start the fight directly end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fight\n @state.fight(self)\n end", "def fight (game)\n @state.fight(self, game)\n end", "def game_state\n end", "def change_dealer\n game_state.dealer_seat = new_dealer_seat \n end", "def state_on_localgame\n @log.debug(\"Net_state: change to state state_on_localgame\")\n @network_state = :state_on_localgame\n make_state_change_ntfy(:ntfy_state_on_localgame)\n end", "def resetStates()\r\n @players.each do |player|\r\n if(player.money > 0)\r\n player.state = \"fine\"\r\n else\r\n player.state = \"broke\"\r\n end\r\n end\r\n end", "def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end", "def game_state\n\t\t\"YOURTURN #{self.current_round} #{@hunter.to_state}, #{@prey.to_state}, W[#{@walls.map{|w| w.to_state}.join(\", \")}]\"\n\tend", "def game_state\n if @game_state.nil?\n @game_state = GameState.new(@player_count,@mode, 6, 7)\n end\n @game_state\n end", "def state_on_netgame\n @log.debug(\"Net_state: change to state state_on_netgame\")\n @network_state = :state_on_netgame\n make_state_change_ntfy(:ntfy_state_on_netgame)\n end", "def change_current_player\n game_state.current_player_seat = next_seat\n end", "def update\n @@game_state.update unless Game.fading? \n \n # update fading\n Game.end_fade! if Gosu::milliseconds >= @@end_fade and Game.fading?\n \n #update changing between game states\n if @@change_game_state and not Game.fading?\n @@game_state = @@change_game_state\n @@change_game_state = nil\n Game.fade_on(FadingTime)\n end\n end", "def game_over args, win_or_lose\n # keep track of whether you won or lost\n args.state.game_state = win_or_lose\nend", "def state\n @game.state\n end", "def white_turn\n @teams[:white].current_team = true\n @teams[:black].current_team = false\n @current_team = @teams[:white]\n end", "def passing\n state(\"passing\")\n end", "def toggle_turn\n if @turn == 0\n @turn = 1\n else\n @turn = 0\n end\nend", "def state_on_table_game_end\n @log.debug(\"Net_state: change to state state_on_table_game_end\")\n @network_state = :state_on_table_game_end\n make_state_change_ntfy(:ntfy_state_on_table_game_end)\n end", "def set_battle_entry(v = true)\n @was_fighting = v\n end", "def current_player_switch()\n if @current_player == 0 \n @current_player = 1\n elsif @current_player == 1 \n @current_player = 0\n end\n end", "def game_state(game_id)\n\n end", "def update(state_manager, game)\n\n end", "def black_turn\n @teams[:white].current_team = false\n @teams[:black].current_team = true\n @current_team = @teams[:black]\n end", "def updateGameState\n\t\t#Updates the duration in which a user input has no immediate action.\n\t\tif !@keyIdle\n\t\t\t@keyIdleCount = @keyIdleCount + 1\n\t\t\tif @keyIdleCount == @keyIdleMax\n\t\t\t\t@keyIdle = true\n\t\t\t\t@keyIdleCount = 0\n\t\t\t\t@keyIdleMax = 0\n\t\t\tend\n\t\t\tif !@hero.sprite.walking and @keyIdleCount == 8\n\t\t\t\t@keyIdle = true\n\t\t\t\t@keyIdleCount = 0\n\t\t\t\t@keyIdleMax = 0\n\t\t\tend\n\t\tend\n\t\treturnState = @nextGameState\n\t\t@nextGameState = self\n\t\treturn returnState\n\tend", "def change_obstacle_states\n @linked_obstacles.each do |i|\n i.switch_state\n end\n end", "def state_ontable_lessplayers\n @log.debug(\"Net_state: change to state state_ontable_lessplayers\")\n @network_state = :state_ontable_lessplayers\n make_state_change_ntfy(:ntfy_state_ontable_lessplayers)\n end", "def update_current_state(player)\n player.correct_letters.each do |key, values|\n values.each do |index|\n player.current_state[index] = key\n end\n end\n end", "def pass_turn\n if (self.pass?)\n end_game\n else\n self.update_attribute(:pass, true)\n end\n end", "def update_state\r\n case @state\r\n when STATE_PICK\r\n @ip1.copy! @ip\r\n Sketchup::set_status_text \"[WALL] Click for end of wall\"\r\n Sketchup::set_status_text \"Length\", SB_VCB_LABEL\r\n Sketchup::set_status_text \"\", SB_VCB_VALUE\r\n @state = STATE_PICK_NEXT\r\n\twhen STATE_PICK_NEXT\r\n\t\tself.draw_wall\r\n\t\treset\r\n end\r\nend", "def change_state(contestant_symbol, contestant_move)\n\t\t@current_state[contestant_move] = contestant_symbol\n\tend", "def set_game_state s=''\n @state = s\n end", "def getFinalState()\r\n dealer_score = @dealer.hand.score\r\n case @dealer.state\r\n when \"bust\"\r\n #every player that didnt bust wins\r\n @players.each do |player|\r\n if(player.state != \"bust\")\r\n player.state = \"won\"\r\n else\r\n player.state = \"lose\"\r\n end\r\n end\r\n when \"fine\"\r\n #everyone with a lower score than the dealer loses, everyone with a higher score that didnt bust wins\r\n @players.each do |player|\r\n if(player.state == \"bust\")\r\n player.state = \"lose\"\r\n elsif(player.hand.score < dealer_score)\r\n player.state = \"lose\"\r\n elsif(player.hand.score > dealer_score)\r\n player.state = \"won\"\r\n else\r\n player.state = \"push\"\r\n end\r\n end\r\n when \"blackjack\"\r\n #everyone lower score loses, everyone equal score pushes\r\n @players.each do |player|\r\n if(player.hand.score == dealer_score)\r\n player.state = \"push\"\r\n else\r\n player.state = \"lose\"\r\n end\r\n end\r\n end\r\n end", "def change_player \n if @current_player == 0\n @current_player = 1\n elsif @current_player == 1\n @current_player = 0\n end\n end", "def switchgamemode(name)\r\n\t\t\t#gamelog \"Switching gamemode to #{name}\"\r\n\t\t\t@gamemode = name\r\n\t\tend", "def gamestate\n\t\t@game_state\n\tend", "def state\n @gameState.state\n end", "def update\n if @state == :game\n @player.update\n @level.update\n end\n end", "def state=(state)\n if not STATES.include? state\n raise PreconditionError, \"Invalid game victory state.\"\n end\n super\n changed(true)\n notify_observers U_COMPLETED, state, self.currentPlayer\n if not self.state == state\n raise PostconditionError, \"State not set correctly.\"\n end\n self.state\n end", "def turn_on!\n @turned_off = false\n end", "def pbToggleFollowingPokemon\n if $game_switches[Following_Activated_Switch]==true\n if $game_switches[Toggle_Following_Switch]==true\n $PokemonTemp.dependentEvents.remove_sprite(true)\n pbWait(1)\n $game_switches[Toggle_Following_Switch]=false\n else\n $FollowingFinishedSurfing = false\n $PokemonTemp.dependentEvents.refresh_sprite\n pbWait(1)\n $game_switches[Toggle_Following_Switch]=true\n end\n end\nend", "def update\n super\n if BattleManager.in_turn?\n process_event\n process_action\n end\n BattleManager.judge_win_loss unless BattleManager.victory_phase?\n if BattleManager.victory_phase?\n if @victory_score.done and @victory_score.active\n sfx = CP::VICTORY::IMAGE_SFX\n vol = CP::VICTORY::SFX_VOL\n pit = CP::VICTORY::SFX_PIT\n RPG::SE.new(sfx, vol, pit).play unless sfx.nil?\n @victory_score.active = false\n @victory_item.active = true\n end\n end\n end", "def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end", "def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end", "def toggle_state\n puts \"******* toggle_state *******\"\n end", "def flip_coin (game)\n @state.flip_coin(self , game)\n end", "def set_state(modes = nil)\r\n @modes = modes\r\n @online = true\r\n end", "def outOfGame\n @inGame = false\n end", "def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end", "def change_state(move_x)\n if move_x == 0\n @state = @standing\n else\n @state = (milliseconds / 175 % 2 == 0) ? @walkL : @walkR\n end\n\n if @vy < 0\n @state = @jump\n end\n end", "def switch_players\n @player1_turn = !@player1_turn\n end", "def update_state\n raise \"Nothing to do\"\n end", "def game_state_update(parsed_state)\n\t\tgame_state = nil\n\t\t@mutex.synchronize do\n\t\t\tif parsed_state['player_data'] and my_data = parsed_state['player_data'][@player_id.to_s]\n\t\t\t\thand = decrypt_hand(my_data['hand'])\n\t\t\t\t@hand_hash[parsed_state['hand_number']] = hand\n\t\t\t\t@seat_number = my_data['seat_number']\n\t\t\t\t@bankroll = my_data['player']['bankroll']\n\t\t\telse\n\t\t\t\thand = @hand_hash[parsed_state['hand_number']]\n\t\t\tend\n\t\t\tgame_state = GameState.new(parsed_state, @player_id, hand)\n\t\tend\n\t\t@mutex.synchronize do\n\t\t\tself.display_game_state(game_state) if self.respond_to?(:display_game_state)\n\t\t\tif game_state.is_acting_player? and game_state.hand\n\t\t\t\tbegin\n\t\t\t\t\t#Timeout.timeout(game_state.timelimit) do\n\t\t\t\t\t\tmove = ask_for_move(game_state)\n\t\t\t\t\t\tmove = 'fold' unless move\n\t\t\t\t\t\tmake_move(game_state, move)\n\t\t\t\t\t#end\n\t\t\t\t#rescue Timeout::Error\n\t\t\t\t\t#puts \"Took too long to make a move, folding\"\n\t\t\t\trescue\n\t\t\t\t\tputs \"Error: #{$!.inspect}\"\n\t\t\t\t\tpp $!.backtrace\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def get_game_state\n @game_state\n end", "def game_state_update(parsed_state)\n\t\tgame_state = nil\n\t\t@mutex.synchronize do\n\t\t\t@seat_number = parsed_state['seat_number']\n\t\t\t@bankroll = parsed_state['player']['bankroll']\n\t\t\tgame_state = GameState.new(parsed_state, @player_id, parsed_state['hand'])\n\t\tend\n\t\t@mutex.synchronize do\n\t\t\tself.display_game_state(game_state) if self.respond_to?(:display_game_state)\n\t\t\tif game_state.is_acting_player? and game_state.hand\n\t\t\t\tbegin\n\t\t\t\t\tTimeout.timeout(game_state.timelimit) do\n\t\t\t\t\t\tmove = ask_for_move(game_state)\n\t\t\t\t\t\t@player_channel.publish({'table_id' => game_state.table_id,\n\t\t\t\t\t\t'command' => 'action', 'action' => move}.to_json)\n\t\t\t\t\tend\n\t\t\t\trescue Timeout::Error\n\t\t\t\t\tputs \"Took too long to make a move, folding\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def change_turns\n (@current_player == @p1) ? @current_player = @p2 : @current_player = @p1\n end", "def turn_player\n go_fish.turn_player\n end", "def update_transition\r\n # If transition is processing\r\n if $game_temp.transition_processing\r\n # Clear transition processing flag\r\n $game_temp.transition_processing = false\r\n # Execute transition\r\n if $game_temp.transition_name == \"\"\r\n Graphics.transition(20)\r\n else\r\n Graphics.transition(40, \"Graphics/Transitions/\" +\r\n $game_temp.transition_name)\r\n end\r\n end\r\n end", "def game_mode; end", "def game_state(game_id)\n @game_list[game_id].game_state\n end", "def update_state!(new_board, ships_remaining)\n if (hit = detect_hit(@last_board, new_board))\n @hunting = false\n @last_hit = hit\n end\n unless ships_remaining.sort == @opponents_ships.sort\n @hunting, @opponents_ships = [true, ships_remaining]\n end\n @last_board = new_board\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end", "def update\n \t@currentState.update\n\tend", "def switch_player\n @current_player = if @current_player == @player_o\n @player_x\n else\n @player_o\n end\n\n @number_of_turns += 1\n end", "def turn_robot_left details\r\n\tif(details.f == 1)\r\n\t\tdetails.f = 4\r\n\telse\r\n\t\tdetails.f -= 1\r\n\tend\r\n\tdetails\r\nend", "def update_board_state(username)\n \n end", "def update_transition\r\n # If transition processing\r\n if $game_temp.transition_processing\r\n # Clear transition processing flag\r\n $game_temp.transition_processing = false\r\n # Execute transition\r\n if $game_temp.transition_name == ''\r\n Graphics.transition(20)\r\n else\r\n Graphics.transition(40, 'Graphics/Transitions/' +\r\n $game_temp.transition_name)\r\n end\r\n end\r\n end", "def dealer_turn\n if win_state == CHECK\n do_hit_or_stay(players[0])\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def set_state_left\n session[:state] = [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0]\n flash[:success] = 'State changed successfully.'\n redirect_to action: 'show'\n end", "def state=(new_state)\n @state = new_state\n refresh\n end", "def winGame\n @victory = true\n if @level == 2\n @win = true\n end\n end", "def status\n\t\tif flying!\n\t\t\tputs 'Flying'\n\t\telse\n\t\t\tputs 'Landed'\n\t\tend\n\tend", "def change_turn\n @turn = @turn >= 'X' ? 'O' : 'X'\n @turn_played += 1\n end", "def draw\n\t\t@currentState.draw\n\tend", "def switch_current_player\n\t\tif @playerx\n\t\t\t@playerx = false\n\t\t\t@current_player.set_text(\"Player: O\")\n\t\telse\n\t\t\t@playerx = true\n\t\t\t@current_player.set_text(\"Player: X\")\n\t\tend\t\t\n\tend", "def toggle_state\n state\n end", "def update(robot, action, state)\n if action == PICK_BEEPER_ACTION \n move()\n end\n end", "def switch_player\n @current_player = (@current_player == 'x' ? 'o' : 'x')\n end", "def won?\n @state.id == 14\n end", "def update\n @player = @player.get_state\n self.run\n self\n end", "def update_phase4_step6\r\n # Clear battler being forced into action\r\n $game_temp.forcing_battler = nil\r\n # If common event ID is valid\r\n if @common_event_id > 0\r\n # Set up event\r\n common_event = $data_common_events[@common_event_id]\r\n $game_system.battle_interpreter.setup(common_event.list, 0)\r\n end\r\n # Shift to step 1\r\n @phase4_step = 1\r\n end", "def turnover\n puts \"---> Turnover\"\n change_of_possession\n end", "def game\n game_mode \n set_solution\n until (@turns_left < 1 || @winner)\n guess\n checker\n @turns_left -= 1\n status\n end\n end", "def transition\n new_state = fetch_sensor_state\n return if new_state == @state\n puts \"Transitioned from #{@state} to #{new_state}\"\n if valid_transition?(new_state)\n @state = new_state\n # Do nothing\n else\n puts \"Invalid transition!\"\n @beam_broken = 0\n # TODO: toss up the correct error light\n end\n end", "def set_state_right\n session[:state] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]\n flash[:success] = 'State changed successfully.'\n redirect_to action: 'show'\n end", "def go_state (index)\n @state = @states[index]\n end", "def turn_on #turn the power on\n @power = true\n end", "def player_state\n @ole.PlayerState\n end", "def choose_move\n choose_move_when_in_check\n #update to be player specific\n choose_piece_to_move\n which_piece_selected\n choose_where_to_move\n end", "def set_State(value)\n set_input(\"State\", value)\n end", "def set_State(value)\n set_input(\"State\", value)\n end", "def switch_state(state)\n node.switch_state(state)\n end", "def back_light=(new_state)\n\t try_set_screen\n\t tmp = new_state ? 1 : 0\n\t Klass.setBacklight(@handle, tmp)\n new_state\n end", "def updateGameState\n\t\tnextGameState = super\n\t\tif @enemyCounter == 0\n\t\t\t@nextGameState = Battle.new(self, @hero, @screen)\n\t\t\treset\n\t\t\tresetEnemyCounter\n\t\tend\n\t\treturn nextGameState\n\tend", "def set_state(state)\n @state = state\n self[:action] = state\n @health = @health.clamp(0, 100)\n trigger 'change'\n send_status_notification unless dead?\n save\n end", "def set_door_state(state)\r\n\t\t@state = state\r\n\tend", "def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end", "def enemy_change_state(id, add, state_id)\n # for all target enemies\n get_enemies(id).each {|enemy|\n # if actually existing enemy\n if enemy.battler != nil\n # clear immortal flag if state is dead state\n enemy.battler.immortal = false if $data_states[state_id].zero_hp\n # add or remove state\n add ? enemy.battler.add_state(state_id) :\n enemy.battler.remove_state(state_id)\n end}\n end" ]
[ "0.6771328", "0.6620415", "0.6596172", "0.6554131", "0.65388846", "0.6462879", "0.64343417", "0.6431999", "0.633717", "0.62915677", "0.6248567", "0.615463", "0.61470455", "0.61247337", "0.61217886", "0.6079126", "0.6059814", "0.6049907", "0.60463655", "0.6041183", "0.60347587", "0.6016509", "0.6012371", "0.60030264", "0.5985147", "0.5967698", "0.596488", "0.59507143", "0.59376436", "0.59361094", "0.5932316", "0.59124345", "0.5908557", "0.5905154", "0.58944756", "0.58889884", "0.5876709", "0.58476615", "0.5807153", "0.58035535", "0.5799941", "0.5783092", "0.57710797", "0.57670045", "0.5762869", "0.5749615", "0.5749412", "0.5742192", "0.5726474", "0.57210094", "0.5718357", "0.5712856", "0.57100755", "0.5703367", "0.56932586", "0.5692416", "0.5690963", "0.5689109", "0.5674148", "0.5671179", "0.56707036", "0.56476223", "0.5642863", "0.5638108", "0.5637032", "0.5636396", "0.563358", "0.56076926", "0.5593641", "0.5593641", "0.5591787", "0.55895567", "0.55829614", "0.5581302", "0.55786383", "0.55777377", "0.5576397", "0.5568838", "0.5567982", "0.55662084", "0.555379", "0.5552449", "0.55502504", "0.55443865", "0.5534194", "0.55299497", "0.5529305", "0.5526367", "0.5521561", "0.5518986", "0.5518434", "0.5517754", "0.5517754", "0.5517069", "0.55162793", "0.55111617", "0.5510173", "0.5508794", "0.5507335", "0.55013776" ]
0.61391
13
Moves the player to a random room using the amulet
def magic room = Room.random return self.magic if room.name == "Entrance" || room.name == "Exit" @game.current_room = room.name "You moved to another room...\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_type_toward_player\n if near_the_player?\n case rand(6)\n when 0 then move_toward_player\n when 1 then move_toward_player\n when 2 then move_toward_player\n when 3 then move_toward_player\n when 4 then move_random\n when 5 then move_forward\n end\n else\n move_random\n end\n end", "def move_random\n case rand(4)\n when 0\n move_down(false)\n when 1\n move_left(false)\n when 2\n move_right(false)\n when 3\n move_up(false)\n end\n end", "def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n\n end", "def move(board)\n \trandom_move(board)\n\tend", "def random_move probability = 1\n return if rand > probability\n\n room = get_object self.container\n area = room.area\n unless room.nil?\n exits = room.exits.select do |e|\n other_side = get_object e.exit_room\n not other_side.nil? and other_side.area == area\n end.map {|e| e.alt_names[0] }\n\n if exits.respond_to? :shuffle\n exits = exits.shuffle\n else\n exits = exits.sort_by { rand }\n end\n\n go exits[rand(exits.length)]\n end\n end", "def move\n @position += MOVMENT_ALTERATIONS[rand(0..1)]\n end", "def move( turn )\n RC[pot[(rand*pot.length).to_i]] # random for basic player\n end", "def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end", "def enter_maze\n\t\t@player.location = @maze.rooms.sample.reference\n\t\tputs \"You go west.\"\n\tend", "def move_type_random\r\n case rand(6)\r\n when 0..3 then move_random\r\n when 4 then move_forward\r\n when 5 then @stop_count = 0\r\n end\r\n end", "def random_player \n\t\tsalida_aleatoria = rand(1..3)\n\t\tsalida_aleatoria\n\tend", "def move_type_avoid_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_away_from_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end", "def M\r\n randomnums = Random.new\r\n roomn = randomnums.rand(1...19) \r\n while roomn == 6 or roomn == 11\r\n roomn = randomnums.rand(1...19) \r\n end\r\n puts(\"\r\n *\r\n *\r\n *\r\n *\r\n *\r\n *\r\n *\")\r\n $roomnumber = roomn\r\n if roomn == 9\r\n room_9\r\n end\r\n return \"ROOM\"\r\nend", "def random_move(board)\n empty_spot = winning_move(board)\n empty_spot ||= board.empty_position.sample\n end", "def moving\n\t\tget_rand(2)\n\t\tcase @location\n\t\twhen \"Cathedral\"\n\t\t\tfrom_cathy()\n\t\twhen \"Hospital\"\n\t\t\tfrom_hospital()\n\t\twhen \"Hillman\"\n\t\t\tfrom_hillman()\n\t\twhen \"Museum\"\n\t\t\tfrom_museum()\n\t\tend\n\tend", "def move_type_random\n case rand(6)\n when 0 then move_random\n when 1 then move_random\n when 2 then move_forward\n when 3 then move_forward\n when 4 then move_forward\n when 5 then @stop_count = 0\n end\n end", "def living_move\n simulate_move(opponent)\n end", "def sel_rand(player, opponent)\n all = @corners + @edges + @center # all board positions\n taken = player + opponent # all occupied board positions\n position = (all - taken).sample # take a random open position\n end", "def random_turn deg\n rand(deg) - (deg/2)\n end", "def move_type_random\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Random\n move_random\n when 4 # 1 step forward\n move_forward\n when 5 # Temporary stop\n @stop_count = 0\n end\n end", "def move_type_random\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Random\n move_random\n when 4 # 1 step forward\n move_forward\n when 5 # Temporary stop\n @stop_count = 0\n end\n end", "def move(direction)\n movements = @game.current_room_model.movement\n monster = @game.current_room_model.monster\n\n if direction == :north and not movements.north\n return \"No exit that way\"\n elsif direction == :south and not movements.south\n return \"There is no exit south\"\n elsif direction == :east and not movements.east\n return \"You cannot go in that direction\"\n elsif direction == :west and not movements.west\n return \"You cannot move through solid stone\"\n elsif direction == :up and not movements.up\n return \"You cannot go up this floor\"\n elsif direction == :down and not movements.down\n return \"You cannot go down this floor\"\n end\n\n return \"Monster shouts: YOU SHALL NOT PASS!!\" if monster && rand < 0.1\n\n @game.current_room = movements.send(direction)\n @game.player.tally += 1\n @game.player.strength -= 5\n\n if @game.player.strength < 1\n @game.state = DeadState.new @game\n else\n @game.state = WinnerState.new(@game) if @game.current_room == \"Exit\"\n end\n\n \"You moved to another room...\"\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end", "def move\n @dungeon.set_next_room( params[:direction].to_sym)\n if @dungeon_instance.update(dungeon_data: @dungeon.to_json)\n redirect_to dungeon_instance_play_path( @dungeon_instance )\n end\n end", "def winning_move\n simulate_move(@player_num)\n end", "def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def move_player1 (choice_case)\n symbole_player1 = @player1.symbole\n @board.move_player1(choice_case, symbole_player1)\n @@game_count+=1\n end", "def new_rooms\n min_rooms = MIN_NEXT_ROOMS\n max_rooms = MAX_NEXT_ROOMS\n rand(min_rooms..max_rooms).times do\n @next_rooms << Zarta::Room.new(@dungeon)\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def move_toward_player\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n return if sx == 0 && sy == 0\n\n abs_sx = sx.abs\n abs_sy = sy.abs\n if abs_sx == abs_sy\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n\n if abs_sx > abs_sy\n sx > 0 ? move_left : move_right\n unless moving? || sy == 0\n sy > 0 ? move_up : move_down\n end\n else\n sy > 0 ? move_up : move_down\n unless moving? || sx == 0\n sx > 0 ? move_left : move_right\n end\n end\n end", "def next_location(random)\n raise 'Error: No location connections to current location' unless @neighbors.count != 0\n rand_position = random.rand(@neighbors.count)\n move_location = @neighbors[rand_position]\n move_location\n end", "def treasures_allot\r\n randomnums = Random.new\r\n for num in (1..4) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6, randomnums.rand(10...109))\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------treasure\")\r\n end\r\nend", "def move_away_from_player\n move_away_from_character($game_player)\n end", "def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end", "def move_away_random(character, turn_enabled = true, distance = 1)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # array of directions\n dirs = ($game_system._8_way ? [1, 2, 3, 4, 6, 7, 8, 9] : [2, 4, 6, 8])\n # determines where can't move according to the x and y differences\n if dx > 0 && dy > 0 # character is up left\n dirs -= [4, 7, 8]\n elsif dx > 0 && dy < 0 # character is down left\n dirs -= [1, 2, 4]\n elsif dx < 0 && dy > 0 # character is up right\n dirs -= [6, 8, 9]\n elsif dx < 0 && dy < 0 # character is down right\n dirs -= [2, 3, 6]\n elsif dx < 0 && dy == 0 # character is right\n dirs -= [3, 6, 9]\n elsif dx > 0 && dy == 0 # character is left\n dirs -= [1, 4, 7]\n elsif dx == 0 && dy < 0 # character is down\n dirs -= [1, 2, 3]\n elsif dx == 0 && dy > 0 # character is up\n dirs -= [7, 8, 9]\n end\n # choose a random direction from available directions\n return case dirs[rand(dirs.size)]\n when 1 then distance.to_i.times {move_lower_left}\n when 2 then distance.to_i.times {move_down(turn_enabled)}\n when 3 then distance.to_i.times {move_lower_right}\n when 4 then distance.to_i.times {move_left(turn_enabled)}\n when 6 then distance.to_i.times {move_right(turn_enabled)}\n when 7 then distance.to_i.times {move_upper_left}\n when 8 then distance.to_i.times {move_up(turn_enabled)}\n when 9 then distance.to_i.times {move_upper_right}\n end\n end", "def assign_enemy\n\t\t@has_enemy = rand(1..2)==1 ? true : false\n\t\t#need an enemy value for the room.\n\tend", "def computer_turn\n begin\n computer_move = (1..9).to_a.sample\n end until active_spaces[computer_move] == \" \"\n puts \"\\nThe Computer makes a move, choosing space #{computer_move}...\\n\\n\" \n self.active_spaces[computer_move] = \"O\"\n game_board.show_board\n end", "def move(home_coordinate)\n @coordinate_change = rand(4)\n\n if @coordinate_change == 0\n move_north(home_coordinate)\n\n elsif @coordinate_change == 1\n move_south\n\n elsif @coordinate_change == 2\n move_east(home_coordinate)\n\n else\n move_west\n end\n end", "def random_movement(distance, delay)\n @movement_options[:moving] = true\n # Random direction\n dir = %w(up down left right)[rand(4)]\n # Move between 0 and 2 steps\n steps = rand(3)\n steps.times do\n turn(dir.intern)\n step(distance)\n end\n sleep delay\n @movement_options[:moving] = false\n end", "def get_random_next_move(arena)\n head = get_head_coords\n moves = []\n # N\n cell = arena.get(head[:x], head[:y] - 1)\n moves << 'N' if cell == 'empty' || cell[0..3] == 'tail'\n # S\n cell = arena.get(head[:x], head[:y] + 1)\n moves << 'S' if cell == 'empty' || cell[0..3] == 'tail'\n # E\n cell = arena.get(head[:x] + 1, head[:y])\n moves << 'E' if cell == 'empty' || cell[0..3] == 'tail'\n # W\n cell = arena.get(head[:x] - 1, head[:y])\n moves << 'W' if cell == 'empty' || cell[0..3] == 'tail'\n\n # Return any direction or nil\n moves.sample\n end", "def move_to_room(room_id)\n if Room.get_room_by_id(room_id)\n @current_room_id = room_id\n update\n end\n end", "def add_monster who, how\n case how\n when :STAIR_UP\n who.move_to @dx, @dy\n when :STAIR_DOWN\n who.move_to @ux, @uy\n when :OTHER\n begin\n y = Kernel.rand(Dungeon::NROW)\n x = Kernel.rand(Dungeon::NCOL)\n end while not @pile[y][x].empty?\n who.move_to x, y\n end\n end", "def move_away_from_player\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n return if sx == 0 && sy == 0\n\n abs_sx = sx.abs\n abs_sy = sy.abs\n if abs_sx == abs_sy\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n\n if abs_sx > abs_sy\n sx > 0 ? move_right : move_left\n unless moving? || sy == 0\n sy > 0 ? move_down : move_up\n end\n else\n sy > 0 ? move_down : move_up\n unless moving? || sx == 0\n sx > 0 ? move_right : move_left\n end\n end\n end", "def player_move\n\n move = TTY::Prompt.new\n\n choices = []\n @options = []\n @rooms.each do |room|\n @options << room.id\n choices << { name: room.name, value: room.id } unless room.id == @current_room_id\n end\n\n input = move.select(slow_type(\"Where would you like to move to?\"), choices)\n\n pause(0.3)\n\n if @options.include?(input) && find_room_by_id(@current_room_id).isLocked\n slow_type(\"#{find_room_by_id(@current_room_id).name} is locked, you'll need to find a way out\") \n\n elsif @options.include?(input) && find_room_by_id(input.to_i).isLocked\n slow_type(\"You cannot get to #{find_room_by_id(input.to_i).name}. it is currently locked\")\n\n else @options.include?(input) && !find_room_by_id(@current_room_id).isLocked\n\n @current_room_id = input\n slow_type(\"\\nYou have moved to #{find_room_by_id(@current_room_id).name}\")\n slow_type(\"#{find_room_by_id(@current_room_id).description}\")\n additional_text\n\n end\n end", "def run(position)\n if (rand() > 0.7)\n position += 5\n puts \"Solid run.\"\n\n elsif (rand() > 0.9)\n position += 7\n puts \"Yasssss Queeen, you werked it\"\n \n elsif (rand() < 0.2)\n position += 0\n puts \"You more felt like standing still\"\n \n else \n position -= 5\n puts \"Opponent drags you back\"\n end\n return position\n \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 acquire_move(ruleset)\n prng = Random.new\n number_of_moves = ruleset.valid_moves_list.length\n x = prng.rand(number_of_moves)\n @move = ruleset.valid_moves_list[x-1]\n puts \"#{@name} chose #{@move.capitalize}.\"\n end", "def spawn_smulg\r\n smulg = spawn_monster(\"Smulg\", 30, 15, 65, 50, rand(3..5), (3..10))\r\nend", "def make_move\n roll = @sampler.sample\n @player_position = new_position(roll)\n @moves += 1\n\n # Update winning state if the player has finished the game\n @game_over = @player_position >= @squares\n end", "def random_fire_upon(player_board)\n @available_cells.shuffle!\n target_coord = @available_cells.pop\n player_board.cells[target_coord].fire_upon\n target_coord\n end", "def reset\n @num_1 = rand(1..20)\n @num_2 = rand(1..20)\n if @current_player == 1\n @current_player = 2\n else\n @current_player = 1\n end\n end", "def move_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # Get absolute value of difference\n abs_sx = sx.abs\n abs_sy = sy.abs\n # If horizontal and vertical distances are equal\n if abs_sx == abs_sy\n # Increase one of them randomly by 1\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n # If horizontal distance is longer\n if abs_sx > abs_sy\n # Move away from player, prioritize left and right directions\n sx > 0 ? move_right : move_left\n if not moving? and sy != 0\n sy > 0 ? move_down : move_up\n end\n # If vertical distance is longer\n else\n # Move away from player, prioritize up and down directions\n sy > 0 ? move_down : move_up\n if not moving? and sx != 0\n sx > 0 ? move_right : move_left\n end\n end\n end", "def random_move\n moves = (0..5).to_a\n sim_board = board_copy\n moves.reject!{|col| sim_board.col_full?(col)}\n moves.sample\n end", "def pbRandomRoam(index)\n if $PokemonGlobal.roamPosition\n keys=pbRoamingAreas(index).keys\n $PokemonGlobal.roamPosition[index]=keys[rand(keys.length)]\n end\nend", "def transfer_scene(map,room=nil,dir=nil)\n\n\tid = map\n\tid = find_map_id(map) if map.is_a?(String)\n\troom = map if room == nil\n\t$map.setup id\n\n\n ev = gev(room)\n \n\t case dir\n\t when 'd'\n\t $player.direction = 2\n\t when 'l'\n\t $player.direction = 4\n\t when 'r'\n\t $player.direction = 6\n\t when 'u'\n\t $player.direction = 8\n\t end\n\n dx = 0\n dy = 0\n dx = 1 if $player.direction == 6\n dx = -1 if $player.direction == 4\n dy = 1 if $player.direction == 2\n dy = -1 if $player.direction == 8\n\n tx = ev.x + dx\n ty = ev.y + dy\n\n if ev.width > 1\n tx += ev.width/2\n end\n\n if ev.height > 1\n ty += ev.height/2\n end\n\n $player.moveto(tx,ty)\n\nend", "def move(board)\n if self.can_win(board) # First, checks to see if it can win\n array = self.can_win(board)\n game_ending_position(array, board)\n elsif self.must_stop_opp(board) # Second, checks to see if it must stop opposing win\n array = self.must_stop_opp(board)\n game_ending_position(array, board)\n else # Third, makes a random move (Game.turn will ensure the move is valid)\n rand(1..9).to_s\n end\n end", "def move(type = :unknown)\n\t\tmovement = rand(MOVEMENT_AMOUNTS[type])\n\t\t@distance += movement\n\t\tmovement.abs\n\tend", "def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end", "def populate_room\n unless @dungeon.first_room\n @enemy = Zarta::Enemy.new(@dungeon) if enemy_spawned\n end\n @dungeon.first_room = false\n @weapon = Zarta::Weapon.new(@dungeon) if weapon_spawned\n @stairs = stairs_spawned\n end", "def round\n @player = @players.first\n puts \"---- NEW TURN -----\"\n ask_question(@player)\n @players.rotate!\n\nend", "def move\n move_by a, m\n end", "def move_fantasma(mapa, novo_mapa, linha, coluna)\n posicoes = posicoes_validas_a_partir_de mapa, novo_mapa, [linha, coluna]\n return if posicoes.empty?\n aleatoria = rand posicoes.size\n posicao = posicoes[aleatoria]\n mapa[linha][coluna] = \" \"\n novo_mapa[posicao[0]][posicao[1]] = \"F\"\nend", "def move(board)\n\t\tgood = false\n\t\tuntil good == true\n\t\t\t@board.board = board\t\t\n\t\t\tai_pieces = Array.new\n\t\t\t@board.board.each do |key, piece|\n\t\t\t\tif piece.color == 'black'\n\t\t\t\t\tai_pieces << key\n\t\t\t\tend\n\t\t\tend\n\t\t\tai_pieces.each do |piece|\n\t\t\tend\n\t\t\tpiece_to_move = ai_pieces[rand(ai_pieces.length)]\n\t\t\tavailable_moves = board[piece_to_move].moves\n\t\t\tif available_moves.length > 0\n\t\t\t\ttarget = available_moves[rand(available_moves.length)]\n\t\t\t\tgood = @board.move(piece_to_move, target, 'black')\n\t\t\tend\n\t\tend\n\t\t@board\n\tend", "def terrors_allot\r\n randomnums = Random.new\r\n for num in (1..6) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6,num)\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------terror\")\r\n end\r\nend", "def place_random_ship\n unless full?\n placement = []\n placement << (0...@grid.length).to_a.shuffle.first\n placement << (0...@grid[0].length).to_a.shuffle.first\n @grid[placement[0]][placement[1]] = :s\n else\n raise 'Board is full'\n end\n\n end", "def game_start\n\n\tclear_screen\n\n\tprint_paragraph(\"Welcome to Trapped In A Cave.\\nGuess what? You're trapped in a cave...\nCan you make it out alive?\\n(For a list of commands type help at anytime.)\")\n\nstart_room\n\nend", "def createRoom()\n\t\twidth = rand(@areaWidth * 0.5 .. @areaWidth * 0.7).floor\n\t\theight = rand(@areaHeight * 0.5 .. @areaHeight * 0.7).floor\n\t\t@room = [\n\t\t\trand(@areaX + @areaWidth * 0.15 .. @areaX + @areaWidth - width * 1.15).ceil,\n\t\t\trand(@areaY + @areaHeight * 0.15 .. @areaY + @areaHeight - height * 1.15).ceil,\n\t\t\twidth,\n\t\t\theight,\n\t\t]\n\tend", "def play(move, peice = @current_player.peice)\n @board[move] = peice\n change_turns\n end", "def comp_move(some_array,which_level) \n include StrategyTools\n include FormatBoard\n \n 3.times{print \"\\n\"}\n center\n print \"MY MOVE\\n\"\n center\n 4.times{print \"_ \"}\n \n case which_level \n when \"1\"\n\trandom_play(some_array) \n \n when \"2\"\n\tif rand(2).odd?\n\t smart_play(some_array) \t\t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n when \"3\"\n if rand(4) < 3\n\t smart_play(some_array) \n\telse\n\t random_play(some_array) \n\tend\n\n when \"4\"\n\tif rand(100) < 98\n\t smart_play(some_array) \t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n end\n \n some_array\nend", "def play(user_id, location)\n x, y = get_move(location)\n move = self.player_1_id == user_id ? 'x' : 'o'\n board.set_cell(x, y, move)\n end", "def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end", "def spawn(player_room)\n # get all possible paths and create a hash indexed by size\n paths_to_player = self.rooms.inject({}) do |hsh, room|\n path = self.class.grue_path(room, player_room, self.edges)\n hsh[path.size] = path\n hsh\n end\n\n # get the longest of the shortest paths\n # (this is as far away as we can get)\n longest_path = paths_to_player[paths_to_player.keys.max]\n\n # get the first element of the first edge\n self.current_room = longest_path.first.first\n end", "def play\n \n puts \"#{current_player.to_s} has randomly been selected as the first player\"\n puts \"pls enter a number between 1 and 9 to make your move\"\n\n board.formatted_grid\n \n invalid_stdout = \"Ignoring this invalid step, pls try again.\"\n while human_move = gets.chomp\n valid_step = false\n if human_move =~ /\\d/ #only 1-9 number\n x, y = human_move_to_coordinate(human_move)\n valid_step = board.set_cell(x, y, current_player)\n end\n \n #ignore those invalid steps\n unless valid_step \n puts invalid_stdout\n next\n end\n\n if board.game_over\n puts game_over_message\n # board.formatted_grid\n return\n else\n switch_players\n puts solicit_move\n end\n end\n end", "def move(action, currRoom, newRoom)\n #*********************MayBe*****************\n if currRoom.has?(action)\n currRoom.remove(action)\n newRoom.add(action)\n end \n \n end", "def move_player2 (choice_case)\n symbole_player2 = @player2.symbole\n @board.move_player2(choice_case, symbole_player2) \n @@game_count+=1\n end", "def roll\n room = Room.new\n room.short_name = short_name\n room.description = description\n room\n end", "def make_move(board)\n puts \"Opponent is thinking...\\n\"\n minimax(board, @char, 0)\n if board.update('O', @choice[0], @choice[1])\n board.draw\n puts \"Opponent chose coordinates (#{@choice[0]+1}, #{@choice[1]+1})\\n\"\n else\n puts \"Something went wrong. The opponent made an illegal move.\\n\"\n end\n end", "def next_round\n sleep(1)\n puts \"\\n----- NEW TURN -----\"\n self.players.rotate!\n round_gameplay\n end", "def move_hero\n #get next square\n next_x = @cur_x + DIRECTION[@hero_direction][0]\n next_y = @cur_y + DIRECTION[@hero_direction][1]\n next_x = 0 if next_x < 0\n next_x = 14 if next_x > 14\n next_y = 0 if next_y < 0\n next_y = 14 if next_y > 14\n #look at new square in room\n next_square = @room[next_x][next_y]\n draw_map(next_x,next_y)\n #don't move onto it if next square is an object that can't be walked over\n if next_square == CHAR_FLOOR || next_square == CHAR_IN || next_square == CHAR_OUT ||\n next_square == CHAR_TRAP || next_square == CHAR_SAFE\n #walked into trap, keep on trap unless strong and lucky\n if @room[@cur_x][@cur_y] == CHAR_TRAP &&\n @stats[:strength] <= (@orig_stats[:strength] * 0.8) &&\n @stats[:luck] <= Random.rand(15)\n next_x = @cur_x\n next_y = @cur_y\n end\n #increase health on any move\n @stats[:strength] += (@stats[:vitality] / 200.0) if @stats[:strength] < @orig_stats[:strength]\n #move the character\n if next_x != @cur_x || next_y != @cur_y\n draw_map(@cur_x, @cur_y)\n @cur_x = next_x\n @cur_y = next_y\n draw_map(@cur_x, @cur_y)\n end\n #if on exit door then decend to next level if have enough experience\n if next_square == CHAR_OUT\n load_dungeon_file(@current_level+1)\n end\n end\n #cause damage if walked into wall\n if next_square == CHAR_WALL\n @stats[:strength] -= 0.3\n end\n\n #dead\n end", "def make_room max_w,max_h\n\t{\n\t\tx: rand(@grid_w - max_w - 1) + 1,\n\t\ty: rand(@grid_h - max_h - 1) + 1,\n\t\tw: rand(max_w) + 1,\n\t\th: rand(max_h) + 1,\n\t}\n\tend", "def kick_wall(wall)\n wall.moveTo(@new_x, @new_y)\n #or wall.moveTo(:direction)\n end", "def next_move\n\n @board.board[@choice] = id\n @board.free.delete(@choice)\n p self\n puts \"player #{id + 1} chooses #{@choice}\"\n puts @board\n\n @board.winner || @board.free.empty?\n end", "def turn\n puts \"#{@current_player.name}\\'s turn. Choose your cell (1-9)\" \n choice = gets.chomp.to_i\n if choice > 9 || choice < 1\n puts \"Warning : number must be between 1 and 9\"\n elsif @current_player.move(choice) != false\n @winner = @current_player if @current_player.winner?\n @turn += 1\n switch_player\n end\n end", "def move_grue(direction)\n next_grue_room = @grue_room.door_destination(direction)\n\n @grue_room.move_grue_from\n @grue_room = get_room_by_name(next_grue_room)\n @grue_room.move_grue_to\n end", "def move(board, position, player = 'X')\n #player = current_player(board) #w/o this line, tictactoe spec will run properly\n position = position.to_i - 1\n board[position] = player\nend", "def assign_random_movement_and_targets(move_positions, type)\n #assign random movement position\n if !battler.moved? #not already moved?\n @move_pos = move_positions[rand(move_positions.size)]\n else #has moved - set to self position\n @move_pos = self.pos\n end\n \n #Not Guard\n if type != nil\n #get skill/attack/etc usage area\n act_range = range\n #select random attack position\n @position = act_range[rand(act_range.size)]\n #find targets (if any)\n $tbs_cursor.moveto(@move_pos)\n $tbs_cursor.target_positions = battler.target_zone(@move_pos, position, type)\n @targets = tbs_make_targets\n else #Guard Type\n @position = battler.pos\n @targets = [battler]\n end\n end", "def move board\n free_pieces = board.free_pieces\n piece = free_pieces.random\n moves = board.possible_moves(piece)\n return [piece.x, piece.y], moves.random \n end", "def reset_game\n @current_room_id = 9\n find_room_by_id(9).isLocked = true\n find_item_by_id(8).show_item = false\n @inventory.delete(8)\n @talk_id = 18\n end", "def get_computer_move\r\n\r\n #Define and array containing a list of three possible moves\r\n moves = [\"ROCK\", \"PAPER\", \"SCISSORS\"]\r\n\r\n #Generate and return a random number between 0 and 2\r\n randomNo = rand(3)\r\n\r\n #Return a randomly selected move to the calling statement\r\n return moves[randomNo]\r\n\r\n end", "def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end", "def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end", "def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end", "def place_room(w,h,room_id)\n \n max_tries = Dungeon::MAX_PLACEMENT_ITERATION\n c_try = 0\n while c_try < max_tries\n\n # Get the top left corner, must be even \n tli = (rand*@width).floor\n tli += 1 if tli.odd?\n tlj = (rand*@height).floor\n tlj += 1 if tlj.odd?\n\n # Check all the cells from this point are unallocated, \n # and an extra 1 width around for perimeter\n failed = false\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n if !failed\n failed = true if @cells[i][j].type != Cell::UNALLOCATED\n end\n end\n end\n\n \n # if checks ok, build the room and the perimeter\n if !failed\n\t\t\t\t# Probability falls so there are an average of 2 doors per room\n\t\t\t\tper = 2*(w+h)\n\t\t\t\tdoor_chance = Dungeon::ROOM_DOORS/per\n\n\t\t\t\t# Prep for building a logical object ready for dead end removal\n\t\t\t\troom_cells = []\n\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n @cells[i][j].type = Cell::ROOM\n @cells[i][j].room_id = room_id\n\t\t\t\t\t\t\t# If perimeter wall, assign door if random number is under the threshold\n \t\t\t\t\t\tif i == tli || i == tli+w+1 || j == tlj || j == tlj+h+1 \n @cells[i][j].type = Cell::PERIMETER \n\t\t\t\t\t\t\t\tif i.odd? || j.odd?\n\t\t @cells[i][j].type = Cell::ENTRANCE if rand < door_chance\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Store the room cells read for assignment to logical structure\n\t\t\t\t\t\t\troom_cells << @cells[i][j];\n end\n end\n # Meet loop criterea\n c_try = Dungeon::MAX_PLACEMENT_ITERATION\n\n\t\t\t\t# Build logical object and map entrance cells to the room\n\t\t\t\troom_obj = RoomBranch.new(room_cells)\n\t\t\t\troom_cells.each { |c| room_map[c] = room_obj if c.type == Cell::ENTRANCE }\n\n end\n \n c_try += 1\n end\n \n end", "def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend", "def go(direction)\n\t\tvalid = true\n\t\treply = \"\\nYou go \" + direction.to_s\n\t\tif find_room_in_direction(direction) == nil\n\t\t\treply = \"\\nYou can't go that way\" \n\t\t\tvalid = false\n\t\telse\n\t\t\t@player.location = find_room_in_direction(direction)\n\t\t\t\n\t\t\t#Rubbisher effect, in case player enters Rubbisher\n\t\t\t#and is wobbed out before beginning turn\n\t\t\tif @player.location == :Rubbisher\n\t\t\t\t@player.stench = 4 \n\t\t\t\t@player.beans = 0\n\t\t\tend\n\t\t\n\t\tend\n\t\tputs reply\n\t\tswitch_player if valid\n\tend", "def place_room(w, h, room_id)\n\n max_tries = Dungeon::MAX_PLACEMENT_ITERATION\n c_try = 0\n while c_try < max_tries\n\n # Get the top left corner, must be even \n tli = (rand*@width).floor\n tli += 1 if tli.odd?\n tlj = (rand*@height).floor\n tlj += 1 if tlj.odd?\n\n # Check all the cells from this point are unallocated, \n # and an extra 1 width around for perimeter\n failed = false\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n if !failed\n failed = true if @cells[i][j].type != Cell::UNALLOCATED\n end\n end\n end\n\n\n # if checks ok, build the room and the perimeter\n if !failed\n # Probability falls so there are an average of 2 doors per room\n per = 2*(w+h)\n door_chance = Dungeon::ROOM_DOORS/per\n\n # Prep for building a logical object ready for dead end removal\n room_cells = []\n\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n @cells[i][j].type = Cell::ROOM\n @cells[i][j].room_id = room_id\n # If perimeter wall, assign door if random number is under the threshold\n if i == tli || i == tli+w+1 || j == tlj || j == tlj+h+1\n @cells[i][j].type = Cell::PERIMETER\n if i.odd? || j.odd?\n @cells[i][j].type = Cell::ENTRANCE if rand < door_chance\n end\n end\n\n # Store the room cells read for assignment to logical structure\n room_cells << @cells[i][j];\n end\n end\n # Meet loop criterea\n c_try = Dungeon::MAX_PLACEMENT_ITERATION\n\n # Build logical object and map entrance cells to the room\n room_obj = RoomBranch.new(room_cells)\n room_cells.each { |c| room_map[c] = room_obj if c.type == Cell::ENTRANCE }\n\n end\n\n c_try += 1\n end\n\n end", "def get_computer_move\r\n \r\n #Define and array containing a list of three possible moves\r\n moves = [\"ROCK\", \"PAPER\", \"SCISSORS\"]\r\n \r\n #Generate and return a random number between 0 and 2\r\n randomNo = rand(3)\r\n \r\n #Return a randomly selected move to the calling statement\r\n return moves[randomNo] \r\n \r\n end", "def transfer(new_room)\n raise HmsErrors::Bed::CannotMoveOffWard unless self.room.ward == new_room.ward\n \n self.room = new_room\n self.save!\n true\n end", "def go_room(command)\n if @current_room.has_exit?(command) \n # current room has this exit \n exit_room = @current_room.get_exit(command) # return string of room name\n # Search for instance of this room\n # update current room\n @game_rooms.each do |room|\n if room.is_room?(exit_room)\n @current_room = room # update current room\n end\n end\n puts \"\\nYou have entered the #{@current_room.print_name}!\\n\"\n else \n puts \"That is not a direction you can travel.\\n\"\n end\n end" ]
[ "0.7186484", "0.6669484", "0.656634", "0.6531436", "0.65267795", "0.6517237", "0.6504112", "0.6494811", "0.62813294", "0.6201292", "0.6187466", "0.61293966", "0.6119683", "0.6094181", "0.6070266", "0.6065082", "0.60642165", "0.6008833", "0.6006094", "0.6001547", "0.5985396", "0.5982752", "0.5981943", "0.5981356", "0.59642375", "0.59571314", "0.5950812", "0.5949988", "0.5933448", "0.5933448", "0.592674", "0.59199005", "0.5885607", "0.5882357", "0.5877154", "0.58685565", "0.58584654", "0.58391076", "0.5836287", "0.5829117", "0.5826834", "0.5816524", "0.5807414", "0.5803341", "0.5781095", "0.5780051", "0.57785785", "0.5776891", "0.5776768", "0.5763641", "0.57521623", "0.57518", "0.5740214", "0.5729214", "0.57196885", "0.571497", "0.5700766", "0.56996983", "0.5694617", "0.56885296", "0.5683741", "0.5673525", "0.56596273", "0.56530786", "0.56525", "0.5643806", "0.5639446", "0.56358397", "0.5619169", "0.5616361", "0.5615931", "0.5611082", "0.56076616", "0.5606336", "0.5603587", "0.560065", "0.5599275", "0.55978566", "0.5596171", "0.5589257", "0.55803347", "0.5576978", "0.5575521", "0.5574648", "0.55705607", "0.5557228", "0.5556332", "0.55562156", "0.55465055", "0.554332", "0.5540798", "0.5539456", "0.55390316", "0.55366004", "0.55356854", "0.5534914", "0.5534478", "0.5528055", "0.5527435", "0.5522267" ]
0.6589035
2
Pickup the treasure in the room if there is any
def pick_up treasure = @game.current_room_model.treasure has_torch = @game.player.has_torch? return "There is no treasure to pick up\n" unless treasure && treasure > 0 return "You cannot see where it is\n" unless has_torch @game.player.wealth += treasure return "You picked-up gems worth $#{treasure}\n" # TODO: update room status end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end", "def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\n end", "def giveTreasureBack(t)\n @usedTreasures << t\n end", "def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(command)\n # Remove from room and add to backpack\n @current_room.remove_item(command)\n @player.pick_up(command)\n puts \"\\nYou have picked up a #{@current_item.name}\"\n puts @current_item.collect_description + \"\\n\\n\"\n else\n puts \"This item isn't here\\n\"\n end\n end", "def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end", "def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end", "def pick_up(item)\n expected_weight = items_weight + item.weight\n if expected_weight <= 250\n item.is_a?(Weapon) ? @equipped_weapon = item : items << item \n else\n return false\nend\nend", "def stealTreasure\n t=nil\n \n if(canISteal)\n if(@enemy.canYouGiveMeATreasure)\n t=@enemy.giveMeATreasure\n @hiddenTreasures.push(t)\n haveStolen\n end\n end\n \n return t\n end", "def treasure_chance\n chance = roll.d100(1)\n if chance <= 100\n @treasure = Treasure.new\n end\n end", "def treasure_chance\n chance = roll.d100(1)\n if chance <= 100\n @treasure = Treasure.new\n end\n end", "def treasure_chance\n chance = roll.d100(1)\n if chance <= 100\n @treasure = Treasure.new\n end\n end", "def collect_treasure\n @gold_coins += 1\n if @gold_coins % 10 == 0\n level_up\n end\n end", "def treasure_drop(enemy)\n if rand(100) < enemy.treasure_prob\n treasure = $data_items[enemy.item_id] if enemy.item_id > 0\n treasure = $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0\n treasure = $data_armors[enemy.armor_id] if enemy.armor_id > 0\n end\n return treasure\n end", "def pickup(object)\n\t\t\tif object.parent == current_room\n\t\t\t\ttake(object)\n\t\t\t\tself.reload\n\t\t\telse\n\t\t\t\traise GreyGoo::Error, \"Can't take that object\"\n\t\t\tend\n\t\tend", "def discardHiddenTreasure(t)\n \n end", "def pick_up\n\n slow_type(\"\\nHere's what's in #{find_room_by_id(@current_room_id).name}:\\n\")\n\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n puts \"#{item.name}\" unless @inventory.include?(item.item_id) || item.show_item == false || item.class == Person\n end\n \n pick_up = TTY::Prompt.new\n\n choices = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false || item.class == Person\n end\n \n input = pick_up.select(slow_type(\"\\nWhat would you like to pick up?\\n\"), choices)\n\n # RUN PICK UP RULES TO CHECK IF WE CAN PICK IT UP\n\n if current_cell_items.include?(input) && !@inventory.include?(input)\n pick_up_checks(input)\n\n else current_cell_items.include?(input) && !@inventory.include?(input)\n put_item_in_inventory(input)\n end\n end", "def pickup(task, elapsed = 0)\n object = task.parameters[:object]\n # Find an unfilled carrying slot.\n self.inventory.values.each do |slot|\n if slot.is_a?(CarryingSlot) && slot.can_fit(object)\n $logger.info \"#{self.inspect} puts the #{object} in #{slot.class}\"\n slot.add_object(@world, object)\n # Tell the task we've picked up the object.\n task.parameters[:object_held] = true\n action_complete\n return object\n end\n end\n # No unfilled slots found; this is unlikely.\n task.job.blocked_workers << self if task.job\n incomplete_task\n end", "def drop_item(item)\n #this will take an item from the hero's inventory and place it in the current room\n end", "def discardVisibleTreasure(t)\n \n end", "def take \n element = @root.level.maps.first.element_at @position\n \n unless element.is_a? Interactable \n say(\"I can't pick it up!\") \n return\n end\n @inventory << element \n @root.level.maps.first.game_objects.delete(element)\n @root.inventory_updated if defined? @root.inventory_updated\n end", "def choice_a_battle\n use_item_in_battle\n end", "def pickUp( char, map )\n addToInventory( char )\n if map then\n map.removeItem( self )\n end\n end", "def stock\n if stock?\n\n if pile.empty?\n return if @areas[:waste].cards.size == 1\n pile.background = Ray::Sprite.new image_path('pile_background')\n refill_stock\n else\n displace_to_waste if @card\n end\n\n if pile.empty?\n if @areas[:waste].cards.size == 1\n pile.background = Ray::Sprite.new image_path('fully_empty_stock')\n else\n pile.background = Ray::Sprite.new image_path('empty_stock')\n end\n end\n\n end\n end", "def take(item_name)\n if current_room.npc && current_room.npc.has_item(item_name)\n npc_item = item_to_take(item_name)\n @player.add_to_inventory(npc_item)\n # this just doesn't seem to remove the item from NPC inventory no matter what I do :(\n current_room.npc.remove_from_inventory(npc_item)\n else\n puts \"Sorry, that item isn't here.\"\n end\n end", "def pick\n if @produce_left > 0\n @produce_picked += 1\n @produce_left -= 1\n puts \"You have picked #{@produce_picked} #{@produce}(s).\"\n else\n puts \"There are no #{@produce}s to pick!\"\n end\n end", "def collect_treasure\n @gold_coins = @gold_coins += 1\n if @gold_coins % 10 == 0\n level_up\n puts \"You got 11 gold coins! Now you have #{ @gold_coins }.\"\n puts \"Oh and you got an extra life, too! Now you have #{ @lives }.\"\n else\n puts \"You got a gold coin! Now you have #{ @gold_coins }.\"\n end #if\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def move_kitty_to_hand\n self\n .update_in(:hands, priority) {|h| h + kitty }\n .put(:kitty, [])\n end", "def restock\n @back_room = @warehouse.clone\n end", "def check_pickups\n @game_state.pickups.select { |pickup| pickup.collides?(self) }.each do |pickup|\n pickup.apply!(self)\n @game_state.pickups.delete(pickup)\n end\n end", "def release_bike\n raise \"There are no bikes docked\" unless empty?\n raise \"Remaining #{@available.length} #{@available.length > 1 ? \"bikes are broken\" : \"bike is broken\"}\" unless any_working?\n @available.pop\n end", "def release_bike\n fail 'No bikes available' if empty?\n @bike = @dock.pop\n end", "def release_bike()\n empty? ? (fail \"There's no bike docked to release!\") : @bikes.pop()\n end", "def take_object(object, silent=false)\n\n # if the player successfully adds it to their inventory,\n # then remove it from the current place\n if add_to_inventory(object, silent)\n\n object.pickup\n @curr_place.remove_object(object)\n\n else\n\n object.pickup_failed\n @gc.d_print(\"You cannot take it.\")\n\n end\n\n end", "def take_fish_from_river\n @stomach.concact(fish_count)\n end", "def trainer_chooses_pokemon\n choose_pokemon = {\"Fire\" => \"Charmander\", \"Grass\" => \"Bulbasaur\", \"Water\" => \"Squirtle\"}\n type_choice = prompt.select(Interactivity.choose_pokemon, choose_pokemon.keys) \n Interactivity.no_turning_back\n user.pokemon = Pokemon.find_by(name: choose_pokemon[type_choice])\n user.save\n end", "def take_from( text, quantity, to_container )\r\n\t\t\tcanteen = to_container.contains?(\"canteen\") > 0\r\n\t\t\tresult = [false, \"\"]\r\n\t\t\tqty = self.contains?( text )\r\n\t\t\tif qty == 1 \r\n\t\t\t\t# There is only one matching item\r\n\t\t\t\tobj = self.match( text )\r\n\t\t\t\tif obj.class <= GFood\r\n\t\t\t\t\t# Food is treated specially\r\n\t\t\t\t\tresult = handle_food( text, quantity, to_container, obj )\r\n\t\t\t\telse\r\n\t\t\t\t\t# Other objects include?\r\n\t\t\t\t\tif self.name == \"inventory\" && obj.name == \"canteen\" && \r\n\t\t\t\t\t\t\tself.contains?(\"water\") > 0 && to_container.name == \"room\"\r\n\t\t\t\t\t\t# If we drop our canteen, we irrevocably lose all of our water\r\n\t\t\t\t\t\tobjs = self.match(\"water\")\r\n\t\t\t\t\t\tself.drop( objs )\r\n\t\t\t\t\t\tresult[1] += \"You have lost all of your water. \"\r\n\t\t\t\t\tend\r\n\t\t\t\t\tif obj.name == \"canteen\" && canteen && to_container.name == \"inventory\"\r\n\t\t\t\t\t\tresult[0] = false\r\n\t\t\t\t\t\tresult[1] += \"You may only have one canteen in your inventory. \"\r\n\t\t\t\t\t\treturn result\r\n\t\t\t\t\tend\r\n\t\t\t\t\tself.drop( obj )\r\n\t\t\t\t\tto_container.add( obj )\r\n\t\t\t\t\tif to_container.name == \"inventory\" then obj.hidden_text = \"\" end\r\n\t\t\t\t\tresult[0] = true\r\n\t\t\t\t\tresult[1] += \"A \" + obj.name + \" has been taken from \" + self.name \r\n\t\t\t\t\tresult[1] += \" and added to \" + to_container.name + \".\"\r\n\t\t\t\tend\r\n\t\t\telsif qty > 1 && $GAME_ADJ.include?('any')\r\n\t\t\t\t# There are more than one matching item, but the player asked for 'any'\r\n\t\t\t\tobjs = self.match( text )\r\n\t\t\t\tobj = objs[0]\r\n\t\t\t\tif obj.class <= GFood\r\n\t\t\t\t\t# Food is treated specially\r\n\t\t\t\t\tresult = handle_food( text, quantity, to_container, obj )\r\n\t\t\t\telse\r\n\t\t\t\t\t# Other objects\r\n\t\t\t\t\t# Note: You can only have one canteen (for now)\r\n\t\t\t\t\tself.drop( obj )\r\n\t\t\t\t\tto_container.add( obj )\r\n\t\t\t\t\tif to_container.name == \"inventory\" then obj.hidden_text = \"\" end\r\n\t\t\t\t\tresult[0] = true\r\n\t\t\t\t\tresult[1] += \"A \" + obj.name + \" has been taken from \" + self.name \r\n\t\t\t\t\tresult[1] += \" and added to \" + to_container.name + \".\"\r\n\t\t\t\tend\r\n\t\t\telsif qty > 1\r\n\t\t\t\t# There is more than one matching item.\r\n\t\t\t\tresult[1] += \"There is more than one item that matches your request.\" \r\n\t\t\telse\r\n\t\t\t\t# There are no matching items\r\n\t\t\t\tresult[1] += \"There are no items that match your request.\" \r\n\t\t\tend\r\n\t\t\treturn result\r\n\t\tend", "def release_bike\n empty?\n @bike_list.pop\n\n\n end", "def nextTreasure\n if @unusedTreasures.empty?\n @unusedTreasures=Array.new(@usedTreasures)\n @usedTreasures.clear\n shuffleTreasures\n end\n \n a_devolver=@unusedTreasures.at(0)\n @unusedTreasures.delete_at(0)\n return a_devolver\n end", "def P\r\n if(get_room_stuff(6) > 0)\r\n if $light == 0\r\n puts(\"YOU CANNOT SEE WHERE IT IS\")\r\n else\r\n $wealth += get_room_stuff(6)\r\n puts(\"PICKED UP $#{get_room_stuff(6)}!\")\r\n set_at_room($roomnumber,6, 0)\r\n end\r\n else\r\n puts(\"THERE IS NO TREASURE TO PICK UP\")\r\n end\r\nend", "def gain_drop_items\n drops = []\n rate = Grade.rate(:drop)\n $game_troop.make_drop_items(rate).each do |item|\n $game_party.gain_item(item, 1)\n drops.push(item)\n end\n SceneManager.scene.drop_items(drops)\n end", "def take_fish_from_river(river)\n fish = river.get_fish()\n @stomach << fish if !fish.nil?\n end", "def activate\n if player.location.has_items?\n # set inventory index being considered for get\n @index = 0\n @item = player.location.inventory[@index]\n if player.inventory.can_fit?(@item)\n if player.location.inventory.size == 1 && @item.quantity == 1\n # a single item at the location so just get it\n player.get(@item)\n game.change_state(Map.new)\n else\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n end\n else\n game.messages << 'Your inventory is full.'\n game.change_state(Map.new)\n end\n else\n # no items at location\n game.change_state(Map.new)\n end\n end", "def treasures_allot\r\n randomnums = Random.new\r\n for num in (1..4) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6, randomnums.rand(10...109))\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------treasure\")\r\n end\r\nend", "def equip_selected\n item = @equip_window.item\n if @equip_window.item.nil?\n Sound.play_buzzer\n return\n end\n @enchant_window.item = item\n Sound.play_ok\n @equip_window.active = false\n @enchant_window.state = 2\n end", "def put_in_foundation\n if can_put_in_foundation?\n add_to_pile_beneath(@card_to_drop)\n @pile.cards.last.face_up unless @pile.empty?\n else\n call_off\n end\n end", "def unequip_item\n\t\tself.equiped = false\n\t\tself.save\n\tend", "def release_bike\n fail \"no bikes docked\" if empty?(@docked_bikes)\n @docked_bikes.pop\n end", "def pbChooseTradablePokemon(variableNumber,nameVarNumber,ableProc=nil,allowIneligible=false)\n chosen = 0\n pbFadeOutIn(99999){\n scene = PokemonParty_Scene.new\n screen = PokemonPartyScreen.new(scene,$Trainer.party)\n if ableProc\n chosen=screen.pbChooseTradablePokemon(ableProc,allowIneligible) \n else\n screen.pbStartScene(_INTL(\"Choose a Jermon.\"),false)\n chosen = screen.pbChoosePokemon\n screen.pbEndScene\n end\n }\n pbSet(variableNumber,chosen)\n if chosen>=0\n pbSet(nameVarNumber,$Trainer.party[chosen].name)\n else\n pbSet(nameVarNumber,\"\")\n end\nend", "def dig_for_treasure(&block)\n return false unless block_given?\n\n if !grub.nil?\n self.swag = grub\n spyglasses.each {|x| self.swag = self.swag.send(x) }\n end\n\n treasure_chest = self.swag.map do |spoils|\n self.prize(spoils)\n end\n\n treasure_chest.each do |loot|\n yield loot\n end\n end", "def cook\n @burger.thaw\n @burger.make_patty\n @burger.grill\n end", "def release_bike\n fail 'No bikes available' if working_bikes.empty?\n bikes.delete working_bikes.pop\n end", "def hatch\n @status = Idle\n @target = nil\n @virility = 0\n babies = []\n rand(MaxBabiesFromEgg).to_i.times {babies << baby_salmon}\n babies\n end", "def current_treasure_balance\n current_hand_treasure_balance + (self.treasure || 0)\n end", "def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end", "def unlock_armoire\n if @house.find_room(:bedroom).inventory.include?(\"key\") && (@level == 1)\n @house.delete_item(\"armoire\")\n @house.create_item(\"armoire\", \"This armoire is unlocked. Hey, when you look inside it, you see a secret room extending to the west. Spooky.\", 30)\n @house.find_room(:bedroom).links[:west] = :secret_room\n @house.last_move_message = \"You took the key out of your pack and it fit the armoire!\"\n @level+=1\n end\n end", "def gain_battle_spoil(gold, treasures)\n $game_party.gain_gold(gold)\n for item in treasures\n case item\n when RPG::Item\n $game_party.gain_item(item.id, 1)\n when RPG::Weapon\n $game_party.gain_weapon(item.id, 1)\n when RPG::Armor\n $game_party.gain_armor(item.id, 1)\n end\n end\n end", "def unequip_item(item)\n pair = @outfit.detect { |type, value| value.name.casecmp(item.to_s).zero? }\n if pair\n # On a successful find, the \"detect\" method always returns\n # an array of length 2; thus, the following line should not fail.\n item = pair[1]\n item.unequip(self)\n add_item(item)\n else\n print NOT_EQUIPPED_ERROR\n end\n end", "def release_bike\n fail 'No bikes available' if empty?\n new_bikes = @bikes\n @bikes.each_with_index do |value, index|\n if value.working? # broken? == false\n new_bikes = @bikes.pop(index)\n break\n end\n end\n raise 'No working bikes available' if new_bikes == @bikes\n return new_bikes\n end", "def release\n @release_bike = storage.last\n raise \"Asking for a bike that doesn't exist\" if empty?\n storage.pop; return @release_bike if !empty?\n end", "def refill_stock\n @areas[:waste].tap { |waste|\n waste.cards.reverse_each do |card|\n @areas[:stock].add_from(waste.piles.first, card)\n end\n }\n end", "def hit()\n #first it runs through all the asteroids and checks if itself is inside one\n for k in GameManager.getAsteroids()\n if Intersect.new([@model.x,@model.y,@size],[k.pos.x,k.pos.y,k.size]).calculate()\n #if it detects it is in an asteroid it calls that asteroids split function and then kills itself\n #it sends the ship that shot it its powerup value and tint so the ship can interpret it\n @ship.powerUp(k.type,k.tint[k.type])\n k.split()\n @ship.points += @ship.pointAdd\n if @ship.pierce == false\n self.kill()\n end\n end\n end\n end", "def buy_tower(tower_class, position)\n Game.scene.selected_tower = Game.scene.create_tower(tower_class, position)\n @cash -= Game.scene.selected_tower.cost\n end", "def equip_weapon(weapon)\n remove_weapon\n if weapon.hands_used > free_hands\n remove_weapon(true)\n end\n add_weapon(weapon)\n end", "def take\n state_change[:board] = game_state.board.dup\n copied_piece = state_change[:board][piece.position.to_s].occupant\n if copied_piece.nil?\n puts state_change[:board].to_ascii\n raise to_san \n end\n copied_piece.place_on(state_change[:board], destination.to_s)\n yield if block_given?\n state_change[:castling_availability] = castling_change\n state_change[:half_move] = half_move?\n game_state.to_state(state_change.delete_if { |_, v| v.nil? })\n end", "def all_treasure_cards\n treasure_cards = []\n cards.each do |c|\n if c.cardmapping.is_treasure == true \n treasure_cards << c \n end\n end\n return treasure_cards\n end", "def create_shovel\n if @satchel.contents.include?(\"fragment1\") && @satchel.contents.include?(\"fragment2\") && @satchel.contents.include?(\"fragment3\")\n @house.last_move_message = \"You've collected all three paper fragments. When you put them all together, you see this message: 'Buried in the garden.' Oh! A gust of wind just carried away all your fragments.\"\n @house.create_item(\"shovel\", \"This shovel is pretty darn heavy.\", 0)\n @house.find_room(:shed).inventory << \"shovel\"\n @satchel.contents.delete_if {|x| [\"fragment1\", \"fragment2\", \"fragment3\"].include?(x)}\n end\n end", "def create_key\n if @house.find_room(:garden).inventory.include?(\"shovel\") && (@level == 0)\n @house.create_item(\"key\", \"It's a key, but what's it for?\", 10)\n @house.find_room(:garden).inventory << \"key\"\n @house.last_move_message = \"You dug up a key in the garden! What's it for?\"\n @level+=1\n end\n end", "def release_bike\n raise 'no bike to be released' if empty?\n raise \"Can't release broken bike\" unless @bikes.last.working?\n @bikes.pop\n end", "def stoke_kettle(p)\n w = kettle_window(p)\n v = {}\n 5.times do\n v = w.kettle_data\n break if (v[:wood] && v[:water]) || v[:done]\n sleep (0.1)\n end\n \n unless (v[:wood] && v[:water]) || v[:done]\n puts \"Didn't read kettle: \"\n puts w.read_text\n puts v\n puts w.kettle_data\n puts \"----\"\n return true\n end\n\n if v[:done]\n w.click_word('Take')\n dismiss_all\n return true\n end\n\n if v[:wood] < 5 && v[:wood] < v[:water]\n w.click_on('Stoke')\n else\n dismiss_all\n end\n return false\n end", "def pbUseKeyItem\n # TODO: Remember move order\n moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH,\n :SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL,\n :WHIRLPOOL]\n realmoves = []\n for i in moves\n move = getID(PBMoves,i)\n next if move==0\n for j in 0...$Trainer.party.length\n next if $Trainer.party[j].egg?\n if $Trainer.party[j].hasMove?(move)\n realmoves.push([move,j]) if Kernel.pbCanUseHiddenMove?($Trainer.party[j],move,false)\n break\n end\n end\n end\n realitems = []\n for i in $PokemonBag.registeredItems\n realitems.push(i) if $PokemonBag.pbHasItem?(i)\n end\n if realitems.length==0 && realmoves.length==0\n Kernel.pbMessage(_INTL(\"An item in the Bag can be registered to this key for instant use.\"))\n else\n $game_temp.in_menu = true\n $game_map.update\n sscene = PokemonReadyMenu_Scene.new\n sscreen = PokemonReadyMenu.new(sscene) \n sscreen.pbStartReadyMenu(realmoves,realitems)\n $game_temp.in_menu = false\n end\nend", "def initialize(name, length_y, width_x, monster, monster_status = \"alive\")\n @name = name\n @room_x = width_x\n @room_y = length_y\n @monster = monster\n @monster_status = monster_status\n @dropped_treasure = []\n @@instances << self\n \n if (name != \"Entryway\") && (name != \"Exit\")\n\n @dropped_treasure << treasure\n end\n \n end", "def populate_room\n unless @dungeon.first_room\n @enemy = Zarta::Enemy.new(@dungeon) if enemy_spawned\n end\n @dungeon.first_room = false\n @weapon = Zarta::Weapon.new(@dungeon) if weapon_spawned\n @stairs = stairs_spawned\n end", "def stole_item_set(user, ext)\n return false unless ext != nil\n @item_stole = @item_to_steal = @stole_item_index = nil\n steal_success = rand(100) < (Steal_Rate + self.steal_attempt) * user.agi / self.agi\n self.steal_attempt += 1\n return nil if self.steal_items.nil? or self.steal_items == []\n return false unless steal_success\n @item_stole = []\n ext.slice!('STEAL/')\n self.steal_items.each do |item, steal_rate|\n item = item.split('')\n if item[0] == 'i' and not ext == 'GOLD'\n item = item.join\n item.slice!('i')\n @item_stole << $data_items[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'a' and not ext == 'GOLD'\n item = item.join\n item.slice!('a')\n @item_stole << $data_armors[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'w' and not ext == 'GOLD'\n item = item.join\n item.slice!('w')\n @item_stole << $data_weapons[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'g' and not ext == 'ITEM'\n item = item.join\n item.slice!('g')\n @item_stole << item.to_i if rand(1000) < (steal_rate * 10).to_i\n end\n end\n return false if @item_stole == []\n self.steal_attempt = 0\n @stole_item_index = rand(@item_stole.size)\n @item_to_steal = @item_stole[@stole_item_index]\n if Multi_Steal\n self.steal_items.delete_at(@stole_item_index)\n else\n self.steal_items = []\n end\n return @item_to_steal\n end", "def use_item(item_name)\n item = self.items.find_by(name: item_name)\n if item.item_type == \"Healing Potion\"\n if self.hp += 10 < self.base_hp\n puts \"You drank the entire bottle. You feel energized! (+10 HP)\"\n puts \"You HP is now #{self.hp}\"\n #removes Item from inventory \n Item.destroy(item)\n else\n #if HP goes ove the base_health, it automatically caps at base_hp aka your max hp\n self.hp = self.base_hp\n puts \"You drank the entire bottle. You are at full health!\"\n puts \"Your HP is now #{self.base_hp}\"\n Item.destroy(item)\n end \n elsif item.item_type == \"Weapon\"\n #weapons will boost the characters attack points by a random number?\n if self.current_weapon == nil \n random_attack_boost = [2,3,5].sample\n self.attack_power += random_attk_boost\n puts \"You've equipped #{item.name}. (+#{random_attk_boost})\"\n else \n equipped_weapon = self.items.find_by(current_weapon)\n Item.destroy(equppied_weapon)\n self.attack_power = self.base_attk\n random_attack_boost = [5,6,10].sample\n self.attack_power += random_attack_boost\n puts \"You have replaced your weapon with #{item.name}. (+#{random_attk_boost})\"\n end \n else \n puts \"You can't use/equip this!\"\n end \n end", "def game_water_action\n if tool_canuse?(WweaponId) and not @showing_water\n if actor.mp >= FlameMpCost\n @gamewater.direction = @direction\n @gamewater.moveto(@x, @y)\n @gamewater.char_steps = 2\n @gamewater.action_time = WaterDuration\n @showing_water = true\n RPG::SE.new(WaterSoundSe,80).play\n #actor.mp -= FlameMpCost\n @tool_anime = WaterDuration\n else\n Sound.play_buzzer\n end\n end\n end", "def tbs_use_item_era(item)\n \n tb = TactBattleManager.tact_battle?\n ch_tar = tb && TactBattleManager.selecting_target? # remove\n \n # Case during a tact battle, and not selecting a target\n if tb && !ch_tar\n return if (tb_event = $game_temp.tb_event).nil?\n dir = tb_event.dir_to_sym_era\n r1,r2 = item.tbs_spec_range, item.tbs_simple_range\n \n range = r1.nil? ? r2 : r1[dir]\n return no_range_set_tb(item) if r1.nil? && r2.nil?\n \n if r1.nil?\n if self.is_a?(Game_Actor)\n \n n,m = item.tb_range_min-1, item.tb_range_max-1\n range=Unit_Range.points(0,0,eqp_r_min(item) + n,eqp_r_max(item)+m)\n else; range = r2; end\n else; range = r1[dir]; end\n \n if !range.nil?\n range = relative_range_era(range)\n $game_map.next_att_highlights(range, item.tbs_hl_color)\n end\n \n # instead of doing this here, alias use_item inside game_battler, and call\n # it twice. Once when using the item initially, and then again after the\n # target has been selected.\n TactBattleManager.set_selecting_target(true)\n $game_temp.tb_item = item\n \n if !SceneManager.scene.is_a?(Scene_Map) && SceneManager.get_stack.size > 0\n SceneManager.return \n end\n # SceneManager.return # <= this fucking line of code... omfg wow.. fucking noob shit\n # was causing SceneManager to pop off last scene from stack\n # and seemingly exit strangely. Scariest error of my life,\n # had no call stack to debug with\n end\n end", "def equip(entity)\n prev_weapon = nil\n if entity.outfit[@type]\n prev_weapon = entity.outfit[@type]\n end\n\n super(entity)\n\n if (prev_weapon && prev_weapon.attack)\n entity.remove_battle_command(prev_weapon.attack)\n end\n\n if @attack\n entity.add_battle_command(@attack)\n end\n\n end", "def sample_treasures\n raise(NotImplementedError, 'A Fighter Entity must know whether it returns treasure or not after losing a battle')\n end", "def pickup_int_character(char)\n if char.throwed\n if char.force_move != nil and char.jump_passable?(1, true)\n char.start_jump(1) ; char.force_move = nil\n end\n unless char.jumping?\n RPG::SE.new(ThrowSe, 90).play\n @player_busy = char.throwed = false\n end\n end\n return if char.is_a?(Game_Bomb) and char.action_time < 35\n if Input.trigger?(ActionKey) and char.picked and\n !$game_map.interpreter.running?\n if char.jump_passable?(4) ; char.start_jump(4)\n elsif char.jump_passable?(3) ; char.start_jump(3)\n elsif char.jump_passable?(2) ; char.start_jump(2)\n else ; char.force_move = true\n end\n char.picked = false\n char.throwed = true\n removepick_graphic ; @tool_anime = 16\n end\n if Input.trigger?(ActionKey) and char.x == @x + ajustxy(self)[0] and\n char.y == @y + ajustxy(self)[1] and !self.moving? and !@player_busy\n RPG::SE.new(PickUpSe, 80).play\n @player_busy = char.picked = true\n applypick_grafhic ; @tool_anime = 16\n end\n end", "def drop(object)\n\t\t\traise GreyGoo::Error, \"You don't have that object\" if !has?(object)\n\t\t\tcurrent_room.take(object)\n\t\t\tself.reload # because the object's parent has lost the object, not us\n\t\tend", "def can_loot?\n false\n end", "def discardNecklaceIfVisible\n @visibleTreasures.each do |vt|\n if vt.kind == TreasureKind::NECKLACE\n CardDealer.instance.giveTreasureBack(vt)\n @visibleTreasures.delete(vt)\n break\n end\n end\n end", "def displace_to_waste\n @areas[:waste].add_from(@pile, @card)\n end", "def substractTreasure(tr_list, t)\n place = tr_list.index(t.kind)\n tr_list.delete_at(place) if place != nil\n end", "def sample_treasures\n raise(NotImplementedError, 'A Fighter must know whether it returns treasure or not after losing a battle.')\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 pbItemMenu(idxBattler,_firstAction)\r\n # Fade out and hide all sprites\r\n visibleSprites = pbFadeOutAndHide(@sprites)\r\n # Set Bag starting positions\r\n oldLastPocket = $PokemonBag.lastpocket\r\n oldChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = @bagLastPocket if @bagLastPocket!=nil\r\n $PokemonBag.setAllChoices(@bagChoices) if @bagChoices!=nil\r\n # Start Bag screen\r\n itemScene = PokemonBag_Scene.new\r\n itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|\r\n useType = GameData::Item.get(item).battle_use\r\n next useType && useType>0\r\n },false)\r\n # Loop while in Bag screen\r\n wasTargeting = false\r\n loop do\r\n # Select an item\r\n item = itemScene.pbChooseItem\r\n break if !item\r\n # Choose a command for the selected item\r\n item = GameData::Item.get(item)\r\n itemName = item.name\r\n useType = item.battle_use\r\n cmdUse = -1\r\n commands = []\r\n commands[cmdUse = commands.length] = _INTL(\"Use\") if useType && useType!=0\r\n commands[commands.length] = _INTL(\"Cancel\")\r\n command = itemScene.pbShowCommands(_INTL(\"{1} is selected.\",itemName),commands)\r\n next unless cmdUse>=0 && command==cmdUse # Use\r\n # Use types:\r\n # 0 = not usable in battle\r\n # 1 = use on Pokémon (lots of items), consumed\r\n # 2 = use on Pokémon's move (Ethers), consumed\r\n # 3 = use on battler (X items, Persim Berry), consumed\r\n # 4 = use on opposing battler (Poké Balls), consumed\r\n # 5 = use no target (Poké Doll, Guard Spec., Launcher items), consumed\r\n # 6 = use on Pokémon (Blue Flute), not consumed\r\n # 7 = use on Pokémon's move, not consumed\r\n # 8 = use on battler (Red/Yellow Flutes), not consumed\r\n # 9 = use on opposing battler, not consumed\r\n # 10 = use no target (Poké Flute), not consumed\r\n case useType\r\n when 1, 2, 3, 6, 7, 8 # Use on Pokémon/Pokémon's move/battler\r\n # Auto-choose the Pokémon/battler whose action is being decided if they\r\n # are the only available Pokémon/battler to use the item on\r\n case useType\r\n when 1, 6 # Use on Pokémon\r\n if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n when 3, 8 # Use on battler\r\n if @battle.pbPlayerBattlerCount==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n end\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Get player's party\r\n party = @battle.pbParty(idxBattler)\r\n partyPos = @battle.pbPartyOrder(idxBattler)\r\n partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)\r\n modParty = @battle.pbPlayerDisplayParty(idxBattler)\r\n # Start party screen\r\n pkmnScene = PokemonParty_Scene.new\r\n pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)\r\n pkmnScreen.pbStartScene(_INTL(\"Use on which Pokémon?\"),@battle.pbNumPositions(0,0))\r\n idxParty = -1\r\n # Loop while in party screen\r\n loop do\r\n # Select a Pokémon\r\n pkmnScene.pbSetHelpText(_INTL(\"Use on which Pokémon?\"))\r\n idxParty = pkmnScreen.pbChoosePokemon\r\n break if idxParty<0\r\n idxPartyRet = -1\r\n partyPos.each_with_index do |pos,i|\r\n next if pos!=idxParty+partyStart\r\n idxPartyRet = i\r\n break\r\n end\r\n next if idxPartyRet<0\r\n pkmn = party[idxPartyRet]\r\n next if !pkmn || pkmn.egg?\r\n idxMove = -1\r\n if useType==2 || useType==7 # Use on Pokémon's move\r\n idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL(\"Restore which move?\"))\r\n next if idxMove<0\r\n end\r\n break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene\r\n end\r\n pkmnScene.pbEndScene\r\n break if idxParty>=0\r\n # Cancelled choosing a Pokémon; show the Bag screen again\r\n itemScene.pbFadeInScene\r\n when 4, 9 # Use on opposing battler (Poké Balls)\r\n idxTarget = -1\r\n if @battle.pbOpposingBattlerCount(idxBattler)==1\r\n @battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index }\r\n break if yield item.id, useType, idxTarget, -1, itemScene\r\n else\r\n wasTargeting = true\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Fade in and show the battle screen, choosing a target\r\n tempVisibleSprites = visibleSprites.clone\r\n tempVisibleSprites[\"commandWindow\"] = false\r\n tempVisibleSprites[\"targetWindow\"] = true\r\n idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)\r\n if idxTarget>=0\r\n break if yield item.id, useType, idxTarget, -1, self\r\n end\r\n # Target invalid/cancelled choosing a target; show the Bag screen again\r\n wasTargeting = false\r\n pbFadeOutAndHide(@sprites)\r\n itemScene.pbFadeInScene\r\n end\r\n when 5, 10 # Use with no target\r\n break if yield item.id, useType, idxBattler, -1, itemScene\r\n end\r\n end\r\n @bagLastPocket = $PokemonBag.lastpocket\r\n @bagChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = oldLastPocket\r\n $PokemonBag.setAllChoices(oldChoices)\r\n # Close Bag screen\r\n itemScene.pbEndScene\r\n # Fade back into battle screen (if not already showing it)\r\n pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting\r\n end", "def setup_check_cover\n return if area_flag\n get_scene.tsbs_apply_substitute(target, item_in_use, self)\n end", "def gain_chest_item\n $game_party.gain_item(online_chest.item, 1)\n end", "def treasure\n [\"ring\", \"necklace\", \"dagger\", \"amulet\", \"ruby\", \"sapphire\", \"piece of jade\", \"human skull\", \"tarask skull\"].sample\nend", "def canYouGiveMeATreasure\n !getVisibleTreasures.empty?\n end", "def next_item\n if (player.location.inventory.length > @index)\n @item = player.location.inventory[@index]\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n else\n game.change_state(Map.new)\n end\n end", "def update_eggs\n @eggs.each do |egg|\n if egg.position.y <= EggNestHeight and rand<EggHatchChance\n self << egg.hatch\n @eggs.delete(egg)\n @eggs.compact!\n elsif egg.position.y > EggNestHeight\n egg.move\n end\n end\n end", "def is_treasure(geonote)\n influence = 2\n popularity(geonote) >= base_popularity + influence * density(geonote)\n end", "def handle_victory(entity)\n # Determine the rewards for defeating the entity.\n gold = entity.sample_gold\n treasure = entity.sample_treasures\n\n add_loot(gold, [treasure]) unless gold.nil? && treasure.nil?\n end", "def choose_pokemon\n choice = nil\n call_scene(GamePlay::StorageTrade) { |scene| choice = scene.return_data }\n return choice\n end", "def process_tool_action(item)\n PearlKernel.load_item(item)\n return if !battler.tool_ready?(item)\n \n unless PearlKernel.has_data?\n if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n msgbox('Tool data missing') if $DEBUG\n return\n end\n if item.scope.between?(1, 6)\n msgbox('Tool data missing') if $DEBUG\n return\n elsif item.scope == 0\n return\n \n elsif !battler.usable?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return \n end\n end\n \n if PearlKernel.has_data? and not usable_test_passed?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return\n end\n \n @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?\n if @user_casting[0] > 0\n @animation_id = 0\n @animation_id = PearlKernel.tool_castanimation\n else\n load_abs_tool(item)\n end\n end", "def pbTossItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n if pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"That's too important to toss out!\"))\n next\n end\n qty = storage.pbQuantity(item)\n itemname = PBItems.getName(item)\n itemnameplural = PBItems.getNamePlural(item)\n if qty>1\n qty=@scene.pbChooseNumber(_INTL(\"Toss out how many {1}?\",itemnameplural),qty)\n end\n if qty>0\n itemname = itemnameplural if qty>1\n if pbConfirm(_INTL(\"Is it OK to throw away {1} {2}?\",qty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n pbDisplay(_INTL(\"Threw away {1} {2}.\",qty,itemname))\n end\n end\n end\n @scene.pbEndScene\n end", "def eat_fish_from_river(fish, river)\n @stomach.push(fish)\n river.lose_fish(fish)\n end" ]
[ "0.6829087", "0.6488601", "0.6486497", "0.6458919", "0.6366758", "0.63478595", "0.6226282", "0.62037694", "0.61397445", "0.61397445", "0.61397445", "0.611368", "0.6049674", "0.59981954", "0.59724754", "0.59649205", "0.59354746", "0.5917451", "0.5849084", "0.58271927", "0.5781923", "0.57623655", "0.5739438", "0.5727866", "0.5718327", "0.5656944", "0.56078595", "0.5566494", "0.5539134", "0.5506153", "0.55038565", "0.54950076", "0.54822814", "0.54803497", "0.5479153", "0.5466014", "0.54303724", "0.5419334", "0.54095954", "0.54069006", "0.53898567", "0.5381479", "0.5379049", "0.53750044", "0.53685224", "0.5364948", "0.532787", "0.53266424", "0.53218925", "0.53202695", "0.5319643", "0.5317474", "0.531201", "0.53017056", "0.52924126", "0.5290972", "0.52858126", "0.5268069", "0.52636", "0.525724", "0.52564436", "0.525608", "0.5253632", "0.52531797", "0.5238414", "0.52146167", "0.5207968", "0.5204626", "0.52022344", "0.5189431", "0.5189025", "0.5185342", "0.5177213", "0.5173946", "0.51719105", "0.5170199", "0.5168816", "0.51687604", "0.516748", "0.5165375", "0.51649326", "0.5164386", "0.5160834", "0.5156704", "0.51495373", "0.51477766", "0.51439196", "0.51360154", "0.5125651", "0.5111548", "0.5106459", "0.5103676", "0.507846", "0.50782794", "0.5077614", "0.507683", "0.50720626", "0.5069634", "0.5065147", "0.50637287" ]
0.75312513
0
Move from one room to another
def move(direction) movements = @game.current_room_model.movement monster = @game.current_room_model.monster if direction == :north and not movements.north return "No exit that way" elsif direction == :south and not movements.south return "There is no exit south" elsif direction == :east and not movements.east return "You cannot go in that direction" elsif direction == :west and not movements.west return "You cannot move through solid stone" elsif direction == :up and not movements.up return "You cannot go up this floor" elsif direction == :down and not movements.down return "You cannot go down this floor" end return "Monster shouts: YOU SHALL NOT PASS!!" if monster && rand < 0.1 @game.current_room = movements.send(direction) @game.player.tally += 1 @game.player.strength -= 5 if @game.player.strength < 1 @game.state = DeadState.new @game else @game.state = WinnerState.new(@game) if @game.current_room == "Exit" end "You moved to another room..." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_room(room_id)\n if Room.get_room_by_id(room_id)\n @current_room_id = room_id\n update\n end\n end", "def move(action, currRoom, newRoom)\n #*********************MayBe*****************\n if currRoom.has?(action)\n currRoom.remove(action)\n newRoom.add(action)\n end \n \n end", "def transfer(new_room)\n raise HmsErrors::Bed::CannotMoveOffWard unless self.room.ward == new_room.ward\n \n self.room = new_room\n self.save!\n true\n end", "def move\n @dungeon.set_next_room( params[:direction].to_sym)\n if @dungeon_instance.update(dungeon_data: @dungeon.to_json)\n redirect_to dungeon_instance_play_path( @dungeon_instance )\n end\n end", "def move_grue(direction)\n next_grue_room = @grue_room.door_destination(direction)\n\n @grue_room.move_grue_from\n @grue_room = get_room_by_name(next_grue_room)\n @grue_room.move_grue_to\n end", "def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end", "def move(rover)\n rover.command.each do |m|\n remove_rover(rover)\n rover.move(m)\n place_rover(rover)\n end\n end", "def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end", "def move_to(row_destination, col_destination)\n if can_castle?(row_destination, col_destination)\n rook = self.game.pieces.active.find_by(row: row_destination, column: col_destination)\n\n # Determine if the king is castling left or right\n direction = col_destination > self.column ? 1 : -1\n\n # Using direction, determine what row the king and rook belong on\n king_column = self.column + (2 * direction)\n rook_column = king_column + (1 * (direction * -1))\n\n # Record the moves. This will end up looking like two consecutive moves\n # due to how table implementation. Nice to have would be a figuring out\n # how to record this specifically as a castle move.\n self.record_move(row_destination, king_column)\n rook.record_move(row_destination, rook_column)\n\n # Update the king and rook using these newly found columns\n self.update_attributes(column: king_column)\n rook.update_attributes(column: rook_column)\n\n move = {:type => 'castling',\n :king => {:id => self.id, :end_row => self.row, :end_column => king_column},\n :rook => {:id => rook.id, :end_row => rook.row, :end_column => rook_column} }\n return move\n else\n return super\n end\n end", "def lmove(source, destination, where_source, where_destination); end", "def lmove(source, destination, where_source, where_destination); end", "def move(direction)\n if not @location.exits.include? direction\n return nil\n end\n destination = @location.exits[direction]\n if not @rooms.include? destination \n raise \"%s was not a known room name.\" % destination\n end\n @location = @rooms[destination]\n return @location\n end", "def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend", "def transfer_scene(map,room=nil,dir=nil)\n\n\tid = map\n\tid = find_map_id(map) if map.is_a?(String)\n\troom = map if room == nil\n\t$map.setup id\n\n\n ev = gev(room)\n \n\t case dir\n\t when 'd'\n\t $player.direction = 2\n\t when 'l'\n\t $player.direction = 4\n\t when 'r'\n\t $player.direction = 6\n\t when 'u'\n\t $player.direction = 8\n\t end\n\n dx = 0\n dy = 0\n dx = 1 if $player.direction == 6\n dx = -1 if $player.direction == 4\n dy = 1 if $player.direction == 2\n dy = -1 if $player.direction == 8\n\n tx = ev.x + dx\n ty = ev.y + dy\n\n if ev.width > 1\n tx += ev.width/2\n end\n\n if ev.height > 1\n ty += ev.height/2\n end\n\n $player.moveto(tx,ty)\n\nend", "def move_player2 (choice_case)\n symbole_player2 = @player2.symbole\n @board.move_player2(choice_case, symbole_player2) \n @@game_count+=1\n end", "def move\n move_by a, m\n end", "def move_to to\n\t\td = Distance.get( @square, to)\n\t\tmove d.dir( @square), to\n\tend", "def move\n\n end", "def go_room(command)\n if @current_room.has_exit?(command) \n # current room has this exit \n exit_room = @current_room.get_exit(command) # return string of room name\n # Search for instance of this room\n # update current room\n @game_rooms.each do |room|\n if room.is_room?(exit_room)\n @current_room = room # update current room\n end\n end\n puts \"\\nYou have entered the #{@current_room.print_name}!\\n\"\n else \n puts \"That is not a direction you can travel.\\n\"\n end\n end", "def move_to who, ox, oy, nx, ny\n @current_level.move_to who, ox, oy, nx, ny\n end", "def move_player1 (choice_case)\n symbole_player1 = @player1.symbole\n @board.move_player1(choice_case, symbole_player1)\n @@game_count+=1\n end", "def move_onto(a, b)\n reveal(a)\n reveal(b)\n move_single(a, b)\n end", "def move; end", "def move; end", "def move_away_from_player\n move_away_from_character($game_player)\n end", "def move\n @node = Node.find(params[:id])\n case params[:to]\n when 'left_of'\n @node.move_to_left_of(params[:dest_id])\n when 'right_of'\n @node.move_to_right_of(params[:dest_id])\n when 'child_of'\n @node.move_to_child_of(params[:dest_id])\n end\n @node.save\n redirect_to(nodes_url)\n end", "def move\n \n end", "def move\n \n end", "def move to_move\r\n\t\tif to_move == 0\r\n\t\t\tvia_road = driver.location.west_road\r\n\t\t\tdriver.location = driver.location.west_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 1\r\n\t\t\tvia_road = driver.location.north_road\r\n\t\t\tdriver.location = driver.location.north_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 2\r\n\t\t\tvia_road = driver.location.east_road\r\n\t\t\tdriver.location = driver.location.east_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 3\r\n\t\t\tvia_road = driver.location.south_road\r\n\t\t\tdriver.location = driver.location.south_location\r\n\t\t\treturn via_road\r\n\t\tend\r\n\t\t\r\n\tend", "def move\n if !destination.alive\n Game.scene.remove_object self\n else\n d_x, d_y = *destination.position\n b_x, b_y = *position\n \n if d_x.round == b_x.round and d_y.round == b_y.round\n finished\n else\n vlen = Math.sqrt((d_x - b_x)*(d_x - b_x) + (d_y - b_y)*(d_y - b_y))\n\t \n\t m_x = (d_x - b_x)*speed/vlen\n\t m_y = (d_y - b_y)*speed/vlen\n\t \n\t position[0] += m_x\n\t position[1] += m_y\n end\n end\n end", "def remove_from_gamespace\n # remove it from the room it's in.\n self.from_room \n self.recycle \n # Possibly in the future return all switches. I.e. an admin taking over an NPC body.\n end", "def move( mobile )\n\t\tif @closed && !mobile.affected?(\"pass door\")\n\t\t\tmobile.output \"The #{name} is closed.\"\n\t\t\treturn false\n elsif mobile.affected?(\"pass door\") && @passproof\n mobile.output \"You can't pass through the #{self.name}.\"\n return false\n\t\telse\n portal = @direction.nil?\n sneaking = mobile.affected?(\"sneak\")\n leave_string = \"\"\n if portal\n leave_string = \"0<N> steps into 1<n>.\"\n mobile.output(\"You step into 0<n>.\", [self]) unless sneaking\n else\n leave_string = \"0<N> leaves #{@direction.name}.\"\n end\n (mobile.room.occupants - [mobile]).each_output(leave_string, [mobile, self]) unless sneaking\n old_room = mobile.room\n mobile.move_to_room( @destination )\n if old_room\n old_room.occupants.select { |t| t.position != :sleeping && t.responds_to_event(:observe_mobile_use_exit) }.each do |t|\n Game.instance.fire_event( t, :observe_mobile_use_exit, {mobile: mobile, exit: self } )\n end\n end\n arrive_string = \"\"\n if portal\n arrive_string = \"0<N> has arrived through 1<n>.\"\n else\n arrive_string = \"0<N> has arrived.\"\n end\n (mobile.room.occupants - [mobile]).each_output arrive_string, [mobile, self] unless sneaking\n\t\tend\n return true\n\tend", "def move(direction)\n \n end", "def second_players_move(current_player)\n player = second_player(current_player)\n player_move(player)\n end", "def move_up()\n floor_before_move = @building.floors[@current_floor]\n floor_before_move.board_elevator(self)\n @current_floor += 1\n exit_passengers(@current_floor)\n new_floor = @building.floors[@current_floor]\n new_floor.board_elevator(self)\n if num_passengers == 0\n @direction = \"stationary\"\n end \n end", "def move pos\n new_board = nil\n next_player = @current_player == :x ? :o : :x\n new_board = @board.make_move @current_player, pos\n State.new new_board, next_player, @computer_player\n end", "def move(board)\n end", "def magic\n room = Room.random\n return self.magic if room.name == \"Entrance\" || room.name == \"Exit\"\n @game.current_room = room.name\n\n \"You moved to another room...\\n\"\n end", "def move_piece(from, to)\n piece = @board[from[0]][from[1]]\n dest_piece = @board[to[0]][to[1]]\n\n dest_piece.player.pieces.delete(dest_piece) unless dest_piece.nil?\n @board[from[0]][from[1]] = nil\n @board[to[0]][to[1]] = piece\n \n piece.pos = [to[0], to[1]]\n end", "def move_to(id, x, y, w=false, no_t = false)\n RME::deprecated_command(\"move_to\", \"use 'event_move_to' or 'player_move_to'\")\n event(id).move_to_position(x, y, w, no_t)\n end", "def move(from, to)\n if !towers.include?(from)\n puts \"Tower #{from} does not exist.\"\n elsif !towers.include?(to)\n puts \"Tower #{to} does not exist.\"\n elsif from.equal?(to)\n puts \"You can't put the same disc where you got it from!\"\n elsif tower(to).any? && tower(to).last < tower(from).last\n puts \"Invalid move. You can't place a bigger tile on top of a smaller one.\"\n else\n tower(to) << tower(from).pop\n self.moves += 1\n end\n end", "def move_to(x, y); end", "def move_piece(from, to)\n piece = self.at(from)\n self.set_at(from, nil)\n self.set_at(to, piece)\n end", "def move (player, direction)\n @players.each { |x| player_object = x if x.name == player}\n @exits.each {|x| x.move player_object << player_object if exit.direction == direction}\n @players.delete player_object\n end", "def move()\n if @direction == \"up\"\n move_up()\n elsif @direction == \"down\"\n move_down()\n else\n #check if anyone is on current floor- which way do majority want to go from here?\n @direction = people_on_current_floor()\n if @direction == \"up\" #were more ppl on this floor wanting to go up\n move_up()\n elsif @direction == \"down\"\n move_down()\n else #no one on this floor, decide direction based on pending rqsts above and below...\n decide_direction()\n end\n end\n end", "def move(from, to, left_behind = ' ')\n piece = board[from[0]][from[1]]\n piece.position = [to[0], to[1]]\n piece.n = 0\n board[from[0]][from[1]] = left_behind\n board[to[0]][to[1]] = piece\n end", "def move\n fetch('games.street_fighter.moves')\n end", "def goto room, args = {}\n\t\treturn false unless (can_goto?(room) && current_room.can_goto?(room))\n\t\t@current_room = room\n\t\tgoto! @current_room\n\t\treturn @current_room\n\tend", "def move\n case @rover_facing\n when 'N'\n @coordinates[1] += 1\n when 'E'\n @coordinates[0] += 1\n when 'S'\n @coordinates[1] -= 1\n when 'W'\n @coordinates[0] -= 1\n end\n end", "def move(from, to)\n index = self.delete_at(from)\n self.insert(to, index)\n end", "def move(from, card, to)\n from_pile = parse_pile(from)\n to_pile = parse_pile(to)\n result = from_pile.move(card, to_pile)\n puts ascii\n result\n end", "def move(board)\n \trandom_move(board)\n\tend", "def move(space)\n @board.move(@current_player, space)\n @state = \n if @board.winning?\n :win\n elsif @board.full?\n :draw\n else\n @current_player = @current_player.opponent\n :continue\n end\n rescue InvalidSpaceException\n :continue\n end", "def move_piece!(from_pos, to_pos)\n piece = self[from_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(to_pos)\n\n piece.prev_pos = from_pos\n piece.moved_during_match ||= true\n\n self[to_pos] = piece\n self[from_pos] = nil\n piece.pos = to_pos\n\n nil\n end", "def move_card(card, destination)\n card.location = destination\n card.save\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end", "def turn\n most_recent_move = current_player.move(@board)\n if !@board.valid_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end", "def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end", "def move_piece(from, to)\n raise 'needs implementation'\n end", "def perform_move(move)\n @board[*move] = self\n @board[*@location] = nil\n @location = move\n @king = true if in_end_row?\n move\n end", "def move_to(new_target_floor)\n return if doors_open\n case direction\n when 1\n return unless new_target_floor > floor\n when -1\n return unless new_target_floor < floor\n end\n self.target_floor = new_target_floor\n run\n true\n end", "def move\n @route.stations[@index_current_station].recieve_train(self)\n @route.stations[@index_current_station - 1].send_train(self)\n end", "def move_piece2(from, to)\n # validate moves, if okay then move\n #\n #\n\n if get_piece(from[0], from[1]).valid_moves.include?(to)\n\n #piece_next_location = piece_current_location\n# get_piece(to[0], to[1]) = get_piece(from[0], from[1])\n #piece_current_location = nil\n# get_piece(from[0], from[1]) = nil\n else\n puts \"Invalid move, try again\"\n end\n end", "def enter_maze\n\t\t@player.location = @maze.rooms.sample.reference\n\t\tputs \"You go west.\"\n\tend", "def move(source, destination)\n if isLegal?(source,destination)\n if source==1\n disk_to_move = @@tower_1.pop\n elsif source==2\n disk_to_move = @@tower_2.pop\n elsif source==3\n disk_to_move = @@tower_3.pop\n else\n puts(\"the source should be 1,2,or 3.\")\n end\n \n if destination ==1 \n @@tower_1.push(disk_to_move)\n elsif destination == 2 \n @@tower_2.push(disk_to_move)\n elsif destination == 3 \n @@tower_3.push(disk_to_move)\n end \n else\n puts(\"Sorry that was an incorrect move. Please review the rules and try again.\")\n end\n end", "def move_entity entity; end", "def move\n case @toy_direction\n when \"NORTH\"\n new_place = [@toy_place[0], @toy_place[1] + 1]\n when \"EAST\"\n new_place = [@toy_place[0] + 1, @toy_place[1]]\n when \"SOUTH\"\n new_place = [@toy_place[0], @toy_place[1] - 1]\n when \"WEST\"\n new_place = [@toy_place[0] - 1, @toy_place[1]]\n end\n place_robot(new_place, @toy_direction)\n end", "def go_to(x, y)\r\n @move_list.push(Move.new(move_type: :go_to, destination: Location.new(x,y)))\r\n end", "def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend", "def make_move(move)\n\t\t@board[move]= $current_player\n\tend", "def move(direction = 'NEXT')\n statement = \"move #{direction} from #{@name}\"\n @connection.exec(statement)\n end", "def move_to who, ox, oy, nx, ny\n if oy != nil and ox != nil\n @monster[oy][ox] = nil\n end\n @monster[ny][nx] = who\n return 10, nx, ny\n end", "def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end", "def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end", "def user_move(start, finish)\n start , finish = Board.pos_to_coord(start), Board.pos_to_coord(finish)\n self[finish] = self[start]\n self[start] = NullPiece.instance\n self[finish].position = finish\n end", "def set_room\n @room = Room.get_room(params[:id], params[:branch_id]).first\n end", "def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end", "def move(board, roll)\n \n # Leave old location\n board.spaces[@location].remove_player(self)\n\n # Calculate next location and move\n times_passing_go = (@location + roll) / 40\n @location = (@location + roll) % 40\n\n # If player lands on go don't overpay\n times_passing_go = @location == 0 ? times_passing_go - 1 : times_passing_go \n \n # Found out if the player needs to be payed for passing go\n times_passing_go.times do\n board.spaces[0].pay_player(self)\n end\n\n if (board.check_special_move(@location) == -1)\n return board.send_to_jail(self)\n end\n\n board.spaces[@location].add_player(self)\n\n # Tell the property groups to update their rent rates if necessary\n board.update_property_groups(roll)\n\n return @location\n end", "def moving\n\t\tget_rand(2)\n\t\tcase @location\n\t\twhen \"Cathedral\"\n\t\t\tfrom_cathy()\n\t\twhen \"Hospital\"\n\t\t\tfrom_hospital()\n\t\twhen \"Hillman\"\n\t\t\tfrom_hillman()\n\t\twhen \"Museum\"\n\t\t\tfrom_museum()\n\t\tend\n\tend", "def move_to(x, y)\n object.x = x\n object.y = y\n end", "def move(x,y)\n self.dup.move!(x,y)\n end", "def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end", "def move(pos1, pos2)\n begin\n p = self[pos1]\n if p\n @moves = p\n @target = self[pos2]\n elsif moves(pos2)\n self[pos1], self[pos2] = self[pos2], self[pos1]\n p\n end\n end\n end", "def move(from, to)\n @ctx.mv(@path + from, @path + to)\n end", "def smove(source, destination, member); end", "def smove(source, destination, member); end", "def south (room , game)\n if @down.nil?\n \"No puedes ir al Sur\"\n else\n @down.call(room, game)\n end\n end", "def move_castle(start_item, end_item)\r\n # move the king\r\n BoardInfoItem.exchange(start_item, end_item)\r\n # move the rook\r\n king_row = end_item.row\r\n king_end_col = end_item.col\r\n rook_start_col = 0\r\n if king_end_col == 6\r\n # short castle\r\n rook_start_col = 7\r\n rook_end_col = king_end_col - 1\r\n else\r\n # long castle\r\n rook_start_col = 0\r\n rook_end_col = king_end_col + 1\r\n end\r\n \r\n rook_start_item = @infosquare[king_row][rook_start_col]\r\n rook_end_item = @infosquare[king_row][rook_end_col]\r\n BoardInfoItem.exchange(rook_start_item, rook_end_item)\r\n end", "def room\n end", "def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end", "def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end", "def move(board)\nend", "def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end", "def move(*args)\n begin\n move_no_cleanup(*args)\n rescue Orp::MovementAlreadyComplete\n warn \"Attempted to complete already completed movement\"\n nil\n rescue\n delete\n raise\n end\n end", "def make_move(board)\n puts \"Opponent is thinking...\\n\"\n minimax(board, @char, 0)\n if board.update('O', @choice[0], @choice[1])\n board.draw\n puts \"Opponent chose coordinates (#{@choice[0]+1}, #{@choice[1]+1})\\n\"\n else\n puts \"Something went wrong. The opponent made an illegal move.\\n\"\n end\n end", "def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end", "def move_to(id, x, y, wait = false)\n\t\tcharacter = $game_player\n\t\tcharacter = $game_map.events[id] if id != 0\n\t\tcharacter.move_to_position(x, y, wait)\n\tend", "def move_castle(start_item, end_item)\n if start_item.type_piece !=:re\n raise \"castle move can't find the king\"\n end\n # move the king\n BoardInfoItem.exchange(start_item, end_item)\n # move the rook\n king_row = end_item.row_start\n king_end_col = end_item.column_start\n rook_start_col = 0\n if king_end_col == 6\n # short castle\n rook_start_col = 7\n rook_end_col = king_end_col - 1\n else\n # long castle\n rook_start_col = 0\n rook_end_col = king_end_col + 1\n end\n \n rook_start_item = @infosquare[king_row][rook_start_col]\n if rook_start_item.type_piece !=:torr\n raise \"castle can't find the rook\"\n end\n rook_end_item = @infosquare[king_row][rook_end_col]\n BoardInfoItem.exchange(rook_start_item, rook_end_item)\n end" ]
[ "0.73906124", "0.70465314", "0.70371914", "0.68144166", "0.6771611", "0.6560597", "0.65593183", "0.65489525", "0.6492228", "0.64834535", "0.64834535", "0.6435682", "0.63932604", "0.6374353", "0.63474596", "0.6339119", "0.63103056", "0.6295871", "0.6250104", "0.6230288", "0.6220441", "0.6216426", "0.6210423", "0.6210423", "0.6171454", "0.6169395", "0.61436564", "0.61436564", "0.61227274", "0.6120258", "0.61179125", "0.61139023", "0.60711074", "0.60536736", "0.6051058", "0.6028895", "0.6028675", "0.6011387", "0.6005047", "0.59864026", "0.5981723", "0.5974605", "0.59744936", "0.597432", "0.5973213", "0.5950885", "0.5940937", "0.591535", "0.59019023", "0.5882321", "0.5875446", "0.586444", "0.5863979", "0.58561826", "0.58539057", "0.58530587", "0.58509976", "0.58458924", "0.5835813", "0.5818627", "0.581818", "0.5816996", "0.5813773", "0.58061063", "0.5794538", "0.5786111", "0.57808626", "0.5777265", "0.5776895", "0.577078", "0.5758809", "0.57545453", "0.5754534", "0.57536083", "0.5753111", "0.575204", "0.57418436", "0.57349306", "0.57349306", "0.57320255", "0.5724318", "0.5723652", "0.5710377", "0.570998", "0.57093346", "0.57043874", "0.5698682", "0.5698682", "0.5679208", "0.567691", "0.5674813", "0.567301", "0.567301", "0.566984", "0.56690294", "0.5667084", "0.56618226", "0.56603867", "0.5659533", "0.56556684" ]
0.6092274
32
Allows the user the probability to scape from a fight
def run(direction) output = "" if rand > 0.7 output << "No, you must stand and fight" game.state = FightingState.new game output << game.state.handle return output else move direction end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gotAttack(damage)\r\n @@probsDeflects = Array['deflect', 'deflect', 'deflect', 'deflect', 'deflect',\r\n 'deflect', 'deflect', 'deflect', 'got hit', 'got hit' ]\r\n\r\n @@probs = @@probsDeflects[rand(0..9)]\r\n if @role.upcase == \"HERO\"\r\n if @@probs == 'deflect'\r\n puts \"#{@name} deflects the attack.\"\r\n @hitpoint += damage\r\n end\r\n end\r\n @hitpoint -= damage\r\n end", "def /(enemy)\n fight(enemy, rand(4 + ((enemy.life % 10)**2)))\n end", "def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end", "def /(enemy)\n fight(enemy, rand(4+((enemy.life%10) ** 2)))\n end", "def attack(target)\n\n #check to see if there is any target\n if target == nil\n puts \"Invite some friends to play this awesome game.\".blue\n\n else\n #print fighting for the user\n\n puts Artii::Base.new.asciify \"Fight\"\n\n\n\n ###methods for determining probability of victory\n ###and damage to the opponent or current user#####\n\n #if the characters have the same attack power\n if self.power == target.power\n\n #if the player wins the battle\n if rand > 0.5\n\n #reduce the target's hp by 10\n target.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #see if the target is still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a greater attack power than that of the target\n elsif self.power > target.power\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand < (0.4 + ((self.power - target.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-5*(self.power - target.power))\n\n #print outcome of the battle\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a lower attack power than that of the target\n else\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand > (0.45 + ((target.power - self.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-2*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-3*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n end\n end\n end", "def set_Probability(value)\n set_input(\"Probability\", value)\n end", "def claim(args)\n \"#{calc(@total_dice_in_game, args[:dice]) + calc(@total_dice_in_game, @total_dice_in_game)}%\"\n end", "def fight()\n\tputs \"--------------------\"\n\tputs \"Let's fight, but first we go to the coffe shop.\"\n\tgo_to_coffee_shop()\n\tnumber_of_turns = 10 + rand(20)\n\tputs \"------------------\"\n\tputs \"TIME TO FIGHT! There are #{number_of_turns} rounds in this fight!\"\n\tnumber_of_turns.times do |x|\n\t\tputs \"------------------\"\n\t\tputs \"Round #{x+1}, FIGHT!\"\n\t\tcurrent_fighter = Person.person_array.sample\n\t\t\n\t\tif current_fighter.is_a?(PowerRanger)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.megazord() if random_roll >= 7 && random_roll <=9\n\t\telsif current_fighter.is_a?(EvilNinja)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.cause_mayhem() if random_roll >= 7 && random_roll <=9\n\t\telse\n\t\t\trandom_roll = rand(2)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\tend\n\tend\n\tputs \"-------------------\"\nend", "def /( enemy )\n fight( enemy, rand( 4 + ( ( enemy.life % 10 ) ** 2 ) ) )\n end", "def /( enemy )\n fight( enemy, rand( 4 + ( ( enemy.life % 10 ) ** 2 ) ) )\n end", "def probability_of_success\n experience / 5.0\n end", "def fight\n # TODO: Add this back in, in a curses way\n #puts\n #puts \"========FIGHT========\"\n #puts \"#{@hero.name} Vs #{@monster.name}\"\n #puts\n\n # Populate an array with X number of levels Hero is and Y number of levels Monster is\n # This way whoever is a higher level has a better chance of attacking \n attack_arr = []\n @hero.level.to_i.times { attack_arr.push(\"Hero\") }\n @monster.level.to_i.times { attack_arr.push(\"Monster\") }\n\n # Loop until one character dies\n while @hero.cur_health > 0 && @monster.cur_health > 0\n case attack_arr.shuffle.first\n when \"Hero\" then @monster.cur_health -= @hero.strength\n when \"Monster\" then @hero.cur_health -= @monster.strength\n end\n end\n\n return (@hero.cur_health > @monster.cur_health)\n end", "def fight\n\tif @health > 0\n\t\tputs \"Would you like to (punch) or (kick) the #{@enemy}\"\n\t\tputs \"\"\n\t\tattack_method = gets.chomp.downcase\n\t\tif attack_method == \"punch\"\n\t\t\tpunch\n\t\telsif attack_method == \"kick\"\n\t\t\tkick\n\t\telse\n\t\t\tputs \"That is not a valid option.\"\n\t\t\tputs \"\"\n\t\t\tfight\n\t\tend\n\telse\t\n\t\tcontroller\n\tend\t\nend", "def compute_damage\nreturn rand(1..6) * @weapon_lvl\nend", "def attack(opponent)\n amplifier = (rand * DamageVariable).ceil\n dmg = 0\n if amplifier + strength > opponent.defense || amplifier == DamageVariable\n dmg = strength * (rand + 0.5)\n dmg -= opponent.defense\n dmg = 1 if dmg < 0\n end\n dmg.ceil\n end", "def compute_damage\n rand(1..6) * @weapon_level\n end", "def sword_damage(str, dex, luck)\n damage = (str + dex)/2 * rand(luck)\n if damage == 0\n puts \"You missed!\"\n else\n puts \"Your sword strikes for #{damage} damage!\"\n end\nend", "def preparation_method\r\n puts(\"INPUT ANY KEY TO FIGHT\")\r\n gets.strip\r\n if $suit == 1\r\n puts(\"YOUR ARMOR INCREASES YOUR CHANCES OF SUCCESS\\n\")\r\n $danger_level = 3* ($danger_level/4)\r\n sleep(2) \r\n end\r\n if $axe == 0 and $sword == 0\r\n puts(\"YOU HAVE NO WEAPONS\\nYOU MUST FIGHT WITH BARE HANDS\\n\")\r\n $danger_level += ($danger_level/5)\r\n elsif\r\n $axe == 1 and $sword == 0\r\n puts(\"YOU HAVE ONLY AN AXE TO FIGHT WITH\\n\")\r\n $danger_level = 4 * ($danger_level/5)\r\n elsif\r\n $axe == 0 and $sword == 1\r\n puts(\"YOU MUST FIGHT WITH YOUR SWORD\\n\")\r\n $danger_level = 3* ($danger_level/4)\r\n else\r\n puts(\"WHICH WEAPON WILL YOU USE? 1 - AXE, 2 - SWORD\")\r\n weapon_chosen = gets.strip.to_i\r\n case weapon_chosen\r\n when 1\r\n puts(\"YOU CHOSE TO FIGHT WITH THE MIGHTY AXE\")\r\n $danger_level = 4 * ($danger_level/5) \r\n when 2\r\n puts(\"YOU CHOSE TO FIGHT WITH THE DEADLY BLADE\")\r\n $danger_level = 3* ($danger_level/4)\r\n else\r\n puts(\"YOU FAILED TO CHOOSE A WEAPON, YOU WILL FIGHT WITH YOUR BARE HANDS\")\r\n $danger_level += ($danger_level/5)\r\n end\r\n end\r\nend", "def determine_damage\n if Random.rand(100) < critical_rate\n [fighter_attack * 2, FightEvent.attack_types['critical']]\n else\n [fighter_attack, FightEvent.attack_types['normal']]\n end\n end", "def compute_damage\r\n return rand(1..6) * @weapon_level\r\n end", "def compute_damage\n rand(1..6) * @weapon_level\n end", "def compute_damage\n return rand(1..6) * @weapon_level\n end", "def compute_damage\n return rand(1..6) * @weapon_level\n end", "def probability\n rand(1..100)\n end", "def battle\n # Your failures might strengthen the enemy\n rune_charges = 0\n if @artifact_rune == 0\n puts \"Rune of Dwayna provides Balthazar regeneration\"\n puts \"When he is about to die, he will use this artifact\"\n puts\n rune_charges = 3\n end\n\n puts \"Don't be afraid of fighting a God, #{@gladiator.name}\"\n puts \"As just a mere mortal, you brought him upon your feet!\"\n puts \"And after all you can gaze into his eyes without any trouble\"\n puts \"Still be careful and choose your weapon wisely.\"\n puts \"Don't forget, he draws his powers from Fire.\"\n puts \"When you are ready, enter any key to continue...\"\n gets\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very good choice against the God of Fire...\"\n gladiator_str += 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, kind of a good choice against the God of Fire...\"\n gladiator_str += 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very bad choice against the God of Fire...\"\n gladiator_str -= 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, not a good choice against the God of Fire...\"\n gladiator_str -= 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Balthazar successfully\"\n enemy_heal -= gladiator_str\n puts \"Balthazar's health is #{enemy_heal}\"\n # In enemy possesses a special item, he can heal back several times.\n if enemy_heal <= 0 && rune_charges > 0\n puts \"Balthazar uses Rune of Dwayna to heal the killing blow\"\n enemy_heal += gladiator_str\n rune_charges -= 1\n end\n # Enemy always strikes last\n if enemy_heal > 0\n puts \"Balthazar strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts \"You have defeated Balthazar! Now the world is safe.\"\n puts \"Or is it?\"\n puts \"...\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Balthazar has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end", "def attack\n (attack_strength * rand(0.8..1.2)).truncate(2)\n end", "def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead!]\"\n return\n end\n\n #Attack the opponent\n your_hit = rand(strength+weapon)\n puts \"[you hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n #Retaliation\n p enemy\n if enemy.life >0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[your enemy hit with #{enemy_hit} points of damage!]\"\n self.hit(enemy_hit)\n end\n end", "def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end", "def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end", "def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end", "def fight( enemy, weapon )\n if life <= 0\n puts \"[#{ self.class } is too dead to fight!]\"\n return\n end\n \n # Attack the opponent\n your_hit = rand( strength + weapon )\n puts \"[You hit with #{ your_hit } points of damage!]\"\n enemy.hit( your_hit )\n\n # Retaliation\n puts \"[#{ enemy.class } has #{enemy.life} life remaining!!]\"\n if enemy.life > 0\n enemy_hit = rand( enemy.strength + enemy.weapon )\n puts \"[Your enemy hit with #{ enemy_hit } points of damage!]\"\n self.hit( enemy_hit )\n end\n end", "def compute_damage\n rand(1..6)\n end", "def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead to fight!]\"\n return\n end\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n puts \"[You hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n # Retaliation\n p enemy\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[Your enemy hit with #{enemy_hit} points of damage!]\"\n hit(enemy_hit)\n end\n end", "def probability=(value)\n @probability = value\n end", "def generate_hero_hp(hero)\n buffer\n line\n puts \"Your hero's hp is being calculated...\"\n buffer\n hp = rand(500..1000)\n hero.hp = hp\n puts \"Your hero's health point are #{hero.hp}\"\n puts \"Is this enough health? Press 1 if it is enough, press 2 to re-roll power level.\"\n line\n choice = gi_integer\n if choice == 1\n generate_hero_gender(hero)\n elsif choice == 2\n generate_hero_hp(hero)\n else line\n puts \"Your input was not recognized. Please begin this step again.\"\n line\n generate_hero_hp(hero)\n end\n end", "def %(enemy)\n lettuce = rand(charisma)\n puts \"[Healthy lettuce gives you #{lettuce} life points!!]\"\n @life += lettuce\n fight(enemy, 0)\n end", "def fight(user, enemies, player1, player2)\n while user.life_points >0 && (player1.life_points > 0 || player2.life_points >0)\n user.show_state\n puts \"\n Quelle action veux-tu effectuer ?\n\n a - chercher une meilleure arme\n s - chercher à se soigner \n \n attaquer un joueur en vue :\n\n 0 - Josiane a #{player1.life_points} points de vie\n 1 - José a #{player2.life_points} points de vie\"\n puts \"*******************************************************************\" \n choice = gets.chomp \n puts \"***********************************************************************\" \n \n if choice == \"a\" \n user.search_weapon\n elsif choice == \"s\"\n user.search_health_pack\n elsif choice == \"0\"\n user.attacks(player1)\n elsif choice == \"1\"\n user.attacks(player2)\n end\n\n puts \"***********************************************************************\" \n enemies.each do |x|\n break if x.life_points <= 0\n x.attacks(user)\n puts \"Les autres joueurs t'attaquent !\"\n end\n end \n if user.life_points > 0\n puts \"BRAVO ! TU AS GAGNE !\"\n else \n puts \"Loser ! Tu as perdu !\"\n end\nend", "def %(enemy)\n lettuce = rand(charisma)\n puts \"[healthy lettuce gives you #{lettuce} life points]\"\n @life +=lettuce\n fight(enemy, 0)\n end", "def enemy_attack(pika_hp)\n random = rand(10) + 1 #includes 10\n if random == 1 || random == 2 || random == 3 || random == 4\n puts \"The enemy's attack missed! Pikachu's hp is #{pika_hp}.\".colorize(:red)\n elsif random == 5 || random == 6\n pika_hp = pika_hp - 1\n puts \"The enemy used Growl. Pikachu's hp is reduced to #{pika_hp}.\".colorize(:red)\n elsif random == 7 || random == 8\n pika_hp = pika_hp - 2\n puts \"The enemy used Quick Attack. Pikachu's hp is reduced to #{pika_hp}.\".colorize(:red)\n else\n pika_hp = pika_hp - 3\n puts \"The enemy used Scratch. Pikachu's hp is reduced to #{pika_hp}.\".colorize(:red)\n end\n return pika_hp\nend", "def compute_damage\r\n return rand(1..6)\r\n end", "def with_prob probability, action = \"\"\n if rand < probability\n if block_given?\n yield\n else\n act action\n end\n true\n else\n false\n end\n end", "def compute_damage\n \treturn rand(1..6)\n end", "def handle(weapon)\n weapon = weapon.to_sym if weapon\n output = \"\"\n return \"No monster here\\n\" unless @game.current_room_model.monster\n # Get the input for the user\n\n player = @game.player\n items = @game.player.items\n weapons = items[:weapons]\n # Omitted double ask for key line 740\n new_ferocity = @game.current_room_model.monster.ferocity\n\n if items.has_key? :suit\n output << \"Your armor increases your chance of success.\\n\"\n new_ferocity = 3 * (@game.current_room_model.monster.ferocity / 4).to_i\n end\n\n has_sword = weapons.include? :sword\n has_axe = weapons.include? :axe\n\n has_two_weapons = has_axe && has_sword\n if not has_two_weapons\n output << \"You must fight with bare hands.\\n\"\n new_ferocity = (new_ferocity + new_ferocity / 5).to_i\n end\n\n has_just_axe = has_axe && !has_sword\n if has_just_axe\n output << \"You has only an axe to fight.\\n\"\n new_ferocity = 4 * (new_ferocity / 5).to_i\n end\n\n has_just_sword = has_sword && !has_axe\n\n if has_just_sword\n output << \"You must fight with your sword.\\n\"\n new_ferocity = 3 * (new_ferocity / 4).to_i\n end\n\n #change to face 2\n #store first axe before sword\n unless weapons.empty?\n new_ferocity = 4 * (new_ferocity / 5).to_i if weapon == :axe\n new_ferocity = 3 * (new_ferocity / 4).to_i if weapon == :sword\n end\n\n #change to face 3 THE BATTLE\n # TODO loop do line 940\n if rand() > 0.5\n output << \"Attacks.\\n\"\n else\n output << \"You attack.\\n\"\n end\n\n if rand() > 0.5 && player.has_torch?\n output << \"Your Torch was knocked from your hand.\\n\"\n items.delete :torch\n end\n\n if rand() > 0.5 && items.has_key?(:axe)\n output << \"You drop your ace in the heat of battle\\n\"\n items.delete :axe\n new_ferocity = 5 * (new_ferocity / 4).to_i\n end\n\n if rand() > 0.5 && items.has_key?(:sword)\n output << \"Your Sword is knocked from your hand!!!\\n\"\n items.delete :sword\n new_ferocity = 4 * (new_ferocity / 3).to_i\n end\n\n if rand() > 0.5\n output << \"You manage to wound it\\n\"\n new_ferocity = (5 * new_ferocity / 6).to_i\n end\n\n if rand() > 0.95\n output << \"Aaaaargh!!\\n\"\n output << \"Rip! Tear! Rip!\\n\"\n end\n\n output << \"You Want to run but you stand your ground...\\n\" if rand() > 0.9\n\n output << '*&%%$#$% $%# !! @ #$$# #$@! #$ $#$' if rand() > 0.9\n\n output << \"Will this be a battle to the death?\\n\" if rand() > 0.7\n\n output << \"His eyes flash fearfully\\n\" if rand() > 0.7\n\n output << \"Blood drips from his claws\\n\" if rand() > 0.7\n\n output << \"You smell the sulphur on his breath\\n\" if rand() > 0.7\n\n output << \"He strikes wildly, madly......\\n\" if rand() > 0.7\n\n output << \"You have never fought and opponent like this!!\\n\" if rand() > 0.7\n\n if rand() > 0.5\n output << \"The monster wounds you!!!\\n\"\n player.strength -= 5\n end\n\n #if the condition of the loop do is false\n if rand() * 16 > new_ferocity\n # TODO implement the to_s from monster\n output << \"And you managed to kill the #{@game.current_room_model.monster.name}\\n\"\n player.monsters_killed += 1\n # TODO update game room status\n else\n output << \"The #{@game.current_room_model.monster.name} defeated you\\n\"\n player.strength /= 2\n end\n @game.state = ExploringState.new @game\n\n output << \"\\n\"\n output << @game.state.status\n\n output\n end", "def probability_of(gram)\n @probabilities.fetch(gram,0.0)\n end", "def being_attacked\n\tif @enemy_health > 0\n\t\t@enemy_power -= rand(-3..3)\n\t\tputs \"The #{@enemy} attacks again, doing #{@enemy_power - @defense} damage.\"\n\t\t@health -= (@enemy_power - @defense)\n\t\tfight\n\telse\n\t\tputs \"You beat the #{@enemy}!\"\n\t\tputs \"\"\n\t\tputs \"+#{@enemy_power + rand(9) + (@luck * @luck_points)} pointless points!\"\n\t\t@pointless_points += (@enemy_power + rand(9) + (@luck * @luck_points))\n\t\tcontroller\n\tend\nend", "def compute_damage\n\t\treturn rand(1..6) * @weapon_level\n\tend", "def attack_process\n\twhile @health > 0\n\t\tif @monster_health <= 0\n\t\ttreasure_4()\n\t\tpath()\n\t\tend\n\tputs \"1) Attack\\n2) Run\\n\"\n\tchoice = gets.chomp.to_i\n\tif choice == 1\n\t\tputs \"Attacking\"\n\t\t@health = @health - @monster_attack\n\t\t@monster_health = @monster_health - @attack_v\n\t\tputs \"Your Health: \" + @health.to_s \n\t\tputs \"Enemy Health: \" + @monster_health.to_s\n\telse choice == 2\n\t\tputs \"Running back to path.\"\n\t\tpath()\n\tend\n\tend\n\tputs \"You have died! Game Over!!\"\n\texit\nend", "def should_invent?\n rand(100) < @probability * 100\n end", "def compute_damage\n return rand(1..6)\n end", "def compute_damage\n return rand(1..6)\n end", "def run_round\n\t\t\tm, random_end = set_up_round\n\t\t\tactive_players = @players.select { |id, player| player[:food] > 0 }\n\t\t\t\n\t\t\tall_choices = Hash.new\n\t\t\ttotal_hunt_choices = 0\n\t\t\tactive_players.each do |id, player|\n\t\t\t\topponents = active_players.keys.shuffle\n\t\t\t\treps = opponents.map {|opp_id| @players[opp_id][:reputation]}\n\t\t\t\tchoices = player[:player].hunt_choices(@round, player[:food], player[:reputation], m, reps)\n\t\t\t\tall_choices[id] = Hash.new\n\t\t\t\topponents.each_with_index do |opp_id, index|\n\t\t\t\t\tall_choices[id][opp_id] = choices[index]\n\t\t\t\t\tif choices[index] == 'h'\n\t\t\t\t\t\t@players[id][:hunts] += 1\n\t\t\t\t\t\t@players[id][:food] -= 6\n\t\t\t\t\t\ttotal_hunt_choices += 1\n\t\t\t\t\telse\n\t\t\t\t\t\t@players[id][:slacks] += 1\n\t\t\t\t\t\t@players[id][:food] -= 2\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treward_hunt_bounties(all_choices)\n\t\t\treward_extra_bounty(active_players, m, total_hunt_choices)\n\t\t\tset_players_remaining\n\t\t\tupdate_reputations\t\n\n\t\t\t@players_remaining < 2 || random_end\n\t\tend", "def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend", "def damage\n @points -= [10, 20, 30].sample\n end", "def hit( damage )\n p_up = rand( charisma )\n if p_up % 9 == 7\n @life += p_up / 4\n puts \"[#{ self.class } magick powers up #{ p_up }!]\"\n end\n @life -= damage\n puts \"[#{ self.class } has died.]\" if @life <= 0\n end", "def generate_fighter(name, initial_health, type)\n if type == \"Runner\"\n Fighter.new(name, initial_health, rand(200..300), rand(20..50))\n elsif type == \"Viking\"\n Fighter.new(name, initial_health, rand(1..50), rand(50..100))\n else\n puts \"check fighter type...\"\n end\nend", "def search_health_pack\n dice = rand(1..6)\n if dice == 1\n puts \"Tu n'as rien trouvé... \"\n elsif dice > 1 && dice < 6 \n @life_points += 50 \n puts \"Bravo, tu as trouvé un pack de +50 points de vie !\" \n if @life_points > 100\n @life_points = 100\n end\n elsif dice == 6 \n @life_points += 80\n puts \"Waow, tu as trouvé un pack de +80 points de vie !\"\n if @life_points > 100\n @life_points = 100\n end\n end\n end", "def view_fight(fight_detail)\n puts \"Enter fight number to view specific fight: \"\n fight_num_input = gets.strip.to_i\n fight_number(fight_num_input, fight_detail)\n end", "def compute_damage\n return rand(1..6)\n end", "def take_action(game)\n @game = game\n if rand(100) < 50\n fold\n else\n bet(game[:current_high_bet])\n end\n end", "def attacks(attacked_player)\n # puts player1.name \n # print \"attacks\"\n # puts \"#{attacked_player}\"\n attacked_player.gets_damage(compute_damage)\n # puts \"He loses #{compute_damage} points\"\n end", "def conform_attack_strength\n rng = rand(0.7..0.9)\n self.attack_strength = (attack_strength > 20 * rng) && new_record? ? (20 * rng).to_i : attack_strength\n end", "def reward\n display_reward\n rewards = [\"some bandages\", \"a weapon\", \"a piece of armor\"]\n reward = rewards.sample\n case reward\n when \"some bandages\"\n hero.update(current_health: hero.max_health)\n puts \"Found #{reward}. Your health is restored.\"\n when \"a weapon\"\n weapon_power = rand(1..5)\n hero.update(power: hero.power + weapon_power)\n puts \"Found #{reward}. Power increased by #{weapon_power}.\"\n when \"a piece of armor\"\n armor_power = rand(1..10)\n hero.update(max_health: hero.max_health + armor_power)\n puts \"Found #{reward}. Max health increased by #{armor_power}.\"\n end\n sleep(3)\n end", "def search_weapon\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = dice\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n puts\"////////////////////////////////////////////////\"\n puts\" \"\n end", "def score(dice)\r\n \r\nend", "def attack(weapon)\n rand(10) + weapon.power\n end", "def get_damage\n 1 + Random.rand(3)\n end", "def win_fight\n if $boss_hp <= 0\n puts \"You win!\"\n $in_combat = false\n $in_boss = false\n $dead_boss = true #add a unique dialogue somewhere if this is true\n $in_forest = true\n end\nend", "def psh_bonuses(roll)\n case roll\n when 1..5\n @@skills << \"Brawling\"\n puts \"Brawling skill\"\n when 6..10\n @@skills << \"Stealth\"\n puts \"Stealth skill\"\n when 11..15\n @@skills << \"Weapons Expert\"\n puts \"Wpn expert!\"\n when 16..20\n @@skills << \"Dodge\"\n puts \"Dodge skill\"\n when 21..37\n @@endurance += 1\n @@strength += 1\n @@agility += 1\n @@accuracy += 1\n @@willpower += 1\n @@intelligence += 1\n @@perception += 1\n @@appearance += 1\n puts \"+1 to each attribute\"\n when 38..44\n @@endurance += (d(6) + d(6))\n puts \"+2d6 endurance\"\n when 45..51\n @@strength += (d(6) + d(6))\n puts \"+2d6 strength\"\n when 52..58\n @@agility += (d(6) + d(6))\n puts \"+2d6 agility\"\n when 59..65\n @@accuracy += (d(6) + d(6))\n puts \"+2d6 accuracy\"\n when 66..74\n @@intelligence += (d(6) + d(6) + d(6))\n puts \"+3d6 intelligence\"\n when 75..83\n @@willpower += (d(6) + d(6))\n puts \"+2d6 willpower\"\n when 84..90\n @@appearance += (d(6) + d(6) + d(6))\n puts \"+3d6 appearance\"\n when 91..97\n @@skills << \"Martial Arts\"\n puts \"Martial arts skill!\"\n when 98..99\n @@endurance += 2\n @@strength += 2\n @@agility += 2\n @@accuracy += 2\n @@willpower += 2\n @@intelligence += 2\n @@perception += 2\n @@appearance += 2\n puts \"+2 to each attribute\"\n when 100\n @@endurance += d(6)\n @@strength += d(6)\n @@agility += d(6)\n @@accuracy += d(6)\n @@willpower += d(6)\n @@intelligence += d(6)\n @@perception += d(6)\n @@appearance += d(6)\n puts \"JACKPOT -- +d6 to EACH Attribute!\"\n end\n\n end", "def activate_guts?\n rand < guts_chance\n end", "def attack(player)\n moveList = @stats[:attacks]\n attack = moveList.keys[rand(moveList.length)]\n puts \"\\nThe #{type} used #{attack}!!\"\n puts \"#{player.name} took #{moveList[attack]} pts of damage...\"\n player.hp -= moveList[attack]\n puts \"#{player.name} now has #{player.hp} HP\"\n Rules.userInput\n end", "def pbRoughDamage(move,user,target,skill,baseDmg)\r\n # Fixed damage moves\r\n return baseDmg if move.is_a?(PokeBattle_FixedDamageMove)\r\n # Get the move's type\r\n type = pbRoughType(move,user,skill)\r\n ##### Calculate user's attack stat #####\r\n atk = pbRoughStat(user,:ATTACK,skill)\r\n if move.function==\"121\" # Foul Play\r\n atk = pbRoughStat(target,:ATTACK,skill)\r\n elsif move.specialMove?(type)\r\n if move.function==\"121\" # Foul Play\r\n atk = pbRoughStat(target,:SPECIAL_ATTACK,skill)\r\n else\r\n atk = pbRoughStat(user,:SPECIAL_ATTACK,skill)\r\n end\r\n end\r\n ##### Calculate target's defense stat #####\r\n defense = pbRoughStat(target,:DEFENSE,skill)\r\n if move.specialMove?(type) && move.function!=\"122\" # Psyshock\r\n defense = pbRoughStat(target,:SPECIAL_DEFENSE,skill)\r\n end\r\n ##### Calculate all multiplier effects #####\r\n multipliers = {\r\n :base_damage_multiplier => 1.0,\r\n :attack_multiplier => 1.0,\r\n :defense_multiplier => 1.0,\r\n :final_damage_multiplier => 1.0\r\n }\r\n # Ability effects that alter damage\r\n moldBreaker = false\r\n if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker?\r\n moldBreaker = true\r\n end\r\n if skill>=PBTrainerAI.mediumSkill && user.abilityActive?\r\n # NOTE: These abilities aren't suitable for checking at the start of the\r\n # round.\r\n abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE]\r\n canCheck = true\r\n abilityBlacklist.each do |m|\r\n next if move.id != m\r\n canCheck = false\r\n break\r\n end\r\n if canCheck\r\n BattleHandlers.triggerDamageCalcUserAbility(user.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.mediumSkill && !moldBreaker\r\n user.eachAlly do |b|\r\n next if !b.abilityActive?\r\n BattleHandlers.triggerDamageCalcUserAllyAbility(b.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive?\r\n # NOTE: These abilities aren't suitable for checking at the start of the\r\n # round.\r\n abilityBlacklist = [:FILTER,:SOLIDROCK]\r\n canCheck = true\r\n abilityBlacklist.each do |m|\r\n next if move.id != m\r\n canCheck = false\r\n break\r\n end\r\n if canCheck\r\n BattleHandlers.triggerDamageCalcTargetAbility(target.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && !moldBreaker\r\n target.eachAlly do |b|\r\n next if !b.abilityActive?\r\n BattleHandlers.triggerDamageCalcTargetAllyAbility(b.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n # Item effects that alter damage\r\n # NOTE: Type-boosting gems aren't suitable for checking at the start of the\r\n # round.\r\n if skill>=PBTrainerAI.mediumSkill && user.itemActive?\r\n # NOTE: These items aren't suitable for checking at the start of the\r\n # round.\r\n itemBlacklist = [:EXPERTBELT,:LIFEORB]\r\n if !itemBlacklist.include?(user.item_id)\r\n BattleHandlers.triggerDamageCalcUserItem(user.item,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && target.itemActive?\r\n # NOTE: Type-weakening berries aren't suitable for checking at the start\r\n # of the round.\r\n if target.item && !target.item.is_berry?\r\n BattleHandlers.triggerDamageCalcTargetItem(target.item,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n # Global abilities\r\n if skill>=PBTrainerAI.mediumSkill\r\n if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||\r\n (@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)\r\n if @battle.pbCheckGlobalAbility(:AURABREAK)\r\n multipliers[:base_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:base_damage_multiplier] *= 4 / 3.0\r\n end\r\n end\r\n end\r\n # Parental Bond\r\n if skill>=PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)\r\n multipliers[:base_damage_multiplier] *= 1.25\r\n end\r\n # Me First\r\n # TODO\r\n # Helping Hand - n/a\r\n # Charge\r\n if skill>=PBTrainerAI.mediumSkill\r\n if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC\r\n multipliers[:base_damage_multiplier] *= 2\r\n end\r\n end\r\n # Mud Sport and Water Sport\r\n if skill>=PBTrainerAI.mediumSkill\r\n if type == :ELECTRIC\r\n @battle.eachBattler do |b|\r\n next if !b.effects[PBEffects::MudSport]\r\n multipliers[:base_damage_multiplier] /= 3\r\n break\r\n end\r\n if @battle.field.effects[PBEffects::MudSportField]>0\r\n multipliers[:base_damage_multiplier] /= 3\r\n end\r\n end\r\n if type == :FIRE\r\n @battle.eachBattler do |b|\r\n next if !b.effects[PBEffects::WaterSport]\r\n multipliers[:base_damage_multiplier] /= 3\r\n break\r\n end\r\n if @battle.field.effects[PBEffects::WaterSportField]>0\r\n multipliers[:base_damage_multiplier] /= 3\r\n end\r\n end\r\n end\r\n # Terrain moves\r\n if skill>=PBTrainerAI.mediumSkill\r\n case @battle.field.terrain\r\n when :Electric\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain?\r\n when :Grassy\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS && user.affectedByTerrain?\r\n when :Psychic\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC && user.affectedByTerrain?\r\n when :Misty\r\n multipliers[:base_damage_multiplier] /= 2 if type == :DRAGON && target.affectedByTerrain?\r\n end\r\n end\r\n # Badge multipliers\r\n if skill>=PBTrainerAI.highSkill\r\n if @battle.internalBattle\r\n # Don't need to check the Atk/Sp Atk-boosting badges because the AI\r\n # won't control the player's Pokémon.\r\n if target.pbOwnedByPlayer?\r\n if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE\r\n multipliers[:defense_multiplier] *= 1.1\r\n elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF\r\n multipliers[:defense_multiplier] *= 1.1\r\n end\r\n end\r\n end\r\n end\r\n # Multi-targeting attacks\r\n if skill>=PBTrainerAI.highSkill\r\n if pbTargetsMultiple?(move,user)\r\n multipliers[:final_damage_multiplier] *= 0.75\r\n end\r\n end\r\n # Weather\r\n if skill>=PBTrainerAI.mediumSkill\r\n case @battle.pbWeather\r\n when :Sun, :HarshSun\r\n if type == :FIRE\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n elsif type == :WATER\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n when :Rain, :HeavyRain\r\n if type == :FIRE\r\n multipliers[:final_damage_multiplier] /= 2\r\n elsif type == :WATER\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n end\r\n when :Sandstorm\r\n if target.pbHasType?(:ROCK) && move.specialMove?(type) && move.function != \"122\" # Psyshock\r\n multipliers[:defense_multiplier] *= 1.5\r\n end\r\n end\r\n end\r\n # Critical hits - n/a\r\n # Random variance - n/a\r\n # STAB\r\n if skill>=PBTrainerAI.mediumSkill\r\n if type && user.pbHasType?(type)\r\n if user.hasActiveAbility?(:ADAPTABILITY)\r\n multipliers[:final_damage_multiplier] *= 2\r\n else\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n end\r\n end\r\n end\r\n # Type effectiveness\r\n if skill>=PBTrainerAI.mediumSkill\r\n typemod = pbCalcTypeMod(type,user,target)\r\n multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE\r\n end\r\n # Burn\r\n if skill>=PBTrainerAI.highSkill\r\n if user.status == :BURN && move.physicalMove?(type) &&\r\n !user.hasActiveAbility?(:GUTS) &&\r\n !(Settings::MECHANICS_GENERATION >= 6 && move.function == \"07E\") # Facade\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n end\r\n # Aurora Veil, Reflect, Light Screen\r\n if skill>=PBTrainerAI.highSkill\r\n if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)\r\n if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && move.physicalMove?(type)\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n elsif target.pbOwnSide.effects[PBEffects::LightScreen] > 0 && move.specialMove?(type)\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n end\r\n end\r\n end\r\n # Minimize\r\n if skill>=PBTrainerAI.highSkill\r\n if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)\r\n multipliers[:final_damage_multiplier] *= 2\r\n end\r\n end\r\n # Move-specific base damage modifiers\r\n # TODO\r\n # Move-specific final damage modifiers\r\n # TODO\r\n ##### Main damage calculation #####\r\n baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max\r\n atk = [(atk * multipliers[:attack_multiplier]).round, 1].max\r\n defense = [(defense * multipliers[:defense_multiplier]).round, 1].max\r\n damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2\r\n damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max\r\n # \"AI-specific calculations below\"\r\n # Increased critical hit rates\r\n if skill>=PBTrainerAI.mediumSkill\r\n c = 0\r\n # Ability effects that alter critical hit rate\r\n if c>=0 && user.abilityActive?\r\n c = BattleHandlers.triggerCriticalCalcUserAbility(user.ability,user,target,c)\r\n end\r\n if skill>=PBTrainerAI.bestSkill\r\n if c>=0 && !moldBreaker && target.abilityActive?\r\n c = BattleHandlers.triggerCriticalCalcTargetAbility(target.ability,user,target,c)\r\n end\r\n end\r\n # Item effects that alter critical hit rate\r\n if c>=0 && user.itemActive?\r\n c = BattleHandlers.triggerCriticalCalcUserItem(user.item,user,target,c)\r\n end\r\n if skill>=PBTrainerAI.bestSkill\r\n if c>=0 && target.itemActive?\r\n c = BattleHandlers.triggerCriticalCalcTargetItem(target.item,user,target,c)\r\n end\r\n end\r\n # Other efffects\r\n c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant]>0\r\n if c>=0\r\n c += 1 if move.highCriticalRate?\r\n c += user.effects[PBEffects::FocusEnergy]\r\n c += 1 if user.inHyperMode? && move.type == :SHADOW\r\n end\r\n if c>=0\r\n c = 4 if c>4\r\n damage += damage*0.1*c\r\n end\r\n end\r\n return damage.floor\r\n end", "def pika_attack(enemy_hp)\n #randomization\n random = rand(10) + 1 #includes 10\n if random == 1 || random == 2\n puts \"Oh no, Pikachu missed!\".colorize(:yellow)\n elsif random == 3 || random == 4 || random == 5\n enemy_hp = enemy_hp - 2\n puts \"Pikachu used Tail Whip. Enemy's hp is reduced to #{enemy_hp}.\".colorize(:yellow)\n elsif random == 6 || random || 7 || random == 8\n enemy_hp = enemy_hp - 3\n puts \"Pikachu used ThunderShock. Enemy's hp is reduced to #{enemy_hp}.\".colorize(:yellow)\n else\n enemy_hp = enemy_hp - 4\n puts \"Pikachu used Slam. Enemy's hp is reduced to #{enemy_hp}.\".colorize(:yellow)\n end\n return enemy_hp\nend", "def fight\n display_hero_attack(attack_resolver(hero, monster))\n if monster.current_health > 0\n display_monster_attack(attack_resolver(monster, hero))\n else\n hero_win\n end\n end", "def gets_damage(damage)\n @life_points = @life_points - damage\n\n # If the user has 0 life point it show a message that he loose\n if @life_points <= 0\n puts \"\\n\"\n puts \"----- La partie est finie #{self.name} a perdu ! -----\"\n end\n end", "def compute_damage\n return rand(1..6)\n end", "def attacks (player)\n damage = compute_damage\n\n puts \">>> Le joueur #{self.name} attaque le joueur #{player.name}\"\n\n puts \">>> Il lui inflige #{damage} points de dommages\"\n\n # Give damages to the \"player\" in argument\n player.gets_damage(damage)\n end", "def attempt_attack(attack, enemy)\n if (Random.rand(100) < attack.success_rate)\n\n multiplier = 1\n if enemy.defense > @attack\n multiplier = 1 - ((enemy.defense * 0.1) - (@attack * 0.1))\n if multiplier < 0\n multiplier = 0\n end\n else\n multiplier = 1 + ((@attack * 0.1) - (enemy.defense * 0.1))\n end\n\n if (attack.wpn_attack)\n multiplier *= weapon.power\n end\n\n enemy.hp -= attack.damage * multiplier\n\n if enemy.hp < 0\n enemy.hp = 0\n end\n\n if multiplier > 0\n type(@name + \" uses #{attack.name} and it was successful, \")\n type(\"bringing #{enemy.name}'s HP down to #{enemy.hp.round(2)}.\")\n else\n type(\"#{@name} uses #{attack.name}, but #{enemy.name}'s defense\")\n type(\"is so high that it didn't have any effect.\")\n end\n print \"\\n\\n\"\n else\n type(\"#{@name} tries to use #{attack.name}, but it failed.\\n\\n\")\n end\n end", "def punch(person)\n\t\tif caffeine_level > 0\n\t\t\t@punch_strength = rand(0..@strength)\n\t\t\tif @punch_strength > 5\n\t\t\t\t@caffeine_level -= 50\n\t\t\t\tputs \"#{self.name} punches #{person.name.capitalize} so hard he does sumersaults in the air!\"\n\t\t\telse \n\t\t\t\tputs \"#{self.name} punches #{person.name.capitalize} so hard he screams and runs away in an extremely un-flattering anner.\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"#{self.name} needs more caffeine to punch. Try drinking coffee.\"\n\t\tend\n\n\t\t#reset caffeine level to zero if it's below\n\t\tif @caffeine_level < 0 \n\t\t\t@caffeine_level = 0\n\t\tend\n\tend", "def tenders_flip()\n\tif Random.rand(2) == 0 #achieves 50/50 probability\n\t\t\"It's Chicken Tenders Day!\" \n\telse \n\t\t\"Nope.\"\n\tend\nend", "def punch(person)\n\t\tif caffeine_level > 0\n\t\t\t@punch_strength = rand(0..@strength)\n\t\t\tif @punch_strength > 5\n\t\t\t\t@caffeine_level -= 50\n\t\t\t\tputs \"#{self.name} punches #{person.name.capitalize} so hard he does sumersaults in the air!\"\n\t\t\telse \n\t\t\t\tputs \"#{self.name} punches #{person.name.capitalize} so hard he screams and run away in an extremely unflattering manner.\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"#{self.name} needs more caffeine to punch. Try drinking coffee.\"\n\t\tend\n\n\t\t#reset caffeine level to zero if it's below\n\t\tif @caffeine_level < 0 \n\t\t\t@caffeine_level = 0\n\t\tend\n\tend", "def fight enemy, weapon\n if life <= 0\n return \"You are dead.\"\n end\n \n out = ''\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n out << \"[You hit the #{enemy.name} with #{your_hit} points of damage!]\\n\"\n out << enemy.hit(your_hit)\n\n # Retaliation\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n out << \"[The #{enemy.name} hit with #{enemy_hit} points of damage!]\\n\"\n out << self.hit(enemy_hit)\n end\n out\n end", "def attack\r\n\t\tputs \"#@name the #@type attacks!\"\r\n\t\tputs \" \"\r\n\t\t$attack = rand(20..60)\r\n\tend", "def drink_potion\n if @potions > 0\n @stats[:strength] = @orig_stats[:strength]\n @potions -= 1\n end\n end", "def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end", "def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end", "def attacks(player)\n\t\tputs \"#{@name} attaque #{player.name} !\"\n\t\tdamage = compute_damage\n player.gets_damage(damage)\n \n\t\tif player.life_points > 0\n\t\tputs \"#{@name} lui inflige #{damage} points de dommage.\\n\\n\"\n\t\telse \n\t\t\tputs \"Oups, #{player.name} c'est fait décapité...\\n\\n\"\n end\n\n end", "def fives2(dice)\n # this gets the number of fives\n fives = get_by_number(dice)[5]\n points = 0\n if fives == 1\n points = 50\n elsif fives == 2\n points += 100\n end\n points\n end", "def attack\r\n\t\tputs \"#@name the #@type attacks!\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\t$attack = rand(1..100)\r\n\tend", "def dmg( d_type, dmg, ap, srpe_att, char_att )\n d = dmg\n\n # surprise attacks do more damage\n if srpe_att\n d = d * 1.5\n end\n\n # when you see it coming, there is a chance that you get to evade part of the damage\n if !srpe_att && (rand(100) + 1 < @c_evade)\n d = d / 1.25; # consider redesigning this feature, the original value was way to strong, temp reducing the divider\n end\n\n # modify damage based on your resistances to the different types\n case d_type\n when :standard\n d -= @c_class == 'Knight' ? 10 : 0 # Warriors get a special resistance to standard damage\n when :magic\n d -= @c_class == 'Wizard' ? 10 : 1 # Magi get a special resistance to magic damage\n when :earth\n d -= 1\n when :fire\n d -= 1\n when :water\n d -= 1\n when :wind\n d -= 1\n when :shadow\n d -= @c_class == 'Shinobi' ? 10 : 1 # Rogue get a special resistance to shadow damage\n when :ice\n d -= 1\n when :lightning\n d -= 1\n when :dark\n d -= 1\n when :light\n d -= 1\n when :psionic\n d -= 1\n else\n d -= 0\n end\n\n # modify damage based on armor worn\n if @armor == 'Leather'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (2 - ap)\n end\n elsif @armor == 'Chain mail'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (6 - ap)\n end\n elsif @armor == 'Full Plate'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (12 - ap)\n end\n end\n\n # make sure we don't give them hp when they block it\n if d < 0\n d = 0;\n end\n\n # apply the damage\n @c_hp = @c_hp - d\n\n # display results\n if d == 0\n puts 'You suffered no damage from the attack, way to go!'\n elsif @c_hp <= 0\n @c_lvl -= 1\n puts \"You #{ @c_name } have perished. You respawn back at town square but have suffered loss in level. You are now level #{ @c_lvl }\"\n else\n puts \"You have suffered #{ d } wounds and now have #{ @c_hp } health left\"\n end\n\n # NOTE: this is becoming to painful, removing until we figure out\n # how to handle all the different combos for the counter attack\n # if @c_hp > 0 && !srpe_att && (rand(100) + 1 < @c_counter)\n # if @c_class == 'Knight' && @weapon == 'Short Sword'\n # char_att.dmg(:physical, rand(10) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Longsword'\n # char_att.dmg(:physical, rand(20) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Battle Axe'\n # char_att.dmg(:physical, rand(11) + 10, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Fireball'\n # char_att.dmg(:fire, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Ice Spikes'\n # char_att.dmg(:ice, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Crushing Grasp'\n # char_att.dmg(:magic, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Tanto'\n # char_att.dmg(:magic, rand(6) + 6, 6, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Ninjato'\n # char_att.dmg(:magic, rand(12) + 6, 3, false)\n # end\n # end\n end", "def get_fortune\r\n\t\trandomNo = 1 + rand(10)\r\n\t\t\r\n\t\t#Assign an answer based on the randomly generated\r\n\t\t#number\r\n\t\tcase randomNo\r\n\t\t\twhen 1\r\n\t\t\t\t$predicition = \"yes\"\r\n\t\t\twhen 2\r\n\t\t\t\t$predicition = \"no\"\r\n\t\t\twhen 3\r\n\t\t\t\t$predicition = \"maybe\"\r\n\t\t\twhen 4\r\n\t\t\t\t$predicition = \"hard to tell. Try again\"\r\n\t\t\twhen 5\r\n\t\t\t\t$predicition = \"unlikely\"\r\n\t\t\twhen 6\r\n\t\t\t\t$predicition = \"unknown\"\r\n\t\t\twhen 7\r\n\t\t\t\t$predicition = \"ask again later\"\r\n\t\t\twhen 8\r\n\t\t\t\t$predicition = \"hazy try again\"\r\n\t\t\twhen 9\r\n\t\t\t\t$predicition = \"better not tell you now\"\r\n\t\t\twhen 10\r\n\t\t\t\t$predicition = \"concentrate and ask again\"\r\n\t\tend\r\n\tend", "def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end", "def attack_effect_dispersion\r\n if self.damage.abs > 0\r\n amp = [self.damage.abs * 15 / 100, 1].max\r\n self.damage += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n end", "def battle\n\n puts \"You have reached the dragon's domain! You will fight him here.\"\n puts \"Mordremoth's biggest weakness if that he is made of plants.\"\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very bad choice against a plant enemy...\"\n gladiator_str -= 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, not a good choice against a plant enemy...\"\n gladiator_str -= 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very good choice against a plant enemy...\"\n gladiator_str += 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, kind of good choice against a plant enemy...\"\n gladiator_str += 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Mordremoth successfully\"\n enemy_heal -= gladiator_str\n puts \"Mordremoth's health is #{enemy_heal}\"\n # Enemy always strikes last\n if enemy_heal> 0\n puts \"Mordremoth strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts\n puts \"You have defeated Mordremoth! Now the world is safe.\"\n puts \"Or is it? Find out in the next episode: Path Of Fire!\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Mordremoth has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end", "def hp_decriment(opponent)\n\t\thp_will_change!\n\t\tputs \"damage taken!\"\n\t\t# self.hp -= 1 \n\t\tself.hp -= (1 + opponent.attack/self.defense)\n\t\tif self.hp <=0 \n\t\t\tputs \"Fatality!\"\n\t\t\tself.lives_decriment()\n\t\tend\n\t\tself.save!\n\tend", "def attack(opponent)\n\t\tmoveNumber = Random.new.rand(1..3)\n\t\tif(moveNumber == 1)\n\t\t\tp @name + \" kicks \"+ opponent.name #+\" loses 3 HP\"\n\t\t\topponent.HP-=3\n\t\t\tp opponent.name + \" loses 3 HP. His new HP is\"\n\t\t\tp opponent.HP\n\t\telsif(moveNumber == 2)\n\t\t\tp @name + \" scrachs \"+opponent.name #+\" loses 2 HP\"\t\n\t\t\tp opponent.name + \" loses 2 HP. His new HP is\"\n\t\t\topponent.HP-=2\n\t\t\tp opponent.HP\n\t\telsif(moveNumber == 3)\n\t\t\tp @name + \" bites \"+opponent.name #+\" loses 1 HP\"\n\t\t\tp opponent.name + \" loses 1 HP. His new HP is\"\n\t\t\topponent.HP-=1\n\t\t\tp opponent.HP\n\t\tend\n\tend", "def search_weapon\n\n #LANCER DE DE\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n\n #SI LE RESULTAT DU DE EST INFERIEUR AU NIVEAU DE L ARME, AFFICHER...\n if dice <= @weapon_level\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\n #SINON, AFFICHER... \n else\n @weapon_level = dice\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n end\n end", "def search_weapon\n weapon = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = weapon\n puts 'Youhou ! elle est meilleure que ton arme actuelle : tu la prends.'\n else\n puts \" M@*!$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end", "def probability_s=(value)\n @probability_s = value\n end", "def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}.\"\n # On récupère le nombre de points de dommage correspondant au lancer de dé via la méthode compute_damage\n damage_points = compute_damage\n puts \"Il lui inflige #{damage_points} points de dommage.\"\n # Ces points de dommage sont infligés à player. Si player n'a plus de points de vie, le programme affiche qu'il est mort.\n player.get_damage(damage_points)\n end", "def fight\n \n \n while @human.life_points >0 && (@player1.life_points > 0 || @player2.life_points >0)\n\n\n puts \"**********Menu**************\"\n puts \"a - find a better weapon\"\n puts \"s - find more points of life\" \n puts \"0 - attack player 1\"\n puts \"1 - attack player 2\"\n puts \"2 - receive attacks\"\n puts \"****************************\"\n puts \"Select an option:\"\n option = gets.chomp.to_s\n\n if option == \"a\"\n @human.search_weapon\n elsif option == \"s\"\n @human.search_health_pack\n elsif option == \"0\"\n @human.attacks(@player1)\n elsif option == \"1\"\n @human.attacks(@player2)\n elsif option == \"2\"\n puts \"You are under attack!\"\n @enemies.each { |i| i.life_points <= 0 ? break : i.attacks(@human)}\n @human.show_state\n else\n end\n end\n puts \"Game over\"\n puts \"You won\"\nend", "def cap_redeem(num_bottles)\n\tnum_bottles/4\nend" ]
[ "0.6536238", "0.65259504", "0.649797", "0.6457003", "0.64236873", "0.64165413", "0.6403955", "0.6380676", "0.63515675", "0.63515675", "0.6351394", "0.6319909", "0.62938344", "0.62728596", "0.62024826", "0.6182185", "0.61672884", "0.61560756", "0.6151404", "0.61190915", "0.61084664", "0.6106098", "0.6106098", "0.61033136", "0.60966414", "0.60876626", "0.6065349", "0.60573983", "0.60573983", "0.6037543", "0.6033162", "0.6022174", "0.6015642", "0.6015237", "0.60086614", "0.60070753", "0.600383", "0.6000545", "0.59851533", "0.5985124", "0.5982315", "0.5978572", "0.597355", "0.59626293", "0.5949212", "0.59480906", "0.59471184", "0.5946651", "0.59315926", "0.59315926", "0.5928158", "0.59238756", "0.5923293", "0.5918705", "0.59039104", "0.59032094", "0.5895696", "0.58941954", "0.58939373", "0.58873725", "0.58784187", "0.58781636", "0.58700955", "0.5868748", "0.58651847", "0.5863493", "0.5859587", "0.58549815", "0.5854579", "0.58506423", "0.58490294", "0.5848675", "0.5843812", "0.5837021", "0.5834525", "0.58257806", "0.5825212", "0.5823848", "0.5821348", "0.5821048", "0.58189976", "0.5816338", "0.58162", "0.58129907", "0.58085597", "0.58020186", "0.5798648", "0.5788053", "0.5787783", "0.5780637", "0.5774857", "0.5768685", "0.57637966", "0.5760168", "0.5752454", "0.57512", "0.5739007", "0.5731598", "0.57284355", "0.5727388", "0.5726101" ]
0.0
-1
Allows the player to eat food
def consume eated_food = 0; player = @game.player puts "you have #{player.food} Units of food" loop do puts "What do you Want to eat?" eated_food = gets.to_i break if eated_food <= player.food && eated_food >= 0 end player.food -= eated_food player.strength = (player.strength + 5 * eated_food).to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eat(food)\n food.eat 1\n @energy += METABOLISM\n end", "def eat\n inventory[:fish] -= @daily_appetite = 10\n\n if inventory[:fish] < 0\n @alive = false\n inventory[:fish] = 0\n end\n end", "def eat(food)\n if food.veggie? && !@carnivore\n @hunger -= 10\n elsif food.meat? && @carnivore\n @hunger -= 10\n end\n @hunger = 0 if @hunger < 0\n end", "def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end", "def feed(food)\n puts \"Mmmm, \" + food + \"!\"\n @hungry = false\n end", "def spot_food(food)\n @fish.direction = @fish.move_towards(food)\n @fish.status = Pursuing\n @fish.target = food\n end", "def eat\n @last_food = Time.now\n end", "def eat(food)\n super(food) #- takes this from parent's eat(food) method\n puts(\"Woof\")\n end", "def beg_for_food(food_served)\n if food_served\n puts \"Whimper\"\n end\n end", "def eat(food)\n @foods_eaten << food\n end", "def eat(food)\n @foods_eaten.push(food)\n end", "def look_for_food(fish)\n fish.stop_turn\n food_range = fish.food_perception\n food = food_around(fish.position, food_range)\n if food.size > 0 && !(fish.status==Escaping)\n food_found = food[0]\n if fish.position.distance(food_found.position) <= EatingAndMatingRange\n fish.consume(food_found)\n @food.delete(food_found)\n @food.compact!\n else\n fish.spot_food(food_found)\n end\n end\n end", "def consume_food\n if @status == :alive\n # eat the food if it is within my scope\n @food = @food + @food_within_scope.first.eat(@consumption_rate) if !@food_within_scope.empty?\n\n # if I have a storage of food, I'll digest it\n if @food > 0\n @food = @food - (1 * @digestion_rate)\n @food = 0 if @food < 0\n else\n # if i run out of food, i'll starve i.e. die faster\n @starvation_rate = @starvation_rate + 1\n end \n \n end \n end", "def eat\n @hungry = false\n end", "def eat\n @hungry = false\n end", "def eat\n @hungry = false\n end", "def feedPet\n @pet.eat\n end", "def eat\n puts 'Start eating'\n end", "def food_command\n name = get_param(\"name=\", \"([a-zA-Z]+)\")\n\n if name\n @app.food name\n else\n puts \"Error!: A name is required to give food to an animal\"\n food_command_help()\n end\n end", "def update_food\n @food.each do |food|\n if food.position.y <= FoodHeight and rand<FoodDissapearChance\n @food.delete(food)\n @food.compact!\n else\n food.move\n end\n end\n # randomly add food\n add_food if rand <= Food_Spawn_Chance\n end", "def eat(food)\n @stomach << food \n end", "def play\n puts \"Oh no! An enemy has appeared before you! \"\n puts \"You must now fight to the death!\"\n puts \"Since this is an easy game, you get to go first\"\n while @player.health > 0 && @foe.health > 0\n puts \"How shall you proceed?\"\n print \"> \"\n action = $stdin.gets.chomp\n if action.include? \"attack\"\n damage = (@player.attack - @foe.defence * 0.25) #defence moderates attack power\n @foe.health -= damage\n puts \"You did #{damage} damage to your foe!\"\n elsif action.include? \"magic\"\n damage = (@player.magic/2)\n puts \"Your magic attack did #{damage} damage to your foe!\"\n @foe.health -= damage\n else\n next\n end\n @foe.attack\n end\n if (@foe.health <= 0)\n @player.restore\n code = \"win\"\n else\n code = \"Dead\"\n end\n return code\n end", "def catch_fish\n inventory[:fish] += @skills[:fish]\n end", "def cook_sink_eat\n delay = 4\n refresh\n HowMuch.amount(6) if click_on 'Mix/Add Honey'\n sleep delay\n refresh\n HowMuch.amount(1) if click_on 'Mix/Add Coconut'\n\n sleep delay\n refresh\n click_on 'Cook'\n popup = PopupWindow.find\n popup.click_on 'OK' if popup\n sleep delay\n\n # Eat!\n refresh\n click_on 'Enjoy'\n sleep delay\n end", "def eat\n puts \"Eating the oreo cookie~~\"\n super\n end", "def eat(food)\n @stomach << food \n digest\n end", "def say_fav_food(food)\n puts \"One of your favorite foods is #{food}\"\n menu_favorite_foods\nend", "def add_food\n srand\n self << FishFood.new(Position.new([randomFloatSigned*2,1,randomFloatSigned]))\n end", "def actions\n answer = @prompt.select(\"Where will you go?\", %w(Foward Back Status Items), cycle:true, per_page:4)\n if answer == \"Foward\"\n if @zone_cur == 10\n narrate(\"you leave the #{self.name}\")\n leave(self.exit_name)\n else\n @zone_cur += 1\n narrate(\"you continue foward\")\n encounter_check\n end\n elsif answer == \"Back\"\n if @zone_cur == 0\n narrate(\"you leave the #{self.name}\")\n leave(self.entrance_name)\n else\n @zone_cur -= 1\n narrate(\"you retreat backwards\")\n encounter_check\n end\n elsif answer == 'Status'\n narrate(\"#{@player.name} has #{@player.hp} hp, #{@player.attack} attack, and #{@player.defence} defence\")\n str = \"\"\n a = @player.equipment.map do |el|\n el.name\n end\n b = a.join(\", \")\n narrate(\"#{@player.name} has the following items equipped: #{b}\")\n here\n elsif answer == 'Items'\n answer = @prompt.select(\"Items Menu\", %w(Equip_item Look_item), cycle:true, per_page:4)\n if answer == 'Equip_item'\n #list inventory\n stuff = @player.items.map do |el|\n el.name\n end\n #select an item from inventory\n answer = @prompt.select(\"Items Menu\", stuff, cycle:true, per_page:4)\n #find that item again\n to_eq = @player.items.find do |el|\n el.name == answer\n end\n binding.pry\n #equip that item\n @player.equip(to_eq)\n narrate( \"You have equipped the #{to_eq.name}!\")\n actions\n end\n end\n end", "def meow\n puts \"My name is #{@name} and I eat #{@preferred_food} at #{eats_at}.\"\n end", "def lookAtFood\n\t\t@player.getFoodDesc \n\tend", "def continue\n\n inventory_with_leisure = expected_inventory.dup\n inventory_with_leisure[:leisure] = 1\n\n inventory_with_fishing = expected_inventory.dup\n # TODO: DRY up this logic with Person#catch_fish\n inventory_with_fishing[:fish] += @skills[:fish]\n\n #p '@'*88\n #p inventory_with_fishing\n #p rank_potential_inventory(inventory_with_fishing)\n #p '@'*88\n #p inventory_with_leisure\n #p rank_potential_inventory(inventory_with_leisure)\n #p '@'*88\n if rank_potential_inventory(inventory_with_fishing) < rank_potential_inventory(inventory_with_leisure)\n catch_fish\n @last_activity = :catch_fish\n else\n @last_activity = :leisure\n end\n\n\n eat # or starve\n end", "def set_eat(eated)\n @eated = eated\n @movetype = :move_eat\n end", "def add_to_total(food)\n Farm.add_food(food)\n end", "def eat_humans\n @health += 20\n self\n end", "def game_water_action\n if tool_canuse?(WweaponId) and not @showing_water\n if actor.mp >= FlameMpCost\n @gamewater.direction = @direction\n @gamewater.moveto(@x, @y)\n @gamewater.char_steps = 2\n @gamewater.action_time = WaterDuration\n @showing_water = true\n RPG::SE.new(WaterSoundSe,80).play\n #actor.mp -= FlameMpCost\n @tool_anime = WaterDuration\n else\n Sound.play_buzzer\n end\n end\n end", "def heal\n @mana -= 5\n if @mana < 5\n puts \"You don't have the mana\"\n @health += 0\n else\n @health += 10\n end\n end", "def game_fire_action\n if tool_canuse?(FweaponId) and not @showing_fire\n if actor.mp >= FlameMpCost\n @gamefire.direction = @direction\n @gamefire.moveto(@x, @y)\n @gamefire.char_steps = 2\n @gamefire.action_time = FlameDuration\n @showing_fire = true\n RPG::SE.new(FlameSoundSe,80).play\n #actor.mp -= FlameMpCost\n @tool_anime = FlameDuration\n else\n Sound.play_buzzer\n end\n end\n end", "def feed(amount=10)\n @food_in_belly += amount\n\n if @food_in_belly > 100\n puts \"#{@name} is stuffed. #{@name} pukes the execess.\"\n @food_in_belly = 100\n else\n puts \"#{@name} eats happily.\"\n end # end of conditional for overstuffed\n time_passed\n end", "def feed_fish\n pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end", "def eat\n puts \"From Oreo\"\n super\n end", "def hungry?\r\n @food <= 2\r\n end", "def food?; @food; end", "def food?; @food; end", "def food?; @food; end", "def eat(food, two)\n binding.pry # self\n super(\"fish\") # call the eat method in the parent class\n puts \"Play with #{food}.\"\n\n end", "def food_eaten\n max_vegetation = 1300 # max size of vegetation jungle 13\n max_food = max_health / 3.0\n\n field.vegetation.size * max_food / max_vegetation\n end", "def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end", "def train_peasant\n if can_train_peasant?\n @gold -= 90\n @food -= 5\n Peasant.new\n end\n end", "def spawn \n\t\tputs \"Greetings, adventurer! What is your name?\" \n\t\t@name = gets.chomp\n\t\tputs \"What race will you be? [E]lven [H]uman [D]warven\"\n\t\tcase gets.chomp.downcase \n\t\t\twhen \"d\" \n\t\t\t\t@race = \"Dwarf\" \n\t\t\t\t@inventory = [\"Axe\", \"Plate Armor\"]\n\t\t\t\t@hit_points = 14\n\t\t\t\t@symbol = \"@\"\n\t\t\twhen \"h\" \n\t\t\t\t@race = \"Human\"\n\t\t\t\t@inventory = [\"Mace\", \"Chainmail\"]\n\t\t\t\t@hit_points = 12 \n\t\t\t\t@symbol = \"@\"\n\t\t\twhen \"e\" \n\t\t\t\t@race = \"Elf\" \n\t\t\t\t@inventory = [\"Sword\", \"Scale Armor\"]\n\t\t\t\t@hit_points = 10 \n\t\t\t\t@symbol = \"@\"\n\t\tend\n\t\tfly(5, 5, @symbol)\n\tend", "def hungry_river\n food = 5\n until food == 21\n puts \"please oh please give me marie back\"\n puts food \n food *= 2 \n end \nend", "def turn\n # start with simplest model of food consumption and creation\n if @food_production >= @population\n food_surplus = @food_production - @population\n else\n food_deficit = @population - @food_production\n end\n\n if food_surplus\n @food_storage += food_surplus\n elsif food_deficit\n if @food_storage >= food_deficit\n @food_storage -= food_deficit\n else\n shortage = food_deficit - @food_storage\n @food_storage = 0\n @population -= shortage # that many people starve\n end\n end\n\n @population += (@population * @@fertility_rate).floor\n end", "def meow\n puts \"My name is #{name} and i eat #{preferred_food} at #{eats_at}\"\n end", "def eat_allergies\t\n\t\tno_allergies != \"scallops\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Beth, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Beth went to the hosptial for some reason, hmm.\"\n\t\tend", "def eat_allergies\t\n\t\tno_allergies != \"scallops\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Beth, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Beth went to the hosptial for some reason, hmm.\"\n\t\tend", "def feed_fish\n self.pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end", "def buy_fish(name)\n pets[:fishes] << Fish.new(name)\n end", "def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end", "def fight(user, enemies, player1, player2)\n while user.life_points >0 && (player1.life_points > 0 || player2.life_points >0)\n user.show_state\n puts \"\n Quelle action veux-tu effectuer ?\n\n a - chercher une meilleure arme\n s - chercher à se soigner \n \n attaquer un joueur en vue :\n\n 0 - Josiane a #{player1.life_points} points de vie\n 1 - José a #{player2.life_points} points de vie\"\n puts \"*******************************************************************\" \n choice = gets.chomp \n puts \"***********************************************************************\" \n \n if choice == \"a\" \n user.search_weapon\n elsif choice == \"s\"\n user.search_health_pack\n elsif choice == \"0\"\n user.attacks(player1)\n elsif choice == \"1\"\n user.attacks(player2)\n end\n\n puts \"***********************************************************************\" \n enemies.each do |x|\n break if x.life_points <= 0\n x.attacks(user)\n puts \"Les autres joueurs t'attaquent !\"\n end\n end \n if user.life_points > 0\n puts \"BRAVO ! TU AS GAGNE !\"\n else \n puts \"Loser ! Tu as perdu !\"\n end\nend", "def heal\n 2.times { super } # or self.helth = [self.helth + 2, MAX_HEALTH].min\n 'Ready for Battle!'\n end", "def eat_allergies\t\n\t\tno_allergies != \"gluten\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Chris, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Chris went to the hosptial for some reason, hmm.\"\n\t\tend", "def eat_allergies\t\n\t\tno_allergies != \"gluten\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Chris, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Chris went to the hosptial for some reason, hmm.\"\n\t\tend", "def heal\n\t\tif self.weapon == true\n\t\t\tself.hitpoints += (self.faith + self.weapon.mending)\n\t\t\thealth_overflow_check\n\t\t\tself.save!\n\t\telse\n\t\t\tself.hitpoints += self.faith\n\t\t\thealth_overflow_check\n\t\t\tself.save!\n\t\tend\n\tend", "def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end", "def %( enemy )\n lettuce = rand( charisma )\n puts \"[Healthy lettuce gives you #{ lettuce } life points!!]\"\n @life += lettuce\n fight( enemy, 0 )\n end", "def attacks (player)\n damage = compute_damage\n\n puts \">>> Le joueur #{self.name} attaque le joueur #{player.name}\"\n\n puts \">>> Il lui inflige #{damage} points de dommages\"\n\n # Give damages to the \"player\" in argument\n player.gets_damage(damage)\n end", "def C\r\n puts \"\\nYOU HAVE #{$food} UNITS OF FOOD\"\r\n puts \"HOW MANY DO YOU WANT TO EAT?\"\r\n wanna_eat = gets.strip.to_i\r\n if wanna_eat> $food\r\n puts \"THATS MORE FOOD THAN YOU HAVE\\n\"\r\n else\r\n $food = $food-wanna_eat\r\n $strength = $strength+(5*wanna_eat)\r\n end\r\n return \"F\" \r\nend", "def feed_fish\n @pets[:fishes].each { |fish| fish.mood = \"happy\"}\n end", "def melee_weapon; end", "def smoke_weed\n\tif (@inventory.include?('marijuana') && @inventory.include?('bong') && @inventory.include?('lighter'))\n\t\t@health = 100\n\t\t@pointless_points += 50\n\t\tputs \"You pack the bong full of weed and take a huge rip!\"\n\t\tputs \"\"\n\t\tputs \"Youre health is now at 100/100\"\n\t\tputs \"+50 points!\"\n\t\tputs \"\"\n\t\t@inventory.slice!(@inventory.index('marijuana'))\n\telse\n\t\tputs \"Maybe you can find somebody to help you out with that...\"\n\t\tputs \"\"\n\tend\n\tcontroller\nend", "def do_action\n if self.affects == \"world\" then\n player_tile = self.character.tile\n\n # an aoe effect is represented as a list of objects,\n # each one representing the effect on one tile\n ITEM_PROPERTIES[self.item_type][\"aoe\"].each do |aoe|\n dx = aoe[\"xCoordPlus\"]\n dy = aoe[\"yCoordPlus\"]\n tile_becomes = aoe[\"tileBecomes\"]\n Tile.tile_at(player_tile.x + dx, player_tile.y + dy).become tile_becomes\n end\n\n elsif self.affects == \"player\" then\n\n dx = self.moves_player_x\n dy = self.moves_player_y\n\n # Move me to the place this item takes me\n if (dx != 0 or dy != 0) then\n target_tile = Tile.tile_at(self.character.tile.x + dx,\n self.character.tile.y + dy)\n if target_tile\n self.character.tile = target_tile\n end\n end\n\n self.character.heal(self.health_effect)\n self.character.charge(self.battery_effect)\n end\n\n if self.consumable then\n self.character.item = nil\n self.destroy\n end\n\n end", "def action\n if player_hand.collect{|x| x.value}.inject(:+) < 21 && player_hand.length == 6\n lengthwin\n else\n puts \"Would you like to 'hit' or 'stay'?\"\n answer = STDIN.gets.chomp.downcase\n until answer == \"hit\" || answer == \"stay\"\n puts \"Simply let me know if you would like to 'hit' or 'stay', sir.\"\n answer = STDIN.gets.chomp\n end\n if answer == \"hit\"\n hit = bjdeck.draw\n player_hand << hit\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) > 21\n puts \"It appears you have busted.\"\n lose\n else\n action\n end\n else\n computer_turn\n end\n end\n end", "def test_eat\n fish_before = @river.fish.length\n fish_target = @river.fish[@river.fish.length-1].name\n @bear1.eat_from(@river)\n fish_after = @river.fish.length\n assert_equal(1, fish_before - fish_after)#checks 1 fish has been removed from river\n assert_equal(fish_target, @bear1.belly[@bear1.belly.length-1])#checks bear's belly contains the fish that it should have eaten from the river\n end", "def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end", "def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end", "def feed_fish\n @pets[:fishes].each {|fish| fish.mood = \"happy\"}\n end", "def meow\n puts \"My name is #{@name.capitalize} and I love eating #{@preferred_food} at #{eats_at}\"\n end", "def fight\n \n \n while @human.life_points >0 && (@player1.life_points > 0 || @player2.life_points >0)\n\n\n puts \"**********Menu**************\"\n puts \"a - find a better weapon\"\n puts \"s - find more points of life\" \n puts \"0 - attack player 1\"\n puts \"1 - attack player 2\"\n puts \"2 - receive attacks\"\n puts \"****************************\"\n puts \"Select an option:\"\n option = gets.chomp.to_s\n\n if option == \"a\"\n @human.search_weapon\n elsif option == \"s\"\n @human.search_health_pack\n elsif option == \"0\"\n @human.attacks(@player1)\n elsif option == \"1\"\n @human.attacks(@player2)\n elsif option == \"2\"\n puts \"You are under attack!\"\n @enemies.each { |i| i.life_points <= 0 ? break : i.attacks(@human)}\n @human.show_state\n else\n end\n end\n puts \"Game over\"\n puts \"You won\"\nend", "def attack(player)\n player.receive_damage\n end", "def flee(monster)\n if dice_roll < @agility\n puts \"----- Nice! -----\".top_border\n puts \"You've made a deft escape.\".bottom_border\n return true \n else\n puts \"Oh no! Your escape was blocked.\"\n monster.attack(self)\n return false\n end \n end", "def buy_fish(fish_name)\n fish = Fish.new(fish_name)\n self.pets[:fishes] << fish\n end", "def command_newFood(name, calories)\n bool = @database.add_basicFood(name, calories)\n if bool == false\n puts \"Food already in database\"\n end\n @dbChanged = true\n end", "def eat(w)\n w.refresh\n text = w.read_text\n return false if text.include?('This is too far')\n\n # Don't know what a kitchen looks like yet. \n if w.click_on 'Consume'\n sleep 5\n w.refresh\n return true\n else\n return false\n end\n end", "def hit\n @printer = []\n @printer << \"You Hit.\"\n deal_player\n pl_total\n if session[:player].bust? || session[:player].hand_total == 21\n @action = :end\n run_dealer\n else\n @action = :choice\n end\n chat\n end", "def grab_food\n\tputs 'grabbing some food'\n\tputs 'and it’s good!'\nend", "def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end", "def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end", "def fly\n @health -= 10\n self\n end", "def attacks(player)\n dice = compute_damage\n puts \"#{@name} attaque #{player.name} : Il lui inflige #{dice} points de dommages\"\n player.life_points = player.life_points - dice\n end", "def cats_favorite_food\n prompt = TTY::Prompt.new\n choices = {\n \" 1 - See which type of food you'll to put out to attract a specific cat\" => 1,\n \" 2 - View all of the cats that prefer wet food\" => 2,\n \" 3 - View all of the cats that prefer dry food\" => 3,\n \" 4 - Return to the Main Menu\" => 4 }\n choice = prompt.select(\"\\nIf you're lonely and want a cat, here's the info you'll need to attract one!\\n\", choices, per_page: 4)\n case (choice.to_i)\n when 1\n puts \"\\nWhich cat would you like to attract?\"\n cat_food_name = gets.chomp\n cat_fav_food = Cat.find_by(name: cat_food_name).favorite_food\n puts \"\\n#{cat_food_name} prefers #{cat_fav_food} food.\"\n when 2\n puts \"\\nCats that prefer wet food:\"\n Cat.where(:favorite_food => \"wet\").select {|cat| puts cat.name}\n when 3\n puts \"\\nCats that prefer dry food:\"\n Cat.where(:favorite_food => \"dry\").select {|cat| puts cat.name}\n when 4\n main_menu\n end\n end", "def set_food=(new_food)\n @food = new_food\n end", "def eat_at\n if @meal_time < 12\n puts \"#{@name} eats at#{@meal_time}AM\"\n else\n puts \"#{@name} eat at #{@meal_time}PM\"\n end\n end", "def attacks(player)\n\t\tputs \"#{@name} attaque #{player.name} !\"\n\t\tdamage = compute_damage\n player.gets_damage(damage)\n \n\t\tif player.life_points > 0\n\t\tputs \"#{@name} lui inflige #{damage} points de dommage.\\n\\n\"\n\t\telse \n\t\t\tputs \"Oups, #{player.name} c'est fait décapité...\\n\\n\"\n end\n\n end", "def attack(opponent)\n if alive?\n opponent.take_damage(strength) \n talk(\"#{full_name} is attacking #{opponent.full_name}\")\n else\n talk \"Hey, you #{last_name} you dead WTF!!\"\n end\n end", "def attacks(player)\n puts \"#{@name} attaque #{player.name}\"\n damage = compute_damage\n puts \" il lui inflige #{damage} points dommages\"\n player.gets_damage(damage)\n end", "def hungry_andrew\n food = 5\n \n until food == 21\n puts \"PLEASE OH PLEASE COME BACK MARIE!\"\n puts food \n food += 1 \n end\nend", "def heal()\r\n @warrior.rest!\r\n end", "def heal()\r\n @warrior.rest!\r\n end", "def heal()\r\n @warrior.rest!\r\n end", "def heal()\r\n @warrior.rest!\r\n end" ]
[ "0.8032357", "0.7786166", "0.7517575", "0.7176732", "0.71376944", "0.7037982", "0.6990854", "0.698429", "0.6956305", "0.6925741", "0.68741566", "0.6721797", "0.6705704", "0.66982865", "0.66982865", "0.66982865", "0.66530955", "0.66468847", "0.65129995", "0.6463032", "0.6277849", "0.6259122", "0.6233279", "0.6210999", "0.6169055", "0.6146507", "0.6133043", "0.61149484", "0.61042225", "0.6101474", "0.610127", "0.6090966", "0.60888046", "0.60842437", "0.60742426", "0.6052424", "0.6031007", "0.6026952", "0.60186505", "0.6016398", "0.6016274", "0.60110736", "0.59875274", "0.59875274", "0.59875274", "0.5968008", "0.5951208", "0.5941016", "0.59254277", "0.5905832", "0.59041727", "0.59004414", "0.58854467", "0.58793813", "0.58793813", "0.58759457", "0.58676463", "0.58658886", "0.583857", "0.58373624", "0.58373094", "0.58373094", "0.5823967", "0.5814578", "0.5814578", "0.5812202", "0.58089095", "0.5802896", "0.5802464", "0.57859755", "0.5782261", "0.576864", "0.5767866", "0.5765763", "0.5763571", "0.5759186", "0.57549846", "0.5751103", "0.5740988", "0.5736729", "0.5733725", "0.5732212", "0.5730069", "0.572934", "0.5725965", "0.57159096", "0.57159096", "0.5696644", "0.5695205", "0.5693552", "0.5691369", "0.5677192", "0.56750315", "0.56748676", "0.56727004", "0.5663186", "0.5654982", "0.5654982", "0.5654982", "0.5654982" ]
0.74527705
3
Transitions to the buying state
def inventory @game.state = BuyingState.new @game @game.state.handle end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_state_update\n return unless state_changed?\n\n return if @ignore_state_changes\n\n case state_change\n when %w(mill_build buyer_unclaimed)\n transition_mill_build_to_buyer_unclaimed\n when %w(buyer_unclaimed buyer_build)\n transition_buyer_unclaimed_buyer_build\n when %w(buyer_build pending)\n transition_buyer_build_to_pending\n when %w(pending ordered)\n transition_pending_to_ordered\n when %w(ordered closed)\n transition_ordered_to_closed\n end\n end", "def handle_purchase\n if saved_change_to_state == %w(draft purchased)\n seller.increase_balance(payment.amount)\n end\n end", "def attemp_buying\n\n end", "def transition_from_pending\n enter_transcoding if Transcoder.available.any?\n end", "def finish\n transition_to(:successful) unless transition_to(:waiting_funds)\n end", "def transition_from_pending\n if requires_transcoding?\n enter_transcoding\n elsif requires_post_processing?\n enter_post_processing\n else\n enter_conformance_checking\n end\n end", "def toggle_picked_up\n @order = Order.find(params[:id]).toggle_pickup!\n redirect_back fallback_location: '/order_seasons/' + params[:id] + \"/orders\"\n end", "def do_buy(number)\r\r\n $game_party.lose_currency(@gold_window.currency, number * buying_price)\r\r\n $game_party.gain_item(@item, number)\r\r\n end", "def to_be_done()\r\n\t\t#\r\n\t\t# loss_trig_price = price - loss\r\n\t\t# loss_price = price - loss - 10\r\n\t\t# obuy \t = push_buy( \t\t quantity: quantity, price: price )\r\n\t\t# monitor_filled( obuy )\r\n\t\t# obuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\t\t#\r\n\t\t#\r\n\t\t# loss_trig_price = price + loss\r\n\t\t# loss_price = price + loss + 10\r\n\t\t# osell = push_sell( \t\t quantity: quantity, price: price)\r\n\t\t# monitor_filled( osell )\r\n\t\t# osell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\t\t#\r\n\r\n\r\n\t\t# modo mais simples primeiro\r\n\t\t# entrar a market\r\n\t\tloss_trig_price = price - loss\r\n\t\tloss_price = price - loss - 10\r\n\t\tobuy \t = push_buy( \t\t quantity: quantity, price: 0 )\r\n\t\tmonitor_filled( obuy )\r\n\t\tobuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\r\n\r\n\t\tloss_trig_price = price + loss\r\n\t\tloss_price = price + loss + 10\r\n\t\tosell = push_sell( \t\t quantity: quantity, price: 0)\r\n\t\tmonitor_filled( osell )\r\n\t\tosell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\tend", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def set_sellable_item_state(state_result)\n if !state_result[:inventory_item].nil?\n if (state_result[:inventory_item].quantity > state_result[:inventory_item].item.quantity_threshold)\n state_result[:inventory_item].update(id: state_result[:inventory_item].id, inventory_item_state: InventoryItemState.find_by(name: \"Available\"))\n elsif (state_result[:inventory_item].quantity == 0)\n state_result[:inventory_item].update(id: state_result[:inventory_item].id, inventory_item_state: InventoryItemState.find_by(name: \"Out_of_Stock\"), inventory_item_condition: InventoryItemCondition.find_by(name: \"Not_Sellable\"))\n else\n state_result[:inventory_item].update(id: state_result[:inventory_item].id, inventory_item_state: InventoryItemState.find_by(name: \"CriticaL_Level\"))\n end\n end\n end", "def take_off!\n\t\t@flying = true\n\t\tself\n\tend", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def activate\n if player.location.has_items?\n # set inventory index being considered for get\n @index = 0\n @item = player.location.inventory[@index]\n if player.inventory.can_fit?(@item)\n if player.location.inventory.size == 1 && @item.quantity == 1\n # a single item at the location so just get it\n player.get(@item)\n game.change_state(Map.new)\n else\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n end\n else\n game.messages << 'Your inventory is full.'\n game.change_state(Map.new)\n end\n else\n # no items at location\n game.change_state(Map.new)\n end\n end", "def buy_it_now\n\t\t# find item with respect to its ID\n @item = Item.find(params[:id])\n\n\t\t# can't buy closed item, security\n if @item.closed\n gflash :error => \"Unknown action\"\n else\n\t\t\t# can't buy your own items\n if current_user == @item.user\n gflash :error => \"You cannot buy your own item!\"\n elsif current_user.money >= @item.bin_price\n\t\t\t\t# if there are bids, refund highest bidder\n if @item.bids.first\n @highest_bid = @item.bids.sort_by{|b| b.price}.last\n highest_bidder = @highest_bid.bidder\n highest_bidder.update_attribute(:money, highest_bidder.money+@highest_bid.price)\n end\n\t\t\t\t\n\t\t\t\t# show pop up regarding BIN success\n gflash :success => \"Congratulations! You have bought the item.\"\n @item.closed = true\n\n\t\t\t\t# automatically replace the html to show the auction is now closed using ajax so\n\t\t\t\t# refreshing the page is not necessary, i.e. automatically update the auction closed box\n render :juggernaut => {:type => :send_to_all} do |page|\n page.replace_html :show_item_time, \"\"\n page.replace_html :bid_id, \"\"\n page.replace_html :highest_bid, \"Auction is closed!\"\n page.replace_html :show_item_bin_button, \"\"\n page.replace_html :show_item_watch, \"\"\n page.replace_html :show_item_stop, \"\"\n page.replace_html \"item_time_#{@item.id}\", :partial => 'items/search_time_ticker', :object => @item\n page.visual_effect :highlight, \"item_time_#{@item.id}\", :duration => 5\n end\n\n\t\t\t\t# update item attribute\n @item.update_attribute(:closed,true)\n\n\t\t\t\t# add money to the seller\n\t\t\t\tposter = @item.user\n poster.update_attribute(:money, poster.money+@item.bin_price)\n\n\t\t\t\t# deduct the money from the buyer\n current_user.update_attribute(:money,current_user.money-@item.bin_price)\n\n\t\t\t\t# create new transaction\n\t\t\t\ttransaction = Transaction.new\n \t transaction.seller_id = poster.id\n \t transaction.buyer_id = current_user.id\n \t transaction.item_id = @item.id\n \t transaction.price = @item.bin_price\n \t transaction.save\n else\n gflash :error => \"Cannot afford to buy this item\"\n end\n end\n redirect_to :controller => 'items', :action => 'show', :id => params[:item_id]\n end", "def update_buy\n # Set status sprite item\n @status_window.item = @buy_window.item\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Change windows to initial mode\n @command_window.active = true\n @dummy_window.visible = true\n @buy_window.active = false\n @buy_window.visible = false\n @status_window.visible = false\n @status_window.item = nil\n # Erase help text\n @help_window.set_text(\"\")\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get item\n @item = @buy_window.item\n # If item is invalid, or price is higher than money possessed\n if @item == nil or @item.price > $game_party.gold\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Get items in possession count\n case @item\n when RPG::Item\n number = $game_party.item_number(@item.id)\n when RPG::Weapon\n number = $game_party.weapon_number(@item.id)\n when RPG::Armor\n number = $game_party.armor_number(@item.id)\n end\n # If 99 items are already in possession\n if number == 99\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Calculate maximum amount possible to buy\n max = @item.price == 0 ? 99 : $game_party.gold / @item.price\n max = [max, 99 - number].min\n # Change windows to quantity input mode\n @buy_window.active = false\n @buy_window.visible = false\n @number_window.set(@item, max, @item.price)\n @number_window.active = true\n @number_window.visible = true\n end\n end", "def sell_pending\n end", "def toggle_pickup\n p = Package.find(params[:id])\n \n if p.picked_up \n p.picked_up = false\n p.clerk_accepted_id = nil\n p.datetime_accepted = nil\n \n if p.save\n flash[:notice] = \"Package was marked as not picked up.\"\n redirect_to packages_path\n else\n flash[:warning] = \"There was an error in marking this package as not picked up.\"\n redirect_to package_path p\n end\n else\n p.picked_up = true\n p.clerk_accepted_id = current_clerk.id\n p.datetime_accepted = Time.now.to_datetime\n if p.save\n flash[:notice] = \"Package was marked as picked up.\"\n redirect_to packages_path # or to the resident sign-up page if they arent opted in?\n else\n flash[:warning] = \"There was an error in marking this package as picked up.\"\n redirect_to package_path p\n end\n end\n end", "def checkout \n system 'clear'\n CoffeeMan.stay_logo\n if @@cart.count == 0 \n puts \"Your cart is empty, please select an item\"\n sleep 1\n main_menu \n else\n system('say \"Already blocked it in my calendar!\"')\n puts \"Your order has been confirmed of #{@@cart.join(\", \")}. It will be ready for pickup in #{rand(20...40)} minutes! Can't wait to hangout!\"\n puts \"Already blocked it in my calendar!\".colorize(:color => :light_blue, :background => :yellow)\n stop_music \n sleep 2\n end\n end", "def buy\n shipment = Shipment.find(params[:shipment_id])\n shipment.update_column(:affiliate_shipping_account, params[:affiliate_shipping_account] == \"true\")\n EasyPost.api_key = shipment.easy_post_api_key\n\n begin\n ep_shipment = EasyPost::Shipment.retrieve(params[:ep_shipment_id])\n easypost_purchase(shipment, params[:rate_id], ep_shipment)\n ShipmentItem.where(shipment_id: shipment.id, special_status: \"\").update_all(special_status: :shipped)\n rescue => e\n flash[:error] = e.message + params[:ep_shipment_id]\n return redirect_back(fallback_location: admin_root_path)\n end\n\n redirect_to admin_store_shipment_path(shipment)\n end", "def buy\n if self.inventory_count == 0\n return false\n else\n # for now, decrementing the inventory count when purchasing a product will do\n self.decrement!(:inventory_count)\n # in the future, could return a receipt number, etc.\n return true\n end\n end", "def enter_state\n end", "def update_buy\r\n # Set status window item\r\n @status_window.item = @buy_window.item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Change windows to initial mode\r\n @command_window.active = true\r\n @dummy_window.visible = true\r\n @buy_window.active = false\r\n @buy_window.visible = false\r\n @status_window.visible = false\r\n @status_window.item = nil\r\n # Erase help text\r\n @help_window.set_text(\"\")\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get item\r\n @item = @buy_window.item\r\n # If item is invalid, or price is higher than money possessed\r\n if @item == nil or @item.price > $game_party.gold\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Get items in possession count\r\n case @item\r\n when RPG::Item\r\n number = $game_party.item_number(@item.id)\r\n when RPG::Weapon\r\n number = $game_party.weapon_number(@item.id)\r\n when RPG::Armor\r\n number = $game_party.armor_number(@item.id)\r\n end\r\n # If 99 items are already in possession\r\n if number == 99\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Calculate maximum amount possible to buy\r\n max = @item.price == 0 ? 99 : $game_party.gold / @item.price\r\n max = [max, 99 - number].min\r\n # Change windows to quantity input mode\r\n @buy_window.active = false\r\n @buy_window.visible = false\r\n @number_window.set(@item, max, @item.price)\r\n @number_window.active = true\r\n @number_window.visible = true\r\n end\r\n end", "def order_upgrade\n @order.next\n @order.complete!\n # Since we dont rely on state machine callback, we just explicitly call this method for spree_store_credits\n if @order.respond_to?(:consume_users_credit, true)\n @order.send(:consume_users_credit)\n end\n @order.finalize!\n end", "def transition(state_change_event=nil)\n if state_change_event.present?\n if self.public_send(\"may_#{state_change_event}?\")\n self.public_send(\"#{state_change_event}\")\n end\n else\n if self.state.blank?\n self.wait_to_clear_pickup\n elsif self.wtg_to_clear_pickup? && self.may_wait_for_driver_dispatch?\n self.wait_for_driver_dispatch\n elsif self.wtg_for_driver_dispatch? && self.may_wait_for_trip_confirmation?\n self.wait_for_trip_confirmation\n elsif self.wtg_for_trip_confirmation? && self.may_wait_for_inventory?\n self.wait_for_inventory\n elsif self.wtg_for_inventory? && self.may_wait_for_title?\n self.wait_for_title\n elsif self.wtg_for_title? && self.may_prepare_for_auction?\n self.prepare_for_auction\n elsif self.ready_for_auction? && self.may_wait_for_sale_confirmation?\n self.wait_for_sale_confirmation\n elsif self.wtg_for_sale_confirmation? && self.may_wait_for_buyer_charge_confirmation?\n self.wait_for_buyer_charge_confirmation\n elsif self.may_wait_for_sale_docs?\n self.wait_for_sale_docs\n elsif (self.awaiting_sale_docs? || self.wtg_for_buyer_charge_confirmation?) && self.may_prepare_for_seller_billing?\n self.prepare_for_seller_billing\n elsif self.ready_for_seller_billing? && self.may_wait_for_settlement_confirmation?\n self.wait_for_settlement_confirmation\n elsif self.may_close?\n self.close\n end\n end\n\n self.state_changed?\n end", "def bought_by(new_owner)\r\n self.owner = new_owner\r\n self.to_inactive\r\n end", "def go_state (index)\n @state = @states[index]\n end", "def update_others!\n if status_changed?\n\n if waiting_for_sell? || declined?\n ::Users::Notification.where(related_model_type:'Trading::BuyRequest', related_model_id: self.id).update_all(status: ::Users::Notification::Status::DELETED)\n end\n\n if waiting_for_sell?\n self.items.each{|item| item.status = ::Item::Status::BUYING; item.save; }\n\n elsif declined? || canceled?\n\n self.items.each{|item| item.activate! }\n\n elsif sold?\n\n self.items.each{|item| item.deactivate! }\n ::NotificationMail.create_from_mail(buyer.parent_id, seller.parent_id, UserMailer.new_buy_request_to_seller_parent(self) )\n\n end\n end\n end", "def state_transition_callback\n if status_changed?\n ScriptLog.info \"order callback: #{status_was} -> #{status}\"\n payout_address = nil\n payout_address = vendor.payout_btc_address if payment_method.is_bitcoin?\n payout_address = vendor.payout_ltc_address if payment_method.is_litecoin?\n\n payment_amount = payment_received\n if multipay_group\n # This order is a member of a multipay group. The requirements for being in a group is that the exact payment amount\n # was received for the set of orders. Therefore the amount paid to an order (either directly or indirectly) will always equal price.\n payment_amount = btc_price\n end\n\n commission_fraction = Rails.configuration.commission\n if vendor.commission\n # Vendor commission defaults to null. If it has been set, use that instead of system default.\n commission_fraction = vendor.commission\n end\n\n # Market changes state to finalized on \"finalize early\" orders so buyer doesn't need to. See FE doc above.\n if status_was == PAID && status == ACCEPTED && fe_required\n self.status = FINALIZED\n ScriptLog.info \"order callback: finalized early #{id}\"\n end\n\n if status_was == PAYMENT_PENDING && status == PAID_NO_STOCK\n self.buyer_payout = OrderPayout.new(btc_amount: payment_amount, payout_type: 'buyer', user: buyer)\n elsif status_was == PAYMENT_PENDING && status == EXPIRED\n # Create a new OrderPayout even if no payment received.\n # Order may never receive any payment but doesn't hurt to have a OP created in case it does later.\n self.buyer_payout = OrderPayout.new(btc_amount: payment_amount, payout_type: 'buyer', user: buyer)\n elsif status_was == PAID && status == DECLINED\n self.buyer_payout = OrderPayout.new(btc_amount: payment_amount, payout_type: 'buyer', user: buyer)\n elsif status_was == SHIPPED && status == FINALIZED\n self.commission = payment_amount * commission_fraction\n self.vendor_payout = OrderPayout.new(btc_amount: payment_amount - commission, payout_type: 'vendor', user: vendor, btc_address: payout_address)\n self.finalized_at = Time.now\n elsif status_was == SHIPPED && status == AUTO_FINALIZED\n self.commission = payment_amount * commission_fraction\n self.vendor_payout = OrderPayout.new(btc_amount: payment_amount - commission, payout_type: 'vendor', user: vendor, btc_address: payout_address)\n elsif (status_was == ACCEPTED || fe_required) && status == FINALIZED # buyer FE or this callback finalized.\n self.commission = payment_amount * commission_fraction\n self.vendor_payout = OrderPayout.new(btc_amount: payment_amount - commission, payout_type: 'vendor', user: vendor, btc_address: payout_address)\n self.finalized_at = Time.now\n elsif status_was == REFUND_REQUESTED && status == REFUND_FINALIZED\n self.buyer_payout = OrderPayout.new(btc_amount: payment_amount * refund_requested_fraction, payout_type: 'buyer', user: buyer)\n # Only create vendor payout if their amount is not zero. Don't care about creating buyer payout with zero payout amount.\n if refund_requested_fraction < 1.0\n vendor_portion = payment_amount - self.buyer_payout.btc_amount\n self.commission = vendor_portion * commission_fraction\n self.vendor_payout = OrderPayout.new(btc_amount: vendor_portion - commission, payout_type: 'vendor', user: vendor, btc_address: payout_address)\n end\n elsif status == ADMIN_FINALIZED\n # refund amounts are final and cannot be adjusted because payout script may have already retrieved payouts since this was saved.\n # Only create vendor payout if their amount is not zero. Don't care about creating buyer payout with zero payout amount.\n self.buyer_payout = OrderPayout.new(btc_amount: payment_amount * admin_finalized_refund_fraction, payout_type: 'buyer', user: buyer)\n if admin_finalized_refund_fraction < 1.0\n vendor_portion = payment_amount - self.buyer_payout.btc_amount\n self.commission = vendor_portion * commission_fraction\n self.vendor_payout = OrderPayout.new(btc_amount: vendor_portion - commission, payout_type: 'vendor', user: vendor, btc_address: payout_address)\n end\n end\n end\n end", "def apply\n agent = @engine.item_by_name(@name)\n agent.state[\"busy\"] -= 1 if agent.state[\"busy\"] > 0\n end", "def pick_out(amnt)\n if amount - amnt > CONST::PRODUCT_IN_STOCK && on_sell?\n update(amount: amount - amnt)\n else\n errors.add(\n :base,\n Response::PRODUCT[:PRODUCT_IN_STOCK]\n ); false\n end\n end", "def sell_to_current_winner\r\n if self.rank_one != nil\r\n winner = self.get_current_winner\r\n item.price = self.get_current_price\r\n item.take_ownership(winner)\r\n item.state = :pending\r\n winner.credits_in_auction -= self.get_current_bid\r\n winner.credits += (self.get_current_bid - self.get_current_price)\r\n EmailSender.win_auction(winner, item)\r\n else\r\n item.state = :inactive\r\n end\r\n end", "def run!\n # Validations here are intended to catch all necessary prerequisites.\n # We return early so all checks have happened already.\n return false if invalid?\n desired_shipment.save! if desired_shipment.new_record?\n\n # Retrieve how many on hand items we can take from desired stock location\n available_quantity = [desired_shipment.stock_location.count_on_hand(variant), 0].max\n\n new_on_hand_quantity = [available_quantity, quantity].min\n unstock_quantity = desired_shipment.stock_location.backorderable?(variant) ? quantity : new_on_hand_quantity\n\n ActiveRecord::Base.transaction do\n if handle_stock_counts?\n # We only run this query if we need it.\n current_on_hand_quantity = [current_shipment.inventory_units.pre_shipment.size, quantity].min\n\n # Restock things we will not fulfil from the current shipment anymore\n current_stock_location.restock(variant, current_on_hand_quantity, current_shipment)\n # Unstock what we will fulfil with the new shipment\n desired_stock_location.unstock(variant, unstock_quantity, desired_shipment)\n end\n\n # These two statements are the heart of this class. We change the number\n # of inventory units requested from one shipment to the other.\n # We order by state, because `'backordered' < 'on_hand'`.\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :on_hand)\n\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(quantity - new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :backordered)\n end\n\n # We modified the inventory units at the database level for speed reasons.\n # The downside of that is that we need to reload the associations.\n current_shipment.inventory_units.reload\n desired_shipment.inventory_units.reload\n\n # If the current shipment now has no inventory units left, we won't need it any longer.\n if current_shipment.inventory_units.length.zero?\n current_shipment.destroy!\n else\n # The current shipment has changed, so we need to make sure that shipping rates\n # have the correct amount.\n current_shipment.refresh_rates\n end\n\n # The desired shipment has also change, so we need to make sure shipping rates\n # are up-to-date, too.\n desired_shipment.refresh_rates\n\n true\n end", "def update_state\n raise \"Nothing to do\"\n end", "def deliver_package package_id\n # remove the item in previous box if any\n current = self.package\n if current and self.status == CONSTANT['BOX_DELIVERING']\n current.status = CONSTANT['PACKAGE_WAITING_FOR_DELIVERY']\n self.status = CONSTANT['BOX_IDLE']\n self.package = nil\n self.access.clear\n self.save!\n current.save!\n Logging.log_manual_action self, current\n elsif current\n return false\n end\n return true if package_id.nil?\n \n if self.status == CONSTANT['BOX_IDLE']\n package = Package.find package_id\n return false if package.nil?\n # find previous box if any\n prev_box = package.box\n prev_backup_box = package.backup_box\n if prev_box or prev_backup_box\n package.status = CONSTANT['PACKAGE_WAITING_FOR_DELIVERY']\n package.save!\n if prev_box and ( prev_box.status == CONSTANT['BOX_DELIVERING'] or prev_box.status == CONSTANT['BOX_RETURNING'] )\n Logging.log_manual_action prev_box, package\n prev_box.status = CONSTANT['BOX_IDLE']\n prev_box.package = nil\n else\n Logging.log_manual_action prev_backup_box, package\n prev_backup_box.backup_package = nil\n end\n # save it later if the new assignment is successful\n end\n return false if package.status != CONSTANT['PACKAGE_WAITING_FOR_DELIVERY'].to_i\n # assign to new box\n package.box_id = self.id\n package.status = CONSTANT['PACKAGE_ENROUTE_DELIVERY']\n if package.save\n self.status = CONSTANT['BOX_DELIVERING']\n self.access.save_barcode package.barcode\n if self.save\n Logging.log_manual_action self, package\n if prev_box and prev_box.status == CONSTANT['BOX_IDLE']\n prev_box.access.clear\n prev_box.save!\n elsif prev_backup_box\n prev_backup_box.access.clear\n prev_backup_box.save!\n end\n return true\n end\n end\n end\n return false\n end", "def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n\r\n puts \"User chose item #{ItemService.item_sym_of(id)}\"\r\n @pedestal.pedestal_item_id = id\r\n\t\t\t$game_party.gain_item(rmxp_item_id, -1)\r\n\r\n SetupEventService.new.setup!\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end", "def buy_product\n products = @seller.show_product_info \n product_buy = @view.buy_product(products)\n @total_price = @seller.save_buy_a_product(product_buy)\n @view.buy_status(@total_price)\n input = @view.menu(\"2\")\n seller_actions(input) \n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def update_buy_selection()\n item = @buy_window.selected_item.item\n \n if Input.trigger?(Input::B)\n Sound.play_cancel\n cancel_command()\n \n elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::UP)\n update_item_stats(item)\n \n elsif Input.repeat?(Input::Y) || Input.repeat?(Input::Z)\n update_character_select(Input.press?(Input::Z))\n \n elsif Input.repeat?(Input::RIGHT) || Input.repeat?(Input::LEFT)\n if !@buy_window.selected_item.active && (Input.press?(Input::RIGHT) ||\n (Input.press?(Input::LEFT) && @buy_window.selected_item.is_min_number?))\n Sound.play_buzzer\n elsif (Input.press?(Input::RIGHT) && !@buy_window.selected_item.is_max_number?) ||\n (Input.press?(Input::LEFT) && !@buy_window.selected_item.is_min_number?)\n Sound.play_cursor\n update_number_select(Input.press?(Input::RIGHT), @buy_window)\n update_transaction(@buy_window.selected_items)\n @buy_window.update_items_activity(@transaction_window.difference)\n end\n \n elsif Input.trigger?(Input::C)\n if (@buy_window.selected_items.size == 0)\n Sound.play_buzzer\n else\n Sound.play_decision\n @confirm_buy_window.show()\n @buy_window.active=false\n end\n end\n\n end", "def setup_rem_state\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n state_id = @acts[1]\n chance = @acts[2] || 100\n chance = chance / 100.0 if c.integer?\n target.remove_state(state_id) if rand < chance\n end\n end", "def checkout\n @current_cart.adjust_inventory\n @current_cart.mark_submited\n current_user.remove_current_cart\n redirect_to cart_path(@current_cart)\n end", "def purchase\n \t@stock -= 1\n end", "def touch_in(station)\n deduct(PENALTYFARE) if @in_joureny == true\n min_balance? ? (fail \"insufficent funds\") : @the_journey.start(station)\n @in_journey = true\n end", "def command_main_buy \r\n # Change windows to buy mode\r\n @command_window.active = false\r\n @dummy_window.visible = false\r\n @buy_window.active = true\r\n @buy_window.visible = true\r\n @buy_window.refresh\r\n @status_window.visible = true\r\n end", "def activate\n self.status = ''\n pushed\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def change_entity(_action)\n return @current_entity = company_pending_par.owner if company_pending_par\n\n if (bids = @bids[@auctioning_company]).any?\n # There are still remaining bids on a limited auction. The\n # lowest-bidding remaining player goes next.\n @current_entity = bids.min_by(&:price).entity\n else\n # If we just exited a limited auction, move to the player after the\n # one who triggered it.\n @current_entity = @auction_triggerer if @auction_triggerer\n\n loop do\n @current_entity = next_entity\n break if !@current_entity.passed? || all_passed?\n end\n end\n end", "def after_redeem() 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 finalize!\n update_attribute(:completed_at, Time.now)\n update_attribute(:payment_method_name, self.payment_method.name) unless self.payment_method_name\n self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\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 checkout\n end", "def update_state(*args)\n if transition_choice?\n found_trans = machine.select_transition(name, *args)\n machine.state = found_trans.to_states.first\n else\n transitions = machine.transitions[name]\n machine.state = transitions[machine.state] || transitions[ANY_STATE] || name\n end\n end", "def trigger!\n\treturn if (@next_state_name == nil)\n\n\tcurrent_state = nil\n current_state = @states.fetch(@current_state_name) unless @current_state_name.nil?\n\n\tnext_state = @states.fetch(@next_state_name)\n next_state_name = @next_state_name\n\n\t@next_state_name = nil\n\n\tcurrent_state.atexit if(current_state.respond_to?(:atexit))\n\t@current_state_name = next_state_name\n\tnext_state.atentry if(next_state.respond_to?(:atentry))\n end", "def determine_state(order)\n return 'pending' if self.inventory_units.any? { |unit| unit.backordered? }\n return 'shipped' if state == 'shipped'\n return 'delivered' if state == 'delivered'\n # Original, that resulted in emails being delivered several times:\n # order.payment_state == 'balance_due' ? 'pending' : 'ready'\n # Updated version that should prevent that from happening:\n order.payment_state == 'balance_due' ? 'pending' : 'ready'\n \n end", "def next_phase\n if phase == 'Action'\n reset_action_variables\n update_attributes(phase: \"Buy\") \n elsif phase == 'Buy'\n reset_player_balances\n current_player.discard.add_deck_to_top( current_player.played )\n current_player.discard.add_deck_to_top( current_player.hand )\n current_player.draw_card(5)\n next_turn\n update_attributes(phase: \"Action\")\n end\n end", "def on_item_ok\n return back_to_items if (item = @item_window.item).nil?\n $game_party.lose_item(item, 1)\n @unit_item_list.tb_unit.gain_item(item, 1)\n TactBattleManager.store_unit_item(@actor.id, item)\n back_to_items\n end", "def settle_item_purchase(seller, buyer, item)\n seller.credits += item.price + Integer((item.price * SELL_BONUS).ceil)\n buyer.credits -= item.price\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 update_shipment_state\n self.shipment_state =\n case shipments.count\n when 0\n nil\n when shipments.delivered.count\n 'delivered'\n when shipments.shipped.count\n 'shipped'\n when shipments.ready.count\n 'ready'\n when shipments.pending.count\n 'pending'\n else\n 'partial'\n end\n self.shipment_state = 'backorder' if backordered?\n\n if old_shipment_state = self.changed_attributes['shipment_state']\n self.state_events.create({\n :previous_state => old_shipment_state,\n :next_state => self.shipment_state,\n :name => 'shipment',\n :user_id => (Spree::User.respond_to?(:current) && Spree::User.current && Spree::User.current.id) || self.user_id\n })\n end\n end", "def pickup_item\n if status == :confirmed \n transaction do\n update(:status => :in_progress)\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'pickup_item',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.picked_up_item)\n end \n end\n self\n end", "def buy_tower(tower_class, position)\n Game.scene.selected_tower = Game.scene.create_tower(tower_class, position)\n @cash -= Game.scene.selected_tower.cost\n end", "def transition(inst, name, state)\n self.transition_save_node = false\n\n return [404, \"No state specified\"] if state.nil?\n # FIXME: validate state\n\n Rails.logger.info(\"Crowbar transition enter: #{name} to #{state}\")\n\n pop_it = false\n node = nil\n\n with_lock \"BA-LOCK\" do\n node = Node.find_by_name(name)\n if node.nil? and (state == \"discovering\" or state == \"testing\")\n Rails.logger.debug(\"Crowbar transition: creating new node for #{name} to #{state}\")\n node = Node.create_new name\n self.transition_save_node = true\n end\n if node.nil?\n Rails.logger.error(\n \"Crowbar transition leaving: node not found nor created - #{name} to #{state}\"\n )\n return [404, \"Node not found\"]\n end\n\n if %w(hardware-installing hardware-updating update).include? state\n Rails.logger.debug(\"Crowbar transition: force run because of state #{name} to #{state}\")\n pop_it = true\n end\n\n if node.crowbar[\"state\"] != state\n Rails.logger.debug(\n \"Crowbar transition: state has changed so we need to do stuff for #{name} to #{state}\"\n )\n\n # Do not allow change to shutdown state from crowbar_upgrade\n # (we need to reboot the nodes for upgrade, but without changing the state)\n if node.crowbar[\"state\"] == \"crowbar_upgrade\" && state == \"shutdown\"\n Rails.logger.debug(\"current node state is crowbar_upgrade; ignoring change to shutdown\")\n return [200, { name: name }]\n end\n\n node.crowbar[\"crowbar\"][\"state_debug\"] = {} if node.crowbar[\"crowbar\"][\"state_debug\"].nil?\n if node.crowbar[\"crowbar\"][\"state_debug\"][state].nil?\n node.crowbar[\"crowbar\"][\"state_debug\"][state] = 1\n else\n node.crowbar[\"crowbar\"][\"state_debug\"][state] = node.crowbar[\"crowbar\"][\"state_debug\"][state] + 1\n end\n\n node.crowbar[\"state\"] = state\n node.crowbar[\"state_change_time\"] = Time.new.to_s\n self.transition_save_node = true\n pop_it = true\n end\n\n node.save if transition_save_node\n end\n\n if pop_it\n #\n # If we are discovering the node and it is an admin,\n # make sure that we add the crowbar config\n #\n if state == \"discovering\" and node.admin?\n crole = RoleObject.find_role_by_name(\"crowbar-config-#{inst}\")\n db = Proposal.where(barclamp: \"crowbar\", name: inst).first\n add_role_to_instance_and_node(\"crowbar\", inst, name, db, crole, \"crowbar\")\n end\n\n roles = RoleObject.find_roles_by_search \"transitions:true AND (transition_list:all OR transition_list:#{ChefObject.chef_escape(state)})\"\n # Sort rules for transition order (deployer should be near the beginning if not first).\n roles.sort! do |x,y|\n xname = x.name.gsub(/-config-.*$/, \"\")\n yname = y.name.gsub(/-config-.*$/, \"\")\n\n xs = BarclampCatalog.run_order(xname)\n ys = BarclampCatalog.run_order(yname)\n xs <=> ys\n end\n\n roles.each do |role|\n role.override_attributes.each do |bc, data|\n rname = role.name.gsub(\"#{bc}-config-\",\"\")\n # Need a lock here, because if many nodes are discovered\n # simultaneously, adding them to a proposal can race,\n # leaving some nodes not present in proposals. e.g.:\n # NtpService::transition uses find_proposal and\n # later saves it with add_role_to_instance_and_node().\n # If this runs for two nodes at the same time, they both\n # find the proposal, then both modify it, then both save\n # it in lockstep. Naturally the second save clobbers\n # the first, so the first node won't be present in that\n # proposal.\n bc_lock = acquire_lock \"#{bc}:#{rname}\"\n begin\n Rails.logger.info(\"Crowbar transition: calling #{bc}:#{rname} for #{name} for #{state}\")\n service = ServiceObject.get_service(bc).new\n answer = service.transition(rname, name, state)\n if answer[0] != 200\n Rails.logger.error(\n \"Crowbar transition: finished #{bc}:#{rname} for #{name} for \" \\\n \"#{state}: FAILED #{answer[1]}\"\n )\n else\n Rails.logger.debug(\n \"Crowbar transition: finished #{bc}:#{rname} for #{name} for #{state}\"\n )\n unless answer[1][\"name\"].nil?\n name = answer[1][\"name\"]\n end\n end\n rescue StandardError => e\n Rails.logger.fatal(\"json/transition for #{bc}:#{rname} failed: #{e.message}\")\n Rails.logger.fatal(e.backtrace.join(\"\\n\"))\n return [500, \"#{bc} transition to #{rname} failed.\\n#{e.message}\\n#{e.backtrace.join(\"\\n\")}\"]\n ensure\n bc_lock.release\n end\n end\n end\n\n # We have a node that has become ready, test to see if there are queued proposals to commit\n process_queue if state == \"ready\"\n end\n\n Rails.logger.debug(\"Crowbar transition leaving: #{name} to #{state}\")\n [200, { name: name }]\n end", "def purchase_one\n product = Product.find(params[:id])\n company = Company.first\n if product[:inventory_count] > 0\n if product.decrement!(:inventory_count)\n total = company[:money] + product[:price]\n\n company.update_!(money: total)\n render json: {\n status: :ok,\n message: 'Successfully bought'\n }.to_json\n else\n render json: {\n status: :internal_server_error,\n message: 'Error purchasing product'\n }\n end\n else\n render json: {\n status: :ok,\n message: 'Item is no longer available'\n } \n end\n end", "def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n item = self.item \n item.update_ready_quantity\n \n return self \n end", "def buy\n\t\t@dates = Bus.where(:status => :open).select{|b| !b.maximum_seats || b.available_tickets('from_waterloo') > 0 || b.available_tickets('to_waterloo') > 0 }.collect {|b| b.date }.uniq\n\t\t@gmapkey = Keys.gmap\n\tend", "def command_number_buy\r\n # Buy process\r\n $game_party.lose_gold(@number_window.number * @item.price)\r\n case @item\r\n when RPG::Item\r\n $game_party.gain_item(@item.id, @number_window.number)\r\n when RPG::Weapon\r\n $game_party.gain_weapon(@item.id, @number_window.number)\r\n when RPG::Armor\r\n $game_party.gain_armor(@item.id, @number_window.number)\r\n end\r\n # Refresh each window\r\n @gold_window.refresh\r\n @buy_window.refresh\r\n @status_window.refresh\r\n # Change windows to buy mode\r\n @buy_window.active = true\r\n @buy_window.visible = true\r\n end", "def update_shipment_state\n # get all the shipment states for this order\n shipment_states = shipments.states\n if shipment_states.size > 1\n # multiple shiment states means it's most likely partially shipped\n self.shipment_state = 'partial'\n else\n # will return nil if no shipments are found\n self.shipment_state = shipment_states.first\n if self.shipment_state\n # shipments exist but there are unassigned inventory units\n self.shipment_state = 'partial'\n end\n end\n\n self.state_changed('shipment')\n end", "def update_shipment_state\n if order.backordered?\n order.shipment_state = 'backorder'\n else\n # get all the shipment states for this order\n shipment_states = shipments.states\n order.shipment_state = if shipment_states.size > 1\n # multiple shipment states means it's most likely partially shipped\n 'partial'\n else\n # will return nil if no shipments are found\n shipment_states.first\n # TODO: inventory unit states?\n # if order.shipment_state && order.inventory_units.where(shipment_id: nil).exists?\n # shipments exist but there are unassigned inventory units\n # order.shipment_state = 'partial'\n # end\n end\n end\n\n order.state_changed('shipment')\n order.shipment_state\n end", "def bringToLife\n @dead = false\n end", "def push_to_draft\n transition_to :draft\n end", "def billing!\n ready! && save!\n end", "def main_transition\r\n # Execute transition\r\n if $data_system.battle_transition == \"\"\r\n Graphics.transition(20)\r\n else\r\n Graphics.transition(40, \"Graphics/Transitions/\" +\r\n $data_system.battle_transition)\r\n end\r\n # Start pre-battle phase\r\n start_phase1\r\n end", "def up\n @state -= 1 unless @state == 0\n @y -= 1 * @boost\n end", "def up\n @state -= 1 unless @state == 0\n @y -= 1 * @boost\n end", "def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n \n \n item = self.item \n item.add_ready_quantity( quantity_to_be_recovered ) \n \n return self \n end", "def checkout(attributes)\n completed = false\n transaction do\n update!(attributes.merge(status: \"Completed\"))\n orderitems.each do |item|\n raise ActiveRecord::Rollback unless item.reduce_stock\n end\n completed = true\n end\n\n completed\n end", "def transfer_inventory(reason)\n packaging.product.transfers.create!(\n :detail => self,\n :happened_at => Time.zone.now,\n :quantity => (-1 * quantity * packaging.size),\n :reason => reason\n )\n end", "def checkout\n\tend", "def update_item_state(item_id, state)\n !send_pairwise_request(\"items/#{item_id}/#{state ? 'activate' : 'suspend'}\", nil, 'Get').nil?\n end", "def swap(target, transact = true)\n move_to(target, :swap, transact) \n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def passing\n state(\"passing\")\n end", "def checkout\n self.update_item_inventory_for_checkout\n self.update(status: \"submitted\")\n self.user.current_cart = nil\n # self.user.save\n # binding.pry\n end", "def make_transition(transition)\n raise ArgumentError, \"Cannot transition from #{self.current_state} with #{transition}\" unless\n transition.from_state == self.current_state\n \n self.current_state = transition.to_state\n @available_actions = nil\n add_reward(transition.reward)\n end", "def hold\n action('hold')\n end", "def trans(from, to, name)\n StateMachineChecker::Transition.new(from, to, name)\nend", "def purchased?\n state == \"purchased\" or stolen == true\n end", "def complete\n @stock_transfer = StockTransfer.find(params[:id])\n @product = @stock_transfer.product\n # Event-b: product ∈ activeProducts\n @locationto = @stock_transfer.stock_location\n @locationfrom = @locationto.previous_location\n\n\n #Mark as complete\n @stock_transfer.update_attribute(:complete,true)\n @stock_transfer.save\n\n #Event-b : act1: productlevels(product) ≔ productlevels(product) <+ {Floor ↦ (productlevels(product)(Floor) + amount),Backroom ↦ (productlevels(product)(Backroom) − amount)}\n @stock_level_to = StockLevel.find_by_product_id_and_stock_location_id(@product,@locationto)\n @stock_level_to.update_attribute(:quantity, (@stock_level_to.quantity + @stock_transfer.quantity))\n @stock_level_to.save\n\n @stock_level_from = StockLevel.find_by_product_id_and_stock_location_id(@product,@locationfrom)\n @stock_level_from.update_attribute(:quantity, (@stock_level_from.quantity - @stock_transfer.quantity))\n @stock_level_from.save\n\n\n\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 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 unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end", "def update_state(product, state, order_line)\n hash = {\n item_id: order_line.item_id,\n transaction_id: order_line.transaction_id\n }\n if state == 'paid'\n hash.merge!(paid: true)\n elsif state == 'shipped'\n hash.merge!(shipped: true)\n end\n\n response = @allegro.complete_sale(hash)\n #Rails.logger.info response.inspect\n response\n end", "def change_dealer\n game_state.dealer_seat = new_dealer_seat \n end", "def toggle_down_inventory\n self.available_inventory -= 1\n self.save\n\n return self.available_inventory\n end", "def jump_to_state(state)\n logger.debug \"STATE JUMP! to #{state}\"\n \n render_state(state)\n end", "def finished!\n Mua::State::Transition.new(state: self.terminal_states[0])\n end", "def check_for_buyout\n if self.is_bought_out\n if self.bought_out_by_team_id\n self.subcontracts.future_years.each do |sub|\n sub.salary_amount *= 0.6\n sub.this_is_a_buyout = true\n sub.save!\n\n # update GM's annual actions to not allow more buyouts\n actions = AnnualGmAction.find_by_team_id_and_year(self.bought_out_by_team_id, current_year)\n actions.has_bought_out = true\n actions.bought_out_player_id = self.player.id\n actions.save!\n end\n end\n end\n end", "def buy_item(name)\n change = @calculator.buy @items[name].last\n [@items[name].pop, change]\n end", "def transition_to_state(state)\n @engine.dispatch do\n run_state!(state)\n end\n \n state\n end", "def main_begin\n create_spriteset\n # When comming back from battle we ensure that we don't have a weird transition by warping immediately\n if $game_temp.player_transferring\n transfer_player\n else\n $wild_battle.reset\n $wild_battle.load_groups\n end\n fade_in(@mbf_type || DEFAULT_TRANSITION, @mbf_param || DEFAULT_TRANSITION_PARAMETER)\n $quests.check_up_signal\n end", "def set_bought_item\n @bought_item = BoughtItem.find(params[:id])\n end" ]
[ "0.61791754", "0.5880421", "0.5840531", "0.5817714", "0.57507575", "0.5735825", "0.56918764", "0.5656137", "0.5631318", "0.5628945", "0.56050783", "0.5581032", "0.556287", "0.55328834", "0.552604", "0.5525676", "0.5499529", "0.54718024", "0.5467789", "0.54663014", "0.5457844", "0.54454625", "0.54155725", "0.54089874", "0.5403776", "0.539621", "0.5389072", "0.5386858", "0.5383058", "0.53824776", "0.53507334", "0.53468555", "0.53353643", "0.53157985", "0.5312205", "0.53020394", "0.52963775", "0.52946246", "0.5280156", "0.5273764", "0.5272639", "0.5270166", "0.52686656", "0.52653635", "0.52644044", "0.526377", "0.5260021", "0.5258351", "0.5252858", "0.5249999", "0.5248673", "0.5238142", "0.52310777", "0.52149314", "0.52114165", "0.52106285", "0.52082205", "0.52031624", "0.52029496", "0.51994103", "0.51933", "0.51917803", "0.5183209", "0.51828724", "0.5170664", "0.51676685", "0.5165957", "0.51649237", "0.5158065", "0.51553446", "0.51536566", "0.5153453", "0.5151913", "0.5151913", "0.5148319", "0.51432", "0.51431936", "0.51412266", "0.5139624", "0.51379263", "0.5133597", "0.51330173", "0.51318276", "0.5130274", "0.5125366", "0.511928", "0.5116402", "0.5111378", "0.5107474", "0.51066774", "0.5105408", "0.5104958", "0.5103198", "0.5102525", "0.50979555", "0.50887305", "0.50878096", "0.50842017", "0.5083693", "0.50815624" ]
0.59932315
1
Converts +sexp+ into a Compiler::Node.
def sexp_to_node(sexp) return nil if sexp.nil? if node_class = Node::Mapping[sexp.first] node_class.create(self, sexp) else raise Error, "Unable to resolve '#{sexp.first.inspect}'" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sexp_to_ast(sexp)\n eval sexp\n end", "def compile_sexp(scope, *exp)\n compile_do(SexpScope.new(scope), *exp)\n end", "def compile_sexp(scope, *exp)\n compile_do(SexpScope.new(scope), *exp)\n end", "def expression sexp\n return nil if sexp == nil\n #pp sexp\n body = sexp.sexp_body\n case sexp[0]\n # when :block # a collection of things to do!\n # body.map { |i| convert(i) + NL }.join\n when :iasgn # assign to instance variable\n value = expression( sexp[2] )\n name = @vars.set( sexp[1], value.type )\n \"#{name} = (#{value})\"\n when :lit, :false, :true, :array # literal values\n literal(sexp)\n when :ivar\n @vars.get(sexp.value)\n when :call # call a 'method' on something\n call(sexp[1], sexp[2], sexp[3].sexp_body)\n when :if # statements resembling ifs\n condition = expression(sexp[1])\n true_code = expression(sexp[2])\n false_code = expression(sexp[3])\n \"( ( #{condition} )?( #{true_code} ):( #{false_code} ) )\"\n when :colon2 # lookup constants\n if sexp[1][0] == :const and sexp[1][1] == :Math\n case sexp[2]\n when :PI\n Value.typed CTypeFloat, Math::PI.inspect\n end\n end\n when :not # the !something operator\n Value.typed CTypeBoolean, \"!(#{ expression(sexp.value) })\"\n else\n raise \"IDK how to handle this S-expression: #{ sexp.inspect }!\"\n end\n end", "def to_ruby(sexp)\n begin\n Sorcerer.source(sexp)\n rescue => e\n p e\n 'UNKNOWN'\n end\n end", "def translate(sexp)\n t = translate_generic_sexp(sexp)\n var = @translator.next_var_name\n ctor = std_init_name(t.value_type)\n add_border_mark(sexp)\n s(:stmts, class_constructor(t.value_type, var),\n s(:call, ctor,\n s(:args, s(:var, var), t.value_sexp))).with_value(s(:var, var), t.value_type)\n rescue NotInlineableError\n nil\n end", "def consume(sexp)\n out = []\n sexp.each do |s|\n if s.kind_of?(Array)\n #\n # Reject +nil+, so that we can optimize out whole expressions\n # just by returning +nil+ from sexp_to_node. \n #\n v = @compiler.sexp_to_node(s)\n out << v unless v.nil?\n else\n out << s\n end\n end\n return out\n end", "def to_sexp(node)\n node && send(\"#{node.first}_to_sexp\", node.last)\n end", "def to_sexp(exp)\n if array?(exp)\n Sexp.from_array(exp)\n elsif exp.is_a?(String)\n parse(exp)\n end\n end", "def get_sexp ast, only_structure\n sexp = ''\n if ast.call? and not only_structure\n sexp = '( ' + ast.method_name.source + LINE_DELIMITER + ast.line.to_s + ' '\n ast.children.each do |child|\n sexp += get_sexp(child, only_structure)\n end\n sexp += ') '\n elsif ast.loop?\n sexp = '( iter' + LINE_DELIMITER + ast.line.to_s + ' '\n ast.children.each do |child|\n sexp += get_sexp(child, only_structure)\n end\n sexp += ') '\n elsif ast.condition?\n sexp = '( cond' + LINE_DELIMITER + ast.line.to_s + ' '\n ast.children.each do |child|\n sexp += get_sexp(child, only_structure)\n end\n sexp += ') '\n else\n ast.children.each do |child|\n sexp += get_sexp(child, only_structure)\n end\n end\n sexp\nend", "def to_sxp\n require 'sxp' unless defined?(SXP)\n # Output rules as a formatted S-Expression\n SXP::Generator.string(@ast.map(&:for_sxp))\n end", "def to_sxp\n require 'sxp' unless defined?(SXP)\n # Output rules as a formatted S-Expression\n SXP::Generator.string(@ast.map(&:for_sxp))\n end", "def compile(source)\n ast = transformer.apply(parser.parse(source))\n ast.compile\n end", "def to_code\n if @sexp\n \"/*:#{@sexp.line}:#{@sexp.column}*/#{@code}\"\n else\n @code\n end\n end", "def build(operators, scope)\n to_sexp(operators, scope)\n end", "def test_to_ruby_sexp\n sexp = nil\n assert_nothing_raised {\n sexp = @tree.to_ruby_sexp\n }\n assert_equal([:block, nil], sexp)\n end", "def build(rule)\n Expr.build ArithmeticParser.new.parse(rule).to_sexp\n end", "def _cedent(sexp)\n iter = self.eval(sexp)\n [iter.length + 1] + iter\n end", "def block(sexp)\n statements(sexp)\n end", "def compile_program filename, sexp\n @filename = filename\n if sexp.nil?\n position = [] # because the debugger special-cases this possibility\n elsif sexp[0] == :block\n position = [] # because position will be printed anyway\n elsif sexp.source\n position = [[:position, @filename] + sexp.source]\n elsif sexp[0] == :masgn\n position = [[:position, @filename] + sexp[1][1].source]\n else\n no 'top s-exp with nil source'\n end\n\n position + compile(sexp)\n end", "def unparse(sexp)\n Ruby2Ruby.new.process(sexp.deep_clone)\n end", "def compile_treetop_runtime_syntax_node node\n if node.elements\n node.elements.map{|element| \n# puts \"Invoking on #{element.class}\"\n compile element}.to_s\n else\n node.text\n end \n end", "def traverse_sexp(sexp, original_sexp)\n if sexp.is_a? Sexp and sexp[0] != :stmts\n \n if sexp[0] == :block\n @event_manager.fire_event(:block_opened, nil)\n end\n\n sexp.each { |a| traverse_sexp(a, original_sexp) }\n\n if sexp[0] == :block\n @event_manager.fire_event(:block_closed, nil)\n end\n\n @event_manager.fire_event(\"#{sexp[0]}_translated\".to_sym,\n EventStruct.new(sexp, original_sexp)) \n end \n end", "def compile\n lexer = Bolverk::ASM::Lexer.new(@stream)\n tokens = lexer.scan\n\n parser = Bolverk::ASM::Parser.new(tokens)\n parse_tree = parser.parse\n\n generator = Bolverk::ASM::Generator.new(parse_tree)\n source = generator.generate\n\n return source\n end", "def compile(ast)\n init(ast) unless ast.nil?\n\n throw('No AST given') if ast.nil?\n throw('Empty AST given') if ast.length == 0\n\n if ast.length == 1 && ast.first.is_a?(Babelfish::Phrase::Literal)\n # просто строка\n return ast.first.text\n end\n\n ready = ast.map do |node|\n case node\n when Babelfish::Phrase::Literal\n node.text\n when Babelfish::Phrase::Variable\n node\n when Babelfish::Phrase::PluralForms\n sub = node.to_ruby_method\n else\n throw(\"Unknown AST node: #{node}\")\n end\n end\n\n lambda do |params|\n data = ready.map do |what|\n case what\n when Babelfish::Phrase::Variable\n params[what.name.to_s].to_s\n when Proc\n what = what.call(params)\n else\n what\n end\n end.join('')\n data\n end\n end", "def get_lambda(sexp)\n l=nil\n visit_tree(sexp, lambda: ->(x) { l=x})\n l\nend", "def generate_syntax_tree\n build_ast(@parse_tree).first\n end", "def quote(sexp)\n [:pushl, sexp]\n end", "def calls(sexp)\n visit_tree sexp,\n lambdacall: ->(x) { puts x.inspect },\n tailcall: ->(x) { puts x.inspect }\nend", "def pipe(sexp)\n self.eval(car(sexp)) + instance_exec { pump_incr; self.eval(cadr(sexp)) }\n end", "def vectorid(sexp)\nself.eval(car(sexp)) + self.eval(cadr(sexp))\n end", "def make_ast(source)\n scanner = make_scanner(source)\n parser = Ringo::Parser::LoxParser.new(scanner.tokens)\n Ringo::Tools::AstPrinter.new.print(parser.parse.first)\nend", "def visitSimpleExpression(smexp)\n\t\tcode = []\n\t\tif smexp.sign!=nil\n\t\t\tcode = smexp.sign\n\t\tend\n\t\t#p \"In simple Expression\"\n\t\t#p smexp\n\t\t#p smexp.termlist.size\n\t\t#p smexp.termlist[0].factlist.first\n\t\t#p smexp.addingoplist\n\t\t#p smexp.termlist[1].factlist.first\n\t\tif smexp.termlist != nil\n\t\t\tcode1 = visitTerm(smexp.termlist.first)\n\t\t\tcode << code1\n\t\t\t#p smexp.termlist[0]\n\t\t\t#p smexp.termlist[1]\n\t\t\tif smexp.termlist.size > 1\n\t\t\t\tfor i in 1..(smexp.termlist.size-1)\n\t\t\t\t\tcode << smexp.addingoplist[i-1].value\n\t\t\t\t\tcode << visitTerm(smexp.termlist[i])\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#p \"simple expression code\"\t\t\n\t\t#p code\n\t\treturn code\n end", "def statements sexp, result=[]\n if null?(sexp)\n return result\n end\n self.eval(car(sexp)) + statements(cdr(sexp), result)\n end", "def _to_a(sexp, result=[])\n if null?(sexp)\n return result\n end\n ident = self.eval(car(sexp))\n sym = ident.last.to_s.to_sym\n [sym] + _to_a(cdr(sexp), result)\n end", "def compile(exp)\n \"\\\"#{compile!(exp)}\\\"\"\n end", "def statements sexp\n return nil if sexp == nil\n case sexp[0]\n when :lit, :false, :true, :array, :hash\n raise \"Line doesn't do anything\"\n when :block\n sexp.sexp_body.map { |i| statements(i) }.join()\n when :if\n condition = expression sexp[1]\n true_code = indent statements sexp[2]\n false_code = indent statements sexp[3]\n if true_code and false_code\n \"if (#{condition}) {\\n#{true_code}} else {\\n#{false_code}}\\n\"\n elsif true_code\n \"if (#{condition}) {\\n#{true_code}}\\n\"\n elsif false_code\n \"if (!(#{condition})) {\\n#{false_code}}\\n\"\n end\n when :while\n condition = expression sexp[1]\n code = indent statements sexp[2]\n if sexp[3] # is precondition?\n \"while (#{condition}) {\\n#{code}}\\n\"\n else\n \"{\\n#{code}} while (#{condition})\\n\"\n end\n else\n \"#{ expression(sexp) };\\n\"\n end\n end", "def unparse(sexp)\n Macro.new.unparse(sexp)\nend", "def ===(sexp)\n Language[rule_name] === sexp\n end", "def build_compiler\n node_name = nodename(:function)\n fact_values = facts_hash(node_name)\n\n # if we specify a pre_condition, we should ensure that we compile that\n # code into a catalog that is accessible from the scope where the\n # function is called\n Puppet[:code] = pre_cond\n\n node_options = {\n :parameters => fact_values,\n }\n\n stub_facts! fact_values\n\n node = build_node(node_name, node_options)\n\n compiler = Puppet::Parser::Compiler.new(node)\n compiler.compile\n compiler\n end", "def jconvert(sexpr)\n raise \"jconvert cannot handle nils!\" if sexpr.nil?\n\n if sexpr.java_kind_of?(Java::OrgLogstashConfigIrExpression::Expression)\n return sexpr\n end\n\n op, left, right = sexpr\n\n left_c = jconvert(left)\n right_c = jconvert(right)\n\n case op\n when :and\n return jdsl.eAnd(left, right);\n when :or\n return jdsl.eOr(left, right);\n else\n raise \"Unknown op #{jop}\"\n end\n end", "def from &code\n @vars = Variabler.new\n sexp = code.to_sexp(strip_enclosure: true)\n sourcecode = statements(sexp)\n pp sexp\n return @vars.sourcecode + NL + sourcecode\n end", "def rewritten_code(sexp, rewriter)\n sexp_copy = VirtualKeywords.deep_copy_array sexp\n new_code = @sexp_stringifier.stringify(\n rewriter.process(sexp_copy))\n end", "def compile_to_c\n operator_c_string + \"(\" + @expression.compile_to_c + \")\"\n end", "def rewrite_sexpr(sexpr)\n case sexpr\n when SExp::List\n case sexpr[0].to_s\n when \"switchdoor\"\n sexpr.strip()\n reader = SExp::Reader.new(sexpr)\n\n switch_reader = reader.read_section(\"switch\")\n switch_pos = switch_reader.read_real_array(\"position\")\n\n door_reader = reader.read_section(\"door\")\n door_pos = door_reader.read_real_array(\"position\")\n door_height = door_reader.read_integer_array(\"height\")\n\n id = \"id#{rand(2**32)}\"\n\n return [SExp::List.new([SExp::Symbol.new(\"switchdoor-switch\"),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"target-id\"),\n SExp::String.new(id)]),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"position\")] +\n switch_pos.map{|i| SExp::Integer.new(i)})]),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"switchdoor-door\"),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"id\"),\n SExp::String.new(id)]),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"height\"),\n SExp::Integer.new(door_height)]),\n SExp::Whitespace.new(\"\\n \"),\n SExp::List.new([SExp::Symbol.new(\"position\")] +\n door_pos.map{|i| SExp::Integer.new(i)})])]\n else\n lst = SExp::List.new([])\n sexpr.each{|i|\n el = rewrite_sexpr(i)\n if el\n if el.is_a?(Array)\n lst.concat(el)\n else\n lst.append(el)\n end\n end\n }\n return lst\n end\n else\n return sexpr\n end\nend", "def for_sxp\n elements = [kind, sym]\n elements << id if id\n elements << [:start, true] if start\n elements << first.sort_by(&:to_s).unshift(:first) if first\n elements << follow.sort_by(&:to_s).unshift(:follow) if follow\n elements << [:cleanup, cleanup] if cleanup\n elements << expr\n elements\n end", "def build_compiler(node_name, fact_values)\n node_options = {\n :parameters => fact_values,\n }\n\n stub_facts! fact_values\n\n node = build_node(node_name, node_options)\n\n compiler = Puppet::Parser::Compiler.new(node)\n compiler.compile\n compiler\n end", "def class(sexp, level)\n cid, sup, body = sexp\n code, vars = nil, []\n\n base, name = if Symbol === cid or String === cid\n ['self', cid.to_s.inspect]\n elsif cid[0] == :colon2\n [process(cid[1], :expression), cid[2].to_s.inspect]\n elsif cid[0] == :colon3\n ['VM.Object', cid[1].to_s.inspect]\n else\n raise \"Bad receiver in class\"\n end\n\n sup = sup ? process(sup, :expression) : 'null'\n\n in_scope(:class) do\n code = process body, :statement\n\n @scope.locals.each { |t| vars << \"#{t} = nil\" }\n @scope.temps.each { |t| vars << t }\n\n code = \"var #{vars.join ', '};\" + code unless vars.empty?\n end\n\n \"$class(#{base}, #{sup}, #{name}, function(self) {\\n#{code}})\"\n end", "def args(sexp)\n if call_site?(sexp)\n (rest(sexp[3])).collect { |each| Code.from_s_expression(each) }\n else\n []\n end\n end", "def compile(xml)\n XML.default_line_numbers = true\n\n doc = nil\n\n if xml.is_a?(String)\n doc = LibXML::XML::Document.string xml\n doc = doc.root\n elsif xml.is_a?(LibXML::XML::Document)\n doc = xml.root\n else\n doc = xml\n end\n\n @context.compile_structural(doc)\n end", "def compile_vexpression\n out = expect :number, :identifier,\n :istring, :lparen,\n :sstring, :operator,\n :keyword,\n :regex,\n :newline,\n :istring_begin,\n :iheredoc_begin,\n :plus, :minus,\n :lbrace => :object,\n :lbrack => :array,\n :arrow => :function,\n [\n :preunop, :unop\n ] => :unop,\n [\n :heredoc_ref, :iheredoc_ref\n ] => :href,\n [\n :heredoc, :iheredoc\n ] => :heredoc\n\n value_expect(out)\n end", "def integer sexp\n [:pushl, car(sexp).to_s.to_i]\n end", "def evaluate(expression)\n @simpleParser.parse expression\n end", "def replace_sexp(sexp, predicate, function)\n Macro.new.replace(sexp, predicate, function)\nend", "def generate_ruby sexp\n ruby = Ruby2Ruby.new.process(sexp)\n ruby.sub!(/\\A(def \\S+)\\(([^\\)]*)\\)/, '\\1 |\\2|') # move args\n ruby.sub!(/\\Adef[^\\n\\|]+/, 'proc { ') # strip def name\n ruby.sub!(/end\\Z/, '}') # strip end\n ruby.gsub!(/\\s+$/, '') # trailing WS bugs me\n ruby\n end", "def mkcompiler source=''\n VishCompiler.new source\nend", "def ruby_simplifier (sexp,var)\n \t#print \"\\n\\nruby_simplifier(\"\n \t#print sexp\n \t#puts \")\\n\\n\"\n\n if sexp and var and sexp[0] === :call and sexp[1] and sexp[1][0] === :lvar \\\n and sexp[1][1] === var then\n \t@@vars.add sexp[2]\n \t[:lvar, \"?\" + sexp[2].to_s]\n elsif sexp and sexp[0] === :call and sexp[1] and sexp[1][0] === :self then\n\t@@vars.add sexp[2]\n\t[:self, \"?\" + sexp[2].to_s]\n elsif sexp and sexp[0] === :call and sexp[1] and sexp[1][0] === :ivar and sexp[1][1] == :@attributes then\n\t@@vars.add sexp[3][1][1]\n\t[:ivar, \"?\" + sexp[3][1][1]]\n else\n \tsexp\n end\n end", "def compileSubroutineCall(tokens, i)\n str = \"\"\n flag = true\n # if flag is false then it is not the . call\n if notToLarge(tokens, i) and isCorrectToken(tokens, i+1, \"(\")\n flag = false\n end\n # flag stays false\n # # if flag is false,\n if flag\n if notToLarge(tokens, i) and isIdentifier(tokens[i][1])\n str += getXMLString(tokens, i)\n i += 1\n end\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \".\")\n str += getXMLString(tokens, i)\n i += 1\n end\n\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \"new\")\n str += getXMLString(tokens, i)\n i += 1\n end\n end\n # now that we took care of this . call\n if notToLarge(tokens, i) and isIdentifier(tokens[i][1])\n str += getXMLString(tokens, i)\n i += 1\n end\n\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \"(\")\n str += getXMLString(tokens, i)\n i += 1\n end\n\n resultList = compileExpressionList(tokens, i)\n str += resultList[0]\n i = resultList[1]\n\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \")\")\n str += getXMLString(tokens, i)\n i += 1\n end\n return [str, i]\nend", "def each_sexp\n self.each do |sexp|\n next unless Sexp === sexp\n\n yield sexp\n end\n end", "def evaluate(scope = {})\n Evaluator.new(scope).process(to_sexp)\n end", "def lit(sexp, level)\n val = sexp.shift\n case val\n when Numeric\n val.inspect\n when Symbol\n @symbols[val.to_s] ||= \"$symbol_#{@sym_id += 1}\"\n when Regexp\n val == // ? /^/.inspect : val.inspect\n when Range\n \"$range(#{val.begin}, #{val.end}, #{val.exclude_end?})\"\n else\n raise \"Bad lit: #{val.inspect}\"\n end\n end", "def to_risc\n risc_compiler = Risc::MethodCompiler.new(@callable , slot_instructions)\n instructions_to_risc(risc_compiler)\n risc_compiler\n end", "def parse(token)\n return parseExpression(token)\n end", "def _icall(sexp)\n symbol = self.eval(sexp).last\n [:pushl, @incr[], :pushl, symbol, :icall]\n end", "def compile(tokens, options = T.unsafe(nil)); end", "def compile_to_c\n statements.collect { |s| s.compile_to_c }.join(\"\\n\")\n end", "def parse(tokens = [], ast = nil)\n # Initialize needed variables to a known state\n @ast = ast\n @tokens = tokens\n @pos = 0\n\n # Parse high level statement\n statement\n\n # Return result\n return @ast\n end", "def compile_to_ruby_source_as parser_class_name\r\n result = \"class #{parser_class_name} < Dhaka::CompiledParser\\n\\n\"\r\n result << \" self.grammar = #{grammar.name}\\n\\n\"\r\n result << \" start_with #{start_state.id}\\n\\n\"\r\n states.each do |state|\r\n result << \"#{state.compile_to_ruby_source}\\n\\n\"\r\n end\r\n result << \"end\"\r\n result\r\n end", "def array (sexp, level)\n return '[]' if sexp.empty?\n\n code, work = \"\", []\n\n until sexp.empty?\n splat = sexp.first.first == :splat\n part = process sexp.shift, :expression\n\n if splat\n if work.empty?\n code += (code.empty? ? part : \".concat(#{part})\")\n else\n join = \"[#{work.join ', '}]\"\n code += (code.empty? ? join : \".concat(#{join})\")\n code += \".concat(#{part})\"\n end\n work = []\n else\n work << part\n end\n end\n\n unless work.empty?\n join = \"[#{work.join ', '}]\"\n code += (code.empty? ? join : \".concat(#{join})\")\n end\n\n code\n end", "def build\n nodes = []\n chars = []\n\n expression.each_char do |character|\n\n if '(' == character\n\n chars << character\n\n elsif /\\d+/.match(character)\n\n nodes.push Tree.new(character.to_i)\n\n elsif operands.include?(character)\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars << Operation::OPERATIONS[character].new\n\n elsif ')' == character\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars.pop\n\n end\n\n end\n\n unless nodes.empty? && chars.empty?\n self.root = Tree.new(chars.pop)\n root.right = nodes.pop\n root.left = nodes.pop\n end\n\n raise \"Ka-Blam! You still have nodes and/or chars\" if nodes.any? || chars.any?\n\n root\n end", "def compile(rule, rs, is_reset=false)\n evaluated = evaluate(rule,rs,is_reset)\n return Compiled.new(\n rule,\n evaluated,\n codes(evaluated)\n ).freeze\n end", "def translate(ast = nil)\n # Ensure that ast is a valid Abstract Syntax Tree\n if ast == nil or !ast.respond_to?(\"root\") or ast.root == nil\n raise @err_class, \"The Abstract Syntax Tree is either invalid or empty!\"\n else\n @ast = ast\n @code = []\n end\n\n # Get root node\n curr_node = ast.root\n if curr_node.name == \"QUIT\"\n @code.push(\"HALT\")\n elsif curr_node.name == \"HOWMANY\" or curr_node.name == \"HOWMUCH\"\n translate_query(curr_node)\n elsif curr_node.name == \"ASSIGN\"\n translate_assign(curr_node)\n end\n\n # Add common initialization code used in all statements\n @code.push(\"CLR $ar\") # Clear general purpose register #1\n @code.push(\"CLR $br\") # Clear general purpose register #2\n @code.push(\"CLR $nr\") # Clear numeral register\n @code.push(\"CLR $rr\") # Clear return register\n @code.push(\"CLR $sr\") # Clear stack register\n\n # Return virtual machine code\n return @code\n end", "def to_s\n PrettyPrinter.new.process(to_sexp)\n end", "def build_parse_tree(exp)\n exp_arr = exp.split\n tree_stack = Stack.new\n tree = BinaryTree.new('')\n current_tree = tree\n exp_arr.each do |i|\n if i == '('\n current_tree.insert_left('')\n tree_stack.push(current_tree)\n current_tree = current_tree.left_child\n elsif i.match(/\\d/)\n current_tree.set_root_value(Integer(i))\n parent = tree_stack.pop\n current_tree = parent\n elsif ['+', '-', '*', '/'].include?(i)\n current_tree.set_root_value(i)\n current_tree.insert_right('')\n tree_stack.push(current_tree)\n current_tree = current_tree.right_child\n elsif i == ')'\n current_tree = tree_stack.pop\n else\n fail 'Invalid Argument'\n end\n end\n tree\nend", "def translate_call(sexp)\n raise NotInlineableError unless inlineable? sexp\n arg1 = translate_generic_sexp sexp[1]\n arg2 = translate_generic_sexp sexp[3][1]\n res_type = ([arg1.value_type, arg2.value_type].include? :Float) ? :Float : :Fixnum\n s().with_value(s(:binary_oper,\n sexp[2], arg1.value_sexp, arg2.value_sexp), res_type)\n end", "def parse(x)\n grammar = interpreter.parser.grammar\n parse_with(grammar, x)\n end", "def compile(source)\n regexp = Regexp.compile(source)\n expression = parse(regexp)\n Regexp.compile(expression.to_s(true), expression.flags)\n end", "def super(sexp, level)\n args = []\n until sexp.empty?\n args << process(sexp.shift, :expression)\n end\n \"$super(arguments.callee, self, [#{args.join ', '}])\"\n end", "def to_risc(compiler)\n build_with(compiler.builder(self))\n end", "def expand(sexp, defs)\n Sexp.from_array(depth_first_exhaustive_collect(sexp,\n lambda { |exp| expandable?(exp, defs) },\n lambda { |exp| (defs[call_keys(exp)].call(*args(exp))).to_s_expression }))\n end", "def replace_sexp_with_type(sexp, type, function)\n Macro.new.replace_sexp_with_type(sexp, type, function)\nend", "def create_tree(exp)\n \toperatorStack, nodeStack = [], []\n \n # define function to create new tree segment\n subtree = Proc.new {\n # pop operands where\n # a [operator] b\n b, a = nodeStack.pop, nodeStack.pop\n\t\t\tnodeStack.push(Tree::Node.new(operatorStack.pop, a, b))\n\t\t}\n \n \texp.split(\"\").each do |c|\n \t\t# Skip whitespace characters\n \t\tif c === \"\\s\"\n \t\t\tnext\n \t\telsif c === ')'\n \t\t\tuntil operatorStack.last === '(' do\n \t\t\t\tsubtree.call\n \t\t\tend\n \t\t\t# remove the remaining open parenthesis\n \t\t\toperatorStack.pop\n \t\telsif %w|+ - * / ^ (|.include? c\n \t\t\tif operatorStack.empty? || c === '('\n \t\t\t\toperatorStack.push(c)\n \t\t\telse\n \t\t\t\twhile precedence_of(operatorStack.last) >= precedence_of(c)\n \t\t\t\t\tsubtree.call\n \t\t\t\tend\n \t\t\t\toperatorStack.push(c)\n \t\t\tend\n \t\telse\n \t\t\tnodeStack.push(Tree::Node.new(c))\n \t\tend\n \tend\n\n \tuntil operatorStack.empty? do\n \t\tsubtree.call\n \tend\n \n # top element of the stack is the root element\n \tTree.new(nodeStack.pop)\n end", "def ast; end", "def ast; end", "def translate_generic_sexp(sexp)\n # Is there a public or a private method translating such a sexp?\n if respond_to? (method_name = \"translate_#{sexp[0]}\".to_sym), true\n remove_border_mark(sexp)\n send(method_name, sexp)\n else\n raise NotInlineableError \n end\n end", "def ps\n [VishParser.new, SexpTransform.new]\nend", "def call(sexp, level)\n recv, meth, arglist, iter = sexp\n @calls << meth.to_s unless @calls.include? meth.to_s\n\n return js_operator_call(sexp, level) if CALL_OPERATORS.include? meth.to_s\n return js_block_given(sexp, level) if meth == :block_given?\n return \"undefined\" if meth == :undefined\n\n if Sexp === arglist.last and arglist.last.first == :block_pass\n block_pass = process arglist.pop, :expression\n end\n\n args = \"\"\n splat = arglist[1..-1].any? { |a| a.first == :splat }\n tmprecv = @scope.new_temp\n tmpproc = @scope.new_temp if iter or block_pass\n\n if recv.nil?\n recv_code = \"self\"\n recv_arg = \"self\"\n else\n recv_code = \"(#{tmprecv} = #{process recv, :expression})\"\n recv_arg = tmprecv\n end\n\n arglist.insert 1, s(:js_tmp, recv_arg), s(:js_tmp, meth.to_s.inspect)\n\n args = process arglist, :expression\n\n mid = mid_to_jsid meth\n dispatch = \"(#{recv_code}, (#{recv_arg} == null ? $nilcls : #{recv_arg})\"\n dispatch += \"#{mid})\"\n\n if iter\n dispatch = \"(#{tmpproc} = #{dispatch}, (#{tmpproc}.$B = #{iter}).$S \"\n dispatch += \"= self, #{tmpproc})\"\n elsif block_pass\n dispatch = \"(#{tmpproc} = #{dispatch}, #{tmpproc}.$B = #{block_pass}, #{tmpproc})\"\n end\n\n @scope.queue_temp tmprecv\n @scope.queue_temp tmpproc if tmpproc\n\n if splat\n \"#{dispatch}.apply(null, #{args})\"\n else\n \"#{dispatch}(#{args})\"\n end\n end", "def call(ast)\n ast\n end", "def compile_to_ruby\n operator_ruby_string + \"(\" + @expression.compile_to_ruby + \")\"\n end", "def parser (tokens)\n\n\t# create the new, concrete syntax tree\n\t# making it global to reduce headaches (hopefully XD )\n\t$cst = ConcreteSyntaxTree.new\n\t\n\t# define some other useful, global vars\n\t$tokens = tokens\n\t$index = 0\n\t\n\t# have to ask alan about this\n\tif $tokens.length <= 1\n\t\tputs \"Insufficient code present! There is only #{$tokens.length} token here!\"\n\t\texit\n\tend\t\n\t\n\t\n\t# Engine to full burn!!!\n\t#parse(\"Program\", program)\n\tprogram\n\t\n\t\n\tbegin\n\t\tif $tokens.length != $index\n\t\t\traise EOFDetectionError.new(\"early\", $tokens[$index - 1].lineno, $tokens[$index - 1].pos)\n\t\tend\n\trescue EOFDetectionError\n\tend\n\t\t\n\t\n\t\n\treturn $cst\nend", "def statement\n # ast => Abstract Syntax Tree\n if ((ast = function_definition) != nil)\n return ast\n elsif ((ast = conditional_statement) != nil)\n return ast\n elsif ((ast = function_call) != nil)\n return ast\n elsif ((ast = return_statement) != nil)\n return ast\n end\n throw :parser_exception\n end", "def compileTerm(tokens, i)\n str = \"\"\n\n # unary Operators\n if notToLarge(tokens, i) and isUnaryOP(tokens[i][1])\n str += getXMLString(tokens, i)\n i += 1\n resultList = compileTerm(tokens, i)\n str += \"<term>\\n\"\n str += resultList[0]\n i = resultList[1]\n str += \"</term>\\n\"\n\n # ( expression )\n elsif notToLarge(tokens, i) and isCorrectToken(tokens, i, \"(\")\n str += getXMLString(tokens, i)\n i += 1\n\n resultList = compileExpression(tokens, i)\n str += resultList[0]\n i = resultList[1]\n\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \")\")\n str += getXMLString(tokens, i)\n i += 1\n end\n\n #int/keyword/string Constant\n elsif notToLarge(tokens, i) and (isIntConstant(tokens[i][1]) or isKeywordConst(tokens[i][1]) or\n tokens[i][0] == \"stringConstant\")\n str += getXMLString(tokens, i)\n i += 1\n\n #the else is for var name and subroutine need to solve this\n elsif isIdentifier(tokens[i][1])\n if notToLarge(tokens, i+1) and isCorrectToken(tokens, i+1, \"[\")\n str += getXMLString(tokens, i)\n i += 1\n str += getXMLString(tokens, i)\n i += 1\n\n resultList = compileExpression(tokens, i)\n str+= resultList[0]\n i = resultList[1]\n\n if notToLarge(tokens, i) and isCorrectToken(tokens, i, \"]\")\n str += getXMLString(tokens, i)\n i += 1\n end\n\n elsif notToLarge(tokens, i+1) and (isCorrectToken(tokens, i+1, \"(\") or isCorrectToken(tokens, i+1, \".\"))\n resultList = compileSubroutineCall(tokens, i)\n str = resultList[0]\n i = resultList[1]\n\n else\n str += getXMLString(tokens, i)\n i += 1\n return [str, i]\n end\n end\n\n return [str, i]\nend", "def scopify(expr)\n expr = insert_b(expr)\n @i = 0\n n_expr = \"\"\n last_empty = 0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n eq = false\n stack = Array.new\n last_e = Array.new\n state = 0\n while @i < expr.size\n case expr[@i]\n # Each part between brackets is seen as a subexpression\n # and it is analyzed recoursively.\n when '('\n scp = Scp.new\n n_expr += expr[@i] + scp.scopify(extract(expr[(@i + 1)...expr.length])) \n @i += scp.count \n when /[\\*\\/]/\n # If there are open brackets of higher opertions\n # it closes them\n if open_m_b > 0\n n_expr += ')' * open_m_b\n last_empty = last_e.pop\n open_m_b = 0\n #open_b -= 1\n end\n if state == 2\n n_expr += ')' * open_p_b\n open_p_b = 0\n state = (stack.size > 0 ? stack.pop : 0)\n end\n # If it is not still analyzing a multiplication, it adds the brackets \n # following the rules\n unless state == 1\n n_expr.insert last_empty, '(' \n state = 1\n open_b += 1\n end\n n_expr += expr[@i]\n last_empty = n_expr.size # + 1\n when /[\\+\\-]/\n # higher priority operation brackets are closed\n # last_empty is shifted\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n state = 0\n open_b = 0\n open_p_b = 0\n n_expr += expr[@i]\n last_empty = n_expr.size\n when /\\^/\n # It begins to put between brackets the operation and its exponent\n if open_m_b > 0 then\n n_expr += \")\" * open_m_b\n last_empty = last_e.pop\n #open_b -= 1\n open_m_b = 0\n end\n n_expr.insert last_empty, '(' unless state == 2\n last_empty += 1 unless state == 2\n n_expr += expr[@i] + (expr[@i+1] == '(' ? '' : '(')\n open_p_b += (expr[@i+1] == '(' ? 1 : (state == 2 ? 1:2))\n stack.push state unless state == 2\n state = 2\n when /\\=/\n # The expression at the left of `=` is put between brackets\n # and a bracket at the right is opened\n # It closes previously opened brackets\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' * open_m_b if open_m_b >0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n n_expr += '('\n last_empty = n_expr.size\n state = 0\n eq = true\n when /\\>/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n open_b = 0\n open_p_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n last_empty = n_expr.size\n when /\\:/\n n_expr.insert last_empty, '('\n n_expr += expr[@i]\n last_k = n_expr[(last_empty+1)...n_expr.size]\n open_m_b += 1 if \"mx:integ:as:from:\".include? last_k\n last_e.pop if last_e.count > 0 and (last_k == \"mx:\" or last_k == \"integ:\")# or last_k == \"solve:\")\n last_e.push last_empty if last_k == \"mx:\" or last_k == \"integ:\"# or last_k == \"solve:\"\n last_empty = n_expr.size\n open_b += 1 unless \"mx:integ:as:from:\".include? last_k\n when /\\\"/\n n_expr += expr[@i]\n @i += 1\n n_expr += discard(expr)\n last_empty = n_expr.length\n when /\\~/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * (open_b - 1 ) if open_b - 1 > 0\n open_p_b = 0\n open_b = 1\n state = (stack.size > 0 ? stack.pop : 0)\n n_expr += expr[@i]\n last_empty = n_expr.size \n else\n n_expr += expr[@i]\n end\n @i += 1\n end\n # it closes all the opened brackets\n n_expr += ')' * open_m_b if open_m_b > 0\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' if eq\n return n_expr\n end", "def parse\n s_expr_list\n end", "def compile_statement\n # write_tag '<statement>'\n return compile_let_statement if check?(TokenType::LET)\n return compile_while_statement if check?(TokenType::WHILE)\n return compile_do_statement if check?(TokenType::DO)\n return compile_return_statement if check?(TokenType::RETURN)\n return compile_if_statement if check?(TokenType::IF)\n # write_tag '</statement>'\n end", "def receiver(sexp)\n if call_site?(sexp)\n sexp[1]\n end\n end", "def while(sexp, level)\n expr, stmt = sexp\n stmt_level = (level == :expression ? :statement_closure : :statement)\n\n code = \"while (#{process expr, :expression}){\"\n\n in_while { code += process(stmt, :statement) }\n code += \"}\"\n\n if stmt_level == :statement_closure\n code = \"(function() {\\n#{code}})()\"\n end\n\n code\n end", "def visit_Squeel_Nodes_Operation(o, parent)\n args = o.args.map do |arg|\n case arg\n when Nodes::Function, Nodes::KeyPath, Nodes::As, Nodes::Literal\n visit(arg, parent)\n when Symbol, Nodes::Stub\n Arel.sql(arel_visitor.accept contextualize(parent)[arg.to_sym])\n else\n quote arg\n end\n end\n\n op = case o.operator\n when :+\n Arel::Nodes::Addition.new(args[0], args[1])\n when :-\n Arel::Nodes::Subtraction.new(args[0], args[1])\n when :*\n Arel::Nodes::Multiplication.new(args[0], args[1])\n when :/\n Arel::Nodes::Division.new(args[0], args[1])\n else\n Arel.sql(\"#{arel_visitor.accept(args[0])} #{o.operator} #{arel_visitor.accept(args[1])}\")\n end\n o.alias ? op.as(o.alias) : op\n end", "def arglist (sexp, level)\n code, work = '', []\n\n until sexp.empty?\n splat = sexp.first.first == :splat\n arg = process sexp.shift, :expression\n\n if splat\n if work.empty?\n if code.empty?\n code += (arg[0] == \"[\" ? arg : \"#{arg}#{mid_to_jsid :to_a}()\")\n else\n code += \".concat(#{arg})\"\n end\n else\n join = \"[#{work.join ', '}]\"\n code += (code.empty? ? join : \".concat(#{join})\")\n code += \".concat(#{arg})\"\n end\n\n work = []\n else\n work.push arg\n end\n end\n\n unless work.empty?\n join = work.join ', '\n code += (code.empty? ? join : \".concat([#{work}])\")\n end\n\n code\n end", "def evaluate(ex)\n @stack=[]\n @expr.each do |el|\n case el\n when HopExprVar\n # evaluate variable\n var,dot,field=el.value.partition('.')\n if field==''\n # scalar\n val=VarStor.getScalar(ex,el.value)\n else\n # cortege field\n begin\n val=VarStor.getCortege(ex,var)[field]\n rescue\n warn \">> Opppps: #{var}.#{field}\"\n nil\n end\n end\n @stack.push val\n\n when Numeric, String\n # constant\n @stack.push el\n\n when HopExprOp\n case el.value\n when '+'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>PLUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f+a2.to_f\n when '*'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f*a2.to_f\n when '-'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>MINUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f-a1.to_f\n when '/'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f/a1.to_f\n when '%'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f%a1.to_f\n else\n raise SyntaxErrHopError\n end\n end #~case\n end # ~each expression\n raise SyntaxErrHopError.new(@expr.to_s+' ('+@stack.to_s+')') if @stack.size>1\n\n return @stack.pop\n end" ]
[ "0.70163244", "0.6789324", "0.6789324", "0.63605344", "0.63386464", "0.63065004", "0.588651", "0.5862931", "0.58546233", "0.5839368", "0.5668713", "0.5668713", "0.5547117", "0.544543", "0.5395736", "0.53711784", "0.53648275", "0.5350735", "0.53485763", "0.52576387", "0.5234957", "0.51926094", "0.5158396", "0.51389724", "0.5097296", "0.50855523", "0.5075523", "0.504793", "0.5013226", "0.49851722", "0.495193", "0.4942766", "0.49345538", "0.49286833", "0.49179697", "0.49053356", "0.49020347", "0.48963535", "0.48921746", "0.48568493", "0.48511797", "0.48421624", "0.4841615", "0.48342028", "0.48301327", "0.48134953", "0.47747588", "0.47605154", "0.47555804", "0.47386596", "0.47365138", "0.47355446", "0.47354206", "0.4724464", "0.47034013", "0.4690723", "0.46832687", "0.4679956", "0.46746114", "0.4644273", "0.46426412", "0.4641596", "0.46294442", "0.4618037", "0.46099022", "0.4593421", "0.4586326", "0.45836058", "0.4574196", "0.45600638", "0.4559524", "0.45583713", "0.45504916", "0.4544104", "0.45242074", "0.45226094", "0.45211178", "0.45102084", "0.4502202", "0.44995624", "0.44941258", "0.4489569", "0.4484856", "0.4484856", "0.4482713", "0.44646192", "0.4459032", "0.44577122", "0.44566423", "0.44549537", "0.44511303", "0.44495597", "0.44468725", "0.4445909", "0.44401398", "0.44389975", "0.44369578", "0.44308996", "0.44225276", "0.44192895" ]
0.73390305
0
Render the XML error for a specific code
def error(code) # Mollie codes taken from https://www.mollie.nl/support/documentatie/betaaldiensten/ideal/en/ errors = [] errors[1] = "Did not receive a proper input value." errors[2] = "A fetch was issued without specification of 'partnerid'." errors[3] = "A fetch was issued without (proper) specification of 'reporturl'." errors[4] = "A fetch was issued without specification of 'amount'." errors[5] = "A fetch was issued without specification of 'bank_id'." errors[6] = "A fetch was issues without specification of a known 'bank_id'." errors[7] = "A fetch was issued without specification of 'description'." errors[8] = "A check was issued without specification of transaction_id." errors[9] = "Transaction_id contains illegal characters. (Logged as attempt to mangle)." errors[10] = "This is an unknown order." errors[11] = "A check was issued without specification of your partner_id." errors[12] = "A fetch was issued without (proper) specification of 'returnurl'." errors[13] = "This amount is only permitted when iDEAL contract is signed and sent to Mollie." errors[14] = "Minimum amount for an ideal transaction is 1,18 EUR." errors[15] = "A fetch was issued for an account which is not allowed to accept iDEAL payments (yet)." errors[16] = "A fetch was issued for an unknown or inactive profile." haml :error, :layout => false, :locals => { :type => "error", :code => code, :message => errors[code*-1] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_xml(code, msg)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n \n doc.Response do\n doc.Errors do\n doc.Error do\n doc.Code code.to_s\n doc.Message msg\n doc.BoxUsage \"0\"\n end\n end\n \n doc.RequestID \"1234\"\n end\n \n xml\n end", "def xml_error(http_error_code=Forbidden, &block)\n render_xml(:error) do |xml|\n block.yield(xml)\n end\n raise http_error_code\n end", "def render_error\n respond_to do| wants|\n wants.html {render :to_xml => 'error.xml.builder', :layout => false, :status => @error.code }\n wants.json {render :to_json => 'error.xml.builder', :status => @error.code }\n wants.xml {render :to_xml => 'error.xml.builder', :layout => false, :status => @error.code }\n wants.yaml {render :to_yaml => 'error.xml.builder', :status => @error.code }\n end\n end", "def render_error(code, message)\n respond_with Utils::RenderableError.new(code, message), status: code\n end", "def render_error(error_code=nil,error_format='json',error_summary=nil)\n if params[:response_type]==\"2\" \n error_format='xml'\n end\n if params[:response_type].nil? == true\n\t\terror_format='json'\n\t end\n\t \n if error_summary.nil?\n error_desc = t(error_code+'.errorcode').to_s + \": \" + t(error_code+'.errordescription')\n logger.debug \"API Error: #{error_desc}\"\n else\n logger.debug \"API Error: #{error_summary}\"\n end \n \n case error_format\n when 'json'\n if error_summary.nil?\n render :json => {responsecode: t(error_code+'.errorcode'),errormessage: t(error_code+'.errordescription')}\n\t\telse\n render :json => {responsecode: t(error_code+'.errorcode'),errormessage: error_summary}\n\t\t end \n when 'xml'\n if error_summary.nil?\n render :xml => {responsecode: t(error_code+'.errorcode'),errormessage: t(error_code+'.errordescription')}\n\t\telse\n render :xml => {responsecode: t(error_code+'.errorcode'),errormessage: error_summary}\n\t\tend\n end\n end", "def render_error(msg, code=500)\n respond_with(nil, :status => {:msg => msg, :code => code})\n end", "def html_error_page err, code=nil\n if @app.development?\n backtrace = err.backtrace || ['No backtrace :(']\n fulltrace = backtrace.join(\"\\n\")\n fulltrace = \"<pre>#{h(fulltrace)}</pre>\"\n\n apptrace = Gin.app_trace(backtrace).join(\"\\n\")\n apptrace = \"<pre>#{h(apptrace)}</pre>\" unless apptrace.empty?\n\n DEV_ERROR_HTML %\n [h(err.class), h(err.class), h(err.message), apptrace, fulltrace]\n\n else\n code ||= status\n filepath = asset(\"#{code}.html\") || asset(\"500.html\")\n\n unless filepath\n filepath = File.join(Gin::PUBLIC_DIR, \"#{code}.html\")\n filepath = File.join(Gin::PUBLIC_DIR, \"500.html\") if !File.file?(filepath)\n end\n\n File.open(filepath, \"rb\")\n end\n end", "def coockies_render_error(error_code=nil,error_format='json',error_summary=nil)\n if params[:response_type]==\"2\" \n error_format='xml'\n end\n if params[:response_type].nil? == true\n\t\terror_format='json'\n\t end\n\t \n if error_summary.nil?\n error_desc = t(error_code+'.errorcode').to_s + \": \" + t(error_code+'.errordescription')\n logger.debug \"API Error: #{error_desc}\"\n else\n logger.debug \"API Error: #{error_summary}\"\n end \n \n case error_format\n when 'json'\n if error_summary.nil?\n render :json => {:success => false, :error => { :code => t(error_code+'.errorcode'), :description => t(error_code+'.errordescription')}}\n else\n \t render :json => {:success => false, :error => { :code => t(error_code+'.errorcode'), :description => error_summary}}\n end \n when 'xml'\n if error_summary.nil?\n render :xml => {:success => false, :error => { :code => t(error_code+'.errorcode'), :description => t(error_code+'.errordescription')}} \n else\n render :xml => {:success => false, :error => { :code => t(error_code+'.errorcode'), :description => error_summary}}\n end\n end\n end", "def render_error(exception = nil)\n\trespond_to do |format|\n\t\tformat.html{\n\t\t\trender :file => \"/app/views/errors/500.html.erb\", :status => 500, :layout => \"application\"\n\t\t}\n\t\tformat.xml { head :not_found }\n\t\tformat.any { head :not_found }\t\n\tend\n end", "def render_openid_error(exception)\n error = case exception\n when OpenID::Server::MalformedTrustRoot then \"Malformed trust root '#{exception.to_s}'\"\n else exception.to_s\n end\n render :text => \"Invalid OpenID request: #{error}\", :status => 500\n end", "def render_openid_error(exception)\n error = case exception\n when OpenID::Server::MalformedTrustRoot then \"Malformed trust root '#{exception.to_s}'\"\n else exception.to_s\n end\n render :text => \"Invalid OpenID request: #{error}\", :status => 500\n end", "def render_error(error_code_and_message)\n LogWrapper.log('ERROR', {\n 'message' => error_code_and_message[1],\n 'method' => \"#{controller_name}##{action_name}\",\n 'status' => error_code_and_message[0]\n })\n return api_response_builder(error_code_and_message[0], {message: error_code_and_message[1]}.to_json)\n end", "def render_error error_code, error_type, text\n content_type :json\n\n #compose output JSON\n output = { \n :status => \"error\", \n :code => error_code.to_i, \n :error_type => error_type.to_s, \n :executed_at => Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"), \n }\n\n if text.is_a?(Hash)\n output.merge!(text)\n else\n output[:message] = text \n end\n\n #warning about conent type!\n output[:warning_invalid_content_type] = \"Please set request header content-type to 'application/json' - if you will not se it you are limited by 64KB by request\" unless request.env['CONTENT_TYPE'] && request.env['CONTENT_TYPE'].include?(\"application/json\")\n\n #items and name specified\n halt error_code.to_i, Yajl::Encoder.encode(output)\n end", "def exception_renderer; end", "def render_xml\n end", "def render_error(arg)\n arg = {:message => arg} unless arg.is_a?(Hash)\n\n @message = arg[:message]\n @message = l(@message) if @message.is_a?(Symbol)\n @status = arg[:status] || 500\n\n respond_to do |format|\n format.html {\n render :template => 'home/error', :layout => 'content', :status => @status\n }\n format.atom { head @status }\n format.xml { head @status }\n format.js { head @status }\n format.json { head @status }\n end\n end", "def render_error(arg)\n arg = {:message => arg} unless arg.is_a?(Hash)\n\n @message = arg[:message]\n @message = I18n.t(@message) if @message.is_a?(Symbol)\n @status = arg[:status] || 500\n\n respond_to do |format|\n format.html {\n render :template => 'common/error', :status => @status\n }\n format.atom { head @status }\n format.xml { head @status }\n format.js { head @status }\n format.json { head @status }\n end\n end", "def render_optional_error_file(status_code)\n status = interpret_status(status_code)\n render :template => \"/errors/#{status[0,3]}.html.erb\", :status => status, :layout => 'default.html.erb'\n end", "def render_exception_response(exception, response_code)\n case response_code\n when :unauthorized\n logged_in? ? access_denied : must_be_logged_in\n when :forbidden\n access_denied\n when :not_implemented\n not_yet_implemented\n else\n status = interpret_status(response_code) # defaults to \"500 Unknown Status\" if response_code is not recognized\n status_code = status[0,3]\n respond_to do |format|\n format.html do\n @error_page_title = I18n.t(\"error_#{status_code}_page_title\", :default => [:error_default_page_title, \"Error.\"])\n @status_code = status_code\n render :layout => 'v2/errors', :template => 'content/error', :status => status_code\n end\n format.js do\n render :layout => false, :template => 'content/error', :status => status_code\n end\n format.all { render :text => status, :status => status_code }\n end\n end\n end", "def render_error(status)\n respond_to do |format|\n # format.html { render file: \"errors/#{ActionController::StatusCodes.send(status)}\", status: status }\n\n # FIXME: I tried to access gem's views/errors/errors and didn't work\n format.html { render file: \"#{Rails.root}/public/404\", status: status }\n format.xml { head status }\n format.any { head status }\n end\n end", "def error(event, msg, code=500, trace = [])\n title = case code\n when 400\n \"Bad Request (400)\"\n when 401\n \"Unauthorized Request\"\n when 403\n \"Access Restricted\"\n when 404\n \"Page Not Found\"\n when 405\n \"HTTP Method Not Allowed\"\n else\n \"An Error Has Occured\"\n end\n @content = render('error', {title: title, message: msg, error_code: code, trace: trace})\n warnlog 'Error handler called with \"' << msg << '\", code ' << code.to_s << ' (trace: ' << trace.to_s << ')'\n end", "def render_error\n\t\terrmsg = env['sinatra.error']\n\t\trender errmsg\n\tend", "def render_error\n nil\n end", "def render_error\n nil\n end", "def err(cod)\n @st = :err\n @ie = cod\n end", "def error\r\n\t\t\t`#{BITS::BITSADMIN} /geterror {#{@id}}`\r\n\t\tend", "def render_error(exception)\n # use the exception_notifier gem to send out an e-mail to the notification list specified in config/environment.rb\n ExceptionNotifier.notify_exception(exception)\n\n #TODO: hide stack traces from students after the beta. leave @error undefined to hide stack traces\n @error = exception\n\n render \"home/error\"\n end", "def render_api_error(code, status_code, type = 'error' , message = nil)\n error = {}\n error[\"code\"] = code\n error[\"type\"] = type\n error[\"message\"] = message || API_CONFIG[\"api.error\"][code]\n Rails.logger.info(\"Rendered API error. Request: #{request.body.read} \\n Responded:\\n#{{error: error, status: status_code}}\")\n render json: {'error' => error}.to_json, status: status_code\n end", "def output_response_error(response)\n # Parse response xml (see https://ocrsdk.com/documentation/specifications/status-codes)\n xml_data = REXML::Document.new(response)\n error_message = xml_data.elements[\"error/message\"]\n puts \"Error: #{error_message.text}\" if error_message\nend", "def error_doc\n @error_doc ||= xml_doc @error\n end", "def error_500\n render 'error/error500'\n end", "def render_error( status_code )\n\n respond_to do |format|\n\n format.html { render( action: status_code, status: status_code )}\n format.all { head( status_code )}\n\n end\n\n @error_sent = true\n\n true # return something so we can chain things\n\n end", "def exception_renderer=(_arg0); end", "def display_error_page(message, error_code)\n self.status = error_code\n self.content_type = 'text/html'\n render :partial => '/shared/error_notification', :layout => 'notification', :locals => {:message => message, :error_code => error_code}\n end", "def get_error_code(code)\n assert_not_nil @rdigg.info.get_error_code(\"500\")\n end", "def error_rendering(exception, symbol)\n Rails.logger.error exception\n\n @exception = exception\n @symbol = symbol\n @code = Rack::Utils::SYMBOL_TO_STATUS_CODE[symbol].to_i\n respond_with @exception, status: @code, template: ERROR_PATH, prefixes: _prefixes\n end", "def error code=nil, message=nil\n if code\n if code.is_a?(String)\n error = Lux::Error.new 400\n error.message = code\n else\n error = Lux::Error.new code\n error.message = message if message\n end\n\n raise error\n else\n Lux::Error::AutoRaise\n end\n end", "def pagseguro_error(xml)\n messages = []\n xml.css(\"errors > error\").each do |error|\n messages << error_message(error.css(\"code\").text, error.css(\"message\").text)\n end\n {}.tap do |data|\n data[:errors] = messages\n end\n end", "def check_error(xml) #:nodoc\n end", "def check_error(xml) #:nodoc\n end", "def check_error(xml) #:nodoc\n end", "def check_error(xml) #:nodoc\n end", "def render_500\n render 'errors/index_500'\n end", "def render_error(msg, status)\n render_403\n end", "def error code, body=nil\n code, body = 500, code if code.respond_to? :to_str\n @response.body = body unless body.nil?\n halt code\n end", "def render_error(exception)\n # use the exception_notifier gem to send out an e-mail\n # to the notification list specified in config/environment.rb\n ExceptionNotifier.notify_exception(exception, env: request.env,\n data: {\n user: current_user,\n course: @course,\n assessment: @assessment,\n submission: @submission\n })\n\n respond_to do |format|\n format.html do\n # stack traces are only shown to instructors and administrators\n # by leaving @error undefined, students and CAs do not see stack traces\n if !current_user.nil? && (current_user.instructor? || current_user.administrator?)\n @error = exception\n\n # Generate course id and assessment id objects\n @course_name = params[:course_name] ||\n (params[:controller] == \"courses\" ? params[:name] : nil)\n if @course_name\n @assessment_name = params[:assessment_name] ||\n (params[:controller] == \"assessments\" ? params[:name] : nil)\n\n end\n end\n\n render \"home/error_500\"\n end\n format.json { head :internal_server_error }\n format.js { head :internal_server_error }\n end\n end", "def error\n\t\t\t\t\"ERROR\"\n\t\t\tend", "def api_error(xml) #:nodoc:\r\n if xml.nil?\r\n res = TruveoResponse.new\r\n res.error_code = '69'\r\n res.error_text = 'bad xml'\r\n return res\r\n end\r\n #<?xml version='1.0' encoding='UTF-8'?><Response><Error Code='14'>Access Denied: invalid appid.</Error></Response>\r\n if elt = xml.elements['//Error']\r\n res = TruveoResponse.new\r\n res.error_code = elt.attributes[\"Code\"]\r\n res.error_text = elt.text\r\n return res\r\n end\r\n nil\r\n end", "def check_error(xml) #:nodoc:\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end", "def error\n doc['error']\n end", "def fancy_error_template( key, response, status_info )\n\t\tself.log.info \"[:fancyerrors] Handling %d status response.\" % [ status_info[:status] ]\n\t\tcontent = self.template( key )\n\t\tcontent.status_info = status_info\n\t\tself.log.debug \" error content template loaded from %s\" % [ content.source_file || 'memory' ]\n\n\t\t# If there's a layout template, just return the template as-is so\n\t\t# templating will wrap it correctly\n\t\treturn content if self.layout\n\t\tself.log.debug \" using the fancyerrors layout template.\"\n\n\t\t# Otherwise, wrap it in a simple layout of our own\n\t\tlayout = self.template( :fancy_error_layout )\n\t\tlayout.body = content\n\t\tlayout.status_info = status_info\n\n\t\tself.log.debug \" error layout template loaded from %s\" % [ layout.source_file || 'memory' ]\n\n\t\t# :templating method\n\t\tself.set_common_attributes( layout, response.request )\n\n\t\treturn layout\n\tend", "def gsm_error_message\n $tracer.trace(__method__)\n #unit_test_no_generate: pur_number_error, li.className(create_ats_regex_string(\"ats-errormsg\"))\n return ToolTag.new(li.className(create_ats_regex_string(\"ats-errormsg\")), __method__, self)\n end", "def notice_xml\n render xml: {\n notice: {\n id: (@results.first[:hash] rescue nil)\n }\n }\n end", "def render_error_status(status=500, log_msg = \"\")\n logger.error \"REQUEST **************** Rendering #{status}: #{log_msg}. Request URI: #{request.url} ****************\"\n render :file => \"#{Rails.root}/public/#{status}.html\", :status => status, :layout => false\n return false\n end", "def to_xml(options={})\n str = \"<error>\"\n str += \" <developerMessage>#{@developerMessage}</developerMessage>\"\n str += \" <userMessage>#{@userMessage}</userMessage>\"\n str += \"</error>\"\n end", "def error\n render plain: '500 Internal Server Error', status: :internal_server_error\n end", "def error exception, req, res\n backtrace = exception.backtrace.join \"\\n\"\n\n res.content_type = 'text/html'\n res.status = 500\n res.body = <<-BODY\n<!DOCTYPE html>\n<html>\n<head>\n<meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\">\n\n<title>Error - #{ERB::Util.html_escape exception.class}</title>\n\n<link type=\"text/css\" media=\"screen\" href=\"#{@mount_path}/css/rdoc.css\" rel=\"stylesheet\">\n</head>\n<body>\n<h1>Error</h1>\n\n<p>While processing <code>#{ERB::Util.html_escape req.request_uri}</code> the\nRDoc (#{ERB::Util.html_escape RDoc::VERSION}) server has encountered a\n<code>#{ERB::Util.html_escape exception.class}</code>\nexception:\n\n<pre>#{ERB::Util.html_escape exception.message}</pre>\n\n<p>Please report this to the\n<a href=\"https://github.com/ruby/rdoc/issues\">RDoc issues tracker</a>. Please\ninclude the RDoc version, the URI above and exception class, message and\nbacktrace. If you're viewing a gem's documentation, include the gem name and\nversion. If you're viewing Ruby's documentation, include the version of ruby.\n\n<p>Backtrace:\n\n<pre>#{ERB::Util.html_escape backtrace}</pre>\n\n</body>\n</html>\n BODY\n end", "def parse_error(env, status_to_render)\n raise Common::Exceptions::BackendServiceException.new(\n \"VETEXT_#{status_to_render}\",\n {\n detail: parse_detail(env.body),\n code: \"VETEXT_#{env.status}\",\n source: \"#{env.method.upcase}: #{env.url.path}\"\n },\n env.status,\n env.body\n )\n end", "def magic_error(code_or_msg = nil, code_or_msg2 = nil,\n code: nil, msg: nil, generic: false, halt: true)\n [code_or_msg2, code_or_msg].each do |v|\n if v.is_a? Array\n msg = v\n elsif v.is_a? String\n msg = [v]\n elsif v.is_a? Integer\n code = v\n end\n end\n\n locals = Hash.new.tap do |h|\n unless code.nil?\n h[:code] = code unless generic\n h[:message] = DEFAULT_ERROR_MESSAGES[code]\n end\n h[:message] = msg unless msg.nil?\n h[:generic] = generic\n end\n\n if (code.nil? || generic)\n status 200\n else\n status code\n end\n\n page = render(:error, locals: locals).randomly { |p| switch_themes p }\n halt && !code.nil? ? halt(code, page) : page\n end", "def error_color(text)\r\n \"<font color=red>#{text}</font>\"\r\n end", "def render_exception(e)\n @message = e.message\n @backtrace = e.backtrace\n\n response_erb = ERB.new(File.read(\"../lib/templates/rescue.html.erb\"))\n response_text = response_erb.result(binding)\n response = ['500', {'Content-type' => 'text/html'}, [response_text]]\n end", "def response_errors(xml, errors)\n for path, status in errors\n xml.response do\n xml.href \"#{scheme}://#{host}:#{port}#{URI.escape(path)}\"\n xml.status \"#{http_version} #{status.status_line}\"\n end\n end\n end", "def render_error(*args)\n format_response(*respond_with('error', args))\n end", "def check_error(xml)\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise KeyError, 'invalid key'\n when 620 then\n raise KeyError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end", "def generate\n contents = []\n contents << template.content_tag(header_tag, header_message) unless options[:header_message] == false\n contents << template.content_tag(message_tag, message) unless options[:message] == false\n contents << template.content_tag(:ul, error_messages)\n \n template.content_tag(error_tag, contents.join.html_safe, html_options)\n end", "def error_message_panel\n $tracer.trace(__method__)\n return ToolTag.new(div.id(\"/ValidationSummary1$/\"), __method__)\n end", "def error_text(error_code)\n ERRORS[error_code.to_i]\n end", "def check_error(xml) #:nodoc:\n err = xml.elements['Error']\n raise Error, err.elements['Message'].text if err\n end", "def error(message, code)\n error_response = {\n message: message\n }\n render :json => error_response, :status => code\n end", "def render_health_xml\n render :xml => @results.values, :status => health_response_code\n end", "def render_400\n render file: \"#{Rails.root}/public/400.html\", layout: false, status: 400\n end", "def render_xml_output(status)\n builder do |xml|\n xml.instruct!\n xml.response do\n xml.status status\n end\n end\nend", "def handle_exception(exception)\n diagnosis = SData::Diagnosis::DiagnosisMapper.map(exception)\n\n status diagnosis.http_status_code || 500\n content_type 'application/xml'\n\n diagnosis.to_xml(:root)\n exception.to_s\n end", "def to_xml\n if has_errors?\n controller.render xml: resource.errors\n else\n controller.render xml: resource\n end\n end", "def render_error(err)\n json_response({ message: err }, :unprocessable_entity)\n end", "def render_error(status, msg)\n render json: {errors: [msg]}, status: status\n end", "def render_create_error\n render_error @resource\n end", "def error code=nil, message=nil\n if code\n error = Lux::Error.new code\n error.message = message if message\n raise error\n else\n Lux::Error::AutoRaise\n end\n end", "def render_soap_error(message, options = {})\n @namespace = NAMESPACE\n soap_error_response = render_to_string :template => 'wash_with_soap/error', :status => 500,\n :locals => { :error_message => message }\n\n if options[:ws_security] == \"encrypt\" || options[:ws_security] == \"sign\" || options[:ws_security] == \"sign_encrypt\"\n soap_error_response = ws_security_apply(soap_error_response, options)\n end\n\n render :xml => soap_error_response\n end", "def get_xml_error(xobj)\n\t\t\tbegin\n\t\t\t\txobj.at_xpath('//ann/warning').content\n\t\t\trescue NoMethodError\n\t\t\t\t\"unrecognized response body\"\n\t\t\tend\n\t\tend", "def quantity_error_message\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(div.id(\"/pnlQuantityError/\"), __method__, self)\n end", "def error(request, response)\n response['rack.rsi'] = '1'\n response['Cache-Control'] = 'max-age=10'\n # depth if set as a param will be string rather than integer\n # depth + 1 in line 36 should raise error on recursive call\n depth = request.params['depth'] || 1\n response.write(%{\n <%= rsi_include( \"/error?depth=#{depth+1}\", :raise_on_error ) %>\n <p>Hello World! #{depth}</p>\n }.gsub(/^\\s*/, \"\").strip)\n end", "def code\n @errorcode\n end", "def message\n @errormsg\n end", "def render_error(exception)\n Bugsnag.notify(exception)\n render template: 'errors/internal_server_error', status: :not_found\n end", "def rendering(snip)\n renderer_instance = renderer_for(snip).new(self)\n yield renderer_instance\n rescue Exception => e\n \"<pre>[Error rendering '#{snip.name}' - \\\"\" + \n e.message.gsub(\"<\", \"&lt;\").gsub(\">\", \"&gt;\") + \"\\\"]\\n\" + \n e.backtrace.join(\"\\n\").gsub(\"<\", \"&lt;\").gsub(\">\", \"&gt;\") + \"</pre>\"\n end", "def error_message; end", "def render_optional_error_file(status_code)\n status = interpret_status(status_code)\n path = \"#{Rails.public_path}/#{status.to_s[0,3]}.html\"\n if File.exist?(path)\n render :file => path, :status => status, :content_type => Mime::HTML\n else\n head status\n end\n end", "def error_render_method\n render :template => \"public/404\", :status => 404, :layout => false\n true\n end", "def error_message_on(object, field, options={})\n error = Array(resolve_object(object).errors[field]).first\n return SafeBuffer.new unless error\n options = { :tag => :span, :class => :error }.update(options)\n tag = options.delete(:tag)\n error = [options.delete(:prepend), error, options.delete(:append)].compact.join(\" \")\n content_tag(tag, error, options)\n end", "def error(x, status:200, type:\"request\", title:\"An error occurred\", message:\"\", args: [])\n x.res.status = status\n if App[:app_error][type.to_sym]\n App[:app_error][type.to_sym][:get][x, title, message, *args]\n else\n x << \"ERROR: #{title} - #{message}\"\n end\n end", "def error_msg(code=ErrorCodes::INTERNAL_SERVER_ERROR, detail=\"Unspecified error\", errors = nil, data = nil)\n @response[:errors] = {\n code: code[:code],\n detail: detail,\n errors: errors,\n data: data\n }\n end", "def error_html\n \"//div[@class='error']\"\n end", "def fetch_errors\n return '' unless authorized?\n xml = REXML::Document.new(load_content)\n\n return 'no-results' if xml.elements.to_a(\"groups/group\").size.zero?\n\n contents = ''\n xml.elements.each(\"groups/group\") do |group|\n message = group.elements[\"error-message\"].text.to_s.gsub(/</, '&lt;').gsub(/>/, '&gt;')\n most_recent = Time.parse(group.elements[\"most-recent-notice-at\"].text)\n rails_env = group.elements[\"rails-env\"].text\n project_id = group.elements[\"project-id\"].text\n project = projects[project_id]\n id = group.elements[\"id\"].text.to_i\n\n contents << %(\n <p onclick=\"widget.openURL('#{link_to_error(id)}');\" title=\"Go to Airbrake\" id=\"exception-#{id}\" class=\"exception\">\n <strong>#{project} [#{rails_env}]</strong>\n <span class=\"timeago\">\n <abbr title=\"#{most_recent.utc.strftime(\"%FT%T%z\")}\">#{most_recent.strftime(\"%%Y-%m-%d ~ %I:%M%p\")}</abbr>\n </span>\n <a>#{message}</a>\n </p>\n )\n end\n\n contents\n end", "def error; state == 'failed' ? @doc['error'] : nil; end", "def render_error_page\n # Create Warden proxy for devise integration\n proxy = Warden::Proxy.new({}, Warden::Manager.new({}))\n renderer = ApplicationController.renderer.new('warden' => proxy)\n renderer.render('errors/error')\n end", "def check_error(xml) #:nodoc:\n if error = Error.parse(xml, :single => true)\n raise Graticule::Error, error.message\n end\n end", "def error_internal\n respond_to do |format|\n format.html{render :layout => \"error\"}\n end\n end", "def render_optional_error_file(status_code)\n status = interpret_status(status_code)\n path = \"#{Rails.public_path}/#{status[0,3]}.html\"\n if File.exist?(path)\n render :file => path, :status => status\n else\n head status\n end\n end", "def to_s\n <<~ERROR\n ERROR [#{@code}]: #{@message}\n #{@errors.collect { |err| \"> #{err.code}: #{err.message}\" }.join \"\\n\"}\n ERROR\n end" ]
[ "0.7871357", "0.7031047", "0.6906747", "0.6870775", "0.6640371", "0.6596013", "0.65924335", "0.64549464", "0.64127886", "0.62870115", "0.62870115", "0.62383896", "0.62260437", "0.62205505", "0.6212974", "0.6210827", "0.61360675", "0.61259276", "0.6089541", "0.607284", "0.6054226", "0.60159016", "0.60079116", "0.60079116", "0.600259", "0.5997455", "0.5997212", "0.5996819", "0.5993506", "0.59732026", "0.59338045", "0.59317416", "0.5929134", "0.59235895", "0.5922012", "0.59207946", "0.5918932", "0.5892546", "0.5883304", "0.5883304", "0.5883304", "0.5883304", "0.5879857", "0.5862506", "0.5857302", "0.5856856", "0.5855935", "0.585103", "0.58486044", "0.58302337", "0.58225626", "0.5820298", "0.5816719", "0.58058286", "0.5802835", "0.5799588", "0.579805", "0.57620806", "0.57607794", "0.5756763", "0.5741749", "0.5739586", "0.5735621", "0.57337207", "0.5733063", "0.57299936", "0.57200336", "0.5719631", "0.5713029", "0.57126504", "0.5708826", "0.57082844", "0.5692688", "0.5681409", "0.56799364", "0.5675928", "0.56742334", "0.56727153", "0.5671035", "0.5670681", "0.5667538", "0.56584775", "0.56572825", "0.564867", "0.5646738", "0.5645204", "0.5633508", "0.56248224", "0.56217015", "0.56132054", "0.56066656", "0.56065106", "0.560468", "0.5603984", "0.56022006", "0.5599842", "0.5597539", "0.55922586", "0.55842334", "0.5583173" ]
0.6433133
8
get numeric ID, from possible name id
def get_assembly_and_node_id(context_params) response = info(context_params) unless response.ok? raise DtkError, "Unable to retrive node information, please try again." end return response.data(:assembly_id), response.data(:id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id\n name.gsub /-/, '_'\n end", "def name_to_id\n @name_to_id ||= build_hash('name', 'id')\n end", "def id\n name.gsub(':', '-')\n end", "def get_id(id)\n native_id = Integer(id.split(\":\")[-1])\n end", "def id_for(_name, _id=nil)\n n = \"#{@object_name}_#{_name}\"\n n += \"_#{_id}\" if _id\n end", "def identifier\n num\n end", "def get_id(model, name)\n\t\tid = 0\n\t\tmodel.each do |hash|\n\t\t\thash.each do |k, v|\n\t\t\t\tif v == name\n\t\t\t\t\tid = k.to_i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tid\n\tend", "def name_as_id\n self.name.downcase.gsub(/\\s/, '-')\n end", "def id\n @id || self.class.name.underscore.split('/').last #gsub('/', '_')\n end", "def id2name() end", "def id2name() end", "def actual_id\n args = params[:id].split('-')\n args[0]\n end", "def name_to_id(name)\n user = User.find_by_username(name)\n if user == nil\n return -1\n else\n user.id\n end\n end", "def numId\n id.to_s.slice(-9,9).hex.to_i\n end", "def name_to_id(model_handle, name, context = {})\n if context.empty?\n return name_to_id_default(model_handle, name)\n end\n name_to_object(model_handle, name, context).id\n end", "def fedora_id_to_numeric_id fedora_id\n /.*:([0-9]+)/.match(fedora_id)[1].to_i\n end", "def generate_identifier\n self.identifier ||= self.name.parameterize.underscore\n end", "def make_name_to_id\n build_hash('name', 'id')\n end", "def id\n \"#{kind}_#{@id}\"\n end", "def id\n \"#{kind}_#{@id}\"\n end", "def get_id(data)\n result = get_full_data(data)\n usrgrpid = nil\n result.each { |usr| usrgrpid = usr['usrgrpid'].to_i if usr['name'] == data[:name] }\n usrgrpid\n end", "def get_id(user_name)\n return get_value_of(user_name, :id)\n end", "def id\n (read_property 'Id') || name\n end", "def generate_id(str); end", "def id\n name && name.gsub(' ', '').downcase\n end", "def numid=(_); end", "def id_text\n sprintf(\"%03d\", $pokedex.national? ? @id : primary_data.id_bis)\n end", "def extract_id(str)\n str.to_s.scan(/\\d+/)\n end", "def id_number; end", "def fetch_id(char_name)\n char = Character.find_by_name(char_name)\n char.id\n end", "def get_id\n default_id = self.class.to_s.split('::').last\n default_id[0] = default_id[0].downcase\n return default_id\n end", "def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end", "def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end", "def make_id\n \"#{self.class.name.downcase}#{id}\"\n end", "def number_from_name(name)\r\n return nil unless name\r\n match = name.scan(/^(\\d+)/).first\r\n match ? match.first.to_i : nil\r\n end", "def getIdFromString(option)\n str = option.split(\" \")\n str[1].to_i\nend", "def identifier\n best_identifier\n end", "def get_oid(name, id)\n OIDPrefix + '.' + OIDMap[name].to_s + \".#{id}\"\n end", "def id_lookup(id)\n id = id.to_i\n if (id >= 128) && (id <= 255)\n id = \"oem_data_#{id}\"\n elsif DMI::ID_TO_DESCRIPTION.key?(id)\n id = DMI::ID_TO_DESCRIPTION[id]\n else\n Ohai::Log.debug(\"unrecognized header id; falling back to 'unknown'\")\n id = \"unknown_dmi_id_#{id}\"\n end\n rescue\n Ohai::Log.debug(\"failed to look up id #{id}, returning unchanged\")\n id\n end", "def numid; end", "def id_attribute_for(class_name)\n class_name = class_name.match(/([^:]+)$/)[1]\n class_name.gsub!(/([A-Z])([A-Z][a-z])/, '\\1_\\2')\n class_name.gsub!(/([a-z])([A-Z])/, '\\1_\\2')\n\n \"#{class_name.downcase}_id\"\n end", "def text_id\n \"#{name} (##{id})\"\n end", "def name\n # The name must be a string\n id.to_s\n end", "def format_id(id)\n /(\\d+)/.match(id)\n end", "def unique_id\n \"name-#{@language_id}-#{@name_id}\"\n end", "def name\n return text_get(0, id)\n end", "def id_of(name, obj)\n return false if obj.nil?\n return false if obj.empty?\n id = false\n\n if obj[\"name\"].match(/#{name}/i)\n return obj[\"id\"]\n else\n return false\n end if obj.has_key?(\"id\") if obj.is_a?(Hash)\n\n obj.each do |object|\n # Check exact\n id = object[\"id\"] if object[\"name\"].match(/#{name}/i) if object.is_a?(Hash)\n id = object.last[\"id\"] if object.last[\"name\"].match(/#{name}/i) if object.is_a?(Array)\n # Check with no spaces\n id = object[\"id\"] if object[\"name\"].delete(' ').match(/#{name}/i) if object.is_a?(Hash)\n id = object.last[\"id\"] if object.last[\"name\"].delete(' ').match(/#{name}/i) if object.is_a?(Array)\n end\n return id\n end", "def i18n_id\n name.split(\"::\").map{|c| c.underscore}.join(\".\")\n end", "def id\n @attributes[\"#{self.class.to_s.split('::').last.underscore.downcase}_id\".to_sym]\n end", "def unique_name(id)\n id.to_s\n end", "def basic_generate_id(str); end", "def value_to_ident(value)\n return nil if value.nil?\n if value.nil?\n return nil\n elsif value.kind_of?(Fixnum)\n the_id = value\n elsif value.respond_to?(:id)\n the_id = value.id\n else\n Kernel.raise \"Cannot search for invalid value #{value.inspect}\"\n end\n return index(the_id)\n end", "def generate_id()\n return nil unless @name and @represents\n @id ||= Digest::SHA1.hexdigest(@name + @represents)[0..5].force_encoding('utf-8').to_s\n end", "def lookup_info_id(info_name)\n\n # Hash of names and ids / key, value\n Info_names = {}\n infos = Info.all.to_a\n\n infos.each do |industry|\n info_names[info.name] = info.id\n end\n\n # return id number\n puts \"Info: #{info_names[info_name]} / #{info_name}\"\n return info_names[info_name]\n\n end", "def new_id\n dbm = self.class.dbm\n\n max = dbm.keys.map { |k| k.to_i }.max || 0\n id = max + 1\n\n dbm[id.to_s] ||= \"\"\n\n id.to_s\n end", "def identifier\n id || name || default_identifier\n end", "def charset_name2id(charset_name)\n #This is a stub, used for indexing\n end", "def nombre_comun_a_id_referencia(num_nombre)\n # El 9 inicial es apra identificarlo, despues se forza el ID a 6 digitos y el numero de nombre comun a 2 digitos\n \"1#{id.to_s.rjust(6,'0')}#{num_nombre.to_s.rjust(3,'0')}\".to_i\n end", "def obfuscate_id_default_spin\n alphabet = Array(\"a\"..\"z\")\n number = name.split(\"\").collect do |char|\n alphabet.index(char)\n end\n\n number.shift(12).join.to_i\n end", "def id\n basename.gsub('.', '-')\n end", "def section_name_to_id(name)\n return \"section-\" +\n name.strip.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/^-+|-+$/, '')\nend", "def num\n name\n end", "def name_to_val(name)\n name.sub(/sotu-(\\d\\d\\d\\d).*/,'\\1').to_i\nend", "def parse_id(fhir_formulary)\n\t\treturn fhir_formulary.id\n\tend", "def tourney_get_id(name)\n name = name.gsub(/[^\\w\\d\\s]/,\"\")\n Dir.glob(\"#{TOURNEY_DATA_DIR}/tourney**/tourneyinfo\") do |filename|\n File.open(\"#{filename}\", \"r\") do |f|\n tourney_name = f.read.split(\"\\n\")[0].split\n tourney_name.shift # remove the \"Tourney Name: \"\n tourney_name.shift\n tourney_name = tourney_name.join(\" \")\n if(name.downcase.eql?(tourney_name.downcase))\n\t\t\t\t# get the id off of the file name: exploits the fact that the file path is only/letters/tourney1111111111/tourneyinfo to get the numbers\n # I can feel my programming practices prof crying as I type.\n\t\t\t\tfields = filename.split('/')\n\t\t\t\tid = fields[fields.length - 2].split('y').pop.to_i\n\t\t\t\tputs \"id: #{id}\"\n\t\t\t\treturn id\n end\n end\n end\n return \"\"\nend", "def oid\n id(get_oid())\n end", "def id_from_record(record)\n f907 = record.find {|f| f.tag == \"907\"}\n f907.subfields.find {|s| s.code == \"a\"}.value\nend", "def make_id_to_name\n build_hash('id', 'name')\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end", "def index\n attribute_value(:id).split('_').last.to_i\n end", "def name\n @name ||= parse_name(id.name)\n end", "def id\n value[0]\n end", "def record_identifier(record)\n record.id\n end", "def name_to_id!\n @name_to_id = make_name_to_id\n self\n end", "def id_text3\n sprintf(\"%03d\", $pokedex.national? ? @id : primary_data.id_bis).to_pokemon_number\n end", "def get_id\n @id ||= 0\n @id += 1\n @id\n end", "def extract_id(dom)\n href_with_id = dom.search('.subtext .age a').map { |link| link['href']}.join\n href_with_id[/\\d+/].to_i\n end", "def get_id()\n return @doc_name\n end", "def extract_id(object)\n case object\n when ::Integer\n object\n when ::String\n object.split('/').last.to_i\n when URI, Addressable::URI\n object.path.split('/').last.to_i\n when Teamsupport::Identity\n object.ID\n end\n end", "def get_new_id(class_name)\n @data = get_all()\n # if array is empty return first id 0\n if @data[class_name].length == 0\n return 0\n end\n\n # go to last item of the array, get the id and sum +1\n return @data[class_name][-1][\"id\"] + 1\n end", "def id\n read_attr :id, :to_sym\n end", "def name_2_id( a_string ) \n return a_string.gsub(\"[\",\"_\").gsub(\"]\",\"\");\n end", "def id\n @data['id'].to_i\n end", "def id\n @data['id'].to_i\n end", "def get_new_id\n\t\t\n\t\tcount = 0 \t\t# Start at 0\n\n\t\twhile true\n\t\t\tcount += 1 # Increment\n\t\t\t# Break out of loop when ID found\n\t\t\tbreak if @templates[ count.to_s ].is_a? NilClass\n\t\tend\n\n\t\t# Raise error if out of range\n\t\traise RangeError, \"#{count} exceeds the planned range, may cause problems\" if count.to_s.length > 9\n\n\t\t# Return id in String form\n\t\tcount.to_s\n\n\tend", "def id\n \"#{controller.url}/#{name}\"[1..-1].gsub('/', '_')\n end", "def id\n name\n end", "def id\n name\n end", "def real_id(model_name, friendly_id)\n if friendly_id.to_s.to_i == 0\n obj = model_name.constantize.find(friendly_id)\n if obj\n return obj.id\n end\n end\n friendly_id\n end", "def id_for(obj)\n \"#{obj.class.name.underscore}-#{obj.id}\"\n end", "def identifier\n @identifiers[0]\n end", "def get_param_id(name)\r\r\n return DND::SUBS::PARAM_TABLE[name].to_i\r\r\n end", "def druid\n id.split(/:/).last\n end", "def id\n name\n end", "def id_for(field_name)\n if name = @form_args[:name]\n \"#{name}_#{field_name}\".downcase.gsub(/-/, '_')\n else\n \"form_#{field_name}\".downcase.gsub(/-/, '_')\n end\n end", "def id_to_name\n @id_to_name ||= build_hash('id', 'name')\n end", "def id\n '1234567890'\n end", "def sub_id() @tag.sub( /.*_/, '' ) end", "def sub_id() @tag.sub( /.*_/, '' ) end", "def id() end", "def get_id(name)\n @users.each do |user|\n return user[:id] if user[:name] == name\n end\n nil\n end" ]
[ "0.74094415", "0.7381823", "0.7337841", "0.72135144", "0.70787054", "0.70539343", "0.70280343", "0.7022979", "0.69923437", "0.6936814", "0.6936814", "0.69234073", "0.6914586", "0.68633854", "0.6834628", "0.68342084", "0.68308085", "0.68124014", "0.6797526", "0.6797526", "0.67607224", "0.67575806", "0.674243", "0.673928", "0.67129284", "0.6709254", "0.6693053", "0.66835034", "0.66815877", "0.6670463", "0.66505307", "0.66439754", "0.66439754", "0.6620176", "0.66195714", "0.6613562", "0.6612205", "0.66042817", "0.66037786", "0.65985394", "0.65936905", "0.6582768", "0.65533173", "0.6535607", "0.6533756", "0.6531281", "0.6523013", "0.6519967", "0.65157956", "0.65097535", "0.65047556", "0.6500974", "0.6497858", "0.64960957", "0.64820504", "0.6469718", "0.64602315", "0.64573944", "0.645244", "0.6446887", "0.64393145", "0.6418837", "0.6414841", "0.64127797", "0.64115626", "0.6407337", "0.6402254", "0.6395685", "0.6394435", "0.6387366", "0.6386987", "0.63862586", "0.63822037", "0.63781154", "0.63755643", "0.6372679", "0.6372291", "0.63715625", "0.6368872", "0.6361129", "0.63560575", "0.6348841", "0.634806", "0.634806", "0.633918", "0.63379854", "0.6334508", "0.6334508", "0.63343775", "0.6332685", "0.6332651", "0.63295025", "0.63259065", "0.63253003", "0.6325107", "0.6323086", "0.6322917", "0.6322307", "0.6322307", "0.6321015", "0.63194305" ]
0.0
-1
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
def lint(dir) files = dir.children.select(&:file?) no_junk?(files) return true if supported(files).empty? correctly_named?(dir) all_same_filetype?(files) expected_files?(files) sequential_files?(files) cover_art?(files) cover_art_looks_ok?(arty(files)) tags = all_tags(files) all_same_album?(tags) all_same_genre?(tags) all_same_year?(tags) all_same_artist?(tags) unless various_artists?(dir) rescue Aur::Exception::LintDirBadName err(dir, 'Invalid directory name') rescue Aur::Exception::LintDirBadFile => e err(dir, "Bad file(s)\n #{e}") rescue Aur::Exception::LintDirMixedFiles err(dir, 'Different file types') rescue Aur::Exception::LintDirBadFileCount => e err(dir, "Missing file(s) (#{e})") rescue Aur::Exception::LintDirUnsequencedFile => e err(dir, "Missing track #{e}") rescue Aur::Exception::LintDirCoverArtMissing err(dir, 'Missing cover art') rescue Aur::Exception::LintDirCoverArtUnwanted err(dir, 'Unwanted cover art') rescue Aur::Exception::LintDirInconsistentTags => e err(dir, "Inconsistent #{e} tag") rescue Aur::Exception::LintDirCoverArtTooBig, Aur::Exception::LintDirCoverArtTooSmall, Aur::Exception::LintDirCoverArtNotSquare => e err(dir, "Unsuitable image size: #{e}") rescue StandardError => e warn "Unhandled exception #{e} in #{dir}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def offences_by; end", "def strategy; end", "def used?; end", "def custom; end", "def custom; end", "def isolated; end", "def isolated; end", "def private_method\n end", "def suivre; end", "def intensifier; end", "def internal; end", "def spec; end", "def spec; end", "def operations; end", "def operations; end", "def initialize\n \n end", "def celebration; end", "def initialize\n\n end", "def initialize\n\n end", "def initialize\n \n end", "def missing; 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 ignores; 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 apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def extra; end", "def initialize\n\t\t\n\tend", "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 villian; end", "def internship_passed; end", "def overrides; end", "def anchored; end", "def initialize() end", "def same; end", "def ignore; end", "def formation; end", "def executor; end", "def executor; end", "def executor; end", "def missing?; end", "def apply\n end", "def weber; end", "def initialize\r\n\r\n end", "def who_we_are\r\n end", "def operation; end", "def initialize\n # nothing here for now\n end", "def identify; end", "def wrapper; end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def used\n raise NotImplementedError\n end", "def processor; end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def prepareForReuse; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end" ]
[ "0.76538837", "0.62887454", "0.62282014", "0.62282014", "0.61805004", "0.6156519", "0.6156519", "0.6156519", "0.6156519", "0.612837", "0.59572196", "0.5944528", "0.5892693", "0.5819787", "0.5819787", "0.5808322", "0.5808322", "0.58052987", "0.5795088", "0.57326925", "0.5687854", "0.56765187", "0.56765187", "0.56681097", "0.56681097", "0.5666472", "0.5664217", "0.5661484", "0.5661484", "0.565292", "0.564905", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.56440926", "0.5631964", "0.561223", "0.561223", "0.561223", "0.5603082", "0.56013376", "0.56013376", "0.55721384", "0.55687004", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55595726", "0.55561584", "0.5554702", "0.5553566", "0.5548372", "0.5537303", "0.5530531", "0.5523947", "0.5509951", "0.55079937", "0.55079937", "0.55079937", "0.55037254", "0.5498602", "0.5495862", "0.54939497", "0.54907876", "0.54850566", "0.5476925", "0.54745", "0.5472552", "0.5469456", "0.5469456", "0.5469456", "0.5469456", "0.5466271", "0.5465413", "0.54596597", "0.54596597", "0.54596597", "0.545392", "0.545392", "0.545392", "0.545392", "0.5444147", "0.5434436", "0.5434436", "0.5434436", "0.5434436", "0.5434436", "0.5434436" ]
0.0
-1
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
def err(dir, msg) msglen = msg.length + 6 warn(format("%-#{TW - msglen}<dir>s %<msg>s", dir: dir, msg: msg)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def used?; end", "def strategy; end", "def suivre; end", "def custom; end", "def custom; end", "def offences_by; end", "def isolated; end", "def isolated; end", "def intensifier; end", "def private_method\n end", "def operations; end", "def operations; end", "def internal; end", "def spec; end", "def spec; end", "def missing; end", "def celebration; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "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 who_we_are\r\n end", "def extra; end", "def internship_passed; end", "def villian; end", "def anchored; end", "def formation; end", "def ignores; end", "def initialize\n\n end", "def initialize\n\n end", "def weber; end", "def initialize\n \n end", "def initialize\n \n end", "def identify; end", "def same; end", "def missing?; end", "def operation; end", "def apply\n end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def processor; end", "def common\n \n end", "def executor; end", "def executor; end", "def executor; end", "def wrapper; end", "def initialize\n\t\t\n\tend", "def initialize() end", "def sitemaps; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def overrides; 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 terpene; end", "def checks; end", "def initialize\n super()\n end", "def appraisals; end", "def appraisals; end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def init; end", "def init; end", "def init; end" ]
[ "0.774036", "0.6475812", "0.6352224", "0.6352224", "0.6292137", "0.62793195", "0.62793195", "0.62793195", "0.62793195", "0.6274397", "0.6028631", "0.59914017", "0.5968494", "0.5968021", "0.5968021", "0.5939466", "0.5892397", "0.5892397", "0.5874267", "0.58390605", "0.58344615", "0.58344615", "0.5824806", "0.5792341", "0.5792341", "0.57739025", "0.5721649", "0.571883", "0.571883", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57144433", "0.57142574", "0.57109314", "0.57026875", "0.5701153", "0.5695153", "0.5695104", "0.5694082", "0.56911623", "0.56911623", "0.5684288", "0.5680014", "0.56486267", "0.5644375", "0.56434697", "0.5626104", "0.5618362", "0.56179744", "0.5607802", "0.5607802", "0.5607802", "0.5607802", "0.56060493", "0.56047577", "0.55961484", "0.55961484", "0.55961484", "0.5594328", "0.55934656", "0.559127", "0.5587816", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.55847275", "0.5584011", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.55816895", "0.557837", "0.55666834", "0.55562794", "0.5556036", "0.5556036", "0.5554961", "0.5554961", "0.5554961", "0.55522805", "0.55522805", "0.55522805" ]
0.0
-1
A "proper" album directory should be of the form 'artist_name.album_name', but these can have subdirectories. So, if we find content in an incorrectly named directory, we examine the parent, and return true if that looks okay.
def correctly_named?(dir, on_retry: false) name = dir.basename.to_s return true if name.match(/^[a-z0-9][a-z\-._0-9]+[a-z0-9]$/) && name.split('.').size == 2 && !name.start_with?('the_') return correctly_named?(dir.parent, on_retry: true) if on_retry == false raise Aur::Exception::LintDirBadName end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_directory_name?(directory_name, metadata_name)\n normalized = metadata_name.tr('/', '-').split('-').last\n normalized == directory_name\n end", "def parent_dir_link?(link)\n link[:href] == '../'\n end", "def root_directory?(path)\n File.directory?(path) &&\n File.expand_path(path) == File.expand_path(File.join(path, \"..\"))\nend", "def fully_qualified_dir_path?(path)\n path[0, 1] == '/'\n end", "def directory?() end", "def in_dir? dir\n self == dir or\n self.to_s.index(File.join(dir, '')) == 0\n end", "def in_directory?(directory)\n !!(fullpath =~ %r{^#{Regexp.escape(directory)}/})\n end", "def has_directory? name\n File.directory? path / name\n end", "def check_valid_file filename\n #check if it has parents\n if filename =~ /(\\.){2}/\n return false\n end\n #Check root folder\n if !(filename =~ /^#{@dirname}/o)\n return false\n end\n\n File.exist?(filename)\n end", "def within?(dir, root)\n expanded_root = File.expand_path(dir, root)\n File.expand_path(@parent, root) == expanded_root ||\n File.expand_path(@path, root).include?(expanded_root)\n end", "def valid_dir?(path)\n case path\n when %r|/no_repo/.hg$|, /\\.bad$/, %r|/\\w+_bad_path/path/\\w+$|\n return false\n end\n return true\n end", "def directory?(path)\n ::File.directory?(prefixed(path))\n end", "def directory?(name)\n File.directory?(path(name))\n end", "def directory_exists?(directory)\n return if File.directory?(File.join(Dir.pwd, directory))\n\n raise \"#{directory} does not exist in parent directory #{Dir.pwd}. Check the file placement and try again.\"\nend", "def validate_directory_structure\n return false unless File.exists? @root\n Find.find(@root) do |path|\n stat = File::Stat.new path\n return false unless stat.uid == OWNER and stat.gid == GROUP\n if File.directory? path\n return false unless stat.mode == DIRMODE\n else\n return false unless stat.mode == FILEMODE\n end\n end\n true\n end", "def entry_directory?(entry)\n File.directory?(build_directory_location(entry)) \n end", "def directory?(path)\n eval(DIRECTORY_CHECK, binding, __FILE__, DIRECTORY_CHECK_LINE)\n nil\nend", "def glob_is_directory?(glob); end", "def directory?(dir)\n current_dir = pwd\n begin\n chdir(dir)\n return true\n rescue\n return false\n ensure\n chdir(current_dir) ## Go back former dir\n end\n end", "def folder_exists?\n empty_name?\n\n if File.exists?(\"#{LOCAL_PATH}/#{@name}\") || File.exists?(\"#{REMOTE_PATH}/#{@name}.git\")\n if File.exists?(\"#{LOCAL_PATH}/#{@name}\")\n print \"Directory `#{@name}` exists in #{LOCAL_PATH}. Pass a new name: \"\n elsif File.exists?(\"#{REMOTE_PATH}/#{@name}.git\")\n print \"Directory `#{@name}.git` exists in #{REMOTE_PATH}. Pass a new name: \"\n end\n\n @name = gets.chomp\n folder_exists?\n end\n\n false\n end", "def directory?(path)\n return File.directory? path\n rescue SystemCallError => e\n if Windows\n dir = ''\n cmd = \"if exist \\\"#{path}/*\\\" echo dir\"\n IO.popen(cmd) { |io| dir = io.read } # dir = \"dir\\n\" if target is a directory\n\n return !dir.empty?\n else\n # JRUBY's' File.directory? has a bug for checking folders with chinese(unicode) characters.\n # Do not raise exception if 'Unknown Error (20047)'.In our case\n # this means a folder already exists (I hope).\n raise unless e.message.match(/Unknown Error \\(20047\\)/)\n end\n end", "def folder_exists_in_audio?(folder_name)\n `ls audio/ | grep #{folder_name}`.chomp.length > 0\n end", "def valid?\n prefix = File.expand_path(root_path)\n prefix == File.expand_path(@file)[0...prefix.size]\n end", "def empty_directory?\n directory? && Dir.entries(to_s).reject { |entry| entry == '.' || entry == '..' }.empty?\n end", "def validate_existence(path, prefix = '')\n pn = Pathname.new(path)\n git = pn + '.git'\n return Issue.new(\"#{prefix}#{pn} is not an absolute path. It must be fully qualified, not relative\") unless pn.absolute?\n return Issue.new(\"#{prefix}#{pn} is not a directory. Has it been cloned?\") unless pn.directory?\n return Issue.new(\"#{prefix}#{pn} is not readable. Are permissions correct?\") unless pn.readable?\n return Issue.new(\"#{prefix}#{git} does not exist. Has #{git.dirname} been cloned properly?\") unless git.directory?\n end", "def directory?(path)\n raise NotImplemented\n end", "def directory_has_children? dir\n (Dir.entries(dir) - ['.', '..']).size > 0\n end", "def directory?(path)\n without_extension?(path) && exists?(path)\n end", "def is_directory?\n files.count > 1\n end", "def directory?(path)\n ensure_relative_path! :directory?, path\n chdir path\n chdir '..'\n true\n rescue\n false\n end", "def validate_directory\n return if root?\n\n parent = parent_directory\n if parent.project != project\n errors.add(:directory_id, \"must be a directory in the same project.\")\n elsif not parent.is_directory\n errors.add(:directory_id, \"must be a directory.\")\n end\n end", "def valid_search_path?(path)\n if File.directory?(path) and Pathname.new(path).absolute?\n return true\n elsif path.match %r[^file:/]\n return true\n end\n\n return false\n end", "def exist?\n File.directory? @full_path\n end", "def directory_exists?(path)\n end", "def directory?(*args)\n File.directory?(*args)\n end", "def falls_in_test_dir?\n %w[spec specs test tests].any? { |dir| File.expand_path(@file_directory).start_with?(\"#{root_dir}/#{dir}\") }\n end", "def local_dir_exists?(full_path)\n File.directory?(full_path)\nend", "def relative?(path)\n while r = chop_basename(path.to_s)\n path, _ = r\n end\n path == ''\n end", "def directory?\n !file?\n end", "def directory?(path)\n GLib.g_file_test(path, GLib::GFileTest::G_FILE_TEST_IS_DIR)\n end", "def strict_file_exists?(path)\n directory = `dirname #{path}`.chomp\n name = `basename #{path}`.chomp\n !`find \"#{directory}\" -name \"#{name}\"`.empty?\n end", "def malformed?\n abs_seq = File.expand_path(@sequential_dir)\n abs_mon = File.expand_path(@monolithic_dir)\n !(File.exist?(abs_seq) && File.exist?(abs_mon))\n end", "def folder?\n children.any?\n end", "def check_folder_contents(query)\n if (system(\"[ -d #{query} ]\"))\n puts(\"Error in current directory: #{query} already exists.\")\n false\n else\n true\n end\n end", "def jobdir?(path)\n jobdir_name?(path.basename.to_s) && path.directory?\n end", "def validnn?()\n return dir_exists?(\"/\") ? true : false\n end", "def is_directory?(path)\n end", "def raw_gitdir?\n\t\t\twith_dir do\n\t\t\t\treturn DR::Bool.to_bool(%x/git rev-parse --is-inside-git-dir/)\n\t\t\tend\n\t\tend", "def empty_dir?(path)\n Dir.foreach(path) {|f|\n return false if f != '.' and f != '..'\n }\n return true\nend", "def directory?(path)\n File.directory?(path_of(path))\n end", "def directory?\n FileTest.directory?(to_s)\n end", "def directory?\n repos.stat(fs_path, revision).directory?\n end", "def dir_exists?(name)\n # Does it exist?\n end", "def checkDir(s)\n gracefulExit(\"#{s} is not a valid directory.\") if !File.directory?(s || \"\")\n if s.include? \"\\\\\" then\n s << \"\\\\\" unless s[s.length-1] == \"\\\\\" #we are using windows\n else\n s << \"/\" unless s[s.length-1] == \"/\" #we are using linux\n end\n debugLog(\"input directory #{s} is OK\")\n s\nend", "def find_folder(parent, name)\n # Check that a folder exists. Also check for \"close matches\" on the name.\n # If a match is found, return the path.\n path = nil\n likely_names = name_variations(name)\n likely_names.each do |n|\n path = \"#{parent}/#{n}\"\n puts \"find_folder(#{name}): trying \\'#{path}\\'\" if @opts[:debug]\n break if Pathname.new(path).directory?\n path = nil\n end\n puts \"find_folder(#{name}): returning path of \\'#{path}\\'\" if @opts[:debug]\n return path\nend", "def directory?(path)\n\t\t@connection.directory?(path)\n\tend", "def directory?(f)\n File.directory? f\n end", "def resolve_as_directory name\n [test_dir + name, context.root + name].detect { |dir|\n dir.directory? and handle? dir\n }\n end", "def exists?\n validate_directory_structure\n end", "def directory?\n return @directory unless @directory.nil?\n @directory = File.directory? absolute_path\n end", "def accessing_outside_parent(path)\n base_path = Pathname.new(\"#{__dir__}/../ECOLE/ADMIN/admin\")\n pn = Pathname.new(path)\n return false if base_path.expand_path == pn.expand_path\n return false if pn.expand_path.to_s.start_with?(base_path.expand_path.to_s)\n\n true\n end", "def valid?\n\t\tFile.directory? dir\n\tend", "def valid?\n\t\tFile.directory? dir\n\tend", "def directory?(path)\n # :nocov:\n false\n # :nocov:\n end", "def accessing_outside_parent(path)\n base_path = Pathname.new(\"#{__dir__}/../ECOLE\")\n pn = Pathname.new(path)\n return false if base_path.expand_path == pn.expand_path\n return false if pn.expand_path.to_s.start_with?(base_path.expand_path.to_s)\n\n true\n end", "def eponymous_directory?\n if !path.end_with?(\"/#{@app.config[:index_file]}\") && destination_path.end_with?(\"/#{@app.config[:index_file]}\")\n return true\n end\n\n @app.files.by_type(:source).watchers.any? do |source|\n (source.directory + Pathname(eponymous_directory_path)).directory?\n end\n end", "def dir?(path)\n begin\n ftype(path) == 'directory'\n rescue\n false\n end\n end", "def exists?( path )\n # directory\n if File.directory?(path)\n # if this cd's then it exists, if it fails, should return false\n connection.chdir( path )\n else\n connection.nlst(File.dirname(path)).include?( File.basename(path) )\n end\n end", "def is_file_in_dir(file, dir)\n dir_ = (dir == '/' ? dir : dir.chomp('/'))\n file_ = (file == '/' ? file : file.chomp('/'))\n\n while file_ != '.' and file_ != '/' and file_ != dir_\n file_ = File.dirname(file_)\n end\n\n return (file_ == dir) ? true : false\n end", "def is_directory?( path )\n path = File.expand_path( path )\n File.directory?( path )\nend", "def relative?\n path = @path\n while r = chop_basename(path)\n path, basename = r\n end\n path == ''\n end", "def verify(path)\r\n return false if Env.check_directories? and not File.directory?(path)\r\n return true\r\n end", "def is_subpage_of?(fullpath, parent_fullpath)\n return false if %w(index 404).include?(fullpath)\n\n if parent_fullpath == 'index' && fullpath.split('/').size == 1\n return true\n end\n\n File.dirname(fullpath.dasherize) == parent_fullpath.dasherize\n end", "def is_directory?(path)\n path_exist(path) and (! exist? path)\n end", "def dir_exists?(path)\n begin\n @meta_data = @client.stat(path)\n if (@meta_data[\"type\"] == \"DIRECTORY\")\n return true\n else\n return false\n end\n rescue\n return false\n end \n end", "def exists?(name)\r\n \t@directory.exists?(name)\r\n end", "def glob_is_directory? glob\n File.directory?(glob) || File.directory?(glob_to_directory(glob))\n end", "def accessing_parent_of_ecole(current_dir_name, path)\n return true if current_dir_name == 'ECOLE' && path == '..'\n\n false\n end", "def file_inside_root?(full_path)\n full_path = File.expand_path full_path\n if full_path.match Regexp.new('^' + Regexp.escape(root_path))\n true\n else\n false\n end\n end", "def exist?(dir)\n return true if !nlst(dir).empty? ## File or not empty directory\n ## Check if a empty directory\n directory?(dir)\n end", "def is_empty_directory?(dir = nil)\n dir ||= Dir.pwd\n dir = File.expand_path(dir)\n File.directory?(dir) and (Dir.entries(dir).size == 2)\n end", "def valid_directory?\n File.directory?(output_directory_path)\n end", "def parent_of?(folder)\n @location.parent_of?(folder.location)\n end", "def directory?(path)\n if session.type == 'meterpreter'\n stat = session.fs.file.stat(path) rescue nil\n return false unless stat\n return stat.directory?\n else\n if session.platform == 'windows'\n f = cmd_exec(\"cmd.exe /C IF exist \\\"#{path}\\\\*\\\" ( echo true )\")\n else\n f = session.shell_command_token(\"test -d \\\"#{path}\\\" && echo true\")\n end\n return false if f.nil? || f.empty?\n return false unless f =~ /true/\n true\n end\n end", "def directory?\n raise NotLoadedError.new(:metadata) unless metadata_loaded?\n self.is_dir\n end", "def root?(path)\n \n root_objects = [\"gemfile\", \"procfile\", \"readme\"]\n current_objects = Dir[path + \"/*\"].map do |file|\n File.basename(file).downcase\n end\n dir = \"\"\n current_objects.each do |co|\n dir = (root_objects.include?(co) == true)? \"ROOT\" : \"NOT ROOT\"\n break if dir == \"ROOT\"\n end\n return true if dir == \"ROOT\"\n return false if dir == \"NOT ROOT\"\n \n end", "def ancestor_exist?\n File.exist? @ancestor_path\n end", "def is_dir?(path)\n File.directory? path\n end", "def invalid_directories?(path_collection)\n invalid_paths = false\n\n return invalid_paths if path_collection.nil? || path_collection.empty?\n\n paths = on_windows? ? path_collection.split(';') : path_collection.split(':')\n paths.each do |path|\n invalid_paths = true unless File.directory?(path) || path.empty?\n end\n\n invalid_paths\n end", "def has_directory?(path)\n @data[:directories].has_key? path.to_sym\n end", "def directory?\n @directory\n end", "def dir? ; directory? ? self : nil ; end", "def directory_index?\n path.include?(@app.config[:index_file]) || path =~ /\\/$/ || eponymous_directory?\n end", "def resolve_as_directory name\n [test_dir + name, context.root + name].detect { |dir| handle?(dir) }\n end", "def find_path_validation\n\t\troot_storage_path = Rails.root.join 'public', 'musics', '000', '000'\n\t\tlatest_path = root_storage_path.children.sort.last\n\t\tif Dir.entries(latest_path).last == self.audio_file_name\n\t\t\ttrue\n\t\telse\n\t\t\tself.destroy\n\t\t\tfalse\n\t\tend\n\tend", "def directory?\n case type\n when T_DIRECTORY then true\n when T_UNKNOWN then nil\n else false\n end\n end", "def accessing_parent_of_admin(current_dir_name, path)\n return true if current_dir_name == 'admin' && path == '..'\n\n false\n end", "def end_of_path?(dir, root = nil)\n dir.nil? || dir.empty? || dir == '.' || dir == root\n end", "def safeIsDirectory?(f)\n ret = false\n Dir.chdir(f) { ret = true } rescue nil\n return ret\nend", "def object_has_hierarchy?\n filepaths.any?(/\\/+/)\n end" ]
[ "0.6723298", "0.6496294", "0.63781554", "0.6343503", "0.63172144", "0.6275673", "0.6244171", "0.62229717", "0.62215686", "0.6197287", "0.6187698", "0.617581", "0.6169126", "0.61688125", "0.6106594", "0.60880655", "0.6076277", "0.60554814", "0.60340625", "0.60251456", "0.60104555", "0.59752584", "0.59703827", "0.5961037", "0.59452546", "0.59412163", "0.5918103", "0.5902745", "0.58928365", "0.58870596", "0.5881205", "0.58722425", "0.5860336", "0.5848952", "0.5834212", "0.5832478", "0.58216286", "0.5820714", "0.5815572", "0.580316", "0.57871085", "0.57697296", "0.5765309", "0.5757521", "0.5755475", "0.5754051", "0.575153", "0.5749917", "0.574504", "0.5740913", "0.5734799", "0.57308996", "0.57281095", "0.57155", "0.57066214", "0.56901217", "0.56832725", "0.5681779", "0.5666227", "0.56627125", "0.5661835", "0.5659322", "0.5659322", "0.5652235", "0.5646873", "0.5644069", "0.5632053", "0.5626194", "0.5617352", "0.56043094", "0.56030977", "0.55951315", "0.5595016", "0.55916953", "0.55915827", "0.558706", "0.55747026", "0.5574594", "0.5574173", "0.5572826", "0.5572316", "0.55654275", "0.5560858", "0.555209", "0.55511886", "0.55510813", "0.55503255", "0.55473715", "0.5538132", "0.55373055", "0.55297416", "0.5529039", "0.5520335", "0.5510654", "0.5510024", "0.5497511", "0.5497056", "0.54928386", "0.5491065", "0.5488186" ]
0.62603676
6
There should only be audio files and possibly cover art, and possibly a directory or two.
def no_junk?(files) uns = files - supported(files) uns.reject! { |f| f.basename.to_s == 'front.jpg' } return true if uns.empty? || uns.all?(&:directory?) raise Aur::Exception::LintDirBadFile, uns.sort.join("\n ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cover_art?(files)\n case files.first.extname\n when '.flac'\n raise Aur::Exception::LintDirCoverArtMissing unless cover_in(files)\n when '.mp3'\n raise Aur::Exception::LintDirCoverArtUnwanted if cover_in(files)\n end\n\n true\n end", "def audio?\n filename =~ /^audio/\n end", "def is_audio_type?\n file_content_type =~ /\\Aaudio\\/.*\\Z/\n end", "def is_audio?\n result = false\n if !mime_type.blank?\n splits = mime_type.split('/')\n if splits[0] == AUDIO\n result = true\n end\n end\n \n result\nend", "def audio?\n not audio_formats.empty?\n end", "def accepted_mimes\n case self.type\n when'Recording'\n '.wav,.mp3'\n when 'Document'\n '.pdf'\n when 'Image'\n '.jpeg,.jpg,.gif,.bmp,.png'\n else\n ''\n end\n end", "def audios_test\n end", "def extension_whitelist\n %w[mp3]\n end", "def is_audio(str)\n str.match(/\\A\\w*.(mp3|flac|alac|aac)\\Z/) != nil\nend", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "def is_mp3?\n if filename != nil\n filename.ends_with?('.mp3')\n else\n false\n end\nend", "def extension_whitelist\n %w(mp4 mp3 jpg jpeg gif png pdf docx)\n end", "def folder_exists_in_audio?(folder_name)\n `ls audio/ | grep #{folder_name}`.chomp.length > 0\n end", "def audio_without_closed_captions?\n audio? && closed_captions.blank?\n end", "def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end", "def audio_source_is_provided\n if self.external_url.blank? &&\n self.mp3.file.nil? &&\n self.enco_number.blank? &&\n self.enco_date.blank?\n self.errors.add(:base,\n \"Audio must have a source (upload, enco, or URL)\")\n end\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def audio_files\n @audio_files ||= path.join(\"data\").each_child.select { |file| [\".wav\", \".mp3\"].include? file.extname }.map { |file| IngestableAudioFile.new(path: file) }\n end", "def contains_audio?\n result = false\n sample_attachments.map{|sa| result = true if sa.is_audio?}\n result\n end", "def all_formats_encoded?\n self.webm_file.path && self.mp4_file.path && self.ogg_file.path ? true : false\n end", "def audio?\n if mime_type == 'application/mxf'\n !ffprobe.codec_type.any? {|type| type == 'video'}\n else\n super\n end\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def audio?\n #or @volume == 0\n if @mute or @type == \"image\"\n #puts \"no audio\"\n return false\n else\n #puts \"has audio\"\n return true\n end\n end", "def validate_header_file_audio\n self.validate_header_file(10, ['mp3', 'ogg', 'wav'], 'errors.messages.audio_too_large')\n end", "def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend", "def music_file(file)\n ext_list = $config[\"music_file\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name = \"\"\n\n $config['music_file']['regex'].each do |pattern|\n if file =~ /.*#{pattern}#{ext}/i\n name = $1 if $1\n return false if name =~ /^sample/i\n return true\n end\n end\n return false\nend", "def all_same_filetype?(files)\n return true if supported(files).map(&:extname).uniq.size <= 1\n\n raise Aur::Exception::LintDirMixedFiles\n end", "def audio?\n !!( content_type =~ Transit.config.audio_regexp )\n end", "def ignored_file?(path); end", "def files # loads all the mp3 files in the path directory / normalizes the filename to just the mp3 filename with no path\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") } # then using the .collect method and gsub to just return the filename with out path\n end", "def extension_white_list\n %w(mp3 wav)\n end", "def audio; end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end", "def check_and_print_media_file_names()\n is_success = true\n if @options.media_file_names.size > 0 then\n @options.media_file_names.each.with_index(1) do |fname, i|\n @renderer.print(\"Media[#{i}]: #{fname}\")\n if FileTest.exist?(fname) then\n @renderer.print(\"\\n\")\n else\n @renderer.print(\": does not exist.\\n\")\n is_success = false\n end\n end\n end\n return is_success\n end", "def is_file?\n !file_type.empty?\n end", "def extension_white_list\n %w(mp3 ogg flac mpc wav aiff mp4 m4a m4b asf)\n end", "def check_file_type\n if self.is_image?\n {\n :thumb => \"200x200>\",\n :medium => \"500x500>\"\n }\n elsif self.is_pdf?\n {\n :thumb => [\"200x200>\", :png],\n :medium => [\"500x500>\", :png]\n }\n\n elsif self.is_video?\n {\n :thumb => {\n :geometry => \"200x200>\",\n :format => 'jpg',\n :time => 0\n },\n :medium => {\n :geometry => \"500x500>\",\n :format => 'jpg',\n :time => 0\n }\n }\n elsif self.is_audio?\n {\n :audio => {\n :format => \"mp3\"\n }\n }\n else\n {}\n end\n end", "def handle_music(music)\n return false if $config['music_file']['process'] != true\n log(\"handle_music -> do something with the music file #{music.file}\")\n ap $config['music_file']['storage'] if $opt[\"debug\"]\nend", "def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\n end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def supported_format?\n !(@file_set.mime_type & self.class.supported_formats).empty? || preservation_file&.original_filename&.first&.downcase&.include?(\".wav\")\n end", "def process_media(options={})\n Dir[\"media/*\"].each do |media_dir|\n next unless File.directory?(media_dir) && !(media_dir =~ /^\\./)\n process_media_directory media_dir, options\n end\n end", "def get_non_flac_paths(source_path)\n non_flac_file_paths = Find.find(source_path).reject {|f| f.end_with?(\".flac\")}\n non_flac_file_paths.reject! {|e| !File.file?(e) }\n return non_flac_file_paths\nend", "def audio_assets(authored_only = false)\n assets = segments.collect { |e| e.audio_asset }\n authored_only ? assets.select { |a| a.authored? } : assets\n end", "def acceptable?(media_type)\n !matches(media_type).empty?\n end", "def files\n # Dir.glob(\"*.mp3\") #this grabs mp3s from path\n Dir.chdir(@path) do \n @mp3s = Dir.glob(\"*.mp3\") \n end\n end", "def open_narration(slide_no)\n if @type == 'm4a'\n @files.extract(\"ppt/media/media#{slide_no}.m4a\", \"#{Rails.root}/public/audios/#{$filename}media#{slide_no}.m4a\") rescue\n $filename+'media'+slide_no.to_s+'.m4a'\n end\n if @type == 'wav'\n\n @files.extract(\"ppt/media/media#{slide_no}.wav\", \"#{Rails.root}/public/audios/#{$filename}media#{slide_no}.wav\") rescue\n $filename+'media'+slide_no.to_s+'.wav'\n\n end\n end", "def check_file_type\n if image_type? || gif_type?\n {\n thumb: '200x200>',\n medium: '500x500>'\n }\n elsif video_type?\n {\n thumb: { geometry: '200x200>' , format: 'jpg', frame_index: 2 },\n medium: { geometry: '500x500>' , format: 'jpg', frame_index: 2 }\n }\n elsif pdf_type?\n {\n thumb: ['200x200>', :png],\n medium: ['500x500>', :png]\n }\n else\n {}\n end\n end", "def process_file(src)\n media = \"\"\n # files first\n get_files(src).each do |file|\n next if file =~ /\\/\\._/\n \n # first we check if the file is a tv series\n episode_status, episode_name, episode_season, episode_episode = tv_file(file) if $config[\"series\"][\"process\"] == true\n if episode_status == true\n episode = Episode.new file\n if episode.is_ep?\n episode.status = handle_series episode \n media = episode.class.to_s\n end\n end\n \n # second we check if the file is music\n music_status = music_file(file) if $config[\"music_file\"][\"process\"] == true\n if music_status == true\n music = Music.new file\n if music.is_music?\n music.status = handle_music music \n media = music.class.to_s\n end\n end\n \n # finally we can handle rar's\n handle_rar(file) if file =~ /\\.rar$/ and file !~ /part\\d+\\.rar$/\n handle_rar(file) if file =~ /part01\\.rar$/\n end # get_files\n media\nend", "def cover_in(files)\n fnames = files.map { |f| f.basename.to_s }\n fnames.include?('front.jpg')\n end", "def audio?\n @descriptive_detail.audio?\n end", "def file_type; 'directory' end", "def mp3?\n File.extname(@path).downcase.eql?('.mp3')\n end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end", "def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\n end", "def single?(file)\n file !~ /\\*/\n end", "def skip_file_other_than_image\n #%w(image/gif image/jpeg image/bmp image/png image/pjpeg).include?(uploaded_content_type)\n uploaded_content_type=~/image/\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect do\n |file| file.gsub(\"#{path}/\",\"\")\n end\n end", "def check_file_type\n if self.is_pdf?\n {\n :square_thumb => ['200x200#', :png],\n :annotation_thumb => ['300x200#', :png],\n :medium => ['500x500>', :png]\n }\n\n elsif self.is_video?\n {\n :square_thumb => { \n :geometry => '200x200!',\n :format => 'jpg',\n :time => 1\n }, \n :annotation_thumb => {\n :geometry => '300x200!',\n :format => 'jpg',\n :time => 1\n },\n :medium => { \n :geometry => '500x500>',\n :format => 'jpg',\n :time => 1\n },\n :transcoded_video => {\n :geometry => '300x200!',\n :format => 'mp4'\n }\n }\n elsif self.is_audio?\n {\n :audio => {\n :format => 'mp3'\n }\n }\n elsif self.is_image?\n {\n :square_thumb => '200x200#', \n :annotation_thumb => '300x200#',\n :medium => '500x500>'\n }\n else\n {}\n end\n end", "def path_to_audio(source, options = T.unsafe(nil)); end", "def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end", "def absolute_non_audio_file_paths\n @absolute_non_audio_file_paths ||= absolute_file_paths.reject { |p| audio_files.map(&:path).include?(p) }\n end", "def path_is_unique\n return true if self.mp3.file.blank?\n\n # Guess what the audio path will be before it's actually saved there.\n # This is predictable for uploaded audio.\n # This could potentially fail if someone was uploading audio at exactly\n # midnight and some audio already existed for the next day.\n path = File.join(\n AUDIO_PATH_ROOT,\n self.store_dir,\n self.filename\n )\n\n if File.exist?(path)\n self.errors.add(:mp3, \"A file with that name already exists; \" \\\n \"please rename your local audio file and try again. \" \\\n \"If you are trying to replace the audio file, first delete the \" \\\n \"old audio.\")\n end\n end", "def parse_args(*args)\n if args.size == 0\n args = [File.expand_path('.')]\n end\n\n @files = []\n args.each do |file|\n next unless File.exists?(file)\n file = File.expand_path(file)\n\n # If target is a dir, we add all music files in this dir\n if File.directory?(file)\n @files += Dir.glob(File.join(file, '**', '*.{mp3,ogg}')).map{|i| File.expand_path(i)}.sort\n else\n @files << file\n end\n end\n end", "def has_audios?\n audios[I18n.locale.to_sym].length + attached_audios[I18n.locale.to_sym].length > 0\n end", "def glob_mp3_files_from_filespec(filespec)\n files = Dir[filespec]\n files.reject! { |fn| File.directory?(fn) }\n files.reject! { |fn| !(can_parse_id3?(fn)) } \n return files\nend", "def glob_is_directory?(glob); end", "def audio_formats\n @descriptive_detail.audio_formats\n end", "def fq_bundle_sample_prompt\n \"public/upload/audio/\" + bundle_resouce_file_name + \".mp3\"\n end", "def audio_path(source, options = T.unsafe(nil)); end", "def no_thumbnail_extensions\n [\".xml\", \".pdf\"]\n end", "def check_title\n if title.to_s == '' && audio_file.present?\n str = File.basename(audio_file_url).gsub(/[_]/, ' ') \n self.title = str.gsub(/[.mp3]/, '')\n self.save\n end\n end", "def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend", "def allows_title?\n case kind\n when COVER, IMAGE1, AUDIO, VIDEO1, TITLE, TEXT then true\n else false\n end\n end", "def allows_text?\n case kind\n when TEXT, IMAGE1, AUDIO, VIDEO1 then true\n else false\n end\n end", "def files; end", "def files; end", "def files; end", "def files; end", "def files; end", "def files; end", "def files\n filename = Dir.glob(\"#{path}/*.mp3\")\n filename = filename.collect{|a_string| a_string.sub(\"#{path}/\", \"\")}\n end", "def applicable_files; end", "def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\n end", "def wp_get_audio_extensions\n # Filters the list of supported audio formats.\n apply_filters('wp_audio_extensions', ['mp3', 'ogg', 'flac', 'm4a', 'wav'])\n end", "def lint(dir)\n files = dir.children.select(&:file?)\n no_junk?(files)\n return true if supported(files).empty?\n\n correctly_named?(dir)\n all_same_filetype?(files)\n expected_files?(files)\n sequential_files?(files)\n cover_art?(files)\n cover_art_looks_ok?(arty(files))\n tags = all_tags(files)\n all_same_album?(tags)\n all_same_genre?(tags)\n all_same_year?(tags)\n all_same_artist?(tags) unless various_artists?(dir)\n rescue Aur::Exception::LintDirBadName\n err(dir, 'Invalid directory name')\n rescue Aur::Exception::LintDirBadFile => e\n err(dir, \"Bad file(s)\\n #{e}\")\n rescue Aur::Exception::LintDirMixedFiles\n err(dir, 'Different file types')\n rescue Aur::Exception::LintDirBadFileCount => e\n err(dir, \"Missing file(s) (#{e})\")\n rescue Aur::Exception::LintDirUnsequencedFile => e\n err(dir, \"Missing track #{e}\")\n rescue Aur::Exception::LintDirCoverArtMissing\n err(dir, 'Missing cover art')\n rescue Aur::Exception::LintDirCoverArtUnwanted\n err(dir, 'Unwanted cover art')\n rescue Aur::Exception::LintDirInconsistentTags => e\n err(dir, \"Inconsistent #{e} tag\")\n rescue Aur::Exception::LintDirCoverArtTooBig,\n Aur::Exception::LintDirCoverArtTooSmall,\n Aur::Exception::LintDirCoverArtNotSquare => e\n err(dir, \"Unsuitable image size: #{e}\")\n rescue StandardError => e\n warn \"Unhandled exception #{e} in #{dir}\"\n end", "def audio?\n codec_type == 'audio'\n end", "def not_image?(file)\n !file.content_type.include? 'image'\n end", "def audio?\n self.sti_type == AUDIO_TYPE\n end", "def testUselessProcessesSourceFiles\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'VolCorrection',\n :Factor => '2db'\n },\n {\n :Name => 'VolCorrection',\n :Factor => '-2db'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n assert Dir.glob('05_Mix/*.wav').empty?\n assert_wave_lnk 'Empty', '05_Mix/Final/Final.wav'\n end\n end", "def extension_whitelist\n %w(jpg jpeg gif png tif tiff avi m4v mov mp4 mpg mpeg mpeg wmv qt)\n end", "def check_file_type\n if is_image_type?\n {\n thumb: '100x100>',\n medium: '640x360>',\n large: '1920x1080>'\n }\n elsif is_video_type?\n {\n thumb: { :geometry => \"100x100#\", format: 'jpg', :time => 5 },\n mp4_sd: { :geometry => \"640x360#\", format: 'mp4', :processors => [:transcoder] },\n mp4_hd: { :geometry => \"1920x1080#\", format: 'mp4', :processors => [:transcoder] },\n #webm_sd: { :geometry => \"640x360#\", format: 'webm', :processors => [:transcoder] },\n webm_hd: { :geometry => \"1920x1080#\", format: 'webm', :processors => [:transcoder] }\n }\n else\n {}\n end\n end", "def media_resource?\n true\n end", "def sound_exist?(filename)\n return File.exist?(filename)\n end", "def test_no_text_samples\n no_text_samples = [\"go.mod\", \"go.sum\"]\n Samples.each do |sample|\n if sample[:language] == \"Text\"\n refute_includes no_text_samples, sample[:filename], \"#{sample[:filename]} should NOT be added as a sample for #{sample[:language]}\"\n end\n end\n end", "def sound\n raise NotImplementedError\n end", "def filetype(path)\n path = File.extname(path)\n if Audio::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'audio'\n elsif Video::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'video'\n elsif Image::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'image'\n else\n return nil\n end\n end", "def check_file_type\n `file #{@desktop_image}`.sub(/^.*: /,'').split.first.downcase\n end" ]
[ "0.687224", "0.6592585", "0.6533416", "0.64984995", "0.64200866", "0.6114563", "0.60932106", "0.6083464", "0.6059063", "0.60468644", "0.6032477", "0.60230094", "0.598636", "0.59822816", "0.59768146", "0.59721226", "0.59602976", "0.5933056", "0.5903965", "0.5899825", "0.58904636", "0.58815074", "0.5851952", "0.58485293", "0.58442634", "0.58427346", "0.58259636", "0.5794652", "0.5776293", "0.5737832", "0.57286197", "0.57244796", "0.57005847", "0.5688015", "0.5678593", "0.5660611", "0.5656794", "0.56544834", "0.56361294", "0.56226015", "0.5617896", "0.5616131", "0.56151235", "0.55995226", "0.5592494", "0.55845976", "0.55772865", "0.55679816", "0.5566057", "0.5564806", "0.55532247", "0.5549638", "0.55487084", "0.5539679", "0.55265063", "0.55229443", "0.5520303", "0.5519238", "0.5506096", "0.549712", "0.5491339", "0.5481264", "0.5480488", "0.54785216", "0.5462456", "0.5461096", "0.5459603", "0.5456454", "0.54556197", "0.5444277", "0.5443469", "0.5441356", "0.543292", "0.54270196", "0.5425467", "0.54236734", "0.5420998", "0.5415756", "0.5415756", "0.5415756", "0.5415756", "0.5415756", "0.5415756", "0.53965175", "0.53879416", "0.5376882", "0.53767", "0.536535", "0.53619456", "0.5361828", "0.53613675", "0.53601944", "0.5348664", "0.53437537", "0.53436065", "0.5340814", "0.53394556", "0.5337321", "0.53367066", "0.5336098" ]
0.612933
5
The number of audio files in the directory should be the same as the highest track number, and track numbers should run from 01 to that highest number, with no breaks. This can get messed up by hidden tracks.
def expected_files?(files) files = supported(files) hn = highest_number(files) return true if hn == files.size raise Aur::Exception::LintDirBadFileCount, "#{files.size}/#{hn}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def manageAudioFiles(maxNumFiles, folder)\n\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n keepSeconds = 7200\n\n while fileNumber > maxNumFiles\n keepSeconds *= 0.5\n Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].each do |filename| \n deleteOldFile(filename, keepSeconds)\n end\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n end\n\n end", "def read_tracks music_file\n count = music_file.gets().to_i\n tracks = Array.new\n\n while count > 0\n count -= 1\n \n track = read_track(music_file)\n tracks << track\n end\n tracks\nend", "def audio_file_count\n @audio_file_list.length\n end", "def read_tracks music_file\n\tcount = music_file.gets.to_i\n\ttracks = Array.new\n\t\n\ti = 0\n\twhile i < count\n\t\ttrack = read_track(music_file)\n\t\ttracks << track\n\t\ti = i + 1\n\tend\n\ttracks\nend", "def auto_tracknumber\n i = 0\n @files.each { |file|\n next unless @selected_files.include? file\n file.set_values('TRACKNUMBER', (i+1).to_s)\n i += 1\n }\n end", "def read_tracks music_file\n\ttracks = Array.new()\n\tcount = music_file.gets().to_i\n tracks = Array.new\n\n # Put a while loop here which increments an index to read the tracks\n\n track = read_track(music_file)\n tracks << track\n\n\ttracks\nend", "def read_tracks music_file\n\tcount = music_file.gets().to_i\n tracks = Array.new\n track = File.open(\"input.txt\")\n i = 0\n while (i < count)\n track = read_track(music_file)\n tracks << track\n i += 1\n end \ntracks\nend", "def read_tracks music_file\n\tcount = music_file.gets().to_i\n\ttracks = Array.new()\n track = File.open('album.txt')\n # Put a while loop here which increments an index to read the tracks\n\ti = 0\n\twhile (i < count)\n \ttrack = read_track(music_file)\n\t\ttracks << track\n\t\ti += 1\n\tend\n\treturn tracks\nend", "def read_tracks(music_file)\n\ttracks = Array.new()\n\tcount = music_file.gets().to_i()\n\n # Put a while loop here which increments an index to read the tracks\n i = 0\n while count > i do\n track = read_track(music_file)\n tracks << track\n i = i + 1\n end\n return tracks\nend", "def read_tracks(music_file)\n\t\tcount = music_file.gets().to_i()\n\t\ttracks = Array.new()\n\t# Put a while loop here which increments an index to read the tracks\n\t\ti = 0 \n\t\twhile i < count do \n\t\t\ttracks << read_track(music_file) \n\t\t\ti +=1\n\t\tend \n\treturn tracks\n end", "def search_audio_file(file_name)\n # Trace.debug(\"Search audio for track #{@rtrack.to_s.brown}\")\n extensions = Cfg.size_over_quality ? FILE_EXTS_BY_SIZE : FILE_EXTS_BY_QUALITY\n\n extensions.each do |ext|\n if File.exists?(file_name+ext)\n set_audio_state(Status::OK, file_name+ext)\n return audio.status\n end\n end\n\n # Remove the root dir & genre dir to get the appropriate sub dir\n file = track_dir(file_name)\n Dir[Cfg.music_dir+'*'].each do |entry|\n next unless File.directory?(entry)\n extensions.each do |ext|\n if File.exists?(entry+file+ext)\n set_audio_state(Status::MISPLACED, entry+file+ext)\n return audio.status\n end\n end\n end\n\n set_audio_state(Status::NOT_FOUND, nil)\n return audio.status\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def read_tracks\n\ttracks = Array.new()\n\tcount = read_integer_in_range(\"Enter track count: \", 0, 15)\n\ti = 0\n\twhile i < count\n\t\ttrack = read_track(i)\n\t\ttracks << track\n\t\ti += 1\n\tend\n\ttracks\nend", "def testNormalTrack\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n [1] => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def create_playlist(path)\n Dir.chdir path # Always change path to the inner scope as long a neccesary (so that the program recognizes folders with File.directory?(x) )\n dir = Dir.new(path)\n arr = []\n tracks = []\n Dir.foreach(dir) do |x|\n next if x == \".\" || x == \"..\"\n if File.directory?(x)\n temp = create_playlist(path + \"/#{x}\")\n arr << temp unless temp == [] # Don't track empty folder OUTSIDE OF FOLDER (so that merging executes faster)\n Dir.chdir path # Change path back (to the outer scope)\n else\n # tracks << x # Dummy solution for easier readability while building program (just for reference)\n tracks << path + \"/#{x}\"\n end\n end\n shuffle(tracks) # Shuffle every rudimentary track-list before merging it with another\n arr << tracks unless tracks == [] # Don't create an array WITHIN AN EMPTY FOLDER (so that the merging executes faster)\n arr.length < 2 ? arr.flatten : merging(arr).flatten # return\nend", "def sync(playcounts)\n iTunes = Appscript.app('iTunes')\n iTunes.tracks.get.each do |track|\n begin\n artist = playcounts[Util.filter_name(track.artist.get)]\n if artist.nil?\n if extra_verbose\n puts \"Couldn't match up #{track.artist.get}\" \n end\n next\n end\n\n playcount = artist[Util.filter_name(track.name.get)]\n if playcount.nil?\n if extra_verbose\n puts \"Couldn't match up #{track.artist.get} - #{track.name.get}\"\n end\n next\n end\n\n itunes_playcount = track.played_count.get || 0\n\n if addpc\n new_itunes_playcount = playcount + itunes_playcount\n elsif playcount > itunes_playcount\n new_itunes_playcount = playcount\n end\n\n if new_itunes_playcount.nil?\n if verbose\n puts \"Skipping #{track.artist.get} - \\\"#{track.name.get}\\\", new playcount smaller than existing\"\n end\n elsif (max_play_count > 0 && new_itunes_playcount > max_play_count)\n if verbose\n puts \"Skipping #{track.artist.get} - \\\"#{track.name.get}\\\", new playcount #{new_itunes_playcount} > max #{max_play_count}\"\n end\n else\n if verbose\n puts \"Setting #{track.artist.get} - \\\"#{track.name.get}\\\" playcount from #{itunes_playcount} -> #{new_itunes_playcount}\"\n end\n track.played_count.set(new_itunes_playcount) unless dry_run\n end\n rescue SystemExit, Interrupt\n raise\n rescue Exception => e\n puts \"Encountered some kind of error on this track: #{e}: #{e.message}\"\n end\n end\n end", "def testNormalTrackWithAliasList\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1,\n :Alias => [ 'Track 1', 'Track 2' ]\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Track 2' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def music_shuffle filenames\n\n number_of_songs = filenames.length\n\n #shuffle twice\n 2.times do\n left_index = 0\n right_index = number_of_songs/2\n shuffled = []\n\n while shuffled.length < number_of_songs\n if shuffled.length % 2 == 0\n #take track from right\n shuffled << filenames[right_index]\n right_index += 1\n else\n #take track from left\n shuffled << filenames[left_index]\n left_index += 1\n end\n end\n\n shuffled = filenames\n end\n\n final = []\n cut = rand(number_of_songs) #index of card to cut at\n counter = 0\n\n while counter < number_of_songs\n final << filenames[(counter+cut)%number_of_songs]\n counter += 1\n end\n\n final\nend", "def query_metadata filename\n song = File.basename(filename, File.extname(filename))\n track = filename[/[0-9]+ /]\n\n unless track.nil?\n song = song[track.size .. -1]\n track = track.to_i\n end\n\n return track,song\nend", "def sounds_for_digits(num)\n result = []\n num.to_s.each_char do |c|\n result << sound_path(\"#{c}.ul\")\n end\n result\n end", "def read_tracks\r\n\ttracks = Array.new()\r\n\tcount = read_integer_in_range(\" Enter number of tracks:\", 1, 15)\r\n\tindex = 0\r\n\twhile index < count\r\n\t\ttrack = read_track()\r\n\t\ttracks << track\r\n\t\tindex += 1\r\n\tend\r\n\ttracks\r\nend", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end", "def tracks\n @tracks ||= begin\n assets_directory = File.join File.expand_path('../../../', __FILE__), 'assets'\n\n Dir.glob(File.join(assets_directory, '*.mp3')).map do |file|\n \"http://#{ip}:#{Ghosty::Settings.port}/#{File.basename(file)}\"\n end\n end\n end", "def generate!(folder)\n counter = 0\n files.each_with_index do |file, index|\n counter += file.videos.length\n file.write!(folder, index+1)\n end\n return counter\n end", "def files\n array_full_names = Dir.glob(\"#{@path}/*.mp3\")\n array_full_names.collect do |full_name|\n full_name[21..-1]\n end\n end", "def audio_files\n @audio_files ||= path.join(\"data\").each_child.select { |file| [\".wav\", \".mp3\"].include? file.extname }.map { |file| IngestableAudioFile.new(path: file) }\n end", "def play_album albums\n\tid = read_integer('Album ID: ')\n\tvalid, index = validate_id(id ,albums)\n\tif valid\n\t\talbum = albums[index]\n\t\tprint_track_list(album)\n\t\tplay_track(album)\n\telse\n\t\tsystem \"clear\" or system \"cls\"\n\tend\nend", "def prepare_tracks(tracks, starting_index, bonus)\n \n last_index = starting_index\n\n # loop through every song in the track list in order, normalizing their sequence numbers\n tracks.values.select{|val| val[\"bonus\"] == bonus.to_s}.sort_by{ |a| a[\"Seq\"].to_i }.each_with_index do |b, i|\n\n last_index = starting_index + i\n\n # sequence in 10s\n b[\"Seq\"] = (last_index * 10).to_s \n\n # if there's no override song name, add in the real song name\n if b[\"SONGID\"].present? \n b[\"Song\"] = Song.find(b[\"SONGID\"].to_i).full_name if b[\"Song\"].empty?\n end\n\n b[:VersionNotes] = nil if b[:VersionNotes].strip.empty?\n \n end\n\n starting_index\n\n end", "def testNormalTrackWithSingleAlias\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1,\n :Alias => 'Track 1'\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Track 1' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def update\n STDOUT.sync = true\n tracks = []\n\n app = Appscript.app.by_name(\"iTunes\", Tunes) \n\n iTunes_tracks = app.selection.get\n if iTunes_tracks.count == 0\n iTunes_tracks = app.library_playlists[1].tracks.get\n end\n\n print \"Reading #{iTunes_tracks.count} tracks \"\n iTunes_tracks.each do | iTunes_track |\n begin\n if iTunes_track.kind.get == 'Matched AAC audio file'\n track = Track.new(iTunes_track)\n unless track.valid?\n tracks << track\n print '*' if ((tracks.count % WORK_SIZE) == 0)\n end\n end\n rescue StandardError => e\n puts e\n end\n end\n puts ''\n\n # all 2 char countries codes lots currently not valid %w(AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF PM VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK SD SR SJ SZ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VE VN VG VI WF EH YE ZM ZW)\n\n countries = %w(AU US GB FR DE CA IT JP DZ AO AI AG AR AM AT AZ BS BH BD BB BY BE BZ BM BO BW BR BN BG CM KY CL CN CO CR CI HR CY CZ DK DM DO EC EG SV EE ET FI GH GR GD GT GY HN HK HU IS IN ID IE IL JM JO KZ KE KR KW LV LB LY LI LT LU MO MK MG MY MV ML MT MU MX MD MS MM NP NL NZ NI NE NG NO OM PK PA PY PE PH PL PT QA RO RU KN LC VC SA SN RS SG SK SI ZA ES LK SR SE CH TW TZ TH TT TN TR TC UG UA AE UY UZ VE VN VG YE)\n\n puts \"Found #{tracks.count} matched tracks\"\n countries.each do | country |\n print \"Querying #{country} store for #{tracks.count} tracks \"\n counter = 0\n tracks.dup.each.each_slice(WORK_SIZE) do | subtracks |\n ids = subtracks.map { | track | track.iTunes_id }\n iTunesUrl = \"http://itunes.apple.com/lookup?id=#{ids.join(',')}&country=#{country}\"\n # puts \"QUERY: #{iTunesUrl}\"\n iTunesHash = JSON.parse(open(iTunesUrl).read)\n print '*'\n iTunesHash['results'].each do | result |\n result_id = result['trackId']\n subtracks.each do | track |\n if result_id == track.iTunes_id\n result['year'] = Date.parse(result['releaseDate']).year if update_year\n track.update_track(result, update_year, dry_run, verbose) \n tracks.delete(track)\n counter += 1\n break\n end\n end\n end\n end\n puts \" #{counter} updated\"\n break if tracks.empty?\n end\n\n puts \"Couldn't find meatadata for #{tracks.count} tracks\" if tracks.count != 0\n end", "def albums_with_one_song(n = 10)\n single_songs = []\n @albums.each do |a|\n b = @tracks.find_all {|s| s.album == a}\n single_songs << b.first unless b.length > 1\n end\n return single_songs[0..n-1]\n end", "def nextTrack(current_track)\n if current_track == @tracks.length() - 1\n return 0\n else \n return current_track + 1\n end\n end", "def next_archive_number # :nodoc:\n max = 0\n Dir.glob(\"#{path}.*\").each do |filename|\n if /\\.\\d+\\z/ =~ filename\n suffix = filename.split(\".\").last.to_i\n max = suffix if suffix > max\n end\n end\n max + 1\n end", "def increment_playcount(path)\n # sometimes files don't end up in the database, add them when played\n self.new_file(path)\n @files.filter(:path => path).update(:playcount => Sequel.expr(1) + :playcount)\n end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end", "def read_track music_file\n\t# fill in the missing code\nend", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def number_of_tracks(talks)\n @total_talks_time = Talk.computeTotalTime(talks)\n\n quotient = @total_talks_time / Track.maxTrackTime\n if @total_talks_time - (quotient * Track.maxTrackTime) >= Track.minTrackTime\n @number_of_tracks = quotient + 1\n else\n @number_of_tracks = quotient\n end\n end", "def read_album music_file\n album_artist = music_file.gets().chomp\n album_title = music_file.gets().chomp\n album_genre = music_file.gets().to_i\n tracks = read_tracks(music_file)\n if tracks.length < 15\n album = Album.new(album_title, album_artist, album_genre, tracks)\n else\n album = Null\n puts \"#{album_title} has more than 15 tracks so it has not been imported.\"\n end\n album\nend", "def import_full_score(dirname)\n num = 0\n loop do \n num += 1\n in_file = Dir[\"#{dirname}/#{num}*.in\"]\n break if in_file.length == 0\n end\n full_score = (num - 1) * 10 \n @problem.full_score = full_score\n @problem.save\n return \"\\nFull score is set to #{full_score}.\"\n end", "def songs\n MusicImporter.new(path).print_songs\n end", "def run\n @files.each do |file|\n generate_tracklist(file)\n end\n end", "def top_songs(n = 3)\n top_list = @tracks.sort_by {|s| s.play_count}.reverse\n return top_list[0..n-1].compact\n end", "def sample_length(tick_sample_length)\n @tracks.keys.collect {|track_name| @tracks[track_name].sample_length(tick_sample_length) }.max || 0\n end", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "def read_albums music_file\n albums = Array.new()\n count = music_file.gets()\n\t i = 0\n while (i < count.to_i)\n album = read_album(i,music_file)\n albums << album\n i += 1\n end\n albums\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end", "def find_most_played_songs\n top_songs_with_play_count_pair = self.lib.songs.reject do |song|\n #this line is describing records it will get rid of\n (!song.metadata.has_key?('play_count')) or (song.metadata['play_count'] == nil)\n end\n\n top_songs_played_sorted = top_songs_with_play_count_pair.sort do |a, b| \n b.metadata['play_count'].to_i <=> a.metadata['play_count'].to_i\n end\n\n top_songs_played = top_songs_played_sorted.first(5)\n song_names_of_top_played = top_songs_played.collect {|song| song.metadata['name']} \n end", "def ex1\n WaveFile::Reader.new(\n File.expand_path('../440Hz,441samples.wav', File.dirname(__FILE__))\n ) do |reader|\n samples = reader.read(441).samples.to_a\n #puts samples.map(&:inspect).join(\",\")\n samples_to_graph!(samples, '440constant')\n embiggen_and_imgcat!('440constant')\n end\nend", "def num_of_tracks\n\t\t@tracks.count\t \n\tend", "def song_count\n self.lib.songs.count\n end", "def build_audio_file_name\n return track.build_audio_file_name(segment_artist, record, segment, genre)\n end", "def number_of_tracklists\n tracklists.size\n end", "def track_count\n return @tracks.length\n end", "def music_shuffle(filenames_array)\n filenames_array.each do |song|\n song_path = song.split '/'\n\n end\nend", "def switches(audio)\n count = 0\n audio.each do |look|\n count = count + 1\n end\n return count\n end", "def song_count\n @song_count = 0 if @song_count.nil?\n @song_count\n end", "def sounds_for_number(number)\n number = number.to_i\n result = []\n thousands = (number / 1000).floor\n if thousands > 0\n result << \"#{thousands}.ul\" << \"thousand.ul\"\n end\n rest = number % 1000\n hundreds = (rest / 100).floor\n if hundreds > 0\n result << \"#{hundreds}.ul\" << \"hundred.ul\"\n end\n rest = rest % 100\n if rest <= 19\n result << \"#{rest}.ul\"\n else\n tens = (rest / 10).floor\n units = rest % 10\n result << \"#{tens}0.ul\" \n result << \"#{units}.ul\" if units > 0\n end\n result.map {|r| sound_path(r) }\n end", "def track_files(glob); end", "def number_of_songs()\n return songs.length\n end", "def number_of_songs()\n return songs.length\n end", "def sample_length_with_overflow(tick_sample_length)\n @tracks.keys.collect {|track_name| @tracks[track_name].sample_length_with_overflow(tick_sample_length) }.max || 0\n end", "def initialize(directory)\n raise BadDirectory.new(\"#{directory} does not exist\") unless Dir.exists?(directory)\n @directory = directory\n @album_title = File.basename(directory)\n @tracks = Dir[\"#{directory}/*\"].map do |filepath|\n Track.new(filepath) rescue next\n end\n end", "def initialize dir, tracks\n @path = dir\n\n @files = tracks.map { |e| e }\n\n @selected_files = @files.slice(0, @files.size).to_set\n end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end", "def test2Tracks\n execute_Record_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env_Track1\n },\n [2] => {\n :Env => :Env_Track2\n }\n }\n }\n }, :RecordedFiles => [\n 'Empty', # Track 1 recording\n 'Empty', # Track 1 silence\n 'Empty', # Track 2 recording\n 'Empty' # Track 2 silence\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n assert_wave 'Empty', '01_Source/Record/Env_Track1.1.wav'\n assert_wave 'Empty', '01_Source/Record/Env_Track1.Silence.wav'\n assert_wave 'Empty', '01_Source/Record/Env_Track2.2.wav'\n assert_wave 'Empty', '01_Source/Record/Env_Track2.Silence.wav'\n end\n end", "def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend", "def testSingle2Tracks\n execute_Record_WithConf({\n :Recordings => {\n :Tracks => {\n [1, 2] => {\n :Env => :Env_Tracks\n }\n }\n }\n }, :RecordedFiles => [\n 'Empty', # Track recording\n 'Empty' # Track silence\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n assert_wave 'Empty', '01_Source/Record/Env_Tracks.1.2.wav'\n assert_wave 'Empty', '01_Source/Record/Env_Tracks.Silence.wav'\n end\n end", "def long_tracks\n @tracks.select { |track| track.duration_ms > 240_000 }\n end", "def audio_file_from_list(idx)\n @audio_file_list[idx]\n end", "def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end", "def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend", "def track_ids\n tracks || []\n end", "def song_count=(value)\n @song_count = 0 if @song_count.nil?\n @song_count = value\n end", "def files\n # Dir.glob(\"*.mp3\") #this grabs mp3s from path\n Dir.chdir(@path) do \n @mp3s = Dir.glob(\"*.mp3\") \n end\n end", "def do_add\n file_paths = ARGV.dup\n\n file_paths.map! { |path| File.expand_path(path) }\n \n file_paths.each do |path|\n ensure_exists(path)\n end\n\n audiofiles = file_paths.map do |path|\n af = nil # SCOPE\n TagLib::FileRef.open(path) do |ref|\n if ref.null?\n warnx(\"#{path}: not an audio file?\")\n exit 1\n end\n warnx(\"parsing #{path}\")\n tags = ref.tag\n af = AudioFile.new(path, tags.title, tags.artist, tags.album)\n end\n\n af\n end\n\n File.open(@playlist_path, \"w\") { |fd|\n fd.puts(PlaylistWriter.new(audiofiles).to_s)\n }\nend", "def testProcessesOrder1Track\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.????????????????????????????????.wav')\n lWave1FileName = getFileFromGlob('05_Mix/Wave.1.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => 'Wave.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n },\n {\n :InputFileName => lWave0FileName,\n :OutputFileName => lWave1FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Empty', '05_Mix/Final/Final.wav'\n end\n end", "def queue_files_for_processing( args )\n\t\t# only queue up files that can have id3 tags to begin with.\n\t\tfiles = clean_file_list( args )\n\n\t\t# add the files to the queue\n\t\tif( files.length == 0 )\n\t\t\tputs \"None of the files were MP3s!!\"\n\t\t\t#FIXME: should this be an exception?\n\t\telse\n\n\t\t\t# Set the track number limits\n\t\t\tcount \t\t\t\t= @renumber_start_at\n\t\t\t@total_tracks = files.length\n\n\t\t\tfiles.each { |x|\n\t\t\t\tputs \"checking #{x}...\"\n\n\t\t\t\t# list its current id3 tag contents.\n\t\t\t\tputs \"\\tid3v2 says this:\"\n\t\t\t\tputs \"\\t\\t#{ID3Tagger::list_file( x )}\"\n\n\t\t\t\t# tell the user what the program intends to change\n\t\t\t\tputs build_proposal_string( count ) + \"\\n\"\n\n\t\t\t\t# add the file to the queue\n\t\t\t\tadd( x, count )\n\t\t\t\tcount = count + 1\n\t\t\t}\n\n\t\t\t# keep files in order\n\t\t\t@files.rehash\n\t\tend\n\tend", "def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\n end", "def print_tracks tracks\n i = 0\n for i in 0..tracks.length - 1 do\n\t puts '*********************************************'\n\t puts '**************** Track No. ' + (i + 1).to_s + ' ****************'\n\t print_track(tracks[i])\n\t puts ''\n end\nend", "def songs_count\n value = 0\n packs.each do |pack|\n value += pack.songs.count\n end\n value += songs.count\n end", "def print_tracks tracks\n\tindex = 0\n\twhile index < tracks.length\n\t\tprint_track tracks[index]\n\t\tindex += 1\n\tend\nend", "def list(songs)\n song_list = []\n counter = 1\n songs.each do |song|\n song_list.push(\"#{counter}. #{song}\")\n counter += 1\n end\n puts song_list\nend", "def generate_play_list\n rplist = DBUtils.get_last_id(\"plist\")+1\n DBIntf.execute(\"INSERT INTO plists VALUES (#{rplist}, 'Charts generated', 1, #{Time.now.to_i}, 0);\")\n rpltrack = DBUtils.get_last_id(\"pltrack\")\n count = 1\n @lsc.each do |model, path, iter|\n DBIntf.execute(\"INSERT INTO pltracks VALUES (#{rpltrack+count}, #{rplist}, #{iter[COL_REF]}, #{count*1024});\")\n count += 1\n end\n end", "def skip_tracks_18(i)\r\n\t t = (s = @playlist.size) - (h = i % s)\r\n\t s = @playlist.size-1\r\n\t @playlist[0, t], @playlist[t..s] = @playlist[h..s], @playlist[0, h]\r\n\t \r\n puts \"New Playlist:\"\r\n\t @playlist.each {|a| puts a}\r\n\tend", "def best_song_from_en(songs)\n best_song = songs.first\n songs.each do |s|\n best_song = if s.tracks.size > best_song.tracks.size\n s\n else\n best_song\n end\n end\n best_song\n end", "def validate_header_file_audio\n self.validate_header_file(10, ['mp3', 'ogg', 'wav'], 'errors.messages.audio_too_large')\n end", "def tracks(query)\n s = \"\\nsearching for #{query}\\nwith maximum 200 items per pagination\\n\"\n pre = \"\"\n s.split(\"\\n\")[2].length.times{|i| pre << \"**\"}\n puts \"#{pre}#{s}#{pre}\"\n #Soundcloud API gets a limit\n # we need add some param to get next_href\n # so we will get all tracks\n #@total = 0 \n get_tracks(query) do |collection, track| \n filter_and_add_to collection, track\n end\n\n end", "def files # loads all the mp3 files in the path directory / normalizes the filename to just the mp3 filename with no path\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") } # then using the .collect method and gsub to just return the filename with out path\n end", "def buildDataTrack(package)\n playlist = \"\"\n i = 1\n package.each do |son|\n playlist = playlist + \"<a href=\\\"http:\\/\\/player.yoyaku.io/mp3/#{son[1]}_#{i}.mp3\\\">#{son[7]} - #{son[9]}</a>\\n\"\n i = i + 1\n end\n return playlist\nend", "def fill( path , file , file_size )\n\n # File info\n self.path = path\n self.file_size = file_size\n\n # Set default values:\n self.name = ''\n self.genre = ''\n self.seconds = 0\n self.track = 0\n self.bitrate = 0\n self.channels = 0\n self.sample_rate = 0\n\n # Get file tags\n file_tags = file.tag\n if file_tags\n self.name = file_tags.title if file_tags.title\n self.genre = file_tags.genre if file_tags.genre\n self.track = file_tags.track if file_tags.track\n end\n\n # Be sure we have a name\n if self.name.empty?\n self.name = File.basename(path, \".*\")\n self.name.gsub!('_',' ')\n end\n self.name.strip!\n\n # Try to extract the track number from the name\n begin\n if self.track == 0 && self.name =~ /\\A\\d+.*/\n # Get the initial number:\n self.track = self.name[/\\A\\d+/].to_i\n self.track = 0 if self.track < 0 || self.track > 9999\n end\n rescue\n end\n\n # Cut long names\n if self.name.length > Constants::NAME_MAX_LENGTH\n self.name = self.name[0..(Constants::NAME_MAX_LENGTH-1)]\n end\n if self.genre && self.genre.length > Constants::NAME_MAX_LENGTH\n self.genre = self.genre[0..(Constants::NAME_MAX_LENGTH-1)]\n end\n\n # Get audio properties\n audio_props = file.audio_properties\n if audio_props\n self.seconds = audio_props.length if audio_props.length\n self.bitrate = audio_props.bitrate if audio_props.bitrate\n self.channels = audio_props.channels if audio_props.channels\n self.sample_rate = audio_props.sample_rate if audio_props.sample_rate\n end\n\n end", "def track_count\n self.tracks.count\n end", "def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\n end", "def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end", "def combine_tracks_from_origin\n begin\n tracks = \"\"\n offsets = []\n # This is disgusting, but I want to get this concept working\n # and my brain isn't cooperating. I'm trying to account for\n # any tracks that both have offsets by subtracting the lower offset\n # from the higher one, and reassigning the higher one with the new value\n # and setting the lower one to 0. That way there are no pauses before the track begins\n os = origins.sort_by(&:offset).reverse\n os.each {|o| offsets << o.offset}\n os.first.offset = offsets[0] - offsets[1]\n os.last.offset = 0\n os.each do |o|\n unless File.exist?(o.jingle.latest_path)\n sox_logger.info(\"#{o.jingle.latest_path} does not exist.\")\n raise Errno::ENOENT, \"#{o.jingle.latest_path} not processed yet\"\n end\n sox_logger.info(\"Added track: #{o.jingle.latest_path}\")\n if o.offset > 0\n tracks += (\" -v 0.8 \" + o.jingle.latest_path + \" -p pad \" + o.offset.to_s + \" 0 | sox - -m\")\n elsif o.offset == 0\n #tracks += (\" -v 1 \" + o.jingle.latest_path + \" pad \" + o.offset.to_s + \" 0 | sox - -m\")\n tracks += (\" -v 0.8 \" + o.jingle.latest_path)\n end\n end\n output = assets_path\n #tracks = tracks[0..-11] # Remove the trailing command\n puts \"sox #{tracks} #{output}original.mp3\"\n m = os.first.offset == 0 ? \"-m \" : \"\"\n result = `sox #{m}#{tracks} #{output}original.mp3`\n duration = `soxi -D #{output}original.mp3`\n stat_data = `soxi #{output}original.mp3`\n # TO FIX\n # Stat data with non-UTF-8 stuff won't save in the DB.\n #stat_data = `sox #{output}original.mp3 -n stat`\n update_attributes(\n track_duration: duration,\n state: \"complete\",\n track_file_name: \"origin.mp3\",\n track_content_type: \"audio/mpeg\",\n track_file_size: (File.size(\"#{output}original.mp3\") rescue 0),\n stat: stat_data #.encode(\"UTF-8\").force_encoding('UTF-8')\n )\n rescue => error\n sox_logger.debug(\"Encountered error:\\n\")\n sox_logger.debug($!.backtrace)\n return false\n end\n end", "def count_songs\n @songs.size\n end", "def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end", "def music_shuffle filenames\n #Shuffle twice, cut once, like cards \n #Sort beforehand \n filenames = filenames.sort \n len = filenames.length \n\n 2.times do \n l_idx = 0 \n r_idx = len/2 \n shuf = []\n\n while shuf.length < len\n if shuf.length%2==0\n shuf.push(filenames[r_idx])\n r_idx = r_idx + 1 \n else \n shuf.push(filenames[l_idx])\n l_idx = l_idx + 1\n end \n end \n filenames = shuf \n end \n arr = []\n cut = rand(len)\n idx = idx + 1 \n while idx < len \n arr.push (filenames[(idx+cut)%len])\n idx = idx +1 \n end \n arr\nend", "def print_tracks tracks\n index = 0\n while index < tracks.length \n print_track tracks[index]\n index += 1\n end\nend" ]
[ "0.66143453", "0.6539918", "0.6303062", "0.6203977", "0.6171165", "0.6108003", "0.60433143", "0.59385604", "0.5855106", "0.5732454", "0.56857014", "0.56785727", "0.56785727", "0.56563485", "0.5637522", "0.5603094", "0.5580981", "0.5553235", "0.5538801", "0.5513338", "0.5472999", "0.5441605", "0.543104", "0.5428648", "0.542775", "0.5413597", "0.53891593", "0.5386334", "0.5385216", "0.5381329", "0.53797454", "0.53731275", "0.5367817", "0.5361459", "0.5360054", "0.53587043", "0.53370494", "0.53362733", "0.53359705", "0.53294635", "0.53243774", "0.5313891", "0.53002226", "0.52956164", "0.5294468", "0.5288397", "0.52804214", "0.52792704", "0.52749616", "0.5274449", "0.52699655", "0.5264407", "0.5255188", "0.5247655", "0.5244546", "0.5232632", "0.52315754", "0.523024", "0.52241296", "0.5218837", "0.5210442", "0.5203677", "0.5203677", "0.5195386", "0.5187558", "0.51829135", "0.5162473", "0.51494986", "0.5149498", "0.5147331", "0.5137313", "0.5137171", "0.5134166", "0.51197803", "0.51154447", "0.5113472", "0.5113315", "0.5110164", "0.51079196", "0.51022977", "0.5098528", "0.5090624", "0.5083827", "0.50684696", "0.5065997", "0.5062927", "0.5062856", "0.5056445", "0.5054112", "0.5050739", "0.50324655", "0.50313526", "0.50294936", "0.50293326", "0.50281274", "0.50170726", "0.5015079", "0.5011369", "0.50110877", "0.50103354", "0.5009533" ]
0.0
-1
Everything should have the same album tag
def all_same_album?(tags) all_same_tag?(tags, :album) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end", "def target_albums(picture)\n self.albums.reject{ |album| album.pictures.include?(picture) }\n end", "def album_name_unique?(album_name, artist_name) \n album_names = self.albums.select{|album| album.artist.present?}\n .select{|album| album.artist.name == artist_name}\n .map{|album| album.name}\n\n album_names.select{|name| name == album_name}.blank?\n \n end", "def album\n track && track.album\n end", "def correct_tag_values?\n validate_tags(info.our_tags)\n validate_album_disc(info.album, file.dirname.basename.to_s)\n end", "def albums\n @albums ||= response.albums.uniq(&:name)\n end", "def album=(v)\n if @album != v\n @needs_commit = true\n @album = v\n end\n end", "def name\n albums = tracks.map{|t| t.album}.compact\n albums.uniq.size == 1 and albums.first\n end", "def add title, artist\n $albums.each do |album, status|\n # screen for duplicates\n if album[0].downcase == title.downcase\n puts \"You already have a song by that name.\"\n return nil\n end\n end\n album = [title, artist]\n $albums[album] = \"unplayed\"\n # artist = artist.gsub('\"', '')\n puts \"Added #{title} by #{artist.gsub('\"', '')}\"\n return album\nend", "def album_unique?(album_object, artist_object)\n\n albums = self.albums.select{|album| album.artist.present?}\n non_nil_albums = albums.select{|album| album.artist.name == artist_object.name} << album_object.name\n non_nil_albums.length == non_nil_albums.uniq.length\n end", "def albums\n self.album\n end", "def album\n alb = super\n if alb.nil?\n alb = Album.new\n alb.title = \"Unknown Album\"\n end\n alb\n end", "def album_name\n album ? album.name : ''\n end", "def all_same_artist?(tags)\n all_same_tag?(tags, :artist)\n end", "def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end", "def album_title\n if album\n album.title\n end\n end", "def albums\n Dir[_(\"*\")].collect do |alb| \n album(File.basename(alb))\n end\n end", "def find_album(artist,url_slug)\n logger.info \"in find album\"\n\t\tartist.albums.uniq.each do |album|\n\t\t\tif album.album_url_slug == url_slug\n\t\t\t\t@album = album\n\t\t\tend\n\t\tend\n\n\t\tlogger.info @album\n\tend", "def populate_album_for_first_time(tag)\n @next_max_id = nil\n tag = find_or_create_tag(tag)\n\n 10.times do\n hit_api_to_get_photos\n photo_data = @photo_data # stubbed; will refactor this away later\n add_all_photos_from_one_page(tag.name, photo_data)\n end\n end", "def index\n params[:tag] ? @photos = Photo.tagged_with(params[:tag]) : @photos = Photo.all\n album = params[:album_id]\n @photos = current_user.photos.all.where(album_id: album).with_attached_pictures\n\n end", "def album(value)\n @ole.Album = value\n nil\n end", "def top_albums(tag)\n get(:standard, {:method => \"tag.getTopAlbums\", :tag => tag})\n end", "def give_metadata(name, folder_name, url)\n album_parts = name.split(\" _ALBUM_ \")\n single_parts = name.split(\" _SINGLE_ \")\n album_parts, single_parts = [album_parts, single_parts].map do |parts_set|\n (parts_set.length < 2) ? nil : parts_set\n end\n artist, album = album_parts || single_parts\n Dir.glob(\"./audio/#{folder_name}/**/*.mp3\").each do |path|\n Mp3Info.open(path) do |mp3|\n mp3.tag.artist = artist\n mp3.tag.album = \"#{album_parts ? \"ALBUM\" : \"SINGLE\"} #{album}\"\n end\n end\n end", "def add_album(new_album)\n if @albums.include?(new_album)\n puts \"The album has already been added\"\n else\n @albums.push(new_album)\n end\n end", "def album_social(artist,album)\n\n\t #-----------For Album Meta Tags----------------\n\n\t #Page Title, Facebook Title and Twitter Title\n\t @social_title = @album.al_name+\" by \"+ @artist.name+\" on Three Repeater\"\n\t #Meta description (google), Facebook Description, and Twitter Card Description\n\t @social_descrip = album.description\n\n\t #facebook url\n\t @social_fb_url = artist_show_album_url(artist.url_slug,album.album_url_slug)\n\n\n\t #Twitter ID\n\t @social_twitter_name = artist.twitter_name\n\n\t #Image for twitter and FB\n\t if album.art.blank?\n\t\t @social_image = artist.logo.to_s\n\t else\n\t\t @social_image = album.art.to_s\n\t end\n\n end", "def part_of_gapless_album(value)\n @ole.PartOfGaplessAlbum = value\n nil\n end", "def retag_album_artist(filename, album_artist_tag)\n Mp3Info.open(filename) do |mp3file|\n print \"Retagging #{filename}...\"\n STDOUT.flush\n if (mp3file.tag2.TPE2)\n puts \"oops!\"\n puts \"Found existing Album Artist tag: #{mp3file.tag2.TPE2}. Skipping file.\"\n return\n end\n mp3file.tag2.TPE2 = album_artist_tag\n puts \"done.\"\n end\nend", "def normalize_all_albums\n albums.each{|tuple| normalize_album(tuple[:albid])}\n end", "def test_has_tag\n ogg = dummy()\n\n assert ogg.has_tag?(\"GENRE\")\n assert !ogg.has_tag?(\"UNKNOWN\")\n end", "def set_album\n @album = Album.includes(:photos, :shares).find(params[:id])\n end", "def add_album(new_album)\n @albums.include?(new_album) ? (puts \"The album has already been added\") : @albums.push(new_album)\n end", "def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end", "def tags(artist, album)\n get(:session, {:method => \"album.getTags\", :artist => artist, :album => album})\n end", "def part_of_gapless_album\n @ole.PartOfGaplessAlbum\n end", "def test_tags\n ogg = dummy()\n\n expected_tags = %w{GENRE UNICODETAG}.to_set\n assert_equal expected_tags, ogg.tags.to_set\n end", "def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end", "def set_from(album)\n @artist = library.artists.add_or_retrieve(album.artist)\n @catalogue_id = album.catalogue_id.dup\n \n if album.format\n @format = library.formats.add_or_retrieve(album.format)\n else\n @format = library.formats['Unknown/Other']\n end\n \n @media_quantity = album.media_quantity \n @title = album.title.dup\n @release_date = album.release_date\n \n clear_tracks()\n \n album.tracks.each do |track|\n new_track = Track.new(self)\n new_track.set_from(track)\n end\n end", "def album(albid)\n if File.exists?(path = _(albid))\n {:albid => albid, :name => albid, :path => cut_path(path)}\n else\n raise Error, \"No such album #{albid}\"\n end\n end", "def songs_by_album\n return @count_by_album if @count_by_album\n\n return get_base_relation(true, false)\n .group('albums.id')\n .order('albums.name')\n .pluck('albums.id' , 'albums.name' , 'count(*)')\n\n end", "def album_reviews(album)\n reviews.select do |r|\n r.album == album\n end\n end", "def create\n @album = Album.new(album_params)\n\n not_blank_photos = @album.photos.select do |photo|\n ! photo.title.blank?\n end\n @album.photos = not_blank_photos\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def top_photo?\n if self.albums.length >= 3\n true\n else\n false\n end\n end", "def all_same_genre?(tags)\n all_same_tag?(tags, :genre)\n end", "def format_photos(photos)\n #photos = flickr.photos.getRecent(:extras=>'tags,url_c')\n photos.reject {|photo| Photo.exists?(:url=>build_urls(photo)) || photo.tags == '' || photo.tags.nil? || photo.tags.include?('uploaded') || photo.tags.include?('filter=none') || photo.tags.include?('filter=nofilter')}\n\n #photos.shuffle\n end", "def photo_album(id)\n backup_photo_albums.find_by_source_album_id(id)\n end", "def normalize_album(albid)\n require 'fileutils'\n FileUtils.mkdir_p(_(albid, 'thumbs'))\n FileUtils.mkdir_p(_(albid, 'trash'))\n all_images(albid).each{|tuple|\n source, target = _(tuple[:path]), _(tuple[:thumb])\n unless File.exists?(target)\n IMagick.create_thumbnail(source, target)\n end\n }\n end", "def album\n\t\talbums == nil ? nil : albums.first\n\tend", "def get_unique_tag_values(tag)\n values = []\n @files.each { |mp3| \n values << mp3.tags.tag if mp3.tags.tag.length\n }\n values.sort!\n end", "def album\n @ole.Album\n end", "def photo_tags\n all_tags = Hash.new {|h,k| h[k]=[]}\n self.tags.find_each do |t|\n all_tags[t.field] << t.value\n end\n all_tags\n end", "def set_album\n @album = Pagealbum.find(params[:id]) rescue Pagealbum.new\n @images=[]\n end", "def show\n if !session[:access_token]\n redirect_to :controller => 'sessions', :action => 'connect'\n end\n\n pmocampo = \"30792403\"\n client = Instagram.client(:access_token => session[:access_token])\n \n @user = client.user(pmocampo)\n \n @album = Album.find(params[:id])\n @photos = client.user_recent_media(pmocampo)\n @photos = @photos.select {|p| p.tags.include?(@album.tag)}\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def album_id_public\n if album\n album.id_public\n end\n end", "def profileAlbum\n aid = self.albums.select{|a| a['name'].include?('Profile')}[0]['id']\n self.fbCall(\"/#{aid}/photos\")\n end", "def songs\n Song.find_by_album(@id)\n end", "def albums_with_one_song(n = 10)\n single_songs = []\n @albums.each do |a|\n b = @tracks.find_all {|s| s.album == a}\n single_songs << b.first unless b.length > 1\n end\n return single_songs[0..n-1]\n end", "def get_album_info(album)\n info = UpcomingReleases::Scraper.scrape_info_page(ALBUM_URL + album.info_url)\n album.add_album_info(info)\n end", "def update\n @song = Song.find(params[:id])\n unless @song.songtype.name == \"mp3\"\n flash[:error] = \"It doesn't work on that song type\"\n redirect_to(songs_url)\n end\n if (@song && tag = (Tagger.new(@song.file)) )\n ## Title\n title_tag = params[:title]\n if title_tag\n tag.title= title_tag\n params[:song][:title] = title_tag\n end\n ## Artist\n artist_tag = params[:artist]\n if artist_tag\n artist = (Artist.find_by_name artist_tag) || Artist.new({:name=>artist_tag})\n if artist.new_record?\n artist.save\n end\n params[:song][:artist] = artist\n tag.artist= artist_tag\n end\n ## Genre\n genre_tag = params[:genre]\n if genre_tag\n genre = (Genre.find_by_name genre_tag) || Genre.new({:name=>genre_tag})\n if genre.new_record?\n genre.save\n end\n params[:song][:genre] = genre\n tag.genre= genre_tag\n end\n genre ||= tag.lookup_genre\n genre_tag ||= genre.name\n ## Album\n\n album_tag = params[:album]\n if album_tag\n album = (Album.find_by_name album_tag) || Album.new({:name=>album_tag})\n if album.new_record?\n album = Album.new({:name=>album_tag, :genre=> genre})\n album.save\n album.artists.push artist\n else\n unless album.artists.include? artist\n album.artists.push artist\n end\n end\n params[:song][:album] = album\n tag.album= album_tag\n end\n tag.saveChanges\n b = Tagger.new(@song.file)\n unless ( ( params[:title] && b.title == params[:title]) && ( params[:artist] && b.artist == params[:artist]) && (params[:album] && b.album == params[:album]) && (params[:genre] && b.lookup_genre == params[:genre]) )\n flash[:error] = \"Song file did not save\"\n redirect_to edit_song_path(@song)\n end\n params[:song][:filemod] = Time.now\n respond_to do |format|\n if @song.update_attributes(params[:song])\n flash[:note] = 'Song was successfully updated.'\n format.html { redirect_to(@song) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n else\n flash[:error] = \"Song or its file Was not found\"\n redirect_to(songs_url)\n end\n end", "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def parse_hashtags\n hashtags = extract_hashtags(@title)\n hashtags += extract_hashtags(@description)\n @albums.each do |album|\n hashtags += extract_hashtags(album['name'])\n hashtags += extract_hashtags(album['description'])\n end\n\n if @tags\n @tags.concat hashtags.uniq\n @tags = @tags.uniq\n else\n @tags = hashtags.uniq\n end\n end", "def album_photos\n \n if album\n album.photos\n else\n []\n end\n \n end", "def test_get_tag\n ogg = dummy()\n\n assert_equal %w{Acoustic Rock}.to_set, ogg['GENRE']\n assert_equal Set[\"öäüoΣø\"], ogg['UNICODETAG']\n\n assert_empty ogg['UNKNOWN']\n assert ogg['UNKNOWN'].frozen?\n end", "def current_album\n current_album_view.album\n end", "def set_album\n @album = Album.friendly.find(params[:id])\n end", "def get_metadata_file album\n Albatross::ThrowIf.is_nil? album, \"album\"\n \"storage/dropbox/#{album}.yml\"\nend", "def test_photo_analyzer_exists\n analyzer = Importer::PhotoAnalyzer.new(@test_flickr_photo_exists)\n assert analyzer.char == 'a', 'Expecting char a'\n assert analyzer.exists, 'This photo already exists'\n assert !analyzer.import, 'This photo does not need to be imported'\n assert analyzer.tags.count == 2 ,'Tags should contain 2 elements'\n assert analyzer.tags.include?('tag1'), 'Tags should contain tag1'\n assert analyzer.tags.include?('tag2'), 'Tags should contain tag3'\n assert !analyzer.tags.include?('canon'), 'Tags should not contain canon'\n assert !analyzer.delete, 'This photo should not be deleted'\n end", "def show_unplayed_by artist\n if $albums.any?\n x = nil\n artist_unplayed = []\n $albums.each do |album, status|\n if album[1].downcase == artist.downcase\n if status == \"unplayed\"\n puts \"#{album[0]} by #{album[1].gsub('\"', '')}\"\n artist_unplayed.push(album)\n x = true\n end\n end\n end\n if x == true\n return artist_unplayed\n else\n puts \"You don't have any unplayed albums by that artist.\"\n end\n else\n puts \"You don't have any albums! You should add some.\"\n end\nend", "def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end", "def albums\n sql = \"SELECT * FROM albums WHERE artist_id = #{@id};\"\n #Select all from albums when the id of the artist we are working on matched the artist_id in albums\n album_list = SqlRunner.run( sql )\n # Save the array to a varibale\n return album_list.map { |album| Album.new(album) }\n # Map the array to a hash.\n end", "def cover_aphoto\n @cover_aphoto ||= (album_photos.find_by_cover_photo(true) || album_photos.first)\n end", "def reviews\n Review.all.select do |r|\n r.album == self\n end\n end", "def display_album(name, spacing, box_height, margin, bar_width, color, button_name,i)\n box_width = bar_width - (margin * 2)\n font_size = 15\n top_seperator = 25\n name = truncate(name, 20)\n \n add_element(ELEMENT,margin,top_seperator + margin + spacing,box_width,box_height,color,TOP,button_name)\n add_element(FONT,margin + box_height + 10,top_seperator + (margin + (box_height / 2) - (font_size / 2)) + spacing,TOP,0.7,TEXT,\"txt_album_name\",name)\n add_element(IMAGE,margin,top_seperator + margin + spacing,box_height,box_height,IMAGE_COLOR,TOP,\"img_album_thumbnail\",@data_array[i].cover)\nend", "def duplicated_songs\n\n # Songs with the same artist, album and name\n @repeated_songs = Song.all\n .joins( :album , :artist )\n .group( 'artists.name' , 'albums.name' , 'songs.name' )\n .having( 'count(*) > 1' )\n .order( 'artists.name' , 'albums.name' , 'songs.name' )\n .pluck( 'artists.name' , 'albums.name' , 'songs.name' , 'count(*)' )\n\n # Songs with with the same artist and name, one with no album and other\n # with one\n @repeated_no_album = Song.all\n .joins( :album , :artist )\n .joins('INNER JOIN songs s2 ON songs.name = s2.name AND ' +\n 'songs.artist_id = s2.artist_id AND songs.album_id <> s2.album_id')\n .joins( 'INNER JOIN albums a2 ON s2.album_id = a2.id' )\n .where( 'albums.name = ?' , Album::UNKNOWN_ALBUM_NAME )\n .pluck( 'artists.name' , 'songs.name' , ' a2.name' )\n\n @short_songs = Song.all\n .joins( :album , :artist )\n .where( 'songs.seconds < 5' )\n .order( 'artists.name' , 'songs.name' , 'albums.name' )\n\n duplicated_wikilinks = Artist.all\n .where( \"coalesce( artists.wikilink , '' ) <> ''\" )\n .group( 'artists.wikilink' )\n .having( 'count(*) > 1' )\n .pluck( 'artists.wikilink' )\n\n @duplicated_artists = Artist.all\n .where( wikilink: duplicated_wikilinks )\n .order( :wikilink , :name )\n\n end", "def sort_album(value)\n @ole.SortAlbum = value\n nil\n end", "def show_all_by artist\n if $albums.any?\n x = nil\n artist_albums = []\n $albums.each do |album, status|\n if album[1].downcase == artist.downcase\n puts \"#{album[0]} by #{album[1].gsub('\"', '')} (#{status})\"\n artist_albums.push(album)\n x = true\n end\n end\n if x == true\n return artist_albums\n else\n puts \"You don't have any albums by that artist.\"\n end\n else\n puts \"You don't have any albums! You should add some.\"\n end\nend", "def uniq_tag?(tag)\n values = @selected_files.map { |file| file[tag] }\n values.reduce(true) { |r, v| r && (v.size == 1) } && (values.map { |v| v.first }.uniq.length == 1)\n end", "def search\n if params[:tag]\n @pictures = Picture.tagged_with(params[:tag])\n elsif params[:search] \n @pictures = Picture.tagged_with(params[:search])\n else \n redirect_to albums_path and return\n end\n render \"index\"\n end", "def album\n @album ||= Album.includes(:images, :poster_image)\n .where(id: params[:id], user_id: user_id)\n .take || halt(404)\n\tend", "def album\n # @friend_id = params[:object_id] unless (params[:object_id] == 'null' || params[:object_id].blank?)\n # if @friend_id\n # friend_data = current_user.picasa_client.user(@friend_id)\n # @friend_name = friend_data.author.name \n # end\n per_page = (params[:limit] ? params[:limit].to_i : 10)\n search_params = {\n albumId: params[:id],\n pageSize: per_page\n }\n if params[:page_token]\n search_params[:pageToken] = params[:page_token]\n end\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n @photos = PicasaPhoto.picasa_request_with_refresh( current_user.picasa_identity ) do\n r = goog.search( search_params )\n @next_page_token = r[\"nextPageToken\"]\n Rails.logger.debug \"[DEBUG] r: #{r}\"\n (r[\"mediaItems\"] || []).map{|mi| PicasaPhoto.new_from_api_response( mi ) }\n end\n # @photos = PicasaPhoto.get_photos_from_album(current_user, params[:id], search_params) \n @synclink_base = params[:synclink_base] unless params[:synclink_base].blank?\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, \n :local_photos => false,\n :organized_by_album => true\n }\n end\n end\n end", "def ensure_correct_media_id\n # only fandoms tags must have medias\n return unless self[:type] == 'Fandom'\n\n uncategorized = Media.uncategorized\n\n # get the first media of the current tag which is not \"Uncategorized Fandoms\"\n current_media = ([self.media] + self.medias).compact\n media = (current_media - [uncategorized]).first\n\n # if we have a media, we don't need \"Uncategorized Fandoms\" as a media\n if media \n self.remove_media(uncategorized) if self.medias.include?(uncategorized)\n self.update_attribute(:media_id, media.id) if self.media == uncategorized\n end\n\n # make sure the tag has a media id\n if !self.media_id # we don't have a media id\n if !media # and we don't have a media\n # we don't have anything, but we're being wrangled, so add \"Uncategorized Fandoms\"\n self.update_attribute(:media_id, uncategorized.id)\n self.parents << uncategorized unless self.parents.include?(uncategorized)\n else # we do have a media\n # use the one for our first media\n self.update_attribute(:media_id, media.id)\n end\n end\n\n # if the media id isn't for our first media or \"Uncategorized Fandoms\", verify that it's a real media\n if !(self.media_id == uncategorized.id || (media && self.media_id == media.id))\n listed_media = Media.find(self.media_id)\n # it's not a real media or it's been removed\n if !listed_media.is_a?(Media) || !self.medias.include?(listed_media)\n if media\n self.update_attribute(:media_id, media.id)\n else\n self.update_attribute(:media_id, uncategorized.id)\n end\n end\n end\n\n end", "def addAlbum(name, length, genre, label, artist_id, price, stock)\n\n\t\tartist_name = $get.artistName(artist_id)\n\n\t\tif (artist_name[0])\n\t\t\turl = \"http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist=#{artist_name[0].gsub(' ','+')}&album=#{name.gsub(' ','+')}&api_key=8ea76991c5d4936f71710eb66b2e63ac\"\n\t\t\tresp = Net::HTTP.get_response(URI.parse(url)).body\n\t\t\tarr = Array.new\n\t\t\tdate = String.new\n\n\t\t\tdoc = Hpricot resp\n\n\t\t\t(doc/\"lfm\").each do |err|\n \t\t if err.attributes[\"status\"] == 'failed'\n \t\t arr << -3\n \t\t return arr\n \t end\n \t end\n\n\t\t\tarr[0] = getOrclStr((doc/\"lfm/album/wiki/summary\").inner_html.gsub(']]>','').gsub('<![CDATA[',''))\n\n\t\t\tif (arr[0]==nil || arr[0].length<5)\n\t\t\t\tarr[0] = \"N/A\"\n\t\t\tend\n\n\t\t\t(doc/\"lfm/album/image\").each do |r|\n\t\t\t\tif r.attributes[\"size\"] == 'large'\n\t\t\t\t\tarr[1] = r.inner_html\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tdate = (doc/\"lfm/album/releasedate\").inner_html\n\t\t\tif (date.length<5)\n\t\t\t\tarr[2] = -1\n\t\t\telse\n\t\t\t\ti=0\n\t\t\t\twhile i < date.length\n\t\t\t\t\tif date[i].chr == ','\n\t\t\t\t\t\tarr[2] = date[i-4, 4]\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\t\ti=i+1\n\t\t\t\tend\n\t\t\tend\n\n\t\t\ti=3\n\t\t\t(doc/\"lfm/album/tracks/track/name\").each do |r|\n\t\t\t\tarr[i] = getOrclStr(r.inner_html)\n\t\t\t\ti=i+1\n\t\t\tend\n\n\t\t\tresult = Array.new\n\t\t\tresult = $manage.addAlbum(name, length, genre, label, artist_id, arr[0], arr[1], arr[2], price, stock)\n\n\t\t\tunless result.first == 0\n\t\t\t return result\n\t\t end\n\n\t\t\tsong_length = \"3:00\"\n\t\t\tsong_genre = \"Other\"\n\t\t\tsong_desc = \"N/A\"\n\n\t\t\ti = 3\t\t\n\t\t\twhile i < arr.length\t\t\t\n\t\t\t\tres = $manage.addSong(result[1].to_i, arr[i], song_length, genre, (i-2), artist_id, song_desc, arr[1], arr[2], '0.99', '-1')\n\n\t\t\t\tunless res == 0\n\t\t\t\t result[0] = -5\n\t\t\t\t $db.execute(\"rollback\")\n\t\t\t\t return result;\n\t\t\t end\n\n\t\t\t\ti=i+1\n\t\t\tend\n\t\telse\n\t\t result = Array.new\n\t\t result << -4\n\t\t\treturn result\n\t\tend\n\t\t$db.execute(\"commit\")\n\t\tresult\n\tend", "def photo_name\n if imageable_type == \"Album\"\n self.update(photo_title: \"#{self.imageable.album_name} photo #{self.id}\")\n end\n end", "def get_tracks_url(album)\n tracks_url = ''\n if album.first == 'Twist and Shout' || album.first == 'A Hard Day\\'s Night' || album.first == 'Yellow Submarine'\n tracks_url = \"https://en.wikipedia.org/wiki/#{album.first} (album)\"\n elsif album.first == 'Something New' || album.first == 'Revolver' || album.first == 'Let It Be'\n tracks_url = \"https://en.wikipedia.org/wiki/#{album.first} (Beatles album)\"\n elsif album.first == 'The Beatles (\"The White Album\")'\n tracks_url = \"https://en.wikipedia.org/wiki/The_Beatles_(album)\"\n else\n tracks_url = \"https://en.wikipedia.org/wiki/#{album.first}\"\n end\n return tracks_url\nend", "def metadata_for_album_photos\n commentables = Commentable.find_for_album_photos(params[:album_id])\n render_commentables(commentables)\n end", "def sort_album\n @ole.SortAlbum\n end", "def get_album_songs_url(album_url)\r\n\t\t\thtml_doc = get_html_doc(album_url)\r\n\t\t\tlinks = html_doc.css('a')\r\n\t\t\tlinks.map {|link| (link.attribute('href').to_s =~ /mp3-song.html/) ? \"http://pzmp3.com/\"+link.attribute('href').to_s : \"\"}.sort.delete_if{|href| href.empty?}\r\n\t\tend", "def album!(options = {})\n raise NotImplementedError(\"Subclasses should implement this!\")\n end", "def amg_album(id, options={})\n perform_lookup('amgAlbumId', id, options)\n end", "def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end", "def itunes\n if self.album.present? && self.album.itunes.present?\n self.album.itunes\n else\n read_attribute(:itunes)\n end\n end", "def store_owner_id\n self.user_id = self.album.user_id\n end", "def document_media_is_unique\n return if self.documents.count == 0\n\n valid = true\n\n corpus_media = Array.new\n\n self.documents.each { |d| corpus_media.push(:id => d.id, :media => d.media_descriptors) }\n\n last_media_urls = Array.new\n last = self.documents.last\n last.media_descriptors.each { |m| last_media_urls.push(m[:media_url]) }\n\n corpus_media.each do |m|\n if m[:id] != last.id then\n item_media_urls = Array.new\n m[:media].each { |m| item_media_urls.push(m[:media_url]) }\n\n if (last_media_urls == item_media_urls)\n valid = false\n break\n end\n end\n end\n\n errors.add :file, \"contains a media set already in this corpus.\" if valid == false\n end", "def set_admin_album_tag\n @admin_album_tag = Admin::AlbumTag.find(params[:id])\n end", "def assign_to_featured_album\r\n return if self.is_a?(Board)\r\n if self.is_in_startpage\r\n return if self.album_ids.include?(self.user.featured_album.id)\r\n self.albums << self.user.featured_album\r\n self.save!\r\n end\r\n end", "def set_album\n @album = Album.find_by(id: params[:id])\n end", "def print_album album\n puts 'Album Artist is ' + album.artist.to_s\n puts 'Album Title is ' + album.title.to_s\n puts 'Genre is ' + album.genre.to_s\n puts $genre_names[album.genre]\n print_tracks(album.tracks)\nend", "def album_params\n params.require(:album).permit(:id, :artist_id, :project_id, :album_id, :title, :release_date, :cover_art, :remove_cover_art, :genre, :genre_list, :tag_list)\n end", "def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end", "def album_photo_ids\n @album_photo_ids ||= Rails.cache.fetch(album_photo_ids_key, :expires_in => 1.hour) do\n self.photos.all(:select => \"id\").map(&:id)\n end\n end", "def album_params # strong params ( see docs)\n params.require(:album).permit(:title, :released, :image, :musician_id)\n end" ]
[ "0.6923608", "0.67246413", "0.6523389", "0.65015626", "0.6436978", "0.6390941", "0.6377134", "0.6305919", "0.6252742", "0.62405795", "0.62250346", "0.619325", "0.6103119", "0.6096799", "0.6064998", "0.603348", "0.6000499", "0.5995257", "0.5979279", "0.59691954", "0.5966707", "0.59134954", "0.59069216", "0.5904796", "0.586431", "0.584593", "0.58299917", "0.58274305", "0.5825815", "0.58217734", "0.5805003", "0.5803492", "0.5777766", "0.5774824", "0.5771572", "0.5771026", "0.5762108", "0.5751274", "0.57418036", "0.57307804", "0.5706909", "0.5675569", "0.5670996", "0.5663421", "0.56430846", "0.56407225", "0.56404346", "0.56380796", "0.55870134", "0.5585754", "0.5577034", "0.55703086", "0.556908", "0.55676544", "0.5564842", "0.55629146", "0.5558098", "0.5544402", "0.5541787", "0.55366707", "0.5535776", "0.55192363", "0.5517773", "0.55136466", "0.5511972", "0.5511684", "0.55035996", "0.5497276", "0.54865944", "0.5470738", "0.5468282", "0.54592454", "0.5456288", "0.5453671", "0.54502106", "0.54470474", "0.5444243", "0.5439966", "0.54351133", "0.54190296", "0.54089034", "0.5406056", "0.5393734", "0.5392869", "0.53867537", "0.5380477", "0.53772235", "0.53771967", "0.53732526", "0.537072", "0.5369157", "0.53613365", "0.5354146", "0.5339041", "0.5335679", "0.5334719", "0.5331253", "0.53301126", "0.53281784", "0.53271246" ]
0.76919574
0
Everything should have the same year tag
def all_same_year?(tags) all_same_tag?(tags, :year) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def year() end", "def match_year?(doc, date)\n return true unless year\n\n idate = RelatonBib.parse_date doc[\"issued-date\"], false\n idate.between? date, date.next_year.prev_day\n end", "def year? = unit == 'year'", "def year; end", "def year; end", "def could_be_year?(year); end", "def publication_year\n end", "def year\n @year ||= details.at(\"h1[itemprop='name'] span#titleYear a\").text.parse_year rescue nil\n end", "def year\n end", "def w_year; end", "def year\n self.range('year')\n end", "def year\n 2020\n end", "def min_year\n 2015\n end", "def should_have_year?\n self.released\n end", "def first_year\n 2012\n end", "def year\n return @year\n end", "def facet_year_group_for_solr\n result = \"\"\n years = associated_years\n logger.debug \"CHECKING: #{years}\"\n current_year = Time.now.year\n if years.length > 0\n #logger.debug \"YGFS:T1\"\n for year_string in years\n # logger.debug \"YGFS:T2\"\n year = year_string.to_i\n if year == current_year\n # logger.debug \"YGFS:T3 - current year match\"\n result << \"current \"\n elsif year == (current_year+1)\n # logger.debug \"YGFS:T4 - next year match\"\n result << \"next \"\n elsif year < (current_year)\n # logger.debug \"YGFS:T5 - previous years\"\n result << \"previous \"\n elsif year >> (current_year + 1)\n # logger.debug \"YGFS:T6 - future past next\"\n result << \"future \"\n end\n end\n #no years found\n else \n # logger.debug \"YGFS:T7 - none found\"\n result = \"none \"\n end\n \n # logger.debug \"YGFS: #{years} => #{result}\"\n result.strip.split(' ').uniq.sort.join(' ')\n end", "def multi_year?\n (multi_year)\n end", "def year_only?(date)\n\t\tdate.length == 4 && @@year_rgx.match(date)\n\tend", "def no_repeat_years(first_year, last_year)\nend", "def year\n self._id['year']\n end", "def comment_year(datetime)\n datetime.year != DateTime.now.year ? \"#{datetime.year} \" : \"\"\n end", "def year(input) = new_year(input).year - 621", "def year?\n @year\n end", "def year_only(dates)\n dates.length == 2 && dates.first.end_with?(\"-01-01T00:00:00Z\") && dates.last.end_with?(\"-12-31T23:59:59Z\")\n end", "def raw_year\n start_on.year\n end", "def publication_year\n super(:dc_date)\n end", "def year?(v = nil)\n super(v || value)\n end", "def update_big_year\n current_year = Time.zone.now.year\n return unless (created_at.year == current_year) && timestamp_changed?\n if user.subscribed?(current_year) || big_year == current_year\n self.big_year = timestamp.try(:year) == current_year ? current_year : 0\n end\n end", "def release_year\n document.search(\"//h5[text()^='Release Date']/..\").innerHTML[/\\d{4}/]\n end", "def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select { |e| not_repeat_year?(e) }\nend", "def year?(v)\n normalize(v).to_s.match?(MATCH_PATTERN[:year])\n end", "def year=(value)\n @year = value\n end", "def associated_years\n years = \"\"\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \n years << start_date.year.to_s if !start_date.blank?\n years << ' '\n years << event_finish.year.to_s if !event_finish.blank?\n \n #remove duplicates and trim off spaces\n unique_years = years.strip.split(' ').uniq.sort\n result = unique_years\n if unique_years.length > 1\n result = []\n for y in unique_years[0]..unique_years[1]\n result << y\n end\n end\n result\n #now we have the 2004-2008 case to deal with, we wish to create [2004,2005,...2008]\n \n end", "def years_needed\n 30\n end", "def years() 365 * days end", "def show_publication_year? _field_config, doc\n doc['journal_title_ts'].blank? && doc['conf_title_ts'].blank? && doc['publisher_ts'].blank?\n end", "def start_year\n Time.now.year - 75\n end", "def year_person? = unit == 'year-person'", "def date_same_year\n\t\tif desde.present? && hasta.present? && Date.parse(desde.to_s).year!=Date.parse(hasta.to_s).year\n\t\t\terrors.add(:desde,\"No se puede seleccionar un periodo que incluya años diferentes.\")\n\t\tend\n\tend", "def has_year?\r\n is_category_type? %w(asset vehicle)\r\n end", "def all_year\n beginning_of_year..end_of_year\n end", "def match_year\n @year ? { 'fiscal_quarter_id' => /^#{@year}/i } : {}\n end", "def year\n current_year = Date.today.year\n\n case raw_year\n when current_year; \"this year\"\n when current_year.next; \"next year\"\n when current_year.pred; \"last year\"\n else; raw_year.to_s\n end\n end", "def new_year(date) = ::Date.new(Integer === date ? date : date(date).year, 1, 1, reform_jd).new_start(::Date::GREGORIAN)", "def same_year? \n same_year_songs = Song.all.select{|song| song.release_year == release_year}\n same_year_songs.select!{|song| song.title == title}\n !same_year_songs.nil?\n end", "def gas_year\n y = year\n if self< Date.new(y,10,1)\n y\n else\n y+1\n end\n end", "def year\n return @year\n end", "def year\n date&.strftime('%Y')\n end", "def year\n document.search('a[@href^=\"/year/\"]').innerHTML.to_i\n end", "def start_year\n Time.now.year - 18\n end", "def year\n @year ||= TODAY.year\n end", "def cwyear\n end", "def select_year(date, options = T.unsafe(nil), html_options = T.unsafe(nil)); end", "def year\n created.strftime '%Y'\n end", "def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select{|yr|not_repeat_year?(yr)}\nend", "def event_of_year?(event)\n event.include? year\n end", "def timestamp_for_year\n if timestamp > Time.zone.now.at_beginning_of_year\n self.errors.add(:timestamp, 'should be not earlier then the beginning of this year.')\n end\n end", "def age_verifier( x, y)\n current_year = Time.now.year\n if x + y == current_year\n true\n else \n false\n end\nend", "def year\n return @t_year\n end", "def normalize_dates!\n pub_date = self.emma_publicationDate&.to_s\n pub_year = pub_date&.first(4)\n if pub_date&.end_with?('-01-01')\n self.dcterms_dateCopyright ||= IsoYear.new(pub_year)\n cpr_date = self.dcterms_dateCopyright.to_s\n self.emma_publicationDate = nil if cpr_date == pub_year\n elsif (cpr_date = self.dcterms_dateCopyright&.to_s)\n self.dcterms_dateCopyright = nil if cpr_date == pub_year\n end\n end", "def handle_om_gr\n handle_om\n next_tag\n handle_gr\n # ignore unit\n @year = @local_date.year + @modifier\n next_tag\n end", "def year_name(number); end", "def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select {|x| not_repeat_year?(x) }\nend", "def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).select { |year| not_repeat_year?(year) }\nend", "def end_year\n Time.now.year \n end", "def year\n self.class.get_year(@bits)\n end", "def build_header_year\n \"#{begin_date.year}/#{end_date.year}\"\n end", "def current_year?\n Application.current_year.include? self.created_at.to_date\n end", "def valid?(v)\n year?(v)\n end", "def year\n (created_at || Time.now).year\n end", "def year_rome_founded\n bce(753)\n end", "def year\n Time.zone.now.year\n end", "def year=(value)\n RegexValidator.validate \"DateGroupItem.year\", /\\d{4}/, value\n @year = value\n end", "def includes?(date)\n @years.include?(date.year)\n end", "def no_repeat_years(first_yr, last_yr)\n years = (first_yr..last_yr)\n years.select { |year| year.to_s.chars.uniq == year.to_s.chars }\nend", "def year_integer\n return self.year_of_publication if !self.year_of_publication.nil?\n return self.source.year if !self.source_id.nil?\n nil\n end", "def include_year_in_dates?\n if @time.year != Date.today.year\n # If the year was in the past, always include the year\n return true\n end\n\n if @time.year == Date.today.year && @time.month < (Date.today.month - 4)\n # If the year is this year, include if it happened more than 6 months\n # ago.\n return true\n end\n end", "def publication_year(field = nil)\n IsoYear.cast(find_record_items(field).first)&.to_s if field\n end", "def oldest_tag_by_ref_year(kw)\n oldest = 9999\n self.tags.by_keyword(kw).each do |t|\n oldest = t.ref.year if !t.ref.blank? && !t.ref.year.blank? && t.ref.year.to_i < oldest\n end\n return nil if oldest == 9999\n\n oldest\n end", "def test_holidays_year\n years = Services::Holiday::DATES.map do |d|\n Date.parse(d).strftime('%Y')\n end.uniq\n\n current_year = Services::Holiday.current_date.strftime('%Y')\n\n assert(years.include?(current_year))\n end", "def make_one_year_older\n @age += 1\n end", "def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n start_year.to_s\n else\n start_year.to_s + '-' + end_year.to_s\n end\n end", "def year(value)\n @ole.Year = value\n nil\n end", "def vintage?\n year <= 1982\n end", "def validate_year(input, year)\n max_year = Date.today.year + 2\n year <= max_year && year >= 1900\n end", "def make_one_year_older\n @age +=1\n end", "def bib_results_filter(result, year)\n missed_years = []\n result.each do |r|\n item = r.fetch\n item.fetched = Date.today.to_s\n return { ret: item } if !year\n\n item.date.select { |d| d.type == \"published\" }.each do |d|\n return { ret: item } if year.to_i == d.on(:year)\n\n missed_years << d.on(:year)\n end\n end\n { years: missed_years }\n end", "def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).to_a.select { |year| not_repeat_year?(year) }\nend", "def year\n ((semester - 1) / 2) + 1\n end", "def parse_year(time)\n year = time.strftime(\"%Y\").to_i\n sounds_for_number(year / 100) + sounds_for_number(year % 100)\n end", "def appropriate_year?\n if released\n if release_year.nil?\n errors.add(:release_year, \"Release year must exist if it is released\")\n elsif release_year > Time.now.year\n errors.add(:release_year, \"Release year must be less than or equal to the current year\")\n end\n end\n end", "def make_year(year, bias); end", "def no_repeat_years(first_yr, last_yr)\n\n result = []\n (first_yr..last_yr).each do |year|\n str = year.to_s\n result << year if not_repeat_year?(str)\n end\n\n result\nend", "def release_not_future_year\n #invalid, if released and release_year is greater than current year\n if release_year && release_year.to_i > Time.now.strftime(\"%Y\").to_i\n errors.add(:release_year, \"cannot be in the future\")\n end\n end", "def year\n doc.search(\"table.info a[href*='/m_act%5Byear%5D/']\").text.to_i\n end", "def effective_year\n if next_year_start_at && Time.zone.now < 1.year.from_now(next_year_start_at)\n if Time.zone.now < next_year_start_at\n return Time.zone.now.year\n elsif Time.zone.now >= next_year_start_at\n if Time.zone.now.year == next_year_start_at.year\n return Time.zone.now.year + 1\n else\n return Time.zone.now.year\n end\n end\n elsif Time.zone.now.month == 12 && Time.zone.now.day >= 1\n return Time.zone.now.year + 1\n end\n\n Time.zone.now.year\n end", "def no_repeat_years(first_yr, last_yr)\n years = (first_yr..last_yr).to_a\n years.select {|year| not_repeat_year?(year)}\n\nend", "def a_year()\n now = Time.now\n if now.month < 4\n now.year - 1\n else\n now.year\n end\nend", "def single_pub_year(ignore_approximate, method_sym)\n result = send(method_sym, date_issued_elements(ignore_approximate))\n result ||= send(method_sym, date_created_elements(ignore_approximate))\n # dateCaptured for web archive seed records\n result || send(method_sym, mods_ng_xml.origin_info.dateCaptured.to_a)\n end" ]
[ "0.7077845", "0.7006944", "0.69565284", "0.68290323", "0.68290323", "0.66205627", "0.6616259", "0.6578683", "0.6476764", "0.64315605", "0.6416924", "0.6416281", "0.6391615", "0.6381706", "0.6340546", "0.63311565", "0.63275373", "0.63248825", "0.6311434", "0.6299756", "0.6283089", "0.6259603", "0.6256287", "0.62519866", "0.6210173", "0.6202029", "0.62010473", "0.61998713", "0.61925596", "0.61919194", "0.61712676", "0.61683387", "0.61558795", "0.6148587", "0.61387444", "0.6125229", "0.6116223", "0.6114361", "0.6111145", "0.610782", "0.6104854", "0.6097446", "0.60940826", "0.60910034", "0.60851926", "0.60788476", "0.60741377", "0.6069216", "0.60680693", "0.6064151", "0.6060434", "0.6057366", "0.60539883", "0.60520977", "0.60517615", "0.60350055", "0.60331863", "0.6028275", "0.6026711", "0.60179615", "0.6005697", "0.6002428", "0.6001203", "0.5997689", "0.599264", "0.59742755", "0.59706444", "0.5968604", "0.5952629", "0.59523576", "0.59441066", "0.5937333", "0.59330547", "0.59315723", "0.5929371", "0.59254307", "0.5925413", "0.5924542", "0.5923897", "0.59187675", "0.59076095", "0.5890174", "0.58890784", "0.5886904", "0.5884405", "0.588222", "0.5876795", "0.58752596", "0.5873296", "0.58732224", "0.5868054", "0.5860645", "0.58542573", "0.5852858", "0.58501905", "0.58490825", "0.58392906", "0.583363", "0.5832048", "0.58064467" ]
0.76637894
0
And probably of the same genre. (Who cares, really, about the genre tag anyway?)
def all_same_genre?(tags) all_same_tag?(tags, :genre) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def genres\n songs.collect do |song|\n song.genre\n end\n .uniq #does not return duplicate genres if the artist has more than one song of a particular genre (artist has many genres through songs)\n end", "def genre; end", "def genre; end", "def genre\n genres = tracks.map{|t| t.genre}.compact\n genres.uniq.size == 1 and genres.first\n end", "def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end", "def genres\n songs.collect{|song| song.genre}.uniq\n end", "def genres \n songs.collect {|song| song.genre}.uniq \n\n end", "def genres\n songs.map{|song|song.genre}.uniq\n end", "def genres\n self.songs.collect {|song| (song.genre) }.uniq\n end", "def genres\n self.songs.map { |song| song.genre }.uniq\n end", "def genres\n self.songs.collect {|song| song.genre}.uniq\n end", "def genres\n @songs.collect{|song| song.genre }.uniq\n end", "def genres\n @songs.collect { |song| song.genre }.uniq\n end", "def genre_name\n self.genre ? self.genre.name : nil\n end", "def genre_name\n self.genre ? self.genre.name : nil\n end", "def genre_name\n \tif self.genre\n \t\tself.genre.name\n \tend\n end", "def genres\n @songs.collect do |song|\n song.genre\n end.uniq\n end", "def genre?\n true\n end", "def fav_genre\n # NOTE : DID NOT ADD GENRES YET\n # r.shows.genres\n \"WIP - no genres yet\"\n end", "def genres\n\t\t@songs.collect {|g| g.genre}\n\tend", "def genres\n songs.map do |song| song.genre end\n end", "def genres\n songs.map {|song| song.genre}\n end", "def genre_name\n # self.genre.name\n self.genre ? self.genre.name : ''\n end", "def genres #How to shorten? \n array = []\n songs.each do |song_instance|\n array << song_instance.genre \n end\n array.uniq\n end", "def genres\n @songs.collect {|s| s.genre}\n end", "def genres\n songs.map {|song| song.genre }\n end", "def genres\n Genre.all.select{|genre| genre.book == self }\n end", "def bookGenre\n\t\tarr =[]\n\t\tcurrent_user.reads.each do |f|\n\t\t\tarr.push(Book.find_by_id(f.book_id).genre)\n\t\tend\n\t\th = Hash.new(0)\n\t\t\tarr.each do |word|\n\t\t\th[word] += 1\n\t\tend\n\t\tgenre = h.sort_by{|word,count| count}\n\t\tgenre = genre.reverse # Hash highest the genre picked the most\n\n\t\tarr2 =[]\n\t\tgenre.each do |key,value|\n\t\t\tarr2.push(key)\n\t\tend\n\t\tif(arr2.size > 1)\n\t\t\t@popGenre = arr2.at(0)\n\t\telse\n\t\t\t@popGenre = \"Adventure\"\n\t\tend\n\tend", "def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end", "def genres\r\n self.songs.collect do |song|\r\n song.genre\r\n end\r\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genre\n @genre\n end", "def genre\n @genre\n end", "def genre\n @genre\n end", "def songs\n Song.all.select {|song_name| song_name.genre == self}\n end", "def genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end", "def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self) # could've used the artist.add_song way \n end", "def genres\n all_genres = []\n Song.all.each do |x|\n if x.artist == self\n all_genres << x.genre\n end\n end\nall_genres\nend", "def get_genre_name\n self.genre.name\n end", "def genres\n self.songs.map do |song|\n song.genre\n end.uniq\n #unduped.uniq #uniq only works on an array\n end", "def genre_list\n {\"1\" => 'シーバス', \"2\" => 'バス', \"3\" => \"青物\",\n \"4\" => \"フラットフィッシュ\", \"6\" => \"アジ\"}\n end", "def genre(hash)\n\thash.group_by { |k, v| v[:genre] }\nend", "def genres\n Song.all.collect{|song|song.genre}\n end", "def genres\n to_array search_by_itemprop 'genre'\n end", "def genres\n self.songs.map {|x| x.genre}\n end", "def songs\n Song.all.select do |song|\n song.genre == self\n end\n end", "def songs\n Song.all.select do |song|\n song.genre == self\n end\n end", "def songs\n Song.all.select do |song|\n song.genre == self \n end\n end", "def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self)\n end", "def genre=(genre)\n @genre = genre\n if genre.class == Genre\n genre.songs << self unless genre.songs.include?(self)\n end\n end", "def genre=(genre)\n @genre = genre #assigns a genre to the song (song belongs to genre)\n genre.songs << self unless genre.songs.include?(self) #adds the song to the genre's collection of songs (genre has many songs); does not add the song to the genre's collection of songs if it already exists therein\n end", "def genres\n self.songs.map do |artist_song|\n artist_song.genre\n end\n end", "def songs\n Song.all.select{|x| x.genre == self}\nend", "def genres\n self.songs.collect {|song| song.genre}\nend", "def genre\n @ole.Genre\n end", "def genre\n case result_item.format\n when \"Book\"\n \"book\"\n when :book_item\n \"bookitem\"\n when :conference_paper\n \"proceeding\"\n when :conference_proceedings\n \"conference\"\n when :report\n \"report\"\n when :serial\n \"journal\"\n when \"Article\"\n \"article\"\n else\n nil\n end \n end", "def lookup_genre(s)\n \tg = genre_list()\n \tg[s]\n end", "def genres\n document[\"genre\"].collect {|gender| gender[\"$\"]} rescue nil\n end", "def genre= (genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self)\n end", "def genre=(genre)\n @genre = genre\n \n # adds the song to the genre's collection of songs \n # (genre has many songs).\n # Doesn't add the song to the genre's collection of\n # songs if it already exists therein\n if !(genre.songs.include?(self))\n genre.songs << self\n end\n end", "def songs\n Song.all.select{|song| song.genre == self}\n end", "def songs\n Song.all.select{|song| song.genre == self}\n end", "def songs\n Song.all.select do |song|\n song.genre == self\n end\nend", "def genres\n songs.map do |song|\n song.genre\n end\nend", "def list_genre\n genre = gets.chomp\n Genre.all.each do |a|\n if a.name == genre\n a.songs.collect { |s| puts \"#{s.artist.name} - #{s.name} - #{s.genre.name}\" }\n end\n end\n end", "def artist_name_and_genre\n \"#{artist_name} - #{genre.name}\"\n end", "def genres_hash\n search_by_itemprop_hash 'genre'\n end", "def genre\n fetch('game.genre')\n end", "def songs\n Song.all.select {|song| song.genre == self}\n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def genre(value)\n @ole.Genre = value\n nil\n end", "def all_songs_with_genre(songs=songs_array, genre)\n songs.select do |song|\n binding.pry\n # song[:genre] == genre\n end\n end", "def genre=(genre)\n @genre = genre \n GENRES << genre \n end", "def genre=(genre)\n @genre = genre\n GENRES << genre\n end", "def genre=(genre)\n @genre = genre\n GENRES << genre\n end", "def genre=(genre)\n \t@genre = genre\n \t# Now that we've assigned a genre to a book, we also want to push that genre to GENRES:\n \tGENRES << genre\n end", "def plays_genres\n genres = Array.new\n self.genres.each do |genre|\n genres << genre.printable\n end\n genres.uniq\n end", "def genres\n document.search(\"h5[text()='Genre:'] ~ a[@href*=/Sections/Genres/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end", "def genres\n details.css(\"div.subtext a[href^='/genre/']\").map { |genre| genre.text } rescue []\n end", "def to_genre\n self\n end", "def list_genres\n Genre.all.uniq.sort { |genre1, genre2| genre1.name <=> genre2.name}.each.with_index(1) do |genre, i|\n puts \"#{i}. #{genre.name}\"\n end\n end", "def books\n Book.all.select do |book|\n # Is this book's genre object matching to \"me\"?\n book.genre == self\n end\n end", "def genre=(genre)\n @genre = genre\n GENRES << genre\n end", "def store_genres(attrs)\n attrs[:genres].each { |genre| genre.downcase! }\n existing_genres = self.get_genres(attrs[:song_id])\n attrs[:genres].each do |genre|\n if existing_genres.include?(genre) == false\n Genre.create({ song_id: attrs[:song_id], genre: genre })\n end\n end\n end", "def genre= (genre)\n @genre = genre\n GENRES << genre\n end", "def artist_by_genre\n all_genres = Artist.all.map{|artist| artist.genre}.uniq.sort\n genre_name = prompt(\"Choose a genre: \", all_genres)\n artists = Artist.all.where(genre: genre_name).map{|artist| artist.name}\n puts \"**************************\"\n puts \"For #{genre_name}\"\n puts \"**************************\"\n prompt(\"Choose an Artist from #{genre_name}\", artists)\n end", "def genre=(genre)\n @genre = genre\n GENRES << genre\nend", "def find_subgenre(subgenres, subgenre_titles, description) \n description.downcase!\n subgenres.each_with_index do |subgenre, index|\n subgenre.each do |word|\n if description.include?(word)\n return subgenre_titles[index]\n end\n end\n end\n return \"other\"\n end", "def select_by_genre(genre)\n where(\"genre = ?\", genre).abc_title\n end", "def genres\n self.songs.collect do |song| #call the artist class on the songs method and collect the song\n song.genre #then call the genre on the song\n end\n end", "def genre=(set_genre)\n @genre = set_genre\n # add this instance\n @genre.add_song(self) unless @genre.songs.include?(self)\n end", "def title_genre\n \" [ #{@document.first(:form_genre_display)} ]\" unless @document[:form_genre_display].nil?\n end", "def slug_candidates\n [\n :genre,\n [:genre, :artist],\n [:genre, :artist, :song_name],\n ]\n end", "def slug_candidates\n [\n :genre,\n [:genre, :artist],\n [:genre, :artist, :song_name],\n ]\n end", "def genres\n # look for a local variable called songs\n # look for a method on self. called songs => self.songs\n # looks up the parent chain\n self.songs.map do |song|\n song.genre\n end\n end" ]
[ "0.7438682", "0.73783296", "0.73783296", "0.73542935", "0.7340227", "0.71654063", "0.7084807", "0.7070509", "0.70590407", "0.70494056", "0.70195603", "0.69873226", "0.6970553", "0.69408435", "0.69408435", "0.6923133", "0.6910801", "0.69086796", "0.6896273", "0.68304724", "0.6801411", "0.6799923", "0.67994577", "0.6795019", "0.6734513", "0.6729665", "0.67265385", "0.6722533", "0.6722454", "0.67199814", "0.6688979", "0.6688979", "0.6688979", "0.6688979", "0.6688979", "0.6686441", "0.6686441", "0.6686441", "0.668147", "0.66799766", "0.6672952", "0.66513276", "0.6648373", "0.66310143", "0.6631004", "0.66189337", "0.6618626", "0.66015524", "0.65981716", "0.65924823", "0.65924823", "0.6576766", "0.6573295", "0.65549916", "0.6536949", "0.6522456", "0.6521806", "0.6487836", "0.6482389", "0.6480855", "0.6475158", "0.64691585", "0.6449408", "0.64376", "0.64371485", "0.64371485", "0.64315486", "0.64235127", "0.641316", "0.6390758", "0.6380432", "0.63724357", "0.6356636", "0.6355596", "0.6355596", "0.6343368", "0.6340053", "0.6321724", "0.6317051", "0.6317051", "0.6294862", "0.62796706", "0.625959", "0.62555796", "0.6231248", "0.62009066", "0.6200575", "0.6199481", "0.6190277", "0.61832803", "0.61678296", "0.61503655", "0.6149969", "0.6141789", "0.61208504", "0.6115405", "0.6107529", "0.6082232", "0.6082232", "0.6060702" ]
0.7803016
0
Hmmm. Problems with "featuring" and collaborations. This will need some thought. Let's see how it plays in everyday usage.
def all_same_artist?(tags) all_same_tag?(tags, :artist) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scientist; end", "def influences_these_works\n find_related_frbr_objects( :is_an_influence_on, :which_works?) \n end", "def addFeaturesAndLabel(team, earliest_date, latest_date, examples, labels)\n home_faceoffs = Game.where(\"home_team = ? and game_date > ? and game_date <= ?\", team, earliest_date, latest_date).order(\"game_date desc\")\n away_faceoffs = Game.where(\"away_team = ? and game_date > ? and game_date <= ?\", team, earliest_date, latest_date).order(\"game_date desc\")\n past_games = home_faceoffs.concat(away_faceoffs)\n # games sort in ascending order. The first game of the 2001 season is located first\n past_games = past_games.sort {|game1, game2| game1.game_date <=> game2.game_date }\n \n player_performances = Hash.new\n\n past_games.each_with_index do |past_game, index|\n feature_set = Feature.find_by_game_id(past_game.id)\n performances = Performance.where(\"game_id = ?\", past_game.id)\n\n performances.each do |perf|\n player = Player.find_by_id(perf.player_id)\n if !player_performances.has_key?(player.retrosheet_id)\n addBlankPlayer(player.retrosheet_id, player_performances)\n end\n end\n\n if past_game.home_team == team.to_s\n feature_set.home_batting_spot_1_walks_last_1_game = player_performances[past_game.home_batting_spot_1][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_2_walks_last_1_game = player_performances[past_game.home_batting_spot_2][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_3_walks_last_1_game = player_performances[past_game.home_batting_spot_3][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_4_walks_last_1_game = player_performances[past_game.home_batting_spot_4][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_5_walks_last_1_game = player_performances[past_game.home_batting_spot_5][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_6_walks_last_1_game = player_performances[past_game.home_batting_spot_6][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_7_walks_last_1_game = player_performances[past_game.home_batting_spot_7][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_8_walks_last_1_game = player_performances[past_game.home_batting_spot_8][\"walks_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_9_walks_last_1_game = player_performances[past_game.home_batting_spot_9][\"walks_last_1_game\"].reduce(:+)\n \n feature_set.home_batting_spot_1_walks_last_2_games = player_performances[past_game.home_batting_spot_1][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_2_walks_last_2_games = player_performances[past_game.home_batting_spot_2][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_3_walks_last_2_games = player_performances[past_game.home_batting_spot_3][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_4_walks_last_2_games = player_performances[past_game.home_batting_spot_4][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_5_walks_last_2_games = player_performances[past_game.home_batting_spot_5][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_6_walks_last_2_games = player_performances[past_game.home_batting_spot_6][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_7_walks_last_2_games = player_performances[past_game.home_batting_spot_7][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_8_walks_last_2_games = player_performances[past_game.home_batting_spot_8][\"walks_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_9_walks_last_2_games = player_performances[past_game.home_batting_spot_9][\"walks_last_2_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_walks_last_5_games = player_performances[past_game.home_batting_spot_1][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_2_walks_last_5_games = player_performances[past_game.home_batting_spot_2][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_3_walks_last_5_games = player_performances[past_game.home_batting_spot_3][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_4_walks_last_5_games = player_performances[past_game.home_batting_spot_4][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_5_walks_last_5_games = player_performances[past_game.home_batting_spot_5][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_6_walks_last_5_games = player_performances[past_game.home_batting_spot_6][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_7_walks_last_5_games = player_performances[past_game.home_batting_spot_7][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_8_walks_last_5_games = player_performances[past_game.home_batting_spot_8][\"walks_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_9_walks_last_5_games = player_performances[past_game.home_batting_spot_9][\"walks_last_5_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_walks_last_10_games = player_performances[past_game.home_batting_spot_1][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_2_walks_last_10_games = player_performances[past_game.home_batting_spot_2][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_3_walks_last_10_games = player_performances[past_game.home_batting_spot_3][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_4_walks_last_10_games = player_performances[past_game.home_batting_spot_4][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_5_walks_last_10_games = player_performances[past_game.home_batting_spot_5][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_6_walks_last_10_games = player_performances[past_game.home_batting_spot_6][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_7_walks_last_10_games = player_performances[past_game.home_batting_spot_7][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_8_walks_last_10_games = player_performances[past_game.home_batting_spot_8][\"walks_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_9_walks_last_10_games = player_performances[past_game.home_batting_spot_9][\"walks_last_10_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_walks_last_20_games = player_performances[past_game.home_batting_spot_1][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_2_walks_last_20_games = player_performances[past_game.home_batting_spot_2][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_3_walks_last_20_games = player_performances[past_game.home_batting_spot_3][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_4_walks_last_20_games = player_performances[past_game.home_batting_spot_4][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_5_walks_last_20_games = player_performances[past_game.home_batting_spot_5][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_6_walks_last_20_games = player_performances[past_game.home_batting_spot_6][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_7_walks_last_20_games = player_performances[past_game.home_batting_spot_7][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_8_walks_last_20_games = player_performances[past_game.home_batting_spot_8][\"walks_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_9_walks_last_20_games = player_performances[past_game.home_batting_spot_9][\"walks_last_20_games\"].reduce(:+)\n\n \n feature_set.home_batting_spot_1_walks_per_game_career = player_performances[past_game.home_batting_spot_1][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"career_walks\"] / player_performances[past_game.home_batting_spot_1][\"career_games\"]\n feature_set.home_batting_spot_2_walks_per_game_career = player_performances[past_game.home_batting_spot_2][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"career_walks\"] / player_performances[past_game.home_batting_spot_2][\"career_games\"]\n feature_set.home_batting_spot_3_walks_per_game_career = player_performances[past_game.home_batting_spot_3][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"career_walks\"] / player_performances[past_game.home_batting_spot_3][\"career_games\"]\n feature_set.home_batting_spot_4_walks_per_game_career = player_performances[past_game.home_batting_spot_4][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"career_walks\"] / player_performances[past_game.home_batting_spot_4][\"career_games\"]\n feature_set.home_batting_spot_5_walks_per_game_career = player_performances[past_game.home_batting_spot_5][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"career_walks\"] / player_performances[past_game.home_batting_spot_5][\"career_games\"]\n feature_set.home_batting_spot_6_walks_per_game_career = player_performances[past_game.home_batting_spot_6][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"career_walks\"] / player_performances[past_game.home_batting_spot_6][\"career_games\"]\n feature_set.home_batting_spot_7_walks_per_game_career = player_performances[past_game.home_batting_spot_7][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"career_walks\"] / player_performances[past_game.home_batting_spot_7][\"career_games\"]\n feature_set.home_batting_spot_8_walks_per_game_career = player_performances[past_game.home_batting_spot_8][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"career_walks\"] / player_performances[past_game.home_batting_spot_8][\"career_games\"]\n feature_set.home_batting_spot_9_walks_per_game_career = player_performances[past_game.home_batting_spot_9][\"career_games\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"career_walks\"] / player_performances[past_game.home_batting_spot_9][\"career_games\"]\n \n\n feature_set.home_batting_spot_1_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_2_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_3_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_4_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_5_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_6_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_7_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_8_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_9_batting_percentage_last_1_game = player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.home_batting_spot_1_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_2_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_3_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_4_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_5_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_6_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_7_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_8_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_9_batting_percentage_last_2_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_2_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_3_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_4_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_5_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_6_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_7_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_8_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_9_batting_percentage_last_5_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_2_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_3_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_4_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_5_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_6_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_7_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_8_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_9_batting_percentage_last_10_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_2_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_3_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_4_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_5_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_6_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_7_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_8_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_9_batting_percentage_last_20_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_batting_percentage_career = player_performances[past_game.home_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"career_hits\"] / player_performances[past_game.home_batting_spot_1][\"career_at_bats\"]\n feature_set.home_batting_spot_2_batting_percentage_career = player_performances[past_game.home_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"career_hits\"] / player_performances[past_game.home_batting_spot_2][\"career_at_bats\"]\n feature_set.home_batting_spot_3_batting_percentage_career = player_performances[past_game.home_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"career_hits\"] / player_performances[past_game.home_batting_spot_3][\"career_at_bats\"]\n feature_set.home_batting_spot_4_batting_percentage_career = player_performances[past_game.home_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"career_hits\"] / player_performances[past_game.home_batting_spot_4][\"career_at_bats\"]\n feature_set.home_batting_spot_5_batting_percentage_career = player_performances[past_game.home_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"career_hits\"] / player_performances[past_game.home_batting_spot_5][\"career_at_bats\"]\n feature_set.home_batting_spot_6_batting_percentage_career = player_performances[past_game.home_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"career_hits\"] / player_performances[past_game.home_batting_spot_6][\"career_at_bats\"]\n feature_set.home_batting_spot_7_batting_percentage_career = player_performances[past_game.home_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"career_hits\"] / player_performances[past_game.home_batting_spot_7][\"career_at_bats\"]\n feature_set.home_batting_spot_8_batting_percentage_career = player_performances[past_game.home_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"career_hits\"] / player_performances[past_game.home_batting_spot_8][\"career_at_bats\"]\n feature_set.home_batting_spot_9_batting_percentage_career = player_performances[past_game.home_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"career_hits\"] / player_performances[past_game.home_batting_spot_9][\"career_at_bats\"]\n\n feature_set.home_batting_spot_1_OPS_last_1_game = player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_2_OPS_last_1_game = player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_3_OPS_last_1_game = player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_4_OPS_last_1_game = player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_5_OPS_last_1_game = player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_6_OPS_last_1_game = player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_7_OPS_last_1_game = player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_8_OPS_last_1_game = player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_9_OPS_last_1_game = player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.home_batting_spot_1_OPS_last_2_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_2_OPS_last_2_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_3_OPS_last_2_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_4_OPS_last_2_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_5_OPS_last_2_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_6_OPS_last_2_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_7_OPS_last_2_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_8_OPS_last_2_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_9_OPS_last_2_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_OPS_last_5_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_2_OPS_last_5_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_3_OPS_last_5_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_4_OPS_last_5_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_5_OPS_last_5_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_6_OPS_last_5_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_7_OPS_last_5_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_8_OPS_last_5_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_9_OPS_last_5_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_OPS_last_10_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_2_OPS_last_10_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_3_OPS_last_10_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_4_OPS_last_10_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_5_OPS_last_10_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_6_OPS_last_10_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_7_OPS_last_10_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_8_OPS_last_10_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_9_OPS_last_10_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_OPS_last_20_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_2_OPS_last_20_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_3_OPS_last_20_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_4_OPS_last_20_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_5_OPS_last_20_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_6_OPS_last_20_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_7_OPS_last_20_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_8_OPS_last_20_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_9_OPS_last_20_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_OPS_career = player_performances[past_game.home_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_1][\"career_at_bats\"]\n feature_set.home_batting_spot_2_OPS_career = player_performances[past_game.home_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_2][\"career_at_bats\"]\n feature_set.home_batting_spot_3_OPS_career = player_performances[past_game.home_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_3][\"career_at_bats\"]\n feature_set.home_batting_spot_4_OPS_career = player_performances[past_game.home_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_4][\"career_at_bats\"]\n feature_set.home_batting_spot_5_OPS_career = player_performances[past_game.home_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_5][\"career_at_bats\"]\n feature_set.home_batting_spot_6_OPS_career = player_performances[past_game.home_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_6][\"career_at_bats\"]\n feature_set.home_batting_spot_7_OPS_career = player_performances[past_game.home_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_7][\"career_at_bats\"]\n feature_set.home_batting_spot_8_OPS_career = player_performances[past_game.home_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_8][\"career_at_bats\"]\n feature_set.home_batting_spot_9_OPS_career = player_performances[past_game.home_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"career_total_bases\"] / player_performances[past_game.home_batting_spot_9][\"career_at_bats\"]\n\n feature_set.home_batting_spot_1_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_2_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_3_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_4_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_5_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_6_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_7_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_8_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.home_batting_spot_9_strikeout_rate_last_1_game = player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.home_batting_spot_1_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_2_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_3_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_4_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_5_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_6_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_7_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_8_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.home_batting_spot_9_strikeout_rate_last_2_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_2_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_3_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_4_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_5_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_6_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_7_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_8_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.home_batting_spot_9_strikeout_rate_last_5_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_2_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_3_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_4_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_5_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_6_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_7_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_8_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.home_batting_spot_9_strikeout_rate_last_10_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.home_batting_spot_1_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_2_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_3_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_4_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_5_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_6_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_7_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_8_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.home_batting_spot_9_strikeout_rate_last_20_games = player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.home_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n \n feature_set.home_batting_spot_1_strikeout_rate_career = player_performances[past_game.home_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_1][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_1][\"career_at_bats\"]\n feature_set.home_batting_spot_2_strikeout_rate_career = player_performances[past_game.home_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_2][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_2][\"career_at_bats\"]\n feature_set.home_batting_spot_3_strikeout_rate_career = player_performances[past_game.home_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_3][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_3][\"career_at_bats\"]\n feature_set.home_batting_spot_4_strikeout_rate_career = player_performances[past_game.home_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_4][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_4][\"career_at_bats\"]\n feature_set.home_batting_spot_5_strikeout_rate_career = player_performances[past_game.home_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_5][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_5][\"career_at_bats\"]\n feature_set.home_batting_spot_6_strikeout_rate_career = player_performances[past_game.home_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_6][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_6][\"career_at_bats\"]\n feature_set.home_batting_spot_7_strikeout_rate_career = player_performances[past_game.home_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_7][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_7][\"career_at_bats\"]\n feature_set.home_batting_spot_8_strikeout_rate_career = player_performances[past_game.home_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_8][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_8][\"career_at_bats\"]\n feature_set.home_batting_spot_9_strikeout_rate_career = player_performances[past_game.home_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.home_batting_spot_9][\"career_strikeouts\"] / player_performances[past_game.home_batting_spot_9][\"career_at_bats\"]\n else\n \n feature_set.away_batting_spot_1_walks_last_1_game = player_performances[past_game.away_batting_spot_1][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_2_walks_last_1_game = player_performances[past_game.away_batting_spot_2][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_3_walks_last_1_game = player_performances[past_game.away_batting_spot_3][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_4_walks_last_1_game = player_performances[past_game.away_batting_spot_4][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_5_walks_last_1_game = player_performances[past_game.away_batting_spot_5][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_6_walks_last_1_game = player_performances[past_game.away_batting_spot_6][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_7_walks_last_1_game = player_performances[past_game.away_batting_spot_7][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_8_walks_last_1_game = player_performances[past_game.away_batting_spot_8][\"walks_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_9_walks_last_1_game = player_performances[past_game.away_batting_spot_9][\"walks_last_1_game\"].reduce(:+)\n\n feature_set.away_batting_spot_1_walks_last_2_games = player_performances[past_game.away_batting_spot_1][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_2_walks_last_2_games = player_performances[past_game.away_batting_spot_2][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_3_walks_last_2_games = player_performances[past_game.away_batting_spot_3][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_4_walks_last_2_games = player_performances[past_game.away_batting_spot_4][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_5_walks_last_2_games = player_performances[past_game.away_batting_spot_5][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_6_walks_last_2_games = player_performances[past_game.away_batting_spot_6][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_7_walks_last_2_games = player_performances[past_game.away_batting_spot_7][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_8_walks_last_2_games = player_performances[past_game.away_batting_spot_8][\"walks_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_9_walks_last_2_games = player_performances[past_game.away_batting_spot_9][\"walks_last_2_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_walks_last_5_games = player_performances[past_game.away_batting_spot_1][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_2_walks_last_5_games = player_performances[past_game.away_batting_spot_2][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_3_walks_last_5_games = player_performances[past_game.away_batting_spot_3][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_4_walks_last_5_games = player_performances[past_game.away_batting_spot_4][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_5_walks_last_5_games = player_performances[past_game.away_batting_spot_5][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_6_walks_last_5_games = player_performances[past_game.away_batting_spot_6][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_7_walks_last_5_games = player_performances[past_game.away_batting_spot_7][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_8_walks_last_5_games = player_performances[past_game.away_batting_spot_8][\"walks_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_9_walks_last_5_games = player_performances[past_game.away_batting_spot_9][\"walks_last_5_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_walks_last_10_games = player_performances[past_game.away_batting_spot_1][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_2_walks_last_10_games = player_performances[past_game.away_batting_spot_2][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_3_walks_last_10_games = player_performances[past_game.away_batting_spot_3][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_4_walks_last_10_games = player_performances[past_game.away_batting_spot_4][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_5_walks_last_10_games = player_performances[past_game.away_batting_spot_5][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_6_walks_last_10_games = player_performances[past_game.away_batting_spot_6][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_7_walks_last_10_games = player_performances[past_game.away_batting_spot_7][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_8_walks_last_10_games = player_performances[past_game.away_batting_spot_8][\"walks_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_9_walks_last_10_games = player_performances[past_game.away_batting_spot_9][\"walks_last_10_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_walks_last_20_games = player_performances[past_game.away_batting_spot_1][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_2_walks_last_20_games = player_performances[past_game.away_batting_spot_2][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_3_walks_last_20_games = player_performances[past_game.away_batting_spot_3][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_4_walks_last_20_games = player_performances[past_game.away_batting_spot_4][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_5_walks_last_20_games = player_performances[past_game.away_batting_spot_5][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_6_walks_last_20_games = player_performances[past_game.away_batting_spot_6][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_7_walks_last_20_games = player_performances[past_game.away_batting_spot_7][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_8_walks_last_20_games = player_performances[past_game.away_batting_spot_8][\"walks_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_9_walks_last_20_games = player_performances[past_game.away_batting_spot_9][\"walks_last_20_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_walks_per_game_career = player_performances[past_game.away_batting_spot_1][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"career_walks\"] / player_performances[past_game.away_batting_spot_1][\"career_games\"]\n feature_set.away_batting_spot_2_walks_per_game_career = player_performances[past_game.away_batting_spot_2][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"career_walks\"] / player_performances[past_game.away_batting_spot_2][\"career_games\"]\n feature_set.away_batting_spot_3_walks_per_game_career = player_performances[past_game.away_batting_spot_3][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"career_walks\"] / player_performances[past_game.away_batting_spot_3][\"career_games\"]\n feature_set.away_batting_spot_4_walks_per_game_career = player_performances[past_game.away_batting_spot_4][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"career_walks\"] / player_performances[past_game.away_batting_spot_4][\"career_games\"]\n feature_set.away_batting_spot_5_walks_per_game_career = player_performances[past_game.away_batting_spot_5][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"career_walks\"] / player_performances[past_game.away_batting_spot_5][\"career_games\"]\n feature_set.away_batting_spot_6_walks_per_game_career = player_performances[past_game.away_batting_spot_6][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"career_walks\"] / player_performances[past_game.away_batting_spot_6][\"career_games\"]\n feature_set.away_batting_spot_7_walks_per_game_career = player_performances[past_game.away_batting_spot_7][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"career_walks\"] / player_performances[past_game.away_batting_spot_7][\"career_games\"]\n feature_set.away_batting_spot_8_walks_per_game_career = player_performances[past_game.away_batting_spot_8][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"career_walks\"] / player_performances[past_game.away_batting_spot_8][\"career_games\"]\n feature_set.away_batting_spot_9_walks_per_game_career = player_performances[past_game.away_batting_spot_9][\"career_games\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"career_walks\"] / player_performances[past_game.away_batting_spot_9][\"career_games\"]\n \n\n feature_set.away_batting_spot_1_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_2_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_3_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_4_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_5_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_6_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_7_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_8_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_9_batting_percentage_last_1_game = player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"hits_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.away_batting_spot_1_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_2_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_3_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_4_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_5_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_6_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_7_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_8_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_9_batting_percentage_last_2_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"hits_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_2_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_3_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_4_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_5_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_6_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_7_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_8_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_9_batting_percentage_last_5_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"hits_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_2_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_3_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_4_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_5_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_6_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_7_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_8_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_9_batting_percentage_last_10_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"hits_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_2_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_3_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_4_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_5_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_6_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_7_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_8_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_9_batting_percentage_last_20_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"hits_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n \n feature_set.away_batting_spot_1_batting_percentage_career = player_performances[past_game.away_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"career_hits\"] / player_performances[past_game.away_batting_spot_1][\"career_at_bats\"]\n feature_set.away_batting_spot_2_batting_percentage_career = player_performances[past_game.away_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"career_hits\"] / player_performances[past_game.away_batting_spot_2][\"career_at_bats\"]\n feature_set.away_batting_spot_3_batting_percentage_career = player_performances[past_game.away_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"career_hits\"] / player_performances[past_game.away_batting_spot_3][\"career_at_bats\"]\n feature_set.away_batting_spot_4_batting_percentage_career = player_performances[past_game.away_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"career_hits\"] / player_performances[past_game.away_batting_spot_4][\"career_at_bats\"]\n feature_set.away_batting_spot_5_batting_percentage_career = player_performances[past_game.away_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"career_hits\"] / player_performances[past_game.away_batting_spot_5][\"career_at_bats\"]\n feature_set.away_batting_spot_6_batting_percentage_career = player_performances[past_game.away_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"career_hits\"] / player_performances[past_game.away_batting_spot_6][\"career_at_bats\"]\n feature_set.away_batting_spot_7_batting_percentage_career = player_performances[past_game.away_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"career_hits\"] / player_performances[past_game.away_batting_spot_7][\"career_at_bats\"]\n feature_set.away_batting_spot_8_batting_percentage_career = player_performances[past_game.away_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"career_hits\"] / player_performances[past_game.away_batting_spot_8][\"career_at_bats\"]\n feature_set.away_batting_spot_9_batting_percentage_career = player_performances[past_game.away_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"career_hits\"] / player_performances[past_game.away_batting_spot_9][\"career_at_bats\"]\n\n feature_set.away_batting_spot_1_OPS_last_1_game = player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_2_OPS_last_1_game = player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_3_OPS_last_1_game = player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_4_OPS_last_1_game = player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_5_OPS_last_1_game = player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_6_OPS_last_1_game = player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_7_OPS_last_1_game = player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_8_OPS_last_1_game = player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_9_OPS_last_1_game = player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"total_bases_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.away_batting_spot_1_OPS_last_2_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_2_OPS_last_2_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_3_OPS_last_2_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_4_OPS_last_2_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_5_OPS_last_2_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_6_OPS_last_2_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_7_OPS_last_2_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_8_OPS_last_2_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_9_OPS_last_2_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"total_bases_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_OPS_last_5_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_2_OPS_last_5_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_3_OPS_last_5_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_4_OPS_last_5_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_5_OPS_last_5_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_6_OPS_last_5_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_7_OPS_last_5_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_8_OPS_last_5_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_9_OPS_last_5_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"total_bases_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_OPS_last_10_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_2_OPS_last_10_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_3_OPS_last_10_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_4_OPS_last_10_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_5_OPS_last_10_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_6_OPS_last_10_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_7_OPS_last_10_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_8_OPS_last_10_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_9_OPS_last_10_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"total_bases_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_OPS_last_20_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_2_OPS_last_20_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_3_OPS_last_20_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_4_OPS_last_20_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_5_OPS_last_20_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_6_OPS_last_20_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_7_OPS_last_20_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_8_OPS_last_20_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_9_OPS_last_20_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"total_bases_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n\n \n feature_set.away_batting_spot_1_OPS_career = player_performances[past_game.away_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_1][\"career_at_bats\"]\n feature_set.away_batting_spot_2_OPS_career = player_performances[past_game.away_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_2][\"career_at_bats\"]\n feature_set.away_batting_spot_3_OPS_career = player_performances[past_game.away_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_3][\"career_at_bats\"]\n feature_set.away_batting_spot_4_OPS_career = player_performances[past_game.away_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_4][\"career_at_bats\"]\n feature_set.away_batting_spot_5_OPS_career = player_performances[past_game.away_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_5][\"career_at_bats\"]\n feature_set.away_batting_spot_6_OPS_career = player_performances[past_game.away_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_6][\"career_at_bats\"]\n feature_set.away_batting_spot_7_OPS_career = player_performances[past_game.away_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_7][\"career_at_bats\"]\n feature_set.away_batting_spot_8_OPS_career = player_performances[past_game.away_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_8][\"career_at_bats\"]\n feature_set.away_batting_spot_9_OPS_career = player_performances[past_game.away_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"career_total_bases\"] / player_performances[past_game.away_batting_spot_9][\"career_at_bats\"]\n\n feature_set.away_batting_spot_1_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_2_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_3_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_4_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_5_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_6_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_7_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_8_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_1_game\"].reduce(:+)\n feature_set.away_batting_spot_9_strikeout_rate_last_1_game = player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"strikeouts_last_1_game\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_1_game\"].reduce(:+)\n\n feature_set.away_batting_spot_1_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_2_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_3_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_4_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_5_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_6_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_7_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_8_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_2_games\"].reduce(:+)\n feature_set.away_batting_spot_9_strikeout_rate_last_2_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"strikeouts_last_2_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_2_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_2_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_3_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_4_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_5_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_6_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_7_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_8_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_5_games\"].reduce(:+)\n feature_set.away_batting_spot_9_strikeout_rate_last_5_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"strikeouts_last_5_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_5_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_2_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_3_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_4_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_5_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_6_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_7_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_8_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_10_games\"].reduce(:+)\n feature_set.away_batting_spot_9_strikeout_rate_last_10_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"strikeouts_last_10_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_10_games\"].reduce(:+)\n\n feature_set.away_batting_spot_1_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_1][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_2_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_2][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_3_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_3][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_4_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_4][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_5_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_5][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_6_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_6][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_7_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_7][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_8_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_8][\"at_bats_last_20_games\"].reduce(:+)\n feature_set.away_batting_spot_9_strikeout_rate_last_20_games = player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+) == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"strikeouts_last_20_games\"].reduce(:+).to_f / player_performances[past_game.away_batting_spot_9][\"at_bats_last_20_games\"].reduce(:+)\n \n feature_set.away_batting_spot_1_strikeout_rate_career = player_performances[past_game.away_batting_spot_1][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_1][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_1][\"career_at_bats\"]\n feature_set.away_batting_spot_2_strikeout_rate_career = player_performances[past_game.away_batting_spot_2][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_2][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_2][\"career_at_bats\"]\n feature_set.away_batting_spot_3_strikeout_rate_career = player_performances[past_game.away_batting_spot_3][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_3][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_3][\"career_at_bats\"]\n feature_set.away_batting_spot_4_strikeout_rate_career = player_performances[past_game.away_batting_spot_4][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_4][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_4][\"career_at_bats\"]\n feature_set.away_batting_spot_5_strikeout_rate_career = player_performances[past_game.away_batting_spot_5][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_5][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_5][\"career_at_bats\"]\n feature_set.away_batting_spot_6_strikeout_rate_career = player_performances[past_game.away_batting_spot_6][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_6][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_6][\"career_at_bats\"]\n feature_set.away_batting_spot_7_strikeout_rate_career = player_performances[past_game.away_batting_spot_7][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_7][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_7][\"career_at_bats\"]\n feature_set.away_batting_spot_8_strikeout_rate_career = player_performances[past_game.away_batting_spot_8][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_8][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_8][\"career_at_bats\"]\n feature_set.away_batting_spot_9_strikeout_rate_career = player_performances[past_game.away_batting_spot_9][\"career_at_bats\"] == 0 ? 0 : player_performances[past_game.away_batting_spot_9][\"career_strikeouts\"] / player_performances[past_game.away_batting_spot_9][\"career_at_bats\"]\n end\n\n feature_set.save\n\n performances.each do |perf|\n player = Player.find_by_id(perf.player_id)\n # career updates\n player_performances[player.retrosheet_id][\"career_games\"] += 1\n player_performances[player.retrosheet_id][\"career_at_bats\"] += perf.at_bats\n player_performances[player.retrosheet_id][\"career_walks\"] += perf.walks\n player_performances[player.retrosheet_id][\"career_hits\"] += perf.hits\n player_performances[player.retrosheet_id][\"career_strikeouts\"] += perf.strikeouts \n player_performances[player.retrosheet_id][\"career_total_bases\"] += perf.total_bases \n \n player_performances[player.retrosheet_id][\"at_bats_last_1_game\"] << perf.at_bats\n player_performances[player.retrosheet_id][\"at_bats_last_2_games\"] << perf.at_bats\n player_performances[player.retrosheet_id][\"at_bats_last_5_games\"] << perf.at_bats\n player_performances[player.retrosheet_id][\"at_bats_last_10_games\"] << perf.at_bats\n player_performances[player.retrosheet_id][\"at_bats_last_20_games\"] << perf.at_bats\n \n player_performances[player.retrosheet_id][\"at_bats_last_1_game\"].shift\n player_performances[player.retrosheet_id][\"at_bats_last_2_games\"].shift\n player_performances[player.retrosheet_id][\"at_bats_last_5_games\"].shift\n player_performances[player.retrosheet_id][\"at_bats_last_10_games\"].shift\n player_performances[player.retrosheet_id][\"at_bats_last_20_games\"].shift\n\n player_performances[player.retrosheet_id][\"walks_last_1_game\"] << perf.walks\n player_performances[player.retrosheet_id][\"walks_last_2_games\"] << perf.walks\n player_performances[player.retrosheet_id][\"walks_last_5_games\"] << perf.walks\n player_performances[player.retrosheet_id][\"walks_last_10_games\"] << perf.walks\n player_performances[player.retrosheet_id][\"walks_last_20_games\"] << perf.walks\n \n player_performances[player.retrosheet_id][\"walks_last_1_game\"].shift\n player_performances[player.retrosheet_id][\"walks_last_2_games\"].shift\n player_performances[player.retrosheet_id][\"walks_last_5_games\"].shift\n player_performances[player.retrosheet_id][\"walks_last_10_games\"].shift\n player_performances[player.retrosheet_id][\"walks_last_20_games\"].shift\n\n player_performances[player.retrosheet_id][\"hits_last_1_game\"] << perf.hits\n player_performances[player.retrosheet_id][\"hits_last_2_games\"] << perf.hits\n player_performances[player.retrosheet_id][\"hits_last_5_games\"] << perf.hits\n player_performances[player.retrosheet_id][\"hits_last_10_games\"] << perf.hits\n player_performances[player.retrosheet_id][\"hits_last_20_games\"] << perf.hits\n \n player_performances[player.retrosheet_id][\"hits_last_1_game\"].shift\n player_performances[player.retrosheet_id][\"hits_last_2_games\"].shift\n player_performances[player.retrosheet_id][\"hits_last_5_games\"].shift\n player_performances[player.retrosheet_id][\"hits_last_10_games\"].shift\n player_performances[player.retrosheet_id][\"hits_last_20_games\"].shift\n\n player_performances[player.retrosheet_id][\"strikeouts_last_1_game\"] << perf.strikeouts\n player_performances[player.retrosheet_id][\"strikeouts_last_2_games\"] << perf.strikeouts\n player_performances[player.retrosheet_id][\"strikeouts_last_5_games\"] << perf.strikeouts\n player_performances[player.retrosheet_id][\"strikeouts_last_10_games\"] << perf.strikeouts\n player_performances[player.retrosheet_id][\"strikeouts_last_20_games\"] << perf.strikeouts\n \n player_performances[player.retrosheet_id][\"strikeouts_last_1_game\"].shift\n player_performances[player.retrosheet_id][\"strikeouts_last_2_games\"].shift\n player_performances[player.retrosheet_id][\"strikeouts_last_5_games\"].shift\n player_performances[player.retrosheet_id][\"strikeouts_last_10_games\"].shift\n player_performances[player.retrosheet_id][\"strikeouts_last_20_games\"].shift\n\n player_performances[player.retrosheet_id][\"total_bases_last_1_game\"] << perf.total_bases\n player_performances[player.retrosheet_id][\"total_bases_last_2_games\"] << perf.total_bases\n player_performances[player.retrosheet_id][\"total_bases_last_5_games\"] << perf.total_bases\n player_performances[player.retrosheet_id][\"total_bases_last_10_games\"] << perf.total_bases\n player_performances[player.retrosheet_id][\"total_bases_last_20_games\"] << perf.total_bases\n \n player_performances[player.retrosheet_id][\"total_bases_last_1_game\"].shift\n player_performances[player.retrosheet_id][\"total_bases_last_2_games\"].shift\n player_performances[player.retrosheet_id][\"total_bases_last_5_games\"].shift\n player_performances[player.retrosheet_id][\"total_bases_last_10_games\"].shift\n player_performances[player.retrosheet_id][\"total_bases_last_20_games\"].shift\n end\n end\nend", "def addFeaturesAndLabel(earliest_date, latest_date, examples, labels)\n all_games = Game.where(\"game_date > ? AND game_date < ?\", earliest_date, latest_date)\n\n all_games.each do |game|\n feature = Feature.find_by_game_id(game.id)\n if feature == nil\n feature = Feature.new\n feature.game_id = game.id\n feature.home_team_won = game.home_team_won\n feature.save\n end\n\n feature_set = []\n\n # Add in individual features\n feature_set << feature.h2h_diff_1\n feature_set << feature.h2h_diff_2\n feature_set << feature.h2h_diff_3\n \n#=begin\n feature_set << feature.run_differentials_1\n feature_set << feature.opp_differentials_1\n feature_set << feature.run_differentials_2\n feature_set << feature.opp_differentials_2\n feature_set << feature.run_differentials_5\n feature_set << feature.opp_differentials_5\n feature_set << feature.run_differentials_10\n feature_set << feature.opp_differentials_10\n feature_set << feature.run_differentials_20\n feature_set << feature.opp_differentials_20\n\n feature_set << feature.win_differentials_1\n feature_set << feature.opp_win_differentials_1\n feature_set << feature.win_differentials_2\n feature_set << feature.opp_win_differentials_2\n feature_set << feature.win_differentials_5\n feature_set << feature.opp_win_differentials_5\n feature_set << feature.win_differentials_10\n feature_set << feature.opp_win_differentials_10\n feature_set << feature.win_differentials_20\n feature_set << feature.opp_win_differentials_20\n#=end\n\n=begin\n # Add in the differences between features. Could be preferable?\n feature_set << feature.run_differentials_1 - feature.opp_differentials_1\n feature_set << feature.run_differentials_2 - feature.opp_differentials_2\n feature_set << feature.run_differentials_5 - feature.opp_differentials_5\n feature_set << feature.run_differentials_10 - feature.opp_differentials_10\n feature_set << feature.run_differentials_20 - feature.opp_differentials_20\n \n feature_set << feature.win_differentials_1 - feature.opp_win_differentials_1\n feature_set << feature.win_differentials_2 - feature.opp_win_differentials_2\n feature_set << feature.win_differentials_5 - feature.opp_win_differentials_5\n feature_set << feature.win_differentials_10 - feature.opp_win_differentials_10\n feature_set << feature.win_differentials_20 - feature.opp_win_differentials_20\n=end\n\n#=begin\n feature_set << feature.home_batting_spot_1_walks_last_1_game\n feature_set << feature.home_batting_spot_2_walks_last_1_game\n feature_set << feature.home_batting_spot_3_walks_last_1_game\n feature_set << feature.home_batting_spot_4_walks_last_1_game\n feature_set << feature.home_batting_spot_5_walks_last_1_game\n feature_set << feature.home_batting_spot_6_walks_last_1_game\n feature_set << feature.home_batting_spot_7_walks_last_1_game\n feature_set << feature.home_batting_spot_8_walks_last_1_game\n feature_set << feature.home_batting_spot_9_walks_last_1_game\n\n feature_set << feature.away_batting_spot_1_walks_last_1_game\n feature_set << feature.away_batting_spot_2_walks_last_1_game\n feature_set << feature.away_batting_spot_3_walks_last_1_game\n feature_set << feature.away_batting_spot_4_walks_last_1_game\n feature_set << feature.away_batting_spot_5_walks_last_1_game\n feature_set << feature.away_batting_spot_6_walks_last_1_game\n feature_set << feature.away_batting_spot_7_walks_last_1_game\n feature_set << feature.away_batting_spot_8_walks_last_1_game\n feature_set << feature.away_batting_spot_9_walks_last_1_game\n\n feature_set << feature.home_batting_spot_1_walks_last_2_games\n feature_set << feature.home_batting_spot_2_walks_last_2_games\n feature_set << feature.home_batting_spot_3_walks_last_2_games\n feature_set << feature.home_batting_spot_4_walks_last_2_games\n feature_set << feature.home_batting_spot_5_walks_last_2_games\n feature_set << feature.home_batting_spot_6_walks_last_2_games\n feature_set << feature.home_batting_spot_7_walks_last_2_games\n feature_set << feature.home_batting_spot_8_walks_last_2_games\n feature_set << feature.home_batting_spot_9_walks_last_2_games\n\n feature_set << feature.away_batting_spot_1_walks_last_2_games\n feature_set << feature.away_batting_spot_2_walks_last_2_games\n feature_set << feature.away_batting_spot_3_walks_last_2_games\n feature_set << feature.away_batting_spot_4_walks_last_2_games\n feature_set << feature.away_batting_spot_5_walks_last_2_games\n feature_set << feature.away_batting_spot_6_walks_last_2_games\n feature_set << feature.away_batting_spot_7_walks_last_2_games\n feature_set << feature.away_batting_spot_8_walks_last_2_games\n feature_set << feature.away_batting_spot_9_walks_last_2_games\n\n feature_set << feature.home_batting_spot_1_walks_last_5_games\n feature_set << feature.home_batting_spot_2_walks_last_5_games\n feature_set << feature.home_batting_spot_3_walks_last_5_games\n feature_set << feature.home_batting_spot_4_walks_last_5_games\n feature_set << feature.home_batting_spot_5_walks_last_5_games\n feature_set << feature.home_batting_spot_6_walks_last_5_games\n feature_set << feature.home_batting_spot_7_walks_last_5_games\n feature_set << feature.home_batting_spot_8_walks_last_5_games\n feature_set << feature.home_batting_spot_9_walks_last_5_games\n\n feature_set << feature.away_batting_spot_1_walks_last_5_games\n feature_set << feature.away_batting_spot_2_walks_last_5_games\n feature_set << feature.away_batting_spot_3_walks_last_5_games\n feature_set << feature.away_batting_spot_4_walks_last_5_games\n feature_set << feature.away_batting_spot_5_walks_last_5_games\n feature_set << feature.away_batting_spot_6_walks_last_5_games\n feature_set << feature.away_batting_spot_7_walks_last_5_games\n feature_set << feature.away_batting_spot_8_walks_last_5_games\n feature_set << feature.away_batting_spot_9_walks_last_5_games\n\n feature_set << feature.home_batting_spot_1_walks_last_10_games\n feature_set << feature.home_batting_spot_2_walks_last_10_games\n feature_set << feature.home_batting_spot_3_walks_last_10_games\n feature_set << feature.home_batting_spot_4_walks_last_10_games\n feature_set << feature.home_batting_spot_5_walks_last_10_games\n feature_set << feature.home_batting_spot_6_walks_last_10_games\n feature_set << feature.home_batting_spot_7_walks_last_10_games\n feature_set << feature.home_batting_spot_8_walks_last_10_games\n feature_set << feature.home_batting_spot_9_walks_last_10_games\n\n feature_set << feature.away_batting_spot_1_walks_last_10_games\n feature_set << feature.away_batting_spot_2_walks_last_10_games\n feature_set << feature.away_batting_spot_3_walks_last_10_games\n feature_set << feature.away_batting_spot_4_walks_last_10_games\n feature_set << feature.away_batting_spot_5_walks_last_10_games\n feature_set << feature.away_batting_spot_6_walks_last_10_games\n feature_set << feature.away_batting_spot_7_walks_last_10_games\n feature_set << feature.away_batting_spot_8_walks_last_10_games\n feature_set << feature.away_batting_spot_9_walks_last_10_games\n\n feature_set << feature.home_batting_spot_1_walks_last_20_games\n feature_set << feature.home_batting_spot_2_walks_last_20_games\n feature_set << feature.home_batting_spot_3_walks_last_20_games\n feature_set << feature.home_batting_spot_4_walks_last_20_games\n feature_set << feature.home_batting_spot_5_walks_last_20_games\n feature_set << feature.home_batting_spot_6_walks_last_20_games\n feature_set << feature.home_batting_spot_7_walks_last_20_games\n feature_set << feature.home_batting_spot_8_walks_last_20_games\n feature_set << feature.home_batting_spot_9_walks_last_20_games\n\n feature_set << feature.away_batting_spot_1_walks_last_20_games\n feature_set << feature.away_batting_spot_2_walks_last_20_games\n feature_set << feature.away_batting_spot_3_walks_last_20_games\n feature_set << feature.away_batting_spot_4_walks_last_20_games\n feature_set << feature.away_batting_spot_5_walks_last_20_games\n feature_set << feature.away_batting_spot_6_walks_last_20_games\n feature_set << feature.away_batting_spot_7_walks_last_20_games\n feature_set << feature.away_batting_spot_8_walks_last_20_games\n feature_set << feature.away_batting_spot_9_walks_last_20_games\n\n feature_set << feature.home_batting_spot_1_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_2_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_3_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_4_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_5_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_6_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_7_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_8_batting_percentage_last_1_game\n feature_set << feature.home_batting_spot_9_batting_percentage_last_1_game\n\n feature_set << feature.away_batting_spot_1_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_2_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_3_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_4_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_5_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_6_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_7_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_8_batting_percentage_last_1_game\n feature_set << feature.away_batting_spot_9_batting_percentage_last_1_game\n\n feature_set << feature.home_batting_spot_1_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_2_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_3_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_4_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_5_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_6_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_7_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_8_batting_percentage_last_2_games\n feature_set << feature.home_batting_spot_9_batting_percentage_last_2_games\n\n feature_set << feature.away_batting_spot_1_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_2_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_3_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_4_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_5_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_6_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_7_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_8_batting_percentage_last_2_games\n feature_set << feature.away_batting_spot_9_batting_percentage_last_2_games\n\n feature_set << feature.home_batting_spot_1_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_2_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_3_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_4_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_5_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_6_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_7_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_8_batting_percentage_last_5_games\n feature_set << feature.home_batting_spot_9_batting_percentage_last_5_games\n\n feature_set << feature.away_batting_spot_1_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_2_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_3_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_4_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_5_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_6_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_7_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_8_batting_percentage_last_5_games\n feature_set << feature.away_batting_spot_9_batting_percentage_last_5_games\n\n feature_set << feature.home_batting_spot_1_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_2_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_3_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_4_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_5_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_6_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_7_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_8_batting_percentage_last_10_games\n feature_set << feature.home_batting_spot_9_batting_percentage_last_10_games\n\n feature_set << feature.away_batting_spot_1_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_2_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_3_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_4_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_5_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_6_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_7_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_8_batting_percentage_last_10_games\n feature_set << feature.away_batting_spot_9_batting_percentage_last_10_games\n\n feature_set << feature.home_batting_spot_1_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_2_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_3_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_4_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_5_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_6_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_7_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_8_batting_percentage_last_20_games\n feature_set << feature.home_batting_spot_9_batting_percentage_last_20_games\n\n feature_set << feature.away_batting_spot_1_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_2_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_3_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_4_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_5_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_6_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_7_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_8_batting_percentage_last_20_games\n feature_set << feature.away_batting_spot_9_batting_percentage_last_20_games\n\n feature_set << feature.home_batting_spot_1_OPS_last_1_game\n feature_set << feature.home_batting_spot_2_OPS_last_1_game\n feature_set << feature.home_batting_spot_3_OPS_last_1_game\n feature_set << feature.home_batting_spot_4_OPS_last_1_game\n feature_set << feature.home_batting_spot_5_OPS_last_1_game\n feature_set << feature.home_batting_spot_6_OPS_last_1_game\n feature_set << feature.home_batting_spot_7_OPS_last_1_game\n feature_set << feature.home_batting_spot_8_OPS_last_1_game\n feature_set << feature.home_batting_spot_9_OPS_last_1_game\n\n feature_set << feature.away_batting_spot_1_OPS_last_1_game\n feature_set << feature.away_batting_spot_2_OPS_last_1_game\n feature_set << feature.away_batting_spot_3_OPS_last_1_game\n feature_set << feature.away_batting_spot_4_OPS_last_1_game\n feature_set << feature.away_batting_spot_5_OPS_last_1_game\n feature_set << feature.away_batting_spot_6_OPS_last_1_game\n feature_set << feature.away_batting_spot_7_OPS_last_1_game\n feature_set << feature.away_batting_spot_8_OPS_last_1_game\n feature_set << feature.away_batting_spot_9_OPS_last_1_game\n\n feature_set << feature.home_batting_spot_1_OPS_last_2_games\n feature_set << feature.home_batting_spot_2_OPS_last_2_games\n feature_set << feature.home_batting_spot_3_OPS_last_2_games\n feature_set << feature.home_batting_spot_4_OPS_last_2_games\n feature_set << feature.home_batting_spot_5_OPS_last_2_games\n feature_set << feature.home_batting_spot_6_OPS_last_2_games\n feature_set << feature.home_batting_spot_7_OPS_last_2_games\n feature_set << feature.home_batting_spot_8_OPS_last_2_games\n feature_set << feature.home_batting_spot_9_OPS_last_2_games\n\n feature_set << feature.away_batting_spot_1_OPS_last_2_games\n feature_set << feature.away_batting_spot_2_OPS_last_2_games\n feature_set << feature.away_batting_spot_3_OPS_last_2_games\n feature_set << feature.away_batting_spot_4_OPS_last_2_games\n feature_set << feature.away_batting_spot_5_OPS_last_2_games\n feature_set << feature.away_batting_spot_6_OPS_last_2_games\n feature_set << feature.away_batting_spot_7_OPS_last_2_games\n feature_set << feature.away_batting_spot_8_OPS_last_2_games\n feature_set << feature.away_batting_spot_9_OPS_last_2_games\n\n feature_set << feature.home_batting_spot_1_OPS_last_5_games\n feature_set << feature.home_batting_spot_2_OPS_last_5_games\n feature_set << feature.home_batting_spot_3_OPS_last_5_games\n feature_set << feature.home_batting_spot_4_OPS_last_5_games\n feature_set << feature.home_batting_spot_5_OPS_last_5_games\n feature_set << feature.home_batting_spot_6_OPS_last_5_games\n feature_set << feature.home_batting_spot_7_OPS_last_5_games\n feature_set << feature.home_batting_spot_8_OPS_last_5_games\n feature_set << feature.home_batting_spot_9_OPS_last_5_games\n\n feature_set << feature.away_batting_spot_1_OPS_last_5_games\n feature_set << feature.away_batting_spot_2_OPS_last_5_games\n feature_set << feature.away_batting_spot_3_OPS_last_5_games\n feature_set << feature.away_batting_spot_4_OPS_last_5_games\n feature_set << feature.away_batting_spot_5_OPS_last_5_games\n feature_set << feature.away_batting_spot_6_OPS_last_5_games\n feature_set << feature.away_batting_spot_7_OPS_last_5_games\n feature_set << feature.away_batting_spot_8_OPS_last_5_games\n feature_set << feature.away_batting_spot_9_OPS_last_5_games\n\n feature_set << feature.home_batting_spot_1_OPS_last_10_games\n feature_set << feature.home_batting_spot_2_OPS_last_10_games\n feature_set << feature.home_batting_spot_3_OPS_last_10_games\n feature_set << feature.home_batting_spot_4_OPS_last_10_games\n feature_set << feature.home_batting_spot_5_OPS_last_10_games\n feature_set << feature.home_batting_spot_6_OPS_last_10_games\n feature_set << feature.home_batting_spot_7_OPS_last_10_games\n feature_set << feature.home_batting_spot_8_OPS_last_10_games\n feature_set << feature.home_batting_spot_9_OPS_last_10_games\n\n feature_set << feature.away_batting_spot_1_OPS_last_10_games\n feature_set << feature.away_batting_spot_2_OPS_last_10_games\n feature_set << feature.away_batting_spot_3_OPS_last_10_games\n feature_set << feature.away_batting_spot_4_OPS_last_10_games\n feature_set << feature.away_batting_spot_5_OPS_last_10_games\n feature_set << feature.away_batting_spot_6_OPS_last_10_games\n feature_set << feature.away_batting_spot_7_OPS_last_10_games\n feature_set << feature.away_batting_spot_8_OPS_last_10_games\n feature_set << feature.away_batting_spot_9_OPS_last_10_games\n\n feature_set << feature.home_batting_spot_1_OPS_last_20_games\n feature_set << feature.home_batting_spot_2_OPS_last_20_games\n feature_set << feature.home_batting_spot_3_OPS_last_20_games\n feature_set << feature.home_batting_spot_4_OPS_last_20_games\n feature_set << feature.home_batting_spot_5_OPS_last_20_games\n feature_set << feature.home_batting_spot_6_OPS_last_20_games\n feature_set << feature.home_batting_spot_7_OPS_last_20_games\n feature_set << feature.home_batting_spot_8_OPS_last_20_games\n feature_set << feature.home_batting_spot_9_OPS_last_20_games\n\n feature_set << feature.away_batting_spot_1_OPS_last_20_games\n feature_set << feature.away_batting_spot_2_OPS_last_20_games\n feature_set << feature.away_batting_spot_3_OPS_last_20_games\n feature_set << feature.away_batting_spot_4_OPS_last_20_games\n feature_set << feature.away_batting_spot_5_OPS_last_20_games\n feature_set << feature.away_batting_spot_6_OPS_last_20_games\n feature_set << feature.away_batting_spot_7_OPS_last_20_games\n feature_set << feature.away_batting_spot_8_OPS_last_20_games\n feature_set << feature.away_batting_spot_9_OPS_last_20_games\n\n feature_set << feature.home_batting_spot_1_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_2_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_3_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_4_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_5_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_6_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_7_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_8_strikeout_rate_last_1_game\n feature_set << feature.home_batting_spot_9_strikeout_rate_last_1_game\n\n feature_set << feature.away_batting_spot_1_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_2_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_3_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_4_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_5_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_6_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_7_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_8_strikeout_rate_last_1_game\n feature_set << feature.away_batting_spot_9_strikeout_rate_last_1_game\n\n feature_set << feature.home_batting_spot_1_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_2_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_3_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_4_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_5_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_6_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_7_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_8_strikeout_rate_last_2_games\n feature_set << feature.home_batting_spot_9_strikeout_rate_last_2_games\n\n feature_set << feature.away_batting_spot_1_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_2_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_3_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_4_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_5_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_6_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_7_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_8_strikeout_rate_last_2_games\n feature_set << feature.away_batting_spot_9_strikeout_rate_last_2_games\n\n feature_set << feature.home_batting_spot_1_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_2_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_3_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_4_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_5_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_6_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_7_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_8_strikeout_rate_last_5_games\n feature_set << feature.home_batting_spot_9_strikeout_rate_last_5_games\n\n feature_set << feature.away_batting_spot_1_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_2_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_3_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_4_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_5_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_6_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_7_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_8_strikeout_rate_last_5_games\n feature_set << feature.away_batting_spot_9_strikeout_rate_last_5_games\n\n feature_set << feature.home_batting_spot_1_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_2_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_3_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_4_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_5_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_6_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_7_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_8_strikeout_rate_last_10_games\n feature_set << feature.home_batting_spot_9_strikeout_rate_last_10_games\n\n feature_set << feature.away_batting_spot_1_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_2_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_3_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_4_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_5_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_6_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_7_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_8_strikeout_rate_last_10_games\n feature_set << feature.away_batting_spot_9_strikeout_rate_last_10_games\n\n feature_set << feature.home_batting_spot_1_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_2_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_3_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_4_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_5_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_6_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_7_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_8_strikeout_rate_last_20_games\n feature_set << feature.home_batting_spot_9_strikeout_rate_last_20_games\n\n feature_set << feature.away_batting_spot_1_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_2_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_3_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_4_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_5_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_6_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_7_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_8_strikeout_rate_last_20_games\n feature_set << feature.away_batting_spot_9_strikeout_rate_last_20_games\n \n feature_set << feature.home_batting_spot_1_walks_per_game_career\n feature_set << feature.home_batting_spot_2_walks_per_game_career\n feature_set << feature.home_batting_spot_3_walks_per_game_career\n feature_set << feature.home_batting_spot_4_walks_per_game_career\n feature_set << feature.home_batting_spot_5_walks_per_game_career\n feature_set << feature.home_batting_spot_6_walks_per_game_career\n feature_set << feature.home_batting_spot_7_walks_per_game_career\n feature_set << feature.home_batting_spot_8_walks_per_game_career\n feature_set << feature.home_batting_spot_9_walks_per_game_career\n \n feature_set << feature.away_batting_spot_1_walks_per_game_career\n feature_set << feature.away_batting_spot_2_walks_per_game_career\n feature_set << feature.away_batting_spot_3_walks_per_game_career\n feature_set << feature.away_batting_spot_4_walks_per_game_career\n feature_set << feature.away_batting_spot_5_walks_per_game_career\n feature_set << feature.away_batting_spot_6_walks_per_game_career\n feature_set << feature.away_batting_spot_7_walks_per_game_career\n feature_set << feature.away_batting_spot_8_walks_per_game_career\n feature_set << feature.away_batting_spot_9_walks_per_game_career\n \n feature_set << feature.home_batting_spot_1_batting_percentage_career\n feature_set << feature.home_batting_spot_2_batting_percentage_career\n feature_set << feature.home_batting_spot_3_batting_percentage_career\n feature_set << feature.home_batting_spot_4_batting_percentage_career\n feature_set << feature.home_batting_spot_5_batting_percentage_career\n feature_set << feature.home_batting_spot_6_batting_percentage_career\n feature_set << feature.home_batting_spot_7_batting_percentage_career\n feature_set << feature.home_batting_spot_8_batting_percentage_career\n feature_set << feature.home_batting_spot_9_batting_percentage_career\n \n feature_set << feature.away_batting_spot_1_batting_percentage_career\n feature_set << feature.away_batting_spot_2_batting_percentage_career\n feature_set << feature.away_batting_spot_3_batting_percentage_career\n feature_set << feature.away_batting_spot_4_batting_percentage_career\n feature_set << feature.away_batting_spot_5_batting_percentage_career\n feature_set << feature.away_batting_spot_6_batting_percentage_career\n feature_set << feature.away_batting_spot_7_batting_percentage_career\n feature_set << feature.away_batting_spot_8_batting_percentage_career\n feature_set << feature.away_batting_spot_9_batting_percentage_career\n \n feature_set << feature.home_batting_spot_1_OPS_career\n feature_set << feature.home_batting_spot_2_OPS_career\n feature_set << feature.home_batting_spot_3_OPS_career\n feature_set << feature.home_batting_spot_4_OPS_career\n feature_set << feature.home_batting_spot_5_OPS_career\n feature_set << feature.home_batting_spot_6_OPS_career\n feature_set << feature.home_batting_spot_7_OPS_career\n feature_set << feature.home_batting_spot_8_OPS_career\n feature_set << feature.home_batting_spot_9_OPS_career\n \n feature_set << feature.away_batting_spot_1_OPS_career\n feature_set << feature.away_batting_spot_2_OPS_career\n feature_set << feature.away_batting_spot_3_OPS_career\n feature_set << feature.away_batting_spot_4_OPS_career\n feature_set << feature.away_batting_spot_5_OPS_career\n feature_set << feature.away_batting_spot_6_OPS_career\n feature_set << feature.away_batting_spot_7_OPS_career\n feature_set << feature.away_batting_spot_8_OPS_career\n feature_set << feature.away_batting_spot_9_OPS_career\n \n feature_set << feature.home_batting_spot_1_strikeout_rate_career\n feature_set << feature.home_batting_spot_2_strikeout_rate_career\n feature_set << feature.home_batting_spot_3_strikeout_rate_career\n feature_set << feature.home_batting_spot_4_strikeout_rate_career\n feature_set << feature.home_batting_spot_5_strikeout_rate_career\n feature_set << feature.home_batting_spot_6_strikeout_rate_career\n feature_set << feature.home_batting_spot_7_strikeout_rate_career\n feature_set << feature.home_batting_spot_8_strikeout_rate_career\n feature_set << feature.home_batting_spot_9_strikeout_rate_career\n \n feature_set << feature.away_batting_spot_1_strikeout_rate_career\n feature_set << feature.away_batting_spot_2_strikeout_rate_career\n feature_set << feature.away_batting_spot_3_strikeout_rate_career\n feature_set << feature.away_batting_spot_4_strikeout_rate_career\n feature_set << feature.away_batting_spot_5_strikeout_rate_career\n feature_set << feature.away_batting_spot_6_strikeout_rate_career\n feature_set << feature.away_batting_spot_7_strikeout_rate_career\n feature_set << feature.away_batting_spot_8_strikeout_rate_career\n feature_set << feature.away_batting_spot_9_strikeout_rate_career \n#=end\n\n=begin\n feature_set << feature.home_batting_spot_1_walks_last_1_game - feature.away_batting_spot_1_walks_last_1_game\n feature_set << feature.home_batting_spot_2_walks_last_1_game - feature.away_batting_spot_2_walks_last_1_game\n feature_set << feature.home_batting_spot_3_walks_last_1_game - feature.away_batting_spot_3_walks_last_1_game\n feature_set << feature.home_batting_spot_4_walks_last_1_game - feature.away_batting_spot_4_walks_last_1_game\n feature_set << feature.home_batting_spot_5_walks_last_1_game - feature.away_batting_spot_5_walks_last_1_game\n feature_set << feature.home_batting_spot_6_walks_last_1_game - feature.away_batting_spot_6_walks_last_1_game\n feature_set << feature.home_batting_spot_7_walks_last_1_game - feature.away_batting_spot_7_walks_last_1_game\n feature_set << feature.home_batting_spot_8_walks_last_1_game - feature.away_batting_spot_8_walks_last_1_game\n feature_set << feature.home_batting_spot_9_walks_last_1_game - feature.away_batting_spot_9_walks_last_1_game\n=end\n\n=begin\n walk_diff = 0\n walk_diff += feature.home_batting_spot_1_walks_last_1_game - feature.away_batting_spot_1_walks_last_1_game\n walk_diff += feature.home_batting_spot_2_walks_last_1_game - feature.away_batting_spot_2_walks_last_1_game\n walk_diff += feature.home_batting_spot_3_walks_last_1_game - feature.away_batting_spot_3_walks_last_1_game\n walk_diff += feature.home_batting_spot_4_walks_last_1_game - feature.away_batting_spot_4_walks_last_1_game\n walk_diff += feature.home_batting_spot_5_walks_last_1_game - feature.away_batting_spot_5_walks_last_1_game\n walk_diff += feature.home_batting_spot_6_walks_last_1_game - feature.away_batting_spot_6_walks_last_1_game\n walk_diff += feature.home_batting_spot_7_walks_last_1_game - feature.away_batting_spot_7_walks_last_1_game\n walk_diff += feature.home_batting_spot_8_walks_last_1_game - feature.away_batting_spot_8_walks_last_1_game\n walk_diff += feature.home_batting_spot_9_walks_last_1_game - feature.away_batting_spot_9_walks_last_1_game\n feature_set << walk_diff\n=end\n \n\n #feature_set << (feature.home_team_won ? 1 : -1)\n\n examples << feature_set\n labels << (feature.home_team_won ? 1 : 0)\n end\nend", "def how_it_works\r\n end", "def work_influences\n find_related_frbr_objects( :is_influenced_by, :which_works?) \n end", "def has_feat ( f )\n return false\n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def legit_feature?\n Flipflop.feature_set.features.map(&:name).include?(params[:feature])\n end", "def wagner; end", "def detectable_contributors?\n true\n end", "def technical_features\n @tech_feat = {\n pros: @pros,\n cons: @cons,\n used_by: @used_by,\n consensus_type: @consensus_type,\n explanation: @explanation,\n further_reading: @further_reading\n }\n\n puts \"\"\n return @tech_feat\n end", "def past_participle; end", "def superwork_influences\n find_related_frbr_objects( :is_influenced_by, :which_superworks?) \n end", "def append_features(mod) end", "def analyze_component_breakdown\n\n end", "def winter_paralympics_sport; end", "def feruchemist; end", "def who_we_are\r\n end", "def anatomy; end", "def romeo_and_juliet; end", "def winter_olympics_sport; end", "def addFeaturesAndLabel(home_team, away_team, earliest_date, latest_date)\n home_faceoffs = Game.where(\"home_team = ? and away_team = ? and game_date > ? and game_date <= ?\", home_team, away_team, earliest_date, latest_date).order(\"game_date desc\")\n away_faceoffs = Game.where(\"home_team = ? and away_team = ? and game_date > ? and game_date <= ?\", away_team, home_team, earliest_date, latest_date).order(\"game_date desc\")\n past_games = home_faceoffs.concat(away_faceoffs)\n past_games = past_games.sort {|game1, game2| game1.game_date <=> game2.game_date }\n\n if past_games.size < 3\n return\n end\n\n run_differentials = [0, 0, 0]\n\n past_games.each_with_index do |past_game, index|\n feature_set = Feature.new\n\n feature_set.game_id = past_game.id\n feature_set.home_team_won = past_game.home_team_won\n\n if past_game.home_team == home_team.to_s\n feature_set.h2h_diff_1 = run_differentials[2]\n feature_set.h2h_diff_2 = run_differentials[1]\n feature_set.h2h_diff_3 = run_differentials[0]\n\n run_differentials << past_game.home_team_runs - past_game.away_team_runs\n else \n feature_set.h2h_diff_1 = -1*run_differentials[2]\n feature_set.h2h_diff_2 = -1*run_differentials[1]\n feature_set.h2h_diff_3 = -1*run_differentials[0]\n\n run_differentials << past_game.away_team_runs - past_game.home_team_runs \n end\n\n feature_set.save\n\n if run_differentials.size > 3\n run_differentials.shift\n end\n end\nend", "def most_interesting_man_in_the_world; end", "def lab\n # STUB\n end", "def alternatives; end", "def collaborators\n (collaborators_from_input || collaborators_from_work) + an_empty_collaborator_for_form_rendering\n end", "def support\n end", "def summer_olympics_sport; end", "def use(*features); end", "def silly_adjective; end", "def summer_paralympics_sport; end", "def loaded_features; end", "def explore\n end", "def explore\n end", "def explore\n end", "def explore\n end", "def explore\n end", "def display_featured_researcher?\n Flipflop.show_featured_researcher?\n end", "def bring_tech_groups_back!\n warn \"Experimental code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n patch_mod_file!(\"common/institutions/00_Core.txt\") do |node|\n node.each do |name, institution|\n if name != \"feudalism\"\n institution[\"penalty\"] = 0.25\n end\n\n # Any non-Europe start really messes up with historical tech spread\n if institution[\"can_start\"]\n institution[\"can_start\"].add! \"continent\", \"europe\"\n end\n end\n\n # TODO: fix node[*][\"embracement_speed\"]\n end\n\n soft_patch_defines_lua!(\"fun_and_balance_tech\",\n [\"NCountry.EMBRACE_INSTITUTION_COST\", 2.5, 5.0],\n [\"NCountry.POWER_MAX\", 999, 3000],\n # For institution balance testing:\n # [\"NGame.END_DATE\", '\"1821.1.2\"', '\"1750.1.2\"'],\n )\n\n groups = [\n # [\"western\", 0.00, 0.00, 0.00],\n # [\"high_american\", 0.00, 0.00, 0.00],\n [\"eastern\", 0.10, 0.10, 0.20, -0.10, 0.20], # avg 15 %\n [\"ottoman\", 0.20, 0.20, 0.40, -0.20, 0.40], # avg 25 %\n [\"muslim\", 0.30, 0.30, 0.60, -0.30, 0.60], # avg 40 %\n [\"indian\", 0.40, 0.40, 0.80, -0.40, 0.80], # avg 60 %\n [\"chinese\", 0.45, 0.45, 0.90, -0.45, 0.90], # avg 60 %\n [\"east_african\", 0.45, 0.45, 0.90, -0.45, 0.90], # avg 60 %\n [\"central_african\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"sub_saharan\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"nomad_group\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"mesoamerican\", 0.75, 0.75, 1.50, -0.75, 1.50], # avg 100 %\n [\"andean\", 0.75, 0.75, 1.50, -0.75, 1.50], # avg 100 %\n [\"north_american\", 1.00, 1.00, 2.00, -0.90, 2.00], # avg 135 %\n [\"south_american\", 1.00, 1.00, 2.00, -0.90, 2.00], # avg 135 %\n ]\n\n node = PropertyList[]\n groups.each do |tech, adm, dip, mil, spread, emb|\n node.add! \"has_#{tech}\", PropertyList[\n \"potential\", PropertyList[\"technology_group\", tech],\n \"trigger\", PropertyList[\"technology_group\", tech],\n \"adm_tech_cost_modifier\", adm,\n \"dip_tech_cost_modifier\", dip,\n \"mil_tech_cost_modifier\", mil,\n \"global_institution_spread\", spread,\n \"embracement_cost\", emb,\n ]\n end\n\n create_mod_file! \"common/triggered_modifiers/01_tech_groups.txt\", node\n # TODO: localization\n end", "def bring_tech_groups_back!\n warn \"Experimental code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n patch_mod_file!(\"common/institutions/00_Core.txt\") do |node|\n node.each do |name, institution|\n if name != \"feudalism\"\n institution[\"penalty\"] = 0.25\n end\n\n # Any non-Europe start really messes up with historical tech spread\n if institution[\"can_start\"]\n institution[\"can_start\"].add! \"continent\", \"europe\"\n end\n end\n\n # TODO: fix node[*][\"embracement_speed\"]\n end\n\n soft_patch_defines_lua!(\"fun_and_balance_tech\",\n [\"NCountry.EMBRACE_INSTITUTION_COST\", 2.5, 5.0],\n [\"NCountry.POWER_MAX\", 999, 3000],\n # For institution balance testing:\n # [\"NGame.END_DATE\", '\"1821.1.2\"', '\"1750.1.2\"'],\n )\n\n groups = [\n # [\"western\", 0.00, 0.00, 0.00],\n # [\"high_american\", 0.00, 0.00, 0.00],\n [\"eastern\", 0.10, 0.10, 0.20, -0.10, 0.20], # avg 15 %\n [\"ottoman\", 0.20, 0.20, 0.40, -0.20, 0.40], # avg 25 %\n [\"muslim\", 0.30, 0.30, 0.60, -0.30, 0.60], # avg 40 %\n [\"indian\", 0.40, 0.40, 0.80, -0.40, 0.80], # avg 60 %\n [\"chinese\", 0.45, 0.45, 0.90, -0.45, 0.90], # avg 60 %\n [\"east_african\", 0.45, 0.45, 0.90, -0.45, 0.90], # avg 60 %\n [\"central_african\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"sub_saharan\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"nomad_group\", 0.60, 0.60, 1.20, -0.60, 1.20], # avg 80 %\n [\"mesoamerican\", 0.75, 0.75, 1.50, -0.75, 1.50], # avg 100 %\n [\"andean\", 0.75, 0.75, 1.50, -0.75, 1.50], # avg 100 %\n [\"north_american\", 1.00, 1.00, 2.00, -0.90, 2.00], # avg 135 %\n [\"south_american\", 1.00, 1.00, 2.00, -0.90, 2.00], # avg 135 %\n ]\n\n node = PropertyList[]\n groups.each do |tech, adm, dip, mil, spread, emb|\n node.add! \"has_#{tech}\", PropertyList[\n \"potential\", PropertyList[\"technology_group\", tech],\n \"trigger\", PropertyList[\"technology_group\", tech],\n \"adm_tech_cost_modifier\", adm,\n \"dip_tech_cost_modifier\", dip,\n \"mil_tech_cost_modifier\", mil,\n \"global_institution_spread\", spread,\n \"embracement_cost\", emb,\n ]\n end\n\n create_mod_file! \"common/triggered_modifiers/01_tech_groups.txt\", node\n # TODO: localization\n end", "def learn_more\n end", "def introduce\n\nend", "def train\n super\n puts \"#{@role} #{@last_name} supports the team during the training\"\n end", "def notes_from_training\n end", "def has_feature?(*)\n end", "def yet?\n \"not famous yet...\"\n end", "def unusual_sport; end", "def probers; end", "def community; end", "def bugs_in_play?; self.list_bugs(true); end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def team; end", "def team; end", "def team; end", "def team; end", "def team; end", "def team; end", "def use_technology_preview; end", "def mitch_hedberg; end", "def engage\n threads = []\n #threads << LisaToolbox.run_in_new_thread(:engage_by_elite_tweets) {engage_by_elite_tweets}\n threads << LisaToolbox.run_in_new_thread(:engage_by_search) {engage_by_search}\n #threads << LisaToolbox.run_in_new_thread(:engage_by_realtime) {engage_by_realtime}\n threads.each { |thread| thread.join }\nend", "def engage\n threads = []\n threads << LisaToolbox.run_in_new_thread(:engage_by_elite_tweets) {engage_by_elite_tweets}\n threads << LisaToolbox.run_in_new_thread(:engage_by_search) {engage_by_search}\n threads << LisaToolbox.run_in_new_thread(:engage_by_realtime) {engage_by_realtime}\n threads.each { |thread| thread.join }\nend", "def engage\n threads = []\n threads << LisaToolbox.run_in_new_thread(:engage_by_elite_tweets) {engage_by_elite_tweets}\n threads << LisaToolbox.run_in_new_thread(:engage_by_search) {engage_by_search}\n threads << LisaToolbox.run_in_new_thread(:engage_by_realtime) {engage_by_realtime}\n threads.each { |thread| thread.join }\nend", "def my\n open_season_ids = Season.is_not_ended.select(:id).map{|s| s.id }\n\n # Why refine? If user tags a meeting out form his affikliation it should be shown\n browsable_season_ids = open_season_ids\n # Refine the list of open seasons:\n #browsable_season_ids = open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_badges_for( season_id ).nil?\n #} + open_season_ids.select{ |season_id|\n # ! current_user.find_team_affiliation_id_from_team_managers_for( season_id ).nil?\n #}\n #browsable_season_ids.uniq!\n\n # Extract the user-tagged browsable meetings:\n meeting_id_list = Meeting\n .where( \"meetings.season_id IN (?)\", browsable_season_ids )\n .tagged_with( \"u#{ current_user.id }\", on: :tags_by_users )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n\n # If user has an associated swimmer look for team tagged and attended meetings too\n if current_user.has_associated_swimmer?\n # Add also the team-tagged browsable meetings.\n # Find the current, browsable team affiliations that may have tagged the meetings,\n # and, for each, add any tagged meeting found to the list:\n browsable_season_ids\n .map{ |season_id| current_user.find_team_affiliation_id_from_badges_for(season_id) }\n .compact.each do |tagger_team_affiliation_id|\n meeting_id_list += Meeting\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .tagged_with( \"ta#{ tagger_team_affiliation_id }\", on: :tags_by_teams )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n # .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n # Add also any already attended and closed meeting belonging to the browsable\n # seasons: (the relationship w/ swimmer is through MIRs, so the inner join is enough)\n meeting_id_list += current_user.swimmer.meetings\n .where( [\"meetings.season_id IN (?)\", browsable_season_ids] )\n .select( :id, :season_id )\n .map{ |meeting| meeting.id }\n end\n\n# .where( [\"meetings.id not in (?) and meetings.season_id IN (?)\", meeting_id_list, browsable_season_ids] )\n\n @calendarMeetingPicker = CalendarMeetingPicker.new( nil, nil, nil, meeting_id_list.uniq! )\n @calendarDAO = @calendarMeetingPicker.pick_meetings( 'DESC', false, current_user )\n @meetings = @calendarDAO.get_meetings\n\n end", "def feature_version(feature); end", "def forkless(interspinous_interdevour, cladodontid_michel)\n end", "def intensifier; end", "def faq\n\n end", "def get_required_features(features)\n end", "def has_contributed_to\n self.contributed_non_profits\n end", "def feature_setup\n raise NotImplementedError\n end", "def test_lab_annotation\n lab = CaTissue::Participant::Clinical::LabAnnotation.new\n lab.merge_attributes(:lab_test_name => 'Test Lab', :participant => @pnt, :result => '4', :result_units => 'mg')\n cln = @pnt.clinical.first\n assert_not_nil(cln, \"Clinical annotation not added to participant\")\n labs = cln.lab_annotations\n assert_not_nil(labs.first, \"Lab not added to participant labs\")\n assert_same(lab, labs.first, \"Lab incorrect\")\n assert_same(@pnt, lab.hook, \"Lab proxy hook not set\")\n end", "def works_evidenced_composers\n all_composers = []\n works.map{|w| all_composers << w.composers}\n all_composers.flatten!\nend", "def test_modifications\n return unless MO.pivotal_enabled && false\n\n # Clean up after failed previous tests.\n stories = Pivotal.get_stories\n stories.select { |s| s.name == \"temp\" }.each do |story|\n puts(\"Cleaning up story ##{story.id}\")\n Pivotal.delete_story(story.id)\n end\n\n puts(\"Creating temp story...\")\n story = Pivotal.create_story(\"temp\", \"this is a test\", mary)\n assert_not_nil(story)\n assert_equal(\"feature\", story.type)\n assert_equal(\"unscheduled\", story.state)\n assert_equal(mary.id, story.user.id)\n assert_equal(\"temp\", story.name)\n assert_equal(\"this is a test\\n\", story.description)\n assert_equal([\"other\"], story.labels)\n assert_equal([], story.comments)\n assert_equal([], story.votes)\n\n puts(\"Casting vote...\")\n result = Pivotal.cast_vote(story.id, rolf, 1)\n assert_kind_of(Pivotal::Story, result)\n assert_equal(story.id, result.id)\n assert_equal(story.name, result.name)\n assert_equal(story.description, result.description)\n assert_equal(1, result.votes.length)\n assert_equal(1, result.score)\n assert_equal(rolf.id, result.votes.first.id)\n assert_equal(1, result.votes.first.data)\n\n puts(\"Changing vote...\")\n result = Pivotal.cast_vote(story.id, rolf, -1)\n assert_kind_of(Pivotal::Story, result)\n assert_equal(story.id, result.id)\n assert_equal(story.name, result.name)\n assert_equal(story.description, result.description)\n assert_equal(1, result.votes.length)\n assert_equal(-1, result.score)\n\n puts(\"Posting comment...\")\n result = Pivotal.post_comment(story.id, mary, \"test comment\")\n assert_kind_of(Pivotal::Comment, result)\n assert_equal(\"test comment\\n\", result.text)\n assert_equal(mary.id, result.user.id)\n\n puts(\"Checking final result...\")\n updated_story = Pivotal.get_story(story.id)\n assert_equal(story.id, updated_story.id)\n assert_equal(1, updated_story.comments.length)\n assert_equal(\"test comment\\n\", updated_story.comments.first.text)\n assert_equal(mary.id, updated_story.comments.first.user.id)\n\n puts(\"Cleaning up...\")\n Pivotal.delete_story(story.id)\n end", "def expert(data)\nend", "def apis; end", "def faq\n end", "def faq\n end", "def modifiers\n [\n #### <---- Start of Markdown\n\n# After the submission of a Podspec to [Trunk](making/getting-setup-with-trunk.html), the documentation service CocoaDocs\n# generates a collection of metrics for the Pod. You can look these metrics for any Pod on [metrics.cocoapods.org/api/v1/pods/[Pod]](http://metrics.cocoapods.org/api/v1/pods/ORStackView).\n# These metrics are used to generate a variety of Quality Modifiers which eventually turns into a single number called the Quality Index.\n\n# This document is a form of [literate programming](https://en.wikipedia.org/wiki/Literate_programming#cite_note-19)\n# within the [CocoaDocs-API](https://github.com/CocoaPods/cocoadocs-api/blob/master/quality_modifiers.rb).\n# As such it contains the actual ruby code that is ran in order to generate the individual scores. Plus, Swift looks like Ruby anyway - so you can read it ;).\n\n# The aim of the Quality Index is to highlight postive metrics, and downplay the negative. It is very possible to have a Pod for which no modifier is actually applied. Meaning the Index stays at the default number of 50.\n# This is a pretty reasonable score.\n#\n# A good example of the mentality we have towards the modifiers is to think of a Pod with a majority of it's code in Swift.\n# It gets a boost, while an Objective-C one doesn't get modified. It's not about reducing points for Objective-C, but highlighting that right now a Swift library represents forward thinking best practices.\n\n# Finally, before we get started. These metrics are not set in stone, they have been evolving since their unveiling and will continue to do so in the future. Feedback is appreciated, ideally in [issues](https://github.com/CocoaPods/cocoapods.org/issues/new) - so they can be discussed.\n\n### Popularity Metrics\n\n# It's a pretty safe bet that an extremely popular library is going to be a well looked after, and maintained library. We weighed different metrics according to how much more valuable the individual metric is rather than just using stars as the core metric.\n\n Modifier.new(\"Very Popular\", \"The popularity of a project is a useful way of discovering if it is useful, and well maintained.\", 30, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n value = stats[:contributors].to_i * 90 + stats[:subscribers].to_i * 20 + stats[:forks].to_i * 10 + stats[:stargazers].to_i\n value > 9000\n }),\n\n# However, not every idea needs to be big enough to warrent such high metrics. A high amount of engagement is useful in it's own right.\n\n Modifier.new(\"Popular\", \"A popular library means there can be a community to help improve and maintain a project.\", 10, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n value = stats[:contributors].to_i * 90 + stats[:subscribers].to_i * 20 + stats[:forks].to_i * 10 + stats[:stargazers].to_i\n value > 1500\n }),\n\n### Swift Package Manager\n# We want to encourage support of Apple's Swift Package Manager, it's better for the community to be unified. For more information see our [FAQ](https://guides.cocoapods.org/using/faq.html).\n# This currently checks for the existence of `Package.swift`, once SPM development has slowed down, we may transistion to testing that it supports the latest release.\n\n Modifier.new(\"Supports Swift Package Manager\", \"Supports Apple's official package manager for Swift.\", 15, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:spm_support]\n }),\n\n### README Scoring\n# The README score is based on an algorithm that looks at the variety of the *bundled* README.\n# You can run the algorithm against any URL here on [clayallsopp.github.io/readme-score](http://clayallsopp.github.io/readme-score).\n# A README is the front-page of your library, it can provide an overview of API or show what the\n# library can do.\n#\n# Strange as it sounds, if you are providing a binary CocoaPod, it is worth embedding your README.md\n# inside the zip. This means CocoaPods can use it to generate your Pod page. We look for a `README{,.md,.markdown}`\n# for two directories from the root of your project.\n#\n# _Note:_ These modifiers are still in flux a bit, as we want to take a Podspec's `documentation_url` into account.\n#\n\n Modifier.new(\"Great README\", \"A well written README gives a lot of context for the library, providing enough information to get started. \", 5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:readme_complexity].to_i > 75\n }),\n\n Modifier.new(\"Minimal README\", \"The README is an overview for a library's API. Providing a minimal README means that it can be hard to understand what the library does.\", -5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:readme_complexity].to_i < 40\n }),\n\n Modifier.new(\"Empty README\", \"The README is the front page of a library. To have this applied you may have a very empty README.\", -8, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:readme_complexity].to_i < 25 && spec.documentation_url == nil\n }),\n\n### CHANGELOG\n#\n# Having a CHANGELOG means that its easier for people for compare older verions, as a metric of quality this generally\n# shows a more mature library with care taken by the maintainer to show changes. We look for a `CHANGELOG{,.md,.markdown}`\n# for two directories from the root of your project.\n\n Modifier.new(\"Has a CHANGELOG\", \"CHANGELOGs make it easy to see the differences between versions of your library.\", 8, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:rendered_changelog_url] != nil\n }),\n\n### Language Choices\n#\n# Swift is happening. We wanted to positively discriminate people writing libraries in Swift.\n\n Modifier.new(\"Built in Swift\", \"Swift is where things are heading.\", 5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:dominant_language] == \"Swift\"\n }),\n\n# Objective-C++ libraries can be difficult to integrate with Swift, and can require a different\n# paradigm of programming from what the majority of projects are used to.\n\n Modifier.new(\"Built in Objective-C++\", \"Usage of Objective-C++ makes it difficult for others to contribute.\", -5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:dominant_language] == \"Objective-C++\"\n }),\n\n### Licensing Issues\n# The GPL is a legitimate license to use for your code.\n# However it is [incompatible](http://www.fsf.org/blogs/licensing/more-about-the-app-store-gpl-enforcement)\n# with putting an App on the App Store, which most people would end up doing.\n# To protect against this case we detract points from GPL'd libraries.\n\n Modifier.new(\"Uses GPL\", \"There are legal issues around distributing GPL'd code in App Store environments.\", -20, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:license_short_name] =~ /GPL/i || false\n }),\n\n# There were also quite a few libraries using the WTFPL, which is a license that aims to not be a license.\n# It was rejected by the [OSI](http://opensource.org/) ( An open source licensing body. ) as being no different\n# than not including a license.\n# If you want to do that, use a [public domain](http://choosealicense.com/licenses/unlicense/) license.\n\n Modifier.new(\"Uses WTFPL\", \"WTFPL was denied as an OSI approved license. Thus it is not classed as code license.\", -5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:license_short_name] == \"WTFPL\"\n }),\n\n### Code Calls\n#\n# Testing a library is important.\n# When you have a library that people are relying on, being able to validate that what you expected to work works increases\n# the quality.\n\n Modifier.new(\"Has Tests\", \"Testing a library shows that the developers care about long term quality on a project as internalized logic is made explicit via testing.\", 4, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n cd_stats[:total_test_expectations].to_i > 10\n }),\n\n Modifier.new(\"Test Expectations / Line of Code\", \"Having more code covered by tests is great.\", 10, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n lines = cd_stats[:total_lines_of_code].to_f\n expectations = cd_stats[:total_test_expectations].to_f\n if lines != 0\n 0.045 < (expectations / lines)\n else\n false\n end\n }),\n\n# CocoaPods makes it easy to create a library with multiple files, we wanted to encourage adoption of smaller\n# more composable libraries.\n\n Modifier.new(\"Lines of Code / File\", \"Smaller, more composeable classes tend to be easier to understand.\", -8, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n files = cd_stats[:total_files].to_i\n if files != 0\n (cd_stats[:total_lines_of_code].to_f / cd_stats[:total_files].to_f) > 250\n else\n false\n end\n }),\n\n### Ownership\n#\n# The CocoaPods Specs Repo isn't curated, and for the larger SDKs people will create un-official Pods.\n# We needed a way to state that this Pod has come for the authors of the library, so, we have verified accounts.\n# These are useful for the companies the size of; Google, Facebook, Amazon and Dropbox.\n# We are applying this very sparingly, and have been reaching out to companies individually.\n\n Modifier.new(\"Verified Owner\", \"When a pod comes from a large company with an official account.\", 20, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n owners.find { |owner| owner.owner.is_verified } != nil\n }),\n\n### Maintenance\n# We want to encourage people to ship semantic versions with their libraries. It can be hard to know\n# what to expect from a library that is not yet at 1.0.0 given there is no social contract there. This\n# is because before v1.0.0 a library author makes no promise on backwards compatability.\n\n Modifier.new(\"Post-1.0.0\", \"Has a Semantic Version that is above 1.0.0\", 5, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n Pod::Version.new(\"1.0.0\") <= Pod::Version.new(spec.version)\n }),\n\n# When it's time to deprecate a library, we should reflect that in the search results.\n\n Modifier.new(\"Is Deprecated\", \"Latest Podspec is declared to be deprecated\", -20, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n spec.deprecated || spec.deprecated_in_favor_of || false\n }),\n\n### Misc - GitHub specific\n\n# This is an experiment in figuring out if a project is abandoned. Issues could be used as a TODO list,\n# but leaving 50+ un-opened feels a bit off. It's more likely that the project has been sunsetted.\n\n Modifier.new(\"Lots of open issues\", \"A project with a lot of open issues is generally abandoned. If it is a popular library, then it is usually offset by the popularity modifiers.\", -8, Proc.new { |spec, cd_stats, stats, cp_stats, owners|\n stats[:open_issues].to_i > 50\n })\n\n #### End of Markdown --->\n ]\n end", "def test_method_features\n @providers = {:numbers => @features[:numeric], :letters => @features[:alpha]}\n @providers[:both] = @features[:numeric] + @features[:alpha]\n @providers[:mixed] = [:one, :b]\n @providers[:neither] = [:something, :else]\n\n @providers.each do |name, methods|\n assert_nothing_raised(\"Could not create provider #{name}\") do\n @type.provide(name) do\n methods.each do |name|\n define_method(name) {}\n end\n end\n end\n end\n\n resource = @type.new(:name => \"foo\")\n {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should|\n should.sort! { |a,b| a.to_s <=> b.to_s }\n provider = @type.provider(name)\n assert(provider, \"Could not find provider #{name}\")\n assert_equal(should, provider.features, \"Provider #{name} has incorrect features\")\n\n inst = provider.new(resource)\n # Make sure the boolean methods work on both the provider and\n # instance.\n @features.keys.each do |feature|\n method = feature.to_s + \"?\"\n assert(inst.respond_to?(method), \"No boolean instance method for #{name} on #{feature}\")\n assert(provider.respond_to?(method), \"No boolean class method for #{name} on #{feature}\")\n\n if should.include?(feature)\n assert(provider.feature?(feature), \"class missing feature? #{feature}\")\n assert(inst.feature?(feature), \"instance missing feature? #{feature}\")\n assert(provider.send(method), \"class missing feature #{feature}\")\n assert(inst.send(method), \"instance missing feature #{feature}\")\n assert(inst.satisfies?(feature), \"instance.satisfy #{feature} returned false\")\n else\n assert(! provider.feature?(feature), \"class has feature? #{feature}\")\n assert(! inst.feature?(feature), \"instance has feature? #{feature}\")\n assert(! provider.send(method), \"class has feature #{feature}\")\n assert(! inst.send(method), \"instance has feature #{feature}\")\n assert(! inst.satisfies?(feature), \"instance.satisfy #{feature} returned true\")\n end\n end\n\n end\n\n Puppet[:trace] = true\n Puppet::Type.loadall\n Puppet::Type.eachtype do |type|\n assert(type.respond_to?(:feature), \"No features method defined for #{type.name}\")\n end\n end", "def feature_module\n unless defined?(@feature_module)\n @features ||= {}\n @feature_module = ::Module.new\n const_set(\"FeatureModule\", @feature_module)\n features = @features\n # Create a feature? method that can be passed a feature name and\n # determine if the feature is present.\n @feature_module.send(:define_method, :feature?) do |name|\n method = name.to_s + \"?\"\n return !!(respond_to?(method) and send(method))\n end\n\n # Create a method that will list all functional features.\n @feature_module.send(:define_method, :features) do\n return false unless defined?(features)\n features.keys.find_all { |n| feature?(n) }.sort { |a,b|\n a.to_s <=> b.to_s\n }\n end\n\n # Create a method that will determine if a provided list of\n # features are satisfied by the curred provider.\n @feature_module.send(:define_method, :satisfies?) do |*needed|\n ret = true\n needed.flatten.each do |feature|\n unless feature?(feature)\n ret = false\n break\n end\n end\n ret\n end\n\n # Create a boolean method for each feature so you can test them\n # individually as you might need.\n @features.each do |name, feature|\n method = name.to_s + \"?\"\n @feature_module.send(:define_method, method) do\n (is_a?(Class) ? declared_feature?(name) : self.class.declared_feature?(name)) or feature.available?(self)\n end\n end\n\n # Allow the provider to declare that it has a given feature.\n @feature_module.send(:define_method, :has_features) do |*names|\n @declared_features ||= []\n names.each do |name|\n @declared_features << name.intern\n end\n end\n # Aaah, grammatical correctness\n @feature_module.send(:alias_method, :has_feature, :has_features)\n end\n @feature_module\n end", "def strategy; end", "def features\n features = Hash[api.get_features(app).body.map{|feature| [feature['name'], feature['enabled']]}]\n actual_features = Hash[api.get_features(target_app).body.map{|feature| [feature['name'], feature['enabled']]}]\n\n features_to_enable = features.select{|feature, enabled| enabled && !actual_features[feature]}\n features_to_disable = actual_features.select{|feature, enabled| enabled && !features[feature]}\n\n action(\"Copying labs features from #{app} and restarting #{target_app}\") do\n features_to_enable.each do |feature|\n puts \"Adding #{feature} to #{target_app}\"\n api.post_feature(feature, target_app)\n end\n\n features_to_disable.each do |feature|\n puts \"Deleting #{feature} from #{target_app}\"\n api.delete_feature(feature, target_app)\n end\n end\n end", "def run_all\n run(\"features\")\n end", "def legit_feature\n return unless legit_feature?\n\n params[:feature]\n end", "def test_feature_for_category\r\n\t\tfeatures = Feature.for_category(categories(:root).id, 99)\r\n\r\n\t\tassert_equal(2, features.length)\r\n\t\tassert_equal(true, features.include?(products(:persian)))\r\n\t\tassert_equal(true, features.include?(products(:cow2)))\r\n\r\n\t\tfeatures = Feature.for_category(categories(:livestock).id, 99)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\t\tassert_equal(true, features.include?(products(:optioner)))\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id, 99)\r\n\r\n\t\tassert_equal(3, features.length)\r\n\t\tassert_equal(true, features.include?(products(:cow2)))\r\n\t\tassert_equal(true, features.include?(products(:cow3)))\r\n\t\tassert_equal(true, features.include?(products(:optioner))) # inherited from livestock\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\t# check that the correct number is given when the number to return is < the number of\r\n\t\t# results found in the db\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id, 1)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\t# check a blank return\r\n\t\tfeatures = Feature.for_category(categories(:utilities).id, 1)\r\n\r\n\t\tassert_equal(0, features.length)\r\n\tend", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def benchs\n %w( alchemy_api google_api language_detector language_detector_tc whatlanguage )\n end", "def witcher; end", "def number_of_influences_these_works(login=nil)\n count_by_frbr(login, :is_an_influence_on, :how_many_works?) \n end", "def is_feature(test)\n test.metadata[:type].to_s == 'feature'\nend", "def dev_minor() end", "def user_profile_feature_pods\n core_pods\nend", "def collegiate_rivals\n end", "def display_features\n puts\n puts \"Features:\"\n @features.each { |feature| puts \" * #{feature}\"}\n puts\n end", "def context_type_team_ranking\n ContextTypeDef.new(\n :team_ranking,\n [\n /(classifica)(\\s+di)?(\\s+societ.)?/i\n# /(?<anything>^.*)/i\n# /(?<empty>^\\s*\\r?\\n|^\\r?\\n|^\\s*\\n|^\\s*$)/i\n# /^\\s*(\\r\\n|\\n|$|\\Z)/i\n ]\n )\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end" ]
[ "0.57867056", "0.57655954", "0.5759622", "0.5660397", "0.5621747", "0.5533095", "0.5524501", "0.53921217", "0.53921217", "0.5384228", "0.53748417", "0.537258", "0.5360202", "0.5359573", "0.5359338", "0.5345139", "0.5311745", "0.52879196", "0.524621", "0.5230852", "0.52249604", "0.52236766", "0.5215243", "0.5215154", "0.52099454", "0.5198684", "0.518934", "0.51752687", "0.5174726", "0.51377296", "0.51199424", "0.5112452", "0.5083408", "0.50827754", "0.50819397", "0.50819397", "0.50819397", "0.50819397", "0.50819397", "0.50789744", "0.50714636", "0.50714636", "0.50706583", "0.50703967", "0.5060553", "0.50603044", "0.50602704", "0.5059293", "0.50502956", "0.50411963", "0.5031595", "0.50281066", "0.50201166", "0.50153726", "0.50153726", "0.50153726", "0.50153726", "0.50153726", "0.50153726", "0.500159", "0.49978828", "0.4990309", "0.4985107", "0.4985107", "0.49810925", "0.49734697", "0.49729738", "0.49696758", "0.49630046", "0.4960012", "0.49556786", "0.49536347", "0.49524635", "0.4943157", "0.49403802", "0.49338028", "0.49237123", "0.49164972", "0.49164972", "0.4915455", "0.49091107", "0.49058187", "0.48998016", "0.48942798", "0.48882526", "0.48760846", "0.4864804", "0.48628327", "0.48613504", "0.48537746", "0.48519936", "0.4847994", "0.4845422", "0.48423386", "0.48423028", "0.48419756", "0.48399007", "0.48377782", "0.48377782", "0.48377782", "0.48377782" ]
0.0
-1
Ignoring cover art, everything should be either an MP3 or a FLAC.
def all_same_filetype?(files) return true if supported(files).map(&:extname).uniq.size <= 1 raise Aur::Exception::LintDirMixedFiles end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cover_art?(files)\n case files.first.extname\n when '.flac'\n raise Aur::Exception::LintDirCoverArtMissing unless cover_in(files)\n when '.mp3'\n raise Aur::Exception::LintDirCoverArtUnwanted if cover_in(files)\n end\n\n true\n end", "def audio_without_closed_captions?\n audio? && closed_captions.blank?\n end", "def extract_cover(replace_cover=true)\n if cover && !replace_cover\n return false\n end\n return false if tracks.empty?\n if full_path = tracks.first.extract_cover\n self.cover = File.basename(full_path)\n self.thumbnail = \"#{id}.png\"\n end\n end", "def meta_flac\n n = 0\n pictures_seen = 0\n @metadata_blocks.each do |block|\n puts \"METADATA block ##{n}\"\n puts \" type: #{block[1]} (#{block[0].upcase})\"\n puts \" is last: #{block[2] == 0 ? \"false\" : \"true\"}\"\n case block[1]\n when 0\n meta_stream\n when 1\n meta_padd\n when 2\n meta_app\n when 3\n meta_seek\n when 4\n meta_vorb\n when 5\n meta_cue\n when 6\n pictures_seen += 1\n meta_pict(pictures_seen)\n end\n n += 1\n end\n nil\n end", "def strip(tags=TagLib::FLAC::File::AllTags)\n end", "def flac_with_m4a?\n asset.content_type == \"audio/flac\" && asset.file_derivatives.has_key?(:m4a)\n end", "def read_track music_file\n\t# fill in the missing code\nend", "def worked?\n if @discFound.getTitle.empty?\n puts \"Disco no encontrado\"\n return false\n end\n\n for i in (0..@mp3Dir.getMP3.count-1)\n trackNumber = i+1\n trackNumber = trackNumber < 10 ? '0' + trackNumber.to_s : trackNumber\n mp3File = @directorio + '/' + @mp3Dir.getMP3[i]\n track = @discFound.getTracks[i]\n\n system \"eyeD3 --remove-all \\\"#{mp3File}\\\"\"\n\n tag = ID3Lib::Tag.new mp3File\n\n tag.title = track.getName\n tag.performer = @discFound.getArtist\n tag.year = @release_year.empty? ? @discFound.getYear : @release_year\n tag.track = i+1\n tag.composer = @discFound.getArtist\n tag.album = @discFound.getTitle + (@album_title_extra.empty? ? '' : @album_title_extra)\n tag.comment = 'Tagged using rtag v1.3.0'\n\n cover = {\n :id => :APIC,\n :mimetype => 'image/jpeg',\n :picturetype => 3,\n :description => 'Disc Cover',\n :textenc => 0,\n :data => File.read('folder.jpg')\n }\n\n tag << cover\n tag.update!\n\n name = track.getName\n name.gsub! /\\//, ''\n \n name.sub! '*','#'\n name.sub! '?',''\n\n targetFile = @directorio + \"/\" + trackNumber.to_s + \". \" + name + \".mp3\"\n\n File.rename mp3File, targetFile\n end\n File.rename 'folder.jpg', @directorio + '/folder.jpg'\n return true\n end", "def exact_covers\n enum_for :each_exact_cover\n end", "def song_decoder(song)\n #TODO\n if song.include?(\"WUB\")\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, ' ').strip()\n else\n song\n end\nend", "def sound_cue(href, ds = nil)\n Kamelopard::SoundCue.new href, ds\n end", "def audio?\n if mime_type == 'application/mxf'\n !ffprobe.codec_type.any? {|type| type == 'video'}\n else\n super\n end\n end", "def audio; end", "def is_audio(str)\n str.match(/\\A\\w*.(mp3|flac|alac|aac)\\Z/) != nil\nend", "def extract_audio_details\n path = audio.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3|\n\t self.title = mp3.tag.title \n\t self.album = mp3.tag.album\n\t self.artist = mp3.tag.artist\n\t self.track = mp3.tag.tracknum\n end\nend", "def media_info_tracks\n MediaInfo.from(filename)\n rescue StandardError => error\n Valkyrie.logger.warn \"#{self.class}: Failed to characterize #{filename} using MediaInfo: #{error.message}\"\n NullTracks.new\n end", "def audio?\n not audio_formats.empty?\n end", "def plieguesCutaneos\n\t\tpliegues = []\n\t\tpliegues << mediaTricipital\n\t\tpliegues << mediaBicipital\n\t\tpliegues << mediaSubescapular\n\t\tpliegues << mediaSuprailiaco\n\t\treturn pliegues\n\tend", "def checkUnspeakableArtist(artist)\n artist.strip!.downcase!\n case artist\n when \"full beat\"\n log \"Changed '#{artist}' into Volbeat\"\n return \"volbeat\"\n when \"a full beat\"\n log \"Changed '#{artist}' into Volbeat\"\n return \"volbeat\"\n when \"the full beats\"\n log \"Changed '#{artist}' into Volbeat\"\n return \"volbeat\"\n when \"soul fly\"\n log \"Changed '#{artist}' into Soulfly\"\n return \"soulfly\"\n when \"so fly\"\n log \"Changed '#{artist}' into Soulfly\"\n return \"soulfly\"\n else\n log \"Changed nothing for '#{artist}'\"\n return artist\n end\n end", "def check_title\n if title.to_s == '' && audio_file.present?\n str = File.basename(audio_file_url).gsub(/[_]/, ' ') \n self.title = str.gsub(/[.mp3]/, '')\n self.save\n end\n end", "def audios_test\n end", "def audio?\n filename =~ /^audio/\n end", "def cover?\n self.kind == COVER\n end", "def autoplayAsCue\r\n if @map.autoplay_bgm\r\n if PBDayNight.isNight? && FileTest.audio_exist?(\"Audio/BGM/\"+ @map.bgm.name+ \"_n\")\r\n pbCueBGM(@map.bgm.name+\"_n\",1.0,@map.bgm.volume,@map.bgm.pitch)\r\n else\r\n pbCueBGM(@map.bgm,1.0)\r\n end\r\n end\r\n if @map.autoplay_bgs\r\n pbBGSPlay(@map.bgs)\r\n end\r\n end", "def audio?\n @descriptive_detail.audio?\n end", "def song_decoder(song)\n song.gsub(\"WUB\", \" \").gsub(/\\s+/, \" \").strip\nend", "def extract_metadata\n path = audio.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n TagLib::FileRef.open(path) do |fileref|\n tag = fileref.tag\n properties = fileref.audio_properties\n self.update_attributes(:artist => tag.artist,:album=> tag.album,:title => tag.title, :genre => tag.genre, :track_number => tag.track, :year_of_release => tag.year, :comments => tag.comment,:bitrate => properties.bitrate,:no_of_channels => properties.channels,:length=> properties.length,:sample_rate=> properties.sample_rate)\n end\n end", "def tag\n super('TagLib::FLAC::File')\n end", "def autoplayAsCue\n if @map.autoplay_bgm\n if PBDayNight.isNight? && FileTest.audio_exist?(\"Audio/BGM/\"+ @map.bgm.name+ \"n\")\n pbCueBGM(@map.bgm.name+\"n\",1.0,@map.bgm.volume,@map.bgm.pitch)\n else\n pbCueBGM(@map.bgm,1.0)\n end\n end\n if @map.autoplay_bgs\n pbBGSPlay(@map.bgs)\n end\n end", "def play_se_for_item\n # Don't play the sound\n end", "def get_non_flac_paths(source_path)\n non_flac_file_paths = Find.find(source_path).reject {|f| f.end_with?(\".flac\")}\n non_flac_file_paths.reject! {|e| !File.file?(e) }\n return non_flac_file_paths\nend", "def testNormalTrack\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n [1] => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def song_decoder(song)\n song.gsub(/WUB/i, ' ').gsub(/(\\A\\s+|\\s+\\z)/, '').gsub(/\\s+/, ' ')\nend", "def extract_metadata!\n unless self.title\n Mp3Info.open(self.server_path) do |mp3|\n self.title = mp3.tag.title\n self.artist = mp3.tag.artist\n self.album = mp3.tag.album\n self.year = mp3.tag.year\n self.comm = mp3.tag2.comm\n self.tcom = mp3.tag2.tcom\n self.tcon = mp3.tag2.tcon\n self.tcop = mp3.tag2.tcop\n self.tit2 = mp3.tag2.tit2\n self.tit3 = mp3.tag2.tit3\n self.tcat = mp3.tag2.tcat\n self.trck = mp3.tag2.trck\n self.tyer = mp3.tag2.tyer\n self.tgid = mp3.tag2.tgid\n self.wfed = mp3.tag2.wfed\n end\n\n self.title = \"Untitled\" unless self.title\n\n self.save\n end\n end", "def is_mixable_with?(song)\n mixables.include?(song)\n end", "def extract_metadata\n return unless audio?\n path = attachment.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end", "def infer_album_artist_from_track_data\n if track_artists().length == 1\n self.artist = track_artists()[0]\n \n @tracks.each do |track|\n track.artist = nil\n end\n else\n raise \"No album artist could be inferred.\"\n end\n end", "def extract_metadata\n return unless audio?\n path = upload.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end", "def extract_metadata\n return unless audio?\n path = upload.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end", "def extract_audio(infile)\n\n infile = Path[infile]\n \n p infile\n \n unless infile.exists?\n STDERR.puts \"Couldn't find #{infile}\"\n return\n end\n\n #unless VALID_EXTS.include? infile.ext\n # STDERR.puts \"Unrecognized video format: #{infile.ext}\"\n # return\n #end\n \n if infile =~ %r{^/dev/fd/}\n outfile = Path.pwd/\"#{infile.filename}.mp3\" \n else \n outfile = infile.with(:ext=>\"mp3\")\n end\n\n if outfile.exists?\n puts \"Error: #{outfile} exists!\"\n return\n end \n \n puts\n puts \"Input: #{infile}\"\n puts \"Output: #{outfile}\"\n puts\n \n # -lameopts q=5\n cmd = %w[mencoder -of rawaudio -oac mp3lame -ovc copy -o] + [outfile.to_s, infile.to_s]\n system(*cmd)\n \nend", "def lyrics\n if @file && @mp3\n self.play\n \n @file.each {|line| charPrint(line)}\n end\n end", "def is_mp3?\n if filename != nil\n filename.ends_with?('.mp3')\n else\n false\n end\nend", "def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend", "def give_metadata(name, folder_name, url)\n album_parts = name.split(\" _ALBUM_ \")\n single_parts = name.split(\" _SINGLE_ \")\n album_parts, single_parts = [album_parts, single_parts].map do |parts_set|\n (parts_set.length < 2) ? nil : parts_set\n end\n artist, album = album_parts || single_parts\n Dir.glob(\"./audio/#{folder_name}/**/*.mp3\").each do |path|\n Mp3Info.open(path) do |mp3|\n mp3.tag.artist = artist\n mp3.tag.album = \"#{album_parts ? \"ALBUM\" : \"SINGLE\"} #{album}\"\n end\n end\n end", "def convert_to_mp3\n\t\tputs \"\\n=> look for m4a files and convert it to mp3\\n\"\n\t\t\n\t\t# grab directory names.\n\t\tdir_names = Dir.entries @@dir_temp\n\t\t# remove .prefixes\n\t\tdir_names = self.remove_hidden_files dir_names\n\t\t\n\t\t# go thru each sub directories.\n\t\tdir_names.each do |current_dir|\n\t\t\tputs \"\\n=> at \" + @@dir_temp + current_dir + \"\\n\"\n\t\t\t\n\t\t\t# grabs the files in the directory\n\t\t\tcurrent_files = Dir.entries(@@dir_temp + \"/\" + current_dir)\n\t\t\t\n\t\t\t# remove the . prefixes.\n\t\t\tcurrent_files = self.remove_hidden_files current_files\n\t\t\t\n\t\t\t# cycle thru the file\n\t\t\tcurrent_files.each do |current_file|\n\t\t\t\t# file names\n\t\t\t\tsrc_file = \"\"\n\t\t\t\tdest_file = \"\"\n\t\t\t\n\t\t\t\t# checks if it has a m4a extension\n\t\t\t\tif self.is_m4a? current_file\t\t\n\t\t\t\t\tputs \"\\n=> encoding \" + current_file\n\t\t\t\t\t\n\t\t\t\t\t# creating src and dest files.\n\t\t\t\t\tsrc_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + self.ext_to_mp3(current_file)\n\t\t\t\t\t\n\t\t\t\t\t#src_file = \"'\" + src_file + \"'\" \n\t\t\t\t\t#dest_file = \"'\" + dest_file + \"'\" \n\t\t\t\t\t\n\t\t\t\t\t# escape the names.\n\t\t\t\t\tsrc_file = self.escaped_file_name(src_file)\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\t\t\n\t\t\t\t\tputs \"=> src \" + src_file \n\t\t\t\t\tputs \"=> dest \" + dest_file\n\t\t\t\t\t\n\t\t\t\t\t# lame encoding.\n\t\t\t\t\tself.lame_str(@@opt_lame, src_file, dest_file)\n\t\t\t\telse\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# split the mp3...\n\t\t\t\tself.mp3splt_str(@@opt_mp3splt, dest_file)\n\t\t\t\t\n\t\t\t\t# delete the source file.\n\t\t\t\t# only want the split files.\n\t\t\t\tself.rm_str(\"\", dest_file)\n\t\t\t\tif (src_file != \"\")\n\t\t\t\t\tself.rm_str(\"\", src_file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "def sound; end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def allows_title?\n case kind\n when COVER, IMAGE1, AUDIO, VIDEO1, TITLE, TEXT then true\n else false\n end\n end", "def audio_formats\n @descriptive_detail.audio_formats\n end", "def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)\n return if !bgm\n bgm=pbResolveAudioFile(bgm,volume,pitch)\n playingBGM=$game_system.playing_bgm\n if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch\n pbBGMFade(seconds)\n if !$PokemonTemp.cueFrames\n $PokemonTemp.cueFrames=(seconds*Graphics.frame_rate)*3/5\n end\n $PokemonTemp.cueBGM=bgm\n elsif playingBGM\n pbBGMPlay(bgm)\n end\nend", "def is_audio?\n result = false\n if !mime_type.blank?\n splits = mime_type.split('/')\n if splits[0] == AUDIO\n result = true\n end\n end\n \n result\nend", "def cover_art\n if @cover_art.nil?\n @cover_art = container.img(:class, 's-access-image').src\n end\n\n @cover_art\n end", "def style_rules!\n # -------------------\n # Get the embeds, and insert them into body if referenced\n # Note that the video won't necessarily be referenced in the body,\n # in which case gsub! won't do anything (return nil)\n self.postmeta.select { |pm| pm[:meta_key] =~ /_oembed/ }.each do |pm|\n if (match = pm[:meta_value].match(/youtube\\.com\\/(?:.+?\\/)?(?<vid>[\\w-]+)/))\n # Got a YouTube embed\n self.content.gsub!(/^http.+?youtube.+?#{match[:vid]}.*$/, pm[:meta_value])\n \n elsif (match = pm[:meta_value].match(/vimeo\\.com\\/video\\/(?<vid>\\d+)/))\n # Got a vimeo iframe\n self.content.gsub!(/^http.+?vimeo.+?#{match[:vid]}.*$/, pm[:meta_value])\n \n elsif (match = pm[:meta_value].match(/vimeo\\.com\\/moogaloop.+?clip_id=(?<vid>\\d+)/))\n # Got old-style vimeo embed\n self.content.gsub!(/^http.+?vimeo.+?#{match[:vid]}.*$/, pm[:meta_value])\n end\n end\n \n \n # If the post matches the [caption] tag, turn it into\n # some regular HTML\n regex = /\\[caption(.+?)\\](.+?)\\[\\/caption\\]/m\n \n self.content.match(regex) do |match|\n attributes = match[1]\n content = match[2]\n style_properties = {}\n \n attributes.split(\"\\\"\").each_slice(2) do |pair| \n style_properties[pair[0].lstrip.chomp(\"=\").to_sym] = pair[1]\n end\n \n self.content.gsub!(regex,\n WP.view.render(\"/admin/multi_american/attachment\", \n properties: style_properties, content: content).to_s\n )\n end\n \n \n # -------------------\n # Turn the main image into a fake AssetHost asset\n parsed_content = Nokogiri::HTML::DocumentFragment.parse(self.content, \"UTF-8\")\n parsed_content.css(\"div[@id*=attachment]\").each do |div|\n \n # -------------------\n # Get caption element\n caption = div.css('p').select { |p| p['class'].blank? }.last\n \n # -------------------\n # Change credit to h4 to conform to SCPR styles\n if credit = div.at_css('p.wp-media-credit')\n credit['class'] = \"\"\n credit.name = \"h4\"\n end\n \n # Nowe remove any ghost p's caused by invalid HTML or blank caption\n parsed_content.css('p').each do |p|\n if p.content.blank?\n p.remove\n end\n end\n \n # -------------------\n # Extract the inline style from the div\n style = {}\n if div['style'].present?\n div['style'].split(';').map { |s| s.split(\":\") }\n .flatten.map { |s| s.strip }\n .each_slice(2) { |p| style[p[0].to_sym] = p[1] }\n end\n \n # -------------------\n # If we were told to float the image (either way), \n # or if the image is really small,\n # render the \"right\" asset partial.\n # Otherwise put it in the middle\n if image = div.at_css('img')\n if %w{left right}.include?(style[:float]) || \n style[:width].to_i.between?(1,180)\n cssClass = \"right\"\n else\n cssClass = \"wide\"\n end\n \n # Render the entire asset block into the div\n div.inner_html = WP.view.render(\"/admin/multi_american/asset\",\n style: style, image: image.to_html, id: div['id'].split(\"_\")[1],\n credit: credit.try(:to_html), caption: caption.try(:to_html),\n cssClass: cssClass).to_s\n \n # Finally, get rid of the main div from WP by replacing it with its own children\n div.swap(div.children)\n end\n end\n \n self.content = parsed_content.to_html\n return self.content.html_safe\n end", "def set_artwork(filename)\n return unless filename\n\n apic = TagLib::ID3v2::AttachedPictureFrame.new\n apic.mime_type = \"image/jpeg\"\n apic.description = \"Cover\"\n apic.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover\n apic.picture = File.open(filename, 'rb') { |f| f.read }\n @raw_tag.add_frame(apic)\n end", "def song_decoder(song)\n song.gsub!(\"WUB\", \" \")\n return song.gsub(/\\s+/, \" \").strip\nend", "def metadata\n puts \"Adding Metadata...\"\n doc = Nokogiri::HTML(open(\"http://www.last.fm/search?q=#{query}&type=track\"))\n url = doc.css(\"span.chartlist-ellipsis-wrap\").first.css(\"a.link-block-target\").first.attr('href')\n ch = url.gsub('/music/', \"\")\n artist, title = ch.split(\"/_/\")\n artist = artist.gsub('+', \" \")\n title = title.gsub('+', \" \")\n doc = Nokogiri::HTML(open(\"http://www.last.fm#{url}\"))\n album = doc.css(\"h3 a\").first\n begin\n Mp3Info.open(\"#{query.gsub(\"+\",\"-\")}.mp3\") do |mp3|\n mp3.tag.title = \"#{URI.unescape(title)}\".strip\n mp3.tag.artist = \"#{URI.unescape(artist)}\".strip\n mp3.tag.album = \"#{URI.unescape(album.content)}\".strip\n end\n puts \"Done\"\n rescue\n puts \"Fail\"\n end\n end", "def select_streams(info)\n unless info[:video].empty?\n # There can be only one (video stream).\n info[:video] = info[:video].first\n end\n\n unless info[:audio].empty?\n audio_streams = []\n audio_stream = nil\n\n # Finds the highest quality English audio stream available\n info[:audio].each do |s|\n if s[:language] == 'eng'\n # Surround tracks\n audio_stream ||= s if s[:codec] == 'dts' # DTS\n audio_stream ||= s if s[:codec] == 'dca' # DTS (older ffmpeg)\n audio_stream ||= s if s[:codec] == 'eac3' # Dolby Digital Plus\n audio_stream ||= s if s[:codec] == 'ac3' # Dolby Digital\n # Stereo tracks\n audio_stream ||= s if s[:codec] == 'alac' # Apple lossless\n audio_stream ||= s if s[:codec] == 'flac' # Open-source lossless\n audio_stream ||= s if s[:codec] == 'opus' # Open-source lossy\n audio_stream ||= s if s[:codec] == 'aac' # AAC\n audio_stream ||= s if s[:codec] == 'vorbis' # OGG Vorbis\n audio_stream ||= s if s[:codec] == 'mp3' # MP3\n end\n end\n\n audio_streams << audio_stream if audio_stream != nil\n\n # Adds all of the non-English audio streams.\n info[:audio].each do |s|\n if s[:language] != 'eng'\n audio_streams << s\n end\n end\n\n info[:audio] = audio_streams\n end\n \n unless info[:subtitle].empty?\n # Removes all non-english subtitle streams.\n info[:subtitle].delete_if { |s| s[:language] != 'eng' }\n\n # Removes Bluray PGS subtitles because ffmpeg doesn't have encoding nor OCR support.\n info[:subtitle].delete_if { |s| s[:codec] == 'hdmv_pgs_subtitle' }\n\n # Removes subtitles marked as \"signs and songs\" which are usually forced.\n info[:subtitle].delete_if { |s| s[:title].downcase.include? 'sign' }\n\n # Default to the last subtitle stream (first one is usually forced subs)\n info[:subtitle] = info[:subtitle].last unless info[:subtitle].empty?\n end\n\n return info\nend", "def find_coverimages(editions)\n images = editions.map{|ed| ed['coverimage']}.compact\n # filter out fake ones\n images.reject! { |url| url =~ /book\\.trans\\.gif$/ }\n return images[0]\n end", "def has_sound?\n !!self.sound\n end", "def song_decoder(song)\n song.gsub('WUB', ' ').strip.squeeze\nend", "def is_audio_type?\n file_content_type =~ /\\Aaudio\\/.*\\Z/\n end", "def song_decoder(song)\n # p song.split('WUB').select { |i| i!= \"\" }.join(',').gsub(/,/, ' ')\n\n p song.gsub(/WUB/, ' ').strip.gsub(/ /, ' ')\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)\n return if !bgm\n bgm = pbResolveAudioFile(bgm,volume,pitch)\n playingBGM = $game_system.playing_bgm\n if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch\n pbBGMFade(seconds)\n if !$PokemonTemp.cueFrames\n $PokemonTemp.cueFrames = (seconds*Graphics.frame_rate)*3/5\n end\n $PokemonTemp.cueBGM=bgm\n elsif playingBGM\n pbBGMPlay(bgm)\n end\nend", "def contains_audio?\n result = false\n sample_attachments.map{|sa| result = true if sa.is_audio?}\n result\n end", "def irrelevant?\n video.nil? && manuscript.nil? && external_reference_link.blank?\n end", "def sound\n raise NotImplementedError\n end", "def cover?(options={})\n !options[:amazon] && cover_img\n end", "def codec\n \"-acodec libmp3lame -y\"\n end", "def parse_flac_meta_blocks\n @fp = File.new(@filename, \"rb\") # Our file pointer\n @comments_changed = nil # Do we need to write a new VORBIS_BLOCK?\n\n # These next 8 lines initialize our public data structures.\n @streaminfo = {}\n @comment = []\n @tags = {}\n @seektable = {}\n @padding = {}\n @application = {}\n @cuesheet = {}\n @picture = {\"n\" => 0}\n\n header = @fp.read(4)\n # First 4 bytes must be 0x66, 0x4C, 0x61, and 0x43\n if header != 'fLaC'\n raise FlacInfoReadError, \"#{@filename} does not appear to be a valid Flac file\"\n end\n\n typetable = { 0 => \"streaminfo\", 1 => \"padding\", 2 => \"application\",\n 3 => \"seektable\", 4 => \"vorbis_comment\", 5 => \"cuesheet\",\n 6 => \"picture\" }\n\n @metadata_blocks = []\n lastheader = 0\n pos = 1\n\n until lastheader == 1\n # first bit = Last-metadata-block flag\n # bits 2-8 = BLOCK_TYPE. See typetable above\n block_header = @fp.read(1).unpack(\"B*\")[0]\n #puts block_header\n lastheader = block_header[0].to_i & 1\n type = sprintf(\"%u\", \"0b#{block_header[1..7]}\").to_i\n @metadata_blocks << [typetable[type], type, lastheader]\n\n if type >= typetable.size\n raise FlacInfoReadError, \"Invalid block header type\"\n end\n\n pos += 1\n self.send \"parse_#{typetable[type]}\"\n end\n\n @fp.close\n end", "def main_audio\r\n super\r\n # Play title BGM\r\n $game_system.bgm_play($data_system.title_bgm)\r\n # Stop playing ME and BGS\r\n Audio.me_stop\r\n Audio.bgs_stop\r\n end", "def apply_song_break_class\n true\n end", "def process_file(src)\n media = \"\"\n # files first\n get_files(src).each do |file|\n next if file =~ /\\/\\._/\n \n # first we check if the file is a tv series\n episode_status, episode_name, episode_season, episode_episode = tv_file(file) if $config[\"series\"][\"process\"] == true\n if episode_status == true\n episode = Episode.new file\n if episode.is_ep?\n episode.status = handle_series episode \n media = episode.class.to_s\n end\n end\n \n # second we check if the file is music\n music_status = music_file(file) if $config[\"music_file\"][\"process\"] == true\n if music_status == true\n music = Music.new file\n if music.is_music?\n music.status = handle_music music \n media = music.class.to_s\n end\n end\n \n # finally we can handle rar's\n handle_rar(file) if file =~ /\\.rar$/ and file !~ /part\\d+\\.rar$/\n handle_rar(file) if file =~ /part01\\.rar$/\n end # get_files\n media\nend", "def convert_audio_to_ac3(stream, index)\n args = [ \"-map 0:a:#{stream[:index]}\",\n \"-metadata:s:a:#{index} title='Surround Track'\",\n \"-metadata:s:a:#{index} language=#{stream[:language]}\",\n \"-disposition:a:#{index} none\",\n \"-codec:a:#{index} ac3\",\n \"-ar:a:#{index} 48k\",\n \"-ab:a:#{index} 448k\",\n \"-ac:a:#{index} 6\" ]\n\n # DCA (DTS) is usually too quiet when converted to AAC.\n args << \"-af:a:#{index} volume=2.0\" if 'dca' == stream[:codec]\n\n return args\nend", "def mixables(options = {})\n track_ids = self.tracks.map(&:id)\n Song.public.find(:all, :include => :mixes,\n :conditions => ['mixes.track_id IN (?) AND mixes.song_id <> ?', track_ids, self.id])\n end", "def cover_aphoto\n @cover_aphoto ||= (album_photos.find_by_cover_photo(true) || album_photos.first)\n end", "def testNormalTrackWithSingleAlias\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1,\n :Alias => 'Track 1'\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Track 1' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def clean2\n content = text.split(\"\\n\")\n \n # First, find and mark songs\n in_song = false\n new_content = []\n content.each do |line|\n if line=~/\\*{5}/ .. line=~END_OF_SONG\n new_content << \"SONG:\" unless in_song\n if line =~ END_OF_SONG\n new_content << line\n in_song = false\n else\n new_content << \" #{line}\"\n in_song = true\n end\n else\n if in_song\n new_content << \"END OF SONG\"\n end\n in_song = false\n new_content << line\n end\n end\n \n # Now, fix line endings and merge lines\n old_content = new_content\n new_content = []\n preserve_breaks = false\n last_line = \"\"\n old_content.each do |line|\n new_content << \"\" if preserve_breaks ||\n last_line =~ END_OF_SONG || \n new_content.size == 0 ||\n line =~ /^.[LS]-\\d+(?:\\]|$|.\\s*\\()/ ||\n line =~ /^\\([A-Z]/ ||\n line =~ /^[A-Z][A-Z, \\.-]+:\\s/ ||\n line =~ /^Scene\\s+\\?\\s+-\\s+\\?/ ||\n line =~ START_OF_SONG ||\n line =~ /^#/\n case line\n when START_OF_SONG\n preserve_breaks = true\n when END_OF_SONG\n preserve_breaks = false\n end\n new_content[-1] += ' ' unless new_content[-1] =~ /^$|\\s$/\n new_content[-1] += line\n last_line = line\n end\n \n # Now, insert extra empty lines\n old_content = new_content\n new_content = []\n extra_space = true\n in_cast = false\n in_song = false\n \n old_content.each do |line|\n if line =~ /^#/\n extra_space = false if in_cast\n else\n in_cast = false\n extra_space = true unless in_song\n end\n new_content << \"\" if extra_space && new_content.size > 0\n new_content << line\n case line\n when /^#CAST FOR SCENE/\n in_cast = true\n when START_OF_SONG\n extra_space = false\n in_song = true\n when END_OF_SONG\n extra_space = true\n in_song = false\n end\n end\n \n # Finally, fix songs\n old_content = new_content\n new_content = []\n i = 0\n while i<old_content.size\n line = old_content[i]\n case line\n when START_OF_SONG\n # Find lines with stars in them\n j = i+1\n while j<old_content.size && old_content[j] !~ END_OF_SONG\n j += 1\n end\n # At this point lines i...j are the song; back up and look for the last \"*****\"\n while j>i && old_content[j] !~ /\\*{5}/\n j -= 1\n end\n # Now lines (i+1)...j are the song information block\n song_information = old_content[(i+1)...j].join\n song_name = song_information[/^[\\s\\*]*([^\\*]+)/,1].strip\n tune = song_information[/([^\\*]+)[\\s\\*]*$/,1].strip\n new_content += [\" SONG: #{song_name}\", \" (To the tune of: #{tune})\"]\n i = j+1\n when END_OF_SONG\n i += 1 # Discard end of song markers; we don't need them anymore\n else\n new_content << line\n i += 1\n end\n end\n \n # Save the results\n text = new_content.join(\"\\n\")\n end", "def cover(as_image = true)\n if as_image\n image_id = Spotify.album_cover(pointer)\n Image.new(image_id.read_string(20)) unless image_id.null?\n else\n link = Spotify.link_create_from_album_cover!(pointer)\n Link.new(link)\n end\n end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end", "def check_audio_codec\n if has_sound?\n @audio_codec = (@audio_stream[:codec_name] + @audio_stream[:profile]).upcase!\n @audio_codec_check = if AUDIO_CODEC == @audio_codec\n true\n else\n false\n end\n end\n end", "def convertToOGG()\n call = \"mpg321 #{File.join(RAILS_ROOT, self.filePath)} -w - | oggenc -o #{ File.join(RAILS_ROOT, @@publicDir, @@tracksDir, self.fileName)}.ogg -\"\n system(call)\n File.delete(self.filePath) if File.exist?(self.filePath)\n self.fileType = \".ogg\"\n \n #ID3 tags get lost in the conversion process - put them back into file\n begin\n musicFile = TagLib::File.new(self.filePath())\n musicFile.title = self.id3Title\n musicFile.artist = self.id3Artist\n musicFile.save()\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end\n \n \n end", "def fetch_cover(response, file_name)\n res = response.to_h\n response_url = res['RESPONSE']['ALBUM']['URL']\n title = res['RESPONSE']['ALBUM']['TITLE']\n file_name = file_name || \"#{title}-cover.jpg\"\n\n APIRequest.get_file(response_url, filename)\n end", "def cover_in(files)\n fnames = files.map { |f| f.basename.to_s }\n fnames.include?('front.jpg')\n end", "def non_musical_sound_recording?\n marc_leader_06_match = record.leader.byteslice(6) == 'i'\n\n marc_006_match = record.fields('006').find do |field|\n field.value.byteslice(0) == 'i'\n end\n\n return true if marc_leader_06_match || marc_006_match\n end", "def audio?\n !!( content_type =~ Transit.config.audio_regexp )\n end", "def audio_format\n @descriptive_detail.audio_format\n end", "def extract_metadata\n return unless audio?\n logger.debug(maudio_params[:path])\n logger.debug('It\\'s audio')\n path = maudio_params[:path]\n #url = URI.parse(path) # turn the string into a URI\n #http = Net::HTTP.new(url.host, url.port) \n #req = Net::HTTP::Get.new(url.path) # init a request with the url\n #req.range = (0..4096) # limit the load to only 4096 bytes\n #res = http.request(req) # load the mp3 file\n #child = {} # prepare an empty array to store the metadata we grab\n #open_opts = { :encoding => 'utf-8' }\n #Mp3Info.open( StringIO.open(res.body) ) do |m| #do the parsing\n # child['title'] = m.tag.title \n # child['album'] = m.tag.album \n # child['artist'] = m.tag.artist\n # child['length'] = m.length\n # \n # puts m\n #end\n #logger.debug('*********************')\n \n #logger.debug(child['length'])\n #logger.debug('*********************')\n end", "def detectAutoGeneratedCover(coverlog, final_cover, archived_cover, logkey='')\n gen = false\n if File.file?(coverlog) and !File.file?(final_cover)\n gen = true\n Mcmlln::Tools.deleteFile(coverlog)\n Mcmlln::Tools.deleteFile(archived_cover)\n elsif File.file?(coverlog) and File.file?(final_cover)\n gen = false\n Mcmlln::Tools.deleteFile(coverlog)\n Mcmlln::Tools.deleteFile(archived_cover)\n elsif !File.file?(coverlog) and !File.file?(final_cover) and !File.file?(archived_cover)\n gen = true\n end\n return gen\nrescue => logstring\n return ''\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def parse_atx_header_gfm_quirk; end", "def soundcloud?; soundcloud.to_s != \"\" end", "def extension_whitelist\n %w[mp3]\n end", "def cover\n pictures.find_by_cover(true) or pictures.first\n end", "def allows_text?\n case kind\n when TEXT, IMAGE1, AUDIO, VIDEO1 then true\n else false\n end\n end", "def all_formats_encoded?\n self.webm_file.path && self.mp4_file.path && self.ogg_file.path ? true : false\n end", "def getAudioUri\n return @data.scan(/https:\\/\\/.*?\\.mp3/)[0]\nend", "def has_sound?\n @has_sound = if @movie_info[:format][:nb_streams] == 1\n false\n elsif @movie_info[:format][:nb_streams] == 2\n true\n end\n end", "def audio?\n #or @volume == 0\n if @mute or @type == \"image\"\n #puts \"no audio\"\n return false\n else\n #puts \"has audio\"\n return true\n end\n end", "def subtitle_marks_spaced_correctly?(content_at_file)\n # Early return if content doesn't contain any subtitle_marks\n return Outcome.new(true, nil) if !content_at_file.contents.index('@')\n\n too_long_captions = find_too_long_captions(content_at_file.contents)\n if too_long_captions.empty?\n Outcome.new(true, nil)\n else\n Outcome.new(\n false, nil, [],\n too_long_captions.map { |(line, length, idx, excerpt)|\n Reportable.error(\n {\n filename: content_at_file.filename,\n line: line,\n context: excerpt,\n },\n [\n 'Subtitle caption is too long',\n %(#{ length } characters in caption ##{ idx }),\n ]\n )\n }\n )\n end\n end" ]
[ "0.67632115", "0.60676503", "0.5811365", "0.57060343", "0.56701577", "0.55040437", "0.54708576", "0.54346895", "0.5416631", "0.5405065", "0.52625066", "0.5200878", "0.5188838", "0.51738554", "0.51483715", "0.5139066", "0.5120301", "0.51178104", "0.509229", "0.50864613", "0.50847244", "0.50816554", "0.504328", "0.5034308", "0.5028675", "0.5009898", "0.50065166", "0.50063807", "0.5004504", "0.4998365", "0.49931312", "0.4987232", "0.4986935", "0.49677157", "0.49667722", "0.49644163", "0.49583027", "0.49562013", "0.49562013", "0.49558344", "0.49042723", "0.4900631", "0.48985565", "0.48955634", "0.48951858", "0.48924953", "0.48893943", "0.48875886", "0.4882482", "0.48755366", "0.48666513", "0.48653147", "0.48633397", "0.4862844", "0.48542777", "0.48505396", "0.483133", "0.48289442", "0.4828704", "0.48237875", "0.4816319", "0.48152143", "0.4814744", "0.48142135", "0.48142135", "0.48135093", "0.48124862", "0.48048416", "0.47889206", "0.47862735", "0.47774512", "0.47713906", "0.47606143", "0.47590017", "0.47513565", "0.47512656", "0.47499213", "0.47443599", "0.47426024", "0.4736327", "0.4723782", "0.4719389", "0.47144136", "0.47128305", "0.4707296", "0.47050783", "0.4703176", "0.47005138", "0.4697481", "0.469617", "0.46896335", "0.46794656", "0.46787444", "0.46772754", "0.46765167", "0.46724612", "0.46690327", "0.4667433", "0.46616012", "0.46605808", "0.46534345" ]
0.0
-1
Do we have a front.jpg?
def cover_in(files) fnames = files.map { |f| f.basename.to_s } fnames.include?('front.jpg') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_imagen?\n\t\tFile.exists?\n\tend", "def has_image?\n\t\treturn File.exists? image_filename\n\tend", "def picture?\n ThriveSmart::Helpers::AssetHelper::asset?(asset_type, asset_urn)\n end", "def image?\n ext = File.extname(@path)\n case ext.downcase\n when '.png', '.jpg', '.jpeg', '.gif'; return true\n else; return false\n end\n end", "def has_image?\n return File.exists? image_filename \n end", "def has_image?\n return File.exists? image_filename \n end", "def image?()\n IMAGE_EXTS.include? extname\n end", "def contains_jpeg?\n contains_images? and @url =~ /j\\z/i\n end", "def has_image?\n File.exists? image_filename\n end", "def image?\n %w(jpg jpeg gif png).include?(file_ext.downcase)\n end", "def is_image?\n ['jpg', 'jpeg', 'pjpeg', 'png', 'bmp', 'gif', 'x-png'].include? self.image_file_name.split('.').last\n end", "def poke_front_exist?(filename, hue = 0)\n test_file_existence(filename, Pokedex_PokeFront_Path.fetch(hue), @poke_front_data[hue])\n end", "def image?(src)\n !File.directory?(src)\n end", "def has_image?\n false\n end", "def has_image?(image)\n # FIXME\n true\n end", "def language_image_exists?( filename )\n return ((!filename.blank?) and FileTest.exists?(\"#{RAILS_ROOT}/public/#{filename}\"))\n end", "def image?\n !!image\n end", "def image?\n image ? true : false\n end", "def main_image_url?\n main_image_source == ImageSource::URL\n end", "def image?\n self.content_type.to_s.index(/image/).nil?\n end", "def image_file?\n false\n end", "def has_image?\n \t# self.image.file?\n true\n end", "def image?\n IMAGE_EXTENSIONS.include? File.extname(filename)[1..-1]\n end", "def photograph?\n true\n end", "def has_image?(type)\n # Use of S3 without AWS-Ruby doesn't allow for checking whether or not image is available\n true\n # path = \"#{Rails.root}/app/assets/images/people/#{key}/#{type.to_s}.jpg\"\n # FileTest.exist?(path) ? path : false\n end", "def image_1_is_from_google?\n !image_1_google_thumb.blank?\n end", "def default_image_exists?\n !!(File.exists? Rails.root.join('public',\"#{default_image_path}_medium.jpg\"))\n end", "def exists?\n if self.class.oneimage_list().include?(resource[:name])\n self.debug \"Found image #{resource[:name]}\"\n true\n end\n end", "def has_image?\n !image.nil?\n end", "def picture_exist?(filename)\n test_file_existence(filename, Pictures_Path, @picture_data)\n end", "def any_pix?\r\n pictures.detect { |x| x && !x.photo_file_name.nil? }\r\n end", "def has_banner_image?\n !banner_image.path.nil?\n end", "def previewable?\n image? file\n end", "def quality_95_image_exists?\n image.present? and image.quality_95.file.exists?\n end", "def exif?\n #TODO could be better?\n # Not good because it can rescues a file doesn't exist error.\n unless many?\n !Jhead.call(\"-exonly\", \"-c\", @match, @pattern).empty? rescue false\n end\n end", "def image?\n !!( content_type =~ Transit.config.image_regexp )\n end", "def has_shelby_avatar() !self.avatar_file_name.blank?; end", "def image?\n self.image.file?\n end", "def image?\n self.image.file?\n end", "def image?\n picture_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end", "def geifile?\n @raw_image_files.first.geifile?\n end", "def has_thumbnail?\n File.exists? path.gsub(/(.+)\\/(.+)/, '\\1/thumbs/\\2')\n end", "def image?\n file_type.match(/\\Aimage\\//).present?\n end", "def any_pix?\n pictures.detect { |x| x && !x.photo_file_name.nil? }\n end", "def checkImageExists\n Find.find(\"./image/\") do |image|\n next unless FileTest.file?(image) && (image =~ /\\.jpg\\Z/ || image =~ /\\.jpeg\\Z/ ||\n image =~ /\\.png\\Z/ || image =~ /\\.gif\\Z/)\n return true\n end\n return false\n end", "def contains_png?\n contains_images? and @url =~ /p\\z/i\n end", "def image?\n return ( VALID_HEADERS.include? @hdr_reader )\n end", "def picture_missing?\n self.image.url.include?(\"https://profilepicturesdp.com/wp-content/uploads/2018/06/default-good-youtube-profile-pictures-3.jpg\")\n end", "def fog_exist?(filename)\n test_file_existence(filename, Fogs_Path, @fog_data)\n end", "def is_main_image?\n self.primary_image == true\n end", "def splash_displayed?\n displayed? SPLASH_VIDEO\n end", "def attached?(filename); end", "def pfile?\n @raw_image_files.first.pfile?\n end", "def media_file_exist?(name)\n expaned_path =\n File.join(Media.media_path, name.gsub(/img\\//, ''))\n File.exist?(expaned_path) and name\n end", "def picture_exists?(path=nil)\n path ||= picture_path\n File.exist? path\n end", "def is_top?\n !top_picture.blank? \n end", "def uploaded_image_displayed?\n displayed? UPLOADED_IMAGE\n end", "def image?\n self.file_content_type == 'image/png' || self.file_content_type == 'image/jpeg'\n end", "def front_camera?\n UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceFront)\n end", "def image_processing?\n !image_tmp.blank?\n end", "def has_photo?\n File.exists? photo_filename\n end", "def has_photo?\n File.exists? photo_filename\n end", "def has_photo?\n File.exists? photo_filename\n end", "def derived_image?\n respond_to?(:format_name) && !format_name.blank?\n end", "def quality_85_image_exists?\n image.present? and image.quality_85.file.exists?\n end", "def image?\n @image ||= !!(attachment_content_type =~ /^image\\/.+/)\n end", "def image?\n (self.file_content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$})\n end", "def url_with_image?(url)\n url.match('\\.(png|jpg|gif)$')\n end", "def flying?\n not $game_map.screen.pictures[@picture_index].name == \"\"\n end", "def image_exists?(filename)\n File.exists?(File.join(absolute_images_path, filename))\n end", "def image_work?\n true\n end", "def image?\n self.type == \"Image\"\n end", "def picture?\n\t\tprovider.in? [\"twitter\", \"facebook\", \"google_oauth2\", \"lastfm\", \"vimeo\"]\n\tend", "def has_image?\n Dir[\"#{Rails.root}/public/ProductImage#{self.openerp_id}\"].size > 0\n end", "def image?\n self.type == \"Assetabler::Image\"\n end", "def has_image\n return self.food_images.size>0\n end", "def quality_100_image_exists?\n image.present? and image.quality_100.file.exists?\n end", "def preview?\n \n self.preview ? File.exists?(self.preview.path) : false\n end", "def contains_images?\n !@url.nil?\n end", "def jpeg?(image)\n cur_page.jpeg?(image)\n end", "def thumbnail_image_exists?\n image.present? and image.thumbnail.file.exists?\n end", "def is_image?\n content_type.split('/')[0] == \"image\"\n end", "def image?(file)\n file.content_type.include? 'image'\n end", "def web_image?\n %w(png jpg jpeg gif).each do |sub_type|\n return true if Rack::Mime.match?(mime_type, \"image/#{sub_type}\")\n end\n\n false\n end", "def image? new_file\n new_file.content_type.start_with? 'image'\n end", "def preview_file_ready?\n if !session[:preview_filename] || !File.exist?(session[:preview_filename])\n render nothing: true, status: :not_found\n end\n end", "def top_image(url)\n og_image = check_og_image(url)\n apple_image = check_apple_image(url)\n mechanize_search = mechanize_search(url)\n if og_image\n return og_image\n elsif apple_image\n return apple_image\n elsif mechanize_search\n mechanize_search \n # In case all else fails ...\n else\n \"../image-dne.jpg\"\n end\n end", "def png?\n \n if @tmpfile \n begin\n image = ChunkyPNG::Image.from_file(@tmpfile.path)\n return true if image\n rescue\n return false\n end\n end\n \n return @png if @png\n return false if location.empty?\n\n # # ... \n\n return true if location =~ /[.]png$/\n \n begin\n response = RestClient.head(location)\n return true if response.headers['content-type'] == 'image/png'\n rescue\n return false\n end\n \n return false\n \n end", "def is_image_type?\n background_media.content_type =~ %r(image)\n end", "def has_media?\n !@front.media.empty? or !back.media.empty?\n end", "def has_background?\n !@background.nil?\n end", "def imageurl?\n !!self.imageurl\n end", "def meta_image?\n meta_image.present? || default_meta_image?\n end", "def image?\n photo_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end", "def has_images?\n !@image_urls.empty?\n end", "def image?\n document_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end", "def check_if_image?\n !(attachment_content_type =~ /^image.*/).nil?\n end", "def file_exists?(img_path)\n File.exists?(File.join(Rails.root, 'public', img_path ))\n end", "def remote_image_exists?(url)\n if url.end_with? 'gif'\n return true\n else\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = (url.scheme == \"https\")\n http.start do |http|\n return http.head(url.request_uri)['Content-Type'].start_with? 'image'\n end\n end\n end", "def raster_file?\n false\n end" ]
[ "0.71890205", "0.70424587", "0.7027508", "0.7014576", "0.6923102", "0.6923102", "0.68960094", "0.6862944", "0.68539727", "0.68206805", "0.6802971", "0.6744579", "0.6739531", "0.67010283", "0.6687487", "0.6671584", "0.66455996", "0.66449165", "0.66317534", "0.65993094", "0.6593887", "0.65861565", "0.65775824", "0.6575853", "0.6565247", "0.65520513", "0.6527575", "0.65195245", "0.6471088", "0.64623445", "0.64586306", "0.6457494", "0.6431853", "0.64253134", "0.6402456", "0.6401324", "0.63917", "0.63903", "0.63903", "0.6383829", "0.6376948", "0.6376417", "0.63740957", "0.6369805", "0.63682556", "0.6366343", "0.63624126", "0.6360605", "0.63478786", "0.63456583", "0.6344519", "0.634286", "0.63385314", "0.6336798", "0.63315547", "0.6319865", "0.6318952", "0.63174105", "0.6317133", "0.6316295", "0.63078016", "0.63078016", "0.63078016", "0.63033605", "0.6298928", "0.6298646", "0.6295625", "0.628206", "0.627227", "0.62707764", "0.6265229", "0.6256506", "0.6256101", "0.6253893", "0.6245411", "0.6226068", "0.622291", "0.62222946", "0.62037", "0.6201574", "0.6200245", "0.61893547", "0.61812776", "0.61785805", "0.615249", "0.6145498", "0.61443645", "0.6140437", "0.6139133", "0.6134034", "0.61232495", "0.6117122", "0.61120915", "0.61042863", "0.61008704", "0.60715353", "0.605234", "0.6035214", "0.6033671", "0.60286725" ]
0.6703465
13
I want cover art for FLACs, but not MP3s.
def cover_art?(files) case files.first.extname when '.flac' raise Aur::Exception::LintDirCoverArtMissing unless cover_in(files) when '.mp3' raise Aur::Exception::LintDirCoverArtUnwanted if cover_in(files) end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cover_art\n if @cover_art.nil?\n @cover_art = container.img(:class, 's-access-image').src\n end\n\n @cover_art\n end", "def extract_cover(replace_cover=true)\n if cover && !replace_cover\n return false\n end\n return false if tracks.empty?\n if full_path = tracks.first.extract_cover\n self.cover = File.basename(full_path)\n self.thumbnail = \"#{id}.png\"\n end\n end", "def set_artwork(filename)\n return unless filename\n\n apic = TagLib::ID3v2::AttachedPictureFrame.new\n apic.mime_type = \"image/jpeg\"\n apic.description = \"Cover\"\n apic.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover\n apic.picture = File.open(filename, 'rb') { |f| f.read }\n @raw_tag.add_frame(apic)\n end", "def exact_covers\n enum_for :each_exact_cover\n end", "def set_cover_image(format)\n case format\n when \"Book\"\n return \"cornell/virtual-browse/book_cvr.png\"\n when \"Journal/Periodical\"\n return \"cornell/virtual-browse/journal_cvr.png\"\n when \"Manuscript/Archive\"\n return \"cornell/virtual-browse/manuscript_cvr.png\"\n when \"Map\"\n return \"cornell/virtual-browse/map_cvr.png\"\n when \"Musical Recording\"\n return \"cornell/virtual-browse/musical_recording_cvr.png\"\n when \"Musical Score\"\n return \"cornell/virtual-browse/musical_score_cvr.png\"\n when \"Non-musical Recording\"\n return \"cornell/virtual-browse/non_musical_cvr.png\"\n when \"Thesis\"\n return \"cornell/virtual-browse/thesis_cvr.png\"\n when \"Video\"\n return \"cornell/virtual-browse/video_cvr.png\"\n when \"Microform\"\n return \"cornell/virtual-browse/microform_cvr.png\"\n else\n return \"cornell/virtual-browse/generic_cvr.png\"\n end\n\n end", "def cover\n pictures.find_by_cover(true) or pictures.first\n end", "def hm_art file_name\r\n hm_art = File.join(File.dirname(__FILE__), '..', 'art', file_name)\r\n img = File.read(hm_art)\r\n end", "def cover_image\n end", "def art_image(art)\n art.poster\n end", "def image\n #images = Musicbrainz_db.get_cover_art(self.id)[\"images\"]\n\n images = SearchModule.get_cover_art(self.id)\n if images != nil\n return images[\"images\"].first[\"thumbnails\"][\"large\"]\n else\n return 'http://djpunjab.in/cover.jpg'\n end\n end", "def cache_artwork\n filename = Track.artwork_directory + \"/T#{self.id}.png\"\n thumb = Track.artwork_directory + \"/T#{self.id}_160x160.png\" \n data = self.artwork.data\n \n # Write the track level data\n write_artwork(data, filename, thumb)\n # Also write the album data\n write_artwork(data, Track.artwork_directory + \"/A#{album_artwork_name}.png\", Track.artwork_directory + \"/A#{album_artwork_name}_160x160.png\" ) \n return thumb\n end", "def find_coverimages(editions)\n images = editions.map{|ed| ed['coverimage']}.compact\n # filter out fake ones\n images.reject! { |url| url =~ /book\\.trans\\.gif$/ }\n return images[0]\n end", "def cover_url\n [\"condition_headache.jpeg\",\"condition_chair.jpeg\",\"condition_time.jpeg\",\"condition_med.jpeg\"][rand(4)] \n end", "def serial_collection_cover_items\n # Carousels load their data asynchronously on the front end\n return [] if cover_type_carousel?\n\n # Only include cover items if this collection has indicated to use them\n cover_type_default? ? [] : collection_cover_items\n end", "def cover_url\n case self.category\n when \"Nutrition\"\n \"nutrition.jpeg\" \n when \"Activity\"\n \"activity.jpeg\"\n when \"Exercise\"\n \"exercise.jpeg\"\n when \"Rehabilitation\"\n \"rehabilitation.jpeg\"\n when \"Medication\"\n \"medications.jpeg\"\n else\n \"activity.jpeg\"\n end\n end", "def cover?(options={})\n !options[:amazon] && cover_img\n end", "def extract_cover!(offset=0.0)\n random_name = (0...8).map { (65 + rand(26)).chr }.join\n tmp_file = \"tmp/#{random_name}.jpg\"\n\n `ffmpeg -itsoffset -#{offset} -i '#{video_file.path}' -vframes 1 -an #{tmp_file}`\n\n # Attach output image as cover image\n File.open(tmp_file) do |f|\n self.cover_image = f\n save\n end\n end", "def art_file\n \"#{Digest::SHA1.hexdigest(\"#{artist_name}/#{album_name}\")}.png\"\n end", "def cover\n \"http://lorempixel.com/100/150/\" +\n %w(abstract nightlife transport).sample +\n \"?a=\" + SecureRandom.uuid\n end", "def add_cover(original, format=nil, thumb=true)\n processor = Toastunes::ImageProcessor.new\n full_path = processor.save_cover(id, original, format)\n self.cover = File.basename(full_path)\n if thumb\n thumbnail_path = processor.write_thumbnail(self)\n self.thumbnail = File.basename(thumbnail_path)\n end\n end", "def cover\n 'http://lorempixel.com/400/300/' + %W(abstract nightlife transport).sample + '?a=' + SecureRandom.uuid\n end", "def with_no_cover\n build_image\n self\n end", "def cover?\n self.kind == COVER\n end", "def cover_image\n add_property('cover-image')\n end", "def update_thumbs\n File.open(self.cover_art) do |f|\n self.default_cover_art = f\n self.default_cover_art.recreate_versions!\n self.save!\n end\n end", "def autoplayAsCue\r\n if @map.autoplay_bgm\r\n if PBDayNight.isNight? && FileTest.audio_exist?(\"Audio/BGM/\"+ @map.bgm.name+ \"_n\")\r\n pbCueBGM(@map.bgm.name+\"_n\",1.0,@map.bgm.volume,@map.bgm.pitch)\r\n else\r\n pbCueBGM(@map.bgm,1.0)\r\n end\r\n end\r\n if @map.autoplay_bgs\r\n pbBGSPlay(@map.bgs)\r\n end\r\n end", "def cover(as_image = true)\n if as_image\n image_id = Spotify.album_cover(pointer)\n Image.new(image_id.read_string(20)) unless image_id.null?\n else\n link = Spotify.link_create_from_album_cover!(pointer)\n Link.new(link)\n end\n end", "def art_link(quality = :full)\n case quality\n when :full\n \"#{self.link}/art\"\n when :medium\n \"#{self.link}/art/medium\"\n when :thumb\n \"#{self.link}/art/thumb\"\n else\n \"#{self.link}/art\"\n end\n end", "def extract_cover\n puts 'Extract front cover'\n extract_png(1, 'cover')\n puts 'Extract back cover'\n extract_png(page_count, 'back')\n end", "def autoplayAsCue\n if @map.autoplay_bgm\n if PBDayNight.isNight? && FileTest.audio_exist?(\"Audio/BGM/\"+ @map.bgm.name+ \"n\")\n pbCueBGM(@map.bgm.name+\"n\",1.0,@map.bgm.volume,@map.bgm.pitch)\n else\n pbCueBGM(@map.bgm,1.0)\n end\n end\n if @map.autoplay_bgs\n pbBGSPlay(@map.bgs)\n end\n end", "def findIssueCover(unit, volume, issue, caption, dbAttrs)\n key = \"#{unit}:#{volume}:#{issue}\"\n if !$issueCoverCache.key?(key)\n # Check the special directories for a cover image.\n filename = \"#{volume.rjust(2,'0')}_#{issue.rjust(2,'0')}_cover\"\n imgPath = nil\n # Try a couple old directories, and both possible file extensions (for JPEG and PNG images)\n [\"/apps/eschol/erep/xtf/static/issueCovers\", \"/apps/eschol/erep/xtf/static/brand\"].each { |staticDir|\n [\"jpg\", \"png\"].each { |ext|\n path = \"#{staticDir}/#{unit}/#{volume.rjust(2,'0')}_#{issue.rjust(2,'0')}_cover.#{ext}\"\n File.exist?(path) and imgPath = path\n }\n }\n data = nil\n if imgPath\n data = putImage(imgPath)\n caption and data[:caption] = sanitizeHTML(caption)\n end\n $issueCoverCache[key] = data\n end\n\n $issueCoverCache[key] and dbAttrs['cover'] = $issueCoverCache[key]\nend", "def item_thumb_url(document)\n if sound_type_item?(document)\n asset_path 'file-audio.png'\n else\n \"https://dlg.usg.edu/thumbnails/#{document['repository_slug_ss']}/#{document['collection_slug_ss']}/#{document['record_id_ss']}.jpg\"\n end\n end", "def get_cover_image(book, url)\n if not url.nil?\n name = book.name || \"#{book.series.name} \\##{book.number}\"\n log(\"attempting to retrieve cover art [#{url}]\", :debug)\n cover_image = book.build_cover_image(:uploaded_data => UrlUpload.new(url))\n if cover_image.save\n log(\"successfully added cover art [#{name}]\", :debug)\n else\n log(\"unable to add cover art [#{name}]\", :debug)\n end\n else\n log(\"invalid URL for cover art [#{name}]\", :debug)\n end\n rescue OpenURI::HTTPError\n log(\"cover art not found [#{name}]\", :debug)\n end", "def cache_album_art\n FileUtils.mkdir_p(Play.album_art_cache_path)\n art_cache_path = \"#{Play.album_art_cache_path}/#{art_file}\"\n\n if !File.exists?(art_cache_path)\n if data = album_art_data\n File.open(art_cache_path, 'wb') { |file| file.write(data) }\n art_cache_path\n end\n end\n end", "def cover_in(files)\n fnames = files.map { |f| f.basename.to_s }\n fnames.include?('front.jpg')\n end", "def large_cover\n return @large_cover\n end", "def quality_and_strip(percentage)\n manipulate! do |img|\n img.format('jpg') # We want to enforce jpeg so we can use good compression.\n img.strip # Do not store EXIF data in the thumb to save space\n img.quality(percentage.to_s)\n img = yield(img) if block_given?\n img\n end\n end", "def masterpiece\n if arts.empty?\n \"BioCorgi.jpg\"\n else\n arts.first.location\n end\n end", "def fetch_cover(response, file_name)\n res = response.to_h\n response_url = res['RESPONSE']['ALBUM']['URL']\n title = res['RESPONSE']['ALBUM']['TITLE']\n file_name = file_name || \"#{title}-cover.jpg\"\n\n APIRequest.get_file(response_url, filename)\n end", "def cover_aphoto\n @cover_aphoto ||= (album_photos.find_by_cover_photo(true) || album_photos.first)\n end", "def cover\n\t\tself.image.blank? ? \"default.jpg\" : self.image\n\tend", "def play_se_for_item\n # Don't play the sound\n end", "def find_exact_cover\n exact_covers.first\n end", "def art_path(love, underscore_name)\n # TODO: adding other file types, this might break\n # extensions = [ \".jpg\", \".png\", \".jpeg\", \".gif\" ]\n\n #love = Love.find(id)\n\n # match any file in the image directory\n wildcard = \"public/images/art_cache/#{love.gb_id}_#{underscore_name}*\"\n # we shouldn't have multiple files extensions for the same game so just grab first\n file_match = Dir[wildcard].first\n \n # alt tag text bit\n # love_title = love.gb\n # love_title = Love.where(:gb_id => love.gb_id).first\n if !love.gb_title = \"<<NO GB HIT>>\"\n alt_tag = love.gb_title\n else\n alt_tag = love.ars_review.ars_title\n end\n puts alt_tag\n\n if file_match\n return image_tag file_match.sub(/^public\\/images\\//,''), :title => alt_tag\n else\n return image_tag \"/images/no_art_#{underscore_name}.gif\", :title => alt_tag\n end\n end", "def cover\n cover_path = [ @site.config['source'] ]\n if single_post? && single_post.data['cover']\n cover_path << single_post.data['cover']\n elsif site_lang?\n cover_path << @config['covers_dir']\n cover_path << site_lang\n cover_path << \"#{@slug}.png\"\n else\n cover_path << @config['covers_dir']\n cover_path << \"#{@slug}.png\"\n end\n\n File.join(cover_path)\n end", "def show\n @artpiece = Artpiece.find(params[:id])\n @artist = Artist.find(@artpiece[:artist_id])\n @files = Dir.glob(\"public/images/artcat/pieces/#{sprintf(\"%03d\", @artpiece.id)}*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @artpiece }\n end\n end", "def thumb\n return if collection?\n\n encoded_thumb if %w[book image manuscript map webarchive-seed].include?(dor_content_type)\n end", "def revise_cover_status\n if self.cover?\n Plant.find(self.plant_id).pictures.each do |picture|\n if (picture.cover? && picture.id != self.id)\n picture.cover = false\n picture.save\n end\n end\n end\n end", "def asset_name\n 'Playlist'\n end", "def make_default\n @picture = Picture.find(params[:id])\n @artwork = Artwork.find(params[:artwork_id])\n\n @artwork.cover = @picture.id\n @artwork.save\n end", "def worked?\n if @discFound.getTitle.empty?\n puts \"Disco no encontrado\"\n return false\n end\n\n for i in (0..@mp3Dir.getMP3.count-1)\n trackNumber = i+1\n trackNumber = trackNumber < 10 ? '0' + trackNumber.to_s : trackNumber\n mp3File = @directorio + '/' + @mp3Dir.getMP3[i]\n track = @discFound.getTracks[i]\n\n system \"eyeD3 --remove-all \\\"#{mp3File}\\\"\"\n\n tag = ID3Lib::Tag.new mp3File\n\n tag.title = track.getName\n tag.performer = @discFound.getArtist\n tag.year = @release_year.empty? ? @discFound.getYear : @release_year\n tag.track = i+1\n tag.composer = @discFound.getArtist\n tag.album = @discFound.getTitle + (@album_title_extra.empty? ? '' : @album_title_extra)\n tag.comment = 'Tagged using rtag v1.3.0'\n\n cover = {\n :id => :APIC,\n :mimetype => 'image/jpeg',\n :picturetype => 3,\n :description => 'Disc Cover',\n :textenc => 0,\n :data => File.read('folder.jpg')\n }\n\n tag << cover\n tag.update!\n\n name = track.getName\n name.gsub! /\\//, ''\n \n name.sub! '*','#'\n name.sub! '?',''\n\n targetFile = @directorio + \"/\" + trackNumber.to_s + \". \" + name + \".mp3\"\n\n File.rename mp3File, targetFile\n end\n File.rename 'folder.jpg', @directorio + '/folder.jpg'\n return true\n end", "def cover_url\n self.cover.expiring_url(3600, :medium)\n end", "def cover\n # we have cover set test because not sufficient to\n # just test for @cover.nil? because nil is a valid\n # condition for @cover and we don't want to go\n # back through all the logic again\n if !@cover_set\n @cover = cover_fetch\n @cover_set = true\n end\n @cover\n end", "def find_cover(artist, album, dir, dl: true)\n\t\t#First try to find a cover in the album dir\n\t\t#SH::Pathname.new(dir).glob(ImagesGlob) #do it directly\n\t\timgs=dir ? images_in_path(dir) : []\n\t\treturn select_cover(imgs) unless imgs.empty?\n\n\t\treturn nil unless artist and album #sanity check\n\t\timgs=stored_covers(artist, album)\n\t\t# this returns nil if we only have covers symlinked to unknown.png\n\t\treturn select_cover(imgs) unless imgs.empty?\n\n\t\tif dl\n\t\t\tyield if block_given?\n\t\t\tresult=dl_covers(artist, album)\n\t\t\tcase result\n\t\t\twhen :found\n\t\t\t\timgs=stored_covers(artist, album)\n\t\t\t\treturn select_cover(imgs) unless imgs.empty?\n\t\t\twhen :notfound\n\t\t\t\t#if we reach here the cover was not found\n\t\t\t\tunknown_album(Covers+(sanitize(\"##{artist}##{album}#unknown.png\")))\n\t\t\twhen :unavailable\n\t\t\t\t#do nothing\n\t\t\tend\n\t\tend\n\n\t\tnil #not found\n\tend", "def set_as_cover\n if imageable_type == \"Album\"\n self.imageable.photos.where(is_cover_photo: true).update_all(is_cover_photo: false)\n self.update(is_cover_photo: true)\n end\n end", "def setup_cutin_fade\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n get_spriteset.cutin.fade(@acts[1], @acts[2])\n end", "def cover_image(safe_mode = false)\n kitty_url = FakeImage.new\n cover = images.try(:last) ? images.last : kitty_url\n image = safe_mode == true ? kitty_url : cover\n image\n end", "def show_in_browser(lfile)\n htfile = \"/tmp/lyrics-out.html\"\n begin\n mp3info = Mp3Shell.new(@track.location.path)\n awfile = mp3info.get_artwork(\"/tmp/artwork\")\n if awfile && (awfile !~ /xxx$/) && (File.size(awfile) > 1024)\n background = \"background: url(#{awfile}) no-repeat center center fixed\"\n else\n Plog.info \"No image found for #{@track.name}. Use gradient\"\n background = \"background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0, #FFFFFF), color-stop(1, #00A3EF))\"\n end\n rescue => errmsg\n p errmsg\n end\n File.open(htfile, \"w\") do |fod|\n fod.puts <<EOF\n<html><head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n<title>#{@track.name} - #{@track.artist}</title>\n<style type=\"text/css\">\n html { \n #{background};\n -webkit-background-size: cover;\n -moz-background-size: cover;\n -o-background-size: cover;\n background-size: cover;\n }\n .transbox {\n width:80%;\n margin:5% 10%;\n padding: 5px;\n background-color:#ffffff;\n border:1px solid #888888;\n opacity:0.7;\n filter:alpha(opacity=70); /* For IE8 and earlier */\n position: relative;\n }\n .info {\n font-size: 80%;\n color: #888;\n }\n .footer {\n position: relative;\n clear: both;\n margin-top: 20px;\n height: 20px;\n }\n</style>\n<script src=\"http://code.jquery.com/jquery.js\"></script>\n</head>\n<body>\n<div class=\"container\">\n<div class=\"transbox\">\nEOF\n fod.puts <<EOF\n<div class=info>\n<b>Artist:</b> #{@track.artist}\n<b>Author:</b> #{@track.composer}\n<b>Album:</b> #{@track.album}\n</div>\nEOF\n fod.puts \"<center><h2>#{@track.name}</h2>\"\n lines = File.read(lfile).split(/[\\r\\n][\\r\\n]+/)[1..-1]\n lines = lines.join(\"\\n\\n\").gsub(/[\\r\\n]/, \"\\n<br>\")\n\n fod.puts(lines)\n q0 = \"Lyrics #{@track.name} #{@track.artist}\"\n q = URI::escape(q0)\n href = \"http://www.google.com/search?q=#{q}&oq=#{q}ie=UTF-8\"\n fod.puts <<EOF\n</center>\n<a href=#{href}>#{q0}</a>\n<div class=\"info footer\">\n<b>Artist:</b> #{@track.artist}\n<b>Author:</b> #{@track.composer}\n<b>Album:</b> #{@track.album}\n</div>\n</div>\n</div>\n</body></html>\nEOF\n end\n browser = @options[:browser] || \"Safari\"\n Pf.system(\"open -a '#{browser}' #{htfile}\", 1)\n end", "def set_image_as_unique_cover\n return unless media_type == 'image'\n cover_file = MediaFile\n .where(attachable: self.attachable, cover: true)\n .where.not(id: id)\n\n if cover?\n cover_file.update_all(cover: false)\n elsif cover_file.blank?\n self.cover = true\n end\n end", "def default_image_for_item_type\n case item_type.to_s\n when 'parfume'\n '/assets/_sample/category-grey-1.jpg'\n when 'song'\n '/assets/_sample/category-grey-2.jpg'\n else\n '/assets/_sample/category-grey-3.jpg'\n end\n end", "def setup_check_cover\n return if area_flag\n get_scene.tsbs_apply_substitute(target, item_in_use, self)\n end", "def cover\n manipulate! do |frame, index|\n frame if index.zero?\n end\n end", "def test_mosaic\n Pikl::Image.open(SAMPLE_IMAGE) do |img|\n img.mosaic(3,3)\n end\n end", "def part_of_gapless_album\n @ole.PartOfGaplessAlbum\n end", "def sound_cue(href, ds = nil)\n Kamelopard::SoundCue.new href, ds\n end", "def image_cover\n album_cover ? album_cover.photo : photos.size > 0 ? photos.first : nil\n end", "def pdf_cover\n cover.gsub(/\\.[^\\.]+\\Z/, '.pdf')\n end", "def test_cropped_fallback\n output = tested 'fallback rms.jpg 1:3'\n\n assert_includes stderr, 'rms.jpg'\n assert_match url_matcher(format: 'webp', width: 30),\n output.at_css('img')['src']\n end", "def show\n @cake = Cake.find params[:id]\n cake_pictures = @cake.cake_pictures\n render_pictures cake_pictures, @cake.name.titleize\n end", "def show\n @song = Song.find(params[:id])\n @metadata = @song.metadatum\n @images = BackgroundImage.where(song_id: @song.id)\n end", "def is_skippable?\n return true if @label.include? 'coverblank'\n end", "def filename\n \"#{Time.now.to_i}_cover.jpg\" if original_filename\n end", "def artwork\n IITArtworkCollection.new(@ole.Artwork)\n end", "def cover_url\n #rails_blob_path(image, disposition: 'attachment', only_path: true)\n end", "def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)\n return if !bgm\n bgm=pbResolveAudioFile(bgm,volume,pitch)\n playingBGM=$game_system.playing_bgm\n if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch\n pbBGMFade(seconds)\n if !$PokemonTemp.cueFrames\n $PokemonTemp.cueFrames=(seconds*Graphics.frame_rate)*3/5\n end\n $PokemonTemp.cueBGM=bgm\n elsif playingBGM\n pbBGMPlay(bgm)\n end\nend", "def stop_if_cover\n @slide = self.new_record? ? nil : Slide.where(:id => self.id).first\n return true if @slide.nil?\n return @slide.kind != COVER\n end", "def picture(size = :medium)\n\t\treturn \"https://img.youtube.com/vi/\" + youtube_id + \"/default.jpg\" if youtube?\n\t\treturn art_url if (art_url.to_s != \"\" and art_url.to_s.downcase != \"null\")\n\t\treturn \"http://beta.stoffiplayer.com/assets/media/disc.png\"\n\tend", "def sound; end", "def add_cover()\n @cover = LVGL::LVObject.new(@screen)\n # Make it so we can use the opacity to fade in/out\n @cover.set_opa_scale_enable(true)\n @cover.set_width(@screen.get_width())\n @cover.set_height(@screen.get_height())\n @cover.set_click(false)\n\n @cover.get_style().dup.tap do |style|\n @cover.set_style(style)\n\n # Background for the splash\n style.body_main_color = BG_COLOR\n style.body_grad_color = BG_COLOR\n # Some themes will add a border to LVObject.\n style.body_border_width = 0\n end\n end", "def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)\n return if !bgm\n bgm = pbResolveAudioFile(bgm,volume,pitch)\n playingBGM = $game_system.playing_bgm\n if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch\n pbBGMFade(seconds)\n if !$PokemonTemp.cueFrames\n $PokemonTemp.cueFrames = (seconds*Graphics.frame_rate)*3/5\n end\n $PokemonTemp.cueBGM=bgm\n elsif playingBGM\n pbBGMPlay(bgm)\n end\nend", "def cover?(filepath)\n File.exist?(coverpath(filepath))\n end", "def show\n @album = Album.find(params[:id])\n raise \"not found\" if @album.blank? \n @tracks = @album.tracks.all(:order => :tracknumber)\n @cover = @album.covers.first\n @comments = @album.comments.all(:order => :posted)\n rescue\n redirect_to artists_url, :notice => \"Can't find this album.\"\n end", "def setup_cutin\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n #-------------------------------------------------------------------------\n file = @acts[1] # Filename\n x = @acts[2] # X Position\n y = @acts[3] # Y Position\n opa = @acts[4] || 255 # Opacity (default: 255)\n zx = @acts[5] || 1.0 # Zoom X (default: 1.0)\n zy = @acts[6] || 1.0 # Zoom Y (default: 1.0)\n #-------------------------------------------------------------------------\n get_spriteset.cutin.start(file,x,y,opa,zx,zy)\n end", "def content_opf_template(escaped_title, copyright, author, uuid, cover_id,\n toc_chapters, manifest_chapters, images)\n if cover_id\n cover_meta = %(<meta name=\"cover\" content=\"#{cover_id}\"/>)\n cover_html = %(<item id=\"cover\" href=\"#{cover_filename}\" media-type=\"application/xhtml+xml\"/>)\n cover_ref = '<itemref idref=\"cover\" linear=\"no\" />'\n else\n cover_meta = cover_html = cover_ref = ''\n end\n%(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package unique-identifier=\"BookID\" version=\"3.0\" xmlns=\"http://www.idpf.org/2007/opf\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\"\n xmlns:opf=\"http://www.idpf.org/2007/opf\">\n <dc:title>#{escaped_title}</dc:title>\n <dc:language>en</dc:language>\n <dc:rights>Copyright (c) #{copyright} #{escape(author)}</dc:rights>\n <dc:creator>#{escape(author)}</dc:creator>\n <dc:publisher>Softcover</dc:publisher>\n <dc:identifier id=\"BookID\">urn:uuid:#{uuid}</dc:identifier>\n <meta property=\"dcterms:modified\">#{Time.now.strftime('%Y-%m-%dT%H:%M:%S')}Z</meta>\n #{cover_meta}\n </metadata>\n <manifest>\n <item href=\"#{nav_filename}\" id=\"nav\" media-type=\"application/xhtml+xml\" properties=\"nav\"/>\n <item id=\"ncx\" href=\"toc.ncx\" media-type=\"application/x-dtbncx+xml\"/>\n <item id=\"page-template.xpgt\" href=\"styles/page-template.xpgt\" media-type=\"application/vnd.adobe-page-template+xml\"/>\n <item id=\"pygments.css\" href=\"styles/pygments.css\" media-type=\"text/css\"/>\n <item id=\"softcover.css\" href=\"styles/softcover.css\" media-type=\"text/css\"/>\n <item id=\"epub.css\" href=\"styles/epub.css\" media-type=\"text/css\"/>\n <item id=\"custom.css\" href=\"styles/custom.css\" media-type=\"text/css\"/>\n <item id=\"custom_epub.css\" href=\"styles/custom_epub.css\" media-type=\"text/css\"/>\n #{cover_html}\n #{manifest_chapters.join(\"\\n\")}\n #{images.join(\"\\n\")}\n </manifest>\n <spine toc=\"ncx\">\n #{cover_ref}\n #{toc_chapters.join(\"\\n\")}\n </spine>\n</package>\n)\n end", "def show\n\n image = @animal.cover.attached? ? rails_blob_path(@animal.cover) : ActionController::Base.helpers.asset_url(\"main-picture.jpeg\", type: :image)\n\n set_meta_tags title: @animal.name, reverse: true,\n description: @animal.description.to_plain_text.truncate(300),\n keywords: I18n.t(@animal.species, count: 1),\n og: {\n title: :title,\n description: :description,\n url: animal_url(@animal),\n image: image\n }\n end", "def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end", "def cover\n @magissue = Magissue.find(params[:id])\n end", "def drawVolcanicAsh\n # apply sky tone\n if @sprites[\"sky\"]\n @sprites[\"sky\"].tone.all -= 4 if @sprites[\"sky\"].tone.all > -100\n @sprites[\"sky\"].tone.gray += 16 if @sprites[\"sky\"].tone.gray < 128\n for i in 0..1\n @sprites[\"cloud#{i}\"].tone.all -= 4 if @sprites[\"cloud#{i}\"].tone.all > -100\n @sprites[\"cloud#{i}\"].tone.gray += 16 if @sprites[\"cloud#{i}\"].tone.gray < 128\n end\n end\n for j in 0...72\n next if @sprites[\"w_volc#{j}\"]\n @sprites[\"w_volc#{j}\"] = Sprite.new(@viewport)\n @sprites[\"w_volc#{j}\"].create_rect(5, 5, Color.black)\n @sprites[\"w_volc#{j}\"].default!\n @sprites[\"w_volc#{j}\"].angle = 90\n @sprites[\"w_volc#{j}\"].oy = 2\n @sprites[\"w_volc#{j}\"].opacity = 0\n end\n end", "def coin_image_title(filename)\n if /R/.match?(filename)\n \"Reverse\"\n elsif /O/.match?(filename)\n \"Obverse\"\n else\n filename\n end\n end", "def flac_with_m4a?\n asset.content_type == \"audio/flac\" && asset.file_derivatives.has_key?(:m4a)\n end", "def mozart; end", "def draw_albums(albums)\n i = 0\n x1 = 50\n y1 = 100\n x2 = 250\n y2 = 300\n while i < albums.length\n if i == 1\n x1 += 220\n x2 += 220\n elsif i == 2\n x1 = 50\n x2 = 250\n y1 += 220\n y2 += 220\n elsif i==3\n x1+=220\n x2+=220\n end \n albums[i].artfile.bmp.draw_as_quad(x1, y1, @image_color, x2, y1, @image_color, x1, y2, @image_color, x2, y2, @image_color,ZOrder::UI)\n i+=1\n end\n end", "def audio; end", "def pbFadeOutInWithMusic(zViewport)\n playingBGS=$game_system.getPlayingBGS\n playingBGM=$game_system.getPlayingBGM\n $game_system.bgm_pause(1.0)\n $game_system.bgs_pause(1.0)\n pos=$game_system.bgm_position\n pbFadeOutIn(zViewport) {\n yield\n $game_system.bgm_position=pos\n $game_system.bgm_resume(playingBGM)\n $game_system.bgs_resume(playingBGS)\n }\nend", "def show\n @piece = Piece.published.where.not(audio: '').find(params[:id])\n end", "def no_thumbnail_extensions\n [\".xml\", \".pdf\"]\n end", "def get_audio_clips\n s3 = AWS::S3.new(\n :access_key_id => Rails.application.secrets.AWS_ACCESS_KEY_ID,\n :secret_access_key => Rails.application.secrets.AWS_SECRET_ACCESS_KEY)\n\n record_beacon_id = Beacon.where(:installation_id => @installation.id).where(:content_type => 'record-audio').first.id\n\n prefix = \"#{@customer.id}\" + '/' + \"#{@installation.id}\" + '/' + \"#{record_beacon_id}\"\n\n audio_clips = s3.buckets['lufthouse-memories'].objects.with_prefix(prefix).collect(&:key)\n\n audio_clip_URLs = Array.new\n\n unless audio_clips == []\n audio_clips.each do |f|\n audio_clip_URLs << \"https://s3.amazonaws.com/lufthouse-memories/\" + f\n end\n end\n\n return audio_clip_URLs.shuffle\n \n end", "def fadeMusic _obj, _args\n \"_obj fadeMusic _args;\" \n end", "def convert_img(el, indent)\n\t\tif el.attr['alt'] == 'videoplayer'\n\t\t\treturn \"<video src='#{cdn_url(el.attr['src'])}' controls preload='none' class='video-js vjs-default-skin' data-setup='{}'>\"\n\t\telsif el.attr['src'] && el.attr['src'] !~ /(^[\\w]*:|^\\/)/\n\t\t\tel.attr['src'] = File.join(@options[:asset_prefix], el.attr['src'])\n\t\tend\n\t\tsuper\n\tend", "def cover_of?(lesson)\n is_a?(Image) && self == lesson.cover.media_elements.first\n end" ]
[ "0.6645724", "0.6444185", "0.63880914", "0.6032172", "0.59754974", "0.5892336", "0.5879069", "0.5864103", "0.583155", "0.58269554", "0.5779838", "0.577262", "0.57449937", "0.57160103", "0.5703578", "0.56971633", "0.5687033", "0.56789696", "0.565744", "0.56429774", "0.5639856", "0.561092", "0.5603637", "0.559286", "0.55855834", "0.5584466", "0.556779", "0.554396", "0.5533417", "0.5527054", "0.54811704", "0.5471983", "0.5424527", "0.5393898", "0.53906024", "0.5389854", "0.5377563", "0.5367762", "0.5365512", "0.5332775", "0.53281647", "0.5313292", "0.5312393", "0.52839994", "0.5282954", "0.5280506", "0.52775776", "0.5268137", "0.5265473", "0.5259645", "0.52533466", "0.52494156", "0.52355003", "0.5208306", "0.51828724", "0.51800543", "0.5163358", "0.51596737", "0.514525", "0.5122734", "0.508703", "0.50629324", "0.50514495", "0.5048375", "0.50480473", "0.5038362", "0.50180006", "0.50090015", "0.5005425", "0.49916607", "0.49855208", "0.49819815", "0.49676374", "0.49538156", "0.49473605", "0.4944302", "0.4928324", "0.49254942", "0.49203622", "0.49156666", "0.49048132", "0.49044427", "0.48943025", "0.4892001", "0.48903036", "0.48890784", "0.48824158", "0.48794988", "0.48776156", "0.48720443", "0.48655716", "0.4855365", "0.48552045", "0.48538178", "0.48491922", "0.4848755", "0.48481935", "0.48477593", "0.48463318", "0.48427585" ]
0.6216487
3
Filter a file list for supported audio types with the correct suffix.
def supported(files) files.select { |f| SUPPORTED_TYPES.include?(f.extname.delete('.')) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wp_get_audio_extensions\n # Filters the list of supported audio formats.\n apply_filters('wp_audio_extensions', ['mp3', 'ogg', 'flac', 'm4a', 'wav'])\n end", "def extension_white_list\n %w(mp3 wav)\n end", "def clean_file_list( args )\n\t\tdirtyfiles = args\n\n\t\t# only allow .mp3 files into the clean list.\n\t\tfiles = Array.new\n\t\tdirtyfiles.each { |x|\n\t\t\tif ( x =~ /.*\\.[mM][pP]3$/ )\n\t\t\t\tfiles.push( x )\n\t\t\telse\n\t\t\t\tputs \"\\tWARNING: No .mp3 suffix in \\\"#{x}\\\"! *** skipping! ***\"\n\t\t\tend\n\t\t}\n\n\t\tfiles\n\tend", "def extension_whitelist\n %w[mp3]\n end", "def extension_white_list\n %w(mp3 ogg flac mpc wav aiff mp4 m4a m4b asf)\n end", "def extension_white_list\n %w(aac AAC mp3 MP3 m4a M4A wav WAV ogg OGG)\n end", "def typed_file_filter(class_name)\n case class_name\n when \"ScannedResource\"\n [\".tif\", \".wav\", \".pdf\", \".zip\", \".jpg\"]\n else\n Rails.logger.warn \"Ingesting a folder with an unsupported class: #{class_name}\"\n []\n end\n end", "def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end", "def files_filtering files\n return files unless @file_regexp\n f = files.select do |file|\n test_name_by_date file\n end\n f\n end", "def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end", "def music_file(file)\n ext_list = $config[\"music_file\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name = \"\"\n\n $config['music_file']['regex'].each do |pattern|\n if file =~ /.*#{pattern}#{ext}/i\n name = $1 if $1\n return false if name =~ /^sample/i\n return true\n end\n end\n return false\nend", "def get_all_mediatype_files\n puts \"Searching for files in #{directory_tree}\"\n # Rewrote to use absolute search paths because FakeFS chokes on Dir.chdir\n matching_files = []\n @extensions.each do |ex|\n search_for = File.join(directory_tree, \"**\", '*' + ex) # example: \"/home/xavier/Tech/Docs/**/*.pdf\"\n matching_files.concat(Dir.glob(search_for))\n end\n #puts \"Found these files: \" + matching_files.to_s\n convert_to_pathnames(matching_files).delete_if { |file| file.dirname.to_s == mediatype_dirname.to_s }\n end", "def accepted_mimes\n case self.type\n when'Recording'\n '.wav,.mp3'\n when 'Document'\n '.pdf'\n when 'Image'\n '.jpeg,.jpg,.gif,.bmp,.png'\n else\n ''\n end\n end", "def processing_audio\n list.select {|l| l[:status] == 35 }\n end", "def audio?\n filename =~ /^audio/\n end", "def extension_whitelist\n %w(mp4 ogv avi)\n end", "def no_extension_files(base_dir, wildcard, non_exts = [])\n list = []\n unless non_exts.empty?\n list = Dir.glob(File.join(base_dir, wildcard, \"{#{non_exts.join(',')}}\"))\n end\n list\n end", "def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end", "def audio_file_from_list(idx)\n @audio_file_list[idx]\n end", "def filter_samples(files)\n files.reject { |f| sample?(f) }\n end", "def audio_files\n @audio_files ||= path.join(\"data\").each_child.select { |file| [\".wav\", \".mp3\"].include? file.extname }.map { |file| IngestableAudioFile.new(path: file) }\n end", "def audio_formats\n @descriptive_detail.audio_formats\n end", "def extension_whitelist\n %w(mp4 mp3 jpg jpeg gif png pdf docx)\n end", "def filtered(files); end", "def audio_types\n ldr6 = record.leader[6]\n\n types = []\n\n # Get the 8524* fields\n f8524 = record.fields('852').select{|f| f.indicator1 == '4'}\n\n # RC\n if %w[i j].include?(ldr6) && (bib_format == 'MU') \n @record.fields('007').map{|f| f.value}.each do |f|\n if f[1] == 'd' && f[12] == 'e'\n types << 'RC'\n break\n end\n end\n end\n\n f8524.each do |f|\n if (f['b'].upcase == 'MUSIC') && (f['j'] =~ /\\ACD/i)\n types << 'RC'\n break\n end\n end\n\n # RL\n\n if (bib_format == 'MU') && %w[i j].include?(ldr6) && self['007[1]'].include?('d')\n record.fields('300').each do |f|\n str = f.subfields.collect {|s| s.value}.join(' ')\n if (str =~ /DISC/i) && str =~ /33 1\\/3 RPM/i\n types << 'RL'\n break\n end\n end\n end\n\n\n f8524.each do |f|\n if (f['j'] =~ /\\ALP/i) &&\n ((f['b'].upcase == 'MUSIC') || (f['c'].upcase == 'MUSI'))\n types << 'RL'\n break\n end\n end\n\n # RM\n types << 'RM' if (ldr6 == 'j') && (bib_format == 'MU')\n\n # RS\n types << 'RS' if (ldr6 == 'i') && (bib_format == 'MU')\n\n # RU\n types << 'RU' if %w[i j].include?(ldr6) && (bib_format == 'MU')\n\n types.uniq!\n return types\n end", "def getFiletype filename\n extension = filename.split(\".\")[1]\n case extension\n when \"wav\" then\t\"audio/wav\"\n when \"amr\" then\t\"audio/amr\"\n when \"amr-wb\" then \"audio/amr-wb\"\n when \"x-speex\" then \"audio/x-speex\"\n when \"spx\" then\t\"audio/x-speex\"\n else \n end\n end", "def filter(files)\n ruleset.watchlist.filter(files)\n #case ruleset.ignore\n #when Ignore\n # ruleset.ignore.filter(list)\n #when Array\n # list.reject!{ |path| ignore.any?{ |ig| /^#{ig}/ =~ path } }\n #else\n # list\n #end\n end", "def files\n filename = Dir.glob(\"#{path}/*.mp3\")\n filename = filename.collect{|a_string| a_string.sub(\"#{path}/\", \"\")}\n end", "def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end", "def is_audio?\n result = false\n if !mime_type.blank?\n splits = mime_type.split('/')\n if splits[0] == AUDIO\n result = true\n end\n end\n \n result\nend", "def is_audio(str)\n str.match(/\\A\\w*.(mp3|flac|alac|aac)\\Z/) != nil\nend", "def get_filename_regex\n return AUDIO_FILENAME_REGEX\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\n end", "def audio?\n if mime_type == 'application/mxf'\n !ffprobe.codec_type.any? {|type| type == 'video'}\n else\n super\n end\n end", "def supported_format?\n !(@file_set.mime_type & self.class.supported_formats).empty? || preservation_file&.original_filename&.first&.downcase&.include?(\".wav\")\n end", "def files\n Dir.glob(\"#{path}/*.mp3\").collect do\n |file| file.gsub(\"#{path}/\",\"\")\n end\n end", "def fix_files\n Dir.glob(\"./audio/**/*.mp3\").each do |path|\n file_name = file_name_from_path(path)\n proper_file_name = file_name.gsub(/[^a-zA-Z1-9\\_\\.]/) { |char| \"_\" }\n unless file_name == proper_file_name\n `mv \"#{path}\" #{path.gsub(file_name, proper_file_name)}`\n end\n end\n end", "def files\n Dir.glob(self.path + '**/*.mp3').collect {|file| File.basename(file)}\n end", "def audio(filename, opts = {})\n n = input(filename, opts)\n @audios << n\n n\n end", "def extension_whitelist\n %w(jpg jpeg gif png tif tiff avi m4v mov mp4 mpg mpeg mpeg wmv qt)\n end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end", "def is_audio_type?\n file_content_type =~ /\\Aaudio\\/.*\\Z/\n end", "def contains_audio?\n result = false\n sample_attachments.map{|sa| result = true if sa.is_audio?}\n result\n end", "def search_sound(file)\n Dir.glob(File.join(@default_dir_images, file) + '.{mp3,wma,wav}').first\n end", "def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end", "def audio?\n not audio_formats.empty?\n end", "def glob_mp3_files_from_filespec(filespec)\n files = Dir[filespec]\n files.reject! { |fn| File.directory?(fn) }\n files.reject! { |fn| !(can_parse_id3?(fn)) } \n return files\nend", "def files\n songs = Dir.entries(path) #this is a separate class within itself \n #this is saying delete each song in the array if it starts with a string of a period because they are all strings\n songs.reject {|song| song[0] == \".\"}\n end", "def x__files_list_filtered(a_filelist, a_file_types, verbose=false)\n x__abort_unless_is_an_array(a_filelist, verbose)\n filtered_list_raw = []\n a_filelist.each do |file|\n filetype = x__file_type(file, verbose=true)\n if filetype == \"directory\" and a_file_types.include?(:directories)\n filtered_list_raw << file\n elsif filetype == \"file\" and a_file_types.include?(:regular_files)\n filtered_list_raw << file\n elsif filetype == \"link\" and a_file_types.include?(:symbolic_links)\n filtered_list_raw << file\n end\n end\n filtered_list_raw.sort\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end", "def files # loads all the mp3 files in the path directory / normalizes the filename to just the mp3 filename with no path\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") } # then using the .collect method and gsub to just return the filename with out path\n end", "def files \n @files = Dir.glob(\"#{path}/*.mp3\")\n @files.collect! {|filename| filename.gsub(/#{path}\\//, \"\")}\n @files\n end", "def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end", "def list(*extensions)\n all_files.keep_if do |filename|\n extensions.include?(Pathname.new(filename).extname)\n end\n all_files.reject! { |file| excluded_file?(file) }\n all_files\n end", "def files\n array_full_names = Dir.glob(\"#{@path}/*.mp3\")\n array_full_names.collect do |full_name|\n full_name[21..-1]\n end\n end", "def in_filetypes(filetypes_a)\n @filetypes = filetypes_a.map { |e| \"*.#{e}\" }\n self\n end", "def get_suffixes\n find_all{|entry| entry.type==Morpheme::SUFFIX}\n end", "def filter_extension\n case record.filter_id\n when nil, '', 'WymEditor'\n return \".html\"\n when 'Textile'\n return \".textile\"\n when 'Markdown'\n return \".markdown\"\n end\n end", "def audio_format(infile)\n format = nil\n cmd = [\"ffprobe\", \"-hide_banner\", infile]\n \n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io| \n io.each_line do |line|\n # Stream #0:1: Audio: aac (LC), 22050 Hz, stereo, fltp\n # Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s\n # Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 67 kb/s\n # Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 310 kb/s\n if line =~ /Stream.+Audio.+(aac|mp3)/\n format = $1\n break\n end\n end\n end\n\n case format\n when nil\n \"\"\n when \"aac\" \n \"m4a\"\n else\n format\n end\nend", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def files\n # fetch the appropriate files\n file_paths = Dir.glob(@path + \"/*.mp3\")\n file_paths.map { |file_path| @files << File.basename(file_path) }\n @files\n end", "def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end", "def manageAudioFiles(maxNumFiles, folder)\n\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n keepSeconds = 7200\n\n while fileNumber > maxNumFiles\n keepSeconds *= 0.5\n Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].each do |filename| \n deleteOldFile(filename, keepSeconds)\n end\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n end\n\n end", "def list_anat_files(options = {}) \n subs = all_subjects\n filt_subs = looked_for(options[:subjects])\n filt_sess = looked_for(options[:sessions])\n filt_types = looked_for(options[:t_types] || [ \"T1\", \"T2\" ]) \n scans_list = all_scans(subs, filt_subs, filt_sess, filt_types) \n results = []\n scans_list.each do |scan_dir|\n resources_path = \"#{scan_dir}/Resources\"\n scanlist_type = list_files(\"#{resources_path}\", :directory).map { |e| Pathname.new(e.name).basename.to_s }\n scanlist_type.each do |scan_type|\n scanlist = list_files(\"#{resources_path}/#{scan_type}/Files\", :regular).map { |e| Pathname.new(e.name).basename.to_s }\n if (! options[:ext].blank?) && options[:ext].is_a?(Regexp)\n scanlist = scanlist.select { |scan| scan.match(options[:ext]) }\n end\n scanlist.each { |scan| results << \"#{resources_path}/#{scan_type}/Files/#{scan}\" }\n end \n end\n results\n end", "def audios_test\n end", "def sounds_for_digits(num)\n result = []\n num.to_s.each_char do |c|\n result << sound_path(\"#{c}.ul\")\n end\n result\n end", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end", "def blacklist_mime_type_pattern; end", "def build_filelist(source_file, rule_name)\n basename = source_file.pathmap('%n') # base name without ext\n prefix = \"#{CONF[\"project\"]}-#{rule_name}--#{basename}\"\n src_lines = File.readlines(source_file)\n\n filelist = {\n source: source_file,\n mp3: \"#{DIR[:mp3]}/#{prefix}.mp3\",\n compile: \"#{DIR[:compile]}/#{prefix}.wav\",\n concat: 1.upto(src_lines.size).map { |n| \"#{DIR[:concat]}/#{prefix}--#{'%04d' % n}.wav\" },\n raw: [],\n say_args_by_raw: {},\n movie_concat: \"#{DIR[:movie]}/CONCAT_#{prefix}.txt\",\n movie: \"#{DIR[:movie]}/#{prefix}.mp4\",\n movie_pics: [],\n app_sounds: [],\n }\n\n\n field_voice = CONF['field'].to_a\n src_lines.each_with_index do |line, line_index|\n line.chomp!\n\n raw_by_field = {}\n line.split(/\\t/).each_with_index do |content, index|\n field, voice = field_voice[index]\n next unless voice\n filename_safe_content = get_filename(content)\n # p [filename_safe_content, content]\n\n if (filelist[:movie_pics][line_index].nil?)\n filelist[:movie_pics].push \"#{DIR[:movie_pics]}/#{filename_safe_content}.png\"\n end\n\n app_config = CONF['app'][rule_name]\n if app_config\n app_root = app_config['app_root']\n if app_root\n if (filelist[:app_sounds][line_index].nil?)\n filelist[:app_sounds].push app_config['sounds'].size.times.map { |n|\n File.join(app_root, \"sounds\", \"#{filename_safe_content}-#{n + 1}.wav\")\n }\n end\n end\n end\n\n filter = CONF['filter'][field]\n content = Filter.send(filter, content) if filter\n digest = Digest::SHA256.hexdigest(voice + content)\n raw_file = \"#{DIR[:raw]}/#{digest}.wav\"\n filelist[:say_args_by_raw][raw_file] = [voice, content]\n raw_by_field[field] = raw_file\n end\n filelist[:raw] << raw_by_field\n end\n filelist\nend", "def audios\n unless @audios\n @audios = {:es => [], :eu => [], :en => [], :all => []}\n\n return @audios if self.multimedia_path.blank?\n\n # Lista de todos los audios en <dir>/*.mp3\n list_of_audios = Dir.glob(full_multimedia_path + \"*.mp3\")\n list_of_audios = list_of_audios.collect {|a| Pathname.new(a).relative_path_from(Pathname.new(class_multimedia_path)).to_s}\n\n Document::LANGUAGES.each do |l|\n # Meto en cada idioma solo los que acaban en \"_<idioma>.mp3\"\n @audios[l.to_sym] = list_of_audios.select {|a| a.match(\"_#{l}.mp3\")}\n list_of_audios = list_of_audios - @audios[l.to_sym]\n end\n\n Document::LANGUAGES.each do |l|\n @audios[l.to_sym] = @audios[l.to_sym] + list_of_audios\n end\n @audios[:all] = @audios.values.flatten.uniq\n end\n return @audios\n end", "def filter_matched_files\n matched_files = []\n\n unless file_extensions.empty?\n extensions = file_extensions.reduce do |total, extension|\n total + \"|\" + extension.downcase\n end\n extensions_regex = \"^(.+\" + extensions + \")$\"\n (git.modified_files + git.added_files).each do |file|\n matched_files += [file] unless file.downcase.match(extensions_regex).nil?\n end\n end\n\n unless file_patterns.empty?\n (git.modified_files + git.added_files).each do |line|\n file_patterns.each do |pattern|\n matched_files += [line] unless line.downcase.match(pattern.downcase).nil?\n end\n end\n end\n\n return [matched_files].flatten.compact\n end", "def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end", "def files\n @files = Dir.glob(\"#{@path}/*.mp3\").collect{ |file| file.gsub(\"#{@path}/\", \"\") }\n end", "def my_music_shuffle filenames\n \n return [] if filenames.empty? # get the empty case out of the way\n \n # split each filename into [path, file]\n filenames.map! {|name| Pathname.new(name).split}\n filenames.map! {|name| [name[0].to_s, name[1].to_s]}\n\n # initialise shuffle\n shufflednames = []\n tailend_flag = false\n pick = rand(filenames.length)\n \n # do the shuffling\n while !(filenames == []) do\n \n # stick pick on the end unless tailend flag is raised, in which case insert randomly\n if !tailend_flag then shufflednames << filenames[pick] else\n shufflednames.insert(rand(shufflednames.length), filenames[pick])\n end\n filenames.delete_at(pick)\n \n # set 'masknames' to list everything of a different genre\n masknames = filenames.select {|name| name[0] != shufflednames[-1][0]} \n \n # find a new pick, raising the tailend flag if we only have one genre left\n if !filenames.empty? then\n if !masknames.empty? then\n pickname = masknames.sample # pick a tune from a different genre\n pick = filenames.index(pickname) # find it in 'filenames' and point 'pick' to it\n else\n pick = rand(filenames.length) # pick any tune\n tailend_flag = true\n end\n end\n \n end # ends while loop\n \n #output the filenames merged back into strings\n shufflednames.map! {|name| name[0].to_s + '/' + name[1].to_s} \n \nend", "def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |f| f.gsub(\"#{path}/\", \"\") }\n end", "def filter_handle_sdf_files\n @sdflist.each do |sdf|\n sdf.tags.each do |item|\n filter_handle_tag item\n end\n end\n end", "def filter_all_but_videos(files)\n files.select { |f| video?(f) }\n end", "def is_mp3?\n if filename != nil\n filename.ends_with?('.mp3')\n else\n false\n end\nend", "def search_audio_file(file_name)\n # Trace.debug(\"Search audio for track #{@rtrack.to_s.brown}\")\n extensions = Cfg.size_over_quality ? FILE_EXTS_BY_SIZE : FILE_EXTS_BY_QUALITY\n\n extensions.each do |ext|\n if File.exists?(file_name+ext)\n set_audio_state(Status::OK, file_name+ext)\n return audio.status\n end\n end\n\n # Remove the root dir & genre dir to get the appropriate sub dir\n file = track_dir(file_name)\n Dir[Cfg.music_dir+'*'].each do |entry|\n next unless File.directory?(entry)\n extensions.each do |ext|\n if File.exists?(entry+file+ext)\n set_audio_state(Status::MISPLACED, entry+file+ext)\n return audio.status\n end\n end\n end\n\n set_audio_state(Status::NOT_FOUND, nil)\n return audio.status\n end", "def filetype(path)\n path = File.extname(path)\n if Audio::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'audio'\n elsif Video::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'video'\n elsif Image::EXTENSION_WHITE_LIST.include?(path[1, path.length])\n return 'image'\n else\n return nil\n end\n end", "def testNormalTrackWithAliasList\n execute_Mix_WithConf({\n :Recordings => {\n :Tracks => {\n [1] => {\n :Env => :Env1,\n :Alias => [ 'Track 1', 'Track 2' ]\n }\n }\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Track 2' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n :PrepareFiles => getPreparedFiles(:Recorded_Env1_1, :Cleaned_Env1_1)\n ) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Env1.1.04.NoiseGate.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => '02_Clean/Record/Env1.1.04.NoiseGate.wav',\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam1'\n }\n }\n ], 'Process_Test.rb'\n assert Dir.glob('05_Mix/Env1.1.Calibrated.0.Test.????????????????????????????????.wav').empty?\n assert_wave_lnk '02_Clean/Record/Env1.1.04.NoiseGate', '05_Mix/Final/Final.wav'\n end\n end", "def glob\n case @raw_image_files.first.filename\n when /^E.*dcm$/\n return 'E*.dcm'\n when /\\.dcm$/\n return '*.dcm'\n when /^I\\./\n return 'I.*'\n when /^I/\n return 'I*.dcm'\n when /.*\\.\\d{3,4}/\n return '*.[0-9]*'\n when /\\.0/\n return '*.0*'\n else\n return nil\n end\n # Note - To exclude just yaml files we could also just use the bash glob\n # '!(*.yaml), but we would have to list all exclusions. This may turn\n # out easier in the long run.\n end", "def audio?\n !!( content_type =~ Transit.config.audio_regexp )\n end", "def upload_filtered_file\n if ALLOWED_FILE_TYPES.include? File.extname(file_params[:file])\n upload_file\n else\n render json: \"Only #{ALLOWED_FILE_TYPES.join(', ')} extension file is allowed to upload\", status: 422\n end\n end", "def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend", "def file_extensions\n [@file_extensions].flatten.compact.uniq\n end", "def filter(lexers)\n mapping = {}\n lexers.each do |lexer|\n mapping[lexer.name] = lexer.filenames || []\n end\n\n GlobMapping.new(mapping, @filename).filter(lexers)\n end", "def target_files(changed_files)\n changed_files.select do |file|\n file.end_with?(\".kt\")\n end\n end", "def media(filename, opts = {})\n n = input(filename, opts)\n @videos << n\n @audios << n\n n\n end", "def apply_to_dir(path_to_directory)\n files = Dir.open(path_to_directory) \n \n files.each do |file|\n next if file[0] == '.'\n convert_to_mp3(construct_file_path(file), files)\n end\n\n # remove the files from directory\n # files.each do |file|\n # if file.include?(\".wav\")\n # FileUtils.rm(construct_file_path(file))\n # end\n # end\n true\nend", "def selected_mime_types\n return [] if mime_types.blank?\n\n mime_types.split(',')\n end", "def list_scan_files(options = {})\n subs = all_subjects\n filt_subs = looked_for(options[:subjects])\n filt_sess = looked_for(options[:sessions])\n filt_types = looked_for(options[:scan_type] || \"fMRI\") \n scans_list = all_scans(subs, filt_subs, filt_sess, filt_types) \n results = []\n scans_list.each do |scan_dir|\n resources_path = \"#{scan_dir}/Resources\"\n scanlist_type = list_files(\"#{resources_path}\", :directory).map { |e| Pathname.new(e.name).basename.to_s }\n scanlist_type.each do |scan_type|\n scanlist = list_files(\"#{resources_path}/#{scan_type}/Files\", :regular).map { |e| Pathname.new(e.name).basename.to_s }\n if (! options[:ext].blank?) && options[:ext].is_a?(Regexp)\n scanlist = scanlist.select { |scan| scan.match(options[:ext]) }\n end\n scanlist.each { |scan| results << \"#{resources_path}/#{scan_type}/Files/#{scan}\" }\n end \n end\n results\n end", "def ext_to_mp3(filename)\n\t\tfilename_without_ext = filename.gsub(/[.]\\w+$/, \"\")\n\t\tfilename_without_ext + \".mp3\"\n\tend", "def audio\n @streams.select { |stream| stream.is_a? AudioStream }\n end", "def format_extension\n extensions.reverse.detect { |ext|\n @environment.mime_types(ext) && !@environment.engines(ext)\n }\n end", "def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end", "def filename_token(options = {})\n \"noaudio\" if options[:audio].eql?(false)\n end", "def get_files\n Dir.foreach(@path) do |file|\n if File.extname(file) == \".mp3\"\n thisfile = SongFile.new(\"#{@path}/#{File.path(file)}\")\n @files << thisfile\n end\n end\n end", "def fq_bundle_sample_prompt\n \"public/upload/audio/\" + bundle_resouce_file_name + \".mp3\"\n end" ]
[ "0.6979946", "0.6608501", "0.6504056", "0.64547306", "0.64311016", "0.61127734", "0.6011407", "0.58593744", "0.5845251", "0.5821931", "0.5806645", "0.5802867", "0.5784186", "0.57713264", "0.5765068", "0.5722019", "0.5631711", "0.5627494", "0.56150115", "0.55762094", "0.5568841", "0.55652505", "0.55595505", "0.55449337", "0.5530738", "0.5530291", "0.55186373", "0.55111134", "0.5500565", "0.5479003", "0.5454441", "0.54542583", "0.54397005", "0.542236", "0.54086643", "0.5408222", "0.5395565", "0.5384248", "0.538333", "0.5371077", "0.53618604", "0.53551626", "0.5327238", "0.5324902", "0.53077143", "0.53030777", "0.5302764", "0.5300101", "0.5278535", "0.5268115", "0.523854", "0.5221035", "0.5220314", "0.52193505", "0.5214601", "0.5183255", "0.51832026", "0.517236", "0.514979", "0.51391435", "0.51391435", "0.51316285", "0.5130841", "0.51266253", "0.51232964", "0.5122841", "0.51142895", "0.5110743", "0.5096924", "0.50965506", "0.5079221", "0.50707823", "0.50538653", "0.5037625", "0.5018656", "0.4998617", "0.49978042", "0.49958235", "0.4992467", "0.49874452", "0.49816394", "0.49727726", "0.49646175", "0.49610943", "0.49572876", "0.4954086", "0.4953583", "0.49495322", "0.49437764", "0.49420416", "0.49337214", "0.49330834", "0.4929631", "0.49274743", "0.49217993", "0.49146247", "0.49097374", "0.490326", "0.4896241", "0.4888593" ]
0.58723116
7
Get the relevant tags for all files.
def all_tags(files) supported(files).map { |f| Aur::FileInfo.new(f).our_tags } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_all_files\n self.files.order('tag')\n end", "def tags_used\n s = Set.new\n @selected_files.each do |file|\n s.merge file.tags\n end\n s.to_a.map { |v| v.downcase }\n end", "def tags\n return @tags_cache if (@tags_cache ||= nil)\n \n global_tags, tag_types = {}, {}\n \n f = nil\n # For each current .hgtags file in our history (including multi-heads), read in\n # the tags\n hg_tags_nodes.each do |rev, node, file_node|\n # get the file\n f = (f && f.file(file_node.file_node)) || self.versioned_file(\".hgtags\", :file_id => file_node.file_node)\n # read the tags, as global, because they're versioned.\n read_tags(f.data.split(\"\\n\"), f, \"global\", global_tags, tag_types)\n end\n \n # Now do locally stored tags, that aren't committed/versioned\n begin\n # get the local file, stored in .hg/\n data = @hg_opener.read(\"localtags\")\n # Read the tags as local, because they are not versioned\n read_tags(data.split_newlines, \"local_tags\", \"local\", global_tags, tag_types)\n rescue Errno::ENOENT\n # do nothing. most people don't have this file.\n end\n # Save our tags for use later. Use ivars.\n @tags_cache, @tags_type_cache = {}, {}\n \n # Go through the global tags to store them in the cache\n global_tags.each do |k, nh|\n # update the cache\n @tags_cache[k] = nh.first unless nh.first == NULL_ID\n @tags_type_cache[k] = tag_types[k]\n end\n \n # tip = special tag\n @tags_cache[\"tip\"] = self.changelog.tip\n \n # return our tags\n @tags_cache\n end", "def tags\n tags = nil\n\n # Jekyll v3 has it in data, while v2 have it at the root\n if @file.data.key?('tags')\n tags = @file.data['tags']\n elsif @file.respond_to? :tags\n tags = @file.tags\n end\n\n return tags if tags.nil?\n\n # Anyway, we force cast it to string as some plugins will extend the tags to\n # full featured objects\n tags.map(&:to_s)\n end", "def tags\n self.lib.tags.map { |r| tag(r) }\n end", "def tag_manifested_files\n tagmanifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n path\n end\n }\n (acc + files).uniq\n end\n end", "def list\n ::MachineTag::Set.new(read_tag_file(@tag_file))\n end", "def all_tags\n each_with_object([]) do |entry, tags|\n tags.concat(entry.tags).sort!.uniq!\n end\n end", "def get_tags\n\t\t\ttaglist = read_command_output( 'hg', 'tags' )\n\t\t\treturn taglist.split( /\\n/ ).collect {|tag| tag[/^\\S+/] }\n\t\tend", "def get_all_tags\n taglist = %x[vorbiscomment -l #{@file.shellescape}].split(\"\\n\")\n tags = {}\n taglist.each do |line|\n key,value = line.split(\"=\")\n tags[key] = value\n end\n return tags\n end", "def tags\n get.tagGuids\n end", "def ruby_svn_tags\n raw_ruby_svn_tags.map { |t| expand_variants(t) }.flatten.uniq.sort\n end", "def return_all_tags\n @tags.uniq.each { |tag| puts tag }\n end", "def tags\n @tags ||= get(\"/repos/show/#{owner.login}/#{name}/tags\")['tags']\n end", "def get_tags\n @logger.info(\"#{__method__}: Getting tags from git\")\n output = `cd #{@conf.clone_path} && git tag`\n tags = output.split(\"\\n\")\n tags.each do |t|\n @logger.debug(\"#{__method__}: #{t}\")\n end\n tags\n end", "def path_to_tags( path )\n return [] if @@no_implicit_tags\n return [] if path.nil? \n if @@split_implicit_tags\n tags_array = path.split(\"/\").find_all { |e| e.size > 0 }\n tags_array.pop # Last item is the entry title\n else\n tags_array = [ File.dirname( path )]\n end\n tags_array.map { |e| e == '.' ? @@root_tag : e }.compact\n end", "def all_tags\n applied_tags + @tags\n end", "def all_tags\n applied_tags + @tags\n end", "def tags\n entries = Entry.all\n # Create a list of all the tags, as a String\n tags_list = String.new\n entries.each do |entry|\n tags_list << entry.tags + \" \"\n end\n # Convert the String to a global array, removing the duplicate elements\n $tags_array = tags_list.split.uniq\n end", "def tags(package)\n importer = package.importer\n all_tags = importer.run_git_bare(package, \"tag\")\n all_tags.find_all do |tag_name|\n end\n end", "def tags\n @tags ||= []\n end", "def available_tags\n available_tags = []\n Tag.all.each do |t|\n available_tags << t.name\n end\n\n tags = []\n self.tags.each do |t|\n tags << t.name\n end\n\n available_tags - tags\n end", "def retrieve_tags\n # noop\n end", "def taglist\n\tself.tags.map {|t| t.name}\n end", "def all\n response= handle_errors{ self.class.get('/get')}\n response[\"tags\"][\"tag\"].collect do |tag| \n t= Rubycious::Tag.new(tag)\n end\n end", "def files\n templates.map(&:filename)\n end", "def related_tags_in(folder = :posts)\n (related_posts_in(folder) << current_post).map{ |post| post.tags }.flatten.uniq.sort\n end", "def taglib_filenames(options)\n plugin = options[:plugin]\n gem = options[:gem]\n app_root = Rails.root if Object.const_defined?(:Rails)\n app_root ||= Pathname.new(File.expand_path('.'))\n search_path = []\n search_path << Dryml.root.join('taglibs') if plugin == 'dryml'\n search_path << Hobo.root.join('lib/hobo/rapid/taglibs') if plugin == 'hobo' || gem == 'hobo'\n search_path << app_root.join('vendor/plugins', plugin, 'taglibs') if !plugin.blank?\n search_path << gem.tr('-','_').camelize.constantize.root.join('taglibs') if !gem.blank?\n search_path << app_root.join('app/views') if options[:src] =~ /\\//\n search_path << Pathname.new(options[:absolute_template_path]) if options[:absolute_template_path]\n search_path << Pathname.new(options[:template_dir]) if options[:template_dir] =~ /^\\//\n search_path << app_root.join(options[:template_dir].gsub(/^\\//, ''))\n src = options[:src] || gem || plugin\n results = nil\n search_path.any? {|path| !(results = Dir[path.join \"#{src}.dryml\"]).empty?}\n raise DrymlException, \"No such taglib: #{src} #{options.inspect}\" if results.empty?\n results - [File.expand_path(options[:source_template])]\n\n end", "def tags\n libraries.collect(&:tag_id)\n end", "def hg_tags_nodes\n return_list = {}\n self.heads.reverse.each do |node|\n changeset = self[node]\n rev = changeset.revision\n file_node = changeset.get_file(\".hgtags\") rescue next\n return_list[file_node] = [rev, node, file_node]\n end\n return return_list.values\n end", "def all\n @tags.keys\n end", "def all\n @tags.keys\n end", "def tags\n tagset = Dogcatcher::TagSet.new\n tagset << \"notifier:#{notifier}\"\n tagset << \"action:#{action}\"\n tagset << \"exception_class:#{exception.class}\"\n tagset << \"program:#{@config.program}\" if @config.program\n tagset << \"ruby_version:#{RUBY_VERSION}\"\n tagset.merge(gem_tags) if @config.gem_tags\n tagset.merge(@config.custom_tags)\n tagset.compile.to_a\n end", "def getTags\r\n\t\t\t\t\treturn @tags\r\n\t\t\t\tend", "def allTags\n tags = []\n MU::MommaCat.listStandardTags.each_pair { |name, value|\n tags << {key: name, value: value}\n }\n\n if @config['optional_tags']\n MU::MommaCat.listOptionalTags.each_pair { |name, value|\n tags << {key: name, value: value}\n }\n end\n\n if @config['tags']\n @config['tags'].each { |tag|\n tags << {key: tag['key'], value: tag['value']}\n }\n end\n\n return tags\n end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags\n @tags ||= []\n end", "def get_unique_tag_values(tag)\n values = []\n @files.each { |mp3| \n values << mp3.tags.tag if mp3.tags.tag.length\n }\n values.sort!\n end", "def tags\n ['any'] + @tags\n end", "def tags\n ['any'] + @tags\n end", "def get_tags() tag_ids.inject([]) { |l, tag_id| l << get_tag_from_id(tag_id) } end", "def files\n @files ||= FILE_RANGE.map(&:to_sym)\n end", "def list_of_tags\n tag_list\n end", "def all_tags\n\t\ttags.map(&:name).join(\", \")\n\tend", "def all\n @hash_tags\n end", "def raw_ruby_svn_tags\n @parent.list_ruby_svn_tags\n end", "def tags\n return @tags\n end", "def tags\n return @tags\n end", "def tags\n return @tags\n end", "def installable\n (expanded_known + ruby_svn_tags).uniq.sort\n end", "def tag_names #helper method\n # gets tag names in an array\n self.tags.map { |tag| tag.name }\n end", "def all\n Tag.all.map{|t| \"#{t.tag} \"}\n end", "def tags\n request_libraries.collect(&:tag_id)\n end", "def tags\n @tags ||= tag_class.in_challenge(collection).group(:id)\n end", "def tags() ; info[:tags] ; end", "def tags() ; info[:tags] ; end", "def local_tags\n @local.tags\n end", "def _tags\n tags = []\n categories.find_each do |category|\n tags << category.self_and_ancestors.pluck(:name)\n end\n tags.flatten.uniq\n end", "def included_tag_names\n parsed_included_tags[:missing]\n end", "def photo_tags\n all_tags = Hash.new {|h,k| h[k]=[]}\n self.tags.find_each do |t|\n all_tags[t.field] << t.value\n end\n all_tags\n end", "def get_all_tags\n print \"Fetching tags...\\r\" if @options[:verbose]\n\n check_github_response { github_fetch_tags }\n end", "def all_tags\n self.tags.map(&:name).join(\", \")\n end", "def all_tags\n self.tags.map(&:name).join(\", \")\n end", "def all_tags\n self.tags.map(&:name).join(\", \")\n end", "def requested_tags\n @requested_tags ||= []\n end", "def all_files\n Dir.glob(\"#{template_path}/**/*\", File::FNM_DOTMATCH).reject{|path| File.directory?(path) }.sort\n end", "def all_tags context = :tags\n ActsAsTaggableOn::Tagging.where(context: context).select(:tag_id).distinct.includes(:tag).map(&:tag)\n end", "def tag_names\n @tag_names ||= tags.map(&:name).join(' ')\n end", "def all_tags(source=nil)\n @tag_svc.get_all(source)\n end", "def get_extension_tags\n get_siteinfo('extensiontags')['query']['extensiontags']\n end", "def tag_names\n self.tags.map{ |t| t.name }.join(\", \")\n end", "def common_tags_to_add\n common_tags = []\n common_tags << self.merger\n common_tags << self if self.canonical\n common_tags << self.parents\n common_tags.flatten.uniq.compact\n end", "def write_tags\n open 'TAGS', 'w' do |io|\n io.write <<-INFO\n!_TAG_FILE_FORMAT\\t2\\t/extended format/\n!_TAG_FILE_SORTED\\t1\\t/sorted/\n!_TAG_PROGRAM_AUTHOR\\tEric Hodel\\t/drbrain@segment7.net/\n!_TAG_PROGRAM_NAME\\trdoc-tags\\t//\n!_TAG_PROGRAM_URL\\thttps://github.com/rdoc/rdoc-tags\\t//\n!_TAG_PROGRAM_VERSION\\t#{VERSION}\\t//\n INFO\n\n @tags.sort.each do |name, definitions|\n definitions.uniq.each do |(file, address, *field)|\n io.write \"#{name}\\t#{file}\\t#{address};\\\"\\t#{field.join \"\\t\"}\\n\"\n end\n end\n end\n end", "def tags\n _get(\"/query/image/tags\") { |json| json }\n end", "def files\n file_sets.map{|fs| fs.files }.flatten\n end", "def tags()\n\t\t\treturn @metadata.attributes[:tags].to_a\n\t\tend", "def files\n return @files\n end", "def tags\n object.tags.each do |tag|\n tag.name\n end\n end", "def referenced_files\r\n\t\t(\r\n\t\t\t[file] +\r\n\t\t\t%w[sourcepath importfile].flat_map do |att|\r\n\t\t\t\tfind(att=>/./).flat_map do |asset|\r\n\t\t\t\t\tasset[att].values.compact.map do |path|\r\n\t\t\t\t\t\tpath.sub!(/#.+/,'')\r\n\t\t\t\t\t\tabsolute_path(path) unless path.empty?\r\n\t\t\t\t\tend.compact\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind.flat_map do |asset|\r\n\t\t\t\tasset.properties.select{ |name,prop| prop.type=='Texture' }.flat_map do |name,prop|\r\n\t\t\t\t\tasset[name].values.compact.uniq.map{ |path| absolute_path(path) }\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind(_type:'Text').flat_map do |asset|\r\n\t\t\t\tasset['font'].values.compact.map{ |font| absolute_path(font) }\r\n\t\t\tend +\r\n\t\t\t@doc.xpath('/UIP/Project/Classes/*/@sourcepath').map{ |att| absolute_path att.value }\r\n\t\t).uniq\r\n\tend", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def tags\n data[:tags]\n end", "def get_all_tags()\n tag_hashes = USER_TAGS.order(:tag_name).all\n\n tags = []\n tag_hashes.each do |tag|\n tags.push(UserTag.new(tag))\n end\n\n return tags\n end", "def tags() []; end", "def all_tags\n all_tags = []\n meanings.each do |meaning_hash|\n if meaning_hash.tags.size > 0\n all_tags << meaning_hash.tags\n end\n end\n return all_tags.flatten\n end", "def get_file_tag_path\n levels=@file_tags.map{|e| e[:level]}.uniq\n\n dirpath = []\n levels.sort.each do |level|\n # select names from all that are not files\n level_path = @file_tags.select{|e| ((e[:level]==level) && (e[:type]!=:file))}.map{|tag| tag[:name]}\n dirpath << level_path.join('_') if !level_path.empty?\n end\n \n filepath = []\n levels.sort.each do |level|\n # select names from all that are not files\n level_path = @file_tags.select{|e| ((e[:level]==level) && (e[:type]!=:dir))}.map{|tag| tag[:name]}\n filepath << level_path.join('_') if !level_path.empty?\n end\n \n \n filename=filepath.join('_')\n dirname=File.join(dirpath)\n \n \n # puts \"#{dirname}, #{filename}\"\n \n return [dirname,filename,@file_tag_tuple_priority]\n \n end", "def files\n @files.values\n end", "def tags\n if new?\n @fake_tags || []\n else\n @tags ||= tags_dataset.all\n end\n end", "def tags(name = nil)\n list = @tags + convert_ref_tags\n return list unless name\n list.select {|tag| tag.tag_name.to_s == name.to_s }\n end", "def show_tags\n tag_list = \"\"\n self.tags.each do |t|\n tag_list << \"#{t.name} \"\n end\n tag_list\n end", "def tags\n @obj['tags']\n end", "def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end", "def download_tags\n\n end", "def tags\r\n return @tags if @tags\r\n\r\n if @options.has_key? :only\r\n @tags = convert_methods(@options[:only])\r\n elsif @options.has_key? :except\r\n @tags = @@tag_titles.keys - convert_methods(@options[:except])\r\n else\r\n @tags = @@tag_titles.keys\r\n end\r\n\r\n @tags\r\n end" ]
[ "0.7601869", "0.7493188", "0.7079424", "0.70394146", "0.69350046", "0.68186414", "0.6686296", "0.66116554", "0.6602238", "0.6523977", "0.6439757", "0.64328825", "0.6408906", "0.6374971", "0.6370682", "0.63505965", "0.63251954", "0.63251954", "0.6319831", "0.62956005", "0.62942606", "0.62583005", "0.62252825", "0.6223276", "0.61893696", "0.6178543", "0.6161165", "0.6159453", "0.6153694", "0.61317295", "0.6105032", "0.6105032", "0.6100343", "0.6092621", "0.60917324", "0.60838354", "0.60838354", "0.60838354", "0.60838354", "0.60838354", "0.60777503", "0.6077734", "0.6074693", "0.6074693", "0.60548437", "0.6034459", "0.60336816", "0.60266364", "0.6025563", "0.60245484", "0.6022055", "0.6022055", "0.6022055", "0.60208386", "0.6001345", "0.5983227", "0.5982269", "0.59818846", "0.5974139", "0.5974139", "0.5970393", "0.59684896", "0.5968105", "0.5962333", "0.5958815", "0.5957904", "0.5957904", "0.5957904", "0.5955309", "0.5945667", "0.59414285", "0.5914786", "0.59145737", "0.5913281", "0.5902182", "0.590215", "0.5899499", "0.589652", "0.58895504", "0.58879805", "0.5883283", "0.5871006", "0.58597803", "0.5852972", "0.5852972", "0.5852972", "0.5852972", "0.5852972", "0.58523506", "0.5849198", "0.5845784", "0.58399963", "0.58389807", "0.58375", "0.58336455", "0.5830028", "0.5828928", "0.5827865", "0.58275604", "0.581644" ]
0.7838998
0
Get all tasks in all rake files that should be run, then remove any duplicates. This is the main method to run.
def files_with_tasks_to_run # load all tasks into self.all_tasks get_tasks_from_rakefiles set_and_log_tasks_already_ran(self.all_tasks) set_and_log_duplicate_tasks(self.all_tasks_not_previously_run) close_log_if_this_created_it(log) rakefiles_with_tasks_to_run rescue => error log.error("Error during #{self.class.name} #{__method__}! #{error}") unless log.nil? raise error end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def clear_db_test_tasks\n FileUtils::mkdir_p 'lib/tasks'\n File.open(\"lib/tasks/heroku_clear_tasks.rake\", \"w\") do |file|\n file.puts \"# rubocop:disable all\"\n content = db_test_tasks_to_clear.map do |task_name|\n <<-FILE\nif Rake::Task.task_defined?('#{task_name}')\n Rake::Task['#{task_name}'].clear\n task '#{task_name}' do\n end\nend\nFILE\n end.join(\"\\n\")\n file.print content\n file.puts \"# rubocop:enable all\"\n end\n end", "def cleanall(rakeTask)\n\t\tif @cleanallRecurse\n\t\t\t@cleanallRecurse = false\n\t\t\ttask rakeTask.name => prereqs().map {|entity| Builder::cleanAllTaskName(entity)}\n\t\t\trakeTask.reenable()\n\t\t\trakeTask.invoke() #run again, starting with our updated prereqs list\n\t\telse #we've called ourselves after updating prereqs and running them; now do our work\n\t\t\tclean()\n\t\tend\n\tend", "def cleanall(rakeTask)\n\t\tif @cleanallRecurse\n\t\t\t@cleanallRecurse = false\n\t\t\tlinkDepsOrdered().select {|entity| BuildEnv::isBuilt?(entity)}.each do |entity|\n\t\t\t\ttask rakeTask.name => Builder::cleanAllTaskName(entity)\n\t\t\tend\n\t\t\trakeTask.reenable()\n\t\t\trakeTask.invoke() #run again, starting with our updated prereqs list\n\t\telse #we've called ourselves after updating prereqs and running them; now do our work\n\t\t\tclean()\n\t\tend\n\tend", "def rakefiles\n @rakefiles ||= []\n end", "def define_clean_tasks\n task :clobber_docs # no-op, just in case\n task :clobber_package # no-op, just in case\n\n desc \"Clean up all the extras.\"\n task :clean => [ :clobber_docs, :clobber_package ] do\n clean_globs.each do |pattern|\n files = Dir[pattern]\n rm_rf files, :verbose => true unless files.empty?\n end\n end\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end", "def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end", "def clean\n # Each the tasks\n @tasks.each do |task|\n # Clean all of them\n task.clean\n end\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def find_tasks_without_specs\n task_file_names.reject do |manifest|\n spec = Noop::Utils.convert_to_spec manifest\n spec_file_names.include? spec\n end\n end", "def remove_all_tasks\n ids = []\n Task.all.each { |task| ids << task.id }\n delete_tasks_from_todoist(ids)\n Task.destroy\n end", "def starting_tasks\n each_task.reject do |task|\n task.dependency_backward_any?\n end\n end", "def collect_tasks\n @top_level_tasks = []\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n else\n @top_level_tasks << arg unless arg =~ /^-/\n end\n end\n @top_level_tasks.push(\"default\") if @top_level_tasks.size == 0\n end", "def generateRakeFor_CleanRecordings\n if (!@Context[:RakeSetupFor_GenerateSourceFiles])\n generateRakeFor_GenerateSourceFiles\n end\n\n # List of cleaning tasks\n # list< Symbol >\n lLstCleanTasks = []\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n # Look for recorded files\n lTracksConf.each do |iLstTracks, iRecordingConf|\n lEnv = iRecordingConf[:Env]\n lRecordedFileName = getRecordedFileName(lEnv, iLstTracks)\n lRecordedBaseName = File.basename(lRecordedFileName[0..-5])\n # Clean the recorded file itself\n lLstCleanTasks << generateRakeForCleaningRecordedFile(lRecordedBaseName, lEnv)\n end\n # Look for calibration files\n @Context[:EnvsToCalibrate].each do |iEnvToCalibratePair, iNil|\n iEnv1, iEnv2 = iEnvToCalibratePair\n # Read the cutting values if any from the conf\n lCutInfo = nil\n if (lRecordingsConf[:EnvCalibration] != nil)\n lRecordingsConf[:EnvCalibration].each do |iEnvPair, iCalibrationInfo|\n if (iEnvPair.sort == iEnvToCalibratePair)\n # Found it\n lCutInfo = iCalibrationInfo[:CompareCuts]\n break\n end\n end\n end\n # Clean the calibration files\n lReferenceFileName = getRecordedCalibrationFileName(iEnv1, iEnv2)\n lLstCleanTasks << generateRakeForCleaningRecordedFile(File.basename(lReferenceFileName)[0..-5], iEnv2, lCutInfo)\n lRecordingFileName = getRecordedCalibrationFileName(iEnv2, iEnv1)\n lLstCleanTasks << generateRakeForCleaningRecordedFile(File.basename(lRecordingFileName)[0..-5], iEnv1, lCutInfo)\n end\n end\n end\n\n desc 'Clean all recorded files: remove silences, cut them, remove DC offset and apply noise gate'\n task :CleanRecordings => lLstCleanTasks.sort.uniq\n\n @Context[:RakeSetupFor_CleanRecordings] = true\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def tasks() []; end", "def run_all\n run_on_additions(Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq))\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def define_clean_tasks\n require 'rake/clean'\n end", "def run_rails_rake_tasks(*names)\n ARGV.clear\n ARGV.concat(names)\n ARGV << \"RAILS_ENV=test\"\n Dir.chdir(RAILS_ROOT) do\n old = Rake.application\n Rake.application = Rake::Application.new\n begin\n Rake.application.run\n ensure\n Rake.application = old\n end\n end\nend", "def ending_tasks\n each_task.reject do |task|\n task.dependency_forward_any?\n end\n end", "def run!(*tasks_to_run)\n tasks_to_run.flatten!\n\n tasks_to_run.map! do |ttr| \n unless ret = self.__tasks.find {|t| t.__name == ttr } \n seq = self.__sequences.find {|t| t.__name == ttr }\n ret = seq.__task_names.map {|tn| self.__tasks.find {|t| t.__name == tn }}.compact if seq\n end\n ret\n end\n tasks_to_run.flatten!\n tasks_to_run.compact!\n\n ret = []\n tasks_to_run.each do |task|\n ret << task.__build_commands(self.__tasks)\n Runner.execute!(:task => task, :tasks => self.__tasks, :servers => self.__servers, :silent => self.__options[:silent], :verbose => self.__options[:verbose])\n end\n\n $stdout << \"\\033[0m\"\n ret.flatten # return this for tests\n end", "def list_available_build_tasks\n cd 'cookbooks/example'\n unset_bundler_env_vars\n run_simple 'bundle exec rake -T'\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def handle_rake_test_task\n test_task = @target\n all_tests = test_task.file_list\n\n @target = test_task.name\n @globs << test_task.file_list\n @options[:force] = true\n\n lambda do |changed|\n tests = all_tests & changed\n\n basenames = (changed - tests).collect do |f|\n File.basename(f).split(\".\").first\n end\n\n tests.concat all_tests.\n select { |t| basenames.any? { |b| t =~ /#{b}/ } }\n\n tests = all_tests.dup if tests.empty?\n\n # Nice API, Rake::TestTask.\n ENV[\"TEST\"] = \"{#{tests.uniq.join(',')}}\"\n end\n end", "def all_tasks\n @all_tasks ||= []\n end", "def write_empty_tasks\n ARGV.shift\n ARGV.each {|a| task a.to_sym do ; end}\nend", "def load_all_tasks_in_order\n load_dir = ENV[\"load_dir\"]\n tasks_and_files= [{\"ansi_code\"=>\"ansicode.csv\"},\n {\"client_profile_group\"=>\"clients.csv\"},\n {\"facilities\"=>\"facilities.csv\"},\n {\"rcc_payer\"=>\"rcc_payer.csv\"},\n {\"temp_reason_codes\"=>\"rcc_reason_codes.csv\"},\n {\"temp_reason_code_mappings\"=>\"rcc_mappings.csv\"},\n {\"temp_lockbox\"=>\"client_profile_lockbox.csv\"},\n {\"temp_payers\"=>\"ABAInfo.csv\"},\n {\"process_relationships_from_temp_tables\"=>\"\"},\n {\"change_partner_to_bac\"=>\"\"},\n {\"remove_temp_tables\" =>\"\"}]\n errors = []\n \n errors << \"Please provide a valid directory\" if (load_dir.blank? || !FileTest.exists?(load_dir))\n if errors.empty?\n tasks_and_files.each do |hash|\n csv_file = hash[hash.keys[0]]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n errors << \"File #{csv_file} not found in #{load_dir}\" if ! FileTest.exists?(abs_path)\n end\n end\n end\n\n if errors.empty?\n tasks_and_files.each do |hash|\n task = hash.keys[0]\n csv_file = hash[task]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n ENV[\"path\"] = abs_path\n puts \"processing file \" + ENV[\"path\"]\n end\n puts \"invoking task dataimport:#{task} ......\"\n Rake::Task[\"dataimport:#{task}\"].invoke \n end\n else\n errors.each do |err|\n puts err + \"\\n\"\n end\n end \nend", "def rake_tasks(&block); end", "def rake_tasks(&block); end", "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def orphan_tasks\n each_task.reject do |task|\n task.dependency_backward_any? or task.dependency_forward_any?\n end\n end", "def tasks_for_all_configurations\n @configurations.keys.collect{ |name| \"#{@project_name}:#{name}\"}\n end", "def rake(*tasks)\n \"rake #{tasks.join(' ')}\"\n end", "def rakefile_test_tasks\n ''\n end", "def tidy_up\n Dir[\"*nin\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nhr\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nsq\"].each do |file|\n File.delete(file)\n end\n Dir[\"*blast\"].each do |file|\n File.delete(file)\n end\n end", "def load_tasks\n RakeLoader.new.load_tasks\n end", "def run_all\n run_on_changes(Watcher.match_files(self, Dir.glob('**{,/*/**}/*').uniq.compact))\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def load_plugin_tasks\n bad = []\n\n $plugin_max = self.class.plugins.map { |s| s.to_s.size }.max\n\n self.class.plugins.each do |plugin|\n warn \"define: #{plugin}\" if $DEBUG\n\n old_tasks = Rake::Task.tasks.dup\n\n begin\n send \"define_#{plugin}_tasks\"\n rescue NoMethodError\n warn \"warning: couldn't activate the #{plugin} plugin, skipping\"\n\n bad << plugin\n next\n end\n\n (Rake::Task.tasks - old_tasks).each do |task|\n task.plugin = plugin\n end\n end\n @@plugins -= bad\n end", "def make_tasks\n make_clean_task\n make_wix_folder_task\n make_copy_file_tasks\n make_sourcery_wxs_file_task\n make_sourcery_wixobj_file_task\n make_product_wxs_file_task\n make_product_wixobj_file_task\n make_msi_file_task\n make_msi_task\n make_test_task\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n TapirLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def run_all\n build_all_assets \"Rebuilding all assets\", true\n end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n EarLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def find_specs_without_tasks\n spec_file_names.reject do |spec|\n manifest = Noop::Utils.convert_to_manifest spec\n task_file_names.include? manifest\n end\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n @rakefiles += rakefiles\n end", "def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them into the Thor::Sandbox namespace\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n if task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile helper: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # Now load the thor files\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n unless task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # load user tasks\n if user_tasks_folder\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\\.rb$/) }\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\\.rb$/) }\n end\n\n @loaded = true\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def convert_to_rake()\n object_multitask = prepare_tasks_for_objects()\n\n res = typed_file_task get_rake_task_type(), get_task_name => object_multitask do\n cmd = calc_command_line\n Dir.chdir(@project_dir) do\n mapfileStr = @mapfile ? \" >#{@mapfile}\" : \"\"\n rd, wr = IO.pipe\n cmdLinePrint = cmd\n printCmd(cmdLinePrint, \"Linking #{executable_name}\", false) #OK\n cmd << {\n :out=> @mapfile ? \"#{@mapfile}\" : wr, # > xy.map\n :err=>wr\n }\n sp = spawn(*cmd)\n cmd.pop\n # for console print\n cmd << \" >#{@mapfile}\" if @mapfile\n consoleOutput = ProcessHelper.readOutput(sp, rd, wr)\n\n process_result(cmdLinePrint, consoleOutput, @tcs[:LINKER][:ERROR_PARSER], nil)\n check_config_file()\n post_link_hook(@tcs[:LINKER])\n end\n end\n res.tags = tags\n res.immediate_output = true\n res.enhance(@config_files)\n res.enhance([@project_dir + \"/\" + @linker_script]) if @linker_script\n\n add_output_dir_dependency(get_task_name, res, true)\n add_grouping_tasks(get_task_name)\n setup_rake_dependencies(res, object_multitask)\n\n # check that all source libs are checked even if they are not a real rake dependency (can happen if \"build this project only\")\n begin\n libChecker = task get_task_name+\"LibChecker\" do\n if File.exists?(get_task_name) # otherwise the task will be executed anyway\n all_dependencies.each do |bb|\n if bb and StaticLibrary === bb\n f = bb.get_task_name # = abs path of library\n if not File.exists?(f) or File.mtime(f) > File.mtime(get_task_name)\n def res.needed?\n true\n end\n break\n end\n end\n end\n end\n end\n rescue\n def res.needed?\n true\n end\n end\n libChecker.transparent_timestamp = true\n res.enhance([libChecker])\n\n return res\n end", "def rake_functionals(opts=nil)\n if ENV['RUBYOPT']\n # remove bundler/setup require that prematurely checks for gems and crashes\n ENV['RUBYOPT'] = ENV['RUBYOPT'].gsub(%r{-r\\s*bundler/setup}, '')\n end\n # runs all the tests for each ruby version in each rails dir\n system(\"bash test/test.sh #{opts}\")\nend", "def connect_common_tasks\n desc \"Build the code narrative HTML\"\n ::Rake::Task.define_task(:codnar => \"codnar_weave\")\n desc \"Remove woven HTML documentation\"\n ::Rake::Task.define_task(\"clobber_codnar\") { rm_rf(@output) }\n ::Rake::Task.define_task(:clobber => \"clobber_codnar\")\n end", "def get_tasks\n\n\ttasks = Task.all.shuffle\n\n\treturned_tasks = []\n\trand(10..18).times do\n\t\treturned_tasks << tasks.pop\n\tend\n\n\treturned_tasks\nend", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def remove_duplicate_imports\n files.each(&:remove_duplicate_imports)\n end", "def run_all\n targets = Watcher.match_files(self, Dir.glob(\"**/*.*\"))\n run_on_changes targets\n end", "def define_racc_tasks\n racc_files = self.spec.files.find_all { |f| f =~ /\\.y$/ }\n rex_files = self.spec.files.find_all { |f| f =~ /\\.rex$/ }\n\n parser_files = racc_files.map { |f| f.sub(/\\.y$/, \".rb\") }\n lexer_files = rex_files.map { |f| f.sub(/\\.rex$/, \".rb\") }\n\n self.clean_globs += parser_files\n self.clean_globs += lexer_files\n\n rule \".rb\" => \".y\" do |t|\n begin\n sh \"racc #{racc_flags} -o #{t.name} #{t.source}\"\n rescue\n abort \"need racc, sudo gem install racc\"\n end\n end\n\n rule \".rb\" => \".rex\" do |t|\n begin\n sh \"rex #{rex_flags} -o #{t.name} #{t.source}\"\n rescue\n abort \"need rexical, sudo gem install rexical\"\n end\n end\n\n task :isolate # stub task\n\n desc \"build the parser\" unless parser_files.empty?\n task :parser => :isolate\n\n desc \"build the lexer\" unless lexer_files.empty?\n task :lexer => :isolate\n\n task :parser => parser_files\n task :lexer => lexer_files\n\n racc_tasks.each do |t|\n task t => [:parser, :lexer]\n end\n end", "def tasks\n\t\t@tasks ||= if self.id.nil?\n\t\t\t[]\n\t\telse\n\t\t\tt_arr = document.tasks.select(container_id: self.id)\n\t\t\ti = 0\n\t\t\twhile i < t_arr.size\n\t\t\t\ttask = t_arr[i]\n\t\t\t\tif task.has_subtasks?\n\t\t\t\t\tt_arr += t_arr.delete_at(i).tasks\n\t\t\t\telse\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tt_arr\n\t\tend\n\tend", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def load_tasks\n end", "def clean(*includes)\n Rake.application.IncludeCleanTargets(includes)\n end", "def load_dummy_tasks(app_root)\n @target_extension_path = Pathname.new(app_root.to_s)\n load 'refinery/tasks/testing.rake'\n end", "def require_tasks system_config\n system_config.gaudi_modules.each do |gm|\n mass_require(Rake::FileList[\"#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb\"])\n end\n end", "def shutdown_tasks\n self.tasks.select { |t| t.interval == :shutdown }\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= []\n @rakefiles += rakefiles\n end", "def run!\n target_files.shuffle.each do |target_file|\n FileRunnerBasic.new(target_file).run!\n end\n end", "def run_exit_tasks!; end", "def run_all\n run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))\n end", "def scan\n reset\n\n @container = @rake_tasks\n\n @stats.add_module @container\n\n catch :eof do\n catch :enddoc do\n parse_rakefile\n end\n end\n\n @top_level\n end", "def define_test_tasks\n default_tasks = []\n\n if File.directory? \"test\" then\n desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'\n task :test do\n ruby make_test_cmd\n end\n\n desc 'Run the test suite using multiruby.'\n task :multi do\n ruby make_test_cmd(:multi)\n end\n\n desc 'Show which test files fail when run alone.'\n task :test_deps do\n tests = Dir[\"test/**/test_*.rb\"] + Dir[\"test/**/*_test.rb\"]\n\n paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)\n null_dev = Hoe::WINDOZE ? '> NUL 2>&1' : '&> /dev/null'\n\n tests.each do |test|\n if not system \"ruby -I#{paths} #{test} #{null_dev}\" then\n puts \"Dependency Issues: #{test}\"\n end\n end\n end\n\n default_tasks << :test\n end\n\n if File.directory? \"spec\" then\n begin\n require 'spec/rake/spectask'\n\n desc \"Run all specifications\"\n Spec::Rake::SpecTask.new(:spec) do |t|\n t.libs = self.rspec_dirs\n t.spec_opts = self.rspec_options\n end\n rescue LoadError\n # do nothing\n end\n default_tasks << :spec\n end\n\n desc 'Run the default task(s).'\n task :default => default_tasks\n\n desc 'Run ZenTest against the package.'\n task :audit do\n libs = %w(lib test ext).join(File::PATH_SEPARATOR)\n sh \"zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}\"\n end\n end", "def flatten_task_tree\n tasks = [self]\n start_index = 0\n loop do\n end_index = tasks.length\n while start_index < end_index\n tasks.concat(tasks[start_index].next_tasks) unless tasks[start_index].next_tasks.nil?\n start_index += 1\n end\n break if end_index == tasks.length\n\n start_index = end_index\n end\n tasks\n end", "def complete_tasks\n # Give me all the tasks such that the task is complete\n # results = @tasks.select { |task| task.complete? }\n # results.sort_by { |task| task.completed_at }\n #\n # We can combine this into a single line\n \n @tasks.select { |task| task.complete? }.sort_by { |task| task.completed_at }\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def purgefiles\n\n pattern = @commandline.arguments\n purgeall = @commandline.option(\"all\")\n recurse = @commandline.option(\"recurse\")\n\n $dontaskprefixes.push(Dir.glob(\"mpx-*\"))\n\n if purgeall then\n $dontaskprefixes.push(Dir.glob(\"*.tex.prep\"))\n $dontaskprefixes.push(Dir.glob(\"*.xml.prep\"))\n end\n\n $dontaskprefixes.flatten!\n $dontaskprefixes.sort!\n\n if purgeall then\n $forsuresuffixes.push($texnonesuffixes)\n $texnonesuffixes = []\n $forsuresuffixes.flatten!\n end\n\n if ! pattern || pattern.empty? then\n globbed = if recurse then \"**/*.*\" else \"*.*\" end\n files = Dir.glob(globbed)\n report(\"purging#{if purgeall then ' all' end} temporary files : #{globbed}\")\n else\n report(\"purging#{if purgeall then ' all' end} temporary files : #{pattern.join(' ')}\")\n pattern.each do |pat|\n nosuf = File.unsuffixed(pat)\n globbed = if recurse then \"**/#{nosuf}-*.*\" else \"#{nosuf}-*.*\" end\n report(\"checking files that match '#{globbed}'\")\n files = Dir.glob(globbed)\n globbed = if recurse then \"**/#{nosuf}.*\" else \"#{nosuf}.*\" end\n report(\"checking files that match '#{globbed}'\")\n files.push(Dir.glob(globbed))\n end\n end\n files.flatten!\n files.sort!\n\n $dontaskprefixes.each do |file|\n removecontextfile(file)\n end\n $dontasksuffixes.each do |suffix|\n files.each do |file|\n removecontextfile(file) if file =~ /#{suffix}$/i\n end\n end\n $forsuresuffixes.each do |suffix|\n files.each do |file|\n removecontextfile(file) if file =~ /\\.#{suffix}$/i\n end\n end\n files.each do |file|\n if file =~ /(.*?)\\.\\d+$/o then\n basename = $1\n if file =~ /mp(graph|run)/o || FileTest.file?(\"#{basename}.mp\") then\n removecontextfile($file)\n end\n end\n end\n $dummyfiles.each do |file|\n (File.delete(file) if (FileTest.size?(file) rescue 10) < 10) rescue false\n end\n $texnonesuffixes.each do |suffix|\n files.each do |file|\n if file =~ /(.*)\\.#{suffix}$/i then\n if FileTest.file?(\"#{$1}.tex\") || FileTest.file?(\"#{$1}.xml\") || FileTest.file?(\"#{$1}.fo\") then\n keepcontextfile(file)\n else\n strippedname = $1.gsub(/\\-[a-z]$/io, '')\n if FileTest.file?(\"#{strippedname}.tex\") || FileTest.file?(\"#{strippedname}.xml\") then\n keepcontextfile(\"#{file} (potential result file)\")\n else\n removecontextfile(file)\n end\n end\n end\n end\n end\n\n files = Dir.glob(\"*.*\")\n $dontasksuffixes.each do |suffix|\n files.each do |file|\n removecontextfile(file) if file =~ /^#{suffix}$/i\n end\n end\n\n if $removedfiles || $keptfiles || $persistentfiles then\n report(\"removed files : #{$removedfiles}\")\n report(\"kept files : #{$keptfiles}\")\n report(\"persistent files : #{$persistentfiles}\")\n report(\"reclaimed bytes : #{$reclaimedbytes}\")\n end\n\n end", "def list_tasks\n config = instantiate_configuration\n config.load 'deploy'\n \n set_up_config(config)\n \n config.task_list(:all)\n end", "def teardown\r\n rake_original_teardown\r\n Rake.application = @original_rake\r\n end", "def filter_by_tags(tasks)\n return tasks if !filtering_by_tags?\n\n res = []\n tasks.each do |task|\n selected_tags.each do |tag|\n res << task if task.has_tag?(tag)\n end\n end\n \n return res.uniq\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def run_build_tasks(*tasks)\n tasks.flatten.each { |t| run_build_task t }\n end", "def run_without_aborting(*tasks)\n errors = []\n\n tasks.each do |task|\n begin\n Rake::Task[task].invoke\n rescue Exception\n errors << task\n end\n end\n\n abort \"Errors running #{errors.join(', ')}\" if errors.any?\nend", "def tasks_list\n (self.tasks || EMPTY_STRING).scan(/\\d+/).map{|x| x.to_i}.sort.uniq\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def rake\n Dir.chdir @temp_dir\n system(\"rake\")\n end" ]
[ "0.73731107", "0.73609394", "0.7315574", "0.7211704", "0.7152086", "0.6963042", "0.6900817", "0.6659179", "0.66154623", "0.6550801", "0.6520932", "0.64826125", "0.64649296", "0.6430665", "0.6423117", "0.641462", "0.63911355", "0.6386233", "0.637804", "0.6366714", "0.63220096", "0.62492263", "0.62221676", "0.61808735", "0.61323583", "0.60867244", "0.60251886", "0.60251886", "0.6005085", "0.59937936", "0.5978783", "0.5976479", "0.5975473", "0.5971196", "0.59695387", "0.59695387", "0.5941909", "0.5922247", "0.5909744", "0.58878976", "0.58747137", "0.58747137", "0.58538574", "0.58441657", "0.5824415", "0.5818818", "0.58182263", "0.57971454", "0.5790583", "0.57631797", "0.57567054", "0.57437634", "0.57211745", "0.57205987", "0.57102084", "0.57007754", "0.5692167", "0.5653501", "0.56197673", "0.5617161", "0.560173", "0.55913967", "0.55847824", "0.55825967", "0.55750656", "0.55748475", "0.5574749", "0.5570317", "0.5565158", "0.55503875", "0.5546941", "0.5542447", "0.5542308", "0.55373144", "0.5530514", "0.55269337", "0.55027795", "0.5491418", "0.5477981", "0.5463722", "0.54502475", "0.5445977", "0.54447097", "0.5440573", "0.54400814", "0.54288155", "0.54215026", "0.54111403", "0.5410151", "0.5397201", "0.5397183", "0.53970164", "0.5394969", "0.53934", "0.5389905", "0.53896374", "0.53871244", "0.53861374", "0.5378971", "0.5378274" ]
0.7013574
5
Get all tasks from the tasks_directory. Return a list of EvaluatedTasks
def get_tasks_from_rakefiles # ensure we're starting out with no tasks or rakefiles clear_all_tasks_and_rakefiles rakefiles_to_read = onetime_rake_files return [] if rakefiles_to_read.empty? rakefiles_to_read.each(&method(:get_tasks_in_rakefile)) self.all_tasks end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all\n return @tasks\n end", "def all_tasks\n @all_tasks ||= []\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n TapirLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n EarLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end", "def tasks\n task_list.tasks\n end", "def work_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_worker, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end", "def fetch_tasks\n tasks = BgTask.all\n tasks = load_tasks if tasks.nil? || tasks.empty?\n tasks\n end", "def tasks\n return @tasks.values\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def all_tasks\n self.stories.collect { |s| s.tasks }.flatten\n end", "def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end", "def list_tasks\n config = instantiate_configuration\n config.load 'deploy'\n \n set_up_config(config)\n \n config.task_list(:all)\n end", "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def tasklists\n get gtasks_tasklists_url\n end", "def tasks\n @tasks ||= Evoke.tasks\n end", "def tasks\n @tasks ||= Task.find(self.task_ids)\n end", "def tasks(tasklist_id = '@default')\n get gtasks_tasks_url(tasklist_id)\n end", "def tasks\n @tasks.values.sort_by { |t| t.name }\n end", "def tasks\n\t\t@tasks ||= if self.id.nil?\n\t\t\t[]\n\t\telse\n\t\t\tt_arr = document.tasks.select(container_id: self.id)\n\t\t\ti = 0\n\t\t\twhile i < t_arr.size\n\t\t\t\ttask = t_arr[i]\n\t\t\t\tif task.has_subtasks?\n\t\t\t\t\tt_arr += t_arr.delete_at(i).tasks\n\t\t\t\telse\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tt_arr\n\t\tend\n\tend", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def get_tasks_for_organisation(_organisation)\n Task.all\n end", "def tasks\n @client.list_tasks(cluster: @cluster, service_name: @name)[0]\n end", "def tasks_list\n (self.tasks || EMPTY_STRING).scan(/\\d+/).map{|x| x.to_i}.sort.uniq\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def tasks\n @tasks ||= {}\n end", "def get_tasks(opts = {})\n data, status_code, headers = get_tasks_with_http_info(opts)\n return data\n end", "def get_tasks(opts = {})\n data, status_code, headers = get_tasks_with_http_info(opts)\n return data\n end", "def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend", "def tasks\n @tasks ||= Harvest::API::Tasks.new(credentials)\n end", "def tasks\n config[:tasks]\n end", "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def list_all_tasks\n task = Task.all\nend", "def determine_visible_tasks\n [root_task] + determine_visible_subtasks(root_task)\n end", "def get_all_subtasks(opts={})\n self.class.get_all_subtasks([id_handle()],opts)\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def task_list\n self.tasks.map do |task|\n task.text\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def failed_tasks\n return @failed_tasks\n end", "def failed_tasks\n return @failed_tasks\n end", "def tasks(wspace=workspace)\n\t\twspace.tasks\n\tend", "def tasks\n @tasks ||= @dom.css(\"BusinessObject[@Name=Task]\").map do |element|\n Task.new(element.to_xml)\n end\n end", "def get_tasklists\n @tasklists = []\n array = @client.execute(@api.tasklists.list).data.to_hash[\"items\"]\n array.each { |h|\n @tasklists.push Tasklist[h]\n }\n end", "def list_tasks\n load_tasks\n\n # set '$thor_runner' to true to display full namespace\n $thor_runner = true\n\n list = [] #Thor.printable_tasks(all = true, subcommand = true)\n Thor::Base.subclasses.each do |klass|\n list += klass.printable_tasks(false) unless klass == Thor\n end\n list.sort!{ |a,b| a[0] <=> b[0] }\n\n title = \"repo_manager tasks\"\n shell.say shell.set_color(title, :blue, bold=true)\n shell.say \"-\" * title.size\n shell.print_table(list, :ident => 2, :truncate => true)\n end", "def all_subtasks task\n [task] + task.tasks.get.flatten.map{|t| all_subtasks(t) }\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def getSubtasks\r\n\t\t\t\t\treturn @tasks\r\n\t\t\t\tend", "def flatten_task_tree\n tasks = [self]\n start_index = 0\n loop do\n end_index = tasks.length\n while start_index < end_index\n tasks.concat(tasks[start_index].next_tasks) unless tasks[start_index].next_tasks.nil?\n start_index += 1\n end\n break if end_index == tasks.length\n\n start_index = end_index\n end\n tasks\n end", "def tasks_all(parameters={ })\n parameters[:conditions]=conditions(parameters[:conditions])\n parameters[:include]= to_include + (parameters[:include]||[])\n return user.company.tasks.all(parameters)\n end", "def load_tasks\n RakeLoader.new.load_tasks\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def getTasklist\r\n\t\t\t\t\treturn @tasklist\r\n\t\t\t\tend", "def tasks\n @config.map do |task_name, options|\n task_params = options.symbolize_keys\n task_params[:queue_ahead] ||= @queue_ahead\n task_params[:name] = task_name\n task_params[:tz] ||= @time_zone\n Task.new(task_params)\n end\n end", "def load_tasks\n end", "def get_task_list(id)\n response = request(\n :expects => 200,\n :idempotent => true,\n :method => 'GET',\n :parser => Fog::ToHashDocument.new,\n :path => \"tasksList/#{id}\"\n )\n ensure_list! response.body, :Task\n response\n end", "def get_tasks_targets\n @test_pack.get_active_tests\n end", "def get_tasks\n\n\ttasks = Task.all.shuffle\n\n\treturned_tasks = []\n\trand(10..18).times do\n\t\treturned_tasks << tasks.pop\n\tend\n\n\treturned_tasks\nend", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def get_tasks(param_map, *args)\n #Strip off the first element, since it is not a Task\n get(\"tasks\", param_map, Babar::Task, true, *args)\n end", "def getAssignedTasks\n\tassignedTasks = CrawlerTask.where(:carrier => $worker_name, :status => 0)\nend", "def list_tasks\n tasks = @repository.all\n @view.display_tasks(tasks)\n end", "def list_bare_tasks\n load_tasks\n\n Thor::Base.subclasses.each do |klass|\n unless klass == Thor\n klass.tasks.each do |t|\n puts \"#{klass.namespace}:#{t[0]}\"\n end\n end\n end\n end", "def tasks(options={})\n ret = Task.where(options.merge(:aspect_id => self.id)).order(\"importance DESC\").all\n if self.has_children?\n self.children.order(\"weight DESC\").each do |aspect|\n ret << aspect.tasks(options)\n end\n end\n return ret.flatten\n end", "def task_lists(current_token)\n session = RedboothRuby::Session.new(token: current_token)\n client = RedboothRuby::Client.new(session)\n\n client.task_list(:index, project_id: self.id).all\n end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def active_tasks\n @tasks.select { | task | task.active }\n end", "def find_all(client, assignee: nil, workspace: nil, project: nil, section: nil, tag: nil, user_task_list: nil, completed_since: nil, modified_since: nil, per_page: 20, options: {})\n params = { assignee: assignee, workspace: workspace, project: project, section: section, tag: tag, user_task_list: user_task_list, completed_since: completed_since, modified_since: modified_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }\n Collection.new(parse(client.get(\"/tasks\", params: params, options: options)), type: self, client: client)\n end", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def all\n Array(@@job_scheduler_instance)\n end", "def tasks=(value)\n @tasks = value\n end", "def tasks=(value)\n @tasks = value\n end", "def tasks=(value)\n @tasks = value\n end", "def tasks_get(opts = {})\n data, _status_code, _headers = tasks_get_with_http_info(opts)\n data\n end", "def tasks_for(list)\n\t\t@tasks[list] ||= fetch_latest_tasks_for(list)\n\tend", "def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend", "def collect_tasks\n @top_level_tasks = []\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n else\n @top_level_tasks << arg unless arg =~ /^-/\n end\n end\n @top_level_tasks.push(\"default\") if @top_level_tasks.size == 0\n end", "def scrape_tasks(url)\n tasks = []\n doc = Nokogiri::HTML(open(url))\n doc.css(\"li.task_event\").each do |node|\n task = scrape_task(node)\n\n tasks << task unless task.empty? or task.nil?\n end\n\n return tasks\nend", "def execute_task_tests\n # Run all tasks tests (ensuring we capture any changes in the sites we are monitoring)\n test_results = @tasks_by_job_ids.values.map {|task|\n puts \"- Running test for task: #{task.class.name}\" \n if task.respond_to?(:test)\n begin\n result = task.test()\n if result.kind_of?(Array) && result.length > 0\n # Log the error for the result\n @task_test_results_logger.error(\"FAILURE:#{result.inspect}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, result)\n end\n rescue Exception => e\n # Log the error for the result\n @task_test_results_logger.error(\"ERROR:#{e.backtrace}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, [e.backtrace.inspect])\n end\n end\n }\n # return the test results\n return test_results\n end", "def task_definitions\n return @task_definitions\n end", "def retrieve_tasks\n Query.get_data(@values[:id], @values[:start_time], @values[:end_time])\n end" ]
[ "0.71893984", "0.71407235", "0.7087454", "0.6891361", "0.6854618", "0.68474025", "0.6811657", "0.67816734", "0.67816734", "0.67582744", "0.6741554", "0.66742885", "0.66622806", "0.6654164", "0.6642603", "0.66316116", "0.66316116", "0.66316116", "0.66090155", "0.6600045", "0.6549449", "0.6517585", "0.6510496", "0.6489356", "0.64643043", "0.64616513", "0.64390796", "0.64152616", "0.6370421", "0.63225234", "0.62627435", "0.616511", "0.6163204", "0.6157581", "0.61165816", "0.6107541", "0.6062149", "0.60577476", "0.60570234", "0.6042648", "0.6040132", "0.6019671", "0.60107374", "0.60107374", "0.59825766", "0.59749424", "0.59523606", "0.595209", "0.5869738", "0.58619934", "0.5830967", "0.58218735", "0.5819041", "0.5814263", "0.5751614", "0.5751527", "0.57393885", "0.57393885", "0.5725481", "0.5723065", "0.5720112", "0.57167715", "0.5713641", "0.5702336", "0.56978816", "0.5696737", "0.56913257", "0.5686752", "0.5681803", "0.56762725", "0.5666337", "0.56381106", "0.5634247", "0.56280774", "0.56222665", "0.56180584", "0.56180584", "0.5616818", "0.55843425", "0.5581953", "0.55794585", "0.5578619", "0.5577897", "0.5572878", "0.5566", "0.55584157", "0.5549427", "0.55442345", "0.55440485", "0.5525313", "0.5525313", "0.5525313", "0.55217147", "0.5517118", "0.5515424", "0.54951745", "0.5494598", "0.5487581", "0.5486521", "0.5479347" ]
0.6636172
15
Return a Hash of only the rakefiles that have tasks to be run. key = rakefile name, value = EvaluatedRakeFile Add the tasks to run for each EvaluatedRakeFile
def rakefiles_with_tasks_to_run rakefiles_with_tasks = new_hash_of_eval_rakefiles # This isn't efficient, but it's clear: all_tasks_to_run.each do |task_to_run| rakefilename = task_to_run.filename ev_rakefile_to_run = self.all_rakefiles[rakefilename] ev_rakefile_to_run.tasks_to_run << task_to_run rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run end rakefiles_with_tasks end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def rakefiles\n @rakefiles ||= []\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def add_rakefile_and_tasks(rakefilename, task_names)\n\n # creates a new EvaluatedRakeFile entry if needed\n ev_rakefile = self.all_rakefiles[rakefilename]\n ev_rakefile.add_task_names(task_names)\n self.all_tasks.concat(ev_rakefile.all_tasks)\n\n ev_rakefile\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def tasks_for_all_configurations\n @configurations.keys.collect{ |name| \"#{@project_name}:#{name}\"}\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def tasks\n @tasks ||= {}\n end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def find_tasks_without_specs\n task_file_names.reject do |manifest|\n spec = Noop::Utils.convert_to_spec manifest\n spec_file_names.include? spec\n end\n end", "def evaluate_pre_tasks\n if using_rake? and Pkg::Config.pre_tasks\n unless Pkg::Config.pre_tasks.is_a?(Hash)\n fail \"The 'pre_tasks' key must be a Hash of depender => dependency pairs\"\n end\n Pkg::Config.pre_tasks.each do |depender, dependency|\n add_dependency(depender, dependency)\n end\n end\n end", "def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def tasks\n config[:tasks]\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def collect_tasks\n @top_level_tasks = []\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n else\n @top_level_tasks << arg unless arg =~ /^-/\n end\n end\n @top_level_tasks.push(\"default\") if @top_level_tasks.size == 0\n end", "def done\n done_ids = @tasks.keys.find_all do |id|\n @tasks[id].done?\n end\n done_tasks = done_ids.inject({}) do |map, id|\n map[id] = @tasks[id]\n map\n end\n done_ids.each do |id|\n @tasks.delete(id)\n end\n return done_tasks\n end", "def spec_run_metadata\n return @spec_run_metadata if @spec_run_metadata\n @spec_run_metadata = {}\n Noop::Config.dir_path_task_spec.find do |spec_file|\n next unless spec_file.file?\n next unless spec_file.to_s.end_with? '_spec.rb'\n spec_name = spec_file.relative_path_from(Noop::Config.dir_path_task_spec)\n spec_data = parse_spec_file spec_file\n @spec_run_metadata[spec_name] = spec_data if spec_data.any?\n end\n @spec_run_metadata\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n TapirLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n EarLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def set_and_log_duplicate_tasks(evaluated_tasks)\n\n return [] if evaluated_tasks.empty?\n\n # get all of the task_names that are duplicates (TODO ruby 2.7: replace this with .tally)\n duplicated_names = evaluated_tasks.group_by(&:name).select { |_name, tasks | tasks.size > 1 }.keys\n\n # Guard condition: no duplicate names, so just return\n return [] if duplicated_names.empty?\n\n # get the duplicated tasks for each name; return all of them\n duplicated_names.map{|dup_name| duplicated_tasks_for_name(dup_name, evaluated_tasks) }.flatten\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def tasks_file(name)\n File.expand_path(File.join(@path, %w[ application tasks ], name))\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def rakefile_test_tasks\n ''\n end", "def tasks_by_section_for_my_tasks(project,\n only_uncompleted: true,\n extra_fields: [])\n raw_tasks = projects.tasks_from_project(project,\n only_uncompleted: only_uncompleted,\n extra_fields: extra_fields + ['assignee_section.name'])\n active_tasks = projects.active_tasks(raw_tasks)\n by_my_tasks_section(active_tasks, project.gid)\n end", "def task_definitions\n return @task_definitions\n end", "def tasks\n @tasks.values.sort_by { |t| t.name }\n end", "def resolve_task_includes(dict, task)\n task[:included_tasks].map! {|name, args|\n debug 4, \"Finding task '#{name}' included in task '#{task[:fqn]}'\"\n incl_task, incl_task_name, role = find_task(dict, task[:parent], name)\n if incl_task.nil?\n debug 1, \"WARNING: Couldn't find task '#{name}' \"\\\n \"(included by task '#{task[:fqn]}')\"\n incl_task = thing(role, :task, incl_task_name, \"unknown\",\n unresolved: true, args: [],\n included_by_tasks: [], scope: [], var: [],\n included_varfiles: [], included_tasks: [],\n used_templates: [],\n data: { registers: [] })\n incl_task\n end\n\n incl_task[:args] += args\n incl_task[:included_by_tasks].push task\n incl_task\n }\n end", "def tasks\n @config.map do |task_name, options|\n task_params = options.symbolize_keys\n task_params[:queue_ahead] ||= @queue_ahead\n task_params[:name] = task_name\n task_params[:tz] ||= @time_zone\n Task.new(task_params)\n end\n end", "def task_triggers\n return @task_triggers\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n return @tasks.values\n end", "def set_and_log_tasks_already_ran(evaluated_tasks)\n return [] if evaluated_tasks.empty?\n\n already_ran = []\n\n evaluated_tasks.each do |evaluated_task|\n successful_attempt = find_successful_attempt_for_task(evaluated_task)\n already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt\n end\n\n already_ran\n end", "def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them into the Thor::Sandbox namespace\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n if task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile helper: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # Now load the thor files\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n unless task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # load user tasks\n if user_tasks_folder\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\\.rb$/) }\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\\.rb$/) }\n end\n\n @loaded = true\n end", "def active_tasks(tasks)\n tasks.select { |task| task.completed_at.nil? }\n end", "def load_all_tasks_in_order\n load_dir = ENV[\"load_dir\"]\n tasks_and_files= [{\"ansi_code\"=>\"ansicode.csv\"},\n {\"client_profile_group\"=>\"clients.csv\"},\n {\"facilities\"=>\"facilities.csv\"},\n {\"rcc_payer\"=>\"rcc_payer.csv\"},\n {\"temp_reason_codes\"=>\"rcc_reason_codes.csv\"},\n {\"temp_reason_code_mappings\"=>\"rcc_mappings.csv\"},\n {\"temp_lockbox\"=>\"client_profile_lockbox.csv\"},\n {\"temp_payers\"=>\"ABAInfo.csv\"},\n {\"process_relationships_from_temp_tables\"=>\"\"},\n {\"change_partner_to_bac\"=>\"\"},\n {\"remove_temp_tables\" =>\"\"}]\n errors = []\n \n errors << \"Please provide a valid directory\" if (load_dir.blank? || !FileTest.exists?(load_dir))\n if errors.empty?\n tasks_and_files.each do |hash|\n csv_file = hash[hash.keys[0]]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n errors << \"File #{csv_file} not found in #{load_dir}\" if ! FileTest.exists?(abs_path)\n end\n end\n end\n\n if errors.empty?\n tasks_and_files.each do |hash|\n task = hash.keys[0]\n csv_file = hash[task]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n ENV[\"path\"] = abs_path\n puts \"processing file \" + ENV[\"path\"]\n end\n puts \"invoking task dataimport:#{task} ......\"\n Rake::Task[\"dataimport:#{task}\"].invoke \n end\n else\n errors.each do |err|\n puts err + \"\\n\"\n end\n end \nend", "def all_tasks\n @all_tasks ||= []\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def rake_tasks(&block); end", "def rake_tasks(&block); end", "def GetUserStoriesAndTasksFromFile(taskFile)\n\n\tFile.open(taskFile, \"r\") do |infile|\n\n\t defect_tasks = Hash.new(Array.new)\n\t us_tasks = Hash.new(Array.new)\n\t work_product = \"\"\n\n\t while (line = infile.gets)\n\t\t\n\t\tline = line.strip\n\n\t\tif (!work_product.match('\\AUS').nil? && line.match('(\\AUS|\\ADE)').nil?) then us_tasks[work_product] += [line] end\n\t\tif (!work_product.match('\\ADE').nil? && line.match('(\\AUS|\\ADE)').nil?) then defect_tasks[work_product] += [line] end\n\t\tif (!line.match('\\AUS').nil? || !line.match('\\ADE').nil?) then work_product = line end\n\n\t end\n\n\t us_tasks.each_pair { |us,values| CreateTasksForUserStory(us,values) }\n\t defect_tasks.each_pair { |de,values| CreateTasksForDefect(de,values) }\n\t\n\tend\nend", "def current_week_tasks\n @current_week_tasks = {monday:[], tuesday:[], wednesday:[], thursday: [], friday: [], saturday:[], sunday:[]}\n end", "def tasks\n @tasks ||= Evoke.tasks\n end", "def failed_tasks\n @failed_tasks ||= @tasks_results.select(&:failure?)\n end", "def incoming_task_runs\n TapirLogger.instance.log \"Finding task runs for #{self}\"\n incoming_task_runs = []\n\n self.entity_mappings.each do |mapping|\n incoming_task_runs << mapping.get_task_run if mapping.get_child == self\n end\n incoming_task_runs\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n @rakefiles += rakefiles\n end", "def completed_weekly_tasks\n self.weekly_tasks.where(\n :is_weekly_attendance_marking_done => true ,\n :is_weekly_payment_collection_finalized => true, \n :is_weekly_payment_approved_by_cashier => true \n )\n end", "def _find_meeting_tasks(tasks, meeting_name)\n meeting_tasks = {}\n tasks.each do |task|\n if task[:meeting] == meeting_name\n if not meeting_tasks.has_key? task[:time]\n meeting_tasks[task[:time]] = []\n end\n meeting_tasks[task[:time]] << task\n end\n end\n meeting_tasks\n end", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end", "def failed_tasks\n each_task.select do |task|\n task.status == :failed\n end\n end", "def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end", "def project_files\n keep = %r/.rake$|Rakefile$|.patch$|.c$/\n strip_path = %r/\\A#{data}?/o\n paths = Hash.new { |h,k| h[k] = [] }\n Find.find( data ) do |path|\n next unless keep =~ path\n\n if File.directory?( path ) then\n paths[ path.sub( strip_path, '' ) ]\n next\n end\n dir = ::File.dirname( path ).sub( strip_path, '' )\n paths[dir] << path.sub( strip_path, '' )\n end\n\n return paths\n end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def require_tasks system_config\n system_config.gaudi_modules.each do |gm|\n mass_require(Rake::FileList[\"#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb\"])\n end\n end", "def task_graph_metadata\n return @task_graph_metadata if @task_graph_metadata\n @task_graph_metadata = {}\n Noop::Config.list_path_modules.each do |path|\n next unless path.directory?\n path.find do |task_file|\n next unless task_file.file?\n next unless task_file.to_s.end_with? 'tasks.yaml'\n begin\n tasks = YAML.load_file task_file\n rescue\n next\n end\n tasks.each do |task|\n id = task['id']\n @task_graph_metadata[id] = task\n end\n end\n end\n\n @task_graph_metadata.each do |id, group_task|\n next unless group_task['type'] == 'group' and group_task['tasks'].is_a? Array\n group_task['tasks'].each do |task|\n next unless @task_graph_metadata[task]\n @task_graph_metadata[task]['groups'] = [] unless @task_graph_metadata[task]['groups'].is_a? Array\n @task_graph_metadata[task]['groups'] << id\n end\n end\n\n @task_graph_metadata\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def completed_tasks\n self.tasks.where('is_completed =?', is_completed = true)\n end", "def find_specs_without_tasks\n spec_file_names.reject do |spec|\n manifest = Noop::Utils.convert_to_manifest spec\n task_file_names.include? manifest\n end\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= []\n @rakefiles += rakefiles\n end", "def tasks_data_today \n tasks_of_today = self.tasks_due_today\n tasks = []\n tasks_of_today.each do |task|\n task = {\n task_name: task.name, \n completion_value: task.completions.last.completion_value,\n completion_max: task.completion_max,\n completion_unit: task.completion_unit\n }\n tasks << task \n end\n tasks \n end", "def rake_task?\n defined?(::Rake) && !Rake.application.top_level_tasks.empty?\n end", "def read_taskwarrior_file(file)\n tasks = []\n open(file).each_line do |l|\n l = l.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => 'X')\n t = l.scan( /\\w+:\".+?\"/ ).collect{|i| \n k, v = i.split(':', 2)\n [k.to_sym, v.gsub(/\\A\"|\"\\Z/,'')] \n } \n t = Hash[t]\n t[:tags] = t[:tags].strip.split(\",\") if t[:tags]\n t[:entry] = t[:entry].to_i\n t[:end] = t[:end].to_i if t[:end]\n tasks << t\n end if File.file? file\n tasks\n end", "def load_tasks\n RakeLoader.new.load_tasks\n end", "def tasks_for_definition(task_def)\n tasks.where(task_definition_id: task_def.id)\n end", "def weekly_tasks_pending_cashier_approval\n self.weekly_tasks.where(\n :is_weekly_attendance_marking_done => true ,\n :is_weekly_payment_collection_finalized => true,\n :is_weekly_payment_approved_by_cashier => false\n )\n end", "def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end", "def failed_tasks\n return @failed_tasks\n end", "def failed_tasks\n return @failed_tasks\n end", "def invoked_tasks\n @invoked_tasks\n end", "def by_my_tasks_section(tasks, project_gid)\n by_section = {}\n sections = client.sections.get_sections_for_project(project_gid: project_gid)\n sections.each_entry { |section| by_section[section_key(section.name)] = [] }\n tasks.each do |task|\n assignee_section = task.assignee_section\n current_section = section_key(assignee_section.name)\n by_section[current_section] ||= []\n by_section[current_section] << task\n end\n by_section\n end", "def execution_error_tasks\n @execution_error_tasks ||= failed_tasks.select(&:execution_error?)\n end", "def active_tasks\n @tasks.select { | task | task.active }\n end", "def add_task_names(task_names)\n return if task_names.empty?\n\n missing_task_names = task_names - all_tasks.map(&:name)\n\n missing_task_names.each { |task_name| add_eval_task_named(task_name) }\n\n all_tasks\n end", "def reviewer_tasks\n tasks.find(:all, :conditions => { :context => 'reviewers', :show_for_context_object_tasks => true })\n end", "def readFiles\n rError = nil\n\n if (File.exists?(@TasksFileName))\n @LstTasks = nil\n File.open(@TasksFileName, 'r') do |iFile|\n @LstTasks = iFile.readlines.map do |iLine|\n next iLine.strip\n end\n end\n if (File.exists?(@TicketsFileName))\n @LstTickets = nil\n File.open(@TicketsFileName, 'r') do |iFile|\n @LstTickets = iFile.readlines.map do |iLine|\n next iLine.strip\n end\n end\n else\n rError = MissingTicketsFileError.new(\"Missing Tickets file: #{@TicketsFileName}\")\n end\n else\n rError = MissingTasksFileError.new(\"Missing Tasks file: #{@TasksFileName}\")\n end\n\n return rError\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end", "def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n @tasks ||= Task.find(self.task_ids)\n end" ]
[ "0.7285169", "0.66919297", "0.66704816", "0.66661507", "0.65413934", "0.63483906", "0.63473564", "0.6193978", "0.6183303", "0.6137314", "0.604493", "0.60397017", "0.6003204", "0.59804475", "0.59750575", "0.58867973", "0.5878638", "0.5859774", "0.58397454", "0.5805866", "0.57243174", "0.57210374", "0.56970316", "0.5675353", "0.5658772", "0.5601337", "0.55979717", "0.5587315", "0.5585722", "0.55688703", "0.5552885", "0.5552255", "0.55290085", "0.5512562", "0.5502197", "0.54985857", "0.5493995", "0.54903185", "0.5473848", "0.54551536", "0.54450434", "0.5433494", "0.54304296", "0.5428018", "0.54270315", "0.54206824", "0.54206824", "0.54108965", "0.54027313", "0.5387405", "0.5384776", "0.537387", "0.5338402", "0.53316605", "0.53316605", "0.53276587", "0.53276587", "0.5315962", "0.5304964", "0.52897483", "0.5282439", "0.52614903", "0.52425206", "0.523104", "0.52309275", "0.52219874", "0.5216223", "0.5213436", "0.5209023", "0.5192028", "0.51861745", "0.5182854", "0.5178961", "0.5170314", "0.5165748", "0.5164942", "0.51627797", "0.5158972", "0.51539755", "0.5133143", "0.5132256", "0.51308286", "0.5129633", "0.51199806", "0.51170206", "0.51170206", "0.51168054", "0.5107668", "0.5100322", "0.50779265", "0.50675684", "0.5067554", "0.50584745", "0.5057012", "0.5056596", "0.505608", "0.5055264", "0.5055264", "0.5055264", "0.50503457" ]
0.8255744
0
If there are tasks with the same name, mark them as duplicates and log them.
def set_and_log_duplicate_tasks(evaluated_tasks) return [] if evaluated_tasks.empty? # get all of the task_names that are duplicates (TODO ruby 2.7: replace this with .tally) duplicated_names = evaluated_tasks.group_by(&:name).select { |_name, tasks | tasks.size > 1 }.keys # Guard condition: no duplicate names, so just return return [] if duplicated_names.empty? # get the duplicated tasks for each name; return all of them duplicated_names.map{|dup_name| duplicated_tasks_for_name(dup_name, evaluated_tasks) }.flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_hardcoded_duplicates(task)\n task.add_duplicate('t1 duplicate 1')\n task.add_duplicate('t1 duplicate 2')\n end", "def ensure_unique_tasks_names! \n for i in 0..(@tasks_params.count-2)\n for j in (i+1)..(@tasks_params.count-1)\n raise RuntimeError, 'Duplicated tasks names' if @tasks_params[i.to_s][:name] == @tasks_params[j.to_s][:name]\n end\n end\n end", "def uniqueness\n if Task.exists?(:name => name, :stage_id => stage_id, :factor_id => factor_id) || Task.exists?(:name => name, :parent_task_id => parent_task_id)\n errors[:base] << \"An identical task already exists\"\n end\n end", "def dedup\n new_tasks = []\n old_tasks = {}\n @tasks.each do |t|\n if not t.toodleid\n new_tasks << t\n elsif old_tasks.key?(t.toodleid)\n # retain only the last update\n old_tasks[t.toodleid] = [old_tasks[t.toodleid], t].max\n else\n old_tasks[t.toodleid] = t\n end\n end\n @tasks = new_tasks + old_tasks.values\n self\n end", "def similar_task(user, taskname)\n can_create_task = true\n user.assignments.each do |assignment_instance|\n if assignment_instance.taskname.downcase == taskname.downcase\n # binding.pry \n can_create_task = false \n end \n end\n can_create_task\n end", "def set_and_log_tasks_already_ran(evaluated_tasks)\n return [] if evaluated_tasks.empty?\n\n already_ran = []\n\n evaluated_tasks.each do |evaluated_task|\n successful_attempt = find_successful_attempt_for_task(evaluated_task)\n already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt\n end\n\n already_ran\n end", "def merge_duplicates!\n Rails.logger.info \"Merging duplicates of #{url}\"\n duplicates.each do |dupe|\n dupe.merge_with!(self)\n end\n end", "def grouped_duplicates(collection); end", "def duplicate_task(name: required(\"name\"), include: nil, options: {}, **data)\n with_params = data.merge(name: name, include: include).reject { |_,v| v.nil? || Array(v).empty? }\n Resource.new(parse(client.post(\"/tasks/#{gid}/duplicate\", body: with_params, options: options)).first, client: client)\n end", "def verify_org_task_unique\n true\n end", "def remove_duplicates\n return @remove_duplicates if @set_remove_duplicates\n @remove_duplicates ||= true\n end", "def _unique(name)\n seen = (@_seen ||= Set.new)\n if seen.include?(name)\n raise ArgumentError, \"duplicate field: #{name.inspect}\"\n else\n seen << name\n end\n end", "def registered_task_names(group = nil)\n task_map(group).keys.dup\n end", "def verify_org_task_unique\n # do not verify for split appeal process\n return if appeal.appeal_split_process == true\n return if !open?\n\n if appeal.tasks.open.where(\n type: type,\n assigned_to: assigned_to,\n parent: parent\n ).any? && assigned_to.is_a?(Organization)\n fail(\n Caseflow::Error::DuplicateOrgTask,\n docket_number: appeal.docket_number,\n task_type: self.class.name,\n assignee_type: assigned_to.class.name\n )\n end\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def print_dupes(paths)\n @dest.puts \"Duplicates found on paths:\"\n @dest.puts paths.map { |p| \"\\t#{p}\" }\n end", "def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end", "def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end", "def set_Duplicates(value)\n set_input(\"Duplicates\", value)\n end", "def track_task(task_list, task, commit)\n # find the track item for this task\n idx = task_list.index { |x|\n x[:task_num] == task[:task_num]\n }\n if idx\n track_item = task_list[idx]\n # this task was already in the list, add the message and update the last status, sha, date, etc\n track_item[:completed] = task[:completed] # set to completed if most recent task is marked as completed\n track_item[:commits] << commit_hash(commit)\n else\n # track item doesn't exist yet\n track_item = { :task_num => task[:task_num],\n :completed => task[:completed],\n :commits => [commit_hash(commit)],\n :type => task[:type]}\n task_list << track_item\n end\n end", "def _create_task_by_name(task_name)\n @tasks.each do |t|\n return t.clone if t.name == task_name\n end\n raise \"Unknown Task!\" # couldn't find it. boo.\n end", "def delete_similar(user, taskname)\n Assignment.all.each do |assignment_instance|\n if assignment_instance.taskname == taskname\n assignment_instance.delete \n # puts \"#{user.name} finishes #{assignment_instance.taskname}\"\n end\n end \n end", "def adjust_task_output_names_patterns(task) #:nodoc:\n local_name = task.params[:_cb_pipeline][\"0\"][:savename].presence\n global_name = task.params[:_cb_output_renaming_pattern].presence\n if local_name\n task.params[:_cb_output_renaming_pattern] = (local_name || \"\") # crush global name\n else\n task.params[:_cb_pipeline][\"0\"][:savename] = (global_name || \"\")\n end\n end", "def more_uniq\n self.uniq_level += 1\n self.rename\n self\n end", "def add_task_names(task_names)\n return if task_names.empty?\n\n missing_task_names = task_names - all_tasks.map(&:name)\n\n missing_task_names.each { |task_name| add_eval_task_named(task_name) }\n\n all_tasks\n end", "def duplicate_scheduled_job?(listserv)\n scheduled_queue = Sidekiq::ScheduledSet.new\n scheduled_queue.any? { |job| check_for_duplicate(listserv, job) }\n end", "def not_duplicate_route\n return unless waypoints.length != 0 && self.name_changed? && self.name != \"Trip route\"\n Route.find_by_radius(waypoints.first.latitude,waypoints.first.longitude, 20).each do |route|\n next if self.id == route.id #Prevents self testing on update\n if route.name == name\n\tputs \"There is already another #{type.titleize.tableize.singularize} in this area with that name. This #{type.titleize.tableize.singularize} might have already been submitted.\"\n errors.add(:route, \"There is already another #{type.titleize.tableize.singularize} in this area with that name. This #{type.titleize.tableize.singularize} might have already been submitted.\")\n end\n end\n end", "def duplicates(collection); end", "def ensure_unique_project_name!\n dup_name_projects = @user.projects.where(\"name=?\", @project.name)\n dup_name_projects.each do |project|\n raise RuntimeError, 'Duplicated project name' if project.id != @project.id\n end\n end", "def duplicate(team, history)\n return false\n end", "def duplicate_imports_info\n import_frequency_mapping = {}\n all_imports.uniq.each do |item|\n item_occurrence = all_imports.count(item)\n if item_occurrence > 1\n import_frequency_mapping[item.chomp] = item_occurrence\n end\n end\n import_frequency_mapping\n end", "def grab_job_uniq\n throw :notimpl\n end", "def consecutive_duplicates(collection); end", "def unique?(name)\n tgts = resolve_mapping(name)\n targets = tgts.is_a?(Array) ? tgts : find(tgts)\n targets.size == 1\n end", "def check_duplicate_comments\n return unless event_type == 'comment' and event_action == 'created'\n if Activity.where(event_type: 'comment', event_action: 'created', user_id: user_id, repo: repo, :commented_on.lte => commented_on, :commented_on.gte => commented_on - 1.hour, description: description).count > 0\n errors.add(:description, 'Duplicate comment for the same repository by the same user')\n end\n end", "def remove_duplicate_entries\n File.open(\"#{output_directory_path}unique_ucf_lists.txt\", \"w+\") { |file|\n file.puts File.readlines(single_bad_ucf_file).uniq\n }\n end", "def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end", "def add_task\r\n\r\n task = task_info(params[:id], true)\r\n dup = BgWorker.first(:conditions => {:name => task[:fullname], :no_duplicate => true})\r\n res = BgWorker.run_task(task, 3) unless dup\r\n if res.nil?\r\n flash[:error] = _(\"Task could not be added to job list!\")\r\n else\r\n flash[:notice] = _(\"Task added to job list.\")\r\n end\r\n redirect_to(:action => :list) and return\r\n end", "def marker_unique_by\n nil\n end", "def check_for_duplicate_message_id\n old_mail_log = nil\n user_thread.schedule do\n old_mail_log = user.mail_logs.find_by_message_id(message_id)\n end\n\n if old_mail_log\n Log.librato(:count, \"system.process_uid.duplicate_message_id\", 1)\n return false\n else\n return true\n end\n end", "def no_duplicate_key_for_project\n project = Project.find(project_id)\n key = project.keys.find_by(name: name)\n\n if key.present?\n updating_key = key.id == id\n\n errors.add(:name, 'Name is already in use.') if !updating_key\n end\n end", "def reassign_judge_assign_tasks\n judge_assign_tasks = open_tasks.of_type(:JudgeAssignTask)\n\n if judge_assign_tasks.any?\n task_ids = judge_assign_tasks.pluck(:id).sort\n message = \"#{cancel} #{task_ids.count} JudgeAssignTasks with ids #{task_ids.join(', ')} and #{create} \" \\\n \"#{task_ids.count} DistributionTasks\"\n Rails.logger.info(message)\n\n if !dry_run\n judge_assign_tasks.each do |task|\n DistributionTask.create!(appeal: task.appeal, parent: task.appeal.root_task)\n update_task_status_with_instructions(task, Constants.TASK_STATUSES.cancelled)\n end\n end\n end\n end", "def remove_duplicates()\n self.duplicate_transactions_by_actor().each do |a, txns|\n # Spaceship operator, if my actor is of greater value than theirs, skip because they should remove the dupe\n next if (self.actor <=> a) == 1\n txns.each do |txn|\n self.counts[self.actor][\"txns\"].delete(txn)\n end\n end\n end", "def on_skip\n super\n @logger.important \" Skipping Task: #{title} \"\n @logger.debug(\" Task was last executed #{@last_executed.to_i}\")\n @logger.debug do\n info = input_files.to_a.map { |file| [file.to_s, file.mtime] }.to_h\n \" Prerequisite tasks: #{info}\"\n end\n end", "def check_multiple_activities\n if @activities.size > 1\n sorted = @activities.sort_by{|a| a[:number_of_hours].to_f}.reverse\n # puts sorted.collect{|a| a[:number_of_hours]}.join(\" > \")\n max_hours = sorted.first[:number_of_hours]\n for activity in sorted[1..sorted.size]\n remove_activity(activity, false)\n report = \"[MultipleActivities]: DUP #{activity[:source]} \"\n report << \"(#{activity[:number_of_hours]} hours <= #{max_hours} hours)\"\n @reports << report\n end\n end\n end", "def uniq(networkcheckoutput)\n mash = Hashie::Mash.new networkcheckoutput\n #networkcheckoutput.hits.hits.each do |value|\n\n #this creates a dataset of unique values based on a specified field. Need to break the Date out of the timestamp field to use.\n seen = Set.new\n mash.hits.hits.inject([]) do |kept, record|\n\n\n #brokenfield = record._source.src_ip.match(/\\w++ [^_]\\w/)\n\n unless seen.include?(record._source.src_ip)\n kept << record\n seen << record._source.src_ip\n end\n kept\n end\n end", "def task_names\n map do |task|\n task.name\n end\n end", "def push(task)\n with_lock do\n tasks << task\n tasks.sort! { |task1, task2| task1.finish_time <=> task2.finish_time }\n end\n end", "def is_duplicate(name_str)\n schedules = @current_user.schedules.where(\"LOWER(schedules.name) LIKE LOWER(?)\", name_str).take\n if schedules && !@testing\n return true\n else\n return false\n end\n end", "def reassign_judge_review_tasks\n judge_review_tasks = open_tasks.of_type(:JudgeDecisionReviewTask)\n\n if judge_review_tasks.any?\n task_ids = judge_review_tasks.pluck(:id).sort\n message = \"#{cancel} #{task_ids.count} JudgeDecisionReviewTasks with ids #{task_ids.join(', ')} and #{move} \" \\\n \"#{task_ids.count} AttorneyTasks to new JudgeDecisionReviewTasks assigned to the attorney's new judge\"\n Rails.logger.info(message)\n\n if !dry_run\n judge_review_tasks.each do |task|\n attorney_task = task.children_attorney_tasks.not_cancelled.order(:assigned_at).last\n reassign_judge_review_task(task, attorney_task)\n end\n end\n end\n end", "def check_for_duplicate_sha1\n # Generate the SHA1.\n self.sha1 = Digest::SHA1.hexdigest(raw_eml)\n\n old_mail_log = nil\n user_thread.schedule do\n old_mail_log = user.mail_logs.find_by_sha1(sha1)\n end\n\n if old_mail_log\n Log.librato(:count, \"system.process_uid.duplicate_sha1\", 1)\n return false\n else\n return true\n end\n end", "def find_dups(hash)\n open(\"dups.txt\", 'w') do |f|\n f.puts '=== Identical Files ===' \n hash.each_value do |a|\n next if a.length == 1\n a.each { |fname| f << (\"\\t\" + fname) }\n f << \"\\n\\n\"\n end\n end\nend", "def update_duplicate_counts(lead)\n unless (lead.previous_values[:id])\n @duplicates_by_id_count += 1\n end\n\n unless (lead.previous_values[:email])\n @duplicates_by_email_count += 1\n end\n end", "def validate_name_uniqueness\n existing_files = ProjectFile.where(directory_id: directory_id, \n project_id: project_id, name: name)\n unless existing_files.empty? or (existing_files.size == 1 and \n existing_files.first == self)\n errors.add(:name, \"must be unique within a folder; please \"+\n \"change #{project.name}:#{path} to something different.\")\n end\n end", "def without_duplicates(bindings); end", "def uppper_depends(task_name)\n task_list = []\n @tasks.each { |t|\n if not t.dependency.nil? then\n task_list.push(t) if t.dependency.include?(task_name)\n end\n }\n task_list\n end", "def intern(task_class, task_name)\n ret = super(task_class, task_name)\n ret.clear if @is_redefining\n return ret\n end", "def reassign_attorney_tasks\n attorney_tasks = open_tasks.of_type(:AttorneyTask)\n\n if attorney_tasks.any?\n task_ids = attorney_tasks.pluck(:id).sort\n parent_task_ids = attorney_tasks.pluck(:parent_id).sort\n message = \"#{cancel} #{task_ids.count} AttorneyTasks with ids #{task_ids.join(', ')}, JudgeDecisionReviewTasks \" \\\n \"with ids #{parent_task_ids.join(', ')}, and #{create} #{task_ids.count} JudgeAssignTasks\"\n Rails.logger.info(message)\n\n if !dry_run\n attorney_tasks.each do |task|\n reassign_attorney_task(task)\n end\n end\n end\n end", "def intern(task_class, task_name)\n @tasks[task_name.to_s] ||= task_class.new(task_name, self)\n end", "def dump_tasks_harvest\n tasks = pull_tasks_harvest()\n harvest_user_id = get_user_id_harvest()\n tasks.each do |task|\n task_id = task[\"id\"]\n same_task = FetchData.where(resource_original_id: task_id, source: 'harvest', resource: 'task').to_a\n if same_task.length == 0\n FetchData.create!(user_id: user_id, source_user_id: harvest_user_id, payload: task, resource_original_id: task_id, source: 'harvest', resource: 'task')\n else\n FetchData.where(resource_original_id: task_id, source: 'harvest', resource: 'task').update(payload: task)\n end\n end\n end", "def duplicates?(collection); end", "def ensure_unique\n puts \"Ensuring uniqueness of tag #{self.tag_id.to_s} to taggable #{self.entity_id.to_s} for user #{self.user_id.to_s}\"\n end", "def handle_duplicate_logs\n all_non_current_user_dup_user_extended_details_ids = []\n\n # Fetch all user_extended_details corresponding to current user_extended_details1_id\n all_non_current_user_dup_user_extended_details_ids += UserKycDuplicationLog.using_client_shard(client: @client).\n non_deleted.where(\n user_extended_details1_id: @user_kyc_detail.user_extended_detail_id, status: GlobalConstant::UserKycDuplicationLog.active_status).pluck(:user_extended_details2_id)\n\n # Fetch all user_extended_details corresponding to current user_extended_details2_id\n all_non_current_user_dup_user_extended_details_ids += UserKycDuplicationLog.using_client_shard(client: @client).\n non_deleted.where(\n user_extended_details2_id: @user_kyc_detail.user_extended_detail_id, status: GlobalConstant::UserKycDuplicationLog.active_status).pluck(:user_extended_details1_id)\n\n # Initiailize\n active_dup_user_extended_details_ids, inactive_dup_user_extended_details_ids, user_ids = [], [], []\n # Fetch active, inactive user_extended_details_ids\n UserKycDuplicationLog.using_client_shard(client: @client).non_deleted.\n where(\n \"user_extended_details1_id IN (?) OR user_extended_details2_id IN (?)\",\n all_non_current_user_dup_user_extended_details_ids,\n all_non_current_user_dup_user_extended_details_ids\n )\n .select(:id, :user1_id, :user2_id, :user_extended_details1_id, :user_extended_details2_id, :status).all.each do |ukdl|\n\n next if (ukdl.user_extended_details1_id == @user_kyc_detail.user_extended_detail_id) ||\n (ukdl.user_extended_details2_id == @user_kyc_detail.user_extended_detail_id)\n\n if ukdl.status == GlobalConstant::UserKycDuplicationLog.active_status\n active_dup_user_extended_details_ids << ukdl.user_extended_details1_id\n active_dup_user_extended_details_ids << ukdl.user_extended_details2_id\n else\n inactive_dup_user_extended_details_ids << ukdl.user_extended_details1_id\n inactive_dup_user_extended_details_ids << ukdl.user_extended_details2_id\n end\n user_ids << ukdl.user1_id\n user_ids << ukdl.user2_id\n end if all_non_current_user_dup_user_extended_details_ids.present?\n\n active_dup_user_extended_details_ids.uniq!\n inactive_dup_user_extended_details_ids.uniq!\n user_ids.uniq!\n\n active_dup_user_extended_details_ids = active_dup_user_extended_details_ids & all_non_current_user_dup_user_extended_details_ids\n inactive_dup_user_extended_details_ids = inactive_dup_user_extended_details_ids & all_non_current_user_dup_user_extended_details_ids\n\n\n inactive_dup_user_extended_details_ids -= active_dup_user_extended_details_ids\n # Mark inactive user_extended_details_ids as was_kyc_duplicate_status\n # Active user_kyc_details will already be is_kyc_duplicate_status\n if inactive_dup_user_extended_details_ids.present?\n UserKycDetail.using_client_shard(client: @client).active_kyc.where(user_extended_detail_id: inactive_dup_user_extended_details_ids).\n update_all(kyc_duplicate_status: GlobalConstant::UserKycDetail.was_kyc_duplicate_status,\n updated_at: Time.now.to_s(:db))\n end\n\n never_dup_user_extended_details_ids = (all_non_current_user_dup_user_extended_details_ids - active_dup_user_extended_details_ids - inactive_dup_user_extended_details_ids)\n # Mark missing dup_user_extended_details_ids as never_kyc_duplicate_status\n if never_dup_user_extended_details_ids.present?\n UserKycDetail.using_client_shard(client: @client).where(user_extended_detail_id: never_dup_user_extended_details_ids).\n update_all(kyc_duplicate_status: GlobalConstant::UserKycDetail.never_kyc_duplicate_status, updated_at: Time.now.to_s(:db))\n end\n\n # Delete all entries corresponding to all_non_current_user_dup_user_extended_details_ids\n UserKycDuplicationLog.using_client_shard(client: @client).where(\"user_extended_details1_id = ? OR user_extended_details2_id = ?\",\n @user_kyc_detail.user_extended_detail_id, @user_kyc_detail.user_extended_detail_id).delete_all\n\n # Mark current user as unprocessed\n @user_kyc_detail.kyc_duplicate_status = GlobalConstant::UserKycDetail.unprocessed_kyc_duplicate_status\n @user_kyc_detail.save!\n # Perform Check duplicates again for current user id\n r = AdminManagement::Kyc::CheckDuplicates.new({client: @client, user_id: @user_kyc_detail.user_id}).perform\n return r unless r.success?\n\n UserKycDetail.using_client_shard(client: @client).bulk_flush(user_ids)\n\n success\n end", "def resolve_task(name)\n name = name.to_s\n @tasks.each do |task|\n return task if task.name == name\n end\n @salticid.tasks.each do |task|\n return task if task.name == name\n end\n nil\n end", "def files_with_duplicate_imports\n files.select(&:has_duplicate_import?)\n end", "def uniqueness_of_title\n if project\n relation = self.class.for_projects_and_groups([project_id], [project.group&.id])\n elsif group\n relation = self.class.for_projects_and_groups(group.projects.select(:id), [group.id])\n end\n\n title_exists = relation.find_by_title(title)\n errors.add(:title, _(\"already being used for another group or project %{timebox_name}.\") % { timebox_name: timebox_name }) if title_exists\n end", "def unique\n return @logs_unique unless @logs_unique.nil?\n\n # Store unique IPs\n @logs_unique = {}\n @logs.each do |log|\n if @logs_unique.has_key? log.url\n @logs_unique[log.url].add(log.ip)\n else\n @logs_unique[log.url] = Set.new([log.ip])\n end\n end\n\n # Count unique IPs\n @logs_unique.each {|url, ip_set| @logs_unique[url] = ip_set.size}\n\n # Inject order method if someone wants to get ordered results\n # TODO ideally it should have the same return type as `unique`\n def @logs_unique.order(direction)\n direction = direction[:views] || :desc\n arr = sort_by {|url, views| views}\n\n direction == :asc ? arr : arr.reverse\n end\n\n @logs_unique\n end", "def print_tasks_to_key(tasks)\n tasks.each { |task|\n puts task.to_string\n @values[:result] << task\n }\n end", "def duplicate_message?(dedupe_key, klass, queue_timeout)\n dupe_detector.found_duplicate?(:id=>dedupe_key, :queue=>klass.to_s, :visibility_timeout=>queue_timeout)\n end", "def ensure_unique\n puts \"Ensuring uniqueness of user #{self.user_id.to_s} to recipe #{self.recipe_id.to_s}\"\n end", "def duplicated(method_name)\n @methods ||= []\n already_exists = @methods.include?(method_name)\n @methods << method_name\n already_exists\nend", "def check_duplicates(result, duplicates)\n duplicates.map do |duplicate|\n conflict = duplicate.position_held == result.parent_position_held\n ['Possible clash with parent position held', duplicate] if conflict\n end\n end", "def clean_up_dupes(dupes, output)\n unless dupes.empty?\n dupes.uniq.each do |sequence|\n output.delete sequence\n end\n end\n\n output\n end", "def grouped_duplicates(collection)\n collection.group_by { |item| item }.values.reject(&:one?)\n end", "def requires_duplicate_detection\n to_bool description['RequiresDuplicateDetection']\n end", "def name_uniqueness\n other_sprint = Sprint.where(board_id: self.board_id, name: self.name).where.not(id: self.id).count\n if other_sprint > 0\n errors.add(:name, 'must be uniq.')\n end\n end", "def eliminate_duplicates\n match_reduce(\n ->((_, rhs1_s), (_, rhs2_s)) { rhs1_s == rhs2_s },\n ->(lhs1, lhs2, _) { @cfg.replace! lhs2, lhs1 }\n )\n end", "def by_label\n labelled = Hash.new\n @tasks.each { |t|\n t.label.each { |t_label|\n unless labelled.include? t_label\n labelled[t_label] = []\n end\n unless t_label.nil?\n labelled[t_label] << t\n end\n }\n }\n labelled\n end", "def unique_track_name(name)\n i = 2\n name_key = name\n while @tracks.has_key? name_key\n name_key = \"#{name}#{i.to_s}\"\n i += 1\n end\n\n name_key\n end", "def unique_track_name(name)\n i = 2\n name_key = name\n while @tracks.has_key? name_key\n name_key = \"#{name}#{i.to_s}\"\n i += 1\n end\n \n return name_key\n end", "def write_taskwarrior_file(file, tasks)\n open(file, 'w') do |f|\n tasks.sort_by(&:toodleid).each do |t|\n t.tags = t.tags.join(\",\") if not t.tags.to_s.empty?\n f.puts('[' + t.to_h.collect{|k, v| %Q{#{k}:\"#{v}\"} }.join(\" \") + ']')\n end\n end\n end", "def duplicates\n Contact.find(:all, :conditions => [\"id != ? AND merge_id = ?\", id, merge_id])\n end", "def duplicate?\n @duplicate == true\n end", "def dup_check(type, name, body, tests)\n set = type == :leaf ? (@leaf_dup_check ||= ::Set.new) : (@rule_dup_check ||= ::Set.new)\n key = [name, body, tests.sort]\n if set.include? key\n true\n else\n set << key\n false\n end\n end", "def normalize_tasks_harvest(tasks)\n tasks.each do |task|\n project_original_id = task[\"payload\"][\"project\"][\"id\"]\n project = Project.find_by(workspace_id: harvest_workspace.id, original_id: project_original_id)\n found_task = Task.find_by(project_id: project.id, original_id: task[\"payload\"][\"task\"][\"id\"])\n if found_task\n found_task.name = task[\"payload\"][\"task\"][\"name\"]\n else\n found_task = Task.create!(project_id: project.id, name: task[\"payload\"][\"task\"][\"name\"], original_id: task[\"payload\"][\"task\"][\"id\"])\n end\n end\n end", "def unique_name(name)\n if @commands_by_name.include?(name)\n count = 2\n name2 = nil\n while (name2 = name + count.to_s) && @commands_by_name.include?(name2)\n count += 1\n end\n name2\n else\n name\n end\n end", "def write_taskwarrior_file\n open(@task_file, 'w') do |f|\n local_tasks.each do |t|\n t[:tags] = t[:tags].join(\",\") if t[:tags]\n f.puts('[' + t.collect{|k, v| %Q{#{k}:\"#{v}\"} }.join(\" \") + ']')\n end\n end\n end", "def query_by_duplicates\n tmp = self.clone\n tmp.list = list.select {|k,v| v.filename.count > 1}\n end", "def expected_duplicate?(id)\n EXPECTED_DUPLICATES.include? id\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def check_for_duplicates(csv_data, column_name)\n data = csv_data.select{|item| !item[column_name].nil? }\n value = data.map{|i| i[column_name]}\n duplicates = value.filter{ |e| value.count(e) > 1 }.sort.uniq\n naughty_values = duplicates.map{|i| \" 👉 \\\"#{i}\\\"\" }.join(\"\\n\")\n if value.uniq.length != value.length\n puts \"🔴 Found some services with the same #{column_name} \\n\\n#{naughty_values}\\n\\n\"\n return true\n else\n return false\n end\n end", "def duplicates?(input_numbers)\n collection_of_numbers = {}\n input_numbers.each do |number|\n if collection_of_numbers[number]\n return true\n else\n collection_of_numbers[number] = true\n end\n end\n return false\nend", "def unique_log\n if self.new_record?\n unless OsTracking.where(:campaign_id => campaign_id, :operating_system_id => operating_system_id, :date => date).count == 0\n errors.add(:os_tracking, I18n.t('models.os_tracking.validate.already_add'))\n end\n end\n end", "def possible_duplicates\n @duplicates = {}\n check_last_name_duplicates if last_name.present?\n check_email_duplicates if email_address.present?\n check_phone_number_duplicates if phone_number.present?\n check_address_duplicates if address_1.present?\n @duplicates\n end", "def findDuplicatesInSurvey(excludedIDs,in_srvyFilename,out_excLogFilename)\n\n\tfollowUpSurveyFile = File.new(in_srvyFilename,'r')\n\texcLogFile = File.new(out_excLogFilename,'a')\n\t\n\tallIDs = []\n\n\tlines = followUpSurveyFile.each_line\n\tlines.next\n\n\tlines.each do |l|\n\t\tl_arr = l.split(',').map(&:strip)\n\t\tallIDs.push(l_arr[1])\n\tend\n\n\trepeats = allIDs.group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first)\n\trepeats = repeats.sort\n\t\n\texcLogFile.puts(\"\\n\\nExcluded the following IDs for duplicate followup survey entries:\")\n\texcLogFile.puts()\n\tif repeats.length == 0\n\t\texcLogFile.puts(\"NONE\")\n\telse\n\t\trepeats.each do |x|\n\t\t\texcludedIDs.push(x)\n\t\t\texcLogFile.puts(x)\n\t\tend\n\tend\n\t\n\tfollowUpSurveyFile.close\n\texcLogFile.close\n\nend", "def remove_duplicates!\n \t\t# current will move forward 1 each step\n \t\tcurrent = @head\n\n \t\t# prev will hold on to the last non-duplicate node\n \t\tprev = @head\n\n \t\twhile (current.next_node)\n \t\t\t# if we find a new value...\n \t\t\tif prev.val != current.val\n \t\t\t\t# add this current node to our non-duplicate list\n \t\t\t\tprev.next_node = current\n \t\t\t\t# update prev to store this most recent non-duplciate node\n \t\t\t\tprev = current\n \t\t\tend\n \t\t\t\n \t\t\t# always advance current\n \t\t\tcurrent = current.next_node\n \t\tend\n \t\t# finally, add tail value if it's unique\n \t\tif prev.val != current.val\n\t\t\t# add this current node to our non-duplicate list\n\t\t\tprev.next_node = current\n\t\t\t@tail = current\n\t\telse\n\t\t\tprev.next_node = nil\n\t\t\t@tail = prev\n\t\tend\n \tend", "def unique_activity\n if self.user.bookings.where(activity_id: self.activity.id).any?\n errors.add(:already_joined, \"this activity!\")\n end\n end", "def add_or_find_duplicate(node)\n @nodes[node.path] ||= node\n @nodes[node.path]\n end", "def mark_duplicate_rows(csv_data)\n # Grouping on first name, last name, email & phone - two different people with the same name shouldn't be counted as one, and if a person has moved they won't be counted as two (people are likely to keep the same email and phone number)\n grouped_data = csv_data.group_by { |row| [row[:first_name], row[:last_name], row[:email], row[:phone]] }\n\n # Add validation errors\n grouped_data.each do |k,rows|\n # Sort by date and reverse first to make sure we don't add the errors to the wrong row\n rows.sort_by! { |row| row[:date_added]}.reverse!\n rows[1..].each do |row|\n row[:validation_errors].append(:duplicate)\n end\n end\n\n grouped_data.transform_values(&:count).count { |k,v| v > 1 }\n end", "def <<(task)\n raise ArgumentError, \"Task expected, got #{task.class}.\" unless task.is_a?(Task)\n\n @tasks << task unless @tasks.map(&:to_s).include?(task.to_s)\n end" ]
[ "0.7487215", "0.6605103", "0.6405019", "0.60654604", "0.5852868", "0.5769097", "0.5662074", "0.56507", "0.56316274", "0.5559704", "0.5549536", "0.5540729", "0.5464778", "0.54593104", "0.54243994", "0.5344918", "0.53351897", "0.53347844", "0.5325831", "0.5311978", "0.5272812", "0.52611715", "0.52556676", "0.52446043", "0.5241266", "0.5184169", "0.5176209", "0.51688445", "0.5161161", "0.5144765", "0.51305753", "0.5130068", "0.51296103", "0.5126869", "0.5125139", "0.512198", "0.50886196", "0.5085363", "0.50764817", "0.5074576", "0.50560343", "0.50294214", "0.50267786", "0.5025914", "0.49788854", "0.49750817", "0.49737832", "0.49693972", "0.4954308", "0.49501798", "0.49414378", "0.49408466", "0.49289382", "0.49255624", "0.4911666", "0.49052384", "0.48992652", "0.48924586", "0.48909605", "0.48854297", "0.48808527", "0.4880532", "0.48683977", "0.48646936", "0.48609543", "0.48570013", "0.48543745", "0.4850974", "0.48484126", "0.48412347", "0.4839666", "0.48333776", "0.4827577", "0.4827246", "0.48252863", "0.48227727", "0.4821921", "0.48203054", "0.48194936", "0.48183584", "0.48181206", "0.48172438", "0.48115125", "0.48017785", "0.4786887", "0.47858205", "0.47841784", "0.47831598", "0.478045", "0.47670668", "0.47599998", "0.4758351", "0.475441", "0.47480074", "0.47465286", "0.47420007", "0.47398564", "0.4734096", "0.47275132", "0.47236645" ]
0.7115204
1
Determine the tasks that have already run successfully in this rakefile
def set_and_log_tasks_already_ran(evaluated_tasks) return [] if evaluated_tasks.empty? already_ran = [] evaluated_tasks.each do |evaluated_task| successful_attempt = find_successful_attempt_for_task(evaluated_task) already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt end already_ran end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end", "def tasks_have_failed?\n return true if @tasks_have_failed\n failed = select do |task|\n task.failed?\n end\n if failed.any?\n debug \"Found failed tasks: #{failed.map { |t| t.name }.join ', '}\"\n @tasks_have_failed = true\n end\n failed.any?\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def run_successfully?(tasks)\n [*tasks].all? do |task|\n Rake::Task.task_defined?(task) && Rake::Task[task].invoke\n end\nend", "def failed_tasks\n @failed_tasks ||= @tasks_results.select(&:failure?)\n end", "def execution_error_tasks\n @execution_error_tasks ||= failed_tasks.select(&:execution_error?)\n end", "def rake_running\n `ps | grep 'rake' | grep -v 'grep' | wc -l`.to_i > 1\nend", "def tasks_are_successful?\n return true if @tasks_are_successful\n return false if @tasks_have_failed\n successful = all? do |task|\n task.successful?\n end\n if successful\n debug 'All tasks are successful'\n @tasks_are_successful = true\n end\n successful\n end", "def failed_tasks\n each_task.select do |task|\n task.status == :failed\n end\n end", "def rake_running\n `pgrep rake | wc -l`.to_i > 1\nend", "def rakefile_test_tasks\n ''\n end", "def tasks_remain?\n\t\ttasks.any?{ |t| t.completed.nil? }\n\tend", "def no_tasks\n $stderr.puts 'No tasks found in the current working directory.'\n exit(1)\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def has_pre_tasks?\n !@pre_tasks.empty?\n end", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def failed_tasks\n return @failed_tasks\n end", "def failed_tasks\n return @failed_tasks\n end", "def incomplete_tasks\n\t\ttasks.select{ |t| !t.completed? }\n\tend", "def rake_task?\n defined?(::Rake) && !Rake.application.top_level_tasks.empty?\n end", "def is_rake_running?\n `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def ready_task\n find do |task|\n task.ready?\n end\n end", "def all_complete\n self.tasks.count == self.tasks.done.count\n end", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def starting_tasks\n each_task.reject do |task|\n task.dependency_backward_any?\n end\n end", "def validate_tasks\n validated = false\n if tasks_completed?\n validated = tasks_completed!\n end\n\n validated\n end", "def tasks_successful_count\n count do |task|\n task.successful?\n end\n end", "def check_tasks\n if !(@free_workers.empty? || @tasks_to_assign.empty?)\n @free_workers.each { |worker| find_task_for(worker) }\n end\n end", "def empty?; tasks.empty? end", "def tasks_failed_count\n count do |task|\n task.failed?\n end\n end", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end", "def rakefiles\n @rakefiles ||= []\n end", "def processing_running_task\n reset_undefined_retries!\n 'running'\n end", "def task_defined?(task_name) \n lookup(task_name) != nil\n end", "def should_skip\n if @needed.nil?\n @needed = prerequisite_tasks.empty? || \\\n input_files.since(@last_executed).any? || \\\n @force\n\n # We also make sure that if the rakefile was modified since last\n # execution, we force reexecution\n if @application.rakefile\n @needed ||= File.mtime(@application.rakefile) > @last_executed\n end\n end\n !@needed\n end", "def list_available_build_tasks\n cd 'cookbooks/example'\n unset_bundler_env_vars\n run_simple 'bundle exec rake -T'\n end", "def rake_tasks(&block); end", "def rake_tasks(&block); end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def depends_on?(other_task)\n depends_on.include?(other_task)\n 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 has_subtasks?\n\t\ttasks.size > 0\n\tend", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def pending_tasks?\n hash = pending_tasks\n return nil unless hash.key? \"tasks\"\n hash[\"tasks\"].length > 0\n end", "def check_tasks\n return true if is_finished?\n if is_cancelled?\n logger.warn \"AudioFile is cancelled and no tasks will be checked\"\n return\n end\n analyze_audio\n copy_original\n transcode_audio\n copy_to_item_storage\n start_copy_to_s3_job\n transcribe_audio\n premium_transcribe_audio\n if !needs_transcript?\n analyze_transcript\n end\n end", "def tasks_status(tasks)\n return 'passing' if tasks.all?(&:passing?)\n return 'failing' if tasks.any?(&:failing?)\n return 'errored' if tasks.any?(&:errored?)\n return 'pending' if tasks.any?(&:pending?)\n return 'incomplete' if tasks.any?(&:incomplete?)\n\n 'unstarted'\n end", "def reset\n @tasks_have_failed = false\n @tasks_are_finished = false\n @tasks_are_successful = false\n end", "def run_all\n passed = @runner.run_all!\n\n throw :task_has_failed unless passed\n end", "def dependencies_have_failed?\n return @dependencies_have_failed unless @dependencies_have_failed.nil?\n failed = select do |task|\n task.failed?\n end\n debug \"Found failed dependencies: #{failed.map { |t| t.name }.join ', '}\" if failed.any?\n @dependencies_have_failed = failed.any?\n end", "def success?\n @success ||= @tasks_results.all?(&:success?)\n end", "def processing_undefined_task\n if @undefined_retries > 0\n @undefined_retries -= 1\n Astute.logger.debug \"Puppet on node has undefined status. \"\\\n \"#{@undefined_retries} retries remained. \"\\\n \"#{task_details_for_log}\"\n Astute.logger.info \"Retrying to check status for following \"\\\n \"nodes: #{@puppet_mclient.node_id}\"\n 'running'\n else\n Astute.logger.error \"Node has failed to get status. There is\"\\\n \" no more retries for status check. #{task_details_for_log}\"\n 'failed'\n end\n end", "def task_triggers\n return @task_triggers\n end", "def ran?\n completed? || failed?\n end", "def check_rakes\n #pids of all configured rakes keyed by rake\n rakes_pids = get_rakes_pids(@configured_rakes.keys)\n #start and stop rakes as necessary so that number running equals qty in config\n @configured_rakes.each do |rake, rakeopts|\n if @ignore_rakes.include?(rake)\n log \"rake #{rake} in ignore rakes. skipping.\"\n next\n end\n qty = rakeopts[:qty] #reassigning vars for readability\n #cnd of processes running rake\n running_cnt = rakes_pids[rake].length\n #start/stop rakes if running cnt </> qty in config\n if running_cnt < qty\n log \"rake #{rake} process count #{running_cnt} less than #{qty}\"\n start_rake(rake, (qty - running_cnt))\n elsif running_cnt > qty\n log \"rake #{rake} process count #{running_cnt} greater than #{qty}\"\n stop_rake(rake, (running_cnt - qty))\n end\n end\n #stop all started_rakes not found in configured_rakes (because they were removed from the config)\n @started_rakes.each do |rake|\n if !@configured_rakes.keys.include?(rake) and !@ignore_rakes.include?(rake)\n log \"rake #{rake} no longer in config\"\n stop_rake(rake) \n @started_rakes.delete(rake)\n end\n end\n end", "def define_sanitycheck_tasks\n\n\t\ttask 'hg:precheckin' => [:spec] if File.directory?( 'spec' )\n\t\ttask 'hg:prep_release' => [ :check_manifest, :check_history ]\n\n\t\t# Rebuild the ChangeLog immediately before release\n\t\ttask :check_manifest => 'ChangeLog'\n\t\ttask :prerelease => 'ChangeLog'\n\n\tend", "def tasks_finished_count\n count do |task|\n task.finished?\n end\n end", "def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them into the Thor::Sandbox namespace\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n if task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile helper: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # Now load the thor files\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n unless task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # load user tasks\n if user_tasks_folder\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\\.rb$/) }\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\\.rb$/) }\n end\n\n @loaded = true\n end", "def active_tasks(tasks)\n tasks.select { |task| task.completed_at.nil? }\n end", "def tasks?\n tasks.summary.items?\n end", "def tasks_are_finished?\n return true if @tasks_are_finished\n finished = all? do |task|\n task.finished?\n end\n if finished\n debug 'All tasks are finished'\n @tasks_are_finished = true\n end\n finished\n end", "def tasks() []; end", "def load_tasks\n end", "def not_completed?\n tasks.any? { |task| task.done != 100 }\n end", "def is_rake\n\tFile.basename($0) == 'rake'\nend", "def task_present?(task_name)\n tasks.key? prepare_key(task_name)\n end", "def has_tasks?\n return true unless session_tasks.empty?\n false\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def upgrade_tasks\n if ENV['UPGRADE'].present?\n ENV['UPGRADE'].split(',')\n else\n all_upgrade_tasks\n end\n end", "def run_exit_tasks!; end", "def completed_tasks\n self.tasks.where('is_completed =?', is_completed = true)\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def total_complete\n tasks.select { |task| task.complete? }.count\n end", "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def invoked_tasks\n @invoked_tasks\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def done\n done_ids = @tasks.keys.find_all do |id|\n @tasks[id].done?\n end\n done_tasks = done_ids.inject({}) do |map, id|\n map[id] = @tasks[id]\n map\n end\n done_ids.each do |id|\n @tasks.delete(id)\n end\n return done_tasks\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def ensure_tasks_folder\n io.mkdir('.webbynode/tasks') unless io.directory?(\".webbynode/tasks\")\n %w[before_push after_push].each do |file|\n io.exec(\"touch .webbynode/tasks/#{file}\") unless io.file_exists?(\".webbynode/tasks/#{file}\")\n end\n end", "def find_tasks_without_specs\n task_file_names.reject do |manifest|\n spec = Noop::Utils.convert_to_spec manifest\n spec_file_names.include? spec\n end\n end", "def status\n # if non of tasks started, then return not started\n return 'not-started' if tasks.none?\n # if all complete then say 'complete'\n if tasks.all? { |task| task.complete? }\n 'complete'\n # in progress if anything in progress or complete\n elsif tasks.any? { |task| task.in_progress? || task.complete? }\n 'in-progress'\n else\n 'not-started'\n end\n end", "def evaluate_pre_tasks\n if using_rake? and Pkg::Config.pre_tasks\n unless Pkg::Config.pre_tasks.is_a?(Hash)\n fail \"The 'pre_tasks' key must be a Hash of depender => dependency pairs\"\n end\n Pkg::Config.pre_tasks.each do |depender, dependency|\n add_dependency(depender, dependency)\n end\n end\n end", "def incomplete_tasks\n # Give me all the tasks such that the task is incomplete\n @tasks.select { |task| task.incomplete? }.sort_by { |task| task.created_at }\n end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\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 verify_org_task_unique\n true\n end", "def tasks\n config[:tasks]\n end", "def ignore_complete?(task)\n !get_result(task).nil?\n end" ]
[ "0.7163444", "0.70850396", "0.7007369", "0.68085676", "0.6796838", "0.67595315", "0.66654855", "0.6606955", "0.6546945", "0.64636683", "0.6439367", "0.64018196", "0.6324853", "0.63228333", "0.62614465", "0.6257521", "0.62568927", "0.62477475", "0.62429225", "0.62429225", "0.623179", "0.6230203", "0.621967", "0.61976796", "0.61976796", "0.6173011", "0.6163975", "0.6114794", "0.61133426", "0.6111844", "0.6098843", "0.60800266", "0.6069384", "0.606891", "0.6068729", "0.60667115", "0.6044538", "0.6035043", "0.6018305", "0.6018001", "0.6006612", "0.5994661", "0.5965795", "0.5919366", "0.5919366", "0.5906581", "0.589184", "0.58899474", "0.5886555", "0.5869402", "0.5868622", "0.585196", "0.5851929", "0.58506083", "0.5849168", "0.5839474", "0.5838195", "0.5822318", "0.5815138", "0.58091015", "0.580778", "0.57935894", "0.5783939", "0.5778457", "0.57770675", "0.5775346", "0.57726043", "0.57711005", "0.5764923", "0.5763715", "0.57584435", "0.57472456", "0.57411546", "0.5739691", "0.5739107", "0.5722915", "0.5690145", "0.5670877", "0.5668349", "0.5667753", "0.5660525", "0.5658741", "0.5656145", "0.5651726", "0.5651662", "0.5649746", "0.5621683", "0.5615914", "0.56115377", "0.56111485", "0.5606511", "0.5605571", "0.56004035", "0.5593483", "0.55811876", "0.55772936", "0.5565462", "0.55577797", "0.55504996", "0.554811" ]
0.58993906
46
Note how the Hash is created: If an entry for a key ( = rake file name) does not exist, then a new entry is made, with the value = EvaluatedRakefile(key).new
def all_rakefiles @all_rakefiles ||= new_hash_of_eval_rakefiles end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_eval_task_named(task_name)\n new_ev_task = EvaluatedRakeTask.new(task_name, self.filename)\n add_eval_task(new_ev_task)\n\n new_ev_task\n end", "def create_or_update_previous_runs!\n if previously_ran?\n current_run.each do |description, elapsed|\n new_times = if previous_run[description.to_s]\n Array(previous_run[description.to_s]) << elapsed\n else\n Array(elapsed)\n end\n\n previous_run.store(description.to_s, new_times)\n end\n\n File.write(previous_runs_filename, previous_run.to_yaml)\n\n else\n\n File.write(previous_runs_filename, current_run.to_yaml)\n\n end\n end", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def rakefile_created(file)\n puts green(\"Rakefile created: #{file}\")\n end", "def add(key_file); end", "def add_rakefile_and_tasks(rakefilename, task_names)\n\n # creates a new EvaluatedRakeFile entry if needed\n ev_rakefile = self.all_rakefiles[rakefilename]\n ev_rakefile.add_task_names(task_names)\n self.all_tasks.concat(ev_rakefile.all_tasks)\n\n ev_rakefile\n end", "def process_key(key)\n if ::File.exists?(key)\n key\n else\n tempfile = ::Tempfile.new('key')\n tempfile.write(key)\n tempfile.flush\n\n tempfile.path\n end\n end", "def init\n @by_day = {}\n if File.exist?('result.txt')\n File.readlines('result.txt').each do |line|\n a = line.chomp.split(\"\\t\")\n @by_day[a.first] = a\n end\n end \nend", "def key(path = self.path)\n (@key ||= EMPTY_HASH.dup)[path] ||= Failures.new(path)\n end", "def build_file_into_master_hash(master_hash, key, source_file)\r\n\t\tentries = grab_and_hashify(source_file, SIZE_OF_HASH_BLOCKS)\r\n\t\tif(!entries.blank?)\r\n\t\t\tmaster_hash.merge({ key.to_sym => entries })\r\n\t\telse\r\n\t\t\tmaster_hash.delete(key.to_sym)\r\n\t\t\tmaster_hash\r\n\t\tend\r\n\tend", "def create_task_hash name\n { name: name,\n schedule: \"To-Do\",\n priority: \"Normal\",\n due_days: 2,\n due_hours: \"0\",\n due_minutes: \"00\",\n followup: \"\",\n assigned_to: \"Negotiator\",\n fees_assigned: \"0.00\",\n task_description: \"#{name} task description\",\n letter_agreement: \"\",\n }\nend", "def build\n fail \"Please provide a value for key, currently: #{key}\" if key.nil?\n\n if in_key\n { in_key.to_sym => { key => data } }\n else\n process_data\n transform_to_hash\n end\n end", "def create_run_info(opts)\n BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)\n\n normalise_regex = /[^a-z0-9]/i\n current_time = Time.zone.now.utc.iso8601.to_s.downcase.gsub(normalise_regex, '_')\n\n dir_run = File.join(@dir_worker_top, BawWorkers::Jobs::Analysis::Runner::DIR_RUNS,\n \"#{opts[:job_id]}_#{opts[:id]}_#{current_time}\")\n dir_run_temp = File.join(dir_run, BawWorkers::Jobs::Analysis::Runner::DIR_TEMP)\n file_run_log = File.join(dir_run, BawWorkers::Jobs::Analysis::Runner::FILE_LOG)\n\n FileUtils.mkpath([dir_run, dir_run_temp])\n\n {\n dir_run: dir_run,\n dir_run_temp: dir_run_temp,\n file_run_log: file_run_log\n }\n end", "def new(entry, date = Date.today)\n YAML::Store.new(\"#{ENV['HOME']}/.nikki/nikki.yaml\").transaction do |store|\n store['entries'] << { date => entry.strip }\n end\n\n ls\n end", "def results_file_path(key)\n File.join(RAILS_ROOT, \"files\", \"activity_results\", \"results_#{id.to_s}_#{key.to_s}.yml\")\n end", "def set_data_by_key(key, value)\n if FileFetcher::directory_exists?(@temp_folder_path) == false\n create_temp_directory\n end\n\n temp_file_path = File.join(@temp_folder_path, \"#{key}.txt\")\n File.open(temp_file_path, \"w+\") do |file|\n file.write(value)\n end\n end", "def create_from_file\n end", "def create_from_task_template\n File.open(file_path, 'w') do |f|\n f.puts build_task_template\n end\n end", "def hash_creator(filepath)\n hash = Hash.new\n CSV.foreach(filepath, headers: true) do |row|\n student = Student.new(fname = row[0], lname = row[1], email = row[2], section = row[3], major1 = row[4], major2 = row[5], minor1 = row[6], minor2 = row[7])\n if hash.has_key?(student.section)\n array = hash[student.section]\n array.push(student)\n hash[student.section] = array\n else\n array = [student]\n hash[student.section] = array\n end\n end\n return hash\nend", "def initialize(file)\n @path = file.path\n @builds = {}\n @task_groups = {}\n instance_eval(file.read, __FILE__, __LINE__)\n end", "def register_defaults(with_hash:)\n\n # *Define* each of the possible defaults. These will have\n # default values. We're actually kind of good to go at\n # this point if we don't want to use the rc file.\n\n with_hash.each {|k,v| define_default(for_key:k, value:v) }\n\n # If the file doesn't exist, create it and add our current\n # key-value pairs to it. Otherwise, read the file, compare\n # it to our current set of key-value pairs, and make\n # adjustments, re-writing the file if necessary.\n\n if !File.file?(file_path)\n FileUtils.mkdir_p(File.dirname(file_path))\n File.open(file_path, 'w') { |file| file.write(hash_representation.to_yaml) }\n else\n #noinspection RubyResolve\n #@type [Hash] working\n working = YAML.load(File.read(file_path))\n new = working.select {|k,_| hash_representation.has_key?(k)} # only keeps working items if they are current.\n new = new.merge(hash_representation.select {|k,_| !new.has_key?(k)}) # select the new items.\n File.open(file_path, 'w') { |file| file.write(new.to_yaml) } unless working == new\n new.each {|k,v| self[k] = v }\n end\n end", "def load_hint_file(hint_file)\n # Determine data_file index.\n @keydir.data_files |= [hint_file.data_file]\n file_id = @keydir.data_files.index hint_file.data_file\n\n hint_file.each do |entry|\n # Check for existing newer entry in keydir\n if (cur = @keydir[entry.key]).nil? or entry.tstamp >= cur.tstamp\n @keydir[entry.key] = Keydir::Entry.new(\n file_id,\n entry.value_sz,\n entry.value_pos,\n entry.tstamp\n )\n end\n end\n end", "def load!(file)\n hash = {}\n YAML.load_file(file).each do |k, v|\n hash[Pathname(k)] = v.map{|vv| Pathname(vv) }\n end\n replace(hash)\n end", "def create_entry( dictionary_name, key_name, value )\n\n KeyError.not_new( dictionary_name, self )\n KeyError.not_new( key_name, self )\n KeyError.not_new( value, self )\n\n self[ dictionary_name ] = {} unless self.has_key?( dictionary_name )\n self[ dictionary_name ][ key_name ] = value\n\n end", "def file_digest(pathname)\n key = pathname.to_s\n if @digests.key?(key)\n @digests[key]\n else\n @digests[key] = super\n end\n end", "def create_if_not_exists(hash, key, val, name: key.to_sym)\n return if hash.key?(key)\n\n self.class.send(:attr_accessor, name)\n send(\"#{name}=\", val)\n end", "def initialize\n super\n @name = \"rum\"\n @rakefiles = DEFAULT_RAKEFILES.dup\n end", "def generate_input_file\n\t\t\t#FileUtils.touch(\"#@run_name.mat\")\n\t\t\t#cronos.new_file\n\t\t\t#eputs \"Make sure you save the file as #@run_name.mat... overwrite the existing empty place holder. When you have saved the file press enter.\"\n\t\t\tif @duplicate_id\n\t\t\t\told = @runner.run_list[@duplicate_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telsif @restart_id\n\t\t\t\told = @runner.run_list[@restart_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}_resultat.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telse\n\t\t\t\tsz = Terminal.terminal_size[1]\n\t\t\t\teputs((str = \"When you have created the file press enter. Don't save it (CodeRunner will automatically save it in the right place. You can edit parameters later as well. CodeRunner will not submit the file... submit it manually using a batch or interactive run.\"; [\"-\"*sz, str, \"-\"*sz]))\n\t\t\t\tcronos.puts(\"zuicreate\")\n\t\t\t\tSTDIN.gets\n\t\t\tend\n\t\t\tcronos.puts(\"param.gene.origine = '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.gene.file = '#@directory/#{@run_name}_resultat.mat'\")\n\t\t\tcronos.puts(\"param.gene.rapsauve = '#@directory/#{@run_name}_resultat'\")\n\t\t\tcronos.puts(\"param.edit.currentfile= '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.from.creation.com = '#@comment'\")\n\t\t\tcronos.puts(\"zuisavedata('force')\")\n\t\t\t#cronos.eval(\"zuicreate\")\n\t\t\trefresh_gui\n\t\t\t\n\t\tend", "def read\n return unless File.exist?(filename)\n\n name = DEFAULT_NAME\n save = Hash.new{ |h,k| h[k.to_s] = {} }\n\n File.read(filename).lines.each do |line|\n if md = /^\\[(\\w+)\\]$/.match(line)\n name = md[1]\n end\n if md = /^(\\w+)\\s+(.*?)$/.match(line)\n save[name][md[2]] = md[1]\n end\n end\n\n save.each do |name, digest|\n @saved[name] = digest\n end\n end", "def config_creates_file(_new_resource)\n return 'Makefile'\n end", "def config_creates_file(_new_resource)\n return 'Makefile'\n end", "def factory( key, *args )\n details = fetch( key, nil )\n raise \"ConfigYaml: missing key when calling factory('#{key}')\" if details.nil?\n klass = details.fetch( 'class', nil )\n raise \"ConfigYaml: missing class when calling factory('#{key}')\" if klass.nil?\n\n requirement = details.fetch( 'require', nil )\n require requirement unless requirement.nil?\n\n unless @class_methods.include? klass\n @class_methods.add klass\n static_keys = details.keys.find_all { |k| k[0].chr == '_' } \n static_keys.each do |k|\n method = k.sub( /^_/, '' )\n text = \"#{klass}.#{method}( #{ details[k].inspect } )\"\n eval text \n end\n end\n \n if args.empty?\n text = \"#{klass}.new( #{ details.fetch( 'initialize', '' ) } )\" \n else\n text = \"#{klass}.new( \"\n args.each_index { |index| text += \"args[#{index}],\" }\n text = text[ 0...text.size-1 ] + ' )'\n end\n\n begin\n instance = eval text\n rescue => details\n raise \"ConfigYaml: cannot eval '#{text}' (missing require?)\\n\" + details.inspect\n end\n\n details.each_pair do |k,value|\n next if ['class','initialize', 'require'].include? k\n next if k[0].chr == '_' # no class methods, please\n eval \"instance.#{k} = #{value.inspect}\"\n end\n\n instance\n end", "def build\n if @default_file\n internal_add_file(@default_file)\n end\n end", "def build(file_name)\n end", "def [](key, file=_root_file)\n with_file(file, key)\n end", "def eval_file; end", "def initialize\n @data = ::Hash.new { |h, k| h[k] = File.new(k, mtime: 0) }\n @mutex = Mutex.new\n end", "def initialize(key)\n @key = key.to_sym\n @defaults = {}\n @file = []\n @validator = nil\n @children = {}\n @env = {}\n end", "def create_dict(file)\n # Since wordlist is constant\n if File.file?(file)\n IO.readlines(file, chomp: true)\n else\n puts 'File not found!'\n end\n end", "def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\nend", "def create_checkpoint(filename)\n full_path = File.join(@abs_path, filename)\n File.new(full_path, File::CREAT|File::TRUNC|File::RDWR, 0644)\n @data = []\n File.open(full_path, 'w') {|f| f.write YAML::dump(@data) }\n\n # TODO: we should be storing relative paths, not absolute paths\n File.new(@current_file, File::CREAT|File::TRUNC|File::RDWR, 0644)\n File.open(@current_file, 'w') {|f| f.write(full_path) }\n end", "def build(resources)\n current = [] || YAML.load_file(path)\n\n resources.each do |resource|\n item = {}\n item['path'] = resource\n item['modified'] = File.mtime(resource).to_s\n item['processed'] = Time.now.to_s\n\n current << item\n end\n\n current\n end", "def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end", "def create_row\n @tasksheet = Tasksheet.new\n @key = params[:key].to_i\n end", "def read!\n file = root + FILENAME\n if file.exist?\n data = YAML.load(File.new(file))\n data.each do |name, value|\n self[name] = value\n end\n end\n return self\n end", "def create_new_report_hash\n new_report_hash = {}\n\n puts \"Great! Now lets create a report about the sighting!\"; sleep(1)\n\n puts \"In what month (MM) did the sighting take place.\"\n new_report_hash[:month] = gets.chomp\n\n puts \"Please title your report.\"\n new_report_hash[:title] = gets.chomp\n\n puts \"What city did you see the animal in?\"\n new_report_hash[:city] = gets.chomp\n\n new_report_hash\nend", "def create(filename)\n time = Time.now\n @files[filename] = time # Updates the \"files\" hash with the timestamp for when the file was created\n puts \"The file #{filename} was created at #{time}\"\n end", "def test_modifyingfile\n keys = []\n names = []\n 3.times {\n k = mkkey\n #h[:ensure] = :present\n #h.retrieve\n keys << k\n names << k.name\n }\n assert_apply(*keys)\n keys.clear\n\n @catalog.clear(true)\n @catalog = nil\n\n newkey = mkkey\n #newkey[:ensure] = :present\n names << newkey.name\n assert_apply(newkey)\n\n # Verify we can retrieve that info\n assert_nothing_raised(\"Could not retrieve after second write\") {\n newkey.provider.prefetch\n }\n\n assert(newkey.provider.exists?, \"Did not see key in file\")\n end", "def set_latest(rule_key, timestamp)\n @timestamps[rule_key]['latest_run'] = timestamp\n end", "def make_entry()\n\n seq_id = @filehandler.readline.chomp\n puts seq_id\n sequence = @filehandler.readline.chomp\n identifier = @filehandler.readline.chomp\n quality = @filehandler.readline.chomp\n\n Entry.new(seq_id, sequence, identifier, quality)\n end", "def create_recipe(rcp_file, keyword, *args, &block)\n keyword = keyword.to_s.to_sym unless Symbol === keyword\n if recipe_types.has_key?(keyword)\n return recipe_types[keyword].new(rcp_file, *args, &block)\n end\n\n nil\n end", "def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end", "def associate hash_values=nil\n @rally_hash = hash_values if hash_values\n if @rally_hash.has_key?(\"Project\")\n project = Project.find_or_create_by(:rally_uri => @rally_hash[\"Project\"][\"_ref\"])\n project.iterations << self\n end\n self.save\n end", "def import_key_string(key_string, activation_date: Time.now)\n rnp = load_key_string(key_string)\n all_keys(rnp).map do |raw|\n metadata = raw.json\n creation_hash = creation_params(\n raw: raw, activation_date: activation_date, metadata: metadata,\n )\n create(creation_hash)\n end\n end", "def create\n bootstrap unless File.exist?(file)\n load_attributes\n end", "def add_key(key)\n begin\n file = Tempfile.new('key')\n file.puts(key)\n file.close\n\n add_keyfile(file.path)\n ensure\n file.close(true) unless file.nil?\n end\n end", "def file_to_run=(file_to_run)\n store[:file_to_run] = file_to_run\n end", "def with_input_file(key, tmp_dir: nil)\n raise \"subclass responsibility\"\n end", "def create_from_file(path)\n abort FileNotFound.new(path) unless File.exist? path\n\n env = ridley.environment.from_file(path)\n ridley.environment.create(env)\n rescue Ridley::Errors::HTTPConflict\n abort EnvironmentExists.new(env.name)\n end", "def temp_key_file(resource, logger)\n file = Tempfile.new('apt_key')\n begin\n file.write resource[:content]\n file.close\n if name.size == 40\n if File.executable? command(:gpg)\n extracted_key = execute([\"#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'\"], :failonfail => false)\n extracted_key = extracted_key.chomp\n\n unless extracted_key.match(/^#{name}$/)\n logger.fail(\"The id in your manifest #{resource[:id]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.\")\n end\n else\n logger.warning('/usr/bin/gpg cannot be found for verification of the id.')\n end\n end\n yield file.path\n ensure\n file.close\n file.unlink\n end\n end", "def new_load_schedule\n @worker_method_triggers = { }\n @my_schedule.each do |key,value|\n case value[:trigger_args]\n when String\n cron_args = value[:trigger_args] || \"0 0 0 0 0\"\n trigger = BackgrounDRb::CronTrigger.new(cron_args)\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n when Hash\n trigger = BackgrounDRb::Trigger.new(value[:trigger_args])\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:trigger_args][:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n end\n end\n end", "def initialize(hash_or_file = self.class.source, section = nil)\n #puts \"new! #{hash_or_file}\"\n case hash_or_file\n when nil\n raise Errno::ENOENT, \"No file specified as Settingslogic source\"\n when Hash\n self.replace hash_or_file\n else\n file_contents = open(hash_or_file).read\n hash = file_contents.empty? ? {} : YAML.load(ERB.new(file_contents).result).to_hash\n if self.class.namespace\n hash = hash[self.class.namespace] or return missing_key(\"Missing setting '#{self.class.namespace}' in #{hash_or_file}\")\n end\n self.replace hash\n end\n @section = section || self.class.source # so end of error says \"in application.yml\"\n create_accessors!\n end", "def find_and_update_task_snapshot(previous_file_hash, new_file_hash)\n ::Snapshot.find_each do |snapshot|\n child = find_child_with_file_hash previous_file_hash, snapshot.contents\n if child\n # update snapshot to use new_file_hash instead of the previous_file_hash\n child['value'] = new_file_hash\n\n # we're updating the internals contents of the snaphot above so\n # be sure to save the snapshot\n snapshot.save!\n end\n end\n end", "def create\n \n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n @entry = Entry.find(params[:id])\n @evaluation = @entry.evaluations.find_by(school_num:params[:evaluation][:school_num])\n success_flag = true\n begin \n if(@evaluation == nil)then\n \n @evaluation = Evaluation.create(evaluation_params)\n @entry.evaluations<<@evaluation\n else\n success_flag = @evaluation.update(evaluation_params)\n end\n rescue\n success_flag = false\n end\n\n if @evaluation.id == nil\n # @evaluation = Evaluation.new\n success_flag = false\n end\n respond_to do |format|\n if success_flag == true\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { redirect_to \"/evaluations/\"+params[:id].to_s + \"/new\", json: @evaluation.errors}\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_entry(key, key_hash, value)\n if key.kind_of?(String) and !key.frozen?\n key = key.dup\n key.freeze\n end\n\n @size += 1\n Entry.new key, key_hash, value\n end", "def buildDfMapFromFile(filepath,lineproc,useTermRoot=false)\n map = Hash.new\n IO.foreach(filepath) do |line|\n lineproc.call line,map,useTermRoot\n end\n map\n end", "def run(&block)\n File.readlines(@path).each do |line|\n next if line =~ /\\s*#/ || line !~ /\\S/\n line = line.strip\n key, val = line.split(/\\s+/, 2)\n\n if key && key.size > 0\n block.call(key, val)\n end\n end\n end", "def rakefile(filename, data=nil, &block)\n puts \"adding rakefile #{filename}\"\n in_root(\"lib/tasks\") do |folder|\n File.open(\"#{folder}/#{filename}\", \"w\") do |f|\n if block_given?\n f.write(code_for(block))\n else\n f.write(data)\n end\n end\n end\n end", "def generateRakeFor_CalibrateRecordings\n if (!@Context[:RakeSetupFor_CleanRecordings])\n generateRakeFor_CleanRecordings\n end\n\n # List of calibrating tasks\n # list< Symbol >\n lLstCalibrateTasks = []\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n # Generate analysis files for calibration files\n @Context[:EnvsToCalibrate].each do |iEnvToCalibratePair, iNil|\n [\n [ iEnvToCalibratePair[0], iEnvToCalibratePair[1] ],\n [ iEnvToCalibratePair[1], iEnvToCalibratePair[0] ]\n ].each do |iEnvPair|\n iEnv1, iEnv2 = iEnvPair\n lCalibrationFileName = getRecordedCalibrationFileName(iEnv1, iEnv2)\n lNoiseGatedFileName = @Context[:CleanFiles][File.basename(lCalibrationFileName)[0..-5]][:NoiseGatedFileName]\n lAnalysisFileName = getRecordedAnalysisFileName(File.basename(lNoiseGatedFileName)[0..-5])\n @Context[:CalibrationAnalysisFiles][iEnvPair] = lAnalysisFileName\n\n desc \"Generate analysis for framed calibration file #{lNoiseGatedFileName}\"\n file lAnalysisFileName => lNoiseGatedFileName do |iTask|\n analyzeFile(iTask.prerequisites[0], iTask.name)\n end\n\n end\n end\n\n # Generate calibrated files\n lTracksConf.each do |iLstTracks, iRecordingConf|\n if (iRecordingConf[:CalibrateWithEnv] != nil)\n # Need calibration\n lRecEnv = iRecordingConf[:Env]\n lRefEnv = iRecordingConf[:CalibrateWithEnv]\n lRecordedBaseName = File.basename(getRecordedFileName(lRecEnv, iLstTracks))[0..-5]\n # Create the data target that stores the comparison of analysis files for calibration\n lCalibrationInfoTarget = \"#{lRecordedBaseName}.Calibration.info\".to_sym\n\n desc \"Compare the analysis of calibration files for recording #{lRecordedBaseName}\"\n task lCalibrationInfoTarget => [\n @Context[:CalibrationAnalysisFiles][[lRefEnv,lRecEnv]],\n @Context[:CalibrationAnalysisFiles][[lRecEnv,lRefEnv]]\n ] do |iTask|\n iRecordingCalibrationAnalysisFileName, iReferenceCalibrationAnalysisFileName = iTask.prerequisites\n # Compute the distance between the 2 average RMS values\n lRMSReference = getRMSValue(iReferenceCalibrationAnalysisFileName)\n lRMSRecording = getRMSValue(iRecordingCalibrationAnalysisFileName)\n log_info \"Reference environment #{lRefEnv} - RMS: #{lRMSReference}\"\n log_info \"Recording environment #{lRecEnv} - RMS: #{lRMSRecording}\"\n iTask.data = {\n :RMSReference => lRMSReference,\n :RMSRecording => lRMSRecording,\n :MaxValue => getAnalysis(iRecordingCalibrationAnalysisFileName)[:MinPossibleValue].abs\n }\n end\n\n # Create the dependency task\n lDependenciesTask = \"Dependencies_Calibration_#{lRecordedBaseName}\".to_sym\n\n desc \"Compute dependencies to know if we need to calibrate tracks [#{iLstTracks.join(', ')}] recording.\"\n task lDependenciesTask => lCalibrationInfoTarget do |iTask|\n lCalibrationInfo = Rake::Task[iTask.prerequisites.first].data\n # If the RMS values are different, we need to generate the calibrated file\n lRecordedBaseName2 = iTask.name.match(/^Dependencies_Calibration_(.*)$/)[1]\n lCalibrateContext = @Context[:Calibrate][lRecordedBaseName2]\n lLstPrerequisitesFinalTask = [iTask.name]\n if (lCalibrationInfo[:RMSRecording] != lCalibrationInfo[:RMSReference])\n # Make the final task depend on the calibrated file\n lLstPrerequisitesFinalTask << lCalibrateContext[:CalibratedFileName]\n # Create the target that will generate the calibrated file.\n\n desc \"Generate calibrated recording for #{lRecordedBaseName2}\"\n file @Context[:Calibrate][lRecordedBaseName2][:CalibratedFileName] => [\n @Context[:CleanFiles][lRecordedBaseName2][:NoiseGatedFileName],\n lCalibrationInfoTarget\n ] do |iTask2|\n iRecordedFileName, iCalibrationInfoTarget = iTask2.prerequisites\n lCalibrationInfo = Rake::Task[iCalibrationInfoTarget].data\n # If the Recording is louder, apply a volume reduction\n if (lCalibrationInfo[:RMSRecording] < lCalibrationInfo[:RMSReference])\n # Here we are loosing quality: we need to increase the recording volume.\n # Notify the user about it.\n lDBValue, lPCValue = val2db(lCalibrationInfo[:RMSReference]-lCalibrationInfo[:RMSRecording], lCalibrationInfo[:MaxValue])\n log_warn \"Tracks [#{iLstTracks.join(', ')}] should be recorded louder (at least #{lDBValue} db <=> #{lPCValue} %).\"\n end\n wsk(iRecordedFileName, iTask2.name, 'Multiply', \"--coeff \\\"#{lCalibrationInfo[:RMSReference]}/#{lCalibrationInfo[:RMSRecording]}\\\"\")\n end\n\n end\n Rake::Task[lCalibrateContext[:FinalTask]].prerequisites.replace(lLstPrerequisitesFinalTask)\n end\n\n # Make the final task depend on this dependency task\n lCalibrateFinalTask = \"Calibrate_#{iLstTracks.join('_')}\".to_sym\n lLstCalibrateTasks << lCalibrateFinalTask\n @Context[:Calibrate][lRecordedBaseName] = {\n :FinalTask => lCalibrateFinalTask,\n :CalibratedFileName => getCalibratedFileName(lRecordedBaseName)\n }\n\n desc \"Calibrate tracks [#{iLstTracks.join(', ')}] recording.\"\n task lCalibrateFinalTask => lDependenciesTask\n\n end\n end\n\n end\n end\n # Generate global task\n\n desc 'Calibrate recordings needing it'\n task :CalibrateRecordings => lLstCalibrateTasks\n\n @Context[:RakeSetupFor_CalibrateRecordings] = true\n end", "def build_entry(type, index, path, left_entry = nil)\n if type == :folder then\n entry = FileSystem::Folder.new(index, path, left_entry)\n else\n entry = FileSystem::FileEntry.new(index, path, left_entry)\n end\n\n entry.original_created_datetime = get_creation_timestamp(path)\n entry.original_modified_datetime = get_modification_timestamp(path)\n entry\n end", "def initialize(key, data_file_name)\n # Get a handle on the file.\n data_file = Pathname.new(__FILE__).dirname + 'data' + data_file_name.to_s\n raise ArgumentError, \"No such file #{data_file.to_s}\" unless data_file.exist?\n\n # Parse\n @data = case data_file.extname\n when '.json'\n JSON.parse( data_file.read, :symbolize_names => true )\n else\n raise ArgumentError \"Cannot parse files of type #{data_file.extname}\"\n end\n\n # Set key and freeze\n @key = key.freeze\n @data.freeze\n end", "def assign_factory(key, factory); @assigned_factories[key] = factory; end", "def [](task_name, scopes=nil)\n task_name = task_name.to_s\n self.lookup(task_name, scopes) or\n enhance_with_matching_rule(task_name) or\n synthesize_file_task(task_name) or\n fail generate_message_for_undefined_task(task_name)\n end", "def build_rake_step\n @rake_task << self.global_config # Open the rake Stek and get General Configuration information\n @rake_task << (self.render self.get_config_template) # get Specific Configuration. Defined in the [tool].rb module file (erb)\n @opt_parser.check_error # stop here if errors found in the configuration\n @rake_task << self.test_validation # step is already done ? Defined in the tool_template.rb file\n @rake_task << (self.render self.tool_template) # get specific Task Code. Defined in the [tool].rb module file (erb)\n @rake_task << self.write_validation # write the check file Defined in the tool_template.rb file\n @rake_task << self.close_step # To close the rake Step Defined in the tool_template.rb file\n end", "def create_todo_hash_from_file(filename)\n todo = Hash.new()\n\n todo['filename'] = filename\n\n file_path = TODOS_DIRECTORY + '/' + filename\n lines = File.read(file_path).split(\"\\n\")\n\n read_mode = 'not_body'\n todo['body'] = ''\n\n for line in lines\n if line.empty?\n next\n elsif line.include?(': ')\n key_and_value = line.split(': ')\n key = key_and_value[0]\n value = key_and_value[1]\n\n if key == 'title'\n todo['title'] = value\n elsif key == 'status'\n todo['status'] = value\n end\n\n elsif line == '---'\n # Once we hit the triple-dashes, that means the rest of the file\n # is the body of the item.\n read_mode = 'body'\n\n elsif read_mode == 'body'\n todo['body'] += line + \"\\n\"\n end\n end\n\n if !todo.has_key?('status')\n # The default status is 'pending'.\n todo['status'] = 'pending'\n end\n\n return todo\nend", "def get_ctime(folder,hash)\n \n \n hash['job_date']=File.ctime(folder).strftime('%d/%m/%y')\n\n\nend", "def filekey(value)\n merge(filekey: value.to_s)\n end", "def makeEntry(hash, e)\n hash[e.id] = {\n name: e.public_name,\n createTimestamp: e.createTimestamp,\n }\n if e.banned?\n hash[e.id][:noLogin] = true\n else\n # Don't publish urls for banned logins\n unless e.urls.empty?\n # need to sort to avoid random changes which seem to occur for urls\n hash[e.id][:urls] = e.urls.sort\n end\n # only add entry if there is a fingerprint\n unless e.pgp_key_fingerprints.empty?\n # need to sort to avoid random changes which seem to occur for fingerprints\n hash[e.id][:key_fingerprints] = e.pgp_key_fingerprints.sort\n end\n end\nend", "def write(key, value)\n paths = ::File.split(full_key(key))\n FileUtils.mkdir_p(paths.first) unless ::File.directory?(paths.first)\n f = ::File.open(full_key(key), 'w') {|f| f.write(value) }\n end", "def initialize name\n\t\t\t@tasks = Hash.new\n\t\t\t@completed_tasks = Hash.new\n\t\t\t@count = 0\n\t\t\t@completed_count = 0\n\t\t\t@name = name\n\t\t\tif !File.exists? Config[:lists_directory]\n\t\t\t\tDir.mkdir(Config[:lists_directory])\n\t\t\tend\n\t\t\tupdate\n\t\t\tConfig[:working_list_name] = name.downcase.gsub(/ /, '_')\n\t\t\tConfig[:working_list_exists] = true\n\t\t\tConfig.write\n\t\t\tputs \"Created List #{name}.\"\n\t\tend", "def create\n file = stocked_file_create_params[:filedata]\n hash_key = Digest::MD5.hexdigest(file.original_filename + Time.now.to_s)\n while StockedFile.where(hash_key: hash_key).count > 0\n hash_key = Digest::MD5.hexdigest(Random.rand.to_s)\n end\n File.open(get_file_path(hash_key), \"wb\") { |f|\n f.write(file.read)\n }\n @stocked_file = StockedFile.new({\n original_name: file.original_filename,\n hash_key: hash_key,\n size: file.size\n })\n\n respond_to do |format|\n if @stocked_file.save\n format.html { redirect_to @stocked_file, notice: 'Stocked file was successfully created.' }\n format.json { render :show, status: :created, location: @stocked_file }\n format.txt { render plain: get_url(hash_key) }\n else\n format.html { render :new }\n format.json { render json: @stocked_file.errors, status: :unprocessable_entity }\n format.txt { render plain: \"error\" }\n end\n end\n end", "def initialize(key, filename, content)\n @key = key\n @filename = filename\n @content = content\n end", "def running_new\n entry = Entry.new\n entry.reference = \"\"\n entry.user = current_user\n entry.set_property(\"entrydate\", params[:data][:StartTime])\n entry.set_property(\"entrylocation\", params[:data][:location])\n entry.set_property(\"comment\", params[:data][:comment])\n entry.set_property(\"publicvisible\", 2)\n entry.set_property(\"courselength\", params[:data][:courselength])\n entry.set_property(\"coursetype\", params[:data][:coursetype])\n entry.public_visible = 2\n\n base_new(params, \"Running\", entry)\n end", "def load_results(key, force = false)\n @log_step = key\n file_path = results_file_path(key)\n print \"Loading results from #{file_path}... \"\n if File.exist?(file_path)\n if force\n puts \"force reload requested.\\nForcing regeneration of #{key.to_s} results to #{file_path}...\"\n return generate_results!(key)\n end\n @results = YAML::load(File.open(file_path))\n puts \"done.\"\n puts \"Read #{@results.size} results from #{File.mtime(file_path).to_s(:long)}\"\n else\n puts \"not found.\"\n @log_step = key\n generate_results!(key)\n end\n end", "def initialize(file_name)\n create(file_name)\n end", "def load_launcher_data launcher_data_file=\"bin/LAUNCHER_TYPE\"\n launcher_data = nil\n\n begin\n File.open launcher_data_file do |f|\n launcher_data = YAML.load(f.read)\n end\n rescue Errno::ENOENT\n end\n\n return {'launcher_main' => 'org.jruby.Main'}\nend", "def store(key, value)\n filename = File.join(dir, key)\n File.write(filename, value)\n filename\n end", "def create_if_not_exists\n args = [\n [available_list_key(), taken_hash_key(), created_at_key()],\n [@resource_count, @expiration, Time.now.to_f()]\n ]\n $redis.eval(create_script(), *args)\n end", "def call_create_filename_for_metric(filename)\n Class.new.extend(\n NewRelic::Agent::Instrumentation::Tilt\n ).create_filename_for_metric(\n filename\n )\n end", "def new_worker(opts={})\n @mutex.synchronize {\n job_key = opts[:job_key] || gen_key\n unless self[job_key]\n self[job_key] = instantiate_worker(opts[:class]).new(opts[:args])\n return job_key\n else\n raise ::BackgrounDRbDuplicateKeyError\n end \n }\n end", "def file_action(do_action, registry_data)\n file_hash = registry_data.new_hash\n chef_server = Cheffish.default_chef_server\n log_info \"file_hash New #{file_hash}\"\n registry_spec = Chef::Provisioning::Registry::ChefRegistrySpec.new(file_hash, chef_server)\n registry_spec.registry_machine_path = registry_machine_file_path\n # registry_spec.save(action_handler) if (save_to_data_bag? && new_resource.save_to_file)\n # registry_spec.save_data_bag(action_handler) if (save_to_data_bag? && !new_resource.save_to_file)\n registry_spec.save_file(action_handler) # if (!save_to_data_bag? && new_resource.save_to_file)\n log_info \"Registry Spec New #{registry_spec.registry_data}\"\n end", "def update\n return unless @hash\n begin\n lockf = File.open(@path+\".lock\", File::CREAT|File::RDWR, 0600)\n lockf.flock File::LOCK_EX\n f = File.open(@path+\".new\", File::CREAT|File::TRUNC|File::WRONLY, 0600)\n for k,v in @hash\n f.printf \"%s=%s\\n\", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))\n end\n f.close\n File.rename @path+\".new\", @path\n ensure\n f&.close\n lockf&.close\n end\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def create_hash(doc, check_usable_entries = false)\n ccr_patient = {}\n @section_importers.each_pair do |section, importer|\n importer.check_for_usable = check_usable_entries\n ccr_patient[section] = importer.create_entries(doc)\n end\n ccr_patient\n end", "def load_old_ratings\n return @old_ratings_cache if @old_ratings_cache\n hash = YAML.load(File.read(File.expand_path('../factories/old_ratings.yml', __FILE__)))\n @old_ratings_cache = hash.keys.inject({}) do |memo, icu_id|\n data = hash[icu_id]\n memo[icu_id] = FactoryGirl.create(:old_rating, icu_id: icu_id, rating: data[0], games: data[1], full: data[2])\n memo\n end\nend", "def build_hash hash, date, worked_hours, departur_hour\n hash[\"#{date.strftime(\"%F\")}\"] = {total: worked_hours, arrival_hour: date, departur_hour: departur_hour}\n hash[:total_worked] += worked_hours\n hash[:total_days] += 1\n return hash\n end", "def create(framework_name)\n results = Hash[:framework => framework_name, :directories => [],\n :files => [], :rakefile => 'Rakefile']\n\n dir = File.join(File.dirname(File.expand_path(__FILE__)), 'generators', framework_name)\n Dir.chdir dir\n Dir[\"**/*\"].each do |f|\n results[:files].push f unless f == 'Rakefile' or File.directory? f \n results[:directories].push f if File.directory? f\n end\n\n results\n end", "def build_index(&key_builder)\n hashes = Hash.new { |h, k| h[k] = [] }\n keys = {}\n pos = 0\n\n @logger.fine('Generating hash...')\n @data.seek(0)\n @data.each_line do |line|\n key = key_builder.call(line)\n raise IndexError.new(\"Key '#{key}' already mapped\") if keys.has_key?(key)\n\n keys[key] = true\n hash = get_hash(key)\n hashes[hash] << [key, pos]\n pos = @data.pos\n end\n\n # Generate the index files now.\n @logger.fine('Constructing index...')\n FileUtils.rm_r(@index_folder) if File.exist?(@index_folder)\n FileUtils.mkdir(@index_folder)\n hashes.each_pair do |hash, data|\n data = data.sort { |d1, d2| d1[0] <=> d2[0] }\n path = File.join(@index_folder, \"#{hash}.index\")\n File.open(path, 'wb') do |f|\n write_int(@data_timestamp, f) # The timestamp for this index file.\n data.each { |key, offset| f.write([key, offset].pack('Z*L')) } # The keys mapped to this index file.\n end\n end\n\n nil\n end", "def classify_key(data, filename); end", "def create_file_from_url_through_valkyrie(env, uri, file_name, auth_header)\n import_url = URI.decode_www_form_component(uri.to_s)\n fs = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url: import_url, label: file_name))\n actor = Hyrax::Actors::FileSetActor.new(fs, env.user, use_valkyrie: true)\n actor.create_metadata(visibility: env.curation_concern.visibility)\n actor.attach_to_work(env.curation_concern)\n if uri.scheme == 'file'\n # Turn any %20 into spaces.\n file_path = CGI.unescape(uri.path)\n IngestLocalFileJob.perform_later(fs, file_path, env.user)\n else\n ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)\n end\n end" ]
[ "0.5577767", "0.5351596", "0.5329253", "0.52678347", "0.52233684", "0.51036537", "0.50883424", "0.50806445", "0.5062501", "0.5035023", "0.5030743", "0.498997", "0.49843746", "0.49692017", "0.49168378", "0.48808083", "0.48577598", "0.484553", "0.48387918", "0.48206738", "0.48155725", "0.47916794", "0.47704798", "0.4756059", "0.47498044", "0.4740146", "0.4732366", "0.47309884", "0.47166166", "0.47163987", "0.47163987", "0.4680829", "0.46799064", "0.4669586", "0.4662231", "0.46525684", "0.46485588", "0.46288007", "0.46279076", "0.4622942", "0.46194986", "0.4612781", "0.46036938", "0.45997056", "0.45923164", "0.45914903", "0.45901406", "0.45835325", "0.4579928", "0.45795915", "0.45715183", "0.45431057", "0.45423713", "0.45407394", "0.45373964", "0.4523095", "0.45156848", "0.45108214", "0.45013565", "0.44981152", "0.44935328", "0.44858527", "0.44833994", "0.44762012", "0.44637564", "0.44627067", "0.4441242", "0.44393405", "0.4438835", "0.44374606", "0.44239396", "0.44222316", "0.4422171", "0.44221258", "0.44216725", "0.44156477", "0.44152623", "0.44112074", "0.44108945", "0.44016504", "0.4401063", "0.4400211", "0.43949848", "0.4394123", "0.43928307", "0.43916106", "0.43888432", "0.43854514", "0.43851194", "0.438165", "0.43807858", "0.43799874", "0.4378645", "0.4377657", "0.437416", "0.4373313", "0.43721026", "0.43720096", "0.43643242", "0.43636608" ]
0.48441526
18
Return all of the tasks that should be run: No duplicates, no tasks that have previously been run successfully.
def all_tasks_to_run self.all_tasks - all_tasks_previously_run - all_tasks_duplicates end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def incomplete_tasks\n\t\ttasks.select{ |t| !t.completed? }\n\tend", "def failed_tasks\n each_task.select do |task|\n task.status == :failed\n end\n end", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def active_tasks(tasks)\n tasks.select { |task| task.completed_at.nil? }\n end", "def all_tasks\n @all_tasks ||= []\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def tasks_list\n (self.tasks || EMPTY_STRING).scan(/\\d+/).map{|x| x.to_i}.sort.uniq\n end", "def done\n done_ids = @tasks.keys.find_all do |id|\n @tasks[id].done?\n end\n done_tasks = done_ids.inject({}) do |map, id|\n map[id] = @tasks[id]\n map\n end\n done_ids.each do |id|\n @tasks.delete(id)\n end\n return done_tasks\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def failed_tasks\n @failed_tasks ||= @tasks_results.select(&:failure?)\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end", "def complete_tasks\n sublist { |task| task.complete? }.sort_by { |task| task.completed_at }\n end", "def active_tasks\n @tasks.select { | task | task.active }\n end", "def complete_tasks\n # Give me all the tasks such that the task is complete\n # results = @tasks.select { |task| task.complete? }\n # results.sort_by { |task| task.completed_at }\n #\n # We can combine this into a single line\n \n @tasks.select { |task| task.complete? }.sort_by { |task| task.completed_at }\n end", "def incomplete_tasks\n sublist { |task| task.incomplete? }.sort_by { |task| task.created_at }\n end", "def incomplete_tasks\n # Give me all the tasks such that the task is incomplete\n @tasks.select { |task| task.incomplete? }.sort_by { |task| task.created_at }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def all\n return @tasks\n end", "def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end", "def next_tasks\n\t\tincomplete_tasks.select{ |t| !t.blocked? }\n\tend", "def get_sorted_list_of_tasks\r\n tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :active_task => true})\r\n unstarted_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :started_at => nil}).sort_by {|t| t.created_at}\r\n finished_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => true}).sort_by {|t| t.created_at}\r\n\r\n tasks.concat(unstarted_tasks).concat(finished_tasks)\r\n return tasks\r\n end", "def print_all_tasks\n tasks = retrieve_tasks\n @values[:result] = Array.new()\n tasks.each_key { |key|\n print_tasks_to_key(tasks[key]) if (tasks[key].size > 0)\n }\n end", "def all_complete\n self.tasks.count == self.tasks.done.count\n end", "def incoming_task_runs\n TapirLogger.instance.log \"Finding task runs for #{self}\"\n incoming_task_runs = []\n\n self.entity_mappings.each do |mapping|\n incoming_task_runs << mapping.get_task_run if mapping.get_child == self\n end\n incoming_task_runs\n end", "def final_completed_tasks\n self.tasks.order(\"created_at DESC\").group_by {|t| t.id }.map { |k, v| v.first }\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def empty?; tasks.empty? end", "def all_tasks\n self.stories.collect { |s| s.tasks }.flatten\n end", "def completed_tasks\n self.tasks.where('is_completed =?', is_completed = true)\n end", "def filter_by_tags(tasks)\n return tasks if !filtering_by_tags?\n\n res = []\n tasks.each do |task|\n selected_tags.each do |tag|\n res << task if task.has_tag?(tag)\n end\n end\n \n return res.uniq\n end", "def get_tasks_from_todoist\n return Todoist::Task.uncompleted(PROGRAMMING_PROJECT_ID)\n end", "def tasks\n @tasks.values.sort_by { |t| t.name }\n end", "def get_tasks\n\n\ttasks = Task.all.shuffle\n\n\treturned_tasks = []\n\trand(10..18).times do\n\t\treturned_tasks << tasks.pop\n\tend\n\n\treturned_tasks\nend", "def failed_tasks\n return @failed_tasks\n end", "def failed_tasks\n return @failed_tasks\n end", "def tasks() []; end", "def work_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_worker, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def inactive_tasks\n @tasks.select { | task | ! task.active }\n end", "def tasks\n return @tasks.values\n end", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def tasks\n @tasks ||= Task.find(self.task_ids)\n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def tasks\n task_list.tasks\n end", "def all_by_exit_status(status)\n\ta = Array.new\n\t@taskchain.taskchain_array.each do |task|\n\t\ta << task if task.exit_status == status\n end\n return a\nend", "def unread_tasks\n notifications = current_user.notifications.unread\n notifications += current_user.task_owners.unread\n \n tasks = notifications.map { |n| n.task }\n tasks = tasks.uniq\n # only get open / in progress tasks\n tasks = tasks.select { |t| (t.status == 0 or t.status == 1) }\n\n return tasks\n end", "def find_tasks_without_specs\n task_file_names.reject do |manifest|\n spec = Noop::Utils.convert_to_spec manifest\n spec_file_names.include? spec\n end\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def determine_visible_tasks\n [root_task] + determine_visible_subtasks(root_task)\n end", "def starting_tasks\n each_task.reject do |task|\n task.dependency_backward_any?\n end\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def all_by_exit_status(status)\n\ta = Array.new\n\t@chain.taskchain_array.each do |task|\n\t\ta << task if task.exit_status == status\n end\n return a\nend", "def all_not_done\n self.select { |todo| !todo.done? }\n end", "def tasks\n\t\t@tasks ||= if self.id.nil?\n\t\t\t[]\n\t\telse\n\t\t\tt_arr = document.tasks.select(container_id: self.id)\n\t\t\ti = 0\n\t\t\twhile i < t_arr.size\n\t\t\t\ttask = t_arr[i]\n\t\t\t\tif task.has_subtasks?\n\t\t\t\t\tt_arr += t_arr.delete_at(i).tasks\n\t\t\t\telse\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tt_arr\n\t\tend\n\tend", "def check_tasks\n if !(@free_workers.empty? || @tasks_to_assign.empty?)\n @free_workers.each { |worker| find_task_for(worker) }\n end\n end", "def tasks\n colocated_tasks_grouped = ColocatedTask.where(assigned_by: user).group_by(&:appeal_id)\n on_hold_legacy_tasks = colocated_tasks_grouped.each_with_object([]) do |(_k, value), result|\n # Attorneys can assign multiple admin actions per appeal, we assume a case is still on hold\n # if not all admin actions are completed\n next if value.map(&:status).uniq == [Constants.TASK_STATUSES.completed]\n result << value.each do |record|\n record.placed_on_hold_at = record.assigned_at\n record.status = Constants.TASK_STATUSES.on_hold\n end\n result\n end\n ama_tasks = Task.incomplete_or_recently_completed\n .where(assigned_to: user, type: [AttorneyTask.name, QualityReviewTask.name])\n (on_hold_legacy_tasks + ama_tasks).flatten\n end", "def run!(*tasks_to_run)\n tasks_to_run.flatten!\n\n tasks_to_run.map! do |ttr| \n unless ret = self.__tasks.find {|t| t.__name == ttr } \n seq = self.__sequences.find {|t| t.__name == ttr }\n ret = seq.__task_names.map {|tn| self.__tasks.find {|t| t.__name == tn }}.compact if seq\n end\n ret\n end\n tasks_to_run.flatten!\n tasks_to_run.compact!\n\n ret = []\n tasks_to_run.each do |task|\n ret << task.__build_commands(self.__tasks)\n Runner.execute!(:task => task, :tasks => self.__tasks, :servers => self.__servers, :silent => self.__options[:silent], :verbose => self.__options[:verbose])\n end\n\n $stdout << \"\\033[0m\"\n ret.flatten # return this for tests\n end", "def unassigned_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).unassigned\n end\n output\n end", "def set_and_log_duplicate_tasks(evaluated_tasks)\n\n return [] if evaluated_tasks.empty?\n\n # get all of the task_names that are duplicates (TODO ruby 2.7: replace this with .tally)\n duplicated_names = evaluated_tasks.group_by(&:name).select { |_name, tasks | tasks.size > 1 }.keys\n\n # Guard condition: no duplicate names, so just return\n return [] if duplicated_names.empty?\n\n # get the duplicated tasks for each name; return all of them\n duplicated_names.map{|dup_name| duplicated_tasks_for_name(dup_name, evaluated_tasks) }.flatten\n end", "def tasks_for_timeline\n tasks.where(status: Constants.TASK_STATUSES.completed).order(\"completed_at DESC\")\n .reject { |t| t.assigned_to.is_a?(Organization) && t.children.pluck(:assigned_to_type).include?(User.name) }\n end", "def tasks_all(parameters={ })\n parameters[:conditions]=conditions(parameters[:conditions])\n parameters[:include]= to_include + (parameters[:include]||[])\n return user.company.tasks.all(parameters)\n end", "def run_list\n groups = run_list_groups\n [ groups[:first], groups[:normal], groups[:last] ].flatten.compact.uniq\n end", "def successful_task_attempts\n OneTimeTasker::SuccessfulTaskAttempt.all\n end", "def validate_tasks(options)\n tasks = []\n\n instances = base_class.where(:id => options[:ids]).order(Arel.sql(\"lower(name)\")).to_a\n return instances, tasks unless options[:invoke_by] == :task # jobs will be used instead of tasks for feedback\n\n instances.each do |instance|\n # create a task for each instance\n task = MiqTask.create(:name => \"#{instance.name}: '#{options[:task]}'\", :userid => options[:userid])\n tasks.push(task)\n\n validate_task(task, instance, options)\n end\n return instances, tasks\n end", "def tasks\n @tasks ||= {}\n end", "def tasks_have_failed?\n return true if @tasks_have_failed\n failed = select do |task|\n task.failed?\n end\n if failed.any?\n debug \"Found failed tasks: #{failed.map { |t| t.name }.join ', '}\"\n @tasks_have_failed = true\n end\n failed.any?\n end", "def filter_tasks(cards)\n cards = Array(cards) unless cards.respond_to?(:count)\n return cards.select { |card| Task.first(:name => card.name).nil? } #TODO: move this to method with descriptive name\n end", "def non_completed_task_ids\n\n # Define a range over the first task to the last task\n first_task = lesson.tasks.first.id\n last_task = lesson.tasks.last.id\n lesson_task_ids = (first_task..last_task).to_a\n\n # Non completed tasks are the difference between all task id's and the completed tasks\n return lesson_task_ids - completed_task_ids\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def running\n tasks.detect {|task| task.running? }\n end", "def task_names\n map do |task|\n task.name\n end\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def validate_tasks(options)\n tasks = []\n\n instances = base_class.where(:id => options[:ids]).order(\"lower(name)\").to_a\n return instances, tasks unless options[:invoke_by] == :task # jobs will be used instead of tasks for feedback\n\n instances.each do |instance|\n # create a task for each instance\n task = MiqTask.create(:name => \"#{instance.name}: '#{options[:task]}'\", :userid => options[:userid])\n tasks.push(task)\n\n validate_task(task, instance, options)\n end\n return instances, tasks\n end", "def task_list\n self.tasks.map do |task|\n task.text\n end\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def execution_error_tasks\n @execution_error_tasks ||= failed_tasks.select(&:execution_error?)\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend", "def parent_tasks\n EarLogger.instance.log \"Finding task runs for #{self}\"\n ObjectManager.instance.find_task_runs(self.id, self.class.to_s)\n end", "def set_and_log_tasks_already_ran(evaluated_tasks)\n return [] if evaluated_tasks.empty?\n\n already_ran = []\n\n evaluated_tasks.each do |evaluated_task|\n successful_attempt = find_successful_attempt_for_task(evaluated_task)\n already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt\n end\n\n already_ran\n end", "def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end", "def active_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).active\n end\n output\n end", "def all_done\n self.select { |todo| todo.done? }\n end", "def execute_task_tests\n # Run all tasks tests (ensuring we capture any changes in the sites we are monitoring)\n test_results = @tasks_by_job_ids.values.map {|task|\n puts \"- Running test for task: #{task.class.name}\" \n if task.respond_to?(:test)\n begin\n result = task.test()\n if result.kind_of?(Array) && result.length > 0\n # Log the error for the result\n @task_test_results_logger.error(\"FAILURE:#{result.inspect}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, result)\n end\n rescue Exception => e\n # Log the error for the result\n @task_test_results_logger.error(\"ERROR:#{e.backtrace}\")\n # Send an email with the failure information\n Notifier.deliver_crawler_error(\"christkv@gmail.com\", task.class.name, [e.backtrace.inspect])\n end\n end\n }\n # return the test results\n return test_results\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def all_completed_todos\n (global_completed_todos + local_completed_todos).uniq\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def tasks_info\n all_tasks = Set.new\n all_job_info = {}\n history.each_key do |cycle_index|\n tasks, job_info = tasks_info_of_snapshot(cycle_index)\n all_tasks.merge(tasks)\n all_job_info.merge!(job_info)\n end\n [all_tasks, all_job_info]\n end", "def tasks_uncompleted\n tasks_uncompleted = assigned_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted += executed_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted.sort_by { |h| h[:deadline] }.reverse!\n end", "def all_subtasks task\n [task] + task.tasks.get.flatten.map{|t| all_subtasks(t) }\n end", "def query_long_running_tasks\n Kernel.sleep(0.01)\n target_tasks = []\n 100.times.each do\n target_tasks = @tasks.get[\"nodes\"]\n .map { |k, v| v[\"tasks\"] }\n .flatten.map { |ts| ts.select { |k, v| /bulk/ =~ v[\"action\"] } }\n .flatten.reject { |t| t.empty? }\n break if target_tasks.size > 0\n end\n\n target_tasks\nend", "def get_finished\n @task_list.select { |task| task.status == \"finished\" }\n end" ]
[ "0.7313079", "0.71757704", "0.7043827", "0.69873416", "0.695203", "0.69262904", "0.68982226", "0.68448985", "0.677307", "0.6768514", "0.6734776", "0.6730305", "0.67107046", "0.6672557", "0.66699564", "0.66674894", "0.6662218", "0.6659026", "0.66383284", "0.6623067", "0.6621279", "0.6621279", "0.6617529", "0.65296334", "0.6523252", "0.6519861", "0.65177613", "0.6516872", "0.6510211", "0.65039325", "0.64967954", "0.6495066", "0.6487136", "0.64755857", "0.647054", "0.64501315", "0.6428469", "0.6425835", "0.64240384", "0.64240384", "0.64136744", "0.640935", "0.6408857", "0.6398448", "0.6382667", "0.6336938", "0.6334232", "0.63270426", "0.6293781", "0.62499946", "0.62452626", "0.6242146", "0.6239964", "0.62206614", "0.62012184", "0.62012184", "0.62012184", "0.61921024", "0.61906976", "0.6187382", "0.6177126", "0.61751354", "0.6170113", "0.61689633", "0.61513543", "0.61436784", "0.6129338", "0.61145", "0.61139894", "0.6113536", "0.61051446", "0.6104878", "0.61020976", "0.6101275", "0.60847074", "0.60847074", "0.6077923", "0.60688305", "0.60682607", "0.60609597", "0.6058572", "0.60474634", "0.60441744", "0.6043486", "0.6040887", "0.6037261", "0.6036445", "0.6030767", "0.6026643", "0.6019272", "0.6003458", "0.6000178", "0.5999023", "0.5995965", "0.598582", "0.5981597", "0.598157", "0.5967263", "0.596511", "0.59611243" ]
0.8064616
0
All .rake files in the onetime_tasks_path
def onetime_rake_files tasks_dir = self.tasks_directory return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir) Dir.glob(File.join('**', '*.rake'), base: tasks_dir) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def rakefiles\n @rakefiles ||= []\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def tasks_file(name)\n File.expand_path(File.join(@path, %w[ application tasks ], name))\n end", "def rakefile_test_tasks\n ''\n end", "def load_tasks\n RakeLoader.new.load_tasks\n end", "def all_tasks\n @all_tasks ||= []\n end", "def rake_tasks(&block); end", "def rake_tasks(&block); end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end", "def list_available_build_tasks\n cd 'cookbooks/example'\n unset_bundler_env_vars\n run_simple 'bundle exec rake -T'\n end", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def load_tasks\n end", "def list_tasks\n config = instantiate_configuration\n config.load 'deploy'\n \n set_up_config(config)\n \n config.task_list(:all)\n end", "def load_dummy_tasks(app_root)\n @target_extension_path = Pathname.new(app_root.to_s)\n load 'refinery/tasks/testing.rake'\n end", "def tasks\n config[:tasks]\n end", "def tasks_for_all_configurations\n @configurations.keys.collect{ |name| \"#{@project_name}:#{name}\"}\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= []\n @rakefiles += rakefiles\n end", "def displayRakeTasks\n Rake.application.tasks.each do |iTask|\n log_info \"+-#{iTask.name}: #{iTask.comment}\"\n iTask.prerequisites.each do |iPrerequisiteTaskName|\n log_info \"| +-#{iPrerequisiteTaskName}\"\n end\n log_info '|'\n end\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n @rakefiles += rakefiles\n end", "def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them into the Thor::Sandbox namespace\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n if task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile helper: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # Now load the thor files\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n unless task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # load user tasks\n if user_tasks_folder\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\\.rb$/) }\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\\.rb$/) }\n end\n\n @loaded = true\n end", "def tasks\n @tasks ||= Evoke.tasks\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def registered_tasks\n # Get the task folder that contains the tasks.\n taskCollection = root_folder.GetTasks(0)\n array = []\n taskCollection.each do |registeredTask|\n array.push(registeredTask)\n end\n array\n end", "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def all_tasks_to_run\n self.all_tasks - all_tasks_previously_run - all_tasks_duplicates\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def configure_tasks\n end", "def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end", "def rake(*tasks)\n \"rake #{tasks.join(' ')}\"\n end", "def require_tasks system_config\n system_config.gaudi_modules.each do |gm|\n mass_require(Rake::FileList[\"#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb\"])\n end\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n TapirLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def load_tasks(tasks)\n load File.join(File.dirname(__FILE__), 'tasks', \"#{tasks}.rb\")\nend", "def run_all\n run_on_additions(Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq))\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def make_tasks\n make_clean_task\n make_wix_folder_task\n make_copy_file_tasks\n make_sourcery_wxs_file_task\n make_sourcery_wixobj_file_task\n make_product_wxs_file_task\n make_product_wixobj_file_task\n make_msi_file_task\n make_msi_task\n make_test_task\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n EarLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def ensure_tasks_folder\n io.mkdir('.webbynode/tasks') unless io.directory?(\".webbynode/tasks\")\n %w[before_push after_push].each do |file|\n io.exec(\"touch .webbynode/tasks/#{file}\") unless io.file_exists?(\".webbynode/tasks/#{file}\")\n end\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def load_tasks\n return load(evoke_file) if File.file?(evoke_file)\n\n # Load the tasks from the current working directory.\n Evoke.load_tasks('lib/tasks')\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def install_tasks\n load 'falkorlib/tasks/git.rake'\n load 'falkorlib/tasks/gitflow.rake'\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def clear_db_test_tasks\n FileUtils::mkdir_p 'lib/tasks'\n File.open(\"lib/tasks/heroku_clear_tasks.rake\", \"w\") do |file|\n file.puts \"# rubocop:disable all\"\n content = db_test_tasks_to_clear.map do |task_name|\n <<-FILE\nif Rake::Task.task_defined?('#{task_name}')\n Rake::Task['#{task_name}'].clear\n task '#{task_name}' do\n end\nend\nFILE\n end.join(\"\\n\")\n file.print content\n file.puts \"# rubocop:enable all\"\n end\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def tasks_directory\n @cached_paths[:tasks_directory] ||= look_up_configured_path(\n :tasks_directory,\n :defaults => ['tasks']\n )\n end", "def define_clean_tasks\n task :clobber_docs # no-op, just in case\n task :clobber_package # no-op, just in case\n\n desc \"Clean up all the extras.\"\n task :clean => [ :clobber_docs, :clobber_package ] do\n clean_globs.each do |pattern|\n files = Dir[pattern]\n rm_rf files, :verbose => true unless files.empty?\n end\n end\n end", "def invoked_tasks\n @invoked_tasks\n end", "def collect_tasks\n @top_level_tasks = []\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n else\n @top_level_tasks << arg unless arg =~ /^-/\n end\n end\n @top_level_tasks.push(\"default\") if @top_level_tasks.size == 0\n end", "def cron_tasks\n end", "def all_tasks\n self.stories.collect { |s| s.tasks }.flatten\n end", "def all_config_files\n #files = Dir[File.join(path, \"_config.yml\")]\n files = Dir[File.join(path, \"_*.yml\")]\n return files\n end", "def all_template_files\n files = super\n files + Dir.glob(\"#{JenkinsJob.flavor_dir}/templates/**.xml.erb\")\n end", "def all_template_files\n files = super\n files + Dir.glob(\"#{JenkinsJob.flavor_dir}/templates/**.xml.erb\")\n end", "def list_bare_tasks\n load_tasks\n\n Thor::Base.subclasses.each do |klass|\n unless klass == Thor\n klass.tasks.each do |t|\n puts \"#{klass.namespace}:#{t[0]}\"\n end\n end\n end\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def rake\n Dir.chdir @temp_dir\n system(\"rake\")\n end", "def define_tasks\n # Task definitions are taken from Rake::TestTask\n # https://github.com/ruby/rake/blob/e644af3/lib/rake/testtask.rb#L98-L112\n namespace :ttnt do\n namespace name do\n define_run_task\n define_anchor_task\n end\n end\n end", "def build_default_tasks\n @rake_task << self.step_template # get General Configuration information\n end", "def handle_rake_test_task\n test_task = @target\n all_tests = test_task.file_list\n\n @target = test_task.name\n @globs << test_task.file_list\n @options[:force] = true\n\n lambda do |changed|\n tests = all_tests & changed\n\n basenames = (changed - tests).collect do |f|\n File.basename(f).split(\".\").first\n end\n\n tests.concat all_tests.\n select { |t| basenames.any? { |b| t =~ /#{b}/ } }\n\n tests = all_tests.dup if tests.empty?\n\n # Nice API, Rake::TestTask.\n ENV[\"TEST\"] = \"{#{tests.uniq.join(',')}}\"\n end\n end", "def tasks\n task_list.tasks\n end", "def all\n return @tasks\n end", "def run_all\n targets = Watcher.match_files(self, Dir.glob(\"**/*.*\"))\n run_on_changes targets\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def run_all\n run_on_changes(Watcher.match_files(self, Dir.glob('**{,/*/**}/*').uniq.compact))\n end", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def projects\n glob = rakefile_glob || ['*/Rakefile']\n Dir[*glob].map { |rakefile| File.dirname(rakefile) }\n end", "def tasks() []; end", "def tasks\n @tasks ||= {}\n end", "def run_all\n run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def ruby_files\n file_list '**/{*.{rb,rake,gemspec},{Gem,Rake}file,Puppetfile.*}'\n end", "def list_tasks\n load_tasks\n\n # set '$thor_runner' to true to display full namespace\n $thor_runner = true\n\n list = [] #Thor.printable_tasks(all = true, subcommand = true)\n Thor::Base.subclasses.each do |klass|\n list += klass.printable_tasks(false) unless klass == Thor\n end\n list.sort!{ |a,b| a[0] <=> b[0] }\n\n title = \"repo_manager tasks\"\n shell.say shell.set_color(title, :blue, bold=true)\n shell.say \"-\" * title.size\n shell.print_table(list, :ident => 2, :truncate => true)\n end", "def execute_tasks(tasks,template_path)\n \n if File.exists?(File.expand_path(File.join(template_path,'tasks.rb')))\n load File.expand_path(File.join(template_path,'tasks.rb'))\n end\n \n tasks.each{\n |task|\n \n puts 'Running Task: ' + task\n \n task = replace_tags(task);\n \n options = task.split(', ')\n action = options.slice!(0)\n \n if(Tasks.respond_to?(action))\n Tasks.send action, options.join(', ')\n else\n send action, options.join(', ')\n end\n \n }\n \n end", "def file_name\n \"#{task_name}.rake\"\n end", "def define_clean_tasks\n require 'rake/clean'\n end", "def run_all\n #run_on_changes(Watcher.match_files(self, Dir.glob(\"**/*.*\")))\n @builder.notify(true)\n end", "def tasks\n @client.list_tasks(cluster: @cluster, service_name: @name)[0]\n end", "def tasks(wspace=workspace)\n\t\twspace.tasks\n\tend", "def declare_rakefile\n @flavor.class.do_declare_resources do\n # :nocov:\n lazy_vars = Chef::DelayedEvaluator.new do\n { tasks: rake_tasks }\n end\n # :nocov:\n add_templates(%w(Rakefile), :create, variables: lazy_vars)\n end\n end", "def custom_install_tasks_for(a=nil)\n []\n end", "def run_all\n run_on_changes(Watcher.match_files(self, Dir.glob('**{,/*/**}/*.coffee')))\n end", "def load_tasks(tasks_relative_path, options = { task_name: \"\" })\n if defined?(Rake::Task) and not Rake::Task.task_defined?(options[:task_name])\n load File.join(@lib_root, \"tasks\", *Array(tasks_relative_path))\n end\n end" ]
[ "0.76642257", "0.75222826", "0.7440642", "0.730027", "0.72978675", "0.71560735", "0.7070981", "0.67436665", "0.6703166", "0.6613974", "0.6610863", "0.6602038", "0.65127033", "0.65127033", "0.6434379", "0.6431884", "0.6407418", "0.6406959", "0.6332786", "0.6290942", "0.6285782", "0.6279273", "0.62664646", "0.6260985", "0.6243154", "0.62382823", "0.6237836", "0.6234377", "0.6221822", "0.6206305", "0.6206305", "0.6202267", "0.61764693", "0.6138341", "0.61291003", "0.6126038", "0.6125055", "0.61244446", "0.6118563", "0.60955966", "0.60900646", "0.606082", "0.606082", "0.6059099", "0.60532546", "0.6048958", "0.6039017", "0.6039017", "0.60381955", "0.6026268", "0.60215366", "0.60037535", "0.59956247", "0.597054", "0.59521323", "0.59386605", "0.5927313", "0.5921354", "0.59017533", "0.5899983", "0.5884791", "0.5872454", "0.58662593", "0.5865458", "0.58373326", "0.5836971", "0.58333075", "0.58183515", "0.581324", "0.5808849", "0.5808849", "0.5780861", "0.5778037", "0.57722795", "0.57515407", "0.5744589", "0.5735009", "0.5725538", "0.5720066", "0.5716593", "0.570755", "0.56830066", "0.5677745", "0.56738466", "0.5654202", "0.5653101", "0.5639747", "0.5629443", "0.56153756", "0.5609279", "0.5605497", "0.5592784", "0.5586199", "0.558214", "0.5571508", "0.5570436", "0.55678874", "0.5559307", "0.555917", "0.55578953" ]
0.8908357
0
Add a new EvaluatedRakeFile for the rakefilename if we don't already have it. Add all task names to the EvalutedRakeFile that it doesn't already have.
def add_rakefile_and_tasks(rakefilename, task_names) # creates a new EvaluatedRakeFile entry if needed ev_rakefile = self.all_rakefiles[rakefilename] ev_rakefile.add_task_names(task_names) self.all_tasks.concat(ev_rakefile.all_tasks) ev_rakefile end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_eval_task_named(task_name)\n new_ev_task = EvaluatedRakeTask.new(task_name, self.filename)\n add_eval_task(new_ev_task)\n\n new_ev_task\n end", "def rakefiles_with_tasks_to_run\n\n rakefiles_with_tasks = new_hash_of_eval_rakefiles\n\n # This isn't efficient, but it's clear:\n all_tasks_to_run.each do |task_to_run|\n rakefilename = task_to_run.filename\n ev_rakefile_to_run = self.all_rakefiles[rakefilename]\n ev_rakefile_to_run.tasks_to_run << task_to_run\n rakefiles_with_tasks[rakefilename] = ev_rakefile_to_run\n end\n\n rakefiles_with_tasks\n end", "def files_with_tasks_to_run\n\n # load all tasks into self.all_tasks\n get_tasks_from_rakefiles\n\n set_and_log_tasks_already_ran(self.all_tasks)\n set_and_log_duplicate_tasks(self.all_tasks_not_previously_run)\n\n close_log_if_this_created_it(log)\n\n rakefiles_with_tasks_to_run\n\n rescue => error\n log.error(\"Error during #{self.class.name} #{__method__}! #{error}\") unless log.nil?\n raise error\n end", "def all_rakefiles\n @all_rakefiles ||= new_hash_of_eval_rakefiles\n end", "def add_task_names(task_names)\n return if task_names.empty?\n\n missing_task_names = task_names - all_tasks.map(&:name)\n\n missing_task_names.each { |task_name| add_eval_task_named(task_name) }\n\n all_tasks\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n @rakefiles += rakefiles\n end", "def add_rakefiles(*rakefiles)\n @rakefiles ||= []\n @rakefiles += rakefiles\n end", "def add_eval_task(ev_task)\n self.all_tasks << ev_task\n end", "def declare_rakefile\n @flavor.class.do_declare_resources do\n # :nocov:\n lazy_vars = Chef::DelayedEvaluator.new do\n { tasks: rake_tasks }\n end\n # :nocov:\n add_templates(%w(Rakefile), :create, variables: lazy_vars)\n end\n end", "def set_and_log_duplicate_tasks(evaluated_tasks)\n\n return [] if evaluated_tasks.empty?\n\n # get all of the task_names that are duplicates (TODO ruby 2.7: replace this with .tally)\n duplicated_names = evaluated_tasks.group_by(&:name).select { |_name, tasks | tasks.size > 1 }.keys\n\n # Guard condition: no duplicate names, so just return\n return [] if duplicated_names.empty?\n\n # get the duplicated tasks for each name; return all of them\n duplicated_names.map{|dup_name| duplicated_tasks_for_name(dup_name, evaluated_tasks) }.flatten\n end", "def set_and_log_tasks_already_ran(evaluated_tasks)\n return [] if evaluated_tasks.empty?\n\n already_ran = []\n\n evaluated_tasks.each do |evaluated_task|\n successful_attempt = find_successful_attempt_for_task(evaluated_task)\n already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt\n end\n\n already_ran\n end", "def define\n task name do\n if not @unless\n log \"Running task: #{@name}\"\n exectask\n else\n log \"Skipping task: #{@name} due to unless condition specified in rakefile\"\n end\n end\n self\n end", "def evaluate_pre_tasks\n if using_rake? and Pkg::Config.pre_tasks\n unless Pkg::Config.pre_tasks.is_a?(Hash)\n fail \"The 'pre_tasks' key must be a Hash of depender => dependency pairs\"\n end\n Pkg::Config.pre_tasks.each do |depender, dependency|\n add_dependency(depender, dependency)\n end\n end\n end", "def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(another_task_fn)\n\n my_tasks_mine_fn = File.join(base_dir, 'my_tasks_all_mine.rake')\n make_tasks_in_file(['task1', 'task2', 'task3', 'task4'], my_tasks_mine_fn, namespace: 'mine') if ok_to_create?(my_tasks_mine_fn)\n\n tasks_run_all_fn = File.join(base_dir, 'other_tasks_run_all.rake')\n make_tasks_in_file(['other_task1_run_me', 'other_task2_run_me', 'other_task3_run_me', 'other_task_not_run_yet'], tasks_run_all_fn) if ok_to_create?(tasks_run_all_fn)\n\n tasks_mixed_duplicates_fn = File.join(base_dir, 'other_tasks_mixed_duplicates.rake')\n make_tasks_in_file(['other_task2_run_me', 'other_task3_run_me'], tasks_mixed_duplicates_fn) if ok_to_create?(tasks_mixed_duplicates_fn)\n\n task2_duplicate_fn = File.join(base_dir, 'task2_duplicate.rake')\n make_tasks_in_file(['task2'], task2_duplicate_fn, namespace: 'mine') if ok_to_create?(task2_duplicate_fn)\n\n task4_duplicate_fn = File.join(base_dir, 'task4_duplicate.rake')\n make_tasks_in_file(['task4'], task4_duplicate_fn, namespace: 'mine') if ok_to_create?(task4_duplicate_fn)\n end", "def rakefiles\n @rakefiles ||= []\n end", "def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end", "def file_name\n \"#{task_name}.rake\"\n end", "def tasks_file(name)\n File.expand_path(File.join(@path, %w[ application tasks ], name))\n end", "def load(filename, wrap = false)\n if filename == 'rails/tasks/yarn.rake'\n # Undo-me\n Kernel.send(:undef_method, :load)\n Kernel.send(:alias_method, :load, :original_load)\n Kernel.send(:undef_method, :original_load)\n\n # Pretend it's loaded\n return\n end\n\n original_load(filename, wrap)\n end", "def add_rollback_task(task_name)\n rollback_tasks << task_name if Rake::Task.task_defined? task_name\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n EarLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def load_tasks(dir=@tasks_dir)\n @task_files = []\n Dir.entries(dir).each do |entry| \n #\n # Check for obvious directories\n #\n if !(entry =~ /^\\./)\n #\n # Make sure it's a file\n #\n if File.file? dir + \"/\" + entry \n #\n # Toss it in our array\n #\n @task_files << dir + \"/\" + entry \n end\n end\n end\n \n #\n # For each of our identified task files...\n #\n @task_files.each do |task_file|\n #\n # Create a new task and eval our task into it\n #\n TapirLogger.instance.log \"Evaluating task: #{task_file}\"\n t = Task.new\n t.instance_eval(File.open(task_file, \"r\").read)\n\n #\n # Add it to our task listing\n #\n @tasks << t\n end\n end", "def load_all_tasks_in_order\n load_dir = ENV[\"load_dir\"]\n tasks_and_files= [{\"ansi_code\"=>\"ansicode.csv\"},\n {\"client_profile_group\"=>\"clients.csv\"},\n {\"facilities\"=>\"facilities.csv\"},\n {\"rcc_payer\"=>\"rcc_payer.csv\"},\n {\"temp_reason_codes\"=>\"rcc_reason_codes.csv\"},\n {\"temp_reason_code_mappings\"=>\"rcc_mappings.csv\"},\n {\"temp_lockbox\"=>\"client_profile_lockbox.csv\"},\n {\"temp_payers\"=>\"ABAInfo.csv\"},\n {\"process_relationships_from_temp_tables\"=>\"\"},\n {\"change_partner_to_bac\"=>\"\"},\n {\"remove_temp_tables\" =>\"\"}]\n errors = []\n \n errors << \"Please provide a valid directory\" if (load_dir.blank? || !FileTest.exists?(load_dir))\n if errors.empty?\n tasks_and_files.each do |hash|\n csv_file = hash[hash.keys[0]]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n errors << \"File #{csv_file} not found in #{load_dir}\" if ! FileTest.exists?(abs_path)\n end\n end\n end\n\n if errors.empty?\n tasks_and_files.each do |hash|\n task = hash.keys[0]\n csv_file = hash[task]\n if !csv_file.blank?\n abs_path = load_dir + \"/\" + csv_file\n ENV[\"path\"] = abs_path\n puts \"processing file \" + ENV[\"path\"]\n end\n puts \"invoking task dataimport:#{task} ......\"\n Rake::Task[\"dataimport:#{task}\"].invoke \n end\n else\n errors.each do |err|\n puts err + \"\\n\"\n end\n end \nend", "def rake_task task_name\n @rake.invoke_task task_name\n end", "def handle_rake_test_task\n test_task = @target\n all_tests = test_task.file_list\n\n @target = test_task.name\n @globs << test_task.file_list\n @options[:force] = true\n\n lambda do |changed|\n tests = all_tests & changed\n\n basenames = (changed - tests).collect do |f|\n File.basename(f).split(\".\").first\n end\n\n tests.concat all_tests.\n select { |t| basenames.any? { |b| t =~ /#{b}/ } }\n\n tests = all_tests.dup if tests.empty?\n\n # Nice API, Rake::TestTask.\n ENV[\"TEST\"] = \"{#{tests.uniq.join(',')}}\"\n end\n end", "def run_rails_rake_tasks(*names)\n ARGV.clear\n ARGV.concat(names)\n ARGV << \"RAILS_ENV=test\"\n Dir.chdir(RAILS_ROOT) do\n old = Rake.application\n Rake.application = Rake::Application.new\n begin\n Rake.application.run\n ensure\n Rake.application = old\n end\n end\nend", "def rakefile\n 'Rakefile'\n end", "def rake(task_string, opts={})\n\n # default behaviour: rake tasks being invoked only once, unless reenabled\n # for multiple execution, so let's just reenable always\n Rake::Task[task_string].reenable\n Rake::Task[task_string].invoke(opts)\n \nend", "def run_task(task_name)\n puts heading(\"Running #{task_name}\")\n @results[task_name] = Rake::Task[task_name].invoke\n end", "def rakefile_created(file)\n puts green(\"Rakefile created: #{file}\")\n end", "def load_dummy_tasks(app_root)\n @target_extension_path = Pathname.new(app_root.to_s)\n load 'refinery/tasks/testing.rake'\n end", "def rake_task_name\n ENV['RAKE_TASK'].to_s.sub(/(?:r?spec|cucumber):?(.*)/, '\\1').upcase\n end", "def describe_rake_task(task_name, filename, &block)\n require \"rake\"\n\n describe \"Rake task #{task_name}\" do\n attr_reader :task\n\n before(:all) do\n @rake = Rake::Application.new\n Rake.application = @rake\n load filename\n @task = Rake::Task[task_name]\n end\n\n after(:all) do\n Rake.application = nil\n end\n\n def invoke!\n for action in task.instance_eval { @actions }\n instance_eval(&action)\n end\n end\n\n def tmppath(*paths)\n parts = [File.dirname(__FILE__), \"tmp\"]\n parts << (@root_time ||= Time.now.to_i.to_s)\n parts += paths\n # parts << rand().to_s.split(\".\").last\n parts.collect! {|path| path.to_s}\n path = File.join(*parts)\n attempts = 10\n while File.exists?(path)\n path.succ!\n attempts -= 1\n raise \"Unable to find a good temp pathname: #{path.inspect}\" if attempts.zero?\n end\n\n File.expand_path(path)\n end\n\n def cleanup\n path = File.expand_path(File.join(File.dirname(__FILE__), \"tmp\"))\n FileUtils.rm_rf(path)\n end\n\n instance_eval(&block)\n end\nend", "def define_manifest_task\n\n if File.exist?( 'Manifest.static' )\n file 'Manifest.txt' => [ 'Manifest.static' ]\n end\n\n gf = clean_list( spec.generated_files ).sort\n [ :gem, :test ].each { |t| task t => gf }\n\n unless gf.empty?\n task :gen_clean do\n rm_f gf\n end\n task :clean => :gen_clean\n end\n\n desc \"Force update of Manifest.txt\"\n task :manifest do\n spec.generate_manifest\n end\n\n mtask = file 'Manifest.txt' do\n spec.generate_manifest\n end\n\n mtask\n end", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def load_tasks(tasks_relative_path, options = { task_name: \"\" })\n if defined?(Rake::Task) and not Rake::Task.task_defined?(options[:task_name])\n load File.join(@lib_root, \"tasks\", *Array(tasks_relative_path))\n end\n end", "def create_or_update_previous_runs!\n if previously_ran?\n current_run.each do |description, elapsed|\n new_times = if previous_run[description.to_s]\n Array(previous_run[description.to_s]) << elapsed\n else\n Array(elapsed)\n end\n\n previous_run.store(description.to_s, new_times)\n end\n\n File.write(previous_runs_filename, previous_run.to_yaml)\n\n else\n\n File.write(previous_runs_filename, current_run.to_yaml)\n\n end\n end", "def build_rake_step\n @rake_task << self.global_config # Open the rake Stek and get General Configuration information\n @rake_task << (self.render self.get_config_template) # get Specific Configuration. Defined in the [tool].rb module file (erb)\n @opt_parser.check_error # stop here if errors found in the configuration\n @rake_task << self.test_validation # step is already done ? Defined in the tool_template.rb file\n @rake_task << (self.render self.tool_template) # get specific Task Code. Defined in the [tool].rb module file (erb)\n @rake_task << self.write_validation # write the check file Defined in the tool_template.rb file\n @rake_task << self.close_step # To close the rake Step Defined in the tool_template.rb file\n end", "def invoke_or_reboot_rake_task(task)\n if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?\n ruby_rake_task task\n else\n Rake::Task[task].invoke\n end\n end", "def invoke_or_reboot_rake_task(task)\n if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?\n ruby_rake_task task\n else\n Rake::Task[task].invoke\n end\n end", "def run_rake(task)\n run \"cd #{current_path} && rake #{task} RAILS_ENV=#{environment}\"\nend", "def run_rake(task)\n run \"cd #{current_path} && rake #{task} RAILS_ENV=#{environment}\"\nend", "def run_rake(task)\n run \"cd #{current_path} && rake #{task} RAILS_ENV=#{environment}\"\nend", "def generateRakeFor_GenerateSourceFiles\n lLstGlobalRecordTasks = []\n\n # 1. Recordings\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n # Generate recordings rules\n # Gather the recording environments and their respective file names to produce\n # map< Symbol, list< String > >\n lRecordings = {}\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n lTracksConf.each do |iLstTracks, iRecordingConf|\n lEnv = iRecordingConf[:Env]\n lRecordedFileName = getRecordedFileName(lEnv, iLstTracks)\n\n desc \"Raw recording of tracks #{iLstTracks.sort.join(', ')} in recording environment #{lEnv}\"\n file lRecordedFileName do |iTask|\n # Raw recording task\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n if (lRecordings[lEnv] == nil)\n lRecordings[lEnv] = []\n end\n lRecordings[lEnv] << lRecordedFileName\n # If there is a need of calibration, record also the calibration files\n if (iRecordingConf[:CalibrateWithEnv] != nil)\n lReferenceEnv = iRecordingConf[:CalibrateWithEnv]\n [\n [ lReferenceEnv, lEnv ],\n [ lEnv, lReferenceEnv ]\n ].each do |iEnvPair|\n iRefEnv, iRecEnv = iEnvPair\n lCalibrationFileName = getRecordedCalibrationFileName(iRefEnv, iRecEnv)\n if (lRecordings[iRecEnv] == nil)\n lRecordings[iRecEnv] = []\n end\n if (!lRecordings[iRecEnv].include?(lCalibrationFileName))\n\n desc \"Calibration recording in recording environment #{iRecEnv} to be compared with reference environment #{iRefEnv}\"\n file lCalibrationFileName do |iTask|\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n lRecordings[iRecEnv] << lCalibrationFileName\n end\n end\n @Context[:EnvsToCalibrate][[ lReferenceEnv, lEnv ].sort] = nil\n end\n end\n end\n # Make the task recording in the correct order\n lSortedEnv = lRecordingsConf[:EnvRecordingOrder] || []\n lRecordings.sort do\n |iElem1, iElem2|\n if (iElem2[1].size == iElem1[1].size)\n next iElem1[0] <=> iElem2[0]\n else\n next iElem2[1].size <=> iElem1[1].size\n end\n end.each do |iElem|\n if (!lSortedEnv.include?(iElem[0]))\n lSortedEnv << iElem[0]\n end\n end\n lLstTasks = []\n lSortedEnv.each do |iEnv|\n lLstFiles = lRecordings[iEnv]\n if (lLstFiles != nil)\n # Record a silence file\n lSilenceFile = getRecordedSilenceFileName(iEnv)\n\n desc \"Record silence file for recording environment #{iEnv}\"\n file lSilenceFile do |iTask|\n # Raw recording task\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n lSymTask = \"Record_#{iEnv}\".to_sym\n\n desc \"Record all files for recording environment #{iEnv}\"\n task lSymTask => lLstFiles + [lSilenceFile]\n\n lLstTasks << lSymTask if (@Context[:LstEnvToRecord].empty?) or (@Context[:LstEnvToRecord].include?(iEnv))\n end\n end\n\n desc 'Record all files'\n task :Record => lLstTasks\n\n lLstGlobalRecordTasks << :Record\n end\n\n # 2. Wave files\n lWaveFilesConf = @RecordConf[:WaveFiles]\n if (lWaveFilesConf != nil)\n # Generate wave files rules\n lLstWaveFiles = []\n lWaveFilesConf[:FilesList].map { |iFileInfo| iFileInfo[:Name] }.each do |iFileName|\n lWaveFileName = getWaveSourceFileName(iFileName)\n if (!File.exists?(iFileName))\n\n desc \"Generate wave file #{iFileName}\"\n file lWaveFileName do |iTask|\n puts \"Create Wave file #{iTask.name}, and press Enter when done.\"\n $stdin.gets\n end\n\n end\n lLstWaveFiles << lWaveFileName\n end\n\n desc 'Generate all wave files'\n task :GenerateWaveFiles => lLstWaveFiles\n\n lLstGlobalRecordTasks << :GenerateWaveFiles\n end\n\n desc 'Generate source files (both recording and Wave files)'\n task :GenerateSourceFiles => lLstGlobalRecordTasks\n\n @Context[:RakeSetupFor_GenerateSourceFiles] = true\n end", "def rakefile_test_tasks\n ''\n end", "def setup\r\n rake_original_setup\r\n @original_rake = Rake.application\r\n @rake = Rake::Application.new\r\n Rake.application = @rake\r\n end", "def define\n desc @description\n task @name => Array(deps) do\n FileUtilsExt.verbose(@verbose) do\n puts \"Use TESTOPTS=\\\"--verbose\\\" to pass --verbose\" \\\n \", etc. to runners.\" if ARGV.include? \"--verbose\"\n args =\n \"#{ruby_opts_string} #{run_code} \" +\n \"#{file_list_string} #{option_list}\"\n ruby args do |ok, status|\n if !ok && status.respond_to?(:signaled?) && status.signaled?\n raise SignalException.new(status.termsig)\n elsif !ok\n status = \"Command failed with status (#{status.exitstatus})\"\n details = \": [ruby #{args}]\"\n message =\n if Rake.application.options.trace or @verbose\n status + details\n else\n status\n end\n\n fail message\n end\n end\n end\n end\n self\n end", "def initialize\n super\n @name = \"rum\"\n @rakefiles = DEFAULT_RAKEFILES.dup\n end", "def [](task_name, scopes=nil)\n task_name = task_name.to_s\n self.lookup(task_name, scopes) or\n enhance_with_matching_rule(task_name) or\n synthesize_file_task(task_name) or\n fail generate_message_for_undefined_task(task_name)\n end", "def rakefile(filename, data=nil, &block)\n puts \"adding rakefile #{filename}\"\n in_root(\"lib/tasks\") do |folder|\n File.open(\"#{folder}/#{filename}\", \"w\") do |f|\n if block_given?\n f.write(code_for(block))\n else\n f.write(data)\n end\n end\n end\n end", "def rake_task?\n defined?(::Rake) && !Rake.application.top_level_tasks.empty?\n end", "def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end", "def convert_to_rake()\n object_multitask = prepare_tasks_for_objects()\n\n res = typed_file_task get_rake_task_type(), get_task_name => object_multitask do\n cmd = calc_command_line\n Dir.chdir(@project_dir) do\n mapfileStr = @mapfile ? \" >#{@mapfile}\" : \"\"\n rd, wr = IO.pipe\n cmdLinePrint = cmd\n printCmd(cmdLinePrint, \"Linking #{executable_name}\", false) #OK\n cmd << {\n :out=> @mapfile ? \"#{@mapfile}\" : wr, # > xy.map\n :err=>wr\n }\n sp = spawn(*cmd)\n cmd.pop\n # for console print\n cmd << \" >#{@mapfile}\" if @mapfile\n consoleOutput = ProcessHelper.readOutput(sp, rd, wr)\n\n process_result(cmdLinePrint, consoleOutput, @tcs[:LINKER][:ERROR_PARSER], nil)\n check_config_file()\n post_link_hook(@tcs[:LINKER])\n end\n end\n res.tags = tags\n res.immediate_output = true\n res.enhance(@config_files)\n res.enhance([@project_dir + \"/\" + @linker_script]) if @linker_script\n\n add_output_dir_dependency(get_task_name, res, true)\n add_grouping_tasks(get_task_name)\n setup_rake_dependencies(res, object_multitask)\n\n # check that all source libs are checked even if they are not a real rake dependency (can happen if \"build this project only\")\n begin\n libChecker = task get_task_name+\"LibChecker\" do\n if File.exists?(get_task_name) # otherwise the task will be executed anyway\n all_dependencies.each do |bb|\n if bb and StaticLibrary === bb\n f = bb.get_task_name # = abs path of library\n if not File.exists?(f) or File.mtime(f) > File.mtime(get_task_name)\n def res.needed?\n true\n end\n break\n end\n end\n end\n end\n end\n rescue\n def res.needed?\n true\n end\n end\n libChecker.transparent_timestamp = true\n res.enhance([libChecker])\n\n return res\n end", "def generateRakeFor_CalibrateRecordings\n if (!@Context[:RakeSetupFor_CleanRecordings])\n generateRakeFor_CleanRecordings\n end\n\n # List of calibrating tasks\n # list< Symbol >\n lLstCalibrateTasks = []\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n # Generate analysis files for calibration files\n @Context[:EnvsToCalibrate].each do |iEnvToCalibratePair, iNil|\n [\n [ iEnvToCalibratePair[0], iEnvToCalibratePair[1] ],\n [ iEnvToCalibratePair[1], iEnvToCalibratePair[0] ]\n ].each do |iEnvPair|\n iEnv1, iEnv2 = iEnvPair\n lCalibrationFileName = getRecordedCalibrationFileName(iEnv1, iEnv2)\n lNoiseGatedFileName = @Context[:CleanFiles][File.basename(lCalibrationFileName)[0..-5]][:NoiseGatedFileName]\n lAnalysisFileName = getRecordedAnalysisFileName(File.basename(lNoiseGatedFileName)[0..-5])\n @Context[:CalibrationAnalysisFiles][iEnvPair] = lAnalysisFileName\n\n desc \"Generate analysis for framed calibration file #{lNoiseGatedFileName}\"\n file lAnalysisFileName => lNoiseGatedFileName do |iTask|\n analyzeFile(iTask.prerequisites[0], iTask.name)\n end\n\n end\n end\n\n # Generate calibrated files\n lTracksConf.each do |iLstTracks, iRecordingConf|\n if (iRecordingConf[:CalibrateWithEnv] != nil)\n # Need calibration\n lRecEnv = iRecordingConf[:Env]\n lRefEnv = iRecordingConf[:CalibrateWithEnv]\n lRecordedBaseName = File.basename(getRecordedFileName(lRecEnv, iLstTracks))[0..-5]\n # Create the data target that stores the comparison of analysis files for calibration\n lCalibrationInfoTarget = \"#{lRecordedBaseName}.Calibration.info\".to_sym\n\n desc \"Compare the analysis of calibration files for recording #{lRecordedBaseName}\"\n task lCalibrationInfoTarget => [\n @Context[:CalibrationAnalysisFiles][[lRefEnv,lRecEnv]],\n @Context[:CalibrationAnalysisFiles][[lRecEnv,lRefEnv]]\n ] do |iTask|\n iRecordingCalibrationAnalysisFileName, iReferenceCalibrationAnalysisFileName = iTask.prerequisites\n # Compute the distance between the 2 average RMS values\n lRMSReference = getRMSValue(iReferenceCalibrationAnalysisFileName)\n lRMSRecording = getRMSValue(iRecordingCalibrationAnalysisFileName)\n log_info \"Reference environment #{lRefEnv} - RMS: #{lRMSReference}\"\n log_info \"Recording environment #{lRecEnv} - RMS: #{lRMSRecording}\"\n iTask.data = {\n :RMSReference => lRMSReference,\n :RMSRecording => lRMSRecording,\n :MaxValue => getAnalysis(iRecordingCalibrationAnalysisFileName)[:MinPossibleValue].abs\n }\n end\n\n # Create the dependency task\n lDependenciesTask = \"Dependencies_Calibration_#{lRecordedBaseName}\".to_sym\n\n desc \"Compute dependencies to know if we need to calibrate tracks [#{iLstTracks.join(', ')}] recording.\"\n task lDependenciesTask => lCalibrationInfoTarget do |iTask|\n lCalibrationInfo = Rake::Task[iTask.prerequisites.first].data\n # If the RMS values are different, we need to generate the calibrated file\n lRecordedBaseName2 = iTask.name.match(/^Dependencies_Calibration_(.*)$/)[1]\n lCalibrateContext = @Context[:Calibrate][lRecordedBaseName2]\n lLstPrerequisitesFinalTask = [iTask.name]\n if (lCalibrationInfo[:RMSRecording] != lCalibrationInfo[:RMSReference])\n # Make the final task depend on the calibrated file\n lLstPrerequisitesFinalTask << lCalibrateContext[:CalibratedFileName]\n # Create the target that will generate the calibrated file.\n\n desc \"Generate calibrated recording for #{lRecordedBaseName2}\"\n file @Context[:Calibrate][lRecordedBaseName2][:CalibratedFileName] => [\n @Context[:CleanFiles][lRecordedBaseName2][:NoiseGatedFileName],\n lCalibrationInfoTarget\n ] do |iTask2|\n iRecordedFileName, iCalibrationInfoTarget = iTask2.prerequisites\n lCalibrationInfo = Rake::Task[iCalibrationInfoTarget].data\n # If the Recording is louder, apply a volume reduction\n if (lCalibrationInfo[:RMSRecording] < lCalibrationInfo[:RMSReference])\n # Here we are loosing quality: we need to increase the recording volume.\n # Notify the user about it.\n lDBValue, lPCValue = val2db(lCalibrationInfo[:RMSReference]-lCalibrationInfo[:RMSRecording], lCalibrationInfo[:MaxValue])\n log_warn \"Tracks [#{iLstTracks.join(', ')}] should be recorded louder (at least #{lDBValue} db <=> #{lPCValue} %).\"\n end\n wsk(iRecordedFileName, iTask2.name, 'Multiply', \"--coeff \\\"#{lCalibrationInfo[:RMSReference]}/#{lCalibrationInfo[:RMSRecording]}\\\"\")\n end\n\n end\n Rake::Task[lCalibrateContext[:FinalTask]].prerequisites.replace(lLstPrerequisitesFinalTask)\n end\n\n # Make the final task depend on this dependency task\n lCalibrateFinalTask = \"Calibrate_#{iLstTracks.join('_')}\".to_sym\n lLstCalibrateTasks << lCalibrateFinalTask\n @Context[:Calibrate][lRecordedBaseName] = {\n :FinalTask => lCalibrateFinalTask,\n :CalibratedFileName => getCalibratedFileName(lRecordedBaseName)\n }\n\n desc \"Calibrate tracks [#{iLstTracks.join(', ')}] recording.\"\n task lCalibrateFinalTask => lDependenciesTask\n\n end\n end\n\n end\n end\n # Generate global task\n\n desc 'Calibrate recordings needing it'\n task :CalibrateRecordings => lLstCalibrateTasks\n\n @Context[:RakeSetupFor_CalibrateRecordings] = true\n end", "def task_defined?(task_name) \n lookup(task_name) != nil\n end", "def md5file(file, task_ext, task_dep)\n task :this_task do\n if File.exists?(\"#{file}.tmp\")\n old_sum = File.read(\"#{file}.tmp\").chomp\n else\n old_sum = \"\"\n end\n new_sum = `md5sum #{file}`.chomp\n if old_sum != new_sum\n Rake::Task[task_dep].invoke\n File.open(\"#{file}.tmp\", \"w\") {|f| f.write(new_sum)}\n end\n end\n task task_ext => :this_task \nend", "def attempt_rule(task_name, task_pattern, args, extensions, block, level)\n sources = make_sources(task_name, task_pattern, extensions)\n prereqs = sources.map { |source|\n trace_rule level, \"Attempting Rule #{task_name} => #{source}\"\n if File.exist?(source) || Rake::Task.task_defined?(source)\n trace_rule level, \"(#{task_name} => #{source} ... EXIST)\"\n source\n elsif parent = enhance_with_matching_rule(source, level + 1)\n trace_rule level, \"(#{task_name} => #{source} ... ENHANCE)\"\n parent.name\n else\n trace_rule level, \"(#{task_name} => #{source} ... FAIL)\"\n return nil\n end\n }\n task = FileTask.define_task(task_name, { args => prereqs }, &block)\n task.sources = prereqs\n task\n end", "def define_tasks\n # Task definitions are taken from Rake::TestTask\n # https://github.com/ruby/rake/blob/e644af3/lib/rake/testtask.rb#L98-L112\n namespace :ttnt do\n namespace name do\n define_run_task\n define_anchor_task\n end\n end\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def reload_tasks(dir=@tasks_dir)\n @task_files = []\n load_tasks(dir)\n end", "def define_run_task\n desc @run_description\n task 'run' do\n target_sha = ENV['TARGET_SHA']\n ts = TTNT::TestSelector.new(repo, target_sha, expanded_file_list)\n tests = ts.select_tests!\n\n if tests.empty?\n STDERR.puts 'No test selected.'\n else\n if ENV['ISOLATED']\n tests.each do |test|\n args = \"#{ruby_opts_string} #{test} #{option_list}\"\n run_ruby args\n break if @failed && ENV['FAIL_FAST']\n end\n else\n args =\n \"#{ruby_opts_string} #{run_code} \" +\n \"#{tests.to_a.join(' ')} #{option_list}\"\n run_ruby args\n end\n end\n end\n end", "def find_rakefile(spec)\n rakefile = DEFAULT_RAKEFILES.\n map { |x| File.join(spec.full_gem_path, x) }.\n find { |x| File.exist?(x) }\n\n unless(File.exist?(rakefile) rescue nil)\n alert_error \"Couldn't find rakefile -- this gem cannot be tested. Aborting.\" \n raise Gem::RakeNotFoundError, \"Couldn't find rakefile, gem #{spec.name} (#{spec.version}) cannot be tested.\"\n end\n end", "def build(rakeTask)\n\t\t#we've called ourselves after updating prereqs and running them; now do our work\n\t\t\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes non-file prereq tasks, so do our own\n\t\t\tlinker().link(:objs => linkDepsOrdered(), :target => target())\n\t\tend\n\tend", "def get_task(task_name)\n if using_rake? and task_defined?(task_name)\n Rake::Task[task_name]\n end\n end", "def remote_rake(task)\n on primary(:app) do\n within current_path do\n with rails_env: fetch(:rails_env) do\n rake task\n end\n end\n end\n end", "def declare_rake_tasks\n @flavor.class.do_declare_resources do\n if snippet?('cookbook_base')\n rake_tasks['foodcritic'] = <<'END'\nrequire 'foodcritic'\nrequire 'foodcritic/rake_task'\n\nFoodCritic::Rake::LintTask.new(:foodcritic)\ntask style: :foodcritic\nEND\n end\n end\n end", "def should_skip\n if @needed.nil?\n @needed = prerequisite_tasks.empty? || \\\n input_files.since(@last_executed).any? || \\\n @force\n\n # We also make sure that if the rakefile was modified since last\n # execution, we force reexecution\n if @application.rakefile\n @needed ||= File.mtime(@application.rakefile) > @last_executed\n end\n end\n !@needed\n end", "def make_tasks_in_file(tasknames = [], filepath = '.', task_body = \"\\n\", namespace: '')\n\n indent = \"\"\n filedir = File.dirname(filepath)\n FileUtils.mkdir_p(filedir) unless Dir.exist?(filedir)\n\n File.open(filepath, 'w') do |f|\n unless namespace.empty?\n indent = \" \"\n f.puts namespace_start(namespace)\n end\n\n tasknames.each do |taskname|\n f.puts simple_rake_task(taskname, indent: indent, task_body: task_body)\n end\n\n f.puts namespace_end unless namespace.empty?\n end\n filepath\n end", "def get_tasks_from_rakefiles\n\n # ensure we're starting out with no tasks or rakefiles\n clear_all_tasks_and_rakefiles\n\n rakefiles_to_read = onetime_rake_files\n\n return [] if rakefiles_to_read.empty?\n\n rakefiles_to_read.each(&method(:get_tasks_in_rakefile))\n\n self.all_tasks\n end", "def task_from_filename(filename)\n require filename\n File.basename(filename).gsub(\".rb\", \"\").camelcase # RAILS_ROOT/rooster/lib/tasks/newsfeed_task.rb => NewsfeedTask\n end", "def build(rakeTask)\n\t\tfilePrereqs = filePrereqs() #remove internal build-system stuff\n\t\tunless FileUtils.uptodate?(target(), filePrereqs) #the check rake does always fails because it includes a non-file prereq task\n\t\t\tstaticLibMaintainer().addOrUpdate(:lib => target(), :objs => filePrereqs)\n\t\t\tstaticLibMaintainer().index(target())\n\t\tend\n\tend", "def load_tasks(tasks)\n load File.join(File.dirname(__FILE__), 'tasks', \"#{tasks}.rb\")\nend", "def include(*filenames)\n # TODO: check for pending\n filenames.each do |fn|\n if fn.respond_to? :to_ary\n include(*fn.to_ary)\n else\n @pending_add << Rake.from_pathname(fn)\n end\n end\n @pending = true\n self\n end", "def generateRakeFor_ProcessSourceFiles\n if (!@Context[:RakeSetupFor_CalibrateRecordings])\n generateRakeFor_CalibrateRecordings\n end\n\n # List of process tasks\n # list< Symbol >\n lLstProcessTasks = []\n\n # 1. Handle recordings\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n # Read global processes and environment processes to be applied before and after recordings\n lGlobalProcesses_Before = lRecordingsConf[:GlobalProcesses_Before] || []\n lGlobalProcesses_After = lRecordingsConf[:GlobalProcesses_After] || []\n lEnvProcesses_Before = lRecordingsConf[:EnvProcesses_Before] || {}\n lEnvProcesses_After = lRecordingsConf[:EnvProcesses_After] || {}\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n lTracksConf.each do |iLstTracks, iRecordingConf|\n lRecEnv = iRecordingConf[:Env]\n # Compute the list of processes to apply\n lEnvProcesses_RecordingBefore = lEnvProcesses_Before[lRecEnv] || []\n lEnvProcesses_RecordingAfter = lEnvProcesses_After[lRecEnv] || []\n lRecordingProcesses = iRecordingConf[:Processes] || []\n # Optimize the list\n lLstProcesses = optimizeProcesses(lGlobalProcesses_Before + lEnvProcesses_RecordingBefore + lRecordingProcesses + lEnvProcesses_RecordingAfter + lGlobalProcesses_After)\n # Get the file name to apply processes to\n lRecordedBaseName = File.basename(getRecordedFileName(lRecEnv, iLstTracks))[0..-5]\n # Create the target that gives the name of the final wave file, and make it depend on the Calibration.Info target only if calibration might be needed\n lPrerequisites = []\n lPrerequisites << \"#{lRecordedBaseName}.Calibration.info\".to_sym if (iRecordingConf[:CalibrateWithEnv] != nil)\n lFinalBeforeMixTarget = \"FinalBeforeMix_Recording_#{lRecordedBaseName}\".to_sym\n\n desc \"Get final wave file name for recording #{lRecordedBaseName}\"\n task lFinalBeforeMixTarget => lPrerequisites do |iTask|\n lRecordedBaseName2 = iTask.name.match(/^FinalBeforeMix_Recording_(.*)$/)[1]\n # Get the name of the file that may be processed\n # Set the cleaned file as a default\n lFileNameToProcess = getNoiseGateFileName(lRecordedBaseName2)\n if (!iTask.prerequisites.empty?)\n lCalibrationInfo = Rake::Task[iTask.prerequisites.first].data\n if (lCalibrationInfo[:RMSReference] != lCalibrationInfo[:RMSRecording])\n # Apply processes on the calibrated file\n lFileNameToProcess = getCalibratedFileName(lRecordedBaseName2)\n end\n end\n # By default, the final name is the one to be processed\n lFinalFileName = lFileNameToProcess\n # Get the list of processes from the context\n if (@Context[:Processes][lRecordedBaseName2] != nil)\n # Processing has to be performed\n # Now generate the whole branch of targets to process the choosen file\n lFinalFileName = generateRakeForProcesses(@Context[:Processes][lRecordedBaseName2][:LstProcesses], lFileNameToProcess, getProcessesRecordDir)\n end\n iTask.data = {\n :FileName => lFinalFileName\n }\n end\n\n if (!lLstProcesses.empty?)\n # Generate the Dependencies task, and make it depend on the target creating the processing chain\n lDependenciesTask = \"Dependencies_ProcessRecord_#{lRecordedBaseName}\".to_sym\n\n desc \"Create the targets needed to process tracks [#{iLstTracks.join(', ')}]\"\n task lDependenciesTask => lFinalBeforeMixTarget do |iTask|\n lRecordedBaseName2 = iTask.name.match(/^Dependencies_ProcessRecord_(.*)$/)[1]\n # Make the final task depend on the processed file\n Rake::Task[@Context[:Processes][lRecordedBaseName2][:FinalTask]].prerequisites.replace([\n iTask.name,\n Rake::Task[iTask.prerequisites.first].data[:FileName]\n ])\n end\n\n # Make the final task depend on the Dependencies task only for the beginning\n lFinalTask = \"ProcessRecord_#{iLstTracks.join('_')}\".to_sym\n lLstProcessTasks << lFinalTask\n\n desc \"Apply processes to recording #{lRecordedBaseName}\"\n task lFinalTask => lDependenciesTask\n\n @Context[:Processes][lRecordedBaseName] = {\n :LstProcesses => lLstProcesses,\n :FinalTask => lFinalTask\n }\n end\n end\n end\n end\n\n # 2. Handle Wave files\n lWaveFilesConf = @RecordConf[:WaveFiles]\n if (lWaveFilesConf != nil)\n lGlobalProcesses_Before = lWaveFilesConf[:GlobalProcesses_Before] || []\n lGlobalProcesses_After = lWaveFilesConf[:GlobalProcesses_After] || []\n lLstWaveInfo = lWaveFilesConf[:FilesList]\n if (lLstWaveInfo != nil)\n lLstWaveInfo.each do |iWaveInfo|\n lWaveProcesses = iWaveInfo[:Processes] || []\n if (iWaveInfo[:Position] != nil)\n lWaveProcesses << {\n :Name => 'SilenceInserter',\n :Begin => iWaveInfo[:Position],\n :End => 0\n }\n end\n # Optimize the list\n lLstProcesses = optimizeProcesses(lGlobalProcesses_Before + lWaveProcesses + lGlobalProcesses_After)\n lFinalBeforeMixTarget = \"FinalBeforeMix_Wave_#{iWaveInfo[:Name]}\"\n\n desc \"Get final wave file name for Wave #{iWaveInfo[:Name]}\"\n task lFinalBeforeMixTarget do |iTask|\n lWaveName = iTask.name.match(/^FinalBeforeMix_Wave_(.*)$/)[1]\n # By default, use the original Wave file\n lFinalFileName = getWaveSourceFileName(lWaveName)\n if (@Context[:WaveProcesses][lWaveName] != nil)\n # Generate rake tasks for processing the clean recorded file.\n lFinalFileName = generateRakeForProcesses(@Context[:WaveProcesses][lWaveName][:LstProcesses], lFinalFileName, getProcessesWaveDir)\n end\n iTask.data = {\n :FileName => lFinalFileName\n }\n end\n\n if (!lLstProcesses.empty?)\n # Generate the Dependencies task, and make it depend on the target creating the processing chain\n lDependenciesTask = \"Dependencies_ProcessWave_#{iWaveInfo[:Name]}\".to_sym\n\n desc \"Create the targets needed to process Wave #{iWaveInfo[:Name]}\"\n task lDependenciesTask => lFinalBeforeMixTarget do |iTask|\n lWaveName = iTask.name.match(/^Dependencies_ProcessWave_(.*)$/)[1]\n # Make the final task depend on the processed file\n Rake::Task[@Context[:WaveProcesses][lWaveName][:FinalTask]].prerequisites.replace([\n iTask.name,\n Rake::Task[iTask.prerequisites.first].data[:FileName]\n ])\n end\n\n # Make the final task depend on the Dependencies task only for the beginning\n lFinalTask = \"ProcessWave_#{iWaveInfo[:Name]}\".to_sym\n lLstProcessTasks << lFinalTask\n\n desc \"Apply processes to Wave #{iWaveInfo[:Name]}\"\n task lFinalTask => lDependenciesTask\n\n @Context[:WaveProcesses][iWaveInfo[:Name]] = {\n :LstProcesses => lLstProcesses,\n :FinalTask => lFinalTask\n }\n end\n end\n end\n end\n\n # 3. Generate global task\n\n desc 'Process source files'\n task :ProcessSourceFiles => lLstProcessTasks\n\n @Context[:RakeSetupFor_ProcessSourceFiles] = true\n end", "def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end", "def define_default_tasks\n\n\t\t# task used to indicate that rake-deveiate has already been setup once; for\n\t\t# global rakefiles.\n\t\ttask :deveiate do\n\t\t\t# no-op\n\t\tend\n\n\t\tdesc \"The task that runs by default\"\n\t\ttask( :default => :spec )\n\n\t\tdesc \"Check in the current changes\"\n\t\ttask :checkin => [ :precheckin, :check, :test ]\n\t\ttask :commit => :checkin\n\t\ttask :ci => :checkin\n\t\ttask :precheckin\n\n\t\tdesc \"Sanity-check the project\"\n\t\ttask :check\n\n\t\tdesc \"Update the history file\"\n\t\ttask :update_history\n\n\t\tdesc \"Package up and push a release\"\n\t\ttask :release => [ :prerelease, :gem, :release_gem, :postrelease ]\n\t\ttask :prerelease\n\t\ttask :release_gem\n\t\ttask :postrelease\n\n\t\tdesc \"Run all the project's tests\"\n\t\ttask :test\n\t\ttask :spec\n\t\ttask :integration\n\n\t\tdesc \"Set up the project for development\"\n\t\ttask :setup do\n\t\t\tself.install_dependencies\n\t\tend\n\n\t\tdesc \"Turn on maintainer mode: build with extra warnings and debugging\"\n\t\ttask :maint do\n\t\t\tENV['MAINTAINER_MODE'] = 'yes'\n\t\tend\n\n\tend", "def define\r\n\t\t\ttask :foo do\r\n\t\t\t\tputs 'foo!'\r\n\t\t\tend\r\n\t\tend", "def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end", "def define_tasks!\n\n define_test_tasks! if has_tests?\n define_rspec_tasks! if has_specs?\n\n namespace(@task_namespace) do\n desc \"Updates the filelist in the gemspec file\"\n task(:manifest) { manifest_task }\n\n desc \"Builds the .gem package\"\n task(:build => :manifest) { build_task }\n\n desc \"Sets the version of the gem in the gemspec\"\n task(:set_version => [:check_version, :check_current_branch]) { version_task }\n task(:check_version => :fetch_origin) { check_version_task }\n\n task(:fetch_origin) { fetch_origin_task }\n task(:check_current_branch) { check_current_branch_task }\n task(:check_clean_status) { check_clean_status_task }\n task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }\n\n checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]\n checks.unshift('spec:basic') if has_specs?\n checks.unshift('test:basic') if has_tests?\n # checks.push << [:check_rubyforge] if gemspec.rubyforge_project\n\n desc \"Perform all checks that would occur before a release\"\n task(:release_checks => checks)\n\n release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]\n # release_tasks << [:rubyforge_release] if gemspec.rubyforge_project\n\n desc \"Release a new version of the gem using the VERSION environment variable\"\n task(:release => release_tasks) { release_task }\n \n namespace(:release) do\n desc \"Release the next version of the gem, by incrementing the last version segment by 1\"\n task(:next => [:next_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a patch increment (0.0.1)\"\n task(:patch => [:next_patch_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a minor increment (0.1.0)\"\n task(:minor => [:next_minor_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a major increment (1.0.0)\"\n task(:major => [:next_major_version] + release_tasks) { release_task }\n end\n\n # task(:check_rubyforge) { check_rubyforge_task }\n # task(:rubyforge_release) { rubyforge_release_task }\n task(:gemcutter_release) { gemcutter_release_task }\n task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }\n task(:tag_version) { tag_version_task }\n task(:commit_modified_files) { commit_modified_files_task }\n\n task(:next_version) { next_version_task }\n task(:next_patch_version) { next_version_task(:patch) }\n task(:next_minor_version) { next_version_task(:minor) }\n task(:next_major_version) { next_version_task(:major) }\n \n desc \"Updates the gem release tasks with the latest version on Github\"\n task(:update_tasks) { update_tasks_task }\n end\n end", "def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end", "def ensure_tasks_folder\n io.mkdir('.webbynode/tasks') unless io.directory?(\".webbynode/tasks\")\n %w[before_push after_push].each do |file|\n io.exec(\"touch .webbynode/tasks/#{file}\") unless io.file_exists?(\".webbynode/tasks/#{file}\")\n end\n end", "def ruby_rake_task(task)\n Rake::Task[task].invoke\nend", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def build_default_tasks\n @rake_task << self.step_template # get General Configuration information\n end", "def add_hardcoded_previous_runs(task)\n task.add_previous_run('t1 previous run 1', dt_2019_06_14_010101)\n task.add_previous_run('t1 previous run 2', dt_2019_06_14_020101)\n end", "def rake_application\n @rake_application || Rake.application\n end", "def configure_tasks\n end", "def rake(task,*args)\n run 'rake', rake_task(task,*args)\n end", "def add_to_scheduler\n name = \"for_survey_#{@schedulable.company_survey.id}\"\n config = {}\n config[:every] = [\"#{@schedulable.repeat_every}#{@schedulable.repeat_mode}\",\n { first_at: calculate_next_delivery }]\n config[:class] = 'SendEmailsJob'\n config[:queue] = 'send_emails'\n config[:persist] = true\n config[:args] = @schedulable.company_survey.id\n Resque.set_schedule(name, config)\n end", "def write_rake_step(default: false)\n prefix = @workflow_id + '_'\n prefix = prefix + 'task_' if not default\n if @rake_task == false\n @log.fatal { 'No Rake Task defined' }; exit\n else\n file_out = \"#{prefix}#{@task_name}.rb\"\n dest = File.open(file_out, 'w') # a = append\n dest.puts @rake_task\n dest.close\n @log.info \"Write Rake Step : [#{@task_name}] in [#{file_out}]\"\n return @project_path + '/' + file_out\n end\n end", "def define\n\t\ttask :foo do\n\t\t\tputs 'foo!'\n\t\tend\n\tend", "def configure_reek_task(task)\n task.reek_opts << \"--quiet\"\n task.source_files = @ruby_sources\n end", "def define\n logger.debug \"Defining tasks for #{name} #{version}\"\n\n namespace \"#{name}\" do\n define_download\n define_verify\n define_unpack\n define_patch\n define_build\n define_install\n\n task :done => \"#{name}:install\"\n task :default => \"#{name}:done\"\n end\n\n desc \"Build and Install #{name} #{version}\"\n task name => \"#{name}:default\"\n end", "def enhance_with_matching_rule(task_name, level=0)\n fail Rake::RuleRecursionOverflowError,\n \"Rule Recursion Too Deep\" if level >= 16\n @rules.each do |pattern, args, extensions, order_only, block|\n if pattern && pattern.match(task_name)\n task = attempt_rule(task_name, pattern, args, extensions, block, level)\n task | order_only unless order_only.nil?\n return task if task\n end\n end\n nil\n rescue Rake::RuleRecursionOverflowError => ex\n ex.add_target(task_name)\n fail ex\n end", "def eval_file; end", "def task_files\r\n Dir.chdir(Rails.root.join('lib', 'tasks')) do |dir|\r\n @task_files = Dir[\"*.rake\"]\r\n end\r\n @task_files = @task_files.reject{|task|\r\n task !~ /\\Abg_worker_/}.map{|task|\r\n task.sub('bg_worker_', '')\r\n }\r\n end", "def intern(task_class, task_name)\n @tasks[task_name.to_s] ||= task_class.new(task_name, self)\n end", "def make_sourcery_wxs_file_task\n return if Rake::FileTask.task_defined? 'wix/Sourcery.wxs'\n sourcery = Rake::FileTask.define_task 'wix/Sourcery.wxs' do |t|\n if File.directory? 'wix/src'\n args = []\n args << '-nologo' # Skip printing of the WiX logo\n args << '-sfrag' # Suppress fragments\n args << '-srd' # Don't harvest the root directory e.g. wix\\src\n args << '-ag' # Auto generate GUIDs\n args << '-template fragment'\n args << '-dr INSTALLDIR'\n args << '-var var.Source'\n args = args.join(' ')\n wix_run 'heat', \"dir wix/src #{args} -out #{t.name}\"\n end\n end\n sourcery.comment = 'Create the Sourcery.wxs file'\n sourcery.enhance ['wix']\n sourcery.enhance @files.values\n end", "def rake_tasks(&block); end", "def rake_tasks(&block); end" ]
[ "0.74772257", "0.6796576", "0.58848387", "0.5873985", "0.5728471", "0.5652964", "0.5614601", "0.55818975", "0.55703884", "0.5515117", "0.5510157", "0.5413402", "0.5365747", "0.52929115", "0.52316236", "0.51894283", "0.51660335", "0.510383", "0.5093368", "0.50860965", "0.5028293", "0.50020945", "0.49962956", "0.49927902", "0.49759862", "0.4968337", "0.49583396", "0.49387586", "0.49156952", "0.4882727", "0.4860479", "0.4832335", "0.48237684", "0.4820966", "0.48091304", "0.48039246", "0.4787177", "0.47861835", "0.47792476", "0.47792476", "0.47629744", "0.47629744", "0.47629744", "0.47503775", "0.4712052", "0.47011346", "0.46746033", "0.46740115", "0.46729407", "0.46690485", "0.4654267", "0.4646757", "0.46427503", "0.46401352", "0.46347", "0.46184817", "0.46108818", "0.45998153", "0.45964", "0.45964", "0.4588609", "0.4586342", "0.45827028", "0.45611757", "0.45502827", "0.45494202", "0.45367485", "0.45322457", "0.45256862", "0.4525284", "0.45136958", "0.4493781", "0.4482311", "0.44822806", "0.4467053", "0.44669706", "0.44565958", "0.44529513", "0.4450192", "0.44341266", "0.4429751", "0.44231704", "0.4411375", "0.4411263", "0.4406759", "0.4400946", "0.43833178", "0.43809345", "0.43779668", "0.43760782", "0.43744925", "0.43710142", "0.43673655", "0.4362999", "0.43539762", "0.43515217", "0.43502924", "0.4348583", "0.43482798", "0.43482798" ]
0.7244897
1
Don't cache (memoize) these. We always want the latest info from the db.
def successful_task_attempts OneTimeTasker::SuccessfulTaskAttempt.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cached?; end", "def refresh_db_related\n return if @table_follows.empty?\n\n @first_db_entry = @table_follows.first\n @last_follow_time = @first_db_entry[:follow_time]\n end", "def now\n cache\n end", "def update_cache\n # Does nothing...up to subclasses to implement.\n end", "def now\n cache\n end", "def now\n cache\n end", "def cache_on?; end", "def cache_on?; end", "def cached\n raise NotImplementedError\n end", "def cache\n rows.each(&:cache)\n end", "def cache(data); end", "def cached\n self\n end", "def fetch_latest\n page = page_with_latest_entries\n most_recent_new_entry = page.entries.first\n last_fetched_entry = @entry_cache.latest\n last_fetched_entry_seen = false \n next_entry = nil\n while !last_fetched_entry_seen && page\n page.entries.each do |entry|\n \n @entry_cache.write(entry, next_entry)\n if last_fetched_entry && entry.entry_id == last_fetched_entry.entry_id\n last_fetched_entry_seen = true\n break\n end\n\n next_entry = entry\n end\n page = page.next\n end\n \n @entry_cache.update_current_state(next_entry, most_recent_new_entry)\n @entry_cache.entries(next_entry, most_recent_new_entry)\n end", "def instance_cache; end", "def refill\n now = Time.now.to_i\n cache_set.each {|rec|\n ttl = rec[:end_ts].to_i - now\n cache_write( rec[:key], rec[:value], ttl ) if ttl > 0 \\\n if rec[:value] and rec[:value].length > MAX_OBJ_SIZE and ttl > 0\n }\n end", "def used\n update(last_used: DateTime.now)\n end", "def flush_cache; end", "def latest_entries\n unless @latest_entries\n @latest_entries = Rails.cache.fetch([@account.cache_key, '/latest_entries'], :expires_in => 10.minutes) do\n Entry.paginate(:all, :from => \"/accounts/#{@account.account_resource_id.to_s}/entries.xml\", :params => { :page => 1, :per_page => 5}) \n end\n end\n @latest_entries\n end", "def cache_value?; end", "def singleton_cache; end", "def cache\n @cache ||= begin\n if @old_commit_oid == @commit_oid\n @old_stats\n else\n compute_stats(@old_commit_oid, @old_stats)\n end\n end\n end", "def cache\n yield\n end", "def get_everything!\n self.update!\n\n prev = @prev\n while prev\n prev.update!\n\n self.merge_entries! prev\n prev = prev.prev\n end\n\n nxt = @next\n while nxt\n nxt.update!\n\n self.merge_entries! nxt\n nxt = nxt.next\n end\n\n self\n end", "def cache_store; end", "def cache_store; end", "def memo\n end", "def cache!\n @@cache\n end", "def fetch!\n self.val = fetch\n self.last_updated = Time.zone.now\n self.save!\n end", "def autorestore; end", "def data\n @cache ||= {}\n end", "def fetch_latest_everything\n\t\t@user_info = @client.execute(api_method: @info.userinfo.get).data\n\t\t@task_lists = @client.execute(api_method: @gtasks.tasklists.list).data.items\n\t\t@tasks = Hash.new\n\t\t@task_lists.each do |list|\n\t\t\t@tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items\n\t\tend\n\t\treturn @user_info, @task_lists, @tasks\n\tend", "def cache\n DataCache\n end", "def memo; end", "def force_refresh_facebook_expensive_cache\n cache(:write, :expires_in => DefaultExpires).facebook_friend_locations\n cache(:write, :expires_in => DefaultExpires).facebook_friend_interests\n cache(:write, :expires_in => DefaultExpires).facebook_friend_likes\n cache(:write, :expires_in => DefaultExpires).facebook_friend_activities\n #full_facebook_friends\n true\n end", "def refresh (num=@max_parallel,use_cache=true)\n\t\t puts \"Add entries to the local cache table from site tracker: \" if @verbose\n\t\t\tresults = Hash.new\n\t\t\ttags = @tag_store.keys\n\t\t\tif tags.size > 0\n\t\t\t\tParallel.map(tags, :in_processes => num) { |target|\n\t\t\t\t\tcheck_adware(target,use_cache)\n\t\t\t\t}.each do |process|\n\t\t\t\t\tif !process\n\t\t\t\t\t\tnext\n\t\t\t\t\telse\n\t\t\t\t\t\tresults.merge!(process)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@tag_store.merge!(results)\n\t\t\t\tputs \"Done loading adware entries.\"\n tags = nil\n\t\t\t\treturn results\n\t\t\telse\n\t\t\t\tputs \"Error: no entry is loaded. Please check your list and try again.\"\n\t\t\tend\n tags = nil\n\t\t\treturn results\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n \tend", "def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end", "def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end", "def create_cached_global_timeline\n\t\tif REDIS.exists(\"latest100\") == false\n\t\t\tglobal_tweets = Tweet.search_latest_tweets(\"\")\n\t\t\tglobal_tweets.each do |tweet|\n\t\t\t\thash = Hash.new\n\t\t\t\thash[:user_id] = tweet.user_id\n\t\t\t\thash[:handle] = tweet.handle\n\t\t\t\thash[:text] = tweet.text\n\t\t\t\thash[:created_at] = Time.at(tweet.created_at).to_s\n\n\t\t\t\tREDIS.lpush(\"latest100\", hash.to_json)\n\t\t\tend\n\t\tend\n\tend", "def cache\n @cache ||= {}\n end", "def cache\n @cache ||= {}\n end", "def prepareForReuse; end", "def outdated; end", "def cache\n @cache ||= build_cache\n end", "def build_cache\n []\n end", "def memo\n derived_values.last\n end", "def counter_cache; end", "def ensure_cache_up_to_date\n self.last_update_timestamp = self.redis.get(\"bluster:last_update_timestamp\").to_i\n if self.last_update_timestamp.nil?\n update_object_cache\n elsif self.last_update_timestamp != File.new(self.objects_path).mtime.to_i\n update_object_cache\n end\n end", "def singleton0_cache; end", "def cached_dynamo_field_values\n # We only want to load the field_values available for this model 1 time otherwise it'll query\n # for each value read from the dynamo model. This was really slowing things down like exporting a model\n # to xls or something where you are reading 100's of dynamo model's and values all at one time.\n self.dynamo_field_value_cache ||= DynamoFieldValue.find_all_by_model_id(self.id)\n end", "def related_releases\n Rails.cache.fetch(\"releases/release-#{id}\", :expires_in => 1.hour) do\n real_releases.all(:order => 'date DESC', :limit => 15)\n end\n end", "def last_retrieved\n unless self.cache_object.nil?\n @last_retrieved = self.cache_object.last_retrieved\n end\n return @last_retrieved\n end", "def load_cache\n a = dataset.all\n h = {}\n a.each{|o| h[o.pk.freeze] = o.freeze}\n @all = a.freeze\n @cache = h.freeze\n end", "def cache_users(stuff)\r\n query_result = stuff.slm.find_all(:user)\r\n query_result.each {|user| add_user(user)}\r\n puts \"\\n\"\r\nend", "def last_synchronize\n last_update\n end", "def cache\n @cache ||= {}\n end", "def cache\n @cache ||= {}\n end", "def cache\n @cache ||= {}\n end", "def fetch_from_db(cache_miss_ids)\n fail 'sub class to implement'\n end", "def filter_cache; end", "def last_updated_at\n if cache\n @last_updated_at ||= remote_last_updated_at\n else\n remote_last_updated_at\n end\n end", "def fetch; end", "def fetch; end", "def loadHistoric()\n\t\treturn @rankedDB.execute(\"SELECT historic FROM ranked WHERE idMap = '#{@idMap}'\").shift.shift\n\tend", "def sync\n # TODO stop forcing a sync every time.\n @cache.sync\n\n if cloned?\n fetch\n else\n clone\n end\n reset\n end", "def fetch_followed\n cache(:expire_in => 2.hours).followed\n end", "def latest\n self\n end", "def refresh\n self.first_name, self.last_name, self.email =\n @redis.hmget(\"contact:#{@id}\", 'first_name', 'last_name', 'email')\n self.media = @redis.hgetall(\"contact_media:#{@id}\")\n self.media_intervals = @redis.hgetall(\"contact_media_intervals:#{self.id}\")\n self.media_rollup_thresholds = @redis.hgetall(\"contact_media_rollup_thresholds:#{self.id}\")\n\n # similar to code in instance method pagerduty_credentials\n if service_key = @redis.hget(\"contact_media:#{@id}\", 'pagerduty')\n self.pagerduty_credentials =\n @redis.hgetall(\"contact_pagerduty:#{@id}\").merge('service_key' => service_key)\n end\n end", "def all\n @cache ||= Request.get('/data')\n\n end", "def updated_data; end", "def cache_version_data\n {}\n end", "def retrieve\n # TODO remove !!self.graph after run once\n if self.new_item? # !!self.graph\n @since_date = 6.months.ago\n end\n @bulk_insert_array = []\n @bulk_update_hash = {}\n puts \" retrieve #{self.id} #{since_date}\"\n since = since_date\n hasta = until_date\n started=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n success = nil\n while (hasta - since_date) >= back_to_date\n since = hasta - back_to_date\n success = do_retrieve(since, hasta)\n # yes just minus 1 second, becomes the end of previous day\n hasta = since - 1\n end\n if !@bulk_update_hash.blank?\n # FbPost.update_bulk! [:replies_to_comment,:post_created_time], @bulk_update_hash\n FbPost.update_bulk! @bulk_update_hash\n @bulk_update_hash = {}\n end\n if !@bulk_insert_array.empty?\n # puts \" retrieve call FbPost.import_bulk!\"\n FbPost.import_bulk! @bulk_insert_array\n @bulk_insert_array = []\n end\n save_posts_details\n self.update_attributes :new_item=>false,:status=>success,:updated_at=>DateTime.now.utc\n begin\n # for today only\n daily_aggregate_data\n rescue Exception=>ex\n logger.error \" retrieve daily_aggregate_data #{ex.message}\"\n end\n begin\n # for past 7 days if no argument \n aggregate_data_daily\n rescue Exception=>ex\n logger.error \" retrieve aggregate_data_daily #{ex.message}\"\n end\n # create additional fb_pages if neccessary\n # aggregate_data 1,'day', true\n # recent_page available after aggregate_data\n save_lifetime_data\n ended=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n puts \" id #{self.id} finished retrieve #{started} - #{ended} \"\n STDOUT.flush\n end", "def build_similarity_cache\n similar = Note.find_similar_raw(self)\n Note.memoize(self,similar,self.user_id)\n end", "def memoize_all; CurrentParser[:memoize]=:all; end", "def cache_fetch(*args)\n super { |key| @store[key] }\n end", "def update_cache\r\n Rails.cache.delete(\"All#{self.class.name.to_s}\")\r\n end", "def head\n raise InvalidDbError if @stale\n super\n end", "def use\n update_column(:last_used_at, Time.now)\n end", "def cached_data(list)\n @klass.where(object_key: list) if @klass\n end", "def cached_instance\n @cached_instance ||= read_instance\n end", "def cached_fetch(key)\n fetch(key) do\n return yield unless h = self[:cache]\n Sequel.synchronize{return h[key] if h.has_key?(key)}\n value = yield\n Sequel.synchronize{h[key] = value}\n end\n end", "def all_fetched_entries\n @entry_cache.all_entries\n end", "def index\n @orders = Order.all\n @cache_key_orders = cache_key('all', @orders)\n fresh_when @cache_key_orders, public: true\n end", "def cache_statistics data\n self.start_date = DateTime.parse data.first[:timestamp]\n self.duration = DateTime.parse(data.last[:timestamp]).to_time - DateTime.parse(data.first[:timestamp]).to_time\n calculate_distance\n self.min_speed = data.map{|p| p[:speed]}.min\n self.max_speed = data.map{|p| p[:speed]}.max\n self.min_height = data.map{|p| p[:alt]}.min\n self.max_height = data.map{|p| p[:alt]}.max\n save\n end", "def last_seen_at() ; info_time(:last_seen) ; end", "def refresh_cache\n @cache = build_cache\n end", "def update_if_necessary\n # we should have a counter stat already if it got to this class\n # only update stats if it's after the date of the last updated date for record\n return unless new_record? || updated_at.nil? || Time.new.localtime.to_date > updated_at.localtime.to_date\n update_usage!\n update_citation_count!\n\n self.updated_at = Time.new # seem to need this for some reason\n\n save!\n end", "def index\n @people = Person.scoped\n\n # Add last_modified header based on @people last update time.record\n # public value implies the cache can be stored in a proxy as Rack::Cache\n fresh_when last_modified: @people.maximum(:updated_at), public: true\n end", "def cache\n the_current_time = current_time\n cache_loaded_at = @cache.loaded_at if @cache\n\n if @cache && cache_expiration_policy_object.stale?(cache_loaded_at, the_current_time)\n flush!(:stale, :loaded => cache_loaded_at, :now => the_current_time)\n end\n\n unless @cache\n instrument('cache_load') do\n @cache = LowCardTables::LowCardTable::Cache.new(@low_card_model, @low_card_model.low_card_options)\n end\n end\n\n @cache\n end", "def data\n # This is a common memoization technique used in Ruby\n @data ||= normalize_data\nend", "def saved_objects\n TimeEntry.where(:id => saved_items.pluck(:obj_id)).order(:id).preload(:activity, :project, :issue => [:tracker, :priority, :status])\n end", "def live_metadata\n metadatas[full_path] ||= build_metadata\n end", "def update(straight = false)\n @prefix_table = {}\n @iso_code_table = {}\n @vendor_table = {}\n vendor_list(straight)\n @mem_timestamp = if config.cache.is_a?(Proc)\n proc_timestamp\n else\n file_timestamp\n end\n end", "def index\n @featured_memorials = Memorial.most_recent\n end", "def cache_change\n @project = Project.find_by_id(project_id)\n if !@project.nil? # prevents issue where @project was returning null, if the project hadn't been approved yet.\n if @project.is_stage_one == \"Is not Stage One\" && @project.active == true && attribute_name != 'active' && @project.donor.name == 'China'\n\n first = Rails.cache.fetch(\"recent/first\")\n\n # if the last project was the same as this one, store it in the string\n # instead of making a new entry\n if first && first[:id] == project_id\n action = first[:action]\n new_action = \"#{(attribute_name || \"#{association_model}s\").titleize.downcase}\"\n\n #no duplicates\n unless /#{new_action}/ =~ action\n first[:action] = action << \", #{new_action}\"\n first[:time] = self.updated_at\n Rails.cache.write(\"recent/first\", first)\n else\n false\n end\n\n else\n # add a new entry and move the old ones down\n second = Rails.cache.fetch(\"recent/second\")\n\n Rails.cache.write(\"recent/third\", second)\n Rails.cache.write(\"recent/second\", first)\n @update_sent = \"updated #{(attribute_name || \"#{association_model}s\").titleize.downcase}\"\n json = {\n id: @project.id,\n title: @project.title,\n info: @project.to_english(exclude_title: true),\n action: @update_sent,\n time: self.updated_at\n }\n\n Rails.cache.write(\"recent/first\", json)\n end\n else\n false\n end\n end\n end" ]
[ "0.6651593", "0.6651593", "0.6651593", "0.6651593", "0.6651593", "0.6651593", "0.6651593", "0.66125804", "0.66006553", "0.6380731", "0.62917256", "0.62245893", "0.62245893", "0.6193067", "0.6193067", "0.6111375", "0.6048916", "0.6005472", "0.6002445", "0.598984", "0.59500194", "0.59033275", "0.5893364", "0.5875648", "0.58655584", "0.58621544", "0.5830071", "0.57549965", "0.57516986", "0.57464564", "0.57429236", "0.57429236", "0.5737502", "0.57322985", "0.57316864", "0.57307184", "0.5711353", "0.56943345", "0.56936103", "0.56901145", "0.5668214", "0.566002", "0.56526613", "0.56526613", "0.5640862", "0.5630519", "0.5630519", "0.56199527", "0.5608226", "0.55800927", "0.5574621", "0.557356", "0.5570321", "0.5563269", "0.5556059", "0.5551323", "0.5525119", "0.5521167", "0.5520537", "0.55149496", "0.55096173", "0.5506551", "0.5506551", "0.54974353", "0.54955965", "0.5494542", "0.5483093", "0.5471896", "0.5471896", "0.54667264", "0.5462654", "0.5441315", "0.5437914", "0.54365075", "0.5432973", "0.54320335", "0.54318124", "0.54303104", "0.5425796", "0.54179406", "0.54060924", "0.5404642", "0.5403025", "0.5400569", "0.5400443", "0.539476", "0.53858566", "0.5378079", "0.5373898", "0.53717685", "0.5368225", "0.5367322", "0.53662604", "0.53615814", "0.5356694", "0.5337613", "0.53336984", "0.5323748", "0.53230816", "0.53208715", "0.53195953" ]
0.0
-1
Find a SuccessfulAttempt for the EvaluatedTask. if a SuccessfulAttempt is found, return the first one found. else return nil if none found
def find_successful_attempt_for_task(evaluated_task) self.successful_task_attempts.detect { |already_ran_task| already_ran_task.task_name == evaluated_task.name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attempt(problem)\n\t\tif problem\n\t\t\treturn self.attempts.where(problem_id: problem.id).first\n\t\tend\n\tend", "def assignment_solution(ass_id)\n self.final_completed_assignments.select{ |a| a.assignment_id == ass_id }.first\n end", "def return_solution_found\n @open.select(&:goal).first\n end", "def lookup(taskPath, initial_scope=nil)\n task = nil\n \n projectPath, name = GetProjectFilePathName(taskPath)\n \n if(projectPath != nil)\n # return the project file specific task\n projectFile = @ProjectFileLoader.LoadedProjectFile(projectPath.RelativePath)\n if(!projectFile)\n return task\n end\n task = projectFile.lookup(name, initial_scope)\n else\n # return the first task that is found in any project file\n @ProjectFileLoader.LoadedProjectFiles().each do |projFile|\n task = projFile.lookup(name, initial_scope)\n if(task != nil)\n break\n end\n end\n end\n return task\n end", "def get_current_exam_attempt(user_id, course_id, exam_id)\r\n response = get_exam_attempts(user_id, course_id, exam_id)\r\n unless response.error?\r\n attempts_json = response.content\r\n json_obj =JSON.parse(attempts_json)\r\n attempts = json_obj['attempts'] || []\r\n current_attempt = nil\r\n\r\n current_attempt = attempts.find { |attempt| !attempt['isCompleted'] }\r\n\r\n if !current_attempt.nil? && !current_attempt.empty?\r\n attempt = { 'attempt' => current_attempt }\r\n response.content = attempt.to_json\r\n else\r\n response.status_code = LearningStudioCore::BasicService::HTTPStatusCode::NOT_FOUND\r\n response.content = \"\"\r\n end\r\n end\r\n\r\n response\r\n end", "def _get_task_by_name(task_name)\n @tasks.each do |t|\n return t if t.name == task_name\n end\n raise \"Unknown Task!\" # couldn't find it. boo.\n end", "def successful_task_attempts\n OneTimeTasker::SuccessfulTaskAttempt.all\n end", "def task_find(task_class)\n tasks_active.to_a.find { |t| t.is_a?(task_class) }\n end", "def puzzle_attempt\n @puzzle_attempt = user_rating.rated_puzzle_attempts\n .find_by(id: params[:id])\n end", "def next_task\n if last?\n return self.episode.lower_item.tasks.first unless self.episode.lower_item.nil?\n else\n return self.lower_item\n end\n end", "def find_item_or_fail(plan)\n items.where(stripe_plan: plan).first\n end", "def next_available_immediate_task\n\t\timmediate_tasks.select{ |t| !t.completed? }.sort_by(&:rank).first\n\tend", "def next_task_id\n\n # If the non_completed_task_ids array is empty, we're done.\n if non_completed_task_ids.empty?\n :lesson_finished\n\n # Else, if the user is completing the last lesson, return them to the first lesson they skipped and didn't complete\n elsif current_task_id == lesson.tasks.last.id\n non_completed_task_ids.min\n\n # Otherwise, just go on to the next lesson\n else\n current_task_id + 1\n end\n\n end", "def get_running_task(t_info) \n if t_info.key?(\"time_entries\")\n t_info[\"time_entries\"].each do |i|\n return i if i.key?(\"stop\") == false\n end\n return \"This User has no Running Tasks\"\n else\n return \"This User has no Tasks!\"\n end\n end", "def get_analysed_against_run_result(run_result)\n results_database = runtime.databases.results_database\n analyser = results_database.get_task_results(run_result, 'analyser').first\n return nil if analyser.nil?\n\n find_run_result(analyser.properties['previous_run'])\n end", "def first!\n fail_not_found_if_nil(first)\n end", "def resolve_task(name)\n name = name.to_s\n @tasks.each do |task|\n return task if task.name == name\n end\n @salticid.tasks.each do |task|\n return task if task.name == name\n end\n nil\n end", "def result\n results.first\n end", "def solution\n if @pb_list.empty? then\n return nil\n elsif @pb_list[0].complete? then\n return @pb_list[0]\n else\n return nil\n end\n end", "def result\n wait_for\n # If the task threw an exception during execution we raise that here.\n @task_error ? raise(@task_error) : @task_result\n end", "def find_task(name)\n name = name.to_sym unless name.nil?\n @tasks[name]\n end", "def attempts_for course\n exams.for_course(course).first(:order => \"attempt DESC\").attempt rescue 0\n end", "def get_first_target\n\n if self.script_targets.empty? && self.script_groups.empty?\n return nil\n else\n if !self.script_targets.empty?\n target = self.script_targets[0].target\n else\n if self.script_groups[0].target_group.target_group_assignments.empty?\n return nil\n else\n target = self.script_groups[0].target_group.target_group_assignments[0].target\n end\n end\n end\n\n return target\n\n end", "def first_not_done_exercise\n i = 0\n while(i < self.user_sequence.size() && self.user_sequence[i][2]) do\n i = i + STEP_SIZE\n end\n if i < self.user_sequence.size()\n i = i - STEP_SIZE + 1\n while(self.user_sequence[i][2]) do\n i = i + 1\n end\n return self.user_sequence[i][0]\n elsif self.user_sequence.last[2] # last exercise is done\n return nil\n else\n i = i - STEP_SIZE + 1\n while(self.user_sequence[i][2]) do\n i = i + 1\n end\n return self.user_sequence[i][0]\n end\n end", "def next_failed_check\n self.failed_checks.first\n end", "def best_problem\n return nil if @pb_list.empty?\n @pb_list[0]\n end", "def get_first_break_point(challenge, ans)\n setting =\n ApplicationController.helpers.first_break_point_setting\n answers = challenge.answers.valid.where(flag: ans.flag)\n if setting.any? && (answers.count - 1) < setting.count\n (setting[answers.count - 1] * ans.flag.point).to_i\n else\n 0\n end\n end", "def attempt_id\n ENV['mapred_task_id']\n end", "def get_original_result\n non_pr_results.first\n end", "def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end", "def first\n results.first\n end", "def find_equivalent_piece(equivalent_piece)\n all_pieces.select { |piece| piece == equivalent_piece }.first\n end", "def success?\n @success ||= @tasks_results.all?(&:success?)\n end", "def next_exercise_minimal_path_not_done\n i = 0\n while(i < self.user_sequence.size() && self.user_sequence[i][2]) do\n i = i + STEP_SIZE\n end\n if i < self.user_sequence.size()\n return self.user_sequence[i][0]\n elsif self.user_sequence.last[2] # last exercise is done\n return nil\n else\n return self.user_sequence.last[0]\n end \n end", "def result\n @s.first[1] || t.default\n end", "def result\n results[0]\n end", "def attempted_record\n @attempted_record\n end", "def last_attempt_number (user)\n t = user.answers.every.desc(:created_at).limit(1).first\n unless t.nil? \n t.attempt_number\n else nil\n end\n end", "def status\n attempts = Attempt.where(:quiz_id => self.quiz_id,:user_id => self.user_id)\n \n if attempts.count == 0\n return :new\n else\n # iterate through attempts and return :compelted if\n # any attempt with completed => true is encountered.\n # else return :paused\n attempts.each do |attempt|\n if attempt.completed\n return :completed\n end\n end\n return :paused\n end\n end", "def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend", "def next_available_task\n\t\tnat_candidate = next_available_immediate_task\n\t\tif nat_candidate && nat_candidate.has_subtasks?\n\t\t\tnat_candidate.next_available_task\n\t\telse\n\t\t\tnat_candidate\n\t\tend\n\tend", "def get_job(job, ds = nil)\n (jobs_to_run + jobs_running).find do |j|\n if ds.nil?\n j[:ds].nil? and j[:job] == job\n else\n (! j[:ds].nil?) and j[:ds].name == ds.name and j[:job] == job\n end\n end\n end", "def get_result(key)\n r = results\n if r != nil\n return r.fetch(key, nil)\n end\n nil\n end", "def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend", "def first\n matches.first\n end", "def getAttemptNumber(assessment_id)\n assessments_answers = AssessmentAnswer.where(user_id: current_user.id, assessment_id: assessment_id)\n if assessments_answers != nil && assessments_answers.length > 0\n assessments_answers = assessments_answers.order(attempt_number: :desc)\n if assessments_answers.first.attempt_number != nil\n assessments_answers.first.attempt_number\n else\n 0\n end\n else\n # puts \"Assessment_answer is nil\"\n 0\n end\n end", "def lookup_in_scope(name, scope)\n loop do\n tn = scope.path_with_task_name(name)\n task = @tasks[tn]\n return task if task\n break if scope.empty?\n scope = scope.tail\n end\n nil\n end", "def find_job(job_id)\n find_users.each do |user|\n user.find_jobs.each do |job|\n return job if job.id == job_id\n end\n end\n\n return nil\n end", "def candidate\n candidates.first\n end", "def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end", "def getNext\n tasks = @db[:tasks]\n query_statuses = [\n Task.getStatusValue(:not_started),\n Task.getStatusValue(:restarted),\n Task.getStatusValue(:waiting),\n ]\n db_task = tasks.where(:status => query_statuses).order(:wake).order(:created).first\n if !db_task.nil?\n if self.lock db_task[:id]\n begin\n require db_task[:path]\n task = Marshal::load(db_task[:data])\n task.id = db_task[:id]\n status = Task.getStatusValue :running\n tasks.where(:id => task.id).update :status => status\n return task\n rescue\n self.unlock db_task[:id]\n end\n else\n @logger.warn \"lock contention for task #{db_task[:id]}\"\n return nil\n end\n end\n end", "def parent_workflow_task\n if ! (_classifications = parent_classifications.limit(1)).empty?\n _classifications.first.workflow_task\n end\n end", "def next_task(tasks = @@DISTANCE_TASKS+@@INCLADE_TASKS, save = true)\n tasks.find do |t|\n if metadata[\"run_#{t}\"] == false or\n (!is_clade? and @@INCLADE_TASKS.include?(t) and\n metadata[\"run_#{t}\"] != true)\n false\n else\n add_result(t, save).nil?\n end\n end\n end", "def best_candidate\n self.by_quality.first\n end", "def first_not_done_exercise_after_index(index)\n i = index\n while(i < self.user_sequence.size() && self.user_sequence[i][2]) do\n i = i + 1\n end\n if(i < self.user_sequence.size())\n return self.user_sequence[i][0]\n else \n return nil\n end \n end", "def get_next_task\n if worker_key && !worker_key.empty?\n BdrbJobQueue.find_next(worker_name.to_s,worker_key.to_s)\n else\n BdrbJobQueue.find_next(worker_name.to_s)\n end\n end", "def value\n # double-checked locking is safe because we only update once\n return @value if @fulfilled\n\n @mutex.synchronize do\n unless @fulfilled\n begin\n @value = @task.call\n rescue\n @value = @default\n ensure\n @fulfilled = true\n end\n end\n return @value\n end\n end", "def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend", "def first!\n first or raise RecordNotFound\n end", "def last_attempt(answer)\n submission = answer.submission\n\n attempts = submission.answers.from_question(answer.question_id)\n last_non_current_answer = attempts.reject(&:current_answer?).last\n current_answer = attempts.find(&:current_answer?)\n # Fallback to last attempt if none of the attempts have been autograded.\n latest_attempt = last_non_current_answer || attempts.last\n\n submission.attempting? ? latest_attempt : current_answer\n end", "def next_step\n if goto_true.present?\n fs = FlowStep.job_flow_step(job_id: job_id, flow_step: goto_true)\n if fs.entered?\n job.quarantine!(msg: \"Broken flow, step already entered #{fs.step}, called from #{self.step}\")\n return nil\n else\n return fs\n end\n end\n nil\n end", "def for_judge(judge)\n pilot_flight.pfj_results.where(:judge_id => judge).first\n end", "def getTaskByID(id) \n ret = nil \n\n @Tasks.each do |task| \n ret = task if task.ID == id\n end \n end", "def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend", "def result_for (label)\n (results = @results[label]) && # There are results for this tag\n results.first && # First hash in the list of results\n results.first.out[0]\n end", "def found\n return @found\n end", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend", "def next\n # try to set next job to running (already running is ok)\n until ready_jobs.empty? || ready_jobs.first.running?\n unless set_to_running(ready_jobs.first)\n locked_jobs << ready_jobs.shift # some other executor running this\n end\n end\n if ready_jobs.empty?\n return nil\n else\n return ready_jobs.first.next_cucumber_test_case\n end\n end", "def get_assignment\n return TestCase.find(params[:id]).assignment\n end", "def get_result\n\t\texecute unless @result\n\t\treturn @result\n\tend", "def solve\n if invalid?\n nil\n elsif solved?\n self\n else\n x, y = @strategy.next_cell(@grid)\n\n # Try each of the possible values for cell [x, y] and if one leads to a solution, return that solution\n self[x, y].each do |val|\n next_game = self.clone\n next_game[x, y] = val\n next_solution = next_game.solve\n return next_solution unless next_solution.nil?\n end\n\n # No solution found\n nil\n end\n end", "def first!\n first || raise_record_not_found_exception!\n end", "def get_question\n if self.key.to_s =~ /(an_)([0-9])/\n q_id = QUESTION_MAP[\"qs_#{$+}\".to_sym][:id]\n q = ProfileQuestion.find_by_profile_id_and_question_id(self.profile_id, q_id)\n q.answer\n else\n nil\n end\n end", "def last_attempt(answer)\n submission = answer.submission\n attempts = submission.answers.from_question(answer.question_id)\n submission.attempting? ? attempts[-2] : attempts[-1]\n end", "def min_ask\n asks.first\n end", "def get_next_task\n sp = current_user.service_provider\n task = sp.get_next_task(belongs_to_common_pool?,belongs_to_back_office?,belongs_to_front_office?)\n if task\n task.update_attributes(:assigned_to_user_id=>sp.user.id,:assigned_by_user_id=>nil)\n flash[:notice] = t(:flash_new_task_from_queue)\n else\n flash[:error] = t(:warning_task_not_found)\n end\n redirect_to(:action => 'index')\n end", "def tracker\n tr = @params['tr']\n if tr\n tr.first\n else\n nil\n end\n end", "def get_user_first_score user\r\n return nil unless self.user_is_done? user\r\n correct = 0\r\n self.problems.each do |p|\r\n (correct = correct + 1) if p.user_did_correct_first?(user)\r\n end\r\n correct\r\n end", "def next_availability\n if job = jobs.detect { |k, v| v['reserved_at'].nil? }\n job.first\n end\n end", "def get_contest\n @contest = Contest.find_by_id(params[:id])\n return if check_nil_object(@contest)\n end", "def solution\n return self.answers.select {|x| x.correct}[0] if solved?\n nil\n end", "def find_next_level_for_session(script)\n session_progress = session[:progress] || {}\n\n script.script_levels.each do |sl|\n next unless sl.valid_progression_level?\n passed_level = session_progress.fetch(sl.level_id, -1) < Activity::MINIMUM_PASS_RESULT\n return sl if passed_level\n end\n\n nil\n end", "def get_dashboard user_id\n task = self.tasks.my_uncompleted(user_id).sorted.first\n if task.nil?\n if self.start_on > Date.today || self.expires_on < Date.today\n -1\n else\n -2 # -2 : no task currently - create one!\n end\n else\n task.percent_complete\n end\n end", "def get_exam_attempt(user_id, course_id, exam_id, attempt_id)\r\n get(Path::USERS_COURSES_EXAMS_ATTEMPTS_WITH_ID % [user_id,\r\n course_id,\r\n exam_id,\r\n attempt_id])\r\n end", "def find(ticket)\n\t\t\tself.result.select{ |p| p['Ticket_Number'] == ticket }.first\n\t\tend", "def first()\n @tiers.each do |tier|\n unless tier.empty?()\n return tier[0]\n end\n end\n \n return nil\n end", "def successful_call\n return @successful_call\n end", "def get_submission\n @submission = Submission.find_by_id(params[:id])\n return if check_nil_object(@submission)\n @problem = @submission.problem\n end", "def get_flow(_task)\n @last_flow ||= nil\n flow = @last_flow&.first\n @last_flow = nil\n flow\n end", "def current\n current_post = Post.last\n\n # makes 2 checks.\n # 1. if the item isn't nil. (sanity check)\n # 2. if the task timed out yet. completed time > time now.\n if current_post != nil # and current_post.completed_at > Time.now.utc\n current_post\n else\n nil\n end\n end", "def currentStep\n steps = @workflow[:steps]\n\n step = nil\n if @current_step_index < steps.size\n step = WorkflowStep_Shim.new(steps[@current_step_index])\n end\n return Optional_Shim.new(step)\n end", "def first(name=nil)\n name.nil? ? matches.first : find(name, false).first\n end", "def find_first_by_conditions(twitter_id, is_valid)\n begin\n #$logger.info \"#{self.class.name}.#{__method__}(#{twitter_id}, #{is_valid})\"\n puts(\"#{self.class.name}.#{__method__}(#{twitter_id}, #{is_valid})\")\n result = Friend.find(:first, :conditions => [ \"twitter_id = ? and is_valid = ?\", twitter_id, is_valid ])\n if not result.nil?\n #$logger.info \"Result returns object: #{result}\"\n puts(\"Result returns object: #{result}\")\n else\n #$logger.info \"Result DOES NOT return any record!\"\n puts(\"Result DOES NOT return any record!\")\n end\n rescue Exception\n #TwitterUtil.show_error(\"#{self.class.name}.#{__method__}()\",($!).class,($!))\n puts(\"#{self.class.name}.#{__method__}()\",($!).class,($!))\n #$logger.info \"Result returns no records!\"\n puts\"Result returns no records!\"\n result = nil\n end\n return result\n end", "def first_noninteger_index\n integer_task.first_noninteger_index(plan)\n end", "def find(id)\n found = nil\n found = @candidates.find { |candidate| candidate.fetch(:id) == id }\n # found = @candidates.select { |candidate| candidate.fetch(:id) == id }\n # found && found = found[0]\nend", "def nextResult\n result = nil\n @mutex.synchronize do\n result = @results.shift\n @progressMutex.synchronize{ @requestProgress.delete result.requestId } if result\n end\n result\n end", "def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend", "def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend", "def last_unaccepted_submission_for(task)\n last_sub = self.last_submission_for(task)\n last_sub if last_sub and !last_sub.is_correct?\n end" ]
[ "0.59902287", "0.54860675", "0.5393403", "0.5380933", "0.5239204", "0.5222303", "0.5192073", "0.51379395", "0.51314205", "0.50945306", "0.5085403", "0.50730133", "0.5069035", "0.5061519", "0.5054054", "0.5049524", "0.50483805", "0.5044419", "0.50382704", "0.49822503", "0.49681205", "0.4950025", "0.49336478", "0.4909798", "0.48967943", "0.48902658", "0.48662046", "0.48543808", "0.4847129", "0.48126903", "0.4808633", "0.4800322", "0.47830138", "0.47808272", "0.47693744", "0.47502458", "0.47435534", "0.47399986", "0.4735971", "0.47316653", "0.4718243", "0.47072783", "0.47012976", "0.46889448", "0.4688874", "0.46872663", "0.4680805", "0.46723098", "0.46718884", "0.46701688", "0.46657154", "0.4658725", "0.4656982", "0.4656459", "0.4651495", "0.46405604", "0.46373367", "0.46282035", "0.4626643", "0.46266115", "0.46261382", "0.46069893", "0.4592861", "0.4592673", "0.45917976", "0.4583241", "0.45775923", "0.45756495", "0.45744845", "0.45677447", "0.45660472", "0.4562531", "0.45618582", "0.45585376", "0.4552973", "0.45518976", "0.4545928", "0.4544535", "0.45433423", "0.45309797", "0.45303395", "0.45283976", "0.4527718", "0.4525684", "0.45237753", "0.45095706", "0.45054272", "0.45000735", "0.44981083", "0.4489649", "0.4483679", "0.44824985", "0.44818413", "0.4475037", "0.44652265", "0.44613913", "0.44608796", "0.44608572", "0.4456663", "0.44551393" ]
0.75626284
0
def year( y) one_year = (1..12).to_a years = (1800..2250) print years if y end endprint
def month_arg_to_s(m) month_array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] month_array[m - 1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dog_years(year)\n\t\tp year*7\n\tend", "def yn(year)\n return year if year.size == 4\n\n y = Date.today.year.to_s[2..4].to_i + 1\n case year.to_i\n when 0...y then \"20#{year}\"\n when y..99 then \"19#{year}\"\n end\n end", "def year() end", "def leap(year1,year2)\n\n for y in year1 .. year2\n if y % 4 == 0 && y % 100 != 0\n p \"Leap Year: #{y}\"\n elsif y % 100 == 0 && y % 400 == 0\n p \"Leap Year: #{y}\"\n end\n\n end\n\nend", "def years\n case @age\n when 1..5 then puts \"You are a baby\"\n when 6..12 then puts \"You are a child\"\n when 13..21 then puts \"You are a young people\"\n when 22...35 then puts \"You are adult\"\n end\n end", "def dog_years(years)\n\t\tnew_years = years * 7\n\t\tputs new_years\n\tend", "def all_year\n beginning_of_year..end_of_year\n end", "def year_name(number); end", "def work_out_year(value)\n case value\n when 0..39\n 2000 + value\n when 40..99\n 1900 + value\n else\n value\n end\n end", "def amy_years\n (Time.now.year - 1977).ordinalize\n end", "def year\n current_year = Date.today.year\n\n case raw_year\n when current_year; \"this year\"\n when current_year.next; \"next year\"\n when current_year.pred; \"last year\"\n else; raw_year.to_s\n end\n end", "def year; end", "def year; end", "def year(input) = new_year(input).year - 621", "def year\n puts \"Please enter a year:\"\n year = gets.chomp.to_s\n puts \"Fantasic! You have answered #{year}\".colorize(:light_blue)\n year = year.to_i\n\n case year\n when 0..500\n puts \"year 0 to 500AD\"\n return 1\n when 501..1000\n puts \"year 501AD to 1000AD\"\n return 2\n when 1001..1500\n puts \"year 1001 to the 1500\"\n return 3\n when 1501..2000\n puts \"1501 to 2000\"\n return 4\n when 2001..2020\n puts \"Current time : 2001 to 2020\"\n return 5\n when 2020..3000\n puts \"The future 2020 to 3000 and beyond!\"\n return 6\n end\n#might be better to put the case in here for the years\nend", "def dog_years(age)\n \thuman_year = age * 7\n \tp human_year.to_i\n end", "def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end", "def gas_year\n y = year\n if self< Date.new(y,10,1)\n y\n else\n y+1\n end\n end", "def print_mvyr\n puts @year\nend", "def a_year()\n now = Time.now\n if now.month < 4\n now.year - 1\n else\n now.year\n end\nend", "def start_year\n Time.now.year - 75\n end", "def make_year(year, bias); end", "def bissextille(year)\n if(year.is_a? Integer)\n if( (year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0)) )\n puts \"L'Année #{year} bissextile.\"\n else puts \"L'Annnée #{year} est NON bissextile.\"\n end\n else \"L'Année n'est pas un entier.\"\n end\nend", "def year\n ((semester - 1) / 2) + 1\n end", "def format_year(year)\n \"#{year}-#{year+1}\"\n end", "def w_year; end", "def valid_year?(y, min, max)\n return false unless y\n return false if y.length != 4\n\n year = y.to_i\n year >= min && year <= max \n end", "def inspect\n \"the year is \" + humanize_list(@years)\n end", "def copyright_notice_year_range(start_year)\n\t\t# In case the input was not a number (nil.to_i will return a 0)\n\t\tstart_year = start_year.to_i\n\n\t\t# Get the current year from the system\n\t\tcurrent_year = Time.new.year\n\n\t\t# When the current year is more recent than the start year, return a string \n\t\t# of a range (e.g., 2010 - 2012). Alternatively, as long as the start year \n\t\t# is reasonable, return it as a string. Otherwise, return the current year \n\t\t# from the system.\n\t\tif current_year > start_year && start_year > 2000\n\t\t\t\"#{start_year} - #{current_year}\"\n\t\telsif start_year > 2000\n\t\t\t\"#{start_year}\"\n\t\telse\n\t\t\t\"#{current_year}\"\n\t\tend\n\tend", "def first_year\n 2012\n end", "def start_year\n Time.now.year - 18\n end", "def leap_years\n puts \"Enter a start year:\"\n\tstart_year = gets.chomp.to_i\n\tputs \"Enter an ending year:\"\n\tending_year = gets.chomp.to_i\n\n\tleap_years = (start_year..ending_year).select do |year|\n\t\tleap_year?(year)\n\tend\n\tputs \"#{leap_years}\"\nend", "def leapyear(n)\n start = (n % 100 != 0 && n % 4 == 0) || (n % 100 == 0 && n % 400 == 0) ? n : n + (4 - (n % 4))\n (0...100).step(4).each do |e|\n year = start + e\n if year % 100 != 0\n puts year\n elsif year % 400 == 0\n puts year\n end\n end\nend", "def end_year\n Time.now.year - 90\n end", "def cwyear\n end", "def end_year\n Time.now.year \n end", "def year\n self.range('year')\n end", "def year\n end", "def work_out_year(value)\n case value\n when 0..39\n 2000 + value\n when 40..99\n 1900 + value\n when nil\n Time.zone.now.year\n else\n # We may be passed something that's not a straight out integer\n # These things include: BigDecimals, Floats and Strings.\n value.to_i\n end\n end", "def next_years\n current_year = Time.now.year\n current_year..(current_year + 4)\n end", "def dog_years(human_years)\n dog_age = human_years * 7\n puts \"Ole is #{dog_age} in dog years.\"\n end", "def dog_years(human_years)\n \tputs human_years / 7\n end", "def years_needed\n 30\n end", "def years() 365 * days end", "def faith_years\n (Time.now.year - 1991).ordinalize\n end", "def year1\n @year1 = @subtotal3 + @mobilisation + @tupe\n end", "def years\n self.to_i * 31_557_600\n end", "def year(year_range = (1930..1950))\n rand(year_range)\nend", "def print_year\n print_top_year\n print_body_rows\n end", "def set_year\n if set_month > 2 and set_month < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end", "def silly_years(year)\n years = []\n\n until years.length == 10\n year += 1\n digits = year.to_s\n\n first_two, middle_two, last_two = [\n digits[0..1], digits[1..2], digits[2..-1]\n ].map { |pair| pair.to_i }\n\n years << year if (first_two + last_two) == middle_two\n\n end\n\n years\nend", "def dog_years(integer)\n dog_years = integer*7\n puts \"#{integer} human years is equal to #{dog_years} dog years.\"\n end", "def age_verifier( x, y)\n current_year = Time.now.year\n if x + y == current_year\n true\n else \n false\n end\nend", "def year\n return @year\n end", "def year\n @year = params[:year].to_i\n @first_month = 1\n @last_month = (Date.today.year == @year) ? Date.today.month : 12\n end", "def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n \"\\#{start_year}\"\n else\n \"\\#{start_year}&#8211;\\#{end_year}\"\n end\n end", "def min_year\n 2015\n end", "def year\n puts \"Please enter a year:\"\n print \"> \"\n year = gets.chomp.to_s\n puts \"Fantasic! You have answered #{year}\".colorize(:light_blue)\n year = year.to_i\n case year\n when 0..500\n puts \"year 0 to 500AD\"\n return 1\n when 501..1000\n puts \"year 501AD to 1000AD\"\n return 2\n when 1001..1500\n puts \"year 1001 to the 1500\"\n return 3\n when 1501..2000\n puts \"1501 to 2000\"\n return 4\n when 2001..2020\n puts \"Current time : 2001 to 2020\"\n return 5\n when 2020..7000\n puts \"The future 2020 to 3000 and beyond!\"\n return 6\n else\n puts \"Time jump not defined. Set to random jump time\"\n return year\n end\nend", "def dog_years(x)\n\t\tdog_age = x * 7\n\t\tputs \"I am (secretly) #{dog_age} years old.\"\n\tend", "def year\n return @year\n end", "def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n start_year.to_s\n else\n start_year.to_s + '-' + end_year.to_s\n end\n end", "def year\n 2020\n end", "def set_year(m)\n if set_month(m) > 2 and set_month(m) < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end", "def year=(value)\n @year = value\n end", "def year\n\tprint \"Enter a Starting Year: \"\n\tyear1 = gets.chomp.to_i\n\t\n\tprint \"Enter an Ending Year: \"\n\tyear2 = gets.chomp.to_i\n\t\n\twhile year2 >= year1\n\t\tisLeap(year1)\n\t\tyear1 += 1\n\tend\nend", "def human_years \n age * DOG_YEARS\n end", "def dog_years(human_age)\n dog_years = human_age * 7\n p dog_years\n end", "def dog_years(human_years)\n human_years * 7\n end", "def year? = unit == 'year'", "def human_years\n age * DOG_YEARS\n end", "def human_years\n age * DOG_YEARS\n end", "def human_years\n age * DOG_YEARS\n end", "def dog_years(human_years)\n dog_years = human_years * 7\n p \"#{human_years} human years * 7 dog years = #{dog_years} dog years.\"\n end", "def list_leap_years(current, future)\n while current <= future do\n if current % 4 != 0\n puts \"#{current} is a common year.\"\n elsif current % 100 == 0 and current % 400 != 0\n puts \"#{current} is a common year.\"\n else\n puts \"#{current} is a leap year!!!\"\n end\n current += 1\n end\n end", "def dog_years (human_years)\n human_years * 7\n end", "def years ; self * 365.days ; end", "def validate_year(input, year)\n max_year = Date.today.year + 2\n year <= max_year && year >= 1900\n end", "def no_repeat_years(first_year, last_year)\nend", "def epochyear\n 2000 + @line1[18...20].to_i\n end", "def js_year(year)\n [year,1,1].compact.join(',')\n end", "def year\n if self.mitDirStudentYear\n Date.today.year + 4 - self.mitDirStudentYear.to_i + ((Date.today.month > 6)?1:0)\n else\n nil\n end\n end", "def academic_year\n academic_year = case quarter_code_id\n when 1\n \"#{year-1}-#{year}\"\n when 2\n \"#{year-1}-#{year}\"\n when 3\n \"#{year}-#{year+1}\"\n when 4\n \"#{year}-#{year+1}\"\n end\n academic_year\n end", "def year\n puts Rainbow(\"Please enter a year. [2006-Present]\").orange\n input = gets.chomp\n if Flights.find_by_year(input) == []\n puts Rainbow(\"SpaceX had no flights that year!\").red\n year\n elsif input.downcase == 'exit'\n exit\n elsif input.downcase == 'main'\n run\n else\n print_minor(Flights.find_by_year(input))\n end\n secondary_selection\n end", "def age_check(years)\n if years >= 21\n \tputs \"Cool, be right back with that.\"\n end\n\n if years < 21\n \tputs \"You got #{21 - years} years to go, dude.\"\n end\n end", "def get_next_yr\n\tset_cur_year(get_cur_year+1)\nend", "def human_years\n age * DOG_YEARS\n end", "def print_year_with_info(year)\n puts \"\"\n puts \"In #{year.year}, #{year.player} scored #{year.total_points} total points in #{year.games_played} total games.\"\n puts \"\"\n end", "def leap_year\n#ask for starting year\nputs \"What is the starting year?\"\nstart_year = gets.chomp.to_i\n\n#ask for ending year\nputs \"What is the ending year?\"\nend_year = gets.chomp.to_i\n\n#loop through array of years from start_year to end_year and select leap years based on given conditions\nleap_arr = []\n\n(start_year..end_year).select do |leap| \n leap_arr = leap % 4 == 0 || leap % 400 == 0\nend\nend", "def max_year\n year - (month < 12 ? 1 : 0)\n end", "def next_year(years = 1)\n advance(years: years)\n end", "def silly_years(year)\n years = []\n until years.length == 10\n year_str = year.to_s\n if (year_str[0..1].to_i + year_str[2..3].to_i == year_str[1..2].to_i)\n years << year\n end\n year += 1\n end\n\n years\nend", "def this_year\n year(Time.now)\n end", "def get_year\n @year ||= params[:year] ? params[:year].to_i : Time.now.year\n end", "def raw_year\n start_on.year\n end", "def get_years\n year = slice_year\n till_year = year.to_i - @past_years\n years = []\n year.to_i.downto(till_year) { |y| years << y }\n years\n end", "def silly_years(year)\n result_arr = []\n # retrieves first two digits\n first_half = year.to_s.split('')[0..1].join('').to_i\n while result_arr.length < 10\n first_half += 1\n mid = first_half%10\n next if mid*10 - first_half < 0\n \n mid = mid*10 + (((mid*10) - first_half)/10)\n second_half = mid - first_half\n year = first_half.to_s\n if second_half.to_s.length == 1\n year += \"0\" + second_half.to_s\n else\n year += second_half.to_s\n end\n \n \n result_arr << year.to_i\n end\n\n result_arr\nend", "def leap_year?(yr1)\r\n if yr1 % 4 > 0\r\n false\r\n elsif yr1 % 100 == 0\r\n if yr1 % 400 == 0\r\n true\r\n else\r\n false\r\n end\r\n elsif yr1 % 4 == 0\r\n true\r\n end\r\nend", "def year\n date&.strftime('%Y')\n end", "def print_age_in_years(age_in_years)\n\n format(\"%.2f\", age_in_years)\n\n if age_in_years < 30 #could probably use a CASE statement for this\n\n puts \"Your age in years: #{age_in_years}\"\n puts \"You are just a young pup!\"\n\n elsif age_in_years > 30 and age_in_years < 55\n\n puts \"Your age in years: #{age_in_years}\"\n puts \"In the prime of your life!\"\n\n elsif age_in_years > 55 and age_in_years < 100\n\n puts \"Your age in years: #{age_in_years}\"\n puts \"Lucky you! Time to enjoy the Golden Years!\"\n\n else\n\n puts \"Your age in years: #{age_in_years}\"\n puts \"Wow...what is your secret!\"\n\n end\n\nend", "def century_year(year)\n\n\tcentury_year = year.div(100) + 1\n\tcentury_year -= 1 if year % 100 == 0\n\tcentury_year.to_s + century_suffix(century_year)\n\nend", "def year\n yearInSchool\n end" ]
[ "0.75494283", "0.75429296", "0.7476533", "0.7330234", "0.72896326", "0.7256799", "0.722942", "0.7194466", "0.711142", "0.7110437", "0.71015155", "0.7077745", "0.7077745", "0.7069117", "0.7066054", "0.70652336", "0.70570046", "0.70355177", "0.70325786", "0.70255804", "0.7017869", "0.70153517", "0.7010383", "0.69791096", "0.6975976", "0.6971844", "0.6958804", "0.69386387", "0.69348377", "0.6934311", "0.6932982", "0.69247997", "0.68981034", "0.6894868", "0.6879912", "0.6878904", "0.68737394", "0.687327", "0.6855577", "0.6852696", "0.6843946", "0.6839501", "0.6829217", "0.6829217", "0.68280137", "0.6827687", "0.68191814", "0.68125945", "0.6811513", "0.68057245", "0.6794824", "0.67902607", "0.6776223", "0.67756957", "0.6772478", "0.6770036", "0.6764877", "0.67538905", "0.67502624", "0.674621", "0.6740799", "0.673439", "0.67248785", "0.67210585", "0.67132217", "0.6710637", "0.66834164", "0.66788566", "0.6672049", "0.66665787", "0.66665787", "0.66665787", "0.6664724", "0.6660841", "0.6658397", "0.6653333", "0.66507393", "0.6640608", "0.66334945", "0.6621936", "0.66017896", "0.65981066", "0.6594329", "0.6593499", "0.6590765", "0.65834445", "0.65773916", "0.6575603", "0.6573649", "0.65733373", "0.657328", "0.6572262", "0.65543836", "0.6553263", "0.65477073", "0.6544623", "0.6531138", "0.6529807", "0.6524343", "0.6510746", "0.64962804" ]
0.0
-1
Tests for Vodafone EPD simulator
def test_simulate_status_frame mqtt_client = SinapseEPDSimulatorVodafone.new(:host => $MQTT_broker, :port => $normal_port, :username => $MQTT_user, :password => $MQTT_password) mqtt_client.connect() # Simulating EPD #result = mqtt_client.simulate_status_frame #assert_equal result[0], {:topic => "LU/LUM/SEN", :message => "FFFFFF;30;1;90;150;220;60;0;60;60;0;60;50"} # RAE: To Improve # EPD with data status_parameters = { id_radio: "123456", temp: 30, stat: 1, dstat: 75, voltage: 220, current: 120, active_power: 75, reactive_power: 0, apparent_power: 75, aggregated_active_energy: 150, aggregated_reactive_energy: 0, aggregated_apparent_energy: 150, frequency: 50 } result = mqtt_client.simulate_status_frame("LU/LUM/SEN", status_parameters) assert_equal result[0], {:topic => "LU/LUM/SEN", :message => "123456;30;1;75;120;220.0;75.0;0.0;75.0;150;0;150;50;"} # RAE: To Improve mqtt_client.disconnect() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ios_testSVODEpisodePlay(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST SVOD EPISODE PLAY@見放題エピソード再生機能\"\n\n\t\t$totalTest = $totalTest + 1\n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tEpisodePlay.new.ios_getEpisodeToPlay(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tEpisodePlay.new.ios_getEpisodeToPlay(client)\n\t\t\tend\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 11\n\t\t@testcase_summary = \"見放題エピソード再生機能\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = \"\"\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def testSVODEpisodePlay(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[ANDROID] STARTING TEST EPISODE PLAY@見放題エピソード再生機能\"\n\n\t\t$totalTest = $totalTest + 1\n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tEpisodePlay.new.getEpisodeToPlay(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tEpisodePlay.new.getEpisodeToPlay(client)\n\t\t\tend\t\t\t\t\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@id='search_kind_selector']\", 0)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"ANDROID\" \n\t\t@testcase_num = 11\n\t\t@testcase_summary = \"見放題エピソード再生機能\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def run_fe_tests\n end", "def test_start_new_game\n @qtquickmemory.start\n @qtquickmemory.verify_pairs_open\n @qtquickmemory.verify_clock_timer\n @qtquickmemory.pause_game\n @qtquickmemory.exit\n end", "def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n\n if code == SUCCESS\n in_tests = false\n connection.waitfor(@end_reg) do |txt|\n in_tests = handle_text(txt: txt, in_tests: in_tests)\n end\n connection.puts(\"cont\\n\")\n end\n end", "def startTest(client, dtype, dname, logid, passw, ttype, tcsno, wifis, build)\n\n\t\t#$dname = client.waitForDevice(\"\\\"@name='#{dname}' AND @remote='true'\\\"\", 300000)\n\t\t@dtype = dtype\n\t\t@dname = dname\n\t\t@logid = logid\n\t\t@passw = passw\n\t\t@ttype = ttype\n\t\t@tcsno = tcsno\n\t\t@wifis = wifis\n\t\t@build = build\n\n\t\tif @ttype == \"select\"\n\t\t\tx = @tcsno.split \",\"\n\t\t\tputs \"::MSG::TCs to be EXECUTED : #{x}\"\n\t\t\t$total_tc = x.length\n\t\telse\n\t\t\t$total_tc = 37\n\t\tend\n\n\t\tif @dtype == \"ios\"\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"c24994f50118a6ae9db6a911da628b477a0ba401\", \"ipadair\")\n\t\t\tclient.setDevice(\"#{\"ios_app:\" + @dname}\")\n\t\t\t#client.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\tclient.sleep(2000)\n\t\t\tif @build == nil\n\t\t\t\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\telse\n\t\t\t\tputs ($obj_instl.ios_testInstallApps(client, @build))\n\t\t\tend\n\t\t\tclient.launch(\"jp.unext.mediaplayer\", true, false)\n\t\t\tclient.sleep(5000)\n\t\t\t$obj_slctv.iosSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\n\t\telsif @dtype == \"android\"\t\t\t\t\t\t\n\t\t\t#client.setDevice(\"#{$dname}\")\n\t\t\t#client.waitForDevice(\"\\\"@name='#{$dname}' AND @remote='true'\\\"\", 300000)\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"CB5A233UKX\", \"401SO\")\n\t\t\tclient.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\t#CURRENTLY AUTO BUILD FOR ANDROID IS NOT PREPARED, WHEN JENKINS AUTO BUILD WILL BE DELIVERED, TEST CAN BE RESUMED\n\t\t\t#if @build == nil\n\t\t\t#\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\t#else\n\t\t\t#\tputs ($obj_instl.testInstallApps(client, @build))\n\t\t\t#end\n\t\t\tclient.launch(\"jp.unext.mediaplayer/jp.co.unext.unextmobile.MainActivity\", true, false)\n\t\t\tclient.sleep(5000)\t\t\t\n\t\t\t$obj_slctv.andSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\t\t\n\t\telse\n\t\t\tputs \"::MSG:: 該当デバイスが見つかりません「Confirm target test devcie」\"\n\t\tend\t\t\n\tend", "def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n @device_config[:init_params] = {\n root_dir: @root_dir\n }\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n if code == SUCCESS\n @device_config[:init_params] = nil\n linker = Linker.new(**@device_config)\n linker.launch(options: \"RunTests:true\")\n\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\n end", "def setup_test_1(test_name, epw_path)\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n if !File.exist?(sql_path(test_name))\n puts \"Running EnergyPlus\"\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def test_001\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n @@pu.destroy\n # logout\n logout\n\n end", "def test_007\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n @@pu = Pu.find_by_name('SamplePU1')\n\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')\n\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link2\"]\n sleep 2\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end", "def pickUp(simulator)\n end", "def test_004\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 全体解析 (Analysis of all)\n select \"analyze_type\", \"label=#{@overall}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #There is no display below \"selection of the upload method of an individual analysis file.\"\n assert !is_text_present(_(\"Select the upload method of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end", "def test_005\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # Below \"selection of the upload method of an individual analysis file\" is displayed.\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end", "def run\n # Change the working directory to the directory of this script.\n Dir.chdir(File.dirname(__FILE__)) \n\n # if LIST_TECHNIQUES is true, just output available evasion techniques.\n if datastore['LIST_TECHNIQUES'] == true\n print_available_techniques()\n else\n payload = datastore['PAYLOAD']\n payload_options = datastore['PAYLOAD_OPTIONS']\n output_directory = datastore['OUTPUT_DIRECTORY']\n executable_name = datastore['EXECUTABLE_NAME']\n evasion_stack = datastore['EVASION_STACK']\n msfvenom_path = datastore['MSFVENOM_PATH']\n\n if payload == nil\n print_error(\"PAYLOAD must be set.\")\n return \n end\n if output_directory == nil \n print_error(\"OUTPUT_DIRECTORY must be set.\")\n return\n end\n if executable_name == nil \n print_error(\"EXECUTABLE_NAME must be set.\") \n return\n end\n if msfvenom_path == \"\"\n # Guess at path to msfvenom\n msfvenom_path = Dir.pwd[0..(Dir.pwd.index(\"pro\")+3)]+\"msf3/msfvenom\"\n print_status(\"MSFVENOM_PATH not specified. Hoping msfvenom can be found at \"+msfvenom_path+\".\")\n end\n\n binary_generated = generate_binary(msfvenom_path, payload, payload_options)\n if binary_generated\n print_status(\"Payload binary generated successfully.\")\n print_status(\"Generating evasive source from generated binary.\")\n\n generate_evasive_source(evasion_stack)\n\n executable_generated = generate_executable(output_directory+\"/\"+executable_name)\n\n if executable_generated\n print_status(\"Executable successfully generated.\")\n else\n print_error(\"Unable to generate executable.\")\n end\n else\n print_error(\"Payload generation with msfvenom failed.\")\n end\n\n print_status(\"Cleaning up temporary files.\")\n\n if File.exist?('tmp/bin'+self.uuid+'.c')\n File.delete('tmp/bin'+self.uuid+'.c')\n end\n if File.exist?('tmp/evasive'+self.uuid+'.c')\n File.delete('tmp/evasive'+self.uuid+'.c')\n end\n\n end\n end", "def test(options:)\n get_device do |device|\n loader = Loader.new(config: @config)\n loader.sideload(options: options, device: device)\n linker = Linker.new(config: @config)\n linker.deeplink(options: Options.new(options: {deeplink: \"RunTests:true\"}), device: device)\n\n telnet_config ={\n 'Host' => device.ip,\n 'Port' => 8085\n }\n connection = Net::Telnet.new(telnet_config)\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\n end", "def test_010\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def testing_engine\n puts \"engine method\"\n end", "def setup\n java.lang.System.setProperty(\"vbox.home\", Travis::Worker.config.vms.vbox_home)\n\n require 'vboxjxpcom.jar'\n\n java_import 'org.virtualbox_4_1.VirtualBoxManager'\n java_import 'org.virtualbox_4_1.VBoxEventType'\n java_import 'org.virtualbox_4_1.LockType'\n java_import 'org.virtualbox_4_1.MachineState'\n java_import 'org.virtualbox_4_1.IMachineStateChangedEvent'\n java_import 'org.virtualbox_4_1.DeviceType'\n java_import 'org.virtualbox_4_1.AccessMode'\n java_import 'org.virtualbox_4_1.MediumType'\n java_import 'org.virtualbox_4_1.SessionState'\n end", "def test_011\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n sleep 2\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link2\"]\n # check log in the navigation bar\n sleep 2\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_0\n\n #log_level_to_debug\n\n li = OpenWFE::LaunchItem.new\n li.wfdurl = 'file:test/_testdef.rb'\n\n dotest(li, %w(a b c).join(\"\\n\"))\n end", "def test_008\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')#\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n\n click $xpath[\"task\"][\"registration_task_button\"]\n sleep 2\n #assert !60.times{ break if (is_text_present(\"解析ツール未選択 入力内容に問題があるためタスクを登録できません。\") rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end", "def test_FleetRequest_FromSearchPage\n # Navigate to the volvo demo site\n @driver.get $env\n \n #1. Login to the application \n Login($uname, $pwd, \"1.0\") \n \n #2. Perform vehicle search with unit# and verify the search results \n VehicleSearchWithUnit_No(\"222\", \"2\")\n \n #3. Perform service location search with location field and verify the search results\n Search_Service_Location_With_Location(\"Dallas,TX\", \"3\")\n \n #4. Create service request for the searched vehicle and service location and submit the request.\n Create_Service_Request(\"123\",\"Engine failure\", \"Please respond immediately\", \"9876543210\", \"testdriver\", \"9876543210\", \"street1\", \"Dallas\", \"Virginia\", \"4\")\n \n end", "def setup_test(test_name, idf_output_requests, model_in_path, epw_path = epw_path_default)\n\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n assert(File.exist?(model_in_path))\n\n if File.exist?(model_out_path(test_name))\n FileUtils.rm(model_out_path(test_name))\n end\n\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new(\"Draft\".to_StrictnessLevel, \"EnergyPlus\".to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(test_name), true)\n\n if is_openstudio_2?\n setup_test_2(test_name, epw_path)\n else\n setup_test_1(test_name, epw_path)\n end\n end", "def test_pentagondodekaeders_suface\n assert_in_delta(82.5829152283, pentagondodekaeders_surface(2), 0.0000000001)\n\n assert_equal(0, pentagondodekaeders_surface(0))\n\n assert_raise(RT) { pentagondodekaeders_surface(-2) }\n assert_raise(RT) { pentagondodekaeders_surface('2') }\n end", "def test_a\n traci =\n Sumo::Traci::Client.newWithServer(SampleConfFile,\n { :logDev => [:stdout,:file],\n# :logLevel => :debug,\n :logLevel => :info,\n },\n :gui) ;\n #\n managerConf = { :traciClient => traci,\n nil => nil }\n vManager = Sumo::Traci::VehicleManager.new(managerConf) ;\n\n # loop\n step = 0 ;\n ustep = 100 ;\n delay = 0.001 ;\n while(step < 2000*1000)\n # simulation を進める。\n step += ustep\n com = Sumo::Traci::Command_SimulationStep.new(step) ;\n traci.execCommands(com) ;\n\n #update\n vManager.updateVehicleTableWhole() ;\n\n #slow down\n if(rand(10) == 0) then\n vehicle = vManager.vehicleList.sample() ;\n if(!vehicle.nil?) then\n speed = 10 * rand() ;\n duration = 1.0 ;\n vehicle.submitSlowDown(speed, duration) ;\n end\n end\n \n #sleep\n sleep(delay) ;\n end\n \n end", "def setup \n\t\tputs 'setup: ' + @test_name \n\n\t\t#device capabilities goes here:\n\t\tcapabilities = {\n\t\t\t:platformName => 'Android',\n\t\t\t:model => 'Galaxy S6', #Optional \n\t\t\t:platformVersion => '', #Optional \n\t\t\t:browserName => 'mobileOS', #Optional \n\t\t\t:browserVersion => '', #Optional for web\n\t\t\t:deviceName => '' #Optional\n\t\t}\n\n\t\t#your host url\n\t\thost = 'branchtest.perfectomobile.com'\n\n\t\t#Your perfecto lab credentials (using security token is recommended)\n\t\tcapabilities['securityToken'] = 'MY_TOKEN'\n\t\t#capabilities['user'] = 'MY_USER'\n\t\t#capabilities['password'] = 'MY_PASS'\n\n\n\t\t@driver = Selenium::WebDriver.for(:remote, :url => \"http://\" + host + \"/nexperience/perfectomobile/wd/hub\", :desired_capabilities =>capabilities) \n\tend", "def testing\n # ...\n end", "def setup_test\n\n assert(File.exist?(model_path))\n\n if !File.exist?(run_dir)\n FileUtils.mkdir_p(run_dir)\n end\n assert(File.exist?(run_dir)) \n\n if File.exist?(report_path)\n FileUtils.rm(report_path)\n end\n\n if !File.exist?(sql_path)\n puts \"Running EnergyPlus\"\n\n osw_path = File.join(run_dir, 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_path))\n workflow.setWeatherFile(File.absolute_path(epw_path))\n workflow.saveAs(osw_path)\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n end\n end", "def test_009\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"analyze_allow_file_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(\"analyze_allow_files(qac)\") rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"analyze_allow_file_link2\"]\n # check log in the navigation bar\n sleep 2\n assert !60.times{ break if (is_text_present(\"analyze_allow_files(qacpp)\") rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_valid_account\n assert_equal 0, elfproef(123456789)\n assert_equal 0, elfproef('12.34.56.789')\n assert_equal 0, elfproef('12 34 56 789')\n assert_equal 0, elfproef(1234567)\n assert_equal 0, elfproef('1234567')\n end", "def test_002\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n click $xpath[\"task\"][\"read_tree\"]\n\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n # logout\n logout\n\n end", "def test_version\n\n #prepare\n subject=Xcider::Xcodebuild.new\n\n #test\n v=subject.version\n\n #verify\n assert_not_nil v\n\n end", "def test_victorious\n\t\tp = Print.new\n\t\tassert_output(\"Going home victorious!\\n\") {p.print_game_win_or_lose(16)}\n\tend", "def test_021\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n # logout\n logout\n\n end", "def ios_testContinuePlay(client)\n\t\tclient.sleep(2000)\n\t\t\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST CONTINUE PLAY@つづきを再生\"\n\n\t\t$totalTest = $totalTest + 1 \n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tif client.waitForElement(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayIndicator' and ./preceding-sibling::*[./*]][1]\", 0, 10000)\n\t\t \t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayingStateView' and @width>0 and ./parent::*[./preceding-sibling::*[./*]]][1]\", 0, 1)\n\t\t\t\t\tContinuePlay.new.ios_playingOperation(client)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayIndicator' and ./preceding-sibling::*[./*]][1]\", 0, 1)\n\t\t\t\tContinuePlay.new.ios_playingOperation(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgConti = \"::MSG:: Exception occurrred while finding ELEMENT\" + e.message\n\t\tend\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 5\n\t\t@testcase_summary = \"つづきを再生\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgConti\n\t\t@comment = @@comment\n\t\t\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def native_eva\n 5\n end", "def pre_rvtest\n RVTEST_RV64U()\n RVTEST_CODE_BEGIN()\n end", "def setup\n\n if File.exist?(reportPath())\n FileUtils.rm(reportPath())\n end\n\n assert(File.exist?(modelPath()))\n\n if !File.exist?(runDir())\n FileUtils.mkdir_p(runDir())\n end\n assert(File.exist?(runDir()))\n\n if !File.exist?(sqlPath())\n puts \"Running EnergyPlus\"\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n vt = OpenStudio::OSVersion::VersionTranslator.new\n model = vt.loadModel(modelPath())\n assert(model.is_initialized)\n model = model.get\n\n # make sure output requests are in pre-run model, this will happen automatically in PAT\n var = OpenStudio::Model::OutputVariable.new('Site Outdoor Air Drybulb Temperature', model)\n var.setReportingFrequency('Monthly')\n\n var = OpenStudio::Model::OutputVariable.new('Zone Air Temperature', model)\n var.setReportingFrequency('Hourly')\n\n var = OpenStudio::Model::OutputVariable.new('Zone Air Relative Humidity', model)\n var.setReportingFrequency('Hourly')\n\n model.save(OpenStudio::Path.new(runDir() + '/in.osm'), true)\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(runDir()), OpenStudio::Path.new(runDir() + '/in.osm'), OpenStudio::Path.new(epwPath()))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def test_collectible_device_showa\n assert_raise('Faker::JapaneseMedia::KamenRider::UnavailableInEra') { @tester.collectible_device(:showa) }\n end", "def test_006\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #A task type is changed into \"individual analysis\"\n # with a \"general control\" tab.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析 (Individual Analysis)\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n #An option setup of \"master: A qac\" subwindow is displayed.\n click $xpath[\"task\"][\"option_setup_link\"]\n # click \"link=設定する\"\n sleep 3\n # #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n sleep 2\n\n # logout\n logout\n\n end", "def make_proxmox_vm(vm)\n # * Disk: Use a SSD if possible. Preallocated might provide faster access.\n hd_file=@disk_folder+\"/#{vm}-HD.vdi\"\n\n # NOTE! Lots of code also available for inspiration in\n # /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.5/plugins/providers/virtualbox/driver/version_4_3.rb\n\n\n unless(File.file?(@install_iso))\n raise \"ERROR - you need to download the ISO file at #{@install_iso} from https://www.proxmox.com/downloads\"\n end\n\n ide_storage_name=\"IDE Controller for #{vm}\"\n description = \"Proxmox-in-Virtualbox generated by https://github.com/mrjcleaver/proxmox-setup \\n\" + \\\n \"Generated \"+Time.now.to_s+ \" using \"+@install_iso\n\n # http://nakkaya.com/2012/08/30/create-manage-virtualBox-vms-from-the-command-line/\n # https://www.virtualbox.org/manual/ch08.html\n run_shell_cmd(\"VBoxManage createvm --name '#{vm}' --register\")\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --description '#{description}'\")\n # Note: Enabling the I/O APIC is required for 64-bit guest operating systems (page 48, manual)\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --memory '#{@ram_mb}' --acpi on --ioapic on --boot1 dvd --vram 12\")\n\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --ostype Debian --audio none\")\n\n run_shell_cmd(\"VBoxManage createhd --filename '#{hd_file}' --size '#{@hd_size_mb}' --variant Fixed\")\n run_shell_cmd(\"VBoxManage storagectl '#{vm}' --name '#{ide_storage_name}' --add ide\")\n\n run_shell_cmd(\"VBoxManage storageattach '#{vm}' --storagectl '#{ide_storage_name}' --port 0 --device 0 --type hdd --medium '#{hd_file}' --nonrotational=#{@hd_on_ssd}\")\n\n run_shell_cmd(\"VBoxManage storageattach '#{vm}' --storagectl '#{ide_storage_name}' --port 1 --device 0 --type dvddrive --medium '#{@install_iso}'\")\n\n run_shell_cmd(\"VBoxManage setextradata '#{vm}' GUI/MouseCapturePolicy Default\")\nend", "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_get_dino\n\t\t@new_driver.dino 5\n\t\tassert_equal 5, @new_driver.dino(0)\n\tend", "def ios_testEditDownloadList(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST EDITING DOWNLOAD@ダウンロードの編集機能\"\n\n\t\t$totalTest = $totalTest + 1 \n\n\t\tbegin\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tEditDownload.new.ilistEditing(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\t\t\t\t\n\t\t\t\tEditDownload.new.ilistEditing(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEditd = \"::MSG:: Exception occurrred while finding element: \" + e.message\t\n\t\tend\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\"\n\t\t@testcase_num = 20\n\t\t@testcase_summary = \"ダウンロードの編集\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgEditd\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def test_024\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the state\n #where it does not check at the information dialog\n #which clicks analyze_deny_files and comes out are enumerated.\n\n click $xpath[\"task\"][\"analyze_deny_files\"]\n sleep 3\n\n assert is_text_present(\"sample_c/Makefile\")\n\n\n # logout\n logout\n\n end", "def test_add_dino\n\t\tassert_equal 1, @new_driver.dino(1)\n\tend", "def test_023\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the check state\n #at the information dialog which clicks analyze_allow_files\n #and comes out are enumerated.\n click $xpath[\"task\"][\"analyze_allow_file_link\"]\n sleep 3\n\n assert !is_text_present(\"sample_c/Makefile\")\n\n # logout\n logout\n\n end", "def test_025\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #Move to general control tab\n click $xpath[\"task\"][\"general_control_tab\"]\n\n #The information set does not disappear and remains.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n # logout\n logout\n\n end", "def test_016\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n #An option setup was performed\n\n assert is_checked($xpath[\"task\"][\"master_option_chk2\"])\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Click a directory link\n click $xpath[\"task\"][\"master_option_dir1\"]\n sleep 2\n assert !is_checked($xpath[\"task\"][\"master_option_chk3\"])\n assert !is_checked($xpath[\"task\"][\"master_option_chk4\"])\n\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_print_items_dinos\r\n\t\tmock_argv = [867530]\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_dinos, 3\r\n\tend", "def test_invalid_account\n assert_equal 9, elfproef(999999999)\n assert_equal 9, elfproef('99.99.99.999')\n assert_equal 9, elfproef('99 99 99 999')\n end", "def ios_testPurchasedItemPlay(client)\n\t\tclient.sleep(2000)\n\t\t\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST PLAYING FROM PURCHASED@購入済みから再生\"\n\n\t\t$totalTest = $totalTest + 1 \n\t\t\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tPurchasePlay.new.ios_purchasedList(client)\n\t\t\telse\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tPurchasePlay.new.ios_purchasedList(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgBougt = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 8\n\t\t@testcase_summary = \"購入済みから再生\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def test_020\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n\n #A subwindow carries out fade-out and closes.\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_without_vm\n prep\n test_services\n end", "def test_environment_can_be_selected_and_changed\r\n @installer = DBGeni::Base.new(helper_sqlite_multiple_environment_file)\r\n assert_nothing_raised do\r\n @installer.select_environment('development')\r\n end\r\n assert_equal('development', @installer.selected_environment_name)\r\n assert_nothing_raised do\r\n @installer.select_environment('test')\r\n end\r\n assert_equal('test', @installer.selected_environment_name)\r\n end", "def test_FT_afn_single_zone_nv\n sdd_ft_test('afn_single_zone_nv.osm')\n end", "def test_003\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # select uploading method in the master tab\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n #Click button Read tree\n click $xpath[\"task\"][\"read_tree\"]\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n #It will return, if a check is returned for uploading collectively (F2-003)\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # logout\n logout\n\n end", "def run_app_tests\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_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end", "def test_ut_da10b_t1_15\n p \"Test 15\"\n # gets a list of pjs belong to selected pu\n pjs = @pu.get_pjs_belong_to_pu\n expected_pj = [[\"\", 0], [\"SamplePJ1\", 1], [\"SamplePJ2\", 2]]\n assert_equal expected_pj, pjs\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def test_017\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n #An option is checked\n assert is_checked($xpath[\"task\"][\"master_option_chk2\"])\n #Click a directory link\n click $xpath[\"task\"][\"master_option_dir1\"]\n sleep 2\n #All file of directory is checked.\n\n assert is_checked($xpath[\"task\"][\"master_option_chk3\"])\n assert is_checked($xpath[\"task\"][\"master_option_chk4\"])\n\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_TestPaper\n # login(\"cn.fra\", \"12345\")\n begin\n\n @@title=$question\n $action.open($link+\"/Course/ExamTemplateTrain.aspx\")\n assert_equal(@@loginpage.getTitle,\"EF Online Academy\")\n @@testpaperpage.addNew\n @@testpaperpage.title(@@title)\n\n @@testpaperpage.uniqueId(Time.now.to_s)\n @@testpaperpage.description(@@title)\n @@testpaperpage.totalScore(\"100\")\n @@testpaperpage.passScore(\"0\")\n @@testpaperpage.testTime(\"10\")\n @@testpaperpage.layout \"123\"\n @@testpaperpage.tag\n # @@testpaperpage.addGroup \"1\",@@title\n @@testpaperpage.addGroup @@title\n sleep 3\n @@testpaperpage.ok\n sleep 6\n @@testpaperpage.titleFilter(@@title)\n @@testpaperpage.search\n sleep 3\n assert($action.findelementByName(\"ctl00$cphMain$rptList$ctl00$imgBtnEdit\"))\n $log.puts(__method__.to_s+\" -------------------pass \\n\")\n\n rescue\n $log.puts(__method__.to_s+\" -------------------fail \\n\")\n $action.screenshot($path)\n puts \":error:#{$!}-----at:#{$@} \\n\"\n end\n end", "def test_valley_smoketest\n @driver.get(@base_url)\n verify_home_page()\n verify_services_page()\n verify_about_page()\n verify_contact_page()\n verify_faq_page()\n verify_links_page()\n end", "def sdd_rt_test(sddsimxml_path)\n full_path = File.join($SddSimDir, sddsimxml_path)\n\n filename = escapeName(sddsimxml_path.gsub(' - ap.xml', '.xml'))\n\n # puts \"\\nRunning for #{filename}\"\n # puts \"Loading #{full_path}\"\n\n if $Disabled_RT_Tests.include?(filename)\n skip \"Test is disabled for #{filename}\"\n end\n rt = OpenStudio::SDD::SddReverseTranslator.new\n _m = rt.loadModel(full_path)\n # Test that RT Worked\n assert _m.is_initialized, \"Failed SDD RT for #{filename}\"\n\n # Need to add the DDY\n m = add_design_days(_m.get)\n\n # If so, then save resulting OSM for diffing\n m_out = File.join($TestDirSddRT, filename)\n # puts \"Saving at #{m_out}\"\n\n m.save(m_out, true)\n\n # Now do the sim_test portion!\n sim_test(filename, { base_dir: $TestDirSddRT })\n # m_out = File.join($TestDirSddRT, \"#{filename}_#{$SdkVersion}_out#{$Custom_tag}.osm\")\nend", "def simulator\n\n if GlobalConstant::Base.main_sub_environment?\n redirect_to :dashboard, status: GlobalConstant::ErrorCode.permanent_redirect\n end\n\n @response = CompanyApi::Request::Economy.new(\n CompanyApi::Response::Formatter::Economy,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_simulator_details\n\n # Check if error present or not?\n unless @response.success?\n render_error_response(@response)\n return\n end\n\n @presenter_obj = ::WebPresenter::Economy::Simulator.new(@response, params)\n unless @presenter_obj.client_token.step_three_done?\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect\n return\n end\n\n end", "def startDSSim\n begin\n $MatLib = SU2DS::MaterialLibrary.new() \n rs = SU2DS::RadianceScene.new()\n rs.export(SU2DS::RadianceScene::EMODE_SIM) ## modified for su2ds\n rescue => e \n msg = \"%s\\n\\n%s\" % [$!.message,e.backtrace.join(\"\\n\")]\n UI.messagebox msg \n end \nend", "def discover_tests\n # List of exterior cells coordinates, per worldspace name, per plugin name\n # Hash< String, Hash< String, Array<[Integer, Integer]> > >\n exterior_cells = {}\n @game.xedit.run_script('DumpInfo', only_once: true)\n @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|\n esp_name, record_type = row[0..1]\n if record_type.downcase == 'cell'\n cell_type, cell_name, cell_x, cell_y = row[3..6]\n if cell_type == 'cow'\n if cell_x.nil?\n log \"!!! Invalid record: #{row}\"\n else\n esp_name.downcase!\n exterior_cells[esp_name] = {} unless exterior_cells.key?(esp_name)\n exterior_cells[esp_name][cell_name] = [] unless exterior_cells[esp_name].key?(cell_name)\n exterior_cells[esp_name][cell_name] << [Integer(cell_x), Integer(cell_y)]\n end\n end\n end\n end\n # Test only exterior cells that have been changed by mods, and make sure we test the minimum, knowing that each cell loaded in game tests 5x5 cells around\n vanilla_esps = @game.game_esps\n vanilla_exterior_cells = vanilla_esps.inject({}) do |merged_worldspaces, esp_name|\n merged_worldspaces.merge(exterior_cells[esp_name] || {}) do |_worldspace, ext_cells_1, ext_cells_2|\n (ext_cells_1 + ext_cells_2).sort.uniq\n end\n end\n changed_exterior_cells = {}\n exterior_cells.each do |esp_name, esp_exterior_cells|\n next if vanilla_esps.include?(esp_name)\n\n esp_exterior_cells.each do |worldspace, worldspace_exterior_cells|\n if vanilla_exterior_cells.key?(worldspace)\n changed_exterior_cells[worldspace] = [] unless changed_exterior_cells.key?(worldspace)\n changed_exterior_cells[worldspace].concat(vanilla_exterior_cells[worldspace] & worldspace_exterior_cells)\n end\n end\n end\n tests = {}\n # Value taken from the ini file\n # TODO: Read it from there (uiGrid)\n loaded_grid = 5\n delta_cells = loaded_grid / 2\n changed_exterior_cells.each do |worldspace, worldspace_exterior_cells|\n # Make sure we select the minimum cells\n # Use a Hash of Hashes for the coordinates to speed-up their lookup.\n remaining_cells = {}\n worldspace_exterior_cells.each do |(cell_x, cell_y)|\n remaining_cells[cell_x] = {} unless remaining_cells.key?(cell_x)\n remaining_cells[cell_x][cell_y] = nil\n end\n until remaining_cells.empty?\n cell_x, cell_ys = remaining_cells.first\n cell_y, _nil = cell_ys.first\n # We want to test cell_x, cell_y.\n # Knowing that we can test it by loading any cell in the range ((cell_x - delta_cells..cell_x + delta_cells), (cell_y - delta_cells..cell_y + delta_cells)),\n # check which cell would test the most wanted cells from our list\n best_cell_x = nil\n best_cell_y = nil\n best_cell_score = nil\n (cell_x - delta_cells..cell_x + delta_cells).each do |candidate_cell_x|\n (cell_y - delta_cells..cell_y + delta_cells).each do |candidate_cell_y|\n # Check the number of cells that would be tested if we were to test (candidate_cell_x, candidate_cell_y)\n nbr_tested_cells = remaining_cells.\n slice(*(candidate_cell_x - delta_cells..candidate_cell_x + delta_cells)).\n inject(0) { |sum_cells, (_cur_cell_x, cur_cell_ys)| sum_cells + cur_cell_ys.slice(*(candidate_cell_y - delta_cells..candidate_cell_y + delta_cells)).size }\n next unless best_cell_score.nil? || nbr_tested_cells > best_cell_score\n\n best_cell_score = nbr_tested_cells\n best_cell_x = candidate_cell_x\n best_cell_y = candidate_cell_y\n end\n end\n # Remove the tested cells from the remaining ones\n (best_cell_x - delta_cells..best_cell_x + delta_cells).each do |cur_cell_x|\n next unless remaining_cells.key?(cur_cell_x)\n\n (best_cell_y - delta_cells..best_cell_y + delta_cells).each do |cur_cell_y|\n remaining_cells[cur_cell_x].delete(cur_cell_y)\n end\n remaining_cells.delete(cur_cell_x) if remaining_cells[cur_cell_x].empty?\n end\n tests[\"#{worldspace}/#{best_cell_x}/#{best_cell_y}\"] = {\n name: \"Load #{worldspace} cell #{best_cell_x}, #{best_cell_y}\"\n }\n end\n end\n tests\n end", "def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end", "def test_012\n\n #login\n login\n\n #Open PU management page\n open_pu_management_page_1\n\n # Find a PU\n # Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #test for make root in the master tab & in the popup which is displayed by clicking 設定する\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n #test for make root\n type \"makeroot_qac\", \"abc\"\n run_script \"destroy_subwindow()\"\n assert is_text_present(_(\"Make root\")+\":\")\n click $xpath[\"task\"][\"option_setup_link\"]\n sleep 2\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n sleep 3\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n type \"makeroot_qac\", \"abc\"\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 2\n assert is_text_present(_(\"Make root\")+\":\")\n click $xpath[\"task\"][\"option_setup_link\"]\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n\n\n\n #logout\n logout\n\n end", "def test_b\n traci =\n Sumo::Traci::Client.newWithServer(SampleConfFile2,\n { :logDev => [:stdout,:file],\n# :logLevel => :debug,\n :logLevel => :info,\n },\n :gui) ;\n #\n managerConf = { :traciClient => traci,\n nil => nil }\n vManager = Sumo::Traci::VehicleManager.new(managerConf) ;\n\n # loop\n step = 0 ;\n ustep = 100 ;\n delay = 0.001 ;\n while(step < 10000*1000)\n # simulation を進める。\n step += ustep\n com = Sumo::Traci::Command_SimulationStep.new(step) ;\n traci.execCommands(com) ;\n\n #update\n vManager.updateVehicleTableWhole() ;\n\n #slow down\n if(rand(10) == 0) then\n vehicle = vManager.vehicleList.sample() ;\n if(!vehicle.nil? && vehicle.isOnRoad?()) then\n speed = 10 * rand() ;\n duration = 1.0 ;\n vehicle.submitSlowDown(speed, duration) ;\n pp [:edgeList, vehicle.fetchRouteIndex(), vehicle.fetchEdgeList() ];\n end\n end\n \n #sleep\n sleep(delay) ;\n end\n traci.closeServer() ;\n end", "def test_022\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n # logout\n logout\n\n end", "def test_vmop_017\n _dolit = @vm.compile(nil, nil, :vm_dolit, :vm_next)\n _halt = @vm.compile(nil, nil, :vm_halt, :vm_next)\n _docol = @vm.compile(nil, nil, :vm_docol, :vm_next)\n _exit = @vm.compile(nil, nil, :vm_exit, :vm_next)\n _qdo = @vm.compile(nil, nil, :vm_question_do, :vm_next)\n _loop = @vm.compile(nil, nil, :vm_loop, :vm_next)\n _i = @vm.compile(nil, nil, :vm_i, :vm_next)\n _drop = @vm.compile(nil, nil, :vm_drop, :vm_next)\n # : test 0 0 ?do i drop loop halt ;\n _test = \n @vm.compile(nil, \n @vm.fetch(_docol), \n _dolit,\n 0,\n _dolit,\n 0,\n _qdo,\n '@L2',\n 'L1',\n _i,\n _drop,\n _loop,\n '@L1',\n 'L2',\n _halt,\n _exit)\n @vm.boot(_test)\n catch :halt do\n assert_equal(0, @vm.rdepth)\n # docol\n assert_equal(:vm_docol, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.rdepth)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(1, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(2, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # ?do\n assert_equal(:vm_question_do, @vm.step)\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n\n # halt\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_push, @vm.step)\n assert_equal(:vm_io, @vm.step)\n end\n assert_equal(:halt, @vm.state)\n end", "def test_perfind_evidence\r\n nodelist = @mymodel.node_list\r\n \r\n node1 = nodelist.add_node(1, 'node one', PERFIND);\r\n \r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil))\r\n\r\n node1.value_function = ValueFunction.new(0, 100, 'degrees')\r\n\r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil)) \r\n assert_in_delta(node1.measure_to_evidence(45.4), 0.454, 0.0001)\r\n end", "def test_001\n # delete all existed projects\n delete_all_pus\n begin\n # there is no project\n open_pu_management_page\n wait_for_text_present(_(\"No PU has been registered\"))\n logout\n rescue Test::Unit::AssertionFailedError\n @verification_errors << $!\n end\n # return the original data (2 pus)\n make_original_pus\n end", "def tests; end", "def tests; end", "def test_dvd_routings\n assert_routing '/dvds', :controller => 'dvds', :action => 'index'\n assert_routing '/dvds/index/1', :controller => 'dvds', :action => 'index', :id => '1'\n assert true\n end", "def test02_EventVideoPhotoPDF\n\t\tloginPost\n\t\t$browser.goto($patch_event)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\t$post_event_title.set(\"hiking extravaganza #{random}\")\n \t\t\t\t$post_event_calendar_start_text.set(\"2013-12-12\") \n \t\t\t\t$post_event_time_start_field.click\n \t\t\t\t$post_event_select_time.select(\"8:00 AM\")\n \t\t\t\t$post_event_location.set(\"olympic national park #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('wolf creek trail is unavailable')\")\n \t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/DungenessSpit102.26.2012.mov\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/PDFDocument.pdf\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/PDF2.pdf\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\tsleep 2\n\t\t\telse puts \"PS04T02: FAILED! User able to Post.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"PS04T02: FAILED! User able to Post.\")\n\t\t\tputs e\n\t\tend\n\tend", "def test_vmop_016\n _dolit = @vm.compile(nil, nil, :vm_dolit, :vm_next)\n _halt = @vm.compile(nil, nil, :vm_halt, :vm_next)\n _docol = @vm.compile(nil, nil, :vm_docol, :vm_next)\n _exit = @vm.compile(nil, nil, :vm_exit, :vm_next)\n _qdo = @vm.compile(nil, nil, :vm_question_do, :vm_next)\n _loop = @vm.compile(nil, nil, :vm_loop, :vm_next)\n _i = @vm.compile(nil, nil, :vm_i, :vm_next)\n _drop = @vm.compile(nil, nil, :vm_drop, :vm_next)\n # : test 10 0 ?do i drop loop halt ;\n _test = \n @vm.compile(nil, \n @vm.fetch(_docol), \n _dolit,\n 10,\n _dolit,\n 0,\n _qdo,\n '@L2',\n 'L1',\n _i,\n _drop,\n _loop,\n '@L1',\n 'L2',\n _halt,\n _exit)\n @vm.boot(_test)\n catch :halt do\n assert_equal(0, @vm.rdepth)\n # docol\n assert_equal(:vm_docol, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.rdepth)\n # 10\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(10, @vm.tos)\n assert_equal(1, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(2, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # ?do\n assert_equal(:vm_question_do, @vm.step)\n assert_equal(4, @vm.rdepth)\n assert_equal(10, @vm.rnos)\n assert_equal(0, @vm.rtos)\n assert_equal(:vm_nop, @vm.step)\n\n # i (0)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(0, @vm.tos)\n\n # drop (0)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (0)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (1)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.tos)\n\n # drop (1)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (1)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (2)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(2, @vm.tos)\n\n # drop (2)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (2)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (3)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(3, @vm.tos)\n\n # drop (3)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (3)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (4)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(4, @vm.tos)\n\n # drop (4)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (4)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (5)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(5, @vm.tos)\n\n # drop (5)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (5)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (6)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(6, @vm.tos)\n\n # drop (6)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (6)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (7)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(7, @vm.tos)\n\n # drop (7)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (7)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (8)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(8, @vm.tos)\n\n # drop (8)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (8)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (9)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(9, @vm.tos)\n\n # drop (9)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (9)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_push, @vm.step)\n assert_equal(:vm_io, @vm.step)\n end\n assert_equal(:halt, @vm.state)\n end", "def test_volume_of_a_cube()\n # add test code here\n result = volume_of_a_cube(2)\n assert_equal(8, result)\n end", "def setup\n # Each debugger test has its own debugger instance.\n @debugger = Google::Cloud::Debugger.new\n debugger_credentials = @debugger.service.credentials\n debugger_channel_cred = GRPC::Core::ChannelCredentials.new.compose \\\n GRPC::Core::CallCredentials.new debugger_credentials.client.updater_proc\n @vtk_debugger_client = Google::Cloud::Debugger::V2::Debugger::Client.new do |config|\n config.credentials = debugger_channel_cred\n end\n\n @debugger.start\n\n refute_nil @debugger, \"You do not have an active debugger to run the tests.\"\n refute_nil @vtk_debugger_client, \"You do not have an active debugger vtk client to run the tests.\"\n super\n end", "def abaeterno_test(test,argv)\n\tmy_args = []\n\tmy_args << test.files('abaeterno_input').first\n\tmy_args << \"options.heartbeat.logfile='../data/abaeterno.out'\"\n\tmy_args << \"options.trace_stats_disasm_file='../data/disasm_output'\"\n\tmy_args += argv\n\n\tlua_defs=LuaDefinitions.new :command_line => my_args\n\topts=Options.new(lua_defs,:test => test,:runid => \"test\"+test.tid+\"-\")\n\topts.load :data_dir, :display,\n\t\t:simnow_dir, :simnow_dir_link,\n\t\t:abaeterno_so, :abaeterno_so_link,\n\t\t:clean_sandbox, :screen\n\n\tsb=Sandbox.new(lua_defs,opts)\n\tsb.install :abaeterno_in, :simnow_pre, :simnow_dir,\n\t\t:abaeterno_so, :test_data\n\n\ti,o=sb.run_output('regression')\n\tdebug2(\"regression output begin\\n#{o}\\nregression output end\")\n\treturn false,\"incorrect return value\",sb.to_str if i!=0\n\n\ti,o=sb.run_output('check_regression')\n\tdebug2(\"check_regression output begin\\n#{o}\\ncheck_regression output end\")\n\treturn false,o.chomp,sb.to_str if i!=0\n\n\tsb.clean\n\treturn true,\"\",\"\"\nend", "def testPowerEfficient\n #=============================================================\n #TESTS POWEREFFICIENTSPACESTATION\n # 1. TO_S\n # 2. FIRE Y PROTECTION METHOD\n #=============================================================\n \n index = 1\n object = \"POWEREFFICIENTSPACESTATION\"\n section = \"METODO TO_S\"\n \n titleTest(index,object,section)\n puts \"#{@powerEfficient.to_s}\"\n \n #=============================================================\n \n index += 1\n section = \"METODOS FIRE Y PROTECTION\"\n \n titleTest(index,object,section)\n puts \"--> FIRE POWER: #{@powerEfficient.fire}\"\n puts \"--> PROTECTION POWER: #{@powerEfficient.protection}\"\n \n end", "def test_002_wip\r\n\r\n begin\r\n\r\n sTestCase_Name = \"test_002_wip\"\r\n puts2(\"Starting Testcase: #{sTestCase_Name}\")\r\n\r\n sleep(2)\r\n \r\n=begin\r\n\r\n# Example outputs on Win7 64bit for FF3.6.28 and IE 8\r\n\r\nBrowser name: Netscape\r\nBrowser version: 5.0 (Windows; en-US)\r\nCookies Enabled: true\r\nPlatform: Win32\r\nUser Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28\r\nappCodeName: Mozilla\r\n\r\nBrowser name: Microsoft Internet Explorer\r\nBrowser version: 4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; MS-RTC LM 8)\r\nCookies Enabled: true\r\nPlatform: Win32\r\nUser Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; MS-RTC LM 8)\r\nappCodeName: Mozilla\r\n\r\n=end\r\n\r\n\r\n\r\n\r\n if($bUseWebDriver == false)\r\n\t puts2(\"Browser appName: \" + $browser.execute_script(\"window.navigator.appName\").to_s)\r\n\t puts2(\"Browser appVersion: \" + $browser.execute_script(\"window.navigator.appVersion\").to_s)\r\n\t puts2(\"Cookies Enabled: \" + $browser.execute_script(\"window.navigator.cookieEnabled\").to_s)\r\n\t puts2(\"Platform: \" + $browser.execute_script(\"window.navigator.platform\").to_s)\r\n\t puts2(\"User Agent: \" + $browser.execute_script(\"window.navigator.userAgent\").to_s)\r\n\t puts2(\"appCodeName: \" + $browser.execute_script(\"window.navigator.appCodeName\").to_s)\r\n else\r\n\t puts2(\"Browser appName: \" + $browser.execute_script(\"return window.navigator.appName\").to_s)\r\n\t puts2(\"Browser appVersion: \" + $browser.execute_script(\"return window.navigator.appVersion\").to_s)\r\n\t puts2(\"Cookies Enabled: \" + $browser.execute_script(\"return window.navigator.cookieEnabled\").to_s)\r\n\t puts2(\"Platform: \" + $browser.execute_script(\"return window.navigator.platform\").to_s)\r\n\t puts2(\"User Agent: \" + $browser.execute_script(\"return window.navigator.userAgent\").to_s)\r\n\t puts2(\"appCodeName: \" + $browser.execute_script(\"return window.navigator.appCodeName\").to_s)\r\n end\r\n\r\n puts2(\"Brand: \" + $browser.brand())\r\n puts2(\"Version: \" + $browser.version())\r\n \r\n #puts2(\"Is jQuery active?\")\r\n #$browser.execute_script(\"return jQuery.active == 0\")\r\n\r\n rescue => e\r\n\r\n puts2(\"*** ERROR Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\r\n\r\n ensure\r\n\r\n $browser.close()\r\n\r\n end\r\n\r\nend", "def test_one_day\n\t\tg = Game.new(0,0,0)\n\t\tmocked_miner = Minitest::Mock.new(\"mocked miner\")\n\t\tdef mocked_miner.current_city; 0; end\n\t\tdef mocked_miner.increase_rubies(x,y); nil; end\n\n\t\tmocked_city = Minitest::Mock.new(\"mocked city\")\n\t\tdef mocked_city.get_rubies(x); [1,1]; end\n\t\tdef mocked_city.name; 'Town'; end\n\n\t\tmocked_printer = Minitest::Mock.new(\"mocked printer\")\n\t\tdef mocked_printer.print_day(x,y); nil; end\n\n\t\tassert_equal([1,1],g.one_day(mocked_miner,[mocked_city],mocked_printer))\n\tend", "def test_drivers_get_dinos\n\t\tloc = Location::new(\"Location\", [\"Place\"])\n\t\tdriv = Driver::new(1, loc)\n\t\tassert_equal 0, driv.get_dinos\n\tend", "def setup_test_2(test_name, epw_path)\n osw_path = File.join(run_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(test_name)))\n workflow.setWeatherFile(File.absolute_path(epw_path))\n workflow.saveAs(osw_path)\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n #puts cmd\n system(cmd)\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def open_start\r\n\r\n @simulator = WIN32OLE.new('AutoItX3.Control')\r\n\r\n Dir.chdir(@sim_gui_path)\r\n Dir.pwd\r\n \r\n @simulator.Run(\"V4SingleSimulatorGUI.exe\")\r\n @simulator.WinWaitActive(\"Emerson (Copyright 2012)\")\r\n @simulator.ControlClick(\"Emerson (Copyright 2012)\",\"Remote Control on Port:\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad11\")\r\n @simulator.Send(\"{F1}\")\r\n @simulator.WinWaitActive(\"Open\")\r\n @simulator.ControlSetText(\"Open\", \"\",\"Edit1\",@sim_path)\r\n @simulator.ControlClick(\"Open\",\"&Open\",\"Button1\")\r\n @simulator.WinWaitActive(\"SelectIPAddress\")\r\n @simulator.ControlClick(\"SelectIPAddress\",\"Select\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad12\")\r\n \r\n #Start simulator\r\n @simulator.Send(\"{F5}\")\r\n\r\n end", "def run_phase2_vmin(state, settings = {})\n\tputz \"Starting phase 2\"\n\t\n\t#if just switching from phase 1\n\t\t#binding.pry\n\t\tputs \"state.current_voltage = #{$state.current_voltage} , will do \"\n\t\tif state.phase_number == 1 \n\t\t\t\n\t\t\tstate.current_voltage = state.last_passing_voltage[state.asic_package]\n\t\t\tstate.results.push(state.last_passing_voltage[state.asic_package])\n\t\t\tstate.results_header.push('vmin_phase1')\n\t\telse\n\t\t\tstate.current_voltage += state.voltage_step\t\t\n\t\tend\n\tputs \"state.current_voltage = #{$state.current_voltage} , done \"\n\t\n\n\t# binding.pry\n\t#overvoltage protections\n\tstate.phase_number = 2\n\t\n\t#setting all packages and dies to default clock \n\tstate.default_clock.each do |i|\n\t\t$t.set_die_clock(i[0],i[1],\"all\",\"all\")\n\tend\n\t\t\n\t\n\t#setting clock value to specific value if defined\n\tif state.adjust_clock.size > 0\n\t\tstate.adjust_clock.each do |i|\n\t\t\t$t.set_die_clock(i[0],i[1],state.asic_package,state.asic_die)\n\t\tend\n\tend\n\t\n\n\tif (state.current_voltage > state.max_voltage)\n\t\tpute \"Maximum voltage of #{state.max_voltage} reached - stopping test\"\n\t\tputz \"Restoring to #{state.original_voltage[state.asic_package]} V\"\n\t\tif state.voltage_module == \"atitool\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.original_voltage[state.asic_package],state.asic_package)\t\n\t\telsif state.voltage_module == \"smu\"\n\t\t\t$vlt.set_voltage_rail(state.voltage_rail_name, state.original_voltage[state.asic_package])\n\t\tend\n\t\treturn false\n\tend\n\t\n\t# debug diag phase 2 load time\n\tsleep 10\n\t\n\tif state.os_type == \"windows\"\n\t\tputz \"\\nSetting #{state.voltage_rail_name} to #{state.current_voltage}\"\n\t\t\n\t\tif state.voltage_module == \"atitool\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.current_voltage,state.asic_package)\n\t\t\tstate.actual_voltage = $t.get_package_voltage(state.voltage_rail_name,state.asic_package)\n\t\telsif state.voltage_module == \"smu\"\n\t\t\tsleep 5\n\t\t\t$vlt.set_voltage_rail(state.voltage_rail_name,state.current_voltage)\n\t\t\tstate.actual_voltage[state.asic_package] = state.current_voltage\n\t\tend\n\t\n\n\t\t\n\t\t$obj.save(state)\n\t\t\n\t\t\n\t\trun_workload(state)\n\t\tsleep(state.phase2_dur)\n\t\tstop_workload(state)\n\t\t\n\telsif state.os_type == \"linux\"\n\t\n\t\tloop do\n\t\t\n\t\t\t# make sure the WD signal sent to server before running Diag\n\t\t\tp \"Starting Diag Test Phase 2\"\n\t\t\t$client.update_timeout(5 * state.update_timeout)\n\t\t\tresult = []\n\t\t\t$state.diag_loops.times {result.push(run_workload(state).to_s)}\n\t\t\t#binding.pry\n\t\t\tputz \"result = #{result}\"\n\t\t\t# assume for diag workload return pass or fail\n\t\t\tbreak if (result.include?('pass') or result.include?('true'))\n\t\t\t\n\t\t\t# increment voltage by one step if fail\n\t\t\tstate.current_voltage += state.voltage_step\n\t\t\tputz \"\\nSetting #{state.voltage_rail_name} to #{state.current_voltage}\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.current_voltage,state.asic_package)\n\t\t\tstate.actual_voltage = $t.get_package_voltage(state.voltage_rail_name,state.asic_package)\n\t\t\n\t\t\t$obj.save(state)\n\t\n\t\tend\n\tend\n\t\t\t\n\t\n\t#restore to save voltage\n\t#debug\n\t# p state.voltage_rail_name\n\t# p state.original_voltage[state.asic_package]\n\t# p state.asic_package\n\t# binding.pry\n\t\n\t#restoring to default condition\n\tif state.voltage_module == \"atitool\"\n\t\t$t.set_package_voltage(state.voltage_rail_name,state.original_voltage[state.asic_package],state.asic_package)\n\telsif state.voltage_module == \"smu\"\n\t\t$vlt.set_voltage_rail(state.voltage_rail_name, state.original_voltage[state.asic_package])\n\tend\n\n\t\n\tstate.default_clock.each do |i|\n\t\t$t.set_die_clock(i[0],i[1],\"all\",\"all\")\n\tend\n\t\n\t# binding.pry\n\tstate.results.push(state.actual_voltage[state.asic_package])\n\tstate.results_header.push('vmin_phase2')\n\tputz \"Completed Phase2\"\n\t\n\t#if it gets here it passed\t\n\treturn true\t\n\t\nend", "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 verify_noop (noop_fc=0)\n \n result = false\n\t \n cmd_valid_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\")\n cmd_error_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\")\n seq_cnt = tlm(\"#{@app.target_hk_str} #{Ccsds::PRI_HDR_SEQUENCE}\")\n event_seq_cnt = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\")\n \n cmd(\"#{@app.target} #{Osk::CMD_STR_NOOP} with #{Ccsds::PRI_HDR_STREAMID} #{@app.cmd_mid}, #{Ccsds::PRI_HDR_SEQUENCE} 0, #{Ccsds::PRI_HDR_LENGTH} 1, #{Ccsds::SEC_HDR_CHECKSUM} 0, #{Ccsds::SEC_HDR_FUNCCODE} #{noop_fc}\")\n wait(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD} == #{cmd_valid_cnt}+1\", 10) # Delay until updated cmd valid count or timeout. \n\t\n #~~puts tlm(\"#{@target_hk_str} CMD_VALID_COUNT\")\n if ( (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == (cmd_valid_cnt + 1)) && \n (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\") == cmd_error_cnt))\n \n # TODO - Add utility to queue recent events so they can be queried \n event_seq_cnt_delta = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\") - event_seq_cnt\n event_app = tlm(\"CFE_EVS EVENT_MSG_PKT APP_NAME\")\n event_type = tlm(\"CFE_EVS EVENT_MSG_PKT EVENT_TYPE\")\n event_msg = tlm(\"CFE_EVS EVENT_MSG_PKT MESSAGE\")\n puts \"event_seq_cnt_delta = #{event_seq_cnt_delta}\\n\"\n if (event_seq_cnt_delta == 1)\n if ((event_app == @app.target) and (event_type == Fsw::Const::CFE_EVS_INFORMATION) and (event_msg.include? @app.version))\n result = true\n end\n else\n puts \"#{@app.target} NOOP test warning: Unable to verify event message. Event message sequence count changed by #{event_seq_cnt_delta}\" \n result = true\n end\n \n else\n if ( tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == seq_cnt)\n raise \"#{@app.target} NOOP test failed: HK telemetry packet not received\"\n end\n raise \"#{@app.target} NOOP test failed: Command counters\"\n end\n\t\n return result\n \n end", "def test_lv_ops\n lvname = \"testlv_#{Time.now.to_i}\"\n bd = nil\n\n #\n # Test creating the LV\n #\n # vgroup does not exist\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('lkjwf99ex', lvname, 1024)\n bd.create\n end\n # invalid lv size\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 100000000024)\n bd.create\n end\n\n assert_nothing_raised do \n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n # device is formatted by default, check it\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n assert(bd.config_string == \"'phy:/dev/localvg/#{lvname},sda1,w'\")\n assert( File.exist? \"/dev/mapper/localvg-#{lvname}\")\n\n # lv already exists\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n\n\n #\n # Test formatting the LV\n #\n bd.format\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n #\n # Test mouting the LV\n #\n mdir = bd.mount\n assert(`mount | grep #{mdir}` =~ /#{mdir}/)\n assert_raises Exception do\n bd.mount\n end\n \n #\n # Test umounting the LV\n #\n bd.umount\n assert(`mount | grep #{mdir}`.strip.chomp.empty?)\n Dir.rmdir mdir\n\n #\n # Test deleting the LV\n #\n bd.delete\n assert( !File.exist?(\"/dev/mapper/localvg-#{lvname}\") )\n end", "def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end", "def test_fortune_from_each_source\n sources = LinuxFortune.get_sources\n fortunes = []\n sources.each do |src|\n fortunes << src.fortune\n assert fortunes.size > 0\n #puts \"#{fortunes.last.source} --- #{src.fullpath}\"\n assert fortunes.last.source == src.fullpath\n end\n end", "def startup(options)\n tester.set_timeset('arm_debug', 40)\n end" ]
[ "0.64946526", "0.57697374", "0.5729185", "0.5614345", "0.5591484", "0.5577504", "0.5557855", "0.5532479", "0.55240047", "0.5487013", "0.54794675", "0.5461433", "0.54234314", "0.53806037", "0.53641784", "0.53615427", "0.5293915", "0.52922744", "0.5290481", "0.52775306", "0.5270423", "0.526523", "0.5256379", "0.5248662", "0.5243238", "0.5224451", "0.5223266", "0.5222401", "0.52055925", "0.51758003", "0.5158807", "0.51534545", "0.5142363", "0.51371574", "0.51338744", "0.5131025", "0.5125163", "0.51246077", "0.512319", "0.5110778", "0.5108978", "0.5105389", "0.50992686", "0.5078877", "0.50748134", "0.5067591", "0.5065646", "0.5061785", "0.50603527", "0.50335294", "0.50286496", "0.5022636", "0.5017059", "0.5013658", "0.5008708", "0.50052893", "0.49939102", "0.49934396", "0.49810785", "0.4979381", "0.49788678", "0.49668068", "0.49668068", "0.49629533", "0.49585432", "0.49511653", "0.49508315", "0.4949289", "0.49452808", "0.4927749", "0.49265078", "0.4924426", "0.49240318", "0.4922501", "0.49076602", "0.4906007", "0.49051332", "0.4898542", "0.4898542", "0.4894574", "0.48938972", "0.48852813", "0.48810482", "0.48738962", "0.48729572", "0.48703656", "0.48628396", "0.48621878", "0.48596543", "0.48541483", "0.48511842", "0.48502383", "0.4848336", "0.48400223", "0.4837685", "0.48359266", "0.48354214", "0.4834589", "0.48297277", "0.48295376" ]
0.5758181
2
Tests for Vodafone EPD simulator
def test_simulate_status_frame_with_timestamp mqtt_client = SinapseEPDSimulatorVodafone.new(:host => $MQTT_broker, :port => $normal_port, :username => $MQTT_user, :password => $MQTT_password) mqtt_client.connect() # Simulating EPD #result = mqtt_client.simulate_status_frame #assert_equal result[0], {:topic => "LU/LUM/SEN", :message => "FFFFFF;30;1;90;150;220;60;0;60;60;0;60;50"} # RAE: To Improve # EPD with data timestamp = Time.now.to_i status_parameters = { id_radio: "123456", temp: 30, stat: 1, dstat: 75, voltage: 220, current: 120, active_power: 75, reactive_power: 0, apparent_power: 75, aggregated_active_energy: 150, aggregated_reactive_energy: 0, aggregated_apparent_energy: 150, frequency: 50, timestamp: timestamp } result = mqtt_client.simulate_status_frame("LU/LUM/SEN", status_parameters) msg_result = "123456;30;1;75;120;220.0;75.0;0.0;75.0;150;0;150;50;" + timestamp.to_s + ";" assert_equal result[0], {:topic => "LU/LUM/SEN", :message => msg_result} # RAE: To Improve mqtt_client.disconnect() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ios_testSVODEpisodePlay(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST SVOD EPISODE PLAY@見放題エピソード再生機能\"\n\n\t\t$totalTest = $totalTest + 1\n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tEpisodePlay.new.ios_getEpisodeToPlay(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tEpisodePlay.new.ios_getEpisodeToPlay(client)\n\t\t\tend\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 11\n\t\t@testcase_summary = \"見放題エピソード再生機能\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = \"\"\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def testSVODEpisodePlay(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[ANDROID] STARTING TEST EPISODE PLAY@見放題エピソード再生機能\"\n\n\t\t$totalTest = $totalTest + 1\n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tEpisodePlay.new.getEpisodeToPlay(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tEpisodePlay.new.getEpisodeToPlay(client)\n\t\t\tend\t\t\t\t\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@id='search_kind_selector']\", 0)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=ホーム\", 0, 1)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"ANDROID\" \n\t\t@testcase_num = 11\n\t\t@testcase_summary = \"見放題エピソード再生機能\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def test_simulate_status_frame\n\t\tmqtt_client = SinapseEPDSimulatorVodafone.new(:host => $MQTT_broker, :port => $normal_port, :username => $MQTT_user, :password => $MQTT_password)\n\t\tmqtt_client.connect()\n\t\t\n\t\t# Simulating EPD\n\t\t#result = mqtt_client.simulate_status_frame\n\t\t#assert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => \"FFFFFF;30;1;90;150;220;60;0;60;60;0;60;50\"} # RAE: To Improve\n\n\t\t# EPD with data\n\t\tstatus_parameters = {\n\t\t\tid_radio: \"123456\",\n\t\t\ttemp: 30,\n\t\t\tstat: 1,\n\t\t\tdstat: 75,\n\t\t\tvoltage: 220,\n\t\t\tcurrent: 120,\n\t\t\tactive_power: 75,\n\t\t\treactive_power: 0,\n\t\t\tapparent_power: 75,\n\t\t\taggregated_active_energy: 150,\n\t\t\taggregated_reactive_energy: 0,\n\t\t\taggregated_apparent_energy: 150,\n\t\t\tfrequency: 50\n\t\t}\n\n\t\tresult = mqtt_client.simulate_status_frame(\"LU/LUM/SEN\", status_parameters)\n\t\tassert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => \"123456;30;1;75;120;220.0;75.0;0.0;75.0;150;0;150;50;\"} # RAE: To Improve\n\n\t\tmqtt_client.disconnect()\n\n\tend", "def run_fe_tests\n end", "def test_start_new_game\n @qtquickmemory.start\n @qtquickmemory.verify_pairs_open\n @qtquickmemory.verify_clock_timer\n @qtquickmemory.pause_game\n @qtquickmemory.exit\n end", "def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n\n if code == SUCCESS\n in_tests = false\n connection.waitfor(@end_reg) do |txt|\n in_tests = handle_text(txt: txt, in_tests: in_tests)\n end\n connection.puts(\"cont\\n\")\n end\n end", "def startTest(client, dtype, dname, logid, passw, ttype, tcsno, wifis, build)\n\n\t\t#$dname = client.waitForDevice(\"\\\"@name='#{dname}' AND @remote='true'\\\"\", 300000)\n\t\t@dtype = dtype\n\t\t@dname = dname\n\t\t@logid = logid\n\t\t@passw = passw\n\t\t@ttype = ttype\n\t\t@tcsno = tcsno\n\t\t@wifis = wifis\n\t\t@build = build\n\n\t\tif @ttype == \"select\"\n\t\t\tx = @tcsno.split \",\"\n\t\t\tputs \"::MSG::TCs to be EXECUTED : #{x}\"\n\t\t\t$total_tc = x.length\n\t\telse\n\t\t\t$total_tc = 37\n\t\tend\n\n\t\tif @dtype == \"ios\"\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"c24994f50118a6ae9db6a911da628b477a0ba401\", \"ipadair\")\n\t\t\tclient.setDevice(\"#{\"ios_app:\" + @dname}\")\n\t\t\t#client.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\tclient.sleep(2000)\n\t\t\tif @build == nil\n\t\t\t\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\telse\n\t\t\t\tputs ($obj_instl.ios_testInstallApps(client, @build))\n\t\t\tend\n\t\t\tclient.launch(\"jp.unext.mediaplayer\", true, false)\n\t\t\tclient.sleep(5000)\n\t\t\t$obj_slctv.iosSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\n\t\telsif @dtype == \"android\"\t\t\t\t\t\t\n\t\t\t#client.setDevice(\"#{$dname}\")\n\t\t\t#client.waitForDevice(\"\\\"@name='#{$dname}' AND @remote='true'\\\"\", 300000)\n\t\t\t#temp: code for reserving a remote iOS device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices')\n\t\t\treq = Net::HTTP::Get.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\t#Get the device id for the desired device\n\t\t\tapi_result = JSON.parse(res.body)\n\t\t\tdevices_array = api_result[\"data\"]\n\t\t\trequested_device_id = \"\"\n\t\t\t\n\t\t\tdevices_array.each do |device|\n\t\t\t \tif device[\"deviceName\"] == @dname\n\t\t\t\t\trequested_device_id = device[\"id\"]\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t\t#And now reserve the device\n\t\t\turi = URI('http://10.4.136.3:8081/api/v1/devices/' + requested_device_id + '/reservations/new')\n\t\t\treq = Net::HTTP::Post.new(uri)\n\t\t\treq.basic_auth 'admin', 'Unext1101'\n\t\t\t#req.basic_auth 'unext-qa', 'Unextqa1'\n\t\t\treq.set_form_data('start' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"), 'end' => '2016-12-30-23-00-00', 'clientCurrentTimestamp' => Time.new.strftime(\"%Y-%m-%d-%H-%M-%S\"))\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) {|http|\n\t\t\t http.request(req)\n\t\t\t}\n\t\t\tclient.addDevice(\"CB5A233UKX\", \"401SO\")\n\t\t\tclient.setDevice(\"#{@dname}\")\n\t\t\t#temp\n\n\t\t\tclient.openDevice()\n\t\t\tclient.sleep(2000)\n\t\t\t$obj_utili.andConnectingWifi(client, @dtype, @dname, @wifis)\n\t\t\t#CURRENTLY AUTO BUILD FOR ANDROID IS NOT PREPARED, WHEN JENKINS AUTO BUILD WILL BE DELIVERED, TEST CAN BE RESUMED\n\t\t\t#if @build == nil\n\t\t\t#\tputs \"::MSG:: Apps will be using currently installed build\"\n\t\t\t#else\n\t\t\t#\tputs ($obj_instl.testInstallApps(client, @build))\n\t\t\t#end\n\t\t\tclient.launch(\"jp.unext.mediaplayer/jp.co.unext.unextmobile.MainActivity\", true, false)\n\t\t\tclient.sleep(5000)\t\t\t\n\t\t\t$obj_slctv.andSelectiveTests(client, @logid, @passw, @ttype, @tcsno)\t\t\n\t\telse\n\t\t\tputs \"::MSG:: 該当デバイスが見つかりません「Confirm target test devcie」\"\n\t\tend\t\t\n\tend", "def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n @device_config[:init_params] = {\n root_dir: @root_dir\n }\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n if code == SUCCESS\n @device_config[:init_params] = nil\n linker = Linker.new(**@device_config)\n linker.launch(options: \"RunTests:true\")\n\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\n end", "def setup_test_1(test_name, epw_path)\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n if !File.exist?(sql_path(test_name))\n puts \"Running EnergyPlus\"\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def test_001\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n @@pu.destroy\n # logout\n logout\n\n end", "def test_007\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n @@pu = Pu.find_by_name('SamplePU1')\n\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')\n\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link2\"]\n sleep 2\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end", "def pickUp(simulator)\n end", "def test_004\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 全体解析 (Analysis of all)\n select \"analyze_type\", \"label=#{@overall}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #There is no display below \"selection of the upload method of an individual analysis file.\"\n assert !is_text_present(_(\"Select the upload method of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end", "def test_005\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # Below \"selection of the upload method of an individual analysis file\" is displayed.\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end", "def run\n # Change the working directory to the directory of this script.\n Dir.chdir(File.dirname(__FILE__)) \n\n # if LIST_TECHNIQUES is true, just output available evasion techniques.\n if datastore['LIST_TECHNIQUES'] == true\n print_available_techniques()\n else\n payload = datastore['PAYLOAD']\n payload_options = datastore['PAYLOAD_OPTIONS']\n output_directory = datastore['OUTPUT_DIRECTORY']\n executable_name = datastore['EXECUTABLE_NAME']\n evasion_stack = datastore['EVASION_STACK']\n msfvenom_path = datastore['MSFVENOM_PATH']\n\n if payload == nil\n print_error(\"PAYLOAD must be set.\")\n return \n end\n if output_directory == nil \n print_error(\"OUTPUT_DIRECTORY must be set.\")\n return\n end\n if executable_name == nil \n print_error(\"EXECUTABLE_NAME must be set.\") \n return\n end\n if msfvenom_path == \"\"\n # Guess at path to msfvenom\n msfvenom_path = Dir.pwd[0..(Dir.pwd.index(\"pro\")+3)]+\"msf3/msfvenom\"\n print_status(\"MSFVENOM_PATH not specified. Hoping msfvenom can be found at \"+msfvenom_path+\".\")\n end\n\n binary_generated = generate_binary(msfvenom_path, payload, payload_options)\n if binary_generated\n print_status(\"Payload binary generated successfully.\")\n print_status(\"Generating evasive source from generated binary.\")\n\n generate_evasive_source(evasion_stack)\n\n executable_generated = generate_executable(output_directory+\"/\"+executable_name)\n\n if executable_generated\n print_status(\"Executable successfully generated.\")\n else\n print_error(\"Unable to generate executable.\")\n end\n else\n print_error(\"Payload generation with msfvenom failed.\")\n end\n\n print_status(\"Cleaning up temporary files.\")\n\n if File.exist?('tmp/bin'+self.uuid+'.c')\n File.delete('tmp/bin'+self.uuid+'.c')\n end\n if File.exist?('tmp/evasive'+self.uuid+'.c')\n File.delete('tmp/evasive'+self.uuid+'.c')\n end\n\n end\n end", "def test(options:)\n get_device do |device|\n loader = Loader.new(config: @config)\n loader.sideload(options: options, device: device)\n linker = Linker.new(config: @config)\n linker.deeplink(options: Options.new(options: {deeplink: \"RunTests:true\"}), device: device)\n\n telnet_config ={\n 'Host' => device.ip,\n 'Port' => 8085\n }\n connection = Net::Telnet.new(telnet_config)\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\n end", "def test_010\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def testing_engine\n puts \"engine method\"\n end", "def setup\n java.lang.System.setProperty(\"vbox.home\", Travis::Worker.config.vms.vbox_home)\n\n require 'vboxjxpcom.jar'\n\n java_import 'org.virtualbox_4_1.VirtualBoxManager'\n java_import 'org.virtualbox_4_1.VBoxEventType'\n java_import 'org.virtualbox_4_1.LockType'\n java_import 'org.virtualbox_4_1.MachineState'\n java_import 'org.virtualbox_4_1.IMachineStateChangedEvent'\n java_import 'org.virtualbox_4_1.DeviceType'\n java_import 'org.virtualbox_4_1.AccessMode'\n java_import 'org.virtualbox_4_1.MediumType'\n java_import 'org.virtualbox_4_1.SessionState'\n end", "def test_011\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n sleep 2\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link2\"]\n # check log in the navigation bar\n sleep 2\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_0\n\n #log_level_to_debug\n\n li = OpenWFE::LaunchItem.new\n li.wfdurl = 'file:test/_testdef.rb'\n\n dotest(li, %w(a b c).join(\"\\n\"))\n end", "def test_008\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')#\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n\n click $xpath[\"task\"][\"registration_task_button\"]\n sleep 2\n #assert !60.times{ break if (is_text_present(\"解析ツール未選択 入力内容に問題があるためタスクを登録できません。\") rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end", "def test_FleetRequest_FromSearchPage\n # Navigate to the volvo demo site\n @driver.get $env\n \n #1. Login to the application \n Login($uname, $pwd, \"1.0\") \n \n #2. Perform vehicle search with unit# and verify the search results \n VehicleSearchWithUnit_No(\"222\", \"2\")\n \n #3. Perform service location search with location field and verify the search results\n Search_Service_Location_With_Location(\"Dallas,TX\", \"3\")\n \n #4. Create service request for the searched vehicle and service location and submit the request.\n Create_Service_Request(\"123\",\"Engine failure\", \"Please respond immediately\", \"9876543210\", \"testdriver\", \"9876543210\", \"street1\", \"Dallas\", \"Virginia\", \"4\")\n \n end", "def setup_test(test_name, idf_output_requests, model_in_path, epw_path = epw_path_default)\n\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n assert(File.exist?(model_in_path))\n\n if File.exist?(model_out_path(test_name))\n FileUtils.rm(model_out_path(test_name))\n end\n\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new(\"Draft\".to_StrictnessLevel, \"EnergyPlus\".to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(test_name), true)\n\n if is_openstudio_2?\n setup_test_2(test_name, epw_path)\n else\n setup_test_1(test_name, epw_path)\n end\n end", "def test_pentagondodekaeders_suface\n assert_in_delta(82.5829152283, pentagondodekaeders_surface(2), 0.0000000001)\n\n assert_equal(0, pentagondodekaeders_surface(0))\n\n assert_raise(RT) { pentagondodekaeders_surface(-2) }\n assert_raise(RT) { pentagondodekaeders_surface('2') }\n end", "def test_a\n traci =\n Sumo::Traci::Client.newWithServer(SampleConfFile,\n { :logDev => [:stdout,:file],\n# :logLevel => :debug,\n :logLevel => :info,\n },\n :gui) ;\n #\n managerConf = { :traciClient => traci,\n nil => nil }\n vManager = Sumo::Traci::VehicleManager.new(managerConf) ;\n\n # loop\n step = 0 ;\n ustep = 100 ;\n delay = 0.001 ;\n while(step < 2000*1000)\n # simulation を進める。\n step += ustep\n com = Sumo::Traci::Command_SimulationStep.new(step) ;\n traci.execCommands(com) ;\n\n #update\n vManager.updateVehicleTableWhole() ;\n\n #slow down\n if(rand(10) == 0) then\n vehicle = vManager.vehicleList.sample() ;\n if(!vehicle.nil?) then\n speed = 10 * rand() ;\n duration = 1.0 ;\n vehicle.submitSlowDown(speed, duration) ;\n end\n end\n \n #sleep\n sleep(delay) ;\n end\n \n end", "def setup \n\t\tputs 'setup: ' + @test_name \n\n\t\t#device capabilities goes here:\n\t\tcapabilities = {\n\t\t\t:platformName => 'Android',\n\t\t\t:model => 'Galaxy S6', #Optional \n\t\t\t:platformVersion => '', #Optional \n\t\t\t:browserName => 'mobileOS', #Optional \n\t\t\t:browserVersion => '', #Optional for web\n\t\t\t:deviceName => '' #Optional\n\t\t}\n\n\t\t#your host url\n\t\thost = 'branchtest.perfectomobile.com'\n\n\t\t#Your perfecto lab credentials (using security token is recommended)\n\t\tcapabilities['securityToken'] = 'MY_TOKEN'\n\t\t#capabilities['user'] = 'MY_USER'\n\t\t#capabilities['password'] = 'MY_PASS'\n\n\n\t\t@driver = Selenium::WebDriver.for(:remote, :url => \"http://\" + host + \"/nexperience/perfectomobile/wd/hub\", :desired_capabilities =>capabilities) \n\tend", "def testing\n # ...\n end", "def setup_test\n\n assert(File.exist?(model_path))\n\n if !File.exist?(run_dir)\n FileUtils.mkdir_p(run_dir)\n end\n assert(File.exist?(run_dir)) \n\n if File.exist?(report_path)\n FileUtils.rm(report_path)\n end\n\n if !File.exist?(sql_path)\n puts \"Running EnergyPlus\"\n\n osw_path = File.join(run_dir, 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_path))\n workflow.setWeatherFile(File.absolute_path(epw_path))\n workflow.saveAs(osw_path)\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n end\n end", "def test_009\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"analyze_allow_file_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(\"analyze_allow_files(qac)\") rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"analyze_allow_file_link2\"]\n # check log in the navigation bar\n sleep 2\n assert !60.times{ break if (is_text_present(\"analyze_allow_files(qacpp)\") rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_valid_account\n assert_equal 0, elfproef(123456789)\n assert_equal 0, elfproef('12.34.56.789')\n assert_equal 0, elfproef('12 34 56 789')\n assert_equal 0, elfproef(1234567)\n assert_equal 0, elfproef('1234567')\n end", "def test_002\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n click $xpath[\"task\"][\"read_tree\"]\n\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n # logout\n logout\n\n end", "def test_version\n\n #prepare\n subject=Xcider::Xcodebuild.new\n\n #test\n v=subject.version\n\n #verify\n assert_not_nil v\n\n end", "def test_victorious\n\t\tp = Print.new\n\t\tassert_output(\"Going home victorious!\\n\") {p.print_game_win_or_lose(16)}\n\tend", "def test_021\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n # logout\n logout\n\n end", "def ios_testContinuePlay(client)\n\t\tclient.sleep(2000)\n\t\t\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST CONTINUE PLAY@つづきを再生\"\n\n\t\t$totalTest = $totalTest + 1 \n\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tif client.waitForElement(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayIndicator' and ./preceding-sibling::*[./*]][1]\", 0, 10000)\n\t\t \t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayingStateView' and @width>0 and ./parent::*[./preceding-sibling::*[./*]]][1]\", 0, 1)\n\t\t\t\t\tContinuePlay.new.ios_playingOperation(client)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayIndicator' and ./preceding-sibling::*[./*]][1]\", 0, 1)\n\t\t\t\tContinuePlay.new.ios_playingOperation(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgConti = \"::MSG:: Exception occurrred while finding ELEMENT\" + e.message\n\t\tend\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 5\n\t\t@testcase_summary = \"つづきを再生\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgConti\n\t\t@comment = @@comment\n\t\t\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def native_eva\n 5\n end", "def pre_rvtest\n RVTEST_RV64U()\n RVTEST_CODE_BEGIN()\n end", "def setup\n\n if File.exist?(reportPath())\n FileUtils.rm(reportPath())\n end\n\n assert(File.exist?(modelPath()))\n\n if !File.exist?(runDir())\n FileUtils.mkdir_p(runDir())\n end\n assert(File.exist?(runDir()))\n\n if !File.exist?(sqlPath())\n puts \"Running EnergyPlus\"\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n vt = OpenStudio::OSVersion::VersionTranslator.new\n model = vt.loadModel(modelPath())\n assert(model.is_initialized)\n model = model.get\n\n # make sure output requests are in pre-run model, this will happen automatically in PAT\n var = OpenStudio::Model::OutputVariable.new('Site Outdoor Air Drybulb Temperature', model)\n var.setReportingFrequency('Monthly')\n\n var = OpenStudio::Model::OutputVariable.new('Zone Air Temperature', model)\n var.setReportingFrequency('Hourly')\n\n var = OpenStudio::Model::OutputVariable.new('Zone Air Relative Humidity', model)\n var.setReportingFrequency('Hourly')\n\n model.save(OpenStudio::Path.new(runDir() + '/in.osm'), true)\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(runDir()), OpenStudio::Path.new(runDir() + '/in.osm'), OpenStudio::Path.new(epwPath()))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def test_collectible_device_showa\n assert_raise('Faker::JapaneseMedia::KamenRider::UnavailableInEra') { @tester.collectible_device(:showa) }\n end", "def test_006\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #A task type is changed into \"individual analysis\"\n # with a \"general control\" tab.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析 (Individual Analysis)\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n #An option setup of \"master: A qac\" subwindow is displayed.\n click $xpath[\"task\"][\"option_setup_link\"]\n # click \"link=設定する\"\n sleep 3\n # #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n sleep 2\n\n # logout\n logout\n\n end", "def make_proxmox_vm(vm)\n # * Disk: Use a SSD if possible. Preallocated might provide faster access.\n hd_file=@disk_folder+\"/#{vm}-HD.vdi\"\n\n # NOTE! Lots of code also available for inspiration in\n # /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.5/plugins/providers/virtualbox/driver/version_4_3.rb\n\n\n unless(File.file?(@install_iso))\n raise \"ERROR - you need to download the ISO file at #{@install_iso} from https://www.proxmox.com/downloads\"\n end\n\n ide_storage_name=\"IDE Controller for #{vm}\"\n description = \"Proxmox-in-Virtualbox generated by https://github.com/mrjcleaver/proxmox-setup \\n\" + \\\n \"Generated \"+Time.now.to_s+ \" using \"+@install_iso\n\n # http://nakkaya.com/2012/08/30/create-manage-virtualBox-vms-from-the-command-line/\n # https://www.virtualbox.org/manual/ch08.html\n run_shell_cmd(\"VBoxManage createvm --name '#{vm}' --register\")\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --description '#{description}'\")\n # Note: Enabling the I/O APIC is required for 64-bit guest operating systems (page 48, manual)\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --memory '#{@ram_mb}' --acpi on --ioapic on --boot1 dvd --vram 12\")\n\n run_shell_cmd(\"VBoxManage modifyvm '#{vm}' --ostype Debian --audio none\")\n\n run_shell_cmd(\"VBoxManage createhd --filename '#{hd_file}' --size '#{@hd_size_mb}' --variant Fixed\")\n run_shell_cmd(\"VBoxManage storagectl '#{vm}' --name '#{ide_storage_name}' --add ide\")\n\n run_shell_cmd(\"VBoxManage storageattach '#{vm}' --storagectl '#{ide_storage_name}' --port 0 --device 0 --type hdd --medium '#{hd_file}' --nonrotational=#{@hd_on_ssd}\")\n\n run_shell_cmd(\"VBoxManage storageattach '#{vm}' --storagectl '#{ide_storage_name}' --port 1 --device 0 --type dvddrive --medium '#{@install_iso}'\")\n\n run_shell_cmd(\"VBoxManage setextradata '#{vm}' GUI/MouseCapturePolicy Default\")\nend", "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_get_dino\n\t\t@new_driver.dino 5\n\t\tassert_equal 5, @new_driver.dino(0)\n\tend", "def ios_testEditDownloadList(client)\n\t\tclient.sleep(2000)\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST EDITING DOWNLOAD@ダウンロードの編集機能\"\n\n\t\t$totalTest = $totalTest + 1 \n\n\t\tbegin\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tEditDownload.new.ilistEditing(client)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\t\t\t\t\n\t\t\t\tEditDownload.new.ilistEditing(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEditd = \"::MSG:: Exception occurrred while finding element: \" + e.message\t\n\t\tend\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\"\n\t\t@testcase_num = 20\n\t\t@testcase_summary = \"ダウンロードの編集\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgEditd\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def test_024\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the state\n #where it does not check at the information dialog\n #which clicks analyze_deny_files and comes out are enumerated.\n\n click $xpath[\"task\"][\"analyze_deny_files\"]\n sleep 3\n\n assert is_text_present(\"sample_c/Makefile\")\n\n\n # logout\n logout\n\n end", "def test_add_dino\n\t\tassert_equal 1, @new_driver.dino(1)\n\tend", "def test_023\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #The directory/file names which were being changed into the check state\n #at the information dialog which clicks analyze_allow_files\n #and comes out are enumerated.\n click $xpath[\"task\"][\"analyze_allow_file_link\"]\n sleep 3\n\n assert !is_text_present(\"sample_c/Makefile\")\n\n # logout\n logout\n\n end", "def test_025\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n #Move to general control tab\n click $xpath[\"task\"][\"general_control_tab\"]\n\n #The information set does not disappear and remains.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n # logout\n logout\n\n end", "def test_016\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n #An option setup was performed\n\n assert is_checked($xpath[\"task\"][\"master_option_chk2\"])\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Click a directory link\n click $xpath[\"task\"][\"master_option_dir1\"]\n sleep 2\n assert !is_checked($xpath[\"task\"][\"master_option_chk3\"])\n assert !is_checked($xpath[\"task\"][\"master_option_chk4\"])\n\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_print_items_dinos\r\n\t\tmock_argv = [867530]\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_dinos, 3\r\n\tend", "def test_invalid_account\n assert_equal 9, elfproef(999999999)\n assert_equal 9, elfproef('99.99.99.999')\n assert_equal 9, elfproef('99 99 99 999')\n end", "def ios_testPurchasedItemPlay(client)\n\t\tclient.sleep(2000)\n\t\t\n\t\tputs \"\"\n\t\tputs \"\"\n\t\tputs \"::MSG::[iOS] STARTING TEST PLAYING FROM PURCHASED@購入済みから再生\"\n\n\t\t$totalTest = $totalTest + 1 \n\t\t\n\t\tclient.sleep(2000)\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"text=つづきを再生\")\n\t\t\t\tPurchasePlay.new.ios_purchasedList(client)\n\t\t\telse\n\t\t\t\tclient.sleep(1000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='ホーム']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tPurchasePlay.new.ios_purchasedList(client)\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgBougt = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\t\n\n\t\tif $execution_time == nil\n\t\t\t@exetime = $execution_time\n\t\telse\n\t\t\t@exetime = $execution_time\n\t\tend\n\t\t@test_device = \"iOS\" \n\t\t@testcase_num = 8\n\t\t@testcase_summary = \"購入済みから再生\"\n\t\t@test_result = $result\n\t\t@capture_url = $captureURL\n\t\t@err_message = $errMsgBougt\n\t\t@comment = @@comment\n\n\t\tputs ($obj_snddb.insertIntoReleaseTestEachFunc(@exetime, @testcase_num, @testcase_summary, @test_result, @capture_url, @err_message, @comment))\n\tend", "def test_020\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n\n #A subwindow carries out fade-out and closes.\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_without_vm\n prep\n test_services\n end", "def test_environment_can_be_selected_and_changed\r\n @installer = DBGeni::Base.new(helper_sqlite_multiple_environment_file)\r\n assert_nothing_raised do\r\n @installer.select_environment('development')\r\n end\r\n assert_equal('development', @installer.selected_environment_name)\r\n assert_nothing_raised do\r\n @installer.select_environment('test')\r\n end\r\n assert_equal('test', @installer.selected_environment_name)\r\n end", "def test_FT_afn_single_zone_nv\n sdd_ft_test('afn_single_zone_nv.osm')\n end", "def test_003\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # select uploading method in the master tab\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n #Click button Read tree\n click $xpath[\"task\"][\"read_tree\"]\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n #It will return, if a check is returned for uploading collectively (F2-003)\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # logout\n logout\n\n end", "def run_app_tests\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_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end", "def test_ut_da10b_t1_15\n p \"Test 15\"\n # gets a list of pjs belong to selected pu\n pjs = @pu.get_pjs_belong_to_pu\n expected_pj = [[\"\", 0], [\"SamplePJ1\", 1], [\"SamplePJ2\", 2]]\n assert_equal expected_pj, pjs\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def test_017\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n #An option is checked\n assert is_checked($xpath[\"task\"][\"master_option_chk2\"])\n #Click a directory link\n click $xpath[\"task\"][\"master_option_dir1\"]\n sleep 2\n #All file of directory is checked.\n\n assert is_checked($xpath[\"task\"][\"master_option_chk3\"])\n assert is_checked($xpath[\"task\"][\"master_option_chk4\"])\n\n\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end", "def test_TestPaper\n # login(\"cn.fra\", \"12345\")\n begin\n\n @@title=$question\n $action.open($link+\"/Course/ExamTemplateTrain.aspx\")\n assert_equal(@@loginpage.getTitle,\"EF Online Academy\")\n @@testpaperpage.addNew\n @@testpaperpage.title(@@title)\n\n @@testpaperpage.uniqueId(Time.now.to_s)\n @@testpaperpage.description(@@title)\n @@testpaperpage.totalScore(\"100\")\n @@testpaperpage.passScore(\"0\")\n @@testpaperpage.testTime(\"10\")\n @@testpaperpage.layout \"123\"\n @@testpaperpage.tag\n # @@testpaperpage.addGroup \"1\",@@title\n @@testpaperpage.addGroup @@title\n sleep 3\n @@testpaperpage.ok\n sleep 6\n @@testpaperpage.titleFilter(@@title)\n @@testpaperpage.search\n sleep 3\n assert($action.findelementByName(\"ctl00$cphMain$rptList$ctl00$imgBtnEdit\"))\n $log.puts(__method__.to_s+\" -------------------pass \\n\")\n\n rescue\n $log.puts(__method__.to_s+\" -------------------fail \\n\")\n $action.screenshot($path)\n puts \":error:#{$!}-----at:#{$@} \\n\"\n end\n end", "def sdd_rt_test(sddsimxml_path)\n full_path = File.join($SddSimDir, sddsimxml_path)\n\n filename = escapeName(sddsimxml_path.gsub(' - ap.xml', '.xml'))\n\n # puts \"\\nRunning for #{filename}\"\n # puts \"Loading #{full_path}\"\n\n if $Disabled_RT_Tests.include?(filename)\n skip \"Test is disabled for #{filename}\"\n end\n rt = OpenStudio::SDD::SddReverseTranslator.new\n _m = rt.loadModel(full_path)\n # Test that RT Worked\n assert _m.is_initialized, \"Failed SDD RT for #{filename}\"\n\n # Need to add the DDY\n m = add_design_days(_m.get)\n\n # If so, then save resulting OSM for diffing\n m_out = File.join($TestDirSddRT, filename)\n # puts \"Saving at #{m_out}\"\n\n m.save(m_out, true)\n\n # Now do the sim_test portion!\n sim_test(filename, { base_dir: $TestDirSddRT })\n # m_out = File.join($TestDirSddRT, \"#{filename}_#{$SdkVersion}_out#{$Custom_tag}.osm\")\nend", "def simulator\n\n if GlobalConstant::Base.main_sub_environment?\n redirect_to :dashboard, status: GlobalConstant::ErrorCode.permanent_redirect\n end\n\n @response = CompanyApi::Request::Economy.new(\n CompanyApi::Response::Formatter::Economy,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_simulator_details\n\n # Check if error present or not?\n unless @response.success?\n render_error_response(@response)\n return\n end\n\n @presenter_obj = ::WebPresenter::Economy::Simulator.new(@response, params)\n unless @presenter_obj.client_token.step_three_done?\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect\n return\n end\n\n end", "def test_valley_smoketest\n @driver.get(@base_url)\n verify_home_page()\n verify_services_page()\n verify_about_page()\n verify_contact_page()\n verify_faq_page()\n verify_links_page()\n end", "def startDSSim\n begin\n $MatLib = SU2DS::MaterialLibrary.new() \n rs = SU2DS::RadianceScene.new()\n rs.export(SU2DS::RadianceScene::EMODE_SIM) ## modified for su2ds\n rescue => e \n msg = \"%s\\n\\n%s\" % [$!.message,e.backtrace.join(\"\\n\")]\n UI.messagebox msg \n end \nend", "def discover_tests\n # List of exterior cells coordinates, per worldspace name, per plugin name\n # Hash< String, Hash< String, Array<[Integer, Integer]> > >\n exterior_cells = {}\n @game.xedit.run_script('DumpInfo', only_once: true)\n @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|\n esp_name, record_type = row[0..1]\n if record_type.downcase == 'cell'\n cell_type, cell_name, cell_x, cell_y = row[3..6]\n if cell_type == 'cow'\n if cell_x.nil?\n log \"!!! Invalid record: #{row}\"\n else\n esp_name.downcase!\n exterior_cells[esp_name] = {} unless exterior_cells.key?(esp_name)\n exterior_cells[esp_name][cell_name] = [] unless exterior_cells[esp_name].key?(cell_name)\n exterior_cells[esp_name][cell_name] << [Integer(cell_x), Integer(cell_y)]\n end\n end\n end\n end\n # Test only exterior cells that have been changed by mods, and make sure we test the minimum, knowing that each cell loaded in game tests 5x5 cells around\n vanilla_esps = @game.game_esps\n vanilla_exterior_cells = vanilla_esps.inject({}) do |merged_worldspaces, esp_name|\n merged_worldspaces.merge(exterior_cells[esp_name] || {}) do |_worldspace, ext_cells_1, ext_cells_2|\n (ext_cells_1 + ext_cells_2).sort.uniq\n end\n end\n changed_exterior_cells = {}\n exterior_cells.each do |esp_name, esp_exterior_cells|\n next if vanilla_esps.include?(esp_name)\n\n esp_exterior_cells.each do |worldspace, worldspace_exterior_cells|\n if vanilla_exterior_cells.key?(worldspace)\n changed_exterior_cells[worldspace] = [] unless changed_exterior_cells.key?(worldspace)\n changed_exterior_cells[worldspace].concat(vanilla_exterior_cells[worldspace] & worldspace_exterior_cells)\n end\n end\n end\n tests = {}\n # Value taken from the ini file\n # TODO: Read it from there (uiGrid)\n loaded_grid = 5\n delta_cells = loaded_grid / 2\n changed_exterior_cells.each do |worldspace, worldspace_exterior_cells|\n # Make sure we select the minimum cells\n # Use a Hash of Hashes for the coordinates to speed-up their lookup.\n remaining_cells = {}\n worldspace_exterior_cells.each do |(cell_x, cell_y)|\n remaining_cells[cell_x] = {} unless remaining_cells.key?(cell_x)\n remaining_cells[cell_x][cell_y] = nil\n end\n until remaining_cells.empty?\n cell_x, cell_ys = remaining_cells.first\n cell_y, _nil = cell_ys.first\n # We want to test cell_x, cell_y.\n # Knowing that we can test it by loading any cell in the range ((cell_x - delta_cells..cell_x + delta_cells), (cell_y - delta_cells..cell_y + delta_cells)),\n # check which cell would test the most wanted cells from our list\n best_cell_x = nil\n best_cell_y = nil\n best_cell_score = nil\n (cell_x - delta_cells..cell_x + delta_cells).each do |candidate_cell_x|\n (cell_y - delta_cells..cell_y + delta_cells).each do |candidate_cell_y|\n # Check the number of cells that would be tested if we were to test (candidate_cell_x, candidate_cell_y)\n nbr_tested_cells = remaining_cells.\n slice(*(candidate_cell_x - delta_cells..candidate_cell_x + delta_cells)).\n inject(0) { |sum_cells, (_cur_cell_x, cur_cell_ys)| sum_cells + cur_cell_ys.slice(*(candidate_cell_y - delta_cells..candidate_cell_y + delta_cells)).size }\n next unless best_cell_score.nil? || nbr_tested_cells > best_cell_score\n\n best_cell_score = nbr_tested_cells\n best_cell_x = candidate_cell_x\n best_cell_y = candidate_cell_y\n end\n end\n # Remove the tested cells from the remaining ones\n (best_cell_x - delta_cells..best_cell_x + delta_cells).each do |cur_cell_x|\n next unless remaining_cells.key?(cur_cell_x)\n\n (best_cell_y - delta_cells..best_cell_y + delta_cells).each do |cur_cell_y|\n remaining_cells[cur_cell_x].delete(cur_cell_y)\n end\n remaining_cells.delete(cur_cell_x) if remaining_cells[cur_cell_x].empty?\n end\n tests[\"#{worldspace}/#{best_cell_x}/#{best_cell_y}\"] = {\n name: \"Load #{worldspace} cell #{best_cell_x}, #{best_cell_y}\"\n }\n end\n end\n tests\n end", "def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end", "def test_b\n traci =\n Sumo::Traci::Client.newWithServer(SampleConfFile2,\n { :logDev => [:stdout,:file],\n# :logLevel => :debug,\n :logLevel => :info,\n },\n :gui) ;\n #\n managerConf = { :traciClient => traci,\n nil => nil }\n vManager = Sumo::Traci::VehicleManager.new(managerConf) ;\n\n # loop\n step = 0 ;\n ustep = 100 ;\n delay = 0.001 ;\n while(step < 10000*1000)\n # simulation を進める。\n step += ustep\n com = Sumo::Traci::Command_SimulationStep.new(step) ;\n traci.execCommands(com) ;\n\n #update\n vManager.updateVehicleTableWhole() ;\n\n #slow down\n if(rand(10) == 0) then\n vehicle = vManager.vehicleList.sample() ;\n if(!vehicle.nil? && vehicle.isOnRoad?()) then\n speed = 10 * rand() ;\n duration = 1.0 ;\n vehicle.submitSlowDown(speed, duration) ;\n pp [:edgeList, vehicle.fetchRouteIndex(), vehicle.fetchEdgeList() ];\n end\n end\n \n #sleep\n sleep(delay) ;\n end\n traci.closeServer() ;\n end", "def test_012\n\n #login\n login\n\n #Open PU management page\n open_pu_management_page_1\n\n # Find a PU\n # Pu created\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #test for make root in the master tab & in the popup which is displayed by clicking 設定する\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n #test for make root\n type \"makeroot_qac\", \"abc\"\n run_script \"destroy_subwindow()\"\n assert is_text_present(_(\"Make root\")+\":\")\n click $xpath[\"task\"][\"option_setup_link\"]\n sleep 2\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n sleep 3\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n type \"makeroot_qac\", \"abc\"\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 2\n assert is_text_present(_(\"Make root\")+\":\")\n click $xpath[\"task\"][\"option_setup_link\"]\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n\n\n\n #logout\n logout\n\n end", "def test_022\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #Open master control tab\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n #Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n sleep 3\n #Click link set of qac\n click $xpath[\"task\"][\"set_qac_link\"]\n\n sleep 3\n #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n #uncheck an option setup of a directory.\n click $xpath[\"task\"][\"master_option_chk2\"]\n sleep 3\n\n #Set Make_root as a suitable directory.\n type \"option_makeroot\", \"public/\"\n\n #The button \"which returns reflecting change\" is clicked.\n click $xpath[\"task\"][\"back_to_reflect_the_changes\"]\n sleep 3\n\n #An option setup of the target tool is changed.\n assert is_text_present(_(\"Make root\")+\":\")\n\n #The Make root directory set as the make_root field enters.\n assert_equal \"public/\", get_value($xpath[\"task\"][\"make_root_main_link\"])\n\n # logout\n logout\n\n end", "def test_vmop_017\n _dolit = @vm.compile(nil, nil, :vm_dolit, :vm_next)\n _halt = @vm.compile(nil, nil, :vm_halt, :vm_next)\n _docol = @vm.compile(nil, nil, :vm_docol, :vm_next)\n _exit = @vm.compile(nil, nil, :vm_exit, :vm_next)\n _qdo = @vm.compile(nil, nil, :vm_question_do, :vm_next)\n _loop = @vm.compile(nil, nil, :vm_loop, :vm_next)\n _i = @vm.compile(nil, nil, :vm_i, :vm_next)\n _drop = @vm.compile(nil, nil, :vm_drop, :vm_next)\n # : test 0 0 ?do i drop loop halt ;\n _test = \n @vm.compile(nil, \n @vm.fetch(_docol), \n _dolit,\n 0,\n _dolit,\n 0,\n _qdo,\n '@L2',\n 'L1',\n _i,\n _drop,\n _loop,\n '@L1',\n 'L2',\n _halt,\n _exit)\n @vm.boot(_test)\n catch :halt do\n assert_equal(0, @vm.rdepth)\n # docol\n assert_equal(:vm_docol, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.rdepth)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(1, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(2, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # ?do\n assert_equal(:vm_question_do, @vm.step)\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n\n # halt\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_push, @vm.step)\n assert_equal(:vm_io, @vm.step)\n end\n assert_equal(:halt, @vm.state)\n end", "def test_perfind_evidence\r\n nodelist = @mymodel.node_list\r\n \r\n node1 = nodelist.add_node(1, 'node one', PERFIND);\r\n \r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil))\r\n\r\n node1.value_function = ValueFunction.new(0, 100, 'degrees')\r\n\r\n assert_equal(Evidence.undefined, node1.measure_to_evidence(nil)) \r\n assert_in_delta(node1.measure_to_evidence(45.4), 0.454, 0.0001)\r\n end", "def test_001\n # delete all existed projects\n delete_all_pus\n begin\n # there is no project\n open_pu_management_page\n wait_for_text_present(_(\"No PU has been registered\"))\n logout\n rescue Test::Unit::AssertionFailedError\n @verification_errors << $!\n end\n # return the original data (2 pus)\n make_original_pus\n end", "def tests; end", "def tests; end", "def test02_EventVideoPhotoPDF\n\t\tloginPost\n\t\t$browser.goto($patch_event)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\t$post_event_title.set(\"hiking extravaganza #{random}\")\n \t\t\t\t$post_event_calendar_start_text.set(\"2013-12-12\") \n \t\t\t\t$post_event_time_start_field.click\n \t\t\t\t$post_event_select_time.select(\"8:00 AM\")\n \t\t\t\t$post_event_location.set(\"olympic national park #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('wolf creek trail is unavailable')\")\n \t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/DungenessSpit102.26.2012.mov\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/PDFDocument.pdf\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/PDF2.pdf\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\tsleep 2\n\t\t\telse puts \"PS04T02: FAILED! User able to Post.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"PS04T02: FAILED! User able to Post.\")\n\t\t\tputs e\n\t\tend\n\tend", "def test_dvd_routings\n assert_routing '/dvds', :controller => 'dvds', :action => 'index'\n assert_routing '/dvds/index/1', :controller => 'dvds', :action => 'index', :id => '1'\n assert true\n end", "def test_vmop_016\n _dolit = @vm.compile(nil, nil, :vm_dolit, :vm_next)\n _halt = @vm.compile(nil, nil, :vm_halt, :vm_next)\n _docol = @vm.compile(nil, nil, :vm_docol, :vm_next)\n _exit = @vm.compile(nil, nil, :vm_exit, :vm_next)\n _qdo = @vm.compile(nil, nil, :vm_question_do, :vm_next)\n _loop = @vm.compile(nil, nil, :vm_loop, :vm_next)\n _i = @vm.compile(nil, nil, :vm_i, :vm_next)\n _drop = @vm.compile(nil, nil, :vm_drop, :vm_next)\n # : test 10 0 ?do i drop loop halt ;\n _test = \n @vm.compile(nil, \n @vm.fetch(_docol), \n _dolit,\n 10,\n _dolit,\n 0,\n _qdo,\n '@L2',\n 'L1',\n _i,\n _drop,\n _loop,\n '@L1',\n 'L2',\n _halt,\n _exit)\n @vm.boot(_test)\n catch :halt do\n assert_equal(0, @vm.rdepth)\n # docol\n assert_equal(:vm_docol, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.rdepth)\n # 10\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(10, @vm.tos)\n assert_equal(1, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # 0\n assert_equal(:vm_dolit, @vm.step)\n assert_equal(0, @vm.tos)\n assert_equal(2, @vm.depth)\n assert_equal(:vm_nop, @vm.step)\n # ?do\n assert_equal(:vm_question_do, @vm.step)\n assert_equal(4, @vm.rdepth)\n assert_equal(10, @vm.rnos)\n assert_equal(0, @vm.rtos)\n assert_equal(:vm_nop, @vm.step)\n\n # i (0)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(0, @vm.tos)\n\n # drop (0)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (0)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (1)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(1, @vm.tos)\n\n # drop (1)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (1)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (2)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(2, @vm.tos)\n\n # drop (2)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (2)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (3)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(3, @vm.tos)\n\n # drop (3)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (3)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (4)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(4, @vm.tos)\n\n # drop (4)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (4)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (5)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(5, @vm.tos)\n\n # drop (5)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (5)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (6)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(6, @vm.tos)\n\n # drop (6)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (6)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (7)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(7, @vm.tos)\n\n # drop (7)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (7)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (8)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(8, @vm.tos)\n\n # drop (8)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (8)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # i (9)\n assert_equal(:vm_r_fetch, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n assert_equal(9, @vm.tos)\n\n # drop (9)\n assert_equal(:vm_drop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n # loop (9)\n assert_equal(4, @vm.rdepth)\n assert_equal(:vm_loop, @vm.step)\n assert_equal(:vm_nop, @vm.step)\n\n assert_equal(1, @vm.rdepth)\n assert_equal(0, @vm.depth)\n assert_equal(:vm_push, @vm.step)\n assert_equal(:vm_io, @vm.step)\n end\n assert_equal(:halt, @vm.state)\n end", "def test_volume_of_a_cube()\n # add test code here\n result = volume_of_a_cube(2)\n assert_equal(8, result)\n end", "def setup\n # Each debugger test has its own debugger instance.\n @debugger = Google::Cloud::Debugger.new\n debugger_credentials = @debugger.service.credentials\n debugger_channel_cred = GRPC::Core::ChannelCredentials.new.compose \\\n GRPC::Core::CallCredentials.new debugger_credentials.client.updater_proc\n @vtk_debugger_client = Google::Cloud::Debugger::V2::Debugger::Client.new do |config|\n config.credentials = debugger_channel_cred\n end\n\n @debugger.start\n\n refute_nil @debugger, \"You do not have an active debugger to run the tests.\"\n refute_nil @vtk_debugger_client, \"You do not have an active debugger vtk client to run the tests.\"\n super\n end", "def abaeterno_test(test,argv)\n\tmy_args = []\n\tmy_args << test.files('abaeterno_input').first\n\tmy_args << \"options.heartbeat.logfile='../data/abaeterno.out'\"\n\tmy_args << \"options.trace_stats_disasm_file='../data/disasm_output'\"\n\tmy_args += argv\n\n\tlua_defs=LuaDefinitions.new :command_line => my_args\n\topts=Options.new(lua_defs,:test => test,:runid => \"test\"+test.tid+\"-\")\n\topts.load :data_dir, :display,\n\t\t:simnow_dir, :simnow_dir_link,\n\t\t:abaeterno_so, :abaeterno_so_link,\n\t\t:clean_sandbox, :screen\n\n\tsb=Sandbox.new(lua_defs,opts)\n\tsb.install :abaeterno_in, :simnow_pre, :simnow_dir,\n\t\t:abaeterno_so, :test_data\n\n\ti,o=sb.run_output('regression')\n\tdebug2(\"regression output begin\\n#{o}\\nregression output end\")\n\treturn false,\"incorrect return value\",sb.to_str if i!=0\n\n\ti,o=sb.run_output('check_regression')\n\tdebug2(\"check_regression output begin\\n#{o}\\ncheck_regression output end\")\n\treturn false,o.chomp,sb.to_str if i!=0\n\n\tsb.clean\n\treturn true,\"\",\"\"\nend", "def testPowerEfficient\n #=============================================================\n #TESTS POWEREFFICIENTSPACESTATION\n # 1. TO_S\n # 2. FIRE Y PROTECTION METHOD\n #=============================================================\n \n index = 1\n object = \"POWEREFFICIENTSPACESTATION\"\n section = \"METODO TO_S\"\n \n titleTest(index,object,section)\n puts \"#{@powerEfficient.to_s}\"\n \n #=============================================================\n \n index += 1\n section = \"METODOS FIRE Y PROTECTION\"\n \n titleTest(index,object,section)\n puts \"--> FIRE POWER: #{@powerEfficient.fire}\"\n puts \"--> PROTECTION POWER: #{@powerEfficient.protection}\"\n \n end", "def test_002_wip\r\n\r\n begin\r\n\r\n sTestCase_Name = \"test_002_wip\"\r\n puts2(\"Starting Testcase: #{sTestCase_Name}\")\r\n\r\n sleep(2)\r\n \r\n=begin\r\n\r\n# Example outputs on Win7 64bit for FF3.6.28 and IE 8\r\n\r\nBrowser name: Netscape\r\nBrowser version: 5.0 (Windows; en-US)\r\nCookies Enabled: true\r\nPlatform: Win32\r\nUser Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28\r\nappCodeName: Mozilla\r\n\r\nBrowser name: Microsoft Internet Explorer\r\nBrowser version: 4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; MS-RTC LM 8)\r\nCookies Enabled: true\r\nPlatform: Win32\r\nUser Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; MS-RTC LM 8)\r\nappCodeName: Mozilla\r\n\r\n=end\r\n\r\n\r\n\r\n\r\n if($bUseWebDriver == false)\r\n\t puts2(\"Browser appName: \" + $browser.execute_script(\"window.navigator.appName\").to_s)\r\n\t puts2(\"Browser appVersion: \" + $browser.execute_script(\"window.navigator.appVersion\").to_s)\r\n\t puts2(\"Cookies Enabled: \" + $browser.execute_script(\"window.navigator.cookieEnabled\").to_s)\r\n\t puts2(\"Platform: \" + $browser.execute_script(\"window.navigator.platform\").to_s)\r\n\t puts2(\"User Agent: \" + $browser.execute_script(\"window.navigator.userAgent\").to_s)\r\n\t puts2(\"appCodeName: \" + $browser.execute_script(\"window.navigator.appCodeName\").to_s)\r\n else\r\n\t puts2(\"Browser appName: \" + $browser.execute_script(\"return window.navigator.appName\").to_s)\r\n\t puts2(\"Browser appVersion: \" + $browser.execute_script(\"return window.navigator.appVersion\").to_s)\r\n\t puts2(\"Cookies Enabled: \" + $browser.execute_script(\"return window.navigator.cookieEnabled\").to_s)\r\n\t puts2(\"Platform: \" + $browser.execute_script(\"return window.navigator.platform\").to_s)\r\n\t puts2(\"User Agent: \" + $browser.execute_script(\"return window.navigator.userAgent\").to_s)\r\n\t puts2(\"appCodeName: \" + $browser.execute_script(\"return window.navigator.appCodeName\").to_s)\r\n end\r\n\r\n puts2(\"Brand: \" + $browser.brand())\r\n puts2(\"Version: \" + $browser.version())\r\n \r\n #puts2(\"Is jQuery active?\")\r\n #$browser.execute_script(\"return jQuery.active == 0\")\r\n\r\n rescue => e\r\n\r\n puts2(\"*** ERROR Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\r\n\r\n ensure\r\n\r\n $browser.close()\r\n\r\n end\r\n\r\nend", "def test_one_day\n\t\tg = Game.new(0,0,0)\n\t\tmocked_miner = Minitest::Mock.new(\"mocked miner\")\n\t\tdef mocked_miner.current_city; 0; end\n\t\tdef mocked_miner.increase_rubies(x,y); nil; end\n\n\t\tmocked_city = Minitest::Mock.new(\"mocked city\")\n\t\tdef mocked_city.get_rubies(x); [1,1]; end\n\t\tdef mocked_city.name; 'Town'; end\n\n\t\tmocked_printer = Minitest::Mock.new(\"mocked printer\")\n\t\tdef mocked_printer.print_day(x,y); nil; end\n\n\t\tassert_equal([1,1],g.one_day(mocked_miner,[mocked_city],mocked_printer))\n\tend", "def test_drivers_get_dinos\n\t\tloc = Location::new(\"Location\", [\"Place\"])\n\t\tdriv = Driver::new(1, loc)\n\t\tassert_equal 0, driv.get_dinos\n\tend", "def setup_test_2(test_name, epw_path)\n osw_path = File.join(run_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(test_name)))\n workflow.setWeatherFile(File.absolute_path(epw_path))\n workflow.saveAs(osw_path)\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n #puts cmd\n system(cmd)\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def create_test_interface\n cmd_out = `VBoxManage hostonlyif create`\n network_description = cmd_out.match(/.*'(.*)'.*/).captures[0]\n `VBoxManage.exe hostonlyif ipconfig \\\"#{network_description}\\\" --ip #{TEST_IP}`\n sleep 3\n network_description\n end", "def open_start\r\n\r\n @simulator = WIN32OLE.new('AutoItX3.Control')\r\n\r\n Dir.chdir(@sim_gui_path)\r\n Dir.pwd\r\n \r\n @simulator.Run(\"V4SingleSimulatorGUI.exe\")\r\n @simulator.WinWaitActive(\"Emerson (Copyright 2012)\")\r\n @simulator.ControlClick(\"Emerson (Copyright 2012)\",\"Remote Control on Port:\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad11\")\r\n @simulator.Send(\"{F1}\")\r\n @simulator.WinWaitActive(\"Open\")\r\n @simulator.ControlSetText(\"Open\", \"\",\"Edit1\",@sim_path)\r\n @simulator.ControlClick(\"Open\",\"&Open\",\"Button1\")\r\n @simulator.WinWaitActive(\"SelectIPAddress\")\r\n @simulator.ControlClick(\"SelectIPAddress\",\"Select\",\"WindowsForms10.BUTTON.app.0.bb8560_r15_ad12\")\r\n \r\n #Start simulator\r\n @simulator.Send(\"{F5}\")\r\n\r\n end", "def run_phase2_vmin(state, settings = {})\n\tputz \"Starting phase 2\"\n\t\n\t#if just switching from phase 1\n\t\t#binding.pry\n\t\tputs \"state.current_voltage = #{$state.current_voltage} , will do \"\n\t\tif state.phase_number == 1 \n\t\t\t\n\t\t\tstate.current_voltage = state.last_passing_voltage[state.asic_package]\n\t\t\tstate.results.push(state.last_passing_voltage[state.asic_package])\n\t\t\tstate.results_header.push('vmin_phase1')\n\t\telse\n\t\t\tstate.current_voltage += state.voltage_step\t\t\n\t\tend\n\tputs \"state.current_voltage = #{$state.current_voltage} , done \"\n\t\n\n\t# binding.pry\n\t#overvoltage protections\n\tstate.phase_number = 2\n\t\n\t#setting all packages and dies to default clock \n\tstate.default_clock.each do |i|\n\t\t$t.set_die_clock(i[0],i[1],\"all\",\"all\")\n\tend\n\t\t\n\t\n\t#setting clock value to specific value if defined\n\tif state.adjust_clock.size > 0\n\t\tstate.adjust_clock.each do |i|\n\t\t\t$t.set_die_clock(i[0],i[1],state.asic_package,state.asic_die)\n\t\tend\n\tend\n\t\n\n\tif (state.current_voltage > state.max_voltage)\n\t\tpute \"Maximum voltage of #{state.max_voltage} reached - stopping test\"\n\t\tputz \"Restoring to #{state.original_voltage[state.asic_package]} V\"\n\t\tif state.voltage_module == \"atitool\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.original_voltage[state.asic_package],state.asic_package)\t\n\t\telsif state.voltage_module == \"smu\"\n\t\t\t$vlt.set_voltage_rail(state.voltage_rail_name, state.original_voltage[state.asic_package])\n\t\tend\n\t\treturn false\n\tend\n\t\n\t# debug diag phase 2 load time\n\tsleep 10\n\t\n\tif state.os_type == \"windows\"\n\t\tputz \"\\nSetting #{state.voltage_rail_name} to #{state.current_voltage}\"\n\t\t\n\t\tif state.voltage_module == \"atitool\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.current_voltage,state.asic_package)\n\t\t\tstate.actual_voltage = $t.get_package_voltage(state.voltage_rail_name,state.asic_package)\n\t\telsif state.voltage_module == \"smu\"\n\t\t\tsleep 5\n\t\t\t$vlt.set_voltage_rail(state.voltage_rail_name,state.current_voltage)\n\t\t\tstate.actual_voltage[state.asic_package] = state.current_voltage\n\t\tend\n\t\n\n\t\t\n\t\t$obj.save(state)\n\t\t\n\t\t\n\t\trun_workload(state)\n\t\tsleep(state.phase2_dur)\n\t\tstop_workload(state)\n\t\t\n\telsif state.os_type == \"linux\"\n\t\n\t\tloop do\n\t\t\n\t\t\t# make sure the WD signal sent to server before running Diag\n\t\t\tp \"Starting Diag Test Phase 2\"\n\t\t\t$client.update_timeout(5 * state.update_timeout)\n\t\t\tresult = []\n\t\t\t$state.diag_loops.times {result.push(run_workload(state).to_s)}\n\t\t\t#binding.pry\n\t\t\tputz \"result = #{result}\"\n\t\t\t# assume for diag workload return pass or fail\n\t\t\tbreak if (result.include?('pass') or result.include?('true'))\n\t\t\t\n\t\t\t# increment voltage by one step if fail\n\t\t\tstate.current_voltage += state.voltage_step\n\t\t\tputz \"\\nSetting #{state.voltage_rail_name} to #{state.current_voltage}\"\n\t\t\t$t.set_package_voltage(state.voltage_rail_name,state.current_voltage,state.asic_package)\n\t\t\tstate.actual_voltage = $t.get_package_voltage(state.voltage_rail_name,state.asic_package)\n\t\t\n\t\t\t$obj.save(state)\n\t\n\t\tend\n\tend\n\t\t\t\n\t\n\t#restore to save voltage\n\t#debug\n\t# p state.voltage_rail_name\n\t# p state.original_voltage[state.asic_package]\n\t# p state.asic_package\n\t# binding.pry\n\t\n\t#restoring to default condition\n\tif state.voltage_module == \"atitool\"\n\t\t$t.set_package_voltage(state.voltage_rail_name,state.original_voltage[state.asic_package],state.asic_package)\n\telsif state.voltage_module == \"smu\"\n\t\t$vlt.set_voltage_rail(state.voltage_rail_name, state.original_voltage[state.asic_package])\n\tend\n\n\t\n\tstate.default_clock.each do |i|\n\t\t$t.set_die_clock(i[0],i[1],\"all\",\"all\")\n\tend\n\t\n\t# binding.pry\n\tstate.results.push(state.actual_voltage[state.asic_package])\n\tstate.results_header.push('vmin_phase2')\n\tputz \"Completed Phase2\"\n\t\n\t#if it gets here it passed\t\n\treturn true\t\n\t\nend", "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 verify_noop (noop_fc=0)\n \n result = false\n\t \n cmd_valid_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\")\n cmd_error_cnt = tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\")\n seq_cnt = tlm(\"#{@app.target_hk_str} #{Ccsds::PRI_HDR_SEQUENCE}\")\n event_seq_cnt = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\")\n \n cmd(\"#{@app.target} #{Osk::CMD_STR_NOOP} with #{Ccsds::PRI_HDR_STREAMID} #{@app.cmd_mid}, #{Ccsds::PRI_HDR_SEQUENCE} 0, #{Ccsds::PRI_HDR_LENGTH} 1, #{Ccsds::SEC_HDR_CHECKSUM} 0, #{Ccsds::SEC_HDR_FUNCCODE} #{noop_fc}\")\n wait(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD} == #{cmd_valid_cnt}+1\", 10) # Delay until updated cmd valid count or timeout. \n\t\n #~~puts tlm(\"#{@target_hk_str} CMD_VALID_COUNT\")\n if ( (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == (cmd_valid_cnt + 1)) && \n (tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_ERR}\") == cmd_error_cnt))\n \n # TODO - Add utility to queue recent events so they can be queried \n event_seq_cnt_delta = tlm(\"CFE_EVS EVENT_MSG_PKT CCSDS_SEQUENCE\") - event_seq_cnt\n event_app = tlm(\"CFE_EVS EVENT_MSG_PKT APP_NAME\")\n event_type = tlm(\"CFE_EVS EVENT_MSG_PKT EVENT_TYPE\")\n event_msg = tlm(\"CFE_EVS EVENT_MSG_PKT MESSAGE\")\n puts \"event_seq_cnt_delta = #{event_seq_cnt_delta}\\n\"\n if (event_seq_cnt_delta == 1)\n if ((event_app == @app.target) and (event_type == Fsw::Const::CFE_EVS_INFORMATION) and (event_msg.include? @app.version))\n result = true\n end\n else\n puts \"#{@app.target} NOOP test warning: Unable to verify event message. Event message sequence count changed by #{event_seq_cnt_delta}\" \n result = true\n end\n \n else\n if ( tlm(\"#{@app.target_hk_str} #{Osk::TLM_STR_CMD_VLD}\") == seq_cnt)\n raise \"#{@app.target} NOOP test failed: HK telemetry packet not received\"\n end\n raise \"#{@app.target} NOOP test failed: Command counters\"\n end\n\t\n return result\n \n end", "def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\t@runner.setLastOpenStudioModel(@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\t@runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end", "def test_lv_ops\n lvname = \"testlv_#{Time.now.to_i}\"\n bd = nil\n\n #\n # Test creating the LV\n #\n # vgroup does not exist\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('lkjwf99ex', lvname, 1024)\n bd.create\n end\n # invalid lv size\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 100000000024)\n bd.create\n end\n\n assert_nothing_raised do \n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n # device is formatted by default, check it\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n assert(bd.config_string == \"'phy:/dev/localvg/#{lvname},sda1,w'\")\n assert( File.exist? \"/dev/mapper/localvg-#{lvname}\")\n\n # lv already exists\n assert_raises Exception do\n bd = Domraider::BlockDevice.new_lv('localvg', lvname, 1024)\n bd.create\n end\n\n\n #\n # Test formatting the LV\n #\n bd.format\n if `blkid /dev/mapper/localvg-#{lvname}` !~ /TYPE=\"ext3\"/\n assert false\n end\n \n #\n # Test mouting the LV\n #\n mdir = bd.mount\n assert(`mount | grep #{mdir}` =~ /#{mdir}/)\n assert_raises Exception do\n bd.mount\n end\n \n #\n # Test umounting the LV\n #\n bd.umount\n assert(`mount | grep #{mdir}`.strip.chomp.empty?)\n Dir.rmdir mdir\n\n #\n # Test deleting the LV\n #\n bd.delete\n assert( !File.exist?(\"/dev/mapper/localvg-#{lvname}\") )\n end", "def startup(options)\n tester.set_timeset('arm_debug', 40)\n end", "def test_fortune_from_each_source\n sources = LinuxFortune.get_sources\n fortunes = []\n sources.each do |src|\n fortunes << src.fortune\n assert fortunes.size > 0\n #puts \"#{fortunes.last.source} --- #{src.fullpath}\"\n assert fortunes.last.source == src.fullpath\n end\n end" ]
[ "0.6494648", "0.57695836", "0.5758841", "0.57284546", "0.5614557", "0.5591371", "0.5577651", "0.5557862", "0.55324453", "0.55242133", "0.5487116", "0.5480146", "0.5461753", "0.5424026", "0.5380782", "0.5364412", "0.53617185", "0.5293567", "0.5292122", "0.529072", "0.52768546", "0.5270558", "0.52636385", "0.5255841", "0.5248121", "0.52439475", "0.5224573", "0.5222617", "0.5221604", "0.5205722", "0.5173973", "0.5158876", "0.5152118", "0.51417214", "0.5137116", "0.51345074", "0.51306474", "0.51250124", "0.5124397", "0.5121945", "0.5110778", "0.51091975", "0.5104348", "0.5098982", "0.5079276", "0.50749636", "0.506719", "0.5065662", "0.50619626", "0.5060463", "0.5033649", "0.5027117", "0.5022751", "0.5017237", "0.5013489", "0.50080985", "0.5004563", "0.49939612", "0.49926564", "0.49800253", "0.49794102", "0.4978009", "0.4966281", "0.4966281", "0.49629197", "0.4958566", "0.49510628", "0.49502724", "0.49501523", "0.49457547", "0.49274817", "0.49252638", "0.49246705", "0.49243692", "0.49225092", "0.49077228", "0.4905717", "0.4905156", "0.4897648", "0.4897648", "0.48939425", "0.48930925", "0.4885374", "0.48795065", "0.48743302", "0.48738942", "0.48699325", "0.48628852", "0.48616165", "0.485851", "0.48537266", "0.4850888", "0.48499435", "0.4849041", "0.48402038", "0.48368734", "0.48353422", "0.48347974", "0.48342183", "0.48302296", "0.4829349" ]
0.0
-1
Set/Get the api method
def method(method = nil) return @method if method.nil? @method = method.to_s.capitalize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_method\n @_api_method ||= \"#{method_from_class_name}.get\"\n end", "def http_method\n METHODS[self[:method]]\n end", "def api_method\n ''\n end", "def http_method(v)\n endpoint_info[:http_method] = v\n end", "def api=(value)\n @api = value\n end", "def method=(value)\n @method = value\n end", "def http_method(value = nil)\n if value\n @http_method = value\n else\n @http_method\n end\n end", "def get_api_method\n return if params[:action] == 'index' && params[:controller] == 'api/docs'\n begin\n # load the parent module (e.g. EOL::Api::Search) to get the default version\n method_class = \"EOL::Api::#{params[:action].camelize}\".constantize\n rescue => e\n render_error(\"Invalid method: #{params[:action]}\")\n return nil\n end\n\n begin\n # load the proper version of the API method (e.g. EOL::Api::Search::V1_0)\n params[:version] ||= method_class::DEFAULT_VERSION\n @api_method = \"#{method_class}::V#{params[:version].tr('.', '_')}\".constantize\n rescue => e\n render_error(\"Invalid version: #{params[:version]}\")\n return nil\n end\n return @api_method\n end", "def api\n @api\n end", "def method\n @method ||= options[:method]\n end", "def method(method = nil)\n return @method unless method\n case method\n when :get, :post, :put, :delete\n @method = method\n else\n raise \"Unknown HTTP method :#{method}.\"\n end\n end", "def method\n options[:method] || :get\n end", "def api_methods\n self.class.instance_methods(false)\n end", "def api_methods\n self.class.instance_methods(false)\n end", "def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end", "def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end", "def api_mode; end", "def set_api(*args); end", "def set_api(*args); end", "def method\n @json['method']\n end", "def api\n return @api\n end", "def method\n @method\n end", "def method\n @method\n end", "def api_method(key, api_methods = self.api_methods)\n begin\n $log.debug(sprintf(\"%s: api methods: %s\", __method__, api_methods.inspect))\n $log.debug(sprintf(\"%s: fetching '%s' from API methods\", __method__, key))\n value = api_methods.fetch(key)\n $log.debug(sprintf(\"%s: retrieved '%s'\", __method__, value.inspect))\n\n path = value['path']\n $log.debug(sprintf(\"%s: path '%s'\", __method__, path))\n method = (value['method'] || 'post')\n $log.debug(sprintf(\"%s: method '%s'\", __method__, method))\n\n # return\n Surveymonkey::API::Method.new(path, method, method_name = key)\n\n rescue KeyError => e\n $log.error(sprintf(\"%s: '%s' not found in api methods\", __method__, key))\n raise e\n rescue StandardError => e\n $log.error(sprintf(\"%s: %s\", __method__, e.message))\n raise\n end\n end", "def method\n @method\n end", "def http_method\n @http_method ||= @options[:http_method] || :post\n end", "def http_method\n\t\t\t\treturn @http_method if defined?(@http_method)\n\n\t\t\t\tmethod_from_method =\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams['_method']\n\t\t\t\t\trescue ArgumentError => e\n\t\t\t\t\t\t## https://github.com/rack/rack/issues/337#issuecomment-48555831\n\t\t\t\t\t\traise unless e.message.include?('invalid %-encoding')\n\t\t\t\t\tend\n\n\t\t\t\t@http_method = (method_from_method || request_method).upcase.to_sym\n\t\t\tend", "def api; end", "def api; end", "def method\n return @method if defined? @method\n @method = headers[METHOD_KEY]\n @method = @method.downcase.to_sym if @method\n @method\n end", "def http_method\n @http_method.to_s.upcase\n end", "def method_missing(method, *args)\n api_obj.send(method, *args)\n end", "def method\n @attributes[:method]\n end", "def http_method\n return @discovery_document['httpMethod'] || 'GET'\n end", "def api_only=(_); end", "def api(method_name)\n clazz = ApiRegistry.find(method_name.to_sym)\n return unless clazz < RestMethod\n api_method = clazz.new\n api_method.session = self if api_method.kind_of? RestMethod\n api_method\n end", "def method\n attributes.fetch(:method)\n end", "def http_method\n @parser.http_method\n end", "def method\n return @method\n end", "def api_endpoint=(value)\n @api_endpoint = value\n end", "def method_missing(method_id, *params)\n _request(method_id.to_s.sub('_api', ''), *params)\n end", "def define_api_verb(verb)\n define_method :\"api_#{verb}\" do |*args, &block|\n args[0] = api_path(args[0])\n send(verb, *args, &block)\n end\n end", "def request_method\n @request_method || :get\n end", "def method\n options.fetch(:method, nil)\n end", "def request_method_symbol; end", "def non_get_methods\n [:post, :put, :delete]\n end", "def api_options(options = {})\n self.action = options.delete(:action).to_s if options[:action]\n self.json_id = options.delete(:json_key) if options[:json_key]\n self.params_method = options.delete(:action_params)\n end", "def http_method\n :get\n end", "def api_only; end", "def api_only; end", "def api_only; end", "def method(method_name)\n \n @_method = method_name.to_s\n \n end", "def api_url\n raise NotImplementedError, \"#{self.class} must implement #api_url!\"\n end", "def define_api_verb(verb)\n @mod.define_singleton_method(\"api_#{verb}\") do |*args, &block|\n class_eval \"Croesus.#{verb}(url(*args)).body\"\n end\n end", "def [](api_name)\n request.api = api_name\n self\n end", "def api_auth\n\t\tauth ::UApi\n\tend", "def request_method; end", "def apis; end", "def protocol\n m = @properties['METHOD']\n m ? m.upcase : m\n end", "def type\n case super\n when 'get' then :get\n when 'set' then :set\n when 'result' then :result\n when 'error' then :error\n else nil\n end\n end", "def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end", "def method_missing(method_name, *args)\n call_api_method(method_name, *args)\n end", "def default_method\n case @action.to_s\n when /create/\n :post\n when /update/\n :put\n when /destroy/\n :delete\n else# and when /(index|show|new|edit)/\n :get\n end\n end", "def method_missing(name, *args)\n api_method = get_api_method(name)\n\n if api_method\n call_api_method(api_method, *args)\n else\n super(name, *args)\n end\n end", "def api(method, path, desc = nil) #:doc:\n return unless Apipie.active_dsl?\n Apipie.add_method_description_args(method, path, desc)\n end", "def api\n methods - Object.public_methods\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def method_missing(api_method, *args) # :nodoc:\n @client.wsdl.soap_actions.include?(api_method.to_sym) ? call(api_method, *args) : super\n end", "def find_by_api_key_method(value = nil)\n rw_config(:find_by_api_key_method, value, :find_by_api_key)\n end", "def method_symbol\r\nHTTP_METHOD_LOOKUP[method]\r\nend", "def method_missing(api_method, *args) # :nodoc:\n raise ArgumentError.new('Please include method parameters.') unless args.size > 0\n params = ''\n args.each do |arg|\n params << arg.map {|k,v| \"#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}\"}.join(\"&\")\n params << '&' unless arg == args.last\n end\n api_url = \"http://#{@console_url}/frontend/#{camelize_api_method_name(api_method.to_s)}.aspx?#{params}\"\n response = HTTPI.get(api_url)\n rc, rb = response.code, response.body.gsub( /\\r\\n/m,'').to_i\n # Raise an error if the method was not found.\n super if rc == 404\n # Raise an error if the request did not succeed.\n raise APIError.new(rc) if rc != 200\n # Raise an error if the IP is not authorized.\n raise APIError.new(rb) if rb == -1011\n # Raise an error if there was an error returned.\n raise APIError.new(rb) if rb == 1\n rb\n end", "def api_base=(value)\n @api_base = value\n end", "def api_base=(value)\n @api_base = value\n end", "def methods\n super + property.keys.map { |v| [\"configure_#{v}\".to_sym, \"request_#{v}\".to_sym] }.flatten\n end", "def http_method(value = nil, &block)\n __define__(:http_method, value, block)\n end", "def method\n @method ||= XmlRpc::API::Message.parse_value(@document.root.elements[\"methodName\"])\n end", "def method_missing(method,val=nil)\n if val.nil?\n get(method)\n else\n method = method.to_s[0..-2].to_sym # get rid of = sign\n set(method,val)\n end\n end", "def method\n parse_request! if @method.nil?\n @method\n end", "def method_missing(method)\n\t\t self[method]\n\t\tend", "def request_method(verb)\n Net::HTTP.const_get(verb.to_s.capitalize)\n end", "def methods=(value)\n @methods = value\n end", "def method_missing(meth, *args, &block)\n config[meth.to_s]\n end", "def define_client_methods api_version\n\n const_set(:API_VERSION, api_version)\n\n api_config = load_api_config(api_version)\n\n api_config[:operations].each do |operation|\n\n builder = request_builder_for(api_config, operation)\n parser = response_parser_for(api_config, operation)\n\n define_client_method(operation[:method], builder, parser)\n\n end\n end", "def api_only=(_arg0); end", "def requested_method\n\t\t\t\t# respond to websocket special case\n\t\t\t\treturn :pre_connect if request.upgrade?\n\t\t\t\t# respond to save 'new' special case\n\t\t\t\treturn (self.class.has_method?(:save) ? :save : false) if (request.request_method =~ /POST|PUT|PATCH/i.freeze) && (params[:id].nil? || params[:id] == 'new'.freeze)\n\t\t\t\t# set DELETE method if simulated\n\t\t\t\trequest.request_method = 'DELETE'.freeze if params[:_method] && params[:_method].to_s.downcase == 'delete'.freeze\n\t\t\t\t# respond to special :id routing\n\t\t\t\tparams[:id].to_s.downcase.to_sym.tap { |met| return met if self.class.has_exposed_method?(met) } if params[:id]\n\t\t\t\t#review general cases\n\t\t\t\tcase request.request_method\n\t\t\t\twhen 'GET'.freeze, 'HEAD'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:index) ? :index : false) unless params[:id]\n\t\t\t\t\treturn (self.class.has_method?(:show) ? :show : false)\n\t\t\t\twhen 'POST'.freeze, 'PUT'.freeze, 'PATCH'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:update) ? :update : false)\n\t\t\t\twhen 'DELETE'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:delete) ? :delete : false)\n\t\t\t\tend\n\t\t\t\tfalse\n\t\t\tend", "def method\r\n@method ||= check_method(env[\"rack.methodoverride.original_method\"] || env['REQUEST_METHOD'])\r\nend", "def set_method_of_use\n @method_of_use = MethodOfUse.find(params[:id])\n end", "def set_method_type\n @method_type = MethodType.find(params[:id])\n end", "def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end", "def url\n resource.url + '/methods'\n end", "def http_method(request)\n raise NotImplementedError\n end", "def http_method(request)\n raise NotImplementedError\n end", "def initialize(api_method = 'getallusers')\n Imified.validate_configuration!\n super(URL.path)\n\n self.basic_auth Imified.email_address, Imified.password\n self.add_field 'apimethod', api_method\n self.add_field 'botkey', Imified.botkey\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def http_verb(params)\n [:post, :put, :delete].detect { |method_name|\n params.key?(method_name)\n } || :get\n end", "def set_api\n @api = Api.find(params[:id])\n end", "def method_missing(method_id, params = {})\n request(method_id.id2name.gsub(/_/, '.'), params)\n end", "def http_method\n raise \"Implement in child class\"\n end" ]
[ "0.81487256", "0.72420007", "0.7237257", "0.7098247", "0.7008305", "0.6984429", "0.6951847", "0.68471026", "0.67859197", "0.67583543", "0.6729883", "0.6723554", "0.66738826", "0.66738826", "0.663073", "0.663073", "0.66288257", "0.66254675", "0.66254675", "0.6602638", "0.65636927", "0.65500176", "0.65500176", "0.64871776", "0.6448281", "0.64303386", "0.64151496", "0.64127153", "0.64127153", "0.6410121", "0.64035004", "0.6403", "0.6381832", "0.6375277", "0.6358037", "0.6356928", "0.63483495", "0.6337034", "0.63342404", "0.63270205", "0.63265234", "0.6309391", "0.6308181", "0.62796605", "0.6260342", "0.62009203", "0.6184546", "0.61633295", "0.61613584", "0.61613584", "0.61613584", "0.61428094", "0.61322767", "0.6124786", "0.61231035", "0.61141706", "0.61065596", "0.6104973", "0.6098812", "0.6076031", "0.60657984", "0.6061522", "0.6055386", "0.6032953", "0.60132825", "0.6011638", "0.60107714", "0.60107714", "0.6000812", "0.5995191", "0.5989324", "0.5984065", "0.5977677", "0.5977677", "0.59691286", "0.5957995", "0.5953476", "0.5936435", "0.59363574", "0.59355825", "0.59341884", "0.59315354", "0.5929854", "0.59136754", "0.59106696", "0.58984387", "0.5890249", "0.5889167", "0.58855486", "0.5882087", "0.5879692", "0.5870198", "0.5870198", "0.5848443", "0.584699", "0.584699", "0.5845808", "0.5822837", "0.5818181", "0.58155197" ]
0.6177752
47
Set response field mapping
def map(from, to) @mapping ||= {} @mapping[from.to_s] = to.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_response(content_type, response)\n return if content_type.nil? || response.nil?\n\n content_type._id = response['id']\n content_type.klass_name = response['klass_name']\n\n response['entries_custom_fields'].each do |remote_field|\n field = content_type.find_field(remote_field['name'])\n _id = remote_field['id']\n\n if field.nil?\n if self.force?\n content_type.fields << Locomotive::Mounter::Models::ContentField.new(_id: _id, _destroy: true)\n end\n else\n field._id = _id\n end\n end\n end", "def response=(value)\n @response_before_type_cast = value\n self.textual_response = value\n end", "def response_fields\n metadata.fetch(:fields, []).map do |name_hash, field|\n ResponseField.new(name_hash[:name], field)\n end\n end", "def response_metadata=(_); end", "def response=(response); @response = response end", "def _response_mapping\n request_mapping.invert\n end", "def set_yammer_field_mapping\n @yammer_field_mapping = YammerFieldMapping.find(params[:id])\n end", "def convert_response(_response)\r\n raise NotImplementedError, 'This method needs\r\n to be implemented in a child class.'\r\n end", "def set_attrs_from_response(response)\n unless response.body.nil? || (response.body.length < 2)\n json = self.class.parse_json(response.body)\n set_attrs(json)\n end\n end", "def augment_success(response)\n return unless response['Content-Type'].to_s().index(self.format.mime_type) == 0\n \n details = begin\n self.format.decode(response.body.to_s(), false)\n rescue\n {}\n end\n \n [:start_index, :page_size, :page_count, :total_count].each do |attribute|\n self.instance_variable_set(:\"@#{attribute}\", details[attribute.to_s()])\n end\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def format_response response \n translate_response_hash_keys response_to_hash(response)\n end", "def dynamic_setter(name, value)\n self.dynamic_attributes ||= {}\n self.dynamic_attributes[name.to_sym] ||= {}\n\n field = self.content_type.find_field(name)\n\n if value.is_a?(Hash) # already localized\n value.keys.each { |locale| self.add_locale(locale) }\n self.dynamic_attributes[name.to_sym].merge!(value.symbolize_keys)\n else\n if field.is_relationship? || !field.localized\n self.dynamic_attributes[name.to_sym] = value\n else\n self.add_locale(Locomotive::Mounter.locale)\n self.dynamic_attributes[name.to_sym][Locomotive::Mounter.locale] = value\n end\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"applicationName\" => lambda {|n| @application_name = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"webUrl\" => lambda {|n| @web_url = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"serviceManagementUrl\" => lambda {|n| @service_management_url = n.get_string_value() },\n \"serviceName\" => lambda {|n| @service_name = n.get_string_value() },\n })\n end", "def set_from_response_data(hash)\n self.response_data = hash\n self.initialize_from_response_data\n self\n end", "def sso_mapping=(value)\n if value.blank?\n value = nil\n else\n value = JSON.parse value if value.is_a? String\n end\n super(value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end", "def set_ResponseFormat(value)\n set_input(\"ResponseFormat\", value)\n end" ]
[ "0.6172235", "0.61236566", "0.6093752", "0.59497976", "0.58926696", "0.5831095", "0.56661344", "0.564511", "0.55249786", "0.54828304", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.5475963", "0.54321015", "0.5429825", "0.542965", "0.5425174", "0.5411858", "0.53983164", "0.53889346", "0.53889346", "0.53889346", "0.53889346", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036", "0.53876036" ]
0.0
-1
right: One angle of the triangle is a right angle (90 degrees) acute: All 3 angles of the triangle are less than 90 degrees obtuse: One angle is greater than 90 degrees.
def triangle(x, y, z) sides = [x, y, z] largest_side = sides.max # binding.pry case when sides.inject(:+) != 180, sides.include?(0) puts :invalid when sides.inject(:+) == 180 && sides.include?(90) puts :right when sides.inject(:+) == 180 && largest_side > 90 puts :obtuse else puts :acute end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n largest_angle = angles.max\n\n case\n when angles.sum != 180, angles.include?(0)\n :invalid\n when largest_angle > 90\n :obtuse\n when largest_angle == 90\n :right\n else\n :acute\n end\nend", "def triangle(*angles)\n return :invalid if angles.any?(0) || angles.sum != 180\n\n return :right if angles.include?(90)\n return :obtuse if angles.sort.last > 90\n :acute\nend", "def triangle(a, b, c)\n angles = [a, b, c]\n return :invalid unless angles.sum == 180 && angles.none?(&:zero?) # no 0s and sum to 180\n return :right if angles.any? { |x| x == 90 }\n return :obtuse if angles.any? { |x| x > 90 }\n :acute\nend", "def triangle(*angles)\n return :invalid if angles.reduce(:+) != 180 || angles.include?(0)\n return :right if angles.include?(90)\n return :obtuse if angles.max > 90\n :acute\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n return :invalid if angles.sum != 180 || angles.min.zero?\n case angles.max\n when 90 then :right\n when 0...90 then :acute\n else :obtuse\n end\nend", "def triangle(a, b, c)\n angles = [a, b, c]\n\n # angles.sum = angles.reduce(:+) \n return :invalid if angles.sum != 180 || angles.any?(0)\n return :right if angles.any?(90)\n return :acute if angles.all? { |angle| angle < 90 }\n :obtuse\nend", "def triangle(angle_1, angle_2, angle_3)\n angles = [angle_1, angle_2, angle_3]\n return :invalid if angles.include?(0) || angles.sum != 180\n \n if angles.include?(90) then :right\n elsif angles.select {|angle| angle > 90}.size > 0 then :obtuse\n else :acute\n end\n\nend", "def triangle(first, second, third)\n angles = [first, second, third]\n return :invalid unless angles.sum == 180 && angles.none?(0)\n\n case\n when angles.any?(90) then :right\n when angles.all? { |angle| angle < 90 } then :acute\n when angles.one? { |angle| angle > 90 } then :obtuse\n else :invalid\n end\nend", "def triangle(a, b, c)\n angles = [a, b, c]\n sum = angles.reduce(:+)\n case\n when sum != 180 || angles.any? { |ang| ang <= 0 }\n :invalid\n when angles.any? { |ang| ang == 90 }\n :right\n when angles.any? { |ang| ang > 90 }\n :obtuse\n when angles.all? { |ang| ang < 90 }\n :acute\n end\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n return :invalid unless angles.sum == 180 && angles.all?(&:positive?)\n\n if angles.include?(90)\n :right\n elsif angles.all? { |angle| angle < 90 }\n :acute\n else\n :obtuse\n end\nend", "def triangle(a, b, c)\n angles = [a, b, c]\n case\n when angles.any? { |x| x <= 0 } || angles.sum != 180 then :invalid\n when angles.any? { |x| x == 90 } then :right\n when angles.all? { |x| x < 90 } then :acute\n when angles.any? { |x| x > 90 } then :obtuse\n end\nend", "def triangle(angle_1, angle_2, angle_3)\n angles = [angle_1, angle_2, angle_3]\n case\n when angles.inject(:+) != 180 || angles.include?(0)\n :invalid\n when angles.include?(90)\n :right\n when angles.any? { |angle| angle > 90}\n :obtuse\n when angles.all? { |angle| angle < 90 }\n :acute\n end\nend", "def triangle(a, b, c)\n angles = [a, b, c]\n\n case\n when angles.sum != 180 || angles.min <= 0\n :invalid\n when angles.max == 90\n :right\n when angles.max > 90\n :obtuse\n else\n :acute\n end\nend", "def triangle(angle_1, angle_2, angle_3)\n angles = [angle_1, angle_2, angle_3]\n\n case \n when angles.sum != 180 || angles.include?(0)\n :invalid\n when angles.any?(90)\n :right\n when angles.all? { |angle| angle < 90 }\n :acute\n else\n :obtuse\n end\nend", "def triangle(a1, a2, a3)\n angles = [a1, a2, a3]\n\n return :invalid if angles.sum != 180 || angles.include?(0)\n return :right if angles.include?(90)\n return :acute if angles.max < 90\n return :obtuse if angles.max > 90\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n \n case \n when angles.reduce(:+) != 180 || angles.include?(0)\n :invalid\n when angles.count(90) == 1\n :right\n when angles.count {|an| an < 90} == 3\n :acute\n when angle1 > 90 || angle2 > 90 || angle3 > 90 \n :obtuse\n end\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n case\n when angles.inject(:+) != 180 then :invalid\n when angles.any? { |angle| angle <= 0 } then :invalid\n when angles.any? { |angle| angle > 90 } then :obtuse\n when angles.any? { |angle| angle == 90 } then :right\n else :acute\n end\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n\n case\n when angles.reduce(:+) != 180, angles.include?(0)\n :invalid\n when angles.include?(90)\n :right\n when angles.all? { |angle| angle < 90 }\n :acute\n else\n :obtuse\n end\nend", "def triangle(ang1, ang2, ang3)\n ary = [ang1, ang2, ang3].sort\n return :invalid if ary.sum != 180 || ary.include?(0)\n if ary[-1] < 90\n :acute\n elsif ary[-1] == 90\n :right\n else\n :obtuse\n end\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n return :invalid if angles.sum != 180\n return :invalid if angles.any? {|angle| angle <= 0}\n return :right if angles.any? {|angle| angle == 90}\n return :acute if angles.all? {|angle| angle < 90}\n return :obtuse if angles.any? {|angle| angle > 90}\nend", "def tri_angle(ang1, ang2, ang3)\n angles = [ang1, ang2, ang3]\n return :invalid unless valid_angles?(angles)\n return :right if angles.include?(90)\n return :acute if angles.all? { |ang| ang < 90 }\n return :obtuse\nend", "def triangle(angle1, angle2, angle3)\n sides = [angle1, angle2, angle3]\n return :invalid if invalid_triangle? [angle1, angle2, angle3]\n return :acute if acute? sides\n return :obtuse if obtuse? sides\n return :right if right? sides\nend", "def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n return :invalid unless is_triangle?(angles)\n\n case\n when angles.any? { |a| a == 90 }\n :right\n when angles.all? { |a| a < 90 }\n :acute\n else\n :obtuse\n end\nend", "def triangle(side1, side2, side3)\n arr = [side1, side2, side3]\n if arr.sum != 180 || arr.any?(0)\n :invalid\n elsif arr.any?(90)\n :right\n elsif arr.any? { |n| n > 90 }\n :obtuse\n else\n :acute\n end\nend", "def right\r\n @angle += ROTATION_ANGLE\r\n end", "def right?\n angles.map(&:degrees).include? 90.0\n end", "def triangle(num1, num2, num3)\n if (num1 + num2 + num3) != 180\n return :invalid \n elsif num1 == 0 || num2 == 0 || num3 == 0 \n return :invalid\n elsif num1 > 90 || num2 > 90 || num3 > 90\n return :obtuse \n elsif num1 == 90 || num2 == 90 || num3 == 90\n return :right \n else \n :acute\n end\nend", "def right(degrees)\n turn(-degrees)\n end", "def right_tri(tri)\n\nend", "def right_triangle?(side_a, side_b, side_c)\n side_a**2 + side_b**2 == side_c**2\nend", "def valid_triangle(deg1, deg2, deg3)\n return :invalid if deg1 + deg2 + deg3 != 180\n return :invalid if deg1 <= 0 || deg2 <= 0 || deg3 <= 0\n :valid\nend", "def area_of_right_angled_triangle(base,height)\n\treturn ((base.to_f * height.to_f)/2)\t\nend", "def third_quadrant?(angle)\n\t\t180 < angle && angle < 270\n\tend", "def is_valid_triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n if angles.reduce(:+) == 180 && angle1 != 0 && angle2 != 0 && angle3 != 0\n true\n else\n false\n end\nend", "def right(values) # turn left\n multiple(values).each { |degree| rotate(-degree) }\n end", "def right\n rotate(1)\n end", "def sterad_triangle_rangled(l1,l2)\n beta=acot(sin(l1)/tan(l2))\n gamma=acot(sin(l2)/tan(l1))\n beta+gamma-PI/2\nend", "def valid_triangle?(angle1, angle2, angle3)\n sides = [angle1, angle2, angle3]\n\n return true if sides.reduce(:+) == 180 && sides.all? { | num| num > 0}\n false\nend", "def other_angle(a, b)\n 180 - (a + b)\nend", "def left(degrees)\n right(-degrees)\n end", "def other_angle(a, b)\n 180 - (a + b)\nend", "def turn_right(angle)\n @angle = @angle -angle*Math::PI / 180\n end", "def right(degrees)\n raise ArgumentError unless degrees.is_a?(Numeric)\n @heading += degrees\n @heading %= 360\n end", "def right_triangle?(a, b, c)\n a**2 + b**2 == c**2\nend", "def valid_triangle?(angles)\n return false if angles.any?(&:zero?)\n\n angles.sum == 180\nend", "def right!\n # TODO: Refactor. Can be less explicit\n case @facing\n when Direction::NORTH\n @facing = Direction::EAST\n when Direction::EAST\n @facing = Direction::SOUTH\n when Direction::SOUTH\n @facing = Direction::WEST\n when Direction::WEST\n @facing = Direction::NORTH\n else\n raise %q{Cannot rotate right}\n end\n end", "def rotate_right\n return false unless on_the_table?\n self.facing = facing.rotate_right\n true\n end", "def rotate(left_or_right)\n facing = [\"N\",\"E\",\"S\",\"W\"]\nif left_or_right == \"L\"\n final = facing[facing.index(@direction)-1]\n @direction = final\nelsif left_or_right == \"R\"\n final = facing[(facing.index(@direction)+1) % facing.length]\n @direction = final\n else\n puts \"error\"\n end\nend", "def first_quadrant?(angle)\n\t\t0 < angle && angle < 90\n\tend", "def rotateRight()\n twoTypeRotate()\n end", "def rotate_right\n @facing =\n @cardinals_rev[@cardinals_rev.index(@facing) - 1]\n self\n end", "def valid_triangle?(a, b, c)\n if (a + b > c) && (a + c > b) && (b + c) > a\n\ttrue\n else\n\tfalse\n end\n\n\n # arr = [a, b, c]\n # largest_side = a\n # index = 0\n # for i in arr\n # \tif i >= largest_side\n # \t\tlargest_side = i\n # \t\tindex_of = arr.index(i)\n # \tend\n # end\n # arr.delete_at(index_of)\n # puts arr\n # angle = (arr[0]**2 + arr[1]**2 - largest_side**2).to_f / (2*arr[0]*arr[1])\n # if largest_side**2 == (arr[0])**2 + (arr[1])**2 - 2*arr[0]*arr[1]*angle\n # \ttrue\n # else\n # \tfalse\n # end\n\n\n\n # if (a**2 == b**2 + c**2) || (b**2 == c**2 + a**2 ) || (c**2 == b**2 + a**2)\n # \ttrue\n # else\n # \tfalse\n # end\n\nend", "def triangle(side_1, side_2, side_3)\n ordered_array = [side_1, side_2, side_3].sort\n if !ordered_array.all? { |side| side > 0 }\n return :invalid\n end\n if (ordered_array[0] + ordered_array[1]) <= ordered_array[2]\n return :invalid\n end\n if (side_1 == side_2) && (side_2 == side_3)\n :equilateral\n elsif (side_1 == side_2) || (side_1 == side_3) || (side_2 == side_3)\n :isosceles\n else\n :scalene\n end\nend", "def right(degrees)\n must_be_number(degrees, 'turn')\n self.heading = heading + degrees.to_f\n end", "def triangle(side1, side2, side3)\n if side1 + side2 > side3 && side2 + side3 > side1 && side1 + side3 > side2\n if side1 == side2 && side2 == side3\n return :equilateral\n elsif side1 == side2 || side2 == side3 || side1 == side3\n return :isosceles\n else\n return :scalene\n end\n else\n return :invalid\n end\nend", "def turn_right\n @angle += ROTATION_SPEED\n end", "def rotate_right\n placed?\n @direction = case @direction\n when \"NORTH\" then \"EAST\"\n when \"EAST\" then \"SOUTH\"\n when \"SOUTH\" then \"WEST\"\n when \"WEST\" then \"NORTH\"\n end\n end", "def right position\n # if currently facing north\n if position[2] == \"north\"\n # right will make it face east\n position[2] = \"east\"\n # if currently facing south\n elsif position[2] == \"south\"\n # right will make it face west\n position[2] = \"west\"\n # if currently facing east\n elsif position[2] == \"east\"\n # right will make it face south\n position[2] = \"south\"\n # if currently facing west\n elsif position[2] == \"west\"\n # right will make it face north\n position[2] = \"north\"\n end\n position\nend", "def left(degrees)\n right(-degrees)\n end", "def rotate_right\n @facing_direction = Direction[@facing_direction.degrees + Direction::RIGHT]\n self\n end", "def turn_right\n @orientation == 3 ? @orientation = 0 : @orientation += 1\n end", "def left_tri(tri)\n\nend", "def left\r\n @angle -= ROTATION_ANGLE\r\n end", "def is_valid_triangle?(sides)\n !(sides.include?(0) || sides.sum != 180)\nend", "def rotate_right\n return false if @direction.nil?\n\n index = Constant::DIRECTIONS.index(@direction)\n @direction = Constant::DIRECTIONS.rotate[index]\n true\n end", "def calculate_radians\n if x_length == 0 || y_length == 0\n angle_to_start_of_quadrant\n else\n case angle_to_end_of_quadrant\n when DEGREES_90\n angle_ignoring_quadrant\n when DEGREES_180\n DEGREES_180 - angle_ignoring_quadrant\n when DEGREES_270\n DEGREES_180 + angle_ignoring_quadrant\n else\n DEGREES_360 - angle_ignoring_quadrant\n end\n end\n end", "def right\n check_placed\n @facing = next_facing(+1)\n end", "def triangle(a_side, b_side, c_side)\n # WRITE THIS CODE\n sum = a_side + b_side + c_side\n minimum = [a_side, b_side, c_side].min\n maximum = [a_side, b_side, c_side].max\n raise TriangleError unless minimum.positive? && (maximum < sum - maximum)\n\n return :equilateral if equilateral?(a_side, b_side, c_side)\n\n return :isosceles if isosceles?(a_side, b_side, c_side)\n\n :scalene\nend", "def triangle(*sides)\n # could have used sides.includes?(0)\n return :invalid unless sides.none?(&:zero?)\n return :invalid if sides.max > sides.reduce(:+) - sides.max\n return :equilateral if sides.min == sides.max\n return :isosceles if sides.count { |x| x == sides.max } == 2\n :scalene\nend", "def rotate_right\n return false if @direction.nil?\n\n index = DIRECTIONS.index(@direction)\n @direction = DIRECTIONS.rotate()[index]\n true\n end", "def rotateRight()\n fourTypeRotate(Tetromino::COUNTERCLOCKWISE)\n end", "def triangle(a, b, c)\n sides = [a, b, c]\n \n return :invalid if sides.include?(0) || sides.max >= sides.min(2).sum\n return :equilateral if sides.max == sides.min\n return :isosceles if sides.tally.value?(2)\n :scalene\nend", "def turn_right\n difference = heading - 270\n (difference < 10 && difference > 0) ? turn(difference) : turn(-10)\n end", "def turn_right\n @orientation = CompassPoints::RIGHT_TURNS[@orientation] if placed?\n end", "def check_angle(hours, minutes)\n (minutes * 6 - (hours * 30 + minutes * 0.5)).abs\nend", "def isTriangle(a,b,c)\n (a+b>c && a+c>b && c+b>a)? true : false\nend", "def triangle(side1, side2, side3)\n sides = [side1, side2, side3].sort\n\n if sides.count(0) > 0 || sides[0] + sides[1] <= sides[2]\n :invalid\n elsif sides.uniq.size == 1\n :equilateral\n elsif sides.uniq.size == 2\n :isosceles\n elsif sides.uniq.size == 3\n :scalene\n end\nend", "def angle_between(vector2)\n end", "def triangle(a, b, c)\n sides = a, b, c\n case\n when sides.any? { |side| side.zero? }\n :invalid\n when sides.any? { |side| sides.reduce(:+) - side < side }\n :invalid\n when sides.all? { |side| side == sides.first }\n :equilateral\n when sides == sides.uniq\n :scalene\n else\n :isosceles\n end\nend", "def isTriangle(a,b,c)\n a+b>c && a + c > b && b + c > a ? true : false\nend", "def triangle(a, b, c)\n sides = [a, b, c]\n\n # https://stackoverflow.com/a/11361502\n raise TriangleError if sides.min <= 0\n\n # my original answer\n #sides.each do |item|\n # if item <= 0\n # raise TriangleError\n # end\n #end\n\n # https://stackoverflow.com/a/11361502\n x, y, z = sides.sort\n raise TriangleError if x + y <= z\n\n # my original answer\n #if a + b <= c or b + c <= a or c + a <= b\n # raise TriangleError\n #end\n\n # https://stackoverflow.com/questions/4742692/a-more-elegant-solution-to-ruby-koans-triangle-rb\n case sides.uniq.size\n when 1 then :equilateral\n when 2 then :isosceles\n else :scalene\n end\n\n # my original answer\n #if a == b and b == c\n # :equilateral\n #elsif a == b or b == c or c == a\n # :isosceles\n #else\n # :scalene\n #end\nend", "def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort!\n if arr[0] + arr[1] <= arr[2]\n :invalid\n elsif arr[0] == arr[1] && arr[0] == arr[2]\n :equilateral\n elsif arr[0] == arr[1] || arr[0] == arr[2] || arr[1] == arr[2]\n :isosceles\n else\n :scalene\n end\nend", "def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort\n return :invalid if arr[0] + arr[1] <= arr[2]\n return :equilateral if arr[0] == arr[1] && arr[1] == arr[2]\n return :isosceles if arr.uniq.size == 2\n return :scalene if arr.uniq.size == 3\nend", "def turnright(degrees: 90)\n send_command 0x74, ((degrees %360) / 5) & 0xFF, 10\n sleep 0.5\n end", "def calc_angle(x1, y1, x2, y2)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n if (x1 == x2)\r\n if (y2 >= y1)\r\n return 0\r\n else\r\n return 180\r\n end #else\r\n elsif (y1 == y2)\r\n if (x2 >= x1)\r\n return 90\r\n else\r\n return 270\r\n end #else\r\n else\r\n x1 = x1 + 0.0 # force to be floating point\r\n x2 = x2 + 0.0 # force to floating point\r\n slope = (y2-y1) / (x2-x1)\r\n radians = Math.atan(slope)\r\n degrees = conv_radian_to_degree(radians)\r\n # Handle Adjusting Quadrent\r\n if ((x2 > x1) && (y2 > y1))\r\n # Quadrent 1;\r\n degrees = degrees\r\n elsif ((x2 > x1) && (y2 < y1))\r\n # Quadrent 2\r\n degrees = 90 - degrees;\r\n elsif ((x2 < x1) && (y2 < y1))\r\n # Quadrent 3\r\n degrees = 270 - degrees\r\n else\r\n # must be Quadrent 4\r\n degrees = 270 - degrees\r\n end # else\r\n end # else\r\n return degrees\r\nend", "def angle(x1, y1, x2, y2)\n end", "def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n largest_side = sides.max\n\n case\n when 2 * largest_side > sides.reduce(:+), sides.include?(0)\n :invalid\n when side1 == side2 && side2 == side3\n :equilateral\n when side1 == side2 || side1 == side3 || side2 == side3\n :isosceles\n else\n :scalene\n end\nend", "def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n largest_side = sides.max\n\n case\n when 2 * largest_side > sides.reduce(:+), sides.include?(0)\n :invalid\n when side1 == side2 && side2 == side3\n :equilateral\n when side1 == side2 || side1 == side3 || side2 == side3\n :isosceles\n else\n :scalene\n end\nend", "def calc_angle(hours, minutes)\n angel = (minutes * 6 - (hours * 60 + minutes) * 0.5).abs\n if angel > 180\n 360 - angel.abs\n else\n angel.abs\n end\nend", "def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n sides.sort!\n return :invalid if sides.include?(0) || sides[0] + sides[1] < sides[2]\n sides_uniq = sides.uniq\n case sides_uniq.length\n when 1 then return :equilateral\n when 2 then return :isosceles\n when 3 then return :scalene\n end\nend", "def rotate_right(node)\n puts \"right rotation on node #{node}\"\n v = node.left\n v.parent = node.parent\n node.left = v.right\n\n node.left.parent=node unless node.left.nil?\n\n v.right = node\n node.parent = v\n\n unless v.parent.nil?\n v.parent.right = v if v.parent.right==node\n v.parent.left = v if v.parent.left==node\n end\n\n update_balance(node)\n update_balance(v)\n v\n end", "def triangle(a, b, c)\n if a==0||b==0||c==0\n\traise TriangleError, \"one of the sides equals zero\"\n end\n if (a+b<=c)||(a+c<=b)||(b+c<=a)\n\traise TriangleError, \"2 any sides must be greater then 1\"\n end\n if a<0||b<0||c<0\n\traise TriangleError, \"negative sides\"\n end\n if (a==b) && (a==c) && (b==c)\n :equilateral\n\telsif (a==b)||(a==c)||(b==c)\n :isosceles\n\telse \n :scalene\nend\n\nend", "def angle_direction(a,b)\n magnitude = angle_difference(a,b)\n if angle_difference(a + 1, b) < magnitude\n magnitude\n else\n -magnitude\n end\n end", "def isTriangle(a,b,c)\n a + b > c && b + c > a && a + c > b\nend", "def isTriangle(a,b,c)\n a + b > c && b + c > a && a + c > b\nend", "def determind_sight_angles(angle)\n case direction\n when 2; value = [270 + angle, 270 - angle]\n when 4; value = [180 + angle, 180 - angle]\n when 6; value = [ 0 + angle, 0 - angle]\n when 8; value = [ 90 + angle, 90 - angle]\n end\n value[0] = (value[0] + 360) % 360\n value[1] = (value[1] + 360) % 360\n return value\n end", "def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n return :invalid if sides.max > sides.sum / 2 || sides.min.zero?\n case sides.uniq.size\n when 1 then :equilateral\n when 2 then :isosceles\n else :scalene\n end\nend", "def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort\n if side1 == side2 && side2 == side3\n :equilateral\n elsif (arr[0] + arr[1]) < arr[2] || arr.include?(0)\n :invalid\n elsif arr[0] == arr[1] || arr[1] == arr[2]\n :isosceles\n else\n :scalene\n end\nend", "def rotate_right\n\t\t\troot = @left\n\t\t\troot = root.with_right(with_left(root.right))\n\t\t\troot.with_right(root.right.with_color(root.color)).with_color(root.right.color)\n\t\tend", "def triangle(s1, s2, s3)\n sides = [s1, s2, s3]\n longest_side = sides.max\n\n case\n when largest_side > sides.reduce(:+) - largest_side, sides.include?(0)\n :invalid\n when s1 == s2 && s2 == s3\n :equilateral\n when s1 == s2 || s1 == s3 || s2 == s3\n :issoceles\n else\n :scalene\n end\nend" ]
[ "0.7794518", "0.7742498", "0.76955456", "0.7676879", "0.76753485", "0.766985", "0.7659761", "0.76219666", "0.76206946", "0.7617786", "0.7601809", "0.75970024", "0.75932664", "0.756196", "0.7550093", "0.75467706", "0.75441426", "0.7513473", "0.7497076", "0.7477304", "0.7303223", "0.73007256", "0.7297647", "0.7215731", "0.69887626", "0.69837135", "0.6913111", "0.67894864", "0.67025906", "0.6674829", "0.66452914", "0.6631463", "0.663074", "0.6622414", "0.66084963", "0.65949434", "0.6567284", "0.65565926", "0.65412456", "0.65293556", "0.65290594", "0.65193397", "0.6480752", "0.6474849", "0.64627725", "0.64258903", "0.6389516", "0.6376385", "0.63227516", "0.6320053", "0.6297371", "0.6226371", "0.62053305", "0.6191965", "0.6152172", "0.6148007", "0.6135397", "0.61273026", "0.61163145", "0.6113379", "0.61119795", "0.61116", "0.6097803", "0.60879445", "0.60805863", "0.607922", "0.606855", "0.6059933", "0.60570264", "0.60566425", "0.60409695", "0.60365075", "0.6031844", "0.6018944", "0.6001562", "0.59933573", "0.59825253", "0.59725344", "0.5968996", "0.59606475", "0.59437346", "0.59412843", "0.5934918", "0.5923599", "0.59213823", "0.5914465", "0.5903426", "0.5903426", "0.59006757", "0.5895423", "0.5894959", "0.58932513", "0.5877287", "0.5874821", "0.5872774", "0.587155", "0.5866466", "0.5855628", "0.5853057", "0.5829492" ]
0.68303883
27
returns Likes involving Comments INSTANCE METHODS
def get_liked_media case likeable_type when 'Post' return Post.find(likeable_id) when 'Comment' return Comment.find(likeable_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def likes\n Like.where(target_id:self.id, target_type:'comment')\n end", "def liked_comments_count\n # Creating comments\n comment_ids = \"SELECT id FROM comments WHERE user_id = :user_id\"\n # Except for self like\n CommentLike.where(\"comment_id IN (#{comment_ids}) AND user_id <> :user_id\", user_id: id).count\n end", "def goodcomments\n User.isliked(self)\n end", "def get_like(comment)\n like = comment.likes.select { |l| l.user_id == current_user.id }\n return like\n end", "def likes\n\t\t@likes ||= fetch_likes\n\tend", "def like\n @comment.liked_by current_user\n end", "def likes\n @likes = @person.likes\n end", "def likes\n Like.all.select do |like|\n # like.tweet.message == self.message # this works, but its extra\n like.tweet == self # self in an instance method refers to that instance\n end\n end", "def getClientLikes()\n\t\tmy_likes = Array.new\n\t\tcleaned_up = Array.new\n\t\tlikes = $client.likes :limit => 20\n\t\tlikes[\"liked_posts\"].each do |like|\n\t\t\tif(like[\"type\"] === \"quote\" || like[\"type\" === \"text\"])\n\t\t\t\tmy_likes.push(like[\"text\"])\n\t\t\tend\n\t\tend\n\t\tmy_likes\n\tend", "def likes\n self.cached_votes_total\n end", "def all_likes\n get_likes_of(self)\n end", "def comment_like(comment)\n comment_likes.create(comment_id: comment.id)\n end", "def likes\n return (@likes.present?) ? @likes : ActiveRecord::Base.connection.execute(\"SELECT COUNT(news_id) AS count FROM newslikes WHERE news_id = #{self.id.to_s}\")[0][\"count\"]\n end", "def likes\n @page.like_count\n end", "def likes\n verbs_of_interest = %w[like unlike]\n\n query = Activity.joins(:verb)\n .with_actor_id(id: guid)\n .with_target_id(id: nil)\n .merge(Verb.with_display_name(name: verbs_of_interest))\n\n @likes ||= query.group(:activity_object_id).having(\"COUNT(1) % 2 == 1\")\n end", "def comment_liking?(comment)\n comment_liking_comments.include?(comment)\n end", "def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end", "def likes_count\n self.likes_count_field\n end", "def display_like_stats(comment)\n comment_likes = comment.likes\n size = comment_likes.size\n if signed_in_user?\n liked = comment_likes.any? { |l| l.user_id == current_user.id } ? true : false\n else\n liked = false\n end\n\n result = \"\"\n if liked\n result += size > 1 ? \"You and \" : \"You \"\n else\n\n end\n\n remaining = liked ? size - 3: size - 2\n\n comment_likes = comment_likes.select { |l| l.user_id != current_user.id } if signed_in_user?\n\n comment_likes.each_with_index do |like, index|\n user = User.find(like.user_id)\n\n if index == 1 || index == size - 2\n result += link_to(user.name, user_path(user))\n break\n elsif index < 1\n result += link_to(user.name, user_path(user)) + \" and \"\n end\n end\n\n result += \" and #{remaining} others\" if remaining > 0\n\n if size > 3\n result += \" likes this.\"\n elsif\n result += liked ? \" like this.\" : \" likes this.\"\n end\n return result\n end", "def likes\n likers(User).count\n end", "def object_likes(uid, options = {})\n fetch_all = options.delete(:fetch_all)\n\n params = { \n :owner_id => user.identifier,\n :count => 1000, \n :type => \"post\", \n :item_id => uid,\n :offset => 0\n }\n params.merge!(options)\n \n if fetch_all\n return fetch_all_method_items(\"likes.getList\", params)\n end\n\n\n user.likes.getList(params)\n end", "def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Generic\n end", "def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end", "def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end", "def liked_comment?(comment)\n liked_comments.include? comment\n end", "def likes_count\n self.likes.size\n end", "def liked\n likes.map {|like| like.likeable}\n end", "def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend", "def likes\n UserReaction.where(note_id: self.id, like: 1).count\n end", "def liked_count_for(klass)\n Recommendations.redis.scard(Recommendations::Helpers::RedisKeyMapper.liked_set_for(klass, id))\n end", "def comments\n object.comments.approved\n end", "def liked_by\n\t\tcomment = Comment.includes(:liked_by).find_by(id: params[:id])\n\t\t@users = comment.has_been_liked_by\t\t\t\t\t\t\t\t\t\n\tend", "def index\n @c_likes = CLike.all\n if params[:comment_id].present?\n like = CLike.find_by(user_id: current_user.id, comment_id: params[:comment_id])\n render json: {status: 'success', like: like, counts: CLike.where(comment_id: params[:comment_id]).count, liked: like.present?}\n end\n end", "def liked_by_count\n Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(self.class, id))\n end", "def show\n @comments = Comment.where(post_id: params[:id])\n if logged_in?\n #@like = Like.where(post_id: params[:id], user_id: current_user.id)\n \n if params[:havelike] == '1'\n if params[:like] == '1'\n @like = Like.new(:post_id => params[:id], :user_id => current_user.id)\n @like.save\n else\n Like.find_by_sql(\"delete from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n end\n @likes = Like.find_by_sql(\"select * from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n \n end", "def liked_count_for(klass)\n Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, id))\n end", "def liked_for(klass)\n Recommendable.query(klass, liked_ids_for(klass))\n end", "def is_liked user\n \tLike.find_by(user_id: user_id, post_id: id)\n end", "def comment_points\n self.comments.map { |comment| comment.vote_count }.inject(:+)\n end", "def likes\n Recommendations.config.ratable_classes.map { |klass| liked_for(klass)}.flatten\n end", "def comments_count\n self.comments.count\n end", "def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end", "def is_liked(comment)\n if Like.where(:likeable => comment ,:user_id => self.id).present?\n Like.where(:likeable => comment ,:user_id => self.id).last.like==true\n end\n end", "def likers \n self.likes.map {|like| like.user_id}\n end", "def count_likes\n self.likers(Profile).length\n end", "def likes\n Activity.joins(:activity_verb).where('activity_verbs.name' => \"like\").\n joins(:activity_objects).where('activity_objects.id' => activity_object_id)\n end", "def liked?\n liked_ids = h.current_user.liked_replies.pluck(:id)\n liked_ids.include?(self.id)\n end", "def find_like\n @like = @post.likes.find(params[:id])\n end", "def likes\n Recommendable.config.ratable_classes.map { |klass| liked_for(klass) }.flatten\n end", "def likes(force = false)\n if force || @likes.nil?\n @likes = flags.all(:conditions => { :reason => 'like' })\n end\n @likes\n end", "def number_comments \n self.comments.count\n end", "def more_like_this\n response.more_like(self).map { |doc| self.class.new(doc, response) }\n end", "def likes_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + liked_count_for(klass)\n end\n end", "def show\n @likes = Like.where(tweet_id: @tweet)\n end", "def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end", "def like?(post)\n self.likes.where(post_id: post.id.to_s)\n end", "def likes\n @likes ||= raw[\"tumblr\"][\"posts\"][\"post\"].collect do |raw_like|\n if raw_like[\"type\"] == \"regular\"\n title = raw_like[\"regular_title\"]\n body = raw_like[\"regular_body\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"quote\"\n title = raw_like[\"quote_text\"]\n body = raw_like[\"quote_source\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"photo\"\n title = raw_like[\"photo_caption\"]\n body = raw_like[\"photo_caption\"]\n type = \"photo\"\n photo_url = raw_like[\"photo_url\"].last\n elsif raw_like[\"type\"] == \"link\"\n title = raw_like[\"link_text\"]\n body = raw_like[\"link_description\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"conversation\"\n title = raw_like[\"conversation_title\"]\n body = raw_like[\"conversation_text\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"video\"\n title = raw_like[\"video_caption\"]\n body = raw_like[\"video_player\"]\n type = \"video\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"audio\"\n title = raw_like[\"audio_caption\"]\n body = raw_like[\"audio_player\"]\n type = \"audio\"\n photo_url = nil\n end\n\n Butterfly::Like.new({\n :service => \"tumblr\",\n :id => raw_like[\"id\"],\n :title => title,\n :description => body,\n :created_at => Time.at(raw_like[\"unix_timestamp\"].to_i),\n :liked_at => nil,\n :tags => raw_like[\"tag\"],\n :photo_url => photo_url,\n :url => raw_like[\"url_with_slug\"],\n :type => type,\n :user => Butterfly::User.new({\n :id => raw_like[\"tumblelog\"],\n :username => raw_like[\"tumblelog\"],\n :name => raw_like[\"tumblelog\"],\n :service_url => \"#{raw_like[\"tumblelog\"]}.tumblr.com\",\n :photo_url => nil,\n :website_url => nil,\n :location => nil,\n })\n })\n end\n end", "def comments_have_votes?\n true\n end", "def likes\n query = \"SELECT COUNT(*) AS num_likes FROM likes WHERE post_id = #{id}\"\n result = DATABASE.execute(query)[0]\n return result[\"num_likes\"]\n end", "def likings(force = false)\n if force || @likings.nil?\n @likings = flaggings.all(:conditions => { :reason => 'like' })\n end\n @likings\n end", "def count_getted_like\n user = User.find_by id: self.id\n reviews = user.reviews\n total = 0\n reviews.each do |review|\n total += review.count_like\n end\n return total\n end", "def show\n @tweet_likes = @tweet.likes\n end", "def create_likes\n end", "def create_likes\n end", "def create_likes\n end", "def model_likes(args)\n options = set_model_likes_defaults(args)\n set_common_options(options)\n \n if options[:b_return_likes_totals]\n totals = make_likes_totals(options)\n end\n \n return model_make_results(options, nil, totals) \n end", "def post_liked?(post)\n find_like(post).any?\n end", "def like_comment(id = nil, user_id = nil)\n comment = Comment.where(:id => id).first\n if not comment.nil?\n #check to make sure user cant like comment more than once\n #users_who_liked is a string which is a comma-separated list of ids of users who like a comment\n\n users = comment.users_who_liked\n if not users.nil?\n users = comment.users_who_liked.split(\",\")\n end\n\n if not user_id.nil? and (users.nil? or not users.include?(user_id.to_s))\n comment.numlikes += 1\n users = users.join(\",\")\n users += \",\" + user_id.to_s\n comment.users_who_liked = users\n comment.save\n return SUCCESS\n end\n end\n return FAILED\n end", "def dislike\n @comment.disliked_by current_user\n end", "def total_like\n self.likes.where(like: true).size\n end", "def most_liked_comments\n Comment\n .preload(:likes)\n .joins(:likes)\n .group('comments.id')\n .order(Arel.sql('count(likes.id) desc'))\n .limit(10)\n end", "def comments_count\n self[:comments_count] || 0\n end", "def comments_count\n self[:comments_count] || 0\n end", "def likes\n people = []\n query = Activity.joins { verb }.where { activity_object_id.eq(my { id }) }\n\n activities_likes = query.where { verb.name.eq('like') }\n activities_likes.each do |activity|\n people.push activity.actor\n end\n\n activities_unlikes = query.where { verb.name.eq('unlike') }\n activities_unlikes.each do |activity|\n people.delete_at people.index(activity.actor)\n end\n\n people\n end", "def count_stars\n arr = []\n self.comments.each do |item|\n arr << item.star\n end\n \n return arr\n end", "def like_total\n self.likes.where(like: true).size\n end", "def likes(username, opts={})\n opts = opts.merge({:https => @https})\n Likes.likes(username, @api_key, opts)\n end", "def review_comment_count\n self.reviews.map { |review| review.comments.count }.inject(:+)\n end", "def like\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n if current_user.already_dislikes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id ,likeble_type: 'Comment').first\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_likes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end", "def liked_for(klass)\n klass.to_s.classify.constantize.find likes_for(klass).map(&:likeable_id)\n end", "def score_of_review_comments\n votes = 0\n self.reviews.each do |review|\n review.comments.each { |comment| votes += comment.vote_count }\n end\n votes\n end", "def liked_tweets\n Like.all.select { |l| l.user == self }.map { |l| l.tweet }\n end", "def common_likes_with(model)\n model_likes = get_likes_of(model)\n self_likes = get_likes_of(self)\n\n self_likes & model_likes\n end", "def show\n @comments = Comment.all\n if user_signed_in?\n @like = Like.where(user_id: current_user.id, post_id: @post.id)\n else\n @like = []\n end\n end", "def like(user)\n comment_vote = CommentVote.new\n comment_vote.comment = self\n comment_vote.user = user\n comment_vote.value = true\n comment_vote.save\n comment_vote\n end", "def comment_count\n comments.length\n end", "def CommentCount\n return Comment.where(:user_id => id).count\n end", "def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end", "def likes(options = {})\n urn = options.delete(:urn)\n path = \"/socialActions/#{urn}/likes\"\n get(path, options)\n end", "def moment_likes(moment_id)\n get(\"/v1/moments/#{moment_id}/likes\")\n end", "def how_many_likes?(sentence)\n \nend", "def like\n @postcomment.liked_by current_user\n redirect_to @urltoredirect\n end", "def photos_comments(options = {})\n params = { \n :owner_id => user.identifier,\n :count => 100, \n :need_likes => 1,\n :offset => 0\n }\n\n params.merge!(options)\n\n fetch_all_method_items_with_days(\"photos.getAllComments\", params)\n end", "def liked_for(klass)\n klass.where(:id => liked_ids_for(klass))\n end", "def fb_likes_url(access_token)\n \"https://graph.facebook.com/#{self.fb_object_id}?\" \\\n \"access_token=#{access_token}&fields=id,likes&\" \\\n \"likes.limit=50\"\n end", "def real_comment_count(photo_data)\n # Don't know what the maximum Instagram will give us is, let's pretend it's\n # 20.\n return photo_data.comments['count'] if photo_data.comments['count'] > 20\n\n # This is getting copy-pasta...\n params = {client_id: AppConfig.instagram.client_id}\n # If photo has a user with creds, make the request as them\n params[:access_token] = self.user.access_token if self.user and self.user.access_token\n\n begin\n response = Star::Requester.get \"media/#{self.uid}/comments\", params\n if response.success? and response.body.data\n return response.body.data\n .select{|comment| comment.from.id != photo_data.user.id}\n .uniq_by{|c| c.from.id}.length\n else\n raise \"/media/{id}/comments was not a success: #{response.body.inspect}\"\n end\n rescue Faraday::Error::ResourceNotFound, Faraday::Error::ClientError\n return photo_data.comments['count']\n end\n end", "def num_comments\n self.comments.count\n end", "def hottest_comment\n unless comments.empty?\n comments.map{|c| [c,c.votes.count]}.sort{|x,y| y[1] <=> x[1]}.first[0]\n end\nend", "def set_comment_like\n @comment_like = CommentLike.find(params[:id])\n end", "def comments\n @comments\n end" ]
[ "0.7464416", "0.7067533", "0.70255697", "0.7013726", "0.698551", "0.69466865", "0.6720291", "0.6671705", "0.6522949", "0.645366", "0.64297676", "0.6402152", "0.63944936", "0.6372771", "0.63526255", "0.63436496", "0.6314729", "0.63088906", "0.6282479", "0.62554735", "0.62172943", "0.6202098", "0.61899513", "0.61899513", "0.61886376", "0.61800826", "0.6168418", "0.61330974", "0.6080556", "0.6061598", "0.60536176", "0.6053491", "0.6015924", "0.6014768", "0.59939957", "0.59927994", "0.59839404", "0.5981883", "0.595701", "0.5909306", "0.5908295", "0.58820987", "0.58773416", "0.58680654", "0.5860188", "0.5858291", "0.5849663", "0.5838319", "0.5830451", "0.58273774", "0.58265185", "0.58120865", "0.5801377", "0.57910514", "0.5790897", "0.57903534", "0.57883817", "0.57881296", "0.5774019", "0.5771352", "0.5742352", "0.57411474", "0.573995", "0.573995", "0.573995", "0.57333827", "0.5733374", "0.57287496", "0.5719727", "0.5717704", "0.5700709", "0.568269", "0.568269", "0.5680934", "0.5678838", "0.56788135", "0.56503135", "0.5645895", "0.56407356", "0.5634048", "0.56247604", "0.56087655", "0.5602136", "0.5599022", "0.5592074", "0.558825", "0.55823267", "0.55775523", "0.5572658", "0.5569022", "0.55583906", "0.5554049", "0.5538273", "0.55378455", "0.55342144", "0.553198", "0.5521587", "0.5518963", "0.5517974", "0.55104625" ]
0.57478327
60
Never trust parameters from the scary internet, only allow the white list through.
def member_invite_params params.require(:member).permit(:email) 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
GET /lessons GET /lessons.json
def index @lessons = @section.lessons.includes(:progressions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @lessons = Lesson.all\n\n render 'index.json'\n end", "def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end", "def index\n @lessons = current_user.organization.lessons.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def index\n @user = current_user\n @course = Course.find(params[:course_id])\n @course_lessons = @course.course_lessons.order(\"updated_at DESC\")\n if @course_lessons.count == 0\n @course_lesson = CourseLesson.new\n end\n @title = @course.name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @course_lessons }\n end\n end", "def index\n @lessons = Lesson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def show\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n @lessons = @course.lessons.all\n @courses = Course.all\n @pages = @lesson.pages.all\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lesson }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson }\n end\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def index\n if params[:topic_id]\n lessons = Lesson.where( topic_id: params[:topic_id] )\n else\n lessons = Lesson.all\n end\n\n respond_to do |format| \n format.html { }\n format.js { }\n format.json { render json: lessons }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lesson }\n end\n end", "def index\n @group_lessons = GroupLesson.all\n @group_lessons.fetch_lessons\n end", "def index\n \n if params[:student_id]\n @student = Student.find(params[:student_id]);\n else\n @lessons = Lesson.all\n end\n \n if params[:classroom_id]\n @classroom = Classroom.find(params[:classroom_id])\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def show\n @study = find_or_redirect_to_study || return #redirecting\n @lessons = @study.lessons\n\n # Users last watched or... for now\n @lesson = @lessons.first\n\n respond_to do |format|\n format.html { redirect_to study_lesson_url(@study, @lesson) }\n format.json { render json: @study }\n end\n end", "def index\n @user_lessons = UserLesson.all\n end", "def index\n if @user\n @lessons = Lesson.view(@user.login, \"lessons_by_author\", {:author => @user.login})\n else\n @lessons = []\n end\n \n #This could be done within the users's branch....\n @public_lessons = Lesson.view(\"master\", \"lessons_by_public\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons}\n end\n end", "def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html\n format.json do\n render json: @tutorials\n end\n end\nend", "def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutorials }\n end\n end", "def new\n #@lesson = Lesson.new\n @lesson = @course.lessons.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lesson }\n end\n end", "def index\n @lessons = Lesson.by_position\n @page_title = \"Our lessons\"\n end", "def show\n #@course = Course.find(params[:course_id])\n @course_lesson = CourseLesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_lesson }\n end\n end", "def index\n @title = t('view.feedbacks.index_title')\n @feedbacks = @lesson.feedbacks.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def index\n # @lessons = Course.all\n # @lessons = @course.lessons.paginate(page: params[:page] )\n redirect_to @course\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson }\n end\n end", "def index\n @private_lessons = PrivateLesson.all\n end", "def index\n @lessons = Lesson.all\n\n if params[:title].present?\n @lessons = @lessons.search_by_title(params[:title])\n end\n\n if params[:lesson_type].present?\n @lessons = @lessons.where(lesson_type: params[:lesson_type])\n end\n\n if params[:terms].present?\n @lessons = @lessons.joins(:terms).where('terms.name in (?)', params[:terms])\n end\n end", "def index\n @lesson_plans = current_user.lesson_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_plans }\n end\n end", "def show\n respond_with @lesson, status: 200\n end", "def index\n @leagues = League.all\n render json: @leagues, status: :ok\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def index\n champions = Champion.all\n render json: champions\n end", "def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def index\n if current_user.admin\n # (10 years is a suitably long time to not matter chasing debts...)\n @lessons_to_debrief = Lesson.where(\n start_time: 10.years.ago..Time.now,\n attended: nil )\n .order(\"start_time DESC\")\n @lessons_not_paid = Lesson.where( start_time: 10.years.ago..Time.now )\n .where.not( attended: nil )\n .where( paid: false )\n .order(\"start_time DESC\")\n @lessons_completed = Lesson.where(\n start_time: 1.month.ago..Time.now,\n attended: true,\n paid: true)\n .order(\"start_time DESC\")\n else\n @lessons = current_user.lessons.where.not( student_notes: nil )\n .where( student_has_read_note: false )\n end\n end", "def index\n @online_students = OnlineStudent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @online_students }\n end\n end", "def index\n @lessons = Lesson.is_approved.order(:cached_votes_up => :desc).first(21)\n @grade = params[:grade] != ''? params[:grade] : 'all grades'\n @subject = params[:subject] != ''? params[:subject] : 'all subjects'\n @code_concept = params[:code_concept] != ''? params[:code_concept] : 'all coding concepts'\n if params[:search_complete]\n tags = []\n # make sure to not search against blank fields\n if params[:subject] != ''\n tags.push(params[:subject])\n end\n if params[:code_concept] != ''\n tags.push(params[:code_concept])\n end\n if params[:grade] != ''\n tags.push(params[:grade])\n end\n @tags = tags\n if @tags.length > 0\n @lessons = Lesson.is_approved.tagged_with(@tags).order(:cached_votes_up => :desc)\n else\n @lessons = @lessons\n end\n respond_to do |format|\n format.js { render :partial => \"lessons_js\", locals: {grade: @grade} }\n end\n\n end\n end", "def index\n @loves = Love.all\n render json: @loves\n end", "def new\n @lesson_learned = LessonLearned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def index\n render json: Story.all\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @championships = Championship.all\n\n render json: @championships\n end", "def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\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", "def index\n @need_helps = NeedHelp.all\n\n respond_to do |format|\n format.json {render :json => @need_helps.to_json(:include => [:need_help_category,\n :user => {:include => :street}])}\n end\n end", "def index\n @students = Student.all\n render json: @students\n end", "def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end", "def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end", "def show\r\n @section = Section.find_by_id(params[:id])\r\n @lesson = @section.lesson\r\n @activities = @section.activities\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @section }\r\n end\r\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end", "def index\n @stories = Story.all\n render json: @stories, root: false\n end", "def list\n @studios = Studio.all;\n return render json: @studios.to_json, status: 200\n end", "def index\n @courses = Course.all\n render json: @courses, status: :ok\n end", "def index\n @study_courses = StudyCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_courses }\n end\n end", "def index\n @games_leaderboards = Games::Leaderboard.all\n\n render json: @games_leaderboards\n end", "def index\n @lesson_responses = LessonResponse.all.where(user_id: current_user.id)\n end", "def new\n lessons = EngSource.get\n \n count = 0\n \n lessons.each do |lesson|\n unless Lesson.where('title = ?', lesson[:title]).count > 0\n Lesson.create(lesson)\n count = count + 1\n end\n end\n\n @lessons = Lesson.order('id DESC')\n \n respond_to do |format|\n format.html { redirect_to lessons_url, notice: count.to_s + ' lesson(s) had been successfully updated.' }\n format.json { render :index, status: :ok }\n end\n end", "def index\n @lesson = Lesson.find(params[:lesson_id])\n @beats = @lesson.beats\n end", "def index\n @heroes = Hero.all\n\n render json: @heroes\n end", "def index\n @laboratories = Laboratory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laboratories }\n end\n end", "def index\n @contests = Contest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def index\n @laws = Law.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end", "def index\n render json: Loan.all\n end", "def index\n @the_loai_saches = TheLoaiSach.all\n end", "def index\n #@usemap = true\n\n @stories = Story.editable_user(current_user.id) \n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @stories }\n end\n end", "def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def index\n @skills = Skill.all\n\n render json: @skills\n end", "def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end", "def index\n @title = \"Studies\"\n\n respond_to do |format|\n format.html do\n @my_studies = Study.with_user(current_user.netid)\n end\n format.json do\n render :json => Study.with_user(current_user.netid).to_json\n end\n end\n end", "def index\n @tutorials = @course.tutorials.all\n end", "def new\n @course = Course.new\n 1.times { @course.lessons.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n @whoarewes = Whoarewe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @whoarewes }\n end\n end", "def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end", "def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\n end\n end", "def index\n @expertises = Expertise.all\n\n render json: @expertises\n end", "def index\n @activities = Activity.all\n render json: @activities\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schools }\n end\n end", "def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def index\n @hackathons = Hackathon.all\n end", "def index\n @hackathons = Hackathon.all\n end", "def index\n @liasons = Liason.all\n end", "def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end", "def index\n @goals = Goal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end", "def index\n @facebook_user_stories = GameRules::Rules.the_rules.facebook_user_stories\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @facebook_user_stories }\n end\n end", "def index\n @joys = Joy.all\n render json: @joys\n end", "def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end", "def index\n @courses = Course.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses}\n end\n end", "def index\n @lesson_items = LessonItem.all\n end", "def index\n @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end", "def initialize(lessons)\n @lessons = lessons\n end" ]
[ "0.80362004", "0.7878625", "0.72607297", "0.72607297", "0.72607297", "0.72607297", "0.7183245", "0.7105748", "0.7048544", "0.7004119", "0.6789726", "0.67773086", "0.6726765", "0.67260987", "0.6724068", "0.6722874", "0.6716223", "0.6640441", "0.65512466", "0.6479717", "0.6405131", "0.63993657", "0.6391056", "0.626119", "0.62392837", "0.6235081", "0.6230535", "0.6213454", "0.6212631", "0.6191518", "0.6174152", "0.61362654", "0.6134188", "0.61187106", "0.60961455", "0.60916215", "0.6085459", "0.60802346", "0.60552275", "0.6039124", "0.60333294", "0.6021585", "0.59993243", "0.59920436", "0.59902364", "0.59902364", "0.59878504", "0.5978086", "0.5965982", "0.59623086", "0.5937219", "0.59343725", "0.593284", "0.59229475", "0.59161884", "0.5913028", "0.5911631", "0.59085464", "0.5902714", "0.5892347", "0.5889936", "0.58887625", "0.58876497", "0.5882398", "0.5880771", "0.58657485", "0.586095", "0.5859634", "0.5856116", "0.585183", "0.58471423", "0.5845661", "0.5842061", "0.58380586", "0.5837785", "0.58370316", "0.5835594", "0.5835384", "0.58350205", "0.5834983", "0.5827332", "0.5827025", "0.58265954", "0.58189535", "0.5815338", "0.5804053", "0.5790558", "0.5790558", "0.5787894", "0.5787894", "0.57867247", "0.5780562", "0.5778406", "0.57762384", "0.57727456", "0.5767461", "0.5762402", "0.5761268", "0.57608753", "0.5752744" ]
0.66399705
18
GET /lessons/1 GET /lessons/1.json
def show @progress = @lesson.progressions.find_by(:user => current_user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @lessons = Lesson.all\n\n render 'index.json'\n end", "def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lesson }\n end\n end", "def index\n @user = current_user\n @course = Course.find(params[:course_id])\n @course_lessons = @course.course_lessons.order(\"updated_at DESC\")\n if @course_lessons.count == 0\n @course_lesson = CourseLesson.new\n end\n @title = @course.name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @course_lessons }\n end\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def show\n @study = find_or_redirect_to_study || return #redirecting\n @lessons = @study.lessons\n\n # Users last watched or... for now\n @lesson = @lessons.first\n\n respond_to do |format|\n format.html { redirect_to study_lesson_url(@study, @lesson) }\n format.json { render json: @study }\n end\n end", "def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end", "def show\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n @lessons = @course.lessons.all\n @courses = Course.all\n @pages = @lesson.pages.all\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lesson }\n end\n end", "def index\n @lessons = Lesson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def index\n @lessons = current_user.organization.lessons.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def new\n #@lesson = Lesson.new\n @lesson = @course.lessons.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lesson }\n end\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson }\n end\n end", "def show\n #@course = Course.find(params[:course_id])\n @course_lesson = CourseLesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_lesson }\n end\n end", "def index\n if params[:topic_id]\n lessons = Lesson.where( topic_id: params[:topic_id] )\n else\n lessons = Lesson.all\n end\n\n respond_to do |format| \n format.html { }\n format.js { }\n format.json { render json: lessons }\n end\n end", "def index\n @lessons = @section.lessons.includes(:progressions)\n end", "def index\n @group_lessons = GroupLesson.all\n @group_lessons.fetch_lessons\n end", "def index\n \n if params[:student_id]\n @student = Student.find(params[:student_id]);\n else\n @lessons = Lesson.all\n end\n \n if params[:classroom_id]\n @classroom = Classroom.find(params[:classroom_id])\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def show\n respond_with @lesson, status: 200\n end", "def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutorials }\n end\n end", "def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html\n format.json do\n render json: @tutorials\n end\n end\nend", "def index\n @user_lessons = UserLesson.all\n end", "def index\n if @user\n @lessons = Lesson.view(@user.login, \"lessons_by_author\", {:author => @user.login})\n else\n @lessons = []\n end\n \n #This could be done within the users's branch....\n @public_lessons = Lesson.view(\"master\", \"lessons_by_public\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons}\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def show\n story = Story.find(params[:id])\n render json: story\n end", "def new\n @lesson_learned = LessonLearned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def index\n @title = t('view.feedbacks.index_title')\n @feedbacks = @lesson.feedbacks.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def index\n @lessons = Lesson.by_position\n @page_title = \"Our lessons\"\n end", "def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end", "def new\n lessons = EngSource.get\n \n count = 0\n \n lessons.each do |lesson|\n unless Lesson.where('title = ?', lesson[:title]).count > 0\n Lesson.create(lesson)\n count = count + 1\n end\n end\n\n @lessons = Lesson.order('id DESC')\n \n respond_to do |format|\n format.html { redirect_to lessons_url, notice: count.to_s + ' lesson(s) had been successfully updated.' }\n format.json { render :index, status: :ok }\n end\n end", "def show\n @backend_tutorial_stat = Backend::TutorialStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @backend_tutorial_stat }\n end\n end", "def show\n @story = Story.find(params[:id])\n\t\t@title = \"Newsy | \" + @story.title\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story }\n end\n end", "def new\n @course = Course.new\n 1.times { @course.lessons.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end", "def show\r\n @section = Section.find_by_id(params[:id])\r\n @lesson = @section.lesson\r\n @activities = @section.activities\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @section }\r\n end\r\n end", "def show\n @yourstory = Yourstory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @yourstory }\n end\n end", "def show\n render status: 200, json: UserTrainingStory.find(params[:id])\n end", "def show\n @lab_teach_resource = LabTeachResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_teach_resource }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lesson }\n end\n end", "def index\n @lesson_plans = current_user.lesson_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_plans }\n end\n end", "def index\n @lesson = Lesson.find(params[:lesson_id])\n @beats = @lesson.beats\n end", "def index\n # @lessons = Course.all\n # @lessons = @course.lessons.paginate(page: params[:page] )\n redirect_to @course\n end", "def show\n @annual_stat = AnnualStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annual_stat }\n end\n end", "def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @story }\n end\n end", "def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @story }\n end\n end", "def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @story }\n end\n end", "def index\n @private_lessons = PrivateLesson.all\n end", "def show\n @lab = Lab.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab }\n end\n end", "def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end", "def show\n @study = Study.find(params[:id])\n render json: @study\n end", "def show\n @laboratory = Laboratory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @laboratory }\n end\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def index\n render json: Story.all\n end", "def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\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", "def show\n @tutorial = Tutorial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tutorial }\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 show\n render json: @laboratory\n end", "def show\n @storylink = Storylink.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @storylink }\n end\n end", "def show\n @lab_name = LabName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_name }\n end\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def show\n @coursemod = Coursemod.find(params[:id])\n @lessons = @coursemod.lessons.paginate(:page => params[:page])\n @title = @coursemod.module_name\n end", "def index\n champions = Champion.all\n render json: champions\n end", "def index\n @contests = Contest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def show\n @subject = Subject.find(params[:subject_id])\n @lessons = ClassJournal.where(subject: @subject, form: @pupil.form).first.lessons\n end", "def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def show\n @title = Title.find(params[:id])\n\n render json: @title\n end", "def show\n @lei = Lei.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lei }\n end\n end", "def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end", "def show\n render status: 200, json: Training.find(params[:id])\n end", "def show\n @tutorial = Tutorial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tutorial.to_hash(false) }\n end\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end", "def show\n @love = Love.find(params[:id])\n render json: @love\n end", "def index\n @stories = Story.all\n render json: @stories, root: false\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def index\n @title = t('view.slides.index_title')\n @slides = @lesson.slides.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @slides }\n end\n end", "def show\n @lab_course = LabCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_course }\n end\n end", "def index\n @lessons = Lesson.all\n\n if params[:title].present?\n @lessons = @lessons.search_by_title(params[:title])\n end\n\n if params[:lesson_type].present?\n @lessons = @lessons.where(lesson_type: params[:lesson_type])\n end\n\n if params[:terms].present?\n @lessons = @lessons.joins(:terms).where('terms.name in (?)', params[:terms])\n end\n end", "def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mission }\n end\n end", "def index\n @championships = Championship.all\n\n render json: @championships\n end", "def show\n @analyst = Analyst.find(params[:id])\n\n render json: @analyst\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def show\n @leader_history = LeaderHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader_history }\n end\n end", "def show\n\t\trender json:Screencast.find(params[:id])\n\tend", "def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end", "def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end", "def index\n @heroes = Hero.all\n\n render json: @heroes\n end", "def show\n @help = Help.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @help }\n end\n end", "def show\n @title = \"View Team Challenge Score\"\n @challenge_grade = ChallengeGrade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge_grade }\n end\n end", "def show\n @contestant = Contestant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contestant }\n end\n end", "def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end", "def show\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_exam }\n end\n end", "def show\n @school = School.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @school }\n end\n end", "def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end" ]
[ "0.7903578", "0.76162004", "0.72275925", "0.71802473", "0.70652306", "0.7041279", "0.7041279", "0.7041279", "0.7041279", "0.6987059", "0.6984014", "0.6935964", "0.6883529", "0.67853045", "0.6742001", "0.67069143", "0.6604449", "0.65758556", "0.65491104", "0.6543736", "0.65306383", "0.64894265", "0.645412", "0.6389311", "0.6386074", "0.6369707", "0.6280753", "0.62453675", "0.6228001", "0.62206745", "0.62157446", "0.61950374", "0.6193479", "0.6192588", "0.6180226", "0.61670357", "0.61615777", "0.6157818", "0.6111906", "0.60988414", "0.60865474", "0.6068502", "0.6068502", "0.6065832", "0.6060328", "0.6055636", "0.60284275", "0.6022369", "0.6022074", "0.60182947", "0.6016795", "0.6016795", "0.60019344", "0.5991162", "0.59900653", "0.5987202", "0.59817755", "0.59748024", "0.59719515", "0.5969394", "0.5948555", "0.59438634", "0.5938412", "0.59351367", "0.59317076", "0.590844", "0.58967334", "0.5893729", "0.58935726", "0.5884583", "0.5881134", "0.5878892", "0.5877503", "0.587205", "0.5864526", "0.58631146", "0.58612645", "0.5860847", "0.58565164", "0.5848743", "0.5845985", "0.5845985", "0.584301", "0.5834955", "0.5831447", "0.58258635", "0.5824435", "0.5823743", "0.5821043", "0.5820268", "0.5819215", "0.5818772", "0.5817335", "0.5817114", "0.5816792", "0.5815636", "0.5812909", "0.5812011", "0.5809322", "0.5808892", "0.58052117" ]
0.0
-1
POST /lessons POST /lessons.json
def create @lesson = Lesson.new(lesson_params) respond_to do |format| if @lesson.save format.html { redirect_to course_section_lessons_path(@course, @section), notice: 'Lesson was successfully created.' } format.json { render action: 'show', status: :created, location: @lesson } else format.html { render action: 'new' } format.json { render json: @lesson.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n #@lesson = Lesson.new(params[:lesson])\n @lesson = @course.lessons.new(params[:lesson])\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to [@course,@lesson], :notice => 'Lesson was successfully created.' }\n format.json { render :json => @lesson, :status => :created, :location => @lesson }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n if @lesson.save\n render :show, status: :created, location: @lesson\n else\n render json: @lesson.errors, status: :unprocessable_entity\n end\n end", "def create\n @lesson = Lesson.new(params[:lesson])\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render json: @lesson, status: :created, location: @lesson }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n course = Course.find(params[:lesson][:course_id])\n @lesson = course.lessons.create(lesson_params)\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to course_lesson_path(@lesson, course_id: @lesson.course.id), notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@course = Course.find(params[:course_id])\n @lesson = @course.lessons.build(lesson_params)\n \n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @course, notice: 'lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @lessons = Lesson.all\n\n render 'index.json'\n end", "def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_lesson = UserLesson.new(user_lesson_params)\n\n respond_to do |format|\n if @user_lesson.save\n format.html { redirect_to @user_lesson, notice: 'User lesson was successfully created.' }\n format.json { render :show, status: :created, location: @user_lesson }\n else\n format.html { render :new }\n format.json { render json: @user_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n #@lesson = Lesson.new\n @lesson = @course.lessons.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lesson }\n end\n end", "def create\n @pupil_has_lesson = PupilHasLesson.new(pupil_has_lesson_params)\n\n respond_to do |format|\n if @pupil_has_lesson.save\n format.html { redirect_to pupil_has_lessons_path, notice: 'Pupil has lesson was successfully created.' }\n format.json { render :show, status: :created, location: @pupil_has_lesson }\n else\n format.html { render :new }\n format.json { render json: @pupil_has_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n lessons = EngSource.get\n \n count = 0\n \n lessons.each do |lesson|\n unless Lesson.where('title = ?', lesson[:title]).count > 0\n Lesson.create(lesson)\n count = count + 1\n end\n end\n\n @lessons = Lesson.order('id DESC')\n \n respond_to do |format|\n format.html { redirect_to lessons_url, notice: count.to_s + ' lesson(s) had been successfully updated.' }\n format.json { render :index, status: :ok }\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n @lesson.profile = current_user.profile\n @lesson.subject_list.add(params[:subject_list], parse: true)\n @lesson.code_concept_list.add(params[:code_concept_list], parse: true)\n @lesson.grade_list.add(params[:grade_list], parse: true) \n @lesson.level = params[:lesson][:level].to_i\n @suggested_lessons = params[:lesson][:suggested_lessons]\n respond_to do |format|\n if @lesson.save\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @course = Course.new\n 1.times { @course.lessons.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end", "def create\n Lesson.create(lesson_params)\n # redirect_to\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson }\n end\n end", "def create\n @group_lesson = GroupLesson.new(group_lesson_params)\n\n respond_to do |format|\n if @group_lesson.save\n format.html { redirect_to @group_lesson, notice: 'Group lesson was successfully created.' }\n format.json { render :show, status: :created, location: @group_lesson }\n else\n format.html { render :new }\n format.json { render json: @group_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user = current_user\n @course = Course.find(params[:course_id])\n @course_lessons = @course.course_lessons.order(\"updated_at DESC\")\n if @course_lessons.count == 0\n @course_lesson = CourseLesson.new\n end\n @title = @course.name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @course_lessons }\n end\n end", "def create\n @private_lesson = PrivateLesson.new(private_lesson_params)\n\n respond_to do |format|\n if @private_lesson.save\n format.html { redirect_to @private_lesson, notice: 'Private lesson was successfully created.' }\n format.json { render :show, status: :created, location: @private_lesson }\n else\n format.html { render :new }\n format.json { render json: @private_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n respond_to do |format|\n if @lesson.save\n format.html { redirect_to [:admin, @lesson], notice: t('activerecord.models.lesson') + '创建成功!' }\n format.json { render action: 'show', status: :created, location: @lesson }\n else\n format.html { render action: 'new' }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = current_user.courses.find(params[:course_id])\n @course_lesson = @course.course_lessons.build(params[:course_lesson])\n @course_lesson.user_id = @course.user_id\n\n respond_to do |format|\n if @course_lesson.save\n format.html { redirect_to profile_path, notice: 'Course lesson was successfully created.' }\n format.json { render json: @course_course_lesson, status: :created, location: @course_lesson }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = current_user.organization.lessons.new(params[:lesson])\n @lesson.author = current_user\n respond_to do |format|\n if @lesson.save\n flash[:notice] = 'Lesson was successfully created.'\n format.html { redirect_to(@lesson) }\n format.xml { render :xml => @lesson, :status => :created, :location => @lesson }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end", "def create\n @lesson_response = LessonResponse.new(lesson_response_params)\n\n respond_to do |format|\n if @lesson_response.save\n format.html { redirect_to @lesson_response, notice: 'Lesson response was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_response }\n else\n format.html { render :new }\n format.json { render json: @lesson_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n @lesson.profile = current_user.profile\n @lesson.subject_list.add(params[:lesson][:subject_list], parse: true)\n @lesson.code_concept_list.add(params[:lesson][:code_concept_list], parse: true)\n # @lesson.grade_list.add(params[:grade_list], parse: true) \n @lesson.level = params[:lesson][:level].to_i\n @suggested_lessons = params[:lesson][:suggested_lessons]\n respond_to do |format|\n if @lesson.save\n if @suggested_lessons.present?\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n end\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def index\n @lessons = Lesson.all\n end", "def create\n @lesson_plan = LessonPlan.new(lesson_plan_params)\n\n respond_to do |format|\n if @lesson_plan.save\n format.html { redirect_to @lesson_plan, notice: 'Lesson plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @lesson_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @lesson_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson_status = LessonStatus.new(lesson_status_params)\n\n respond_to do |format|\n if @lesson_status.save\n format.html { redirect_to @lesson_status, notice: 'Lesson status was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_status }\n else\n format.html { render :new }\n format.json { render json: @lesson_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_lesson(lesson, homework, date, period)\n response = @mech.post(URLS[:post_lesson], {\n userId: @user_id,\n date: date.strftime(\"%m/%d/%Y\"),\n period: period,\n notes: lesson,\n homework: homework\n })\n return response\n end", "def new\n @lesson_learned = LessonLearned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def create\n @lesson_completed = LessonCompleted.new(lesson_completed_params)\n\n respond_to do |format|\n if @lesson_completed.save\n format.html { redirect_to @lesson_completed, notice: 'Lesson completed was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_completed }\n else\n format.html { render :new }\n format.json { render json: @lesson_completed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new( { :subject_id => params[:subject_id] } )\n\n respond_to do |format|\n if @course.save\n current_user.courses << @course\n lesson = @course.lessons.new\n @course.lessons << lesson\n flash[:notice] = 'Start learning'\n format.html { redirect_to :controller => 'lessons', :action => 'show', :id => lesson.id }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n flash[:error] = 'Problem encountered.'\n format.html { redirect_to(:back) }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tutorials = Tutorial.all\n @tutorial = Tutorial.new(tutorial_params)\n\n if @tutorial.save\n render json: @tutorial\n else\n render json: @tutorial.errors.full_messages, status:400\n end\n end", "def index\n @lessons = Lesson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def create\n @lesson_reference = LessonReference.new(lesson_reference_params)\n\n respond_to do |format|\n if @lesson_reference.save\n format.html { redirect_to @lesson_reference, notice: 'Lesson reference was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_reference }\n else\n format.html { render :new }\n format.json { render json: @lesson_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson_entryset = LessonEntryset.new(lesson_entryset_params)\n\n respond_to do |format|\n if @lesson_entryset.save\n format.html { redirect_to @lesson_entryset, notice: 'Lesson entryset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @lesson_entryset }\n else\n format.html { render action: 'new' }\n format.json { render json: @lesson_entryset.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @lessons = current_user.organization.lessons.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def create\n @departmentlesson = Departmentlesson.new(departmentlesson_params)\n\n respond_to do |format|\n if @departmentlesson.save\n format.html { redirect_to @departmentlesson, notice: 'Department lesson was successfully created.' }\n format.json { render :show, status: :created, location: @departmentlesson }\n else\n format.html { render :new }\n format.json { render json: @departmentlesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @user\n pub = false\n if params[:lesson][:public] == \"1\"\n pub = true\n end\n lesson = Lesson.save(@user.login, params[:lesson], pub)\n end\n \n if params[:form_type]\n redirect_to :controller => \"ui\", :action => :lesson_view, :id => lesson.attributes[\"_id\"]\n else\n respond_to do |format|\n flash[:notice] = 'lesson was successfully created.'\n format.html { redirect_to lesson_url(lesson.attributes[\"_id\"]) }\n format.xml { render :xml => lesson, :status => :created, :location => lesson }\n end\n end\n end", "def create\n @course = Course.find(params[:course_id])\n @lesson = Lesson.find(params[:lesson_id])\n @lesson_word = LessonWord.new(lesson_word_params)\n\n respond_to do |format|\n if @lesson_word.save\n format.js\n format.html { redirect_to @lesson_word, notice: 'Lesson word was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_word }\n else\n format.html { render :new }\n format.json { render json: @lesson_word.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @practice = Practice.new(practice_params)\n @lessons = current_user.lessons.select(:id,:name)\n @lesson = Lesson.find(practice_params[\"lesson_id\"])\n @practice.category = @lesson.category\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to new_question_path(practice_id: @practice.id), notice: 'Practice was successfully created.' }\n format.json { render :show, status: :created, location: @practice }\n else\n format.html { render :new }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @title = t('view.feedbacks.new_title')\n @feedback = @lesson.feedbacks.build default_args.reverse_merge(feedback_params)\n\n respond_to do |format|\n if @feedback.save\n format.html { redirect_to [@lesson, @feedback], notice: t('view.feedbacks.correctly_created') }\n format.json { render json: @feedback, status: :created, location: @feedback }\n else\n format.html { render action: 'new' }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user_lessons = UserLesson.all\n end", "def create\n @topic = current_user.topics.find(params[:topic_id])\n @topic.lessons.build(lesson_params)\n\n @topic.lessons.last.title = 'New Lesson (rename)' if @topic.lessons.last.title == ''\n\n respond_to do |format|\n if @topic.save\n @lesson = @topic.lessons.last\n format.html { redirect_to course_topic_lesson_path(@course, @topic, @lesson), notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.find(params[:lesson_id])\n @respond = @lesson.responds.build(params[:respond])\n @respond.user = current_user\n\n if @respond.save\n flash[:success] = 'You AAR respond has been posted'\n redirect_to @lesson\n else\n @lesson = Lesson.find(params[:lesson_id])\n render 'lessons/show'\n end\n end", "def create\n @timetable = Timetable.new(timetable_params)\n @timetable.save\n respond_with [@timetable.lesson,@timetable]\n end", "def create\n @learn = Learn.new(params[:learn])\n\n respond_to do |format|\n if @learn.save\n format.html { redirect_to @learn, notice: 'Learn was successfully created.' }\n format.json { render json: @learn, status: :created, location: @learn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @learn.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @title = t('view.feedbacks.new_title')\n @feedback = @lesson.feedbacks.build(default_args)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback }\n end\n end", "def create\n @learning = Learning.new(learning_params)\n\n respond_to do |format|\n if @learning.save\n format.html { redirect_to @learning, notice: 'Learning was successfully created.' }\n format.json { render :show, status: :created, location: @learning }\n else\n format.html { render :new }\n format.json { render json: @learning.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson_plan = LessonPlan.new(lesson_plan_params)\n @lesson_plan.educator_id = current_educator.id\n respond_to do |format|\n if @lesson_plan.save\n format.html { redirect_to current_educator, notice: 'Lesson plan was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_plan }\n else\n format.html { render :new }\n format.json { render json: @lesson_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n \n if params[:student_id]\n @student = Student.find(params[:student_id]);\n else\n @lessons = Lesson.all\n end\n \n if params[:classroom_id]\n @classroom = Classroom.find(params[:classroom_id])\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end", "def create\n @add_on = @game.add_ons.new(add_on_params)\n\n respond_to do |format|\n if @add_on.save\n format.html { redirect_to @game, notice: 'Add on was successfully created.' }\n format.json { render :show, status: :created, location: @add_on }\n else\n format.html { render :new }\n format.json { render json: @add_on.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n\n if @lesson.save\n redirect_to @lesson, notice: 'Lesson successfully logged.' \n else\n render :new\n end\nend", "def create\n @the_loai_sach = TheLoaiSach.new(the_loai_sach_params)\n\n respond_to do |format|\n if @the_loai_sach.save\n format.html { redirect_to @the_loai_sach, notice: \"The loai sach was successfully created.\" }\n format.json { render :show, status: :created, location: @the_loai_sach }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @the_loai_sach.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @yourstory = Yourstory.new(params[:yourstory])\n\n respond_to do |format|\n if @yourstory.save\n format.html { redirect_to @yourstory, notice: 'Yourstory was successfully created.' }\n format.json { render json: @yourstory, status: :created, location: @yourstory }\n else\n format.html { render action: \"new\" }\n format.json { render json: @yourstory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n training.attributes = training_params\n\n respond_to do |format|\n if training.save\n format.html { redirect_to student_url(training.student_id), notice: \"Training was successfully created.\" }\n format.json { render :show, status: :created, location: training }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: training.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @story = Story.new(story_params)\n if @story.save\n render json: @story, status: :ok\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end", "def create\n @leadership = Leadership.new(leadership_params)\n\n respond_to do |format|\n if @leadership.save\n format.html { redirect_to @leadership, notice: 'Leadership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @leadership }\n else\n format.html { render action: 'new' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end", "def lesson_params\n params.require(:lesson).permit(:title, :desc, :price, :image_url, :category_id, :category_name, :level, :start_date, :duration, :tutor_id, :tutor_name)\n end", "def initialize(lessons)\n @lessons = lessons\n end", "def create\n @welcome = Welcome.new(params[:welcome])\n\n respond_to do |format|\n if @welcome.save\n format.html { render action: \"new\", notice: \"done\" }\n format.json { render json: @welcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lesson_plan = LessonPlan.new(params[:lesson_plan])\n\n respond_to do |format|\n if @lesson_plan.save\n format.html { redirect_to(@lesson_plan, :notice => 'LessonPlan was successfully created.') }\n format.xml { render :xml => @lesson_plan, :status => :created, :location => @lesson_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lesson_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @group_lessons = GroupLesson.all\n @group_lessons.fetch_lessons\n end", "def create\n @shortner = Shortner.new(shortner_params)\n\n respond_to do |format|\n if @shortner.save\n format.html { redirect_to @shortner, notice: 'Shortner was successfully created.' }\n format.json { render :show, status: :created, location: @shortner }\n else\n format.html { render :new }\n format.json { render json: @shortner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laboratory = Laboratory.new(laboratory_params)\n if @laboratory.save\n render json: @laboratory, status: :created\n else\n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end", "def lesson_params\n params.require(:lesson).permit(:name, :description)\n end", "def create\n @lesson_payment = LessonPayment.new(lesson_payment_params)\n\n respond_to do |format|\n if @lesson_payment.save\n format.html { redirect_to @lesson_payment, notice: 'Lesson payment was successfully created.' }\n format.json { render :show, status: :created, location: @lesson_payment }\n else\n format.html { render :new }\n format.json { render json: @lesson_payment.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n if params[:topic_id]\n lessons = Lesson.where( topic_id: params[:topic_id] )\n else\n lessons = Lesson.all\n end\n\n respond_to do |format| \n format.html { }\n format.js { }\n format.json { render json: lessons }\n end\n end", "def create\n @tutorial = current_user.tutorials.create(tutorial_params)\n\n respond_to do |format|\n if @tutorial.save\n format.html { redirect_to @tutorial, notice: 'Tutorial was successfully created.' }\n format.json { render :show, status: :created, location: @tutorial }\n else\n format.html { render :new }\n format.json { render json: @tutorial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @welcome = Welcome.new(welcome_params)\n \n respond_to do |format|\n if @welcome.save\n format.html { redirect_to @welcome, notice: 'Welcome was successfully created.' }\n format.json { render :show, status: :created, location: @welcome }\n else\n format.html { render :new }\n format.json { render json: @welcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @title = t 'view.teaches.new_title'\n\n respond_to do |format|\n if @teach.save\n format.html { redirect_to @teach, notice: t('view.teaches.correctly_created') }\n format.json { render json: @teach, status: :created, location: @teach }\n else\n format.html { render action: 'new' }\n format.json { render json: @teach.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.create(params[:inschool])\n\n respond_to do |format|\n if @inschool.save\n StudentMailer.mailer_inschool(@student, @inschool).deliver\n format.html { redirect_to :back, notice: 'Inschool was successfully created and an email sent was sent to the teacher.' }\n format.json { render json: @inschool, status: :created, location: @inschool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inschool.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news_story = NewsStory.new(news_story_params)\n\n respond_to do |format|\n if @news_story.save\n format.html { redirect_to @news_story, notice: 'News story was successfully created.' }\n format.json { render :show, status: :created, location: @news_story }\n else\n format.html { render :new }\n format.json { render json: @news_story.errors, status: :unprocessable_entity }\n end\n end\n end", "def lesson_params\n params.require(:lesson).permit(:id, :player, :date, :time, :notes, :coach)\n end", "def create\n @lessons = Lesson.all\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n @booking = @job.create_booking(params[:job][:lesson_id])\n format.html { redirect_to new_payment_url(booking_id: @booking) }\n format.json { render :show, status: :created, location: @job }\n else\n flash[:error] = @job.errors.full_messages.to_sentence\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hackathon = Hackathon.new(hackathon_params)\n\n respond_to do |format|\n if @hackathon.save\n format.html { redirect_to @hackathon, notice: 'Hackathon was successfully created.' }\n format.json { render :show, status: :created, location: @hackathon }\n else\n format.html { render :new }\n format.json { render json: @hackathon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n if params[:journey_id]\n @journey = Journey.find(params[:journey_id])\n render_403 and return if @journey.user_id != current_user.id\n else\n @journey = Journey.create(user_id: current_user.id)\n end\n\n @url = \"/journeys/#{@journey.id}/legs\"\n @method = :POST\n @journey_leg = JourneyLeg.new(journey_leg_params.merge(journey_id: @journey.id))\n\n respond_to do |format|\n if @journey_leg.save\n format.html { redirect_to @journey, notice: 'Journey leg was successfully created.' }\n format.json { render json: @journey, status: :created, location: @journey }\n format.xml { render xml: @journey, status: :created, location: @journey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @journey_leg.errors, status: :unprocessable_entity }\n format.xml { render xml: @journey_leg.errors, status: :unprocessable_entity }\n end\n end\n end", "def lesson_params\n params.require(:lesson).permit(:name, :description, :start_time, :end_time, :class_date)\n end", "def index\n # @lessons = Course.all\n # @lessons = @course.lessons.paginate(page: params[:page] )\n redirect_to @course\n end", "def create\n @backend_tutorial_stat = Backend::TutorialStat.new(params[:backend_tutorial_stat])\n\n respond_to do |format|\n if @backend_tutorial_stat.save\n Backend::TutorialStat.update_all_cohorts\n Backend::Stat.update_all_cohorts\n \n format.html { redirect_to @backend_tutorial_stat, notice: 'Tutorial stat was successfully created.' }\n format.json { render json: @backend_tutorial_stat, status: :created, location: @backend_tutorial_stat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @backend_tutorial_stat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n lesson_plan_saver = LessonPlanSaver.new(user: current_user,\n params: lesson_plan_params)\n @lesson_plan = lesson_plan_saver.lesson_plan\n\n respond_to do |format|\n if lesson_plan_saver.save\n format.html { redirect_to user_lesson_plans_path(current_user.id), notice: 'Lesson plan was successfully created.' }\n format.json { render json: @lesson_plan, status: :created, location: @lesson_plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lesson_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n story_params = {\n title: params[:title],\n summary: params[:summary],\n }\n @story = Story.new(story_params)\n\n if @story.save\n # render :show, status: :created, location: @story\n render json: @story\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end", "def create\n @welcome = Welcome.new(welcome_params)\n\n respond_to do |format|\n if @welcome.save\n format.html { redirect_to @welcome, notice: 'Welcome was successfully created.' }\n format.json { render :show, status: :created, location: @welcome }\n else\n format.html { render :new }\n format.json { render json: @welcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @games_leaderboard = Games::Leaderboard.new(games_leaderboard_params)\n\n if @games_leaderboard.save\n render json: @games_leaderboard, status: :created, location: @games_leaderboard\n else\n render json: @games_leaderboard.errors, status: :unprocessable_entity\n end\n end", "def create\n streak, success = jsonapi_create.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end", "def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end", "def index\n @lessons = @section.lessons.includes(:progressions)\n end", "def create\n @quest_stat = QuestStat.new(quest_stat_params)\n\n respond_to do |format|\n if @quest_stat.save\n format.html { redirect_to @quest_stat, notice: 'Quest stat was successfully created.' }\n format.json { render :show, status: :created, location: @quest_stat }\n else\n format.html { render :new }\n format.json { render json: @quest_stat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_story(attributes = {})\n api_url = URI.parse(\"#{CONFIG[:api_location]}/projects/#{@id}/stories\")\n query_string = attributes.map { |key, value| \"story[#{key}]=#{CGI::escape(value)}\"}.join('&')\n response = Net::HTTP.start(api_url.host, api_url.port) do |http|\n http.post(api_url.path, query_string.concat(\"&token=#{@token}\"))\n end\n\n story = (Hpricot(response.body)/:story)\n Story.new(:story => story, :project_id => @id, :token => @token)\n end", "def create\n @knowledge_level = KnowledgeLevel.new(knowledge_level_params)\n \n respond_to do |format|\n if @knowledge_level.save\n format.html { redirect_to @knowledge_level, notice: 'Knowledge level was successfully created.' }\n format.json { render :show, status: :created, location: @knowledge_level }\n else\n format.html { render :new }\n format.json { render json: @knowledge_level.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @goal = @todo.goals.create(goal_params)\n render json: @goal\n end", "def create\n @hero = Hero.new(hero_params)\n\n if @hero.save\n render json: @hero, status: :created, location: @hero\n else\n render json: @hero.errors, status: :unprocessable_entity\n end\n end", "def create\n @tutorial_quest = Tutorial::Quest.new(params[:tutorial_quest])\n\n respond_to do |format|\n if @tutorial_quest.save\n format.html { redirect_to @tutorial_quest, notice: 'Quest was successfully created.' }\n format.json { render json: @tutorial_quest, status: :created, location: @tutorial_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutorial_quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @leader = Leader.new(params[:leader])\n\n respond_to do |format|\n if @leader.save\n format.html { redirect_to @leader, notice: 'Leader was successfully created.' }\n format.json { render json: @leader, status: :created, location: @leader }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.682627", "0.674735", "0.6718514", "0.6697686", "0.6697032", "0.667032", "0.667032", "0.667032", "0.6563873", "0.651799", "0.64450693", "0.63522065", "0.6337182", "0.63099784", "0.6258918", "0.62086457", "0.6198391", "0.616112", "0.6153891", "0.612597", "0.6121709", "0.6114019", "0.6077737", "0.60720503", "0.6027101", "0.6009907", "0.59834725", "0.596577", "0.59589833", "0.59589833", "0.59589833", "0.59589833", "0.5865614", "0.58595866", "0.58498657", "0.5822973", "0.58104575", "0.58100927", "0.5799579", "0.5715445", "0.5701813", "0.56959766", "0.56638575", "0.566038", "0.5658674", "0.56337124", "0.5623071", "0.5620615", "0.5618351", "0.55917794", "0.557816", "0.5569006", "0.55505896", "0.55351835", "0.5529531", "0.550034", "0.5494743", "0.5480124", "0.5471886", "0.5453033", "0.54407", "0.5437604", "0.54317147", "0.5427385", "0.54030627", "0.53960854", "0.53940624", "0.5393132", "0.5389646", "0.5371957", "0.53691244", "0.536457", "0.53566486", "0.5352983", "0.5343743", "0.5337272", "0.5335659", "0.53295434", "0.53282833", "0.5327434", "0.5324318", "0.5322134", "0.5314465", "0.53121114", "0.5308544", "0.53074145", "0.5302457", "0.5298183", "0.52941775", "0.5290544", "0.5290504", "0.52891564", "0.5288767", "0.5288417", "0.5285835", "0.5284561", "0.5279532", "0.5278837", "0.52783126", "0.5277215" ]
0.6643393
8
PATCH/PUT /lessons/1 PATCH/PUT /lessons/1.json
def update respond_to do |format| if @lesson.update(lesson_params) format.html { redirect_to @course, notice: 'Lesson was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @lesson.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n format.html { redirect_to [@course,@lesson], :notice => 'Lesson was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @course = current_user.courses.find(params[:course_id])\n @course_lesson = @course.course_lessons.find(params[:id])\n respond_to do |format|\n if @course_lesson.update_attributes(params[:course_lesson])\n format.html { redirect_to @course, notice: 'Course lesson was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lessons = Lesson.all\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to recent_jobs_url, notice: 'Job updated successfully.' }\n format.json { render :show, status: :ok, location: @job }\n else\n flash[:error] = @job.errors.full_messages.to_sentence\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lesson = current_user.organization.lessons.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n flash[:notice] = 'Lesson was successfully updated.'\n format.html { redirect_to(@lesson) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @lesson.update(lesson_params)\n render :show, status: :ok, location: @lesson\n else\n render json: @lesson.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n @suggested_lessons = params[:lesson][:suggested_lessons]\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end", "def update\n if params[:course_id]\n @course = Course.find(params[:course_id])\n @lesson = Lesson.find(params[:id])\n else\n @lesson = Lesson.find(params[:id])\n end\n\n attributes = params[:lesson]\n attributes = extract_values if params[:content]\n\n respond_to do |format|\n if @lesson.update_attributes(attributes)\n format.html { redirect_to show_enrolled_course_path(@course), :notice => 'Lesson was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @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\n @need_help = NeedHelp.find(params[:id])\n\n respond_to do |format|\n if @need_help.update_attributes(params[:need_help])\n format.json {head :no_content}\n else\n format.json {render json: @need_help.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n # @topic = current_user.topics.find(params[:lesson][:topic_id])\n # @course = @topic.courses.first\n\n # @lesson.title = 'New Lesson (rename)' if params[:title] = ''\n respond_to do |format|\n if @lesson.update(lesson_update)\n format.html { redirect_to course_topic_lesson_path(@lesson.topic.course, @lesson.topic, @lesson), notice: 'Lesson was updated created.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end", "def update\n @yourstory = Yourstory.find(params[:id])\n\n respond_to do |format|\n if @yourstory.update_attributes(params[:yourstory])\n format.html { redirect_to @yourstory, notice: 'Yourstory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @yourstory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n if @learn.update_attributes(params[:learn])\n format.html { redirect_to @learn, notice: 'Learn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @learn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @major = Major.find(params[:id])\n\n respond_to do |format|\n if @major.update_attributes(params[:major])\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @course = Course.find(params[:course_id])\n @lesson = Lesson.find(params[:id])\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to course_lesson_path(@course, @lesson), notice: 'lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pupil_has_lesson.update(pupil_has_lesson_params)\n format.html { redirect_to pupil_has_lessons_path, notice: 'Pupil has lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @pupil_has_lesson }\n else\n format.html { render :edit }\n format.json { render json: @pupil_has_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to course_lesson_path(@lesson, course_id: @lesson.course.id), notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lab = Lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(params[:lab])\n format.html { redirect_to @lab, notice: 'Lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson_entryset.update(lesson_entryset_params)\n format.html { redirect_to @lesson_entryset, notice: 'Lesson entryset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lesson_entryset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @staffer = Staffer.find(params[:id])\n\n respond_to do |format|\n if @staffer.update_attributes(params[:staffer])\n format.html { redirect_to @staffer, notice: 'Staffer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @staffer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @backend_tutorial_stat = Backend::TutorialStat.find(params[:id])\n\n respond_to do |format|\n if @backend_tutorial_stat.update_attributes(params[:backend_tutorial_stat])\n format.html { redirect_to @backend_tutorial_stat, notice: 'Tutorial stat was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @backend_tutorial_stat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lesson.subject_list.add(params[:lesson][:subject_list], parse: true)\n @lesson.code_concept_list.add(params[:lesson][:code_concept_list], parse: true)\n @suggested_lessons = params[:lesson][:suggested_lessons]\n if @suggested_lessons.present?\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n end\n # raise 'hell'\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @story.update(story_params)\n format.json { render json: @story, root: false, status: :ok, location: @story }\n else\n format.json { render json: @story.errors, root: false, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n flash[:notice] = 'Lesson was successfully updated.'\n format.html { redirect_to(@lesson) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lesson.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @leadership.update(leadership_params)\n format.html { redirect_to @leadership, notice: 'Leadership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tutorials = Tutorials.find(params[:id])\n\n respond_to do |format|\n if @tutorials.update_attributes(params[:tutorials])\n flash[:notice] = 'Tutorials was successfully updated.'\n format.html { redirect_to(@tutorials) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tutorials.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n #@story = Story.friendly.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lab_method = LabMethod.find(params[:id])\n\n respond_to do |format|\n if @lab_method.update_attributes(params[:lab_method])\n format.html { redirect_to @lab_method, notice: 'Lab method was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab_method.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end", "def update\n put :update\n end", "def update\n @lab = Lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(lab_params)\n format.html { redirect_to @lab, notice: 'Lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n @story.update_attributes(params[:story])\n respond_with @story\n end", "def update\n @lab = lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(params[:lab])\n format.html { redirect_to @lab, notice: 'lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lunch.update(lunch_params)\n format.html { redirect_to @lunch, notice: 'Lunch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lunch.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 @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n if @my_exam.update_attributes(params[:my_exam])\n format.html { redirect_to @my_exam, notice: 'My exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @headline.update(headline_params)\n format.html { redirect_to @headline, notice: 'Headline was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @headline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n \n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Zmiany zostały zapisane.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend", "def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end", "def update\n @expertise = Expertise.find(params[:id])\n\n if @expertise.update(expertise_params)\n head :no_content\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to [:admin, @lesson], notice: t('activerecord.models.lesson') +'更新成功!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, :notice => 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @story.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n if @jetty.update_attributes(params[:jetty])\n format.html { redirect_to @jetty, notice: 'Jetty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jetty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, :notice => 'Story was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @story.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, :notice => 'Story was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @story.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { render :show, status: :ok, location: @major }\n else\n format.html { render :edit }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n if @my_studio_client.update_attributes(params[:my_studio_client])\n format.html { redirect_to @my_studio_client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\nlogger.debug \"update discipline: \"+@discipline.inspect\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @lesson_plan.update(lesson_plan_params)\n format.html { redirect_to @lesson_plan, notice: 'Lesson plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lesson_plan.errors, status: :unprocessable_entity }\n end\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 @title = t('view.feedbacks.edit_title')\n @feedback = find_feedback\n\n respond_to do |format|\n if @feedback.update default_args.reverse_merge(feedback_params)\n format.html { redirect_to [@lesson, @feedback], notice: t('view.feedbacks.correctly_updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n if @gotcha.update_attributes(params[:gotcha])\n format.html { redirect_to @gotcha, notice: 'Gotcha was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gotcha.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @story.update(story_params)\n head :no_content\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end", "def update\n @team = Team.find(params[:id])\n\n if @team.update_attributes(params[:team])\n head :no_content\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end", "def put!\n request! :put\n end", "def update\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n if @lesson_learned.update_attributes(params[:lesson_learned])\n # Now index it in Solr\n @rsolr.add(:id=>@lesson_learned.id,\n :lesson_date=>@lesson_learned.lessonDate.to_s + 'T00:00:00Z',\n :project_reference=>@lesson_learned.projectReference,\n :project_engineer=>@lesson_learned.projectEngineer,\n :project_architect=>@lesson_learned.projectArchitect,\n :project_owner=>@lesson_learned.projectOwner,\n :division=>@lesson_learned.division,\n :text=>@lesson_learned.input)\n @rsolr.commit\n\n format.html { redirect_to @lesson_learned, notice: 'Lesson learned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lesson_learned.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson_reference.update(lesson_reference_params)\n format.html { redirect_to @lesson_reference, notice: 'Lesson reference was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson_reference }\n else\n format.html { render :edit }\n format.json { render json: @lesson_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student_major = StudentMajor.find(params[:id])\n\n respond_to do |format|\n if @student_major.update_attributes(student_major_params)\n format.html { redirect_to @student_major, notice: 'Student major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # if @bonus.update(bonus_params)\n # render :show, status: :ok, location: @bonus\n # else\n # render json: @bonus.errors, status: :unprocessable_entity\n # end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to exams_path, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lab_name = LabName.find(params[:id])\n\n respond_to do |format|\n if @lab_name.update_attributes(params[:lab_name])\n format.html { redirect_to @lab_name, notice: 'Lab name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n if @practice.update_attributes(params[:practice])\n format.html { redirect_to @practice, notice: 'Practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, :notice => 'Hack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n update_resource_response(@headline, headline_params)\n end", "def update\n @story = Story.find(params[:id])\n\t\t@title = \"Edycja newsa\"\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Wiadomość zapisano pomyślnie.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lesson_status.update(lesson_status_params)\n format.html { redirect_to @lesson_status, notice: 'Lesson status was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson_status }\n else\n format.html { render :edit }\n format.json { render json: @lesson_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_lesson.update(user_lesson_params)\n format.html { redirect_to @user_lesson, notice: 'User lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_lesson }\n else\n format.html { render :edit }\n format.json { render json: @user_lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n @analyst = Analyst.find(params[:id])\n\n if @analyst.update(params[:analyst])\n head :no_content\n else\n render json: @analyst.errors, status: :unprocessable_entity\n end\n end", "def update\n @student = Student.find(params[:student_id])\n @lunchdetention = @student.lunchdetentions.find(params[:id])\n\n respond_to do |format|\n if @lunchdetention.update_attributes(params[:lunchdetention])\n format.html { redirect_to :back, notice: 'lunchdetention was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lunchdetention.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @story.update(story_params)\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @story.update(story_params)\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @story.update(story_params)\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @story.update(story_params)\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hackathon.update(hackathon_params)\n format.html { redirect_to @hackathon, notice: 'Hackathon was successfully updated.' }\n format.json { render :show, status: :ok, location: @hackathon }\n else\n format.html { render :edit }\n format.json { render json: @hackathon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hackathon.update(hackathon_params)\n format.html { redirect_to @hackathon, notice: 'Hackathon was successfully updated.' }\n format.json { render :show, status: :ok, location: @hackathon }\n else\n format.html { render :edit }\n format.json { render json: @hackathon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, notice: 'Hack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hack.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.65853786", "0.63851297", "0.6311894", "0.6126403", "0.6070752", "0.6058629", "0.6054614", "0.6053014", "0.6053014", "0.6053014", "0.6030143", "0.60123265", "0.6002697", "0.5999764", "0.5945133", "0.5942412", "0.5940565", "0.592433", "0.5909988", "0.5904255", "0.5901184", "0.58801657", "0.5873482", "0.58703655", "0.5865025", "0.5847307", "0.58363223", "0.58348405", "0.58336496", "0.58329743", "0.5829252", "0.5811527", "0.5810527", "0.580832", "0.58050114", "0.5803007", "0.57981414", "0.5788909", "0.5780088", "0.5768746", "0.5768203", "0.5762686", "0.57556415", "0.5750073", "0.574472", "0.5742089", "0.5732796", "0.5723784", "0.57150906", "0.57114977", "0.5711064", "0.5708363", "0.5706647", "0.57045907", "0.5695078", "0.56919926", "0.5691491", "0.5689519", "0.5689519", "0.5684186", "0.5683066", "0.5683066", "0.56811625", "0.5678112", "0.56769174", "0.567545", "0.56737673", "0.5667325", "0.56624043", "0.5661171", "0.5661119", "0.565469", "0.565277", "0.5648546", "0.56480885", "0.564033", "0.5632843", "0.5632401", "0.56284", "0.5627255", "0.56264955", "0.56246877", "0.5620243", "0.5619056", "0.5618184", "0.5617442", "0.5617371", "0.5615071", "0.5613253", "0.56108844", "0.56093985", "0.56077486", "0.5606968", "0.5606968", "0.5606968", "0.5606968", "0.56046534", "0.56046534", "0.5603724", "0.560259" ]
0.6150968
3
DELETE /lessons/1 DELETE /lessons/1.json
def destroy @lesson.destroy respond_to do |format| format.html { redirect_to lessons_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @lesson = Lesson.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to lessons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson = Lesson.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to lessons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to course_lessons_path(@course) }\n format.json { head :no_content }\n end\n end", "def destroy\n @course_lesson = CourseLesson.find(params[:id])\n @course_lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to course_lessons_url }\n format.json { head :ok }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to lessons_url, notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to lessons_url, notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to lessons_url, notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson = Lesson.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to(lessons_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lesson = current_user.organization.lessons.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to(lessons_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to admin_path, notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to admin_path(:anchor => 'tab=lessons') , notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to lessons_url, notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to admin_lessons_url, notice: t('activerecord.models.lesson') +'删除成功!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @private_lesson.destroy\n respond_to do |format|\n format.html { redirect_to private_lessons_url, notice: 'Private lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_item.destroy\n respond_to do |format|\n format.html { redirect_to lesson_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_lesson.destroy\n respond_to do |format|\n format.html { redirect_to user_lessons_url, notice: 'User lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @backend_tutorial_stat = Backend::TutorialStat.find(params[:id])\n @backend_tutorial_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to backend_tutorial_stats_url }\n format.json { head :ok }\n end\n end", "def destroy\n @pupil_has_lesson.destroy\n respond_to do |format|\n format.html { redirect_to pupil_has_lessons_url, notice: 'Pupil has lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_entryset.destroy\n respond_to do |format|\n format.html { redirect_to lesson_entrysets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_lesson.destroy\n respond_to do |format|\n format.html { redirect_to group_lessons_url, notice: 'Group lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_plan.destroy\n respond_to do |format|\n format.html { redirect_to lesson_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_module = LessonModule.all\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to course_lessons_path(course_id: @lesson.course.id), notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial = Tutorial.find(params[:id])\n @tutorial.destroy\n render json: @tutorial\n end", "def destroy\n @lesson_reference.destroy\n respond_to do |format|\n format.html { redirect_to lesson_references_url, notice: 'Lesson reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @lesson_status.destroy\n respond_to do |format|\n format.html { redirect_to lesson_statuses_url, notice: 'Lesson status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial.destroy\n respond_to do |format|\n format.html { redirect_to tutorials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:course_id])\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to course_path(@course), notice: 'lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @learn = Learn.find(params[:id])\n @learn.destroy\n\n respond_to do |format|\n format.html { redirect_to learns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_exam = MyExam.find(params[:id])\n @my_exam.destroy\n\n respond_to do |format|\n format.html { redirect_to my_exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @welcome = Welcome.find(params[:id])\n @welcome.destroy\n\n respond_to do |format|\n format.html { redirect_to welcomes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_plan = current_user.lesson_plans.detect{params[:id]}\n @lesson_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @leadership.destroy\n respond_to do |format|\n format.html { redirect_to leaderships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @notebook = current_user.notebooks.find(params[:notebook_id])\n @lesson = @notebook.lessons.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to(notebook_lessons_path) }\n format.js { render :nothing => true }\n end\n end", "def destroy\n @tutorial = Tutorial.find(params[:id])\n @tutorial.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorials = Tutorials.find(params[:id])\n @tutorials.destroy\n\n respond_to do |format|\n format.html { redirect_to(tutorials_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson.destroy\n end", "def destroy\n @tutorial.destroy\n respond_to do |format|\n format.html { redirect_to admin_course_tutorials_path(@course) }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_plan.destroy\n respond_to do |format|\n format.html { redirect_to current_educator, notice: 'Lesson plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @storyline = Storyline.find(params[:id])\n @storyline.destroy\n\n respond_to do |format|\n format.html { redirect_to storylines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @yourstory = Yourstory.find(params[:id])\n @yourstory.destroy\n\n respond_to do |format|\n format.html { redirect_to yourstories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @departmentlesson.destroy\n respond_to do |format|\n format.html { redirect_to departmentlessons_url, notice: 'Department lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @lesson_completed.destroy\n respond_to do |format|\n format.html { redirect_to lesson_completeds_url, notice: 'Lesson completed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@tutorial = Tutorial.find(params[:id])\n #@tutorial.destroy\n #\n #respond_to do |format|\n # format.html { redirect_to tutorials_url }\n # format.json { head :no_content }\n #end\n end", "def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\t\t@title = \"Usuwanie newsa\"\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @nightclub.destroy\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_response.destroy\n respond_to do |format|\n format.html { redirect_to lesson_responses_url, notice: 'Lesson response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @introexam.destroy\n respond_to do |format|\n format.html { redirect_to introexams_url, notice: 'Introexam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab = Lab.find(params[:id])\n @lab.destroy\n\n respond_to do |format|\n format.html { redirect_to labs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial.destroy\n respond_to do |format|\n format.html { redirect_to tutorials_url, notice: 'Tutorial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @lab = lab.find(params[:id])\n @lab.destroy\n\n respond_to do |format|\n format.html { redirect_to labs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_learned = LessonLearned.find(params[:id])\n @lesson_learned.destroy\n\n # Now remove it from Solr\n @rsolr.delete_by_id(@lesson_learned.id)\n @rsolr.commit\n\n respond_to do |format|\n format.html { redirect_to lesson_learneds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contestant = Contestant.find(params[:id])\n @contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storylink = Storylink.find(params[:id])\n @storylink.destroy\n\n respond_to do |format|\n format.html { redirect_to storylinks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n rehearsals = Rehearsal.where(lesson_id: @lesson)\n rehearsals.each { |r| LessonRehearsal.where(rehearsal_id: r).delete_all } if rehearsals.any?\n rehearsals.each { |r| PerformanceFeedback.where(rehearsal_id: r).delete_all } if rehearsals.any?\n Rehearsal.where(lesson_id: @lesson).delete_all\n\n @lesson.destroy\n respond_to do |format|\n format.html { redirect_to course_topic_path(@course, @topic), notice: 'Lesson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @nightclub = Nightclub.find(params[:id])\n @nightclub.destroy\n\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mostsmallmission = Mostsmallmission.find(params[:id])\n @mostsmallmission.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallmissions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mission = Mission.find(params[:id])\n @mission.destroy\n\n respond_to do |format|\n format.html { redirect_to missions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story.destroy\n respond_to do |format|\n format.html { redirect_to admin_stories_path, notice: 'Story was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @url_shortner.destroy\n respond_to do |format|\n format.html { redirect_to url_shortners_url, notice: 'Url shortner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @story = Story.find(params[:id])\n #@story = Story.friendly.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lecture.destroy\n respond_to do |format|\n format.html { redirect_to lectures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mission = Mission.find(params[:id])\n @mission.destroy\n\n respond_to do |format|\n format.html { redirect_to missions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @hackathon.destroy\n respond_to do |format|\n format.html { redirect_to hackathons_url, notice: 'Hackathon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @urlshortner.destroy\n respond_to do |format|\n format.html { redirect_to urlshortners_url }\n format.json { head :no_content }\n end\n end", "def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end", "def destroy\n @typetutorial.destroy\n respond_to do |format|\n format.html { redirect_to typetutorials_url, notice: 'Typetutorial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial.destroy\n respond_to do |format|\n format.html { redirect_to tutorials_url, notice: 'Your Tutorial post was successfully deleted and is now permanently offline...' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lei = Lei.find(params[:id])\n @lei.destroy\n\n respond_to do |format|\n format.html { redirect_to leis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :ok }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @first_exam.destroy\n respond_to do |format|\n format.html { redirect_to first_exams_url, notice: 'First exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lunch.destroy\n respond_to do |format|\n format.html { redirect_to lunches_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end" ]
[ "0.75589675", "0.75589675", "0.74921167", "0.729321", "0.7290526", "0.7290526", "0.72901374", "0.720436", "0.71760815", "0.7165285", "0.7135993", "0.71059334", "0.7060732", "0.702374", "0.7002369", "0.6976492", "0.6957436", "0.69083154", "0.6900947", "0.6881635", "0.68790466", "0.6861032", "0.6860565", "0.68385696", "0.68339455", "0.6804439", "0.6797062", "0.6791067", "0.6776859", "0.67697597", "0.67695326", "0.676576", "0.67481166", "0.674257", "0.67236", "0.66893816", "0.668622", "0.66836804", "0.66809714", "0.6676354", "0.6675362", "0.6666903", "0.6663337", "0.6662601", "0.66586995", "0.6644793", "0.66442806", "0.6639003", "0.6634827", "0.66328746", "0.6628003", "0.6626948", "0.662601", "0.66211265", "0.66211265", "0.66211265", "0.66134703", "0.66066575", "0.6603975", "0.66011703", "0.6596098", "0.6588495", "0.65802604", "0.65793234", "0.6572484", "0.6568908", "0.6565317", "0.6564337", "0.65620774", "0.65620774", "0.6556381", "0.6556381", "0.6556381", "0.6556381", "0.655555", "0.6539223", "0.6534741", "0.65346324", "0.6533387", "0.65320057", "0.65320057", "0.65320057", "0.65320057", "0.6528806", "0.6528395", "0.65258366", "0.6522076", "0.65191746", "0.65190804", "0.65186924", "0.6517992", "0.6517666", "0.6517332", "0.651639", "0.65128064", "0.6511176", "0.6510949", "0.65092", "0.65074587", "0.65071875" ]
0.75231284
2
Use callbacks to share common setup or constraints between actions.\
def set_section @course = Course.find(params[:course_id]) @section = @course.sections.find(params[:section_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_hook; end", "def callbacks; end", "def callbacks; end", "def run_actions; end", "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def actions; end", "def add_actions; end", "def define_action_hook; 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 post_setup\n end", "def action_run\n end", "def before_setup; end", "def setup_handler\n end", "def workflow\n end", "def define_action_helpers; end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def after_set_callback; end", "def setup_signals; end", "def pre_task\n end", "def after_generate_callbacks; end", "def set_actions\n actions :all\n end", "def setup(resources) ; end", "def setup\n # override and do something appropriate\n end", "def matt_custom_action_begin(label); end", "def before_dispatch(env); end", "def before_action \n end", "def determine_valid_action\n\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 after_validate\n end", "def callback\n\tend", "def define_action_helpers?; end", "def callback\n\n end", "def setup(_context)\n end", "def callback\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 around_hooks; end", "def advice\n end", "def initialize(*args)\n super\n @action = :set\nend", "def save_action; 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 action\n end", "def config(action, *args); end", "def after_view_setup\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 #implement in subclass;\n end", "def prepare_for_execution(evt,config)\n # here for sub-classes to override.\n end", "def callback_phase\n super\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 before_run; 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 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 action_target()\n \n end", "def action(unit)\n\tend", "def release_actions; end", "def form_setup\n\tend", "def setup\n\t\tend", "def setup\n\t\tend", "def execute(setup)\n @action.call(setup)\n end", "def initialize(*args)\n super \n @action = :add_server\nend", "def setup\n # override this if needed\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def lookup_action; end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def after_create; end", "def default_action; end", "def after_actions(*logic)\n self.after_actions = logic\n 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 functions\n\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def process_action(...)\n send_action(...)\n end", "def before_configuration_tasks \n end", "def action=(_arg0); end", "def setup(easy)\n super\n easy.customrequest = @verb\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 initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def initialize(*args)\n super\n @action = :create\nend", "def before_workflow_launch(workflow, user)\n #raise \"Must implement in target model!\"\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 validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def admin_logic\n end", "def pre_authorize_cb=(_arg0); end" ]
[ "0.64831156", "0.6397671", "0.6397671", "0.63712466", "0.63701516", "0.6322635", "0.6234728", "0.6212416", "0.59583217", "0.59089357", "0.58330506", "0.579678", "0.5764087", "0.5706481", "0.5685825", "0.56603265", "0.56603265", "0.56603265", "0.5648843", "0.5648843", "0.5648843", "0.5648843", "0.5648843", "0.56177026", "0.5612616", "0.55813855", "0.55482185", "0.5544033", "0.5534805", "0.5529061", "0.55160993", "0.55094355", "0.5492725", "0.5482432", "0.5470708", "0.54464364", "0.54464364", "0.5437309", "0.54342645", "0.5431523", "0.5429605", "0.5418606", "0.5416118", "0.54150796", "0.5413039", "0.53910905", "0.53881735", "0.5383261", "0.53804773", "0.5375125", "0.5360429", "0.53546196", "0.53544235", "0.5352364", "0.5351267", "0.5350743", "0.53491384", "0.5333675", "0.53328717", "0.5318803", "0.5317152", "0.5316928", "0.53125083", "0.53104067", "0.53101873", "0.530163", "0.5294549", "0.5294549", "0.5292392", "0.5289199", "0.5286616", "0.5274089", "0.5264365", "0.5263695", "0.52607054", "0.52607054", "0.5257899", "0.5257822", "0.5254594", "0.52504075", "0.52504075", "0.5249992", "0.52404577", "0.5235477", "0.5234856", "0.523378", "0.52276695", "0.5224735", "0.5223059", "0.5223059", "0.5223059", "0.5223059", "0.5223059", "0.5223059", "0.5223059", "0.5223059", "0.5221394", "0.52198744", "0.5212055", "0.52117383", "0.5205543" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def lesson_params params.require(:lesson).permit(:name, :description) 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
Sets up internal state, natch, and accepts a block that customizes the resulting object.
def initialize @items = [] @item_stack = [] yield self if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(&block)\n @block = block\n end", "def initialize(&block)\n configure(&block) if block_given?\n end", "def initialize(&block)\n @block = block\n end", "def initialize(&block)\n @block = block\n end", "def initialize\n @block_args = []\n end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def post_init_block(&block)\n with(&block)\n end", "def initialize(&block)\n instance_eval(&block) if block_given?\n end", "def initialize(&block)\n instance_exec(&block) if block_given?\n end", "def block_node=(_); end", "def setup &block\n block.try(:call, self)\n end", "def initialize(&block)\n instance_eval(&block) if block_given?\n end", "def initialize(&block)\n @required_options = []\n instance_exec &block\n end", "def configure(&block); end", "def configure(&block); end", "def initialize(&block)\n yield self\n end", "def initialize(&block)\n load_defaults!\n\n instance_eval(&block) if block_given?\n\n set_defaults!\n end", "def initialize (&block)\n instance_exec(&block)\n end", "def configure &block\n\t\tinstance_eval &block\n\tend", "def block_node; end", "def block_node; end", "def configure\n yield flags if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure(&block)\n self.instance_eval(&block)\n end", "def initialize(*)\n super\n yield self if block_given?\n end", "def post_init_block(&block)\n raise ArgumentError, \"does not accept a block\"\n end", "def configure(&block)\n yield(self)\n end", "def configure(&block)\n yield(self)\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def blocks; end", "def blocks; end", "def blocks; end", "def block=(_arg0); end", "def block=(_arg0); end", "def configure(&block)\n self.instance_eval(&block) if block_given?\n end", "def init (&block)\n @init_block = block\n end", "def initialize\n yield( self ) if block_given? # allow setup with code block\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(args={}, &block)\n save_state\n configure_with_args args\n configure_with_block &block if block_given?\n self\n end", "def configure(args={}, &block)\n save_state\n configure_with_args args\n configure_with_block &block if block_given?\n self\n end", "def initialize(&block)\n load_defaults!\n\n instance_eval(&block)\n end", "def alter(&block)\n dup.tap { |o| o.instance_eval(&block) }\n end", "def configure(&blk)\n @blk = blk if block_given?\n self\n end", "def define &block\n new block\n end", "def configure(&block)\n default_values!\n yield self\n end", "def create_block_object(&block)\n block\nend", "def initialize(&block)\n super(state: :waiting, result: nil, error: nil)\n block.call.to_promise.then do |result|\n mutate!(state: :success, result: result)\n end.error do |error|\n mutate!(state: :error, error: error)\n end\n end", "def configure(&block)\n cfg = self.class::CONFIGURATOR.new(self)\n block.call(cfg)\n # allow configuration tuning for derived recipes\n post_configure\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure &blk\n instance_eval &blk\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize(&block)\n yield self\n end", "def initialize(&block)\r\n yield(self) if block_given? \r\n end", "def populate &block\n instance_eval(&block)\n self\n end", "def initialize(state, &block)\n if nil == state\n raise \"Passed nil to initialize. Generally disallowed.\"\n end\n @state = state\n @fields = {}\n # @context = context\n # @vars = Hashie::Mash.new(vars)\n\n instance_eval &block\n end", "def configure\n yield(self) if block_given?\n end", "def initialize block_parser\n @block_parser = block_parser\nend", "def with_block(&block)\n end", "def setup &block\n if @setup_block\n setup_block = @setup_block\n exec_setup_block = method(:exec_setup_block)\n @setup_block = lambda do |attributes, options, backend_class|\n [setup_block, block].each do |blk|\n exec_setup_block.call(self, attributes, options, backend_class, &blk)\n end\n end\n else\n @setup_block = block\n end\n end", "def init(&block)\n @inits << block\n end", "def init(&block)\n @inits << block\n end", "def initialize(initial_state, klass, &block)\n @class = klass\n @initial = initial_state\n @states = Hash.new\n @events = Hash.new\n @callbacks = {before: Hash.new , after: Hash.new}\n instance_eval &block\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize(options = {}, &block)\n\t\t \n\t\t\tyield self unless block == nil\n\t\tend", "def block(block)\n @components[:__base__] = self.class.build(&block)\n @load_order << :__base__\n true\n end", "def initialize(&block)\n load_defaults!\n\n @only_collections ||= Array.new\n @additional_options ||= Array.new\n @ipv6 ||= false\n @lock ||= false\n\n instance_eval(&block)\n prepare!\n end", "def initialize(params ={}, &block)\n super\n instance_eval &block\n end", "def run(&block)\n end", "def preprocess(&block); end", "def construct( &block )\n self.instance_eval(&block)\n @options\n end" ]
[ "0.6856396", "0.67710245", "0.6750125", "0.6750125", "0.66565245", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66492355", "0.66177946", "0.6599448", "0.65475714", "0.6534999", "0.64890593", "0.6475739", "0.646309", "0.6458712", "0.6458712", "0.6445676", "0.6444496", "0.6408673", "0.63810617", "0.6358083", "0.6358083", "0.6336752", "0.633269", "0.633269", "0.63285226", "0.6323213", "0.6318341", "0.6313583", "0.6313583", "0.6302087", "0.6302087", "0.6302087", "0.6302087", "0.6301317", "0.6301317", "0.6301317", "0.6297134", "0.6297134", "0.6287426", "0.6287299", "0.6284634", "0.626498", "0.626498", "0.6261409", "0.6261409", "0.6256616", "0.6256565", "0.6254464", "0.6252357", "0.62500584", "0.62435776", "0.62271225", "0.6222292", "0.62035114", "0.61891246", "0.61891246", "0.61891246", "0.6183697", "0.6180514", "0.6180514", "0.6180514", "0.6180514", "0.6166155", "0.615065", "0.61482996", "0.6141911", "0.61369324", "0.6129645", "0.6129024", "0.6103467", "0.60984164", "0.60984164", "0.60927033", "0.60919875", "0.60919875", "0.6088236", "0.60815555", "0.60716754", "0.60669583", "0.60564166", "0.6056107", "0.60528064" ]
0.0
-1
Inserts an HTML comment (eg )
def comment!(str) if str.include? "\n" text! "<!--\n#{str}\n-->\n" else text! "<!-- #{str} -->\n" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment(text)\n@out << \"<!-- #{text} -->\"\nnil\nend", "def comment(text)\n @out << \"<!-- #{text} -->\"\n nil\n end", "def add_comment comment\n \"\\n###### #{comment} ######\\n\" \n end", "def comment(text)\n @xml << \"<!-- #{text} -->\"\n nil\n end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def add_comment(comment)\n \"\\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\\n\"\n end", "def comment!(content)\n build! do\n @_crafted << \"<!-- \"\n @_crafted << Tools.escape(content.to_s)\n @_crafted << \" -->\"\n end\n end", "def comment(*args)\n #:stopdoc:\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n jig = (Cache[:comment] ||= new(\"<!-- \".freeze, GAP, \" -->\\n\".freeze).freeze)\n jig.plug(GAP, *args)\n #:startdoc:\n end", "def comment(str)\n @out.comment(str)\n end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment comment\n end", "def comment?; end", "def comment?; end", "def comment(contents='', &block)\n contents = build(:blank, Context, &block) if block\n '<!-- %s -->' % indent(contents)\n end", "def comment( text = nil, &block )\n make_indent if @indent > 0\n \n @serial = @serial + 1\n @buffer << \"<!-- \"\n \n if text then \n @buffer << encode(text)\n elsif !block.nil? then\n capture(&block)\n end\n \n @buffer << \" -->\"\n end", "def add_comment(comment); end", "def comment str\n self.add_comment(\"This is a paragraph comment for the paragraph\", \"OCELOT Commenter\");\n end", "def create_comment(string, &block); end", "def create_comment(string, &block); end", "def create_comment(content)\n DOM(`#@native.createComment(#{content})`)\n end", "def comment(text)\n comments << text\n end", "def render_comment(line)\n conditional, content = line.scan(COMMENT_REGEX)[0]\n content.strip!\n\n if @block_opened && !content.empty?\n raise SyntaxError.new('Illegal Nesting: Nesting within a tag that already has content is illegal.')\n end\n\n try_one_line = !content.empty?\n push_silent \"_hamlout.open_comment(#{try_one_line}, #{conditional.inspect}, #{@output_tabs})\"\n @output_tabs += 1\n push_and_tabulate([:comment, !conditional.nil?])\n if try_one_line\n push_text content\n close\n end\n end", "def new_comment comment, line_no = nil\n c = RDoc::Comment.new comment, @top_level, :ruby\n c.line = line_no\n c.format = @markup\n c\n end", "def render_comment(line)\n conditional, line = balance(line, ?[, ?]) if line[0] == ?[\n line.strip!\n conditional << \">\" if conditional\n\n if block_opened? && !line.empty?\n raise SyntaxError.new('Illegal nesting: nesting within a tag that already has content is illegal.', @next_line.index)\n end\n\n open = \"<!--#{conditional}\"\n\n # Render it statically if possible\n unless line.empty?\n return push_text(\"#{open} #{line} #{conditional ? \"<![endif]-->\" : \"-->\"}\")\n end\n\n push_text(open, 1)\n @output_tabs += 1\n push_and_tabulate([:comment, !conditional.nil?])\n unless line.empty?\n push_text(line)\n close\n end\n end", "def add_comment(comment)\n @comment += comment + \"\\n\"\n end", "def comment!(str)\n @comments_buf << str\n end", "def write_comment(text)\n puts \"# #{text.chomp}\" # TODO: correctly output multi-line comments\n end", "def write_comment(text)\n puts \"# #{text.chomp}\" # TODO: correctly output multi-line comments\n end", "def write_html(indent,part)\n# \"<!-- #{indent} --> #{' '*(if indent<0 then 0 else indent end)}#{part}\\n\"\n \"#{' '*(if indent<0 then 0 else indent end)}#{part}\\n\"\n end", "def comment(path, content)\n gsub_file path, content, \"##{content}\"\n end", "def rude_comment\n @res.write GO_AWAY_COMMENT\n end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def start_comment(description = 'Description')\n str = \"#{@indent}/**\\n\"\n str += \"#{@indent} *\\t@brief\\t<##{description}#>\\n\"\n str \n end", "def visit_comment(node)\n line = @original_haml_lines[node.line - 1]\n indent = line.index(/\\S/)\n @ruby_chunks << PlaceholderMarkerChunk.new(node, 'comment', indent: indent)\n end", "def nice_comment\n @res.write THANK_YOU_COMMENT\n end", "def comment!(comment = nil)\n mutate(:comment, comment)\n end", "def comment(value)\n @ole.Comment = value\n nil\n end", "def _HtmlComment\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"<!--\")\n unless _tmp\n self.pos = _save\n break\n end\n while true\n\n _save2 = self.pos\n while true # sequence\n _save3 = self.pos\n _tmp = match_string(\"-->\")\n _tmp = _tmp ? nil : true\n self.pos = _save3\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = get_byte\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = match_string(\"-->\")\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_HtmlComment unless _tmp\n return _tmp\n end", "def add_comment_node(node, text)\n comment_node = Nokogiri::XML::Comment.new(node.document, \"wovn-src:#{text}\")\n if node.parent.name == 'title'\n node.parent.add_previous_sibling(comment_node)\n else\n node.add_previous_sibling(comment_node)\n end\n end", "def trigger_comment(comment) end", "def getComment(var)\n return \"/* \" << var.text << \" */\\n\"\n end", "def on_comment(comment)\n STDOUT << \"on_comment\" << \"\\n\" <<\n \" comment: \" << comment << \"\\n\"\n STDOUT.flush\n end", "def create_comment(string, &block)\n Nokogiri::XML::Comment.new(self, string.to_s, &block)\n end", "def comment name\n\t\tempty = \"//\\n\"\n\n\t\tret = ''\n\t\tret << empty << empty\n\t\tret << \"// #{name}\\n\"\n\t\tret << \"// This is an object created by COBGIN\\n\"\n\t\tret << empty << empty\n\t\tret << \"// by Mickey Barboi\\n\"\n\t\tret << empty << empty << \"\\n\\n\"\n\n\t\tret\n\tend", "def escape_comment(text)\n text.gsub(/--/, '')\n end", "def comment _args\n \"comment _args;\" \n end", "def add_sql_diff_comment(comment = nil)\n sql_diff_text_log << '--'\n sql_diff_text_log << \" #{comment}\" if comment\n sql_diff_text_log << \"\\r\\n\"\n end", "def process_initial_comment(tk); end", "def placeholder_element(comment: nil, tag: :div, **opt)\n opt[:'aria-hidden'] = true unless opt.key?(:'aria-hidden')\n html_tag(tag, opt) do\n \"<!-- #{comment} -->\".html_safe if comment.present?\n end\n end", "def format_comment(comment)\n comment\n end", "def save_comment(name)\n Jhead.call(\"-cs\", name.shellescape, @match, @pattern)\n end", "def item_comment_string(item, html_required)\n return \"\" if item.nil?\n \n if item.comment.nil? || item.comment.blank?\n return \"Comment: \" + (html_required ? \"<span class='none_text'>none</span>\" : \"none\")\n else\n return \"Comment: \" + (html_required ? \"<div class='comment_text'>#{white_list(simple_format(item.comment))}</div>\" : (\"\\n | \" + item.comment.gsub(/\\n/, \"\\n | \")))\n end\n end", "def comment\n multi_line_comment || single_line_comment\n end", "def comment(comment = nil)\n set_option(:comment, comment)\n end", "def comments(*args)\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n args.push \"\\n\"\n comment(\"\\n\", *args)\n end", "def f_slash_comment\n emit_comment(parse(\"\\n\"))\nend", "def test_html_check_comment_exist\n ct = CodeTerminator::Html.new\n p \"1 test if comment exist in code with comment\"\n p errors = ct.match(\"exercises/html/check_comment_exist.html\",\"<html><head></head><body><!-- This is a comment --></body></html>\")\n assert_equal errors.empty? , true\n end", "def comment=(comment)\n Jhead.call(\"-cl\", comment.shellescape, @match, @pattern)\n end", "def comment=(*)\n # do nothing with comment\n end", "def comment\n @comment ||= begin\n space = node.previous_sibling and\n space.to_s.blank? && space.to_s.count(\"\\n\") == 1 and\n comment_node = space.previous_sibling\n\n if comment_node.is_a?(REXML::Comment)\n doc.restore_erb_scriptlets(comment_node.to_s.strip)\n end\n end\n end", "def comment=(value)\n @comment = value\n end", "def comment=(value)\n @comment = value\n end", "def mysql_modsec_versioned_comment\n if self =~ /(--|\\/\\*|\\#)/\n delim=$1\n inj = self.gsub(\"#{delim}\", '')\n else\n inj=self\n end\n foo=\"/*!30#{rand(9).to_s+rand(9).to_s+rand(9).to_s}#{inj}*/\"\n foo += delim if delim\n return foo\n end", "def wine_comment\n end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comment\n cyc.comment(self.to_sym)\n end", "def comment(text, options = {})\n if options[:kind] && @comment_kinds\n Array(options[:kind]).each do |kind|\n @builder.comment!(\"$#{kind}$ #{text}\")\n end\n elsif @comments\n @builder.comment!(text)\n end\n end", "def comment\n \"%-#{$plugin_max}s # %s\" % [plugin, old_comment] if old_comment\n end", "def default_allows_comments?; true; end", "def test_html_check_comment_text\n ct = CodeTerminator::Html.new\n p \"3 test if text in comment is the same as the text of comment in code\"\n p errors = ct.match(\"exercises/html/check_comment_text.html\",\"<html><head></head><body><!-- This is a comment --></body></html>\")\n assert_equal errors.empty? , true\n end", "def convert_xml_comment(el, opts)\n block = el.options[:category] == :block\n indent = SPACE * @current_indent\n content = el.value\n content.gsub!(/^<!-{2,}\\s*/, \"\") if content.start_with?(\"<!--\")\n content.gsub!(/-{2,}>$/, \"\") if content.end_with?(\"-->\")\n result = content.lines.map.with_index do |line, i|\n (i.zero? && !block ? \"\" : indent) +\n @pastel.decorate(\"#{@symbols[:hash]} \" + line.chomp,\n *@theme[:comment])\n end.join(NEWLINE)\n block ? result + NEWLINE : result\n end", "def description\n markup @comment\n end", "def ensure_comments_section\n if self.body.match(/^\\* COMMENT Comments$/)\n self.body[$~.end(0)..-1] = self.body[$~.end(0)..-1].gsub(/^\\* COMMENT Comments/, '')\n else\n self.body << \"\\n* COMMENT Comments\\n\"\n end\n end" ]
[ "0.7763619", "0.7685479", "0.76105225", "0.74348044", "0.7343113", "0.7343113", "0.7343113", "0.7343113", "0.7337848", "0.7320871", "0.7216868", "0.72111416", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6990976", "0.6930071", "0.69122875", "0.69122875", "0.6911143", "0.6903601", "0.6894209", "0.6886455", "0.6806619", "0.6806619", "0.67881215", "0.6723099", "0.67115307", "0.67019475", "0.66727835", "0.6630831", "0.6627873", "0.65829754", "0.65829754", "0.6574062", "0.65566885", "0.65209967", "0.64957887", "0.64957887", "0.64957887", "0.64957887", "0.64596546", "0.6417569", "0.6414615", "0.63981557", "0.638937", "0.63762313", "0.6340337", "0.6296012", "0.62811506", "0.6236441", "0.62204343", "0.6216232", "0.62058127", "0.6194839", "0.6158728", "0.61565036", "0.6155322", "0.614845", "0.6141099", "0.6132775", "0.6131833", "0.6129803", "0.6107646", "0.6089247", "0.60634553", "0.6063012", "0.6061163", "0.60480773", "0.6047914", "0.6047914", "0.6033701", "0.60324496", "0.6026558", "0.6026558", "0.6026558", "0.6026558", "0.6026558", "0.6026558", "0.60265386", "0.6026163", "0.6014501", "0.6005734", "0.59858596", "0.59832454", "0.5980579", "0.5975423" ]
0.70936906
12
Allow pushing new elements
def <<(new_item) if @item_stack.empty? @items << new_item else @item_stack.last.html << new_item end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(element); end", "def push(element)\r\n # IMPLEMENTME!\r\n end", "def push_dup; end", "def push(element)\n # IMPLEMENT ME!\n end", "def push(elt)\n @elements << elt\n end", "def push(item); end", "def push(new_element)\n @collection.push(new_element)\n end", "def push(x)\n self << x\nend", "def push(element)\n @store.push(element)\n @top += 1\n end", "def push(element)\n # add element to the head of @store\n @store.add_first(element)\n end", "def push(x)\n \n end", "def push(x)\n \n end", "def push(element)\n @store.push(element)\n self\n end", "def push(value); end", "def push(element)\n @data[@data.length] = element\n end", "def push(element)\n @data.push(element)\n end", "def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end", "def add(element)\n @push_stack.push(element)\n end", "def push(val)\n \n end", "def push\n end", "def push_dup\n push(@store.last) if size > 0\n end", "def <<(elem)\r\n self.add elem\r\n end", "def add(element)\n\t\t@size += 1\n\t\t@data.push(element)\n\t\telement\n\tend", "def push(e)\n idx = @data.size\n @data.push e\n percolate_up\n end", "def push(el)\n @stack.push(el)\n end", "def add element\n add_last(element)\n end", "def add element\n add_last(element)\n end", "def push\n end", "def push(item)\n end", "def push(el)\n @ivar << el \n end", "def push_elements_into_array(array, new_element)\n array.push new_element\nend", "def append(element)\n updated(@children + [element])\n end", "def add(el)\n\t\tif(@elements.length < @size)\n\t\t\t@elements.push(el)\n\t\t\tbubble_up()\n\t\telsif el[@orderBy] < max\n\t\t\t# remove the max\n\t\t\tbubble_down()\n\t\t\t# add the new element\n\t\t\t@elements.push(el)\n\t\t\tbubble_up()\n\t\tend\n\tend", "def push(element)\n \t@data = LinkedListNode.new(element, @data)\n \tend", "def push(el)\n self.stack_var << el \n end", "def push(item)\n @container << item\n end", "def add(element)\n @entries << element\n element.parent = self\n end", "def push(x)\n @q << x \n end", "def put_in_place\n if place==:append\n item = self\n self.class.with_tree_scope(self) do\n root.append(item)\n end\n end\n end", "def push(*elements)\n @buffer.push(*elements)\n @buffer = @buffer[-@size, @size] if(@buffer.size > @size)\n end", "def push_element\n return if @element_name.nil?\n\n # Add the class attribute if the element is a <p> element.\n @attrs[:class] = 'ppp' if :p == @element_name\n\n # Check @void_elements to determine how the element start would be\n # written. HTML includes void elements that are self closing so those\n # should be handled correctly.\n if VOID_ELEMENTS.include?(@element_name)\n @builder.void_element(@element_name, @attrs)\n else\n @builder.element(@element_name, @attrs)\n end\n # Reset the element name.\n @element_name = nil\n @attrs = {}\n end", "def enqueue(el)\n @data.push(el)\n end", "def push(val)\n self.concat([val])\n shift if size > @max_size\n end", "def enqueue(element)\n @items.push(element)\n nil\n end", "def push_elements_into_array(arr, ele)\n arr.push(ele)\n arr\nend", "def push *items\n @components ||= []\n @components.push items\n self\n end", "def push(*rest) end", "def enqueue(element)\n @in.push(element)\n end", "def add(*args); elements.add(*args); end", "def add(new_element)\n\n case new_element\n when DrawingGroup\n @drawingArray = (@drawingArray << new_element.drawingArray).flatten\n when Drawing\n @drawingArray << new_element\n else\n raise Argument \"New_element (#{@new_element}) is not a valid input\"\n end\n \n end", "def add(elem)\n @elements << elem\n i = @elements.size-1\n pa = parent(i)\n while i>0 and @comparator.call(@elements[i],@elements[pa]) > 0\n swap(i,pa)\n i = pa\n pa = parent(pa)\n end\n end", "def add_to_end(arr, element)\n arr.push(element)\nend", "def add_to_back(item)\n @array << item\n end", "def push(x)\n end", "def <<(to_append); end", "def push(element)\n # get the current length of array\n # because we will be using it several times\n current_length = @items.length\n\n # check if stack is empty\n if @count == 0\n # if so create array with size 1\n @items = Array.new(1)\n elsif @count == current_length\n # if stack is not empty then double size of array\n new_array = Array.new(current_length * 2)\n\n # copy old array onto new array\n @items.each_with_index do |item, i|\n new_array[i] = item\n end\n\n # set items to new_array\n @items = new_array\n end\n\n # set last element to element added\n @items[@count] = element\n\n # add 1 to the count\n @count += 1\n end", "def enqueue(ele)\n @push_stack.push(ele)\n end", "def push(new)\n @stack.unshift(new)\n self\n end", "def push(x)\n @in << x\n end", "def enqueue(el)\n @queue << el\n el\n end", "def push(ele)\n \n if(@stk.size == nil)\n\t p \"Stack full\"\n\telse\n @count = @count + 1\n\t @stk[@count] = ele\t \n\tend\n end", "def push *items\n @items.concat items\n end", "def push(*obj)\n obj.each {|obj| self << obj }\n self\n end", "def push(piece)\n set(pieces: pieces + [piece])\n end", "def push (*args)\n\n args.each { |a| self << a }\n\n self\n end", "def push(element)\n # beginnig of if statement\n # if the method full? returns true or the value of the local var element is nil\n if full? or element.nil?\n # return nil\n nil\n # if the method full? returns false or the value of the local var element is not nil\n else\n # take the value of the variable @top and add one to it\n # assign this new value back to the var @top\n @top = @top.succ\n # assign the value of the local var element\n # to the position in the array @store at the value of @top\n @store[@top] = element\n # return self\n self\n # end if/else statement\n end\n # end push method\n end", "def enqueue(el)\n @queue.push(el)\n true\n end", "def push(x)\n @input.push x\n end", "def end_push\n ## empty\n return [[], []]\n end", "def add(element)\n @element_list << element\n end", "def enqueue(el)\n self.queue_var = [el] + self.queue_var \n end", "def push(val)\n resize! if self.length == self.capacity\n self.length += 1 \n self[length - 1] = val \n nil \n end", "def <<(element)\n if element.nil?\n pair = [0,NilClass]\n else\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n end\n index = @size\n @map[index] = @added.size\n @added << pair\n #@commands << [:append, pair]\n @size += 1\n end", "def push(element)\n # we can't put nil onto the stack, and we can't add to the stack if it is full\n if full? or element.nil?\n nil\n else\n # we need to move our top marker to the new element, which is now the top\n @top = @top.succ\n # and we actually put that element here, in our new top index\n @store[@top] = element\n # explicit return of the stack, i think\n self\n end\n end", "def push(element)\n if length == @buffer_size\n shift\n end\n\n array_push(element)\n end", "def push value\n self.set( self.get_length + 1 , value)\n end", "def add_product(products, new_product)\n products.push(new_product)\nend", "def push(element)\t\t\n\t\twhile !@q1.empty? do\n\t\t\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\n\t\tend\n\t\t@q1.enq(element)\n\t\twhile !@q2.empty? do\n\t\t\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\n\t\tend\t\n\tend", "def push(*items)\n items = _ensure_array_is_valid items\n super\n end", "def push(val)\n # byebug\n if @length < @array.length\n @array[@last + 1] = val\n @last += 1\n @length += 1\n else\n new_array = StaticArray.new(@array.length * 2)\n for i in 0..(@length - 1)\n new_array[i] = @array[i]\n end\n new_array[@last + 1] = val\n @length += 1\n @array = new_array\n @capacity = @capacity * 2\n end\n end", "def addWatchingElement(name)\n if(name.is_a?(Array)) then\n\tname.each{ |n| \n\t addWatchingElement(n);\n\t}\n else\n\t@watcher.push(name) ;\n end\n end", "def <<(element)\n @elements << element\n self\n end", "def push(element)\r\n # So if we're using LinkedListNode like an array, \r\n # how would we do this if it were an array using\r\n # the same basic method? \r\n # It should be something like:\r\n\r\n # def Arrayer\r\n # if array.nil?\r\n # array << element.value\r\n # else \r\n # array << Arrayer(element.next_node)\r\n # Or something like that...\r\n # end\r\n\r\n # Maybe something along those lines. \r\n # So if we're using LinkedListNode in place of\r\n # an array as a way to put the linked list in\r\n # memory, we need to do basically the same thing\r\n \r\n # def push(element)\r\n # if @data.nil?\r\n # @data = LinkedListNode.new(element.value)\r\n # I think we have to do it like this because\r\n # We're taking the input below as an argument\r\n # else\r\n # @data = LinkedListNode.new(element.next_node)\r\n # end\r\n\r\n end", "def push(x)\n @store << x\n \n end", "def enqueue(el)\n @queue.push(el)\n end", "def push_back(data)\n insert(data, @size)\n end", "def added(array)\nend", "def push(element)\n# If the array is too capacity, or if we try to push in nil, return nil.\n if full? or element.nil?\n nil\n# Otherwise, put the element in the array.\n else\n # why do we want @top to be @top + 1?\n @top = @top.succ\n # The element is the next item in the array. I guess if we keep taking the\n # element at index -1, it will be nil. I used pry to investigate:\n # @store=[3, 2, 6, 5, nil, nil]\n # The positions will be occupied by nil if we don't have an element there.\n @store[@top] = element\n # The instance of push will be returned??\n self\n end\n end", "def enqueue(el)\n @ivar << el\n end", "def <<(elemento)\n end", "def add_data_elements\n \n end", "def push!(obj)\n @objs << obj\n end", "def unique_push!(*elements)\n elements.each do |element|\n self << element unless self.include?(element)\n end\n self\n end", "def init_push\n ## empty\n end", "def push *parts\n self.parts.concat parts\n end", "def enqueue(element)\n if element.class.name == \"RealQueue\"\n require 'pry'\n binding.pry\n end\n @store.unshift(element)\n self\n end", "def push(element)\n @data = LinkedListNode.new(element, @data)\n end", "def append! x\n\t\t\tcurrent << x\n\t\t\tx\n\t\tend", "def push(value)\n insert(value)\n self\n end", "def push(element)\n\t if element.is_a?(Numeric)\n\t\t@elements.push Spacer.new(element)\n\t elsif element.is_a?(Spacer)\n\t\t@elements.push element\n\t else\n\t\t@elements.push Spacer.new(spacing) if spacing && !(elements.empty? || elements.last.is_a?(Spacer))\n\t\t@elements.push element\n\t end\n\n\t self\n\tend", "def << item\n @items << item\n end" ]
[ "0.79241586", "0.7751034", "0.7641397", "0.7558929", "0.699", "0.69857013", "0.6949971", "0.6936835", "0.6917913", "0.6767125", "0.6749102", "0.6749102", "0.67055446", "0.67011863", "0.66773635", "0.6676324", "0.6661785", "0.6656265", "0.66262835", "0.659952", "0.6583686", "0.6545258", "0.65127754", "0.6500342", "0.6490737", "0.648945", "0.648945", "0.64657533", "0.6457177", "0.6455406", "0.6411453", "0.6410667", "0.63929665", "0.6392271", "0.6390652", "0.63209194", "0.6313119", "0.6309692", "0.6308603", "0.6298252", "0.62854916", "0.6274496", "0.6271497", "0.62678486", "0.6250321", "0.62289613", "0.6226854", "0.62219524", "0.62169135", "0.6214988", "0.62039864", "0.6203414", "0.6171841", "0.61636466", "0.6146446", "0.61458474", "0.61446714", "0.6141851", "0.61330235", "0.61216974", "0.61178124", "0.61134696", "0.61107796", "0.610139", "0.6099563", "0.6096056", "0.6085325", "0.60838425", "0.6078991", "0.6071485", "0.60648507", "0.6062547", "0.6060121", "0.60561585", "0.60559607", "0.6050856", "0.6034932", "0.6032792", "0.60224855", "0.6019894", "0.6015927", "0.6014975", "0.6014939", "0.60125107", "0.600176", "0.5997286", "0.5994782", "0.5993308", "0.5982534", "0.5981114", "0.59809834", "0.5980809", "0.5979547", "0.59787714", "0.59687185", "0.5968318", "0.5966102", "0.5956038", "0.5955801", "0.5952758", "0.59475935" ]
0.0
-1
Create a new element explicitly
def tag(tag, *args, &block) item = Html::Element.new(tag, *args) self << item if block @item_stack.push item block.call(item) @item_stack.pop end return self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_element(name, *contents_or_attrs, &block); end", "def new_node(element)\n Node.new(element)\n end", "def new\n @element = Element.new\n end", "def new_element(key)\n Element.new('Key' => key)\n end", "def new\n @element = @@model.new()\n end", "def start_new_element(name, attrs)\r\n parent = @element_stack.last\r\n\r\n #puts \"Adding element '#{name}' to '#{parent.name}'\"\r\n\r\n child = REXML::Element.new(name, parent)\r\n child.add_attributes(attrs)\r\n\r\n @element_stack.push(child)\r\n end", "def build_up_new_tag(element)\n @current_node.children << TagNode.new(element)\n end", "def create_element(target, type, parent, options = {})\n # Create element\n element = `document.createElement(#{type})`\n\n # Add element to DOM\n if options[:prepend]\n `#{parent.element}.insertBefore(#{element}, #{options[:prepend].element})`\n else\n `#{parent.element}.appendChild(#{element})`\n end\n\n # Add ruby class to the node\n `#{element}.classList.add(#{dasherize(target.class.name)})`\n\n # Add ruby superclass to the node to allow for more generic styling\n if target.class.superclass != BaseElement\n `#{element}.classList.add(#{dasherize(target.class.superclass.name)})`\n end\n\n # Set ruby object_id as default element id\n if !options.has_key?(:id)\n `#{element}.id = #{target.object_id}`\n end\n \n # Set attributes\n options.each do |name, value|\n case name\n when :prepend\n nil\n when :content\n `#{element}.appendChild(document.createTextNode(#{value}))`\n else\n `#{element}.setAttribute(#{name}, #{value})`\n end\n end\n\n element\n end", "def create(element, element_id=nil, &block)\n element = initialize_element(element, element_id)\n style_and_context(element, element_id, &block)\n\n element\n end", "def initialize_element\n end", "def element_add\r\n @env.issue.element_add @meta.element_add ElementAdd.new(@env).insert @is.element_add\r\n end", "def create_ng_element(xml_translation, document)\n element_name = xml_translation.fetch('element', nil)\n validate_present element_name, \"element key\"\n document.create_element(element_name)\n end", "def push_element\n return if @element_name.nil?\n\n # Add the class attribute if the element is a <p> element.\n @attrs[:class] = 'ppp' if :p == @element_name\n\n # Check @void_elements to determine how the element start would be\n # written. HTML includes void elements that are self closing so those\n # should be handled correctly.\n if VOID_ELEMENTS.include?(@element_name)\n @builder.void_element(@element_name, @attrs)\n else\n @builder.element(@element_name, @attrs)\n end\n # Reset the element name.\n @element_name = nil\n @attrs = {}\n end", "def test_element_creation\r\n xdoc = XmlDocument.new()\r\n products = xdoc.create_element('Products')\r\n xdoc.append_child(products)\r\n\r\n product1 = xdoc.create_element('Product')\r\n product2 = xdoc.create_element('Product')\r\n\r\n products.append_child(product1)\r\n products.append_child(product2)\r\n\r\n assert_equal xdoc.child_nodes.count, 1\r\n assert_equal xdoc.child_nodes[0].child_nodes.count, 2\r\n end", "def initialize_element(elem, element_id)\n if elem.is_a?(Class) && elem < TreeLayout\n layout = elem.new\n elem = layout.view\n elsif elem.is_a?(Class)\n elem = elem.new\n elsif elem.is_a?(TreeLayout)\n layout = elem\n elem = elem.view\n end\n\n if layout\n if element_id\n name_element(layout, element_id)\n end\n @child_layouts << layout\n elsif element_id\n name_element(elem, element_id)\n end\n\n return elem\n end", "def new_elem\n @type_name = params[:type]\n @name =eval(@type_name).to_p_name\n @parent_id = params[:parent_id]\n end", "def new_element\n # collect element data\n class_key = params[:classKey]\n element = keytechAPI.element_handler.new_element(class_key)\n\n # Layout holds all controls to fill\n layout = getLayout(class_key)\n errors = []\n layout.controls.each do |control|\n # Labels are the only control type a element can not use for data\n next unless control.controlType != 'LABEL'\n\n key = control.attributeName\n value = params[control.attributeName]\n\n unless control.isNullable\n if value.blank?\n errors.push \"Feld '#{control.displayname}' darf nicht leer sein. \"\n end\n end\n\n element.keyValueList[key] = value\n end\n\n unless errors.empty?\n logger.error \"Errors occured: #{errors.inspect}\"\n flash[:warning] = errors\n return redirect_back(fallback_location: root_path)\n end\n\n saved_element = keytechAPI.element_handler.save(element)\n # Save ok? If not create a warning and rebuild\n logger.info \"New element saved: #{saved_element.key}\"\n if saved_element.blank?\n logger.warn('Could not save element')\n flash[:warning] = 'Konnte Element nicht anlegen.'\n redirect_back(fallback_location: root_path)\n else\n flash[:info] = 'Element wurde angelegt.'\n redirect_to show_element_path(id: saved_element.key)\n end\n end", "def add_element(element, attrs=nil)\n self << new_element = XML::Node.new(element.to_s, self.document)\n new_element.add_attributes(attrs)\n return new_element\n end", "def new_element(element_id)\n e = [element_id]\n DATA_ELEMENTS.times do\n e.push -999 # Ignore\n end\n return e\n end", "def initialize_from_element!\n end", "def make_node(type, *args)\n elem = type.new self, *args\n @nodes << elem\n self.core_node ||= elem.id\n elem.expand\n elem\n end", "def add_elem(elem)\n # (native code) \n end", "def add_element(type,*args)\n # Case statement sorts elements by type\n # in order to align it to it's correct\n # class then add it to @elements array\n case type\n when ELEMENT\n # Element Argument Structure:\n # (type, x, y, width, height, colour, z, name)\n @elements << Element.new(*args)\n when IMAGE\n # Image Argument Structure:\n # (type, x, y, width, height, colour, z, name, file_path)\n @elements << Image.new(*args)\n when FONT\n # Element Argument Structure:\n # (type, x, y, z, size, colour, name, text)\n @elements << Font.new(*args)\n end\nend", "def add_elem(elem)\n # (native code)\n end", "def add_elem(elem)\n # (native code)\n end", "def add_elem(elem)\n # (native code)\n end", "def add_elem(elem)\n # (native code)\n end", "def add_elem(elem)\n # (native code)\n end", "def add_elem(elem)\n # (native code)\n end", "def element=(element); end", "def element(name, type, options = {})\n element = Element.new(name, type, options)\n attr_accessor element.method_name.intern unless @elements[name]\n @elements[name] = element\n end", "def <<(elem)\r\n self.add elem\r\n end", "def create_element(name, builder=nil, **options, &block)\n opts = {}\n\n if options[:is] ||= (options.dig(:attrs, :is))\n opts[:is] = options[:is]\n end\n\n if ns = options[:namespace]\n elem = `#@native.createElementNS(#{ns}, #{name}, #{opts.to_n})`\n else\n elem = `#@native.createElement(name, #{opts.to_n})`\n end\n\n if options[:classes]\n `#{elem}.className = #{Array(options[:classes]).join(\" \")}`\n end\n\n if options[:id]\n `#{elem}.id = #{options[:id]}`\n end\n\n if options[:attrs]\n options[:attrs].each do |k,v|\n next unless v\n `#{elem}.setAttribute(#{k}, #{v})`\n end\n end\n\n dom = DOM(elem)\n\n if block_given?\n dom.inner_dom(builder, &block)\n end\n\n if builder\n builder << dom\n end\n\n dom\n end", "def create_from_scratch(attributes)\n element = new_from_scratch(attributes)\n element.save if element\n return element\n end", "def create_from_scratch(attributes)\n element = new_from_scratch(attributes)\n element.save if element\n return element\n end", "def createElement(tagName)\n ret = Element.new(tagName)\n ret.ownerDocument = self\n ret\n end", "def <<(elemento)\n end", "def create_node(node, tag=nil)\n end", "def create\n @paste_from_clipboard = !params[:paste_from_clipboard].blank?\n @element = Alchemy::Element.new_from_scratch(params[:element])\n put_element_in_cell if @page.can_have_cells?\n @element.container = @page\n if @element.save\n render :action => :create\n else\n render_remote_errors(@element, 'form#new_element button.button')\n end\n end", "def factory(element_xml)\n OpenNebula::PoolElement.new(element_xml,client)\n end", "def push(element)\r\n # IMPLEMENTME!\r\n end", "def add(w)\n adopt(w, getElement())\n @children << w if @children\n end", "def add_element(name, attrs=nil)\n self.root = new_element = XML::Node.new(name, self)\n self.root.add_attributes(attrs) if attrs\n\n new_element\n end", "def add(element)\n @entries << element\n element.parent = self\n end", "def build_element(node, handler)\n obj = handler.proxy.new({}, node, handler)\n populate_element(obj, node)\n end", "def plus(elem)\n self.class.new(\"#{@name}[#{elem.name}]\", \"#{@id}:#{elem.options[:id] || elem.name}\")\n end", "def create_optional( element )\n return Util::ExpressionForms::Optional.new( element )\n end", "def add(element)\n @element_list << element\n end", "def method_missing(method, *args, &block)\n parts = method.to_s.match(/^([a-z]+[0-9]?)$/)\n if parts\n # Assume it's a new element, create the tag\n tag(parts[1], *args, &block)\n else\n # There really is no method...\n super\n end\n end", "def add_element(parent, key, value)\n elem = Nokogiri::XML::Node.new(key, @xml.document)\n elem.content = value\n\n parent.add_child(elem)\n end", "def create_element_content(element_id, data)\n create_content(Voog::API::Contents::ParentKind::Element, element_id, data)\n end", "def typed_add(element)\n if element.kind_of?(REXML::Element) && @@element_classes.has_key?(element.name)\n super(@@element_classes[element.name]::import(element))\n else\n super(element)\n end\n end", "def element=(_arg0); end", "def <<(element)\n if element.nil?\n pair = [0,NilClass]\n else\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n end\n index = @size\n @map[index] = @added.size\n @added << pair\n #@commands << [:append, pair]\n @size += 1\n end", "def add(el)\n raise NotImplementedError\n end", "def create_new(base_node)\n first(base_node,:create_new=>true)\n end", "def __element_object_initialize(h, val)\n obj = __element_object_get(h)\n\n val = { '__content' => val } unless val.respond_to?(:each)\n if h.single?\n obj.__initialize_with(val)\n else\n val.map { |v| obj.new(v) }\n end\n end", "def new_node\n\t\t\traise NotImplementedError.new('#new_node must be implemented')\n\t\tend", "def add(new_element)\n\n case new_element\n when DrawingGroup\n @drawingArray = (@drawingArray << new_element.drawingArray).flatten\n when Drawing\n @drawingArray << new_element\n else\n raise Argument \"New_element (#{@new_element}) is not a valid input\"\n end\n \n end", "def create_node(name, content = nil)\n return create_nodes(name) if content.nil? && name.is_a?(Hash) # Handle accidentally passing in a full hash\n \n element = self.class.elements.detect{|e| e.method_name.to_sym == name}\n raise Exceptions::InvalidElement.new(\"No known element named '#{name}'\") unless element || self.respond_to?(\"#{name}=\")\n \n case name\n when Hash then create_nodes(name)\n when Array then create_empty_nodes(name)\n else\n value = if content.nil?\n make_object?(element) ? element.type.new : ''\n elsif content.is_a?(Array) && (element && !element.options[:single])\n # If elements expects multiple instances, instantiate them all (e.g. StreetAddresses)\n # Note that this assumes the object (only known case is Trufina::Elements::StreetAddress) has a :name element\n out = content.collect do |local_content|\n make_object?(element) ? element.type.new(:name => local_content) : local_content\n end\n else\n make_object?(element) ? element.type.new(content) : content\n end\n \n self.send(\"#{name}=\", value)\n end\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements << el\n end", "def inner_dom= element\n clear\n append element\n end", "def push(element)\n # IMPLEMENT ME!\n end", "def create_from_scratch(element, essence_hash)\n essence_hash.stringify_keys!\n if content = build(element, essence_hash)\n content.create_essence!(essence_hash['essence_type'])\n end\n content\n end", "def create_from_scratch(element, essence_hash)\n essence_hash.stringify_keys!\n if content = build(element, essence_hash)\n content.create_essence!(essence_hash['essence_type'])\n end\n content\n end", "def __set_element(el, opts = {})\n unless el.is_a?(Nokogiri::XML::Element)\n el = Nokogiri::XML::Element.new(opts[:tag], @__node)\n @__node << el\n if opts[:namespace]\n el.namespace = el.namespace_scopes.find { |n| n.prefix == opts[:namespace] }\n end\n end\n h = __elements_handlers.for_xml_object(el)\n el.instance_variable_set(:@__handler, h)\n __initialize_elements_container(h) << h.from_xml_element(el)\n end", "def element(name, &continuation)\n Element.new(name, &continuation)\n end", "def << elem\n unless @element_type.nil? or elem.is_a?(@element_type)\n raise TypeError.new(\"Cannot add element of type #{elem.class}\")\n end\n self[@hash.call(elem)] = elem\n end", "def push(new_element)\n @collection.push(new_element)\n end", "def <<(element)\n @elements << element\n self\n end", "def create(param)\n\t\traise NotImplementedError\n\tend", "def from_xml_elem(ctx, root)\n #p [:from_xml_elem, :ctx, root]\n attributes = root.attributes.inject({ }) { |hash, (k, v)| hash[k] = EscapeXML.unescape(v.to_s); hash}\n text, children = root.children.partition{ |x| text_node?(x) }\n text = text.map{ |x| x.to_s}.reject{ |s| s =~ /^\\s*$/}.join('')\n element_name = root.name\n if element_name !~ /[A-Z]/\n element_name = Doodle::Utils.camel_case(element_name)\n end\n klass = Utils.const_lookup(element_name, ctx)\n #p [:creating_new, klass, text, attributes]\n #p [:root1, root]\n # don't pass in empty text - screws up when class has only\n # child elements (and no attributes) because tries to\n # instantiate child element from empty string \"\"\n if text == \"\"\n text = nil\n end\n args = [text, attributes].compact\n oroot = klass.new(*args) {\n #p [:in_block]\n from_xml_elem(root)\n }\n #p [:oroot, oroot]\n oroot\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements ||= []\n @elements << el\n end", "def create\n @element = Element.new(element_params)\n @element.save\n respond_with @element\n end", "def start_element(name, attrs = T.unsafe(nil)); end", "def start_element(name, attrs = T.unsafe(nil)); end", "def create_new_unit(xml_unit, new_version)\n unit_name = xml_unit.attribute('name')\n\n new_version.units.new(\n :name => unit_name\n )\n end", "def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end", "def element_factory(element_name)\r\n jssh_type = Element.new(element_name,self).element_type\r\n #puts \"jssh type is : #{jssh_type}\" # DEBUG\r\n candidate_class = jssh_type =~ /HTML(.*)Element/ ? $1 : ''\r\n #puts candidate_class # DEBUG\r\n if candidate_class == 'Input'\r\n $jssh_socket.send(\"#{element_name}.type;\\n\", 0)\r\n input_type = read_socket().downcase.strip\r\n puts input_type # DEBUG\r\n firewatir_class = input_class(input_type)\r\n else\r\n firewatir_class = jssh2firewatir(candidate_class)\r\n end\r\n \r\n #puts firewatir_class # DEBUG\r\n klass = Kernel.const_get(firewatir_class)\r\n\r\n if klass == Element\r\n klass.new(element_name,self)\r\n elsif klass == CheckBox\r\n klass.new(self,:jssh_name,element_name,[\"checkbox\"])\r\n elsif klass == Radio\r\n klass.new(self,:jssh_name,element_name,[\"radio\"])\r\n else\r\n klass.new(self,:jssh_name,element_name)\r\n end \r\n end", "def push(element); end", "def make_stub(opt)\n # Rails.logger.debug \"--> creating stub element for #{self.name}, arguments: #{opt.inspect}\"\n if opt.nil?\n raise CreationError, \"Tried to create document without opt parameter\"\n end\n root_tag_name = self.name.downcase\n doc = ActiveXML::Node.new(\"<#{root_tag_name}/>\")\n doc.set_attribute('name', opt[:name])\n doc.set_attribute('created', opt[:created_at]) if opt[:created_at]\n doc.set_attribute('updated', opt[:updated_at]) if opt[:updated_at]\n doc.add_element 'title'\n doc.add_element 'description'\n doc\n end", "def initialize(element)\n @element = element\n @name = element.name\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements ||= []\n @elements << el\n end", "def CreateApplicationElement(arg0, arg1)\n ret = _invoke(1610744102, [arg0, arg1], [VT_I4, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def initialize(elem)\n @element = elem\n end", "def new_from_element(element)\n OpenStruct.new.tap do |obj|\n obj.asin = element.at('ASIN').inner_text\n obj.url = element.at('DetailPageURL').inner_text\n obj.title = element.at(\"Title\").inner_text\n end\n end", "def create\n @element = RegisteredElement.new(registered_element_params)\n authorize @element\n begin\n @element.save!\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @element.errors.any? ? @element : e },\n status: :bad_request\n else\n toast!(title: \"Element created\",\n message: \"The element \\\"#{@element.name}\\\" has been created.\")\n render \"shared/reload\"\n end\n end", "def add_element (element, row_num, col_num)\n #puts \"adding element #{element} #{row_num} #{col_num}\"\n @rows[row_num].add element\n @columns[col_num].add element\n @blocks.block(row_num, col_num).add element\n end", "def element!(name, content = nil, attributes = nil)\n build! do\n if content or block_given?\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}>\"\n if block_given?\n value = yield\n content = value if !@_appended or value.kind_of? String\n end\n\n content = content.respond_to?(:empty?) && content.empty? ? '' : content.to_s\n\n @_crafted << Tools.escape(content) if content != \"\"\n @_crafted << \"</#{name}>\"\n else\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}/>\"\n end\n end\n end", "def inner_dom=(node)\n clear\n\n self << node\n end", "def create!(attributes = {})\n raise NotSupportedError\n end", "def create_insert()\n script = []\n attributes.each do |a|\n script << a.create_insert\n end\n children.each do |c|\n script << c.create_insert\n end\n \n InsertElement.new(XElement.new(self.name), script)\n end", "def element; end", "def element; end", "def element; end", "def element; end", "def new_node(*args)\n add_node(build_node(*args))\n end", "def create_line_item_button\n self.get_element(@browser, 'create')\n end", "def add_element(key, value = nil, &block)\n key_node = Niceogiri::XML::Node.new(key)\n @xml.add_child(key_node)\n if block\n block.call(key_node)\n else\n key_node.content = value if value\n end\n key_node\n end", "def prepare_attribute!(_element, _options)\n end", "def initialize(tagname_or_element, *a, &block)\n case tagname_or_element\n when Element\n @tagname = tagname_or_element.tagname_symbol\n @attrs = tagname_or_element.attrs\n @attrs.shared = true\n @attrs_hash = tagname_or_element.attrs_hash\n @hide_hid = tagname_or_element.hide_hid\n if block_given?\n init_body(&block)\n else\n @body = tagname_or_element.body.clone\n end\n when Symbol, String\n set_tag(tagname_or_element)\n @attrs = AttrArray.new\n @attrs_hash = {}\n @hide_hid = false\n if a.size() == 1 and a.kind_of?(AttrArray)\n @attrs = a\n @attrs.shared = true\n @attrs.each do |a|\n @attrs_hash[a.key_symbol] = a\n end\n else\n a.each { |aa| put_attr(aa) }\n end\n if block_given?\n init_body(&block)\n else\n @body = Null\n end\n end\n end" ]
[ "0.75434154", "0.71173775", "0.7096989", "0.68765473", "0.6745791", "0.6736986", "0.67275465", "0.6501975", "0.64983755", "0.6442474", "0.6370774", "0.63694227", "0.6364067", "0.6274943", "0.62178594", "0.62094265", "0.62063265", "0.61668473", "0.61467594", "0.6127663", "0.61129934", "0.6098209", "0.60801584", "0.60634303", "0.60634303", "0.60634303", "0.60634303", "0.60634303", "0.60634303", "0.60559845", "0.6050207", "0.6042054", "0.6037111", "0.60156554", "0.60156554", "0.6014652", "0.60074574", "0.59903234", "0.59361714", "0.59231406", "0.59005743", "0.5895797", "0.58925503", "0.5869672", "0.58653706", "0.58556944", "0.58531135", "0.5844243", "0.58356583", "0.5824083", "0.5822598", "0.5794383", "0.57891935", "0.5787728", "0.5777152", "0.57660025", "0.5760118", "0.575328", "0.57498485", "0.57446456", "0.57281476", "0.5726822", "0.57267946", "0.57191247", "0.57191247", "0.57168055", "0.57020384", "0.57010156", "0.5695884", "0.56764424", "0.5665122", "0.5648906", "0.56486416", "0.5646709", "0.5626147", "0.5626147", "0.5613209", "0.5612704", "0.560897", "0.5600517", "0.55949163", "0.5572617", "0.5568542", "0.55514556", "0.55494285", "0.5538058", "0.553415", "0.5525148", "0.5505483", "0.55032206", "0.55032", "0.5502656", "0.550255", "0.550255", "0.550255", "0.550255", "0.54980856", "0.5492804", "0.548702", "0.54843915", "0.54842347" ]
0.0
-1
Creates a new element on any method missing calls. Returns self, so you can chain calls (eg html.div('foo').span('bar') )
def method_missing(method, *args, &block) parts = method.to_s.match(/^([a-z]+[0-9]?)$/) if parts # Assume it's a new element, create the tag tag(parts[1], *args, &block) else # There really is no method... super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(method, *args, &block)\n super(method, *args) unless block_given?\n options, attrs, element = (args.detect { |arg| arg.is_a?(Hash) } || {}), {}, nil\n\n # handle methods separately if they match the pre-defined elements\n if ELEMENTS.include?(method.to_sym)\n attrs, element = options, method\n else \n attrs, element = { :class => method.to_s.downcase.gsub('_', options[:glue] || ' ') }, :div \n end\n \n wrapper(element, attrs, @template.capture(&block), block.binding)\n end", "def method_missing(meth, *args, &blk) \n if meth.to_s =~ /^(.*)!$/\n self << XML.new($1.to_sym, *args, &blk)\n else\n real_method_missing(meth, *args, &blk)\n end\n end", "def create_element(name, builder=nil, **options, &block)\n opts = {}\n\n if options[:is] ||= (options.dig(:attrs, :is))\n opts[:is] = options[:is]\n end\n\n if ns = options[:namespace]\n elem = `#@native.createElementNS(#{ns}, #{name}, #{opts.to_n})`\n else\n elem = `#@native.createElement(name, #{opts.to_n})`\n end\n\n if options[:classes]\n `#{elem}.className = #{Array(options[:classes]).join(\" \")}`\n end\n\n if options[:id]\n `#{elem}.id = #{options[:id]}`\n end\n\n if options[:attrs]\n options[:attrs].each do |k,v|\n next unless v\n `#{elem}.setAttribute(#{k}, #{v})`\n end\n end\n\n dom = DOM(elem)\n\n if block_given?\n dom.inner_dom(builder, &block)\n end\n\n if builder\n builder << dom\n end\n\n dom\n end", "def method_missing method, *args, &block\n # respond_to?(symbol, include_all=false)\n if dom.respond_to? method, true\n dom.send method, *args, &block\n else\n super\n end\n end", "def new\n @element = Element.new\n end", "def element_init\n extend TagMaker\n methods = \"\"\n # - -\n for element in %w[ A TT I B U STRIKE BIG SMALL SUB SUP EM STRONG\n DFN CODE SAMP KBD VAR CITE FONT ADDRESS DIV center MAP\n APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT table TITLE\n STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE\n CAPTION ]\n methods += <<-BEGIN + nn_element_def(element) + <<-END\n def #{element.downcase}(attributes = {})\n BEGIN\n end\n END\n end\n\n # - O EMPTY\n for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT\n ISINDEX META ]\n methods += <<-BEGIN + nOE_element_def(element) + <<-END\n def #{element.downcase}(attributes = {})\n BEGIN\n end\n END\n end\n\n # O O or - O\n for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr\n th td ]\n methods += <<-BEGIN + nO_element_def(element) + <<-END\n def #{element.downcase}(attributes = {})\n BEGIN\n end\n END\n end\n eval(methods)\n end", "def tag(tag, *args, &block)\n item = Html::Element.new(tag, *args)\n self << item\n if block\n @item_stack.push item\n block.call(item) \n @item_stack.pop\n end\n return self\n end", "def method_missing_with_wrapper(symbol, *args, &block)\n @element.respond_to?(symbol) ? @element.send(symbol, *args, &block) : method_missing_without_wrapper(symbol, *args, &block)\n end", "def method_missing(method, *args, &block)\n return super unless new.respond_to?(method)\n new.send(method, *args, &block)\n end", "def method_missing(method, *args, &block)\n return super unless new.respond_to?(method)\n new.send(method, *args, &block)\n end", "def method_missing(meth, *args, &block) # :nodoc:\n xpath = _xpath_for_element(meth.to_s, args.shift)\n return nil if xpath.empty?\n\n if block_given?\n xpath.each_with_index do |node, idx|\n @nodes.push(node)\n case block.arity\n when 1\n yield idx\n when 2\n yield self.class.new(node, @namespaces, false), idx\n else\n yield\n end\n @nodes.pop\n end\n self\n else\n node = xpath.first\n\n if node.xpath('text()').length == 1\n content = node.xpath('text()').first.content\n case meth.to_s\n when /\\?$/\n !! Regexp.new(/(t(rue)?|y(es)?|1)/i).match(content)\n else\n content\n end\n else\n self.class.new(node, @namespaces, false)\n end\n end\n end", "def factory_twiml_block(meth, *args)\n if meth =~ /twiml_appointments_/\n klass = meth.to_s.gsub(\"twiml_appointments_\", \"skej/twiml/appointments/\").classify\n else\n klass = meth.to_s.gsub(\"twiml_\", \"skej/twiml/\").classify\n end\n\n # Make the string representation a real Class object.\n klass = klass.constantize\n\n # Prepare view local variables\n data = { device: @device, session: @session, debug: generate_debug_formatted_message }\n if args.length > 0 and args[0].kind_of? Hash\n data.merge! args[0]\n end\n\n log \"twiml_view_factory -> #{klass.name.underscore}\"\n\n # Instantiate the new instance from the dynamic Klass\n # we generated earlier.\n instance = klass.new(data)\n\n # Return the TwiML view instance\n instance\n end", "def create_element(name, *contents_or_attrs, &block); end", "def method_missing(symbol, *args, &block)\n constructor = :element\n text = symbol.to_s\n\n if text =~ /!\\z/\n text.chop!\n constructor = :element!\n elsif text =~ /\\?\\z/\n text.chop!\n constructor = :anonymous\n end\n\n if text =~ /_$/ # alternate for clashes with existing methods\n text.chop!\n end\n\n if text =~ /_/\n # Single _ gets converted to : for XML name spaces\n # Double _ gets converted to single _\n text = text.gsub(/([^_])_([^_])/){|x| \"#{$1}:#{$2}\"}.gsub(/__/, '_')\n end\n\n if self != Jig::XML and self != Jig::XHTML\n namespace = name.split('::').last.downcase\n text = \"#{namespace}:#{text}\"\n end\n send(constructor, text, *args, &block)\n end", "def element(name, type, options = {})\n element = Element.new(name, type, options)\n attr_accessor element.method_name.intern unless @elements[name]\n @elements[name] = element\n end", "def method_missing(meth, *args, &block)\n if args.length == 0\n code = Block.new(meth.to_s , self )\n if block_given?\n add_block code\n code.instance_eval(&block)\n end\n return code\n else\n super\n end\n end", "def method_missing(method, *args, &block)\n return super unless builder\n\n builder.send(method, *args, &block)\n end", "def method_missing(method, *args, &block)\n return super unless builder\n\n builder.send(method, *args, &block)\n end", "def method_missing(name, *args, &block)\n super unless respond_to? name\n @builder = Builder.new(builder.tree) do\n __send__(name, *args, &block)\n end\n end", "def build\n nodes << element_klass.new\n\n yield(nodes.last) if block_given?\n\n nodes.last\n end", "def add_form_element(obj = nil, method = 'attribute', options = {}, html_options = {})\n type = options[:type] || 'text'\n type = nil unless %w(file text hidden textarea password select checkbox).include?(type)\n label = options[:label] || method.humanize.titleize\n\n description = options[:description]\n\n html_options[:class] = \"#{type} form_elem #{html_options[:class]}\"\n label_for = if html_options.key?(:id)\n html_options[:id]\n else\n \"#{obj}_#{method}\"\n end\n\n element = case type\n when 'text'\n text_field(obj, method, html_options)\n when 'hidden'\n hidden_field(obj, method, html_options)\n when 'textarea'\n text_area(obj, method, html_options)\n when 'password'\n password_field(obj, method, html_options)\n when 'select'\n select_options = options[:select_options]\n selected = options[:selected]\n include_blank = options[:include_blank]\n\n select(obj, method, select_options, { selected: selected, include_blank: include_blank }, html_options)\n when 'checkbox'\n if [true, 'true', 1, '1'].include?(html_options[:value])\n html_options[:checked] = 'checked'\n else\n ''\n end\n check_box(obj, method, html_options)\n when 'file'\n file_field(obj, method, html_options)\n else\n ''\n end\n\n case type\n when 'hidden'\n element\n else\n <<-EOS.html_safe\n<div class=\"group clearfix\">\n <div class=\"row\">\n <div class=\"column grid2of5\">\n <div class=\"spacer\">\n <label for=\"#{label_for}\">#{label}<span>#{description}</span></label>\n </div>\n </div>\n\n <div class=\"column grid3of5\">\n <div class=\"#{'boxed ' unless type == 'checkbox'}spacer\">\n #{element}\n </div>\n </div>\n </div>\n</div>\n EOS\n end\n end", "def push_element\n return if @element_name.nil?\n\n # Add the class attribute if the element is a <p> element.\n @attrs[:class] = 'ppp' if :p == @element_name\n\n # Check @void_elements to determine how the element start would be\n # written. HTML includes void elements that are self closing so those\n # should be handled correctly.\n if VOID_ELEMENTS.include?(@element_name)\n @builder.void_element(@element_name, @attrs)\n else\n @builder.element(@element_name, @attrs)\n end\n # Reset the element name.\n @element_name = nil\n @attrs = {}\n end", "def factory_method_for(tag); end", "def initialize(element)\n set_methods_from_attributes(element)\n set_method_from_text(element)\n update_class_list_variable(element)\n end", "def element(name, &continuation)\n Element.new(name, &continuation)\n end", "def self_new\n raise \"Not implemented.\"\n end", "def method_missing(method, *arguments, &block)\n if xhtml_block?(method, arguments)\n @xml.__send__(method, *arguments) do\n @xml.div(xmlns: \"http://www.w3.org/1999/xhtml\") do |xhtml|\n block.call(xhtml)\n end\n end\n else\n @xml.__send__(method, *arguments, &block)\n end\n end", "def new_block_el(*args); end", "def no_extensions\n self.class.base_edge_wrapper.new graph, element\n end", "def method_missing(*args, &block)\n Markaby::Builder.new({}, self).capture {send(*args, &block)}\n end", "def initialize(tagname_or_element, *a, &block)\n case tagname_or_element\n when Element\n @tagname = tagname_or_element.tagname_symbol\n @attrs = tagname_or_element.attrs\n @attrs.shared = true\n @attrs_hash = tagname_or_element.attrs_hash\n @hide_hid = tagname_or_element.hide_hid\n if block_given?\n init_body(&block)\n else\n @body = tagname_or_element.body.clone\n end\n when Symbol, String\n set_tag(tagname_or_element)\n @attrs = AttrArray.new\n @attrs_hash = {}\n @hide_hid = false\n if a.size() == 1 and a.kind_of?(AttrArray)\n @attrs = a\n @attrs.shared = true\n @attrs.each do |a|\n @attrs_hash[a.key_symbol] = a\n end\n else\n a.each { |aa| put_attr(aa) }\n end\n if block_given?\n init_body(&block)\n else\n @body = Null\n end\n end\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements << el\n end", "def tmp\n [:h2, :ul, :li].each do |m|\n define_singleton_method m do |text|\n if block_given?\n yield self.instance_eval(&block)\n end\n\n \"<#{m}>#{text}</#{m}>\"\n end\n end\n yield self.instance_eval(&block) if block_given?\nend", "def method_missing(meth, *args, &block)\n # Check to see if it can be evaluated\n if(matches? meth)\n #Defines the method and caches it to the class\n self.class.send(:define_method, meth) do\n if element_id_exists_method?(meth)\n if respond_to?(meth.to_s.chop)\n begin\n send meth.to_s.chop\n rescue Selenium::WebDriver::Error::NoSuchElementError => e\n return false\n end\n return true\n end\n elsif wait_method?(meth)\n send :wait_for, meth.to_s.sub('wait_for_','').to_sym\n elsif navigate_method?(meth)\n send :navigate_to, instance_variable_get(\"@#{meth.to_s.sub('navigate_to_','')}\")\n elsif element_id_method?(meth)\n @driver.find_element(:id, meth)\n end\n end\n # calls the method\n send meth, *args, &block\n else\n super\n end\n end", "def method_missing(method_name, *args)\r\n get_or_create_node(method_name.to_s, true)\r\n end", "def method_missing(meth, *args)\n if @elements[@root].respond_to? meth\n @elements[@root].send meth, *args\n else\n super\n end\n end", "def method_missing(method, *args, &block)\n if RUBY_ENGINE == 'opal' && node.respond_to?(method, true)\n n = node.send(method, *args, &block)\n elsif RUBY_ENGINE != 'opal'\n if node.is_a?(Oga::XML::NodeSet) && node.first.respond_to?(method, true)\n n = node.first.send(method, *args, &block)\n elsif node.respond_to?(method, true)\n n = node.send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n\n if RUBY_ENGINE == 'opal'\n n.is_a?(Element) ? Instance.new(n, cache, scope) : n\n else\n n.class.name['Oga::'] ? Instance.new(n, cache, scope) : n\n end\n end", "def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end", "def method_missing method_sym, *args\n if wd_element.respond_to?(method_sym)\n wd_element.send(method_sym, *args)\n else\n raise NoMethodError, \"No such method #{method_sym} for #{self.class}\"\n end\n end", "def method_missing(method, *args, &block)\n # Check to see if it can be evaluated\n if(matches?(method))\n #Defines the method and caches it to the class\n self.class.send(:define_method, method) do\n if element_id_exists_method?(method)\n if respond_to?(method.to_s.chop)\n begin\n send method.to_s.chop\n rescue Selenium::WebDriver::Error::NoSuchElementError => e\n return false\n end\n return true\n end\n elsif wait_method?(method)\n send :wait_for, method.to_s.sub('wait_for_','').to_sym\n elsif navigate_method?(method)\n send :navigate_to, instance_variable_get(\"@#{method.to_s.sub('navigate_to_','')}\")\n elsif element_id_method?(method)\n find(:xpath, \"//*[@id='#{method.to_s}']\")\n end\n end\n # calls the method\n send(method, *args, &block)\n else\n super\n end\n end", "def really_new\n return self.new\n end", "def create!(*)\n unavailable_method\n end", "def not_a_member_hops\n $tracer.trace(__method__)\n #unit_test_no_generate: not_a_member_hops, a.className(create_ats_regex_string(\"ats-nonmember\"))\n return ToolTag.new(a.className(create_ats_regex_string(\"ats-nonmember\")), __method__, self)\n end", "def hops_not_member_panel\n $tracer.trace(__method__)\n return ToolTag.new(div.id(\"/notmember/\"), __method__, self)\n end", "def with!( &blk )\n self.instance_eval &blk\n self\n end", "def new\n @element = @@model.new()\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements ||= []\n @elements << el\n end", "def <<(sym)\n `c$Element.prototype.m$add_class.call(#{@element},sym)`\n return self\n end", "def create(*)\n unavailable_method\n end", "def create(*)\n unavailable_method\n end", "def create(*)\n unavailable_method\n end", "def create(*)\n unavailable_method\n end", "def create(*)\n unavailable_method\n end", "def build_markup\n Object.const_get(output_class).new\n end", "def to_html(*)\n self\n end", "def from_xml_elem(ctx, root)\n #p [:from_xml_elem, :ctx, root]\n attributes = root.attributes.inject({ }) { |hash, (k, v)| hash[k] = EscapeXML.unescape(v.to_s); hash}\n text, children = root.children.partition{ |x| text_node?(x) }\n text = text.map{ |x| x.to_s}.reject{ |s| s =~ /^\\s*$/}.join('')\n element_name = root.name\n if element_name !~ /[A-Z]/\n element_name = Doodle::Utils.camel_case(element_name)\n end\n klass = Utils.const_lookup(element_name, ctx)\n #p [:creating_new, klass, text, attributes]\n #p [:root1, root]\n # don't pass in empty text - screws up when class has only\n # child elements (and no attributes) because tries to\n # instantiate child element from empty string \"\"\n if text == \"\"\n text = nil\n end\n args = [text, attributes].compact\n oroot = klass.new(*args) {\n #p [:in_block]\n from_xml_elem(root)\n }\n #p [:oroot, oroot]\n oroot\n end", "def method_missing method, *params, &block\n __tag_and_raise__ NoMethodError.new(method) if ProhibitedNames.include?(method)\n\n case\n # assignment in conditionals is usually a bad smell, here it helps minimize regex matching\n when (name = method[/^\\w+$/, 0]) && params.length == 0\n # the call is an attribute reader\n\n return self.class.new.freeze if frozen? and not @hash.has_key?(method)\n self.class.send :__define_attribute__, name\n\n return send(method) if @hash.has_key? method\n\n # close the scope for storing call chain\n parent = self\n nested_blobject = self.class.new\n\n store_in_parent = lambda do\n parent.send \"#{name}=\", nested_blobject\n nested_blobject.send :remove_instance_variable, :@store_in_parent\n end\n\n nested_blobject.instance_variable_set :@store_in_parent, store_in_parent\n\n return nested_blobject\n\n when (name = method[/^(\\w+)=$/, 1]) && params.length == 1\n # the call is an attribute writer\n\n self.class.send :__define_attribute__, name\n return send method, params.first\n\n when (name = method[/^(\\w+)\\?$/, 1]) && params.length == 0\n # the call is an attribute checker\n\n self.class.send :__define_attribute__, name\n return send method\n end\n\n super\n end", "def new(*args, &block)\n\t\tif $Auto_wrapper then\n\t\treturn $Auto_wrapper.wrap(auto_wrapper_old_new(*args, &block))\n\t\telse\n\t\treturn auto_wrapper_old_new(*args, &block)\n\t\tend\n\tend", "def render_with(method, template, data = {})\n renderer = new(template, data)\n yield renderer if block_given?\n renderer.send(method.to_sym)\n end", "def element(opts={})\n el = Element.new(opts)\n yield(el) if block_given?\n @elements ||= []\n @elements << el\n end", "def method_missing(sym, *args, &blk)\n if [:<<, :push, :+, :-, :concat].include?(sym)\n args = href_from_items(*args)\n end\n\n result = @new.send(sym, *args, &blk)\n @new = sanitize(@new)\n result\n end", "def new\n AwesomeObject.new(self)\n end", "def new\n AwesomeObject.new(self)\n end", "def method_missing(sym, *args, &block)\n cache_method_call(sym) if ::Builder::XmlBase.cache_method_calls\n tag!(sym, *args, &block)\n end", "def element(*args, &block)\n __element__(*args, &block)\n end", "def element(*args, &block)\n __element__(*args, &block)\n end", "def define_elements!\n element_names.each do |name, selector|\n metaclass.class_eval(<<-END, __FILE__, __LINE__)\n def #{name}(*filters, &block)\n make_element_set(#{name.inspect}, #{selector.inspect}, *filters, &block)\n end\n END\n end\n end", "def op_helper_simple(tagname, tagclass, to_add)\n @content << %(<#{tagname} class=\"#{tagclass}\">) << to_add << %(</#{tagname}>)\n end", "def initialize element, class_chain, blocks\n @element = element.dup\n # TODO: how to convert lists, tables, definition lists etc. to text\n @text = element.text\n @parent = element.parent.name\n @path = element.path\n @wrapper = BLOCK_ELEMENTS.include?(element.name) ? \\\n element.name : parent\n @class_chain = class_chain\n @blocks = blocks\n end", "def +@\n return self\n end", "def +@\n return self\n end", "def initialize(*)\n super\n if as != :button_to\n extend NfgUi::Components::Utilities::Methodable\n end\n end", "def method_missing(method_name, *args)\n\t \tif public_instance_methods.include? method_name\n\t \t\tnew.send(method_name, *args)\n\t \telse\n\t \t\tsuper\n\t \tend\n\t end", "def initialize_from_element!\n end", "def method_builder; end", "def initialize(element)\n @html_string = element\n element = valid_tag(element) unless element.is_a? Array\n case element[0]\n when :start_element\n @name = element[2]\n @attributes = element[3]\n @children = (Array(element[4..-1]) || []).map {|c | TestTag.new c}\n when :text\n @text = element[1]\n @name = \"text\"\n @attributes = []\n @children = []\n end\n\n end", "def createElement(tagName)\n ret = Element.new(tagName)\n ret.ownerDocument = self\n ret\n end", "def build_element(node, handler)\n obj = handler.proxy.new({}, node, handler)\n populate_element(obj, node)\n end", "def create_method(name, &block)\n eigen = class << self; self; end\n eigen.send(:define_method, name, &block)\n end", "def build_tags(method, options)\n options[:class] ||= \"\"\n options[:label] ||= method.to_s.humanize\n options[:label] << \" *\" if options[:required]\n content = setup_label_for(method, options[:label]) \n content = add_hint_to(options[:hint],content)\n return content\n end", "def of method, *args, &block\n @current = natural method, *args, &block\n @callings.unshift @current\n self\n end", "def method_missing(method_name, *args) self end", "def method_missing(method_name, *args) self end", "def element(tag='div', *args)\n attrs = args.last.respond_to?(:fetch) && args.pop || nil\n args.push(lambda(&Proc.new)) if block_given?\n args.push GAP if args.empty?\n _element(tag).plug(ATTRS => attrs, GAP => args)\n end", "def element!(name, content = nil, attributes = nil)\n build! do\n if content or block_given?\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}>\"\n if block_given?\n value = yield\n content = value if !@_appended or value.kind_of? String\n end\n\n content = content.respond_to?(:empty?) && content.empty? ? '' : content.to_s\n\n @_crafted << Tools.escape(content) if content != \"\"\n @_crafted << \"</#{name}>\"\n else\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}/>\"\n end\n end\n end", "def html_class(*args)\n (@html_class ||= HTMLClass.new) << args\n end", "def create\n unavailable_method\n end", "def create(*)\n unavailable_method\n end", "def method_missing(method, *args, &block) \n return super unless part(method)\n part(method).render\n end", "def new(*args)\n raise NoMethodError.new(\"You can not instaniate this class!\")\n end", "def new_node(element)\n Node.new(element)\n end", "def call\n raise NoMethodError\n end", "def create_element(target, type, parent, options = {})\n # Create element\n element = `document.createElement(#{type})`\n\n # Add element to DOM\n if options[:prepend]\n `#{parent.element}.insertBefore(#{element}, #{options[:prepend].element})`\n else\n `#{parent.element}.appendChild(#{element})`\n end\n\n # Add ruby class to the node\n `#{element}.classList.add(#{dasherize(target.class.name)})`\n\n # Add ruby superclass to the node to allow for more generic styling\n if target.class.superclass != BaseElement\n `#{element}.classList.add(#{dasherize(target.class.superclass.name)})`\n end\n\n # Set ruby object_id as default element id\n if !options.has_key?(:id)\n `#{element}.id = #{target.object_id}`\n end\n \n # Set attributes\n options.each do |name, value|\n case name\n when :prepend\n nil\n when :content\n `#{element}.appendChild(document.createTextNode(#{value}))`\n else\n `#{element}.setAttribute(#{name}, #{value})`\n end\n end\n\n element\n end", "def constructor(new_fn = nil, **options, &block)\n next_fn = Function[new_fn || block]\n\n if next_fn.wrapper?\n self.class.wrapper_type.new(with(**options), fn: next_fn)\n else\n with(**options, fn: fn >> next_fn)\n end\n end", "def method_missing(method, *args, &block)\n @view.send(method, @selector, *args, &block)\n self\n end", "def initialize(*opts)\n\t\tself.elements = [ ]\n\t\tself.add_element(*opts)\n\tend", "def initialize(object_name, method_name, template, options = {}, html_options = {}) #:nodoc:\n options = { :object_name => object_name, :method_name => method_name }.merge(options)\n \n @template, @options, @html_options = template, options.dup, html_options.dup\n @engine = (@options.delete(:engine) || \"google\")\n @object = (@options.delete(:object) || @template.instance_variable_get(\"@#{object_name}\"))\n @html_options[:id] ||= id\n end", "def new\n self\n end", "def internal_create_override(method_name, mode=:instance, &block)\n builder = ExpectationBuilder.new method_name\n block.call builder unless block.nil?\n exp = builder.build\n exp.events = events[mode] \n expectations.add_expectation exp, mode\n exp\n end", "def create_optional( element )\n return Util::ExpressionForms::Optional.new( element )\n end" ]
[ "0.6483127", "0.63952464", "0.5681417", "0.564917", "0.56264347", "0.560671", "0.5602902", "0.54857296", "0.54509574", "0.54509574", "0.53960353", "0.53789043", "0.5373109", "0.5336202", "0.5317931", "0.5313115", "0.5299496", "0.5299496", "0.5297895", "0.52955025", "0.5293478", "0.52760786", "0.5247495", "0.52408594", "0.5240237", "0.5191879", "0.5187551", "0.518013", "0.514843", "0.5134316", "0.5128479", "0.5127098", "0.51180625", "0.51111203", "0.51107603", "0.5103783", "0.5085569", "0.5082191", "0.50663567", "0.50645345", "0.50567925", "0.50551564", "0.5046599", "0.50435597", "0.50279415", "0.5026629", "0.5025147", "0.50203705", "0.50187004", "0.50173616", "0.50173616", "0.50173616", "0.50173616", "0.5005111", "0.5001261", "0.4985149", "0.4975654", "0.49738735", "0.49713054", "0.4967202", "0.49589363", "0.49565828", "0.49565828", "0.4949415", "0.49392873", "0.49392873", "0.49343407", "0.49334756", "0.4929736", "0.49062955", "0.49062955", "0.48855022", "0.4883061", "0.48807183", "0.4878133", "0.48724994", "0.4872221", "0.48637834", "0.48617306", "0.485988", "0.4854445", "0.48511365", "0.48511365", "0.4846672", "0.4843125", "0.48392943", "0.48369813", "0.48331925", "0.48297086", "0.48274037", "0.4818028", "0.48140702", "0.48041445", "0.48036084", "0.47992444", "0.4794203", "0.47797745", "0.47729933", "0.47448206", "0.47441104" ]
0.65207535
0
Make sure our objects advertise their support of tags
def respond_to_missing?(method, include_private) parts = method.to_s.match(/^([a-z]+[0-9]?)$/) if parts true else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tagged?; end", "def allowed_tags; end", "def allowed_tags; end", "def register_transitive_tags(object); end", "def research_acts_as_taggable\n research_acts_as_taggable_on :tags\n end", "def allowed_tags=(_arg0); end", "def allowed_tags=(_arg0); end", "def add_tags\n raise NotImplementedError\n end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def supported_tags\n [\n # attributes\n\n # simple tags\n :attack_class, :attack_score, :attack_type, :attack_value, :capec,\n :cwe_id, :description, :dissa_asc, :normalized_url, :oval, :owasp2007,\n :owasp2010, :owasp2013, :recommendation, :vuln_method, :vuln_param,\n :vuln_type, :vuln_url, :web_site\n # nested tags\n ]\nend", "def eligible_tagtypes\n [ :Untyped, :Source, :Author, :CulinaryTerm ]\n end", "def strict_tag_requirements\n true\n end", "def tags\n send_tags('tags', @handle, @security)\n end", "def available_tags\n available_tags = []\n Tag.all.each do |t|\n available_tags << t.name\n end\n\n tags = []\n self.tags.each do |t|\n tags << t.name\n end\n\n available_tags - tags\n end", "def complete_tags\n\n end", "def collect_tags_indeed(text_to_scan, offer_object)\n puts \"Mining tags from posting\"\n tags = Tag.all.map(&:name)\n tags.each do |tag|\n offer_object[:tags] << tag if text_to_scan.include?(tag)\n end\n end", "def tags\n ['any'] + @tags\n end", "def tags\n ['any'] + @tags\n end", "def sanitized_allowed_tags=(tags); end", "def sanitized_allowed_tags=(tags); end", "def tags!\n @tags = nil\n tags\n end", "def test_tags\n ogg = dummy()\n\n expected_tags = %w{GENRE UNICODETAG}.to_set\n assert_equal expected_tags, ogg.tags.to_set\n end", "def _tagging\n t_tagging[:tag_id].in(self.tags) unless self.tags.length == 0\n end", "def correct_tags?\n missing_tags?\n unwanted_tags?\n duplicate_tags?\n end", "def tags() []; end", "def tags() ; info[:tags] ; end", "def tags() ; info[:tags] ; end", "def create_tags\n\tend", "def register_tags(*additional_tags); end", "def unwanted_tags?\n unwanted_tags = info.tags.keys - required_tags - [:encoder]\n return true if unwanted_tags.empty? || unwanted_tags == [:tyer]\n\n raise Aur::Exception::LintUnwantedTags, unwanted_tags.join(', ')\n end", "def research_acts_as_ordered_taggable\n research_acts_as_ordered_taggable_on :tags\n end", "def find_tags\n @find_tags = true\n end", "def has_tag?(name); end", "def has_tag?(tag)\n self.tags.include?(tag)\n end", "def handle_adding_tag(tag, tags)\n if tags.include?(tag)\n puts \"Warning: duplicate tag #{tag} detected\"\n else\n tags.push(tag)\n end\n return tags\n end", "def handle_adding_tag(tag, tags)\n if tags.include?(tag)\n puts \"Warning: duplicate tag #{tag} detected\"\n else\n tags.push(tag)\n end\n return tags\n end", "def tagged?(tag)\n @tags.include?(tag)\n end", "def tagging_tags\n filtered_tags(:tagtype_x => [11, :Collection, :List])\n end", "def taggable?\n description['taggable'] == true\n end", "def transitive_tags; end", "def tags\n @tags ||= tags_from_collection.merge(tags_from_item).values.select(&:release)\n end", "def set_tags(given_tags = {})\n @tags.merge!(given_tags)\n end", "def tag(*tags)\n attribute 'tags' do |existing_tags|\n existing_tags ||= []\n tags.each do |tag|\n if !existing_tags.include?(tag.to_s)\n existing_tags << tag.to_s\n end\n end\n existing_tags\n end\n end", "def validate_tag_rules\n # Check for aliases and implications from the same tag\n dupe = @tag_implications.keys.find { |k| @tag_aliases.key? k }\n if dupe\n fail_with \"Tag \\\"#{dupe}\\\" is both aliased and implied from. \"\\\n \"Imply from the alias instead.\"\n end\n\n error_for_aliases_that_should_be_implications\n\n # Check for loooops.\n starter_tags = Tag[@tag_implications.keys].to_set.merge Tag[@tag_aliases.keys].to_set\n update_tags(starter_tags, verbose: true)\n end", "def tags(name = T.unsafe(nil)); end", "def has_tag?(t)\n tags.include?(t)\n end", "def is_tagged?\n ! @tags.empty?\n end", "def create_tags(tags)\n tags.each do |tag_name|\n self.tags.create!(name: tag_name.downcase) unless self.tags.find_by(name: tag_name.downcase)\n end\n end", "def tag(tag); end", "def tag(tag); end", "def supported_tags\n [\n # attributes\n :nexpose_id, :title, :severity, :pci_severity, :cvss_score, :cvss_vector,\n :published, :added, :modified,\n\n # simple tags\n :description, :solution,\n\n # multiple tags\n :references, :tags\n ]\n end", "def has_tag?(value)\r\n @tags.include?(value)\r\n end", "def tagged\n taggings.collect(&:taggable)\n end", "def research_acts_as_taggable_on(*tag_types)\n research_taggable_on(false, tag_types)\n end", "def required_tags=(required_tags)\n assert_unloaded\n @required_tags = names_to_tags(required_tags)\n end", "def is_tagged?\n ! @tags.empty?\n end", "def has_tags?\n tags.is_a?(Hash) ? false : true\n end", "def tag(*tags)\n tags.each { |tag| @tags << tag }\n end", "def tags_to_add\n local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }\n end", "def add_tags(*new_tags)\n raise TypeError, \"Must set agent= before using tag manager\" unless @agent\n @agent.update_tags(new_tags, [])\n true\n end", "def tag(name); end", "def specifies?(tag)\n include?(tag)\n end", "def test_should_associate_tags\n # Load some products and see if they really don't have any tags.\n a_stuff = items(:the_stuff)\n assert_equal a_stuff.tags.count, 0\n # Load some tags and see if they really don't have any products.\n weird_tag = tags(:weird)\n weird_counter = weird_tag.products.count\n # Associate one with the other and both must know about that.\n a_stuff.tags << weird_tag\n assert_equal a_stuff.tags.count, 1\n assert_equal weird_tag.products.count, weird_counter + 1\n\n # Break the association.\n a_stuff.tags.delete(weird_tag)\n assert_equal a_stuff.tags.count, 0\n assert_equal weird_tag.products.count, weird_counter\n end", "def tag(*tags)\n tags.each {|t| @tags << t}\n @tags.uniq!\n end", "def tag; end", "def tag; end", "def access_tags\n tags = []\n tags << 'admin' if admin?\n tags << 'speaker' if speaker?\n tags << 'staff' if staff?\n tags\n end", "def has_tag?(tag)\n tags.include?(tag.to_s)\n end", "def add_tags tags\n aux_errors = []\n tags = tags.split(\",\") if tags.instance_of? String\n tags = tags.map{|tag| tag.strip }\n tags.each do |tag_name|\n # find a tag if exists\n tag = Tag.where(:name => tag_name).first\n\n if tag.nil?\n if Tag.creatable_by? current_user\n t = Tag.new :name => tag_name, :creator => current_user\n aux_errors.push \"Tag #{tag_name} could not be saved\" unless t.save\n else\n aux_errors.push \"You don't have permission to create tag #{tag_name}\"\n end\n else\n self.tags << tag\n end\n end\n aux_errors\n end", "def tags\n @tags ||= tag_class.in_challenge(collection).group(:id)\n end", "def requested_tags\n @requested_tags ||= []\n end", "def supported_tags\n [\n # attributes\n :name,\n\n # simple tags\n\n # multiple tags\n :fingerprints, :configurations, :tests\n ]\n end", "def exact_tag?(entity, tags)\n\treturn (entity.has? :tag )&&( in_arr?(tags, entity.tag, true))\nend", "def tag_with(tag_names)\n _tags = []\n Tag.parse(tag_names).each do |tag_name|\n _tags << Tag.find_or_create_by_name(tag_name.downcase)\n end\n self.tags = _tags.uniq\n end", "def add_tags\n self.tag_list = 'bug, feature, improvement, feedback, discussion, help'\n end", "def purge_unused_tags!\n unused_tags.each do |tag|\n logger.info(\"Purging tag '#{tag}'\")\n entries_with(label: tag).each do |entry|\n payload = Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(entry.tag_id), label: '')\n context.send_message(target: Target.new(site_id: entry.site_id),\n payload: payload,\n acknowledge: true)\n end\n end\n Timeout.timeout(5) do\n while !unused_tags.empty?\n sleep 0.1\n end\n end\n end", "def robotags\n object.tags User.super_id\n end", "def tags\n @tags ||= []\n end", "def retrieve_tags\n # noop\n end", "def test_tags_from_metadata(metadata)\n sanitize_tags(metadata[:tags])\n end", "def tags\n @tags ||= []\n end", "def tags(*tags)\n @_tags = tags unless tags.empty?\n @_tags\n end", "def tag(*tags)\n p tags\n tags.each do |tag|\n tag << self\n @tags << tag\n end\n end", "def tag(*tags)\n p tags\n tags.each do |tag|\n tag << self\n @tags << tag\n end\n end", "def tags=(_arg0); end", "def private_tags\n ActsAsTaggableOn::Tag.not_in(public_ids).inject(@tags) do |private_tags, tag|\n\n private_tags[self.class.key(tag.name)] = meta(tag.name, tag.slug, false)\n\n private_tags\n end\n end", "def prepare_tags()\n\t$currentCase.create_tag(OCR_MUST)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_500KB)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_1MB)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_5MB)\n\t$currentCase.create_tag(OCR_AVG_WORDS_01_20)\n\t$currentCase.create_tag(OCR_AVG_WORDS_21_40)\n\t$currentCase.create_tag(OCR_AVG_WORDS_41_60)\n\t$currentCase.create_tag(OCR_AVG_WORDS_61_80)\n\t$currentCase.create_tag(OCR_AVG_WORDS_81_100)\n\t$currentCase.create_tag(OCR_AVG_WORDS_101)\nend", "def test_has_tag\n ogg = dummy()\n\n assert ogg.has_tag?(\"GENRE\")\n assert !ogg.has_tag?(\"UNKNOWN\")\n end", "def tags\n\t\t@tags = @identities = Identity.sorted_alphabetic.decorate\n\tend", "def add_tags\n if @tags.nil?\n @tags = IFFID3.new\n else\n raise AIFFError, 'an ID3 tag already exists'\n end\n end", "def not_found\n super('Tags not found.')\n end", "def determine_applicable_tags(additional_tags, method, *tags)\n use_tags = @@tags.merge(additional_tags)\n if method == :disable\n # if method is set to :disable blacklist (remove) the supplied tags\n tags.each { |t| use_tags.delete(t) }\n else\n # only use the supplied tags (whitelist) if method is not :disable\n new_use_tags = {}\n tags.each { |t| new_use_tags[t] = use_tags[t] if use_tags.key?(t) }\n use_tags = new_use_tags\n end\n use_tags\n end", "def tags\n if new?\n @fake_tags || []\n else\n @tags ||= tags_dataset.all\n end\n end", "def tags\n normal[:tags] = Array(normal[:tags])\n normal[:tags]\n end", "def see_tag(text); end", "def tag\n raise NotImplementedError\n end", "def tag\n raise NotImplementedError\n end" ]
[ "0.6868584", "0.677748", "0.677748", "0.667371", "0.66311777", "0.6584921", "0.6584921", "0.65792376", "0.65394396", "0.65394396", "0.65394396", "0.65394396", "0.65394396", "0.64252406", "0.63591045", "0.63555723", "0.63349926", "0.6334745", "0.63187134", "0.63146937", "0.62946945", "0.62946945", "0.62275255", "0.62275255", "0.6158742", "0.6157088", "0.6146237", "0.6135056", "0.6134228", "0.61226577", "0.61226577", "0.61103", "0.6104286", "0.6075005", "0.60695165", "0.60669225", "0.6063114", "0.60364246", "0.60285145", "0.60285145", "0.6025634", "0.60182244", "0.6016843", "0.60104847", "0.59987885", "0.5988159", "0.59858555", "0.59749055", "0.59540147", "0.5952921", "0.5937437", "0.59183085", "0.5909", "0.5909", "0.5901157", "0.5886597", "0.58849734", "0.5881729", "0.5879606", "0.58790135", "0.5864958", "0.58634436", "0.58568454", "0.58545697", "0.58535683", "0.58535016", "0.5848692", "0.5838022", "0.5838013", "0.5838013", "0.58249557", "0.5819148", "0.5804488", "0.57940364", "0.5789631", "0.5788445", "0.5787052", "0.57747746", "0.5768607", "0.5767767", "0.57600844", "0.57581544", "0.57508194", "0.5740566", "0.57403034", "0.57378334", "0.5731426", "0.5731426", "0.5727771", "0.57254875", "0.57228255", "0.57205707", "0.57198834", "0.57192254", "0.5716025", "0.57105863", "0.5708421", "0.5695249", "0.56825227", "0.5681435", "0.5681435" ]
0.0
-1
Renders out as html accepts depth param to indicate level of indentation
def render(depth = 0, inblock = true) # Convert elements to strings @items.collect do |item| if item.is_a?(String) if inblock inblock = false ' '*depth + item else item end elsif item.nil? '' else item.render(depth,inblock) end end.join('') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(params={})\n level = params[:level] || 0\n indent = params[:indent] || 2\n indent_str = \" \" * indent * level\n output = \"\"\n if @comments.length > 0\n output << \"\\n\" + indent_str\n join_str = \"\\n\" + indent_str\n output << \"<!-- \" + @comments.join(join_str) + \" --!>\\n\\n\"\n end\n output << indent_str\n opening_tag = \"<#{@name}\"\n @attrs.each_pair do |k, v|\n opening_tag << \" #{k}=\\\"#{v}\\\" \"\n end\n opening_tag << \"/\" unless @value || @children.length > 0\n opening_tag << \">\"\n output << opening_tag\n if @value\n output << \"\\n\" + \" \" * indent * (level + 1) + @value\n elsif @children.length > 0\n @children.each do |child|\n output << \"\\n\" + child.render(:level => level + 1, :indent => indent)\n end\n end\n output << \"\\n\" + indent_str + \"</#{@name}>\" if @value || @children.length > 0\n output\n end", "def html(args)\n str = \"\"\n str << (@inden * level(args)) if pretty?(args)\n str << html_content\n str << @nl if pretty?(args)\n str\n end", "def render(params={})\n @root_tag.render :indent => params[:indent] || 2\n end", "def to_html\n # output the segments, but adjust the indentation\n indent = 0\n html = \"<!-- begin generated output -->\\n\"\n @out.each do |part|\n case\n when part =~ /^<\\/.*>$/\n indent -= 1\n html << write_html(indent,part)\n when part =~ /^<.*<\\/.*>$/\n html << write_html(indent,part)\n when part =~ /^<.*\\/>$/\n html << write_html(indent,part)\n when part =~ /^<.*>$/\n html << write_html(indent,part)\n indent += 1\n else\n html << write_html(indent,part)\n end\n end\n # return the formatted string\n html << \"<!-- end generated output -->\\n\"\n return html\n end", "def html_output(head, level)\n classes = \"class='level-tag level-tag-#{@level}'\"\n \"<div #{classes}>#{head}<span>#{level}</span></div>\"\n end", "def render(node = nil)\n elt = node | tree\n puts \"\\nNodes: #{elt.body.count}\"\n puts \"\\nAttributes:\"\n elt.attrs.each{ |k, v| puts(\"#{k}: #{v}\") }\n children = elt.body.select{ |i| i.is_a?(Node) }\n puts \"\\nChildren: #{children.each{ |c| render(c) }}\"\n\n\n end", "def dump(depth = 0)\n print ' ' * depth * 2\n print \"<!DOCTYPE #{@name}>\\n\"\n end", "def pretty_print(depth = 0)\n depth.times { STDERR.print ' *' }\n STDERR.print ' '\n STDERR.puts \"#{@name} (#{@id})\"\n @contents.each { |obj| obj.pretty_print(depth + 1) }\n end", "def render\n\t\t\ttree.flatten.map(&:to_s).join\n\t\tend", "def resource_indentation(depth)\n indent_str = ''\n (depth - 2).times do | i |\n indent_str << content_tag(:span, '',\n { :class => 'indent' })\n end\n if depth > 1\n indent_str << content_tag(:span, image_tag('/shapes/images/list/tab.png'),\n { :class => 'indent' })\n end\n indent_str\n end", "def dump(depth = 0)\n print ' ' * depth * 2\n print \"// #{self.to_s}\\n\"\n end", "def trees_to_html(trees)\nend", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def to_html\n return \"\" unless file_name\n return e if e?\n page = render.to_html\n path = File.dirname(file_path)\n # Get child content.\n # A reflexive.\n files(path).each do |file|\n doc = Document.new :base_path => self.base_path, :lang => self.lang, :indent => self.indent, :settings => self.settings, :web_path => self.web_path, :commit => self.commit, :repository => self.repository, :filename => file\n self.browsers << doc\n page += doc.to_html\n end\n dirs(path).each do |dir|\n # Plus one indent from parent. Change h[1-6] tag to h[2-7] if indent is 1.\n doc = Document.new :base_path => dir, :lang => self.lang, :indent => self.indent + 1, :settings => self.settings, :web_path => self.web_path[0..-2] + dir.gsub(self.base_path, \"\"), :commit => self.commit, :repository => self.repository\n self.childs << doc\n page += doc.to_html\n end\n page\n end", "def printout\n\t\t\n\t\tindex = 0\n\t\t\n\t\tdef small_loop (node, index)\n\t\t\t\n\t\t\tfor i in 0...index\n\t\t\t\tprint \" \"\n\t\t\tend\n\t\t\t\n\t\t\tputs node.name\n\t\t\tindex += 1\n\t\t\t\n\t\t\tif node.children.length > 0\n\t\t\t\tindex += 1\n\t\t\t\tnode.children.cycle(1) { |child| small_loop(child, index) }\n\t\t\tend\n\t\tend\n\t\t\n\t\tsmall_loop(@root, index)\n\tend", "def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend", "def show_tree\n htmltree = \"\"\n self.each { |node| \n htmltree += \"<li><a href='#{normalize(node.name)}'>\"\n htmltree += '&nbsp; ' * node.node_depth * 3\n htmltree += \"#{node.name}</a></li>\\n\"\n }\n htmltree\n end", "def render_tag_tree(tree_node=@tree.root)\n string = \" \" * 2 * tree_node.depth\n string += \"<#{tree_node.info.type}\"\n string += \" class=#{tree_node.info.classes}\" unless tree_node.info.classes.nil?\n string += \" id=#{tree_node.info.id}\" unless tree_node.info.id.nil?\n string += \" name=#{tree_node.info.name}\" unless tree_node.info.name.nil?\n string += \">\"\n string += \" #{tree_node.info.text}\"\n puts string\n\n tree_node.children.each do |child|\n render_tag_tree(child)\n end\n end", "def output_tree(element, indent = '')\n\t\t\t\tputs \"#{indent}#{element.class}: #{element.text_value}\"\n\t\t\t\t(element.elements || []).each do |e|\n\t\t\t\t\toutput_tree(e, \"#{indent} \")\n\t\t\t\tend\n\t\t\tend", "def format_as_indented_block_html(name, attr, body, indent); end", "def write_html(indent,part)\n# \"<!-- #{indent} --> #{' '*(if indent<0 then 0 else indent end)}#{part}\\n\"\n \"#{' '*(if indent<0 then 0 else indent end)}#{part}\\n\"\n end", "def inspect_ancestry_tree(output = '', _indent_level = 0, _options = {})\n # Walk up ancestry first\n if parent\n parent.inspect_ancestry_tree(output, _indent_level + 1, _options)\n end\n output << element_summary(_indent_level, _options)\n output << \"\\n\"\n output\n end", "def trees_to_html(trees)\n # the first part of the html skeleton\n result = '\n <!doctype html>\n <html>\n <head><title>Green Thumb Nursery </title></head>\n <body>\n <h1>Catalog</h1>\n <table>\n <tr>\n <td>Type of tree</td>\n <td>Size of the tree</td>\n <td>Price of the tree</td>\n </tr>\n '\n\n # for each record, add it to the html\n tree_parser(trees).each do |type, size, price|\n result << \"\n <tr>\n <td>#{type}</td>\n <td>#{size}</td>\n <td>#{price}</td>\n </tr>\n \"\n end\n\n # close off the html\n result << '\n </table>\n </body>\n </html>\n '\n\n result\nend", "def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end", "def start_lvl(output, depth = 0, args = {})\n end", "def nesting() end", "def nested_array_to_html(nodes)\n classes = \"depth-#{ nodes.first[:depth] }\"\n classes += \" folder-tree\" if nodes.first[:depth].zero?\n\n html = \"<ul class=\\\"#{ classes }\\\">\"\n nodes.each do |node|\n html += \"<li>\"\n\n if node[:children]\n html += '<i class=\"icon-folder-close\"></i>'\n else\n html += '<i class=\"icon-file-alt\"></i>'\n end\n\n html += \"<span class=\\\"name\\\">#{ node[:name].strip }</span>\"\n unless (node[:children].nil? || node[:children].empty?)\n html += nested_array_to_html(node[:children]) \n end\n html += '</li>'\n end\n\n html += '</ul>'\n\n html\n end", "def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)", "def print(depth)\n spaces = \" \".freeze * depth\n \"#{left_stats} #{spaces} └── #{@node.name}\"\n end", "def print_tree\n ''\n end", "def recursive(request, response)\n response['rack.rsi'] = '1'\n response['Cache-Control'] = 'max-age=10'\n depth = ( request.params['depth'] || 1 ).to_i\n response.write(%{\n <%= rsi_include( \"/recursive?depth=#{depth+1}\", :raise_on_error ) %>\n <p>Hello World! #{depth}</p>\n }.gsub(/^\\s*/, \"\").strip)\n end", "def indentation; end", "def indentation; end", "def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend", "def end_lvl(output, depth = 0, args = {})\n end", "def render_tree(elements, symbols, parents = [])\n i = 0\n x = elements.map do |li|\n last = elements.length == i+1\n\n current = indentation(parents, last, symbols) + li[:value]\n\n children = \"\"\n if li[:children].length > 0\n children = \"\\n\" + render_tree(li[:children], symbols, parents + [last])\n end\n\n i += 1\n current + children\n end\n\n x.join(\"\\n\")\n end", "def _deep_output(io, obj, depth: 0)\n if obj.is_a? Hash\n obj.each do |k, v|\n io.print ' ' * depth\n io.puts k.to_s\n _deep_output(io, v, depth: depth+1)\n end\n else\n obj.each do |array|\n key = array[0]\n title = _adjust(array[1])\n text = array[2]\n io.print ' ' * depth\n io.print ColorUtils.color(key, title)\n io.print ' '\n io.puts text\n end\n end\n end", "def write(output, indent = T.unsafe(nil)); end", "def from_list_to_html(list, depth_to_traverse=1000, start_depth=0)\n depth = start_depth\n if list.is_a?(Array) && !list.empty?\n str =''\n str << '<ul>'\n depth += 1\n list.each do |value|\n unless depth > depth_to_traverse\n str << \"<li> #{value} </li> \"\n if value.is_a?(Array) \n str << from_hash_to_html(value, depth_to_traverse, depth)\n end\n end\n end\n str << '</ul> '\n return str\n end\n return ''\n end", "def print_tree(level = 0)\n if is_root?\n print \"\\n*\"\n else\n print \"|\" unless parent.is_root?\n print(' ' * (level - 1) * 4)\n print(is_root? ? \"+\" : \"|\")\n print \"---\"\n print(has_children? ? \"+\" : \">\")\n end\n\n if content\n content_hash = content.split(\"[\").first\n else\n content_hash = nil\n end\n\n puts \" #{content}\" + \" <Type: \" + (@node_type || \"no_type\") + \">\"\n\n children { |child| child.print_tree(level + 1)}\n end", "def depth; end", "def _dump(depth)\n \"\"\n end", "def _dump(depth)\n \"\"\n end", "def render\n path = [[root,0]]\n current_height = 0\n\n while (current, height = path.shift)\n next if nil_node_proc.call(current)\n # don't print empty leafs\n next if height >= max_height\n\n # height increased: we print the / \\ separator\n if height > current_height\n current_height += 1\n print_height_separator(current_height)\n end\n\n current.render(padding(height))\n\n # navigate left\n if !nil_node_proc.call(current.l)\n path.push([current.l, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n\n # navigate right\n if !nil_node_proc.call(current.r)\n path.push([current.r, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n end\n puts \"\\n\"\n end", "def nodeAsHTML(node, level)\n output = \"\"\n indent = \"\\t\" * level.size\n max = level.size\n \n special = false\n\n if node.title\n output += indent + '<dt>'\n \n prefix = \"\"\n index = 0\n maxIndex = level.size - 1\n level.each do |sect|\n prefix += sect.to_s\n if index < maxIndex\n prefix += \".\"\n end\n index = index + 1\n end\n node.levelPrefix = prefix\n \n output += \"#{prefix}</dt>\\n\"\n\n output += indent + '<dd>'\n if node.pageID\n output += '<a href=\"' + linkToPageIDFrom(node.pageID, \"toc\") + '\" target =\"main\">' + CGI::escapeHTML(node.title) + '</a>'\n else\n output += CGI::escapeHTML(node.title)\n end\n output += \"</dd>\\n\"\n\n output += indent + '<dd class=\"special\">' + \"\\n\"\n special = true\n end\n \n if node.childNodes.size > 0\n level.push(1)\n output += indent + '<dl>' + \"\\n\"\n node.childNodes.each do |childNode|\n output += nodeAsHTML(childNode, level)\n end\n output += indent + \"</dl>\\n\"\n level.pop\n end\n \n if special\n output += indent + \"</dd>\\n\"\n end\n \n if level.size > 0\n level[-1] = level[-1] + 1\n end\n return output\nend", "def write(output, indent); end", "def dump(depth = 0)\n print ' ' * depth * 2\n print \"<?#{@value.inspect}?>\\n\"\n end", "def format_as_block_html(name, attr, body, indent); end", "def to_html(html)\n traverse = lambda do |priv|\n output = '<li>'\n output << html.xml_name(priv['privilege'])\n output << ' <i>(abstract)</i>' unless priv['abstract'].blank?\n output << \" #{html.h(priv['description'])}\" if priv.key?('description')\n\n if priv.key?('aggregates')\n output << \"\\n<ul>\\n\"\n priv['aggregates'].each do |sub_priv|\n output << traverse.call(sub_priv)\n end\n output << '</ul>'\n end\n output << \"</li>\\n\"\n\n output\n end\n\n output = \"<ul class=\\\"tree\\\">\"\n output << traverse.call(@privileges)\n output << \"</ul>\\n\"\n\n output\n end", "def print_depth(item)\n return if item.hidden?\n print_item item, 0\n list_recur_print item, 2\n end", "def print_tree(array , item, level)\n items = array[item]\n unless items == nil\n indent = level > 0 ? sprintf(\"%#{level * 2}s\", \" \") : \"\"\n items.each do |e|\n puts \"#{indent}-#{e[:title]}\"\n print_tree(e, level + 1)\n end\n end\nend", "def tree_print(tree, folder)\n str = \"\";\n tree.each do |key, value|\n if not value.is_a?(Hash)\n # page\n if value.name != \"Home\"\n str += \"<li><a href=\\\"/#{@wiki.base_path}#{value.url_path}\\\">#{value.name}</a></li>\"\n end\n else\n # folder\n subfolder = folder + \"/\" + key\n str += \"<li><a href=\\\"#{@wiki.base_path}#{subfolder}/\\\">#{key}</a>\"\n str += \"<ul>\"\n str += tree_print(value, subfolder)\n str += \"</ul>\"\n str += \"</li>\"\n end\n end\n return str\n end", "def _dump(depth)\n inject(\"\") { |str, node| str << node.dump_node << self.class.node_sep }\n end", "def output(out, output_width)\n @group.breakables.shift\n if @group.break?\n out << @pp.newline\n out << @pp.genspace.call(@indent)\n @indent\n else\n @pp.group_queue.delete @group if @group.breakables.empty?\n out << @obj\n output_width + @width\n end\n end", "def dump(depth = 0)\n attr = ''\n @attr.each do |a| ## self.attributes do |a|\n attr += a.to_s + \", \"\n end if @attr\n attr.chop!\n attr.chop!\n print ' ' * depth * 2\n print \"#{@name}(#{attr})\\n\"\n @children.each do |child|\n child.dump(depth + 1)\n end if @children\n end", "def write_depths(io, trail_name, trail_sequence, kmer_hash)\n #write header\n io.print %w(trail position).join(\"\\t\")\n io.print \"\\t\"\n kmer_hash.number_of_abundances.times{|i| io.print \"\\tcoverage#{i+1}\"}\n io.puts\n\n #write data\n pos = 1\n Bio::Sequence::NA.new(trail_sequence).window_search(kmer_hash.kmer_length,1) do |kmer|\n io.puts [trail_name, pos, kmer_hash[kmer]].flatten.join(\"\\t\")\n pos += 1\n end\n end", "def html_options\n @tree.html\n end", "def pretty_print(io = STDOUT, level = 0, indent = ' ')\n io.puts(indent * level + self.to_s)\n end", "def render_recursively\n @obj = Node.find(params[:id])\n max_depth = params[:max_depth].to_f if params[:max_depth]\n\n respond_to do |format|\n format.html {render inline: NodeRepToHtml::convert(NodeRep.new(@obj, max_depth))}\n format.json {render json: NodeRep.new(@obj, max_depth)}\n end\n\n end", "def my_depth\n 1\n end", "def write(out, indent = T.unsafe(nil)); end", "def write(out, indent = T.unsafe(nil)); end", "def to_html\n mark_trees_for_export\n export_options = {\n :decorate_title => @in_buffer_settings[\"TITLE\"],\n :export_heading_number => export_heading_number?,\n :export_todo => export_todo?,\n :use_sub_superscripts => use_sub_superscripts?,\n :export_footnotes => export_footnotes?,\n :link_abbrevs => @link_abbrevs,\n :skip_syntax_highlight => @parser_options[:skip_syntax_highlight],\n :markup_file => @parser_options[:markup_file]\n }\n export_options[:skip_tables] = true if not export_tables?\n output = \"\"\n output_buffer = HtmlOutputBuffer.new(output, export_options)\n\n if @in_buffer_settings[\"TITLE\"]\n\n # If we're given a new title, then just create a new line\n # for that title.\n title = Line.new(@in_buffer_settings[\"TITLE\"], self, :title)\n translate([title], output_buffer)\n end\n translate(@header_lines, output_buffer) unless skip_header_lines?\n\n # If we've output anything at all, remove the :decorate_title option.\n export_options.delete(:decorate_title) if (output.length > 0)\n @headlines.each do |headline|\n next if headline.export_state == :exclude\n case headline.export_state\n when :exclude\n # NOTHING\n when :headline_only\n translate(headline.body_lines[0, 1], output_buffer)\n when :all\n translate(headline.body_lines, output_buffer)\n end\n end\n output << \"\\n\"\n\n return output if @parser_options[:skip_rubypants_pass]\n \n rp = RubyPants.new(output) \n rp.to_html\n end", "def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n \n result = \"\"\n \n options[:output] = result \n # Traverse tree and modify result by tacking on child names.\n printTraversal(options)\n \n puts result\n end", "def debug(depth = 0)\n if debug?\n debug_info = yield\n debug_info = debug_info.inspect unless debug_info.is_a?(String)\n debug_info = debug_info.split(\"\\n\").map { |s| \":#{depth.to_s.rjust 4}: #{s}\" }\n output.puts debug_info\n end\n end", "def _display_tree(max_length=20, tabs='')\n\t\treturn @contents._display_tree(max_length, tabs)\n\tend", "def output_hierarchy(output=$stdout)\n hierarchy.print_tree(output)\n end", "def print_tree(tree)\n\t\t\tif tree.is_leaf? and tree.depth > 0\n\t\t\t\tprint_line((\"|\\t\"*(tree.depth-1))+\"+------\"+tree.name)\n\t\t\telse\n\t\t\t\tprint_line((\"|\\t\"*tree.depth)+tree.name)\n\t\t\tend\n\t\t\ttree.children.each_pair do |name,child|\n\t\t\t\t\tprint_tree(child)\n\t\t\tend\n\t\tend", "def dump\n dump_text = ''\n regions.each do |child|\n dump_text << ' '*child.level << \"[Level: #{child.level}] \" << child.content.to_s << \"\\n\"\n end\n dump_text\n end", "def output_hierarchy(table)\n output_string = \"%3d %-60s %4s %10s\" \n @stdout.puts\n @stdout.puts 'File Hierarchy'.bold\n @stdout.puts \"%3s %-60s %4s %10s\" % ['Lvl', 'File','Type','Size']\n @stdout.puts '-'*80\n sum_size = 0\n sum_not_existing = 0\n sum_xml_err = 0\n table.each do |t|\n output = output_string % [t[:level],\n format_name(t[:level],t[:path]),\n t[:type].to_s,\n format_size(t[:size])]\n sum_size += t[:size]\n if t[:status] == FileData::STATUS_NOT_FOUND\n @stdout.puts output.red\n sum_not_existing += 1\n elsif t[:status] == FileData::STATUS_ERR\n @stdout.puts output.red\n sum_xml_err += 1 \n else\n @stdout.puts output\n end\n end\n @stdout.puts '-'*80\n summary = \"#{table.length} file(s) with approx. #{format_size(sum_size)}.\"\n if sum_not_existing > 0\n summary += \" #{sum_not_existing} file(s) not found.\".red\n end\n if sum_xml_err > 0\n summary += \" #{sum_xml_err} file(s) with errors.\".red\n end\n @stdout.puts summary\n end", "def outdent(flag=nil)\r\n current_indent = @indents.last\r\n \r\n if current_indent.nil?\r\n yield\r\n else\r\n flag ||= \":outdent_#{rand(10000000)}:\"\r\n @outdents << flag\r\n \r\n write \"#{flag}#{current_indent.length}:#{rstrip}\"\r\n @indents << ''\r\n \r\n yield\r\n \r\n @indents.pop\r\n \r\n write \"#{flag}#{rstrip}\"\r\n end\r\n \r\n self\r\n end", "def generate_html\n to_return = \"\"\n\n @child_objects.each do |child_object|\n to_return += child_object.generate_html\n end\n\n return to_return\n end", "def printf(children=nil)\n h = height(@root) + 1\n root = @root\n h.times do |i|\n self.print_level(root, i)\n end\n end", "def prettyPrint(name, level)\n timeInSecs = brickWeeklyTimeAggregate(name)\n @base = timeInSecs if(level == 0)\n unless(timeInSecs == 0)\n brickTimePretty = TimeUtils.timeDiffPretty(brickWeeklyTimeAggregate(name))\n frontSpaceStr = \" \"*(level) + '-'\n pomos = (timeInSecs * 1.0 / 60 / @@pomo_duration).round(1)\n perc = ( (timeInSecs / @base) * 100 ).round\n timeStr = \"[%s -- %02i%s -- %.1f/%i]\" % [brickTimePretty, perc, '%', pomos, brickWeeklyBudgetedAgg(name)]\n nameStrWDots = \"%s %s\" % [name, '.' * (25 - name.length)]\n print \"%s %-25s%-20s\\n\" % [frontSpaceStr, nameStrWDots, timeStr]\n #print \" \"*(level), '- ', \"#{name} [#{brickTimePretty} -- #{perc}%] \\n\"\n end\n @tree[name]['children'].each { |brickName|\n raise \"Pretty Print: child node #{brickName} is not in the tree.\" unless @tree.has_key?(brickName)\n prettyPrint(brickName, level+1)\n }\n end", "def nested_set_full_outline(item,options={})\r\n return '' if item.nil?\r\n options = {\r\n :action => options[:action] || :show,\r\n :controller => options[:controller] || item.class.to_s.underscore,\r\n :separator => options[:separator] || ' &gt; '.html_safe }\r\n s = []\r\n for it in item.ancestors\r\n if block_given?\r\n s << yield(it) + options[:separator]\r\n else\r\n s << link_to(it.disp_name, { :controller => options[:controller], :action => options[:action], :id => it }) + options[:separator]\r\n end\r\n end\r\n if block_given?\r\n s << yield(item)\r\n else\r\n s << h(item.disp_name)\r\n end unless options[:parent_only]\r\n return s.join.html_safe\r\n end", "def createTextOutput(tree, width, height, divisions)\n\tareaMap = [ ]\n\ttextOutput = [ ]\n\tfor x in 0..width \n\t\tareaMap[x] = [ ]\n\t\tfor y in 0..height \n\t\t\tareaMap[x][y] = '#'\n\t\tend\n\tend\n\tareaMap = tree.displayTree(areaMap)\n\tsaveTextOutput(1, areaMap, width, height, divisions)\nend", "def indent; end", "def indent; end", "def indent; end", "def indent; end", "def indent; end", "def to_s(options = { title: true })\n title_str = root? ? '' : \"#{'#' * level} #{@title}\\n\"\n md_string = \"#{options[:title] ? title_str : ''}#{@content}#{@children.map(&:to_s).join}\"\n md_string << \"\\n\" unless md_string.end_with?(\"\\n\")\n md_string\n end", "def to_s(page = nil)\n page ||= self.pages['index']\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position}, template=#{page.template_translations.keys.inspect})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end", "def show(spread=2, root=@root, indent=0)\n unless !root\n puts \"#{\" \"*indent*spread}#{root.data}\"\n show(spread, root.left, indent + 1)\n show(spread, root.right, indent + 1)\n end\n end", "def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end", "def dump2(m, k, level, path)\n indent_str = 1.upto(level).map{|x| \" \"}.join\n indent_str = level.to_s + indent_str\n\n if (m) then\n if (m.is_a?(Hashie::Mash)) then\n puts \"#{indent_str} #{k} {\"\n m.keys.each{|item|\n dump2(m[item], item, level + 1, path.push(item))\n }\n puts \"#{indent_str} }\"\n elsif (m.is_a?(String)) then\n puts \"#{indent_str} #{path.last} = #{m}\"\n else\n puts \"#{indent_str} #{path.last} = #{m}\"\n end\n end\nend", "def write_tree\n invoke(:write_tree)\n end", "def generate_recurse(entry)\n keyword = entry.full_name\n\n if keyword\n puts keyword\n @current_content = service.info(keyword) #lookup(keyword)\n else\n keyword = ''\n @current_content = \"Welcome\"\n end\n\n file = entry.file_name\n file = File.join(output, file)\n\n #file = keyword\n #file = file.gsub('::', '--')\n #file = file.gsub('.' , '--')\n #file = file.gsub('#' , '-')\n #file = File.join(output, file + '.html')\n\n write(file, service.info(keyword))\n\n cmethods = entry.class_methods.map{ |x| x.to_s }.sort\n cmethods.each do |name|\n mname = \"#{entry.full_name}.#{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/c-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n imethods = entry.instance_methods.map{ |x| x.to_s }.sort\n imethods.each do |name|\n mname = \"#{entry.full_name}##{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/i-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n entry.subspaces.each do |child_name, child_entry|\n next if child_entry == entry\n @directory_depth += 1\n generate_recurse(child_entry)\n @directory_depth -= 1\n end\n end", "def close_subgraph(level)\n puts_indent level, \"}\"\nend", "def show_tree\n\tend", "def html( attrs = {}, &block )\n @buffer << \"<!DOCTYPE html>\"\n @buffer << \"\\n\" if @pretty_print\n make( :html, attrs, &block )\n flush\n end", "def block_html(raw)\n raw = unindent(raw)\n\n if md = raw.match(/\\<(.+?)\\>(.*)\\<(\\/.+?)\\>/m)\n open_tag, content, close_tag = md.captures\n \"<#{open_tag}>\\n#{recursive_render(unindent(content))}<#{close_tag}>\"\n else\n raw\n end\n end", "def to_s(page = nil)\n page ||= self.pages['index']\n\n return unless page.translated_in?(Locomotive::Mounter.locale)\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end", "def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend", "def inspect_tree(tree_hash=tree, indentation=\"\")\n parts = []\n tree_hash.each do |id, subtree|\n parts << indentation + nodes_by_id[id].to_s\n unless subtree.empty?\n parts << inspect_tree(subtree, indentation + \" \")\n end\n end\n\n unless parts.empty?\n parts.compact.join(\"\\n\")\n end\n end", "def cmd_tree\n print_tree(Editor, 0)\n end", "def draw_tree\n result = ''\n max_cols = @n + 1\n calc_tree.each do |row|\n print = ' ' * ((max_cols - row.length) / 2) * max_cols\n print << row.join(' ')\n result << \"#{print}\\n\"\n end\n puts result\n end", "def to_s_indented(options = {})\n options[:space] ||= 0\n\n # indentation\n (' ' * options[:space]) +\n\n # option level name, option name\n [\"(#{level.try(:name)})\", \"#{rank}. #{option.try(:name) || '[Root]'}\"].compact.join(' ') +\n\n # parent, mission\n \" (mission: #{mission.try(:name) || '[None]'}, \" +\n \"option-mission: #{option ? option.mission.try(:name) || '[None]' : '[N/A]'}, \" +\n \"option-set: #{option_set.try(:name) || '[None]'})\" +\n\n \"\\n\" + sorted_children.map{ |c| c.to_s_indented(:space => options[:space] + 2) }.join\n end", "def group_by_depth(arr)\n output = []\n\n nested = false\n arr.each do |x|\n\n if output.last\n\n last_line = output.last[-1]\n\n if line_depth(last_line) == line_depth(x)\n\n if x =~ /Features:/ && last_line =~ /Page: \\d/\n nested = true\n end\n\n if nested\n output.last << x\n else\n output << [x]\n end\n\n elsif line_depth(last_line) > line_depth(x)\n # we are outdenting\n nested = false\n output << [x]\n\n elsif line_depth(last_line) < line_depth(x)\n # we are indenting further\n nested = true\n output.last << x\n end\n else\n output << [x]\n end\n end\n\n output\n end" ]
[ "0.7267937", "0.6594751", "0.65514535", "0.6452624", "0.6405705", "0.63899523", "0.6369388", "0.6286185", "0.62668234", "0.6234819", "0.61783546", "0.61572", "0.6083242", "0.6083242", "0.6073232", "0.606556", "0.60488796", "0.60220414", "0.60202694", "0.6013512", "0.59466386", "0.592194", "0.59188056", "0.5899513", "0.5892513", "0.5887981", "0.58862716", "0.588323", "0.5877669", "0.58105344", "0.5800028", "0.57958627", "0.57897866", "0.57897866", "0.57825845", "0.575565", "0.5740873", "0.5730937", "0.57247907", "0.5721514", "0.5717652", "0.57118684", "0.5711471", "0.5711471", "0.5707705", "0.5701401", "0.5677353", "0.56755656", "0.5668442", "0.56606954", "0.5646218", "0.56447774", "0.5636117", "0.5617785", "0.56156796", "0.5611949", "0.5605712", "0.56041133", "0.5602631", "0.55986166", "0.55937666", "0.55572355", "0.55572355", "0.5550781", "0.55390954", "0.55334985", "0.5529784", "0.5503608", "0.54852676", "0.5455445", "0.54426086", "0.5439714", "0.5435025", "0.54167557", "0.54083085", "0.5405475", "0.5401924", "0.53782374", "0.53782374", "0.53782374", "0.53782374", "0.53782374", "0.53759533", "0.5365955", "0.5358325", "0.53497165", "0.5339713", "0.5327713", "0.53190315", "0.5317302", "0.5306901", "0.53057164", "0.5305452", "0.53006965", "0.52992946", "0.5292029", "0.52915376", "0.5290867", "0.528337", "0.52828586" ]
0.64623773
3
GET /public_repositories GET /public_repositories.json
def index @public_repositories = PublicRepository.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def public_repositories\n raw_repos = GitHub::API.json(\"/organizations/#{self.login}/public_repositories\")['repositories']\n repos = []\n\n raw_repos.each do |repo|\n repos << GitHub::Repository.new(repo)\n end\n\n return repos\n end", "def index\n @repositories = current_user.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def index\n @repositories = current_user.repositories\n respond_to do |format|\n format.html { redirect_to session_url }\n format.json { render json: @repositories }\n end\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def index\n @repositories = Repository.all\n\n respond_with(@repositories)\n end", "def index\n @repositories = Repository.all\n @path_repos = request.path.starts_with? '/repos'\n end", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def index\n @repositories = Repository.all\n end", "def set_public_repository\n @public_repository = PublicRepository.find(params[:id])\n end", "def index\n @repositories = @project.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def user_repos\n @repos = @github.repos.list user: params[:username]\n render json: @repos\n end", "def index\n @repos = @user.repos.includes(:user)\n render json: to_json(@repos)\n end", "def get_repos\n @api.list_repositories\n end", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def repositories\n @repositories ||= (organization.exists? ? organization.repositories : client.list_repositories)\n end", "def repositories\n client.repositories(user_repo, @options)\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def repos\n ReposAPI.new(self)\n end", "def index\n @git_hub_repos = GitHubRepo.all\n end", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def index\n @repositories = policy_scope(Repository)\n @team_repositories = Repository\n .joins(namespace: { team: :users })\n .where(\"users.id = :user_id\", user_id: current_user.id)\n @other_repositories = @repositories - @team_repositories\n @team_repositories_serialized = API::Entities::Repositories.represent(\n @team_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n @other_repositories_serialized = API::Entities::Repositories.represent(\n @other_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n end", "def show\n @repo = @user.repos.find_by_name!(params[:id])\n render json: to_json(@repo)\n end", "def index\n @repos = Repo.all\n end", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def index\n repos = CodeburnerUtil.get_repos\n\n render(:json => { \"count\": repos.length, \"results\": repos })\n end", "def show_repo_list\n # Synchronize user's id_github with Git Hub (4 days between refreshs)\n @owner.sync_github!(4.days).save!\n \n # Synchronize list of user's projects (4 hours between refreshs)\n if @owner.sync_projects_delay?(4.hours)\n github_projects = @owner.get_github_projects\n \n if github_projects\n @owner.upd_projectlist_at = Time.now\n repos = CacheRepo.where(path: github_projects)\n \n # Drop any projects than no more exist in the user space\n if repos.length > 0\n CacheRepo.where.not(id: repos.map(&:id)).where(owner: @owner).delete_all\n end\n \n # Add any new project to this user\n (github_projects - repos.map(&:path)).each do |github_project_new|\n new_project = CacheRepo.new(path: github_project_new, owner: @owner)\n # Alway be aware of we have multiple workers and possibility concurrent insert\n if !new_project.save\n new_project = CacheRepo.where(path: github_project_new).first\n new_project.owner = @owner\n new_project.save!\n end\n end\n end\n @owner.save!\n end\n \n # Repository information will be refreshed only if the user request it\n # So, this action is more light than #show_repo_details\n @projects = CacheRepo.where(owner: @owner)\n respond_to do |format|\n format.html { render }\n format.json { render :show_repo_list, status: :ok, location: @owner }\n end\n end", "def list\n @repos\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def repository_data(user)\n Travis::RemoteVCS::Repository.new.show(\n repository_id: repository.id,\n admin_id: user.id\n )\n end", "def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end", "def count_public_repos\n @top_ten.each do |user|\n public_repos = self.class.get(\"/users/#{user[0]}/repos?q=visibility:public+created:\\>\\=2015-01-01T00:00:00-07:00\").parsed_response\n user << public_repos.length\n end\n end", "def show\n render json: JSONAPI::Serializer.serialize(@repo)\n end", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def user_repos1\n addons = Addon.joins(:user).where(\"lower(users.login) = ?\", params[:login].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def public_repo_count\n repositories.reject { |repo| repo.private? }.length\n end", "def list\n @connection.get('/user/repos').map do |repo_data|\n Rails.logger.info \"listing repos\"\n GitHubApi::Repo.new(self, repo_data)\n end\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def create\n @public_repository = PublicRepository.new(public_repository_params)\n\n respond_to do |format|\n if @public_repository.save\n format.html { redirect_to @public_repository, notice: 'Public repository was successfully created.' }\n format.json { render :show, status: :created, location: @public_repository }\n else\n format.html { render :new }\n format.json { render json: @public_repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def repositories(repo, options = {})\n paginate repo.public_user_repos_path, options if valid_user?(repo)\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def index\n @title = 'Repositories'\n @repositories = Repository.includes(:leaks).all.order(:url).page params[:page]\n end", "def repositories\n octokit.repositories('zold-io').map { |json| json['full_name'] }\n end", "def show\n respond_with(@repository)\n end", "def index\n @client_repos = ClientRepo.all\n\n respond_to do |format|\n format.json { render json: @client_repos }\n format.html { render action: 'index' }\n end\n end", "def get_repositories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Repository>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#get_repositories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_repos\n\t\t@repos = Repo.all\n\tend", "def list_repositories\n return static_list_repositories if false\n super.select do |repo|\n sleep 1\n begin\n github[\"repos/#{repo['full_name']}/contents/.dockstore.yml\"].head\n sleep 1\n rescue RestClient::NotFound\n output.puts \"No .dockstore.yml found in #{repo['full_name']}, skipping\"\n end\n end\n end", "def repositories\n # TODO : merge with current data\n load_repos\n end", "def get_repos\n begin\n @repos ||= github_api_setup.repos.list\n rescue Exception => e\n logger.error \"Github #get_repos error #{e}\"\n end\n end", "def index\n @criteria = {}\n @criteria['sort'] = repositories_sort_by\n # let's not include any 0-collection repositories unless specified\n # include_zero = (!params.blank? && params['include_empty'])\n # ok, page sizing is kind of complicated if not including zero counts\n page_size = params['page_size'].to_i if !params.blank?\n page_size = AppConfig[:pui_search_results_page_size] if page_size == 0\n query = 'primary_type:repository'\n facets = find_resource_facet\n page = params['page'] || 1 if !params.blank?\n @criteria['page_size'] = 100\n @search_data = archivesspace.search(query, page, @criteria) || {}\n @json = []\n\n if !@search_data['results'].blank?\n @pager = Pager.new(\"/repositories?\", @search_data['this_page'], @search_data['last_page'])\n @search_data['results'].each do |result|\n hash = ASUtils.json_parse(result['json']) || {}\n id = hash['uri']\n if !facets[id].blank?\n hash['count'] = facets[id]\n @json.push(hash)\n end\n end\n else\n raise NoResultsError.new(\"No repository records found!\")\n end\n @page_title = I18n.t('list', {:type => (@json.length > 1 ? I18n.t('repository._plural') : I18n.t('repository._singular'))})\n render\n end", "def repos(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/repositories', arguments.params)\n end", "def get_app_repositories\n json_response = @client.list_installation_repos\n\n repository_list = []\n if json_response.count > 0\n json_response[\"repositories\"].each do |repo|\n repository_list.push(repo[\"full_name\"])\n end\n else\n puts json_response\n end\n\n repository_list\nend", "def repositories\n Repositories.instance\n end", "def update\n respond_to do |format|\n if @public_repository.update(public_repository_params)\n format.html { redirect_to @public_repository, notice: 'Public repository was successfully updated.' }\n format.json { render :show, status: :ok, location: @public_repository }\n else\n format.html { render :edit }\n format.json { render json: @public_repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def all\n repos = self.class.load_json(repos_url)\n repos.map! { |repo| self.class.filter_repo_info(repo) }\n self.class.slice_in(repos, 3)\n end", "def repo1\n addons = Addon.where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def get_contents\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_contents(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository contents: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_contents_json = response.parsed_response\n end", "def list_all_registered_repos\n data, code = get_json(@all_repos_path)\n return data,code\n end", "def repos\n @client.repos.all.collect(&:clone_url)\n end", "def fetch_projects!\n projects.destroy_all\n\n if github?\n result = YAML.load open(\"http://github.com/api/v2/yaml/repos/show/#{github}/\")\n\n result['repositories'].each do |repository|\n projects.create! :name => repository[:name], :description => repository[:description]\n end\n end\n rescue OpenURI::HTTPError # user not found, ignore\n end", "def find_repos(user)\n user.repos\n end", "def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend", "def index\n @git_repos = GitRepo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @git_repos }\n end\n end", "def repositories\n\t\t\telems = []\n\t\t\tget_resource_link(:datacenterrepositories, \"datacenterRepositories\", \"datacenterRepository\").each do |data|\n\t\t\t\telems << Repository.new(data)\n\t\t\tend\n\t\t\telems\n\t\tend", "def index\n @repositories = Repository.all.order(created_at: :desc)\n end", "def repos\n pry(Git::Multi.repositories)\nend", "def show\n @idea = Idea.find(params[:id])\n #clone idea repo from owners copy if current user isn't owner\n if(current_user and current_user.id != @idea.user_id)\n\t repo_path = \"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\"\n\t\t\t@repo = Repository.new()\n\t\t\t@repo.path = repo_path\n\t\t\t@repo.user = current_user\n\t\t\t@repo.idea = @idea\n\t\t\t@repo.save\n\t\telsif(current_user and current_user.id == @idea.user_id)\n\t\t\t#load up existing repository\n\t\t\t@repo = Repository.where(user_id: current_user.id).where(idea_id: params[:id]).first\n\t\telse\n\t\t\t#load up existing repository\n\t\t\t@repo = Repository.where(user_id: params[:user_id]).where(idea_id: params[:id]).first\n\t\tend\n\n\t\tif current_user\n\t\t\tunless File.exists?(\"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\")\n\t\t\t\tDir.chdir(\"#{Rails.root}/public/data/repository/#{current_user.id}/\")\n\t\t\t\t@git = Git.clone(\"#{Rails.root}/public/data/repository/#{@idea.user_id}/#{@idea.name}\", @idea.name)\n\t\t\tend\n\t\tend\n\t\t@user = User.find(@idea.user_id)\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => {:idea => @idea,\n\t\t\t\t :user => @user }}\n\t\tend\n end", "def create\n #@repo = Repo.new(repo_params)\n\n user= params[:user]\n repo= params[:repos]\n\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n\n # respond_to do |format|\n # if @repo.save\n # format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @repo }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @repo.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def owned_repositories_with_user(user)\n repos = owned_repositories.publics\n repos = repos.or(user.membered_repositories.where(user_id: id)) if user\n repos\n end", "def add_repositories_for_member name\n # For a single repo, we'd call\n # GET /users/:username/repos (see https://developer.github.com/v3/repos/#list-user-repositories)\n GithubApi.get(\"/users/#{name}/repos\").each do |r|\n @repositories << r[\"full_name\"]\n end\n end", "def index\n @jira_repos = JiraRepo.all\n end", "def index\n log_level = Rails.env.production? ? Logger::WARN : Logger::DEBUG\n\n ActiveRecord::Base.logger.silence(log_level) do\n @repositories = Repository.all.order(:id).paginate(page: params[:page]).decorate\n respond_to do |format|\n format.html\n format.js\n format.json\n end\n end\n end", "def get(user, repo_name)\n org_data = @connection.get(\"/repos/#{user}/#{repo_name}\")\n GitHubApi::Repo.new_with_all_data(self, org_data)\n rescue RestClient::ResourceNotFound\n raise NotFound, \"The repository #{user}/#{repo_name} does not exist or is not visible to the user.\"\n end", "def repos\n @repos ||= OY.repos\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def repository_url(repositiory)\n http_uri + repositiory.path\n end", "def repository; end", "def list_repos\n repos = []\n end_cursor = nil\n\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n\n while next_page do\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n end\n\n repos.reject { |r| r.dig(\"isArchived\") || r.dig(\"isDisabled\") }\n end", "def repository\n @repository ||= Github::Repository.find user: user, name: name\n end", "def repositories\n opts[:repositories]\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def travis_repos\n x = $travis_conn.get 'owner/ropenscibot/repos'\n x.travis_raise\n return MultiJson.load(x.body)\nend", "def show\n @repo_cred = @repo.repo_creds.where(created_by_id: current_user.id).first || @repo.repo_creds.new\n @repo_projects = @repo.projects @repo_cred\n logger.debug \"@repo_projects: #{@repo_projects}\"\n end", "def itemsUrl(url, repo_name)\n url + '/api/repos/' + repo_name + '/items'\nend", "def get_github_api(project, endpoint)\n token = \"9874304d5d35c105f590df83c48112ff43518fba\"\n uri = URI.parse(\"https://api.github.com/repos/NuCivic/\" + project + \"/\" + endpoint + '?access_token=' + token)\n request = Net::HTTP::Get.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n JSON.parse(response.body)\n end", "def load_json\n uri = URI.parse(\"https://api.github.com/users/#{@login}/repos\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n JSON.parse(response.body)\n end", "def admin_repository_stats\n get_admin_stats \"repos\"\n end", "def user_repo1\n addon = Addon.joins(:user)\n .where(\"lower(users.login) = ?\", params[:login].downcase)\n .where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n .first\n render json: to_v1_repo_hash(addon)\n end", "def show\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end" ]
[ "0.78826284", "0.77906513", "0.7607299", "0.75962114", "0.7578652", "0.75022125", "0.7365388", "0.7232404", "0.72304016", "0.7222917", "0.71868205", "0.7180374", "0.7151602", "0.70675856", "0.706707", "0.7039443", "0.69558156", "0.69347835", "0.6913989", "0.6825737", "0.6814731", "0.6813934", "0.67915636", "0.67383546", "0.6735451", "0.6733002", "0.67326206", "0.6715217", "0.6683945", "0.6652198", "0.6611976", "0.6581976", "0.65797454", "0.65666044", "0.6565309", "0.6562339", "0.654705", "0.6484915", "0.6473083", "0.64662254", "0.642695", "0.642372", "0.6421764", "0.64140713", "0.64094853", "0.64035857", "0.63806206", "0.6370765", "0.6344031", "0.63337094", "0.6331821", "0.63071144", "0.6273558", "0.6270892", "0.62702465", "0.62537134", "0.62530977", "0.6232243", "0.6232159", "0.6212655", "0.62009543", "0.6143366", "0.61070186", "0.60987633", "0.6084931", "0.6083616", "0.6078001", "0.60687137", "0.606827", "0.60618794", "0.6058045", "0.60467976", "0.60382456", "0.6027923", "0.60268134", "0.6020493", "0.6002572", "0.59966165", "0.59945774", "0.5992302", "0.59833956", "0.59829295", "0.5952617", "0.594889", "0.59465265", "0.59425944", "0.5935588", "0.5931412", "0.59313405", "0.59236246", "0.59218884", "0.59152573", "0.59078205", "0.59014297", "0.5900892", "0.58955806", "0.58927643", "0.58882374", "0.5887687", "0.5885102" ]
0.83718145
0
GET /public_repositories/1 GET /public_repositories/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @public_repositories = PublicRepository.all\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def index\n @repositories = current_user.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def show\n @repo = @user.repos.find_by_name!(params[:id])\n render json: to_json(@repo)\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def index\n @repositories = current_user.repositories\n respond_to do |format|\n format.html { redirect_to session_url }\n format.json { render json: @repositories }\n end\n end", "def index\n @repositories = Repository.all\n end", "def index\n @repositories = Repository.all\n\n respond_with(@repositories)\n end", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def set_public_repository\n @public_repository = PublicRepository.find(params[:id])\n end", "def index\n @repos = @user.repos.includes(:user)\n render json: to_json(@repos)\n end", "def index\n @repositories = Repository.all\n @path_repos = request.path.starts_with? '/repos'\n end", "def index\n @repositories = @project.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def repo1\n addons = Addon.where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def user_repos\n @repos = @github.repos.list user: params[:username]\n render json: @repos\n end", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def show\n render json: JSONAPI::Serializer.serialize(@repo)\n end", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def repos\n ReposAPI.new(self)\n end", "def user_repo1\n addon = Addon.joins(:user)\n .where(\"lower(users.login) = ?\", params[:login].downcase)\n .where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n .first\n render json: to_v1_repo_hash(addon)\n end", "def user_repos1\n addons = Addon.joins(:user).where(\"lower(users.login) = ?\", params[:login].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def index\n @repositories = policy_scope(Repository)\n @team_repositories = Repository\n .joins(namespace: { team: :users })\n .where(\"users.id = :user_id\", user_id: current_user.id)\n @other_repositories = @repositories - @team_repositories\n @team_repositories_serialized = API::Entities::Repositories.represent(\n @team_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n @other_repositories_serialized = API::Entities::Repositories.represent(\n @other_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n end", "def show\n respond_with(@repository)\n end", "def index\n @repos = Repo.all\n end", "def get_repos\n @api.list_repositories\n end", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def public_repositories\n raw_repos = GitHub::API.json(\"/organizations/#{self.login}/public_repositories\")['repositories']\n repos = []\n\n raw_repos.each do |repo|\n repos << GitHub::Repository.new(repo)\n end\n\n return repos\n end", "def repository_data(user)\n Travis::RemoteVCS::Repository.new.show(\n repository_id: repository.id,\n admin_id: user.id\n )\n end", "def show_repo_list\n # Synchronize user's id_github with Git Hub (4 days between refreshs)\n @owner.sync_github!(4.days).save!\n \n # Synchronize list of user's projects (4 hours between refreshs)\n if @owner.sync_projects_delay?(4.hours)\n github_projects = @owner.get_github_projects\n \n if github_projects\n @owner.upd_projectlist_at = Time.now\n repos = CacheRepo.where(path: github_projects)\n \n # Drop any projects than no more exist in the user space\n if repos.length > 0\n CacheRepo.where.not(id: repos.map(&:id)).where(owner: @owner).delete_all\n end\n \n # Add any new project to this user\n (github_projects - repos.map(&:path)).each do |github_project_new|\n new_project = CacheRepo.new(path: github_project_new, owner: @owner)\n # Alway be aware of we have multiple workers and possibility concurrent insert\n if !new_project.save\n new_project = CacheRepo.where(path: github_project_new).first\n new_project.owner = @owner\n new_project.save!\n end\n end\n end\n @owner.save!\n end\n \n # Repository information will be refreshed only if the user request it\n # So, this action is more light than #show_repo_details\n @projects = CacheRepo.where(owner: @owner)\n respond_to do |format|\n format.html { render }\n format.json { render :show_repo_list, status: :ok, location: @owner }\n end\n end", "def show\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end", "def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def show\n @idea = Idea.find(params[:id])\n #clone idea repo from owners copy if current user isn't owner\n if(current_user and current_user.id != @idea.user_id)\n\t repo_path = \"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\"\n\t\t\t@repo = Repository.new()\n\t\t\t@repo.path = repo_path\n\t\t\t@repo.user = current_user\n\t\t\t@repo.idea = @idea\n\t\t\t@repo.save\n\t\telsif(current_user and current_user.id == @idea.user_id)\n\t\t\t#load up existing repository\n\t\t\t@repo = Repository.where(user_id: current_user.id).where(idea_id: params[:id]).first\n\t\telse\n\t\t\t#load up existing repository\n\t\t\t@repo = Repository.where(user_id: params[:user_id]).where(idea_id: params[:id]).first\n\t\tend\n\n\t\tif current_user\n\t\t\tunless File.exists?(\"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\")\n\t\t\t\tDir.chdir(\"#{Rails.root}/public/data/repository/#{current_user.id}/\")\n\t\t\t\t@git = Git.clone(\"#{Rails.root}/public/data/repository/#{@idea.user_id}/#{@idea.name}\", @idea.name)\n\t\t\tend\n\t\tend\n\t\t@user = User.find(@idea.user_id)\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => {:idea => @idea,\n\t\t\t\t :user => @user }}\n\t\tend\n end", "def index\n @git_hub_repos = GitHubRepo.all\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def show\n render(:json => Repo.find(params[:id]).to_json)\n rescue ActiveRecord::RecordNotFound\n render(:json => {error: \"no repo with that id found}\"}, :status => 404)\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def index\n repos = CodeburnerUtil.get_repos\n\n render(:json => { \"count\": repos.length, \"results\": repos })\n end", "def repositories\n @repositories ||= (organization.exists? ? organization.repositories : client.list_repositories)\n end", "def list\n @repos\n end", "def get_repositories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Repository>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#get_repositories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def repository\n @repository ||= Github::Repository.find user: user, name: name\n end", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def show\n @gitHubRepo = GitHubRepo.where(:id => @git_hub_issue.repo_id).first.repo\n end", "def get_contents\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_contents(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository contents: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_contents_json = response.parsed_response\n end", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def get_repo\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_json = response.parsed_response\n end", "def index\n @title = 'Repositories'\n @repositories = Repository.includes(:leaks).all.order(:url).page params[:page]\n end", "def get(user, repo_name)\n org_data = @connection.get(\"/repos/#{user}/#{repo_name}\")\n GitHubApi::Repo.new_with_all_data(self, org_data)\n rescue RestClient::ResourceNotFound\n raise NotFound, \"The repository #{user}/#{repo_name} does not exist or is not visible to the user.\"\n end", "def repositories\n client.repositories(user_repo, @options)\n end", "def index\n @client_repos = ClientRepo.all\n\n respond_to do |format|\n format.json { render json: @client_repos }\n format.html { render action: 'index' }\n end\n end", "def repository(id)\n repositories[id.to_s]\n end", "def show\n @repository = Repository.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @repository }\n end\n end", "def show\n redirect_to [@repository.owner, @repository]\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend", "def create\n @public_repository = PublicRepository.new(public_repository_params)\n\n respond_to do |format|\n if @public_repository.save\n format.html { redirect_to @public_repository, notice: 'Public repository was successfully created.' }\n format.json { render :show, status: :created, location: @public_repository }\n else\n format.html { render :new }\n format.json { render json: @public_repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def repository(id)\n self.repositories.select {|r| r.id == id}.first\n end", "def create\n #@repo = Repo.new(repo_params)\n\n user= params[:user]\n repo= params[:repos]\n\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n\n # respond_to do |format|\n # if @repo.save\n # format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @repo }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @repo.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def get_repositories_by_type_with_http_info(type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories_by_type ...'\n end\n # verify the required parameter 'type' is set\n if @api_client.config.client_side_validation && type.nil?\n fail ArgumentError, \"Missing the required parameter 'type' when calling RepositoryApi.get_repositories_by_type\"\n end\n # verify enum value\n allowable_values = [\"MAVEN\", \"NPM\", \"GEM\", \"PYPI\", \"NUGET\", \"HEX\", \"UNSUPPORTED\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/v1/repository/{type}'.sub('{' + 'type' + '}', CGI.escape(type.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Repository>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#get_repositories_by_type\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @repositories = Repository.all.order(created_at: :desc)\n end", "def get_app_repositories\n json_response = @client.list_installation_repos\n\n repository_list = []\n if json_response.count > 0\n json_response[\"repositories\"].each do |repo|\n repository_list.push(repo[\"full_name\"])\n end\n else\n puts json_response\n end\n\n repository_list\nend", "def show\n @repo = Repo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @repo }\n end\n end", "def index\n @criteria = {}\n @criteria['sort'] = repositories_sort_by\n # let's not include any 0-collection repositories unless specified\n # include_zero = (!params.blank? && params['include_empty'])\n # ok, page sizing is kind of complicated if not including zero counts\n page_size = params['page_size'].to_i if !params.blank?\n page_size = AppConfig[:pui_search_results_page_size] if page_size == 0\n query = 'primary_type:repository'\n facets = find_resource_facet\n page = params['page'] || 1 if !params.blank?\n @criteria['page_size'] = 100\n @search_data = archivesspace.search(query, page, @criteria) || {}\n @json = []\n\n if !@search_data['results'].blank?\n @pager = Pager.new(\"/repositories?\", @search_data['this_page'], @search_data['last_page'])\n @search_data['results'].each do |result|\n hash = ASUtils.json_parse(result['json']) || {}\n id = hash['uri']\n if !facets[id].blank?\n hash['count'] = facets[id]\n @json.push(hash)\n end\n end\n else\n raise NoResultsError.new(\"No repository records found!\")\n end\n @page_title = I18n.t('list', {:type => (@json.length > 1 ? I18n.t('repository._plural') : I18n.t('repository._singular'))})\n render\n end", "def show\n @repo_cred = @repo.repo_creds.where(created_by_id: current_user.id).first || @repo.repo_creds.new\n @repo_projects = @repo.projects @repo_cred\n logger.debug \"@repo_projects: #{@repo_projects}\"\n end", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def show\n @git_repo = GitRepo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @git_repo }\n end\n end", "def show\n if params[:id]\n @repo = Repo.find_by_id(params[:id])\n ident = \"with ID \" + params[:id].to_s\n end\n \n if (params[:owner] and params[:name])\n @repo = Repo.find_by_owner_and_name(params[:owner].strip, params[:name].strip)\n ident = params[:owner].strip + \"/\" + params[:name].strip\n end\n \n unless @repo.nil?\n @alternatives = @repo.find_related_labels\n end\n \n respond_to do |format|\n unless @repo.nil? \n # Repo and Alternatives found\n format.html # show.html.erb\n format.json { render json: @repo }\n else\n # Repo could not be found\n redirect_to repos_url, notice: \"Repo '#{ident}' could not be found.\"\n end\n end\n end", "def list_repositories\n return static_list_repositories if false\n super.select do |repo|\n sleep 1\n begin\n github[\"repos/#{repo['full_name']}/contents/.dockstore.yml\"].head\n sleep 1\n rescue RestClient::NotFound\n output.puts \"No .dockstore.yml found in #{repo['full_name']}, skipping\"\n end\n end\n end", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def repositories\n Repositories.instance\n end", "def itemsUrl(url, repo_name)\n url + '/api/repos/' + repo_name + '/items'\nend", "def repo\n @repository\n end", "def update\n respond_to do |format|\n if @public_repository.update(public_repository_params)\n format.html { redirect_to @public_repository, notice: 'Public repository was successfully updated.' }\n format.json { render :show, status: :ok, location: @public_repository }\n else\n format.html { render :edit }\n format.json { render json: @public_repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end", "def load_json\n uri = URI.parse(\"https://api.github.com/users/#{@login}/repos\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n JSON.parse(response.body)\n end", "def [](name)\n repositories.fetch(name)\n end", "def travis_repos\n x = $travis_conn.get 'owner/ropenscibot/repos'\n x.travis_raise\n return MultiJson.load(x.body)\nend", "def repository_base_url(result)\n if result['slug'] && AppConfig[:use_human_readable_urls]\n url = \"repositories/\" + result['slug']\n else\n url = result['uri']\n end\n\n return url\n end", "def repos\n pry(Git::Multi.repositories)\nend", "def fetch_projects!\n projects.destroy_all\n\n if github?\n result = YAML.load open(\"http://github.com/api/v2/yaml/repos/show/#{github}/\")\n\n result['repositories'].each do |repository|\n projects.create! :name => repository[:name], :description => repository[:description]\n end\n end\n rescue OpenURI::HTTPError # user not found, ignore\n end", "def repository; end", "def repos(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/repositories', arguments.params)\n end", "def repositories\n octokit.repositories('zold-io').map { |json| json['full_name'] }\n end", "def get_repo(repo_id)\n response=client.extensions.repository.retrieve_with_details(repo_id)\n code=response.code\n body=response.body\n case code\n when 200\n repo=JSON.parse(body.to_json)\n type = repo[\"notes\"][\"_repo-type\"]\n #puts repos\n repo_data=nil\n case type\n when REPO_TYPE_RPM\n yum_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_distributor'}[0]\n yum_importer = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_importer'}[0]\n distributor = nil\n if yum_distributor\n distributor = {\n :auto_publish => yum_distributor[\"auto_publish\"],\n :last_publish => yum_distributor[\"last_publish\"],\n :config => yum_distributor[\"config\"]\n }\n end\n importer = nil\n if yum_importer\n importer = {\n :last_sync => yum_importer[\"last_sync\"],\n :config => yum_importer[\"config\"]\n }\n end\n\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_RPM,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor,\n :importer => importer,\n }\n #puts repos\n when REPO_TYPE_PUPPET\n puppet_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'puppet_distributor'}[0]\n distributor =nil\n if puppet_distributor\n distributor = {\n :auto_publish => puppet_distributor[\"auto_publish\"],\n :last_publish => puppet_distributor[\"last_publish\"],\n :config => puppet_distributor[\"config\"]\n }\n end\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_PUPPET,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor\n }\n else\n end\n repo_data\n else\n raise \"Exception: cannot get repository detail: response code :#{code}\"\n end\n end", "def get_repos\n\t\t@repos = Repo.all\n\tend", "def list\n @connection.get('/user/repos').map do |repo_data|\n Rails.logger.info \"listing repos\"\n GitHubApi::Repo.new(self, repo_data)\n end\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def request_repo_data\n self.class.get(\"/#{@repo}\", headers: {\n 'Authorization' => \"token #{@token}\",\n 'User-Agent' => 'stefanrush/weightof.it'\n })\n end", "def count_public_repos\n @top_ten.each do |user|\n public_repos = self.class.get(\"/users/#{user[0]}/repos?q=visibility:public+created:\\>\\=2015-01-01T00:00:00-07:00\").parsed_response\n user << public_repos.length\n end\n end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def index\n @git_repos = GitRepo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @git_repos }\n end\n end", "def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end" ]
[ "0.7826773", "0.7553163", "0.74977154", "0.7406152", "0.7361076", "0.73259926", "0.7206645", "0.7170066", "0.7105372", "0.7098396", "0.7077001", "0.70127416", "0.6973323", "0.6962501", "0.69317156", "0.6921056", "0.6911089", "0.68687874", "0.6820289", "0.6801923", "0.6768693", "0.6748316", "0.67031395", "0.66746294", "0.6673596", "0.6667878", "0.6660011", "0.6657847", "0.66436", "0.66396487", "0.6639228", "0.6590092", "0.6572719", "0.65667826", "0.6558949", "0.6539069", "0.65078944", "0.64681506", "0.64633816", "0.64494956", "0.64489067", "0.64361006", "0.64225245", "0.64126945", "0.6401022", "0.6400197", "0.6399191", "0.63854474", "0.63849765", "0.6367167", "0.6335741", "0.6333307", "0.6321182", "0.6320828", "0.6313964", "0.63102907", "0.62413025", "0.62387097", "0.62213576", "0.62204826", "0.6214043", "0.62096626", "0.620844", "0.62069756", "0.6199228", "0.61922234", "0.61633015", "0.6156046", "0.6151766", "0.6150436", "0.6149261", "0.61349654", "0.6111398", "0.61059916", "0.6103991", "0.60978085", "0.60884994", "0.60709226", "0.6068132", "0.60677135", "0.6063745", "0.6053684", "0.60490584", "0.6041334", "0.60390955", "0.6031447", "0.602676", "0.60258985", "0.60216945", "0.60127825", "0.60089946", "0.60055894", "0.5980022", "0.59790015", "0.59719974", "0.59675634", "0.59675634", "0.59675634", "0.59675634", "0.5966764", "0.5958771" ]
0.0
-1
POST /public_repositories POST /public_repositories.json
def create @public_repository = PublicRepository.new(public_repository_params) respond_to do |format| if @public_repository.save format.html { redirect_to @public_repository, notice: 'Public repository was successfully created.' } format.json { render :show, status: :created, location: @public_repository } else format.html { render :new } format.json { render json: @public_repository.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @public_repositories = PublicRepository.all\n end", "def create\n #@repo = Repo.new(repo_params)\n\n user= params[:user]\n repo= params[:repos]\n\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n\n # respond_to do |format|\n # if @repo.save\n # format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @repo }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @repo.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @repository = current_user.repositories.new(params[:repository])\n\n respond_to do |format|\n if @repository.save\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render json: @repository, status: :created, location: @repository }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def set_public_repository\n @public_repository = PublicRepository.find(params[:id])\n end", "def public_repository_params\n params.require(:public_repository).permit(:name, :url, :record_id)\n end", "def index\n @repositories = current_user.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def create\n final_params = repository_params\n languages = Language.where(name: repository_params[:languages])\n final_params[:languages] = languages\n \n @repository = Repository.new(final_params)\n @uri = URI(@repository.repo_location)\n @repository.secret_path = SecureRandom.hex.to_s + @uri.path.split(\"/\").last.to_s\n @secret_path_to_clone_to = @repository.secret_path\n \n respond_to do |format|\n if @repository.save\n Git.clone(@uri, @secret_path_to_clone_to, :path => Rails.root.join(\"storage\", \"repositories\"))\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render :show, status: :created, location: @repository }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @repositories = current_user.repositories\n respond_to do |format|\n format.html { redirect_to session_url }\n format.json { render json: @repositories }\n end\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repositories }\n end\n end", "def create\n @repository = @project.repositories.new(params[:repository])\n @repository.path = '/home/git/repositories'\n @repository.repo_name = @repository.name.downcase.gsub(\" \",\"_\")\n respond_to do |format|\n if @repository.save\n flash[:notice] = 'Repository was successfully created.'\n format.html { redirect_to([@project,@repository]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @repository = Repository.new(repository_params)\n\n respond_to do |format|\n if @repository.save\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render :show, status: :created, location: @repository }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(*args)\n params = args.extract_options!\n normalize! params\n filter! VALID_REPO_OPTIONS + %w[ org ], params\n assert_required_keys(%w[ name ], params)\n\n # Requires authenticated user\n post_request(\"/1.0/repositories/\", DEFAULT_REPO_OPTIONS.merge(params))\n end", "def public_repositories\n raw_repos = GitHub::API.json(\"/organizations/#{self.login}/public_repositories\")['repositories']\n repos = []\n\n raw_repos.each do |repo|\n repos << GitHub::Repository.new(repo)\n end\n\n return repos\n end", "def create\n @repository = Repository.new(repository_params)\n\n respond_to do |format|\n if @repository.save\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render action: 'show', status: :created, location: @repository }\n else\n format.html { render action: 'new' }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @repositories = Repository.all\n end", "def index\n @repositories = Repository.all\n\n respond_with(@repositories)\n end", "def index\n @repositories = @project.repositories.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def create\n resp = Faraday.post('https://api.github.com/user/repos') do |req|\n req.body = {'name': params[:name]}.to_json\n req.headers['Authorization'] = 'token ' + session[:token]\n req.headers['Accept'] = 'application/json'\n end\n redirect_to '/'\n end", "def repository_params\n params.require(:repository).permit :profile_name, :name, :url, :public,\n :description\n end", "def add_repositories_for_member name\n # For a single repo, we'd call\n # GET /users/:username/repos (see https://developer.github.com/v3/repos/#list-user-repositories)\n GithubApi.get(\"/users/#{name}/repos\").each do |r|\n @repositories << r[\"full_name\"]\n end\n end", "def user_repos\n @repos = @github.repos.list user: params[:username]\n render json: @repos\n end", "def repository_params\n params.require(:repository).permit(:name, :url, :acronym, :status, :institutional_LSID, :is_index_herbarioum_record, :created_by_id, :updated_by_id)\n end", "def create\n @git_hub_repo = GitHubRepo.new(git_hub_repo_params)\n\n respond_to do |format|\n if @git_hub_repo.save\n format.html { redirect_to @git_hub_repo, notice: 'Git hub repo was successfully created.' }\n format.json { render :show, status: :created, location: @git_hub_repo }\n else\n format.html { render :new }\n format.json { render json: @git_hub_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @public_repository.update(public_repository_params)\n format.html { redirect_to @public_repository, notice: 'Public repository was successfully updated.' }\n format.json { render :show, status: :ok, location: @public_repository }\n else\n format.html { render :edit }\n format.json { render json: @public_repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def create_repo(name)\n response = Faraday.post \"https://api.github.com/user/repos\", {name: \"#{name}\" }.to_json, {'Authorization'=>\"token #{self.access_token}\", 'Accept' => 'application/json'}\n end", "def create\n\n begin\n\n if params[:access_token]\n # # get name and email by GitHub API with access_token\n client = Octokit::Client.new(access_token: params[:access_token])\n user = client.user\n name = user.login\n\n # if user with this name not exists...\n @user = User.where(name: name).first\n if @user.blank?\n @user = User.create(name: name)\n end\n\n project_json = JSON.parse(params[:project])\n project_name = project_json['name']\n project_data = JSON.pretty_generate(project_json['data'])\n\n @project = @user.project.build(name: project_name, data: project_data)\n @project.name = @project.name.delete(\" \")\n\n # JSON.parse project data and create nodes and links\n # nodes -> node_ids, links -> link_ids\n # check if node and link already exists\n # (node unique parameter : name && author && year)\n # (link unique parameter : refering node id && referred node id)\n # create node and link only when it not exists\n # update node_ids and link_ids\n\n if @project.save # auto check if project uniqueness ?\n @success = true\n else\n @success = false\n end\n else\n @success = false\n end\n rescue => e\n @success = false\n end\n\n end", "def repository_params\n params.require(:repository).permit(:repo_id, :name, :user, :description, :stars)\n end", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def create\n @repository = Repository.new(repository_params)\n\n respond_to do |format|\n if @repository.save\n #format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n #format.json { render :show, status: :created, location: @repository }\n format.js { render :create }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @repositories = Repository.all\n @path_repos = request.path.starts_with? '/repos'\n end", "def create_repository(name, proxy, url, id, policy, provider)\n json = if proxy\n create_proxy_repository_json(name, url, id, policy, provider)\n else\n create_hosted_repository_json(name, id, policy, provider)\n end\n response = nexus.post(nexus_url(\"service/local/repositories\"), :body => json, :header => DEFAULT_CONTENT_TYPE_HEADER)\n case response.status\n when 201\n return true\n when 400\n raise CreateRepsitoryException.new(response.content)\n else\n raise UnexpectedStatusCodeException.new(response.status)\n end\n end", "def create\n url = repo_params[:html_url]\n params = Repo.get_repo(url, current_user)\n if params == nil\n redirect_to :back, notice: 'Error with API access token.'\n return\n end\n if params == -1\n redirect_to :back, alert: 'Repo already exists' and return\n end\n\n params[:user_id] = current_user.id\n @repo = Repo.new(params)\n\n respond_to do |format|\n if @repo.save\n format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n format.json { render :show, status: :created, location: @repo }\n else\n format.html { render :new }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def repository; end", "def create\n # Create an empty repo in memory\n repo = Repo.new\n \n # Var. 1) Github Repo posted to \"/addrepo?url=\"\n if params[:url]\n url = params[:url]\n # Strip url of leading or trailing whitespace\n # Gsub part of url that is not nescessary\n ident = url.gsub(\"https://github.com/\", \"\").strip\n \n # Split repo ident\n repo.owner = ident.split(\"/\")[0]\n repo.name = ident.split(\"/\")[1]\n repo.ident = ident\n end\n \n # Var. 2) Github Repo is being added by posting to \"/repo\" through form\n if params[:repo]\n # Remove leading and trialing whitespace\n repo.owner = params[:repo][:owner].strip\n repo.name = params[:repo][:name].strip\n repo.ident = repo.owner + \"/\" + repo.name\n end\n \n respond_to do |format|\n if Repo.find_by_ident(repo.ident).nil?\n # Repo is not yet listed\n if repo.save # Check if validations pass\n # Validations passed\n if Repo.init_repo(repo.id)\n # Repo could be found on Github\n format.html { redirect_to repo, notice: \"Success! You added '#{repo.owner}/#{repo.name}' successfully. Thanks for helping to improve this site! You might tag this repo!!!\" }\n else\n # Repo could not be found on Github and was deleted\n format.html { redirect_to root_url, notice: \"Sorry. I could not find '#{repo.owner}/#{repo.name} on github. Spelled everything correctly?\"}\n end\n # Repo validation fails while performing initialization\n format.html { redirect_to root_url, notice: \"Repo validation failed. Please mail our team with details how you managed to get this error.\"}\n else\n # Validation failed\n format.html { redirect_to root_url, notice: \"Sorry, I could not recognize a repo owner and name in there. My bad.\" }\n end\n \n else\n # Repo already listed \n repo = Repo.find_by_ident(repo.ident) \n format.html { redirect_to repo, notice: \"Double success! '#{repo.owner}/#{repo.name}' is listed already. Checkout the tags below and refine them to do some good for your fellow human programmers. Thanks!\"}\n end\n end\n end", "def user_repos1\n addons = Addon.joins(:user).where(\"lower(users.login) = ?\", params[:login].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def create_repos\n response = HTTParty.get('https://api.github.com/orgs/' + org_name + '/repos')\n data = response.parsed_response\n data.each {|repo| github_repos.create(name: repo['name'], github_id: repo['id'])}\n end", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def repo1\n addons = Addon.where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def repo_params\n params.require(:repo).permit(:repo_type, :name, :api_url)\n end", "def create\n @repo = Repo.new(repo_params)\n good_type = Repo.types.include?(repo_params[:repo_type])\n respond_to do |format|\n if good_type && @repo.save\n format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n format.json { render :show, status: :created, location: @repo }\n else\n format.html { render :new }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def repos\n ReposAPI.new(self)\n end", "def repo_params\n params.require(:repo).permit(:name, :owner, :html_url, :description, :language, :size, :user_id, :repo_ids => [])\n end", "def index\n @repositories = policy_scope(Repository)\n @team_repositories = Repository\n .joins(namespace: { team: :users })\n .where(\"users.id = :user_id\", user_id: current_user.id)\n @other_repositories = @repositories - @team_repositories\n @team_repositories_serialized = API::Entities::Repositories.represent(\n @team_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n @other_repositories_serialized = API::Entities::Repositories.represent(\n @other_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n end", "def repository_data(user)\n Travis::RemoteVCS::Repository.new.show(\n repository_id: repository.id,\n admin_id: user.id\n )\n end", "def repository_params\n params.permit(:user, :name, :private, :new_name, :description)\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def create\n display 'Create a new Unfuddle repository'\n \n repo = Unfuddle::Resources::Repository.create(\n :repository => {\n :title => ask('Name', :required => true),\n :abbreviation => ask('Slug', :required => true),\n :system => 'git',\n :projects => {\n :project => {\n :id => 24468 \n }\n }\n }\n )\n end", "def repository_params\n params.permit(:organization_id, :repo_id, :name)\n end", "def index\n @repos = @user.repos.includes(:user)\n render json: to_json(@repos)\n end", "def create\n @repository = Repository.new(params[:repository])\n\n respond_to do |format|\n if @repository.save\n flash[:notice] = 'Repository was successfully created.'\n format.html { redirect_to(@repository) }\n format.xml { render :xml => @repository, :status => :created, :location => @repository }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @repository.errors, :status => :unprocessable_entity }\n end\n end\n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def destroy\n @public_repository.destroy\n respond_to do |format|\n format.html { redirect_to public_repositories_url, notice: 'Public repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def push_to_repo\n return if @remote_type == :none\n\n if @remote_type == :bitbucket\n puts 'Cannot automatically create BitBucket repository.'\n puts 'Please, open it manually at https://bitbucket.org/repo/create'\n `#{ENV['BROWSER']} https://bitbucket.org/repo/create`\n return\n end\n\n return unless %i[github].include?(@remote_type)\n\n gh_options = [\n @name,\n ]\n gh_options << '--team algolia' if @is_algolia\n\n if @is_private\n gh_options << '--private'\n else\n gh_options << '--public'\n end\n\n command = \"gh repo create #{gh_options.join(' ')}\"\n\n if command_success?(command)\n puts '✔ Creating GitHub repository'\n else\n puts '✘ Failed to create GitHub repository'\n exit 1\n end\n\n if command_success?('git push origin main')\n puts '✔ Pushed to repository'\n else\n puts '✘ Failed to push to repository'\n exit 1\n end\n end", "def repository_params\n params.require(:repository).permit(:title, :path, :vcs_type, :weblink_to_commit, :hook_enabled, :hook_login, :hook_password)\n end", "def create_repository_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.create_repository ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) \n\n # return_type\n return_type = opts[:return_type] || 'Repository' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#create_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def travis_repos\n x = $travis_conn.get 'owner/ropenscibot/repos'\n x.travis_raise\n return MultiJson.load(x.body)\nend", "def create\n\t\t# we're sent here by the GET '/auth' => 'sessions#create' route\n\t\t# response = Faraday.post(\"https://github.com/login/oauth/access_token\") do |request|\n\t\t# \trequest.headers['Accept'] = 'application/json'\n\t\t# \trequest.body = JSON.generate({\n\t\t# \t\t\t'client_id': ENV[\"GITHUB_CLIENT_ID\"],\n\t\t# \t\t\t'client_secret': ENV[\"GITHUB_CLIENT_SECRET\"],\n\t\t# \t\t\t'code': params[:code]\n\t\t# \t\t})\n\t\t# end\n\t\t# could also be written \n\t\tresponse = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: ENV[\"GITHUB_CLIENT_ID\"], client_secret: ENV[\"GITHUB_CLIENT_SECRET\"],code: params[:code]}, {'Accept' => 'application/json'}\n\n\t\t# this is sent back by github under the following form by default\n\t\t# access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer\n\t\t# and since we asked for headers \"Accept: application/json\"\n\t\t# {\"access_token\":\"e72e16c7e42f292c6912e7710c838347ae178b4a\", \"scope\":\"repo,gist\", \"token_type\":\"bearer\"}\n\t\taccess_hash = JSON.parse(response.body)\n\t\tsession[:token] = access_hash[\"access_token\"]\n\n\t\t##### Now we have the token and we can use it to access the API\n\n\t\t# we make a call to get the username\n\t\tuser_response = Faraday.get \"https://api.github.com/user\", {}, {'Authorization' => \"token #{session[:token]}\", 'Accept' => 'application/json'}\n\t\t# parse the response body\n\t\tuser_json = JSON.parse(user_response.body)\n\t\t# set the username into the session\n\t\tsession[:username] = user_json[\"login\"]\n\t\tbinding.pry\n\t\t# next step happens in the root path (repositories#index)\n\t\tredirect_to root_path\n\tend", "def update\n if @repo.update(repo_params)\n render json: JSONAPI::Serializer.serialize(@repo), status: :ok\n else\n render json: { errors: repo.errors }, status: :unprocessable_entity\n end\n end", "def get_repositories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Repository>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#get_repositories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def create\n @repo = Repo.new(params[:repo])\n\n respond_to do |format|\n if @repo.save\n flash[:notice] = 'Repo was successfully created.'\n format.html { redirect_to(@repo) }\n format.xml { render :xml => @repo, :status => :created, :location => @repo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @repo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n project_attrs = params[:project].merge(validate_repo_connectivity: true)\n @project = current_user.owned_projects.create(project_attrs, as: :owner)\n respond_with @project do |format|\n format.json do\n if @project.valid?\n render json: decorate(@project).to_json, status: :created\n else\n render json: {project: @project.errors.as_json}.to_json, status: :unprocessable_entity\n end\n end\n end\n end", "def index\n @repositories = Repository.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @repositories }\n end\n end", "def index\n @git_hub_repos = GitHubRepo.all\n end", "def repository_params\n params.require(:repository).permit(:name, :project, :repo_location, languages: [])\n end", "def repo_params\n params.require(:repo).permit(:name, :user_id)\n end", "def import_repositories\n import_generic(REPOSITORIES_PATH, Repository, 'uuid',\n %w(uuid title url notes address_1 address_2 city state zip phone_number email contact_email ldap_admin_group))\n end", "def create_repository(name, options = {})\n opts = options.dup\n organization = opts.delete :organization\n opts.merge! :name => name\n if opts.include? :is_template\n opts = ensure_api_media_type(:template_repositories, opts)\n end\n\n if organization.nil?\n post 'user/repos', opts\n else\n post \"#{Organization.path organization}/repos\", opts\n end\n end", "def create\n @author_repository = AuthorRepository.new(params[:author_repository])\n\n respond_to do |format|\n if @author_repository.save\n format.html { redirect_to(@author_repository, :notice => 'Author repository was successfully created.') }\n format.xml { render :xml => @author_repository, :status => :created, :location => @author_repository }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @author_repository.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @repos = Repo.all\n end", "def fetch_projects!\n projects.destroy_all\n\n if github?\n result = YAML.load open(\"http://github.com/api/v2/yaml/repos/show/#{github}/\")\n\n result['repositories'].each do |repository|\n projects.create! :name => repository[:name], :description => repository[:description]\n end\n end\n rescue OpenURI::HTTPError # user not found, ignore\n end", "def repositories\n client.repositories(user_repo, @options)\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end", "def repository_params\n params.require(:repository).permit(:url, :framework)\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def create\n @repository = Repository.new repository_params\n\n respond_to do |format|\n if @repository.save\n @repository.publish_creation current_user.profile\n FeedSubscription.add current_user.profile, @repository\n\n format.html do\n redirect_to profile_repository_url(@repository.profile, @repository),\n notice: 'Repository was successfully created.'\n end\n format.xml do\n render xml: @repository, status: :created,\n location: [@repository.profile, @repository]\n end\n else\n format.html { render action: \"new\" }\n format.xml do\n render xml: @repository.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def count_public_repos\n @top_ten.each do |user|\n public_repos = self.class.get(\"/users/#{user[0]}/repos?q=visibility:public+created:\\>\\=2015-01-01T00:00:00-07:00\").parsed_response\n user << public_repos.length\n end\n end", "def show\n render json: JSONAPI::Serializer.serialize(@repo)\n end", "def save_repos(repos)\n json = MultiJson.encode(repos)\n File.open(repos_file, 'w') { |f| f.write(json) }\n end", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def show_repo_list\n # Synchronize user's id_github with Git Hub (4 days between refreshs)\n @owner.sync_github!(4.days).save!\n \n # Synchronize list of user's projects (4 hours between refreshs)\n if @owner.sync_projects_delay?(4.hours)\n github_projects = @owner.get_github_projects\n \n if github_projects\n @owner.upd_projectlist_at = Time.now\n repos = CacheRepo.where(path: github_projects)\n \n # Drop any projects than no more exist in the user space\n if repos.length > 0\n CacheRepo.where.not(id: repos.map(&:id)).where(owner: @owner).delete_all\n end\n \n # Add any new project to this user\n (github_projects - repos.map(&:path)).each do |github_project_new|\n new_project = CacheRepo.new(path: github_project_new, owner: @owner)\n # Alway be aware of we have multiple workers and possibility concurrent insert\n if !new_project.save\n new_project = CacheRepo.where(path: github_project_new).first\n new_project.owner = @owner\n new_project.save!\n end\n end\n end\n @owner.save!\n end\n \n # Repository information will be refreshed only if the user request it\n # So, this action is more light than #show_repo_details\n @projects = CacheRepo.where(owner: @owner)\n respond_to do |format|\n format.html { render }\n format.json { render :show_repo_list, status: :ok, location: @owner }\n end\n end", "def create_site_repo\n begin\n access_token = OAuth2::AccessToken.new(new_client, github_info.access_token)\n github_username = github_info.github_username\n\n repo_data = JSON.parse(access_token.get(\"/api/v2/json/repos/show/#{github_username}\"))\n repo_exists = repo_data[\"repositories\"].any? { |repo| repo[\"name\"] == remote_repo_name }\n p \"repo exists\" if repo_exists\n\n site_repo_created! if repo_exists\n rescue OAuth2::AccessDenied\n self.lost_github_access!\n end\n end", "def public_repo_count\n repositories.reject { |repo| repo.private? }.length\n end", "def create_repository name, admin_password: nil, project_code: nil\n admin_password = SecureRandom.hex(20) if admin_password.nil? || admin_password.empty?\n\n repo = Fossil::Repo.create fossilify(name), username: username\n\n repo.repository_db do |db|\n # little bit of security, prevents someone on the server from accessing\n # the web ui without credentials\n db[:config].where(name: \"localauth\").update(value: 1)\n\n # Set the project name, on new repos this doesn't seem to exist so lets\n # insert it and I'll worry about problems later. This could be expanded\n # to include other data too in the future such as the description and\n # logo too perhaps?\n db[:config].insert(name: \"project-name\", value: name, mtime: Time.now)\n\n next if project_code.nil? || project_code.empty?\n\n # Change the project code if provided. This allows you to push an\n # existing repository up.\n db[:config].where(name: \"project-code\").update(value: project_code)\n end\n\n # Note: changing the password has to happen after the project-code is\n # changed, as it seems fossil uses the project-code to salt it's password\n # hashes to some extent\n repo.change_password username: username, password: admin_password\n\n [admin_password, repo]\n end", "def create\n @client_repo = ClientRepo.new(client_repo_params)\n\n respond_to do |format|\n if @client_repo.save\n format.html { redirect_to @client_repo, notice: 'Client repo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @client_repo }\n else\n format.html { render action: 'new' }\n format.json { render json: @client_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.post(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def repository_params\n params.require(:repository).permit(:title, :staff_id, :data, :uploaded, :uploaded_file_name, :uploaded_content_type, :uploaded_file_size)\n end", "def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"git@github.com:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n end\n end" ]
[ "0.71290064", "0.68316734", "0.66983736", "0.6648425", "0.6557433", "0.64827067", "0.6468792", "0.64037853", "0.63793594", "0.6345854", "0.6336951", "0.62572116", "0.62235355", "0.6174402", "0.6172524", "0.61462986", "0.6130395", "0.6120652", "0.60852766", "0.6064981", "0.6056706", "0.604228", "0.60344017", "0.60252213", "0.60176027", "0.6008594", "0.5987586", "0.5980662", "0.59605116", "0.5958635", "0.5924468", "0.5920006", "0.5916501", "0.5914159", "0.59133595", "0.589455", "0.5892841", "0.587987", "0.58743435", "0.5866399", "0.58153075", "0.5802313", "0.5798451", "0.57932955", "0.5788111", "0.5785855", "0.5773525", "0.57683957", "0.57446146", "0.57258874", "0.5723182", "0.57135546", "0.5690379", "0.5689961", "0.56759423", "0.56718355", "0.5664837", "0.5664837", "0.5664837", "0.5664837", "0.56545186", "0.5637591", "0.5633664", "0.5633052", "0.5628427", "0.56184274", "0.56176996", "0.5608432", "0.56083655", "0.5608139", "0.56057835", "0.5600536", "0.55831987", "0.5578798", "0.5574555", "0.5569401", "0.5565723", "0.5544477", "0.55366313", "0.553396", "0.5531069", "0.5524558", "0.5524558", "0.5521741", "0.5514042", "0.55137527", "0.5508807", "0.5504488", "0.5496087", "0.54781485", "0.5474373", "0.5469503", "0.5466113", "0.5450854", "0.5440975", "0.5438794", "0.54376477", "0.5422577", "0.54188806", "0.5404464" ]
0.7281976
0
PATCH/PUT /public_repositories/1 PATCH/PUT /public_repositories/1.json
def update respond_to do |format| if @public_repository.update(public_repository_params) format.html { redirect_to @public_repository, notice: 'Public repository was successfully updated.' } format.json { render :show, status: :ok, location: @public_repository } else format.html { render :edit } format.json { render json: @public_repository.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @repo = @user.repos.find_by_name!(params[:id])\n\n if @repo.update_attributes(params[:repo])\n head :no_content\n else\n render json: @repo.errors, status: :unprocessable_entity\n end\n end", "def update\n if @repo.update(repo_params)\n render json: JSONAPI::Serializer.serialize(@repo), status: :ok\n else\n render json: { errors: repo.errors }, status: :unprocessable_entity\n end\n end", "def update\n @repository = Repository.find(params[:id])\n\n respond_to do |format|\n if @repository.update_attributes(params[:repository])\n format.html { redirect_to @repository, notice: 'Repository was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repository.update(repository_params)\n format.html { redirect_to @repository, notice: 'Repository was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repository.update(repository_params)\n format.html { redirect_to @repository, notice: 'Repository was successfully updated.' }\n format.json { render :show, status: :ok, location: @repository }\n else\n format.html { render :edit }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repo.update(repo_params)\n format.html { redirect_to @repo, notice: 'Repo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repository.update_attributes(repo_params)\n format.html { redirect_to [@repository.owner, @repository], notice: 'Repository was successfully updated.' }\n format.json { head :no_content }\n format.js { flash[:notice] = 'Repository was updated.'}\n else\n flash_save_errors \"repository\", @repository.errors\n format.html { render action: \"edit\" }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repo.update(repo_params)\n format.html { redirect_to @repo, notice: 'Repo was successfully updated.' }\n format.json { render :show, status: :ok, location: @repo }\n else\n format.html { render :edit }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_repo(repo_id)\n response = HTTParty.put(\n GIT_BASE_URL + 'projects/' + repo_id.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n },\n :body => {\n :visibility_level => 0\n }\n )\n Rails.logger.info \"Git server response (edit repo): #{response}\"\n end", "def update\n @git = Git.open(Rails.root.join(\"storage\", \"repositories\", @repository.secret_path))\n @git.pull\n \n final_params = update_params\n if update_params[:languages]\n languages = Language.where(name: update_params[:languages])\n final_params[:languages] = languages\n end\n \n respond_to do |format|\n if @repository.update(final_params)\n format.html { redirect_to @repository, notice: 'Repository was successfully updated.' }\n format.json { render :show, status: :ok, location: @repository }\n else\n format.html { render :edit }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @repository = Repository.find(params[:id])\n\n respond_to do |format|\n if @repository.update_attributes(params[:repository])\n flash[:notice] = 'Repository was successfully updated.'\n format.html { redirect_to project_repositories_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @repository.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.put(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def update\n good_type = Repo.types.include?(repo_params[:repo_type])\n respond_to do |format|\n if good_type && @repo.update(repo_params)\n format.html { redirect_to @repo, notice: 'Repo was successfully updated.' }\n format.json { render :show, status: :ok, location: @repo }\n else\n format.html { render :edit }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client_repo.update(client_repo_params)\n format.html { redirect_to @client_repo, notice: 'Client repo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @client_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @repository = Repository.find(params[:id])\n\n respond_to do |format|\n if @repository.update_attributes(params[:repository])\n flash[:notice] = 'Repository was successfully updated.'\n format.html { redirect_to(repositories_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @repository.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @git_hub_repo.update(git_hub_repo_params)\n format.html { redirect_to @git_hub_repo, notice: 'Git hub repo was successfully updated.' }\n format.json { render :show, status: :ok, location: @git_hub_repo }\n else\n format.html { render :edit }\n format.json { render json: @git_hub_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit(user_name, repo_name, params={ })\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n\n normalize! params\n filter! VALID_REPO_OPTIONS, params\n\n put_request(\"/1.0/repositories/#{user}/#{repo.downcase}/\", DEFAULT_REPO_OPTIONS.merge(params))\n end", "def update\n @repo = Repo.find(params[:id])\n\n respond_to do |format|\n if @repo.update_attributes(params[:repo])\n flash[:notice] = 'Repo was successfully updated.'\n format.html { redirect_to(@repo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @repo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pullRequest = PullRequest.find(params[:id])\n\t\t@git = Git.init()\n\t\tDir.chdir(@pullRequest.source_repo.path)\n\t\trequestor_path = \"#{@pullRequest.repository.path}\"\n\t\t@git.pull(requestor_path, \"master\") # fetch and a merge\n\t\t@pullRequest.status = \"ACCEPTED\"\n if @pullRequest.save\n\t\t\trespond_with(@pullRequest)\n\t\telse\n\t\t\trender json: {error: \"An error occurred while updating your pull request\"}\n end\n end", "def edit_gist(id, files={}, options={:public => true})\n options.merge!(files)\n patch \"/gists/#{id}\", :body => options\n end", "def update\n @spaces = current_user.spaces_owned\n @repository = current_user.repositories.find(params[:id])\n @repository.attributes = repo_params\n\n if @repository.save\n redirect_to(edit_repository_path(@repository), :flash => { success: msg_updated(@repository) })\n else\n render('edit')\n end\n end", "def edit(*args)\n arguments(args, required: [:owner, :repo, :id])\n\n patch_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def update\n respond_to do |format|\n if @repository.update_attributes repository_params\n format.html do\n redirect_to profile_repository_url(@repository.profile, @repository),\n notice: 'Repository was successfully updated.'\n end\n format.xml { head :ok }\n else\n @original_repository = Repository.find(@repository.id)\n format.html { render action: \"edit\" }\n format.xml do\n render xml: @repository.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update_repository_file(project_id, options = {})\n put \"/projects/#{project_id}/repository/files\", options\n end", "def update\n respond_to do |format|\n if @jira_repo.update(jira_repo_params)\n format.html { redirect_to @jira_repo, notice: 'Jira repo was successfully updated.' }\n format.json { render :show, status: :ok, location: @jira_repo }\n else\n format.html { render :edit }\n format.json { render json: @jira_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n begin\n existing_repo_name = @project.repo_name\n @project.instance_variable_set(:@old_repo_name, existing_repo_name)\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n respond_to do |format|\n format.html { render :edit }\n format.json { render json: e.as_json, status: :service_unavailable }\n end\n end\n end", "def update\n authorize! :update, @repo\n respond_to do |format|\n if @repo_cred.update(repo_cred_params)\n format.html { redirect_to @repo, notice: 'Repo cred was successfully updated.' }\n format.json { render :show, status: :ok, location: @repo_cred }\n else\n format.html { redirect_to @repo, error: 'Repo credential was not successfully updated.' }\n format.json { render json: @repo_cred.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_repo\n puts \"starting to update_repo: '#{self.ident}'\"\n github = JSON.parse(Curl::Easy.perform(\"https://api.github.com/repos/\" + self.ident).body_str)\n \n if github[\"message\"]\n # Something has gone wrong\n # probably: repo does not exist\n # => 1) incorrect information provided when adding a repo\n # => 2) previously existing repo has had some changes (e.g. name, ownership)\n return false\n # do: better error handling here\n # what happens if a repo has been renamed / ownership transferred / deleted\n # => set flag 'needs_an_eye' to true\n # => then jump to the next repo\n # => might be done using 'markable' gem\n else\n %w{name description homepage}.each do |field|\n # set field or fall back to defaults\n self[field] = github[field] || \"\"\n end\n %w{watchers forks}.each do |field|\n # set field or fall back to defaults\n self[field] = github[field] || 0\n end\n\n self.github_url = github[\"html_url\"]\n self.owner = github[\"owner\"][\"login\"]\n self.last_updated = github[\"pushed_at\"]\n self.save\n end\n end", "def update_from_github(auth, cv)\n cv['email'] = auth.info.email if auth.info.email\n cv['password'] = Devise.friendly_token[0,20] if Devise.friendly_token[0,20]\n cv['name'] = auth.info.name if auth.info.name\n cv['image'] = auth.info.image if auth.info.image\n cv['biography'] = auth.extra.raw_info.bio if auth.extra.raw_info.bio\n token = auth.credentials.token if auth.credentials.token\n tmp = Array.new\n\n uri = URI(auth.extra.raw_info.repos_url)\n\n #repos = JSON.parse(open(uri.to_s, 'Authentication' => \"token #{token}\").read)\n\n HTTP.auth(\"token #{token}\")\n repos = JSON.parse(HTTP.get(uri.to_s).body)\n\n repos.each do |gitPr|\n if not gitPr['fork']\n uri = URI(gitPr['languages_url'])\n lang = JSON.parse(HTTP.get(uri.to_s).body)\n lang.each do |key,_|\n tmp << key\n end\n end\n end\n $uriTmp = auth.extra.raw_info.starred_url.to_s\n $realUri = $uriTmp.gsub(/{(.*?)}/,'')\n\n starred = JSON.parse(HTTP.get($realUri).body)\n starred.each do |gitPr|\n uri = URI(gitPr['languages_url'])\n lang = JSON.parse(HTTP.get(uri.to_s).body)\n lang.each do |key,_|\n tmp << key\n end\n end\n cv['it_languages'] = tmp.uniq\n cv['github_auth'] = true\n end", "def set_public_repository\n @public_repository = PublicRepository.find(params[:id])\n end", "def update\n @project = Project.find(params[:id])\n #@old_repo = @project.repo_name\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n if @project.github_token? && @project.repo_name?\n create_hook\n end\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @git_repo = GitRepo.find(params[:id])\n\n respond_to do |format|\n if @git_repo.update_attributes(params[:git_repo])\n flash[:notice] = 'GitRepo was successfully updated.'\n format.html { redirect_to(@git_repo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @git_repo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @repositories = args[:repositories] if args.key?(:repositories)\n end", "def update_repository_with_http_info(project_name, repository_name, repository, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.update_repository ...'\n end\n # verify the required parameter 'project_name' is set\n if @api_client.config.client_side_validation && project_name.nil?\n fail ArgumentError, \"Missing the required parameter 'project_name' when calling RepositoryApi.update_repository\"\n end\n # verify the required parameter 'repository_name' is set\n if @api_client.config.client_side_validation && repository_name.nil?\n fail ArgumentError, \"Missing the required parameter 'repository_name' when calling RepositoryApi.update_repository\"\n end\n # verify the required parameter 'repository' is set\n if @api_client.config.client_side_validation && repository.nil?\n fail ArgumentError, \"Missing the required parameter 'repository' when calling RepositoryApi.update_repository\"\n end\n if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1\n fail ArgumentError, 'invalid value for \"opts[:\"x_request_id\"]\" when calling RepositoryApi.update_repository, the character length must be great than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/projects/{project_name}/repositories/{repository_name}'.sub('{' + 'project_name' + '}', project_name.to_s).sub('{' + 'repository_name' + '}', repository_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'X-Request-Id'] = opts[:'x_request_id'] if !opts[:'x_request_id'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(repository)\n auth_names = ['basic']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#update_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @author_repository = AuthorRepository.find(params[:id])\n\n respond_to do |format|\n if @author_repository.update_attributes(params[:author_repository])\n format.html { redirect_to(@author_repository, :notice => 'Author repository was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @author_repository.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n head :ok\n end", "def update\n if params[:project][:owner_username]\n params[:project][:owner_id] = User.find_by_username(params[:project].delete('owner_username')).try(:id)\n end\n\n if (fps = params[:project].delete(:filter_paths_string))\n params[:project][:filter_paths] = fps.split(/[\\r\\n]+/).reject(&:blank?)\n end\n\n if (wps = params[:project].delete(:whitelist_paths_string))\n params[:project][:whitelist_paths] = wps.split(/[\\r\\n]+/).reject(&:blank?)\n end\n\n @project.assign_attributes params[:project].merge(validate_repo_connectivity: true), as: current_user.role(@project)\n @project.uses_releases_override = true if @project.uses_releases_changed?\n @project.save\n\n class << @project\n def filter_paths_string() filter_paths.join(\"\\n\") end\n def whitelist_paths_string() whitelist_paths.join(\"\\n\") end\n end\n\n respond_with @project\n end", "def repo1\n addons = Addon.where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def patch_kubernetes_addon_repository_with_http_info(moid, kubernetes_addon_repository, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_addon_repository ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_addon_repository\"\n end\n # verify the required parameter 'kubernetes_addon_repository' is set\n if @api_client.config.client_side_validation && kubernetes_addon_repository.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_addon_repository' when calling KubernetesApi.patch_kubernetes_addon_repository\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AddonRepositories/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_addon_repository)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAddonRepository'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_addon_repository\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_addon_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n respond_to do |format|\n if @pet_image_repo.update(pet_image_repo_params)\n format.html { redirect_to @pet_image_repo, notice: 'Image successfully updated.' }\n format.json { render :show, status: :ok, location: @pet_image_repo }\n else\n format.html { render :edit }\n format.json { render json: @pet_image_repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n @main_projects = Project.roots.where(creator_id: @project.creator_id)\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_repository 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_update_repository_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::Repository.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end", "def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend", "def update(state = 'open')\n @current_requests = @github.pull_requests(source_repo, state)\n repos = @current_requests.collect do |request|\n repo = request.head.repository\n \"#{repo.owner}/#{repo.name}\" if repo\n end\n repos.uniq.compact.each do |rep|\n git_call \"fetch git@github.com:#{rep}.git +refs/heads/*:refs/pr/#{rep}/*\"\n end\n end", "def update\n head :unauthorized\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update_profile\n response = HTTParty.get('https://api.github.com/orgs/' + org_name, :body=> {\n :username => \"9e8c7f5bb19cf14c39e38fe17c14e6d3b161f738\"\n } )\n data = response.parsed_response\n self.html_url = data['html_url']\n self.public_repos = data['public_repos']\n self.save\n end", "def put_json_for_repo(repo, json_data, append)\n throw \"Can't use a locked vault\" if @locked == true\n throw 'bad token value' if @authorized == false\n path = \"secret/#{repo}\"\n data, code = get_json(@all_repos_path)\n return code if code > 399 && code != 404\n if code == 404\n data = { 'repos' => { repo => 1 } }\n else\n data['repos'][repo] = 1\n end\n code = put_json_in_path(@all_repos_path, data)\n return code if code > 399\n if append\n current_dataset, code = get_json(path)\n if code > 399 && code != 404\n return code\n elsif code == 404\n current_dataset = {}\n end\n json_data.keys.each do |key|\n current_dataset[key] = json_data[key]\n end\n code = put_json_in_path(path, current_dataset)\n else\n code = put_json_in_path(path, json_data)\n end\n end", "def set_public(repo, options = {})\n # GitHub Api for setting private updated to use private attr, rather than public\n update_repository repo, options.merge({ :private => false })\n end", "def set_repository\n @repository = Repository.find(params[:id])\n end", "def set_repository\n @repository = Repository.find(params[:id])\n end", "def set_repository\n @repository = Repository.find(params[:id])\n end", "def set_repository\n @repository = Repository.find(params[:id])\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_datapackage\n update_file_in_repo(\"datapackage.json\", create_json_datapackage)\n end", "def update!(**args)\n @repository = args[:repository] if args.key?(:repository)\n @revision_id = args[:revision_id] if args.key?(:revision_id)\n end", "def update!(**args)\n @repository = args[:repository] if args.key?(:repository)\n @revision_id = args[:revision_id] if args.key?(:revision_id)\n end", "def update_kubernetes_addon_repository_with_http_info(moid, kubernetes_addon_repository, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.update_kubernetes_addon_repository ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.update_kubernetes_addon_repository\"\n end\n # verify the required parameter 'kubernetes_addon_repository' is set\n if @api_client.config.client_side_validation && kubernetes_addon_repository.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_addon_repository' when calling KubernetesApi.update_kubernetes_addon_repository\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AddonRepositories/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_addon_repository)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAddonRepository'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.update_kubernetes_addon_repository\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#update_kubernetes_addon_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def partial_update_with_http_info(rpm_repository_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoriesRpmApi.partial_update ...'\n end\n # verify the required parameter 'rpm_repository_href' is set\n if @api_client.config.client_side_validation && rpm_repository_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_repository_href' when calling RepositoriesRpmApi.partial_update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RepositoriesRpmApi.partial_update\"\n end\n # resource path\n local_var_path = '{rpm_repository_href}'.sub('{' + 'rpm_repository_href' + '}', rpm_repository_href.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'RpmRpmRepository')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoriesRpmApi#partial_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update(opts)\n opts.each_pair do |k,v|\n @repositories.send(k.to_sym, v)\n end\n\n repositories\n end", "def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end", "def edit\n @registry = Registry.find(params[:id])\n @can_change_hostname = !Repository.any?\n end", "def edit\n @registry = Registry.find(params[:id])\n @can_change_hostname = !Repository.any?\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @repositories = args[:repositories] if args.key?(:repositories)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end", "def update\n authorize @project\n if @project.update(project_params.merge!(updated_by_id: current_user.id))\n render json: @project\n else\n render json: {errors: @project.errors.full_messages}, status: 422\n end\n end", "def update\n @profile = Profile.where(:name => params[:profile_name]).first!\n @repository = @profile.repositories.where(:name => params[:repo_name]).\n first!\n @issue = @repository.issues.where(:number => params[:issue_number]).\n first!\n @comment = Comment.find(params[:comment_id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @idea = Idea.find(params[:id])\n @idea.name = params[:name]\n @idea.description = params[:description]\n repo_path = \"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\"\n cover_img_path = \"/data/repository/#{current_user.id}/#{@idea.name}\"\n\n if params[:cover_img]\n @idea.cover_img = params[:cover_img]\n DataFile.save(params[:cover_img], cover_img_path)\n\t\t\t@git = GitHelper.init(repo_path, current_user.email, current_user.name)\n\t\t\tGitHelper.commitAll(@git, \"Changed cover image.\")\n end\n\n if @idea.save\n\t\t\trender json: @idea\n\t\telse\n\t\t\trender json: {error: \"Failed to update idea\"}, status: :unauthorized\n end\n end", "def update!(**args)\n @id = args[:id] unless args[:id].nil?\n @sha1 = args[:sha1] unless args[:sha1].nil?\n @url = args[:url] unless args[:url].nil?\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def public_repository_params\n params.require(:public_repository).permit(:name, :url, :record_id)\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\n render 'projects/error', status: 422\n end\n end", "def put!\n request! :put\n end", "def repository_params\n params.require(:repository).permit(:repo_id, :name, :user, :description, :stars)\n end", "def update\n repo = ProjectRepo.new current_user\n @v_project = VProject.new(params[:v_project])\n\n respond_to do |format|\n if (repo.update(params[:id], @v_project))\n format.html { redirect_to @v_project, notice: 'V project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @v_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'owner')\n if @project.update(project_params)\n render @project.to_json(include: :project_detail), status: 200\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n else\n render json: { error: 'Only the project owner can update its details' }, status: :unauthorized\n end\n else\n render json: { error: \"no project found with id of #{params[:id]}\" }, status: 404\n end\n end", "def update_pr_body(body)\n @repo ||= pr_json.base.repo.full_name\n @number ||= pr_json.number\n api.update_pull_request(@repo, @number, body: body)\n end", "def change_name(repo_id, name)\n response = HTTParty.put(\n GIT_BASE_URL + 'projects/' + repo_id.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n },\n :body => {\n :name => name\n }\n )\n Rails.logger.info \"Git server response (change name): #{response}\"\n end", "def update\n project_params[:owner_id] = current_user[:id] if project_params[:owner_id].nil? or not current_user.is_admin?\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_url, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def repository_params\n params.require(:repository).permit(:name, :url, :acronym, :status, :institutional_LSID, :is_index_herbarioum_record, :created_by_id, :updated_by_id)\n end", "def create\n #@repo = Repo.new(repo_params)\n\n user= params[:user]\n repo= params[:repos]\n\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n\n # respond_to do |format|\n # if @repo.save\n # format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @repo }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @repo.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n respond_to do |format|\n if @ezii_delta_git.update(ezii_delta_git_params)\n format.html { redirect_to @ezii_delta_git, notice: 'Ezii delta git was successfully updated.' }\n format.json { render :show, status: :ok, location: @ezii_delta_git }\n else\n format.html { render :edit }\n format.json { render json: @ezii_delta_git.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_with_http_info(rpm_repository_href, data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoriesRpmApi.update ...'\n end\n # verify the required parameter 'rpm_repository_href' is set\n if @api_client.config.client_side_validation && rpm_repository_href.nil?\n fail ArgumentError, \"Missing the required parameter 'rpm_repository_href' when calling RepositoriesRpmApi.update\"\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling RepositoriesRpmApi.update\"\n end\n # resource path\n local_var_path = '{rpm_repository_href}'.sub('{' + 'rpm_repository_href' + '}', rpm_repository_href.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(data)\n auth_names = ['Basic']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AsyncOperationResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoriesRpmApi#update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def repo_params\n params.require(:repo).permit(:repo_type, :name, :api_url)\n end", "def update(username, password, id, new_asset_obj)\n raise NotImplementedError, \"Not implemented\"\n end", "def modify(name: nil, avatar: nil, channel_id: nil)\n RestClient.patch(@url, { name: name, avatar: avatarise(avatar), channel_id: channel_id }.compact.to_json, content_type: :json)\n end", "def edit_gist(filepath, opts = {})\n begin\n id, name = select_gist_id(\"edit\")\n edit_opts = generate_options(filepath, opts)[0]\n options = {:body => edit_opts.to_json}\n resp = self.class.patch(\"/gists/#{id}\", options)\n response_handling(resp, 200, name, \"edited\")\n rescue SocketError => e\n puts \"\\ncould not connect to Github, heres the error - SocketError - #{e}\\n\"\n puts \"your probably not connected to the internetz, dumbo\"\n end\n end", "def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end", "def repository_params\n params.require(:repository).permit :profile_name, :name, :url, :public,\n :description\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def create_repository_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.create_repository ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) \n\n # return_type\n return_type = opts[:return_type] || 'Repository' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#create_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end" ]
[ "0.68845284", "0.6866079", "0.63830954", "0.6369074", "0.62794113", "0.6275017", "0.62050563", "0.6169712", "0.61696035", "0.60915154", "0.60879403", "0.60823905", "0.6050669", "0.60343266", "0.6016511", "0.59620047", "0.5920089", "0.58699167", "0.58692586", "0.5866568", "0.5852512", "0.5829422", "0.5806899", "0.5742838", "0.5733201", "0.57206273", "0.5714234", "0.56916094", "0.56870884", "0.5683373", "0.5682642", "0.56400347", "0.56369495", "0.56246156", "0.5597775", "0.5584081", "0.5580657", "0.5578383", "0.55755675", "0.55692273", "0.5555354", "0.5543035", "0.5539129", "0.5523431", "0.55142474", "0.55077", "0.5507036", "0.548591", "0.5476769", "0.5463249", "0.5462648", "0.54612786", "0.5457811", "0.5453217", "0.5443397", "0.5414989", "0.5408213", "0.5408213", "0.5408213", "0.5408213", "0.5402219", "0.5399214", "0.5399068", "0.5399068", "0.5381078", "0.5372827", "0.5370562", "0.5369925", "0.53685445", "0.53665584", "0.53665584", "0.53652745", "0.53609896", "0.53594", "0.5355802", "0.53509074", "0.5344055", "0.5341311", "0.53400016", "0.53391004", "0.53387076", "0.5326968", "0.5324393", "0.53132904", "0.53115976", "0.5304263", "0.5303407", "0.53010184", "0.5298399", "0.52924293", "0.5289414", "0.5287619", "0.52868754", "0.52815306", "0.5278014", "0.52745605", "0.5269936", "0.5260912", "0.5257102", "0.52542" ]
0.6650245
2
DELETE /public_repositories/1 DELETE /public_repositories/1.json
def destroy @public_repository.destroy respond_to do |format| format.html { redirect_to public_repositories_url, notice: 'Public repository was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @repository = Repository.find(params[:id])\n @repository.destroy\n\n respond_to do |format|\n format.html { redirect_to repositories_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository = @project.repositories.find(params[:id])\n @repository.destroy\n\n respond_to do |format|\n format.html { redirect_to project_repositories_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @repository.destroy\n respond_to do |format|\n format.html { redirect_to repositories_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def destroy\n @repository.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_repositories_url, notice: \"Repository #{@repository.name} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository = Repository.find(params[:id])\n @repository.destroy\n\n respond_to do |format|\n format.html { redirect_to(repositories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n repo = ProjectRepo.new current_user\n repo.destroy params[:id]\n\n respond_to do |format|\n format.html { redirect_to v_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profile = Profile.where(name: params[:profile_name]).first!\n @repository = @profile.repositories.where(name: params[:repo_name]).first!\n @repository.destroy\n @repository.publish_deletion current_user.profile\n\n respond_to do |format|\n format.html { redirect_to(repositories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client_repo.destroy\n respond_to do |format|\n format.html { redirect_to client_repos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n repo = assets_repo\n repo.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to v_assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @folder_to_delete = @repository.get_secret_path\n if @repository.destroy\n FileUtils.rm_rf(@folder_to_delete, :secure =>true)\n puts @path\n respond_to do |format|\n format.html { redirect_to repositories_url, notice: 'Repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n format.html { redirect_to @repository, notice: 'Repository was not destroyed.' }\n end\n end", "def destroy\n @repository.destroy\n respond_to do |format|\n format.html { redirect_to repositories_url, notice: 'Repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository.destroy\n respond_to do |format|\n format.html { redirect_to repositories_url, notice: 'Repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository.destroy\n respond_to do |format|\n format.html { redirect_to repositories_url, notice: 'Repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo = Repo.find(params[:id])\n @repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(repos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @git_repo = GitRepo.find(params[:id])\n @git_repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(git_repos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @git_hub_repo.destroy\n respond_to do |format|\n format.html { redirect_to git_hub_repos_url, notice: 'Git hub repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n arguments(args, required: [:user, :repo])\n\n delete_request(\"/repos/#{arguments.user}/#{arguments.repo}\", arguments.params)\n end", "def delete(*args)\n arguments(args, required: [:user, :repo])\n\n delete_request(\"/repos/#{arguments.user}/#{arguments.repo}\", arguments.params)\n end", "def destroy\n authorize! :destroy, @repo\n @repo_cred.destroy\n respond_to do |format|\n format.html { redirect_to @repo, notice: 'Repo cred was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete repos, id\n HTTPClient.post(\"https://github.com/#{repos}/downloads/#{id.gsub( \"download_\", '')}\", {\n \"_method\" => \"delete\",\n \"login\" => @login,\n \"token\" => @token\n })\n end", "def destroy\n @author_repository = AuthorRepository.find(params[:id])\n @author_repository.destroy\n\n respond_to do |format|\n format.html { redirect_to(author_repositories_url) }\n format.xml { head :ok }\n end\n end", "def delete_public_lib(repo_id)\n curl_delete(\"#{self.host}/api2/repos/#{repo_id}/public/\").body_str\n end", "def delete_all repos\n unless repos\n raise \"required repository name\"\n end\n repos = @login + '/' + repos unless repos.include? '/'\n list_files(repos).each { |obj|\n delete repos, obj[:id]\n }\n end", "def destroy\n @repo = Repository.find(params[:id])\n\n\t\t#REMOVE FILE FROM FILE SYSTEM AND DO A GIT commit\n\t\tif(FileUtils.rm(params[:path]))\n\t\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\t\tGitHelper.commitAll(@git, \"Removed file :: #{params[:path]}\")\n\t\tend\n end", "def destroy\n @certified_repository = CertifiedRepository.find(params[:id])\n @certified_repository.destroy\n\n respond_to do |format|\n format.html { redirect_to(certified_repositories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @jira_repo.destroy\n respond_to do |format|\n format.html { redirect_to jira_repos_url, notice: 'Jira repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @client.dois.present?\n message = \"Can't delete repository that has DOIs.\"\n status = 400\n Rails.logger.warn message\n render json: {\n errors: [{ status: status.to_s, title: message }],\n }.to_json,\n status: status\n elsif @client.update(is_active: nil, deleted_at: Time.zone.now)\n @client.send_delete_email unless Rails.env.test?\n head :no_content\n else\n # Rails.logger.error @client.errors.inspect\n render json: serialize_errors(@client.errors, uid: @client.uid),\n status: :unprocessable_entity\n end\n end", "def destroy\n @pet_image_repo.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Image was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end", "def destroy\n FileUtils.rm_r(@repository.path)\n end", "def destroy\n @ezii_delta_git.destroy\n respond_to do |format|\n format.html { redirect_to ezii_delta_gits_url, notice: 'Ezii delta git was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n get_repository_object.delete(*args)\n end", "def delete_github_repo_file\n # commit\n commit_to_github(@repo, post_params)\n end", "def delete_repository_file(project_id, options = {})\n delete \"/projects/#{project_id}/repository/files\", options\n end", "def deleteRepositoryObject(path)\n begin\n File.delete(path+\".obj\")\n rescue DefaultException => e\n puts \"Failed to delete repository object : #{path}\"\n end\n end", "def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n delete_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def destroy\n @git_datum = GitDatum.find(params[:id])\n @git_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to git_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @distro.destroy\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def destroy\n @distro = Distro.find(params[:id])\n removefromaccount(\"distros\", @distro)\n @distro.destroy\n\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :ok }\n end\n end", "def destroy\n @passwordrepository.destroy\n respond_to do |format|\n format.html { redirect_to passwordrepositories_url, notice: 'Passwordrepository was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(user_name, repo_name)\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n\n delete_request(\"/1.0/repositories/#{user}/#{repo.downcase}\")\n end", "def destroy\n @distro = Distro.find(params[:id])\n @distro.destroy\n\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n clear_cached_vars\n Regulate::Git::Interface.delete({\n :id => id,\n :commit_message => commit_message || \"Deleting resource #{title}\",\n :author_name => author_name,\n :author_email => author_email\n })\n end", "def destroy\n @project = Project.find_by_slug(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @gitto = Gitto.find(params[:id])\n @gitto.destroy\n\n respond_to do |format|\n format.html { redirect_to gittos_url }\n format.json { head :no_content }\n end\n end", "def delete_repository(payload)\n path = repository_path(payload)\n if(File.exists?(path))\n warn \"Deleting repository directory: #{path}\"\n FileUtils.rm_rf(path)\n true\n else\n false\n end\n end", "def destroy\n @github_load.destroy\n respond_to do |format|\n format.html { redirect_to github_loads_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete_dataset_in_github\n begin\n jekyll_service.delete_dataset_in_github\n rescue Octokit::NotFound\n Rails.logger.info \"Repository does not exist\"\n end\n end", "def delete_dataset_in_github\n begin\n jekyll_service.delete_dataset_in_github\n rescue Octokit::NotFound\n Rails.logger.info \"Repository does not exist\"\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.delete\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @githuber = Githuber.find(params[:id])\n @githuber.destroy\n\n respond_to do |format|\n format.html { redirect_to githubers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @project\n @project.destroy\n\n head :no_content\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_maybe!(repositories)\n return if APP_CONFIG[\"background\"][\"sync\"][\"strategy\"] == \"update\"\n\n portus = User.portus\n Tag.where(repository_id: repositories).find_each { |t| t.delete_by!(portus) }\n Repository.where(id: repositories).find_each { |r| r.delete_by!(portus) }\n end", "def destroy\n @project.destroy\n head :no_content\n end", "def destroy\n project = Project.find(params[:id])\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find_by_permalink(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n authorize @project\n @project.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end", "def destroy\n @package.status = nil\n @package.save!\n respond_to do |format|\n format.html { redirect_to packages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @idea = Idea.find(params[:id])\n\t\tif(@idea.user == current_user)\n\t\t repo_path = \"#{Rails.root}/public/data/repository/#{current_user.id}/#{@idea.name}\"\n\t\t FileUtils.rm_rf(repo_path)\n\t\t @idea.destroy\n\t\t respond_with(@idea)\n\t\telse\n\t\t\trender json: {error: \"You must be the idea owner to delete an idea\"}, status: :unauthorized\n\t\tend\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n<<<<<<< HEAD:app/controllers/projects_controller.rb\n \n=======\n\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/controllers/projects_controller.rb\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n @project.users.delete_all\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.status = 'deleted'\n @project.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @project.destroy\n\n head :no_content\n end", "def destroy\n @public_account = PublicAccount.find(params[:id])\n @public_account.destroy\n\n respond_to do |format|\n format.html { redirect_to public_accounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @curso.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @jedi = Jedi.find(params[:id])\n @jedi.destroy\n\n respond_to do |format|\n format.html { redirect_to jedis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_name = params[:username]\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @publicidade = Publicidade.find(params[:id])\n @publicidade.destroy\n\n respond_to do |format|\n format.html { redirect_to publicidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def destroy\n @gist.destroy\n respond_to do |format|\n format.html { redirect_to gists_url }\n format.json { head :no_content }\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @project = Project.find(params[:id])\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7298792", "0.7293004", "0.7288492", "0.7246774", "0.7238375", "0.72131383", "0.716087", "0.70857424", "0.7051341", "0.70495045", "0.7045577", "0.70149195", "0.70111895", "0.6992315", "0.6992315", "0.6992315", "0.6963399", "0.69523406", "0.69523406", "0.68760896", "0.683452", "0.682192", "0.67820907", "0.67820907", "0.6751942", "0.67020744", "0.6640407", "0.65453863", "0.6504968", "0.6474989", "0.6463814", "0.64176846", "0.6414268", "0.63722295", "0.63712364", "0.6367333", "0.63555664", "0.6351619", "0.6345845", "0.6345638", "0.63334084", "0.6285251", "0.6272925", "0.62463635", "0.62392724", "0.6228425", "0.6217754", "0.62096626", "0.6202186", "0.61982816", "0.6194925", "0.6181546", "0.6178144", "0.6169998", "0.61626565", "0.61620283", "0.61585784", "0.6155051", "0.61458296", "0.6144522", "0.6142179", "0.6142179", "0.6142179", "0.6142179", "0.61411744", "0.61411744", "0.6139142", "0.61362773", "0.6124064", "0.6118493", "0.6108916", "0.61001843", "0.6095265", "0.60951495", "0.60838646", "0.6082675", "0.60823977", "0.60613173", "0.6051379", "0.6047112", "0.6046324", "0.6031773", "0.6031365", "0.6025115", "0.6015077", "0.60137784", "0.6009264", "0.60011095", "0.5998158", "0.59954166", "0.59911954", "0.59854877", "0.59850866", "0.59827983", "0.59776086", "0.59768796", "0.59768796", "0.59671706", "0.5964929", "0.5964462" ]
0.7528295
0
Use callbacks to share common setup or constraints between actions.
def set_public_repository @public_repository = PublicRepository.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 public_repository_params params.require(:public_repository).permit(:name, :url, :record_id) 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 valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 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 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 filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.6292164", "0.62917984", "0.62836355", "0.6242686", "0.6241917", "0.62210834", "0.6214862", "0.62125784", "0.619428", "0.617912", "0.617705", "0.61735916", "0.6163706", "0.61532795", "0.6152666", "0.6148062", "0.6123372", "0.61180484", "0.61088324", "0.6106139", "0.60925204", "0.608326", "0.60711503", "0.606551", "0.60216546", "0.6018924", "0.6015004", "0.60106766", "0.6008301", "0.6008301", "0.60028726", "0.60020626", "0.5999236", "0.59931505", "0.5993037", "0.59917194", "0.5982164", "0.5968051", "0.5960277", "0.5960268", "0.5960012", "0.59594494", "0.5954652", "0.5954304", "0.59440255", "0.59404963", "0.59404963", "0.59401006", "0.593522", "0.5932182", "0.5925528", "0.5924541", "0.5918796", "0.59123147", "0.5910144", "0.5909186", "0.5907257", "0.5899382", "0.5897783", "0.58972496", "0.58958495", "0.58948576", "0.5892734", "0.5888056", "0.58843875", "0.58818483", "0.5873746", "0.58700997", "0.5870056", "0.5869255", "0.58668107", "0.58662325", "0.5865003", "0.5862908", "0.5862406", "0.58614665", "0.5859661", "0.585562", "0.5855185", "0.58523446", "0.58504915" ]
0.0
-1
POST /posts POST /posts.json
def create @start_time = DateTime.parse(params["booking"]["start_time(1i)"].to_s + '-' + params["booking"]["start_time(2i)"].to_s + '-' + params["booking"]["start_time(3i)"].to_s + ' ' + params["booking"]["start_time(4i)"].to_s + ':' + params["booking"]["start_time(5i)"].to_s + ':' + '0') @end_time = DateTime.parse(params["booking"]["end_time(1i)"].to_s + '-' + params["booking"]["end_time(2i)"].to_s + '-' + params["booking"]["end_time(3i)"].to_s + ' ' + params["booking"]["end_time(4i)"].to_s + ':' + params["booking"]["end_time(5i)"].to_s + ':' + '0') @booking = Booking.new(:price => params[:hiddenPrice], :parking_space_id => params[:parking_space_id], :user_id => current_user.id, :start_time => @start_time, :end_time => @end_time) @booking.save redirect_to new_charge_path(booking: @booking, price: params[:hiddenPrice]) # after saving redirect to charges controller to make the charge. Example of how to link to a route with nested resources: # redirect_to parking_space_booking_path(@parking_space, @booking) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n render json: Post.create(params[\"post\"])\n end", "def create\n respond_with Post.create(params[:posts])\n end", "def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n if @post.save\n render json: @post, status: :created, location: api_v1_post_path(@post), serializer: Api::V1::PostSerializer\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n\n if @post.save\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end", "def create\n post = @current_user.posts.create(post_params)\n\n if post.save\n render json: post\n else\n render json: { errors: post.errors.full_messages }, status: :forbidden\n end\n end", "def create\n title = params[:title]\n body = params[:body]\n\n @post = current_user.posts.create(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end", "def create\n @post = Post.new({ :title => params[:post][:title] })\n \n respond_to do |format|\n if @post.save\n format.json { render :json => { :post => @post.as_json}, :status => :created, :location => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find(params[:user_id])\n @post = @user.posts.new(post_params)\n\n if @post.save\n render json: @post, status: :created, location: [@user, @post]\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = Post.new(post_params)\n\n if @post.save\n render json: {\n message: 'Post was successfully created.'\n }, status: :created\n else\n render json: {\n errors: @post.errors,\n message: 'Post could not be created.'\n }, status: :unprocessable_entity\n end\n end", "def post(id, opts = {})\r\n uri = url_for(\"posts/#{id}\", opts)\r\n response = RestClient.get(uri)\r\n JSON.parse response\r\n end", "def create\n\n\n @post = current_user.posts.build(post_params)\n\n if @post.save\n\n render json: \"Posted successfully\", status: 201\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = Post.new(params[:post])\n respond_to do |format|\n if @post.save\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.create(params[:post])\n end", "def create\n\t\tpost = @current_user.posts.create(post_params) \n\t\tif post.save\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id}\n\t else\n\t render json: {success: false, errors: post.errors.full_messages, message: \"Validation failed\"}, status: 422\n\t\tend \n\tend", "def create_posts\n end", "def create_posts\n end", "def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end", "def create\n @api_post = Api::Post.new(api_post_params)\n\n if @api_post.save\n render json: @api_post, status: :created, location: @api_post\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render :show, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \tif logged_in?\n params[:post][:user_id] = current_user.id\n @post = Post.new(post_params)\n if @post.save\n puts @post.published\n render json: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n respond_with Post.create(post_params)\n end", "def posts(opts)\n response = get(\"posts\", opts)\n response\n end", "def post(*args)\n request(:post, *args)\n end", "def post(*args)\n request :post, *args\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_post = current_user.posts.new(api_post_params)\n if @api_post.save\n render :show\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end", "def create\n authenticated\n\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new post_params\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n if @post.save\n render :show, status: :created, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n puts \"create post: #{post_params.inspect}\"\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @title = \"Create New Post\"\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end", "def create\n post_service = PostService.new(current_user, params)\n post_service.create_post\n #post_service.create\n respond_to do |format|\n if post_service.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to new_post_url, alert: post_service.errors }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render json: @post, status: :created, location: @post }\n format.xml { render xml: @post, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #raise params.inspect\n \n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @posts = Post.page(params[:page]).order('created_at desc')\n @post = Post.new(post_params)\n @user = User.where('account_id == ?', current_account.id)[0]\n respond_to do |format|\n if @post.save\n format.html { redirect_to '/posts' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :index }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\t\t\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user_post_param\n respond_to do |format|\n if @post.save\n format.html do\n redirect_to @post, notice:\n \"Post was successfully created.\"\n end\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json do\n render json: @post.errors, status:\n :unprocessable_entity\n end\n end\n end\n end", "def create\n @api_v1_post = Api::V1::Post.new(api_v1_post_params)\n\n respond_to do |format|\n if @api_v1_post.save\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_post }\n else\n format.html { render :new }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(params[:post])\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path, flash: { error: @post.errors.full_messages } }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def new\n post = Post.new\n render json: post\n end", "def create\n @user = current_user\n @post = @user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render json: @post, status: :created, location: @post }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @post = Post.create(post_params)\n set_posts\n respond_to do |format|\n format.js\n format.html\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, :notice => \"slam\" }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path }\n flash[:alert] = \"shit.\"\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n post\n end", "def create\n @post = Post.new(content: params[:post][:content], user_id: @user.id)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @user }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to @user }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = params[:user_id]\n if @post.save\n render json: @post, meta: { status: :created }, meta_key: 'result', status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = current_user.posts.new(post_params.merge(writter: current_user.name))\n\n if @post.save\n render json: {status: 1, id: @post.id.to_s, notice: \"新增成功,标题是:#{@post.title.capitalize}\", number: @post.number, errors: []}\n else\n render json: {status: -1, notice: \"新增失败,请先登录\", errors: @post.errors.full_messages}\n end\n end", "def create\n puts \"Trying to Create New Post\"\n # Creates new post with given content tied to given userid\n @post = Post.new(post_params) \n if @post.save\n puts \"Post successfully created\"\n response.status=(201)\n render json: {status: \"Success\", message: [\"Post created!\"]}\n else\n # Error handling\n puts \"Something went wrong while creating new Post\"\n puts(@Post.errors.full_messages)\n response.status=(422)\n render json: { status: \"Error\", message: [@post.errors.full_messages]}\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to list_of_posts_post_path(@post.user), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(*args)\n execute(:post, *args)\n end", "def create\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n coerce_date(params[:post], 'published_at')\n @post = Mist::Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to new_post_successful_posts_path, notice: 'Anúncio criado com sucesso.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end", "def create\n redirect_to login_path unless session[:user_id]\n message = 'Post was successfully created.'\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: message }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user = User.find_by_auth_token!(cookies[:auth_token])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n if @post.save\n redirect_to find_redirect(@post.page)\n else\n render :new\n render json: @post.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.74463975", "0.73221767", "0.73072433", "0.7123966", "0.7015686", "0.701327", "0.69841874", "0.6939327", "0.69313824", "0.69053805", "0.68196476", "0.6812792", "0.6793222", "0.6792862", "0.6779654", "0.6779654", "0.67625546", "0.67602354", "0.67515427", "0.6735786", "0.66983837", "0.6694823", "0.6676922", "0.6648634", "0.6618174", "0.6609208", "0.6576672", "0.6567517", "0.6535031", "0.65248317", "0.6517826", "0.6512526", "0.6512526", "0.65004253", "0.64875203", "0.6482612", "0.64796066", "0.6479418", "0.64762664", "0.64762664", "0.64762664", "0.64762664", "0.64762664", "0.64762664", "0.64762664", "0.6452396", "0.6443543", "0.64413923", "0.6439579", "0.6431225", "0.6411242", "0.64027417", "0.6402409", "0.63972473", "0.63956606", "0.6388207", "0.6388207", "0.6380103", "0.63764375", "0.6374259", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.63714516", "0.6369631", "0.6361449", "0.6350474", "0.6349784", "0.6345706", "0.6312865", "0.63084143", "0.630361", "0.63009614", "0.62957925", "0.6295694", "0.62955", "0.6294854", "0.62942207", "0.628781", "0.62877417", "0.6283785", "0.6282612", "0.6263583" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_parking_space @parking_space = ParkingSpace.find(params[:parking_space_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 booking_params params.require(:booking).permit(:start_time, :end_time, :price, :parking_space_id, :user_id) 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
Use this method in DSL methods to add a base directory to config
def add_base_dir(name, base_dir_string) if name.to_s !~ BASE_DIR_NAME_REGEX raise ArgumentError.new("A base dir name must match this regex: #{ BASE_DIR_NAME_REGEX.inspect }") end # guarantee trailing slash bd = base_dir_string.to_s.gsub(/\/\z/, '') + '/' @base_dirs[name.to_sym] = bd end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_config_path\n BASE_CONFIG_PATH\n end", "def base_path\n raise NotImplementedError, \"Subclass #{self.class.name} of Configuration must implement base_path\"\n end", "def get_base\n # See if we need to extend the base_dir\n if @config['base']\n extended_base = File.expand_path(File.join(@real_base, @config['base']))\n if File.directory? extended_base\n @base_dir = extended_base\n else\n puts \"Your base directory doesn't exist: #{extended_base}\"\n exit 1\n end\n end\n end", "def add_config_folder\n directory 'templates/dry/config', \"#{name}/config\", recursive: true\n end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir\n raise NotImplementedError\n end", "def base_dir\n options.fetch('base_dir', '')\n end", "def base_directory\n @base_directory\n end", "def base_dir_for_path_parameters; end", "def basepath; end", "def base_dir(name)\n if name.to_s !~ BASE_DIR_NAME_REGEX\n raise ArgumentError.new(\"A base dir name must match this regex: #{ BASE_DIR_NAME_REGEX.inspect }\")\n end\n get_config_val(@base_dirs, name)\n end", "def configure(root_config)\n late_config_merge(root_config)\n\n unless File.directory? work_dir\n FileUtils.mkdir_p work_dir\n end\n end", "def base_dir # :nodoc:\n File.join @root_dir, 'bundler'\n end", "def default_path\n Pathname.pwd.join(*base_config_path, self.class.config_folder)\n end", "def configure_directories\n processing_dir = @config['processing_dir']\n if @config['directory_formats']\n @spec['origdir'] = @config['origdir'] || parse_directory_format(@config['directory_formats']['origdir']) || File.join(processing_dir, @spec['subid'] + '_orig')\n @spec['procdir'] = @config['procdir'] || parse_directory_format(@config['directory_formats']['procdir']) || File.join(processing_dir, @spec['subid'] + '_proc')\n @spec['statsdir'] = @config['statsdir'] || parse_directory_format(@config['directory_formats']['statsdir']) || File.join(processing_dir, @spec['subid'] + '_stats')\n else\n @spec['origdir'] = @config['origdir'] || File.join(processing_dir, @spec['subid'] + '_orig')\n @spec['procdir'] = @config['procdir'] || File.join(processing_dir, @spec['subid'] + '_proc')\n @spec['statsdir'] = @config['statsdir'] || File.join(processing_dir, @spec['subid'] + '_stats')\n end\n end", "def base_path=(base_path)\n @base_path = base_path\n end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_dir=(_arg0); end", "def base_path\n @base_path ||= server_path(File.expand_path(Dir.pwd))\n end", "def initialize(base_dir)\r\n read_config(base_dir)\r\n end", "def base_uri(value)\n @config[:base_uri] = value\n end", "def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end", "def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end", "def root\n settings[:basedir]\n end", "def destination(base_directory); end", "def create_config_base\n # Create keys directory for environment\n FileUtils.cd(self.project_root) { FileUtils.mkdir_p \"config/environments/#{self.name}\" }\n FileUtils.cd(\"#{project_root}/config/environments/#{self.name}\") { FileUtils.mkdir_p %w{steps keys} }\n # Create ssh key for puppet user if environment is vagrant\n generate_puppet_user_keys('vagrant') if self.name == 'vagrant'\n end", "def source_paths\n Array(super) +\n [File.join(File.expand_path(File.dirname(__FILE__)),'rails_root')] +\n [File.join(File.expand_path(File.dirname(__FILE__)),'rails_root', 'config')]\nend", "def cfg_dir\n File.join(@full_path, CONFIG_DIR)\n end", "def config_directory\n return @dir if @dir\n\n path = @options[:directory] || default_config_dir\n @dir = File.expand_path(path)\n end", "def base_path\n Dir.pwd + \"/\"\n end", "def base_path\n @base_path ||= Dir.pwd\n end", "def configure_paths\n @source = Pathname.new(configuration[:source]).expand_path\n @root = Pathname.new(configuration[:root]).expand_path\n # Systems like Homebrew and Stow symlink the scripts into $PATH,\n # but RUNNER_BASE_DIR is not relative to the symlink.\n if (@source + control_script_name).symlink?\n @source = (@source + control_script_name).realpath.parent\n end\n end", "def base_path\n @base_path ||= self.class.respond_to?(:base_path) ? self.class.base_path : Merb.dir_for(:public)\n end", "def initialize(base_dir)\n @base_dir = base_dir\n end", "def base_dir(dir_name)\n File.expand_path(dir_name)\n end", "def config_root\n @config_root ||= root / 'config'\n end", "def addDir(basefile)\n\t\tdir = File.dirname(basefile)\n\n\t\t# recurse - add parent dirs also\n\t\tif (dir != \".\") then\n\t\t\t@dirList << dir\n\t\t\taddDir(dir)\n\t\tend\n\tend", "def base_paths\n @base_paths ||= find_base_paths\n end", "def dir_base\n File.expand_path(File.dirname(__FILE__)+\"/../..\")\n end", "def config_files(override); end", "def set_base_url\n $base_url = (ENV['base_url'].nil? || ENV['base_url'].empty?) ? CONFIG['default_base_url'] : ENV['base_url']\nend", "def set_config_paths\n @config_file_path = \"config/dissect/\"\n end", "def install_configure_in(base)\n base.instance_eval <<-EOF\n # Configuration class for host module\n #\n #{base.name}::Configuration = Class.new(Configurations::Configuration)\n\n # The central configure method\n # @params [Proc] block the block to configure host module with\n # @raise [ArgumentError] error when not given a block\n # @example Configure a configuration\n # MyGem.configure do |c|\n # c.foo = :bar\n # end\n #\n def self.configure(&block)\n fail ArgumentError, \"configure needs a block\" unless block_given?\n include_configuration_type!(#{base.name}::Configuration)\n\n set_configuration!(&block)\n end\n\n # A reader for Configuration\n #\n def configuration\n return Thread.current[configuration_name] if Thread.current.key?(configuration_name)\n\n @configuration_defaults && configure {}\n end\n\n\n private\n\n # Sets the configuration instance variable\n #\n def self.set_configuration!(&block)\n Thread.current[configuration_name] = #{base.name}::Configuration.__new__(\n configuration_options,\n &block\n )\n end\n\n def self.configuration_name\n :\"#{underscore_camelized(base.name)}\"\n end\n\n EOF\n end", "def get_config_directory()\n\t\t\tconfig_directory= File.join(@base_directory, \"config\")\n\t\t\treturn config_directory\n\t\tend", "def initialize current_dir,configuration\n @current_dir=current_dir\n @configuration=configuration\n @base_dir=File.expand_path(@configuration['base_dir'])\n @base_src=File.join(@base_dir,'src')\n end", "def post_configure\n super\n @path = File.expand_path(path)\n end", "def mock_with_basedir(mock, basedir)\n config = IO.readlines(mock)\n basedir = \"config_opts['basedir'] = '#{basedir}'\"\n config.unshift(basedir)\n tempdir = Pkg::Util::File.mktemp\n newmock = File.join(tempdir, File.basename(mock))\n File.open(newmock, 'w') { |f| f.puts config }\n newmock\nend", "def generate_base_directory_environments(tmpdir)\n puppet_conf = \"#{tmpdir}/puppet2.conf\"\n dir_envs = \"#{tmpdir}/environments\"\n\n step 'Configure a the direnv directory environment'\n apply_manifest_on master, %Q{\n File {\n ensure => directory,\n owner => #{master.puppet['user']},\n group => #{master.puppet['group']},\n mode => \"0750\",\n }\n file {\n [\n '#{dir_envs}',\n '#{dir_envs}/direnv',\n ]:\n }\n\n file {\n '#{puppet_conf}':\n ensure => file,\n content => \"\n [main]\n environmentpath=#{dir_envs}\n \"\n }\n }\n\n return puppet_conf\n end", "def base_directory\n File.expand_path(File.join(File.dirname(__FILE__), '..'))\n end", "def configure(root_config)\n end", "def configure(root_config)\n end", "def setup_skeleton\n self.destination_root = File.join(path, name)\n @class_name = name.classify\n directory(\"base_app/\", self.destination_root)\n store_component_config('.components')\n end", "def hiera_configpath(hiera)\n File.join('config', 'hieras', hiera, 'hiera.yaml')\nend", "def base_dir\n AYTests.base_dir\n end", "def yml_directory\n @data_magic_yml_directory ||= 'config'\n end", "def configuration_file_for(target_dir); end", "def base\n return @config[\"base\"]\n end", "def update_basedir(basedir=nil)\n @generator.remove_basedir\n _basedir = basedir || create_basedir\n @generator = Generator.new(_basedir)\n return _basedir\n end", "def base_path(val=nil)\n if val\n @base_path = val\n else\n @base_path || default_base_path_name\n end\n end", "def relative_directory; end", "def basedir\n File.dirname File.absolute_path options[:file]\n end", "def config_path\n etc+\"php/\"\n end", "def set_git_path basedir\n @git_path = basedir\n end", "def base_uri=(value)\n raise ConfigurationInvalid, \"Invalid value for base uri, should be a string\" if !value.is_a?(String)\n @base_uri ||= value\n end", "def relative_config_file\n File.join(@settings[:config_dir], @settings[:config_file])\n end", "def install_configure_in(base)\n base.class_eval <<-EOF\n class << self\n # The central configure method\n # @params [Proc] block the block to configure host module with\n # @raise [ArgumentError] error when not given a block\n # @example Configure a configuration\n # MyGem.configure do |c|\n # c.foo = :bar\n # end\n #\n def configure(&block)\n raise ArgumentError, 'can not configure without a block' unless block_given?\n @configuration = #{self}::Configuration.new(@configuration_defaults, @configurable, &block)\n end\n end\n EOF\n end", "def init_config_folder\n copy_file('config/app.js', src_path('config/app.js'))\n copy_file('config/routes.js', src_path('config/routes.js'))\n copy_file('config/router.js', src_path('config/router.js'))\n end", "def config_path=(value)\n @config_path = value\n end", "def basedir\n self.class._basedir\n end", "def basedir\n \"tyrant\"\n end", "def base_path\n @base_path || self.class.base_path\n end", "def setup\n preference_file = \"#{defaults[:root_dir]}/config.yml\"\n preferences = {}\n if File.exists? preference_file\n require 'yaml'\n File.open(preference_file) { |file| preferences = YAML.load(file) }\n end\n base_file_variations(absolute_paths(defaults.merge(preferences)))\n end", "def configure(root_config)\n\n end", "def default_test_base_path\n File.join(kitchen_root, Kitchen::DEFAULT_TEST_DIR)\n end", "def config_dir\n dir = options[:config] ? File.dirname(options[:config]) : './config'\n File.expand_path(dir)\n end", "def base_relative_dir\n \t\t@dir.gsub(/^\\//,\"\")\n \tend", "def initialize( base_dir )\n raise BaseDirNotValid unless base_dir && Dir.exists?( base_dir )\n @base_dir = base_dir\n\n # TODO: Base directory will contain a configuration file that will change\n # the settings of this object.\n\n yield self if block_given?\n end", "def relative_directory\n @relative_directory ||= \"_#{label}\"\n end", "def install_configure_in(base)\n base.instance_eval <<-EOF\n # Configuration class for host module\n #\n #{base.name}::Configuration = Class.new(Configurations::Configuration)\n\n # The central configure method\n # @params [Proc] block the block to configure host module with\n # @raise [ArgumentError] error when not given a block\n # @example Configure a configuration\n # MyGem.configure do |c|\n # c.foo = :bar\n # end\n #\n def self.configure(&block)\n semaphore.synchronize do\n fail ArgumentError, \"configure needs a block\" unless block_given?\n include_configuration_type!(#{base.name}::Configuration)\n\n set_configuration!(&block)\n end\n end\n\n # A reader for Configuration\n #\n def configuration\n semaphore.synchronize do\n return @configuration if @configuration\n\n if @configuration_defaults\n include_configuration_type!(#{base.name}::Configuration)\n set_configuration! { }\n end\n end\n end\n\n\n private\n\n # Sets the configuration instance variable\n #\n def self.set_configuration!(&block)\n @configuration = #{base.name}::Configuration.__new__(\n configuration_options,\n &block\n )\n end\n\n @semaphore = Mutex.new\n def self.semaphore\n @semaphore\n end\n\n EOF\n end", "def rewrite_base_path(path) # :nodoc:\n if path !~ %r(^/)\n File.join('/', dir, path)\n else\n path\n end\n end", "def base_dir\r\n datastore['WritableDir']\r\n end", "def base_path\n instance.options[:base_path]\n end", "def config_dir\n Wonkavision::Sample::CONFIG_DIR\n end", "def configure(root_config)\n super(root_config)\n end", "def inject_into_load_path\n \n # Add ALL paths under the engine root to the load path\n %w(app/controllers \n app/helpers \n app/models\n components\n lib).collect { |dir|\n File.join(root, dir)\n }.select { |dir| File.directory?(dir) }.each do |path|\n insert_into_load_path(path) \n end\n end", "def conf_folder\n conf['conf_folder'] || '.'\n end", "def deploy_to_base_dir\n # stage[:deploy_to] || '/sites' # TODO: verify if server setup supports `:deploy_to` override\n Pvcglue.configuration.web_app_base_dir # TODO: server setup does not yet support `:deploy_to` override, and would have to be refactored at a higher level than stage.\n end", "def get_uplift_config_folder\n path = File.expand_path(@@config_file_path)\n FileUtils.mkdir_p path\n\n return path\n end" ]
[ "0.7167291", "0.6974187", "0.68447685", "0.68133307", "0.66286707", "0.66286707", "0.66286707", "0.66286707", "0.66286707", "0.66286707", "0.66286707", "0.6516731", "0.63902855", "0.63769853", "0.63632095", "0.6300203", "0.6238117", "0.6217147", "0.62078077", "0.6200272", "0.6174953", "0.61502934", "0.61476845", "0.61476845", "0.61476845", "0.61476845", "0.61476845", "0.61476845", "0.61476845", "0.61476845", "0.612365", "0.6084048", "0.6038804", "0.6017303", "0.6017303", "0.6014174", "0.59902775", "0.5963469", "0.5963174", "0.5958655", "0.59139764", "0.5893889", "0.5893011", "0.5883494", "0.5881956", "0.5881515", "0.58626944", "0.58449864", "0.5844454", "0.58330536", "0.5825932", "0.58203673", "0.58202446", "0.5799305", "0.57873225", "0.5787106", "0.57729095", "0.57595503", "0.5726682", "0.5717088", "0.57132494", "0.5710771", "0.5710771", "0.5700552", "0.5699928", "0.56981325", "0.569731", "0.56925994", "0.5671754", "0.56660056", "0.5661623", "0.5655159", "0.5652967", "0.5644664", "0.5644633", "0.56426394", "0.56423753", "0.5641587", "0.56339794", "0.5632573", "0.56241554", "0.5610413", "0.56019753", "0.5591969", "0.5581002", "0.5573111", "0.5571951", "0.5569816", "0.5562436", "0.55609965", "0.5560924", "0.5543751", "0.5535133", "0.5523459", "0.5514767", "0.5512069", "0.55111676", "0.55103856", "0.5479866", "0.54766804" ]
0.6327108
15